Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60570934bb | ||
|
|
1113b6a3ea | ||
|
|
7325d8946a | ||
|
|
a290eb3a80 | ||
|
|
c013425587 | ||
|
|
c9463b0dbb | ||
|
|
98306a646d |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.idea/
|
||||
temp/
|
||||
vendor/
|
||||
vendor/
|
||||
build.zip
|
||||
|
||||
34
commands/Bot.php
Normal file
34
commands/Bot.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\Folders;
|
||||
use App\Component\Models\Orders;
|
||||
use App\Component\Models\Settings;
|
||||
use App\Component\Models\Tasks;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Bot extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getbot';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$settings = Settings::where('code', '=', 5)->where('value', '=', 1)->get();
|
||||
if (isset($settings['0']['value'])) {
|
||||
$dishes = Dishes::where('is_bot_export', '=', 0)->update(['is_bot_export' => 1]);
|
||||
$folders = Folders::where('is_bot_export', '=', 0)->update(['is_bot_export' => 1]);
|
||||
}
|
||||
$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();
|
||||
foreach ($order as $value) {
|
||||
$delete = Tasks::where('method', '=', 'orderinfo')->where('more', '=', $value['id'])->delete();
|
||||
}
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
];
|
||||
}
|
||||
}
|
||||
74
commands/ClientFile.php
Normal file
74
commands/ClientFile.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
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();
|
||||
$tmp_dirname = __DIR__ . "\\..\\..\\..\\Exchange\\" . $terminal['key'] . "\\tmp\\" . $terminal['key'] . "\\";
|
||||
$dirname = __DIR__ . "\\..\\..\\..\\Exchange\\" . $terminal['key'] . "\\";
|
||||
$filename = str_replace(' ', '_', date("d.m.Y H.i.s")) . '.csv';
|
||||
$code = '';
|
||||
|
||||
if (isset($input['complete'])) {
|
||||
foreach (glob($tmp_dirname . "*.tmp") as $tmp_filename) {
|
||||
$code .= file_get_contents($tmp_filename);
|
||||
file_put_contents($dirname . $filename, $code);
|
||||
unlink($tmp_filename);
|
||||
}
|
||||
|
||||
$baseCSV = file($dirname . $filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
|
||||
foreach ($baseCSV as $itemBaseCSV) {
|
||||
$arrLineCsv = explode(";", $itemBaseCSV);
|
||||
$arrUniqFinish[mb_convert_encoding($arrLineCsv[0], 'CP1251') . ";" . $arrLineCsv[1]] = $arrLineCsv[1];
|
||||
}
|
||||
$arrUniqFinish = array_unique($arrUniqFinish);
|
||||
|
||||
foreach ($arrUniqFinish as $keyArr => $valueArr) {
|
||||
$finishSavedCsv[] = $keyArr;
|
||||
}
|
||||
file_put_contents($dirname . $filename, implode("\n", $finishSavedCsv));
|
||||
return [
|
||||
'status' => 'success',
|
||||
'filename' => $filename,
|
||||
'terminalKey' => $terminal['key'],
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
$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();
|
||||
|
||||
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);
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'filename' => $filename,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
28
commands/ClientGroup.php
Normal file
28
commands/ClientGroup.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETClientGroup extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getclientgroup';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if (ClientsGroup::where('code', '0')->count() == 0) {
|
||||
$group = new ClientsGroup;
|
||||
$group->code = '0';
|
||||
$group->name = 'Без группы';
|
||||
$group->save();
|
||||
}
|
||||
$client_groups = ClientsGroup::orderBy('code')->get();
|
||||
foreach ($client_groups as $client_group) {
|
||||
$out[] = array('id' => $client_group['id'], 'name' => $client_group['name']);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'groups' => $out,
|
||||
];
|
||||
}
|
||||
}
|
||||
71
commands/Clients.php
Normal file
71
commands/Clients.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsAddress;
|
||||
use App\Component\Models\ClientsBarcode;
|
||||
use App\Component\Models\ClientsEmail;
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Clients extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getclients';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if (ClientsGroup::where('code', '0')->count() == 0) {
|
||||
$group = new ClientsGroup([
|
||||
'code' => '0',
|
||||
'name' => 'Без группы',
|
||||
]);
|
||||
$group->save();
|
||||
}
|
||||
$countPerPage = 25;
|
||||
$offset = ($input['page'] - 1) * $countPerPage;
|
||||
if ($input['group_id'] == 0) {
|
||||
$group = ClientsGroup::where('code', '=', $input['group_id'])->first();
|
||||
} else {
|
||||
$group = ClientsGroup::where('id', '=', $input['group_id'])->first();
|
||||
}
|
||||
$clients = Client::where('group_id', '=', $group['code'])->skip($offset)->take($countPerPage)->get();
|
||||
$total = Client::where('group_id', '=', $group['code'])->count();
|
||||
if ($total == NULL) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => array(),
|
||||
'total' => 0,
|
||||
'size' => $countPerPage,
|
||||
'pages' => 1,
|
||||
'currentGroup' => $group['id'],
|
||||
];
|
||||
} else {
|
||||
|
||||
foreach ($clients as $client) {
|
||||
$phone = ClientsPhone::where('client_guid', '=', $client['user_code'])->first();
|
||||
$email = ClientsEmail::where('client_guid', '=', $client['user_code'])->first();
|
||||
$address = ClientsAddress::where('client_guid', '=', $client['user_code'])->first();
|
||||
$barcode = ClientsBarcode::where('client_guid', '=', $client['user_code'])->first();
|
||||
$group = ClientsGroup::where('code', '=', $client['group_id'])->first();
|
||||
$out[] = array(
|
||||
'id' => $client['id'],
|
||||
'client_group' => $group['id'],
|
||||
'name' => $client['name'],
|
||||
'phone' => $phone['phone'],
|
||||
'email' => $email['email'],
|
||||
'address' => $address['address'],
|
||||
'barcode' => $barcode['code_id'],
|
||||
);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => $out,
|
||||
'total' => $total,
|
||||
'size' => $countPerPage,
|
||||
'pages' => ceil($total / $countPerPage),
|
||||
'currentGroup' => $group['id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
54
commands/CreateBarcode.php
Normal file
54
commands/CreateBarcode.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsBarcode;
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class CreateBarcode extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postcreatebarcode';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$group = ClientsGroup::where('id', '=', $input['group_id'])->first();
|
||||
if (($input['start'] <= $input['end']) && (srtlen($input['start']) == srtlen($input['end']))) {
|
||||
for ($i = $input['start']; $i <= $input['end']; $i++) {
|
||||
$total = Client::where('name', '=', $i)->count();
|
||||
$client = new Client;
|
||||
if ($total >= 1) {
|
||||
$total = $total + 1;
|
||||
$client->name = '#' . $total . ' ' . urldecode($i);
|
||||
} else {
|
||||
$client->name = urldecode($i);
|
||||
}
|
||||
$client->user_code = strtoupper(md5(time() + $i));
|
||||
$client->group_id = $group['code'];
|
||||
$client->is_special_price = 0;
|
||||
$client->barcode_type = 1;
|
||||
|
||||
$barcode = new ClientsBarcode;
|
||||
$barcode->code_id = $i;
|
||||
$barcode->name = '';
|
||||
$barcode->client_guid = $client->user_code;
|
||||
$barcode->value = $i;
|
||||
$barcode->block = 0;
|
||||
$barcode->symptom_block = 0;
|
||||
|
||||
$barcode->save();
|
||||
$client->save();
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Штрих коды созданы',
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'message' => 'Проверьте правильность введенных данных',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
85
commands/CreateClient.php
Normal file
85
commands/CreateClient.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsAddress;
|
||||
use App\Component\Models\ClientsBarcode;
|
||||
use App\Component\Models\ClientsEmail;
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class CreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postcreateclient';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$group = ClientsGroup::where('id', '=', $input['group_id'])->first();
|
||||
$total = Client::where('name', '=', $input['name'])->count();
|
||||
if ($input['is_special_price'] == 'true') {
|
||||
$specialPrice = 1;
|
||||
} else {
|
||||
$specialPrice = 0;
|
||||
}
|
||||
$client = new Client;
|
||||
if ($total >= 1) {
|
||||
$total = $total + 1;
|
||||
$client->name = '#' . $total . ' ' . urldecode($input['name']);
|
||||
} else {
|
||||
$client->name = urldecode($input['name']);
|
||||
}
|
||||
$client->user_code = strtoupper(md5(time()));
|
||||
$client->group_id = $group['code'];
|
||||
$client->is_special_price = $specialPrice;
|
||||
$client->barcode_start = 0;
|
||||
$client->barcode_end = 0;
|
||||
$client->contractor = '';
|
||||
$client->last_change = date("Ymd");
|
||||
|
||||
$clientEmail = new ClientsEmail;
|
||||
$clientEmail->email = urldecode($input['email']);
|
||||
$clientEmail->client_guid = $client->user_code;
|
||||
|
||||
$clientAddress = new ClientsAddress;
|
||||
$clientAddress->address = urldecode($input['address']);
|
||||
$clientAddress->client_guid = $client->user_code;
|
||||
|
||||
$clientPhone = new ClientsPhone;
|
||||
if ($input['phone'] !== '') {
|
||||
$phoneData = urldecode($input['phone']);
|
||||
$phone = '+375 (' . substr($phoneData, 0, 2) . ') ' . substr($phoneData, 2, 3) . '-' . substr($phoneData, 5, 2) . '-' . substr($phoneData, 7, 2);
|
||||
} else {
|
||||
$phone = '';
|
||||
}
|
||||
$clientPhone->phone = $phone;
|
||||
$clientPhone->client_guid = $client->user_code;
|
||||
|
||||
if ($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' => 'Клиент создан',
|
||||
];
|
||||
}
|
||||
}
|
||||
35
commands/Equipment.php
Normal file
35
commands/Equipment.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Printer;
|
||||
use App\Component\Models\PrinterSettings;
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Equipment extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getequipment';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$terminals = Terminal::select('work_code', 'work_group')
|
||||
->where('key', '=', $input['terminal'])
|
||||
->get();
|
||||
foreach ($terminals as $terminal) {
|
||||
$terminal_data = array('work_code' => $terminal['work_code'], 'work_group' => $terminal['work_group']);
|
||||
}
|
||||
$printer_groups = Printer::select('code', 'name')
|
||||
->where('is_history', '=', 0)
|
||||
->get();
|
||||
$printers = PrinterSettings::select('name', 'id', 'ip', 'com_port', 'type', 'speed', 'printer_group', 'template', 'size', 'driver', 'codepage', 'more')
|
||||
->where('workgroup', '=', $terminal_data['work_group'])
|
||||
->where('workcode', '=', $terminal_data['work_code'])
|
||||
->get();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'terminal_data' => $terminal_data,
|
||||
'printer_groups' => $printer_groups,
|
||||
'printers' => $printers,
|
||||
];
|
||||
}
|
||||
}
|
||||
22
commands/Fiscals.php
Normal file
22
commands/Fiscals.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Fiscals extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postfiscals';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$terminals = Terminal::select('work_code', 'work_group')->where('key', '=', $input['terminal'])->get();
|
||||
foreach ($terminals as $terminal) {
|
||||
$out = array('work_code' => $terminal['work_code'], 'work_group' => $terminal['work_group']);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'terminal_data' => $out,
|
||||
];
|
||||
}
|
||||
}
|
||||
28
commands/GETClientGroup.php
Normal file
28
commands/GETClientGroup.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETClientGroup extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getclientgroup';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if (ClientsGroup::where('code', '0')->count() == 0) {
|
||||
$group = new ClientsGroup;
|
||||
$group->code = '0';
|
||||
$group->name = 'Без группы';
|
||||
$group->save();
|
||||
}
|
||||
$client_groups = ClientsGroup::orderBy('code')->get();
|
||||
foreach ($client_groups as $client_group) {
|
||||
$out[] = array('id' => $client_group['id'], 'name' => $client_group['name']);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'groups' => $out,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use App\Models\User;
|
||||
|
||||
class HelloWorld extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'gethello';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$users = User::all();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'users' => $users
|
||||
];
|
||||
}
|
||||
}
|
||||
87
commands/Import.php
Normal file
87
commands/Import.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Import extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getimport';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$HRCPortalURL = 'https://portal.hrc.by/';
|
||||
$folder = 'backup';
|
||||
$terminals = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->where('work_code', '=', 1)->get();
|
||||
$end_date = date('m/d/Y H:i:s', strtotime($input['end_date']) + 86399);
|
||||
$start_date = date('m/d/Y H:i:s', strtotime($input['start_date']));
|
||||
foreach ($terminals as $terminal) {
|
||||
$url = $HRCPortalURL . 'api/cloud/list?api=2.0&project_code=hrc&code=' . $terminal['key'] . '&folder=' . $folder;
|
||||
$search = curl_init();
|
||||
|
||||
curl_setopt_array($search, array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
));
|
||||
$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']);
|
||||
$fulldate = mktime($fulldate['hour'], $fulldate['minute'], $fulldate['second'], $fulldate['month'], $fulldate['day'], $fulldate['year']);
|
||||
if ($fulldate >= strtotime($start_date) && $fulldate <= strtotime($end_date)) {
|
||||
$out[] = date('d-m-Y-H-i-s', $fulldate);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($out)) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'shifts not found',
|
||||
];
|
||||
} else {
|
||||
foreach ($out as $filename) {
|
||||
$path = '/backup/' . $filename . '.xml';
|
||||
$download_url = $HRCPortalURL . 'api/cloud/download?api=2.0&project_code=hrc&code=' . $terminal['key'] . '&path=' . $path;
|
||||
$download = curl_init();
|
||||
|
||||
curl_setopt_array($download, array(
|
||||
CURLOPT_URL => $download_url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
));
|
||||
$download_response = curl_exec($download);
|
||||
curl_close($download);
|
||||
$file = json_decode($download_response, TRUE)['content'];
|
||||
$params = array('code' => $terminal['key'], 'name' => $filename . '.xml', 'folder' => 'exchange', 'content' => $file, 'project_code' => 'hrc', 'api' => '2.0');
|
||||
$upload = curl_init();
|
||||
curl_setopt_array($upload, array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => true,
|
||||
CURLOPT_URL => $HRCPortalURL . 'api/cloud/upload',
|
||||
CURLOPT_SSL_VERIFYHOST => 0,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $params,
|
||||
));
|
||||
$upload_response = curl_exec($upload);
|
||||
curl_close($upload);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'start_date' => strtotime($start_date),
|
||||
'end_date' => strtotime($end_date),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
138
commands/OutOrders.php
Normal file
138
commands/OutOrders.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Orders;
|
||||
use App\Component\Models\Report;
|
||||
use App\Component\Models\Shifts;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class OutOrders extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getoutorders';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if ((array_key_exists('shift_id', $input)) === true) {
|
||||
$shifts = Shifts::select('id', 'opened', 'closed')->where('id', '=', $input['shift_id'])->get();
|
||||
if (is_array($shifts) || is_object($shifts)) {
|
||||
foreach ($shifts as $shift) {
|
||||
$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();
|
||||
$count_items = 0;
|
||||
if (is_array($orders) || is_object($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
$order_id = $order['id'];
|
||||
$price = json_decode(base64_decode($order['order']), true)['price'];
|
||||
$items = json_decode(base64_decode($order['order']), true)['items'];
|
||||
$date = strtotime($order['created_at']);
|
||||
$newformat = date('Y-m-d H:i:s', $date);
|
||||
foreach ($items as $key => $item) {
|
||||
$out_item[$key] = array(
|
||||
'id' => $item['id'], 'name' => $item['name'], 'count' => $item['count'], 'price' => $item['price'],
|
||||
'full_price' => $item['full_price'],
|
||||
);
|
||||
$count_items += 1;
|
||||
}
|
||||
$remoteOrder[] = array(
|
||||
'id' => $order_id,
|
||||
'items_count' => $count_items,
|
||||
'items' => $out_item,
|
||||
'date' => $newformat,
|
||||
'price' => $price,
|
||||
);
|
||||
unset($out_item);
|
||||
$count_items = 0;
|
||||
}
|
||||
}
|
||||
if (isset($remoteOrder)) {
|
||||
$total_count = 0;
|
||||
$total_price = 0;
|
||||
foreach ($orders as $order) {
|
||||
$total_count += 1;
|
||||
$total_price += json_decode(base64_decode($order['order']), true)['price'];
|
||||
}
|
||||
$total = array('total_count' => $total_count, 'total_price' => $total_price);
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'true',
|
||||
'shift' => $out,
|
||||
'orders' => $remoteOrder,
|
||||
'total' => $total,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'false',
|
||||
];
|
||||
}
|
||||
}
|
||||
if ((array_key_exists('start_date', $input)) === true) {
|
||||
$start_t = strtotime($input['start_date']) + 1;
|
||||
$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();
|
||||
$count_items = 0;
|
||||
if (is_array($orders) || is_object($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
$order_id = $order['id'];
|
||||
$price = json_decode(base64_decode($order['order']), true)['price'];
|
||||
$items = json_decode(base64_decode($order['order']), true)['items'];
|
||||
$date = strtotime($order['created_at']);
|
||||
$newformat = date('Y-m-d H:i:s', $date);
|
||||
foreach ($items as $key => $item) {
|
||||
$out_item[$key] = array(
|
||||
'id' => $item['id'],
|
||||
'name' => $item['name'],
|
||||
'count' => $item['count'],
|
||||
'price' => $item['price'],
|
||||
'full_price' => $item['full_price'],
|
||||
);
|
||||
$count_items += 1;
|
||||
}
|
||||
$remoteOrder[] = array(
|
||||
'id' => $order_id,
|
||||
'items_count' => $count_items,
|
||||
'items' => $out_item,
|
||||
'date' => $newformat,
|
||||
'price' => $price,
|
||||
);
|
||||
unset($out_item);
|
||||
$count_items = 0;
|
||||
}
|
||||
}
|
||||
if (isset($remoteOrder)) {
|
||||
$total_count = 0;
|
||||
$total_price = 0;
|
||||
if (is_array($orders) || is_object($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
$total_count += 1;
|
||||
$total_price += json_decode(base64_decode($order['order']), true)['price'];
|
||||
}
|
||||
}
|
||||
$total = array('total_count' => $total_count, 'total_price' => $total_price);
|
||||
$report = new Report;
|
||||
$report->user_id = $input['admin_user_id'];
|
||||
$report->name = 'Отчет по внешним заказам';
|
||||
$report->shift_id = 0;
|
||||
$report->start_date = $start;
|
||||
$report->end_date = $end;
|
||||
$report->report_type = 'out';
|
||||
$report->save();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'true',
|
||||
'orders' => $remoteOrder,
|
||||
'total' => $total,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'false',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
89
commands/POSTClient.php
Normal file
89
commands/POSTClient.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsAddress;
|
||||
use App\Component\Models\ClientsBarcode;
|
||||
use App\Component\Models\ClientsEmail;
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class POSTClient extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postclient';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
|
||||
if (isset($input['task']) && isset($input['id'])) {
|
||||
if ($input['task'] == 'update') {
|
||||
$client = Client::find($input['id']);
|
||||
$client->name = urldecode($input['name']);
|
||||
$client->unloaded = 0;
|
||||
|
||||
$clientGroup = ClientsGroup::where('id', $input['group_id'])->first();
|
||||
$client->group_id = urldecode($clientGroup->code);
|
||||
|
||||
$clientPhone = ClientsPhone::where('client_guid', $client->user_code)->first();
|
||||
if ($input['phone'] !== '') {
|
||||
if (substr($input['phone'], 0, 1) == '+') {
|
||||
$phoneData = urldecode($input['phone']);
|
||||
} else {
|
||||
$phoneData = urldecode($input['phone']);
|
||||
$clientPhone->phone = '+375 (' . substr($phoneData, 0, 2) . ') ' . substr($phoneData, 2, 3) . '-' . substr($phoneData, 5, 2) . '-' . substr($phoneData, 7, 2);
|
||||
}
|
||||
} else {
|
||||
$clientPhone->phone = '';
|
||||
}
|
||||
|
||||
$clientEmail = ClientsEmail::where('client_guid', $client->user_code)->first();
|
||||
$clientEmail->email = urldecode($input['email']);
|
||||
|
||||
$clientAddress = ClientsAddress::where('client_guid', $client->user_code)->first();
|
||||
$clientAddress->address = urldecode($input['address']);
|
||||
|
||||
$clientBarcode = ClientsBarcode::where('client_guid', $client->user_code)->first();
|
||||
$clientBarcode->code_id = urldecode($input['barcode']);
|
||||
|
||||
$client->save();
|
||||
$clientGroup->save();
|
||||
$clientPhone->save();
|
||||
$clientEmail->save();
|
||||
$clientAddress->save();
|
||||
$clientBarcode->save();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'client' => $client,
|
||||
'phone' => $clientPhone,
|
||||
'email' => $clientEmail,
|
||||
'address' => $clientAddress,
|
||||
'barcode' => $clientBarcode,
|
||||
'message' => 'Клиент обновлен',
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'delete') {
|
||||
$client = Client::where('id', '=', $input['id'])->first();
|
||||
$clientPhone = ClientsPhone::where('client_guid', $client->user_code)->first();
|
||||
$clientEmail = ClientsEmail::where('client_guid', $client->user_code)->first();
|
||||
$clientAddress = ClientsAddress::where('client_guid', $client->user_code)->first();
|
||||
$clientBarcode = ClientsBarcode::where('client_guid', $client->user_code)->first();
|
||||
$clientPhone->delete();
|
||||
$clientEmail->delete();
|
||||
$clientAddress->delete();
|
||||
$clientBarcode->delete();
|
||||
$client->delete();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Клиент удален',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
58
commands/POSTClientGroup.php
Normal file
58
commands/POSTClientGroup.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class POSTClientGroup extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postclientgroup';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
|
||||
if (isset($input['task']) && isset($input['id'])) {
|
||||
if ($input['task'] == 'update') {
|
||||
$group = ClientsGroup::find($input['id']);
|
||||
$group->name = $input['name'];
|
||||
$group->save();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'group' => $group,
|
||||
'message' => 'Группа обновлена',
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'delete') {
|
||||
$group = ClientsGroup::where('id', '=', $input['id'])->first();
|
||||
if ($group->code == '0') {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Запрещено удаление группы по умолчанию',
|
||||
];
|
||||
} else {
|
||||
$client_count = Client::where('group_id', '=', $group->code)->count();
|
||||
if ($client_count !== 0) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Разрешено удаление только пустых групп.',
|
||||
];
|
||||
} else {
|
||||
$group->delete();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Группа удалена',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
71
commands/Printers.php
Normal file
71
commands/Printers.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Printer;
|
||||
use App\Component\Models\PrinterSettings;
|
||||
use App\Component\Models\Tasks;
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Printers extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postprinters';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$terminals = Terminal::select('id', 'work_code', 'work_group')->where('key', '=', $input['terminal'])->get();
|
||||
foreach ($terminals as $terminal) {
|
||||
$terminal_data = array('id' => $terminal['id'], 'work_code' => $terminal['work_code'], 'work_group' => $terminal['work_group']);
|
||||
}
|
||||
$first_printer_data = PrinterSettings::where('id', '=', $input['id'])->get();
|
||||
foreach ($first_printer_data as $old_printer_data) {
|
||||
}
|
||||
$printer_name = Printer::where('code', '=', $input['group'])->get();
|
||||
foreach ($printer_name as $group_name) {
|
||||
}
|
||||
if ($input['group'] == 0) {
|
||||
$group_name['name'] = $input['name'];
|
||||
}
|
||||
if ($input['type'] == 'COM') {
|
||||
$task[] = "UPDATE main.printers SET `name`='" . urldecode($group_name['name']) . "', `IP`=NULL, `port`=NULL, `COMport`='" . $input['com_port'] . "', `type`='" . $input['type'] . "', `size`=" . $input['size'] . ", `speed`=" . $input['speed'] . ", `driver`=NULL, `workcode`=" . $terminal_data['work_code'] . ", `workgroup`=" . $terminal_data['work_group'] . ",`printer_group`=" . $input['group'] . ", `template`='" . $input['template'] . "', `more`='" . urldecode($input['more']) . "' WHERE `name`='" . $old_printer_data['name'] . "' AND `workcode`=" . $terminal_data['work_code'] . " AND `workgroup`=" . $terminal_data['work_group'] . ";";
|
||||
$task = base64_encode(json_encode(array('queries' => $task), TRUE));
|
||||
$add_task = new Tasks;
|
||||
$add_task->terminal_id = $terminal_data['id'];
|
||||
$add_task->next_at = date("Y-m-d H:i:s");
|
||||
$add_task->method = 'runquery';
|
||||
$add_task->period = 0;
|
||||
$add_task->is_cycle = 0;
|
||||
$add_task->more = $task;
|
||||
$add_task->save();
|
||||
}
|
||||
if ($input['type'] == 'LAN') {
|
||||
$task[] = "UPDATE main.printers SET `name`='" . urldecode($group_name['name']) . "', `IP`='" . $input['ip_address'] . "', `port`=9100, `COMport`=NULL, `type`='" . $input['type'] . "', `size`=" . $input['size'] . ", `speed`=NULL, `driver`=NULL, `workcode`=" . $terminal_data['work_code'] . ", `workgroup`=" . $terminal_data['work_group'] . ",`printer_group`=" . $input['group'] . ", `template`='" . $input['template'] . "', `more`='" . urldecode($input['more']) . "' WHERE `name`='" . $old_printer_data['name'] . "' AND `workcode`=" . $terminal_data['work_code'] . " AND `workgroup`=" . $terminal_data['work_group'] . ";";
|
||||
$task = base64_encode(json_encode(array('queries' => $task)));
|
||||
$add_task = new Tasks;
|
||||
$add_task->terminal_id = $terminal_data['id'];
|
||||
$add_task->next_at = date("Y-m-d H:i:s");
|
||||
$add_task->method = 'runquery';
|
||||
$add_task->period = 0;
|
||||
$add_task->is_cycle = 0;
|
||||
$add_task->more = $task;
|
||||
$add_task->save();
|
||||
}
|
||||
if ($input['type'] == 'Windows') {
|
||||
$task[] = "UPDATE main.printers SET `name`='" . urldecode($group_name['name']) . "', `IP`=NULL, `port`=NULL, `COMport`=NULL, `type`='" . $input['type'] . "', `size`=" . $input['size'] . ", `speed`=NULL, `driver`='" . urldecode($input['driver']) . "', `workcode`=" . $terminal_data['work_code'] . ", `workgroup`=" . $terminal_data['work_group'] . ",`printer_group`=" . $input['group'] . ", `template`='" . $input['template'] . "', `more`='" . urldecode($input['more']) . "' WHERE `name`='" . $old_printer_data['name'] . "' AND `workcode`=" . $terminal_data['work_code'] . " AND `workgroup`=" . $terminal_data['work_group'] . ";";
|
||||
$task = base64_encode(json_encode(array('queries' => $task)));
|
||||
$add_task = new Tasks;
|
||||
$add_task->terminal_id = $terminal_data['id'];
|
||||
$add_task->next_at = date("Y-m-d H:i:s");
|
||||
$add_task->method = 'runquery';
|
||||
$add_task->period = 0;
|
||||
$add_task->is_cycle = 0;
|
||||
$add_task->more = $task;
|
||||
$add_task->save();
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'input' => $input,
|
||||
'task' => $task,
|
||||
];
|
||||
}
|
||||
}
|
||||
70
commands/TopDishes.php
Normal file
70
commands/TopDishes.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\OnlineItems;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class TopDishes extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'gettopdishes';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
|
||||
$info = OnlineItems::where('menu_code', '>', 0)->get()->unique('menu_code');
|
||||
$count = OnlineItems::where('menu_code', '>', 0)->count();
|
||||
if ($count > 0) {
|
||||
foreach ($info as $key => $value) {
|
||||
$out[] = $value;
|
||||
}
|
||||
foreach ($out as $key => $item) {
|
||||
$dishInfo = Dishes::select('name')
|
||||
->where('code', '=', $item['menu_code'])
|
||||
->where('legacy_code', '=', $item['dish_code'])
|
||||
->where('is_history', '=', 0)
|
||||
->first();
|
||||
$onlineDishInfo = OnlineItems::select('real_price', 'sale_price', 'special_price')
|
||||
->where('menu_code', '=', $item['menu_code'])
|
||||
->where('dish_code', '=', $item['dish_code'])
|
||||
->first();
|
||||
$dishName = $dishInfo['name'];
|
||||
$dishCount = OnlineItems::where('menu_code', '=', $item['menu_code'])->sum('count');
|
||||
$dishSum = $onlineDishInfo['real_price'] * $dishCount;
|
||||
if ($dishSum > 0) {
|
||||
$dishTotalCost = round(($onlineDishInfo['special_price'] * $dishCount), 2);
|
||||
$dishPercent = round((100 - ((($dishSum - $dishTotalCost) * 100) / $dishSum)), 2);
|
||||
$dishProfit = $dishSum - $dishTotalCost;
|
||||
} else {
|
||||
$dishTotalCost = 0;
|
||||
$dishPercent = 0;
|
||||
$dishProfit = 0;
|
||||
}
|
||||
$dishes[] = array('name' => $dishName, 'count' => $dishCount, 'sum' => $dishSum, 'totalCost' => $dishTotalCost, 'percentProffit' => $dishPercent, 'proffit' => $dishProfit);
|
||||
}
|
||||
for ($i = 0; $i < count($dishes); $i++) {
|
||||
$sortkey[$i] = $dishes[$i]['count'];
|
||||
}
|
||||
arsort($sortkey);
|
||||
foreach ($sortkey as $key => $key) {
|
||||
$sorted[] = $dishes[$key];
|
||||
}
|
||||
$sorted = array_slice($sorted, 0, 10);
|
||||
return [
|
||||
'status' => 'success',
|
||||
'dishes' => $sorted,
|
||||
// 'info' => $info,
|
||||
// 'test' => $dishes,
|
||||
// 'count' => $dishCount,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'dishes' => [],
|
||||
// 'info' => $info,
|
||||
// 'test' => $dishes,
|
||||
// 'count' => $dishCount,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hrc-admin/hello-world",
|
||||
"version": "1.0",
|
||||
"version": "1.6",
|
||||
"require": {
|
||||
"horeca/admin-php-module-core": "dev-master"
|
||||
},
|
||||
|
||||
742
composer.lock
generated
742
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTestTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('test', function(Blueprint $table)
|
||||
{
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('test');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddRevenueToExchangeShiftsTable extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() {
|
||||
if (!Schema::hasColumn('exchange_shifts', 'revenue')) {
|
||||
Schema::table('exchange_shifts', function (Blueprint $table) {
|
||||
$table->decimal('revenue', $precision = 16, $scale = 2)->nullable()->after('closed');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() {
|
||||
Schema::table('exchange_shifts', function (Blueprint $table) {
|
||||
$table->dropColumn('revenue');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddValueToExchangeActionsTable extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() {
|
||||
Schema::table('exchange_actions', function (Blueprint $table) {
|
||||
$table->string('value', 255)->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() {
|
||||
Schema::table('exchange_actions', function (Blueprint $table) {
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddOrderToOrderbotStorageTable extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() {
|
||||
Schema::table('orderbot_storage', function (Blueprint $table) {
|
||||
$table->text('order')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() {
|
||||
Schema::table('orderbot_storage', function (Blueprint $table) {
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateClientsBarcodesTable extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() {
|
||||
Schema::create('clients_barcodes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('client_guid');
|
||||
$table->string('code_id');
|
||||
$table->string('name');
|
||||
$table->string('block');
|
||||
$table->string('value');
|
||||
$table->string('symptom_block');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() {
|
||||
Schema::dropIfExists('clients_barcodes');
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Component\Seeders;
|
||||
|
||||
use App\Models\Subscriber;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AddAfterMenuUploadSubscriber extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Subscriber::add('sync:postmenu', 'hello:gethello', 10);
|
||||
}
|
||||
}
|
||||
17
database/seeders/AddAfterSyncHelloSubscriber.php
Normal file
17
database/seeders/AddAfterSyncHelloSubscriber.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Component\Seeders;
|
||||
|
||||
use App\Models\Subscriber;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AddAfterSyncHelloSubscriber extends Seeder {
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run() {
|
||||
Subscriber::add('sync:gethello', 'v1:getbot', 10);
|
||||
}
|
||||
}
|
||||
23
database/seeders/AddClientGroup.php
Normal file
23
database/seeders/AddClientGroup.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Component\Seeders;
|
||||
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AddClientGroup extends Seeder {
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run() {
|
||||
if (ClientsGroup::where('code', '0')->count() == 0) {
|
||||
$group = new ClientsGroup([
|
||||
'code' => '0',
|
||||
'name' => 'Без группы',
|
||||
]);
|
||||
$group->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Component\Seeders;
|
||||
|
||||
use App\Models\Right;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AddTestRight extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Right::add('test', 'Тестовый раздел');
|
||||
}
|
||||
}
|
||||
16
models/Client.php
Normal file
16
models/Client.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Client extends Model {
|
||||
protected $table = 'clients';
|
||||
|
||||
/**
|
||||
* Get clients phone.
|
||||
*/
|
||||
public function clientPhone() {
|
||||
return $this->hasOne('App\Component\Models\ClientsPhone', 'client_guid', 'user_code');
|
||||
}
|
||||
}
|
||||
9
models/ClientsAddress.php
Normal file
9
models/ClientsAddress.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientsAddress extends Model {
|
||||
protected $table = 'clients_addreses';
|
||||
}
|
||||
9
models/ClientsBarcode.php
Normal file
9
models/ClientsBarcode.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientsBarcode extends Model {
|
||||
protected $table = 'clients_barcodes';
|
||||
}
|
||||
9
models/ClientsEmail.php
Normal file
9
models/ClientsEmail.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientsEmail extends Model {
|
||||
protected $table = 'clients_email';
|
||||
}
|
||||
9
models/ClientsGroup.php
Normal file
9
models/ClientsGroup.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientsGroup extends Model {
|
||||
protected $table = 'client_groups';
|
||||
}
|
||||
16
models/ClientsPhone.php
Normal file
16
models/ClientsPhone.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientsPhone extends Model {
|
||||
protected $table = 'clients_phone';
|
||||
|
||||
/**
|
||||
* Get clients.
|
||||
*/
|
||||
public function client() {
|
||||
return $this->hasOne('App\Component\Models\Clients', 'user_code', 'client_guid');
|
||||
}
|
||||
}
|
||||
9
models/Dishes.php
Normal file
9
models/Dishes.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Dishes extends Model {
|
||||
protected $table = 'dishes';
|
||||
}
|
||||
9
models/Fiscal.php
Normal file
9
models/Fiscal.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fiscal extends Model {
|
||||
protected $table = 'fiscals';
|
||||
}
|
||||
9
models/Folders.php
Normal file
9
models/Folders.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Folders extends Model {
|
||||
protected $table = 'folders';
|
||||
}
|
||||
9
models/OnlineItems.php
Normal file
9
models/OnlineItems.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OnlineItems extends Model {
|
||||
protected $table = 'shift_online_items';
|
||||
}
|
||||
9
models/Orders.php
Normal file
9
models/Orders.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Orders extends Model {
|
||||
protected $table = 'orderbot_storage';
|
||||
}
|
||||
9
models/Printer.php
Normal file
9
models/Printer.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Printer extends Model {
|
||||
protected $table = 'printers';
|
||||
}
|
||||
9
models/PrinterSettings.php
Normal file
9
models/PrinterSettings.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PrinterSettings extends Model {
|
||||
protected $table = 'printer_settings';
|
||||
}
|
||||
9
models/Report.php
Normal file
9
models/Report.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Report extends Model {
|
||||
protected $table = 'report_history';
|
||||
}
|
||||
19
models/Right.php
Normal file
19
models/Right.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Right extends Model {
|
||||
protected $table = 'rights';
|
||||
|
||||
public static function add($code, $name) {
|
||||
if (Right::where('code', $code)->count() == 0) {
|
||||
$right = new Right([
|
||||
'code' => $code,
|
||||
'name' => $name,
|
||||
]);
|
||||
$right->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
9
models/Settings.php
Normal file
9
models/Settings.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Settings extends Model {
|
||||
protected $table = 'settings';
|
||||
}
|
||||
9
models/Shifts.php
Normal file
9
models/Shifts.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Shifts extends Model {
|
||||
protected $table = 'exchange_shifts';
|
||||
}
|
||||
9
models/Tasks.php
Normal file
9
models/Tasks.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tasks extends Model {
|
||||
protected $table = 'terminals_update';
|
||||
}
|
||||
9
models/Terminal.php
Normal file
9
models/Terminal.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Terminal extends Model {
|
||||
protected $table = 'terminals';
|
||||
}
|
||||
@@ -4,6 +4,6 @@ namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Test extends Model {
|
||||
protected $table = 'test';
|
||||
class User extends Model {
|
||||
protected $table = 'users';
|
||||
}
|
||||
5
module.ini
Normal file
5
module.ini
Normal file
@@ -0,0 +1,5 @@
|
||||
[info]
|
||||
name=V1
|
||||
version=1.6
|
||||
[build]
|
||||
version=1.6
|
||||
25
web/controllers/reimport.js
Normal file
25
web/controllers/reimport.js
Normal file
@@ -0,0 +1,25 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('ReImportCtrl', ReImportCtrl);
|
||||
|
||||
TestHelloCtrl.$inject = ['$scope', 'smartRequest', '$location', 'Notification'];
|
||||
function TestHelloCtrl($scope, smartRequest, $location, Notification) {
|
||||
$scope.orders = [];
|
||||
$scope.total = [];
|
||||
|
||||
$scope.getOrders = function () {
|
||||
smartRequest.get('v1/hello?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function (data) {
|
||||
$scope.orders = data.orders;
|
||||
$scope.total = data.total;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.update = function () {
|
||||
$scope.getOrders();
|
||||
};
|
||||
|
||||
$scope.update();
|
||||
}
|
||||
})();
|
||||
@@ -1,23 +0,0 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('TestHelloCtrl', TestHelloCtrl);
|
||||
|
||||
TestHelloCtrl.$inject = ['$scope', 'smartRequest', '$location', 'Notification'];
|
||||
function TestHelloCtrl($scope, smartRequest, $location, Notification) {
|
||||
$scope.users = [];
|
||||
|
||||
$scope.getUsers = function () {
|
||||
smartRequest.get('php/hello', function (data) {
|
||||
$scope.users = data.users;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.update = function () {
|
||||
$scope.getUsers();
|
||||
};
|
||||
|
||||
$scope.update();
|
||||
}
|
||||
})();
|
||||
@@ -1,19 +0,0 @@
|
||||
group_name: 'Разработка',
|
||||
item: [
|
||||
{
|
||||
name: 'Тест',
|
||||
acl: 'test',
|
||||
icon: 'code',
|
||||
order: 0,
|
||||
items: [
|
||||
{
|
||||
name: 'Hello',
|
||||
acl: 'test',
|
||||
url: 'app.test.hello',
|
||||
icon: 'line_style',
|
||||
count: 0,
|
||||
order: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
code: 'app.test.hello',
|
||||
url: '/test/hello',
|
||||
templateUrl: '../views/test_hello.html',
|
||||
data: { title : 'Hello' },
|
||||
controller: 'TestHelloCtrl',
|
||||
resolve: ['scripts/controllers/test_hello.js']
|
||||
code: 'app.v1.reimport',
|
||||
url: '/v1/reimport',
|
||||
templateUrl: '../views/reimport.html',
|
||||
data: { title : 'Повторная выгрузка' },
|
||||
controller: 'ReImportCtrl',
|
||||
resolve: ['scripts/controllers/reimport.js']
|
||||
}
|
||||
51
web/views/out.html
Normal file
51
web/views/out.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" id="reportOut">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<button class="btn btn-icon white" ng-click="printElem('#reportOut')">
|
||||
<i class="fa fa-print"></i>
|
||||
</button>
|
||||
<h4 class="modal-title">{{globals.currentUser.organization.name}}</h4>
|
||||
<h5 class="modal-title">Отчет по внешним заказам</h5>
|
||||
<span class="text-muted">{{start_date}} - {{end_date}}</span>
|
||||
</div>
|
||||
<div class="modal-body p-lg">
|
||||
<div class="box">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover m-a-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 10%;vertical-align : middle;text-align:center;" rowspan="2">Номер заказа</th>
|
||||
<th style="width: 80%;vertical-align : middle;text-align:center;" colspan="4">Товар</th>
|
||||
<th style="width: 10%;vertical-align : middle;text-align:center;" rowspan="2">Общ. итог</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Наим.</th>
|
||||
<th>Кол-во</th>
|
||||
<th>Цена</th>
|
||||
<th>Итог</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody ng-repeat="order in orders">
|
||||
<tr ng-repeat="item in order.items">
|
||||
<td ng-if="$index == 0" style="vertical-align : middle;text-align:center;" rowspan={{order.items_count}}>{{item.id}}</td>
|
||||
<td>{{item.name}}</td>
|
||||
<td>{{item.count}}</td>
|
||||
<td>{{item.price}}</td>
|
||||
<td>{{item.full_price}} </td>
|
||||
<td ng-if="$index == 0" style="vertical-align : middle;text-align:center;" rowspan={{order.items_count}}> {{order.price}} </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<thead>
|
||||
<th colspan="6">Всего заказов: {{total.total_count}}</th>
|
||||
</thead>
|
||||
<thead>
|
||||
<th colspan="6">Итого: {{total.total_price | curr}} BYN</th>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
80
web/views/reimport.html
Normal file
80
web/views/reimport.html
Normal file
@@ -0,0 +1,80 @@
|
||||
<div class="padding">
|
||||
<div class="box">
|
||||
<div class="padding">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="single">Выберите даты для повторной выгрузки реализаций</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>С</label>
|
||||
<div class='input-group date' ui-jp="datetimepicker" ui-options="{
|
||||
format: 'DD.MM.YYYY',
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-screenshot',
|
||||
clear: 'fa fa-trash',
|
||||
close: 'fa fa-remove'
|
||||
}
|
||||
}">
|
||||
<input type='text' class="form-control" ng-model="start_date" />
|
||||
<span class="input-group-addon">
|
||||
<i class="material-icons"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>По</label>
|
||||
<div class='input-group date' ui-jp="datetimepicker" ui-options="{
|
||||
format: 'DD.MM.YYYY',
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-screenshot',
|
||||
clear: 'fa fa-trash',
|
||||
close: 'fa fa-remove'
|
||||
}
|
||||
}">
|
||||
<input type='text' class="form-control" ng-model="end_date" />
|
||||
<span class="input-group-addon">
|
||||
<i class="material-icons"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<button class="btn info btn-block" ng-click="createReport()">Выполнить повторную выгрузку
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/libs/js/moment/locale/ru.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('.date').on('dp.change', function () {
|
||||
$(this).find('input').trigger('change');
|
||||
});
|
||||
</script>
|
||||
@@ -1,35 +0,0 @@
|
||||
<div id="container-floating">
|
||||
<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">
|
||||
<thead>
|
||||
<th style="width: 20%">#</th>
|
||||
<th style="width: 80%">Имя</th>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr ng-repeat="user in users">
|
||||
<td>{{ user.id }}</td>
|
||||
<td>{{ user.name }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user