v.2.12
-Add new setting "Delete shift" -Move "Shift" frontend to V1 module
This commit is contained in:
36
commands/GETSettings.php
Normal file
36
commands/GETSettings.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Settings;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETSettings extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getsettings';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if (isset($input['code'])) {
|
||||
$setting = Settings::where('code', $input['code'])->first();
|
||||
if ($setting) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'name' => $setting['name'],
|
||||
'code' => $setting['code'],
|
||||
'value' => $setting['value'],
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'more' => 'Setting not found',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$settings = Settings::all();
|
||||
return [
|
||||
'status' => 'success',
|
||||
'settings' => $settings,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
86
commands/POSTDeleteData.php
Normal file
86
commands/POSTDeleteData.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
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\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class POSTDeleteData extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postdeletedata';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if ($input['value'] == 'delete_shift') {
|
||||
if ($input['shift_id']) {
|
||||
$exchange_shift = ExchangeShifts::where('id', $input['shift_id'])->first();
|
||||
$exchange_orders = ExchangeOrders::where('shift_id', '=', $input['shift_id'])->get();
|
||||
$exchange_items = ExchangeItems::where('shift_id', '=', $input['shift_id'])->get();
|
||||
$exchange_actions = ExchangeActions::where('shift_id', '=', $input['shift_id'])->get();
|
||||
$exchange_deleted = ExchangeDeleted::where('shift_id', '=', $input['shift_id'])->get();
|
||||
if ($exchange_shift) {
|
||||
$exchange_shift = ExchangeShifts::find($input['shift_id']);
|
||||
$exchange_shift->delete();
|
||||
}
|
||||
if ($exchange_orders) {
|
||||
foreach ($exchange_orders as $key => $exchange_order) {
|
||||
$order = ExchangeOrders::find($exchange_order['id']);
|
||||
$order->delete();
|
||||
}
|
||||
}
|
||||
if ($exchange_items) {
|
||||
foreach ($exchange_items as $key => $exchange_item) {
|
||||
$item = ExchangeItems::find($exchange_item['id']);
|
||||
$item->delete();
|
||||
}
|
||||
}
|
||||
if ($exchange_actions) {
|
||||
foreach ($exchange_actions as $key => $exchange_action) {
|
||||
$action = ExchangeActions::find($exchange_action['id']);
|
||||
$action->delete();
|
||||
}
|
||||
}
|
||||
if ($exchange_deleted) {
|
||||
foreach ($exchange_deleted as $key => $exchange_delete) {
|
||||
$delete = ExchangeDeleted::find($exchange_delete['id']);
|
||||
$delete->delete();
|
||||
}
|
||||
}
|
||||
function dirDel($dir) {
|
||||
$d = opendir($dir);
|
||||
while (($entry = readdir($d)) !== false) {
|
||||
if ($entry != "." && $entry != "..") {
|
||||
if (is_dir($dir . "/" . $entry)) {
|
||||
dirDel($dir . "/" . $entry);
|
||||
} else {
|
||||
unlink($dir . "/" . $entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($d);
|
||||
rmdir($dir);
|
||||
}
|
||||
$cache_dir = __DIR__ . "\\..\\..\\..\\Cache\\";
|
||||
dirDel($cache_dir);
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Данные удалены',
|
||||
];
|
||||
|
||||
} else {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'message' => 'Check input data',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'message' => 'Check input data',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user