v.1.7 update
This commit is contained in:
1
Logs/10.06.2021_13.34.39.log
Normal file
1
Logs/10.06.2021_13.34.39.log
Normal file
@@ -0,0 +1 @@
|
||||
{"status":"success","version":"1.6","file":"http:\/\/portal.hrc.by\/uploads\/modules\/v1\/1.6\/build.zip","name":"v1"}
|
||||
1
Logs/10.06.2021_16.12.38.log
Normal file
1
Logs/10.06.2021_16.12.38.log
Normal file
@@ -0,0 +1 @@
|
||||
{"status":"success","version":"1.6","file":"http:\/\/portal.hrc.by\/uploads\/modules\/v1\/1.6\/build.zip","name":"v1"}
|
||||
@@ -4,7 +4,7 @@ namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\Folders;
|
||||
use App\Component\Models\Orders;
|
||||
use App\Component\Models\OrderBot;
|
||||
use App\Component\Models\Settings;
|
||||
use App\Component\Models\Tasks;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
@@ -22,7 +22,7 @@ class Bot extends HRCCommand implements HRCCommandInterface {
|
||||
$ordersinfo = Tasks::where('method', '=', 'orderinfo')->get();
|
||||
$delete_params = ['closed', 'deleted'];
|
||||
foreach ($ordersinfo as $more) {
|
||||
$order = Orders::where('id', '=', $more['more'])->whereIn('status', $delete_params)->get();
|
||||
$order = OrderBot::where('id', '=', $more['more'])->whereIn('status', $delete_params)->get();
|
||||
foreach ($order as $value) {
|
||||
$delete = Tasks::where('method', '=', 'orderinfo')->where('more', '=', $value['id'])->delete();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class ClientFile extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getclientfile';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$terminal = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->where('work_code', '=', 1)->first();
|
||||
$terminal = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->first();
|
||||
$tmp_dirname = __DIR__ . "\\..\\..\\..\\Exchange\\" . $terminal['key'] . "\\tmp\\" . $terminal['key'] . "\\";
|
||||
$dirname = __DIR__ . "\\..\\..\\..\\Exchange\\" . $terminal['key'] . "\\";
|
||||
$code = '';
|
||||
@@ -57,24 +57,25 @@ class ClientFile extends HRCCommand implements HRCCommandInterface {
|
||||
'filedate' => $file,
|
||||
];
|
||||
}
|
||||
$clientsCount = Client::count();
|
||||
$urlThread = $input['th'];
|
||||
$mainThreads = 4;
|
||||
$countPerThread = ceil($clientsCount / $mainThreads);
|
||||
$offset = ($urlThread - 1) * $countPerThread;
|
||||
$clients = Client::with('clientPhone:client_guid,phone')->skip($offset)->take($countPerThread)->get();
|
||||
|
||||
$clientsCount = Client::count();
|
||||
$urlThread = $input['th'];
|
||||
$mainThreads = 4;
|
||||
$countPerThread = ceil($clientsCount / $mainThreads);
|
||||
$offset = ($urlThread - 1) * $countPerThread;
|
||||
$clients = Client::with('clientPhone:client_guid')->skip($offset)->take($countPerThread)->get();
|
||||
|
||||
if (!is_dir($tmp_dirname)) {
|
||||
mkdir($tmp_dirname, 0755, 'w+');
|
||||
}
|
||||
$filename = str_replace(' ', '_', date("d.m.Y H.i.s")) . '_' . $urlThread . '.tmp';
|
||||
$handle = fopen($tmp_dirname . $filename, 'w+');
|
||||
fputs($handle, chr(0xEF) . chr(0xBB) . chr(0xBF)); // BOM
|
||||
$filename = str_replace('_', ' ', $filename);
|
||||
foreach ($clients as $row) {
|
||||
if (($row['clientPhone']->phone !== '') && ($row['clientPhone']->phone !== '+375 ( ) - -')) {
|
||||
$row = array($row['name'], $row['clientPhone']->phone);
|
||||
fputcsv($handle, $row, ';');
|
||||
if (!is_dir($tmp_dirname)) {
|
||||
mkdir($tmp_dirname, 0755, 'w+');
|
||||
}
|
||||
$filename = str_replace(' ', '_', date("d.m.Y H.i.s")) . '_' . $urlThread . '.tmp';
|
||||
$handle = fopen($tmp_dirname . $filename, 'w+');
|
||||
$filename = str_replace('_', ' ', $filename);
|
||||
foreach ($clients as $row) {
|
||||
if (($row['clientPhone']->phone !== '') && ($row['clientPhone']->phone !== '+375 ( ) - -')) {
|
||||
$row = array($row['name'], $row['clientPhone']->phone);
|
||||
fputcsv($handle, $row, ';');
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
@@ -15,9 +15,22 @@ class CreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postcreateclient';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$group = ClientsGroup::where('id', '=', $input['group_id'])->first();
|
||||
if (isset($input['group_id'])) {
|
||||
$group = ClientsGroup::where('id', '=', $input['group_id'])->first();
|
||||
} else {
|
||||
$group['code'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($input['email'])) {
|
||||
$input['email'] = '';
|
||||
}
|
||||
|
||||
if (!isset($input['address'])) {
|
||||
$input['address'] = '';
|
||||
}
|
||||
|
||||
$total = Client::where('name', '=', $input['name'])->count();
|
||||
if ($input['is_special_price'] == 'true') {
|
||||
if (isset($input['is_special_price']) && $input['is_special_price'] == 'true') {
|
||||
$specialPrice = 1;
|
||||
} else {
|
||||
$specialPrice = 0;
|
||||
@@ -51,23 +64,32 @@ class CreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
$clientPhone->phone = $phone;
|
||||
$clientPhone->client_guid = $client->user_code;
|
||||
|
||||
$clientBarcode = new ClientsBarcode;
|
||||
$clientBarcode->code_id = urldecode($input['barcode']);
|
||||
$clientBarcode->name = '';
|
||||
$clientBarcode->client_guid = $client->user_code;
|
||||
$clientBarcode->value = urldecode($input['barcode']);
|
||||
$clientBarcode->block = 0;
|
||||
$clientBarcode->symptom_block = 0;
|
||||
|
||||
$clientBarcode->save();
|
||||
$clientEmail->save();
|
||||
$clientAddress->save();
|
||||
$client->save();
|
||||
$clientPhone->save();
|
||||
if (isset($input['barcode']) && $input['barcode'] > 0) {
|
||||
$client->barcode_type = 1;
|
||||
$clientBarcode = new ClientsBarcode;
|
||||
$clientBarcode->code_id = urldecode($input['barcode']);
|
||||
$clientBarcode->name = '';
|
||||
$clientBarcode->client_guid = $client->user_code;
|
||||
$clientBarcode->value = urldecode($input['barcode']);
|
||||
$clientBarcode->block = 0;
|
||||
$clientBarcode->symptom_block = 0;
|
||||
$client->save();
|
||||
$clientPhone->save();
|
||||
$clientEmail->save();
|
||||
$clientAddress->save();
|
||||
$clientBarcode->save();
|
||||
} else {
|
||||
$client->barcode_type = 0;
|
||||
$client->save();
|
||||
$clientPhone->save();
|
||||
$clientEmail->save();
|
||||
$clientAddress->save();
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Клиент создан',
|
||||
'client' => $client,
|
||||
];
|
||||
}
|
||||
}
|
||||
129
commands/GETOrder.php
Normal file
129
commands/GETOrder.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsAddress;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\OrderItems;
|
||||
use App\Component\Models\Orders;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETOrder extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getorder';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
|
||||
if (isset($input['task'])) {
|
||||
if ($input['task'] == 'single' && isset($input['order_id'])) {
|
||||
$order = Orders::where('id', '=', $input['order_id'])->first();
|
||||
|
||||
if (isset($order->client_id) && $order->client_id !== null && $order->client_id !== '') {
|
||||
$client = Client::where('user_code', '=', $order->client_id)->first();
|
||||
$client = $client->name;
|
||||
$client_phone = ClientsPhone::where('client_guid', '=', $order->client_id)->first();
|
||||
$client_phone = $client_phone->phone;
|
||||
$client_address = ClientsAddress::where('client_guid', '=', $order->client_id)->first();
|
||||
$client_address = $client_address->address;
|
||||
} else {
|
||||
$client = '';
|
||||
$client_phone = '';
|
||||
$client_address = '';
|
||||
}
|
||||
|
||||
$orderItems = OrderItems::where('order_id', '=', $order->id)->whereNull('modifier_id')->get();
|
||||
$modOut = array();
|
||||
if (isset($orderItems)) {
|
||||
foreach ($orderItems as $key => $item) {
|
||||
$itemName = Dishes::where('code', '=', $item->item_id)->first();
|
||||
$itemName = $itemName->name;
|
||||
$itemModifiers = OrderItems::where('order_id', '=', $order->id)->where('parent_id', '=', $item->id)->whereNotNull('modifier_id')->get();
|
||||
if (isset($itemModifiers)) {
|
||||
foreach ($itemModifiers as $key => $itemModifier) {
|
||||
$modifier = Modifier::where('id', '=', $itemModifier->modifier_id)->first();
|
||||
if ($modifier->dish_code == 0 && $modifier->unit_id == 0) {
|
||||
$modOut[] = array('' => , );
|
||||
}
|
||||
}
|
||||
}
|
||||
$output[] = array('id' => $item->id,
|
||||
'num' => $key + 1,
|
||||
'order_id' => $item->order_id,
|
||||
'item_id' => $item->item_id,
|
||||
'item_name' => $itemName,
|
||||
'item_count' => $item->item_count,
|
||||
'item_price' => $item->item_price,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$output = [];
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Заказ №' . $order->id,
|
||||
'order' => $order,
|
||||
'orderItems' => $output,
|
||||
'client_name' => $client,
|
||||
'client_phone' => $client_phone,
|
||||
'client_address' => $client_address,
|
||||
'totalCount' => $order->total_count,
|
||||
'totalPrice' => $order->total_price,
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'list') {
|
||||
$orders = Orders::all();
|
||||
foreach ($orders as $key => $order) {
|
||||
$client = Client::where('user_code', '=', $order->client_id)->first();
|
||||
$client_phone = ClientsPhone::where('client_guid', '=', $order->client_id)->first();
|
||||
$client_address = ClientsAddress::where('client_guid', '=', $order->client_id)->first();
|
||||
if (isset($client)) {
|
||||
$output[] = array('id' => $order->id, 'client_name' => $client->name, 'client_phone' => $client_phone->phone, 'client_address' => $client_address->address, 'total_count' => $order->total_count, 'total_price' => $order->total_price, 'is_send' => $order->is_send);
|
||||
} else {
|
||||
$output[] = array('id' => $order->id, 'client_name' => '', 'client_phone' => '', 'client_address' => '', 'total_count' => $order->total_count, 'total_price' => $order->total_price, 'is_send' => $order->is_send);
|
||||
}
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Список заказов',
|
||||
'orders' => $output,
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'clientsearch' && $input['search']) {
|
||||
$input['search'] = urldecode($input['search']);
|
||||
$phone = '+375 (' . substr($input['search'], 0, 2) . ') ' . substr($input['search'], 2, 3) . '-' . substr($input['search'], 5, 2) . '-' . substr($input['search'], 7, 2);
|
||||
$clients = ClientsPhone::where('phone', '=', $phone)->get();
|
||||
if (isset($clients)) {
|
||||
foreach ($clients as $key => $client) {
|
||||
$client_name = Client::where('user_code', '=', $client->client_guid)->first();
|
||||
$client_name = $client_name->name;
|
||||
$client_address = ClientsAddress::where('client_guid', '=', $client->client_guid)->first();
|
||||
$client_phone = $client->phone;
|
||||
$client_guid = $client->client_guid;
|
||||
$output[] = array('guid' => $client_guid, 'name' => $client_name, 'phone' => $client_phone, 'address' => $client_address->address);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($clients)) {
|
||||
$clients = [];
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Список клиентов',
|
||||
'clients' => $output,
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
20
commands/HelloWorld.php
Normal file
20
commands/HelloWorld.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\User;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class HelloWorld extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'gethello';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$users = User::all();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'users' => $users,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ class Import extends HRCCommand implements HRCCommandInterface {
|
||||
$search_response = curl_exec($search);
|
||||
curl_close($search);
|
||||
$responses = json_decode($search_response, TRUE)['files'];
|
||||
|
||||
foreach ($responses as $key => $response) {
|
||||
if (array_key_exists('filename', $response)) {
|
||||
$fulldate = date_parse_from_format('d-m-Y-H-i-s', $response['filename']);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Orders;
|
||||
use App\Component\Models\OrderBot;
|
||||
use App\Component\Models\Report;
|
||||
use App\Component\Models\Shifts;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
@@ -19,7 +19,7 @@ class OutOrders extends HRCCommand implements HRCCommandInterface {
|
||||
$out = array('id' => $shift['id'], 'opened' => $shift['opened'], 'closed' => $shift['closed']);
|
||||
}
|
||||
}
|
||||
$orders = Orders::select('id', 'order', 'created_at')->where('created_at', '>', $out['opened'])->where('created_at', '<=', $out['closed'])->get();
|
||||
$orders = OrderBot::select('id', 'order', 'created_at')->where('created_at', '>', $out['opened'])->where('created_at', '<=', $out['closed'])->get();
|
||||
$count_items = 0;
|
||||
if (is_array($orders) || is_object($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
@@ -73,7 +73,7 @@ class OutOrders extends HRCCommand implements HRCCommandInterface {
|
||||
$end_t = strtotime($input['end_date']) - 1;
|
||||
$start = date('Y-m-d H:i:s', $start_t);
|
||||
$end = date('Y-m-d H:i:s', $end_t);
|
||||
$orders = Orders::select('id', 'order', 'created_at')->where('created_at', '>', $start)->where('created_at', '<=', $end)->get();
|
||||
$orders = OrderBot::select('id', 'order', 'created_at')->where('created_at', '>', $start)->where('created_at', '<=', $end)->get();
|
||||
$count_items = 0;
|
||||
if (is_array($orders) || is_object($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
|
||||
107
commands/POSTOrder.php
Normal file
107
commands/POSTOrder.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\OrderItems;
|
||||
use App\Component\Models\Orders;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class POSTOrder extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postorder';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
|
||||
if (isset($input['task'])) {
|
||||
if ($input['task'] == 'create') {
|
||||
$order = new Orders;
|
||||
$order->staff_id = 1;
|
||||
$order->is_send = 0;
|
||||
$order->save();
|
||||
$order = Orders::where('id', '=', $order->id)->first();
|
||||
$orderItems = OrderItems::where('order_id', '=', $order->id)->get();
|
||||
if (!isset($orderItems)) {
|
||||
$orderItems = [];
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'order' => $order,
|
||||
'orderItems' => $orderItems,
|
||||
'message' => 'Заказ создан',
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'delete' && isset($input['id'])) {
|
||||
$order = Orders::where('id', '=', $input['id'])->first();
|
||||
if ($order->total_count > 0) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Разрешено удаление только пустых заказов.',
|
||||
];
|
||||
} else {
|
||||
$order->delete();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Заказ удален',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($input['task'] == 'update' && isset($input['order_id'])) {
|
||||
$order = Orders::find($input['order_id']);
|
||||
if (isset($input['item']) && $input['item'] == 'add') {
|
||||
$orderItem = new OrderItems;
|
||||
$orderItem->order_id = $input['order_id'];
|
||||
$orderItem->item_id = $input['item_id'];
|
||||
$orderItem->item_count = $input['item_count'];
|
||||
$item_price = Dishes::where('code', '=', $input['item_id'])->first();
|
||||
$orderItem->item_price = $item_price->cosht;
|
||||
$orderItem->staff_id = 1;
|
||||
$orderItem->save();
|
||||
}
|
||||
if (isset($input['client_id'])) {
|
||||
if ($input['client_id'] !== null) {
|
||||
$order->client_id = $input['client_id'];
|
||||
} else {
|
||||
$order->client_id = null;
|
||||
}
|
||||
|
||||
}
|
||||
if (isset($input['item_count'])) {
|
||||
$order->total_count = $order->total_count + $input['item_count'];
|
||||
$order->total_price = $order->total_price + ($item_price->cosht * $input['item_count']);
|
||||
}
|
||||
|
||||
$order->is_send = 0;
|
||||
$order->save();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Заказ обновлен',
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'complete' && isset($input['id'])) {
|
||||
$order = Orders::find($input['id']);
|
||||
$order->is_send = 1;
|
||||
if (isset($input['client_id'])) {
|
||||
$order->client_id = $input['client_id'];
|
||||
}
|
||||
$order->is_delivery = $input['is_delivery'];
|
||||
$order->is_pickup = $input['is_pickup'];
|
||||
$order->save();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Заказ отправлен',
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
88
commands/POSTOrderItem.php
Normal file
88
commands/POSTOrderItem.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\OrderItems;
|
||||
use App\Component\Models\Orders;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class POSTOrderItem extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postorderitem';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if (isset($input['task']) && isset($input['order_id'])) {
|
||||
if ($input['task'] == 'create' && isset($input['order_id'])) {
|
||||
$order_item = new OrderItems;
|
||||
$order_item->order_id = $input['order_id'];
|
||||
$order_item->item_id = $input['item_id'];
|
||||
$order_item->item_count = $input['item_count'];
|
||||
$order_item->item_price = $input['item_price'];
|
||||
$order_item->staff_id = 1;
|
||||
$order_item->save();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'order' => $order_item,
|
||||
'message' => 'Товар добавлен в заказ №' . $input['order_id'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'delete' && isset($input['id'])) {
|
||||
$order_item = OrderItems::where('order_id', '=', $input['order_id'])->where('id', '=', $input['id'])->first();
|
||||
$order_item->delete();
|
||||
$order = Orders::where('id', '=', $input['order_id'])->first();
|
||||
$orderItems = OrderItems::where('order_id', '=', $input['order_id'])->get();
|
||||
$totalCount = 0;
|
||||
$totalPrice = 0;
|
||||
foreach ($orderItems as $key => $item) {
|
||||
$totalCount = $totalCount + $item->item_count;
|
||||
$totalPrice = $totalPrice + $item->item_count * $item->item_price;
|
||||
}
|
||||
$order->total_count = $totalCount;
|
||||
$order->total_price = $totalPrice;
|
||||
$order->save();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Позиция удалена',
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'update' && isset($input['id']) && isset($input['item_count'])) {
|
||||
$order_item = OrderItems::where('order_id', '=', $input['order_id'])->where('id', '=', $input['id'])->first();
|
||||
if ($input['item_count'] == 0) {
|
||||
$order_item->delete();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Позиция удалена',
|
||||
];
|
||||
} else {
|
||||
$order_item->item_count = $input['item_count'];
|
||||
$order_item->save();
|
||||
|
||||
$order = Orders::where('id', '=', $input['order_id'])->first();
|
||||
$orderItems = OrderItems::where('order_id', '=', $input['order_id'])->get();
|
||||
$totalCount = 0;
|
||||
$totalPrice = 0;
|
||||
foreach ($orderItems as $key => $item) {
|
||||
$totalCount = $totalCount + $item->item_count;
|
||||
$totalPrice = $totalPrice + $item->item_count * $item->item_price;
|
||||
}
|
||||
$order->total_count = $totalCount;
|
||||
$order->total_price = $totalPrice;
|
||||
$order->save();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Заказ обновлен',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hrc-admin/hello-world",
|
||||
"version": "1.2",
|
||||
"version": "1.7",
|
||||
"require": {
|
||||
"horeca/admin-php-module-core": "dev-master"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateOrdersTable extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() {
|
||||
Schema::create('orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('total_count')->nullable();
|
||||
$table->integer('total_price')->nullable();
|
||||
$table->integer('staff_id');
|
||||
$table->string('client_id')->nullable();
|
||||
$table->integer('is_send');
|
||||
$table->integer('is_delivery')->nullable();
|
||||
$table->integer('is_pickup')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() {
|
||||
Schema::dropIfExists('orders');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateOrderItemsTable extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() {
|
||||
Schema::create('order_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('order_id');
|
||||
$table->integer('item_id');
|
||||
$table->integer('modifier_id')->nullable();
|
||||
$table->integer('parent_id')->nullable();
|
||||
$table->integer('item_count');
|
||||
$table->integer('item_price');
|
||||
$table->integer('staff_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() {
|
||||
Schema::dropIfExists('order_items');
|
||||
}
|
||||
}
|
||||
9
models/Modifier.php
Normal file
9
models/Modifier.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Modifier extends Model {
|
||||
protected $table = 'modifiers';
|
||||
}
|
||||
9
models/OrderBot.php
Normal file
9
models/OrderBot.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OrderBot extends Model {
|
||||
protected $table = 'orderbot_storage';
|
||||
}
|
||||
9
models/OrderItems.php
Normal file
9
models/OrderItems.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OrderItems extends Model {
|
||||
protected $table = 'order_items';
|
||||
}
|
||||
@@ -5,5 +5,5 @@ namespace App\Component\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Orders extends Model {
|
||||
protected $table = 'orderbot_storage';
|
||||
protected $table = 'orders';
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
[info]
|
||||
name=V1
|
||||
version=1.2
|
||||
version=1.7
|
||||
[build]
|
||||
version=1.2
|
||||
version=1.7
|
||||
|
||||
407
web/controllers/orders.js
Normal file
407
web/controllers/orders.js
Normal file
@@ -0,0 +1,407 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('OrdersCtrl', OrdersCtrl);
|
||||
|
||||
OrdersCtrl.$inject = ['$scope', 'smartRequest', '$location', 'Notification'];
|
||||
function OrdersCtrl($scope, smartRequest, $location, Notification) {
|
||||
|
||||
|
||||
|
||||
$scope.orders = [];
|
||||
|
||||
$scope.readonlyMode = false;
|
||||
|
||||
$scope.selectedElement = {
|
||||
type: '',
|
||||
value: 0,
|
||||
currentModal: '',
|
||||
param: {},
|
||||
info: '',
|
||||
subtype: ''
|
||||
};
|
||||
|
||||
$scope.defaultCount = 1;
|
||||
$scope.itemDelete = '';
|
||||
$scope.itemDeleteId = '';
|
||||
$scope.inputSearch = '';
|
||||
|
||||
$scope.searchClient = function(text, orderId) {
|
||||
$scope.order_id = orderId;
|
||||
$scope.inputSearch = text;
|
||||
smartRequest.get('v1/order?task=clientsearch&search=' + text, function(data) {
|
||||
$scope.clients = data.clients;
|
||||
if (!data.clients) {
|
||||
$('#edit-client-not-found').modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
console.log($scope.clients);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.clearClient = function() {
|
||||
$scope.client_name = '';
|
||||
$scope.client_phone = '';
|
||||
$scope.client_address = '';
|
||||
};
|
||||
|
||||
$scope.deleteClient = function(orderId) {
|
||||
$scope.client_name = '';
|
||||
$scope.client_phone = '';
|
||||
$scope.client_address = '';
|
||||
$scope.inputSearch = '';
|
||||
$scope.clients = '';
|
||||
smartRequest.post('v1/order', {
|
||||
task: 'update',
|
||||
order_id: orderId,
|
||||
client_id: null
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
$scope.getOrder(orderId);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.createClient = function(orderId) {
|
||||
$scope.searchOrderId = orderId;
|
||||
$('#edit-client-not-found').modal('hide');
|
||||
$('#create-client').modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addClientToOrder = function(orderId, clientGUID) {
|
||||
smartRequest.post('v1/order', {
|
||||
task: 'update',
|
||||
order_id: orderId,
|
||||
client_id: clientGUID
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
$scope.getOrder(orderId);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addClient = function(orderId, name, phone, address) {
|
||||
smartRequest.post('v1/createclient', {
|
||||
name: name,
|
||||
phone: phone,
|
||||
address: address,
|
||||
}, function(data) {
|
||||
$scope.addClientToOrder(orderId, data.client.user_code);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.inOrderIncrement = function(item, count) {
|
||||
item.item_count = parseInt(count);
|
||||
item.item_count++;
|
||||
smartRequest.post('v1/orderitem', {
|
||||
task: 'update',
|
||||
id: item.id,
|
||||
order_id: item.order_id,
|
||||
item_count: item.item_count
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
$scope.getOrder(item.order_id);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.inOrderDecrement = function(item, count) {
|
||||
item.item_count = parseInt(count);
|
||||
item.item_count--;
|
||||
smartRequest.post('v1/orderitem', {
|
||||
task: 'update',
|
||||
id: item.id,
|
||||
order_id: item.order_id,
|
||||
item_count: item.item_count
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
$scope.getOrder(item.order_id);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.increment = function(item, count) {
|
||||
item.realCount = parseInt(count);
|
||||
item.realCount++;
|
||||
};
|
||||
$scope.decrement = function(item, count) {
|
||||
item.realCount = parseInt(count);
|
||||
item.realCount--;
|
||||
};
|
||||
|
||||
$scope.deleteItem = function(item) {
|
||||
$scope.itemDelete = item;
|
||||
console.log($scope.itemDelete);
|
||||
$('#edit-item-confirm-delete').modal('toggle');
|
||||
};
|
||||
$scope.deleteItemConfirm = function(item) {
|
||||
smartRequest.post('v1/orderitem', {
|
||||
task: 'delete',
|
||||
order_id: item.order_id,
|
||||
id: item.id,
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
$scope.getOrder(item.order_id);
|
||||
$scope.itemDelete = '';
|
||||
});
|
||||
$('#edit-item-confirm-delete').modal('hide');
|
||||
};
|
||||
|
||||
$scope.navigationStack = [];
|
||||
|
||||
$scope.update = function() {
|
||||
smartRequest.get('v1/order?task=list', function(data) {
|
||||
$scope.orders = data.orders;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function(orderId) {
|
||||
$('#edit-order-confirm-delete').modal('hide');
|
||||
$('#new-order').modal('hide');
|
||||
|
||||
smartRequest.post('v1/order', {
|
||||
task: 'delete',
|
||||
id: orderId
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.create = function() {
|
||||
$('#new-order').modal('toggle');
|
||||
$scope.client_name = '';
|
||||
$scope.client_phone = '';
|
||||
$scope.client_address = '';
|
||||
$scope.items = [];
|
||||
$scope.totalCount = '';
|
||||
$scope.totalPrice = '';
|
||||
smartRequest.post('v1/order', {
|
||||
task: 'create',
|
||||
is_send: 0
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
$scope.orderId = data.order.id;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/* MENU BLOCK */
|
||||
$scope.selectMenuItemParams = {
|
||||
currentMenu: 0,
|
||||
currentFolder: 0,
|
||||
menus: [],
|
||||
folders: [],
|
||||
items: []
|
||||
};
|
||||
|
||||
$scope.selectedMenuElement = {};
|
||||
$scope.selectMenuNavigationStack = [];
|
||||
|
||||
$scope.enterCount = function(orderId, itemId) {
|
||||
$('#edit-selectmenuitem').modal('hide');
|
||||
$('#edit-item-count').modal('toggle');
|
||||
$scope.itemId = itemId;
|
||||
};
|
||||
|
||||
$scope.getOrder = function(orderId, newOrder) {
|
||||
smartRequest.get('v1/order?task=single&order_id=' + orderId, function (data) {
|
||||
$scope.items = data.orderItems;
|
||||
$scope.totalCount = data.totalCount;
|
||||
$scope.totalPrice = data.totalPrice;
|
||||
$scope.client_name = data.client_name;
|
||||
$scope.client_address = data.client_address;
|
||||
$scope.client_phone = data.client_phone;
|
||||
if (newOrder == true) {
|
||||
$('#new-order').modal('toggle');
|
||||
$scope.orderId = orderId;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addItem = function(orderId, itemId, itemCount) {
|
||||
smartRequest.post('v1/order', {
|
||||
task: 'update',
|
||||
item: 'add',
|
||||
order_id: orderId,
|
||||
item_id: itemId,
|
||||
item_count: itemCount
|
||||
}, function(data) {
|
||||
Notification.success('Товар добавлен');
|
||||
$('#edit-selectmenuitem').modal('toggle');
|
||||
$scope.getOrder(orderId);
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.selectMenuItem = function(orderId) {
|
||||
$scope.selectMenuItemParams = {
|
||||
currentMenu: 0,
|
||||
currentFolder: 0,
|
||||
menus: [],
|
||||
folders: [],
|
||||
items: []
|
||||
};
|
||||
smartRequest.get('menu/list', function (data) {
|
||||
$scope.selectMenuItemParams.menus = data.menus;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openMenuItem = function(menu) {
|
||||
$scope.selectMenuItemParams.currentMenu = menu.id;
|
||||
|
||||
$scope.selectMenuNavigationStack.push({
|
||||
type: 'menu',
|
||||
value: menu
|
||||
});
|
||||
|
||||
smartRequest.get('menu/folder/list?menu_id=' + $scope.selectMenuItemParams.currentMenu + '&parent_id=0', function (data) {
|
||||
$scope.selectMenuItemParams.folders = data.folders;
|
||||
});
|
||||
|
||||
smartRequest.get('menu/dish/list?menu_id=' + $scope.selectMenuItemParams.currentMenu + '&parent_id=0', function (data) {
|
||||
$scope.selectMenuItemParams.items = data.dishes;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openFolderItem = function(folder) {
|
||||
$scope.selectMenuItemParams.currentFolder = folder.id;
|
||||
|
||||
$scope.selectMenuNavigationStack.push({
|
||||
type: 'folder',
|
||||
value: folder
|
||||
});
|
||||
|
||||
smartRequest.get('menu/folder/list?menu_id=' + $scope.selectMenuItemParams.currentMenu + '&parent_id=' + $scope.selectMenuItemParams.currentFolder, function (data) {
|
||||
$scope.selectMenuItemParams.folders = data.folders;
|
||||
});
|
||||
|
||||
smartRequest.get('menu/dish/list?menu_id=' + $scope.selectMenuItemParams.currentMenu + '&parent_id=' + $scope.selectMenuItemParams.currentFolder, function (data) {
|
||||
$scope.selectMenuItemParams.items = data.dishes;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.upMenuItem = function() {
|
||||
if($scope.selectMenuNavigationStack.length > 1) {
|
||||
$scope.selectMenuNavigationStack.pop();
|
||||
var page = $scope.selectMenuNavigationStack.pop();
|
||||
|
||||
if(page.type === 'menu') {
|
||||
$scope.openMenuItem(page.value);
|
||||
}
|
||||
|
||||
if(page.type === 'folder') {
|
||||
$scope.openFolderItem(page.value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$scope.selectMenuItem();
|
||||
}
|
||||
};
|
||||
/* END MENU BLOCK */
|
||||
|
||||
/* CLIENT BLOCK */
|
||||
$scope.selectClientItemParams = {
|
||||
clients: [],
|
||||
groups: [],
|
||||
isParent: true
|
||||
};
|
||||
|
||||
$scope.selectClientItem = function() {
|
||||
$scope.selectClientItemParams = {
|
||||
clients: [],
|
||||
groups: [],
|
||||
isParent: true
|
||||
};
|
||||
$scope.currentPage = 1;
|
||||
$scope.pages = 1;
|
||||
smartRequest.get('v1/clientgroup', function(data) {
|
||||
$scope.selectClientItemParams.groups = data.groups;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openGroup = function(group) {
|
||||
$scope.selectClientItemParams.isParent = false;
|
||||
$scope.currentGroup = group.id;
|
||||
$scope.currentPage = 1;
|
||||
$scope.selectClientItemParams.groups = [];
|
||||
$scope.selectClientItemParams.clients = [];
|
||||
|
||||
smartRequest.get('v1/clients?group_id=' + $scope.currentGroup + '&page=' + $scope.currentPage, function(data) {
|
||||
$scope.selectClientItemParams.clients = data.clients;
|
||||
$scope.pages = data.pages;
|
||||
$scope.currentGroup = data.currentGroup;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.pager = function(currentPage) {
|
||||
$scope.selectClientItemParams.isParent = false;
|
||||
$scope.selectClientItemParams.groups = [];
|
||||
$scope.selectClientItemParams.clients = [];
|
||||
smartRequest.get('v1/clients?group_id=' + $scope.currentGroup + '&page=' + $scope.currentPage, function(data) {
|
||||
$scope.selectClientItemParams.clients = data.clients;
|
||||
$scope.pages = data.pages;
|
||||
$scope.currentGroup = data.currentGroup;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.upGroup = function() {
|
||||
$scope.selectClientItemParams = {
|
||||
clients: [],
|
||||
groups: [],
|
||||
isParent: true
|
||||
};
|
||||
|
||||
smartRequest.get('v1/clientgroup', function(data) {
|
||||
$scope.selectClientItemParams.groups = data.groups;
|
||||
});
|
||||
};
|
||||
/* END CLIENT BLOCK */
|
||||
|
||||
$scope.selectItem = function(value, type, info) {
|
||||
$scope.selectedElement.value = value;
|
||||
$scope.selectedElement.type = type;
|
||||
$scope.selectedElement.info = info;
|
||||
};
|
||||
|
||||
$scope.editTermParam = function(param) {
|
||||
$scope.$eval(param.type[0].toLowerCase() + param.type.slice(1) + '()');
|
||||
|
||||
$scope.selectedElement = {
|
||||
type: param.type,
|
||||
value: param.value,
|
||||
currentModal: '#edit-' + param.type.toLowerCase(),
|
||||
param: param,
|
||||
info: param.info,
|
||||
subtype: param.subtype
|
||||
};
|
||||
|
||||
$($scope.selectedElement.currentModal).modal();
|
||||
};
|
||||
|
||||
$scope.confirmSelect = function() {
|
||||
$($scope.selectedElement.currentModal).modal('toggle');
|
||||
|
||||
$scope.selectedElement.param.value = $scope.selectedElement.value;
|
||||
$scope.selectedElement.param.info = $scope.selectedElement.info;
|
||||
$scope.selectedElement.param.subtype = $scope.selectedElement.type;
|
||||
};
|
||||
|
||||
$scope.update();
|
||||
|
||||
smartRequest.get('discount/type/list', function(data) {
|
||||
$scope.terms = data.discount_types;
|
||||
$scope.defaultTerm = data.default.code;
|
||||
});
|
||||
|
||||
smartRequest.get('menu/readonly', function (data) {
|
||||
$scope.readonlyMode = data.readonly;
|
||||
|
||||
if (data.readonly) {
|
||||
Notification.error('Режим просмотра!');
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
31
web/views/orders/createnewclient.html
Normal file
31
web/views/orders/createnewclient.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Создание нового клиента</h5>
|
||||
</div>
|
||||
<div class="modal-body text-center p-lg">
|
||||
<form role="form" class="ng-pristine ng-valid container">
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="Имя" ng-model="client_name" class="form-control"></input>
|
||||
<p>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<input ng-model="inputSearch" class="form-control" ui-mask="+375 (99) 999-99-99"></input>
|
||||
<p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="col-sm-12">
|
||||
<input placeholder="Адрес" ng-model="client_address" class="form-control"></input>
|
||||
<p>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal" ng-click="clearClient()">Отмена</button>
|
||||
<button type="button" class="btn success p-x-md" ng-model="orderId" ng-click="addClient(orderId, client_name, inputSearch, client_address)" data-dismiss="modal">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
110
web/views/orders/edit.html
Normal file
110
web/views/orders/edit.html
Normal file
@@ -0,0 +1,110 @@
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" ng-model="orderId">Заказ №{{orderId}}</h5>
|
||||
</div>
|
||||
<div class="modal-body text-center p-lg">
|
||||
<form role="form" class="ng-pristine ng-valid container">
|
||||
<div class="form-group row">
|
||||
<label>Клиент</label>
|
||||
</div>
|
||||
|
||||
<div ng-if="!client_name" class="form-group row">
|
||||
<div class="col-sm-12">
|
||||
<input ng-model="inputSearch" ng-keyup="(inputSearch.length >= 9) && searchClient(inputSearch)" class="form-control" ui-mask="+375 (99) 999-99-99">
|
||||
<div ng-if="clients" class="list-group">
|
||||
<div ng-repeat="client in clients">
|
||||
<button type="button" class="list-group-item list-group-item-action" ng-click="addClientToOrder(orderId, client.guid)">
|
||||
Имя: {{client.name}}<br>
|
||||
Адрес: {{client.address}}<br>
|
||||
Телефон: {{client.phone}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="client_name && client_address" class="form-group row">
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="Имя" ng-model="client_name" class="form-control" value="client_name" disabled></input>
|
||||
<p>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<input ng-model="client_phone" class="form-control" ui-mask="+375 (99) 999-99-99" disabled></input>
|
||||
<p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="col-sm-12">
|
||||
<input placeholder="Адрес" ng-model="client_address" class="form-control" disabled></input>
|
||||
<p>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal" ng-click="deleteClient(orderId)">Отменить</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group row">
|
||||
<label>Заказ</label>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<button type="button" class="btn danger p-x-md pull-right" data-toggle="modal" data-target="#edit-selectmenuitem" ng-click="selectMenuItem(orderId)">Добавить товары в заказ</button>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="padding">
|
||||
<div class="box">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered m-a-0 table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Наименование</th>
|
||||
<th style="width: 120px; text-align: center">Количество</th>
|
||||
<th style="width: 80px; text-align: center">Цена</th>
|
||||
<th style="width: 80px; text-align: center">Итого</th>
|
||||
<th style="width: 20px; text-align: center">#</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="item in items" ng-click="">
|
||||
<td>{{ item.num }}</td>
|
||||
<td>{{ item.item_name }}</td>
|
||||
<td>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-secondary btn-sm" ng-click="inOrderDecrement(item, item.item_count)" ng-disabled="item.item_count<=1">-</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm" ng-model="item.item_count" disabled>{{item.item_count}}</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm" ng-click="inOrderIncrement(item, item.item_count)">+</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ item.item_price }} BYN</td>
|
||||
<td>{{ item.item_price * item.item_count }} BYN</td>
|
||||
<td>
|
||||
<button type="button" class="btn danger btn-sm" ng-model="item" ng-click="deleteItem(item)">
|
||||
<i class="material-icons"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div ng-if="totalCount" class="col">Количество товаров: {{totalCount}}</div>
|
||||
<div ng-if="totalPrice" class="col">Итоговая сумма заказа: {{totalPrice}} BYN</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn danger p-x-md pull-left" data-toggle="modal" data-target="#edit-order-confirm-delete">
|
||||
<i class="material-icons"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" class="btn success p-x-md" data-dismiss="modal" ng-click="save()">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript" src="/libs/js/moment/locale/ru.js"></script>
|
||||
96
web/views/orders/orders.html
Normal file
96
web/views/orders/orders.html
Normal file
@@ -0,0 +1,96 @@
|
||||
<div id="container-floating">
|
||||
<div class="nd3 nds" data-toggle="tooltip" data-placement="left" title="Добавить" ng-click="create()" ng-if="!readonlyMode" style="background-color: #3c80f6" onmouseenter="$(this).tooltip('show')">
|
||||
<i class="material-icons"></i>
|
||||
</div>
|
||||
|
||||
<div class="nd1 nds" data-toggle="tooltip" data-placement="left" title="Обновить" ng-click="update()" style="background-color: #d3a411" onmouseenter="$(this).tooltip('show')">
|
||||
<i class="material-icons"></i>
|
||||
</div>
|
||||
|
||||
<div id="floating-button" data-toggle="tooltip" data-placement="left" title="Действия" onmouseenter="$(this).tooltip('show')">
|
||||
<p class="plus"><i class="material-icons"></i></p>
|
||||
<p class="edit"><i class="material-icons"></i></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="padding">
|
||||
<div class="box">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered m-a-0 table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 10px; text-align: center">#</th>
|
||||
<th style="width: 120px; text-align: center">Имя</th>
|
||||
<th style="width: 120px; text-align: center">Телефон</th>
|
||||
<th style="width: 120px; text-align: center">Адрес</th>
|
||||
<th style="width: 40px; text-align: center">Товаров</th>
|
||||
<th style="width: 40px; text-align: center">Сумма</th>
|
||||
<th style="width: 60px; text-align: center">Статус заказа</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="order in orders" ng-click="getOrder(order.id, true)">
|
||||
<td style="text-align: center">{{ order.id }}</td>
|
||||
<td style="text-align: center">{{ order.client_name }}</td>
|
||||
<td style="text-align: center">{{ order.client_phone }}</td>
|
||||
<td style="text-align: center">{{ order.client_address }}</td>
|
||||
<td style="text-align: center">{{ order.total_count }}</td>
|
||||
<td style="text-align: center">{{ order.total_price }} <span ng-if="order.total_price > 0">BYN</span></td>
|
||||
<td style="text-align: center">{{ order.is_send }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="new-order" data-backdrop="true" ng-if="!readonlyMode">
|
||||
<div ui-include="'../views/orders/edit.html'"></div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="create-client" data-backdrop="true" style="z-index: 1052">
|
||||
<div ui-include="'../views/orders/createnewclient.html'"></div>
|
||||
</div>
|
||||
|
||||
<div id="edit-order-confirm-delete" class="modal confirm-box" data-backdrop="true" style="z-index: 1052">
|
||||
<div class="bottom white b-b" style="height: 90px">
|
||||
<div class="confirm-box-body p-lg">
|
||||
<p>Вы действительно хотите удалить заказ?</p>
|
||||
</div>
|
||||
|
||||
<div class="confirm-box-footer">
|
||||
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Нет</button>
|
||||
<button type="button" class="btn danger p-x-md" ng-click="delete(orderId)">Да</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-item-confirm-delete" class="modal confirm-box" data-backdrop="true" style="z-index: 1052">
|
||||
<div class="bottom white b-b" style="height: 90px">
|
||||
<div class="confirm-box-body p-lg">
|
||||
<p>Вы действительно хотите удалить позицию?</p>
|
||||
</div>
|
||||
|
||||
<div class="confirm-box-footer">
|
||||
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Нет</button>
|
||||
<button type="button" class="btn danger p-x-md" ng-model="itemDelete" ng-click="deleteItemConfirm(itemDelete)">Да</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-client-not-found" class="modal confirm-box" data-backdrop="true" style="z-index: 1052">
|
||||
<div class="bottom white b-b" style="height: 90px">
|
||||
<div class="confirm-box-body p-lg">
|
||||
<p>Клиент не найден. Создать?</p>
|
||||
</div>
|
||||
|
||||
<div class="confirm-box-footer">
|
||||
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Нет</button>
|
||||
<button type="button" class="btn danger p-x-md" ng-model="order_id" ng-click="createClient(order_id)">Да</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="edit-selectmenuitem" data-backdrop="true" style="z-index: 1052">
|
||||
<div ui-include="'../views/orders/selectmenuitem.html'"></div>
|
||||
</div>
|
||||
65
web/views/orders/selectclientitem.html
Normal file
65
web/views/orders/selectclientitem.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<div class="modal-dialog modal-list">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Выбор клиента</h5>
|
||||
</div>
|
||||
|
||||
<div class="modal-body p-lg">
|
||||
<div ng-if="selectClientItemParams.isParent == false">
|
||||
<div class="list-item pointer no_selection" ios-dblclick="upGroup()">
|
||||
<div class="list-left">
|
||||
<span class="w-30">
|
||||
<i class="material-icons" style="font-size: 30px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-body" style="line-height: 30px">...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list inset" ng-repeat="group in selectClientItemParams.groups">
|
||||
<div class="list-item pointer no_selection" sglclick="selectItem(group.id, 'client_group', group.name)"
|
||||
ios-dblclick="openGroup(group)"
|
||||
ng-class="group.id == selectedElement.value && selectedElement.type == 'client_group' ? 'active' : ''">
|
||||
<div class="list-left">
|
||||
<span class="w-30">
|
||||
<i class="material-icons" style="font-size: 30px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-body" style="line-height: 30px">
|
||||
{{ group.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list inset" ng-repeat="client in selectClientItemParams.clients">
|
||||
<div class="list-item pointer no_selection" ng-click="selectItem(client.id, 'client', client.name)"
|
||||
ng-class="client.id == selectedElement.value && selectedElement.type == 'client' ? 'active' : ''">
|
||||
<div class="list-left">
|
||||
<span class="w-30">
|
||||
<i class="material-icons" style="font-size: 30px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-body" style="line-height: 30px">
|
||||
{{ client.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-a text-center">
|
||||
<div class="btn-group" role="group">
|
||||
<a class="btn btn-md btn-outline rounded b-info text-info" ng-class="{disabled:currentPage === 1}" ng-click="pager(currentPage=currentPage-1)"><</a>
|
||||
<a class="btn btn-md btn-outline rounded b-info text-info" ng-class="{disabled:currentPage}">{{currentPage}}/{{pages}}</a>
|
||||
<a class="btn btn-md btn-outline rounded b-info text-info" ng-class="{disabled:currentPage === pages}" ng-click="pager(currentPage=currentPage+1)">></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Отмена</button>
|
||||
<button type="button" class="btn success p-x-md" ng-disabled="selectedElement.value == 0"
|
||||
ng-click="confirmSelect()">Выбрать
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
20
web/views/orders/selectitemcount.html
Normal file
20
web/views/orders/selectitemcount.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Укажите количество</h5>
|
||||
</div>
|
||||
<div class="modal-body text-center p-lg">
|
||||
<form role="form" class="ng-pristine ng-valid container">
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-6">
|
||||
<input class="form-control" placeholder="Количество" type="text" ng-model="item.count">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn success p-x-md" ng-model="itemId" ng-click="addItem(orderId, itemId, item.count)" data-dismiss="modal">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
104
web/views/orders/selectmenuitem.html
Normal file
104
web/views/orders/selectmenuitem.html
Normal file
@@ -0,0 +1,104 @@
|
||||
<div class="modal-dialog modal-list">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Выбор элемента меню</h5>
|
||||
</div>
|
||||
|
||||
<div class="modal-body p-lg">
|
||||
<div ng-if="selectMenuItemParams.currentMenu > 0">
|
||||
<div class="list-item pointer no_selection" ios-dblclick="upMenuItem()">
|
||||
<div class="list-left">
|
||||
<span class="w-30">
|
||||
<i class="material-icons" style="font-size: 30px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-body" style="line-height: 30px">...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="selectMenuItemParams.currentMenu == 0">
|
||||
<div class="list inset" ng-repeat="menu in selectMenuItemParams.menus">
|
||||
<div class="list-item pointer no_selection" ios-dblclick="openMenuItem(menu)"
|
||||
sglclick="selectItem(menu.id, 'menu', menu.name)"
|
||||
ng-class="menu.id == selectedElement.value && selectedElement.type == 'menu' ? 'active' : ''">
|
||||
<div class="list-left">
|
||||
<span class="w-30">
|
||||
<i class="material-icons" style="font-size: 30px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-body" style="line-height: 30px">
|
||||
{{ menu.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="selectMenuItemParams.currentMenu > 0">
|
||||
<div class="list inset" ng-repeat="folder in selectMenuItemParams.folders">
|
||||
<div class="list-item pointer no_selection" ios-dblclick="openFolderItem(folder)"
|
||||
sglclick="selectItem(folder.id, 'folder', folder.name)"
|
||||
ng-class="folder.id == selectedElement.value && selectedElement.type == 'folder' ? 'active' : ''">
|
||||
<div class="list-left">
|
||||
<span class="w-30">
|
||||
<i class="material-icons" style="font-size: 30px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-body" style="line-height: 30px">
|
||||
{{ folder.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="selectMenuItemParams.currentMenu > 0">
|
||||
<div class="list inset" ng-repeat="item in selectMenuItemParams.items">
|
||||
<li class="list-item pointer no_selection" ng-click="selectItem(item.id, 'item', item.name)"
|
||||
>
|
||||
<div class="list-left">
|
||||
<span class="w-30">
|
||||
<i class="material-icons" style="font-size: 30px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-body">
|
||||
<div class="container">
|
||||
<div class="row justify-content-around">
|
||||
<div class="col-6 col-sm-3">
|
||||
{{ item.name }} <span class="text-muted">#{{ item.code }}</span>
|
||||
<small class="block text-muted">{{ item.cosht | curr }} BYN</small>
|
||||
</div>
|
||||
<div ng-if="item.realCount" class="col-6 col-sm-4">
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-secondary" ng-click="decrement(item, item.realCount)" ng-disabled="realCount<=0">-</button>
|
||||
<button type="button" class="btn btn-secondary" ng-model="item.realCount" disabled>{{item.realCount}}</button>
|
||||
<button type="button" class="btn btn-secondary" ng-click="increment(item, item.realCount)">+</button>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if="!item.realCount" class="col-6 col-sm-4">
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-secondary" ng-click="decrement(item, defaultCount)" ng-disabled="defaultCount<=0">-</button>
|
||||
<button type="button" class="btn btn-secondary" ng-model="defaultCount" disabled>{{defaultCount}}</button>
|
||||
<button type="button" class="btn btn-secondary" ng-click="increment(item, defaultCount)">+</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-sm-3">
|
||||
<button ng-if="!item.realCount" type="button" class="btn btn btn-success p-x-md" ng-model="orderId" ng-click="addItem(orderId, item.code, defaultCount)">+</button>
|
||||
<button ng-if="item.realCount" type="button" class="btn btn btn-success p-x-md" ng-model="orderId" ng-click="addItem(orderId, item.code, item.realCount)">+</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user