55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use App\Component\Models\ClientsGroup;
|
|
use App\Component\Models\Terminal;
|
|
use App\Console\Commands\HRCCommand;
|
|
use App\Console\Commands\HRCCommandInterface;
|
|
|
|
class ClientGroup 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']);
|
|
}
|
|
$terminal = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->where('work_code', '=', 1)->first();
|
|
$dir = __DIR__ . "/../../../Exchange/" . $terminal['key'] . "/";
|
|
if (!is_dir($dir)) {
|
|
mkdir($dir, 0755, 'w+');
|
|
}
|
|
|
|
$files = glob($dir . "*.*");
|
|
if (count($files) > 0) {
|
|
usort($files, function ($a, $b) {
|
|
return filemtime($a) < filemtime($b);
|
|
});
|
|
|
|
foreach ($files as $plk2) {
|
|
$file_array[] = str_replace($dir, '', $plk2);
|
|
}
|
|
$filename = $file_array['0'];
|
|
$file = date("d.m.Y H:i:s", filemtime(__DIR__ . "/../../../Exchange/" . $terminal['key'] . "/" . $file_array['0']));
|
|
} else {
|
|
$file_array = '';
|
|
$filename = '';
|
|
$file = '';
|
|
}
|
|
return [
|
|
'status' => 'success',
|
|
'groups' => $out,
|
|
'terminalKey' => $terminal['key'],
|
|
'files' => $files,
|
|
'filename' => $filename,
|
|
'filedate' => $file,
|
|
];
|
|
}
|
|
} |