diff --git a/commands/Import — копия.php b/commands/Import — копия.php deleted file mode 100644 index 5593ee9..0000000 --- a/commands/Import — копия.php +++ /dev/null @@ -1,90 +0,0 @@ -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) { - $url = $HRCPortalURL . 'api/cloud/list?api=2.0&project_code=hrc&code=' . $terminal['key'] . '&folder=' . $folder; - $search = curl_init(); - - curl_setopt_array($search, array( - CURLOPT_URL => $url, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_HEADER => false, - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - )); - $search_response = curl_exec($search); - curl_close($search); - $responses = json_decode($search_response, TRUE)['files']; - - foreach ($responses as $key => $response) { - if (array_key_exists('filename', $response)) { - $fulldate = date_parse_from_format('d-m-Y-H-i-s', $response['filename']); - $fulldate = mktime($fulldate['hour'], $fulldate['minute'], $fulldate['second'], $fulldate['month'], $fulldate['day'], $fulldate['year']); - if ($fulldate >= strtotime($start_date) && $fulldate <= strtotime($end_date)) { - $out[] = date('d-m-Y-H-i-s', $fulldate); - } - } - } - if (!isset($out)) { - return [ - 'status' => 'success', - 'message' => 'shifts not found', - ]; - } else { - foreach ($out as $filename) { - $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(); - - curl_setopt_array($download, array( - CURLOPT_URL => $download_url, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_HEADER => false, - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - )); - $download_response = curl_exec($download); - curl_close($download); - $file = json_decode($download_response, TRUE)['content']; - $params = array('code' => $terminal['key'], 'name' => $filename . '.xml', 'folder' => 'exchange', 'content' => $file, 'project_code' => 'hrc', 'api' => '2.0'); - $upload = curl_init(); - curl_setopt_array($upload, array( - CURLOPT_RETURNTRANSFER => true, - CURLOPT_HEADER => true, - CURLOPT_URL => $HRCPortalURL . 'api/cloud/upload', - CURLOPT_SSL_VERIFYHOST => 0, - CURLOPT_POST => true, - CURLOPT_POSTFIELDS => $params, - )); - $upload_response = curl_exec($upload); - curl_close($upload); - } - return [ - 'status' => 'success', - 'start_date' => strtotime($start_date), - 'end_date' => strtotime($end_date), - ]; - } - } - } -} \ No newline at end of file diff --git a/database/migrations/2022_01_10_150113_add_columns_to_units_list.php b/database/migrations/2022_01_10_150113_add_columns_to_units_list.php new file mode 100644 index 0000000..3184a5d --- /dev/null +++ b/database/migrations/2022_01_10_150113_add_columns_to_units_list.php @@ -0,0 +1,29 @@ +string('legacy_code')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() { + Schema::table('units_list', function (Blueprint $table) { + $table->dropColumn('legacy_code'); + }); + } +}