From 3c8a6b27361d6fd356cc2cac0ee91443df1afdb0 Mon Sep 17 00:00:00 2001 From: miroman-afk <74014189+miroman-afk@users.noreply.github.com> Date: Tue, 16 Nov 2021 15:43:14 +0300 Subject: [PATCH] v.2.0 Clients file update --- commands/ClientFile.php | 2 +- commands/Import.php | 6 ++++-- models/Client.php | 2 +- models/ClientsPhone.php | 2 +- web/controllers/reimport.js | 4 ++++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/commands/ClientFile.php b/commands/ClientFile.php index 2564108..385e3c0 100644 --- a/commands/ClientFile.php +++ b/commands/ClientFile.php @@ -64,7 +64,7 @@ class ClientFile extends HRCCommand implements HRCCommandInterface { $mainThreads = 4; $countPerThread = ceil($clientsCount / $mainThreads); $offset = ($urlThread - 1) * $countPerThread; - $clients = Client::with('clientPhone:client_guid')->skip($offset)->take($countPerThread)->get(); + $clients = Client::with('clientPhone')->skip($offset)->take($countPerThread)->get(); if (!is_dir($tmp_dirname)) { mkdir($tmp_dirname, 0755, 'w+'); diff --git a/commands/Import.php b/commands/Import.php index 8793160..5593ee9 100644 --- a/commands/Import.php +++ b/commands/Import.php @@ -12,7 +12,7 @@ class Import extends HRCCommand implements HRCCommandInterface { 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(); + $terminals = Terminal::where('soft', '=', 1)->where('is_active', '=', 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) { @@ -48,7 +48,9 @@ class Import extends HRCCommand implements HRCCommandInterface { ]; } else { foreach ($out as $filename) { - $path = '/backup/' . $filename . '.xml'; + $date_file = date('Y-m-d', $filename); + //$path = '/backup/' . $filename . '.xml'; + $path = '/Резервная%20копия/' . $date_file . '/exchange/' . $date_file . '/exchange/' . $filename . '.xml'; $download_url = $HRCPortalURL . 'api/cloud/download?api=2.0&project_code=hrc&code=' . $terminal['key'] . '&path=' . $path; $download = curl_init(); diff --git a/models/Client.php b/models/Client.php index e98c571..8524e74 100644 --- a/models/Client.php +++ b/models/Client.php @@ -11,6 +11,6 @@ class Client extends Model { * Get clients phone. */ public function clientPhone() { - return $this->hasOne('App\Component\Models\ClientsPhone', 'client_guid', 'user_code'); + return $this->belongsTo('App\Component\Models\ClientsPhone', 'user_code', 'client_guid'); } } \ No newline at end of file diff --git a/models/ClientsPhone.php b/models/ClientsPhone.php index acfca8e..1ec0454 100644 --- a/models/ClientsPhone.php +++ b/models/ClientsPhone.php @@ -11,6 +11,6 @@ class ClientsPhone extends Model { * Get clients. */ public function client() { - return $this->hasOne('App\Component\Models\Clients', 'user_code', 'client_guid'); + return $this->belongsTo('App\Component\Models\Clients', 'user_code', 'client_guid'); } } \ No newline at end of file diff --git a/web/controllers/reimport.js b/web/controllers/reimport.js index 505b31f..5545997 100644 --- a/web/controllers/reimport.js +++ b/web/controllers/reimport.js @@ -16,6 +16,10 @@ }); }; + $scope.createReport = function () { + + }; + $scope.update = function () { $scope.getOrders(); };