From 9610a5977a0154668b904ef5b3b0cbeb2bca4a5b Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 22 Aug 2022 03:01:06 +0700 Subject: [PATCH 001/131] 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 b547aa1d3a19210fa241231ce120fde12650d1d5 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 24 Aug 2022 02:15:51 +0700 Subject: [PATCH 002/131] 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 3b3129d5b71270fdb7d8b355576f58c96556a902 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 24 Aug 2022 02:36:41 +0700 Subject: [PATCH 003/131] 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 6a55b9b25e2f27b8c2202ce4605353e4eb3306d9 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 24 Aug 2022 04:29:04 +0700 Subject: [PATCH 004/131] 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 c0238cd82d0119c0db408c2e731f0d5cc5e750a4 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 24 Aug 2022 05:12:44 +0700 Subject: [PATCH 005/131] 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 4259609b99c7995da409aa29aa1eee13fd93cb9b Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 25 Aug 2022 18:29:15 +0700 Subject: [PATCH 006/131] 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 74aa57b724c97fae7060491126d00f7a79662d7b Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 25 Aug 2022 18:29:31 +0700 Subject: [PATCH 007/131] 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 f1c99e904bb29b5fac88815a3f01ad282c2e155a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 25 Aug 2022 18:30:53 +0700 Subject: [PATCH 008/131] 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 6183502af26b640abd2a9308973b9331cb21d669 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 25 Aug 2022 18:31:24 +0700 Subject: [PATCH 009/131] 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 da48d25fa80ed07f5d042ebfbfc69ee79787c050 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 30 Aug 2022 23:11:56 +0700 Subject: [PATCH 010/131] 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 482d04949dcb04068dbf4defac427e917e372b1d Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 6 Sep 2022 14:12:52 +0700 Subject: [PATCH 011/131] 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 ca7b58d362e07da86684952d05ecffa1827aa399 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 7 Sep 2022 17:04:04 +0700 Subject: [PATCH 012/131] 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 f35aa9fb65fc86b1746a04b48a5693668e975e1e Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 8 Sep 2022 12:02:46 +0700 Subject: [PATCH 013/131] 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 2cb90c8d682b88d3652eade2e4ab78029d7bde99 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 15 Sep 2022 15:02:12 +0700 Subject: [PATCH 014/131] 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 b3e987128d1a831dca66a878df0964d6aac710b8 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 15 Sep 2022 15:20:15 +0700 Subject: [PATCH 015/131] 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 4539e11a7459b5c31866fda5e34ffdcd013a621f Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 15 Sep 2022 15:25:22 +0700 Subject: [PATCH 016/131] 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 017/131] 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 6ffcda0892e667565771c90e0226e43fac09521f Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 4 Oct 2022 16:25:23 +0700 Subject: [PATCH 018/131] tab --- routes/web.php | 810 ++++++++++++++++++++++++------------------------- 1 file changed, 405 insertions(+), 405 deletions(-) diff --git a/routes/web.php b/routes/web.php index b636078..77e9196 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,37 +1,37 @@ 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->post('/role/search', 'RoleController@search'); $router->post('/role/add', 'RoleController@add'); @@ -40,384 +40,384 @@ $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->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'); + }); }); From 8e49f34b26ced03dcc0e80aaf4674e94325178c4 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 4 Oct 2022 16:29:29 +0700 Subject: [PATCH 019/131] add dummy api --- .../Controllers/DashboardBoDController.php | 95 ++++++++++++++----- 1 file changed, 71 insertions(+), 24 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index ec845e2..b903ff6 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -16,6 +16,7 @@ class DashboardBoDController extends Controller return $year; } + // to do public function getCompanyCashFlow($year = '%') { $year = $this->interpolateYear($year); @@ -27,15 +28,39 @@ class DashboardBoDController extends Controller 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), + 'total_budget' => (int) $totalBudgets ?? rand(0,10000000000), + 'total_expenditure' => rand(0,10000000000), // to do integrasi + 'total_invoice' => rand(0,10000000000), + 'total_paid_invoice' => rand(0,10000000000), ] ], 200); } - public function getProjectPerScheduleHealth($year = '%'){ + public function getInvoiceOutstanding($year = '%'){ + return response()->json([ + 'data' => [ + 0 => [ + 'project' => 'Project A', + 'invoiced' => rand(0, 9000000000), + 'paid' => rand(0, 9000000000), + ], + 1 => [ + 'project' => 'Project B', + 'invoiced' => rand(0, 9000000000), + 'paid' => rand(0, 9000000000), + ], + 2 => [ + 'project' => 'Project C', + 'invoiced' => rand(0, 9000000000), + 'paid' => rand(0, 9000000000), + ], + ] + ], 200); + + } + + // to do + public function getTotalProjectPerScheduleHealth($year = '%'){ $year = $this->interpolateYear($year); // get data plan (vol) in % // get data actual in % @@ -48,7 +73,8 @@ class DashboardBoDController extends Controller ], 200); } - public function getProjectScheduleHealthPerDivision($year = '%'){ + // todo + public function getTotalProjectScheduleHealthPerDivision($year = '%'){ $year = $this->interpolateYear($year); $divisions = Divisi::whereNull('parent')->get(); @@ -66,28 +92,47 @@ class DashboardBoDController extends Controller ], 200); } - public function getProjectPerBudgetHealth($year = '%'){ + public function getTotalProjectPerBudgetHealth($year = '%'){ $year = $this->interpolateYear($year); return response()->json([ 'data' => [ - 'overrun' => rand(0,10), - 'warning' => rand(0,10), - 'on-budget' => rand(0,10), + 'overrun' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'overrun')->count(), + 'warning' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'warning')->count(), + 'on-budget' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'on-budget')->count(), ] ], 200); } - public function getProjectBudgetHealthPerDivision($year = '%'){ - $year = $this->interpolateYear($year); + private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health){ + return Project::where('divisi_id', $divisi) + ->where('mulai_proyek', 'like', $year) + ->where('budget_health', $health) + ->count(); + } - $divisions = Divisi::whereNull('parent')->get(); + + public function getTotalProjectBudgetHealthPerDivision($year = '%'){ + $year = $this->interpolateYear($year); + $divisions = Divisi::select('id','name') + ->with('children') + ->whereNull('parent') + ->get(); + // to do : count in more than 1 level child 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'); + $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'overrun'), 'overrun'); + $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'warning'), 'warning'); + $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'on-budget'), 'on-budget'); + foreach($division->children as $d){ + $budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'overrun'); + $budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'warning'); + $budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'on-budget'); + } + unset($division->children); $division->budgetData = $budgetData; } + foreach($divisions as $division){ + } return response()->json([ 'data' => [ $divisions @@ -95,11 +140,13 @@ class DashboardBoDController extends Controller ], 200); } - public function getProjectPerPhase($year = '%'){ + public function getTotalProjectPerPhase($year = '%'){ $year = $this->interpolateYear($year); $projectPhases = ProjectPhase::orderBy('order')->get(); foreach($projectPhases as $phase){ - $phase->totalProject = rand(0,10); + $phase->totalProject = Project::where('phase_id', $phase->id) + ->where('mulai_proyek', 'like', $year) + ->count(); } return response()->json([ 'data' => [ @@ -117,13 +164,13 @@ class DashboardBoDController extends Controller public function getTotalProjectPerDivision($year = '%') { $year = $this->interpolateYear($year); - $totalProjectPerDivision = Divisi::select('id','name') + $divisions = Divisi::select('id','name') ->with('children') ->whereNull('parent') ->get(); // to do : count in more than 1 level child - foreach($totalProjectPerDivision as $v){ + foreach($divisions as $v){ $v->total = $this->countTotalProjectInDivision($v->id, $year); foreach($v->children as $d){ $v->total += $this->countTotalProjectInDivision($d->id, $year); @@ -132,7 +179,7 @@ class DashboardBoDController extends Controller } return response()->json([ - 'data' => $totalProjectPerDivision + 'data' => $divisions ], 200); } @@ -147,13 +194,13 @@ class DashboardBoDController extends Controller public function getTotalProjectValuePerDivision($year = '%') { $year = $this->interpolateYear($year); - $totalProjectValuePerDivision = Divisi::select('id','name') + $divisions = Divisi::select('id','name') ->with('children') ->whereNull('parent') ->get(); // to do : count in more than 1 level child - foreach($totalProjectValuePerDivision as $v){ + foreach($divisions as $v){ $v->total = $this->countTotalProjectValueInDivision($v->id, $year); foreach($v->children as $d){ $v->total += $this->countTotalProjectValueInDivision($d->id, $year); @@ -162,7 +209,7 @@ class DashboardBoDController extends Controller } return response()->json([ - 'data' => $totalProjectValuePerDivision + 'data' => $divisions ], 200); } From fc5c14eda093d9bd0d733b821ddc69b8a878f3d8 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Sat, 15 Oct 2022 23:23:02 +0700 Subject: [PATCH 020/131] remove unused codes --- app/Http/Controllers/ProjectController.php | 160 +++++++-------------- 1 file changed, 55 insertions(+), 105 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 4c18e2c..039ea7d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -256,125 +256,75 @@ 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; - $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(); - if($d->area_kerja != ''){ - $d->geolocation = $this->httpReq($d->area_kerja); + $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(); + if($d->area_kerja != ''){ + $d->geolocation = $this->httpReq($d->area_kerja); $d->geolocation = []; - } else { - $d->geolocation = []; - } - } + } else { + $d->geolocation = []; + } + } - $totalPlannedCost = $data->sum('plannedCost'); - $totalActualCost = $data->sum('actualCost'); + $totalPlannedCost = $data->sum('plannedCost'); + $totalActualCost = $data->sum('actualCost'); $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 (\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()]); - } + $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 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(); - - if(!$data) - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); - - return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); - } - - 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', - '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) - ->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(); - - $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', - 'ma.name as activity') - ->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id') - ->where('ma.proyek_id', $id) - ->orderBy('comment_by') - ->take(2) - ->get(); - - $data->actual_cost = $actualCost; - $data->progress = $progress; - $data->comment = $commentActivity; - $data->man_power = $manpowers; - - return response()->json(['status'=>'success','code'=>200,'data'=> $data], 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); } private function httpReq($search){ - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 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); + $output = curl_exec($ch); + curl_close($ch); - return json_decode($output); + return json_decode($output); } } From f5a2d1e6f0eefeb30419f27b66af78c21a54fadf Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Sat, 15 Oct 2022 23:26:59 +0700 Subject: [PATCH 021/131] move s-curve endpoint --- app/Http/Controllers/ActivityController.php | 322 ------------------ app/Http/Controllers/ProjectController.php | 349 +++++++++++++++++++- routes/web.php | 16 +- 3 files changed, 345 insertions(+), 342 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 19c7182..c74f841 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -3,14 +3,11 @@ 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 Illuminate\Http\Request; class ActivityController extends Controller @@ -280,325 +277,6 @@ class ActivityController extends Controller return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); } - public function getPercentagePerDay(Request $request) - { - $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); - } - } - - - 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); - } - } - $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"); - } - - 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++; - } - - $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++; - } - - $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); - } - } - - - 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"; - } - - $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(); diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 039ea7d..729942e 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -2,31 +2,31 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; -use App\Models\Project; -use App\Models\UserToProyek; use App\Models\Activity; -use App\Models\UserToActivity; -use App\Models\User; +use App\Models\ActivityDokumen; use App\Models\AssignMaterial; +use App\Models\CommentActivity; use App\Models\DokumenProject; use App\Models\FolderDocumentProyek; -use App\Models\ProjectCharter; +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\ProjectPhase; -use App\Models\ProjectType; +use App\Models\ProjectCharter; use App\Models\ProjectMileStone; use App\Models\ProjectParticipants; +use App\Models\ProjectPhase; +use App\Models\ProjectType; +use App\Models\ReportActivity; use App\Models\ShowHideColumn; +use App\Models\User; +use App\Models\UserToActivity; +use App\Models\UserToProyek; use App\Models\VersionGantt; -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 DB; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; @@ -327,5 +327,322 @@ class ProjectController extends Controller return json_decode($output); } + 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 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); + } + } + $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"); + } + + 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++; + } + + $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++; + } + + $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); + } + } + + + 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"; + } + + $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); + } + + public function getPercentagePerDay(Request $request) + { + $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); + } + } + } diff --git a/routes/web.php b/routes/web.php index 77e9196..06d4d10 100644 --- a/routes/web.php +++ b/routes/web.php @@ -58,8 +58,18 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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/get-s-curve', 'ProjectController@getSCurve'); + /* $router->get('/project/get-progress/{id}/{date?}', 'ProjectController@getProgress'); */ + /* $router->get('/project/get-acwp/{id}/{date?}', 'ProjectController@getACWP'); */ + /* $router->get('/project/get-bcwp/{id}/{date?}', 'ProjectController@getBCWP'); */ + /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ + /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ + /* $router->get('/project/get-overdue-activities/{id}/{date?}', 'ProjectController@getOverdueActivities'); */ + /* $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'); @@ -189,9 +199,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('/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'); From 88fbfa395606ffdbfa8b4e74a2fc7fc0b8508dc7 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Sun, 16 Oct 2022 23:23:12 +0700 Subject: [PATCH 022/131] move synchro & baseline codes --- app/Http/Controllers/ActivityController.php | 52 --------------------- 1 file changed, 52 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index c74f841..3fdd675 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -277,57 +277,5 @@ class ActivityController extends Controller return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 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 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") - ); - - } - } - - 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 51672832d7bbf944728ab1346a75ae4337d821f1 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Sun, 16 Oct 2022 23:25:51 +0700 Subject: [PATCH 023/131] adjust s-curve API --- app/Http/Controllers/ProjectController.php | 114 ++++++++++++++++++--- routes/web.php | 10 +- 2 files changed, 105 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 729942e..a547fe0 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -336,18 +336,20 @@ class ProjectController extends Controller return $data; } - public function getCalculateCurvaS(Request $request) // for adw (plan & actual == date) + public function getSCurve(Request $request) { DB::enableQueryLog(); $dataPayload = $request->all(); + /* print_r($dataPayload); exit(); */ + $allGantt = []; - if(isset($dataPayload['gannt_id'])){ - $allGantt = $dataPayload['gannt_id']; + + if(isset($dataPayload['gantt_id'])){ + $allGantt = $dataPayload['gantt_id']; }else{ - foreach ($dataPayload['project_id'] as $val) { - $allGantt[] = $this->getLatestGantt($val); - } + $allGantt[] = $this->getLatestGantt($dataPayload['project_id']); } + $dataFinal=[]; foreach ($allGantt as $keyGantt) { $dataProject = Project::find($keyGantt['proyek_id']); @@ -376,21 +378,29 @@ class ProjectController extends Controller ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) ->min("plan_date"); + /* ->min("planned_Start"); */ $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); + ->max("planned_end"); + /* ->whereNull('deleted_at') */ + /* ->get(); */ + /* ->max("plan_date"); */ // plan date overlapped with assign_material_to_activity's, it should be m_activity's + /* print_r($maxDate); exit(); */ + + $begin = new \DateTime($minDate.' Monday'); + $end = new \DateTime($maxDate. ' Friday'); + $interval = new \DateInterval('P7D'); + // timezone problems in KIT case also occurs in here + $period = new \DatePeriod($begin, $interval, $end); + /* $period = new \DatePeriod($begin->modify('-1 days'), $interval, $end); */ $arr_ActualM = []; $tempDate = []; - $tempPercentage = []; + $tempPercentagePlan = []; + $tempPercentagePlanWhr = []; + $tempPercentageReal = []; $tempTtlPercentPlan=0; $tempTtlPercentActual=0; @@ -482,9 +492,14 @@ class ProjectController extends Controller $currentBCWP += $totalBCWP; $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); + $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); + $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; + $tempPercentageReal[] = round($tempTtlPercentActual, 2); $tempDate[] = array($dt->format("Y-m-d"), 0, 0); }else{ $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); + $tempPercentagePlan[] = round($sumPercentagePlan, 2); + $tempPercentageReal[] = round($sumPercentageActual, 2); $tempDate[] = array($dt->format("Y-m-d"), 0, 0); } } @@ -515,6 +530,8 @@ class ProjectController extends Controller $dataResponse = array( "date" =>$tempDate, "percentage" =>$tempPercentage, + "percentagePlan" => $tempPercentagePlan, + "percentageReal" => $tempPercentageReal, "data_details" =>$arr_ActualM, "budget_control" =>array("current_budget"=> $totalRencanaBudget, "acwp" => round($totalACWP,0), @@ -644,5 +661,74 @@ class ProjectController extends Controller } } + 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 = $this->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); + } + + 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") + ); + + } + } + + 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); + } + } diff --git a/routes/web.php b/routes/web.php index 06d4d10..affecf1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -56,16 +56,18 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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->post('/project/get-s-curve', 'ProjectController@getSCurve'); /* $router->get('/project/get-progress/{id}/{date?}', 'ProjectController@getProgress'); */ - /* $router->get('/project/get-acwp/{id}/{date?}', 'ProjectController@getACWP'); */ - /* $router->get('/project/get-bcwp/{id}/{date?}', 'ProjectController@getBCWP'); */ + /* $router->get('/project/get-overdue-activities/{id}/{date?}', 'ProjectController@getOverdueActivities'); */ + /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ - /* $router->get('/project/get-overdue-activities/{id}/{date?}', 'ProjectController@getOverdueActivities'); */ /* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */ /* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */ @@ -199,8 +201,6 @@ $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->get('/activity/set-baseline/{gantt_id}', 'ActivityController@setBaseline'); - $router->get('/activity/synchronize-report/{gantt_id}', 'ActivityController@synchronizeReport'); $router->post('/link', 'LinkController@add'); $router->put('/link/{id}', 'LinkController@update'); From 8a6cb2b8948e6689b329c173b0a1244915ad3834 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 01:02:20 +0700 Subject: [PATCH 024/131] fix real progress --- app/Http/Controllers/ProjectController.php | 21 ++++++++++++++------- app/Models/ReportActivity.php | 10 +++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index a547fe0..cb29b1c 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -20,6 +20,7 @@ use App\Models\ProjectParticipants; use App\Models\ProjectPhase; use App\Models\ProjectType; use App\Models\ReportActivity; +use App\Models\ReportActivityMaterial; use App\Models\ShowHideColumn; use App\Models\User; use App\Models\UserToActivity; @@ -384,7 +385,7 @@ class ProjectController extends Controller ->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("planned_end"); + ->max("plan_date"); /* ->whereNull('deleted_at') */ /* ->get(); */ /* ->max("plan_date"); */ // plan date overlapped with assign_material_to_activity's, it should be m_activity's @@ -407,6 +408,9 @@ class ProjectController extends Controller $currentACWP = 0; $currentBCWP = 0; + /* foreach($period as $x){ */ + /* echo $x->format("Y-m-d")."\n"; */ + /* } exit(); */ 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') @@ -420,7 +424,8 @@ class ProjectController 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', '>',$dt->modify('-7 day')->format("Y-m-d")) ->get(); $dataTempPlan = []; $x = 0; @@ -683,9 +688,9 @@ class ProjectController extends Controller foreach($activities as $activity) { $activity_id = $activity->id; - $countReports = ReportActivity::where('activity_id', $activity_id)->count(); + $countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count(); if ($countReports === 1) { - $dataReports = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->get(); + $dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); foreach($dataReports as $dr) { $reports[] = array( 'activity_id'=>$activity_id, @@ -695,16 +700,18 @@ class ProjectController extends Controller } } 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(); + $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']); diff --git a/app/Models/ReportActivity.php b/app/Models/ReportActivity.php index 8db5702..85b77e4 100644 --- a/app/Models/ReportActivity.php +++ b/app/Models/ReportActivity.php @@ -12,16 +12,16 @@ class ReportActivity extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'activity_id', - 'user_id', + 'activity_id', + 'user_id', 'report_date', 'job_count_report', 'description', 'lat', 'lon', - 'created_at', - 'created_by', - 'updated_at', + 'created_at', + 'created_by', + 'updated_at', 'updated_by' ]; } From d73c1055f66461dd120c99949df27053cd7d69ac Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 02:00:10 +0700 Subject: [PATCH 025/131] fix interval, start and close on friday --- app/Http/Controllers/ProjectController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index cb29b1c..3b930a1 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -391,9 +391,10 @@ class ProjectController extends Controller /* ->max("plan_date"); */ // plan date overlapped with assign_material_to_activity's, it should be m_activity's /* print_r($maxDate); exit(); */ - $begin = new \DateTime($minDate.' Monday'); - $end = new \DateTime($maxDate. ' Friday'); - $interval = new \DateInterval('P7D'); + $begin = new \DateTime($minDate.' Friday'); + /* print_r($begin); exit(); */ + $end = new \DateTime($maxDate); + $interval = new \DateInterval('P1W'); // timezone problems in KIT case also occurs in here $period = new \DatePeriod($begin, $interval, $end); /* $period = new \DatePeriod($begin->modify('-1 days'), $interval, $end); */ @@ -417,14 +418,16 @@ class ProjectController extends Controller ->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")) + /* ->whereDate('ama.plan_date', $dt->format("Y-m-d")) */ + ->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d")) + ->whereDate('ama.plan_date', '>',$dt->modify('-7 day')->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")) + ->whereDate('ram.report_date', '<=',$dt->format("Y-m-d")) ->whereDate('ram.report_date', '>',$dt->modify('-7 day')->format("Y-m-d")) ->get(); $dataTempPlan = []; From 15040d01ed403f066713f2c5b24f30853409db23 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 03:38:16 +0700 Subject: [PATCH 026/131] recalc s-curve date & api overdue activities --- app/Http/Controllers/ProjectController.php | 81 ++++++++++++++-------- routes/web.php | 2 +- 2 files changed, 52 insertions(+), 31 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 3b930a1..1351b7a 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -374,30 +374,29 @@ class ProjectController extends Controller 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"); - /* ->min("planned_Start"); */ - - $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"); - /* ->whereNull('deleted_at') */ - /* ->get(); */ - /* ->max("plan_date"); */ // plan date overlapped with assign_material_to_activity's, it should be m_activity's - /* print_r($maxDate); exit(); */ - - $begin = new \DateTime($minDate.' Friday'); - /* print_r($begin); exit(); */ - $end = new \DateTime($maxDate); - $interval = new \DateInterval('P1W'); - // timezone problems in KIT case also occurs in here + /* $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"); */ + $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); + + $begin = new \DateTime($minDate.' Monday'); + if(isset($dataPayload['end_date'])){ + $maxDate = $dataPayload['end_date']; + $end = new \DateTime($maxDate); + $interval = \DateInterval::createFromDateString('1 day'); + } else { + $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"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's + $end = new \DateTime($maxDate. ' Friday'); + $interval = new \DateInterval('P7D'); + } $period = new \DatePeriod($begin, $interval, $end); - /* $period = new \DatePeriod($begin->modify('-1 days'), $interval, $end); */ + $arr_ActualM = []; $tempDate = []; $tempPercentagePlan = []; @@ -409,10 +408,12 @@ class ProjectController extends Controller $currentACWP = 0; $currentBCWP = 0; - /* foreach($period as $x){ */ - /* echo $x->format("Y-m-d")."\n"; */ - /* } exit(); */ + foreach($period as $x){ + echo $x->format("Y-m-d")."\n"; + } exit(); foreach ($period as $dt) { + $minSevenDays = new \Datetime($dt->format("Y-m-d")); + $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); $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') @@ -420,7 +421,7 @@ class ProjectController extends Controller ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) /* ->whereDate('ama.plan_date', $dt->format("Y-m-d")) */ ->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d")) - ->whereDate('ama.plan_date', '>',$dt->modify('-7 day')->format("Y-m-d")) + ->whereDate('ama.plan_date', '>', $minSevenDays) ->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') @@ -428,7 +429,7 @@ class ProjectController 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', '>',$dt->modify('-7 day')->format("Y-m-d")) + ->whereDate('ram.report_date', '>',$minSevenDays) ->get(); $dataTempPlan = []; $x = 0; @@ -503,14 +504,14 @@ class ProjectController extends Controller $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; $tempPercentageReal[] = round($tempTtlPercentActual, 2); - $tempDate[] = array($dt->format("Y-m-d"), 0, 0); }else{ $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); $tempPercentagePlan[] = round($sumPercentagePlan, 2); $tempPercentageReal[] = round($sumPercentageActual, 2); - $tempDate[] = array($dt->format("Y-m-d"), 0, 0); } + $tempDate[] = array($dt->format("Y-m-d")); } + /* print_r($tempDate); exit(); */ try { @@ -740,5 +741,25 @@ class ProjectController extends Controller 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); + + 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); + } + } diff --git a/routes/web.php b/routes/web.php index affecf1..21f880e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -63,8 +63,8 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->get('/project/synchronize-report/{gantt_id}', 'ProjectController@synchronizeReport'); $router->post('/project/get-s-curve', 'ProjectController@getSCurve'); + $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); /* $router->get('/project/get-progress/{id}/{date?}', 'ProjectController@getProgress'); */ - /* $router->get('/project/get-overdue-activities/{id}/{date?}', 'ProjectController@getOverdueActivities'); */ /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ From 13a87932f01f21d314df4dfa0e9f46fd4dc5d578 Mon Sep 17 00:00:00 2001 From: ardhi Date: Mon, 17 Oct 2022 13:53:41 +0700 Subject: [PATCH 027/131] add: ProjectComment (m_project_comment) --- .../Controllers/ProjectCommentController.php | 57 +++++++++++++++++++ app/Models/ProjectComment.php | 24 ++++++++ routes/web.php | 4 ++ 3 files changed, 85 insertions(+) create mode 100644 app/Http/Controllers/ProjectCommentController.php create mode 100644 app/Models/ProjectComment.php diff --git a/app/Http/Controllers/ProjectCommentController.php b/app/Http/Controllers/ProjectCommentController.php new file mode 100644 index 0000000..6b5f72f --- /dev/null +++ b/app/Http/Controllers/ProjectCommentController.php @@ -0,0 +1,57 @@ +all(); + + $data['created_by'] = $this->currentName; + + $result = ProjectComment::create($data); + + if($result){ + return response()->json(['status'=>'success','message'=>'add comment successfully!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'add comment failed!','code'=>400], 400); + } + } + + public function update(Request $request, $id) + { + if(!$id || (int) $id < 0 || $id==""){ + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + } + + $data = ProjectComment::find($id); + + if($data){ + $result = $data->update($request->all()); + }else{ + return response()->json(['status'=>'failed','message'=>'data project not found!','code'=>400], 400); + die(); + } + + if($result){ + return response()->json(['status'=>'success','message'=>'data project successfully updated!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'data project failed updated!','code'=>400], 400); + } + } + + public function search(Request $request) + { + $payload = $request->all(); + $dataBuilder = $this->setUpPayload($payload, 'm_project_comment'); + $builder = $dataBuilder['builder']; + $countBuilder = $dataBuilder['count']; + $dataGet = $builder->get(); + $totalRecord = $countBuilder->count(); + return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); + } +} diff --git a/app/Models/ProjectComment.php b/app/Models/ProjectComment.php new file mode 100644 index 0000000..57ec97f --- /dev/null +++ b/app/Models/ProjectComment.php @@ -0,0 +1,24 @@ +group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); }); }); From ae5b1380961f1fd384d33e55c633c88a17baddc5 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 16:28:27 +0700 Subject: [PATCH 028/131] calculate project expenditures --- .../Controllers/DashboardBoDController.php | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index b903ff6..d1f3123 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -5,8 +5,10 @@ namespace App\Http\Controllers; use App\Models\Project; use App\Models\Divisi; use App\Models\ProjectPhase; +use App\Models\AssignMaterial; +use App\Models\ReportActivityMaterial; use Illuminate\Support\Collection; -use DB; +use Illuminate\Support\Facades\DB; class DashboardBoDController extends Controller { @@ -26,12 +28,32 @@ class DashboardBoDController extends Controller ->pluck('sum') ->first(); + /* $projectsWithMaterials = DB::table('m_proyek as p') */ + /* ->join('assign_material_to_activity as ama', 'p.id', '=', 'ama.proyek_id') */ + /* ->join('report_activity_material as ram', 'ama.id', '=', 'ram.assign_material_id') */ + /* ->where('p.mulai_proyek', 'like', $year) */ + /* ->get(); */ + + $totalExpenditure = 0; + $projects = Project::where('mulai_proyek', 'like', $year)->get(); + foreach($projects as $project){ + $project->expenses = 0; + $assignedMaterials = AssignMaterial::where('proyek_id', $project->id)->get(); + foreach($assignedMaterials as $assignedMaterial) { + $reportedMaterials = ReportActivityMaterial::where('assign_material_id', $assignedMaterial->id)->get(); + foreach($reportedMaterials as $reportedMaterial) { + $project->expenses += $reportedMaterial->qty * $assignedMaterial->budget; + } + } + $totalExpenditure += $project->expenses; + } + return response()->json([ 'data' => [ - 'total_budget' => (int) $totalBudgets ?? rand(0,10000000000), - 'total_expenditure' => rand(0,10000000000), // to do integrasi - 'total_invoice' => rand(0,10000000000), - 'total_paid_invoice' => rand(0,10000000000), + 'total_budget' => (int) $totalBudgets ?? 0, + 'total_expenditure' => $totalExpenditure, + 'total_invoice' => 0, + 'total_paid_invoice' => 0, ] ], 200); } From 37998c3eec7b9e9d8edd9730766c0ba15b5b13d0 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 16:28:58 +0700 Subject: [PATCH 029/131] implement invoice api integration --- app/Http/Controllers/ProjectController.php | 36 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 1351b7a..24ba04b 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -408,9 +408,9 @@ class ProjectController extends Controller $currentACWP = 0; $currentBCWP = 0; - foreach($period as $x){ - echo $x->format("Y-m-d")."\n"; - } exit(); + /* foreach($period as $x){ */ + /* echo $x->format("Y-m-d")."\n"; */ + /* } exit(); */ foreach ($period as $dt) { $minSevenDays = new \Datetime($dt->format("Y-m-d")); $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); @@ -761,5 +761,35 @@ class ProjectController extends Controller return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 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 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'); + $token = config('api.adw_token'); + $response = $this->curlReq($url, $token); + + if($response->data->project_no == "") + return response()->json(['status'=>'error', 'message' => 'Project '.$search.' not found!', 'code'=>404], 404); + + return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); + } } From f549db4139a915048906223db465b7c871fdb405 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 16:29:25 +0700 Subject: [PATCH 030/131] implement invoice api integration --- routes/web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/web.php b/routes/web.php index 476bc95..ef0bf50 100644 --- a/routes/web.php +++ b/routes/web.php @@ -64,6 +64,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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->get('/project/get-progress/{id}/{date?}', 'ProjectController@getProgress'); */ /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ From d7cda428444dd59f8b4e479e7dd8f7162516fef9 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 21:12:11 +0700 Subject: [PATCH 031/131] division by zero catch --- app/Http/Controllers/ProjectController.php | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 24ba04b..023d3fd 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -282,7 +282,7 @@ class ProjectController extends Controller ->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) { + } catch (\DivisionByZeroError $e) { return response()->json(['message' => $e->getMessage()]); } try { @@ -291,7 +291,7 @@ class ProjectController extends Controller ->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') ->groupBy('m_type_proyek.name') ->get(); - } catch (\Exception $e) { + } catch (\DivisionByZeroError $e) { return response()->json(['message' => $e->getMessage()]); } @@ -452,10 +452,14 @@ class ProjectController extends Controller $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; + try { + $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; + } catch (\DivisionByZeroError $e) { + return response()->json(['message' => $e->getMessage()]); + } $x++; } @@ -476,11 +480,11 @@ class ProjectController extends Controller $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 { + $dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; + $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; $totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; - } catch (\Exception $e) { + } catch (\DivisionByZeroError $e) { return response()->json(['message' => $e->getMessage()]); } $dataTempReport [$w]['totalacwp'] = $totalACWP; @@ -520,7 +524,7 @@ class ProjectController extends Controller }else{ $estimatedCost = ($totalRencanaBudget+0); } - } catch (\Exception $e) { + } catch (\DivisionByZeroError $e) { return response()->json([ 'message' => $e->getMessage(), "line" => 566, @@ -791,5 +795,6 @@ class ProjectController extends Controller return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); } + } From d5fbe4b56d785d2bcc16ed31ca2e943905837487 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 21:12:33 +0700 Subject: [PATCH 032/131] dashboard bod invoice integration --- .../Controllers/DashboardBoDController.php | 100 +++++++++++++----- 1 file changed, 72 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index d1f3123..d1ba1c1 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -18,26 +18,56 @@ class DashboardBoDController extends Controller return $year; } + 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); + } + + private function getInvoiceIntegration($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'); + $token = config('api.adw_token'); + $response = $this->curlReq($url, $token); + + if(@$response->data->project_no == "") + return null; + + return $response; + } + // to do public function getCompanyCashFlow($year = '%') { $year = $this->interpolateYear($year); + $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; // 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) + /* ->orWhere('akhir_proyek', 'like', $year) */ ->pluck('sum') ->first(); - /* $projectsWithMaterials = DB::table('m_proyek as p') */ - /* ->join('assign_material_to_activity as ama', 'p.id', '=', 'ama.proyek_id') */ - /* ->join('report_activity_material as ram', 'ama.id', '=', 'ram.assign_material_id') */ - /* ->where('p.mulai_proyek', 'like', $year) */ - /* ->get(); */ - - $totalExpenditure = 0; - $projects = Project::where('mulai_proyek', 'like', $year)->get(); + $projects = Project::where('mulai_proyek', 'like', $year) + /* ->orWhere('akhir_proyek', 'like', $year) */ + ->get(); foreach($projects as $project){ $project->expenses = 0; + + // expenditure $assignedMaterials = AssignMaterial::where('proyek_id', $project->id)->get(); foreach($assignedMaterials as $assignedMaterial) { $reportedMaterials = ReportActivityMaterial::where('assign_material_id', $assignedMaterial->id)->get(); @@ -46,39 +76,49 @@ class DashboardBoDController extends Controller } } $totalExpenditure += $project->expenses; + + $resp = null; + if($project->kode_sortname != ""){ + $resp = $this->getInvoiceIntegration($project->kode_sortname); + /* $resp = $project->kode_sortname; */ + $totalInvoice += $resp->data->total_invoice_amount ?? 0; + $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0; + } + } return response()->json([ 'data' => [ 'total_budget' => (int) $totalBudgets ?? 0, 'total_expenditure' => $totalExpenditure, - 'total_invoice' => 0, - 'total_paid_invoice' => 0, + 'total_invoice' => $totalInvoice, + 'total_paid_invoice' => $totalPaidInvoice , ] ], 200); } public function getInvoiceOutstanding($year = '%'){ + $year = $this->interpolateYear($year); + $projects = Project::where('mulai_proyek', 'like', $year) + /* ->orWhere('akhir_proyek', 'like', $year) */ + ->get(); + $return = []; + foreach($projects as $project){ + $resp = null; + if($project->kode_sortname != ""){ + $resp = $this->getInvoiceIntegration($project->kode_sortname); + array_push($return, [ + 'project' => $project->nama, + 'invoiced' => $resp->data->total_invoice_amount ?? 0, + 'paid' => $resp->data->total_invoice_paid_amount ?? 0, + 'response' => $resp, + ]); + } + } + return response()->json([ - 'data' => [ - 0 => [ - 'project' => 'Project A', - 'invoiced' => rand(0, 9000000000), - 'paid' => rand(0, 9000000000), - ], - 1 => [ - 'project' => 'Project B', - 'invoiced' => rand(0, 9000000000), - 'paid' => rand(0, 9000000000), - ], - 2 => [ - 'project' => 'Project C', - 'invoiced' => rand(0, 9000000000), - 'paid' => rand(0, 9000000000), - ], - ] + 'data' => $return ], 200); - } // to do @@ -128,6 +168,7 @@ class DashboardBoDController extends Controller private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health){ return Project::where('divisi_id', $divisi) ->where('mulai_proyek', 'like', $year) + /* ->orWhere('akhir_proyek', 'like', $year) */ ->where('budget_health', $health) ->count(); } @@ -168,6 +209,7 @@ class DashboardBoDController extends Controller foreach($projectPhases as $phase){ $phase->totalProject = Project::where('phase_id', $phase->id) ->where('mulai_proyek', 'like', $year) + /* ->orWhere('akhir_proyek', 'like', $year) */ ->count(); } return response()->json([ @@ -180,6 +222,7 @@ class DashboardBoDController extends Controller private function countTotalProjectInDivision($id, $year){ return Project::where('divisi_id', $id) ->where('mulai_proyek', 'like', $year) + /* ->orWhere('akhir_proyek', 'like', $year) */ ->count(); } @@ -208,6 +251,7 @@ class DashboardBoDController extends Controller private function countTotalProjectValueInDivision($id, $year){ return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) ->where('mulai_proyek', 'like', $year) + /* ->orWhere('akhir_proyek', 'like', $year) */ ->where('divisi_id', $id) ->pluck('sum') ->first(); From 976c4ae778061c013da1ede038b77c926ab01b09 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 17 Oct 2022 22:46:17 +0700 Subject: [PATCH 033/131] s-curve iterate breaker --- app/Http/Controllers/ProjectController.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 023d3fd..e9b1125 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -355,6 +355,9 @@ class ProjectController 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(); + if(isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek){ + $dataPayload['end_date'] = $dataProject->akhir_proyek; + } 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"); @@ -501,6 +504,14 @@ class ProjectController extends Controller if(isset($dataPayload['period']) && $dataPayload['period'] == 'week'){ $tempTtlPercentPlan+= $sumPercentagePlan; $tempTtlPercentActual+= $sumPercentageActual; + + if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= 100){ + if($tempTtlPercentActual >= 100) + $tempTtlPercentActual = 100; + if($tempTtlPercentPlan >= 100) + $tempTtlPercentPlan = 100; + } + $currentACWP += $totalACWP; $currentBCWP += $totalBCWP; @@ -508,6 +519,9 @@ class ProjectController extends Controller $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; $tempPercentageReal[] = round($tempTtlPercentActual, 2); + if($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100){ + break; + } }else{ $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); $tempPercentagePlan[] = round($sumPercentagePlan, 2); @@ -517,7 +531,6 @@ class ProjectController extends Controller } /* print_r($tempDate); exit(); */ - try { if(round($totalACWP,0) > $totalRencanaBudget){ $estimatedCost = round($totalACWP,0)+0; From 6cc0a077bce3519bbcbf5bdbd77165ac2b63907a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 01:21:23 +0700 Subject: [PATCH 034/131] endpoint peta persebaran laporan --- app/Http/Controllers/ProjectController.php | 20 ++++++++++++++++++++ routes/web.php | 1 + 2 files changed, 21 insertions(+) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index e9b1125..36cca6b 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -809,5 +809,25 @@ class ProjectController extends Controller return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 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', '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']]) + ->get(); + + return response()->json(['status'=>'success', 'code'=> 200, 'data'=> $reports], 200); + } } diff --git a/routes/web.php b/routes/web.php index ef0bf50..2c869be 100644 --- a/routes/web.php +++ b/routes/web.php @@ -65,6 +65,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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-progress/{id}/{date?}', 'ProjectController@getProgress'); */ /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ From 96524bc7d1751f54c5113b5530701be74369d2b7 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 02:49:59 +0700 Subject: [PATCH 035/131] remove unused codes & add qty real on report distributions --- app/Http/Controllers/ProjectController.php | 110 +-------------------- 1 file changed, 1 insertion(+), 109 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 36cca6b..8a9d124 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -341,7 +341,6 @@ class ProjectController extends Controller { DB::enableQueryLog(); $dataPayload = $request->all(); - /* print_r($dataPayload); exit(); */ $allGantt = []; @@ -577,116 +576,9 @@ class ProjectController extends Controller ); } - return response()->json(['status'=>'success','code'=>200, 'data' => $dataFinal], 200); } - public function getPercentagePerDay(Request $request) - { - $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); - } - } - public function detail($id){ if(empty($id) || !is_int((int)$id)) return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); @@ -816,7 +708,7 @@ class ProjectController extends Controller 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', 'rm.description as material_name', 'rm.uom as material_unit', + ->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') From 466732b9186c09d4fb26d4987cbccc9993e82d28 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 03:02:36 +0700 Subject: [PATCH 036/131] bod schedule health --- .../Controllers/DashboardBoDController.php | 204 ++++++++++++++++-- 1 file changed, 183 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index d1ba1c1..6377da7 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -3,6 +3,8 @@ namespace App\Http\Controllers; use App\Models\Project; +use App\Models\Activity; +use App\Models\VersionGantt; use App\Models\Divisi; use App\Models\ProjectPhase; use App\Models\AssignMaterial; @@ -57,7 +59,7 @@ class DashboardBoDController extends Controller // 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) - /* ->orWhere('akhir_proyek', 'like', $year) */ + /* ->orWhere('akhir_proyek', 'like', $year) */ ->pluck('sum') ->first(); @@ -121,30 +123,52 @@ class DashboardBoDController extends Controller ], 200); } - // to do public function getTotalProjectPerScheduleHealth($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); + + $return = [ + 'behind-schedule' => 0, + 'warning' => 0, + 'on-schedule' => 0, + ]; + + $projects = Project::where('mulai_proyek', 'like', $year)->get(); + foreach($projects as $project) { + $project->scurve = $this->getSCurve($project->id); + if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) + $return['warning'] += 1; + elseif(@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) + $return['behind-schedule'] += 1; + elseif(@$project->scurve['difference'] == 0) + $return['on-schedule'] += 1; + } + + return response()->json(['data' => $return], 200); } - // todo public function getTotalProjectScheduleHealthPerDivision($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'); + $behindSchedule = $warning = $onSchedule = 0; + + $projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get(); + foreach($projects as $project) { + $project->scurve = $this->getSCurve($project->id); + if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) + $warning++; + elseif(@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) + $behindSchedule++; + elseif(@$project->scurve['difference'] == 0) + $onSchedule++; + } + + $scheduleData->prepend($behindSchedule, 'behindSchedule'); + $scheduleData->prepend($warning, 'warning'); + $scheduleData->prepend($onSchedule, 'onSchedule'); $division->scheduleData = $scheduleData; } return response()->json([ @@ -168,7 +192,7 @@ class DashboardBoDController extends Controller private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health){ return Project::where('divisi_id', $divisi) ->where('mulai_proyek', 'like', $year) - /* ->orWhere('akhir_proyek', 'like', $year) */ + /* ->orWhere('akhir_proyek', 'like', $year) */ ->where('budget_health', $health) ->count(); } @@ -208,9 +232,9 @@ class DashboardBoDController extends Controller $projectPhases = ProjectPhase::orderBy('order')->get(); foreach($projectPhases as $phase){ $phase->totalProject = Project::where('phase_id', $phase->id) - ->where('mulai_proyek', 'like', $year) - /* ->orWhere('akhir_proyek', 'like', $year) */ - ->count(); + ->where('mulai_proyek', 'like', $year) + /* ->orWhere('akhir_proyek', 'like', $year) */ + ->count(); } return response()->json([ 'data' => [ @@ -222,7 +246,7 @@ class DashboardBoDController extends Controller private function countTotalProjectInDivision($id, $year){ return Project::where('divisi_id', $id) ->where('mulai_proyek', 'like', $year) - /* ->orWhere('akhir_proyek', 'like', $year) */ + /* ->orWhere('akhir_proyek', 'like', $year) */ ->count(); } @@ -251,7 +275,7 @@ class DashboardBoDController extends Controller private function countTotalProjectValueInDivision($id, $year){ return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) ->where('mulai_proyek', 'like', $year) - /* ->orWhere('akhir_proyek', 'like', $year) */ + /* ->orWhere('akhir_proyek', 'like', $year) */ ->where('divisi_id', $id) ->pluck('sum') ->first(); @@ -279,5 +303,143 @@ class DashboardBoDController extends Controller ], 200); } + private function getSCurve($project_id) + { + DB::enableQueryLog(); + + $dataPayload = [ + 'project_id' => $project_id, + 'period' => 'week', + ]; + $allGantt[] = $this->getLatestGantt($dataPayload['project_id']); + $dataResponse=[]; + + foreach ($allGantt as $keyGantt) { + $dataProject = Project::find($keyGantt['proyek_id']); + + $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); + + 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 = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); + + $begin = new \DateTime($minDate.' Monday'); + $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"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's + $end = new \DateTime($maxDate. ' Friday'); + $interval = new \DateInterval('P7D'); + $period = new \DatePeriod($begin, $interval, $end); + + $tempTtlPercentPlan=0; + $tempTtlPercentActual=0; + $tempPercentagePlan = []; + $tempPercentageReal = []; + + foreach ($period as $dt) { + $minSevenDays = new \Datetime($dt->format("Y-m-d")); + $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); + $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")) + ->whereDate('ama.plan_date', '>', $minSevenDays) + ->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")) + ->whereDate('ram.report_date', '>',$minSevenDays) + ->get(); + $sumPercentagePlan=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(); + try { + $sumPercentagePlan+=($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning; + } catch (\DivisionByZeroError $e) { + return response()->json(['message' => $e->getMessage()]); + } + } + + $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(); + try { + $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; + } catch (\DivisionByZeroError $e) { + return response()->json(['message' => $e->getMessage()]); + } + } + + $tempTtlPercentPlan+= $sumPercentagePlan; + $tempTtlPercentActual+= $sumPercentageActual; + + if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= 100){ + if($tempTtlPercentActual >= 100) + $tempTtlPercentActual = 100; + if($tempTtlPercentPlan >= 100) + $tempTtlPercentPlan = 100; + } + + + $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); + $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); + $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; + $tempPercentageReal[] = round($tempTtlPercentActual, 2); + if($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100){ + break; + } + } + + $plannedPercentage = end($tempPercentagePlan); + $progressPercentage = end($tempPercentageReal); + $difference = $plannedPercentage - $progressPercentage; + + $dataResponse = array( + 'planned' => $plannedPercentage, + 'progress' => $progressPercentage, + 'difference' => $difference, + ); + + + } + + return $dataResponse; + } + + private function getLatestGantt($id){ + $maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); + $data = array( + "last_gantt_id" => $maxGanttId, + "proyek_id" => $id + ); + return $data; + } + } From 4f99572a7e12c474e347c14b57f921e1188ed42a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 03:51:01 +0700 Subject: [PATCH 037/131] detail viewed --- .../Controllers/DashboardBoDController.php | 39 ++++++++++++++++--- routes/web.php | 2 +- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 6377da7..b84592e 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -2,13 +2,15 @@ namespace App\Http\Controllers; -use App\Models\Project; use App\Models\Activity; -use App\Models\VersionGantt; +use App\Models\AssignMaterial; use App\Models\Divisi; +use App\Models\Project; use App\Models\ProjectPhase; -use App\Models\AssignMaterial; use App\Models\ReportActivityMaterial; +use App\Models\User; +use App\Models\UserToVersionGantt; +use App\Models\VersionGantt; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; @@ -421,8 +423,8 @@ class DashboardBoDController extends Controller $difference = $plannedPercentage - $progressPercentage; $dataResponse = array( - 'planned' => $plannedPercentage, - 'progress' => $progressPercentage, + 'planned' => $plannedPercentage == false ? 0 : $plannedPercentage, + 'progress' => $progressPercentage == false ? 0 : $progressPercentage, 'difference' => $difference, ); @@ -441,5 +443,32 @@ class DashboardBoDController extends Controller return $data; } + public function getDetailExpenditure($year = '%'){ + $year = $this->interpolateYear($year); + $projects = Project::where('mulai_proyek', 'like', $year) + /* ->orWhere('akhir_proyek', 'like', $year) */ + ->get(); + foreach($projects as $project){ + $lastGantt = $this->getLatestGantt($project->id); + + if($project->kode_sortname != ""){ + $resp = $this->getInvoiceIntegration($project->kode_sortname); + $project->invoice = [ + 'invoiced' => $resp->data->total_invoice_amount ?? 0, + 'paid' => $resp->data->total_invoice_paid_amount ?? 0, + ]; + } + + $project->pm = User::find($project->pm_id); + /* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */ + $project->scurve = $this->getSCurve($project->id); + $project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count(); + } + + return response()->json([ + 'data' => $projects, + 'total_manpowers' => User::count() + ], 200); + } } diff --git a/routes/web.php b/routes/web.php index 2c869be..fbb539b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -32,6 +32,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); @@ -66,7 +67,6 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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-progress/{id}/{date?}', 'ProjectController@getProgress'); */ /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ From cef46de0fd48bb1d5d9678c56d2e2eef168d55ca Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 04:41:02 +0700 Subject: [PATCH 038/131] bugfix --- app/Http/Controllers/ProjectController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 8a9d124..39aee49 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -387,7 +387,8 @@ class ProjectController extends Controller if(isset($dataPayload['end_date'])){ $maxDate = $dataPayload['end_date']; $end = new \DateTime($maxDate); - $interval = \DateInterval::createFromDateString('1 day'); + /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged + $interval = new \DateInterval('P7D'); } else { $maxDate = DB::table('assign_material_to_activity as ama') ->where("ama.proyek_id", $keyGantt['proyek_id']) From cdd50b4d3679d40a3d41c9369590d56bfc0c4dea Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 04:54:56 +0700 Subject: [PATCH 039/131] add gantt id --- app/Http/Controllers/DashboardBoDController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index b84592e..42170cc 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -463,6 +463,7 @@ class DashboardBoDController extends Controller /* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */ $project->scurve = $this->getSCurve($project->id); $project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count(); + $project->lastGanttId = $this->getLatestGantt($project->id); } return response()->json([ From 5581e04ac8bdb35f62456b7d8afdaea1260f7d3d Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 14:19:18 +0700 Subject: [PATCH 040/131] total expenditure integration --- app/Http/Controllers/DashboardBoDController.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 42170cc..c0ccd94 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -71,20 +71,11 @@ class DashboardBoDController extends Controller foreach($projects as $project){ $project->expenses = 0; - // expenditure - $assignedMaterials = AssignMaterial::where('proyek_id', $project->id)->get(); - foreach($assignedMaterials as $assignedMaterial) { - $reportedMaterials = ReportActivityMaterial::where('assign_material_id', $assignedMaterial->id)->get(); - foreach($reportedMaterials as $reportedMaterial) { - $project->expenses += $reportedMaterial->qty * $assignedMaterial->budget; - } - } - $totalExpenditure += $project->expenses; - $resp = null; if($project->kode_sortname != ""){ $resp = $this->getInvoiceIntegration($project->kode_sortname); /* $resp = $project->kode_sortname; */ + $totalExpenditure+= $resp->data->total_invoice_amount ?? 0; $totalInvoice += $resp->data->total_invoice_amount ?? 0; $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0; } From 179483abd7d7f2712cf9ae9adc54cb1d439ac8d1 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 16:30:25 +0700 Subject: [PATCH 041/131] bugfix --- app/Http/Controllers/DashboardBoDController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index c0ccd94..315c0ca 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -75,7 +75,9 @@ class DashboardBoDController extends Controller if($project->kode_sortname != ""){ $resp = $this->getInvoiceIntegration($project->kode_sortname); /* $resp = $project->kode_sortname; */ - $totalExpenditure+= $resp->data->total_invoice_amount ?? 0; + $cost = $resp->data->total_cost ?? 0; + $cost = substr($cost, 0, strpos($cost, ".")); + $totalExpenditure+= (int) $cost; $totalInvoice += $resp->data->total_invoice_amount ?? 0; $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0; } From a58c43dfdc2f0d8e99e803482e5da85fa99ba0ef Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 10:52:23 +0700 Subject: [PATCH 042/131] disable some calc --- app/Http/Controllers/ProjectController.php | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 39aee49..8cdb564 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -531,27 +531,27 @@ class ProjectController extends Controller } /* print_r($tempDate); exit(); */ - try { - if(round($totalACWP,0) > $totalRencanaBudget){ - $estimatedCost = round($totalACWP,0)+0; - }else{ - $estimatedCost = ($totalRencanaBudget+0); - } - } catch (\DivisionByZeroError $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"; - } + /* try { */ + /* if(round($totalACWP,0) > $totalRencanaBudget){ */ + /* $estimatedCost = round($totalACWP,0)+0; */ + /* }else{ */ + /* $estimatedCost = ($totalRencanaBudget+0); */ + /* } */ + /* } catch (\DivisionByZeroError $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"; */ + /* } */ $dataResponse = array( "date" =>$tempDate, @@ -564,9 +564,9 @@ class ProjectController extends Controller "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, + /* "estimated_at_completion" => $estimatedCost, */ + /* "cost_deviation" => $costDeviation, */ + /* "potential" => $potential, */ ) ); From 589187f15a02c81f704a5e513657ea2a0a641173 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 10:56:06 +0700 Subject: [PATCH 043/131] add default value --- app/Http/Controllers/ProjectController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 8cdb564..09afb5d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -402,6 +402,7 @@ class ProjectController extends Controller $arr_ActualM = []; $tempDate = []; + $tempPercentage = []; $tempPercentagePlan = []; $tempPercentagePlanWhr = []; $tempPercentageReal = []; From 87893310a6b7f42740a7b370f5296660376281bc Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 11:38:22 +0700 Subject: [PATCH 044/131] bugfix --- app/Http/Controllers/ProjectController.php | 54 +++++++++++----------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 09afb5d..2dbe9c2 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -381,7 +381,9 @@ class ProjectController extends Controller /* ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') */ /* ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) */ /* ->min("plan_date"); */ - $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); + /* $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); */ + $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->whereNull('parent_id')->pluck('start_date')->first(); + /* print_r($minDate); exit(); */ $begin = new \DateTime($minDate.' Monday'); if(isset($dataPayload['end_date'])){ @@ -402,7 +404,6 @@ class ProjectController extends Controller $arr_ActualM = []; $tempDate = []; - $tempPercentage = []; $tempPercentagePlan = []; $tempPercentagePlanWhr = []; $tempPercentageReal = []; @@ -415,6 +416,7 @@ class ProjectController extends Controller /* foreach($period as $x){ */ /* echo $x->format("Y-m-d")."\n"; */ /* } exit(); */ + foreach ($period as $dt) { $minSevenDays = new \Datetime($dt->format("Y-m-d")); $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); @@ -532,27 +534,27 @@ class ProjectController extends Controller } /* print_r($tempDate); exit(); */ - /* try { */ - /* if(round($totalACWP,0) > $totalRencanaBudget){ */ - /* $estimatedCost = round($totalACWP,0)+0; */ - /* }else{ */ - /* $estimatedCost = ($totalRencanaBudget+0); */ - /* } */ - /* } catch (\DivisionByZeroError $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"; */ - /* } */ + try { + if(round($totalACWP,0) > $totalRencanaBudget){ + $estimatedCost = round($totalACWP,0)+0; + }else{ + $estimatedCost = ($totalRencanaBudget+0); + } + } catch (\DivisionByZeroError $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"; + } $dataResponse = array( "date" =>$tempDate, @@ -565,9 +567,9 @@ class ProjectController extends Controller "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, */ + "estimated_at_completion" => $estimatedCost, + "cost_deviation" => $costDeviation, + "potential" => $potential, ) ); From cc6516c712344405434bcbaa7c28cdd189a13ab5 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 14:32:02 +0700 Subject: [PATCH 045/131] bugfix date --- app/Http/Controllers/DashboardBoDController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 315c0ca..4cebea1 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -326,7 +326,8 @@ class DashboardBoDController extends Controller if(!$alreadyHasReport) continue; - $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); + /* $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); */ + $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->whereNull('parent_id')->pluck('start_date')->first(); $begin = new \DateTime($minDate.' Monday'); $maxDate = DB::table('assign_material_to_activity as ama') From 348e56c7986c0ce3ba7a5bc29a20b8088986d6ab Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 14:40:51 +0700 Subject: [PATCH 046/131] bugfix --- app/Http/Controllers/DashboardBoDController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 4cebea1..85c5eb3 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -386,7 +386,7 @@ class DashboardBoDController extends Controller ->groupBy('activity_id') ->first(); try { - $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; + $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan ?? 0)*$keyActualM->bobot_planning; } catch (\DivisionByZeroError $e) { return response()->json(['message' => $e->getMessage()]); } From dc816444d3da38702b395b5f6968fed4b7c6e984 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 14:44:24 +0700 Subject: [PATCH 047/131] bugfix --- app/Http/Controllers/DashboardBoDController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 85c5eb3..46d2b34 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -326,8 +326,8 @@ class DashboardBoDController extends Controller if(!$alreadyHasReport) continue; - /* $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); */ - $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->whereNull('parent_id')->pluck('start_date')->first(); + $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("start_date"); + /* $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->whereNull('parent_id')->pluck('start_date')->first(); */ $begin = new \DateTime($minDate.' Monday'); $maxDate = DB::table('assign_material_to_activity as ama') @@ -386,7 +386,7 @@ class DashboardBoDController extends Controller ->groupBy('activity_id') ->first(); try { - $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan ?? 0)*$keyActualM->bobot_planning; + $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; } catch (\DivisionByZeroError $e) { return response()->json(['message' => $e->getMessage()]); } From aaf4aecaf05ca44feb0a0be4ffff486cb6417853 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 14:47:00 +0700 Subject: [PATCH 048/131] revert --- app/Http/Controllers/DashboardBoDController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 46d2b34..315c0ca 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -326,8 +326,7 @@ class DashboardBoDController extends Controller if(!$alreadyHasReport) continue; - $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("start_date"); - /* $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->whereNull('parent_id')->pluck('start_date')->first(); */ + $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); $begin = new \DateTime($minDate.' Monday'); $maxDate = DB::table('assign_material_to_activity as ama') From 5c1567db0a76abb48ddc4e05fa8163e1e6165a38 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 16:43:02 +0700 Subject: [PATCH 049/131] fix mindate --- app/Http/Controllers/DashboardBoDController.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 315c0ca..6c952ef 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -130,15 +130,19 @@ class DashboardBoDController extends Controller $projects = Project::where('mulai_proyek', 'like', $year)->get(); foreach($projects as $project) { $project->scurve = $this->getSCurve($project->id); + try { if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) $return['warning'] += 1; elseif(@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) $return['behind-schedule'] += 1; elseif(@$project->scurve['difference'] == 0) $return['on-schedule'] += 1; + } catch (\Error $e) { + return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200); + } } - return response()->json(['data' => $return], 200); + return response()->json(['data' => $return, 'q' => $projects], 200); } public function getTotalProjectScheduleHealthPerDivision($year = '%'){ @@ -326,7 +330,8 @@ class DashboardBoDController extends Controller if(!$alreadyHasReport) continue; - $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); + /* $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); */ + $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->whereNull('parent_id')->pluck('start_date')->first(); $begin = new \DateTime($minDate.' Monday'); $maxDate = DB::table('assign_material_to_activity as ama') @@ -379,15 +384,15 @@ class DashboardBoDController extends Controller $sumPercentageActual=0; foreach ($dataActualM as $keyActualM) { + try { $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(); - try { $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; - } catch (\DivisionByZeroError $e) { - return response()->json(['message' => $e->getMessage()]); + } catch (\Exception $e) { + return response()->json(['message' => $e->getMessage(), 'q' => $sumVolActual]); } } From a05cfab65d29cc08b376591bc999c0ea54506726 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 31 Oct 2022 22:24:10 +0700 Subject: [PATCH 050/131] bugfix type activity and improve update bobot --- app/Http/Controllers/ActivityController.php | 22 ++++++------ app/Models/Activity.php | 38 +++++++-------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 3fdd675..a647bdb 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -25,7 +25,7 @@ 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); @@ -42,20 +42,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->type = $type; $finalData[] = $objRow; $finalData = array_merge($finalData, $dataChildren); @@ -183,7 +185,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(); } @@ -209,16 +214,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; diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 52708f4..e1eacb3 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -44,6 +44,7 @@ class Activity extends Model if(Activity::where("parent_id", $data->parent_id)->count() == 0) Activity::find($data->parent_id)->update(["type_activity"=>"task"]); + $data->updateBobot(true); $data->updateCostPlanning(); $data->updatePersentaseProgress(); $data->updateCostActual(); @@ -51,39 +52,26 @@ class Activity extends Model } - private function updateBobot() + private function updateBobot($isDelete = false) { - $rootActivity = Activity::where('version_gantt_id', $this->version_gantt_id) + $root = Activity::where('version_gantt_id', $this->version_gantt_id) ->where("proyek_id", $this->proyek_id) - ->where('type_activity', 'header') + ->whereNull('parent_id') ->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))') - ) - ->where("proyek_id", $this->proyek_id) - ->where("version_gantt_id", $this->version_gantt_id) - ->whereNull("parent_id") - ->first(); - } else { - $totalCost = Activity::select(DB::raw('sum(cast(rencana_biaya as double precision))')) - ->where("proyek_id", $this->proyek_id) - ->where("version_gantt_id", $this->version_gantt_id) - ->where("parent_id", $rootActivity->id) - ->first(); - } - - if($totalCost->sum > 0){ + if($root->rencana_biaya > 0){ $activities = Activity::where("proyek_id", $this->proyek_id)->where("version_gantt_id", $this->version_gantt_id)->get(); foreach ($activities as $activity) { - $activity->update([ - "bobot_planning" => ( (int)$activity->rencana_biaya / $totalCost->sum ) * 100, - "updated_by" => auth()->user() ? auth()->user()->name : "system", - ]); - $activity->save(); + if($isDelete && $activity->id == $this->id) + continue; + + $activity->bobot_planning = ( (int)$activity->rencana_biaya / $root->rencana_biaya) * 100; + $activity->updated_by = auth()->user() ? auth()->user()->name : "system"; + $activity->saveQuietly(); + } } + } private function updateCostActual() From 4272c9062e7955f134a90a4cf1e302e6b7ab066e Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 2 Nov 2022 13:42:52 +0700 Subject: [PATCH 051/131] move curl req to helper --- app/Helpers/MasterFunctionsHelper.php | 32 +++++++++++++++ app/Http/Controllers/ActivityController.php | 2 +- app/Http/Controllers/ProjectController.php | 44 ++------------------- composer.json | 3 ++ 4 files changed, 40 insertions(+), 41 deletions(-) create mode 100644 app/Helpers/MasterFunctionsHelper.php diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php new file mode 100644 index 0000000..033c78c --- /dev/null +++ b/app/Helpers/MasterFunctionsHelper.php @@ -0,0 +1,32 @@ +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; + $objRow->progress = $objRow->persentase_progress / 100; $objRow->type = $type; $finalData[] = $objRow; $finalData = array_merge($finalData, $dataChildren); diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 2dbe9c2..ec9923b 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Helpers\MasterFunctionsHelper; use App\Models\Activity; use App\Models\ActivityDokumen; use App\Models\AssignMaterial; @@ -262,12 +263,7 @@ class ProjectController extends Controller ->where('m_proyek.id', $d->id) ->pluck('m_users.name') ->first(); - if($d->area_kerja != ''){ - $d->geolocation = $this->httpReq($d->area_kerja); - $d->geolocation = []; - } else { - $d->geolocation = []; - } + $d->geolocation = []; } $totalPlannedCost = $data->sum('plannedCost'); @@ -313,21 +309,6 @@ class ProjectController extends Controller ], 200); } - private function httpReq($search){ - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); - - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_VERBOSE, true); - curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w')); - - $output = curl_exec($ch); - curl_close($ch); - - return json_decode($output); - } - private function getLatestGantt($id){ $maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); $data = array( @@ -674,30 +655,13 @@ class ProjectController extends Controller return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 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 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'); - $token = config('api.adw_token'); - $response = $this->curlReq($url, $token); + + $response = MasterFunctionsHelper::curlReq($url); if($response->data->project_no == "") return response()->json(['status'=>'error', 'message' => 'Project '.$search.' not found!', 'code'=>404], 404); diff --git a/composer.json b/composer.json index 6602dc4..26c3321 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,9 @@ "phpunit/phpunit": "^9.5.10" }, "autoload": { + "files": [ + "app/Helpers/MasterFunctionsHelper.php" + ], "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", From c831a1a6193e066c537a14a2e61d4a53648a3fee Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Fri, 11 Nov 2022 02:38:33 +0700 Subject: [PATCH 052/131] implement human resource integration --- .../Commands/syncHumanResourceIntegration.php | 77 +++++++++++++++++++ app/Console/Kernel.php | 5 +- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/syncHumanResourceIntegration.php diff --git a/app/Console/Commands/syncHumanResourceIntegration.php b/app/Console/Commands/syncHumanResourceIntegration.php new file mode 100644 index 0000000..0f3b72d --- /dev/null +++ b/app/Console/Commands/syncHumanResourceIntegration.php @@ -0,0 +1,77 @@ +message != 'success') + return; + + if(!is_int($response->total) || $response->total == 0) + return; + + $totalPage = $response->last_page; + echo "\nTotal Page = " . $totalPage; + $currentResponse = $response; + for($i = 1; $i <= $totalPage; $i++){ + echo "\nCurrent Page = " . $i; + $employeesPageData = $currentResponse->data; + foreach($employeesPageData as $employee){ + HumanResource::firstOrCreate( + ['ktp_number' => $employee->emp_id], + [ + 'name' => $employee->name, + 'employee_type' => 'employee', + 'status_resource' => 'active', + 'role_id' => 24, + 'created_by' => 'integration' + ], + ); + } + echo "\n------------------------------------------\n"; + $currentResponse = MasterFunctionsHelper::curlReq(str_replace('1', $i, $url)); + } + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index cdba880..a379d80 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,6 +13,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ + Commands\syncHumanResourceIntegration::class ]; /** @@ -23,5 +24,7 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - } + $schedule->command('sync:integration-human-resources')->twiceDaily(); + } + } From 13b2d53c9cd3a12f4245c62cbe6f5890852c8b25 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 17 Nov 2022 16:27:52 +0700 Subject: [PATCH 053/131] set default timezone to Asia/Jakarta --- app/Http/Controllers/ActivityController.php | 1 - bootstrap/app.php | 2 +- config/app.php | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 8788f21..5e6224d 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -5,7 +5,6 @@ use App\Models\Activity; use App\Models\CommentActivity; use App\Models\Link; use App\Models\Project; -use App\Models\ReportActivity; use App\Models\TemplateGantt; use App\Models\UserToActivity; use Illuminate\Http\Request; diff --git a/bootstrap/app.php b/bootstrap/app.php index 5f8ccca..0bef746 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -6,7 +6,7 @@ require_once __DIR__.'/../vendor/autoload.php'; dirname(__DIR__) ))->bootstrap(); -date_default_timezone_set(env('APP_TIMEZONE', 'UTC')); +date_default_timezone_set(env('APP_TIMEZONE', 'Asia/Jakarta')); /* |-------------------------------------------------------------------------- diff --git a/config/app.php b/config/app.php index 2ab666c..c1875ec 100644 --- a/config/app.php +++ b/config/app.php @@ -5,5 +5,7 @@ 'cost_health_danger_threshold' => 0, 'schedule_health_warning_threshold' => 30, 'schedule_health_danger_threshold' => 0, + 'timezone' => env('APP_TIMEZONE', 'Asia/Jakarta'), + 'app_timezone' => env('APP_TIMEZONE', 'Asia/Jakarta'), ]; ?> From 7fd4316fbdc372cc8af7390ab64d53f045e56d1a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 17 Nov 2022 18:51:46 +0700 Subject: [PATCH 054/131] fix timezone problem --- app/Models/Activity.php | 17 +++++++++++++++ app/Models/AssignMaterial.php | 1 - app/Models/ReportActivityMaterial.php | 8 +++++++ app/Models/RequestMaterial.php | 30 +++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index e1eacb3..7b3468f 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -8,6 +8,7 @@ use App\Models\ReportActivityMaterial; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; +use Carbon\Carbon; class Activity extends Model { @@ -30,6 +31,22 @@ class Activity extends Model 'jobs_done', 'assign_hr', 'assign_material', 'assign_tools' ]; + + public function getStartDateAttribute($value) + { + return Carbon::createFromTimestamp(strtotime($value)) + ->timezone(env('APP_TIMEZONE')) + ->toDateTimeString(); + } + + public function getEndDateAttribute($value) + { + return Carbon::createFromTimestamp(strtotime($value)) + ->timezone(env('APP_TIMEZONE')) + ->toDateTimeString(); + } + + public static function boot() { parent::boot(); diff --git a/app/Models/AssignMaterial.php b/app/Models/AssignMaterial.php index 597f430..988446a 100644 --- a/app/Models/AssignMaterial.php +++ b/app/Models/AssignMaterial.php @@ -5,7 +5,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use App\Models\RequestMaterial; use App\Models\Activity; -use Carbon\Carbon; class AssignMaterial extends Model { diff --git a/app/Models/ReportActivityMaterial.php b/app/Models/ReportActivityMaterial.php index 1549248..2b90acb 100644 --- a/app/Models/ReportActivityMaterial.php +++ b/app/Models/ReportActivityMaterial.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use App\Models\Activity; use App\Models\AssignMaterial; +use Carbon\Carbon; class ReportActivityMaterial extends Model { @@ -18,6 +19,13 @@ class ReportActivityMaterial extends Model 'report_date', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; + public function getReportDateAttribute($value) + { + return Carbon::createFromTimestamp(strtotime($value)) + ->timezone(env('APP_TIMEZONE')) + ->toDateTimeString(); + } + public static function boot() { parent::boot(); diff --git a/app/Models/RequestMaterial.php b/app/Models/RequestMaterial.php index c4239fd..550d2d5 100644 --- a/app/Models/RequestMaterial.php +++ b/app/Models/RequestMaterial.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Carbon\Carbon; class RequestMaterial extends Model { @@ -35,4 +36,33 @@ class RequestMaterial extends Model 'updated_by', 'price' ]; + + public function getRequiredDateAttribute($value) + { + return Carbon::createFromTimestamp(strtotime($value)) + ->timezone(env('APP_TIMEZONE')) + ->toDateTimeString(); + } + + public function getFomDateAttribute($value) + { + return Carbon::createFromTimestamp(strtotime($value)) + ->timezone(env('APP_TIMEZONE')) + ->toDateTimeString(); + } + + public function getPrDateAttribute($value) + { + return Carbon::createFromTimestamp(strtotime($value)) + ->timezone(env('APP_TIMEZONE')) + ->toDateTimeString(); + } + + public function getPoDateAttribute($value) + { + return Carbon::createFromTimestamp(strtotime($value)) + ->timezone(env('APP_TIMEZONE')) + ->toDateTimeString(); + } + } From 71e0432f66ea61a49384440bfd97bb54629fa208 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Sat, 19 Nov 2022 23:55:18 +0700 Subject: [PATCH 055/131] fix volume actual calc --- app/Models/Activity.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 7b3468f..3ec0bac 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -130,20 +130,14 @@ 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()) return 0; - foreach ($dataPlan as $value) { - $tmpPercentage[] = 100; - $getDataVolActual = ReportActivityMaterial::where('assign_material_id', '=', $value->id)->sum("qty"); - $percentage = ($getDataVolActual * 100) / $value->qty_planning; - if($value->status_activity != 'done'){ - $tmpPercentage[] = $percentage >= 100 ? 90 : $percentage; - } - } - return array_sum($tmpPercentage) > 0 ? array_sum($tmpPercentage) / count($tmpPercentage) : 0; + $totalPlan = $dataPlan->sum('qty_planning'); + $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $this->id)->sum("qty"); + $percentage = ($totalVolumeActual * 100) / $totalPlan; + return $percentage > 95 ? 95 : $percentage; } public function getAssignHrAttribute() From 203eaa48259709cc46f0bf851c745fedeff4dd25 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 21 Nov 2022 16:34:46 +0700 Subject: [PATCH 056/131] set default max percentage --- .../ReportActivityMaterialController.php | 41 ++----------------- app/Models/Activity.php | 2 +- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index 04ae220..9ed7bea 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -9,13 +9,13 @@ use App\Models\AssignMaterial; use Datatables; class ReportActivityMaterialController extends Controller -{ +{ private function sanitizeDecimal($number) { $number = str_replace(".","",$number); $number = str_replace(",",".",$number); return $number; } - + public function add(Request $request){ $this->validate($request, [ @@ -88,9 +88,9 @@ class ReportActivityMaterialController extends Controller if($status_activity == 'done'){ $tmpPercentage1[] = $percentage1 > 100 ? 100 : $percentage1; }else if($status_activity == 'on-progress'){ - $tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; + $tmpPercentage1[] = $percentage1 >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage1; }else{ - $tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; + $tmpPercentage1[] = $percentage1 >= config('max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage1; } } $totalPercentage = array_sum($tmpPercentage1) / count($tmpPercentage1); @@ -108,39 +108,6 @@ class ReportActivityMaterialController extends Controller return $dataActivity->update($dataUpdate); } - public function countForProgressTest() - { - $dataPlan = AssignMaterial::where('activity_id', 807)->get(); - $tmpPercentage1 = []; - - if(!$dataPlan->isEmpty()){ - foreach ($dataPlan as $value) { - # code... - $price = $value->material_id; - $qty_plan = $value->qty_planning; - $status_activity = $value->status_activity; - - $getDataVolActual = ReportActivityMaterial::where('assign_material_id', '=', $value->id)->sum("qty"); - $percentage1 = ($getDataVolActual * 100) / $qty_plan; - $percentage1 = ($getDataVolActual * 100) / $qty_plan; - if($status_activity == 'done'){ - $tmpPercentage1[] = $percentage1 > 100 ? 100 : $percentage1; - }else if($status_activity == 'on-progress'){ - $tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; - }else{ - $tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; - } - - - } - $totalPercentage = array_sum($tmpPercentage1) / count($tmpPercentage1); - }else{ - $totalPercentage = 0; - } - - return response()->json(['status'=>'success','code'=>200,'data'=>$dataPlan, 'tmpPercentage1'=> $tmpPercentage1, 'totalPercentage'=> $totalPercentage], 200); - } - public function search(Request $request) { $payload = $request->all(); diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 3ec0bac..9ad288b 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -137,7 +137,7 @@ class Activity extends Model $totalPlan = $dataPlan->sum('qty_planning'); $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $this->id)->sum("qty"); $percentage = ($totalVolumeActual * 100) / $totalPlan; - return $percentage > 95 ? 95 : $percentage; + return $percentage > config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; } public function getAssignHrAttribute() From 611a5bb21ff80969b0f943fc4df90144c560ed20 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 21 Nov 2022 16:35:01 +0700 Subject: [PATCH 057/131] set default max percentage --- config/app.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/app.php b/config/app.php index c1875ec..7ed1c88 100644 --- a/config/app.php +++ b/config/app.php @@ -7,5 +7,6 @@ 'schedule_health_danger_threshold' => 0, 'timezone' => env('APP_TIMEZONE', 'Asia/Jakarta'), 'app_timezone' => env('APP_TIMEZONE', 'Asia/Jakarta'), + 'max_percentage_not_done' => 95, ]; ?> From 484d74a5c4d8f328b010aa1b74dd1be43b2c5e5a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 21 Nov 2022 16:35:34 +0700 Subject: [PATCH 058/131] remove unused endpoint --- routes/web.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index fbb539b..6c07361 100644 --- a/routes/web.php +++ b/routes/web.php @@ -320,8 +320,6 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); From 637b768b4583f9be034912df4af756b763a78f42 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 22 Nov 2022 09:26:37 +0700 Subject: [PATCH 059/131] header show progress --- app/Http/Controllers/ActivityController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 5e6224d..561c767 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -31,7 +31,10 @@ class ActivityController extends Controller $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(); From 07dc607386ac2b329b6869eede53fcf1a292d83f Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 22 Nov 2022 14:05:28 +0700 Subject: [PATCH 060/131] overhaul progress calc --- .../ReportActivityMaterialController.php | 41 ------------------- app/Models/Activity.php | 7 ++-- app/Models/AssignMaterial.php | 4 +- app/Models/ReportActivityMaterial.php | 24 ++++++++++- 4 files changed, 28 insertions(+), 48 deletions(-) diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index 9ed7bea..b2cf7c7 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -31,7 +31,6 @@ class ReportActivityMaterialController extends Controller if(!ReportActivityMaterial::create($data)) return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400]); - $this->countForProgress($request->activity_id); return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200]); } @@ -68,46 +67,6 @@ class ReportActivityMaterialController extends Controller return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=>200], 200); } - private function countForProgress($id) - { - - $dataActivity = Activity::find($id); - $dataPlan = AssignMaterial::where('activity_id', $id)->get(); - $tmpPercentage1 = []; - if(!$dataPlan->isEmpty()){ - - foreach ($dataPlan as $value) { - # code... - $price = $value->material_id; - $qty_plan = $value->qty_planning; - $status_activity = $value->status_activity; - - $getDataVolActual = ReportActivityMaterial::where('assign_material_id', '=', $value->id)->sum("qty"); - $percentage1 = ($getDataVolActual * 100) / $qty_plan; - - if($status_activity == 'done'){ - $tmpPercentage1[] = $percentage1 > 100 ? 100 : $percentage1; - }else if($status_activity == 'on-progress'){ - $tmpPercentage1[] = $percentage1 >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage1; - }else{ - $tmpPercentage1[] = $percentage1 >= config('max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage1; - } - } - $totalPercentage = array_sum($tmpPercentage1) / count($tmpPercentage1); - }else{ - $totalPercentage = 0; - } - - - - - $dataUpdate = array( - "persentase_progress" => $totalPercentage, - "updated_by" => $this->currentName - ); - return $dataActivity->update($dataUpdate); - } - public function search(Request $request) { $payload = $request->all(); diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 9ad288b..ac836bf 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -134,10 +134,9 @@ class Activity extends Model return 0; if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get()) return 0; - $totalPlan = $dataPlan->sum('qty_planning'); - $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $this->id)->sum("qty"); - $percentage = ($totalVolumeActual * 100) / $totalPlan; - return $percentage > config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; + if($dataPlan[0]->status_activity == 'done') + return 100; + return $this->persentase_progress; } public function getAssignHrAttribute() diff --git a/app/Models/AssignMaterial.php b/app/Models/AssignMaterial.php index 988446a..1b6d29e 100644 --- a/app/Models/AssignMaterial.php +++ b/app/Models/AssignMaterial.php @@ -14,7 +14,9 @@ class AssignMaterial extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'proyek_id', 'activity_id', 'material_id', 'qty_planning', 'budget', 'plan_date','created_at', 'created_by', 'updated_at', 'updated_by' + 'proyek_id', 'activity_id', 'material_id', 'qty_planning', + 'budget', 'plan_date', 'status_activity', + 'created_at', 'created_by', 'updated_at', 'updated_by' ]; protected $casts = [ diff --git a/app/Models/ReportActivityMaterial.php b/app/Models/ReportActivityMaterial.php index 2b90acb..3caac56 100644 --- a/app/Models/ReportActivityMaterial.php +++ b/app/Models/ReportActivityMaterial.php @@ -30,13 +30,22 @@ class ReportActivityMaterial extends Model parent::boot(); static::created(function($data) { - $activity = Activity::find($data->activity_id); $assignedMaterial = AssignMaterial::find($data->assign_material_id); $activity->biaya_actual += floatval($assignedMaterial->budget) * floatval($data->qty); - $activity->save(); + $dataPlan = AssignMaterial::where('activity_id', $activity->id)->get(); + if($dataPlan[0]->status_activity == 'done'){ + $activity->persentase_progress = 100; + } else { + $totalPlan = $dataPlan->sum('qty_planning'); + $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $activity->id)->sum("qty"); + $percentage = ($totalVolumeActual * 100) / $totalPlan; + $activity->persentase_progress = $percentage >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; + } + + $activity->save(); }); static::deleted(function($data) { @@ -45,6 +54,17 @@ class ReportActivityMaterial extends Model $assignedMaterial = AssignMaterial::find($data->assign_material_id); $activity->biaya_actual -= floatval($assignedMaterial->budget) * floatval($data->qty); + + $dataPlan = AssignMaterial::where('activity_id', $activity->id)->get(); + if($dataPlan[0]->status_activity == 'done'){ + $activity->persentase_progress = 100; + } else { + $totalPlan = $dataPlan->sum('qty_planning'); + $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $activity->id)->sum("qty"); + $percentage = ($totalVolumeActual * 100) / $totalPlan; + $activity->persentase_progress = $percentage >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; + } + $activity->save(); }); From fc445ebe02b3b18a715eccdb238126151719032f Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 22 Nov 2022 18:21:37 +0700 Subject: [PATCH 061/131] new flow & bugfix old reporting problem --- .../Controllers/AssignMaterialController.php | 17 ++++++++++------- .../ReportActivityMaterialController.php | 9 +++++++-- app/Models/Activity.php | 13 ++++++++++++- app/Models/AssignMaterial.php | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index 0122c01..583d2cd 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -104,11 +104,13 @@ class AssignMaterialController extends Controller public function datatables(Request $request){ $id_activity = $request->query('idact'); + $type = $request->query('type') ?? "material"; $data = AssignMaterial::select( "assign_material_to_activity.*","m.description as material_name", "m.uom as uom" ) ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('assign_material_to_activity.activity_id', $id_activity) + ->where('assign_material_to_activity.type', $type) ->orderBy('plan_date', 'desc') ->get(); return Datatables::of($data) @@ -124,14 +126,15 @@ class AssignMaterialController extends Controller $id_activity = $request->query('idact'); $data = AssignMaterial::select( - AssignMaterial::raw( - 'SUM(qty_planning) as qty_planning'), + AssignMaterial::raw('SUM(qty_planning) as qty_planning'), "m.description as material_name", - "assign_material_to_activity.activity_id as activity_id" + "assign_material_to_activity.activity_id", + "assign_material_to_activity.type", ) ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->groupBy("m.description") ->groupBy("assign_material_to_activity.activity_id") + ->groupBy("assign_material_to_activity.type") ->where("assign_material_to_activity.activity_id", $id_activity)->get(); return Datatables::of($data) ->addIndexColumn() @@ -171,8 +174,10 @@ class AssignMaterialController extends Controller return $val_uom ? $val_uom->uom : null; }) ->addColumn('action', function($row){ - $actionBtn = ''; - $actionBtn .= ''; + $dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") + ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); + $actionBtn = ''; + $actionBtn .= ''; return $actionBtn; }) ->rawColumns(['action'])->make(true); @@ -184,8 +189,6 @@ class AssignMaterialController extends Controller ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('assign_material_to_activity.activity_id', $id_activity)->get(); foreach ($data as $key) { - # code... - $val_qty_sum = ReportActivityMaterial::where('assign_material_id', '=', $key->id)->sum("qty"); } $countData = $data->count(); diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index b2cf7c7..57ecfe3 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -25,7 +25,8 @@ class ReportActivityMaterialController extends Controller $data = $request->all(); $data['created_by'] = $this->currentName; - $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); + /* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */ + $data['assign_material_id'] = $request->assign_material_id; $data['qty'] = $this->sanitizeDecimal($data['qty']); if(!ReportActivityMaterial::create($data)) @@ -92,12 +93,13 @@ class ReportActivityMaterialController extends Controller public function datatables(Request $request){ $id_activity = $request->query('idAct'); - $id_assign_material_id= $request->query('idAmi'); $type = $request->query('type'); + $materialName = $request->query('materialName'); if($type == 'plan'){ $data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('assign_material_to_activity.activity_id', $id_activity) + ->where('m.description', $materialName) ->orderBy('assign_material_to_activity.id', 'asc') ->get(); return Datatables::of($data) @@ -109,8 +111,11 @@ class ReportActivityMaterialController extends Controller ->rawColumns(['action'])->make(true); }else{ $data = ReportActivityMaterial::select("report_activity_material.*", "u.name as human_resource") + ->join("assign_material_to_activity as amta", "amta.id", "=", "report_activity_material.assign_material_id") + ->join("m_req_material as m", "m.id", "=", "amta.material_id") ->join("m_users as u", "u.id", "=", "report_activity_material.user_id") ->where('report_activity_material.activity_id', $id_activity) + ->where('m.description', $materialName) ->orderBy('report_activity_material.report_date', 'asc') ->get(); return Datatables::of($data) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index ac836bf..0220975 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -28,7 +28,7 @@ class Activity extends Model ]; protected $appends = [ - 'jobs_done', 'assign_hr', 'assign_material', 'assign_tools' + 'jobs_done', 'assign_hr', 'assign_material', 'assign_tools', 'assign_expense' ]; @@ -153,6 +153,17 @@ class Activity extends Model return Arr::flatten(AssignMaterial::select("m.description as name") ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('assign_material_to_activity.activity_id', $this->id) + ->where('assign_material_to_activity.type', "material") + ->get() + ->toArray()); + } + + public function getAssignExpenseAttribute() + { + return Arr::flatten(AssignMaterial::select("m.description as name") + ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") + ->where('assign_material_to_activity.activity_id', $this->id) + ->where('assign_material_to_activity.type', "expense") ->get() ->toArray()); } diff --git a/app/Models/AssignMaterial.php b/app/Models/AssignMaterial.php index 1b6d29e..5cb8bc5 100644 --- a/app/Models/AssignMaterial.php +++ b/app/Models/AssignMaterial.php @@ -15,7 +15,7 @@ class AssignMaterial extends Model protected $fillable = [ 'proyek_id', 'activity_id', 'material_id', 'qty_planning', - 'budget', 'plan_date', 'status_activity', + 'budget', 'plan_date', 'status_activity', 'type', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; From 9ff926765d97eb831b7e4ee0791b0120cc38aa39 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 23 Nov 2022 14:05:58 +0700 Subject: [PATCH 062/131] recalc progress proportionally --- app/Models/Activity.php | 16 ++++++++++------ app/Models/ReportActivityMaterial.php | 11 ++++++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 0220975..b8da186 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -104,14 +104,18 @@ class Activity extends Model private function updatePersentaseProgress() { - $siblings = Activity::where("parent_id", $this->parent_id); - $sumProgress = $siblings->sum("persentase_progress"); - $totalChild = $siblings->count(); - - $this->persentage_progress = $sumProgress / $totalChild; if($parent = Activity::find($this->parent_id)){ + $parentActWeight = $parent->bobot_planning; + + $totalChildProportionalProgress = 0; + $childs = Activity::where("parent_id", $parent->id)->get(); + foreach($childs as $child){ + $currentActWeight = $child->bobot_planning; + $currentActProportionalProgress = ($currentActWeight / $parentActWeight) * $child->persentase_progress; + $totalChildProportionalProgress += $currentActProportionalProgress; + } $parent->update([ - "persentase_progress" => $sumProgress / $totalChild, + "persentase_progress" => $totalChildProportionalProgress ]); } } diff --git a/app/Models/ReportActivityMaterial.php b/app/Models/ReportActivityMaterial.php index 3caac56..75b0817 100644 --- a/app/Models/ReportActivityMaterial.php +++ b/app/Models/ReportActivityMaterial.php @@ -33,18 +33,23 @@ class ReportActivityMaterial extends Model $activity = Activity::find($data->activity_id); $assignedMaterial = AssignMaterial::find($data->assign_material_id); - $activity->biaya_actual += floatval($assignedMaterial->budget) * floatval($data->qty); + $biayaActual = $activity->biaya_actual + floatval($assignedMaterial->budget) * floatval($data->qty); $dataPlan = AssignMaterial::where('activity_id', $activity->id)->get(); if($dataPlan[0]->status_activity == 'done'){ - $activity->persentase_progress = 100; + $percentage = 100; } else { $totalPlan = $dataPlan->sum('qty_planning'); $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $activity->id)->sum("qty"); $percentage = ($totalVolumeActual * 100) / $totalPlan; - $activity->persentase_progress = $percentage >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; + $percentage = $percentage >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; } + $activity->update([ + "persentase_progress" => $percentage, + "biaya_actual" => $biayaActual, + ]); + $activity->save(); }); From 4b9da555b15f23fb9452ac96b2ae82d91550c549 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 29 Nov 2022 18:31:54 +0700 Subject: [PATCH 063/131] temp: calc up bobot planning --- app/Models/Activity.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index b8da186..cc4beb1 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -87,8 +87,14 @@ class Activity extends Model $activity->saveQuietly(); } + } else { + if($parent = Activity::find($this->parent_id)){ + $totalChildWeight = Activity::where("parent_id", $this->parent_id)->sum('bobot_planning'); + $parent->update([ + "bobot_planning" => $totalChildWeight + ]); + } } - } private function updateCostActual() From 72fcd472acab7d51c74ed615e9c7bfdbac8955bf Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 1 Dec 2022 15:43:36 +0700 Subject: [PATCH 064/131] type gantt --- app/Http/Controllers/VersionGanttController.php | 7 +++---- app/Models/VersionGantt.php | 10 ++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/VersionGanttController.php b/app/Http/Controllers/VersionGanttController.php index 9406237..dbd7a6a 100644 --- a/app/Http/Controllers/VersionGanttController.php +++ b/app/Http/Controllers/VersionGanttController.php @@ -6,11 +6,10 @@ use Illuminate\Http\Request; use App\Models\VersionGantt; class VersionGanttController extends Controller -{ +{ public function add(Request $request){ $this->validate($request, [ 'name_version' => 'required', - 'description' => 'required', 'proyek_id' => 'required' ]); $data = $request->all(); @@ -36,7 +35,7 @@ class VersionGanttController extends Controller return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); die(); } - + if($result){ return response()->json(['status'=>'success','message'=>'version gantt Project successfully updated!','code'=>200], 200); }else{ @@ -54,7 +53,7 @@ class VersionGanttController extends Controller return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); die(); } - + if($delete){ return response()->json(['status'=>'success','message'=>'version gantt Project successfully deleted!','code'=>200], 200); diff --git a/app/Models/VersionGantt.php b/app/Models/VersionGantt.php index 0cea0b5..1cf1787 100644 --- a/app/Models/VersionGantt.php +++ b/app/Models/VersionGantt.php @@ -12,14 +12,16 @@ class VersionGantt extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'name_version', + 'name_version', 'description', 'date_base_line', 'proyek_id', 'config_dayoff', - 'created_at', - 'created_by', - 'updated_at', + 'auto_schedule', + 'calculation_type', + 'created_at', + 'created_by', + 'updated_at', 'updated_by' ]; } From ca9c6488f76dac623d4bcdaf265a11ff7e22284f Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Fri, 2 Dec 2022 15:45:41 +0700 Subject: [PATCH 065/131] gantt column by type --- app/Http/Controllers/ShowHideColumnController.php | 13 ++++++++++++- app/Models/GanttColumnByType.php | 10 ++++++++++ routes/web.php | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/Models/GanttColumnByType.php diff --git a/app/Http/Controllers/ShowHideColumnController.php b/app/Http/Controllers/ShowHideColumnController.php index 5492ab7..a2db693 100644 --- a/app/Http/Controllers/ShowHideColumnController.php +++ b/app/Http/Controllers/ShowHideColumnController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\UserToVersionGantt; use App\Models\ShowHideColumn; +use App\Models\GanttColumnByType; class ShowHideColumnController extends Controller { @@ -111,11 +112,21 @@ class ShowHideColumnController extends Controller $success--; } } - + if($success > 0){ return response()->json(['status'=>'success','message'=>'data show hide column successfully updated!','code'=>200], 200); }else{ return response()->json(['status'=>'failed','message'=>'data show hide column failed updated!','code'=>400], 400); } } + + public function getColumnByType($type = 'detail') + { + $data = GanttColumnByType::where("calculation_type", $type)->get(); + if(!$data) + return response()->json(['status'=>'failed','message'=>'No data found!','code'=> 404], 404); + + return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); + } + } diff --git a/app/Models/GanttColumnByType.php b/app/Models/GanttColumnByType.php new file mode 100644 index 0000000..0f5428c --- /dev/null +++ b/app/Models/GanttColumnByType.php @@ -0,0 +1,10 @@ +group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); From deea3080d0b4477d11e94b11e09fee5ed6a4818d Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Fri, 2 Dec 2022 17:19:37 +0700 Subject: [PATCH 066/131] logger progress --- app/Models/Activity.php | 29 +++++++++++++++++++++++++---- app/Models/ActivityProgressLog.php | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 app/Models/ActivityProgressLog.php diff --git a/app/Models/Activity.php b/app/Models/Activity.php index cc4beb1..ff6d559 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Models\AssignMaterial; +use App\Models\ActivityProgressLog; use App\Models\AssignTools; use App\Models\ReportActivityMaterial; use Illuminate\Database\Eloquent\Model; @@ -50,11 +51,17 @@ class Activity extends Model public static function boot() { parent::boot(); + static::updating(function($data) { + $data->logPersentaseProgress(); + }); + static::updated(function($data) { $data->updateBobot(); $data->updateCostPlanning(); - $data->updatePersentaseProgress(); - $data->updateCostActual(); + if($data->persentase_bobot){ + $data->updatePersentaseProgress(); + $data->updateCostActual(); + } }); static::deleted(function($data) { @@ -63,8 +70,10 @@ class Activity extends Model $data->updateBobot(true); $data->updateCostPlanning(); - $data->updatePersentaseProgress(); - $data->updateCostActual(); + if($data->persentase_bobot){ + $data->updatePersentaseProgress(); + $data->updateCostActual(); + } }); } @@ -138,6 +147,18 @@ class Activity extends Model } } + private function logPersentaseProgress() + { + ActivityProgressLog::create([ + 'version_gantt_id' => $this->version_gantt_id, + 'activity_id' => request()->id, + 'old_percentage' => $this->persentase_progress, + 'new_percentage' => request()->persentase_progress, + 'variance' => $this->persentase_progress - request()->persentase_progress, + 'created_by'=> "system" + ]); + } + public function getJobsDoneAttribute() { if(!ReportActivityMaterial::where('activity_id', $this->id)->first()) diff --git a/app/Models/ActivityProgressLog.php b/app/Models/ActivityProgressLog.php new file mode 100644 index 0000000..0746c92 --- /dev/null +++ b/app/Models/ActivityProgressLog.php @@ -0,0 +1,19 @@ + Date: Wed, 7 Dec 2022 16:12:25 +0700 Subject: [PATCH 067/131] move s curve calc to helper --- app/Helpers/MasterFunctionsHelper.php | 262 ++++++++++++++++- .../Controllers/DashboardBoDController.php | 153 +--------- app/Http/Controllers/ProjectController.php | 264 +----------------- 3 files changed, 273 insertions(+), 406 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 033c78c..d1f1ec6 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -2,10 +2,13 @@ namespace App\Helpers; +use App\Models\Activity; +use App\Models\Project; +use App\Models\VersionGantt; +use Illuminate\Support\Facades\DB; class MasterFunctionsHelper { - public static function curlReq($url, $token = ""){ if(!$token) $token = config('api.adw_token'); @@ -29,4 +32,261 @@ class MasterFunctionsHelper { return json_decode($output); } + public function getLatestGantt($id){ + $maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); + $data = array( + "last_gantt_id" => $maxGanttId, + "proyek_id" => $id + ); + return $data; + } + + // dipake di dashboard project & bod + public function getSCurve($request){ + $allGantt = []; + if(!is_int($request)){ + $dataPayload = $request->all(); + if(isset($dataPayload['gantt_id'])){ + $allGantt = $dataPayload['gantt_id']; + }else{ + $allGantt[] = MasterFunctionsHelper::getLatestGantt($dataPayload['project_id']); + } + } else { + $allGantt[] = MasterFunctionsHelper::getLatestGantt($request); + } + foreach($allGantt as $gantt){ + $gantt = VersionGantt::where('id', $gantt['last_gantt_id'])->first()->toArray(); + if($gantt['calculation_type'] == 'simple') { + // to do + } else { + return MasterFunctionsHelper::calculateProgressBasedOnReportMaterial($gantt); + } + } + } + + public function calculateProgressBasedOnReportMaterial($keyGantt) + { + DB::enableQueryLog(); + + $dataFinal=[]; + $dataPayload = []; + $dataPayload['period'] = 'week'; + + $dataProject = Project::find($keyGantt['proyek_id']); + $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->first(); + if(isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek){ + $dataPayload['end_date'] = $dataProject->akhir_proyek; + } + + if($dataHeader){ + $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); + }else{ + $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); + } + + if(!Activity::where("version_gantt_id", $keyGantt['id'])->first()) + return $dataFinal; + + $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['id']) + ->exists(); + + if(!$alreadyHasReport) + return $dataFinal; + + $minDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('start_date')->first(); + + $begin = new \DateTime($minDate.' Monday'); + if(isset($dataPayload['end_date'])){ + $maxDate = $dataPayload['end_date']; + $end = new \DateTime($maxDate); + /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged + $interval = new \DateInterval('P7D'); + } else { + $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['id']) + ->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's + $end = new \DateTime($maxDate. ' Friday'); + $interval = new \DateInterval('P7D'); + } + $period = new \DatePeriod($begin, $interval, $end); + + $arr_ActualM = []; + $tempDate = []; + $tempPercentagePlan = []; + $tempPercentagePlanWhr = []; + $tempPercentageReal = []; + $tempTtlPercentPlan=0; + $tempTtlPercentActual=0; + + $currentACWP = 0; + $currentBCWP = 0; + + foreach ($period as $dt) { + $minSevenDays = new \Datetime($dt->format("Y-m-d")); + $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); + $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['id']) + ->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d")) + ->whereDate('ama.plan_date', '>', $minSevenDays) + ->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['id']) + ->where('a.proyek_id', '=', $keyGantt['proyek_id']) + ->whereDate('ram.report_date', '<=',$dt->format("Y-m-d")) + ->whereDate('ram.report_date', '>',$minSevenDays) + ->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; + try { + $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; + } catch (\DivisionByZeroError $e) { + return response()->json(['message' => $e->getMessage()]); + } + $x++; + } + + $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; + try { + $dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; + $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; + $totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; + } catch (\DivisionByZeroError $e) { + return response()->json(['message' => $e->getMessage()]); + } + $dataTempReport [$w]['totalacwp'] = $totalACWP; + $w++; + } + + $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; + + if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= 100){ + if($tempTtlPercentActual >= 100) + $tempTtlPercentActual = 100; + if($tempTtlPercentPlan >= 100) + $tempTtlPercentPlan = 100; + } + + $currentACWP += $totalACWP; + $currentBCWP += $totalBCWP; + + $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); + $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); + $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; + $tempPercentageReal[] = round($tempTtlPercentActual, 2); + if($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100){ + break; + } + }else{ + $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); + $tempPercentagePlan[] = round($sumPercentagePlan, 2); + $tempPercentageReal[] = round($sumPercentageActual, 2); + } + $tempDate[] = array($dt->format("Y-m-d")); + } + + try { + if(round($totalACWP,0) > $totalRencanaBudget){ + $estimatedCost = round($totalACWP,0)+0; + }else{ + $estimatedCost = ($totalRencanaBudget+0); + } + } catch (\DivisionByZeroError $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"; + } + + $dataResponse = array( + "date" =>$tempDate, + "percentage" =>$tempPercentage, + "percentagePlan" => $tempPercentagePlan, + "percentageReal" => $tempPercentageReal, + "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, + "gantt"=>$keyGantt + ); + + return $dataFinal; + } + } diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 6c952ef..94931b6 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -2,15 +2,12 @@ namespace App\Http\Controllers; -use App\Models\Activity; -use App\Models\AssignMaterial; +use App\Helpers\MasterFunctionsHelper; use App\Models\Divisi; use App\Models\Project; use App\Models\ProjectPhase; -use App\Models\ReportActivityMaterial; use App\Models\User; use App\Models\UserToVersionGantt; -use App\Models\VersionGantt; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; @@ -129,7 +126,7 @@ class DashboardBoDController extends Controller $projects = Project::where('mulai_proyek', 'like', $year)->get(); foreach($projects as $project) { - $project->scurve = $this->getSCurve($project->id); + $project->scurve = MasterFunctionsHelper::getSCurve($project->id); try { if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) $return['warning'] += 1; @@ -156,7 +153,7 @@ class DashboardBoDController extends Controller $projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get(); foreach($projects as $project) { - $project->scurve = $this->getSCurve($project->id); + $project->scurve = MasterFunctionsHelper::getSCurve($project->id); if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) $warning++; elseif(@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) @@ -302,144 +299,6 @@ class DashboardBoDController extends Controller ], 200); } - private function getSCurve($project_id) - { - DB::enableQueryLog(); - - $dataPayload = [ - 'project_id' => $project_id, - 'period' => 'week', - ]; - $allGantt[] = $this->getLatestGantt($dataPayload['project_id']); - $dataResponse=[]; - - foreach ($allGantt as $keyGantt) { - $dataProject = Project::find($keyGantt['proyek_id']); - - $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); - - 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 = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); */ - $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->whereNull('parent_id')->pluck('start_date')->first(); - - $begin = new \DateTime($minDate.' Monday'); - $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"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's - $end = new \DateTime($maxDate. ' Friday'); - $interval = new \DateInterval('P7D'); - $period = new \DatePeriod($begin, $interval, $end); - - $tempTtlPercentPlan=0; - $tempTtlPercentActual=0; - $tempPercentagePlan = []; - $tempPercentageReal = []; - - foreach ($period as $dt) { - $minSevenDays = new \Datetime($dt->format("Y-m-d")); - $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); - $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")) - ->whereDate('ama.plan_date', '>', $minSevenDays) - ->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")) - ->whereDate('ram.report_date', '>',$minSevenDays) - ->get(); - $sumPercentagePlan=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(); - try { - $sumPercentagePlan+=($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning; - } catch (\DivisionByZeroError $e) { - return response()->json(['message' => $e->getMessage()]); - } - } - - $sumPercentageActual=0; - foreach ($dataActualM as $keyActualM) { - try { - $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(); - $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; - } catch (\Exception $e) { - return response()->json(['message' => $e->getMessage(), 'q' => $sumVolActual]); - } - } - - $tempTtlPercentPlan+= $sumPercentagePlan; - $tempTtlPercentActual+= $sumPercentageActual; - - if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= 100){ - if($tempTtlPercentActual >= 100) - $tempTtlPercentActual = 100; - if($tempTtlPercentPlan >= 100) - $tempTtlPercentPlan = 100; - } - - - $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); - $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); - $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; - $tempPercentageReal[] = round($tempTtlPercentActual, 2); - if($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100){ - break; - } - } - - $plannedPercentage = end($tempPercentagePlan); - $progressPercentage = end($tempPercentageReal); - $difference = $plannedPercentage - $progressPercentage; - - $dataResponse = array( - 'planned' => $plannedPercentage == false ? 0 : $plannedPercentage, - 'progress' => $progressPercentage == false ? 0 : $progressPercentage, - 'difference' => $difference, - ); - - - } - - return $dataResponse; - } - - 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 getDetailExpenditure($year = '%'){ $year = $this->interpolateYear($year); @@ -447,7 +306,7 @@ class DashboardBoDController extends Controller /* ->orWhere('akhir_proyek', 'like', $year) */ ->get(); foreach($projects as $project){ - $lastGantt = $this->getLatestGantt($project->id); + $lastGantt = MasterFunctionsHelper::getLatestGantt($project->id); if($project->kode_sortname != ""){ $resp = $this->getInvoiceIntegration($project->kode_sortname); @@ -459,9 +318,9 @@ class DashboardBoDController extends Controller $project->pm = User::find($project->pm_id); /* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */ - $project->scurve = $this->getSCurve($project->id); + $project->scurve = MasterFunctionsHelper::getSCurve($project->id); $project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count(); - $project->lastGanttId = $this->getLatestGantt($project->id); + $project->lastGanttId = MasterFunctionsHelper::getLatestGantt($project->id); } return response()->json([ diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index ec9923b..d0934e5 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -309,261 +309,6 @@ class ProjectController extends Controller ], 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 getSCurve(Request $request) - { - DB::enableQueryLog(); - $dataPayload = $request->all(); - - $allGantt = []; - - if(isset($dataPayload['gantt_id'])){ - $allGantt = $dataPayload['gantt_id']; - }else{ - $allGantt[] = $this->getLatestGantt($dataPayload['project_id']); - } - - $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(isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek){ - $dataPayload['end_date'] = $dataProject->akhir_proyek; - } - - 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"); - } - - 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"); */ - /* $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); */ - $minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->whereNull('parent_id')->pluck('start_date')->first(); - /* print_r($minDate); exit(); */ - - $begin = new \DateTime($minDate.' Monday'); - if(isset($dataPayload['end_date'])){ - $maxDate = $dataPayload['end_date']; - $end = new \DateTime($maxDate); - /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged - $interval = new \DateInterval('P7D'); - } else { - $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"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's - $end = new \DateTime($maxDate. ' Friday'); - $interval = new \DateInterval('P7D'); - } - $period = new \DatePeriod($begin, $interval, $end); - - $arr_ActualM = []; - $tempDate = []; - $tempPercentagePlan = []; - $tempPercentagePlanWhr = []; - $tempPercentageReal = []; - $tempTtlPercentPlan=0; - $tempTtlPercentActual=0; - - $currentACWP = 0; - $currentBCWP = 0; - - /* foreach($period as $x){ */ - /* echo $x->format("Y-m-d")."\n"; */ - /* } exit(); */ - - foreach ($period as $dt) { - $minSevenDays = new \Datetime($dt->format("Y-m-d")); - $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); - $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")) */ - ->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d")) - ->whereDate('ama.plan_date', '>', $minSevenDays) - ->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")) - ->whereDate('ram.report_date', '>',$minSevenDays) - ->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; - try { - $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; - } catch (\DivisionByZeroError $e) { - return response()->json(['message' => $e->getMessage()]); - } - $x++; - } - - $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; - try { - $dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; - $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; - $totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; - } catch (\DivisionByZeroError $e) { - return response()->json(['message' => $e->getMessage()]); - } - $dataTempReport [$w]['totalacwp'] = $totalACWP; - $w++; - } - - $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; - - if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= 100){ - if($tempTtlPercentActual >= 100) - $tempTtlPercentActual = 100; - if($tempTtlPercentPlan >= 100) - $tempTtlPercentPlan = 100; - } - - $currentACWP += $totalACWP; - $currentBCWP += $totalBCWP; - - $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); - $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); - $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; - $tempPercentageReal[] = round($tempTtlPercentActual, 2); - if($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100){ - break; - } - }else{ - $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); - $tempPercentagePlan[] = round($sumPercentagePlan, 2); - $tempPercentageReal[] = round($sumPercentageActual, 2); - } - $tempDate[] = array($dt->format("Y-m-d")); - } - /* print_r($tempDate); exit(); */ - - try { - if(round($totalACWP,0) > $totalRencanaBudget){ - $estimatedCost = round($totalACWP,0)+0; - }else{ - $estimatedCost = ($totalRencanaBudget+0); - } - } catch (\DivisionByZeroError $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"; - } - - $dataResponse = array( - "date" =>$tempDate, - "percentage" =>$tempPercentage, - "percentagePlan" => $tempPercentagePlan, - "percentageReal" => $tempPercentageReal, - "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); - } - public function detail($id){ if(empty($id) || !is_int((int)$id)) return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); @@ -573,7 +318,7 @@ class ProjectController extends Controller if(!$result) return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); - $gantt = $this->getLatestGantt($id); + $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); @@ -663,8 +408,6 @@ class ProjectController extends Controller $response = MasterFunctionsHelper::curlReq($url); - if($response->data->project_no == "") - return response()->json(['status'=>'error', 'message' => 'Project '.$search.' not found!', 'code'=>404], 404); return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); } @@ -689,5 +432,10 @@ class ProjectController extends Controller return response()->json(['status'=>'success', 'code'=> 200, 'data'=> $reports], 200); } + + public function getSCurve(Request $request){ + $data = MasterFunctionsHelper::getSCurve($request); + return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); + } } From 0f3b54f38d68c905ec123c1cf85bdfc88d01f610 Mon Sep 17 00:00:00 2001 From: bnu Date: Fri, 9 Dec 2022 17:19:43 +0700 Subject: [PATCH 068/131] update curva versi simple --- app/Helpers/MasterFunctionsHelper.php | 227 ++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index d1f1ec6..a5092cf 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -58,6 +58,7 @@ class MasterFunctionsHelper { $gantt = VersionGantt::where('id', $gantt['last_gantt_id'])->first()->toArray(); if($gantt['calculation_type'] == 'simple') { // to do + return MasterFunctionsHelper::calculateProgressBasedOnSimple($gantt); } else { return MasterFunctionsHelper::calculateProgressBasedOnReportMaterial($gantt); } @@ -289,4 +290,230 @@ class MasterFunctionsHelper { return $dataFinal; } + public function calculateProgressBasedOnSimple($keyGantt){ + DB::enableQueryLog(); + + $dataFinal=[]; + $dataPayload = []; + $dataPayload['period'] = 'week'; + + $dataProject = Project::find($keyGantt['proyek_id']); + $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->first(); + if(isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek){ + $dataPayload['end_date'] = $dataProject->akhir_proyek; + } + + if($dataHeader){ + $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); + }else{ + $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); + } + + if(!Activity::where("version_gantt_id", $keyGantt['id'])->first()) + return $dataFinal; + + // $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['id']) + // ->exists(); + + // if(!$alreadyHasReport) + // return $dataFinal; + + $minDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('start_date')->first(); + + $begin = new \DateTime($minDate.' Monday'); + if(isset($dataPayload['end_date'])){ + $maxDate = $dataPayload['end_date']; + $end = new \DateTime($maxDate); + /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged + $interval = new \DateInterval('P7D'); + } else { + // $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['id']) + // ->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's + $maxDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('end_date')->first(); + $end = new \DateTime($maxDate. ' Friday'); + $interval = new \DateInterval('P7D'); + } + $period = new \DatePeriod($begin, $interval, $end); + + $arr_ActualM = []; + $tempDate = []; + $tempPercentagePlan = []; + $tempPercentagePlanWhr = []; + $tempPercentageReal = []; + $tempTtlPercentPlan=0; + $tempTtlPercentActual=0; + + $currentACWP = 0; + $currentBCWP = 0; + + foreach ($period as $dt) { + $minSevenDays = new \Datetime($dt->format("Y-m-d")); + $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); + + $dataPlanM = DB::table('m_activity') + ->select('id as activity_id', 'bobot_planning', 'start_date', 'biaya_actual', 'duration', 'persentase_progress') + // ->join('m_activity as a', 'a.id', '=', 'activity_id') + ->where('proyek_id', '=', $keyGantt['proyek_id']) + ->where('type_activity', '=', 'task') + ->where('version_gantt_id', '=', $keyGantt['id']) + ->whereDate('start_date', '<=',$dt->format("Y-m-d")) + ->whereDate('start_date', '>', $minSevenDays) + ->get(); + + $dataActualM = DB::table('m_activity as a') + ->select('mapl.id as id_progress_log', 'mapl.activity_id', 'mapl.variance', 'mapl.created_at', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') + ->join('m_activity_progress_log as mapl', 'a.id', '=', 'mapl.activity_id') + ->where('a.version_gantt_id', '=', $keyGantt['id']) + ->where('a.type_activity', '=', 'task') + ->where('mapl.variance', '>', 0) + ->where('a.proyek_id', '=', $keyGantt['proyek_id']) + ->whereDate('mapl.created_at', '<=',$dt->format("Y-m-d")) + ->whereDate('mapl.created_at', '>',$minSevenDays) + ->get(); + $dataTempPlan = []; + $x = 0; + $sumPercentagePlan=0; + $totalACWP = isset($totalACWP) ? $totalACWP : 0; + $totalBCWP = isset($totalBCWP) ? $totalBCWP : 0; + + foreach ($dataPlanM as $keyPlanM) { + + $dataTempPlan [$x]['activity_id'] = $keyPlanM->activity_id; + $dataTempPlan [$x]['qty_plan'] = $keyPlanM->bobot_planning; + $dataTempPlan [$x]['plan_date'] = $keyPlanM->start_date; + $dataTempPlan [$x]['start_activity'] = $keyPlanM->start_date; + $dataTempPlan [$x]['bobot_planning'] = $keyPlanM->bobot_planning; + $dataTempPlan [$x]['ttl_plan'] = $keyPlanM->bobot_planning; + $dataTempPlan [$x]['biaya_actual'] = $keyPlanM->biaya_actual; + $dataTempPlan [$x]['duration'] = $keyPlanM->duration; + $dataTempPlan [$x]['persentase_progress'] = $keyPlanM->persentase_progress; + try { + $dataTempPlan [$x]['percentage'] = $keyPlanM->bobot_planning; + $sumPercentagePlan+=$keyPlanM->bobot_planning; + $totalBCWP += 0; + $dataTempPlan [$x]['totalBCWP'] = $totalBCWP; + } catch (\DivisionByZeroError $e) { + return response()->json(['message' => $e->getMessage()]); + } + $x++; + } + + $w = 0; + $dataTempReport = []; + $sumPercentageActual=0; + foreach ($dataActualM as $keyActualM) { + $sumVolActual = DB::table('m_activity_progress_log') + ->select('id', DB::raw('SUM(variance) as ttl_percen_act')) + ->where('id', '=', $keyActualM->id_progress_log) + ->groupBy('id') + ->first(); + $dataTempReport [$w]['id_progress_log'] = $keyActualM->id_progress_log; + // $dataTempReport [$w]['qty'] = $keyActualM->qty; + $dataTempReport [$w]['report_date'] = $keyActualM->created_at; + $dataTempReport [$w]['bobot_planning'] = $keyActualM->bobot_planning; + // $dataTempReport [$w]['ttl_plan'] = $sumVolActual->ttl_percen_act ? $sumVolActual->ttl_percen_act : 0; + $dataTempReport [$w]['biaya_actual'] = $keyActualM->biaya_actual; + $dataTempReport [$w]['duration'] = $keyActualM->duration; + $dataTempReport [$w]['persentase_progress'] = $keyActualM->persentase_progress; + try { + $dataTempReport [$w]['percentage'] = $sumVolActual->ttl_percen_act ? ($sumVolActual->ttl_percen_act/100)*$keyActualM->bobot_planning : 0; + $sumPercentageActual+=$sumVolActual->ttl_percen_act ? ($sumVolActual->ttl_percen_act/100)*$keyActualM->bobot_planning : 0; + $totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; + } catch (\DivisionByZeroError $e) { + return response()->json(['message' => $e->getMessage()]); + } + $dataTempReport [$w]['totalacwp'] = $totalACWP; + $w++; + } + + $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; + + if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= 100){ + if($tempTtlPercentActual >= 100) + $tempTtlPercentActual = 100; + if($tempTtlPercentPlan >= 100) + $tempTtlPercentPlan = 100; + } + + $currentACWP += $totalACWP; + $currentBCWP += $totalBCWP; + + $tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); + $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); + $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; + $tempPercentageReal[] = round($tempTtlPercentActual, 2); + if($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100){ + break; + } + }else{ + $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); + $tempPercentagePlan[] = round($sumPercentagePlan, 2); + $tempPercentageReal[] = round($sumPercentageActual, 2); + } + $tempDate[] = array($dt->format("Y-m-d")); + } + + try { + if(round($totalACWP,0) > $totalRencanaBudget){ + $estimatedCost = round($totalACWP,0)+0; + }else{ + $estimatedCost = ($totalRencanaBudget+0); + } + } catch (\DivisionByZeroError $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"; + } + + $dataResponse = array( + "date" =>$tempDate, + "percentage" =>$tempPercentage, + "percentagePlan" => $tempPercentagePlan, + "percentageReal" => $tempPercentageReal, + "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, + "gantt"=>$keyGantt, + ); + + return $dataFinal; + } + } From b578daebab54f13bfc80971420a4eed004c77874 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 12:05:10 +0700 Subject: [PATCH 069/131] bugfix sum up --- app/Models/Activity.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index ff6d559..3bb06fb 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -18,6 +18,7 @@ class Activity extends Model const CREATED_AT = 'created_at'; const UPDATED_AT = 'updated_at'; + // persentase bobot gak kepake yg dipakenya bobot_planning protected $fillable = [ 'proyek_id', 'parent_id', 'kode_sortname', 'name', 'rencana_biaya', 'start_date', 'end_date', 'area_kerja', 'biaya_actual', 'persentase_bobot', 'persentase_progress', @@ -58,7 +59,7 @@ class Activity extends Model static::updated(function($data) { $data->updateBobot(); $data->updateCostPlanning(); - if($data->persentase_bobot){ + if($data->bobot_planning){ $data->updatePersentaseProgress(); $data->updateCostActual(); } @@ -70,7 +71,7 @@ class Activity extends Model $data->updateBobot(true); $data->updateCostPlanning(); - if($data->persentase_bobot){ + if($data->bobot_planning){ $data->updatePersentaseProgress(); $data->updateCostActual(); } @@ -119,6 +120,7 @@ class Activity extends Model private function updatePersentaseProgress() { + print_r(2); if($parent = Activity::find($this->parent_id)){ $parentActWeight = $parent->bobot_planning; @@ -129,9 +131,11 @@ class Activity extends Model $currentActProportionalProgress = ($currentActWeight / $parentActWeight) * $child->persentase_progress; $totalChildProportionalProgress += $currentActProportionalProgress; } - $parent->update([ + print_r($totalChildProportionalProgress); + $x = $parent->update([ "persentase_progress" => $totalChildProportionalProgress ]); + print_r($x); } } From dcb365cee16c153458bb91c8ed6c918693128548 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 12:16:21 +0700 Subject: [PATCH 070/131] bugfix sum up --- app/Models/Activity.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 3bb06fb..49bcc1e 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -120,7 +120,6 @@ class Activity extends Model private function updatePersentaseProgress() { - print_r(2); if($parent = Activity::find($this->parent_id)){ $parentActWeight = $parent->bobot_planning; @@ -131,11 +130,9 @@ class Activity extends Model $currentActProportionalProgress = ($currentActWeight / $parentActWeight) * $child->persentase_progress; $totalChildProportionalProgress += $currentActProportionalProgress; } - print_r($totalChildProportionalProgress); - $x = $parent->update([ + $parent->update([ "persentase_progress" => $totalChildProportionalProgress ]); - print_r($x); } } From bb8542c1aafe46d51cc836031701d882eb59db76 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 14:34:53 +0700 Subject: [PATCH 071/131] update header if start / end date changed / an activity deleted --- app/Models/Activity.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 49bcc1e..7e06d88 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -63,6 +63,9 @@ class Activity extends Model $data->updatePersentaseProgress(); $data->updateCostActual(); } + if($this->start_date != request()->start_date || $this->end_date != request()->end_date) { + $data->updateStartEndDateHeader(); + } }); static::deleted(function($data) { @@ -75,6 +78,9 @@ class Activity extends Model $data->updatePersentaseProgress(); $data->updateCostActual(); } + if($this->start_date != request()->start_date || $this->end_date != request()->end_date) { + $data->updateStartEndDateHeader(); + } }); } @@ -160,6 +166,18 @@ class Activity extends Model ]); } + private function updateStartEndDateHeader() + { + $earliestStartDate = Activity::where('version_gantt_id', $this->version_gantt_id)->oldest('start_date')->pluck('start_date')->first(); + $latestEndDate = Activity::where('version_gantt_id', $this->version_gantt_id)->latest('end_date')->pluck('end_date')->first(); + if($header = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNull('parent_id')->first()) { + $header->update([ + "start_date" => $earliestStartDate, + "end_date" => $latestEndDate + ]); + } + } + public function getJobsDoneAttribute() { if(!ReportActivityMaterial::where('activity_id', $this->id)->first()) From f58551b6929b25c4b803a909da1513c3da77c18e Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 14:35:30 +0700 Subject: [PATCH 072/131] update header if start / end date changed / an activity deleted --- app/Models/Activity.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 7e06d88..a673524 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -78,9 +78,7 @@ class Activity extends Model $data->updatePersentaseProgress(); $data->updateCostActual(); } - if($this->start_date != request()->start_date || $this->end_date != request()->end_date) { - $data->updateStartEndDateHeader(); - } + $data->updateStartEndDateHeader(); }); } From fd0bc81d88058dc0a6c6cb22cb10f5cc23d7380e Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 15:02:53 +0700 Subject: [PATCH 073/131] update header if start / end date changed / an activity deleted --- app/Models/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index a673524..60cb164 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -63,7 +63,7 @@ class Activity extends Model $data->updatePersentaseProgress(); $data->updateCostActual(); } - if($this->start_date != request()->start_date || $this->end_date != request()->end_date) { + if($data->start_date != request()->start_date || $data->end_date != request()->end_date) { $data->updateStartEndDateHeader(); } }); From 69ea8e83e31299e4edb09ece869889dc58046d9d Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 15:18:59 +0700 Subject: [PATCH 074/131] update header if start / end date changed / an activity deleted --- app/Models/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 60cb164..0d55312 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -166,8 +166,8 @@ class Activity extends Model private function updateStartEndDateHeader() { - $earliestStartDate = Activity::where('version_gantt_id', $this->version_gantt_id)->oldest('start_date')->pluck('start_date')->first(); - $latestEndDate = Activity::where('version_gantt_id', $this->version_gantt_id)->latest('end_date')->pluck('end_date')->first(); + $earliestStartDate = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNotNull('parent_id')->oldest('start_date')->pluck('start_date')->first(); + $latestEndDate = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNotNull('parent_id')->latest('end_date')->pluck('end_date')->first(); if($header = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNull('parent_id')->first()) { $header->update([ "start_date" => $earliestStartDate, From 459a0adc0ca4a4d3673675ef0ba6d34197bbba6a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 15:31:36 +0700 Subject: [PATCH 075/131] update header if start / end date changed / an activity deleted --- app/Models/Activity.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 0d55312..9be182c 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -169,10 +169,9 @@ class Activity extends Model $earliestStartDate = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNotNull('parent_id')->oldest('start_date')->pluck('start_date')->first(); $latestEndDate = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNotNull('parent_id')->latest('end_date')->pluck('end_date')->first(); if($header = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNull('parent_id')->first()) { - $header->update([ - "start_date" => $earliestStartDate, - "end_date" => $latestEndDate - ]); + $header->start_date = $earliestStartDate; + $header->end_date = $latestEndDate; + $header->saveQuietly(); } } From c8b1c603c78c103d4aa2e3cfaa040382efafde0f Mon Sep 17 00:00:00 2001 From: ardhi Date: Fri, 3 Feb 2023 15:07:29 +0700 Subject: [PATCH 076/131] add property material_id di fungsi datatablesForReportActivity AssignMaterialController dan report_id di fungsi add ReportActivityMaterialController --- app/Http/Controllers/AssignMaterialController.php | 1 + app/Http/Controllers/ReportActivityMaterialController.php | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index 583d2cd..d037750 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -130,6 +130,7 @@ class AssignMaterialController extends Controller "m.description as material_name", "assign_material_to_activity.activity_id", "assign_material_to_activity.type", + "assign_material_to_activity.material_id" ) ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->groupBy("m.description") diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index 57ecfe3..5588235 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -29,10 +29,12 @@ class ReportActivityMaterialController extends Controller $data['assign_material_id'] = $request->assign_material_id; $data['qty'] = $this->sanitizeDecimal($data['qty']); - if(!ReportActivityMaterial::create($data)) - return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400]); + $created = ReportActivityMaterial::create($data); - return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200]); + if(!$created) + return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null]); + + return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]); } public function updateStatusStartFinish(Request $request){ From ba46cdc1e58ce43beaabd10fb02d93f995065cae Mon Sep 17 00:00:00 2001 From: ardhi Date: Fri, 3 Feb 2023 16:16:40 +0700 Subject: [PATCH 077/131] try fix --- app/Http/Controllers/AssignMaterialController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index d037750..f843bd9 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -130,7 +130,7 @@ class AssignMaterialController extends Controller "m.description as material_name", "assign_material_to_activity.activity_id", "assign_material_to_activity.type", - "assign_material_to_activity.material_id" + "assign_material_to_activity.material_id", ) ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->groupBy("m.description") From 83e04e358327dd7b17b85435355ec8668814f6fc Mon Sep 17 00:00:00 2001 From: ibnu Date: Fri, 3 Feb 2023 17:50:12 +0700 Subject: [PATCH 078/131] add material_id in reportactivitymaterial --- app/Http/Controllers/AssignMaterialController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index f843bd9..0f857d6 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -129,8 +129,8 @@ class AssignMaterialController extends Controller AssignMaterial::raw('SUM(qty_planning) as qty_planning'), "m.description as material_name", "assign_material_to_activity.activity_id", - "assign_material_to_activity.type", - "assign_material_to_activity.material_id", + "assign_material_to_activity.type" + // "assign_material_to_activity.material_id", ) ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->groupBy("m.description") @@ -174,6 +174,11 @@ class AssignMaterialController extends Controller ->where('description', '=', $row->material_name)->first(); return $val_uom ? $val_uom->uom : null; }) + ->addColumn('material_id', function($row){ + $material_id =AssignMaterial::select('assign_material_to_activity.material_id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") + ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); + return $material_id ? $material_id->material_id : null; + }) ->addColumn('action', function($row){ $dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); From a04142b44cdea68fd400d283304ddde12368ec81 Mon Sep 17 00:00:00 2001 From: ardhi Date: Mon, 6 Feb 2023 13:11:48 +0700 Subject: [PATCH 079/131] add button Lihat Foto Report --- app/Http/Controllers/ReportActivityMaterialController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index 5588235..a661e80 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -107,7 +107,8 @@ class ReportActivityMaterialController extends Controller return Datatables::of($data) ->addIndexColumn() ->addColumn('action', function($row){ - $actionBtn = ''; + $actionBtn = ''; + $actionBtn .= ''; return $actionBtn; }) ->rawColumns(['action'])->make(true); From 0f1bc0f32f3f148c2b6bb8797755556eb005ba62 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 7 Feb 2023 09:59:03 +0700 Subject: [PATCH 080/131] update presence boundary --- app/Http/Controllers/PresenceController.php | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 3feced9..192abea 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Log; use Illuminate\Http\Request; use App\Models\Presence; +use App\Models\Activity; use GuzzleHttp\Client; use Illuminate\Support\Facades\Http; use Carbon\Carbon; @@ -14,6 +15,10 @@ class PresenceController extends Controller { public function add(Request $request) { + + // + // $test = $this->checkLocation($request); + // return response()->json(['status'=>$test,'code'=>200], 200); $this->validate($request, [ 'user_id' => 'required' ]); @@ -58,12 +63,32 @@ class PresenceController extends Controller $result = Presence::create($dataAdd); + $data=array( + 'id' => $result->id, + 'boundary' => true + ); + if($result){ - return response()->json(['status'=>'success', 'id'=>$result->id,'message'=>'clock in successfully!','code'=>200], 200); + return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); }else{ return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); } } + private function checkLocation($params){ + // cek user tersebut apakah punya assign task yang ada bondary nya + // geom ada di table activity + $geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id") + ->join("m_activity as ma", "ma.id", "=", "ahta.activity_id") + ->where("ahta.user_id", $params->user_id) + ->whereDate("ma.start_date", "<=", $params->clock_time) + ->whereDate("ma.end_date", ">=", $params->clock_time) + ->where(DB::raw("ST_Intersects(ST_GeomFromGeoJSON('ma.geom'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326))")) + ->get(); + // Activity::select('geom')->where(''); + // gejson to geom + // intersect dengan point req + return $geom; + } public function edit($id){ if(!$id || (int) $id < 0 || $id==""){ From 82069a335478c4f6404c70e3943b1e6a9fa94807 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 7 Feb 2023 10:10:48 +0700 Subject: [PATCH 081/131] add assign_material_id in API reportActivity --- app/Http/Controllers/AssignMaterialController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index 0f857d6..16f848a 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -174,10 +174,10 @@ class AssignMaterialController extends Controller ->where('description', '=', $row->material_name)->first(); return $val_uom ? $val_uom->uom : null; }) - ->addColumn('material_id', function($row){ - $material_id =AssignMaterial::select('assign_material_to_activity.material_id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") + ->addColumn('assign_material_id', function($row){ + $assignMaterial =AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); - return $material_id ? $material_id->material_id : null; + return $assignMaterial ? $assignMaterial->id : null; }) ->addColumn('action', function($row){ $dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") From 88ed027670d1395e653f48d3bce294dec904f3d6 Mon Sep 17 00:00:00 2001 From: ardhi Date: Wed, 8 Feb 2023 09:32:58 +0700 Subject: [PATCH 082/131] add waypoint/add-bulk function to send phone gps data --- app/Http/Controllers/WaypointController.php | 26 ++++++ rest-client.http | 89 +++++++++++++++++++-- routes/web.php | 1 + 3 files changed, 111 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/WaypointController.php b/app/Http/Controllers/WaypointController.php index f2d47ce..6702ca8 100644 --- a/app/Http/Controllers/WaypointController.php +++ b/app/Http/Controllers/WaypointController.php @@ -28,6 +28,32 @@ class WaypointController extends Controller } } + public function addBulk(Request $request) + { + $data = $request->all(); + $now = date("Y-m-d H:i:s"); + $data_send = array(); + + if (isset($data['wp_records']) && count($data['wp_records']) > 0) { + foreach($data['wp_records'] as $userLoc) { + $userLoc['created_at'] = $now; + $userLoc['created_by'] = $this->currentName; + $userLoc['updated_at'] = $now; + $userLoc['updated_by'] = $this->currentName; + $data_send[] = $userLoc; + } + $result = Waypoint::insert($data_send); + if($result){ + return response()->json(['status'=>'success','message'=>'add waypoint successfully!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'add waypoint failed!','code'=>400], 400); + } + } + else { + return response()->json(['status'=>'failed','message'=>'add waypoint failed!','code'=>400], 400); + } + } + public function edit($id){ if(!$id || (int) $id < 0 || $id==""){ return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); diff --git a/rest-client.http b/rest-client.http index 6417009..aeda668 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,12 +1,14 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLXN0YWdpbmctYWR3Lm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjU5NDc0MDY3LCJleHAiOjE2NjAwNzg4NjcsIm5iZiI6MTY1OTQ3NDA2NywianRpIjoia0ljaHBFOEpiaFI0TjN3UyIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.PxGL0NcRtxzhG2J21Ca-zgMbr1anY7vhNzEOpZHSNOk +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzU3NjY2NzcsImV4cCI6MTY3NjM3MTQ3NywibmJmIjoxNjc1NzY2Njc3LCJqdGkiOiJwODNpWG1kU3pTV2ZVMGs3Iiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.I9Q6uI-IOHR8JKaMJfjfAizOM8KNPQsm8EyWM8f6Qbk # @hostname = https://kit-api.ospro.id/api +# @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api -@hostname = http://localhost:8099/api +# @hostname = http://localhost:8099/api # @hostname = http://103.73.125.81:8444/api +@hostname = http://localhost:8074/adw-backend/api ###### login POST {{hostname}}/login @@ -15,8 +17,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "admin", - "password": "admin123" + "username": "demo", + "password": "demo123" } ###### Tools Req @@ -809,4 +811,81 @@ content-type: application/json "clock_time": "2022-04-25T16:40:17+07:00", "type": "out", "user_id": 262 -} \ No newline at end of file +} + +###### + +POST {{hostname}}/waypoint/add +Authorization: Bearer {{token}} +content-type: application/json +{ + "user_id": 1247, + "lat": -6.2622811, + "lng": 106.7881746, + "wptime": "2023-02-07T10:40:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0 +} + +###### + +POST {{hostname}}/waypoint/add-bulk +Authorization: Bearer {{token}} +content-type: application/json + +{ + "wp_records": [ + { + "user_id": 1247, + "lon": 106.88702067952579, + "lat": -6.193331793510694, + "wptime": "2023-02-07T10:40:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:40:17+07:00" + }, + { + "user_id": 1247, + "lon": 106.88731982052337, + "lat": -6.1933255977790225, + "wptime": "2023-02-07T10:41:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:41:17+07:00" + }, + { + "user_id": 1247, + "lon": 106.88765896352822, + "lat": -6.193328086924183, + "wptime": "2023-02-07T10:42:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:42:17+07:00" + }, + { + "user_id": 1247, + "lon": 106.88812637133634, + "lat": -6.1933373805197505, + "wptime": "2023-02-07T10:43:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:43:17+07:00" + }, + { + "user_id": 1247, + "lon": 106.88867721532353, + "lat": -6.1933448515770095, + "wptime": "2023-02-07T10:44:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:44:17+07:00" + } + ] +} + diff --git a/routes/web.php b/routes/web.php index f07588b..46b30a2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -322,6 +322,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); From 4d381a9e8ddec8d45ae0acb710720baf1942a55f Mon Sep 17 00:00:00 2001 From: farhan048 Date: Wed, 8 Feb 2023 15:09:01 +0700 Subject: [PATCH 083/131] add Logic check password, and username --- app/Http/Controllers/AuthController.php | 107 ++++++++++++++---------- 1 file changed, 63 insertions(+), 44 deletions(-) diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 67ad016..d898cf9 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -8,7 +8,9 @@ use Illuminate\Support\Facades\Hash; use App\Models\User; use App\Models\Role; - +use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Password; +use Illuminate\Validation\ValidationException; class AuthController extends Controller { public function __construct() @@ -26,48 +28,65 @@ class AuthController extends Controller if(empty($username) || empty($password)) return response()->json(['status'=>'error','message'=>'You must fill all the fields'], 400); - $user = User::where('username', $username)->where('password', md5($password))->first(); - - if($is_mobile){ - $fcm_token = $request->fcm_token; - - if(!$fcm_token || $fcm_token=="") - return response()->json(['status'=>'error','message'=>'FCM Token is required'], 400); - - $dataUpdateFcm = array( - "fcm_token"=>$fcm_token - ); - - $hr = User::find($user->id); - - if($hr) - $hr->update($dataUpdateFcm); - } - - $dataRole = Role::find($user->role_id); - - if($dataRole) - $user->role = $dataRole; - - if (! $token =Auth::login($user)) - return response()->json(['error' => 'Unauthorized'], 401); - - $ttl = 60; - if($remember) - $ttl = 10080; - - // todo : change existing md5 hashed function to laravel's originally bcrypt - /* $token = auth()->setTTL($ttl)->attempt(['username' => $username, 'password' => Hash::make($password)]); */ - /* dd(response()->json(['code'=>'200', 'token' => $token, 'ttl' => $ttl])); */ - - return response()->json([ - 'code' => 200, - 'data' => array( - 'data_user' => $user, - 'access_token' => $token, - 'token_type' => 'bearer', - 'expires_in' => auth()->factory()->getTTL() * $ttl, - ), - ]); + $usernameCheck = false; + $passwordCheck = false; + + if (User::where('username', $username)->exist()) + $usernameCheck = true; + + if (User::where('password', md5($password))->exists()) + $passwordCheck = true; + + if ($usernameCheck & $passwordCheck){ + $user = User::where('username', $username)->where('password', md5($password))->first(); + if($is_mobile){ + $fcm_token = $request->fcm_token; + + if(!$fcm_token || $fcm_token=="") + return response()->json(['status'=>'error','message'=>'FCM Token is required'], 400); + + $dataUpdateFcm = array( + "fcm_token"=>$fcm_token + ); + + $hr = User::find($user->id); + + if($hr) + $hr->update($dataUpdateFcm); + } + + $dataRole = Role::find($user->role_id); + + if($dataRole) + $user->role = $dataRole; + + if (! $token =Auth::login($user)) + return response()->json(['error' => 'Unauthorized'], 401); + + $ttl = 60; + if($remember) + $ttl = 10080; + + // todo : change existing md5 hashed function to laravel's originally bcrypt + /* $token = auth()->setTTL($ttl)->attempt(['username' => $username, 'password' => Hash::make($password)]); */ + /* dd(response()->json(['code'=>'200', 'token' => $token, 'ttl' => $ttl])); */ + + return response()->json([ + 'code' => 200, + 'data' => array( + 'data_user' => $user, + 'access_token' => $token, + 'token_type' => 'bearer', + 'expires_in' => auth()->factory()->getTTL() * $ttl, + ), + ]); + }else { + if (!$usernameCheck && !$passwordCheck) + return response()->json(['code' => 201, 'message' => "username and password doesn't match"], 201); + if (!$passwordCheck) + return response()->json(['code' => 201, 'message' => "password doesn't match"], 201); + if (!$usernameCheck) + return response()->json(['code' => 201, 'message' => "username doesn't match"], 201); + } } } From 25b2386708f1ede5a3cfa63363635f503e4b1b5f Mon Sep 17 00:00:00 2001 From: ardhi Date: Wed, 8 Feb 2023 15:54:03 +0700 Subject: [PATCH 084/131] add button --- app/Http/Controllers/ReportActivityMaterialController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index a661e80..a4a120b 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -124,7 +124,8 @@ class ReportActivityMaterialController extends Controller return Datatables::of($data) ->addIndexColumn() ->addColumn('action', function($row){ - $actionBtn = ''; + $actionBtn = ''; + $actionBtn .= ''; return $actionBtn; }) ->rawColumns(['action'])->make(true); From 19049cb71fd41aa3e24f65eb861de2ce7e39c34c Mon Sep 17 00:00:00 2001 From: ibnu Date: Wed, 8 Feb 2023 17:13:03 +0700 Subject: [PATCH 085/131] done cico with check geotagging --- app/Http/Controllers/PresenceController.php | 89 ++++++++++++++++----- app/Models/Presence.php | 3 +- 2 files changed, 70 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 192abea..a2664b4 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -15,14 +15,17 @@ class PresenceController extends Controller { public function add(Request $request) { - - // - // $test = $this->checkLocation($request); - // return response()->json(['status'=>$test,'code'=>200], 200); $this->validate($request, [ 'user_id' => 'required' ]); - + + $checkLocation = $this->checkLocation($request); + $statusBoundary = false; + $date = date_create($request->clock_time); + // $ActivityId = null; + if(count($checkLocation) > 0){ + $statusBoundary = true; + } if($request->type=="out"){ @@ -32,12 +35,31 @@ class PresenceController extends Controller "clock_out_lat" => $request->clock_out_lat, "clock_out_lng" => $request->clock_out_lng, "updated_by"=>$this->currentName, - "clock_out_loc" => $clock_out_loc + "clock_out_loc" => $clock_out_loc, + "clock_out_boundary" => $statusBoundary ); $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); if($resultUpdate && $resultUpdate > 0){ - return response()->json(['status'=>'success', 'id'=>$resultUpdate,'message'=>'clock out success!','code'=>200], 200); + if($statusBoundary){ + for ($i=0; $i < count($checkLocation); $i++) { + # code... + DB::table('clock_in_out_boundary')->insert([ + "clock_in_out_id" => $resultUpdate, + "user_id" => $request->user_id, + "activity_id" => $checkLocation[$i]['activity_id'], + "type" => $request->type, + "created_at" => $date, + "created_by" => $this->currentName + ]); + }; + }; + $data=array( + 'id' => $resultUpdate, + 'boundary' => $statusBoundary + ); + + return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); } else{ return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); @@ -45,35 +67,46 @@ class PresenceController extends Controller die(); } - $date = date_create($request->clock_time); $onlyDate = date_format($date,"Y-m-d"); - $clock_in_loc = "-"; $dataAdd = array( 'user_id'=> $request->user_id, 'clock_in'=> $request->clock_time, 'date_presence'=> $onlyDate, - 'created_by' =>$this->currentName, + 'created_by' => $this->currentName, 'clock_in_lat' => $request->clock_in_lat, 'clock_in_lng' => $request->clock_in_lng, - 'clock_in_loc' => $clock_in_loc + 'clock_in_loc' => $clock_in_loc, + 'clock_in_boundary' => $statusBoundary ); $result = Presence::create($dataAdd); - $data=array( 'id' => $result->id, - 'boundary' => true + 'boundary' => $statusBoundary ); - - if($result){ + if($result){ + if($statusBoundary){ + for ($i=0; $i < count($checkLocation); $i++) { + # code... + DB::table('clock_in_out_boundary')->insert([ + "clock_in_out_id" => $result->id, + "user_id" => $request->user_id, + "activity_id" => $checkLocation[$i]['activity_id'], + "type" => $request->type, + "created_at" => $date, + "created_by" => $this->currentName + ]); + }; + }; return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); }else{ return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); } } + private function checkLocation($params){ // cek user tersebut apakah punya assign task yang ada bondary nya // geom ada di table activity @@ -82,12 +115,27 @@ class PresenceController extends Controller ->where("ahta.user_id", $params->user_id) ->whereDate("ma.start_date", "<=", $params->clock_time) ->whereDate("ma.end_date", ">=", $params->clock_time) - ->where(DB::raw("ST_Intersects(ST_GeomFromGeoJSON('ma.geom'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326))")) ->get(); - // Activity::select('geom')->where(''); - // gejson to geom - // intersect dengan point req - return $geom; + $temp = []; + foreach($geom as $dataGeom){ + $valGeom = json_decode($dataGeom->geom); + if($params->type=="out"){ + $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326)) as boundary")); + }else{ + $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary")); + } + foreach ($check as $key) { + if($key->boundary){ + $temp[]=array( + "activity_id" => $dataGeom->id, + "boundary" => $key->boundary + ); + } + } + + + } + return $temp; } public function edit($id){ @@ -151,7 +199,6 @@ class PresenceController extends Controller } private function updateFormAdd($data, $id){ - $date = date_create($data['clock_out']); $onlyDate = date_format($date,"Y-m-d"); diff --git a/app/Models/Presence.php b/app/Models/Presence.php index e5276cc..620a91e 100644 --- a/app/Models/Presence.php +++ b/app/Models/Presence.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\DB; class Presence extends Model { @@ -14,7 +15,7 @@ class Presence extends Model protected $fillable = [ 'user_id', 'clock_in', 'clock_out', 'date_presence', 'clock_in_lat', 'clock_in_lng', 'clock_out_lat', 'clock_out_lng', - 'clock_in_loc', 'clock_out_loc', + 'clock_in_loc', 'clock_out_loc','clock_in_boundary', 'clock_out_boundary', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; } From f060db4539bb8e6bb603e895f665c519f2a8311a Mon Sep 17 00:00:00 2001 From: ibnu Date: Wed, 8 Feb 2023 17:13:45 +0700 Subject: [PATCH 086/131] done cico with check geotagging --- rest-client.http | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/rest-client.http b/rest-client.http index 6417009..29a58e5 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,22 +1,21 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLXN0YWdpbmctYWR3Lm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjU5NDc0MDY3LCJleHAiOjE2NjAwNzg4NjcsIm5iZiI6MTY1OTQ3NDA2NywianRpIjoia0ljaHBFOEpiaFI0TjN3UyIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.PxGL0NcRtxzhG2J21Ca-zgMbr1anY7vhNzEOpZHSNOk +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NTgzNTM3NSwiZXhwIjoxNjc2NDQwMTc1LCJuYmYiOjE2NzU4MzUzNzUsImp0aSI6IlhyVjlkTW55TXpOazlrTUIiLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.41uAX7bnRwftkC_daRiVwwKcFIN7EDV0Ly_zDuq4_MY - -# @hostname = https://kit-api.ospro.id/api +# @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api -@hostname = http://localhost:8099/api +@hostname = http://localhost:8444/api # @hostname = http://103.73.125.81:8444/api ###### login POST {{hostname}}/login # Authorization: Bearer xxx -# X-REQUEST-TYPE: GraphQL +# X-REQUEST-TYPE: GraphQL 1123150023 content-type: application/json { "username": "admin", - "password": "admin123" + "password": "1nt3gr4s14" } ###### Tools Req @@ -798,15 +797,23 @@ content-type: application/json ###### - POST {{hostname}}/presence/add Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -6.2622811, - "clock_out_lng": 106.7881746, - "clock_time": "2022-04-25T16:40:17+07:00", - "type": "out", - "user_id": 262 -} \ No newline at end of file + "clock_in_lat": -6.2622811, + "clock_in_lng": 106.7881746, + "clock_time": "2023-02-06T16:40:17+07:00", + "type": "in", + "user_id": 1 +} + + +###### +# POST {{hostname}}/ + + +GET {{hostname}}/assign-material/datatablesForReportActivity?draw=2&columns[0][data]=material_name&columns[0][name]=material_name&columns[0][searchable]=true&columns[0][orderable]=true&columns[0][search][value]=&columns[0][search][regex]=false&columns[1][data]=type&columns[1][name]=type&columns[1][searchable]=true&columns[1][orderable]=true&columns[1][search][value]=&columns[1][search][regex]=false&columns[2][data]=qty_planning&columns[2][name]=&columns[2][searchable]=true&columns[2][orderable]=true&columns[2][search][value]=&columns[2][search][regex]=false&columns[3][data]=qty_sum&columns[3][name]=&columns[3][searchable]=true&columns[3][orderable]=true&columns[3][search][value]=&columns[3][search][regex]=false&columns[4][data]=uom&columns[4][name]=uom&columns[4][searchable]=true&columns[4][orderable]=true&columns[4][search][value]=&columns[4][search][regex]=false&columns[5][data]=action&columns[5][name]=action&columns[5][searchable]=true&columns[5][orderable]=true&columns[5][search][value]=&columns[5][search][regex]=false&order[0][column]=0&order[0][dir]=asc&start=0&length=10&search[value]=&search[regex]=false&idact=2511&_=1675418553660 +Authorization: Bearer {{token}} +content-type: application/json From efe6efcbd0147ffa80eb54f3e799caa196ae0ce1 Mon Sep 17 00:00:00 2001 From: ibnu Date: Wed, 8 Feb 2023 22:00:06 +0700 Subject: [PATCH 087/131] update bug fix login --- app/Http/Controllers/AuthController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index d898cf9..bb31e8c 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -31,7 +31,7 @@ class AuthController extends Controller $usernameCheck = false; $passwordCheck = false; - if (User::where('username', $username)->exist()) + if (User::where('username', $username)->exists()) $usernameCheck = true; if (User::where('password', md5($password))->exists()) From 360015d90b09bd6bc3b24381b84cbdd87c00a555 Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 9 Feb 2023 12:07:35 +0700 Subject: [PATCH 088/131] update todo in presence, and update replace mandatory field parent in page divisi --- app/Http/Controllers/DivisiController.php | 4 ++-- app/Http/Controllers/PresenceController.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index ea7c3d4..aad3c90 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(); diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index a2664b4..5086ce1 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -28,7 +28,7 @@ class PresenceController extends Controller } if($request->type=="out"){ - + // $clock_out_loc get data from api.nominatim url serach address payload (lat lot); $clock_out_loc = "-"; $dataUpdate = array( "clock_out"=>$request->clock_time, @@ -69,6 +69,7 @@ class PresenceController extends Controller $onlyDate = date_format($date,"Y-m-d"); + // $clock_in_loc get data from api.nominatim url serach address payload (lat lot); $clock_in_loc = "-"; $dataAdd = array( From ff2e8bbc7618d59cb1bd6ae44df5bd06cc5cc000 Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 9 Feb 2023 12:10:19 +0700 Subject: [PATCH 089/131] add example hit api.nominatim --- rest-client.http | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/rest-client.http b/rest-client.http index 5fc4e13..dae46c8 100644 --- a/rest-client.http +++ b/rest-client.http @@ -814,8 +814,26 @@ content-type: application/json ###### # POST {{hostname}}/ +GET {{hostname}}/assign-material/datatablesForReportActivity?draw=2&columns[0][data]=material_name&columns[0][name]=material_name&columns[0][searchable]=true&columns[0][orderable]=true&columns[0][search][value]=&columns[0][search][regex]=false&columns[1][data]=type&columns[1][name]=type&columns[1][searchable]=true&columns[1][orderable]=true&columns[1][search][value]=&columns[1][search][regex]=false&columns[2][data]=qty_planning&columns[2][name]=&columns[2][searchable]=true&columns[2][orderable]=true&columns[2][search][value]=&columns[2][search][regex]=false&columns[3][data]=qty_sum&columns[3][name]=&columns[3][searchable]=true&columns[3][orderable]=true&columns[3][search][value]=&columns[3][search][regex]=false&columns[4][data]=uom&columns[4][name]=uom&columns[4][searchable]=true&columns[4][orderable]=true&columns[4][search][value]=&columns[4][search][regex]=false&columns[5][data]=action&columns[5][name]=action&columns[5][searchable]=true&columns[5][orderable]=true&columns[5][search][value]=&columns[5][search][regex]=false&order[0][column]=0&order[0][dir]=asc&start=0&length=10&search[value]=&search[regex]=false&idact=2511&_=1675418553660 +Authorization: Bearer {{token}} +content-type: application/json +###### +GET {{hostname}}/dashboard/get-total-project-per-schedule-health +Authorization: Bearer {{token}} +content-type: application/json -GET {{hostname}}/assign-material/datatablesForReportActivity?draw=2&columns[0][data]=material_name&columns[0][name]=material_name&columns[0][searchable]=true&columns[0][orderable]=true&columns[0][search][value]=&columns[0][search][regex]=false&columns[1][data]=type&columns[1][name]=type&columns[1][searchable]=true&columns[1][orderable]=true&columns[1][search][value]=&columns[1][search][regex]=false&columns[2][data]=qty_planning&columns[2][name]=&columns[2][searchable]=true&columns[2][orderable]=true&columns[2][search][value]=&columns[2][search][regex]=false&columns[3][data]=qty_sum&columns[3][name]=&columns[3][searchable]=true&columns[3][orderable]=true&columns[3][search][value]=&columns[3][search][regex]=false&columns[4][data]=uom&columns[4][name]=uom&columns[4][searchable]=true&columns[4][orderable]=true&columns[4][search][value]=&columns[4][search][regex]=false&columns[5][data]=action&columns[5][name]=action&columns[5][searchable]=true&columns[5][orderable]=true&columns[5][search][value]=&columns[5][search][regex]=false&order[0][column]=0&order[0][dir]=asc&start=0&length=10&search[value]=&search[regex]=false&idact=2511&_=1675418553660 +###### +GET {{hostname}}/dashboard/get-detail-expenditure Authorization: Bearer {{token}} content-type: application/json + + +###### +GET {{hostname}}/presence/bulk-update-location +Authorization: Bearer {{token}} +content-type: application/json + + +##### +GET https://nominatim.oslogdev.com/reverse?lat=-6.2622811&lon=106.7881746&format=json \ No newline at end of file From d6ca4b1d0e97b04bbf6e8914cd9c7d0e83055a7f Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 9 Feb 2023 14:07:00 +0700 Subject: [PATCH 090/131] Display name clock in clock out --- app/Http/Controllers/Controller.php | 5 +++++ app/Http/Controllers/PresenceController.php | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 742db50..a1f786f 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -250,4 +250,9 @@ class Controller extends BaseController $totalCost = AssignMaterial::selectRaw("ISNULL(qty_planning,0)*ISNULL(budget,0) as totalCost")->where("proyek_id", $proyek_id)->where("activity_id", $activity_id)->sum("totalCost"); return $totalCost; } + + private function getLoc($lat, $lng){ + $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); + return $response; + } } diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index a2664b4..4c73a5b 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -274,7 +274,12 @@ class PresenceController extends Controller $dataGet = $builder->get(); $finalData = []; - + foreach($dataGet as $data){ + $responseIn = $this.getLoc($clock_in_lat, $clock_in_lng); + $responseOut = $this.getLoc($clock_in_lat, $clock_in_lng); + $data->clock_in_loc = $responseIn->json()["display_name"]; + $data->clock_out_loc = $responseOut->json()["display_name"]; + } $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); } From d19ba8b42a3ee2fb3c1a8b4ed7d6f54136a26638 Mon Sep 17 00:00:00 2001 From: ardhi Date: Thu, 9 Feb 2023 14:39:55 +0700 Subject: [PATCH 091/131] add waypoint/add-bulk --- rest-client.http | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rest-client.http b/rest-client.http index aeda668..a27147a 100644 --- a/rest-client.http +++ b/rest-client.http @@ -8,7 +8,8 @@ # @hostname = https://api-staging-adw.ospro.id/api # @hostname = http://localhost:8099/api # @hostname = http://103.73.125.81:8444/api -@hostname = http://localhost:8074/adw-backend/api +# @hostname = http://localhost:8074/adw-backend/api +@hostname = http://172.20.10.2:8074/adw-backend/api ###### login POST {{hostname}}/login @@ -17,8 +18,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "demo", - "password": "demo123" + "username": "admin", + "password": "1nt3gr4s14" } ###### Tools Req From 71deadce25178c85fff401c73f3b03a48df0acdc Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 9 Feb 2023 16:01:04 +0700 Subject: [PATCH 092/131] update get location address when CICO --- app/Http/Controllers/Controller.php | 27 +++++++++++++++++++-- app/Http/Controllers/PresenceController.php | 19 +++++++++------ rest-client.http | 6 ++--- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a1f786f..1ccbf9c 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Http; use Laravel\Lumen\Routing\Controller as BaseController; @@ -251,8 +252,30 @@ class Controller extends BaseController return $totalCost; } - private function getLoc($lat, $lng){ - $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); + protected function getLoc($lat, $lng){ + // $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); + // return $response->json; + + $url = config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"; + // $token = config('api.adw_token'); + $response = $this->curlRequest($url); return $response; } + + private function curlRequest($url){ + $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); + } } diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 7fe5ae3..f7ea87b 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -18,6 +18,11 @@ class PresenceController extends Controller $this->validate($request, [ 'user_id' => 'required' ]); + + + // $test = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; + // // display_name + // return response()->json(["data"=>$test,'code'=>400], 400); $checkLocation = $this->checkLocation($request); $statusBoundary = false; @@ -28,8 +33,8 @@ class PresenceController extends Controller } if($request->type=="out"){ - // $clock_out_loc get data from api.nominatim url serach address payload (lat lot); - $clock_out_loc = "-"; + + $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; $dataUpdate = array( "clock_out"=>$request->clock_time, "clock_out_lat" => $request->clock_out_lat, @@ -67,10 +72,8 @@ class PresenceController extends Controller die(); } - $onlyDate = date_format($date,"Y-m-d"); - - // $clock_in_loc get data from api.nominatim url serach address payload (lat lot); - $clock_in_loc = "-"; + $onlyDate = date_format($date,"Y-m-d"); + $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; $dataAdd = array( 'user_id'=> $request->user_id, @@ -276,8 +279,8 @@ class PresenceController extends Controller $finalData = []; foreach($dataGet as $data){ - $responseIn = $this.getLoc($clock_in_lat, $clock_in_lng); - $responseOut = $this.getLoc($clock_in_lat, $clock_in_lng); + // $responseIn = $this->getLoc($clock_in_lat, $clock_in_lng); + // $responseOut = $this->getLoc($clock_in_lat, $clock_in_lng); $data->clock_in_loc = $responseIn->json()["display_name"]; $data->clock_out_loc = $responseOut->json()["display_name"]; } diff --git a/rest-client.http b/rest-client.http index dae46c8..214a772 100644 --- a/rest-client.http +++ b/rest-client.http @@ -804,10 +804,10 @@ Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -6.2622811, - "clock_out_lng": 106.7881746, + "clock_in_lat": -6.2622811, + "clock_in_lng": 106.7881746, "clock_time": "2023-02-06T16:40:17+07:00", - "type": "out", + "type": "in", "user_id": 1 } From 361ac26923b75ea45fa6f3ae0cfb6b8753b0b5b1 Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 9 Feb 2023 16:29:14 +0700 Subject: [PATCH 093/131] update bulk location, add solving search, and update rest-client --- app/Http/Controllers/PresenceController.php | 25 +++++---------------- rest-client.http | 6 ++--- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index f7ea87b..6651154 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -18,11 +18,6 @@ class PresenceController extends Controller $this->validate($request, [ 'user_id' => 'required' ]); - - - // $test = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; - // // display_name - // return response()->json(["data"=>$test,'code'=>400], 400); $checkLocation = $this->checkLocation($request); $statusBoundary = false; @@ -276,14 +271,6 @@ class PresenceController extends Controller $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; $dataGet = $builder->get(); - $finalData = []; - - foreach($dataGet as $data){ - // $responseIn = $this->getLoc($clock_in_lat, $clock_in_lng); - // $responseOut = $this->getLoc($clock_in_lat, $clock_in_lng); - $data->clock_in_loc = $responseIn->json()["display_name"]; - $data->clock_out_loc = $responseOut->json()["display_name"]; - } $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); } @@ -310,17 +297,16 @@ class PresenceController extends Controller $clock_in_lat = $objRow->clock_in_lat; $clock_in_lng = $objRow->clock_in_lng; $objRow->clock_in_loc = ""; - if (isset($clock_in_lat) && isset($clock_in_lng)) { - $response = Http::get(config('api.nominatim') . "/reverse?lat=".$clock_in_lat."&lon=".$clock_in_lng."&format=json"); - $objRow->clock_in_loc = $response->json()["display_name"]; + if (isset($clock_in_lat) && isset($clock_in_lng)) { + $objRow->clock_in_loc = $this->getLoc($clock_in_lat, $clock_in_lng)->display_name; } $clock_out_lat = $objRow->clock_out_lat; $clock_out_lng = $objRow->clock_out_lng; $objRow->clock_out_loc = ""; - if (isset($clock_out_lat) && isset($clock_out_lng)) { - $response = Http::get(config('api.nominatim') . "/reverse?lat=".$clock_out_lat."&lon=".$clock_out_lng."&format=json"); - $objRow->clock_out_loc = $response->json()["display_name"]; + if (isset($clock_out_lat) && isset($clock_out_lng) && $clock_out_lng != null) { + $locAddress = $this->getLoc($clock_out_lat, $clock_out_lng); + $objRow->clock_out_loc = isset($locAddress->display_name) ? $locAddress->display_name : "-"; } @@ -328,5 +314,6 @@ class PresenceController extends Controller $presence->clock_out_loc = $objRow->clock_out_loc; $presence->save(); } + return response()->json(['status'=>'success','message'=>'success update!','code'=>200], 200); } } diff --git a/rest-client.http b/rest-client.http index 214a772..dae46c8 100644 --- a/rest-client.http +++ b/rest-client.http @@ -804,10 +804,10 @@ Authorization: Bearer {{token}} content-type: application/json { - "clock_in_lat": -6.2622811, - "clock_in_lng": 106.7881746, + "clock_out_lat": -6.2622811, + "clock_out_lng": 106.7881746, "clock_time": "2023-02-06T16:40:17+07:00", - "type": "in", + "type": "out", "user_id": 1 } From 6e92aab7c75b9f39ecb06372d105380462656afd Mon Sep 17 00:00:00 2001 From: ardhi Date: Sat, 11 Feb 2023 12:24:29 +0700 Subject: [PATCH 094/131] fix when checkLocation when mobile do presence --- app/Http/Controllers/PresenceController.php | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 6651154..5dafe10 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -116,23 +116,23 @@ class PresenceController extends Controller ->whereDate("ma.end_date", ">=", $params->clock_time) ->get(); $temp = []; - foreach($geom as $dataGeom){ - $valGeom = json_decode($dataGeom->geom); - if($params->type=="out"){ - $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326)) as boundary")); - }else{ - $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary")); - } - foreach ($check as $key) { - if($key->boundary){ - $temp[]=array( - "activity_id" => $dataGeom->id, - "boundary" => $key->boundary - ); - } + if (count($geom) > 0) { + foreach($geom as $dataGeom){ + $valGeom = json_decode($dataGeom->geom); + if($params->type=="out"){ + $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326)) as boundary")); + }else{ + $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary")); + } + foreach ($check as $key) { + if($key->boundary){ + $temp[]=array( + "activity_id" => $dataGeom->id, + "boundary" => $key->boundary + ); + } + } } - - } return $temp; } From 9d8b19a826a5e9b12b377665ee0d5a25fd8cf472 Mon Sep 17 00:00:00 2001 From: ardhi Date: Sun, 12 Feb 2023 15:12:20 +0700 Subject: [PATCH 095/131] WIP: map-monitoring API --- .../Controllers/MapMonitoringController.php | 47 ++++++++++++++ app/Models/MapMonitoring.php | 33 ++++++++++ rest-client.http | 63 +++++++++++++++---- routes/web.php | 2 + 4 files changed, 134 insertions(+), 11 deletions(-) create mode 100644 app/Http/Controllers/MapMonitoringController.php create mode 100644 app/Models/MapMonitoring.php diff --git a/app/Http/Controllers/MapMonitoringController.php b/app/Http/Controllers/MapMonitoringController.php new file mode 100644 index 0000000..3614c2f --- /dev/null +++ b/app/Http/Controllers/MapMonitoringController.php @@ -0,0 +1,47 @@ +all(); + // $dataBuilder = $this->setUpPayload($payload, 't_clock_in_out'); + // $builder = $dataBuilder['builder']; + // $countBuilder = $dataBuilder['count']; + // $dataGet = $builder->get(); + // $totalRecord = $countBuilder->count(); + // return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); + + $monitoringData = MapMonitoring::getUsers($request->all()); + var_dump($monitoringData); + + } + + public function list() + { + $data = Presence::all(); + $countData = $data->count(); + + if($data){ + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get list presence, please try again later!','code'=>400], 400); + } + } + + +} diff --git a/app/Models/MapMonitoring.php b/app/Models/MapMonitoring.php new file mode 100644 index 0000000..a5e5fba --- /dev/null +++ b/app/Models/MapMonitoring.php @@ -0,0 +1,33 @@ +table) + ->select('id', 'user_id', 'clock_in', 'clock_out', 'clock_in_lat', 'clock_in_lng', 'clock_out_lat', 'clock_out_lng', 'clock_in_loc', 'clock_out_loc', 'clock_in_boundary', 'clock_out_boundary') + ->whereBetween('created_at', [$payload->timeFrom, $payload->timeTo]) + ->orderBy('created_at', 'desc') + ->get(); + + return $users; + } +} diff --git a/rest-client.http b/rest-client.http index a7a710b..453e2e5 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,12 +1,12 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NTgzNTM3NSwiZXhwIjoxNjc2NDQwMTc1LCJuYmYiOjE2NzU4MzUzNzUsImp0aSI6IlhyVjlkTW55TXpOazlrTUIiLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.41uAX7bnRwftkC_daRiVwwKcFIN7EDV0Ly_zDuq4_MY +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzYxODQ5ODgsImV4cCI6MTY3Njc4OTc4OCwibmJmIjoxNjc2MTg0OTg4LCJqdGkiOiJSMkk1R3FLdXM3bWhMUWwzIiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.GlxG-DaiY1Slc0dR8sRK6CvU-F7MTjT47989MImubJ0 # @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api -@hostname = http://localhost:8444/api +# @hostname = http://localhost:8444/api # @hostname = http://103.73.125.81:8444/api -# @hostname = http://172.20.10.2:8074/adw-backend/api +@hostname = http://localhost:8074/adw-backend/api ###### login POST {{hostname}}/login @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "admin", - "password": "1nt3gr4s14" + "username": "demo", + "password": "demo123" } ###### Tools Req @@ -805,11 +805,11 @@ Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -6.2622811, - "clock_out_lng": 106.7881746, - "clock_time": "2023-02-06T16:40:17+07:00", - "type": "out", - "user_id": 1 + "clock_out_lat": -6.16678379060529, + "clock_out_lng": 106.9175039866567, + "clock_time": "2023-02-10T14:48:17+07:00", + "type": "in", + "user_id": 1247 } @@ -913,4 +913,45 @@ content-type: application/json "datesend": "2023-02-07T10:44:17+07:00" } ] -} \ No newline at end of file +} + +##### +POST {{hostname}}/map-monitoring/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "time_from": "2023-02-10 00:00:00", + "time_to": "2023-02-10 23:59:00", +} + +# { +# "columns": [ +# { +# "logic_operator": "range", +# "name": "created_at", +# "operator": "AND", +# "value": "2023-02-10 00:00:00", +# "value1": "2023-02-10 23:59:00" +# } +# ], +# "joins": [ +# { +# "column_join": "user_id", +# "column_results": [ +# "username", "name" +# ], +# "name": "m_users" +# } +# ], +# "orders": { +# "ascending": false, +# "columns": [ +# "created_at" +# ] +# }, +# "paging": { +# "length": 25, +# "start": 0 +# } +# } \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 46b30a2..57e03bc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -432,6 +432,8 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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 a835dbaa3d31bd01ceb8043fbe6f70506813411e Mon Sep 17 00:00:00 2001 From: ardhi Date: Sun, 12 Feb 2023 15:16:53 +0700 Subject: [PATCH 096/131] WIP: map-monitoring API --- app/Models/MapMonitoring.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/MapMonitoring.php b/app/Models/MapMonitoring.php index a5e5fba..50f9fee 100644 --- a/app/Models/MapMonitoring.php +++ b/app/Models/MapMonitoring.php @@ -24,7 +24,7 @@ class MapMonitoring extends Model { $users = DB::table($this->table) ->select('id', 'user_id', 'clock_in', 'clock_out', 'clock_in_lat', 'clock_in_lng', 'clock_out_lat', 'clock_out_lng', 'clock_in_loc', 'clock_out_loc', 'clock_in_boundary', 'clock_out_boundary') - ->whereBetween('created_at', [$payload->timeFrom, $payload->timeTo]) + ->whereBetween('created_at', [$payload->time_from, $payload->time_to]) ->orderBy('created_at', 'desc') ->get(); From 4ca0f1105e78075d1e23a9494b186b332b5fea01 Mon Sep 17 00:00:00 2001 From: ibnu Date: Sun, 12 Feb 2023 15:16:59 +0700 Subject: [PATCH 097/131] update sample presence --- rest-client.http | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/rest-client.http b/rest-client.http index a7a710b..e7b5a5a 100644 --- a/rest-client.http +++ b/rest-client.http @@ -796,22 +796,31 @@ GET {{hostname}}/presence/clockinout/262 Authorization: Bearer {{token}} content-type: application/json -####### -"clock_out_lat": -1.4264273154149407, - "clock_out_lng": 113.98530036945851, ###### POST {{hostname}}/presence/add Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -6.2622811, - "clock_out_lng": 106.7881746, + "clock_in_lat": -6.2622811, + "clock_in_lng": 106.7881746, "clock_time": "2023-02-06T16:40:17+07:00", - "type": "out", + "type": "in", "user_id": 1 } +###### +POST {{hostname}}/presence/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "clock_out_lat": -1.4264273154149407, + "clock_out_lng": 113.98530036945851, + "clock_time": "2023-02-06T16:40:17+07:00", + "type": "in", + "user_id": 1 +} ###### # POST {{hostname}}/ From b630b9706368ab70eb92b12464a6b0d9b7a37467 Mon Sep 17 00:00:00 2001 From: farhan048 Date: Mon, 13 Feb 2023 10:09:48 +0700 Subject: [PATCH 098/131] Project Expenditure order by DESC, Search Divisi --- app/Http/Controllers/DashboardBoDController.php | 1 + app/Http/Controllers/DivisiController.php | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 94931b6..c6309e5 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -304,6 +304,7 @@ class DashboardBoDController extends Controller $year = $this->interpolateYear($year); $projects = Project::where('mulai_proyek', 'like', $year) /* ->orWhere('akhir_proyek', 'like', $year) */ + ->orderBy('id', 'desc') ->get(); foreach($projects as $project){ $lastGantt = MasterFunctionsHelper::getLatestGantt($project->id); diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index aad3c90..1991c24 100644 --- a/app/Http/Controllers/DivisiController.php +++ b/app/Http/Controllers/DivisiController.php @@ -72,8 +72,13 @@ class DivisiController extends Controller public function search() { - return $this->list(); - // cant use builder for this case + $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); } public function list() From fb674e529e753fdacda70272ba1c58d19363d229 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 14 Feb 2023 01:42:45 +0700 Subject: [PATCH 099/131] update presensi add policy boundary --- app/Http/Controllers/PresenceController.php | 196 +++++++++++--------- rest-client.http | 8 +- 2 files changed, 113 insertions(+), 91 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 5dafe10..a472138 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -5,9 +5,9 @@ namespace App\Http\Controllers; use Log; use Illuminate\Http\Request; use App\Models\Presence; -use App\Models\Activity; -use GuzzleHttp\Client; -use Illuminate\Support\Facades\Http; +// use App\Models\Activity; +// use GuzzleHttp\Client; +// use Illuminate\Support\Facades\Http; use Carbon\Carbon; use Illuminate\Support\Facades\DB; @@ -24,86 +24,102 @@ class PresenceController extends Controller $date = date_create($request->clock_time); // $ActivityId = null; if(count($checkLocation) > 0){ - $statusBoundary = true; + $checkLocation[0]['status_assign'] ? $statusBoundary = true + : $statusBoundary = false; } - if($request->type=="out"){ - - $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; - $dataUpdate = array( - "clock_out"=>$request->clock_time, - "clock_out_lat" => $request->clock_out_lat, - "clock_out_lng" => $request->clock_out_lng, - "updated_by"=>$this->currentName, - "clock_out_loc" => $clock_out_loc, - "clock_out_boundary" => $statusBoundary + if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ + $data=array( + 'id' => null, + 'boundary' => $statusBoundary ); - - $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); - if($resultUpdate && $resultUpdate > 0){ - if($statusBoundary){ - for ($i=0; $i < count($checkLocation); $i++) { - # code... - DB::table('clock_in_out_boundary')->insert([ - "clock_in_out_id" => $resultUpdate, - "user_id" => $request->user_id, - "activity_id" => $checkLocation[$i]['activity_id'], - "type" => $request->type, - "created_at" => $date, - "created_by" => $this->currentName - ]); - }; - }; - $data=array( - 'id' => $resultUpdate, - 'boundary' => $statusBoundary - ); - - return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); - } - else{ - return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); - } - die(); + return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); } - $onlyDate = date_format($date,"Y-m-d"); - $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; - - $dataAdd = array( - 'user_id'=> $request->user_id, - 'clock_in'=> $request->clock_time, - 'date_presence'=> $onlyDate, - 'created_by' => $this->currentName, - 'clock_in_lat' => $request->clock_in_lat, - 'clock_in_lng' => $request->clock_in_lng, - 'clock_in_loc' => $clock_in_loc, - 'clock_in_boundary' => $statusBoundary - ); - - $result = Presence::create($dataAdd); - $data=array( - 'id' => $result->id, - 'boundary' => $statusBoundary - ); - if($result){ - if($statusBoundary){ - for ($i=0; $i < count($checkLocation); $i++) { - # code... - DB::table('clock_in_out_boundary')->insert([ - "clock_in_out_id" => $result->id, - "user_id" => $request->user_id, - "activity_id" => $checkLocation[$i]['activity_id'], - "type" => $request->type, - "created_at" => $date, - "created_by" => $this->currentName - ]); - }; - }; - return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); + if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ + $data=array( + 'id' => null, + 'boundary' => $statusBoundary + ); + return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200); } + + // if($request->type=="out"){ + // $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; + // $dataUpdate = array( + // "clock_out"=>$request->clock_time, + // "clock_out_lat" => $request->clock_out_lat, + // "clock_out_lng" => $request->clock_out_lng, + // "updated_by"=>$this->currentName, + // "clock_out_loc" => $clock_out_loc, + // "clock_out_boundary" => $statusBoundary + // ); + + // $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); + // if($resultUpdate && $resultUpdate > 0){ + // if($statusBoundary){ + // for ($i=0; $i < count($checkLocation); $i++) { + // # code... + // DB::table('clock_in_out_boundary')->insert([ + // "clock_in_out_id" => $resultUpdate, + // "user_id" => $request->user_id, + // "activity_id" => $checkLocation[$i]['activity_id'], + // "type" => $request->type, + // "created_at" => $date, + // "created_by" => $this->currentName + // ]); + // }; + // }; + // $data=array( + // 'id' => $resultUpdate, + // 'boundary' => $statusBoundary + // ); + + // return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); + // } + // else{ + // return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); + // } + // die(); + // } + + // $onlyDate = date_format($date,"Y-m-d"); + // $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; + + // $dataAdd = array( + // 'user_id'=> $request->user_id, + // 'clock_in'=> $request->clock_time, + // 'date_presence'=> $onlyDate, + // 'created_by' => $this->currentName, + // 'clock_in_lat' => $request->clock_in_lat, + // 'clock_in_lng' => $request->clock_in_lng, + // 'clock_in_loc' => $clock_in_loc, + // 'clock_in_boundary' => $statusBoundary + // ); + + // $result = Presence::create($dataAdd); + // $data=array( + // 'id' => $result->id, + // 'boundary' => $statusBoundary + // ); + // if($result){ + // if($statusBoundary){ + // for ($i=0; $i < count($checkLocation); $i++) { + // # code... + // DB::table('clock_in_out_boundary')->insert([ + // "clock_in_out_id" => $result->id, + // "user_id" => $request->user_id, + // "activity_id" => $checkLocation[$i]['activity_id'], + // "type" => $request->type, + // "created_at" => $date, + // "created_by" => $this->currentName + // ]); + // }; + // }; + // return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); + // }else{ + // return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); + // } } private function checkLocation($params){ @@ -128,11 +144,25 @@ class PresenceController extends Controller if($key->boundary){ $temp[]=array( "activity_id" => $dataGeom->id, - "boundary" => $key->boundary + "boundary" => $key->boundary, + "status_assign" => true ); - } + } + } + if(count($temp) < 1){ + $temp[]=array( + "activity_id" => null, + "boundary" => null, + "status_assign" => true + ); } } + }else{ + $temp[]=array( + "activity_id" => null, + "boundary" => null, + "status_assign" => false + ); } return $temp; } @@ -152,14 +182,10 @@ class PresenceController extends Controller } } - - public function clockinout($id) { $dateTimeNow = Carbon::now()->addHour(7); $dataPresence = Presence::where('user_id', $id)->orderBy('id', 'DESC')->first(); - - if($dataPresence){ $dateNow = date("Y-m-d"); @@ -199,10 +225,8 @@ class PresenceController extends Controller private function updateFormAdd($data, $id){ $date = date_create($data['clock_out']); - $onlyDate = date_format($date,"Y-m-d"); - $dataPresence = Presence::where('user_id',$id) ->where("clock_in", "<=", $data["clock_out"]) ->orderByDesc("id") @@ -237,7 +261,6 @@ class PresenceController extends Controller die(); } - if($result){ return response()->json(['status'=>'success','message'=>'data presence successfully updated!','code'=>200], 200); }else{ @@ -256,7 +279,6 @@ class PresenceController extends Controller die(); } - if($delete){ return response()->json(['status'=>'success','message'=>'data presence successfully deleted!','code'=>200], 200); }else{ diff --git a/rest-client.http b/rest-client.http index 416c9b0..120334f 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,12 +1,12 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzYxODQ5ODgsImV4cCI6MTY3Njc4OTc4OCwibmJmIjoxNjc2MTg0OTg4LCJqdGkiOiJSMkk1R3FLdXM3bWhMUWwzIiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.GlxG-DaiY1Slc0dR8sRK6CvU-F7MTjT47989MImubJ0 +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NjI5MTQwNiwiZXhwIjoxNjc2ODk2MjA2LCJuYmYiOjE2NzYyOTE0MDYsImp0aSI6IkNNRVNGMEcwVzVNQlRLenoiLCJzdWIiOjEyNDcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.ZV2ncAf6H61vnK7fmg-bMfeqBTcxm0aFE5zs_4tor8g # @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api -# @hostname = http://localhost:8444/api +@hostname = http://localhost:8444/api # @hostname = http://103.73.125.81:8444/api -@hostname = http://localhost:8074/adw-backend/api +# @hostname = http://localhost:8444/adw-ba/api ###### login POST {{hostname}}/login @@ -817,7 +817,7 @@ content-type: application/json { "clock_out_lat": -1.4264273154149407, "clock_out_lng": 113.98530036945851, - "clock_time": "2023-02-06T16:40:17+07:00", + "clock_time": "2023-02-13T16:40:17+07:00", "type": "in", "user_id": 1 } From f4f7e15ea05d6888f65f22a1212b69b9d4985b9c Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 14 Feb 2023 02:46:01 +0700 Subject: [PATCH 100/131] update presensi --- app/Http/Controllers/PresenceController.php | 142 ++++++++++---------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index a472138..0e844d0 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -44,82 +44,82 @@ class PresenceController extends Controller return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200); } - // if($request->type=="out"){ - // $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; - // $dataUpdate = array( - // "clock_out"=>$request->clock_time, - // "clock_out_lat" => $request->clock_out_lat, - // "clock_out_lng" => $request->clock_out_lng, - // "updated_by"=>$this->currentName, - // "clock_out_loc" => $clock_out_loc, - // "clock_out_boundary" => $statusBoundary - // ); + if($request->type=="out"){ + $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; + $dataUpdate = array( + "clock_out"=>$request->clock_time, + "clock_out_lat" => $request->clock_out_lat, + "clock_out_lng" => $request->clock_out_lng, + "updated_by"=>$this->currentName, + "clock_out_loc" => $clock_out_loc, + "clock_out_boundary" => $statusBoundary + ); - // $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); - // if($resultUpdate && $resultUpdate > 0){ - // if($statusBoundary){ - // for ($i=0; $i < count($checkLocation); $i++) { - // # code... - // DB::table('clock_in_out_boundary')->insert([ - // "clock_in_out_id" => $resultUpdate, - // "user_id" => $request->user_id, - // "activity_id" => $checkLocation[$i]['activity_id'], - // "type" => $request->type, - // "created_at" => $date, - // "created_by" => $this->currentName - // ]); - // }; - // }; - // $data=array( - // 'id' => $resultUpdate, - // 'boundary' => $statusBoundary - // ); + $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); + if($resultUpdate && $resultUpdate > 0){ + if($statusBoundary){ + for ($i=0; $i < count($checkLocation); $i++) { + # code... + DB::table('clock_in_out_boundary')->insert([ + "clock_in_out_id" => $resultUpdate, + "user_id" => $request->user_id, + "activity_id" => $checkLocation[$i]['activity_id'], + "type" => $request->type, + "created_at" => $date, + "created_by" => $this->currentName + ]); + }; + }; + $data=array( + 'id' => $resultUpdate, + 'boundary' => $statusBoundary + ); - // return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); - // } - // else{ - // return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); - // } - // die(); - // } + return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); + } + else{ + return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); + } + die(); + } - // $onlyDate = date_format($date,"Y-m-d"); - // $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; + $onlyDate = date_format($date,"Y-m-d"); + $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; - // $dataAdd = array( - // 'user_id'=> $request->user_id, - // 'clock_in'=> $request->clock_time, - // 'date_presence'=> $onlyDate, - // 'created_by' => $this->currentName, - // 'clock_in_lat' => $request->clock_in_lat, - // 'clock_in_lng' => $request->clock_in_lng, - // 'clock_in_loc' => $clock_in_loc, - // 'clock_in_boundary' => $statusBoundary - // ); + $dataAdd = array( + 'user_id'=> $request->user_id, + 'clock_in'=> $request->clock_time, + 'date_presence'=> $onlyDate, + 'created_by' => $this->currentName, + 'clock_in_lat' => $request->clock_in_lat, + 'clock_in_lng' => $request->clock_in_lng, + 'clock_in_loc' => $clock_in_loc, + 'clock_in_boundary' => $statusBoundary + ); - // $result = Presence::create($dataAdd); - // $data=array( - // 'id' => $result->id, - // 'boundary' => $statusBoundary - // ); - // if($result){ - // if($statusBoundary){ - // for ($i=0; $i < count($checkLocation); $i++) { - // # code... - // DB::table('clock_in_out_boundary')->insert([ - // "clock_in_out_id" => $result->id, - // "user_id" => $request->user_id, - // "activity_id" => $checkLocation[$i]['activity_id'], - // "type" => $request->type, - // "created_at" => $date, - // "created_by" => $this->currentName - // ]); - // }; - // }; - // return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); - // }else{ - // return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); - // } + $result = Presence::create($dataAdd); + $data=array( + 'id' => $result->id, + 'boundary' => $statusBoundary + ); + if($result){ + if($statusBoundary){ + for ($i=0; $i < count($checkLocation); $i++) { + # code... + DB::table('clock_in_out_boundary')->insert([ + "clock_in_out_id" => $result->id, + "user_id" => $request->user_id, + "activity_id" => $checkLocation[$i]['activity_id'], + "type" => $request->type, + "created_at" => $date, + "created_by" => $this->currentName + ]); + }; + }; + return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); + } } private function checkLocation($params){ From 47b4f779bfe555573fbfec14308755d5e3787b91 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Tue, 14 Feb 2023 13:29:19 +0700 Subject: [PATCH 101/131] Project to k3 checklist adding name --- app/Http/Controllers/ProjectToChecklistK3Controller.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/ProjectToChecklistK3Controller.php b/app/Http/Controllers/ProjectToChecklistK3Controller.php index 99413ba..3fb5a8e 100644 --- a/app/Http/Controllers/ProjectToChecklistK3Controller.php +++ b/app/Http/Controllers/ProjectToChecklistK3Controller.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\ProjectToChecklistK3; +use App\Models\ChecklistK3; class ProjectToChecklistK3Controller extends Controller { @@ -122,6 +123,12 @@ class ProjectToChecklistK3Controller extends Controller $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; $dataGet = $builder->get(); + + foreach($dataGet as $key => $value) { + $checklist = ChecklistK3::where('id', $value->checklist_k3_id)->first(); + $dataGet[$key]->checklist_k3_name = $checklist->name; + } + $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); } From 43e96917ffb9baadf41809abe6d69cdee69d8f1f Mon Sep 17 00:00:00 2001 From: farhan048 Date: Tue, 14 Feb 2023 17:53:50 +0700 Subject: [PATCH 102/131] search divisi update --- app/Http/Controllers/DivisiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index 1991c24..6fe8287 100644 --- a/app/Http/Controllers/DivisiController.php +++ b/app/Http/Controllers/DivisiController.php @@ -70,7 +70,7 @@ class DivisiController extends Controller return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200); } - public function search() + public function search(Request $request) { $payload = $request->all(); $dataBuilder = $this->setUpPayload($payload, 'm_divisi'); From 7a07f7bd12585ced6f1d03066fc8f5a657a54120 Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 16 Feb 2023 00:48:50 +0700 Subject: [PATCH 103/131] update api maps monitoring --- .../Controllers/MapMonitoringController.php | 64 +++++++++++++++---- rest-client.http | 17 +++-- 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/MapMonitoringController.php b/app/Http/Controllers/MapMonitoringController.php index 3614c2f..26b36cb 100644 --- a/app/Http/Controllers/MapMonitoringController.php +++ b/app/Http/Controllers/MapMonitoringController.php @@ -7,8 +7,6 @@ use Illuminate\Http\Request; use App\Models\Presence; use App\Models\Activity; use App\Models\MapMonitoring; -use GuzzleHttp\Client; -use Illuminate\Support\Facades\Http; use Carbon\Carbon; use Illuminate\Support\Facades\DB; @@ -17,18 +15,56 @@ class MapMonitoringController extends Controller // default map monitoring shows today's presence lat lon in the map public function search(Request $request) - { - // $payload = $request->all(); - // $dataBuilder = $this->setUpPayload($payload, 't_clock_in_out'); - // $builder = $dataBuilder['builder']; - // $countBuilder = $dataBuilder['count']; - // $dataGet = $builder->get(); - // $totalRecord = $countBuilder->count(); - // return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); - - $monitoringData = MapMonitoring::getUsers($request->all()); - var_dump($monitoringData); - + { + $dateNow = Carbon::today()->addHour(7)->format('Y-m-d'); + // get distinct human assign project + $hr_assign_project = DB::table('assign_hr_to_proyek') + ->select('user_id') + ->whereIn('proyek_id', $request->project_id) + ->distinct() + ->get(); + // get position hr in presensi + $tmp = []; + foreach($hr_assign_project as $key){ + $presensi = DB::table('t_clock_in_out as tcio') + ->select('tcio.id as clock_in_out_id','mu.id as user_id', 'mu.name as fullname', 'tcio.clock_in', 'tcio.clock_out', 'tcio.clock_in_lat', 'tcio.clock_in_lng', + 'tcio.clock_out_lat', 'tcio.clock_out_lng', 'tcio.clock_in_loc', 'tcio.clock_out_loc', 'tcio.clock_in_boundary', + 'tcio.clock_out_boundary', 'mu.username', 'tcio.date_presence', 'tcio.created_at') + ->join('m_users as mu', 'mu.id', '=', 'tcio.user_id') + ->where('mu.id', $key->user_id) + ->orderBy('tcio.id', 'DESC') + ->first(); + $project = DB::table('assign_hr_to_proyek as ahtp') + ->select('ahtp.proyek_id as id', 'mp.nama as project_name') + ->join('m_proyek as mp', 'mp.id', '=', 'ahtp.proyek_id') + ->whereIn('ahtp.proyek_id', $request->project_id) + ->where('ahtp.user_id', $key->user_id) + ->get(); + if($presensi && isset($presensi->user_id)){ + $image = DB::table('m_image')->select('image')->where('category', 'presensi')->where('ref_id', $presensi->clock_in_out_id)->first(); + $tmp[] = array( + 'user_id' => $presensi->user_id, + 'clock_in' => $presensi->clock_in, + 'clock_out' => $presensi->clock_out, + 'date_presence' => $presensi->date_presence, + 'clock_in_lat' => $presensi->clock_in_lat, + 'clock_in_lng' => $presensi->clock_in_lng, + 'clock_out_lat' => $presensi->clock_out_lat, + 'clock_out_lng' => $presensi->clock_out_lng, + 'clock_in_loc' => $presensi->clock_in_loc, + 'clock_out_loc' => $presensi->clock_out_loc, + 'clock_in_boundary' => $presensi->clock_in_boundary, + 'clock_out_boundary' => $presensi->clock_out_boundary, + 'username' => $presensi->username, + 'name' => $presensi->fullname, + 'image_selfie' => isset($image->image) ? $image->image : '-', + 'created_at' => $presensi->created_at, + 'presence_status' => $presensi->date_presence == $dateNow ? true : false,//true, //status date_presence, + 'projects' => $project + ); + } + } + return response()->json(['status'=>'success','code'=>200, 'data' => $tmp, 'totalRecord'=>count($tmp)], 200); } public function list() diff --git a/rest-client.http b/rest-client.http index 120334f..6cdd4ad 100644 --- a/rest-client.http +++ b/rest-client.http @@ -802,8 +802,8 @@ Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -6.16678379060529, - "clock_out_lng": 106.9175039866567, + "clock_in_lat": -6.16678379060529, + "clock_in_lng": 106.9175039866567, "clock_time": "2023-02-10T14:48:17+07:00", "type": "in", "user_id": 1247 @@ -815,8 +815,8 @@ Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -1.4264273154149407, - "clock_out_lng": 113.98530036945851, + "clock_in_lat": -1.4264273154149407, + "clock_in_lng": 113.98530036945851, "clock_time": "2023-02-13T16:40:17+07:00", "type": "in", "user_id": 1 @@ -864,7 +864,16 @@ content-type: application/json } ###### +POST {{hostname}}/map-monitoring/search +Authorization: Bearer {{token}} +content-type: application/json +{ + "project_id" : [1, 2, 3] + +} + +###### POST {{hostname}}/waypoint/add-bulk Authorization: Bearer {{token}} content-type: application/json From 742b23a8168940f499a2149d06258550e1224357 Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 16 Feb 2023 09:49:30 +0700 Subject: [PATCH 104/131] update bugfix presensi --- app/Http/Controllers/PresenceController.php | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 0e844d0..3a6e7f5 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -22,24 +22,26 @@ class PresenceController extends Controller $checkLocation = $this->checkLocation($request); $statusBoundary = false; $date = date_create($request->clock_time); - // $ActivityId = null; - if(count($checkLocation) > 0){ - $checkLocation[0]['status_assign'] ? $statusBoundary = true - : $statusBoundary = false; + // assign and in boundary + if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ + // $checkLocation[0]['status_assign'] ? $statusBoundary = true + // : + $statusBoundary = true; } - if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ + // not assign + if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ $data=array( 'id' => null, 'boundary' => $statusBoundary ); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); } - - if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ + // assign and not in boundary + if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ $data=array( 'id' => null, - 'boundary' => $statusBoundary + 'boundary' => true ); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200); } @@ -141,6 +143,7 @@ class PresenceController extends Controller $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary")); } foreach ($check as $key) { + // assign and in boundary if($key->boundary){ $temp[]=array( "activity_id" => $dataGeom->id, @@ -149,18 +152,22 @@ class PresenceController extends Controller ); } } + // assign and not in boundary if(count($temp) < 1){ $temp[]=array( "activity_id" => null, - "boundary" => null, + "boundary" => false, "status_assign" => true + // "geom" => $geom, + // "cek" => $check[0]->boundary ); } } }else{ + // not assign $temp[]=array( "activity_id" => null, - "boundary" => null, + "boundary" => false, "status_assign" => false ); } From 7101008905c0341c44fa433f788f6e93c10cb883 Mon Sep 17 00:00:00 2001 From: farhan048 Date: Thu, 16 Feb 2023 15:26:36 +0700 Subject: [PATCH 105/131] Add boundary status --- app/Models/HumanResource.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 4647aa2..222a835 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -32,6 +32,7 @@ class HumanResource extends Model 'created_by', 'updated_at', 'updated_by', - 'divisi_id' + 'divisi_id', + 'status_boundary' ]; } From 790ad536f89aff48a8490189fe066e9ba63029af Mon Sep 17 00:00:00 2001 From: farhan048 Date: Thu, 16 Feb 2023 16:07:41 +0700 Subject: [PATCH 106/131] Update Model HR --- app/Models/HumanResource.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 222a835..4745a1d 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -34,5 +34,6 @@ class HumanResource extends Model 'updated_by', 'divisi_id', 'status_boundary' + ]; } From 9503d9e6c6c146a54eff450ddf364d48acfc184b Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 20 Feb 2023 12:41:20 +0700 Subject: [PATCH 107/131] Handling if cost planning < 0 --- app/Models/Activity.php | 7 +++++++ app/Models/UserToActivity.php | 3 +++ 2 files changed, 10 insertions(+) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 9be182c..7ee841a 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -127,6 +127,13 @@ class Activity extends Model if($parent = Activity::find($this->parent_id)){ $parentActWeight = $parent->bobot_planning; + if ($parentActWeight == 0) { + $parent->update([ + "persentase_progress" => 0 + ]); + return; + } + $totalChildProportionalProgress = 0; $childs = Activity::where("parent_id", $parent->id)->get(); foreach($childs as $child){ diff --git a/app/Models/UserToActivity.php b/app/Models/UserToActivity.php index 3dac828..a33667c 100644 --- a/app/Models/UserToActivity.php +++ b/app/Models/UserToActivity.php @@ -50,6 +50,9 @@ class UserToActivity extends Model } $activity->rencana_biaya -= $salary; + if ($activity->rencana_biaya < 0) { + $activity->rencana_biaya = 0; + } $activity->save(); }); From 418cf7c6b4c3674fef3957b55f9eeeb5dc7c3c80 Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 11:14:40 +0700 Subject: [PATCH 108/131] change rest-client.http --- rest-client.http | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/rest-client.http b/rest-client.http index 453e2e5..e0ef125 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,12 +1,12 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzYxODQ5ODgsImV4cCI6MTY3Njc4OTc4OCwibmJmIjoxNjc2MTg0OTg4LCJqdGkiOiJSMkk1R3FLdXM3bWhMUWwzIiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.GlxG-DaiY1Slc0dR8sRK6CvU-F7MTjT47989MImubJ0 +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2NTE5NDQ2LCJleHAiOjE2NzcxMjQyNDYsIm5iZiI6MTY3NjUxOTQ0NiwianRpIjoiTXE4R3QzeTZRMllCMnRCWiIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.bXhL34fVSLDvAn4OIqiJnDtUCPcTG-Lyct_WtNPd9K8 -# @hostname = https://adw-api.ospro.id/api +@hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api # @hostname = http://localhost:8444/api # @hostname = http://103.73.125.81:8444/api -@hostname = http://localhost:8074/adw-backend/api +# @hostname = http://localhost:8074/adw-backend/api ###### login POST {{hostname}}/login @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "demo", - "password": "demo123" + "username": "admin", + "password": "1nt3gr4s14" } ###### Tools Req @@ -749,6 +749,10 @@ content-type: application/json "project_id": [15] } +### +GET https://adw-api.ospro.id/api/request-material/get-material-integration?name=c +Authorization: Bearer {{token}} +content-type: application/json ### POST {{hostname}}/presence/search @@ -766,8 +770,8 @@ content-type: application/json "name": "m_users", "column_join": "user_id", "column_results": [ - "name", - "ktp_number" + "username", + "name" ] } ], @@ -804,13 +808,15 @@ POST {{hostname}}/presence/add Authorization: Bearer {{token}} content-type: application/json -{ - "clock_out_lat": -6.16678379060529, - "clock_out_lng": 106.9175039866567, - "clock_time": "2023-02-10T14:48:17+07:00", - "type": "in", - "user_id": 1247 -} +# { +# "clock_out_lat": -6.16678379060529, +# "clock_out_lng": 106.9175039866567, +# "clock_time": "2023-02-10T14:48:17+07:00", +# "type": "in", +# "user_id": 1247 +# } +{"clock_time":"2023-02-14T02:34:28+07:00","type":"in","user_id":1247,"clock_in_lat":-6.2646449,"clock_in_lng":106.7893041} + ###### @@ -954,4 +960,12 @@ content-type: application/json # "length": 25, # "start": 0 # } -# } \ No newline at end of file +# } + + +### get image +# GET {{hostname}}/image/106/presensi +GET {{hostname}}/image/1634/report_activity +Authorization: Bearer {{token}} +content-type: application/json + From 57161f5fe1a5d111dae5fcd1d4a17aa80888cf21 Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 14:23:05 +0700 Subject: [PATCH 109/131] add project_code in dashboard --- app/Http/Controllers/DashboardBoDController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index c6309e5..6901b21 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -103,6 +103,7 @@ class DashboardBoDController extends Controller $resp = $this->getInvoiceIntegration($project->kode_sortname); array_push($return, [ 'project' => $project->nama, + 'project_code' => $project->kode_sortname, 'invoiced' => $resp->data->total_invoice_amount ?? 0, 'paid' => $resp->data->total_invoice_paid_amount ?? 0, 'response' => $resp, From ff1e6082823d43ebf13ea2e7c8dc39f1f313cce3 Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 15:39:08 +0700 Subject: [PATCH 110/131] change rest-client.http --- rest-client.http | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/rest-client.http b/rest-client.http index 22de8e8..247fbcb 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,20 +1,12 @@ -<<<<<<< HEAD -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2NTE5NDQ2LCJleHAiOjE2NzcxMjQyNDYsIm5iZiI6MTY3NjUxOTQ0NiwianRpIjoiTXE4R3QzeTZRMllCMnRCWiIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.bXhL34fVSLDvAn4OIqiJnDtUCPcTG-Lyct_WtNPd9K8 -======= @token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NjI5MTQwNiwiZXhwIjoxNjc2ODk2MjA2LCJuYmYiOjE2NzYyOTE0MDYsImp0aSI6IkNNRVNGMEcwVzVNQlRLenoiLCJzdWIiOjEyNDcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.ZV2ncAf6H61vnK7fmg-bMfeqBTcxm0aFE5zs_4tor8g ->>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api -@hostname = http://localhost:8444/api +# @hostname = http://localhost:8444/api # @hostname = http://103.73.125.81:8444/api -<<<<<<< HEAD -# @hostname = http://localhost:8074/adw-backend/api -======= -# @hostname = http://localhost:8444/adw-ba/api ->>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b +# @hostname = http://localhost:8444/adw-backend/api ###### login POST {{hostname}}/login @@ -813,17 +805,6 @@ POST {{hostname}}/presence/add Authorization: Bearer {{token}} content-type: application/json -<<<<<<< HEAD -# { -# "clock_out_lat": -6.16678379060529, -# "clock_out_lng": 106.9175039866567, -# "clock_time": "2023-02-10T14:48:17+07:00", -# "type": "in", -# "user_id": 1247 -# } -{"clock_time":"2023-02-14T02:34:28+07:00","type":"in","user_id":1247,"clock_in_lat":-6.2646449,"clock_in_lng":106.7893041} - -======= { "clock_in_lat": -6.16678379060529, "clock_in_lng": 106.9175039866567, @@ -831,7 +812,6 @@ content-type: application/json "type": "in", "user_id": 1247 } ->>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b ###### POST {{hostname}}/presence/add From c3f076716692d450c1a9a8def6c6dd0a3536bd1e Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 16:02:25 +0700 Subject: [PATCH 111/131] rest-client --- rest-client.http | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest-client.http b/rest-client.http index 247fbcb..fb33a36 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,4 +1,4 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NjI5MTQwNiwiZXhwIjoxNjc2ODk2MjA2LCJuYmYiOjE2NzYyOTE0MDYsImp0aSI6IkNNRVNGMEcwVzVNQlRLenoiLCJzdWIiOjEyNDcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.ZV2ncAf6H61vnK7fmg-bMfeqBTcxm0aFE5zs_4tor8g +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2OTY4ODM5LCJleHAiOjE2Nzc1NzM2MzksIm5iZiI6MTY3Njk2ODgzOSwianRpIjoiYW9jS3djZWYyaHRyQ2w1cCIsInN1YiI6MTI0NywicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.krJmIqfkqQ4Dh9mZye5gCQeB2-JjVf1t1B_GEwnIslQ @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "admin", - "password": "1nt3gr4s14" + "username": "demo", + "password": "demo123" } ###### Tools Req From f9e957a522d39085e1c28b46dc643301170abe22 Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 18:05:35 +0700 Subject: [PATCH 112/131] change rest-client --- rest-client.http | 95 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 3 deletions(-) diff --git a/rest-client.http b/rest-client.http index fb33a36..47496cb 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,4 +1,4 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2OTY4ODM5LCJleHAiOjE2Nzc1NzM2MzksIm5iZiI6MTY3Njk2ODgzOSwianRpIjoiYW9jS3djZWYyaHRyQ2w1cCIsInN1YiI6MTI0NywicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.krJmIqfkqQ4Dh9mZye5gCQeB2-JjVf1t1B_GEwnIslQ +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2OTc2Mjc1LCJleHAiOjE2Nzc1ODEwNzUsIm5iZiI6MTY3Njk3NjI3NSwianRpIjoiQ1dMUFZOend6cHdZd0dDZyIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.w0ZXoDAch3Hu8ziKBQTSTF5QH5SbaOhFsA__DHJp66A @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "demo", - "password": "demo123" + "username": "admin", + "password": "1nt3gr4s14" } ###### Tools Req @@ -784,6 +784,95 @@ content-type: application/json } +### +POST {{hostname}}/report-k3/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "paging": { + "start": 0, + "length": 10 + }, + "filter_columns": [ + { + "name": "name", + "value": "", + "table_name": "m_users" + } + ], + "columns": [ + { + "name": "report_date", + "logic_operator": "range", + "value": "2023-02-21 00:00:00", + "value1": "2023-02-21 23:59:59", + "operator": "AND" + }, + { + "name": "name", + "logic_operator": "ilike", + "value": "", + "operator": "AND", + "table_name": "m_users" + }, + { + "name": "proyek_id", + "logic_operator": "in", + "value": [ + 80, + 79, + 78, + 76, + 75, + 74, + 73, + 72, + 71, + 66, + 64, + 63, + 62, + 58, + 57, + 49, + 48, + 47, + 37, + 31 + ] + } + ], + "joins": [ + { + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name" + ] + }, + { + "name": "m_proyek", + "column_join": "proyek_id", + "column_results": [ + "nama" + ] + } + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + }, + "child_data": { + "table_name": "t_report_k3_detail", + "column_table": "report_k3_id", + "column_name": "id" + } +} + + ### POST {{hostname}}/assign-material/ForReportActivityByMaterial From f4a3195ec597c2d77f1cc22eac4215059688f575 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 23 Feb 2023 16:38:01 +0700 Subject: [PATCH 113/131] Report date validation --- .../ReportActivityMaterialController.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index a4a120b..fd61e5f 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -23,18 +23,24 @@ class ReportActivityMaterialController extends Controller 'qty' => 'required' ]); + $activity = Activity::where('id', $request->activity_id)->first(); + + $start_date = $activity->start_date; + $start_date = substr($start_date, 0, 19); // remove the timezone offset + $startDate = new \DateTime(date("Y-m-d", strtotime($start_date))); + $reportDate = new \DateTime(date("Y-m-d", strtotime($request->report_date))); + $data = $request->all(); $data['created_by'] = $this->currentName; /* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */ $data['assign_material_id'] = $request->assign_material_id; $data['qty'] = $this->sanitizeDecimal($data['qty']); - - $created = ReportActivityMaterial::create($data); - - if(!$created) - return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null]); - - return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]); + if($reportDate > $startDate){ + $created = ReportActivityMaterial::create($data); + return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]); + } else { + return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null], 400); + } } public function updateStatusStartFinish(Request $request){ From e18d0c3c5b06faa60a69b484259ec0102546422f Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 23 Feb 2023 18:51:33 +0700 Subject: [PATCH 114/131] Plan date has to be more than start date --- .../Controllers/AssignMaterialController.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index 16f848a..5a89147 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\AssignMaterial; use App\Models\RequestMaterial; +use App\Models\Activity; use App\Models\ReportActivityMaterial; use Datatables; @@ -23,23 +24,30 @@ class AssignMaterialController extends Controller 'qty_planning' => 'required' ]); + $activity = Activity::where('id', $request->activity_id)->first(); + $checkStock = RequestMaterial::where("id", $request->material_id)->first(); $currentStock = $checkStock->qty; if((int)$currentStock < (int)$request->qty_planning){ return response()->json(['status'=>'failed','message'=>'Stock is not enough!','code'=> 500]); } + + $start_date = $activity->start_date; + $start_date = substr($start_date, 0, 19); // remove the timezone offset + $startDate = new \DateTime(date("Y-m-d", strtotime($start_date))); + $planDate = new \DateTime(date("Y-m-d", strtotime($request->plan_date))); $data = $request->all(); $data['created_by'] = $this->currentName; $data['budget'] = $checkStock->price; $data['qty_planning'] = $this->sanitizeDecimal($data['qty_planning']); - $result = AssignMaterial::create($data); - if(!$result) - return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500]); - - return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200]); - + if ($planDate > $startDate) { + $result = AssignMaterial::create($data); + return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 400], 400); + } } public function update(Request $request, $id){ From 6ef3ca0da9f97b15e6bb3c0891c7bdeaa4644e8f Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 27 Feb 2023 15:05:23 +0700 Subject: [PATCH 115/131] Adding functions for project dashboard --- app/Http/Controllers/ProjectController.php | 16 +++++++++++++++- routes/web.php | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index d0934e5..6a14f1a 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -215,6 +215,20 @@ 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(); @@ -389,7 +403,7 @@ class ProjectController extends Controller 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 diff --git a/routes/web.php b/routes/web.php index 57e03bc..9021ba1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -62,6 +62,8 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); From 982065e59f71b974b3248cac54226dd3e39123d2 Mon Sep 17 00:00:00 2001 From: ibnu Date: Wed, 1 Mar 2023 14:23:40 +0700 Subject: [PATCH 116/131] update command integrations HR --- app/Console/Commands/syncHumanResourceIntegration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/syncHumanResourceIntegration.php b/app/Console/Commands/syncHumanResourceIntegration.php index 0f3b72d..7b4ef5f 100644 --- a/app/Console/Commands/syncHumanResourceIntegration.php +++ b/app/Console/Commands/syncHumanResourceIntegration.php @@ -68,7 +68,7 @@ class syncHumanResourceIntegration extends Command 'role_id' => 24, 'created_by' => 'integration' ], - ); + ); } echo "\n------------------------------------------\n"; $currentResponse = MasterFunctionsHelper::curlReq(str_replace('1', $i, $url)); From 95d7c5885c9bb6b581fd4abb909cab646a0e8b4d Mon Sep 17 00:00:00 2001 From: ibnu Date: Wed, 1 Mar 2023 14:24:07 +0700 Subject: [PATCH 117/131] update conflict --- rest-client.http | 50 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/rest-client.http b/rest-client.http index 6cdd4ad..b708d1d 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,4 +1,4 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NjI5MTQwNiwiZXhwIjoxNjc2ODk2MjA2LCJuYmYiOjE2NzYyOTE0MDYsImp0aSI6IkNNRVNGMEcwVzVNQlRLenoiLCJzdWIiOjEyNDcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.ZV2ncAf6H61vnK7fmg-bMfeqBTcxm0aFE5zs_4tor8g +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NzQ3NzIzMSwiZXhwIjoxNjc4MDgyMDMxLCJuYmYiOjE2Nzc0NzcyMzEsImp0aSI6ImR5WWhRY3ZIbUJEcmFKMG0iLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.9zT6CBbQholzIdQ9ZBDoxMvrR-PKvIYkGzdNB6bim0Y # @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "demo", - "password": "demo123" + "username": "admin", + "password": "1nt3gr4s14" } ###### Tools Req @@ -804,7 +804,7 @@ content-type: application/json { "clock_in_lat": -6.16678379060529, "clock_in_lng": 106.9175039866567, - "clock_time": "2023-02-10T14:48:17+07:00", + "clock_time": "2023-02-16T14:48:17+07:00", "type": "in", "user_id": 1247 } @@ -869,8 +869,7 @@ Authorization: Bearer {{token}} content-type: application/json { - "project_id" : [1, 2, 3] - + "project_id" : [75, 76, 78] } ###### @@ -972,4 +971,41 @@ content-type: application/json # "length": 25, # "start": 0 # } -# } \ No newline at end of file +# } + + +GET /stock_master?name=SEARCH + +###### +GET {{hostname}}/request-material/get-material-integration +Authorization: Bearer {{token}} +content-type: application/json + + +###### +POST {{hostname}}/presence/reportk3 +Authorization: Bearer {{token}} +content-type: application/json + +{ + "time" : "2023-02-16T14:48:17+07:00", // untuk report date, time_clockin/out + "user_id": 1247, + "clock_in_out": { + "clock_in_lat": -6.16678379060529, + "clock_in_lng": 106.9175039866567, + "type": "in" + }, + "report_k3": { + "proyek_id": "", + "description": "", + "detail": [{ + "checklist_id": 1, + "checklist_name": "" + }, + { + "checklist_id": 2, + "checklist_name": "" + }] + + } +} \ No newline at end of file From bbd8d9d7631c602908c8e5485f6e1a6bcec007ce Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 2 Mar 2023 10:17:41 +0700 Subject: [PATCH 118/131] adding new function for filtering activity --- .../Controllers/UserToActivityController.php | 34 ++++++++++++++++++- routes/web.php | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php index 2b9b403..8cf9ad6 100644 --- a/app/Http/Controllers/UserToActivityController.php +++ b/app/Http/Controllers/UserToActivityController.php @@ -134,7 +134,39 @@ class UserToActivityController extends Controller }else{ return response()->json(['status'=>'failed','message'=>'failed get list user to activity gantt, please try again later!','code'=>400], 400); } - } + } + + public function listFiltered(Request $request) + { + $startDate = $request->start_date; + $endDate = $request->end_date; + $userId = $request->user_id; + $proyekId = $request->proyek_id; + + if (isset($proyekId)) { + $data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date') + ->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id') + ->where('m_activity.start_date', '=', $startDate) + ->where('m_activity.end_date', '=', $endDate) + ->where('assign_hr_to_activity.user_id', '=', $userId) + ->where('assign_hr_to_activity.proyek_id', '=', $proyekId) + ->get(); + }else { + $data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date') + ->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id') + ->where('m_activity.start_date', '=', $startDate) + ->where('m_activity.end_date', '=', $endDate) + ->where('assign_hr_to_activity.user_id', '=', $userId) + ->get(); + } + $countData = $data->count(); + + if($data){ + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get list user to activity gantt, please try again later!','code'=>400], 400); + } + } public function datatables(Request $request){ $id_activity = $request->query('idact'); diff --git a/routes/web.php b/routes/web.php index 9021ba1..4a66429 100644 --- a/routes/web.php +++ b/routes/web.php @@ -192,6 +192,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); From 5f2d7154dfe12872ec4216ea6858147741327d4b Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 2 Mar 2023 10:27:48 +0700 Subject: [PATCH 119/131] update API Presence and K3 --- app/Http/Controllers/Controller.php | 18 +- app/Http/Controllers/PresenceController.php | 146 +- app/Http/Controllers/ReportK3Controller.php | 15 +- app/Models/HumanResource.php | 1 - rest-client.http | 2218 +++++++++---------- routes/web.php | 1 + 6 files changed, 1258 insertions(+), 1141 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 1ccbf9c..f45ab75 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -3,9 +3,10 @@ namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Http; - use Laravel\Lumen\Routing\Controller as BaseController; +use App\Models\ReportK3Detail; + class Controller extends BaseController { protected $pathImage = "assets/image/"; @@ -211,7 +212,7 @@ class Controller extends BaseController return $query; } - protected function calculateAllCost($activity, $proyek_id){ + protected function calculateAllCost($activity_id, $proyek_id){ $humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id); $materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id); $toolsCostPlanning = 0; @@ -278,4 +279,17 @@ class Controller extends BaseController return json_decode($response); } + + protected function addDetailK3($dataDetail, $report_id){ + foreach ($dataDetail as $value) { + $dataNew = array( + "report_k3_id"=>$report_id, + "checklist_k3_id"=>$value['checklist_id'], + "name_checklist_k3"=>$value['checklist_name'], + "created_by"=>$this->currentName + ); + + ReportK3Detail::create($dataNew); + } + } } diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 3a6e7f5..400c812 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -5,9 +5,7 @@ namespace App\Http\Controllers; use Log; use Illuminate\Http\Request; use App\Models\Presence; -// use App\Models\Activity; -// use GuzzleHttp\Client; -// use Illuminate\Support\Facades\Http; +use App\Models\ReportK3; use Carbon\Carbon; use Illuminate\Support\Facades\DB; @@ -23,9 +21,7 @@ class PresenceController extends Controller $statusBoundary = false; $date = date_create($request->clock_time); // assign and in boundary - if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ - // $checkLocation[0]['status_assign'] ? $statusBoundary = true - // : + if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ $statusBoundary = true; } @@ -124,23 +120,151 @@ class PresenceController extends Controller } } + public function reportK3(Request $request){ + // return response()->json(['status'=>'success', 'message'=>$request->report_k3['detail'],'code'=>200], 200); + + $this->validate($request, [ + 'user_id' => 'required' + ]); + + $dataFormK3 = array( + "user_id" => $request->user_id, + "proyek_id" => $request->report_k3['proyek_id'], + "report_date" => $request->time, + "description" => $request->report_k3['description'] + ); + + $checkLocation = $this->checkLocation($request); + $statusBoundary = false; + $date = date_create($request->time); + // assign and in boundary + if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ + $statusBoundary = true; + } + + // not assign + if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ + $data=array( + 'id' => null, + 'boundary' => $statusBoundary + ); + return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); + } + // assign and not in boundary + if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ + $data=array( + 'id' => null, + 'boundary' => true + ); + return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200); + } + + if($request->clock_in_out['type']=="out"){ + $clock_out_loc = $this->getLoc($request->clock_in_out['clock_out_lat'], $request->clock_in_out['clock_out_lng'])->display_name; + $dataUpdate = array( + "clock_out"=>$request->time, + "clock_out_lat" => $request->clock_in_out['clock_out_lat'], + "clock_out_lng" => $request->clock_in_out['clock_out_lng'], + "updated_by"=>$this->currentName, + "clock_out_loc" => $clock_out_loc, + "clock_out_boundary" => $statusBoundary + ); + + $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); + if($resultUpdate && $resultUpdate > 0){ + if($statusBoundary){ + for ($i=0; $i < count($checkLocation); $i++) { + # code... + DB::table('clock_in_out_boundary')->insert([ + "clock_in_out_id" => $resultUpdate, + "user_id" => $request->user_id, + "activity_id" => $checkLocation[$i]['activity_id'], + "type" => $request->clock_in_out['type'], + "created_at" => $date, + "created_by" => $this->currentName + ]); + }; + }; + $data=array( + 'presence_id' => $resultUpdate, + 'boundary' => $statusBoundary + ); + + return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); + } + else{ + return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); + } + die(); + } + + $onlyDate = date_format($date,"Y-m-d"); + $clock_in_loc = $this->getLoc($request->clock_in_out['clock_in_lat'], $request->clock_in_out['clock_in_lng'])->display_name; + + $dataFormPresence = array( + 'user_id' => $request->user_id, + 'clock_in' => $request->time, + 'date_presence' => $onlyDate, + 'created_by' => $this->currentName, + 'clock_in_lat' => $request->clock_in_out['clock_in_lat'], + 'clock_in_lng' => $request->clock_in_out['clock_in_lng'], + 'clock_in_loc' => $clock_in_loc, + 'clock_in_boundary' => $statusBoundary + ); + + $result = Presence::create($dataFormPresence); + $data=array( + 'presence_id' => $result->id, + 'boundary' => $statusBoundary + ); + if($result){ + if($statusBoundary){ + $insertk3 = $this->insertK3($dataFormK3, $request->report_k3['detail']) ; + for ($i=0; $i < count($checkLocation); $i++) { + # code... + DB::table('clock_in_out_boundary')->insert([ + "clock_in_out_id" => $result->id, + "user_id" => $request->user_id, + "activity_id" => $checkLocation[$i]['activity_id'], + "type" => $request->type, + "created_at" => $date, + "created_by" => $this->currentName + ]); + }; + $data['report_id'] = $insertk3->id; + }; + return response()->json(['status'=>'success', 'data'=> $data, 'message'=>'clock in successfully!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); + } + } + + private function insertK3($params, $details){ + $insert = ReportK3::create($params); + if($insert && $details){ + $this->addDetailK3($details, $insert->id); + } + return $insert; + } + private function checkLocation($params){ // cek user tersebut apakah punya assign task yang ada bondary nya // geom ada di table activity + // $clock_time = $geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id") ->join("m_activity as ma", "ma.id", "=", "ahta.activity_id") ->where("ahta.user_id", $params->user_id) - ->whereDate("ma.start_date", "<=", $params->clock_time) - ->whereDate("ma.end_date", ">=", $params->clock_time) + ->whereDate("ma.start_date", "<=", $params->time) + ->whereDate("ma.end_date", ">=", $params->time) ->get(); $temp = []; if (count($geom) > 0) { foreach($geom as $dataGeom){ $valGeom = json_decode($dataGeom->geom); - if($params->type=="out"){ - $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326)) as boundary")); + if($params->clock_in_out['type']=="out"){ + $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary")); }else{ - $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary")); + $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); } foreach ($check as $key) { // assign and in boundary diff --git a/app/Http/Controllers/ReportK3Controller.php b/app/Http/Controllers/ReportK3Controller.php index 310e435..76db167 100644 --- a/app/Http/Controllers/ReportK3Controller.php +++ b/app/Http/Controllers/ReportK3Controller.php @@ -8,7 +8,7 @@ use App\Models\ReportK3Detail; use App\Models\ProjectToChecklistK3; use App\Models\ChecklistK3; use App\Models\Image; -use DB; +use Illuminate\Support\Facades\DB; class ReportK3Controller extends Controller { @@ -35,19 +35,6 @@ class ReportK3Controller extends Controller return response()->json(['status'=>'failed','message'=>'add data report k3 failed!','code'=>400], 400); } } - - private function addDetailK3($dataDetail, $report_id){ - foreach ($dataDetail as $value) { - $dataNew = array( - "report_k3_id"=>$report_id, - "checklist_k3_id"=>$value['checklist_id'], - "name_checklist_k3"=>$value['checklist_name'], - "created_by"=>$this->currentName - ); - - ReportK3Detail::create($dataNew); - } - } public function edit($id){ if(!$id || (int) $id < 0 || $id==""){ diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 4745a1d..222a835 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -34,6 +34,5 @@ class HumanResource extends Model 'updated_by', 'divisi_id', 'status_boundary' - ]; } diff --git a/rest-client.http b/rest-client.http index 61b3d7a..03878db 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,1113 +1,1105 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NzQ3NzIzMSwiZXhwIjoxNjc4MDgyMDMxLCJuYmYiOjE2Nzc0NzcyMzEsImp0aSI6ImR5WWhRY3ZIbUJEcmFKMG0iLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.9zT6CBbQholzIdQ9ZBDoxMvrR-PKvIYkGzdNB6bim0Y - -@hostname = https://adw-api.ospro.id/api -# @hostname = https://ospro-api.ospro.id/api -# @hostname = https://api-iu.ospro.id/api -# @hostname = https://api-staging-adw.ospro.id/api -# @hostname = http://localhost:8444/api -# @hostname = http://103.73.125.81:8444/api -# @hostname = http://localhost:8444/adw-backend/api - -###### login -POST {{hostname}}/login -# Authorization: Bearer xxx -# X-REQUEST-TYPE: GraphQL 1123150023 -content-type: application/json - -{ - "username": "admin", - "password": "1nt3gr4s14" -} - -###### Tools Req -### add -POST {{hostname}}/req-tools/add -Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvb3Nwcm8tYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjUyODYzNzM4LCJleHAiOjE2NTI5NTAxMzgsIm5iZiI6MTY1Mjg2MzczOCwianRpIjoia2ZwNnhwc0ZZZ0dFNEtGSSIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.f7a0M-GKYgacXtaEmZJUs2UOPFXaigEwGu8OfZ117kI - -content-type: application/json - -{ - "asset_type": "Alat Berat 1", - "asset_name": "Beco", - "required_date":"2021-12-16", - "qty": 10, - "uom": "Kg", - "description": "test Data", - "created_by":"admin", - "proyek_id":1 -} - -### update -PUT {{hostname}}/req-tools/update/3 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "qty": 332, -} - -### search -POST {{hostname}}/req-tools/search -Authorization: Bearer {{token}} -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[ - { - "name":"asset_type", - "logic_operator":"like", - "value":"", - "operator":"AND" - }, - { - "name":"status", - "logic_operator":"<>", - "value":"receipt to site", - "operator":"AND" - } - ], - "joins":[], - "orders":{ - "columns":[ - "id" - ], - "ascending":false - } -} - -### delete -DELETE {{hostname}}/req-tools/delete/13 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - - -###### Menu -### add -POST {{hostname}}/menu/add -Authorization: {{token}} -content-type: application/json - -{ - "alias_name": "Alat Berat 1", - "icon": "#", - "name":"2021-12-16", - "parent_id": 23, - "sequence": 100, - "url": "test Data" -} - -### update -PUT {{hostname}}/req-tools/update/3 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "qty": 332, -} - -### search -POST {{hostname}}/menu/search -Authorization: Bearer {{token}} -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[ - { - "name":"name", - "logic_operator":"like", - "value":"", - "operator":"AND" - } - ], - "joins":[ - { - "name":"m_menu", - "column_join":"parent_id", - "column_results":["name"], - } - ], - "orders":{ - "columns":[ - "id" - ], - "ascending":false - } -} - -### delete -DELETE {{hostname}}/req-tools/delete/13 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - - -###### Material Req -### add -POST {{hostname}}/request-material/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "description": "Lempengan Besi", - "required_date": "2022-05-04", - "qty": "1000", - "uom": "Lembar", - "fom_date": "2022-05-04", - "proyek_id": 29, - "price":10 - } - -### update -PUT {{hostname}}/request-material/update/20 -Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvb3Nwcm8tYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjQyMTE1NjQyLCJleHAiOjE2NDIyMDIwNDIsIm5iZiI6MTY0MjExNTY0MiwianRpIjoiVWt1UjRnZjVUMHQ5YXRQWSIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.ftCrSs5v7GxqxW64ZcfZn40Opxom5YoFcDMMF1TvWrk -Content-Type: application/x-www-form-urlencoded -Accept: application/json - -{ - "description": "Pebble", - "fom_date": "2022-01-12T09:59:26.190Z", - "id": 20, - "po_date": null, - "pr_date": null, - "qty": "10", - "qty_received": "100", - "received_date": null, - "required_date": "2022-01-12T09:59:07.739Z", - "status": "fom", - "uom": "kg" -} - - - -### search -POST {{hostname}}/request-material/search -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[ - { - "name":"description", - "logic_operator":"like", - "value":"", - "operator":"AND" - } - ], - "joins":[], - "orders":{ - "columns":[ - "id" - ], - "ascending":false - } -} - -### delete -DELETE {{hostname}}/request-material/delete/2 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - - -###### Human Resource -### add -POST {{hostname}}/human-resource/add -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "role_id" : 1, - "username" : "ibnu", - "password" : "test", - "name" : "ibnu", - "phone_number" : "083823134569", - "email" : "ibnu@gmail.com", - "address" : "gria pesona madani", - "ktp_number" : "3212141105950004", - "employee_type" : "freelance" -} - -### update -PUT {{hostname}}/human-resource/update/8 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "address" : "gria pesona madani 1" -} - - -### delete -DELETE {{hostname}}/human-resource/delete/8 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -### search -POST {{hostname}}/human-resource/search -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[ - { - "name":"name", - "logic_operator":"like", - "value":"", - "operator":"AND" - } - ], - "joins":[], - "orders":{ - "columns":[ - "id" - ], - "ascending":false - } -} - - -###### Material Resource -### add -POST {{hostname}}/material-resource/add -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "id": 3, - "name": "Batangan Besi", - "uom": "truck", - "unit_price": 500000, - "description": "Pasir", - "qty": 1000 -} - -### update -PUT {{hostname}}/material-resource/update/5 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "uom" : "Batang" -} - - -### delete -DELETE {{hostname}}/material-resource/delete/5 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -### search -POST {{hostname}}/material-resource/search -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[ - { - "name":"name", - "logic_operator":"like", - "value":"", - "operator":"AND" - } - ], - "joins":[], - "orders":{ - "columns":[ - "id" - ], - "ascending":false - } -} - - -###### Tools Resource -### add -POST {{hostname}}/tools-resource/add -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "name": "Excavator Belco", - "description": "Excavator Belco", - "uom":"unit", - "qty": "100", - "asset_type": "Alat Berat" -} - -### update -PUT {{hostname}}/tools-resource/update/5 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "name" : "Excavator Kobelco" -} - - -### delete -DELETE {{hostname}}/tools-resource/delete/5 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -### search -POST {{hostname}}/tools-resource/search -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[ - { - "name":"name", - "logic_operator":"like", - "value":"", - "operator":"AND" - } - ], - "joins":[], - "orders":{ - "columns":[ - "id" - ], - "ascending":false - } -} - - -###### Project - -### list -GET {{hostname}}/project/list -Authorization: Bearer {{token}} -content-type: application/json - - -### add -POST {{hostname}}/project/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "nama": "Excavator Belco", - "keterangan": "Excavator Belco", - "mulai_proyek":"2022/01/11", - "akhir_proyek": "2022/05/11" -} - -### update -PUT {{hostname}}/project/update/5 -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "name" : "Excavator Kobelco" -} - - -### delete -DELETE {{hostname}}/project/delete/19 -Authorization: Bearer {{token}} -content-type: application/json - -### search -POST {{hostname}}/tools-resource/search -Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[ - { - "name":"name", - "logic_operator":"like", - "value":"", - "operator":"AND" - } - ], - "joins":[], - "orders":{ - "columns":[ - "id" - ], - "ascending":false - } -} - -### dashboard -GET {{hostname}}/project/dashboard/47 -Authorization: Bearer {{token}} -content-type: application/json - - -###### Divisi - -### list -GET {{hostname}}/divisi/list -Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvb3Nwcm8tYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjQxNDYwNDcyLCJleHAiOjE2NDE0NjQwNzIsIm5iZiI6MTY0MTQ2MDQ3MiwianRpIjoiRjRxYmJ3U25YcEw0OXN0QyIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.CLm_ZOEW5GCyGJuIcRNIRD8m1XxIeSCH60QK2HxF8d0 -content-type: application/json - - - -###### Activity -### get data by id version -GET {{hostname}}/activity/33/29/get -Authorization: Bearer {{token}} -content-type: application/json - -###### Rate Sallary - -### list -GET {{hostname}}/project-role/list -Authorization: Bearer {{token}} -content-type: application/json - - - -###### Rate Sallary - -### list -GET {{hostname}}/rate-sallary/list -Authorization: Bearer {{token}} -content-type: application/json - - -### add -POST {{hostname}}/rate-sallary/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_role_id" : 4, - "cost" : 2000, - "type_rate" : "UMR Jatim" -} - -### update -PUT {{hostname}}/rate-sallary/update/{id} -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_role_id" : 4, - "cost" : 2000, - "type_rate" : "UMR Jatim" -} - -### delete -POST {{hostname}}/rate-sallary/delete/{id} -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_role_id" : 4, - "cost" : 2000, - "type_rate" : "UMR Jatim" -} - - - -### search -POST {{hostname}}/dashboard/percentage-planning-actual -Authorization: Bearer {{token}} -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[ - { - "name":"proyek_id", - "logic_operator":"in", - "value":[7,6,4], - "operator":"AND" - }, - { - "name":"version_gantt_id", - "logic_operator":"=", - "value":3, - "operator":"AND" - } - ], - "joins":[], - "orders":{ - "columns":[ - "proyek_id" - ], - "ascending":true - } -} - - -### -POST {{hostname}}/dashboard/cost-planning-actual -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_id" : [11] -} - - -### -POST {{hostname}}/dashboard/percentage-planning-actual -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_id" : [11] -} - - -###### project participants -### add -POST {{hostname}}/project-participants/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "proyek_id" : 11, - "tittle" : "investor", - "name" : "ibnu" -} - - -# get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit'); -### update -# PUT {{hostname}}//project-participants/update/11 - -# POST {{hostname}}/project-participants/search -# DELETE {{hostname}}/project-participants/delete/{id} -# GET {{hostname}}/project-participants/list - -### -GET {{hostname}}/project-participants/list -Authorization: Bearer {{token}} -content-type: application/json - - -### -GET {{hostname}}/project-participants/proyek_id/11 -Authorization: Bearer {{token}} -content-type: application/json - -### -DELETE {{hostname}}/project-participants/delete/1 -Authorization: Bearer {{token}} -content-type: application/json - -### -DELETE {{hostname}}/project-participants/delete-by-proyek/7 -Authorization: Bearer {{token}} -content-type: application/json - -###### project-approval -POST {{hostname}}/project-approval/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "proyek_id" : 7, - "tittle" : "investor", - "name" : "koko", - "date_approval" : "2022/01/21" -} - -### -get {{hostname}}/project-approval/edit/{id} - - -put {{hostname}}/project-approval/update/{id} -post {{hostname}}/project-approval/search -delete {{hostname}}/project-approval/delete/{id} -get {{hostname}}/project-approval/list - -###### project-milestone -post {{hostname}}/project-milestone/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "proyek_id" : 7, - "status" : "Build 2. Finish eksekusi", - "due_date" : "2022/01/21", - "deadline" : "2022/01/21" -} - -### -get {{hostname}}/project-milestone/edit/{id} -put {{hostname}}/project-milestone/update/{id} -post {{hostname}}/project-milestone/search -delete {{hostname}}/project-milestone/delete/{id} -get {{hostname}}/project-milestone/list -get {{hostname}}/project-milestone/select - - -### -GET {{hostname}}/template-gantt/get-tree/3 -Authorization: Bearer {{token}} -content-type: application/json - -### -POST {{hostname}}/folder-document-proyek/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "proyek_id": "12", - "name_folder": "test 1", - "parent_id" : 1 -} - - -### -GET {{hostname}}/folder-document-proyek/list -Authorization: Bearer {{token}} -content-type: application/json - - -### -GET {{hostname}}/folder-document-proyek/get-tree/12 -Authorization: Bearer {{token}} -content-type: application/json - - - -### -POST {{hostname}}/human-resource/select -Authorization: Bearer {{token}} -content-type: application/json - -{ - "idact" : "362", - "idProyek": "11" -} - - -### -POST https://ospro-api.ospro.id/api/dashboard/status-proyek -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_id": [11] -} - - -### -POST {{hostname}}/activity/get-percentage -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_id": [11] -} - - -### -POST {{hostname}}/activity/get-curva-s -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_id": [47], - "period": "week" -} - - -### -POST {{hostname}}/dashboard/curva-s -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_id": [15] -} - -### -GET https://adw-api.ospro.id/api/request-material/get-material-integration?name=c -Authorization: Bearer {{token}} -content-type: application/json - -### -POST {{hostname}}/presence/search -Authorization: Bearer {{token}} -content-type: application/json - -{ - "paging":{ - "start":0, - "length":10 - }, - "columns":[], - "joins": [ - { - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "username", - "name" - ] - } - ], - "orders":{ - "columns":[ - "id" - ], - "ascending":true - } -} - - -### -POST {{hostname}}/report-k3/search -Authorization: Bearer {{token}} -content-type: application/json - -{ - "paging": { - "start": 0, - "length": 10 - }, - "filter_columns": [ - { - "name": "name", - "value": "", - "table_name": "m_users" - } - ], - "columns": [ - { - "name": "report_date", - "logic_operator": "range", - "value": "2023-02-21 00:00:00", - "value1": "2023-02-21 23:59:59", - "operator": "AND" - }, - { - "name": "name", - "logic_operator": "ilike", - "value": "", - "operator": "AND", - "table_name": "m_users" - }, - { - "name": "proyek_id", - "logic_operator": "in", - "value": [ - 80, - 79, - 78, - 76, - 75, - 74, - 73, - 72, - 71, - 66, - 64, - 63, - 62, - 58, - 57, - 49, - 48, - 47, - 37, - 31 - ] - } - ], - "joins": [ - { - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "name" - ] - }, - { - "name": "m_proyek", - "column_join": "proyek_id", - "column_results": [ - "nama" - ] - } - ], - "orders": { - "columns": [ - "id" - ], - "ascending": false - }, - "child_data": { - "table_name": "t_report_k3_detail", - "column_table": "report_k3_id", - "column_name": "id" - } -} - - - -### -POST {{hostname}}/assign-material/ForReportActivityByMaterial -Authorization: Bearer {{token}} -content-type: application/json - -{ - "idact": 387 -} - - -###### -GET {{hostname}}/presence/clockinout/262 -Authorization: Bearer {{token}} -content-type: application/json - -###### -POST {{hostname}}/presence/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "clock_in_lat": -6.16678379060529, - "clock_in_lng": 106.9175039866567, - "clock_time": "2023-02-16T14:48:17+07:00", - "type": "in", - "user_id": 1247 -} - -###### -POST {{hostname}}/presence/add -Authorization: Bearer {{token}} -content-type: application/json - -{ - "clock_in_lat": -1.4264273154149407, - "clock_in_lng": 113.98530036945851, - "clock_time": "2023-02-13T16:40:17+07:00", - "type": "in", - "user_id": 1 -} - -###### -# POST {{hostname}}/ -GET {{hostname}}/assign-material/datatablesForReportActivity?draw=2&columns[0][data]=material_name&columns[0][name]=material_name&columns[0][searchable]=true&columns[0][orderable]=true&columns[0][search][value]=&columns[0][search][regex]=false&columns[1][data]=type&columns[1][name]=type&columns[1][searchable]=true&columns[1][orderable]=true&columns[1][search][value]=&columns[1][search][regex]=false&columns[2][data]=qty_planning&columns[2][name]=&columns[2][searchable]=true&columns[2][orderable]=true&columns[2][search][value]=&columns[2][search][regex]=false&columns[3][data]=qty_sum&columns[3][name]=&columns[3][searchable]=true&columns[3][orderable]=true&columns[3][search][value]=&columns[3][search][regex]=false&columns[4][data]=uom&columns[4][name]=uom&columns[4][searchable]=true&columns[4][orderable]=true&columns[4][search][value]=&columns[4][search][regex]=false&columns[5][data]=action&columns[5][name]=action&columns[5][searchable]=true&columns[5][orderable]=true&columns[5][search][value]=&columns[5][search][regex]=false&order[0][column]=0&order[0][dir]=asc&start=0&length=10&search[value]=&search[regex]=false&idact=2511&_=1675418553660 -Authorization: Bearer {{token}} -content-type: application/json - -###### -GET {{hostname}}/dashboard/get-total-project-per-schedule-health -Authorization: Bearer {{token}} -content-type: application/json - -###### -GET {{hostname}}/dashboard/get-detail-expenditure -Authorization: Bearer {{token}} -content-type: application/json - - -###### -GET {{hostname}}/presence/bulk-update-location -Authorization: Bearer {{token}} -content-type: application/json - - -##### -GET https://nominatim.oslogdev.com/reverse?lat=-6.2622811&lon=106.7881746&format=json - -###### - -POST {{hostname}}/waypoint/add -Authorization: Bearer {{token}} -content-type: application/json -{ - "user_id": 1247, - "lat": -6.2622811, - "lng": 106.7881746, - "wptime": "2023-02-07T10:40:17+07:00", - "speed": 0, - "angle": 0, - "satelite": 0 -} - -###### -POST {{hostname}}/map-monitoring/search -Authorization: Bearer {{token}} -content-type: application/json - -{ - "project_id" : [75, 76, 78] -} - -###### -POST {{hostname}}/waypoint/add-bulk -Authorization: Bearer {{token}} -content-type: application/json - -{ - "wp_records": [ - { - "user_id": 1247, - "lon": 106.88702067952579, - "lat": -6.193331793510694, - "wptime": "2023-02-07T10:40:17+07:00", - "speed": 0, - "angle": 0, - "satelite": 0, - "datesend": "2023-02-07T10:40:17+07:00" - }, - { - "user_id": 1247, - "lon": 106.88731982052337, - "lat": -6.1933255977790225, - "wptime": "2023-02-07T10:41:17+07:00", - "speed": 0, - "angle": 0, - "satelite": 0, - "datesend": "2023-02-07T10:41:17+07:00" - }, - { - "user_id": 1247, - "lon": 106.88765896352822, - "lat": -6.193328086924183, - "wptime": "2023-02-07T10:42:17+07:00", - "speed": 0, - "angle": 0, - "satelite": 0, - "datesend": "2023-02-07T10:42:17+07:00" - }, - { - "user_id": 1247, - "lon": 106.88812637133634, - "lat": -6.1933373805197505, - "wptime": "2023-02-07T10:43:17+07:00", - "speed": 0, - "angle": 0, - "satelite": 0, - "datesend": "2023-02-07T10:43:17+07:00" - }, - { - "user_id": 1247, - "lon": 106.88867721532353, - "lat": -6.1933448515770095, - "wptime": "2023-02-07T10:44:17+07:00", - "speed": 0, - "angle": 0, - "satelite": 0, - "datesend": "2023-02-07T10:44:17+07:00" - } - ] -} - -##### -POST {{hostname}}/map-monitoring/search -Authorization: Bearer {{token}} -content-type: application/json - -{ - "time_from": "2023-02-10 00:00:00", - "time_to": "2023-02-10 23:59:00", -} - -# { -# "columns": [ -# { -# "logic_operator": "range", -# "name": "created_at", -# "operator": "AND", -# "value": "2023-02-10 00:00:00", -# "value1": "2023-02-10 23:59:00" -# } -# ], -# "joins": [ -# { -# "column_join": "user_id", -# "column_results": [ -# "username", "name" -# ], -# "name": "m_users" -# } -# ], -# "orders": { -# "ascending": false, -# "columns": [ -# "created_at" -# ] -# }, -# "paging": { -# "length": 25, -# "start": 0 -# } -# } - - -<<<<<<< HEAD -GET /stock_master?name=SEARCH - -###### -GET {{hostname}}/request-material/get-material-integration -Authorization: Bearer {{token}} -content-type: application/json - - -###### -POST {{hostname}}/presence/reportk3 -Authorization: Bearer {{token}} -content-type: application/json - -{ - "time" : "2023-02-16T14:48:17+07:00", // untuk report date, time_clockin/out - "user_id": 1247, - "clock_in_out": { - "clock_in_lat": -6.16678379060529, - "clock_in_lng": 106.9175039866567, - "type": "in" - }, - "report_k3": { - "proyek_id": "", - "description": "", - "detail": [{ - "checklist_id": 1, - "checklist_name": "" - }, - { - "checklist_id": 2, - "checklist_name": "" - }] - - } -} -======= -### get image -# GET {{hostname}}/image/106/presensi -GET {{hostname}}/image/1634/report_activity -Authorization: Bearer {{token}} -content-type: application/json - ->>>>>>> e18d0c3c5b06faa60a69b484259ec0102546422f +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NzQ3NzIzMSwiZXhwIjoxNjc4MDgyMDMxLCJuYmYiOjE2Nzc0NzcyMzEsImp0aSI6ImR5WWhRY3ZIbUJEcmFKMG0iLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.9zT6CBbQholzIdQ9ZBDoxMvrR-PKvIYkGzdNB6bim0Y + +@hostname = https://adw-api.ospro.id/api +# @hostname = https://ospro-api.ospro.id/api +# @hostname = https://api-iu.ospro.id/api +# @hostname = https://api-staging-adw.ospro.id/api +# @hostname = http://localhost:8444/api +# @hostname = http://103.73.125.81:8444/api +# @hostname = http://localhost:8444/adw-backend/api + +###### login +POST {{hostname}}/login +# Authorization: Bearer xxx +# X-REQUEST-TYPE: GraphQL 1123150023 +content-type: application/json + +{ + "username": "admin", + "password": "1nt3gr4s14" +} + +###### Tools Req +### add +POST {{hostname}}/req-tools/add +Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvb3Nwcm8tYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjUyODYzNzM4LCJleHAiOjE2NTI5NTAxMzgsIm5iZiI6MTY1Mjg2MzczOCwianRpIjoia2ZwNnhwc0ZZZ0dFNEtGSSIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.f7a0M-GKYgacXtaEmZJUs2UOPFXaigEwGu8OfZ117kI + +content-type: application/json + +{ + "asset_type": "Alat Berat 1", + "asset_name": "Beco", + "required_date":"2021-12-16", + "qty": 10, + "uom": "Kg", + "description": "test Data", + "created_by":"admin", + "proyek_id":1 +} + +### update +PUT {{hostname}}/req-tools/update/3 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "qty": 332, +} + +### search +POST {{hostname}}/req-tools/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[ + { + "name":"asset_type", + "logic_operator":"like", + "value":"", + "operator":"AND" + }, + { + "name":"status", + "logic_operator":"<>", + "value":"receipt to site", + "operator":"AND" + } + ], + "joins":[], + "orders":{ + "columns":[ + "id" + ], + "ascending":false + } +} + +### delete +DELETE {{hostname}}/req-tools/delete/13 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + + +###### Menu +### add +POST {{hostname}}/menu/add +Authorization: {{token}} +content-type: application/json + +{ + "alias_name": "Alat Berat 1", + "icon": "#", + "name":"2021-12-16", + "parent_id": 23, + "sequence": 100, + "url": "test Data" +} + +### update +PUT {{hostname}}/req-tools/update/3 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "qty": 332, +} + +### search +POST {{hostname}}/menu/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[ + { + "name":"name", + "logic_operator":"like", + "value":"", + "operator":"AND" + } + ], + "joins":[ + { + "name":"m_menu", + "column_join":"parent_id", + "column_results":["name"], + } + ], + "orders":{ + "columns":[ + "id" + ], + "ascending":false + } +} + +### delete +DELETE {{hostname}}/req-tools/delete/13 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + + +###### Material Req +### add +POST {{hostname}}/request-material/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "description": "Lempengan Besi", + "required_date": "2022-05-04", + "qty": "1000", + "uom": "Lembar", + "fom_date": "2022-05-04", + "proyek_id": 29, + "price":10 + } + +### update +PUT {{hostname}}/request-material/update/20 +Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvb3Nwcm8tYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjQyMTE1NjQyLCJleHAiOjE2NDIyMDIwNDIsIm5iZiI6MTY0MjExNTY0MiwianRpIjoiVWt1UjRnZjVUMHQ5YXRQWSIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.ftCrSs5v7GxqxW64ZcfZn40Opxom5YoFcDMMF1TvWrk +Content-Type: application/x-www-form-urlencoded +Accept: application/json + +{ + "description": "Pebble", + "fom_date": "2022-01-12T09:59:26.190Z", + "id": 20, + "po_date": null, + "pr_date": null, + "qty": "10", + "qty_received": "100", + "received_date": null, + "required_date": "2022-01-12T09:59:07.739Z", + "status": "fom", + "uom": "kg" +} + + + +### search +POST {{hostname}}/request-material/search +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[ + { + "name":"description", + "logic_operator":"like", + "value":"", + "operator":"AND" + } + ], + "joins":[], + "orders":{ + "columns":[ + "id" + ], + "ascending":false + } +} + +### delete +DELETE {{hostname}}/request-material/delete/2 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + + +###### Human Resource +### add +POST {{hostname}}/human-resource/add +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "role_id" : 1, + "username" : "ibnu", + "password" : "test", + "name" : "ibnu", + "phone_number" : "083823134569", + "email" : "ibnu@gmail.com", + "address" : "gria pesona madani", + "ktp_number" : "3212141105950004", + "employee_type" : "freelance" +} + +### update +PUT {{hostname}}/human-resource/update/8 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "address" : "gria pesona madani 1" +} + + +### delete +DELETE {{hostname}}/human-resource/delete/8 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +### search +POST {{hostname}}/human-resource/search +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[ + { + "name":"name", + "logic_operator":"like", + "value":"", + "operator":"AND" + } + ], + "joins":[], + "orders":{ + "columns":[ + "id" + ], + "ascending":false + } +} + + +###### Material Resource +### add +POST {{hostname}}/material-resource/add +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "id": 3, + "name": "Batangan Besi", + "uom": "truck", + "unit_price": 500000, + "description": "Pasir", + "qty": 1000 +} + +### update +PUT {{hostname}}/material-resource/update/5 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "uom" : "Batang" +} + + +### delete +DELETE {{hostname}}/material-resource/delete/5 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +### search +POST {{hostname}}/material-resource/search +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[ + { + "name":"name", + "logic_operator":"like", + "value":"", + "operator":"AND" + } + ], + "joins":[], + "orders":{ + "columns":[ + "id" + ], + "ascending":false + } +} + + +###### Tools Resource +### add +POST {{hostname}}/tools-resource/add +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "name": "Excavator Belco", + "description": "Excavator Belco", + "uom":"unit", + "qty": "100", + "asset_type": "Alat Berat" +} + +### update +PUT {{hostname}}/tools-resource/update/5 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "name" : "Excavator Kobelco" +} + + +### delete +DELETE {{hostname}}/tools-resource/delete/5 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +### search +POST {{hostname}}/tools-resource/search +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[ + { + "name":"name", + "logic_operator":"like", + "value":"", + "operator":"AND" + } + ], + "joins":[], + "orders":{ + "columns":[ + "id" + ], + "ascending":false + } +} + + +###### Project + +### list +GET {{hostname}}/project/list +Authorization: Bearer {{token}} +content-type: application/json + + +### add +POST {{hostname}}/project/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "nama": "Excavator Belco", + "keterangan": "Excavator Belco", + "mulai_proyek":"2022/01/11", + "akhir_proyek": "2022/05/11" +} + +### update +PUT {{hostname}}/project/update/5 +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "name" : "Excavator Kobelco" +} + + +### delete +DELETE {{hostname}}/project/delete/19 +Authorization: Bearer {{token}} +content-type: application/json + +### search +POST {{hostname}}/tools-resource/search +Authorization: Bearer dFWBXe6qQQm_s4DyH68yVt:APA91bFTms-pjqm-9OkugufLF2yjtOTJZQBlVxY8FC5iYq3owmWzGZtlPSSHholMeUxeE0TRQ6pFfEKvy5xRHnufPu4dJNiY-2gRGHKch6o4iWU9gp3GDHQ7sm-ySsE9keCMKzmQ11aM +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[ + { + "name":"name", + "logic_operator":"like", + "value":"", + "operator":"AND" + } + ], + "joins":[], + "orders":{ + "columns":[ + "id" + ], + "ascending":false + } +} + +### dashboard +GET {{hostname}}/project/dashboard/47 +Authorization: Bearer {{token}} +content-type: application/json + + +###### Divisi + +### list +GET {{hostname}}/divisi/list +Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvb3Nwcm8tYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjQxNDYwNDcyLCJleHAiOjE2NDE0NjQwNzIsIm5iZiI6MTY0MTQ2MDQ3MiwianRpIjoiRjRxYmJ3U25YcEw0OXN0QyIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.CLm_ZOEW5GCyGJuIcRNIRD8m1XxIeSCH60QK2HxF8d0 +content-type: application/json + + + +###### Activity +### get data by id version +GET {{hostname}}/activity/33/29/get +Authorization: Bearer {{token}} +content-type: application/json + +###### Rate Sallary + +### list +GET {{hostname}}/project-role/list +Authorization: Bearer {{token}} +content-type: application/json + + + +###### Rate Sallary + +### list +GET {{hostname}}/rate-sallary/list +Authorization: Bearer {{token}} +content-type: application/json + + +### add +POST {{hostname}}/rate-sallary/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_role_id" : 4, + "cost" : 2000, + "type_rate" : "UMR Jatim" +} + +### update +PUT {{hostname}}/rate-sallary/update/{id} +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_role_id" : 4, + "cost" : 2000, + "type_rate" : "UMR Jatim" +} + +### delete +POST {{hostname}}/rate-sallary/delete/{id} +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_role_id" : 4, + "cost" : 2000, + "type_rate" : "UMR Jatim" +} + + + +### search +POST {{hostname}}/dashboard/percentage-planning-actual +Authorization: Bearer {{token}} +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[ + { + "name":"proyek_id", + "logic_operator":"in", + "value":[7,6,4], + "operator":"AND" + }, + { + "name":"version_gantt_id", + "logic_operator":"=", + "value":3, + "operator":"AND" + } + ], + "joins":[], + "orders":{ + "columns":[ + "proyek_id" + ], + "ascending":true + } +} + + +### +POST {{hostname}}/dashboard/cost-planning-actual +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_id" : [11] +} + + +### +POST {{hostname}}/dashboard/percentage-planning-actual +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_id" : [11] +} + + +###### project participants +### add +POST {{hostname}}/project-participants/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "proyek_id" : 11, + "tittle" : "investor", + "name" : "ibnu" +} + + +# get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit'); +### update +# PUT {{hostname}}//project-participants/update/11 + +# POST {{hostname}}/project-participants/search +# DELETE {{hostname}}/project-participants/delete/{id} +# GET {{hostname}}/project-participants/list + +### +GET {{hostname}}/project-participants/list +Authorization: Bearer {{token}} +content-type: application/json + + +### +GET {{hostname}}/project-participants/proyek_id/11 +Authorization: Bearer {{token}} +content-type: application/json + +### +DELETE {{hostname}}/project-participants/delete/1 +Authorization: Bearer {{token}} +content-type: application/json + +### +DELETE {{hostname}}/project-participants/delete-by-proyek/7 +Authorization: Bearer {{token}} +content-type: application/json + +###### project-approval +POST {{hostname}}/project-approval/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "proyek_id" : 7, + "tittle" : "investor", + "name" : "koko", + "date_approval" : "2022/01/21" +} + +### +get {{hostname}}/project-approval/edit/{id} + + +put {{hostname}}/project-approval/update/{id} +post {{hostname}}/project-approval/search +delete {{hostname}}/project-approval/delete/{id} +get {{hostname}}/project-approval/list + +###### project-milestone +post {{hostname}}/project-milestone/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "proyek_id" : 7, + "status" : "Build 2. Finish eksekusi", + "due_date" : "2022/01/21", + "deadline" : "2022/01/21" +} + +### +get {{hostname}}/project-milestone/edit/{id} +put {{hostname}}/project-milestone/update/{id} +post {{hostname}}/project-milestone/search +delete {{hostname}}/project-milestone/delete/{id} +get {{hostname}}/project-milestone/list +get {{hostname}}/project-milestone/select + + +### +GET {{hostname}}/template-gantt/get-tree/3 +Authorization: Bearer {{token}} +content-type: application/json + +### +POST {{hostname}}/folder-document-proyek/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "proyek_id": "12", + "name_folder": "test 1", + "parent_id" : 1 +} + + +### +GET {{hostname}}/folder-document-proyek/list +Authorization: Bearer {{token}} +content-type: application/json + + +### +GET {{hostname}}/folder-document-proyek/get-tree/12 +Authorization: Bearer {{token}} +content-type: application/json + + + +### +POST {{hostname}}/human-resource/select +Authorization: Bearer {{token}} +content-type: application/json + +{ + "idact" : "362", + "idProyek": "11" +} + + +### +POST https://ospro-api.ospro.id/api/dashboard/status-proyek +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_id": [11] +} + + +### +POST {{hostname}}/activity/get-percentage +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_id": [11] +} + + +### +POST {{hostname}}/activity/get-curva-s +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_id": [47], + "period": "week" +} + + +### +POST {{hostname}}/dashboard/curva-s +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_id": [15] +} + +### +GET https://adw-api.ospro.id/api/request-material/get-material-integration?name=c +Authorization: Bearer {{token}} +content-type: application/json + +### +POST {{hostname}}/presence/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "paging":{ + "start":0, + "length":10 + }, + "columns":[], + "joins": [ + { + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "username", + "name" + ] + } + ], + "orders":{ + "columns":[ + "id" + ], + "ascending":true + } +} + + +### +POST {{hostname}}/report-k3/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "paging": { + "start": 0, + "length": 10 + }, + "filter_columns": [ + { + "name": "name", + "value": "", + "table_name": "m_users" + } + ], + "columns": [ + { + "name": "report_date", + "logic_operator": "range", + "value": "2023-02-21 00:00:00", + "value1": "2023-02-21 23:59:59", + "operator": "AND" + }, + { + "name": "name", + "logic_operator": "ilike", + "value": "", + "operator": "AND", + "table_name": "m_users" + }, + { + "name": "proyek_id", + "logic_operator": "in", + "value": [ + 80, + 79, + 78, + 76, + 75, + 74, + 73, + 72, + 71, + 66, + 64, + 63, + 62, + 58, + 57, + 49, + 48, + 47, + 37, + 31 + ] + } + ], + "joins": [ + { + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name" + ] + }, + { + "name": "m_proyek", + "column_join": "proyek_id", + "column_results": [ + "nama" + ] + } + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + }, + "child_data": { + "table_name": "t_report_k3_detail", + "column_table": "report_k3_id", + "column_name": "id" + } +} + + + +### +POST {{hostname}}/assign-material/ForReportActivityByMaterial +Authorization: Bearer {{token}} +content-type: application/json + +{ + "idact": 387 +} + + +###### +GET {{hostname}}/presence/clockinout/262 +Authorization: Bearer {{token}} +content-type: application/json + +###### +POST {{hostname}}/presence/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "clock_in_lat": -6.16678379060529, + "clock_in_lng": 106.9175039866567, + "clock_time": "2023-02-16T14:48:17+07:00", + "type": "in", + "user_id": 1247 +} + +###### +POST {{hostname}}/presence/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "clock_in_lat": -1.4264273154149407, + "clock_in_lng": 113.98530036945851, + "clock_time": "2023-02-13T16:40:17+07:00", + "type": "in", + "user_id": 1 +} + +###### +# POST {{hostname}}/ +GET {{hostname}}/assign-material/datatablesForReportActivity?draw=2&columns[0][data]=material_name&columns[0][name]=material_name&columns[0][searchable]=true&columns[0][orderable]=true&columns[0][search][value]=&columns[0][search][regex]=false&columns[1][data]=type&columns[1][name]=type&columns[1][searchable]=true&columns[1][orderable]=true&columns[1][search][value]=&columns[1][search][regex]=false&columns[2][data]=qty_planning&columns[2][name]=&columns[2][searchable]=true&columns[2][orderable]=true&columns[2][search][value]=&columns[2][search][regex]=false&columns[3][data]=qty_sum&columns[3][name]=&columns[3][searchable]=true&columns[3][orderable]=true&columns[3][search][value]=&columns[3][search][regex]=false&columns[4][data]=uom&columns[4][name]=uom&columns[4][searchable]=true&columns[4][orderable]=true&columns[4][search][value]=&columns[4][search][regex]=false&columns[5][data]=action&columns[5][name]=action&columns[5][searchable]=true&columns[5][orderable]=true&columns[5][search][value]=&columns[5][search][regex]=false&order[0][column]=0&order[0][dir]=asc&start=0&length=10&search[value]=&search[regex]=false&idact=2511&_=1675418553660 +Authorization: Bearer {{token}} +content-type: application/json + +###### +GET {{hostname}}/dashboard/get-total-project-per-schedule-health +Authorization: Bearer {{token}} +content-type: application/json + +###### +GET {{hostname}}/dashboard/get-detail-expenditure +Authorization: Bearer {{token}} +content-type: application/json + + +###### +GET {{hostname}}/presence/bulk-update-location +Authorization: Bearer {{token}} +content-type: application/json + + +##### +GET https://nominatim.oslogdev.com/reverse?lat=-6.2622811&lon=106.7881746&format=json + +###### + +POST {{hostname}}/waypoint/add +Authorization: Bearer {{token}} +content-type: application/json +{ + "user_id": 1247, + "lat": -6.2622811, + "lng": 106.7881746, + "wptime": "2023-02-07T10:40:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0 +} + +###### +POST {{hostname}}/map-monitoring/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "project_id" : [75, 76, 78] +} + +###### +POST {{hostname}}/waypoint/add-bulk +Authorization: Bearer {{token}} +content-type: application/json + +{ + "wp_records": [ + { + "user_id": 1247, + "lon": 106.88702067952579, + "lat": -6.193331793510694, + "wptime": "2023-02-07T10:40:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:40:17+07:00" + }, + { + "user_id": 1247, + "lon": 106.88731982052337, + "lat": -6.1933255977790225, + "wptime": "2023-02-07T10:41:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:41:17+07:00" + }, + { + "user_id": 1247, + "lon": 106.88765896352822, + "lat": -6.193328086924183, + "wptime": "2023-02-07T10:42:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:42:17+07:00" + }, + { + "user_id": 1247, + "lon": 106.88812637133634, + "lat": -6.1933373805197505, + "wptime": "2023-02-07T10:43:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:43:17+07:00" + }, + { + "user_id": 1247, + "lon": 106.88867721532353, + "lat": -6.1933448515770095, + "wptime": "2023-02-07T10:44:17+07:00", + "speed": 0, + "angle": 0, + "satelite": 0, + "datesend": "2023-02-07T10:44:17+07:00" + } + ] +} + +##### +POST {{hostname}}/map-monitoring/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "time_from": "2023-02-10 00:00:00", + "time_to": "2023-02-10 23:59:00", +} + +# { +# "columns": [ +# { +# "logic_operator": "range", +# "name": "created_at", +# "operator": "AND", +# "value": "2023-02-10 00:00:00", +# "value1": "2023-02-10 23:59:00" +# } +# ], +# "joins": [ +# { +# "column_join": "user_id", +# "column_results": [ +# "username", "name" +# ], +# "name": "m_users" +# } +# ], +# "orders": { +# "ascending": false, +# "columns": [ +# "created_at" +# ] +# }, +# "paging": { +# "length": 25, +# "start": 0 +# } +# } + + +<<<<<<< HEAD +GET /stock_master?name=SEARCH + +###### +GET {{hostname}}/request-material/get-material-integration +Authorization: Bearer {{token}} +content-type: application/json + + +###### +POST {{hostname}}/presence/reportk3 +Authorization: Bearer {{token}} +content-type: application/json + +{ + "time" : "2023-02-16T14:48:17+07:00", // untuk report date, time_clockin/out + "user_id": 1247, + "clock_in_out": { + "clock_in_lat": -6.16678379060529, + "clock_in_lng": 106.9175039866567, + "type": "in" + }, + "report_k3": { + "proyek_id": "", + "description": "", + "detail": [{ + "checklist_id": 1, + "checklist_name": "" + }, + { + "checklist_id": 2, + "checklist_name": "" + }] + + } +} diff --git a/routes/web.php b/routes/web.php index 57e03bc..49cc04b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -230,6 +230,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); From d25be9309daf3c8afb5d56c41f2055b64f43c3a1 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 2 Mar 2023 14:32:48 +0700 Subject: [PATCH 120/131] Adding import activity --- app/Http/Controllers/ActivityController.php | 108 +++++++++++++++++++- app/Models/Activity.php | 6 +- routes/web.php | 1 + 3 files changed, 111 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 561c767..4fedaf9 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -6,6 +6,7 @@ use App\Models\CommentActivity; use App\Models\Link; use App\Models\Project; use App\Models\TemplateGantt; +use App\Models\VersionGantt; use App\Models\UserToActivity; use Illuminate\Http\Request; @@ -277,7 +278,112 @@ 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) + { + $data = $request->all(); + + $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']); + + $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); + } + $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; + } + + $activity->level = $activity_row['level']; + + 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); + } + } + + $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']; + + if (@$activityStack[count($activityStack) - 1]->level != $activity->level && $activity->level != $data['activities'][$i - 1]['level']) { + array_push($activityStack, $activity); + } + + if ($activity->level < @$data['activities'][$i + 1]['level']) { + unset($activity->level); + $activity->type_activity = "project"; + $activity->save(); + $activity->level = $activity_row['level']; + } + + 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); + } } diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 7ee841a..4c436d8 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -63,9 +63,9 @@ class Activity extends Model $data->updatePersentaseProgress(); $data->updateCostActual(); } - if($data->start_date != request()->start_date || $data->end_date != request()->end_date) { - $data->updateStartEndDateHeader(); - } + // if($data->start_date != request()->start_date || $data->end_date != request()->end_date) { + // $data->updateStartEndDateHeader(); + // } }); static::deleted(function($data) { diff --git a/routes/web.php b/routes/web.php index b102e41..8d6f568 100644 --- a/routes/web.php +++ b/routes/web.php @@ -200,6 +200,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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'); From e32e51fc22a6324bf5494574451a5f6b42973c7d Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Fri, 3 Mar 2023 10:54:49 +0700 Subject: [PATCH 121/131] Fix project list --- app/Http/Controllers/ProjectController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 6a14f1a..623613d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -245,7 +245,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 = $d->rencana_biaya - $rootActivity->biaya_actual; + $costVariance = (int)$d->rencana_biaya - $rootActivity->biaya_actual ?? 0; $actualCost = $rootActivity->biaya_actual ?? 0; $progress = $rootActivity->persentase_progress ?? 0; @@ -263,7 +263,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 = $d->rencana_biaya; + $d->plannedCost = (int)$d->rencana_biaya; $d->actualCost = $actualCost; $d->lastActivity = $lastActivity ?? "-"; $d->costVariance = $costVariance; From 15d220ccdf4712d8b80e08f053188c1df6b773c0 Mon Sep 17 00:00:00 2001 From: ibnu Date: Fri, 3 Mar 2023 11:07:39 +0700 Subject: [PATCH 122/131] update presence check null geom --- app/Http/Controllers/PresenceController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 400c812..c772c82 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -254,6 +254,7 @@ class PresenceController extends Controller $geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id") ->join("m_activity as ma", "ma.id", "=", "ahta.activity_id") ->where("ahta.user_id", $params->user_id) + ->whereNotNull("ma.geom") ->whereDate("ma.start_date", "<=", $params->time) ->whereDate("ma.end_date", ">=", $params->time) ->get(); From ce9784e32bd0e3dce082f81321f9a8b8d47a677a Mon Sep 17 00:00:00 2001 From: ibnu Date: Fri, 3 Mar 2023 11:37:51 +0700 Subject: [PATCH 123/131] update presence out --- app/Http/Controllers/PresenceController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index c772c82..3dba574 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -126,13 +126,6 @@ class PresenceController extends Controller $this->validate($request, [ 'user_id' => 'required' ]); - - $dataFormK3 = array( - "user_id" => $request->user_id, - "proyek_id" => $request->report_k3['proyek_id'], - "report_date" => $request->time, - "description" => $request->report_k3['description'] - ); $checkLocation = $this->checkLocation($request); $statusBoundary = false; @@ -201,6 +194,13 @@ class PresenceController extends Controller $onlyDate = date_format($date,"Y-m-d"); $clock_in_loc = $this->getLoc($request->clock_in_out['clock_in_lat'], $request->clock_in_out['clock_in_lng'])->display_name; + $dataFormK3 = array( + "user_id" => $request->user_id, + "proyek_id" => $request->report_k3['proyek_id'], + "report_date" => $request->time, + "description" => $request->report_k3['description'] + ); + $dataFormPresence = array( 'user_id' => $request->user_id, 'clock_in' => $request->time, From 47cdf72e476b07c07e302686d26f68b56c9c290c Mon Sep 17 00:00:00 2001 From: ardhi Date: Mon, 6 Mar 2023 17:38:46 +0700 Subject: [PATCH 124/131] show image report in detail (multiple) --- app/Http/Controllers/ReportK3Controller.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ReportK3Controller.php b/app/Http/Controllers/ReportK3Controller.php index 76db167..6cc5342 100644 --- a/app/Http/Controllers/ReportK3Controller.php +++ b/app/Http/Controllers/ReportK3Controller.php @@ -110,12 +110,20 @@ class ReportK3Controller extends Controller $resultData = DB::table($dataChild['table_name'])->where($columnSelf,$value->{$columnForeign})->get(); $value->childData = $resultData; $value->k3_checked = $resultData->pluck("name_checklist_k3")->all(); - $dataImage = Image::where("category", "report_k3")->where("ref_id", $value->id)->first(); - if($dataImage){ - $value->image = $dataImage->image; - }else{ - $value->image = null; + // $dataImage = Image::where("category", "report_k3")->where("ref_id", $value->id)->first(); + // if($dataImage){ + // $value->image = $dataImage->image; + // }else{ + // $value->image = null; + // } + $dataImage = Image::where("category", "report_k3")->where("ref_id", $value->id)->get(); + $images = []; + if (count($dataImage) > 0) { + foreach($dataImage as $reportImage) { + array_push($images, $reportImage); + } } + $value->image = $images; $idsChecklist = $resultData->pluck("checklist_k3_id")->all(); $CheklistK3Ids = ProjectToChecklistK3::whereNotIn("checklist_k3_id", $idsChecklist)->where("proyek_id", $value->proyek_id)->pluck("checklist_k3_id"); $value->k3_not_checked = ChecklistK3::whereIn("id", $CheklistK3Ids)->pluck("name")->all(); From 91728ecdc6495326d67f9123f32f4e0816360e5d Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 14 Mar 2023 14:50:41 +0700 Subject: [PATCH 125/131] 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 126/131] 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 127/131] 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 128/131] 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 129/131] 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 130/131] 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 131/131] 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);