From e1a91a2d3cb44fbf2007f032113917aa9c17e071 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 22 Aug 2022 03:01:06 +0700 Subject: [PATCH 01/24] default phase_id value --- app/Http/Controllers/ProjectController.php | 41 +++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 1855eca..c53764d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -47,6 +47,9 @@ class ProjectController extends Controller $data['created_by'] = $this->currentName; + if(empty($data['phase_id'])) + $data['phase_id'] = 1; + $result = Project::create($data); if(!$result) @@ -260,11 +263,12 @@ class ProjectController extends Controller ->first(); if($d->area_kerja != ''){ $d->geolocation = $this->httpReq($d->area_kerja); + $d->geolocation = []; } else { - $d->geolocation = ''; + $d->geolocation = []; } } - + $totalPlannedCost = $data->sum('plannedCost'); $totalActualCost = $data->sum('actualCost'); $manpowers = User::count(); @@ -322,18 +326,18 @@ class ProjectController extends Controller } public function dashboard($id) - { + { $data = DB::table('m_proyek as mp') - ->select('mp.kode_sortname', 'mp.nama as name_project', 'mp.mulai_proyek as start', 'mp.akhir_proyek as finish', + ->select('mp.kode_sortname', 'mp.nama as name_project', 'mp.mulai_proyek as start', 'mp.akhir_proyek as finish', 'mp.rencana_biaya', 'mp.company', 'mp.currency_symbol', 'mu.name as pm', 'mp.budget_health') ->join('m_users as mu', 'mu.id', '=', 'mp.pm_id') ->where('mp.id', $id) - ->get(); - $countData = $data->count(); + ->get(); + $countData = $data->count(); $manpowers = UserToProyek::where('proyek_id', $id)->count(); $rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); - + if($rootActivity){ $actualCost = $rootActivity->biaya_actual ?? 0; $progress = $rootActivity->persentase_progress ?? 0; @@ -364,27 +368,30 @@ class ProjectController extends Controller $dataRes['progress'] = $progress; $dataRes['comment'] = $commentActivity; $dataRes['man_power'] = $manpowers; - } - + } + if(!$data) - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); + return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); return response()->json(['status'=>'success','code'=>200,'data'=>$dataRes, 'totalRecord'=>$countData], 200); } - + private function httpReq($search){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); - - // SSL important + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - //curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - + curl_setopt($ch, CURLOPT_VERBOSE, true); + curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w')); + + $info = curl_getinfo($ch); + $output = curl_exec($ch); curl_close($ch); - + return json_decode($output); } - + } + From d1ce3d178a141ae788f5439051e745c046354e22 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 24 Aug 2022 02:15:51 +0700 Subject: [PATCH 02/24] fix s-curve --- app/Http/Controllers/ActivityController.php | 56 +++++++-------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index f6952aa..b3805ef 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -389,6 +389,7 @@ class ActivityController extends Controller public function getCalculateCurvaS(Request $request) // for adw (plan & actual == date) { + DB::enableQueryLog(); $dataPayload = $request->all(); $allGantt = []; if(isset($dataPayload['gannt_id'])){ @@ -417,7 +418,7 @@ class ActivityController extends Controller ->join('m_activity as b', 'b.id', '=', 'a.activity_id') ->where('b.version_gantt_id', '=', $keyGantt['last_gantt_id']) ->exists(); - + if(!$alreadyHasReport) continue; @@ -432,7 +433,7 @@ class ActivityController extends Controller ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) ->max("plan_date"); - + $begin = new \DateTime($minDate); $end = new \DateTime($maxDate); $end2 = new \DateTime($maxDate); @@ -445,10 +446,7 @@ class ActivityController extends Controller $tempTtlPercentActual=0; $currentACWP = 0; - $budgetControlACWP = 0; - $currentProgressActivity = 0; $currentBCWP = 0; - $budgetControlBCWP = 0; foreach ($period as $dt) { $dataPlanM = DB::table('assign_material_to_activity as ama') @@ -463,8 +461,11 @@ class ActivityController extends Controller ->join('m_activity as a', 'a.id', '=', 'ram.activity_id') ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) ->where('a.proyek_id', '=', $keyGantt['proyek_id']) - ->whereDate('ram.report_date', $dt->format("Y-m-d")) + /* ->whereDate('ram.report_date', $dt->format("Y-m-d")) */ + ->whereDate('ram.report_date', '2021-11-08') ->get(); + /* dd($dt->format('Y-m-d')); */ + dd($dataActualM); $dataTempPlan = []; $x = 0; $sumPercentagePlan=0; @@ -516,7 +517,7 @@ class ActivityController extends Controller $totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; } catch (\Exception $e) { return response()->json(['message' => $e->getMessage()]); - } + } $dataTempReport [$w]['totalacwp'] = $totalACWP; $w++; } @@ -529,39 +530,20 @@ class ActivityController extends Controller 'actual'=>$dataTempReport, ); if(isset($dataPayload['period']) && $dataPayload['period'] == 'week'){ - if($dt->format("w")==1){ - if($totalACWP > 0 ){ - $budgetControlACWP = $currentACWP + $totalACWP; - } - if($totalBCWP > 0 ){ - $budgetControlBCWP = $currentBCWP + $totalBCWP; - } + $tempTtlPercentPlan+= $sumPercentagePlan; + $tempTtlPercentActual+= $sumPercentageActual; + $currentACWP += $totalACWP; + $currentBCWP += $totalBCWP; - $tempTtlPercentPlan+= $sumPercentagePlan; - $tempTtlPercentActual+= $sumPercentageActual; - $currentACWP += $totalACWP; - $currentBCWP += $totalBCWP; - - $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); - $tempDate[] = array($dt->format("Y-m-d"), 0, 0); - }else if($dt->format("Y-m-d") == $end2->format("Y-m-d")) { - $tempTtlPercentPlan+= $sumPercentagePlan; - $tempTtlPercentActual+= $sumPercentageActual; - $currentACWP += $totalACWP; - $currentBCWP += $totalBCWP; - - $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); - $tempDate[] = array($dt->format("Y-m-d"), 0, 0); - $tempTtlPercentPlan = 0; - $tempTtlPercentActual = 0; - } + $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); + $tempDate[] = array($dt->format("Y-m-d"), 0, 0); }else{ $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); $tempDate[] = array($dt->format("Y-m-d"), 0, 0); } } - + try { if(round($totalACWP,0) > $totalRencanaBudget){ $estimatedCost = round($totalACWP,0)+0; @@ -570,13 +552,13 @@ class ActivityController extends Controller } } catch (\Exception $e) { return response()->json([ - 'message' => $e->getMessage(), + 'message' => $e->getMessage(), "line" => 566, 'gantt' => $keyGantt, ]); } - //$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget; - + $estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget; + $costDeviation = $totalRencanaBudget - $estimatedCost; if($costDeviation > 0){ $potential = "SAVING"; @@ -598,7 +580,7 @@ class ActivityController extends Controller "potential" => $potential, ) ); - + $dataFinal[] = array( "proyek_name"=> $dataProject->nama, "data"=>$dataResponse, From d64f5a8b815edfff7c3de9caaf5af1ddbefa7bc7 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 24 Aug 2022 02:36:41 +0700 Subject: [PATCH 03/24] bug fix --- app/Models/Activity.php | 14 +++++++------- app/Models/AssignMaterial.php | 18 ------------------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 1f01083..0753d20 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -57,6 +57,10 @@ class Activity extends Model private function updateBobot() { + $rootActivity = Activity::where('version_gantt_id', $this->version_gantt_id) + ->where("proyek_id", $this->proyek_id) + ->where('type_activity', 'header') + ->first(); if(Activity::where('version_gantt_id', $this->version_gantt_id)->where("proyek_id", $this->proyek_id)->where('type_activity', 'header')->count() == 0) { $totalCost = Activity::select( DB::raw('sum(cast(rencana_biaya as double precision))') @@ -72,10 +76,6 @@ class Activity extends Model ->where("parent_id", $rootActivity->id) ->first(); } - $rootActivity = Activity::where('version_gantt_id', $this->version_gantt_id) - ->where("proyek_id", $this->proyek_id) - ->where('type_activity', 'header') - ->first(); if($totalCost->sum > 0){ @@ -130,9 +130,9 @@ class Activity extends Model public function getJobsDoneAttribute() { $tmpPercentage = []; - if(!ReportActivityMaterial::where('activity_id', $this->id)->first()) - return 0; - if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get()) + if(!ReportActivityMaterial::where('activity_id', $this->id)->first()) + return 0; + if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get()) return 0; foreach ($dataPlan as $value) { $tmpPercentage[] = 100; diff --git a/app/Models/AssignMaterial.php b/app/Models/AssignMaterial.php index e3957a8..597f430 100644 --- a/app/Models/AssignMaterial.php +++ b/app/Models/AssignMaterial.php @@ -29,32 +29,14 @@ class AssignMaterial extends Model static::created(function($data) { $activity = Activity::find($data->activity_id); $material = RequestMaterial::where("id", $data->material_id)->first(); - $old = $activity->rencana_biaya; $activity->rencana_biaya += floatval($material->price) * floatval($data->qty_planning); $activity->save(); - - $msg = Carbon::now()->toDateTimeString() . ": ".$activity->id." ".$activity->name.PHP_EOL; - $msg .= "Added: ".$material->desc." (".floatval($material->price)." * ".floatval($data->qty_planning)."), Cost plan old: ".$old." | +".$activity->rencana_biaya.PHP_EOL; - $msg .= "Data type (".gettype(floatval($material->price))." * ".gettype(floatval($material->qty_planning))."), ".gettype(floatval($old))." | ".gettype(floatval($activity->rencana_biaya)).PHP_EOL; - $msg .= "Data type origin (".gettype($material->price)." * ".gettype($material->qty_planning)."), ".gettype($old)." | ".gettype($activity->rencana_biaya).PHP_EOL; - $msg .= "------".PHP_EOL; - file_put_contents('activity_log.txt', $msg, FILE_APPEND | LOCK_EX); - }); static::deleted(function($data) { $activity = Activity::where('id', $data->activity_id)->first(); - $old = $activity->rencana_biaya; $activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning); $activity->save(); - $material = RequestMaterial::where("id", $data->material_id)->first(); - - $msg = Carbon::now()->toDateTimeString() . ": ".$activity->id." ".$activity->name.PHP_EOL; - $msg .= "Deleted: ".$material->desc." (".floatval($data->budget)." * ".floatval($data->qty_planning)."), Cost plan old: ".$old." | -".$activity->rencana_biaya.PHP_EOL; - $msg .= "Data type (".gettype(floatval($data->budget))." * ".gettype(floatval($data->qty_planning))."), ".gettype(floatval($old))." | ".gettype(floatval($activity->rencana_biaya)).PHP_EOL; - $msg .= "Data type origin (".gettype($data->budget)." * ".gettype($data->qty_planning)."), ".gettype($old)." | ".gettype($activity->rencana_biaya).PHP_EOL; - $msg .= "------".PHP_EOL; - file_put_contents('activity_log.txt', $msg, FILE_APPEND | LOCK_EX); }); } From 42f925ef60e13527f8e72756f863c0de2feec137 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 24 Aug 2022 04:29:04 +0700 Subject: [PATCH 04/24] remove unnecessary comment --- app/Models/Activity.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 0753d20..52708f4 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -25,10 +25,6 @@ class Activity extends Model 'planned_start', 'planned_end', 'satuan_id', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; - // this piece of shit prepend column on create(), causing bugs - //protected $attributes = [ - // 'jobs_done', 'assign_hr', 'assign_material', 'assign_tools' - //]; protected $appends = [ 'jobs_done', 'assign_hr', 'assign_material', 'assign_tools' From 514c0a1468a2b3dbc97eae008878ddd6daa93061 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 24 Aug 2022 05:12:44 +0700 Subject: [PATCH 05/24] fix s-curve --- app/Http/Controllers/ActivityController.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index b3805ef..c9d2a7f 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -1,4 +1,4 @@ -whereNull('parent_id') ->orderByRaw('id ASC') ->get(); - + foreach($resultTypeProject as $objRow){ $childActivities = TemplateGantt::where("parent_id", $objRow->id)->count(); $resultNew = Activity::create([ @@ -438,7 +438,7 @@ class ActivityController extends Controller $end = new \DateTime($maxDate); $end2 = new \DateTime($maxDate); $interval = \DateInterval::createFromDateString('1 day'); - $period = new \DatePeriod($begin, $interval, $end); + $period = new \DatePeriod($begin->modify('-1 days'), $interval, $end); $arr_ActualM = []; $tempDate = []; $tempPercentage = []; @@ -461,11 +461,9 @@ class ActivityController extends Controller ->join('m_activity as a', 'a.id', '=', 'ram.activity_id') ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) ->where('a.proyek_id', '=', $keyGantt['proyek_id']) - /* ->whereDate('ram.report_date', $dt->format("Y-m-d")) */ - ->whereDate('ram.report_date', '2021-11-08') + ->whereDate('ram.report_date', $dt->format("Y-m-d")) + /* ->whereDate('ram.report_date', '2021-11-08') */ ->get(); - /* dd($dt->format('Y-m-d')); */ - dd($dataActualM); $dataTempPlan = []; $x = 0; $sumPercentagePlan=0; From cda5ce7337fc4f9ef8510d278c28b7181972cf4b Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 25 Aug 2022 18:29:15 +0700 Subject: [PATCH 06/24] ignore swap file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4bde401..466ebe8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ api-testing.http bootstrap/backup .config-prod.json activity_log.txt +.swp From af28237160dddf08e5e5ec7f61225d82931f4a79 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 25 Aug 2022 18:29:31 +0700 Subject: [PATCH 07/24] remove swap files --- app/Models/.Activity.php.swp | Bin 20480 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/Models/.Activity.php.swp diff --git a/app/Models/.Activity.php.swp b/app/Models/.Activity.php.swp deleted file mode 100644 index 1f10603e10d65dac1b058a297422c9a500943daa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeI2ZEPGz8ON8Dlw6>tFMMbvB&LUxyGvr9Q=pVf?dTG_G%0D_I7yM>aLnDUeQWRS zZgyvrI3biGM1znD;zepHl_*pKDN3aP6^IuJgoN5kln)@%B9&IH_)w4#&@U9e@PB4^ z_RZ(mPIxOCOTS!p=lwskGxIz%?a@Pf_OV+>wj21n#xOoL@lyN8x34ptlZGK&-=fzm z{Y^|x-+AEfsp0oEKR7*kx6El^l8;k{_2aI;5O};}2K6@YESOHW-ki91cvt*??s@fn zZr8Mfdb1;}W0qJP@p|6C4E0N`fL3623WQ>I_|~h9_uRaFloGtVd=tC=x`V4rt7B;e zv;tZIt$>3mHq$sw;RUm z;1%#P_!;;n_yqVcxDDJ0ZUFzd8gap|!LPs*;4|P1u)%fU$*TVS{1p0at+y;Dxss#^c}ta01xidhjYVIuAY#P5{!Z0oH*F(C}&S z6gUUAgA(`)94C*0L*Op(esD7w0b9WqupX=f=io#+0}g>Eco(<*rZJv)EH>Hv_TOIPaZ#sgFF?E%q(U`TIZgoiXtYCON3T|25TJ03n zP;X5?Kq@|GwmjdR^UWYY4nslMpHh!?HY8lZ?cF`g?(QHZGtV-z)wV5X4rO%Q&=J+z z4vLe_f^tkEA)s3J;&Owu+;W^Qj+kr6@t*0MNF|$yHk7xaQiW!rR5Z-ajQTj0 ztyGTW=(gI6QZ*imUbP050@JV7*iM#zF+A?@zR4P_94rRH?3cHZwj{sXc16pxx#M6+ z$*iiZYB{2osR71$hdaC_TgQ^|i3Z4Kvl`pNwvUcRd1lgOx~w$o`X=x6SXG5vX25tL z`#?6d#-J7YJ8n1yXFn}9B7Jw!T*!||^$N|8V;#fj!&q$1aYu+;r$7-{e~|;O1Sn)<t=J{sFqF%1mDm7A?oo2Y$ zW=6xP&|j*MPUdF2v-w+cADHFg~)~uT4t8UqCBSJDUN1R%BGZx6|LG)w#kZzhN$VQoNH`( zY`iRZuuzVdumQT~*UhCF=M+L^0>OpVX*6&#(-da6s@Bq~RDv}84~j!$Eh}-{N2IE% zXT0_du4klRqtV7>D3>h{pR3hjQQ~x;5QWRO9ihxC^KLt6bzR4#;lzW$nsZt`Kl9MX zzQVV-op~i(*A6PQ3vmUe53`H)#Pe|Nl@^b~kgZ;)%8nsKb;w zqpcD1EVE-Wca{Y`OVIR0^4*L$n#;Ah@P+%qB#yUIC%jaDy3@Ac3^zlhWWuOOKKiO?l=zQ3>d9US}3#LEMqe@4* zWHW_eEqn;ka75p=WNb>G-R049W^*kYQFw>3BRBfl%##H}##NgLdRV~y>{j6Vf_7~5 zLjC3zLJE*w99K~)oEfCEmThxdCgo>nsZ}9(JTo17 z9vVDzJMUl-31%jC?N}~K)AyHzO<=ib^T3>$wB4g2tg9JWOcbx_dC_Aqv)`mr)V#kh zo=uiSYs#tT0L?7Rgr!Lh>Ku9Do}~prrQ3GWwR*DuIc(cS*u7-`t8@K7!mj@|I19+` ze;j-RoCIa?H`w%l06ztv11G^W_z<`QOo9pUPH-bw2Yv+G|1t0-;DdX?pJ4x=1^0v9 zU>r2SZ(;9W0KWlGfV02`L*P}|_`d_c0MCG@!6V=yuphh*oBsRY9QZ0wzJNadKM%+c z@I2c42>3j>4}1)q0;IzUp#QW2S^=$qRzNGD75FzOa2l3R>;@7pwoH7nT8nJ!*xdzt zEAe_LTPxbI3pd%wjVSwGS_{enoVc~-UCXJK`>iM)JlSsO!vKPZ2JS^x?vF^fae0g$ zVsmb35z!mOBnOFaiqLl$DhyY;%?0+1)y!@zaS|bK>CQw^^h;?^!3K=%Ol3SXSTC8x zO=Yzu-c|^(dT|oNXYKm<=Fyf)eo=K)Bq*BpLGp4%jrPSG+N?|&bBl^zjan+3%M`5V z=bEv)p+w$m=@kxX(1Zgpq3M$bWnA8^%{KUF4N(*U}|Un)jCRyloKEpk>4 ziM|JSR3|#!sWG^Y$qm13cpVlQo!%7FHP|S*L*(Zhp9SP{K70h0+Yn67xFj|{M$UJX z^?^}1_%k7tjXWzk#_iCAs~&EqFi3_Ly9pMc^tZspOX2(gKb+1) zPW~GC|KkjgibZMQ)6sz}Y-yS?HrVQFG-4NJJTqj5IhnR&_(zq32`4^XL3z=k6}+KY zv85!?fa;K*GmsODyngbOLDo1vVu-s=Mkk-Yia0!O1(SVG&}506lK0R%nn={Akybu- zfEFjn%%MWQreuzjLkfZqn6CE112zE%*wWD^2SRdYmh%Kehh`XoyU0T$m68WB|I&lA zT!}RPa^=asU(Ja_@d%MrRymQ%v7E_wdWrsW^xiVZl6g4ENJP1AuZUNVV7h&5!1HJ_w1CN5QfQNw%EU*>4hWh*xJPW=EsD9I+3jU1x{v7nd zM?e#7058CeItb9josFc@lWt0w*&wH From 72328707e71a22ed67cf0601bacab0df999df451 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 25 Aug 2022 18:30:53 +0700 Subject: [PATCH 08/24] update integration material --- .../Controllers/RequestMaterialController.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/app/Http/Controllers/RequestMaterialController.php b/app/Http/Controllers/RequestMaterialController.php index 3ef51db..693cbae 100644 --- a/app/Http/Controllers/RequestMaterialController.php +++ b/app/Http/Controllers/RequestMaterialController.php @@ -151,4 +151,48 @@ class RequestMaterialController extends Controller return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200); } + + private function curlReq($url, $token){ + $ch = curl_init(); + $headers = [ + 'Authorization: '.$token + ]; + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $response = curl_exec($ch); + if ($response === false) + $response = curl_error($ch); + curl_close($ch); + + return json_decode($response); + } + + public function getMaterialIntegration(Request $request) { + $search = urlencode($request->name); + if(empty($search)) + return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); + $url = str_replace("SEARCH", $search, config('api.adw').'/stock_master?name=SEARCH'); + $token = config('api.adw_token'); + $firstResponse = $this->curlReq($url, $token); + + if($firstResponse->total == 0) + return response()->json(['status'=>'error', 'message' => 'Data not found!', 'code'=>404], 404); + + $data = $firstResponse->data; + $currentPage = 1; + + if($firstResponse->last_page > 0) { + do { + $currentPage++; + $response = $this->curlReq($url.'&page='.$currentPage, $token); + foreach($response->data as $d){ + array_push($data, $d); + } + } while ($currentPage < $firstResponse->last_page); + } + + return response()->json(['status'=>'success', 'data'=> $data, 'total' => count($data), 'code'=>200], 200); + } } From 31823505ebe98b09122329824b09981520c37260 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 25 Aug 2022 18:31:24 +0700 Subject: [PATCH 09/24] update integration material --- config/api.php | 4 +++- routes/web.php | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config/api.php b/config/api.php index dfe274b..4a6fad5 100644 --- a/config/api.php +++ b/config/api.php @@ -1,5 +1,7 @@ env('API_NOMINATIM', 'https://nominatim.oslogdev.com') + 'nominatim' => env('API_NOMINATIM', 'https://nominatim.oslogdev.com'), + 'adw' => env('API_ADW', 'http://ospro-api.adyawinsa.com:9083/api'), + 'adw_token' => env('API_ADW_TOKEN', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxMjAyIiwiZXhwIjoxNjkxODMwNDkzfQ.DvBQIOZsdFndWsliPCZT65Y6G5Xx4vWBKz8Rhe7rvRA') ]; ?> diff --git a/routes/web.php b/routes/web.php index 153d050..92113f4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,13 +97,13 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->put('/project-type/update/{id}', 'ProjectTypeController@update'); $router->delete('/project-type/delete/{id}', 'ProjectTypeController@delete'); $router->get('/project-type/list', 'ProjectTypeController@list'); - + $router->post('/project-phase/search', 'ProjectPhaseController@search'); $router->post('/project-phase/add', 'ProjectPhaseController@add'); $router->get('/project-phase/edit/{id}', 'ProjectPhaseController@edit'); $router->put('/project-phase/update/{id}', 'ProjectPhaseController@update'); $router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete'); - $router->get('/project-phase/list', 'ProjectPhaseController@list'); + $router->get('/project-phase/list', 'ProjectPhaseController@list'); $router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek'); @@ -113,6 +113,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->put('/request-material/update/{id}', 'RequestMaterialController@update'); $router->delete('/request-material/delete/{id}', 'RequestMaterialController@delete'); $router->get('/request-material/list', 'RequestMaterialController@list'); + $router->get('/request-material/get-material-integration', 'RequestMaterialController@getMaterialIntegration'); $router->put('/request-material/update-warehouse-site/{id}', 'RequestMaterialController@updateWarehouseSite'); From ecc6b0a63fbb8d131bfbc8c086f4fd7525d46652 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 30 Aug 2022 23:11:56 +0700 Subject: [PATCH 10/24] remove unused codes --- app/Http/Controllers/ActivityController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index c9d2a7f..19c7182 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -462,7 +462,6 @@ class ActivityController extends Controller ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) ->where('a.proyek_id', '=', $keyGantt['proyek_id']) ->whereDate('ram.report_date', $dt->format("Y-m-d")) - /* ->whereDate('ram.report_date', '2021-11-08') */ ->get(); $dataTempPlan = []; $x = 0; From 9787bf1879bb284d6d296574835613e1d7d92306 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 6 Sep 2022 14:12:52 +0700 Subject: [PATCH 11/24] integration improvement --- app/Http/Controllers/RequestMaterialController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/RequestMaterialController.php b/app/Http/Controllers/RequestMaterialController.php index 693cbae..605cf5f 100644 --- a/app/Http/Controllers/RequestMaterialController.php +++ b/app/Http/Controllers/RequestMaterialController.php @@ -190,7 +190,10 @@ class RequestMaterialController extends Controller foreach($response->data as $d){ array_push($data, $d); } - } while ($currentPage < $firstResponse->last_page); + } while ($currentPage < 5); + // let the user narrow down the search by themself + // a searching action with 'cable' keyword could take minutes + // because there are >1k items associated with that keyword } return response()->json(['status'=>'success', 'data'=> $data, 'total' => count($data), 'code'=>200], 200); From 0a45c5959b3461370442421459155952ba4a70c2 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 7 Sep 2022 17:04:04 +0700 Subject: [PATCH 12/24] implement hierarchy --- app/Http/Controllers/DivisiController.php | 27 ++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index 06a533c..ea7c3d4 100644 --- a/app/Http/Controllers/DivisiController.php +++ b/app/Http/Controllers/DivisiController.php @@ -9,7 +9,8 @@ class DivisiController extends Controller { private function getAllChildren($divisi, $depth = 0, $array = []) { - $array[$divisi->id] = $divisi->name; + $divisi->depth = $depth; + array_push($array, $divisi); foreach($divisi->children as $child){ $array = $this->getAllChildren($child, $depth + 1, $array); } @@ -69,20 +70,10 @@ class DivisiController extends Controller return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200); } - public function search(Request $request) + public function search() { - $payload = $request->all(); - - if($payload['columns'][0]['value'] == "") - $this->list(); - - $dataBuilder = $this->setUpPayload($payload, 'm_divisi'); - $builder = $dataBuilder['builder']; - $countBuilder = $dataBuilder['count']; - $dataGet = $builder->get(); - $totalRecord = $countBuilder->count(); - - return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); + return $this->list(); + // cant use builder for this case } public function list() @@ -91,7 +82,13 @@ class DivisiController extends Controller $divisions = []; foreach($parentMenus as $menu){ $childs = $this->getAllChildren($menu); - $divisions = $divisions + $childs; + foreach($childs as $d){ + $d->displayName = ' ' . $d->name; + for($i=0; $i < $d->depth; $i++){ + $d->displayName = '--' . $d->displayName ; + } + array_push($divisions, $d); + } } $countData = count($divisions); if($countData == 0) From 3555e6c22bbc0e5871d6c3c7b02dcb5d50e63fa1 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 8 Sep 2022 12:02:46 +0700 Subject: [PATCH 13/24] add divisi project field --- app/Models/Project.php | 77 +++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/app/Models/Project.php b/app/Models/Project.php index 5cbc7b4..452dd62 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -6,46 +6,47 @@ use Illuminate\Database\Eloquent\Model; class Project extends Model { - protected $table = 'm_proyek'; + protected $table = 'm_proyek'; - const CREATED_AT = 'created_at'; - const UPDATED_AT = 'updated_at'; + const CREATED_AT = 'created_at'; + const UPDATED_AT = 'updated_at'; - protected $fillable = [ - 'kode_sortname', - 'jumlah_stakeholder', - 'nama', - 'mulai_proyek', - 'akhir_proyek', - 'area_kerja', - 'lokasi_kantor', - 'rencana_biaya', - 'biaya_actual', - 'company', - 'pm_id', - 'type_proyek_id', - 'persentase_progress', - 'keterangan', - 'durasi_proyek', - 'progress_by_worklog', - 'status', - 'currency_simbol', - 'currency_code', - 'currency_name', - 'project_objectives', - 'considered_success_when', - 'potential_risk', - 'testing_environment', - 'currency_code', - 'currency_symbol', - 'currency_name', - 'budget_health', - 'phase_id', - 'created_at', - 'created_by', - 'updated_at', - 'updated_by' - ]; + protected $fillable = [ + 'kode_sortname', + 'jumlah_stakeholder', + 'nama', + 'mulai_proyek', + 'akhir_proyek', + 'area_kerja', + 'lokasi_kantor', + 'rencana_biaya', + 'biaya_actual', + 'company', + 'pm_id', + 'type_proyek_id', + 'divisi_id', + 'persentase_progress', + 'keterangan', + 'durasi_proyek', + 'progress_by_worklog', + 'status', + 'currency_simbol', + 'currency_code', + 'currency_name', + 'project_objectives', + 'considered_success_when', + 'potential_risk', + 'testing_environment', + 'currency_code', + 'currency_symbol', + 'currency_name', + 'budget_health', + 'phase_id', + 'created_at', + 'created_by', + 'updated_at', + 'updated_by' + ]; } From 9e15bc725a8d5a15e40cdffb064dac61c9eab242 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 15 Sep 2022 15:02:12 +0700 Subject: [PATCH 14/24] WIP: HR integration --- .../Controllers/UserToProyekController.php | 51 +++++++++++++++++-- routes/web.php | 1 + 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/UserToProyekController.php b/app/Http/Controllers/UserToProyekController.php index 25cb2ce..fecdfec 100644 --- a/app/Http/Controllers/UserToProyekController.php +++ b/app/Http/Controllers/UserToProyekController.php @@ -59,8 +59,8 @@ class UserToProyekController extends Controller return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400); die(); } - - + + if($result){ return response()->json(['status'=>'success','message'=>'data assign hr to proyek successfully updated!','code'=>200], 200); }else{ @@ -82,7 +82,7 @@ class UserToProyekController extends Controller return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400); die(); } - + if($delete){ return response()->json(['status'=>'success','message'=>'data assign hr to proyek successfully deleted!','code'=>200], 200); @@ -166,4 +166,49 @@ class UserToProyekController extends Controller return response()->json($data); } + + private function curlReq($url, $token){ + $ch = curl_init(); + $headers = [ + 'Authorization: '.$token + ]; + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $response = curl_exec($ch); + if ($response === false) + $response = curl_error($ch); + curl_close($ch); + + return json_decode($response); + } + + public function getEmployeeIntegration(Request $request) { + $search = urlencode($request->name); + if(empty($search)) + return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); + $url = str_replace("SEARCH", $search, config('api.adw').'/employees?emp_name=SEARCH'); + $token = config('api.adw_token'); + $firstResponse = $this->curlReq($url, $token); + + if($firstResponse->total == 0) + return response()->json(['status'=>'error', 'message' => 'Data not found!', 'code'=>404], 404); + + $data = $firstResponse->data; + return response()->json([$data]); + $currentPage = 1; + + if($firstResponse->last_page > 0) { + do { + $currentPage++; + $response = $this->curlReq($url.'&page='.$currentPage, $token); + foreach($response->data as $d){ + array_push($data, $d); + } + } while ($currentPage < $firstResponse->last_page); + } + + return response()->json(['status'=>'success', 'data'=> $data, 'total' => count($data), 'code'=>200], 200); + } } diff --git a/routes/web.php b/routes/web.php index 92113f4..16d4786 100644 --- a/routes/web.php +++ b/routes/web.php @@ -359,6 +359,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->delete('/user-to-proyek/delete/{id}', 'UserToProyekController@delete'); $router->get('/user-to-proyek/list', 'UserToProyekController@list'); $router->get('/user-to-proyek/select', 'UserToProyekController@select'); + $router->get('/user-to-proyek/get-employee-integration', 'UserToProyekController@getEmployeeIntegration'); $router->post('/folder-document-proyek/add', 'FolderDocumentProyekController@add'); $router->get('/folder-document-proyek/edit/{id}', 'FolderDocumentProyekController@edit'); From 6d1fcfe38bdef7ab7d7c15efecec9e268e0b12f9 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 15 Sep 2022 15:20:15 +0700 Subject: [PATCH 15/24] remove unrelated things --- app/Http/Controllers/DashboardController.php | 218 ------------------- app/Http/Controllers/ProjectController.php | 38 +--- routes/web.php | 6 - 3 files changed, 11 insertions(+), 251 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 2623b1c..6240a74 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -2,224 +2,6 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; -use App\Models\Project; -use App\Models\Activity; -use App\Models\ReportActivity; -use App\Models\Role; - class DashboardController extends Controller { - public function costPlanningActual(Request $request) - { - $dataPayload = $request->all(); - $dataMaxVersionGantt = []; - foreach ($dataPayload['project_id'] as $val) { - $dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); - } - - $dataFinal=[]; - foreach ($dataMaxVersionGantt as $val) { - $data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.rencana_biaya', 'm_activity.biaya_actual', 'mp.nama as proyek_name')->join("m_proyek as mp", "m_activity.proyek_id", "=", "mp.id")->where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->orderBy('id', 'asc')->get(); - $dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); - } - - if(!$dataFinal) - return response()->json(['status'=>'failed','message'=>'Data not found','code'=> 404], 404); - - return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); - } - - public function getMaxVersionGantt($id){ - $data = Activity::select(Activity::raw('MAX(version_gantt_id) as last_version_gantt'))->where("proyek_id", $id)->first(); - return array("last_version_gantt"=>$data->last_version_gantt, "proyek_id" => $id, "proyek_name" => $data->proyek_name); - } - - public function percentagePlanningActual(Request $request) - { - $dataPayload = $request->all(); - $dataMaxVersionGantt = []; - foreach ($dataPayload['project_id'] as $val) { - $dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); - } - $dataFinal=[]; - foreach ($dataMaxVersionGantt as $val) { - $data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.persentase_progress', 'm_activity.persentase_bobot', 'm_activity.bobot_planning', 'mp.nama as proyek_name')->join("m_proyek as mp", "m_activity.proyek_id", "=", "mp.id")->where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->orderBy('id', 'asc')->get(); - $dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); - } - - if(!$dataFinal) - return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); - - return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); - } - - public function list() - { - $data = Role::all(); - $countData = $data->count(); - - if(!$data) - return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); - - return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); - } - - public function getActivityByProjectId($projectId) { - $output = []; - $data = Activity::select('id')->where('proyek_id', $projectId)->get(); - foreach ($data as $actData) { - $output[] = $actData->id; - } - return $output; - } - - /* - const statusProyek = [ - { - "id": "1", - "proyek_name": "Pembuatan Aplikasi Survey Covid Varian Baru", // ambil dari m_proyek - "total_task": 80, // ambil dari m_activity -> SUM(jumlah_pekerjaan) where proyek_id berdasarkan proyek_id terpilih - "task_on_progress": 60, // ambil dari report_activity -> SUM(job_count_report) where activity_id berdasarkan activity_id terpilih - "day_left": 7, // ambil dari m_proyek, cari sisa hari (end_date - hari ini) - "percentage": 75 // (task_on_progress / total_task * 100) - }, - { - "id": "2", - "proyek_name": "Pembangunan Jembatan Layang", - "total_task": 70, // SELECT SUM(jumlah_pekerjaan) FROM public.m_activity WHERE proyek_id IN (11); - "task_on_progress": 70, // SELECT SUM(job_count_report) FROM public.report_activity WHERE activity_id IN (349, 355); - "day_left": 0, - "percentage": 100 - }, - ... - ] - */ - public function statusProyek(Request $request) { - $dataPayload = $request->all(); - $reqProject = $dataFinal = []; - - if (!isset($dataPayload['project_id'])) - return response()->json(['status'=>'failed','message'=>'Undefined project_id','code'=>400], 400); - - foreach ($dataPayload['project_id'] as $val) { - $prj["project_id"] = $val; - $prj["activity_id"] = $this->getActivityByProjectId($val); - $reqProject[] = $prj; - } - - if (count($reqProject) > 0) { - $row = []; - - for ($i=0; $i < count($reqProject); $i++) { - $dataMaxVersionGantt = Activity::select(Activity::raw('MAX(version_gantt_id) as last_version_gantt'))->where("proyek_id", $reqProject[$i]['project_id'])->first(); - $last_version_gantt = $dataMaxVersionGantt->last_version_gantt; - $queryProject = Project::select('id', 'nama', 'mulai_proyek', 'akhir_proyek')->where('id',$reqProject[$i]['project_id'])->first(); - $sum_jumlah_pekerjaan = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->sum("jumlah_pekerjaan"); - $count_activity = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->count("id"); - $count_activity_done = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('persentase_progress', '100')->where('version_gantt_id', $last_version_gantt)->count("id"); - $count_progress_percentage = Activity::where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->count("persentase_progress"); - $progress_actual = Activity::select('id', 'bobot_planning', 'persentase_progress')->where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->get(); - $current_progress = 0; - - foreach($progress_actual as $objRow) { - $current_progress += ($objRow->bobot_planning * $objRow->persentase_progress) / 100; - } - if (count($reqProject[$i]['activity_id']) > 0) { - for ($j=0; $j < count($reqProject[$i]['activity_id']); $j++) { - $sum_job_count_report = ReportActivity::whereIn('activity_id', $reqProject[$i]['activity_id'])->sum("job_count_report"); - } - } - if (!isset($queryProject->id)) - return response()->json(['status'=>'failed','message'=>'Project with id='.$reqProject[$i]['project_id'].' is not found!','code'=>400], 400); - - $now = time(); - $akhir_proyek = strtotime($queryProject->akhir_proyek); - $datediff = $akhir_proyek - $now; - - $mulai_proyek = strtotime($queryProject->mulai_proyek); - $total_kontrak = $akhir_proyek - $mulai_proyek; - - $row["id"] = $queryProject->id; - $row["proyek_name"] = $queryProject->nama; - $row["mulai_proyek"] = $queryProject->mulai_proyek; - $row["akhir_proyek"] = $queryProject->akhir_proyek; - $row["total_kontrak"] = round($total_kontrak / (60 * 60 * 24)); - $row["total_task"] = $sum_jumlah_pekerjaan; - $row["task_on_progress"] = $sum_job_count_report; - $row["count_activity"] = $count_activity; - $row["count_activity_done"] = $count_activity_done; - $row["day_left"] = round($datediff / (60 * 60 * 24)); - $row["percentage"] = round($current_progress,3); - $row["count_progress_percentage"] = $count_progress_percentage; - - $dataFinal[] = $row; - } - } - - if(empty($dataFinal)) - return response()->json(['status'=>'failed','message'=>'failed get status proyek, please try again later!','code'=>400], 400); - - return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>count($dataFinal)], 200); - } - - public function curvaS(Request $request) - { - $dataPayload = $request->all(); - $dataMaxVersionGantt = []; - $dataFinal=[]; - - foreach ($dataPayload['project_id'] as $val) { - $dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); - } - - foreach ($dataMaxVersionGantt as $val) { - $data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.persentase_progress', 'm_activity.persentase_bobot', 'm_activity.bobot_planning', 'm_activity.biaya_actual', 'mp.nama as proyek_name')->join("m_proyek as mp", "m_activity.proyek_id", "=", "mp.id")->where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->orderBy('id', 'asc')->get(); - $totalCostPlanning = Activity::where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->sum('rencana_biaya'); - - for ($i=0; $i < count($data); $i++) { - $tmpp = $tmpa = $tmpbc = $tmpac = 0; - for ($x=$i; $x >= 0 ; $x--) { - $tmpp += $data[$x]['bobot_planning']; - $tmpa += ($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100; - $tmpbc += ((($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100)*$totalCostPlanning)/100; - $tmpac += $data[$x]['biaya_actual']; - } - - $data[$i]['cal_bobot_p'] = round($tmpp,2); - - if($i > 0 ){ - if($data[$i-1]['cal_bobot_a'] != null){ - if($data[$i-1]['cal_bobot_a'] == round($tmpa,2)){ - $data[$i]['cal_bobot_a'] = null; - }else{ - $data[$i]['cal_bobot_a'] = round($tmpa,2); - } - }else{ - $data[$i]['cal_bobot_a'] = null; - } - if($data[$i-1]['cal_actual_cost'] != null){ - if($data[$i-1]['cal_actual_cost'] == round($tmpac,2)){ - $data[$i]['cal_actual_cost'] = null; - }else{ - $data[$i]['cal_actual_cost'] = round($tmpac,2); - } - }else{ - $data[$i]['cal_actual_cost'] = null; - } - }else{ - $data[$i]['cal_bobot_a'] = round($tmpa,2); - $data[$i]['cal_actual_cost'] = round($tmpac,2); - } - $data[$i]['cal_budget_cost'] = round($tmpbc,2); - } - - $dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); - } - - if(!$dataFinal) - return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); - - return response()->json(['status'=>'success','code'=>200, 'data'=>$dataFinal, 'totalRecord'=>1], 200); - } } diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index c53764d..4c18e2c 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -332,16 +332,16 @@ class ProjectController extends Controller 'mp.rencana_biaya', 'mp.company', 'mp.currency_symbol', 'mu.name as pm', 'mp.budget_health') ->join('m_users as mu', 'mu.id', '=', 'mp.pm_id') ->where('mp.id', $id) - ->get(); - $countData = $data->count(); + ->first(); + + if(!$data) + return response()->json(['status'=>'failed','message'=>'Data tidak ditemukan!','code'=> 404], 404); $manpowers = UserToProyek::where('proyek_id', $id)->count(); $rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); - if($rootActivity){ - $actualCost = $rootActivity->biaya_actual ?? 0; - $progress = $rootActivity->persentase_progress ?? 0; - } + $actualCost = @$rootActivity->biaya_actual ?? 0; + $progress = @$rootActivity->persentase_progress ?? 0; $commentActivity = DB::table('m_comment_activity as mca') ->select('mca.activity_id', 'mca.comment as comment', 'mca.created_by as comment_by', 'mca.created_at as comment_created', @@ -352,28 +352,12 @@ class ProjectController extends Controller ->take(2) ->get(); - foreach ($data as $val) { - $dataRes['kode_sortname'] = $val->kode_sortname; - $dataRes['name_project'] = $val->name_project; - $dataRes['start'] = $val->start; - $dataRes['finish'] = $val->finish; - $dataRes['rencana_biaya'] = $val->rencana_biaya; - $dataRes['company'] = $val->company; - $dataRes['currency_symbol'] = $val->currency_symbol; - // get firstname - $arr = explode(" ", $val->pm); - $dataRes['pm'] = $arr[0]; - $dataRes['budget_health'] = $val->budget_health; - $dataRes['actual_cost'] = $actualCost; - $dataRes['progress'] = $progress; - $dataRes['comment'] = $commentActivity; - $dataRes['man_power'] = $manpowers; - } - - if(!$data) - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); + $data->actual_cost = $actualCost; + $data->progress = $progress; + $data->comment = $commentActivity; + $data->man_power = $manpowers; - return response()->json(['status'=>'success','code'=>200,'data'=>$dataRes, 'totalRecord'=>$countData], 200); + return response()->json(['status'=>'success','code'=>200,'data'=> $data], 200); } private function httpReq($search){ diff --git a/routes/web.php b/routes/web.php index 16d4786..55fee29 100644 --- a/routes/web.php +++ b/routes/web.php @@ -285,12 +285,6 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->get('/project-milestone/select', 'ProjectMileStoneController@select'); $router->get('/project-milestone/{where}/{val}', 'ProjectMileStoneController@customWhere'); - $router->post('/dashboard/cost-planning-actual', 'DashboardController@costPlanningActual'); - $router->post('/dashboard/percentage-planning-actual', 'DashboardController@percentagePlanningActual'); - $router->post('/dashboard/search-user-presence', 'DashboardController@searchUserPresencePoints'); - $router->post('/dashboard/status-proyek', 'DashboardController@statusProyek'); - $router->post('/dashboard/curva-s', 'DashboardController@curvaS'); - $router->post('/report-activity/add', 'ReportActivityController@add'); $router->get('/report-activity/edit/{id}', 'ReportActivityController@edit'); $router->put('/report-activity/update/{id}', 'ReportActivityController@update'); From 31144174d31ba2939209dbcc76a0ba934f9e6c5a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 15 Sep 2022 15:25:22 +0700 Subject: [PATCH 16/24] remove unrelated things --- app/Http/Controllers/DashboardController.php | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 app/Http/Controllers/DashboardController.php diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php deleted file mode 100644 index 6240a74..0000000 --- a/app/Http/Controllers/DashboardController.php +++ /dev/null @@ -1,7 +0,0 @@ - Date: Tue, 20 Sep 2022 14:48:05 +0700 Subject: [PATCH 17/24] WIP: Dashboard BoD --- .../Controllers/DashboardBoDController.php | 170 ++++++++++++++++++ routes/web.php | 10 ++ 2 files changed, 180 insertions(+) create mode 100644 app/Http/Controllers/DashboardBoDController.php diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php new file mode 100644 index 0000000..ec845e2 --- /dev/null +++ b/app/Http/Controllers/DashboardBoDController.php @@ -0,0 +1,170 @@ +interpolateYear($year); + + // we can't use eloquent's sum() method because someone decided to use varchar as datatype in rencana_biaya field + $totalBudgets = Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) + ->where('mulai_proyek', 'like', $year) + ->pluck('sum') + ->first(); + + return response()->json([ + 'data' => [ + 'total_budget' => (int) $totalBudgets ?? rand(0,10), + 'total_expenditure' => rand(0,10), // to do integrasi + 'total_invoice' => rand(0,10), + 'total_paid_invoice' => rand(0,10), + ] + ], 200); + } + + public function getProjectPerScheduleHealth($year = '%'){ + $year = $this->interpolateYear($year); + // get data plan (vol) in % + // get data actual in % + return response()->json([ + 'data' => [ + 'behind-schedule' => rand(0,10), + 'warning' => rand(0,10), + 'on-schedule' => rand(0,10), + ] + ], 200); + } + + public function getProjectScheduleHealthPerDivision($year = '%'){ + $year = $this->interpolateYear($year); + + $divisions = Divisi::whereNull('parent')->get(); + foreach($divisions as $division){ + $scheduleData = new Collection(); + $scheduleData->prepend(rand(0, 10), 'behindSchedule'); + $scheduleData->prepend(rand(0, 10), 'warning'); + $scheduleData->prepend(rand(0, 10), 'onSchedule'); + $division->scheduleData = $scheduleData; + } + return response()->json([ + 'data' => [ + $divisions + ] + ], 200); + } + + public function getProjectPerBudgetHealth($year = '%'){ + $year = $this->interpolateYear($year); + return response()->json([ + 'data' => [ + 'overrun' => rand(0,10), + 'warning' => rand(0,10), + 'on-budget' => rand(0,10), + ] + ], 200); + } + + public function getProjectBudgetHealthPerDivision($year = '%'){ + $year = $this->interpolateYear($year); + + $divisions = Divisi::whereNull('parent')->get(); + foreach($divisions as $division){ + $budgetData = new Collection(); + $budgetData->prepend(rand(0, 10), 'overrun'); + $budgetData->prepend(rand(0, 10), 'warning'); + $budgetData->prepend(rand(0, 10), 'onBudget'); + $division->budgetData = $budgetData; + } + return response()->json([ + 'data' => [ + $divisions + ] + ], 200); + } + + public function getProjectPerPhase($year = '%'){ + $year = $this->interpolateYear($year); + $projectPhases = ProjectPhase::orderBy('order')->get(); + foreach($projectPhases as $phase){ + $phase->totalProject = rand(0,10); + } + return response()->json([ + 'data' => [ + $projectPhases + ] + ], 200); + } + + private function countTotalProjectInDivision($id, $year){ + return Project::where('divisi_id', $id) + ->where('mulai_proyek', 'like', $year) + ->count(); + } + + public function getTotalProjectPerDivision($year = '%') { + $year = $this->interpolateYear($year); + + $totalProjectPerDivision = Divisi::select('id','name') + ->with('children') + ->whereNull('parent') + ->get(); + + // to do : count in more than 1 level child + foreach($totalProjectPerDivision as $v){ + $v->total = $this->countTotalProjectInDivision($v->id, $year); + foreach($v->children as $d){ + $v->total += $this->countTotalProjectInDivision($d->id, $year); + } + unset($v->children); + } + + return response()->json([ + 'data' => $totalProjectPerDivision + ], 200); + } + + private function countTotalProjectValueInDivision($id, $year){ + return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) + ->where('mulai_proyek', 'like', $year) + ->where('divisi_id', $id) + ->pluck('sum') + ->first(); + } + + public function getTotalProjectValuePerDivision($year = '%') { + $year = $this->interpolateYear($year); + + $totalProjectValuePerDivision = Divisi::select('id','name') + ->with('children') + ->whereNull('parent') + ->get(); + + // to do : count in more than 1 level child + foreach($totalProjectValuePerDivision as $v){ + $v->total = $this->countTotalProjectValueInDivision($v->id, $year); + foreach($v->children as $d){ + $v->total += $this->countTotalProjectValueInDivision($d->id, $year); + } + unset($v->children); + } + + return response()->json([ + 'data' => $totalProjectValuePerDivision + ], 200); + } + +} + diff --git a/routes/web.php b/routes/web.php index 55fee29..b636078 100644 --- a/routes/web.php +++ b/routes/web.php @@ -23,6 +23,16 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { + $router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure + $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in + $router->get('/dashboard/get-project-per-schedule-health[/{year}]', 'DashboardBoDController@getProjectPerScheduleHealth'); + $router->get('/dashboard/get-project-per-budget-health[/{year}]', 'DashboardBoDController@getProjectPerBudgetHealth'); + $router->get('/dashboard/get-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getProjectScheduleHealthPerDivision'); + $router->get('/dashboard/get-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getProjectBudgetHealthPerDivision'); + $router->get('/dashboard/get-project-per-phase[/{year}]', 'DashboardBoDController@getProjectPerPhase'); // todo + $router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision'); // done + $router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision'); // done + $router->post('/role/search', 'RoleController@search'); $router->post('/role/add', 'RoleController@add'); $router->get('/role/edit/{id}', 'RoleController@edit'); From 91728ecdc6495326d67f9123f32f4e0816360e5d Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 14 Mar 2023 14:50:41 +0700 Subject: [PATCH 18/24] update conflict --- app/Http/Controllers/ActivityController.php | 295 ++++++++++++-------- 1 file changed, 180 insertions(+), 115 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 0af8028..19c7182 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -3,11 +3,14 @@ namespace App\Http\Controllers; use App\Models\Activity; use App\Models\CommentActivity; +use App\Models\Holiday; use App\Models\Link; use App\Models\Project; +use App\Models\ReportActivity; use App\Models\TemplateGantt; -use App\Models\VersionGantt; use App\Models\UserToActivity; +use App\Models\VersionGantt; +use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; class ActivityController extends Controller @@ -25,17 +28,14 @@ class ActivityController extends Controller private function getDataActivity($id) { - $checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count(); $finalData = []; + $checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count(); $finalData = []; if($checkHeader > 0){ $dataHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->first(); $startDate = date_create($dataHeader->start_date); $endDate = date_create($dataHeader->end_date); $dataHeader->start_date = date_format($startDate,"Y-m-d H:i:s"); $dataHeader->end_date = date_format($endDate,"Y-m-d H:i:s"); - $dataHeader->progress = $dataHeader->persentase_progress / 100; - $dataHeader->planned_start = isset($dataHeader->planned_start) ? date_format(date_create($dataHeader->planned_start),"Y-m-d H:i:s") : NULL; - $dataHeader->planned_end = isset($dataHeader->planned_end) ? date_format(date_create($dataHeader->planned_end),"Y-m-d H:i:s") : NULL; - $dataHeader->type = "header"; + $dataHeader->type = "project"; $dataHeader->text = $dataHeader->name; $finalData[] = $dataHeader; $data = Activity::where('version_gantt_id', $id)->where('parent_id', $dataHeader->id)->orderBy('id', 'asc')->get(); @@ -45,22 +45,20 @@ class ActivityController extends Controller foreach($data as $objRow){ $type = "project"; - $dataChildren = $this->getChildren($id, $objRow->id); - $startDate = date_create($objRow->start_date); - $endDate = date_create($objRow->end_date); - if($objRow->type_activity=="milestone") $type = $objRow->type_activity; if(empty($dataChildren)) $type = "task"; - $objRow->text = $objRow->name; $objRow->parent = $objRow->parent_id ? $objRow->parent_id : null; + $startDate = date_create($objRow->start_date); + $endDate = date_create($objRow->end_date); $objRow->start_date = date_format($startDate,"Y-m-d H:i:s"); $objRow->end_date = date_format($endDate,"Y-m-d H:i:s"); $objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start),"Y-m-d H:i:s") : NULL; $objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end),"Y-m-d H:i:s") : NULL; - $objRow->progress = $objRow->persentase_progress / 100; + $objRow->progress = (int) $objRow->persentase_progress / 100; + $dataChildren = $this->getChildren($id, $objRow->id); $objRow->type = $type; $finalData[] = $objRow; $finalData = array_merge($finalData, $dataChildren); @@ -188,10 +186,7 @@ class ActivityController extends Controller $parent = $data['parent_id'] ?? null; if($parent){ - $parentData = Activity::find($parent); - if($parentData->parent_id) { - $parentData->update(["type_activity" => "project"]); - } + Activity::find($parent)->update(["type_activity"=>"project"]); CommentActivity::where('activity_id', $parent)->delete(); UserToActivity::where('activity_id', $parent)->delete(); } @@ -217,11 +212,16 @@ class ActivityController extends Controller if(empty($id) || !is_int((int)$id)) return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400); - $updateBobot = true; + $updateBobot = false; if(!$data = Activity::find($id)) return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404); $dataUpdate = $request->all(); + $oldRencanaBiaya = $data->rencana_biaya; + $newRencanaBiaya = str_replace(",",".",$request->rencana_biaya); + if($oldRencanaBiaya != $newRencanaBiaya) + $updateBobot = true; + $dataUpdate['name'] = $request->text; $dataUpdate['persentase_progress'] = $request->progress*100; $dataUpdate['updated_by'] = $this->currentName; @@ -278,37 +278,115 @@ class ActivityController extends Controller $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); - } + } - public function import(Request $request) + public function getPercentagePerDay(Request $request) { - $data = $request->all(); + $dataPayload = $request->all(); + $allGantt = []; + foreach ($dataPayload['project_id'] as $val) { + $allGantt[] = $this->getLatestGantt($val); + } + + $dataFinal=[]; + foreach ($allGantt as $val) { + $dataProject = Project::find($val['proyek_id']); + $holidays = Holiday::where("version_gantt_id", $val['last_gantt_id'])->where("proyek_id", $val['proyek_id'])->get(); + $dateHoliday = []; //$holiday->all(); + foreach ($holidays as $holiday) { + $startH = new \DateTime($holiday->date); + $endH = clone $startH; + $endH->modify('+'.$holiday->duration.' day'); + $intervalH = \DateInterval::createFromDateString('1 day'); + $periodH = new \DatePeriod($startH, $intervalH, $endH); + foreach ($periodH as $dt) { + $dateHoliday[] = $dt->format("Y-m-d"); + } + } + $verGantt = VersionGantt::find($val['last_gantt_id']); + $configOff = $verGantt->config_dayoff; + if($configOff && $configOff!= ""){ + $dayOff = explode(",", $verGantt->config_dayoff); + $dayOff = array_map( + function($value) { return (int)$value; }, + $dayOff + ); + }else{ + $dayOff = []; + } + $checkHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->count(); + if($checkHeader > 0){ + $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); + $minDate = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->min("start_date"); + $maxDate = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->max("end_date"); + }else{ + $minDate = Activity::whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->min("start_date"); + $maxDate = Activity::whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->max("end_date"); + } + + $begin = new \DateTime($minDate); + $end = new \DateTime($maxDate); + $end = $end->modify( '+1 day' ); + $interval = \DateInterval::createFromDateString('1 day'); + $period = new \DatePeriod($begin, $interval, $end); + $checkHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->count(); + if($checkHeader > 0){ + $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); + $totalRencanaBudget = Activity::select(DB::raw('sum(cast(rencana_biaya as integer))'))->where('parent_id', $dataHeader->id)->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); + }else{ + $totalRencanaBudget = Activity::select(DB::raw('sum(cast(rencana_biaya as integer))'))->whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); + } + + $totalRencanaBudget = $totalRencanaBudget->sum; + $currentPercentage = 0; + $dataDate = []; + $dataPercen = []; + foreach ($period as $dt) { + $weekDay = $dt->format("w"); + $currentDate = $dt->format("Y-m-d"); + if(!in_array($weekDay, $dayOff) && !in_array($currentDate, $dateHoliday)) + { + $totalPercentage = 0; + $checkHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->count(); + if($checkHeader > 0){ + $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); + $dataActivity = Activity::whereRaw("'".$currentDate."' BETWEEN DATE(m_activity.start_date) AND DATE(m_activity.end_date)")->where('parent_id', $dataHeader->id)->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->get(); + }else{ + $dataActivity = Activity::whereRaw("'".$currentDate."' BETWEEN DATE(m_activity.start_date) AND DATE(m_activity.end_date)")->whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->get(); + } + + foreach ($dataActivity as $activity) { + $duration = $activity->duration; + if($totalRencanaBudget > 0 && $duration > 0){ + $totalPercentage = $totalPercentage + ((($activity->rencana_biaya/$totalRencanaBudget)*100)/$duration); + } + } + $currentPercentage = $currentPercentage + $totalPercentage; + $dataDate[] = $currentDate; + $dataPercen[] = $currentPercentage; + }else{ + $dataDate[] = $currentDate; + $dataPercen[] = "dateOff"; + } + } + $dataPercentage = array( + "date"=>$dataDate, + "percentage"=>$dataPercen + ); + $dataFinal[] = array( + "proyek_name"=> $dataProject->nama, + "data"=>$dataPercentage + ); + } + + if($dataFinal){ + return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get list percentage day, please try again later!','code'=>400], 400); + } + } - $data['created_by'] = $this->currentName; - Activity::where('version_gantt_id', $data['ganttId'])->delete(); - - $projectId = VersionGantt::where('id', $data['ganttId'])->first()->proyek_id; - - $activityStack = []; - - foreach ($data['activities'] as $i => $activity_row) { - $startDate = \DateTime::createFromFormat('d-m-y', $activity_row['start_date']); - $endDate = \DateTime::createFromFormat('d-m-y', $activity_row['end_date']); - -<<<<<<< HEAD - $input['name'] = $activity_row['name']; - $input['proyek_id'] = $projectId; - $input['version_gantt_id'] = $data['ganttId']; - $input['parent_id'] = null; - $input['start_date'] = $startDate->format('Y-m-d'); - $input['end_date'] = $endDate->format('Y-m-d'); - $input['duration'] = $activity_row['duration']; - $input['bobot_planning'] = $activity_row['weight']; - $input['persentase_progress'] = 0; - $input['type_activity'] = $i == 0 ? "header" : "task"; - $input['created_by'] = $this->currentName; -======= public function getCalculateCurvaS(Request $request) // for adw (plan & actual == date) { DB::enableQueryLog(); @@ -325,26 +403,13 @@ class ActivityController extends Controller foreach ($allGantt as $keyGantt) { $dataProject = Project::find($keyGantt['proyek_id']); $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->first(); ->>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 - - if (!$activity = Activity::create($input)) { - Activity::where('version_gantt_id', $data['ganttId'])->delete(); - return response()->json(['status' => 'error', 'message' => 'Input failed on ' . $activity['name'], 'code' => 500], 500); - } - -<<<<<<< HEAD - $data['activities'][$i]['activity_id'] = $activity->id; - if ($i == 0) { - $activity->type_activity = "project"; - $activity->save(); - $activity->level = $activity_row['level']; - array_push($activityStack, $activity); - continue; + if($dataHeader){ + $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); + }else{ + $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); } - $activity->level = $activity_row['level']; -======= if(!Activity::where("version_gantt_id", $keyGantt['last_gantt_id'])->first()) continue; @@ -524,67 +589,67 @@ class ActivityController extends Controller return response()->json(['status'=>'success','code'=>200, 'data' => $dataFinal], 200); } ->>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 - - if ($lastStack = end($activityStack)) { - $levelLowerThanLastStack = $activity->level < $lastStack->level; - $levelEqualWithLastStack = $activity->level == $lastStack->level; - - if ($levelLowerThanLastStack) { - $lastStackIsNotRight = $levelLowerThanLastStack; - do { - array_pop($activityStack); - $lastStack = end($activityStack); - if ($activity->level > $lastStack->level) - $lastStackIsNotRight = false; - } while ($lastStackIsNotRight); - } - if ($levelEqualWithLastStack) { - array_pop($activityStack); - } - } + private function getLatestGantt($id){ + $maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); + $data = array( + "last_gantt_id" => $maxGanttId, + "proyek_id" => $id + ); + return $data; + } - $activity->parent_id = $activityStack[count($activityStack) - 1]->id ?? null; - // there should be better way to except / filter attribute level before save because it's cause error - // cant use except() / filter() on $activity collection somehow - unset($activity->level); - $activity->save(); - $activity->level = $activity_row['level']; + public function setBaseline($gantt_id) + { + $activities = Activity::where("version_gantt_id", $gantt_id)->get(); - if (@$activityStack[count($activityStack) - 1]->level != $activity->level && $activity->level != $data['activities'][$i - 1]['level']) { - array_push($activityStack, $activity); - } + foreach ($activities as $activity) { + $activity->update([ + "planned_start"=>$activity->start_date, + "planned_end"=>$activity->end_date, + ]); + } - if ($activity->level < @$data['activities'][$i + 1]['level']) { - unset($activity->level); - $activity->type_activity = "project"; - $activity->save(); - $activity->level = $activity_row['level']; + return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); + } + + public function synchronizeReport($gantt_id) + { + $activities = Activity::where("version_gantt_id", $gantt_id)->get(); + $reports = []; + + foreach($activities as $activity) { + $activity_id = $activity->id; + $countReports = ReportActivity::where('activity_id', $activity_id)->count(); + if ($countReports === 1) { + $dataReports = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->get(); + foreach($dataReports as $dr) { + $reports[] = array( + 'activity_id'=>$activity_id, + 'min_date'=>$dr->report_date, + 'max_date'=>date_modify(date_create($dr->report_date), "1 days") + ); + } } + if ($countReports > 1) { + $firstReport = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->first(); + $lastReport = ReportActivity::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); + $reports[] = array( + 'activity_id'=>$activity_id, + 'min_date'=>$firstReport->report_date, + 'max_date'=>date_modify(date_create($lastReport->report_date), "1 days") + ); - if (!empty($activity_row['predecessor'])) { - $key = array_search($activity_row['predecessor'], array_column($data['activities'], 'no')); - - if (!$predecessorActivity = Activity::find($data['activities'][$key]['activity_id'])) - continue; - - $predecessorFinishDate = new \DateTime($predecessorActivity->end_date); - $interval = $predecessorFinishDate->diff(new \DateTime($activity->start_date)); - $diff = $interval->days; - - Link::create([ - 'created_by' => $this->currentName, - 's_activity_id' => $predecessorActivity->id, - 't_activity_id' => $activity->id, - 'type_link' => 0, - 'code_link' => 'FS', - 'version_gantt_id' => $data['ganttId'], - 'lag' => $diff > 1 ? $diff : null, - ]); } } - return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200); - } + for ($i=0; $i < count($reports); $i++) { + $activity = Activity::find($reports[$i]['activity_id']); + $activity->start_date = $reports[$i]['min_date']; + $activity->end_date = $reports[$i]['max_date']; + $activity->save(); + } + + return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); + } } From cd915f2c9bc2aa002a365ede2daabbe3b4b4b689 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 14 Mar 2023 20:04:19 +0700 Subject: [PATCH 19/24] update conflict --- routes/web.php | 451 +++---------------------------------------------- 1 file changed, 22 insertions(+), 429 deletions(-) diff --git a/routes/web.php b/routes/web.php index 88753d0..b636078 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,38 +1,27 @@ get('/', function () use ($router) { - return $router->app->version(); + return $router->app->version(); }); $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($router) { - $router->post('/login', 'AuthController@login'); - - $router->post('/menu/add', 'MenuController@add'); - $router->get('/menu/edit/{id}', 'MenuController@edit'); - $router->put('/menu/update/{id}', 'MenuController@update'); - $router->delete('/menu/delete/{id}', 'MenuController@delete'); - $router->post('/menu/search', 'MenuController@search'); - $router->get('/menu/management/{id}', 'MenuController@listMenu'); - $router->get('/menu/list', 'MenuController@list'); - $router->post('/role-menu/add', 'RoleMenuController@add'); - $router->put('/role-menu/update/{id}', 'RoleMenuController@update'); - $router->delete('/role-menu/delete/{id}', 'RoleMenuController@delete'); - $router->delete('/role-menu/delete-byrole/{id}', 'RoleMenuController@deleteByRole'); - $router->post('/role-menu/search', 'RoleMenuController@search'); - $router->get('/role-menu/get-role/{id}', 'RoleMenuController@listMenu'); - - $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { - - $router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure - $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in - $router->get('/dashboard/get-total-project-per-schedule-health[/{year}]', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); - $router->get('/dashboard/get-total-project-per-budget-health[/{year}]', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); - $router->get('/dashboard/get-total-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); - $router->get('/dashboard/get-total-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision'); - $router->get('/dashboard/get-total-project-per-phase[/{year}]', 'DashboardBoDController@getTotalProjectPerPhase'); - $router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision'); - $router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision'); - $router->get('/dashboard/get-detail-expenditure[/{year}]', 'DashboardBoDController@getDetailExpenditure'); + $router->post('/login', 'AuthController@login'); + + $router->post('/menu/add', 'MenuController@add'); + $router->get('/menu/edit/{id}', 'MenuController@edit'); + $router->put('/menu/update/{id}', 'MenuController@update'); + $router->delete('/menu/delete/{id}', 'MenuController@delete'); + $router->post('/menu/search', 'MenuController@search'); + $router->get('/menu/management/{id}', 'MenuController@listMenu'); + $router->get('/menu/list', 'MenuController@list'); + $router->post('/role-menu/add', 'RoleMenuController@add'); + $router->put('/role-menu/update/{id}', 'RoleMenuController@update'); + $router->delete('/role-menu/delete/{id}', 'RoleMenuController@delete'); + $router->delete('/role-menu/delete-byrole/{id}', 'RoleMenuController@deleteByRole'); + $router->post('/role-menu/search', 'RoleMenuController@search'); + $router->get('/role-menu/get-role/{id}', 'RoleMenuController@listMenu'); + + $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { $router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in @@ -51,407 +40,12 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->delete('/role/delete/{id}', 'RoleController@delete'); $router->get('/role/list', 'RoleController@list'); - $router->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen'); - $router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId'); - $router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete'); - $router->post('/document-project/search', 'ProjectDokumenController@searchDocProject'); + $router->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen'); + $router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId'); + $router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete'); + $router->post('/document-project/search', 'ProjectDokumenController@searchDocProject'); $router->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen'); -<<<<<<< HEAD - $router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen'); - $router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId'); - $router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete'); - $router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject'); - $router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen'); - - $router->post('/project/search', 'ProjectController@search'); - $router->post('/project/add', 'ProjectController@add'); - $router->put('/project/update/{id}', 'ProjectController@update'); - $router->get('/project/edit/{id}', 'ProjectController@edit'); - $router->get('/project/detail/{id}', 'ProjectController@detail'); - $router->delete('/project/delete/{id}', 'ProjectController@delete'); - $router->get('/project/list', 'ProjectController@list'); - $router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline'); - $router->get('/project/synchronize-report/{gantt_id}', 'ProjectController@synchronizeReport'); - $router->get('/project/manpower/{proyek_id}', 'ProjectController@getManpower'); - $router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR'); - - $router->post('/project/get-s-curve', 'ProjectController@getSCurve'); - $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); - $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); - $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); - - /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ - /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ - /* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */ - /* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */ - - - $router->post('/project-charter/search', 'ProjectCharterController@search'); - $router->post('/project-charter/add', 'ProjectCharterController@add'); - $router->put('/project-charter/update/{id}', 'ProjectCharterController@update'); - - $router->post('/divisi/add', 'DivisiController@add'); - $router->get('/divisi/edit/{id}', 'DivisiController@edit'); - $router->put('/divisi/update/{id}', 'DivisiController@update'); - $router->post('/divisi/search', 'DivisiController@search'); - $router->delete('/divisi/delete/{id}', 'DivisiController@delete'); - $router->get('/divisi/list', 'DivisiController@list'); - - $router->post('/config-alert/search', 'ConfigAlertController@search'); - $router->post('/config-alert/add', 'ConfigAlertController@add'); - $router->get('/config-alert/edit/{id}', 'ConfigAlertController@edit'); - $router->put('/config-alert/update/{id}', 'ConfigAlertController@update'); - $router->delete('/config-alert/delete/{id}', 'ConfigAlertController@delete'); - $router->get('/config-alert/list', 'ConfigAlertController@list'); - - $router->post('/config-alert-to-user/search', 'ConfigAlertUserController@search'); - $router->post('/config-alert-to-user/add', 'ConfigAlertUserController@add'); - $router->put('/config-alert-to-user/update/{id}', 'ConfigAlertUserController@update'); - $router->delete('/config-alert-to-user/delete/{id}', 'ConfigAlertUserController@delete'); - $router->get('/config-alert/get-user/{id}', 'ConfigAlertUserController@getConfigUser'); - - $router->post('/human-resource/search', 'HumanResourceController@search'); - $router->post('/human-resource/add', 'HumanResourceController@add'); - $router->get('/human-resource/edit/{id}', 'HumanResourceController@edit'); - $router->put('/human-resource/update/{id}', 'HumanResourceController@update'); - $router->delete('/human-resource/delete/{id}', 'HumanResourceController@delete'); - $router->get('/human-resource/list', 'HumanResourceController@list'); - $router->get('/human-resource/select', 'HumanResourceController@select'); - $router->post('/human-resource/check-old-password/{id}', 'HumanResourceController@checkOldPassword'); - - $router->post('/project-role/search', 'ProjectRoleController@search'); - $router->post('/project-role/add', 'ProjectRoleController@add'); - $router->get('/project-role/edit/{id}', 'ProjectRoleController@edit'); - $router->put('/project-role/update/{id}', 'ProjectRoleController@update'); - $router->delete('/project-role/delete/{id}', 'ProjectRoleController@delete'); - $router->get('/project-role/list', 'ProjectRoleController@list'); - $router->get('/project-role/select', 'ProjectRoleController@select'); - - $router->post('/project-type/search', 'ProjectTypeController@search'); - $router->post('/project-type/add', 'ProjectTypeController@add'); - $router->get('/project-type/edit/{id}', 'ProjectTypeController@edit'); - $router->put('/project-type/update/{id}', 'ProjectTypeController@update'); - $router->delete('/project-type/delete/{id}', 'ProjectTypeController@delete'); - $router->get('/project-type/list', 'ProjectTypeController@list'); - - $router->post('/project-phase/search', 'ProjectPhaseController@search'); - $router->post('/project-phase/add', 'ProjectPhaseController@add'); - $router->get('/project-phase/edit/{id}', 'ProjectPhaseController@edit'); - $router->put('/project-phase/update/{id}', 'ProjectPhaseController@update'); - $router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete'); - $router->get('/project-phase/list', 'ProjectPhaseController@list'); - - $router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek'); - - $router->post('/request-material/add', 'RequestMaterialController@add'); - $router->post('/request-material/search', 'RequestMaterialController@search'); - $router->get('/request-material/edit/{id}', 'RequestMaterialController@edit'); - $router->put('/request-material/update/{id}', 'RequestMaterialController@update'); - $router->delete('/request-material/delete/{id}', 'RequestMaterialController@delete'); - $router->get('/request-material/list', 'RequestMaterialController@list'); - $router->get('/request-material/get-material-integration', 'RequestMaterialController@getMaterialIntegration'); - - $router->put('/request-material/update-warehouse-site/{id}', 'RequestMaterialController@updateWarehouseSite'); - - $router->post('/material-to-project/assign', 'MaterialProjectController@assignMaterial'); - - $router->post('/material-resource/add', 'MaterialResourceController@add'); - $router->post('/material-resource/search', 'MaterialResourceController@search'); - $router->get('/material-resource/update/{id}', 'MaterialResourceController@edit'); - $router->put('/material-resource/update/{id}', 'MaterialResourceController@update'); - $router->delete('/material-resource/delete/{id}', 'MaterialResourceController@delete'); - $router->get('/material-resource/list', 'MaterialResourceController@list'); - $router->get('/material-resource/select', 'MaterialResourceController@select'); - - $router->post('/tools-to-project/assign', 'ToolsProjectController@assignTools'); - $router->get('/tools-to-project/search', 'ToolsProjectController@searchTools'); - - $router->post('/tools-resource/add', 'ToolsResourceController@add'); - $router->post('/tools-resource/search', 'ToolsResourceController@search'); - $router->get('/tools-resource/edit/{id}', 'ToolsResourceController@edit'); - $router->put('/tools-resource/update/{id}', 'ToolsResourceController@update'); - $router->delete('/tools-resource/delete/{id}', 'ToolsResourceController@delete'); - $router->get('/tools-resource/list', 'ToolsResourceController@list'); - $router->get('/tools-resource/select', 'ToolsResourceController@select'); - - $router->post('/req-tools/add', 'ToolsRequestController@add'); - $router->get('/req-tools/edit/{id}', 'ToolsRequestController@edit'); - $router->put('/req-tools/update/{id}', 'ToolsRequestController@update'); - $router->post('/req-tools/search', 'ToolsRequestController@search'); - $router->delete('/req-tools/delete/{id}', 'ToolsRequestController@delete'); - $router->get('/req-tools/list', 'ToolsRequestController@list'); - - $router->post('/version-gantt/add', 'VersionGanttController@add'); - $router->get('/version-gantt/edit/{id}', 'VersionGanttController@edit'); - $router->put('/version-gantt/update/{id}', 'VersionGanttController@update'); - $router->post('/version-gantt/search', 'VersionGanttController@search'); - $router->delete('/version-gantt/delete/{id}', 'VersionGanttController@delete'); - $router->get('/version-gantt/list', 'VersionGanttController@list'); - - $router->post('/user-to-version-gantt/add', 'UserToVersionGanttController@add'); - $router->post('/user-to-version-gantt/add-multiple', 'UserToVersionGanttController@addMultiple'); - $router->get('/user-to-version-gantt/edit/{id}', 'UserToVersionGanttController@edit'); - $router->put('/user-to-version-gantt/update/{id}', 'UserToVersionGanttController@update'); - $router->post('/user-to-version-gantt/search', 'UserToVersionGanttController@search'); - $router->delete('/user-to-version-gantt/delete/{id}', 'UserToVersionGanttController@delete'); - $router->get('/user-to-version-gantt/list', 'UserToVersionGanttController@list'); - $router->get('/user-to-version-gantt/get-by-gantt/{gantt_id}', 'UserToVersionGanttController@getByUserGantt'); - - $router->post('/user-to-activity/add', 'UserToActivityController@add'); - $router->post('/user-to-activity/add-multiple', 'UserToActivityController@addMultiple'); - $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); - $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); - $router->post('/user-to-activity/search', 'UserToActivityController@search'); - $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); - $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); - $router->get('/user-to-activity/list', 'UserToActivityController@list'); - $router->get('/user-to-activity/datatables', 'UserToActivityController@datatables'); - - $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); - $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); - $router->get('/activity/search', 'ActivityController@search'); - $router->post('/activity/import', 'ActivityController@import'); - $router->post('/task', 'ActivityController@add'); - $router->get('/task/edit/{id}', 'ActivityController@edit'); - $router->put('/task/{id}', 'ActivityController@update'); - $router->put('/task/update-regular/{id}', 'ActivityController@updateRegular'); - $router->delete('/task/{id}', 'ActivityController@delete'); - $router->get('/task/get-update/{id}', 'ActivityController@getUpdate'); - - $router->post('/link', 'LinkController@add'); - $router->put('/link/{id}', 'LinkController@update'); - $router->delete('/link/{id}', 'LinkController@delete'); - - $router->post('/template-gantt/add', 'TemplateGanttController@add'); - $router->get('/template-gantt/edit/{id}', 'TemplateGanttController@edit'); - $router->put('/template-gantt/update/{id}', 'TemplateGanttController@update'); - $router->post('/template-gantt/search', 'TemplateGanttController@search'); - $router->delete('/template-gantt/delete/{id}', 'TemplateGanttController@delete'); - $router->get('/template-gantt/list', 'TemplateGanttController@list'); - $router->get('/template-gantt/get-tree/{id}', 'TemplateGanttController@getTreeByTypeProject'); - - $router->post('/comment-activity/add', 'CommentActivityController@add'); - $router->get('/comment-activity/edit/{id}', 'CommentActivityController@edit'); - $router->put('/comment-activity/update/{id}', 'CommentActivityController@update'); - $router->post('/comment-activity/search', 'CommentActivityController@search'); - $router->delete('/comment-activity/delete/{id}', 'CommentActivityController@delete'); - $router->get('/comment-activity/list', 'CommentActivityController@list'); - - $router->post('/presence/add', 'PresenceController@add'); - $router->get('/presence/edit/{id}', 'PresenceController@edit'); - $router->put('/presence/update/{id}', 'PresenceController@update'); - $router->post('/presence/search', 'PresenceController@search'); - $router->delete('/presence/delete/{id}', 'PresenceController@delete'); - $router->get('/presence/list', 'PresenceController@list'); - $router->get('/presence/clockinout/{id}', 'PresenceController@clockinout'); - $router->post('/presence/reportk3', 'PresenceController@reportK3'); - $router->get('/presence/bulk-update-location', 'PresenceController@bulkUpdateLocation'); - - $router->post('/permit/add', 'AbsentController@add'); - $router->get('/permit/edit/{id}', 'AbsentController@edit'); - $router->put('/permit/update/{id}', 'AbsentController@update'); - $router->post('/permit/search', 'AbsentController@search'); - $router->delete('/permit/delete/{id}', 'AbsentController@delete'); - $router->get('/permit/list', 'AbsentController@list'); - - $router->post('/assign-tools/add', 'AssignToolsController@add'); - $router->get('/assign-tools/edit/{id}', 'AssignToolsController@edit'); - $router->put('/assign-tools/update/{id}', 'AssignToolsController@update'); - $router->post('/assign-tools/search', 'AssignToolsController@search'); - $router->delete('/assign-tools/delete/{id}', 'AssignToolsController@delete'); - $router->get('/assign-tools/list', 'AssignToolsController@list'); - $router->get('/assign-tools/datatables', 'AssignToolsController@datatables'); - - $router->post('/assign-material/add', 'AssignMaterialController@add'); - $router->get('/assign-material/edit/{id}', 'AssignMaterialController@edit'); - $router->put('/assign-material/update/{id}', 'AssignMaterialController@update'); - $router->post('/assign-material/search', 'AssignMaterialController@search'); - $router->delete('/assign-material/delete/{id}', 'AssignMaterialController@delete'); - $router->get('/assign-material/list', 'AssignMaterialController@list'); - $router->get('/assign-material/datatables', 'AssignMaterialController@datatables'); - $router->get('/assign-material/datatablesForReportActivity', 'AssignMaterialController@datatablesForReportActivity'); - $router->post('/assign-material/ForReportActivityByMaterial', 'AssignMaterialController@ForReportActivityByMaterial'); - - $router->post('/image/search', 'ImageController@search'); - $router->delete('/image/delete/{id}', 'ImageController@delete'); - $router->delete('/image/delete/{id}/{category}', 'ImageController@deleteByRef'); - $router->post('/image/upload', 'ImageController@uploadImage'); - $router->get('/image/{id}/{category}', 'ImageController@getByRefId'); - - $router->post('/panic-button/add', 'PanicButtonController@add'); - $router->get('/panic-button/edit/{id}', 'PanicButtonController@edit'); - $router->put('/panic-button/update/{id}', 'PanicButtonController@update'); - $router->post('/panic-button/search', 'PanicButtonController@search'); - $router->delete('/panic-button/delete/{id}', 'PanicButtonController@delete'); - $router->get('/panic-button/list', 'PanicButtonController@list'); - - $router->post('/rate-sallary/add', 'RateSallaryController@add'); - $router->get('/rate-sallary/edit/{id}', 'RateSallaryController@edit'); - $router->put('/rate-sallary/update/{id}', 'RateSallaryController@update'); - $router->post('/rate-sallary/search', 'RateSallaryController@search'); - $router->delete('/rate-sallary/delete/{id}', 'RateSallaryController@delete'); - $router->get('/rate-sallary/list', 'RateSallaryController@list'); - - $router->post('/project-participants/add', 'ProjectParticipantsController@add'); - $router->get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit'); - $router->put('/project-participants/update/{id}', 'ProjectParticipantsController@update'); - $router->post('/project-participants/search', 'ProjectParticipantsController@search'); - $router->delete('/project-participants/delete/{id}', 'ProjectParticipantsController@delete'); - $router->delete('/project-participants/delete-by-proyek/{id}', 'ProjectParticipantsController@deleteByProyek'); - $router->get('/project-participants/list', 'ProjectParticipantsController@list'); - $router->get('/project-participants/{where}/{val}', 'ProjectParticipantsController@customWhere'); - - $router->post('/project-approval/add', 'ProjectApprovalController@add'); - $router->get('/project-approval/edit/{id}', 'ProjectApprovalController@edit'); - $router->put('/project-approval/update/{id}', 'ProjectApprovalController@update'); - $router->post('/project-approval/search', 'ProjectApprovalController@search'); - $router->delete('/project-approval/delete/{id}', 'ProjectApprovalController@delete'); - $router->delete('/project-approval/delete-by-proyek/{id}', 'ProjectApprovalController@deleteByProyek'); - $router->get('/project-approval/list', 'ProjectApprovalController@list'); - $router->get('/project-approval/{where}/{val}', 'ProjectApprovalController@customWhere'); - - $router->post('/project-milestone/add', 'ProjectMileStoneController@add'); - $router->get('/project-milestone/edit/{id}', 'ProjectMileStoneController@edit'); - $router->put('/project-milestone/update/{id}', 'ProjectMileStoneController@update'); - $router->post('/project-milestone/search', 'ProjectMileStoneController@search'); - $router->delete('/project-milestone/delete/{id}', 'ProjectMileStoneController@delete'); - $router->delete('/project-milestone/delete-by-proyek/{id}', 'ProjectMileStoneController@deleteByProyek'); - $router->get('/project-milestone/list', 'ProjectMileStoneController@list'); - $router->get('/project-milestone/select', 'ProjectMileStoneController@select'); - $router->get('/project-milestone/{where}/{val}', 'ProjectMileStoneController@customWhere'); - - $router->post('/report-activity/add', 'ReportActivityController@add'); - $router->get('/report-activity/edit/{id}', 'ReportActivityController@edit'); - $router->put('/report-activity/update/{id}', 'ReportActivityController@update'); - $router->post('/report-activity/search', 'ReportActivityController@search'); - $router->delete('/report-activity/delete/{id}', 'ReportActivityController@delete'); - $router->get('/report-activity/list', 'ReportActivityController@list'); - $router->post('/report-activity/search-point', 'ReportActivityController@searchPoint'); - $router->get('/report-activity/datatables', 'ReportActivityController@datatables'); - - $router->post('/report-activity-material/add', 'ReportActivityMaterialController@add'); - $router->post('/report-activity-material/search', 'ReportActivityMaterialController@search'); - $router->delete('/report-activity-material/delete/{id}', 'ReportActivityMaterialController@delete'); - $router->get('/report-activity-material/list', 'ReportActivityMaterialController@list'); - $router->get('/report-activity-material/datatables', 'ReportActivityMaterialController@datatables'); - $router->post('/report-activity-material/update-status', 'ReportActivityMaterialController@updateStatusStartFinish'); - - $router->post('/waypoint/add', 'WaypointController@add'); - $router->post('/waypoint/add-bulk', 'WaypointController@addBulk'); - $router->get('/waypoint/edit/{id}', 'WaypointController@edit'); - $router->put('/waypoint/update/{id}', 'WaypointController@update'); - $router->post('/waypoint/search', 'WaypointController@search'); - $router->delete('/waypoint/delete/{id}', 'WaypointController@delete'); - $router->get('/waypoint/list', 'WaypointController@list'); - - $router->post('/holiday/add', 'HolidayController@add'); - $router->get('/holiday/edit/{id}', 'HolidayController@edit'); - $router->put('/holiday/update/{id}', 'HolidayController@update'); - $router->post('/holiday/search', 'HolidayController@search'); - $router->delete('/holiday/delete/{id}', 'HolidayController@delete'); - $router->get('/holiday/list', 'HolidayController@list'); - $router->get('/holiday/datatables', 'HolidayController@datatables'); - - $router->post('/satuan/add', 'SatuanController@add'); - $router->get('/satuan/edit/{id}', 'SatuanController@edit'); - $router->put('/satuan/update/{id}', 'SatuanController@update'); - $router->post('/satuan/search', 'SatuanController@search'); - $router->delete('/satuan/delete/{id}', 'SatuanController@delete'); - $router->get('/satuan/list', 'SatuanController@list'); - - $router->post('/checklist-k3/add', 'ChecklistK3Controller@add'); - $router->get('/checklist-k3/edit/{id}', 'ChecklistK3Controller@edit'); - $router->put('/checklist-k3/update/{id}', 'ChecklistK3Controller@update'); - $router->post('/checklist-k3/search', 'ChecklistK3Controller@search'); - $router->delete('/checklist-k3/delete/{id}', 'ChecklistK3Controller@delete'); - $router->get('/checklist-k3/list', 'ChecklistK3Controller@list'); - - $router->post('/report-k3/add', 'ReportK3Controller@add'); - $router->get('/report-k3/edit/{id}', 'ReportK3Controller@edit'); - $router->put('/report-k3/update/{id}', 'ReportK3Controller@update'); - $router->post('/report-k3/search', 'ReportK3Controller@search'); - $router->delete('/report-k3/delete/{id}', 'ReportK3Controller@delete'); - $router->get('/report-k3/list', 'ReportK3Controller@list'); - - $router->post('/report-k3-detail/add', 'ReportK3DetailController@add'); - $router->get('/report-k3-detail/edit/{id}', 'ReportK3DetailController@edit'); - $router->put('/report-k3-detail/update/{id}', 'ReportK3DetailController@update'); - $router->post('/report-k3-detail/search', 'ReportK3DetailController@search'); - $router->delete('/report-k3-detail/delete/{id}', 'ReportK3DetailController@delete'); - $router->get('/report-k3-detail/list', 'ReportK3DetailController@list'); - - $router->post('/user-to-proyek/add', 'UserToProyekController@add'); - $router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit'); - $router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update'); - $router->post('/user-to-proyek/search', 'UserToProyekController@search'); - $router->delete('/user-to-proyek/delete/{id}', 'UserToProyekController@delete'); - $router->get('/user-to-proyek/list', 'UserToProyekController@list'); - $router->get('/user-to-proyek/select', 'UserToProyekController@select'); - $router->get('/user-to-proyek/get-employee-integration', 'UserToProyekController@getEmployeeIntegration'); - - $router->post('/folder-document-proyek/add', 'FolderDocumentProyekController@add'); - $router->get('/folder-document-proyek/edit/{id}', 'FolderDocumentProyekController@edit'); - $router->put('/folder-document-proyek/update/{id}', 'FolderDocumentProyekController@update'); - $router->post('/folder-document-proyek/search', 'FolderDocumentProyekController@search'); - $router->delete('/folder-document-proyek/delete/{id}', 'FolderDocumentProyekController@delete'); - $router->get('/folder-document-proyek/list', 'FolderDocumentProyekController@list'); - $router->get('/folder-document-proyek/get-tree/{id}', 'FolderDocumentProyekController@getTree'); - - $router->post('/office-hours/add', 'OfficeHoursController@add'); - $router->get('/office-hours/edit/{id}', 'OfficeHoursController@edit'); - $router->put('/office-hours/update/{id}', 'OfficeHoursController@update'); - $router->post('/office-hours/search', 'OfficeHoursController@search'); - $router->delete('/office-hours/delete/{id}', 'OfficeHoursController@delete'); - $router->get('/office-hours/list', 'OfficeHoursController@list'); - - $router->get('/gantt-show-hide/get-by-gantt/{gantt_id}', 'ShowHideColumnController@getByUserGantt'); - $router->post('/gantt-show-hide/add', 'ShowHideColumnController@add'); - $router->post('/gantt-show-hide/update/{gantt_id}', 'ShowHideColumnController@update'); - $router->get('/gantt-show-hide/get-column-by-type/{type}', 'ShowHideColumnController@getColumnByType'); - - - $router->post('/shift/add', 'ShiftController@add'); - $router->get('/shift/edit/{id}', 'ShiftController@edit'); - $router->put('/shift/update/{id}', 'ShiftController@update'); - $router->post('/shift/search', 'ShiftController@search'); - $router->delete('/shift/delete/{id}', 'ShiftController@delete'); - $router->get('/shift/list', 'ShiftController@list'); - - $router->post('/user-monthly-shift/add', 'UserMonthlyShiftController@add'); - $router->put('/user-monthly-shift/update/{id}', 'UserMonthlyShiftController@update'); - $router->post('/user-monthly-shift/search', 'UserMonthlyShiftController@search'); - $router->delete('/user-monthly-shift/delete/{id}', 'UserMonthlyShiftController@delete'); - $router->delete('/user-monthly-shift/delete-at/{yyyymm}', 'UserMonthlyShiftController@deleteYYYYMM'); - $router->get('/user-monthly-shift/list', 'UserMonthlyShiftController@list'); - $router->post('/user-monthly-shift/import', 'UserMonthlyShiftController@import'); - $router->get('/user-monthly-shift/list/{yyyymm}', 'UserMonthlyShiftController@listYYYYMM'); - - $router->post('/user-to-shift/add', 'UserToShiftController@add'); - $router->get('/user-to-shift/edit/{id}', 'UserToShiftController@edit'); - $router->put('/user-to-shift/update/{id}', 'UserToShiftController@update'); - $router->post('/user-to-shift/search', 'UserToShiftController@search'); - $router->delete('/user-to-shift/delete/{id}', 'UserToShiftController@delete'); - $router->get('/user-to-shift/list', 'UserToShiftController@list'); - - $router->post('/control-monitoring/search', 'ControlMonitoringController@search'); - $router->get('/currency/list', 'CurrencyController@list'); - - $router->post('/project-to-checklist-k3/add', 'ProjectToChecklistK3Controller@add'); - $router->post('/project-to-checklist-k3/add-multiple', 'ProjectToChecklistK3Controller@addMultiple'); - $router->get('/project-to-checklist-k3/edit/{id}', 'ProjectToChecklistK3Controller@edit'); - $router->put('/project-to-checklist-k3/update/{id}', 'ProjectToChecklistK3Controller@update'); - $router->post('/project-to-checklist-k3/search', 'ProjectToChecklistK3Controller@search'); - $router->delete('/project-to-checklist-k3/delete/{id}', 'ProjectToChecklistK3Controller@delete'); - $router->get('/project-to-checklist-k3/list', 'ProjectToChecklistK3Controller@list'); - - $router->post('/project-comment/add', 'ProjectCommentController@add'); - $router->put('/project-comment/update/{id}', 'ProjectCommentController@update'); - $router->post('/project-comment/search', 'ProjectCommentController@search'); - - $router->post('/map-monitoring/search', 'MapMonitoringController@search'); - }); -======= $router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen'); $router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId'); $router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete'); @@ -825,6 +419,5 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->delete('/project-to-checklist-k3/delete/{id}', 'ProjectToChecklistK3Controller@delete'); $router->get('/project-to-checklist-k3/list', 'ProjectToChecklistK3Controller@list'); }); ->>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 }); From 2f9609c05dcfebeed291bcdd4b1c15fbd6553710 Mon Sep 17 00:00:00 2001 From: ibnu Date: Wed, 15 Mar 2023 05:32:48 +0700 Subject: [PATCH 20/24] update tmp import --- app/Http/Controllers/ActivityController.php | 484 +++++--------------- app/Http/Controllers/Controller.php | 1 + app/Http/Controllers/DivisiController.php | 14 +- app/Http/Controllers/ProjectController.php | 269 +++-------- app/Models/TmpImport.php | 17 + 5 files changed, 205 insertions(+), 580 deletions(-) create mode 100644 app/Models/TmpImport.php diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 19c7182..b948351 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -3,14 +3,12 @@ namespace App\Http\Controllers; use App\Models\Activity; use App\Models\CommentActivity; -use App\Models\Holiday; use App\Models\Link; use App\Models\Project; -use App\Models\ReportActivity; use App\Models\TemplateGantt; -use App\Models\UserToActivity; use App\Models\VersionGantt; -use Illuminate\Support\Facades\DB; +use App\Models\UserToActivity; +use App\Models\TmpImport; use Illuminate\Http\Request; class ActivityController extends Controller @@ -28,14 +26,17 @@ class ActivityController extends Controller private function getDataActivity($id) { - $checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count(); $finalData = []; + $checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count(); $finalData = []; if($checkHeader > 0){ $dataHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->first(); $startDate = date_create($dataHeader->start_date); $endDate = date_create($dataHeader->end_date); $dataHeader->start_date = date_format($startDate,"Y-m-d H:i:s"); $dataHeader->end_date = date_format($endDate,"Y-m-d H:i:s"); - $dataHeader->type = "project"; + $dataHeader->progress = $dataHeader->persentase_progress / 100; + $dataHeader->planned_start = isset($dataHeader->planned_start) ? date_format(date_create($dataHeader->planned_start),"Y-m-d H:i:s") : NULL; + $dataHeader->planned_end = isset($dataHeader->planned_end) ? date_format(date_create($dataHeader->planned_end),"Y-m-d H:i:s") : NULL; + $dataHeader->type = "header"; $dataHeader->text = $dataHeader->name; $finalData[] = $dataHeader; $data = Activity::where('version_gantt_id', $id)->where('parent_id', $dataHeader->id)->orderBy('id', 'asc')->get(); @@ -45,20 +46,22 @@ class ActivityController extends Controller foreach($data as $objRow){ $type = "project"; + $dataChildren = $this->getChildren($id, $objRow->id); + $startDate = date_create($objRow->start_date); + $endDate = date_create($objRow->end_date); + if($objRow->type_activity=="milestone") $type = $objRow->type_activity; if(empty($dataChildren)) $type = "task"; + $objRow->text = $objRow->name; $objRow->parent = $objRow->parent_id ? $objRow->parent_id : null; - $startDate = date_create($objRow->start_date); - $endDate = date_create($objRow->end_date); $objRow->start_date = date_format($startDate,"Y-m-d H:i:s"); $objRow->end_date = date_format($endDate,"Y-m-d H:i:s"); $objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start),"Y-m-d H:i:s") : NULL; $objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end),"Y-m-d H:i:s") : NULL; - $objRow->progress = (int) $objRow->persentase_progress / 100; - $dataChildren = $this->getChildren($id, $objRow->id); + $objRow->progress = $objRow->persentase_progress / 100; $objRow->type = $type; $finalData[] = $objRow; $finalData = array_merge($finalData, $dataChildren); @@ -186,7 +189,10 @@ class ActivityController extends Controller $parent = $data['parent_id'] ?? null; if($parent){ - Activity::find($parent)->update(["type_activity"=>"project"]); + $parentData = Activity::find($parent); + if($parentData->parent_id) { + $parentData->update(["type_activity" => "project"]); + } CommentActivity::where('activity_id', $parent)->delete(); UserToActivity::where('activity_id', $parent)->delete(); } @@ -212,16 +218,11 @@ class ActivityController extends Controller if(empty($id) || !is_int((int)$id)) return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400); - $updateBobot = false; + $updateBobot = true; if(!$data = Activity::find($id)) return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404); $dataUpdate = $request->all(); - $oldRencanaBiaya = $data->rencana_biaya; - $newRencanaBiaya = str_replace(",",".",$request->rencana_biaya); - if($oldRencanaBiaya != $newRencanaBiaya) - $updateBobot = true; - $dataUpdate['name'] = $request->text; $dataUpdate['persentase_progress'] = $request->progress*100; $dataUpdate['updated_by'] = $this->currentName; @@ -278,378 +279,141 @@ class ActivityController extends Controller $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); - } + } - public function getPercentagePerDay(Request $request) + public function import(Request $request) { - $dataPayload = $request->all(); - $allGantt = []; - foreach ($dataPayload['project_id'] as $val) { - $allGantt[] = $this->getLatestGantt($val); - } + $data = $request->all(); - $dataFinal=[]; - foreach ($allGantt as $val) { - $dataProject = Project::find($val['proyek_id']); - $holidays = Holiday::where("version_gantt_id", $val['last_gantt_id'])->where("proyek_id", $val['proyek_id'])->get(); - $dateHoliday = []; //$holiday->all(); - foreach ($holidays as $holiday) { - $startH = new \DateTime($holiday->date); - $endH = clone $startH; - $endH->modify('+'.$holiday->duration.' day'); - $intervalH = \DateInterval::createFromDateString('1 day'); - $periodH = new \DatePeriod($startH, $intervalH, $endH); - foreach ($periodH as $dt) { - $dateHoliday[] = $dt->format("Y-m-d"); - } - } - $verGantt = VersionGantt::find($val['last_gantt_id']); - $configOff = $verGantt->config_dayoff; - if($configOff && $configOff!= ""){ - $dayOff = explode(",", $verGantt->config_dayoff); - $dayOff = array_map( - function($value) { return (int)$value; }, - $dayOff - ); - }else{ - $dayOff = []; - } - $checkHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->count(); - if($checkHeader > 0){ - $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); - $minDate = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->min("start_date"); - $maxDate = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->max("end_date"); - }else{ - $minDate = Activity::whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->min("start_date"); - $maxDate = Activity::whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->max("end_date"); - } + $data['created_by'] = $this->currentName; - $begin = new \DateTime($minDate); - $end = new \DateTime($maxDate); - $end = $end->modify( '+1 day' ); - $interval = \DateInterval::createFromDateString('1 day'); - $period = new \DatePeriod($begin, $interval, $end); - $checkHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->count(); - if($checkHeader > 0){ - $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); - $totalRencanaBudget = Activity::select(DB::raw('sum(cast(rencana_biaya as integer))'))->where('parent_id', $dataHeader->id)->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); - }else{ - $totalRencanaBudget = Activity::select(DB::raw('sum(cast(rencana_biaya as integer))'))->whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); - } + Activity::where('version_gantt_id', $data['ganttId'])->delete(); - $totalRencanaBudget = $totalRencanaBudget->sum; - $currentPercentage = 0; - $dataDate = []; - $dataPercen = []; - foreach ($period as $dt) { - $weekDay = $dt->format("w"); - $currentDate = $dt->format("Y-m-d"); - if(!in_array($weekDay, $dayOff) && !in_array($currentDate, $dateHoliday)) - { - $totalPercentage = 0; - $checkHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->count(); - if($checkHeader > 0){ - $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first(); - $dataActivity = Activity::whereRaw("'".$currentDate."' BETWEEN DATE(m_activity.start_date) AND DATE(m_activity.end_date)")->where('parent_id', $dataHeader->id)->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->get(); - }else{ - $dataActivity = Activity::whereRaw("'".$currentDate."' BETWEEN DATE(m_activity.start_date) AND DATE(m_activity.end_date)")->whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->get(); - } - - foreach ($dataActivity as $activity) { - $duration = $activity->duration; - if($totalRencanaBudget > 0 && $duration > 0){ - $totalPercentage = $totalPercentage + ((($activity->rencana_biaya/$totalRencanaBudget)*100)/$duration); - } - } - $currentPercentage = $currentPercentage + $totalPercentage; - $dataDate[] = $currentDate; - $dataPercen[] = $currentPercentage; - }else{ - $dataDate[] = $currentDate; - $dataPercen[] = "dateOff"; - } - } - $dataPercentage = array( - "date"=>$dataDate, - "percentage"=>$dataPercen - ); - $dataFinal[] = array( - "proyek_name"=> $dataProject->nama, - "data"=>$dataPercentage - ); - } + $projectId = VersionGantt::where('id', $data['ganttId'])->first()->proyek_id; - if($dataFinal){ - return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'failed get list percentage day, please try again later!','code'=>400], 400); - } - } + $activityStack = []; + foreach ($data['activities'] as $i => $activity_row) { + $startDate = \DateTime::createFromFormat('d-m-y', $activity_row['start_date']); + $endDate = \DateTime::createFromFormat('d-m-y', $activity_row['end_date']); - public function getCalculateCurvaS(Request $request) // for adw (plan & actual == date) - { - DB::enableQueryLog(); - $dataPayload = $request->all(); - $allGantt = []; - if(isset($dataPayload['gannt_id'])){ - $allGantt = $dataPayload['gannt_id']; - }else{ - foreach ($dataPayload['project_id'] as $val) { - $allGantt[] = $this->getLatestGantt($val); + $input['name'] = $activity_row['name']; + $input['proyek_id'] = $projectId; + $input['version_gantt_id'] = $data['ganttId']; + $input['parent_id'] = null; + $input['start_date'] = $startDate->format('Y-m-d'); + $input['end_date'] = $endDate->format('Y-m-d'); + $input['duration'] = $activity_row['duration']; + $input['bobot_planning'] = $activity_row['weight']; + $input['persentase_progress'] = 0; + $input['type_activity'] = $i == 0 ? "header" : "task"; + $input['created_by'] = $this->currentName; + + if (!$activity = Activity::create($input)) { + Activity::where('version_gantt_id', $data['ganttId'])->delete(); + return response()->json(['status' => 'error', 'message' => 'Input failed on ' . $activity['name'], 'code' => 500], 500); } - } - $dataFinal=[]; - foreach ($allGantt as $keyGantt) { - $dataProject = Project::find($keyGantt['proyek_id']); - $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->first(); - if($dataHeader){ - $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); - }else{ - $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); + $data['activities'][$i]['activity_id'] = $activity->id; + + if ($i == 0) { + $activity->type_activity = "project"; + $activity->save(); + $activity->level = $activity_row['level']; + array_push($activityStack, $activity); + continue; } - if(!Activity::where("version_gantt_id", $keyGantt['last_gantt_id'])->first()) - continue; - - $alreadyHasReport = DB::table('report_activity_material as a') - ->select('a.id') - ->join('m_activity as b', 'b.id', '=', 'a.activity_id') - ->where('b.version_gantt_id', '=', $keyGantt['last_gantt_id']) - ->exists(); - - if(!$alreadyHasReport) - continue; - - $minDate = DB::table('assign_material_to_activity as ama') - ->where("ama.proyek_id", $keyGantt['proyek_id']) - ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') - ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) - ->min("plan_date"); - - $maxDate = DB::table('assign_material_to_activity as ama') - ->where("ama.proyek_id", $keyGantt['proyek_id']) - ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') - ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) - ->max("plan_date"); - - $begin = new \DateTime($minDate); - $end = new \DateTime($maxDate); - $end2 = new \DateTime($maxDate); - $interval = \DateInterval::createFromDateString('1 day'); - $period = new \DatePeriod($begin->modify('-1 days'), $interval, $end); - $arr_ActualM = []; - $tempDate = []; - $tempPercentage = []; - $tempTtlPercentPlan=0; - $tempTtlPercentActual=0; - - $currentACWP = 0; - $currentBCWP = 0; - - foreach ($period as $dt) { - $dataPlanM = DB::table('assign_material_to_activity as ama') - ->select('ama.activity_id', 'ama.qty_planning', 'ama.plan_date', 'ama.start_activity', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') - ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') - ->where('ama.proyek_id', '=', $keyGantt['proyek_id']) - ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) - ->whereDate('ama.plan_date', $dt->format("Y-m-d")) - ->get(); - $dataActualM = DB::table('report_activity_material as ram') - ->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') - ->join('m_activity as a', 'a.id', '=', 'ram.activity_id') - ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) - ->where('a.proyek_id', '=', $keyGantt['proyek_id']) - ->whereDate('ram.report_date', $dt->format("Y-m-d")) - ->get(); - $dataTempPlan = []; - $x = 0; - $sumPercentagePlan=0; - $totalACWP = isset($totalACWP) ? $totalACWP : 0; - $totalBCWP = isset($totalBCWP) ? $totalBCWP : 0; - - foreach ($dataPlanM as $keyPlanM) { - $sumVolPlan = DB::table('assign_material_to_activity') - ->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan')) - ->where('activity_id', '=', $keyPlanM->activity_id) - ->groupBy('activity_id') - ->first(); - $dataTempPlan [$x]['activity_id'] = $keyPlanM->activity_id; - $dataTempPlan [$x]['qty_plan'] = $keyPlanM->qty_planning; - $dataTempPlan [$x]['plan_date'] = $keyPlanM->plan_date; - $dataTempPlan [$x]['start_activity'] = $keyPlanM->start_activity; - $dataTempPlan [$x]['bobot_planning'] = $keyPlanM->bobot_planning; - $dataTempPlan [$x]['ttl_plan'] = $sumVolPlan->ttl_qty_plan; - $dataTempPlan [$x]['biaya_actual'] = $keyPlanM->biaya_actual; - $dataTempPlan [$x]['duration'] = $keyPlanM->duration; - $dataTempPlan [$x]['persentase_progress'] = $keyPlanM->persentase_progress; - $dataTempPlan [$x]['percentage'] = ($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning; - $sumPercentagePlan+=($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning; - $totalBCWP += (((($keyPlanM->persentase_progress*$keyPlanM->bobot_planning)/100)/$keyPlanM->duration)* $totalRencanaBudget)/100; - $dataTempPlan [$x]['totalBCWP'] = $totalBCWP; - $x++; - } + $activity->level = $activity_row['level']; + + if ($lastStack = end($activityStack)) { + $levelLowerThanLastStack = $activity->level < $lastStack->level; + $levelEqualWithLastStack = $activity->level == $lastStack->level; - $w = 0; - $dataTempReport = []; - $sumPercentageActual=0; - foreach ($dataActualM as $keyActualM) { - $sumVolActual = DB::table('assign_material_to_activity') - ->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan')) - ->where('activity_id', '=', $keyActualM->activity_id) - ->groupBy('activity_id') - ->first(); - $dataTempReport [$w]['activity_id'] = $keyActualM->activity_id; - $dataTempReport [$w]['qty'] = $keyActualM->qty; - $dataTempReport [$w]['report_date'] = $keyActualM->report_date; - $dataTempReport [$w]['bobot_planning'] = $keyActualM->bobot_planning; - $dataTempReport [$w]['ttl_plan'] = $sumVolActual->ttl_qty_plan; - $dataTempReport [$w]['biaya_actual'] = $keyActualM->biaya_actual; - $dataTempReport [$w]['duration'] = $keyActualM->duration; - $dataTempReport [$w]['persentase_progress'] = $keyActualM->persentase_progress; - $dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; - $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; - try { - $totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; - } catch (\Exception $e) { - return response()->json(['message' => $e->getMessage()]); - } - $dataTempReport [$w]['totalacwp'] = $totalACWP; - $w++; + if ($levelLowerThanLastStack) { + $lastStackIsNotRight = $levelLowerThanLastStack; + do { + array_pop($activityStack); + $lastStack = end($activityStack); + if ($activity->level > $lastStack->level) + $lastStackIsNotRight = false; + } while ($lastStackIsNotRight); } - $arr_ActualM[] = array( - 'date'=>$dt->format("Y-m-d"), - 'percentPlan'=>$sumPercentagePlan, - 'percentActual'=>$sumPercentageActual, - 'plan'=>$dataTempPlan, - 'actual'=>$dataTempReport, - ); - if(isset($dataPayload['period']) && $dataPayload['period'] == 'week'){ - $tempTtlPercentPlan+= $sumPercentagePlan; - $tempTtlPercentActual+= $sumPercentageActual; - $currentACWP += $totalACWP; - $currentBCWP += $totalBCWP; - - $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); - $tempDate[] = array($dt->format("Y-m-d"), 0, 0); - }else{ - $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); - $tempDate[] = array($dt->format("Y-m-d"), 0, 0); + if ($levelEqualWithLastStack) { + array_pop($activityStack); } } + $activity->parent_id = $activityStack[count($activityStack) - 1]->id ?? null; + // there should be better way to except / filter attribute level before save because it's cause error + // cant use except() / filter() on $activity collection somehow + unset($activity->level); + $activity->save(); + $activity->level = $activity_row['level']; - try { - if(round($totalACWP,0) > $totalRencanaBudget){ - $estimatedCost = round($totalACWP,0)+0; - }else{ - $estimatedCost = ($totalRencanaBudget+0); - } - } catch (\Exception $e) { - return response()->json([ - 'message' => $e->getMessage(), - "line" => 566, - 'gantt' => $keyGantt, - ]); - } - $estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget; - - $costDeviation = $totalRencanaBudget - $estimatedCost; - if($costDeviation > 0){ - $potential = "SAVING"; - } else { - $potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN"; + if (@$activityStack[count($activityStack) - 1]->level != $activity->level && $activity->level != $data['activities'][$i - 1]['level']) { + array_push($activityStack, $activity); } - $dataResponse = array( - "date" =>$tempDate, - "percentage" =>$tempPercentage, - "data_details" =>$arr_ActualM, - "budget_control" =>array("current_budget"=> $totalRencanaBudget, - "acwp" => round($totalACWP,0), - "bcwp" => round($totalBCWP,0), - "rem_to_complete" => ($totalRencanaBudget - round($totalACWP,0)), - "add_cost_to_complete" => 0, - "estimated_at_completion" => $estimatedCost, - "cost_deviation" => $costDeviation, - "potential" => $potential, - ) - ); - - $dataFinal[] = array( - "proyek_name"=> $dataProject->nama, - "data"=>$dataResponse, - "allGant"=>$allGantt - ); - } - - - return response()->json(['status'=>'success','code'=>200, 'data' => $dataFinal], 200); - - } - - private function getLatestGantt($id){ - $maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); - $data = array( - "last_gantt_id" => $maxGanttId, - "proyek_id" => $id - ); - return $data; - } - - public function setBaseline($gantt_id) - { - $activities = Activity::where("version_gantt_id", $gantt_id)->get(); + if ($activity->level < @$data['activities'][$i + 1]['level']) { + unset($activity->level); + $activity->type_activity = "project"; + $activity->save(); + $activity->level = $activity_row['level']; + } - foreach ($activities as $activity) { - $activity->update([ - "planned_start"=>$activity->start_date, - "planned_end"=>$activity->end_date, - ]); + if (!empty($activity_row['predecessor'])) { + $key = array_search($activity_row['predecessor'], array_column($data['activities'], 'no')); + + if (!$predecessorActivity = Activity::find($data['activities'][$key]['activity_id'])) + continue; + + $predecessorFinishDate = new \DateTime($predecessorActivity->end_date); + $interval = $predecessorFinishDate->diff(new \DateTime($activity->start_date)); + $diff = $interval->days; + + Link::create([ + 'created_by' => $this->currentName, + 's_activity_id' => $predecessorActivity->id, + 't_activity_id' => $activity->id, + 'type_link' => 0, + 'code_link' => 'FS', + 'version_gantt_id' => $data['ganttId'], + 'lag' => $diff > 1 ? $diff : null, + ]); + } } - return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); - } + return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200); + } - public function synchronizeReport($gantt_id) + public function uploadTmpImport(Request $request) { - $activities = Activity::where("version_gantt_id", $gantt_id)->get(); - $reports = []; - - foreach($activities as $activity) { - $activity_id = $activity->id; - $countReports = ReportActivity::where('activity_id', $activity_id)->count(); - if ($countReports === 1) { - $dataReports = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->get(); - foreach($dataReports as $dr) { - $reports[] = array( - 'activity_id'=>$activity_id, - 'min_date'=>$dr->report_date, - 'max_date'=>date_modify(date_create($dr->report_date), "1 days") - ); + if($request->hasFile('dokumen')){ + $document = $request->file('dokumen'); + $ref_id = $request->ref_id; + $name = $document->getClientOriginalName(); + + $result = $document->move($this->pathDocument, $name); + if($result){ + $data = [ + 'ref_id' => (int)$ref_id, + 'file' => $name, + 'type_dokumen' => $request->type_dokumen + ]; + + $result = TmpImport::create($data); + + if(!$result){ + unlink($this->pathDocument.$name); + return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); } - } - if ($countReports > 1) { - $firstReport = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->first(); - $lastReport = ReportActivity::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); - $reports[] = array( - 'activity_id'=>$activity_id, - 'min_date'=>$firstReport->report_date, - 'max_date'=>date_modify(date_create($lastReport->report_date), "1 days") - ); + return response()->json(['status'=>'success','message'=>'Upload successful!','code'=>200], 200); } + return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); } - - for ($i=0; $i < count($reports); $i++) { - $activity = Activity::find($reports[$i]['activity_id']); - $activity->start_date = $reports[$i]['min_date']; - $activity->end_date = $reports[$i]['max_date']; - $activity->save(); - } - - return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); + return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400); } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index f45ab75..a12208d 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -11,6 +11,7 @@ class Controller extends BaseController { protected $pathImage = "assets/image/"; protected $pathDocument = "assets/file/project/"; + protected $pathTmpImport = "assets/file/import/"; protected $pathActivityDocument = "assets/file/activity/"; protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth']; diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index 22188ca..ea7c3d4 100644 --- a/app/Http/Controllers/DivisiController.php +++ b/app/Http/Controllers/DivisiController.php @@ -20,8 +20,8 @@ class DivisiController extends Controller public function add(Request $request){ $this->validate($request, [ 'name' => 'required', - 'description' => 'string' - // 'parent' => 'integer' + 'description' => 'string', + 'parent' => 'integer' ]); $data = $request->all(); @@ -72,18 +72,8 @@ class DivisiController extends Controller public function search() { -<<<<<<< HEAD - $payload = $request->all(); - $dataBuilder = $this->setUpPayload($payload, 'm_divisi'); - $builder = $dataBuilder['builder']; - $countBuilder = $dataBuilder['count']; - $dataGet = $builder->get(); - $totalRecord = $countBuilder->count(); - return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); -======= return $this->list(); // cant use builder for this case ->>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 } public function list() diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 0394ff6..359e14a 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -2,32 +2,30 @@ namespace App\Http\Controllers; -use App\Helpers\MasterFunctionsHelper; +use Illuminate\Http\Request; +use App\Models\Project; +use App\Models\UserToProyek; use App\Models\Activity; -use App\Models\ActivityDokumen; +use App\Models\UserToActivity; +use App\Models\User; use App\Models\AssignMaterial; -use App\Models\CommentActivity; use App\Models\DokumenProject; use App\Models\FolderDocumentProyek; -use App\Models\Holiday; -use App\Models\Image; -use App\Models\Link; -use App\Models\OfficeHours; -use App\Models\Project; -use App\Models\ProjectApproval; use App\Models\ProjectCharter; -use App\Models\ProjectMileStone; -use App\Models\ProjectParticipants; +use App\Models\ProjectApproval; use App\Models\ProjectPhase; use App\Models\ProjectType; -use App\Models\ReportActivity; -use App\Models\ReportActivityMaterial; +use App\Models\ProjectMileStone; +use App\Models\ProjectParticipants; use App\Models\ShowHideColumn; -use App\Models\User; -use App\Models\UserToActivity; -use App\Models\UserToProyek; use App\Models\VersionGantt; -use Illuminate\Http\Request; +use App\Models\Image; +use App\Models\CommentActivity; +use App\Models\Link; +use App\Models\ActivityDokumen; +use App\Models\Holiday; +use App\Models\ReportActivity; +use App\Models\OfficeHours; use Illuminate\Support\Facades\DB; const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; @@ -215,20 +213,6 @@ class ProjectController extends Controller return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); } - public function getManpower($proyek_id){ - $manPower = UserToProyek::where('proyek_id', $proyek_id)->get(); - $manCount = $manPower->count(); - return response()->json(['data'=>$manPower, 'totalRecord'=>$manCount]); - } - - public function getAssignedHR($gantt_id){ - $results = UserToActivity::select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date') - ->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id') - ->where('assign_hr_to_activity.version_gantt_id', $gantt_id) - ->get(); - return response()->json(['data'=>$results]); - } - public function list() { $data = Project::orderBy('id', 'desc')->get(); @@ -245,7 +229,7 @@ class ProjectController extends Controller $scheduleHealth = "on-track"; $rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $d->id)->orderBy('version_gantt_id', 'desc')->first(); if($rootActivity){ - $costVariance = (int)$d->rencana_biaya - $rootActivity->biaya_actual ?? 0; + $costVariance = $d->rencana_biaya - $rootActivity->biaya_actual; $actualCost = $rootActivity->biaya_actual ?? 0; $progress = $rootActivity->persentase_progress ?? 0; @@ -263,7 +247,7 @@ class ProjectController extends Controller $lastActivity = date("d/m/Y", strtotime($rootActivity->end_date)); } $d->plannedInterval = date("d/m/Y", strtotime($d->mulai_proyek)) . " - " . date("d/m/Y", strtotime($d->akhir_proyek)); - $d->plannedCost = (int)$d->rencana_biaya; + $d->plannedCost = $d->rencana_biaya; $d->actualCost = $actualCost; $d->lastActivity = $lastActivity ?? "-"; $d->costVariance = $costVariance; @@ -272,18 +256,6 @@ class ProjectController extends Controller $d->progress = $progress; $d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null; $d->manpower = UserToProyek::where("proyek_id", $d->id)->count() ?? 0; -<<<<<<< HEAD - $d->projectManager = DB::table('m_proyek') - ->join('m_users', 'm_users.id', '=', 'm_proyek.pm_id') - ->where('m_proyek.id', $d->id) - ->pluck('m_users.name') - ->first(); - $d->geolocation = []; - } - - $totalPlannedCost = $data->sum('plannedCost'); - $totalActualCost = $data->sum('actualCost'); -======= $d->projectManager = DB::table('m_proyek') ->join('m_users', 'm_users.id', '=', 'm_proyek.pm_id') ->where('m_proyek.id', $d->id) @@ -299,178 +271,60 @@ class ProjectController extends Controller $totalPlannedCost = $data->sum('plannedCost'); $totalActualCost = $data->sum('actualCost'); ->>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 $manpowers = User::count(); $projectsOnDanger = Project::where('budget_health', 'danger')->count(); - $projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); - $projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); - try { - $projectsByPhase = DB::table('m_proyek') - ->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) - ->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id') - ->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') - ->get(); - } catch (\DivisionByZeroError $e) { - return response()->json(['message' => $e->getMessage()]); - } - try { - $projectsByType = DB::table('m_proyek') - ->select('m_type_proyek.name', DB::raw('count(*) as total')) - ->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') - ->groupBy('m_type_proyek.name') - ->get(); - } catch (\DivisionByZeroError $e) { - return response()->json(['message' => $e->getMessage()]); - } + $projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); + $projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); + try { + $projectsByPhase = DB::table('m_proyek') + ->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) + ->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id') + ->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') + ->get(); + } catch (\Exception $e) { + return response()->json(['message' => $e->getMessage()]); + } + try { + $projectsByType = DB::table('m_proyek') + ->select('m_type_proyek.name', DB::raw('count(*) as total')) + ->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') + ->groupBy('m_type_proyek.name') + ->get(); + } catch (\Exception $e) { + return response()->json(['message' => $e->getMessage()]); + } return response()->json( - [ - 'status'=>'success', - 'code'=>200, - 'data'=>$data, - 'totalRecord'=>$countData, - 'totalPlannedCost' => $totalPlannedCost, - 'totalActualCost' => $totalActualCost, - 'totalRevenue' => $totalPlannedCost - $totalActualCost, - 'manpowers' => $manpowers, - 'projectsOnDanger'=> $projectsOnDanger, - 'projectPhases' => $projectPhases, - 'projectsByPhase' => $projectsByPhase, - 'projectTypes' => $projectTypes, - 'projectsByType' => $projectsByType, - ], 200); - } - - public function detail($id){ - if(empty($id) || !is_int((int)$id)) - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - - $result = Project::find($id); - - if(!$result) - return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); - - $gantt = MasterFunctionsHelper::getLatestGantt($id); - $result->projectManager = User::where('id', $result->pm_id)->value('name'); - $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first(); - return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); - } - -<<<<<<< HEAD - public function synchronizeReport($gantt_id) - { - $activities = Activity::where("version_gantt_id", $gantt_id)->get(); - $reports = []; - - foreach($activities as $activity) { - $activity_id = $activity->id; - $countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count(); - if ($countReports === 1) { - $dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); - foreach($dataReports as $dr) { - $reports[] = array( - 'activity_id'=>$activity_id, - 'min_date'=>$dr->report_date, - 'max_date'=>date_modify(date_create($dr->report_date), "1 days") - ); - } - } - if ($countReports > 1) { - $firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); - $lastReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); - $reports[] = array( - 'activity_id'=>$activity_id, - 'min_date'=>$firstReport->report_date, - 'max_date'=>date_modify(date_create($lastReport->report_date), "1 days") - ); - } - $activity->reports = $reports; - } - /* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */ - /* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */ - - for ($i=0; $i < count($reports); $i++) { - $activity = Activity::find($reports[$i]['activity_id']); - $activity->start_date = $reports[$i]['min_date']; - $activity->end_date = $reports[$i]['max_date']; - $activity->save(); - } - - return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); - } - - public function setBaseline($gantt_id) - { - $activities = Activity::where("version_gantt_id", $gantt_id)->get(); - - foreach ($activities as $activity) { - $activity->update([ - "planned_start"=>$activity->start_date, - "planned_end"=>$activity->end_date, - ]); - } - - return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); - } - - public function getOverdueActivities(Request $request){ - $payload = $request->all(); - if(empty($payload['id']) || !is_int((int)$payload['id'])) - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - - $result = Project::find($payload['id']); - - if(!$result) - return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); - //TODO possible overdue bug - if(isset($payload['till_date'])) - $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); - else - $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); - - $result->overdueActivities = $overdueActivities; - - return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); - } - - public function getInvoiceIntegration(Request $request) { - $search = urlencode($request->search); - if(empty($search)) - return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); - $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); - - $response = MasterFunctionsHelper::curlReq($url); - - - return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); + [ + 'status'=>'success', + 'code'=>200, + 'data'=>$data, + 'totalRecord'=>$countData, + 'totalPlannedCost' => $totalPlannedCost, + 'totalActualCost' => $totalActualCost, + 'totalRevenue' => $totalPlannedCost - $totalActualCost, + 'manpowers' => $manpowers, + 'projectsOnDanger'=> $projectsOnDanger, + 'projectPhases' => $projectPhases, + 'projectsByPhase' => $projectsByPhase, + 'projectTypes' => $projectTypes, + 'projectsByType' => $projectsByType, + ], 200); } - public function getReportDistribution(Request $request){ - $payload = $request->all(); - - if(empty($payload['project_id']) || !is_int((int)$payload['project_id'])) - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - - $reports = DB::table('assign_material_to_activity as ama') - ->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit', - 'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date') - ->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id') - ->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id') - ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') - ->join('m_users as u', 'u.id', '=', 'ram.user_id') - ->where('ama.proyek_id', '=', $payload['project_id']) - ->whereNotNull('ram.lat') - ->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]) + public function getListProjectTask($id){ + $data = UserToActivity::select("assign_hr_to_activity.user_id as user_id","m_proyek.*") + ->where("assign_hr_to_activity.user_id", $id) + ->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id') + ->groupBy("m_proyek.proyek_id") ->get(); - return response()->json(['status'=>'success', 'code'=> 200, 'data'=> $reports], 200); - } + if(!$data) + return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); - public function getSCurve(Request $request){ - $data = MasterFunctionsHelper::getSCurve($request); - return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); + return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); } -======= + public function dashboard($id) { $data = DB::table('m_proyek as mp') @@ -523,6 +377,5 @@ class ProjectController extends Controller return json_decode($output); } ->>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 } diff --git a/app/Models/TmpImport.php b/app/Models/TmpImport.php new file mode 100644 index 0000000..a7a2311 --- /dev/null +++ b/app/Models/TmpImport.php @@ -0,0 +1,17 @@ + Date: Wed, 15 Mar 2023 05:35:03 +0700 Subject: [PATCH 21/24] update tmp import --- routes/web.php | 831 +++++++++++++++++++++++++------------------------ 1 file changed, 426 insertions(+), 405 deletions(-) diff --git a/routes/web.php b/routes/web.php index b636078..5d81e16 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,37 +1,38 @@ get('/', function () use ($router) { - return $router->app->version(); + return $router->app->version(); }); $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($router) { - $router->post('/login', 'AuthController@login'); - - $router->post('/menu/add', 'MenuController@add'); - $router->get('/menu/edit/{id}', 'MenuController@edit'); - $router->put('/menu/update/{id}', 'MenuController@update'); - $router->delete('/menu/delete/{id}', 'MenuController@delete'); - $router->post('/menu/search', 'MenuController@search'); - $router->get('/menu/management/{id}', 'MenuController@listMenu'); - $router->get('/menu/list', 'MenuController@list'); - $router->post('/role-menu/add', 'RoleMenuController@add'); - $router->put('/role-menu/update/{id}', 'RoleMenuController@update'); - $router->delete('/role-menu/delete/{id}', 'RoleMenuController@delete'); - $router->delete('/role-menu/delete-byrole/{id}', 'RoleMenuController@deleteByRole'); - $router->post('/role-menu/search', 'RoleMenuController@search'); - $router->get('/role-menu/get-role/{id}', 'RoleMenuController@listMenu'); - - $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { - - $router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure - $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in - $router->get('/dashboard/get-project-per-schedule-health[/{year}]', 'DashboardBoDController@getProjectPerScheduleHealth'); - $router->get('/dashboard/get-project-per-budget-health[/{year}]', 'DashboardBoDController@getProjectPerBudgetHealth'); - $router->get('/dashboard/get-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getProjectScheduleHealthPerDivision'); - $router->get('/dashboard/get-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getProjectBudgetHealthPerDivision'); - $router->get('/dashboard/get-project-per-phase[/{year}]', 'DashboardBoDController@getProjectPerPhase'); // todo - $router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision'); // done - $router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision'); // done + $router->post('/login', 'AuthController@login'); + + $router->post('/menu/add', 'MenuController@add'); + $router->get('/menu/edit/{id}', 'MenuController@edit'); + $router->put('/menu/update/{id}', 'MenuController@update'); + $router->delete('/menu/delete/{id}', 'MenuController@delete'); + $router->post('/menu/search', 'MenuController@search'); + $router->get('/menu/management/{id}', 'MenuController@listMenu'); + $router->get('/menu/list', 'MenuController@list'); + $router->post('/role-menu/add', 'RoleMenuController@add'); + $router->put('/role-menu/update/{id}', 'RoleMenuController@update'); + $router->delete('/role-menu/delete/{id}', 'RoleMenuController@delete'); + $router->delete('/role-menu/delete-byrole/{id}', 'RoleMenuController@deleteByRole'); + $router->post('/role-menu/search', 'RoleMenuController@search'); + $router->get('/role-menu/get-role/{id}', 'RoleMenuController@listMenu'); + + $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { + + $router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure + $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in + $router->get('/dashboard/get-total-project-per-schedule-health[/{year}]', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); + $router->get('/dashboard/get-total-project-per-budget-health[/{year}]', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); + $router->get('/dashboard/get-total-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); + $router->get('/dashboard/get-total-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision'); + $router->get('/dashboard/get-total-project-per-phase[/{year}]', 'DashboardBoDController@getTotalProjectPerPhase'); + $router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision'); + $router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision'); + $router->get('/dashboard/get-detail-expenditure[/{year}]', 'DashboardBoDController@getDetailExpenditure'); $router->post('/role/search', 'RoleController@search'); $router->post('/role/add', 'RoleController@add'); @@ -40,384 +41,404 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->delete('/role/delete/{id}', 'RoleController@delete'); $router->get('/role/list', 'RoleController@list'); - $router->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen'); - $router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId'); - $router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete'); - $router->post('/document-project/search', 'ProjectDokumenController@searchDocProject'); + $router->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen'); + $router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId'); + $router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete'); + $router->post('/document-project/search', 'ProjectDokumenController@searchDocProject'); $router->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen'); - $router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen'); - $router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId'); - $router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete'); - $router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject'); - $router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen'); - - $router->post('/project/search', 'ProjectController@search'); - $router->post('/project/add', 'ProjectController@add'); - $router->put('/project/update/{id}', 'ProjectController@update'); - $router->get('/project/edit/{id}', 'ProjectController@edit'); - $router->delete('/project/delete/{id}', 'ProjectController@delete'); - $router->get('/project/list', 'ProjectController@list'); - $router->get('/project/dashboard/{id}', 'ProjectController@dashboard'); - $router->get('/project/list-user/{id}', 'ProjectController@getListProjectTask'); - $router->post('/project-charter/search', 'ProjectCharterController@search'); - $router->post('/project-charter/add', 'ProjectCharterController@add'); - $router->put('/project-charter/update/{id}', 'ProjectCharterController@update'); - - $router->post('/divisi/add', 'DivisiController@add'); - $router->get('/divisi/edit/{id}', 'DivisiController@edit'); - $router->put('/divisi/update/{id}', 'DivisiController@update'); - $router->post('/divisi/search', 'DivisiController@search'); - $router->delete('/divisi/delete/{id}', 'DivisiController@delete'); - $router->get('/divisi/list', 'DivisiController@list'); - - $router->post('/config-alert/search', 'ConfigAlertController@search'); - $router->post('/config-alert/add', 'ConfigAlertController@add'); - $router->get('/config-alert/edit/{id}', 'ConfigAlertController@edit'); - $router->put('/config-alert/update/{id}', 'ConfigAlertController@update'); - $router->delete('/config-alert/delete/{id}', 'ConfigAlertController@delete'); - $router->get('/config-alert/list', 'ConfigAlertController@list'); - - $router->post('/config-alert-to-user/search', 'ConfigAlertUserController@search'); - $router->post('/config-alert-to-user/add', 'ConfigAlertUserController@add'); - $router->put('/config-alert-to-user/update/{id}', 'ConfigAlertUserController@update'); - $router->delete('/config-alert-to-user/delete/{id}', 'ConfigAlertUserController@delete'); - $router->get('/config-alert/get-user/{id}', 'ConfigAlertUserController@getConfigUser'); - - $router->post('/human-resource/search', 'HumanResourceController@search'); - $router->post('/human-resource/add', 'HumanResourceController@add'); - $router->get('/human-resource/edit/{id}', 'HumanResourceController@edit'); - $router->put('/human-resource/update/{id}', 'HumanResourceController@update'); - $router->delete('/human-resource/delete/{id}', 'HumanResourceController@delete'); - $router->get('/human-resource/list', 'HumanResourceController@list'); - $router->get('/human-resource/select', 'HumanResourceController@select'); - $router->post('/human-resource/check-old-password/{id}', 'HumanResourceController@checkOldPassword'); - - $router->post('/project-role/search', 'ProjectRoleController@search'); - $router->post('/project-role/add', 'ProjectRoleController@add'); - $router->get('/project-role/edit/{id}', 'ProjectRoleController@edit'); - $router->put('/project-role/update/{id}', 'ProjectRoleController@update'); - $router->delete('/project-role/delete/{id}', 'ProjectRoleController@delete'); - $router->get('/project-role/list', 'ProjectRoleController@list'); - $router->get('/project-role/select', 'ProjectRoleController@select'); - - $router->post('/project-type/search', 'ProjectTypeController@search'); - $router->post('/project-type/add', 'ProjectTypeController@add'); - $router->get('/project-type/edit/{id}', 'ProjectTypeController@edit'); - $router->put('/project-type/update/{id}', 'ProjectTypeController@update'); - $router->delete('/project-type/delete/{id}', 'ProjectTypeController@delete'); - $router->get('/project-type/list', 'ProjectTypeController@list'); - - $router->post('/project-phase/search', 'ProjectPhaseController@search'); - $router->post('/project-phase/add', 'ProjectPhaseController@add'); - $router->get('/project-phase/edit/{id}', 'ProjectPhaseController@edit'); - $router->put('/project-phase/update/{id}', 'ProjectPhaseController@update'); - $router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete'); - $router->get('/project-phase/list', 'ProjectPhaseController@list'); - - $router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek'); - - $router->post('/request-material/add', 'RequestMaterialController@add'); - $router->post('/request-material/search', 'RequestMaterialController@search'); - $router->get('/request-material/edit/{id}', 'RequestMaterialController@edit'); - $router->put('/request-material/update/{id}', 'RequestMaterialController@update'); - $router->delete('/request-material/delete/{id}', 'RequestMaterialController@delete'); - $router->get('/request-material/list', 'RequestMaterialController@list'); - $router->get('/request-material/get-material-integration', 'RequestMaterialController@getMaterialIntegration'); - - $router->put('/request-material/update-warehouse-site/{id}', 'RequestMaterialController@updateWarehouseSite'); - - $router->post('/material-to-project/assign', 'MaterialProjectController@assignMaterial'); - - $router->post('/material-resource/add', 'MaterialResourceController@add'); - $router->post('/material-resource/search', 'MaterialResourceController@search'); - $router->get('/material-resource/update/{id}', 'MaterialResourceController@edit'); - $router->put('/material-resource/update/{id}', 'MaterialResourceController@update'); - $router->delete('/material-resource/delete/{id}', 'MaterialResourceController@delete'); - $router->get('/material-resource/list', 'MaterialResourceController@list'); - $router->get('/material-resource/select', 'MaterialResourceController@select'); - - $router->post('/tools-to-project/assign', 'ToolsProjectController@assignTools'); - $router->get('/tools-to-project/search', 'ToolsProjectController@searchTools'); - - $router->post('/tools-resource/add', 'ToolsResourceController@add'); - $router->post('/tools-resource/search', 'ToolsResourceController@search'); - $router->get('/tools-resource/edit/{id}', 'ToolsResourceController@edit'); - $router->put('/tools-resource/update/{id}', 'ToolsResourceController@update'); - $router->delete('/tools-resource/delete/{id}', 'ToolsResourceController@delete'); - $router->get('/tools-resource/list', 'ToolsResourceController@list'); - $router->get('/tools-resource/select', 'ToolsResourceController@select'); - - $router->post('/req-tools/add', 'ToolsRequestController@add'); - $router->get('/req-tools/edit/{id}', 'ToolsRequestController@edit'); - $router->put('/req-tools/update/{id}', 'ToolsRequestController@update'); - $router->post('/req-tools/search', 'ToolsRequestController@search'); - $router->delete('/req-tools/delete/{id}', 'ToolsRequestController@delete'); - $router->get('/req-tools/list', 'ToolsRequestController@list'); - - $router->post('/version-gantt/add', 'VersionGanttController@add'); - $router->get('/version-gantt/edit/{id}', 'VersionGanttController@edit'); - $router->put('/version-gantt/update/{id}', 'VersionGanttController@update'); - $router->post('/version-gantt/search', 'VersionGanttController@search'); - $router->delete('/version-gantt/delete/{id}', 'VersionGanttController@delete'); - $router->get('/version-gantt/list', 'VersionGanttController@list'); - - $router->post('/user-to-version-gantt/add', 'UserToVersionGanttController@add'); - $router->post('/user-to-version-gantt/add-multiple', 'UserToVersionGanttController@addMultiple'); - $router->get('/user-to-version-gantt/edit/{id}', 'UserToVersionGanttController@edit'); - $router->put('/user-to-version-gantt/update/{id}', 'UserToVersionGanttController@update'); - $router->post('/user-to-version-gantt/search', 'UserToVersionGanttController@search'); - $router->delete('/user-to-version-gantt/delete/{id}', 'UserToVersionGanttController@delete'); - $router->get('/user-to-version-gantt/list', 'UserToVersionGanttController@list'); - $router->get('/user-to-version-gantt/get-by-gantt/{gantt_id}', 'UserToVersionGanttController@getByUserGantt'); - - $router->post('/user-to-activity/add', 'UserToActivityController@add'); - $router->post('/user-to-activity/add-multiple', 'UserToActivityController@addMultiple'); - $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); - $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); - $router->post('/user-to-activity/search', 'UserToActivityController@search'); - $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); - $router->get('/user-to-activity/list', 'UserToActivityController@list'); - $router->get('/user-to-activity/datatables', 'UserToActivityController@datatables'); - - $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); - $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); - $router->get('/activity/search', 'ActivityController@search'); - $router->post('/task', 'ActivityController@add'); - $router->get('/task/edit/{id}', 'ActivityController@edit'); - $router->put('/task/{id}', 'ActivityController@update'); - $router->put('/task/update-regular/{id}', 'ActivityController@updateRegular'); - $router->delete('/task/{id}', 'ActivityController@delete'); - $router->get('/task/get-update/{id}', 'ActivityController@getUpdate'); - $router->post('/activity/get-percentage', 'ActivityController@getPercentagePerDay'); - $router->get('/activity/set-baseline/{gantt_id}', 'ActivityController@setBaseline'); - $router->post('/activity/get-curva-s', 'ActivityController@getCalculateCurvaS'); - $router->get('/activity/synchronize-report/{gantt_id}', 'ActivityController@synchronizeReport'); - - $router->post('/link', 'LinkController@add'); - $router->put('/link/{id}', 'LinkController@update'); - $router->delete('/link/{id}', 'LinkController@delete'); - - $router->post('/template-gantt/add', 'TemplateGanttController@add'); - $router->get('/template-gantt/edit/{id}', 'TemplateGanttController@edit'); - $router->put('/template-gantt/update/{id}', 'TemplateGanttController@update'); - $router->post('/template-gantt/search', 'TemplateGanttController@search'); - $router->delete('/template-gantt/delete/{id}', 'TemplateGanttController@delete'); - $router->get('/template-gantt/list', 'TemplateGanttController@list'); - $router->get('/template-gantt/get-tree/{id}', 'TemplateGanttController@getTreeByTypeProject'); - - $router->post('/comment-activity/add', 'CommentActivityController@add'); - $router->get('/comment-activity/edit/{id}', 'CommentActivityController@edit'); - $router->put('/comment-activity/update/{id}', 'CommentActivityController@update'); - $router->post('/comment-activity/search', 'CommentActivityController@search'); - $router->delete('/comment-activity/delete/{id}', 'CommentActivityController@delete'); - $router->get('/comment-activity/list', 'CommentActivityController@list'); - - $router->post('/presence/add', 'PresenceController@add'); - $router->get('/presence/edit/{id}', 'PresenceController@edit'); - $router->put('/presence/update/{id}', 'PresenceController@update'); - $router->post('/presence/search', 'PresenceController@search'); - $router->delete('/presence/delete/{id}', 'PresenceController@delete'); - $router->get('/presence/list', 'PresenceController@list'); - $router->get('/presence/clockinout/{id}', 'PresenceController@clockinout'); - $router->get('/presence/bulk-update-location', 'PresenceController@bulkUpdateLocation'); - - $router->post('/permit/add', 'AbsentController@add'); - $router->get('/permit/edit/{id}', 'AbsentController@edit'); - $router->put('/permit/update/{id}', 'AbsentController@update'); - $router->post('/permit/search', 'AbsentController@search'); - $router->delete('/permit/delete/{id}', 'AbsentController@delete'); - $router->get('/permit/list', 'AbsentController@list'); - - $router->post('/assign-tools/add', 'AssignToolsController@add'); - $router->get('/assign-tools/edit/{id}', 'AssignToolsController@edit'); - $router->put('/assign-tools/update/{id}', 'AssignToolsController@update'); - $router->post('/assign-tools/search', 'AssignToolsController@search'); - $router->delete('/assign-tools/delete/{id}', 'AssignToolsController@delete'); - $router->get('/assign-tools/list', 'AssignToolsController@list'); - $router->get('/assign-tools/datatables', 'AssignToolsController@datatables'); - - $router->post('/assign-material/add', 'AssignMaterialController@add'); - $router->get('/assign-material/edit/{id}', 'AssignMaterialController@edit'); - $router->put('/assign-material/update/{id}', 'AssignMaterialController@update'); - $router->post('/assign-material/search', 'AssignMaterialController@search'); - $router->delete('/assign-material/delete/{id}', 'AssignMaterialController@delete'); - $router->get('/assign-material/list', 'AssignMaterialController@list'); - $router->get('/assign-material/datatables', 'AssignMaterialController@datatables'); - $router->get('/assign-material/datatablesForReportActivity', 'AssignMaterialController@datatablesForReportActivity'); - $router->post('/assign-material/ForReportActivityByMaterial', 'AssignMaterialController@ForReportActivityByMaterial'); - - $router->post('/image/search', 'ImageController@search'); - $router->delete('/image/delete/{id}', 'ImageController@delete'); - $router->delete('/image/delete/{id}/{category}', 'ImageController@deleteByRef'); - $router->post('/image/upload', 'ImageController@uploadImage'); - $router->get('/image/{id}/{category}', 'ImageController@getByRefId'); - - $router->post('/panic-button/add', 'PanicButtonController@add'); - $router->get('/panic-button/edit/{id}', 'PanicButtonController@edit'); - $router->put('/panic-button/update/{id}', 'PanicButtonController@update'); - $router->post('/panic-button/search', 'PanicButtonController@search'); - $router->delete('/panic-button/delete/{id}', 'PanicButtonController@delete'); - $router->get('/panic-button/list', 'PanicButtonController@list'); - - $router->post('/rate-sallary/add', 'RateSallaryController@add'); - $router->get('/rate-sallary/edit/{id}', 'RateSallaryController@edit'); - $router->put('/rate-sallary/update/{id}', 'RateSallaryController@update'); - $router->post('/rate-sallary/search', 'RateSallaryController@search'); - $router->delete('/rate-sallary/delete/{id}', 'RateSallaryController@delete'); - $router->get('/rate-sallary/list', 'RateSallaryController@list'); - - $router->post('/project-participants/add', 'ProjectParticipantsController@add'); - $router->get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit'); - $router->put('/project-participants/update/{id}', 'ProjectParticipantsController@update'); - $router->post('/project-participants/search', 'ProjectParticipantsController@search'); - $router->delete('/project-participants/delete/{id}', 'ProjectParticipantsController@delete'); - $router->delete('/project-participants/delete-by-proyek/{id}', 'ProjectParticipantsController@deleteByProyek'); - $router->get('/project-participants/list', 'ProjectParticipantsController@list'); - $router->get('/project-participants/{where}/{val}', 'ProjectParticipantsController@customWhere'); - - $router->post('/project-approval/add', 'ProjectApprovalController@add'); - $router->get('/project-approval/edit/{id}', 'ProjectApprovalController@edit'); - $router->put('/project-approval/update/{id}', 'ProjectApprovalController@update'); - $router->post('/project-approval/search', 'ProjectApprovalController@search'); - $router->delete('/project-approval/delete/{id}', 'ProjectApprovalController@delete'); - $router->delete('/project-approval/delete-by-proyek/{id}', 'ProjectApprovalController@deleteByProyek'); - $router->get('/project-approval/list', 'ProjectApprovalController@list'); - $router->get('/project-approval/{where}/{val}', 'ProjectApprovalController@customWhere'); - - $router->post('/project-milestone/add', 'ProjectMileStoneController@add'); - $router->get('/project-milestone/edit/{id}', 'ProjectMileStoneController@edit'); - $router->put('/project-milestone/update/{id}', 'ProjectMileStoneController@update'); - $router->post('/project-milestone/search', 'ProjectMileStoneController@search'); - $router->delete('/project-milestone/delete/{id}', 'ProjectMileStoneController@delete'); - $router->delete('/project-milestone/delete-by-proyek/{id}', 'ProjectMileStoneController@deleteByProyek'); - $router->get('/project-milestone/list', 'ProjectMileStoneController@list'); - $router->get('/project-milestone/select', 'ProjectMileStoneController@select'); - $router->get('/project-milestone/{where}/{val}', 'ProjectMileStoneController@customWhere'); - - $router->post('/report-activity/add', 'ReportActivityController@add'); - $router->get('/report-activity/edit/{id}', 'ReportActivityController@edit'); - $router->put('/report-activity/update/{id}', 'ReportActivityController@update'); - $router->post('/report-activity/search', 'ReportActivityController@search'); - $router->delete('/report-activity/delete/{id}', 'ReportActivityController@delete'); - $router->get('/report-activity/list', 'ReportActivityController@list'); - $router->post('/report-activity/search-point', 'ReportActivityController@searchPoint'); - $router->get('/report-activity/datatables', 'ReportActivityController@datatables'); - - $router->post('/report-activity-material/add', 'ReportActivityMaterialController@add'); - $router->post('/report-activity-material/search', 'ReportActivityMaterialController@search'); - $router->delete('/report-activity-material/delete/{id}', 'ReportActivityMaterialController@delete'); - $router->get('/report-activity-material/list', 'ReportActivityMaterialController@list'); - $router->get('/report-activity-material/datatables', 'ReportActivityMaterialController@datatables'); - $router->post('/report-activity-material/update-status', 'ReportActivityMaterialController@updateStatusStartFinish'); - $router->get('/report-activity-material/test', 'ReportActivityMaterialController@countForProgressTest'); - - - $router->post('/waypoint/add', 'WaypointController@add'); - $router->get('/waypoint/edit/{id}', 'WaypointController@edit'); - $router->put('/waypoint/update/{id}', 'WaypointController@update'); - $router->post('/waypoint/search', 'WaypointController@search'); - $router->delete('/waypoint/delete/{id}', 'WaypointController@delete'); - $router->get('/waypoint/list', 'WaypointController@list'); - - $router->post('/holiday/add', 'HolidayController@add'); - $router->get('/holiday/edit/{id}', 'HolidayController@edit'); - $router->put('/holiday/update/{id}', 'HolidayController@update'); - $router->post('/holiday/search', 'HolidayController@search'); - $router->delete('/holiday/delete/{id}', 'HolidayController@delete'); - $router->get('/holiday/list', 'HolidayController@list'); - $router->get('/holiday/datatables', 'HolidayController@datatables'); - - $router->post('/satuan/add', 'SatuanController@add'); - $router->get('/satuan/edit/{id}', 'SatuanController@edit'); - $router->put('/satuan/update/{id}', 'SatuanController@update'); - $router->post('/satuan/search', 'SatuanController@search'); - $router->delete('/satuan/delete/{id}', 'SatuanController@delete'); - $router->get('/satuan/list', 'SatuanController@list'); - - $router->post('/checklist-k3/add', 'ChecklistK3Controller@add'); - $router->get('/checklist-k3/edit/{id}', 'ChecklistK3Controller@edit'); - $router->put('/checklist-k3/update/{id}', 'ChecklistK3Controller@update'); - $router->post('/checklist-k3/search', 'ChecklistK3Controller@search'); - $router->delete('/checklist-k3/delete/{id}', 'ChecklistK3Controller@delete'); - $router->get('/checklist-k3/list', 'ChecklistK3Controller@list'); - - $router->post('/report-k3/add', 'ReportK3Controller@add'); - $router->get('/report-k3/edit/{id}', 'ReportK3Controller@edit'); - $router->put('/report-k3/update/{id}', 'ReportK3Controller@update'); - $router->post('/report-k3/search', 'ReportK3Controller@search'); - $router->delete('/report-k3/delete/{id}', 'ReportK3Controller@delete'); - $router->get('/report-k3/list', 'ReportK3Controller@list'); - - $router->post('/report-k3-detail/add', 'ReportK3DetailController@add'); - $router->get('/report-k3-detail/edit/{id}', 'ReportK3DetailController@edit'); - $router->put('/report-k3-detail/update/{id}', 'ReportK3DetailController@update'); - $router->post('/report-k3-detail/search', 'ReportK3DetailController@search'); - $router->delete('/report-k3-detail/delete/{id}', 'ReportK3DetailController@delete'); - $router->get('/report-k3-detail/list', 'ReportK3DetailController@list'); - - $router->post('/user-to-proyek/add', 'UserToProyekController@add'); - $router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit'); - $router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update'); - $router->post('/user-to-proyek/search', 'UserToProyekController@search'); - $router->delete('/user-to-proyek/delete/{id}', 'UserToProyekController@delete'); - $router->get('/user-to-proyek/list', 'UserToProyekController@list'); - $router->get('/user-to-proyek/select', 'UserToProyekController@select'); - $router->get('/user-to-proyek/get-employee-integration', 'UserToProyekController@getEmployeeIntegration'); - - $router->post('/folder-document-proyek/add', 'FolderDocumentProyekController@add'); - $router->get('/folder-document-proyek/edit/{id}', 'FolderDocumentProyekController@edit'); - $router->put('/folder-document-proyek/update/{id}', 'FolderDocumentProyekController@update'); - $router->post('/folder-document-proyek/search', 'FolderDocumentProyekController@search'); - $router->delete('/folder-document-proyek/delete/{id}', 'FolderDocumentProyekController@delete'); - $router->get('/folder-document-proyek/list', 'FolderDocumentProyekController@list'); - $router->get('/folder-document-proyek/get-tree/{id}', 'FolderDocumentProyekController@getTree'); - - $router->post('/office-hours/add', 'OfficeHoursController@add'); - $router->get('/office-hours/edit/{id}', 'OfficeHoursController@edit'); - $router->put('/office-hours/update/{id}', 'OfficeHoursController@update'); - $router->post('/office-hours/search', 'OfficeHoursController@search'); - $router->delete('/office-hours/delete/{id}', 'OfficeHoursController@delete'); - $router->get('/office-hours/list', 'OfficeHoursController@list'); - - $router->get('/gantt-show-hide/get-by-gantt/{gantt_id}', 'ShowHideColumnController@getByUserGantt'); - $router->post('/gantt-show-hide/add', 'ShowHideColumnController@add'); - $router->post('/gantt-show-hide/update/{gantt_id}', 'ShowHideColumnController@update'); - - - $router->post('/shift/add', 'ShiftController@add'); - $router->get('/shift/edit/{id}', 'ShiftController@edit'); - $router->put('/shift/update/{id}', 'ShiftController@update'); - $router->post('/shift/search', 'ShiftController@search'); - $router->delete('/shift/delete/{id}', 'ShiftController@delete'); - $router->get('/shift/list', 'ShiftController@list'); - - $router->post('/user-monthly-shift/add', 'UserMonthlyShiftController@add'); - $router->put('/user-monthly-shift/update/{id}', 'UserMonthlyShiftController@update'); - $router->post('/user-monthly-shift/search', 'UserMonthlyShiftController@search'); - $router->delete('/user-monthly-shift/delete/{id}', 'UserMonthlyShiftController@delete'); - $router->delete('/user-monthly-shift/delete-at/{yyyymm}', 'UserMonthlyShiftController@deleteYYYYMM'); - $router->get('/user-monthly-shift/list', 'UserMonthlyShiftController@list'); - $router->post('/user-monthly-shift/import', 'UserMonthlyShiftController@import'); - $router->get('/user-monthly-shift/list/{yyyymm}', 'UserMonthlyShiftController@listYYYYMM'); - - $router->post('/user-to-shift/add', 'UserToShiftController@add'); - $router->get('/user-to-shift/edit/{id}', 'UserToShiftController@edit'); - $router->put('/user-to-shift/update/{id}', 'UserToShiftController@update'); - $router->post('/user-to-shift/search', 'UserToShiftController@search'); - $router->delete('/user-to-shift/delete/{id}', 'UserToShiftController@delete'); - $router->get('/user-to-shift/list', 'UserToShiftController@list'); - - $router->post('/control-monitoring/search', 'ControlMonitoringController@search'); - $router->get('/currency/list', 'CurrencyController@list'); - - $router->post('/project-to-checklist-k3/add', 'ProjectToChecklistK3Controller@add'); - $router->post('/project-to-checklist-k3/add-multiple', 'ProjectToChecklistK3Controller@addMultiple'); - $router->get('/project-to-checklist-k3/edit/{id}', 'ProjectToChecklistK3Controller@edit'); - $router->put('/project-to-checklist-k3/update/{id}', 'ProjectToChecklistK3Controller@update'); - $router->post('/project-to-checklist-k3/search', 'ProjectToChecklistK3Controller@search'); - $router->delete('/project-to-checklist-k3/delete/{id}', 'ProjectToChecklistK3Controller@delete'); - $router->get('/project-to-checklist-k3/list', 'ProjectToChecklistK3Controller@list'); - }); + $router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen'); + $router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId'); + $router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete'); + $router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject'); + $router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen'); + + $router->post('/project/search', 'ProjectController@search'); + $router->post('/project/add', 'ProjectController@add'); + $router->put('/project/update/{id}', 'ProjectController@update'); + $router->get('/project/edit/{id}', 'ProjectController@edit'); + $router->get('/project/detail/{id}', 'ProjectController@detail'); + $router->delete('/project/delete/{id}', 'ProjectController@delete'); + $router->get('/project/list', 'ProjectController@list'); + $router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline'); + $router->get('/project/synchronize-report/{gantt_id}', 'ProjectController@synchronizeReport'); + $router->get('/project/manpower/{proyek_id}', 'ProjectController@getManpower'); + $router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR'); + + $router->post('/project/get-s-curve', 'ProjectController@getSCurve'); + $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); + $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); + $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); + + /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ + /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ + /* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */ + /* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */ + + + $router->post('/project-charter/search', 'ProjectCharterController@search'); + $router->post('/project-charter/add', 'ProjectCharterController@add'); + $router->put('/project-charter/update/{id}', 'ProjectCharterController@update'); + + $router->post('/divisi/add', 'DivisiController@add'); + $router->get('/divisi/edit/{id}', 'DivisiController@edit'); + $router->put('/divisi/update/{id}', 'DivisiController@update'); + $router->post('/divisi/search', 'DivisiController@search'); + $router->delete('/divisi/delete/{id}', 'DivisiController@delete'); + $router->get('/divisi/list', 'DivisiController@list'); + + $router->post('/config-alert/search', 'ConfigAlertController@search'); + $router->post('/config-alert/add', 'ConfigAlertController@add'); + $router->get('/config-alert/edit/{id}', 'ConfigAlertController@edit'); + $router->put('/config-alert/update/{id}', 'ConfigAlertController@update'); + $router->delete('/config-alert/delete/{id}', 'ConfigAlertController@delete'); + $router->get('/config-alert/list', 'ConfigAlertController@list'); + + $router->post('/config-alert-to-user/search', 'ConfigAlertUserController@search'); + $router->post('/config-alert-to-user/add', 'ConfigAlertUserController@add'); + $router->put('/config-alert-to-user/update/{id}', 'ConfigAlertUserController@update'); + $router->delete('/config-alert-to-user/delete/{id}', 'ConfigAlertUserController@delete'); + $router->get('/config-alert/get-user/{id}', 'ConfigAlertUserController@getConfigUser'); + + $router->post('/human-resource/search', 'HumanResourceController@search'); + $router->post('/human-resource/add', 'HumanResourceController@add'); + $router->get('/human-resource/edit/{id}', 'HumanResourceController@edit'); + $router->put('/human-resource/update/{id}', 'HumanResourceController@update'); + $router->delete('/human-resource/delete/{id}', 'HumanResourceController@delete'); + $router->get('/human-resource/list', 'HumanResourceController@list'); + $router->get('/human-resource/select', 'HumanResourceController@select'); + $router->post('/human-resource/check-old-password/{id}', 'HumanResourceController@checkOldPassword'); + + $router->post('/project-role/search', 'ProjectRoleController@search'); + $router->post('/project-role/add', 'ProjectRoleController@add'); + $router->get('/project-role/edit/{id}', 'ProjectRoleController@edit'); + $router->put('/project-role/update/{id}', 'ProjectRoleController@update'); + $router->delete('/project-role/delete/{id}', 'ProjectRoleController@delete'); + $router->get('/project-role/list', 'ProjectRoleController@list'); + $router->get('/project-role/select', 'ProjectRoleController@select'); + + $router->post('/project-type/search', 'ProjectTypeController@search'); + $router->post('/project-type/add', 'ProjectTypeController@add'); + $router->get('/project-type/edit/{id}', 'ProjectTypeController@edit'); + $router->put('/project-type/update/{id}', 'ProjectTypeController@update'); + $router->delete('/project-type/delete/{id}', 'ProjectTypeController@delete'); + $router->get('/project-type/list', 'ProjectTypeController@list'); + + $router->post('/project-phase/search', 'ProjectPhaseController@search'); + $router->post('/project-phase/add', 'ProjectPhaseController@add'); + $router->get('/project-phase/edit/{id}', 'ProjectPhaseController@edit'); + $router->put('/project-phase/update/{id}', 'ProjectPhaseController@update'); + $router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete'); + $router->get('/project-phase/list', 'ProjectPhaseController@list'); + + $router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek'); + + $router->post('/request-material/add', 'RequestMaterialController@add'); + $router->post('/request-material/search', 'RequestMaterialController@search'); + $router->get('/request-material/edit/{id}', 'RequestMaterialController@edit'); + $router->put('/request-material/update/{id}', 'RequestMaterialController@update'); + $router->delete('/request-material/delete/{id}', 'RequestMaterialController@delete'); + $router->get('/request-material/list', 'RequestMaterialController@list'); + $router->get('/request-material/get-material-integration', 'RequestMaterialController@getMaterialIntegration'); + + $router->put('/request-material/update-warehouse-site/{id}', 'RequestMaterialController@updateWarehouseSite'); + + $router->post('/material-to-project/assign', 'MaterialProjectController@assignMaterial'); + + $router->post('/material-resource/add', 'MaterialResourceController@add'); + $router->post('/material-resource/search', 'MaterialResourceController@search'); + $router->get('/material-resource/update/{id}', 'MaterialResourceController@edit'); + $router->put('/material-resource/update/{id}', 'MaterialResourceController@update'); + $router->delete('/material-resource/delete/{id}', 'MaterialResourceController@delete'); + $router->get('/material-resource/list', 'MaterialResourceController@list'); + $router->get('/material-resource/select', 'MaterialResourceController@select'); + + $router->post('/tools-to-project/assign', 'ToolsProjectController@assignTools'); + $router->get('/tools-to-project/search', 'ToolsProjectController@searchTools'); + + $router->post('/tools-resource/add', 'ToolsResourceController@add'); + $router->post('/tools-resource/search', 'ToolsResourceController@search'); + $router->get('/tools-resource/edit/{id}', 'ToolsResourceController@edit'); + $router->put('/tools-resource/update/{id}', 'ToolsResourceController@update'); + $router->delete('/tools-resource/delete/{id}', 'ToolsResourceController@delete'); + $router->get('/tools-resource/list', 'ToolsResourceController@list'); + $router->get('/tools-resource/select', 'ToolsResourceController@select'); + + $router->post('/req-tools/add', 'ToolsRequestController@add'); + $router->get('/req-tools/edit/{id}', 'ToolsRequestController@edit'); + $router->put('/req-tools/update/{id}', 'ToolsRequestController@update'); + $router->post('/req-tools/search', 'ToolsRequestController@search'); + $router->delete('/req-tools/delete/{id}', 'ToolsRequestController@delete'); + $router->get('/req-tools/list', 'ToolsRequestController@list'); + + $router->post('/version-gantt/add', 'VersionGanttController@add'); + $router->get('/version-gantt/edit/{id}', 'VersionGanttController@edit'); + $router->put('/version-gantt/update/{id}', 'VersionGanttController@update'); + $router->post('/version-gantt/search', 'VersionGanttController@search'); + $router->delete('/version-gantt/delete/{id}', 'VersionGanttController@delete'); + $router->get('/version-gantt/list', 'VersionGanttController@list'); + + $router->post('/user-to-version-gantt/add', 'UserToVersionGanttController@add'); + $router->post('/user-to-version-gantt/add-multiple', 'UserToVersionGanttController@addMultiple'); + $router->get('/user-to-version-gantt/edit/{id}', 'UserToVersionGanttController@edit'); + $router->put('/user-to-version-gantt/update/{id}', 'UserToVersionGanttController@update'); + $router->post('/user-to-version-gantt/search', 'UserToVersionGanttController@search'); + $router->delete('/user-to-version-gantt/delete/{id}', 'UserToVersionGanttController@delete'); + $router->get('/user-to-version-gantt/list', 'UserToVersionGanttController@list'); + $router->get('/user-to-version-gantt/get-by-gantt/{gantt_id}', 'UserToVersionGanttController@getByUserGantt'); + + $router->post('/user-to-activity/add', 'UserToActivityController@add'); + $router->post('/user-to-activity/add-multiple', 'UserToActivityController@addMultiple'); + $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); + $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); + $router->post('/user-to-activity/search', 'UserToActivityController@search'); + $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); + $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); + $router->get('/user-to-activity/list', 'UserToActivityController@list'); + $router->get('/user-to-activity/datatables', 'UserToActivityController@datatables'); + + $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); + $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); + $router->get('/activity/search', 'ActivityController@search'); + $router->post('/activity/import', 'ActivityController@import'); + $router->post('/task', 'ActivityController@add'); + $router->get('/task/edit/{id}', 'ActivityController@edit'); + $router->put('/task/{id}', 'ActivityController@update'); + $router->put('/task/update-regular/{id}', 'ActivityController@updateRegular'); + $router->delete('/task/{id}', 'ActivityController@delete'); + $router->get('/task/get-update/{id}', 'ActivityController@getUpdate'); + + $router->post('/link', 'LinkController@add'); + $router->put('/link/{id}', 'LinkController@update'); + $router->delete('/link/{id}', 'LinkController@delete'); + + $router->post('/template-gantt/add', 'TemplateGanttController@add'); + $router->get('/template-gantt/edit/{id}', 'TemplateGanttController@edit'); + $router->put('/template-gantt/update/{id}', 'TemplateGanttController@update'); + $router->post('/template-gantt/search', 'TemplateGanttController@search'); + $router->delete('/template-gantt/delete/{id}', 'TemplateGanttController@delete'); + $router->get('/template-gantt/list', 'TemplateGanttController@list'); + $router->get('/template-gantt/get-tree/{id}', 'TemplateGanttController@getTreeByTypeProject'); + + $router->post('/comment-activity/add', 'CommentActivityController@add'); + $router->get('/comment-activity/edit/{id}', 'CommentActivityController@edit'); + $router->put('/comment-activity/update/{id}', 'CommentActivityController@update'); + $router->post('/comment-activity/search', 'CommentActivityController@search'); + $router->delete('/comment-activity/delete/{id}', 'CommentActivityController@delete'); + $router->get('/comment-activity/list', 'CommentActivityController@list'); + + $router->post('/presence/add', 'PresenceController@add'); + $router->get('/presence/edit/{id}', 'PresenceController@edit'); + $router->put('/presence/update/{id}', 'PresenceController@update'); + $router->post('/presence/search', 'PresenceController@search'); + $router->delete('/presence/delete/{id}', 'PresenceController@delete'); + $router->get('/presence/list', 'PresenceController@list'); + $router->get('/presence/clockinout/{id}', 'PresenceController@clockinout'); + $router->post('/presence/reportk3', 'PresenceController@reportK3'); + $router->get('/presence/bulk-update-location', 'PresenceController@bulkUpdateLocation'); + + $router->post('/permit/add', 'AbsentController@add'); + $router->get('/permit/edit/{id}', 'AbsentController@edit'); + $router->put('/permit/update/{id}', 'AbsentController@update'); + $router->post('/permit/search', 'AbsentController@search'); + $router->delete('/permit/delete/{id}', 'AbsentController@delete'); + $router->get('/permit/list', 'AbsentController@list'); + + $router->post('/assign-tools/add', 'AssignToolsController@add'); + $router->get('/assign-tools/edit/{id}', 'AssignToolsController@edit'); + $router->put('/assign-tools/update/{id}', 'AssignToolsController@update'); + $router->post('/assign-tools/search', 'AssignToolsController@search'); + $router->delete('/assign-tools/delete/{id}', 'AssignToolsController@delete'); + $router->get('/assign-tools/list', 'AssignToolsController@list'); + $router->get('/assign-tools/datatables', 'AssignToolsController@datatables'); + + $router->post('/assign-material/add', 'AssignMaterialController@add'); + $router->get('/assign-material/edit/{id}', 'AssignMaterialController@edit'); + $router->put('/assign-material/update/{id}', 'AssignMaterialController@update'); + $router->post('/assign-material/search', 'AssignMaterialController@search'); + $router->delete('/assign-material/delete/{id}', 'AssignMaterialController@delete'); + $router->get('/assign-material/list', 'AssignMaterialController@list'); + $router->get('/assign-material/datatables', 'AssignMaterialController@datatables'); + $router->get('/assign-material/datatablesForReportActivity', 'AssignMaterialController@datatablesForReportActivity'); + $router->post('/assign-material/ForReportActivityByMaterial', 'AssignMaterialController@ForReportActivityByMaterial'); + + $router->post('/image/search', 'ImageController@search'); + $router->delete('/image/delete/{id}', 'ImageController@delete'); + $router->delete('/image/delete/{id}/{category}', 'ImageController@deleteByRef'); + $router->post('/image/upload', 'ImageController@uploadImage'); + $router->get('/image/{id}/{category}', 'ImageController@getByRefId'); + + $router->post('/panic-button/add', 'PanicButtonController@add'); + $router->get('/panic-button/edit/{id}', 'PanicButtonController@edit'); + $router->put('/panic-button/update/{id}', 'PanicButtonController@update'); + $router->post('/panic-button/search', 'PanicButtonController@search'); + $router->delete('/panic-button/delete/{id}', 'PanicButtonController@delete'); + $router->get('/panic-button/list', 'PanicButtonController@list'); + + $router->post('/rate-sallary/add', 'RateSallaryController@add'); + $router->get('/rate-sallary/edit/{id}', 'RateSallaryController@edit'); + $router->put('/rate-sallary/update/{id}', 'RateSallaryController@update'); + $router->post('/rate-sallary/search', 'RateSallaryController@search'); + $router->delete('/rate-sallary/delete/{id}', 'RateSallaryController@delete'); + $router->get('/rate-sallary/list', 'RateSallaryController@list'); + + $router->post('/project-participants/add', 'ProjectParticipantsController@add'); + $router->get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit'); + $router->put('/project-participants/update/{id}', 'ProjectParticipantsController@update'); + $router->post('/project-participants/search', 'ProjectParticipantsController@search'); + $router->delete('/project-participants/delete/{id}', 'ProjectParticipantsController@delete'); + $router->delete('/project-participants/delete-by-proyek/{id}', 'ProjectParticipantsController@deleteByProyek'); + $router->get('/project-participants/list', 'ProjectParticipantsController@list'); + $router->get('/project-participants/{where}/{val}', 'ProjectParticipantsController@customWhere'); + + $router->post('/project-approval/add', 'ProjectApprovalController@add'); + $router->get('/project-approval/edit/{id}', 'ProjectApprovalController@edit'); + $router->put('/project-approval/update/{id}', 'ProjectApprovalController@update'); + $router->post('/project-approval/search', 'ProjectApprovalController@search'); + $router->delete('/project-approval/delete/{id}', 'ProjectApprovalController@delete'); + $router->delete('/project-approval/delete-by-proyek/{id}', 'ProjectApprovalController@deleteByProyek'); + $router->get('/project-approval/list', 'ProjectApprovalController@list'); + $router->get('/project-approval/{where}/{val}', 'ProjectApprovalController@customWhere'); + + $router->post('/project-milestone/add', 'ProjectMileStoneController@add'); + $router->get('/project-milestone/edit/{id}', 'ProjectMileStoneController@edit'); + $router->put('/project-milestone/update/{id}', 'ProjectMileStoneController@update'); + $router->post('/project-milestone/search', 'ProjectMileStoneController@search'); + $router->delete('/project-milestone/delete/{id}', 'ProjectMileStoneController@delete'); + $router->delete('/project-milestone/delete-by-proyek/{id}', 'ProjectMileStoneController@deleteByProyek'); + $router->get('/project-milestone/list', 'ProjectMileStoneController@list'); + $router->get('/project-milestone/select', 'ProjectMileStoneController@select'); + $router->get('/project-milestone/{where}/{val}', 'ProjectMileStoneController@customWhere'); + + $router->post('/report-activity/add', 'ReportActivityController@add'); + $router->get('/report-activity/edit/{id}', 'ReportActivityController@edit'); + $router->put('/report-activity/update/{id}', 'ReportActivityController@update'); + $router->post('/report-activity/search', 'ReportActivityController@search'); + $router->delete('/report-activity/delete/{id}', 'ReportActivityController@delete'); + $router->get('/report-activity/list', 'ReportActivityController@list'); + $router->post('/report-activity/search-point', 'ReportActivityController@searchPoint'); + $router->get('/report-activity/datatables', 'ReportActivityController@datatables'); + + $router->post('/report-activity-material/add', 'ReportActivityMaterialController@add'); + $router->post('/report-activity-material/search', 'ReportActivityMaterialController@search'); + $router->delete('/report-activity-material/delete/{id}', 'ReportActivityMaterialController@delete'); + $router->get('/report-activity-material/list', 'ReportActivityMaterialController@list'); + $router->get('/report-activity-material/datatables', 'ReportActivityMaterialController@datatables'); + $router->post('/report-activity-material/update-status', 'ReportActivityMaterialController@updateStatusStartFinish'); + + $router->post('/waypoint/add', 'WaypointController@add'); + $router->post('/waypoint/add-bulk', 'WaypointController@addBulk'); + $router->get('/waypoint/edit/{id}', 'WaypointController@edit'); + $router->put('/waypoint/update/{id}', 'WaypointController@update'); + $router->post('/waypoint/search', 'WaypointController@search'); + $router->delete('/waypoint/delete/{id}', 'WaypointController@delete'); + $router->get('/waypoint/list', 'WaypointController@list'); + + $router->post('/holiday/add', 'HolidayController@add'); + $router->get('/holiday/edit/{id}', 'HolidayController@edit'); + $router->put('/holiday/update/{id}', 'HolidayController@update'); + $router->post('/holiday/search', 'HolidayController@search'); + $router->delete('/holiday/delete/{id}', 'HolidayController@delete'); + $router->get('/holiday/list', 'HolidayController@list'); + $router->get('/holiday/datatables', 'HolidayController@datatables'); + + $router->post('/satuan/add', 'SatuanController@add'); + $router->get('/satuan/edit/{id}', 'SatuanController@edit'); + $router->put('/satuan/update/{id}', 'SatuanController@update'); + $router->post('/satuan/search', 'SatuanController@search'); + $router->delete('/satuan/delete/{id}', 'SatuanController@delete'); + $router->get('/satuan/list', 'SatuanController@list'); + + $router->post('/checklist-k3/add', 'ChecklistK3Controller@add'); + $router->get('/checklist-k3/edit/{id}', 'ChecklistK3Controller@edit'); + $router->put('/checklist-k3/update/{id}', 'ChecklistK3Controller@update'); + $router->post('/checklist-k3/search', 'ChecklistK3Controller@search'); + $router->delete('/checklist-k3/delete/{id}', 'ChecklistK3Controller@delete'); + $router->get('/checklist-k3/list', 'ChecklistK3Controller@list'); + + $router->post('/report-k3/add', 'ReportK3Controller@add'); + $router->get('/report-k3/edit/{id}', 'ReportK3Controller@edit'); + $router->put('/report-k3/update/{id}', 'ReportK3Controller@update'); + $router->post('/report-k3/search', 'ReportK3Controller@search'); + $router->delete('/report-k3/delete/{id}', 'ReportK3Controller@delete'); + $router->get('/report-k3/list', 'ReportK3Controller@list'); + + $router->post('/report-k3-detail/add', 'ReportK3DetailController@add'); + $router->get('/report-k3-detail/edit/{id}', 'ReportK3DetailController@edit'); + $router->put('/report-k3-detail/update/{id}', 'ReportK3DetailController@update'); + $router->post('/report-k3-detail/search', 'ReportK3DetailController@search'); + $router->delete('/report-k3-detail/delete/{id}', 'ReportK3DetailController@delete'); + $router->get('/report-k3-detail/list', 'ReportK3DetailController@list'); + + $router->post('/user-to-proyek/add', 'UserToProyekController@add'); + $router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit'); + $router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update'); + $router->post('/user-to-proyek/search', 'UserToProyekController@search'); + $router->delete('/user-to-proyek/delete/{id}', 'UserToProyekController@delete'); + $router->get('/user-to-proyek/list', 'UserToProyekController@list'); + $router->get('/user-to-proyek/select', 'UserToProyekController@select'); + $router->get('/user-to-proyek/get-employee-integration', 'UserToProyekController@getEmployeeIntegration'); + + $router->post('/folder-document-proyek/add', 'FolderDocumentProyekController@add'); + $router->get('/folder-document-proyek/edit/{id}', 'FolderDocumentProyekController@edit'); + $router->put('/folder-document-proyek/update/{id}', 'FolderDocumentProyekController@update'); + $router->post('/folder-document-proyek/search', 'FolderDocumentProyekController@search'); + $router->delete('/folder-document-proyek/delete/{id}', 'FolderDocumentProyekController@delete'); + $router->get('/folder-document-proyek/list', 'FolderDocumentProyekController@list'); + $router->get('/folder-document-proyek/get-tree/{id}', 'FolderDocumentProyekController@getTree'); + + $router->post('/office-hours/add', 'OfficeHoursController@add'); + $router->get('/office-hours/edit/{id}', 'OfficeHoursController@edit'); + $router->put('/office-hours/update/{id}', 'OfficeHoursController@update'); + $router->post('/office-hours/search', 'OfficeHoursController@search'); + $router->delete('/office-hours/delete/{id}', 'OfficeHoursController@delete'); + $router->get('/office-hours/list', 'OfficeHoursController@list'); + + $router->get('/gantt-show-hide/get-by-gantt/{gantt_id}', 'ShowHideColumnController@getByUserGantt'); + $router->post('/gantt-show-hide/add', 'ShowHideColumnController@add'); + $router->post('/gantt-show-hide/update/{gantt_id}', 'ShowHideColumnController@update'); + $router->get('/gantt-show-hide/get-column-by-type/{type}', 'ShowHideColumnController@getColumnByType'); + + + $router->post('/shift/add', 'ShiftController@add'); + $router->get('/shift/edit/{id}', 'ShiftController@edit'); + $router->put('/shift/update/{id}', 'ShiftController@update'); + $router->post('/shift/search', 'ShiftController@search'); + $router->delete('/shift/delete/{id}', 'ShiftController@delete'); + $router->get('/shift/list', 'ShiftController@list'); + + $router->post('/user-monthly-shift/add', 'UserMonthlyShiftController@add'); + $router->put('/user-monthly-shift/update/{id}', 'UserMonthlyShiftController@update'); + $router->post('/user-monthly-shift/search', 'UserMonthlyShiftController@search'); + $router->delete('/user-monthly-shift/delete/{id}', 'UserMonthlyShiftController@delete'); + $router->delete('/user-monthly-shift/delete-at/{yyyymm}', 'UserMonthlyShiftController@deleteYYYYMM'); + $router->get('/user-monthly-shift/list', 'UserMonthlyShiftController@list'); + $router->post('/user-monthly-shift/import', 'UserMonthlyShiftController@import'); + $router->get('/user-monthly-shift/list/{yyyymm}', 'UserMonthlyShiftController@listYYYYMM'); + + $router->post('/user-to-shift/add', 'UserToShiftController@add'); + $router->get('/user-to-shift/edit/{id}', 'UserToShiftController@edit'); + $router->put('/user-to-shift/update/{id}', 'UserToShiftController@update'); + $router->post('/user-to-shift/search', 'UserToShiftController@search'); + $router->delete('/user-to-shift/delete/{id}', 'UserToShiftController@delete'); + $router->get('/user-to-shift/list', 'UserToShiftController@list'); + + $router->post('/control-monitoring/search', 'ControlMonitoringController@search'); + $router->get('/currency/list', 'CurrencyController@list'); + + $router->post('/project-to-checklist-k3/add', 'ProjectToChecklistK3Controller@add'); + $router->post('/project-to-checklist-k3/add-multiple', 'ProjectToChecklistK3Controller@addMultiple'); + $router->get('/project-to-checklist-k3/edit/{id}', 'ProjectToChecklistK3Controller@edit'); + $router->put('/project-to-checklist-k3/update/{id}', 'ProjectToChecklistK3Controller@update'); + $router->post('/project-to-checklist-k3/search', 'ProjectToChecklistK3Controller@search'); + $router->delete('/project-to-checklist-k3/delete/{id}', 'ProjectToChecklistK3Controller@delete'); + $router->get('/project-to-checklist-k3/list', 'ProjectToChecklistK3Controller@list'); + + $router->post('/project-comment/add', 'ProjectCommentController@add'); + $router->put('/project-comment/update/{id}', 'ProjectCommentController@update'); + $router->post('/project-comment/search', 'ProjectCommentController@search'); + + $router->post('/map-monitoring/search', 'MapMonitoringController@search'); + }); }); From 412f5a03a90d34b15787c642c03e98d26aad0bcd Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 23 Mar 2023 10:10:12 +0700 Subject: [PATCH 22/24] update conflict --- app/Http/Controllers/Controller.php | 2 +- app/Imports/ActivityImport.php | 0 routes/web.php | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 app/Imports/ActivityImport.php diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a12208d..31cc056 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -11,7 +11,7 @@ class Controller extends BaseController { protected $pathImage = "assets/image/"; protected $pathDocument = "assets/file/project/"; - protected $pathTmpImport = "assets/file/import/"; + protected $pathTmpImport = "assets/file/tmpimport/"; protected $pathActivityDocument = "assets/file/activity/"; protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth']; diff --git a/app/Imports/ActivityImport.php b/app/Imports/ActivityImport.php new file mode 100644 index 0000000..e69de29 diff --git a/routes/web.php b/routes/web.php index 5d81e16..337e6e3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -207,6 +207,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->put('/task/update-regular/{id}', 'ActivityController@updateRegular'); $router->delete('/task/{id}', 'ActivityController@delete'); $router->get('/task/get-update/{id}', 'ActivityController@getUpdate'); + $router->post('/tmp-import/upload', 'ActivityController@uploadTmpImport'); $router->post('/link', 'LinkController@add'); $router->put('/link/{id}', 'LinkController@update'); From eb7fb115abf7d09db98c9016f7ca38cd59f312de Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 23 Mar 2023 10:13:12 +0700 Subject: [PATCH 23/24] remove package excel --- bootstrap/app.php | 1 - 1 file changed, 1 deletion(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 0bef746..af68fb8 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -97,7 +97,6 @@ $app->routeMiddleware([ */ $app->register(App\Providers\CatchAllOptionsRequestsProvider::class); - $app->register(App\Providers\AuthServiceProvider::class); $app->register(Tymon\JWTAuth\Providers\LumenServiceProvider::class); $app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class); From 1f086ea51c3df2623cca628784cfc1220e7cac64 Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 23 Mar 2023 10:17:33 +0700 Subject: [PATCH 24/24] update conflict --- app/Http/Controllers/ActivityController.php | 33 ++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index b948351..467147d 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -6,9 +6,9 @@ use App\Models\CommentActivity; use App\Models\Link; use App\Models\Project; use App\Models\TemplateGantt; +use App\Models\TmpImport; use App\Models\VersionGantt; use App\Models\UserToActivity; -use App\Models\TmpImport; use Illuminate\Http\Request; class ActivityController extends Controller @@ -279,9 +279,10 @@ class ActivityController extends Controller $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); - } + } - public function import(Request $request) + // before upload file + public function importOld(Request $request) { $data = $request->all(); @@ -307,7 +308,7 @@ class ActivityController extends Controller $input['bobot_planning'] = $activity_row['weight']; $input['persentase_progress'] = 0; $input['type_activity'] = $i == 0 ? "header" : "task"; - $input['created_by'] = $this->currentName; + $input['created_by'] = $this->currentName; if (!$activity = Activity::create($input)) { Activity::where('version_gantt_id', $data['ganttId'])->delete(); @@ -386,19 +387,31 @@ class ActivityController extends Controller } return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200); - } + } + + public function import(Request $request) + { + $data = $request->all(); + $data['created_by'] = $this->currentName; + Activity::where('version_gantt_id', $data['gantt_id'])->delete(); + $projectId = VersionGantt::where('id', $data['gantt_id'])->first()->proyek_id; + // get data excel + $excel = TmpImport::latest('id')->first(); + + return response()->json(['stack' => $excel, 'status' => 'success', 'message' => 'Data imported!', 'data' => $data, 'code' => 200], 200); + } public function uploadTmpImport(Request $request) { if($request->hasFile('dokumen')){ - $document = $request->file('dokumen'); - $ref_id = $request->ref_id; + $document = $request->file('dokumen'); + $gantt_id = $request->gantt_id; $name = $document->getClientOriginalName(); - $result = $document->move($this->pathDocument, $name); + $result = $document->move($this->pathTmpImport, $name); if($result){ $data = [ - 'ref_id' => (int)$ref_id, + 'gantt_id' => (int)$gantt_id, 'file' => $name, 'type_dokumen' => $request->type_dokumen ]; @@ -406,7 +419,7 @@ class ActivityController extends Controller $result = TmpImport::create($data); if(!$result){ - unlink($this->pathDocument.$name); + unlink($this->pathTmpImport.$name); return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); } return response()->json(['status'=>'success','message'=>'Upload successful!','code'=>200], 200);