|
|
|
@ -10,6 +10,7 @@ use App\Models\Company;
|
|
|
|
|
use App\Models\ReportK3Detail; |
|
|
|
|
use App\Models\UserToActivity; |
|
|
|
|
use App\Models\ProductTransaction; |
|
|
|
|
use App\Models\Project; |
|
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
use Carbon\Carbon; |
|
|
|
|
use Illuminate\Support\Facades\Http; |
|
|
|
@ -45,13 +46,10 @@ class Controller extends BaseController
|
|
|
|
|
|
|
|
|
|
protected function setCustomeDirectoryUpload($company_name) |
|
|
|
|
{ |
|
|
|
|
$current_date = date('Y-m-d'); |
|
|
|
|
[$year, $month, $day] = explode('-', $current_date); |
|
|
|
|
|
|
|
|
|
$pathImage = 'assets/' . $company_name . ' ' . $year . '-' . $month . '-' . $day . '/image/'; |
|
|
|
|
$pathDocument = 'assets/' . $company_name . ' ' . $year . '-' . $month . '-' . $day . '/file/project/'; |
|
|
|
|
$pathTmpImport = 'assets/' . $company_name . ' ' . $year . '-' . $month . '-' . $day . '/file/tmpimport/'; |
|
|
|
|
$pathActivityDocument = 'assets/' . $company_name . ' ' . $year . '-' . $month . '-' . $day . '/file/activity/'; |
|
|
|
|
$pathImage = 'assets/' . $company_name . '/image/'; |
|
|
|
|
$pathDocument = 'assets/' . $company_name . '/file/project/'; |
|
|
|
|
$pathTmpImport = 'assets/' . $company_name . '/file/tmpimport/'; |
|
|
|
|
$pathActivityDocument = 'assets/' . $company_name . '/file/activity/'; |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
'pathImage' => $pathImage, |
|
|
|
@ -64,14 +62,10 @@ class Controller extends BaseController
|
|
|
|
|
public function storage($company_name) |
|
|
|
|
{ |
|
|
|
|
$directory = 'assets/' . urldecode($company_name); |
|
|
|
|
|
|
|
|
|
if (!is_dir($directory)) { |
|
|
|
|
return "Directory not found"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$size = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) { |
|
|
|
|
$size += $file->getSize(); |
|
|
|
@ -79,10 +73,32 @@ class Controller extends BaseController
|
|
|
|
|
} catch (Exception $e) { |
|
|
|
|
return "Error while calculating size: " . $e->getMessage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return round($size / 1048576, 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function storageAllCompany() |
|
|
|
|
{ |
|
|
|
|
$companies = Company::get(); |
|
|
|
|
$formData = []; |
|
|
|
|
foreach($companies as $data) { |
|
|
|
|
$size = 0; |
|
|
|
|
$directory = 'assets/' . urldecode($data['company_name']); |
|
|
|
|
if (is_dir($directory)) { |
|
|
|
|
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) { |
|
|
|
|
$size += $file->getSize(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$formData[] = [ |
|
|
|
|
'company_name' => $data['company_name'], |
|
|
|
|
'size' => round($size / 1048576, 2), |
|
|
|
|
'exp_ospro' => ProductTransaction::query()->where('company_id', $data['id'])->value('exp_ospro'), |
|
|
|
|
'project_total' => Project::query()->where('company_id',$data['id'])->count() |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $formData; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setExpiredTimeOspro($company_id) |
|
|
|
|
{ |
|
|
|
|
$currentDate = Carbon::now(); |
|
|
|
|