diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 255a081..181811a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -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(); diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index bbad373..a5be020 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -84,17 +84,8 @@ class ProjectController extends Controller return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); } - // $result = Project::query() - // ->from('m_proyek AS mp') - // ->where('mp.id', $id) - // ->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek, - // area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status'); - - // if (!is_null($result->first()['divisi_id'])) { - // $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id') - // ->addSelect(DB::raw('m_divisi.name AS nama_divisi')); - // } - $result = Project::select( + $result = Project:: + select( 'value_proyek', 'scoupe_of_work', 'kode_sortname', @@ -126,6 +117,7 @@ class ProjectController extends Controller 'phase_id', 'calculation_status', 'md.name as divisi_name', + 'm_proyek.company_id' ) ->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id') ->where('m_proyek.id', $id) diff --git a/routes/web.php b/routes/web.php index 221cbbb..0509a92 100644 --- a/routes/web.php +++ b/routes/web.php @@ -591,6 +591,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->get('/demo-management/list', 'DemoController@list'); $router->get('/information-storage/{company_name}', 'Controller@storage'); + $router->get('/information-storage-all-company','Controller@storageAllCompany'); $router->post('/refferal-code/search', 'RefferalCodeController@search'); $router->post('/refferal-code/add', 'RefferalCodeController@add');