v.2.27
Fixed reports
This commit is contained in:
@@ -30,11 +30,26 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
}
|
||||
|
||||
$total = Client::where('name', '=', $input['name'])->count();
|
||||
if (isset($input['client_guid'])) {
|
||||
$check_guid = Client::where('user_code', $input['client_guid'])->count();
|
||||
if ($check_guid > 0) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Клиент уже существует'
|
||||
];
|
||||
}
|
||||
}
|
||||
$client_code = Client::max('code') + 1;
|
||||
if (isset($input['is_special_price']) && $input['is_special_price'] == 'true') {
|
||||
$specialPrice = 1;
|
||||
} else {
|
||||
$specialPrice = 0;
|
||||
}
|
||||
if (isset($input['is_employee']) && $input['is_employee'] == 'true') {
|
||||
$employee = 1;
|
||||
} else {
|
||||
$employee = 0;
|
||||
}
|
||||
$client = new Client;
|
||||
if ($total >= 1) {
|
||||
$total = $total + 1;
|
||||
@@ -42,10 +57,17 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
} else {
|
||||
$client->name = urldecode($input['name']);
|
||||
}
|
||||
$client->user_code = strtoupper(md5(time()));
|
||||
if (!isset($input['client_guid'])) {
|
||||
$client->user_code = strtoupper(md5(time()));
|
||||
} else {
|
||||
$client->user_code = $input['client_guid'];
|
||||
}
|
||||
|
||||
$client->code = $client_code;
|
||||
$client->group_id = $group['code'];
|
||||
$client->is_special_price = $specialPrice;
|
||||
|
||||
$client->is_employee = $employee;
|
||||
$client->last_change = date("Ymd");
|
||||
$clientEmail = new ClientsEmail;
|
||||
$clientEmail->email = urldecode($input['email']);
|
||||
$clientEmail->client_guid = $client->user_code;
|
||||
@@ -55,7 +77,7 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
$clientAddress->client_guid = $client->user_code;
|
||||
|
||||
$clientPhone = new ClientsPhone;
|
||||
if ($input['phone'] !== '') {
|
||||
if ($input['phone'] !== '' && isset($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 {
|
||||
@@ -65,7 +87,7 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
$clientPhone->client_guid = $client->user_code;
|
||||
|
||||
if (isset($input['barcode']) && $input['barcode'] > 0) {
|
||||
$client->barcode_type = 1;
|
||||
$client->barcode_type = 2;
|
||||
$clientBarcode = new ClientsBarcode;
|
||||
$clientBarcode->code_id = urldecode($input['barcode']);
|
||||
$clientBarcode->name = '';
|
||||
@@ -73,13 +95,15 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
$clientBarcode->value = urldecode($input['barcode']);
|
||||
$clientBarcode->block = 0;
|
||||
$clientBarcode->symptom_block = 0;
|
||||
$client->barcode_start = urldecode($input['barcode']);
|
||||
$client->barcode_end = urldecode($input['barcode']);
|
||||
$client->save();
|
||||
$clientPhone->save();
|
||||
$clientEmail->save();
|
||||
$clientAddress->save();
|
||||
$clientBarcode->save();
|
||||
} else {
|
||||
$client->barcode_type = 0;
|
||||
$client->barcode_type = 1;
|
||||
$client->save();
|
||||
$clientPhone->save();
|
||||
$clientEmail->save();
|
||||
|
||||
Reference in New Issue
Block a user