diff --git a/commands/GETClientInfo.php b/commands/GETClientInfo.php index 468fe27..921c3a1 100644 --- a/commands/GETClientInfo.php +++ b/commands/GETClientInfo.php @@ -38,7 +38,7 @@ class GETClientInfo extends HRCCommand implements HRCCommandInterface 'email' => $email, 'address' => $address, 'order_count' => $orders_count, - 'order_sum' => $orders_sum, + 'order_sum' => round($orders_sum, 2), 'presale' => $presale, 'bonus' => intval($bonus), ) diff --git a/commands/GETClientOrders.php b/commands/GETClientOrders.php index ad57d3d..399e9ca 100644 --- a/commands/GETClientOrders.php +++ b/commands/GETClientOrders.php @@ -17,29 +17,21 @@ class GETClientOrders extends HRCCommand implements HRCCommandInterface if (isset($input['id'])) { $client = Client::where('id', $input['id'])->first(); $client_guid = $client['user_code']; - $exchange_orders = ExchangeOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->orderByDesc('closed')->get(); - $online_orders = ShiftOnlineOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->orderByDesc('closed')->get(); - $orders = []; - foreach ($online_orders as $online_order) { - $orders[] = array( - 'id' => $online_order['code'], - 'opened' => $online_order['opened'], - 'closed' => $online_order['closed'], - 'sum' => $online_order['order_sum'], - 'discount' => $online_order['sale_sum'], - 'shift_id' => 0 - ); - } - foreach ($exchange_orders as $exchange_order) { - $orders[] = array( - 'id' => $exchange_order['code'], - 'opened' => $exchange_order['opened'], - 'closed' => $exchange_order['closed'], - 'sum' => $exchange_order['order_sum'], - 'discount' => $exchange_order['sale_sum'], - 'shift_id' => $exchange_order['shift_id'] - ); - } + $exchange_orders = ExchangeOrders::select('code', 'opened', 'closed', 'order_sum', 'sale_sum') + ->where('client_code', $client_guid) + ->where('is_returned', 0) + ->where('is_deleted', 0) + ->orderByDesc('closed') + ->get() + ->toArray(); + $online_orders = ShiftOnlineOrders::select('code', 'opened', 'closed', 'order_sum', 'sale_sum') + ->where('client_code', $client_guid) + ->where('is_returned', 0) + ->where('is_deleted', 0) + ->orderByDesc('closed') + ->get() + ->toArray(); + $orders = array_merge($online_orders, $exchange_orders); return [ 'status' => 'success', 'orders' => $orders, diff --git a/commands/GETDataReport.php b/commands/GETDataReport.php index 1948093..8d933fc 100644 --- a/commands/GETDataReport.php +++ b/commands/GETDataReport.php @@ -5,6 +5,7 @@ namespace App\Commands; use App\Component\Models\Dishes; use App\Component\Models\ExchangeActions; use App\Component\Models\ExchangeDeleted; +use App\Component\Models\ExchangeItems; use App\Component\Models\ExchangeOrders; use App\Component\Models\ExchangeShifts; use App\Component\Models\Reasons; @@ -739,6 +740,36 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface 'deleted' => $deleted ]; } + if ($input['type'] == 'abc') { + if (isset($input['start_date']) && isset($input['end_date'])) { + $end_date = date('Y-m-d H:i:s', strtotime($input['end_date'])); + $start_date = date('Y-m-d H:i:s', strtotime($input['start_date'])); + $orders_shifts = ExchangeOrders::where('opened', '>=', $start_date) + ->where('closed', '=<', $end_date) + ->where('is_deleted', 0) + ->where('is_returned', 0) + ->where('is_closed', 1) + ->groupBy('shift_id') + ->get(); + $orders = ExchangeOrders::where('opened', '>=', $start_date) + ->where('closed', '=<', $end_date) + ->where('is_deleted', 0) + ->where('is_returned', 0) + ->where('is_closed', 1) + ->get(); + $revenue = 0; + foreach ($orders_shifts as $orders_shift) { + $shift_revenue = ExchangeShifts::where('shift_id', $orders_shift['shift_id']) + ->first(); + $revenue += $shift_revenue['revenue']; + } + foreach ($orders as $order) { + $order_items = ExchangeItems::where('order_code', $order['code']) + ->where('shift_id', $order['shift_id']) + ->get(); + } + } + } } else { return [ 'status' => 'success', diff --git a/commands/POSTBonus.php b/commands/POSTBonus.php index 7b3b102..8857bf4 100644 --- a/commands/POSTBonus.php +++ b/commands/POSTBonus.php @@ -14,15 +14,16 @@ class POSTBonus extends HRCCommand implements HRCCommandInterface public function command($input, $output = null) { $client_guid = $input['client_id']; - $bonus_amount = $input['amount']; + $bonus_amount = abs($input['amount']); $staff_id = $input['who']; $bonus_time = $input['date_transaction']; - ClientsBonus::bonusReg($client_guid, $bonus_amount); + $type = $input['type']; + ClientsBonus::bonusReg($client_guid, $bonus_amount, $type); ClientsBonus::bonusLog($client_guid, $bonus_amount, $bonus_time, $staff_id); - if ($bonus_amount > 0) { + if ($type == 'in') { $message = 'Начислено ' . $bonus_amount . ' бонусов'; - } else { - $message = 'Списано ' . abs($bonus_amount) . ' бонусов'; + } elseif ($type == 'out') { + $message = 'Списано ' . $bonus_amount . ' бонусов'; } $bonus_result = ClientsBonus::getBonus($client_guid); return [ diff --git a/commands/POSTPresale.php b/commands/POSTPresale.php index 4ee1c4c..b59f37a 100644 --- a/commands/POSTPresale.php +++ b/commands/POSTPresale.php @@ -13,15 +13,16 @@ class POSTPresale extends HRCCommand implements HRCCommandInterface public function command($input, $output = null) { $client_guid = $input['client_id']; - $presale_amount = $input['amount']; + $presale_amount = abs($input['amount']); $staff_id = $input['who']; $presale_time = $input['date_transaction']; - ClientsPresale::presaleReg($client_guid, $presale_amount); + $type = $input['type']; + ClientsPresale::presaleReg($client_guid, $presale_amount, $type); ClientsPresale::presaleLog($client_guid, $presale_amount, $presale_time, $staff_id); - if ($presale_amount > 0) { + if ($type == 'in') { $message = 'Внесен аванс на сумму ' . $presale_amount . ' BYN'; - } else { - $message = 'Зачтен аванс на сумму ' . abs($presale_amount) . ' BYN'; + } elseif ($type == 'out') { + $message = 'Зачтен аванс на сумму ' . $presale_amount . ' BYN'; } $presale_result = ClientsPresale::getPresale($client_guid); return [ diff --git a/composer.json b/composer.json index 4b1b572..37fce98 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "hrc-admin/hello-world", - "version": "2.24", + "version": "2.25", "require": { "horeca/admin-php-module-core": "dev-master", "guzzlehttp/guzzle": "^7.4", diff --git a/forUpdate/toDirectives/angular-drag-resize.js b/forUpdate/toDirectives/angular-drag-resize.js index 5775d01..38b59d4 100644 --- a/forUpdate/toDirectives/angular-drag-resize.js +++ b/forUpdate/toDirectives/angular-drag-resize.js @@ -4,7 +4,7 @@ .provider('adrConfig', function adrConfigProvider() { //defaults var defaultConfig = { - iconPosition: [0, 0], + iconPosition: [-1, 10], mode: 'all', modes: ['all', 'horizontal', 'vertical'] }; @@ -28,15 +28,18 @@ var doc = {}; var el = {}; //create button for resizing - var btn = document.createElement("span"); - btn.style.width = '15px'; - btn.style.height = '15px'; - btn.innerHTML = - "" - ; - btn.style.bottom = iconPosition[0] + 6 + 'px'; - btn.style.right = iconPosition[1] + 5 + 'px'; - btn.style.position = 'absolute'; + //var btn = document.createElement("span"); + var btn = document.createElement("i"); + btn.classList.add('fa'); + btn.classList.add('fa-expand'); + btn.classList.add('fa-rotate-90'); + btn.style.border = '25px solid transparent'; + +/* btn.innerHTML = + "" + ;*/ + + btn.style.position = 'fixed'; btn.style.visibility = 'hidden'; if (mode == 'horizontal') { btn.style.cursor = 'ew-resize'; @@ -50,22 +53,21 @@ switch ($event.which) { case 1: $event.stopImmediatePropagation(); +/* console.log(element.offsetParent().prevObject[0].parentNode.parentNode.getBoundingClientRect().bottom); + console.log(element[0].parentNode); + console.log(element[0].parentNode.parentNode); + console.log(element[0].parentNode.parentNode.parentNode);*/ doc.left = element[0].parentNode.parentNode.getBoundingClientRect().left; doc.top = element[0].parentNode.parentNode.getBoundingClientRect().top; doc.bottom = element[0].parentNode.parentNode.getBoundingClientRect().bottom; doc.right = element[0].parentNode.parentNode.getBoundingClientRect().right; el.width = element[0].getBoundingClientRect().width; el.height = element[0].getBoundingClientRect().height; - console.log('doc.left: ' + doc.left); - console.log('doc.top: ' + doc.top); - console.log('doc.bottom: ' + doc.bottom); - console.log('doc.right: ' + doc.right); position.x = $event.clientX; position.y = $event.clientY; dimension.width = element.prop('offsetWidth'); dimension.height = element.prop('offsetHeight'); - console.log('dimension.width: ' + dimension.width); - console.log('dimension.height: ' + dimension.height); + btn.style.visibility = 'hidden'; $document.bind('mousemove', mousemove); $document.bind('mouseup', mouseup); return false; @@ -77,18 +79,24 @@ switch ($event.which) { case 1: - - if ($event.clientX < doc.right && $event.clientY < doc.bottom) { + if ($event.clientX < doc.right) { var deltaWidth = dimension.width - (position.x - $event.clientX); - var deltaHeight = dimension.height - (position.y - $event.clientY); - } else { - var deltaWidth = el.width; - var deltaHeight = el.height; + if (deltaWidth < 100) { + deltaWidth = 100; + } + } + if ($event.clientY < doc.bottom) { + var deltaHeight = dimension.height - (position.y - $event.clientY); + if (deltaHeight < 100) { + deltaHeight = 100; + } + } + if ($event.clientX > doc.right) { + deltaWidth = element[0].getBoundingClientRect().width; + } + if ($event.clientY > doc.bottom ) { + deltaHeight = element[0].getBoundingClientRect().height; } -/* console.log('deltaWidth: ' + deltaWidth); - console.log('deltaHeight: ' + deltaHeight); - console.log('position.x: ' + position.x); - console.log('position.y: ' + position.y);*/ var newDimensions = {}; if (mode == 'horizontal') { newDimensions = { @@ -105,6 +113,9 @@ }; } element.css(newDimensions); + element[0].children[0].style.setProperty('width', deltaWidth + 'px'); + element[0].children[0].style.setProperty('height', deltaHeight + 'px'); + //console.log(element[0].children[0]); return false; break; } @@ -113,14 +124,20 @@ function mouseup() { $document.unbind('mousemove', mousemove); $document.unbind('mouseup', mouseup); + btn.style.visibility = 'hidden'; } element.append(btn); + //show button on hover element.bind('mouseover', function () { + /*console.log(element[0].children[1].children[0]);*/ + btn.style.top = element[0].getBoundingClientRect().top + element[0].getBoundingClientRect().height - 50 + 'px'; + btn.style.left = element[0].getBoundingClientRect().left + element[0].getBoundingClientRect().width - 50 + 'px'; btn.style.visibility = 'visible'; }); element.bind('mouseout', function () { + /* console.log(element);*/ btn.style.visibility = 'hidden'; }); } @@ -160,17 +177,34 @@ var posdy = position.y + dy; var posdx = position.x + dx; - if (posdy > doc.top && posdx > doc.left && (posdx + element[0].getBoundingClientRect().width) < doc.right && (posdy + element[0].getBoundingClientRect().height) < doc.bottom) { - element.css({ - top: posdy + 'px', - left: posdx + 'px' - }); - } else { - element.css({ - top: position.y + 'px', - left: position.x + 'px' - }); + if (posdy > doc.top) { + var top = posdy; } + if (posdx > doc.left){ + var left = posdx; + } + if ((posdx + element[0].getBoundingClientRect().width) < doc.right) { + left = posdx; + } + if ((posdy + element[0].getBoundingClientRect().height) < doc.bottom){ + top = posdy; + } + if (posdy < doc.top) { + top = doc.top; + } + if (posdx < doc.left) { + left = doc.left; + } + if ((posdx + element[0].getBoundingClientRect().width) > doc.right) { + left = doc.right - element[0].getBoundingClientRect().width; + } + if ((posdy + element[0].getBoundingClientRect().height) > doc.bottom) { + top = doc.bottom - element[0].getBoundingClientRect().height; + } + element.css({ + top: top + 'px', + left: left + 'px' + }); return false; break; diff --git a/models/ClientsBonus.php b/models/ClientsBonus.php index ae1881e..126d1ca 100644 --- a/models/ClientsBonus.php +++ b/models/ClientsBonus.php @@ -27,15 +27,20 @@ class ClientsBonus extends Model /** * Save bonus value. */ - public static function bonusReg($guid, $value) + public static function bonusReg($guid, $value, $type) { $bonus_value = ClientsBonus::where('client_guid', $guid)->first(); - $bonus = ClientsBonus::updateOrCreate( - ['client_guid' => $guid], - ['value' => $bonus_value['value'] + $value] - ); - - return $bonus['value']; + if ($type == 'in') { + ClientsBonus::updateOrCreate( + ['client_guid' => $guid], + ['value' => $bonus_value['value'] + $value] + ); + } elseif ($type == 'out') { + ClientsBonus::updateOrCreate( + ['client_guid' => $guid], + ['value' => $bonus_value['value'] - $value] + ); + } } /** diff --git a/models/ClientsPresale.php b/models/ClientsPresale.php index 3be97fe..61e51c3 100644 --- a/models/ClientsPresale.php +++ b/models/ClientsPresale.php @@ -27,15 +27,20 @@ class ClientsPresale extends Model /** * Save presale value. */ - public static function presaleReg($guid, $value) + public static function presaleReg($guid, $value, $type) { $presale_value = ClientsPresale::where('client_guid', $guid)->first(); - $presale = ClientsPresale::updateOrCreate( - ['client_guid' => $guid], - ['value' => $presale_value['value'] + $value] - ); - - return $presale['value']; + if ($type == 'in') { + ClientsPresale::updateOrCreate( + ['client_guid' => $guid], + ['value' => $presale_value['value'] + $value] + ); + } elseif ($type == 'out') { + ClientsPresale::updateOrCreate( + ['client_guid' => $guid], + ['value' => $presale_value['value'] - $value] + ); + } } /** diff --git a/models/ExchangeOrders.php b/models/ExchangeOrders.php index 4ecd58b..2b0d1fc 100644 --- a/models/ExchangeOrders.php +++ b/models/ExchangeOrders.php @@ -18,7 +18,7 @@ class ExchangeOrders extends Model $close_time = $order['closed']; $who_open = Staff::getName($order['who_open']); $who_close = Staff::getName($order['who_close']); - $items = ExchangeItems::where('order_code', $order_id)->where('shift_id', $shift_id)->get(); + $items = ExchangeItems::where('order_code', $order_id)->where('dishes_code', '<>', 0)->where('shift_id', $shift_id)->get(); $order_status = ''; if ($order['is_deleted'] > 0) { $order_status = 'Удален'; @@ -47,7 +47,7 @@ class ExchangeOrders extends Model } $order_info[] = array( 'id' => $key + 1, - 'name' => Dishes::getName($item['dish_code']), + 'name' => Dishes::getName($item['menu_code']), 'count' => $item['count'], 'price' => $item['real_price'], 'sale_price' => $item['sale_price'], diff --git a/models/ShiftOnlineOrders.php b/models/ShiftOnlineOrders.php index 88bdef2..f8e11e0 100644 --- a/models/ShiftOnlineOrders.php +++ b/models/ShiftOnlineOrders.php @@ -17,8 +17,13 @@ class ShiftOnlineOrders extends Model $open_time = $order['opened']; $close_time = $order['closed']; $who_open = Staff::getName($order['who_open']); - $who_close = Staff::getName($order['who_close']); - $items = ShiftOnlineItems::where('order_code', $order_id)->get(); + if ($order['who_close'] == 0) { + $who_close = ''; + } else { + $who_close = Staff::getName($order['who_close']); + } + + $items = ShiftOnlineItems::where('order_code', $order_id)->where('modificator_code', 0)->get(); $order_status = ''; if ($order['is_deleted'] > 0) { $order_status = 'Удален'; @@ -54,7 +59,7 @@ class ShiftOnlineOrders extends Model 'cof' => $item['cof'], 'unit' => Units::getName($item['units_id']), 'amount' => round($item['sale_price'] * $item['count'], 2), - 'discount' => round($discount, 2) + 'discount' => round($discount, 0) ); $amount += round($item['sale_price'] * $item['count'], 2); $full_price += round($realPrice,2); diff --git a/module.ini b/module.ini index a0039a5..964be3b 100644 --- a/module.ini +++ b/module.ini @@ -1,5 +1,5 @@ [info] name=V1 -version=2.24 +version=2.25 [build] -version=2.24 +version=2.25 diff --git a/web/views/clients/index.html b/web/views/clients/index.html index 1b70919..287971a 100644 --- a/web/views/clients/index.html +++ b/web/views/clients/index.html @@ -123,7 +123,7 @@
Сумма заказа: {{order.sum | curr}} BYN (Скидка: {{order.discount | curr}} BYN)
+Сумма заказа: {{order.order_sum | curr}} BYN (Скидка: {{order.sale_sum | curr}} BYN)