Order history
This commit is contained in:
miroman-afk
2022-03-25 00:03:43 +03:00
parent 4ad154c65a
commit 85fd6af04f
10 changed files with 256 additions and 26 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Commands;
use App\Component\Models\ActionTypes;
use App\Component\Models\Dishes;
use App\Component\Models\ShiftOnlineActions;
use App\Component\Models\ShiftOnlineItems;
use App\Component\Models\Staff;
use App\Component\Models\Units;
use App\Component\Models\UnitsList;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETOrderHistory extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getorderhistory';
public function command($input, $output = null) {
if (isset($input['order_id'])) {
$order = ShiftOnlineActions::where('order_code', $input['order_id'])->orderBy('time', 'asc')->get();
foreach ($order as $key => $item) {
$action_type = ActionTypes::where('type_id', $item['type_action'])->first();
$action_name = $action_type['name'];
$staff = Staff::where('code', $item['who'])->first();
$staff_name = $staff['name'];
if ($item['type_action'] == 45 || $item['type_action'] == 39) {
$action_name = $item['value'];
}
if ($item['type_action'] == 46 || $item['type_action'] == 35) {
$action_name = $action_name . ': ' . $item['value'];
}
if ($item['type_action'] == 2) {
$shiftOnlineItem = ShiftOnlineItems::where('order_code', $item['order_code'])->where('dish_code', $item['more'])->first();
$unitsList = UnitsList::where('id', $shiftOnlineItem['units_code'])->first();
$units = Units::where('id', $unitsList['unit_id'])->first();
$unit_name = $units['name'];
$dish = Dishes::where('code', $item['more'])->first();
$action_name = $action_name . ': ' . $dish['name'] . ' в количестве ' . $item['value'] . ' ' . $unit_name;
}
$order_info[] = array('id' => $key, 'action' => $action_name, 'who' => $staff_name, 'time' => $item['time'], 'workgroup' => $item['workgroup'], 'workcode' => $item['workcode']);
}
return [
'status' => 'success',
'actions' => $order_info,
];
} else {
return [
'status' => 'success',
'error_message' => 'Проверьте введенные данные',
];
}
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Database\Component\Seeders;
use App\Component\Models\ActionTypes;
use Illuminate\Database\Seeder;
class Add53ActionType extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run() {
if (ActionTypes::where('type_id', 53)->count() == 0) {
$types = ActionTypes::upsert([
['name' => 'Выход из заказа', 'type_id' => 53],
], ['name'], ['type_id']
);
}
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Database\Component\Seeders;
use App\Component\Models\ActionTypes;
use Illuminate\Database\Seeder;
class Add54ActionType extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run() {
if (ActionTypes::where('type_id', 54)->count() == 0) {
$types = ActionTypes::upsert([
['name' => 'Автоматический выход из заказа', 'type_id' => 54],
], ['name'], ['type_id']
);
}
}
}

9
models/Staff.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class Staff extends Model {
protected $table = 'staffs';
}

9
models/Units.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class Units extends Model {
protected $table = 'units';
}

9
models/UnitsList.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class UnitsList extends Model {
protected $table = 'units_list';
}

View File

@@ -722,6 +722,17 @@
}); });
}; };
$scope.getTotalItems = function (order) {
$('#get-more-total').modal('toggle');
smartRequest.get('dashboard/total/items?order=' + order.number, function (data) {
$scope.order = data;
smartRequest.get('v1/orderhistory?order_id=' + order.number, function (actions) {
$scope.actions = actions;
});
$('#items-total').modal('toggle');
});
};
$scope.getStaffMore = function (staff) { $scope.getStaffMore = function (staff) {
smartRequest.get('dashboard/more/staff?code=' + staff.code, function (data) { smartRequest.get('dashboard/more/staff?code=' + staff.code, function (data) {
$scope.staff = data; $scope.staff = data;

View File

@@ -0,0 +1,55 @@
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-toggle="modal" data-target="#items-total" ng-click="returnModal('total')">
<i class="material-icons md-24">arrow_back</i>
</button>
<h5 class="modal-title" style="padding-bottom: 12px;">Подробнее о заказе № {{ order.title }}</h5>
<div class="row">
<div class="col-xs-6 col-md-3">
<p class="text-muted m-b-0">Открыт</p>
<p class="m-b-0">{{ order.who_open }}</p>
<p class="m-b-0">{{ order.opened }}</p>
</div>
<div class="col-xs-6 col-md-3">
<div ng-if="getClosedDate(order.closed) == NOT_CLOSED">
<p class="text-muted m-b-0">{{NOT_CLOSED}}</p>
</div>
<div ng-if="getClosedDate(order.closed) != NOT_CLOSED">
<p class="text-muted m-b-0">Закрыт</p>
<p class="m-b-0">{{ order.who_close }}</p>
<p class="m-b-0">{{ order.closed }}</p>
</div>
</div>
</div>
</div>
<div class="modal-body p-lg">
<div class="table-responsive">
<table class="table m-a-0">
<thead>
<tr>
<th>Блюдо</th>
<th>Количество</th>
<th class="text-right">Сумма, BYN</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in order.items">
<td>{{ item.name }}</td>
<td>{{ item.count }}</td>
<td class="text-right">{{ item.sale_price | curr }}</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="2"></th>
<th class="text-right">Итого: {{ order.total | curr }} BYN</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>

View File

@@ -24,6 +24,19 @@
</div> </div>
</div> </div>
<div class="modal-body p-lg"> <div class="modal-body p-lg">
<div>
<div class="b-b nav-active-bg">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="" data-toggle="tab" data-target="#tab1" aria-expanded="true">Товары</a>
</li>
<li class="nav-item">
<a class="nav-link" href="" data-toggle="tab" data-target="#tab2" aria-expanded="false">Журнал заказа</a>
</li>
</ul>
</div>
<div class="tab-content p-a m-b-md">
<div class="tab-pane animated fadeIn text-muted active" id="tab1" aria-expanded="true">
<div class="table-responsive"> <div class="table-responsive">
<table class="table m-a-0"> <table class="table m-a-0">
<thead> <thead>
@@ -33,7 +46,6 @@
<th class="text-right">Сумма, BYN</th> <th class="text-right">Сумма, BYN</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="item in order.items"> <tr ng-repeat="item in order.items">
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
@@ -41,7 +53,6 @@
<td class="text-right">{{ item.sale_price | curr }}</td> <td class="text-right">{{ item.sale_price | curr }}</td>
</tr> </tr>
</tbody> </tbody>
<thead> <thead>
<tr> <tr>
<th colspan="2"></th> <th colspan="2"></th>
@@ -51,5 +62,33 @@
</table> </table>
</div> </div>
</div> </div>
<div class="tab-pane animated fadeIn text-muted" id="tab2" aria-expanded="false">
<div class="table-responsive">
<table class="table m-a-0">
<thead>
<tr>
<th>Действие</th>
<th>Персонал</th>
<th>Время</th>
<th>Группа</th>
<th>Место</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="action in actions.actions">
<td>{{ action.action }}</td>
<td>{{ action.who }}</td>
<td>{{ action.time }}</td>
<td>{{ action.workgroup }}</td>
<td>{{ action.workcode }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>

View File

@@ -17,7 +17,7 @@
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="order in moreData.orders" ng-click="getItems('total', order)"> <tr ng-repeat="order in moreData.orders" ng-click="getTotalItems(order)">
<td>{{ order.number }}</td> <td>{{ order.number }}</td>
<td>{{ order.opened }}</td> <td>{{ order.opened }}</td>
<td>{{ getClosedDate(order.closed) }}</td> <td>{{ getClosedDate(order.closed) }}</td>