|
|
|
@ -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; |
|
|
|
@ -64,14 +65,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 +76,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(); |
|
|
|
|