v.2.21
Обновлен перенос клиента из группы в группу Обновлен метод восстановления смены Добавлен метод загрузки меню 1с из облака
This commit is contained in:
@@ -14,6 +14,58 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getdatareport';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
|
||||
function validate_json($string)
|
||||
{
|
||||
// decode the JSON data
|
||||
$result = json_decode(utf8_encode($string), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
|
||||
// switch and check possible JSON errors
|
||||
switch (json_last_error()) {
|
||||
case JSON_ERROR_NONE:
|
||||
$error = ''; // JSON is valid // No error has occurred
|
||||
break;
|
||||
case JSON_ERROR_DEPTH:
|
||||
$error = 'The maximum stack depth has been exceeded.';
|
||||
break;
|
||||
case JSON_ERROR_STATE_MISMATCH:
|
||||
$error = 'Invalid or malformed JSON.';
|
||||
break;
|
||||
case JSON_ERROR_CTRL_CHAR:
|
||||
$error = 'Control character error, possibly incorrectly encoded.';
|
||||
break;
|
||||
case JSON_ERROR_SYNTAX:
|
||||
$error = 'Syntax error, malformed JSON.';
|
||||
break;
|
||||
// PHP >= 5.3.3
|
||||
case JSON_ERROR_UTF8:
|
||||
$error = 'Malformed UTF-8 characters, possibly incorrectly encoded.';
|
||||
break;
|
||||
// PHP >= 5.5.0
|
||||
case JSON_ERROR_RECURSION:
|
||||
$error = 'One or more recursive references in the value to be encoded.';
|
||||
break;
|
||||
// PHP >= 5.5.0
|
||||
case JSON_ERROR_INF_OR_NAN:
|
||||
$error = 'One or more NAN or INF values in the value to be encoded.';
|
||||
break;
|
||||
case JSON_ERROR_UNSUPPORTED_TYPE:
|
||||
$error = 'A value of a type that cannot be encoded was given.';
|
||||
break;
|
||||
default:
|
||||
$error = 'Unknown JSON error occured.';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($error !== '') {
|
||||
// throw the Exception or exit // or whatever :)
|
||||
return false;
|
||||
}
|
||||
|
||||
// everything is OK
|
||||
return true;
|
||||
}
|
||||
|
||||
function data_decode($data) {
|
||||
$alph = [
|
||||
"А", "Б", "В", "Г", "Д",
|
||||
@@ -103,7 +155,12 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface {
|
||||
if ($item_action['more']) {
|
||||
$merge_trigger = 1;
|
||||
$merge_items_before = $merge_items_after = $merge_items = $merge_order_item_before = $merge_order_item_after = $merged_items = [];
|
||||
$merge_order_items = json_decode(utf8_encode($item_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if (validate_json($item['more'])) {
|
||||
$merge_order_items = json_decode(utf8_encode($item_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
} else {
|
||||
$merge_order_items = json_decode(utf8_encode(base64_decode($item_action['more'], TRUE)), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
}
|
||||
|
||||
$merge_order_items_before = $merge_order_items['before']['items'];
|
||||
$merge_order_items_after = $merge_order_items['after']['items'];
|
||||
foreach ($merge_order_items_before as $key => $merge_order_item_before) {
|
||||
@@ -168,13 +225,21 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface {
|
||||
foreach ($actions as $key => $action) {
|
||||
$value = $action['value'];
|
||||
$codeOrder = $action['order_code'];
|
||||
$moved_items = json_decode(utf8_encode($action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if (validate_json($action['more'])) {
|
||||
$moved_items = json_decode(utf8_encode($action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
} else {
|
||||
$moved_items = json_decode(utf8_encode(base64_decode($action['more'], TRUE)), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
}
|
||||
$from_place = ExchangeActions::where('order_code', $codeOrder)->where('action_type', 45)->where('shift_id', $input['shift_id'])->first();
|
||||
$from_place = data_decode($from_place['value']);
|
||||
$to_place = ExchangeActions::where('order_code', $value)->where('action_type', 45)->where('shift_id', $input['shift_id'])->first();
|
||||
$to_place = data_decode($to_place['value']);
|
||||
$to_action = ExchangeActions::where('value', $codeOrder)->where('order_code', $value)->where('action_type', 34)->where('shift_id', $input['shift_id'])->first();
|
||||
$start_data = json_decode(utf8_encode($to_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if (validate_json($to_action['more'])) {
|
||||
$start_data = json_decode(utf8_encode($to_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
} else {
|
||||
$start_data = json_decode(utf8_encode(base64_decode($to_action['more'], TRUE)), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
}
|
||||
$staff_name = staffName($action['who']);
|
||||
$time = date('d.m.Y H:i:s', strtotime($action['time']));
|
||||
$sliced_order_data[] = array('from_order' => $codeOrder, 'from_place' => $from_place, 'staff' => $staff_name, 'time' => $time, 'start_data' => $start_data, 'to_order' => $value, 'to_place' => $to_place, 'moved_items' => $moved_items);
|
||||
|
||||
Reference in New Issue
Block a user