Browse Source

Merge pull request 'staging' (#1) from staging into master

Reviewed-on: OSPRO/ADW-Backend#1
pull/3/head
yusuf 2 years ago
parent
commit
6500375845
  1. 1
      .gitignore
  2. 20
      activity_log.txt
  3. 436
      app/Http/Controllers/ActivityController.php
  4. 174
      app/Http/Controllers/ActivityDokumenController.php
  5. 433
      app/Http/Controllers/AssignMaterialController.php
  6. 135
      app/Http/Controllers/AuthController.php
  7. 21
      app/Http/Controllers/Controller.php
  8. 455
      app/Http/Controllers/DashboardController.php
  9. 155
      app/Http/Controllers/DivisiController.php
  10. 415
      app/Http/Controllers/ProjectController.php
  11. 179
      app/Http/Controllers/ProjectDokumenController.php
  12. 297
      app/Http/Controllers/RequestMaterialController.php
  13. 191
      app/Http/Controllers/RoleController.php
  14. 344
      app/Http/Controllers/UserToActivityController.php
  15. 45
      app/Models/AssignMaterial.php
  16. 36
      app/Models/RequestMaterial.php
  17. 39
      app/Models/UserToActivity.php
  18. 6
      config/api.php
  19. 4
      config/auth.php
  20. 5
      config/jwt.php
  21. 0
      database/sql/001-absensi.sql
  22. 51
      routes/web.php

1
.gitignore vendored

@ -1,5 +1,6 @@
/vendor
/.idea
/assets
/storage
Homestead.json
Homestead.yaml

20
activity_log.txt

@ -0,0 +1,20 @@
2022-07-12 00:13:26: 1379 Penentuan harga project
Added: (10000000 * 1), Cost plan old: 0 | +10000000
Data type (double * double), double | double
Data type origin (double * NULL), string | double
------
2022-07-12 00:13:32: 1378 Contract Management
Deleted: (10000000 * 1), Cost plan old: 20000000 | -10000000
Data type (double * double), double | double
Data type origin (double * double), string | double
------
2022-07-12 00:13:38: 1377 Brainstorming peningkatan layanan masyarakat
Deleted: (10000000 * 1), Cost plan old: 20000000 | -10000000
Data type (double * double), double | double
Data type origin (double * double), string | double
------
2022-07-12 00:13:47: 1379 Penentuan harga project
Deleted: (10000000 * 1), Cost plan old: 10000000 | -0
Data type (double * double), double | double
Data type origin (double * double), string | double
------

436
app/Http/Controllers/ActivityController.php

@ -11,7 +11,6 @@ use App\Models\UserToActivity;
use App\Models\CommentActivity;
use App\Models\AssignMaterial;
use App\Models\AssignTools;
use App\Models\OfficeHours;
use App\Models\VersionGantt;
use App\Models\Holiday;
use App\Models\ReportActivity;
@ -33,7 +32,7 @@ class ActivityController extends Controller
}
return response()->json(['status'=>'success','data'=>$dataGantt,'code'=>200], 200);
}
}
private function getDataActivity($id)
{
@ -52,7 +51,7 @@ class ActivityController extends Controller
}else{
$data = Activity::where('version_gantt_id', $id)->whereNull('parent_id')->orderBy('id', 'asc')->get();
}
foreach($data as $objRow){
$objRow->text = $objRow->name;
if($objRow->parent_id){
@ -153,14 +152,14 @@ class ActivityController extends Controller
$dataPlan = AssignMaterial::where('activity_id', $id)->get();
$tmpPercentage1 = [];
if(!$dataPlan->isEmpty()){
foreach ($dataPlan as $value) {
foreach ($dataPlan as $value) {
$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[] = 100;
}
}
else{
$tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1;
}
@ -169,7 +168,7 @@ class ActivityController extends Controller
$totalPercentage = array_sum($tmpPercentage1) > 0 ? array_sum($tmpPercentage1) / count($tmpPercentage1) : 0;
}else{
$totalPercentage = 0;
}
return $totalPercentage;
@ -343,7 +342,7 @@ class ActivityController extends Controller
}
if($data){
$upactual = false;
$result = $data->update($dataUpdate);
$result = $data->update($dataUpdate);
if($result){
if($parent && (int)$parent > 0){
$this->updateCostPlanning($parent);
@ -376,8 +375,8 @@ class ActivityController extends Controller
return response()->json(['status'=>'failed','message'=>'data activity not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'data activity successfully updated!','code'=>200], 200);
}else{
@ -427,7 +426,7 @@ class ActivityController extends Controller
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'data activity not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success', "action"=>"deleted",'message'=>'data activity successfully deleted!','code'=>200], 200);
@ -507,7 +506,7 @@ class ActivityController extends Controller
{
$biayaActual = Activity::where("parent_id", $id)->sum("biaya_actual");
$dataActivity = Activity::find($id);
$dataUpdate = array(
"biaya_actual" => $biayaActual,
"updated_by" => $this->currentName
@ -534,136 +533,21 @@ class ActivityController extends Controller
public function calculateAllCost($activity_id, $proyek_id)
{
$humanCostPlanning = $this->calculateHuman($activity_id, $proyek_id);
$materialCostPlanning = 0;
$toolsCostPlanning = 0;
$allCost = $humanCostPlanning + $materialCostPlanning + $toolsCostPlanning;
$allCost = $materialCostPlanning + $toolsCostPlanning;
return $allCost;
}
private function calculateHuman($activity_id, $proyek_id)
{
$dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate","ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate")->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id")
->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id)
->where("ahp.proyek_id", $proyek_id)
->get();
$totalCost = 0;
foreach ($dataHuman as $human) {
$uom = $human->uom_standart_rate;
$totalCost += $this->calculateHumanCost($human, $activity_id);
}
return $totalCost;
}
private function calculateHumanCost($human, $activity_id)
{
$activity = Activity::find($activity_id);
$duration = $activity->duration;
$standarRate = $human->standart_rate;
$maxUsed = $human->max_used/100;
$totalCost = ($standarRate*$duration)*$maxUsed;
return $totalCost;
}
private function calculateHumanDay($human, $activity_id)
{
$activity = Activity::find($activity_id);
$duration = $activity->duration;
$standarRate = $human->standart_rate;
$maxUsed = $human->max_used/100;
$totalCost = ($standarRate*$duration)*$maxUsed;
return $totalCost;
}
private function calculateHumanHours($human, $activity_id, $proyek_id)
{
$hours = OfficeHours::where("proyek_id", $proyek_id)->first();
$activity = Activity::find($activity_id);
$ganttId = $activity->version_gantt_id;
$verGantt = VersionGantt::find($ganttId);
$holiday = Holiday::where("version_gantt_id", $ganttId)->where("proyek_id", $proyek_id)->pluck("date");
$dateHoliday = $holiday->all();
$configOff = $verGantt->config_dayoff;
if($configOff && $configOff!= ""){
$dayOff = explode(",", $verGantt->config_dayoff);
$dayOff = array_map(
function($value) { return (int)$value; },
$dayOff
);
}else{
$dayOff = [];
}
$begin = new \DateTime($activity->start_date);
$end = new \DateTime($activity->end_date);
$end = $end->modify( '+1 day' );
$interval = \DateInterval::createFromDateString('1 day');
$period = new \DatePeriod($begin, $interval, $end);
$totalCost = 0;
foreach ($period as $dt) {
$weekDay = $dt->format("w");
$currentDay = $dt->format("Y-m-d");
if(!in_array($weekDay, $dayOff) && !in_array($currentDay, $dateHoliday))
{
$totalHours = $this->getHourInDay($hours, $weekDay);
$standarRate = $human->standart_rate;
$maxUsed = $human->max_used/100;
$totalCost += ($standarRate*$totalHours)*$maxUsed;
}
}
return $totalCost;
}
private function getHourInDay($hours, $day)
{
$totalHours = 0;
switch ($day) {
case 1:
$totalHours = ceil(abs(((strtotime($hours->monday_end)-strtotime($hours->monday_start))/60)/60));
break;
case 2:
$totalHours = ceil(abs(((strtotime($hours->tuesday_end)-strtotime($hours->tuesday_start))/60)/60));
break;
case 3:
$totalHours = ceil(abs(((strtotime($hours->wednesday_end)-strtotime($hours->wednesday_start))/60)/60));
break;
case 4:
$totalHours = ceil(abs(((strtotime($hours->thursday_end)-strtotime($hours->thursday_start))/60)/60));
break;
case 5:
$totalHours = ceil(abs(((strtotime($hours->friday_end)-strtotime($hours->friday_start))/60)/60));
break;
case 6:
$totalHours = ceil(abs(((strtotime($hours->saturday_end)-strtotime($hours->saturday_start))/60)/60));
break;
default:
$totalHours = ceil(abs(((strtotime($hours->sunday_end)-strtotime($hours->sunday_start))/60)/60));
break;
}
return $totalHours;
}
private function calculateMaterial($activity_id, $proyek_id)
{
$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 calculateTools($activity_id, $proyek_id)
{
}
public function getPercentagePerDay(Request $request)
{
{
$dataPayload = $request->all();
$allGantt = [];
foreach ($dataPayload['project_id'] as $val) {
$allGantt[] = $this->getMaxVersionGantt($val);
}
$dataFinal=[];
foreach ($allGantt as $val) {
$dataProject = Project::find($val['proyek_id']);
@ -699,7 +583,7 @@ class ActivityController extends Controller
$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' );
@ -712,14 +596,14 @@ class ActivityController extends Controller
}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");
$currentDate = $dt->format("Y-m-d");
if(!in_array($weekDay, $dayOff) && !in_array($currentDate, $dateHoliday))
{
$totalPercentage = 0;
@ -730,7 +614,7 @@ class ActivityController extends Controller
}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){
@ -764,12 +648,12 @@ class ActivityController extends Controller
public function getCalculateCurvaS(Request $request) // for adw (plan & actual == date)
{
{
$dataPayload = $request->all();
$allGantt = [];
if(isset($dataPayload['gannt_id'])){
$allGantt = $dataPayload['gannt_id'];
}else{
}else{
foreach ($dataPayload['project_id'] as $val) {
$allGantt[] = $this->getMaxVersionGantt($val);
}
@ -790,7 +674,7 @@ class ActivityController 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'])
->min("plan_date");
->min("plan_date");
$maxDate = DB::table('assign_material_to_activity as ama')
->where("ama.proyek_id", $keyGantt['proyek_id'])
@ -804,7 +688,7 @@ class ActivityController extends Controller
$interval = \DateInterval::createFromDateString('1 day');
$period = new \DatePeriod($begin, $interval, $end);
$arr_ActualM = [];
$tempDate = [];
$tempDate = [];
$tempPercentage = [];
$tempTtlPercentPlan=0;
$tempTtlPercentActual=0;
@ -814,12 +698,12 @@ class ActivityController extends Controller
$currentProgressActivity = 0;
$currentBCWP = 0;
$budgetControlBCWP = 0;
foreach ($period as $dt) {
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('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();
@ -833,7 +717,7 @@ class ActivityController extends Controller
$dataTempPlan = [];
$x = 0;
$sumPercentagePlan=0;
$totalACWP = isset($totalACWP) ? $totalACWP : 0;
$totalACWP = isset($totalACWP) ? $totalACWP : 0;
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
foreach ($dataPlanM as $keyPlanM) {
@ -845,13 +729,13 @@ class ActivityController extends Controller
$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]['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;
$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;
@ -869,34 +753,34 @@ class ActivityController extends Controller
->first();
$dataTempReport [$w]['activity_id'] = $keyActualM->activity_id;
$dataTempReport [$w]['qty'] = $keyActualM->qty;
$dataTempReport [$w]['report_date'] = $keyActualM->report_date;
$dataTempReport [$w]['report_date'] = $keyActualM->report_date;
$dataTempReport [$w]['bobot_planning'] = $keyActualM->bobot_planning;
$dataTempReport [$w]['ttl_plan'] = $sumVolActual->ttl_qty_plan;
$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]['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;
$totalACWP += $keyActualM->biaya_actual/$keyActualM->duration;
$dataTempReport [$w]['totalacwp'] = $totalACWP;
$sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
$totalACWP += $keyActualM->biaya_actual/$keyActualM->duration;
$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'){
if($dt->format("w")==1){
'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;
@ -916,34 +800,39 @@ class ActivityController extends Controller
$tempTtlPercentPlan = 0;
$tempTtlPercentActual = 0;
}
}else{
}else{
$tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2));
$tempDate[] = array($dt->format("Y-m-d"), 0, 0);
}
}
if(round($totalACWP,0) > $totalRencanaBudget){
$estimatedCost = round($totalACWP,0)+0;
$estimatedCost = round($totalACWP,0)+0;
}else{
$estimatedCost = ($totalRencanaBudget+0);
$estimatedCost = ($totalRencanaBudget+0);
}
$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" => $costDeviation > 0 ? "SAVING" : $costDeviation == 0 ? "ON BUDGET" : "OVERRUN"
"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,
@ -952,196 +841,17 @@ class ActivityController extends Controller
}
return response()->json(['status'=>'success','code'=>200, 'data' => $dataFinal], 200);
}
public function getCalculateCurvaSBackup(Request $request)
{
$dataPayload = $request->all();
$allGantt = [];
foreach ($dataPayload['project_id'] as $val) {
$allGantt[] = $this->getMaxVersionGantt($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);
$end2 = new \DateTime($maxDate);
$end2 = $end2->modify( '-1 day' );
$interval = \DateInterval::createFromDateString('1 day');
$period = new \DatePeriod($begin, $interval, $end);
$dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first();
if($dataHeader){
$totalRencanaBudget = Activity::select(DB::raw('sum(cast(rencana_biaya as bigint))'))->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 bigint))'))->whereNull('parent_id')->where("proyek_id", $val['proyek_id'])->where("version_gantt_id", $val['last_gantt_id'])->first();
}
$totalRencanaBudget = $totalRencanaBudget->sum;
$currentPercentage = 0;
$currentACWP = 0;
$budgetControlACWP = 0;
$currentProgressActivity = 0;
$currentBCWP = 0;
$budgetControlBCWP = 0;
$dataDate = [];
$dataPercen = [];
$testdata = [];
$countWeek = 0;
foreach ($period as $dt) {
$weekDay = $dt->format("w");
$currentDate = $dt->format("Y-m-d");
$testdata[] = array('weekday' => $weekDay, 'date' =>$currentDate, 'dayof' => $dayOff);
$totalPercentage = isset($totalPercentage) ? $totalPercentage : 0;
$totalACWP = isset($totalACWP) ? $totalACWP : 0;
$totalProgressActivity = isset($totalProgressActivity) ? $totalProgressActivity : 0;
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
if(!in_array($weekDay, $dayOff) && !in_array($currentDate, $dateHoliday))
{
$dataActivity = Activity::whereRaw("'".$currentDate."' BETWEEN DATE(m_activity.start_date) AND DATE(m_activity.end_date) - INTERVAL '1 DAY'")->where('type_activity', 'task')->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 += $activity->bobot_planning/$duration;
if($activity->biaya_actual > 0 && $activity->persentase_progress){
$totalACWP += $activity->biaya_actual/$duration;
$totalProgressActivity += (($activity->persentase_progress*$activity->bobot_planning)/100)/$duration;
$totalBCWP += (((($activity->persentase_progress*$activity->bobot_planning)/100)/$duration)* $totalRencanaBudget)/100;
}
}
}
}
if($currentDate == $end2->format('Y-m-d')){
$currentPercentage = round(($currentPercentage + $totalPercentage), 0);
if($totalACWP > 0 ){
$budgetControlACWP = $currentACWP + $totalACWP;
}
if($totalBCWP > 0 ){
$budgetControlBCWP = $currentBCWP + $totalBCWP;
}
$currentACWP = $totalACWP == 0 ? null : $currentACWP + $totalACWP;
$currentProgressActivity = $totalProgressActivity == 0 ? null : round(($currentProgressActivity + $totalProgressActivity),0);
$currentBCWP = $totalBCWP == 0 ? null :$currentBCWP + $totalBCWP;
$currentPercentage = $currentPercentage > 100 ? 100 : $currentPercentage;
$currentProgressActivity = $currentProgressActivity > 100 ? 100 : $currentProgressActivity;
$dataDate[] = array($currentDate, round($currentBCWP,0), round($currentACWP,0));
$dataPercen[] = array($currentPercentage, $currentProgressActivity);
$totalPercentage = 0;
$totalACWP = 0;
$totalProgressActivity = 0;
$totalBCWP = 0;
}else if($weekDay == "0"){
$currentPercentage = round(($currentPercentage + $totalPercentage), 0);
if($totalACWP > 0 ){
$budgetControlACWP = $currentACWP + $totalACWP;
}
if($totalBCWP > 0 ){
$budgetControlBCWP = $currentBCWP + $totalBCWP;
}
$currentACWP = $totalACWP == 0 ? null : $currentACWP + $totalACWP;
$currentProgressActivity = $totalProgressActivity == 0 ? null : round(($currentProgressActivity + $totalProgressActivity),0);
$currentBCWP = $totalBCWP == 0 ? null :$currentBCWP + $totalBCWP;
$currentPercentage = $currentPercentage > 100 ? 100 : $currentPercentage;
$currentProgressActivity = $currentProgressActivity > 100 ? 100 : $currentProgressActivity;
$dataDate[] = array($currentDate, round($currentBCWP,0), round($currentACWP,0));
$dataPercen[] = array($currentPercentage, $currentProgressActivity);
$totalPercentage = 0;
$totalACWP = 0;
$totalProgressActivity = 0;
$totalBCWP = 0;
}
}
if(round($budgetControlACWP,0) > $totalRencanaBudget){
$estimatedCost = round($budgetControlACWP,0)+0;
}else{
$estimatedCost = ($totalRencanaBudget+0);
}
$costDeviation = $totalRencanaBudget - $estimatedCost;
$dataResponse = array(
"date" =>$dataDate,
"percentage" =>$dataPercen,
"budget_control" =>array("current_budget"=> $totalRencanaBudget,
"acwp" => round($budgetControlACWP,0),
"bcwp" => round($budgetControlBCWP,0),
"rem_to_complete" => ($totalRencanaBudget - round($budgetControlACWP,0)),
"add_cost_to_complete" => 0,
"estimated_at_completion" => $estimatedCost,
"cost_deviation" => $costDeviation,
"potential" => $costDeviation > 0 ? "SAVING" : $costDeviation == 0 ? "ON BUDGET" : "OVERRUN"
)
);
$dataFinal[] = array(
"proyek_name"=> $dataProject->nama,
"data"=>$dataResponse
);
}
if($dataFinal){
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'test' => array('current'=>$currentDate,'max' =>$end2->format('Y-m-d')), 'totalRecord'=>1], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list percentage day, please try again later!','code'=>400], 400);
}
}
public function getCalculateCurvaSDays(Request $request)
{
{
$dataPayload = $request->all();
$allGantt = [];
foreach ($dataPayload['project_id'] as $val) {
$allGantt[] = $this->getMaxVersionGantt($val);
}
$dataFinal=[];
foreach ($allGantt as $val) {
$dataProject = Project::find($val['proyek_id']);
@ -1176,7 +886,7 @@ class ActivityController extends Controller
$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);
$interval = \DateInterval::createFromDateString('1 day');
@ -1187,7 +897,7 @@ class ActivityController extends Controller
}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;
$currentACWP = 0;
@ -1196,7 +906,7 @@ class ActivityController extends Controller
$dataDate = [];
$dataPercen = [];
$testdata = [];
foreach ($period as $dt) {
foreach ($period as $dt) {
$weekDay = $dt->format("w");
$currentDate = $dt->format("Y-m-d");
$testdata[] = array('weekday' => $weekDay, 'date' =>$currentDate);
@ -1208,19 +918,19 @@ class ActivityController extends Controller
$totalBCWP = 0;
$dataActivity = Activity::whereRaw("'".$currentDate."' BETWEEN DATE(m_activity.start_date) AND DATE(m_activity.end_date) - INTERVAL '1 DAY'")->where('type_activity', 'task')->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){
if($totalRencanaBudget > 0 && $duration > 0){
$totalPercentage += $activity->bobot_planning/$duration;
if($activity->biaya_actual > 0 && $activity->persentase_progress){
$totalACWP += $activity->biaya_actual/$duration;
$totalProgressActivity += (($activity->persentase_progress*$activity->bobot_planning)/100)/$duration;
$totalBCWP += (((($activity->persentase_progress*$activity->bobot_planning)/100)/$duration)* $totalRencanaBudget)/100;
}
}
}
}
$currentPercentage = round(($currentPercentage + $totalPercentage), 0);
$currentPercentage = round(($currentPercentage + $totalPercentage), 0);
$currentACWP = $totalACWP == 0 ? null : $currentACWP + $totalACWP;
$currentProgressActivity = $totalProgressActivity == 0 ? null : round(($currentProgressActivity + $totalProgressActivity),0);
$currentBCWP = $totalBCWP == 0 ? null :$currentBCWP + $totalBCWP;
@ -1230,7 +940,7 @@ class ActivityController extends Controller
$dataDate[] = array($currentDate, $currentBCWP, $currentACWP);
$dataPercen[] = array($currentPercentage, $currentProgressActivity);
}else{
}else{
$dataDate[] = $currentDate;
$dataPercen[] = array($currentPercentage,$currentProgressActivity);
}
@ -1286,7 +996,7 @@ class ActivityController extends Controller
foreach($activities as $activity) {
$activity_id = $activity->id;
$countReports = ReportActivity::where('activity_id', $activity_id)->count();
$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) {
@ -1318,4 +1028,4 @@ class ActivityController extends Controller
return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200);
}
}
}

174
app/Http/Controllers/ActivityDokumenController.php

@ -7,93 +7,89 @@ use App\Models\ActivityDokumen;
class ActivityDokumenController extends Controller
{
public function dokumenByActivityId($id){
if($id && $id!="" && (int)$id > 0){
$dataDokumen = ActivityDokumen::where("activity_id", $id)->get();
return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'activity id is required!','code'=>400], 400);
}
}
public function delete($id)
{
if($id && $id!="" && (int)$id > 0){
$dokumen = ActivityDokumen::find($id);
if($dokumen){
if(file_exists($this->pathActivityDocument.$dokumen->file)){
unlink($this->pathActivityDocument.$dokumen->file);
}
$dokumen->delete();
return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
}
}
public function uploadProjectDokumen(Request $request)
{
if($request->hasFile('dokumen')){
$activity_id = $request->activity_id;
$dokumen = $request->file('dokumen');
$extension = $dokumen->extension();
$name = $dokumen->getClientOriginalName();
$result = $dokumen->move($this->pathActivityDocument, $name);
if($result){
$data = [
'activity_id' => (int)$activity_id,
'file' => $name,
'description' => $request->description
];
$result = ActivityDokumen::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'file upload is successfully!','code'=>200], 200);
}else{
unlink($this->pathActivityDocument.$name);
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400);
}
}
public function searchDocProject(Request $request){
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_document_activity');
$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 downloadDokumen($id)
{
if($id && $id!="" && (int)$id > 0){
$dokumen = ActivityDokumen::find($id);
if($dokumen){
if(file_exists($this->pathActivityDocument.$dokumen->file)){
$pathToFile = $this->pathActivityDocument.$dokumen->file;
return response()->download($pathToFile);
}else{
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
}
}
public function dokumenByActivityId($id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'activity id is required!','code'=>400], 400);
$dataDokumen = ActivityDokumen::where("activity_id", $id)->get();
return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200);
}
public function delete($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
$document = ActivityDokumen::find($id);
if(!$document)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if(file_exists($this->pathActivityDocument.$document->file))
unlink($this->pathActivityDocument.$document->file);
$document->delete();
return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200);
}
public function uploadProjectDokumen(Request $request)
{
if(!$request->hasFile('dokumen'))
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400);
$activity_id = $request->activity_id;
$document = $request->file('dokumen');
$name = $document->getClientOriginalName();
$result = $document->move($this->pathActivityDocument, $name);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
$data = [
'activity_id' => (int)$activity_id,
'file' => $name,
'description' => $request->description
];
$result = ActivityDokumen::create($data);
if(!$result){
unlink($this->pathActivityDocument.$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload success!','code'=>200], 200);
}
public function searchDocProject(Request $request){
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_document_activity');
$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 downloadDokumen($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
$document = ActivityDokumen::find($id);
if(!$document)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
if(file_exists($this->pathActivityDocument.$document->file)){
$pathToFile = $this->pathActivityDocument.$document->file;
return response()->download($pathToFile);
}
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
}
}

433
app/Http/Controllers/AssignMaterialController.php

@ -4,277 +4,178 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\AssignMaterial;
use App\Models\MaterialResource;
use App\Models\RequestMaterial;
use App\Models\Activity;
use App\Models\ReportActivityMaterial;
use Datatables;
class AssignMaterialController extends Controller
{
public function add_backup(Request $request){
$this->validate($request, [
'activity_id' => 'required',
'material_id' => 'required',
'qty_planning' => 'required',
'budget' => 'required'
]);
$checkStock = MaterialResource::where("id", $request->material_id)->first();
$currentStock = $checkStock->qty;
if((int)$currentStock < (int)$request->qty_planning){
return response()->json(['status'=>'failed','message'=>'Not enough stock in warehouse!','code'=>400]);
die();
}
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = AssignMaterial::create($data);
if($result){
$checkStock = MaterialResource::find($request->material_id);
$newStock = (int)$checkStock->qty - (int)$request->qty_planning;
$dataUpdate = array(
"qty"=>$newStock,
"updated_by"=>$this->currentName
);
$checkStock->update($dataUpdate);
return response()->json(['status'=>'success','message'=>'Assign material successfull created','code'=>200]);
}else{
return response()->json(['status'=>'failed','message'=>'Assign material failed created','code'=>400]);
}
}
public function add(Request $request){
$this->validate($request, [
'activity_id' => 'required',
'material_id' => 'required',
'qty_planning' => 'required'
]);
$checkStock = RequestMaterial::where("id", $request->material_id)->first();
$currentStock = $checkStock->qty;
$price = $checkStock->price;
if((int)$currentStock < (int)$request->qty_planning){
return response()->json(['status'=>'failed','message'=>'Not enough stock !','code'=>400]);
die();
}
$data = $request->all();
$data['created_by'] = $this->currentName;
$data['budget'] = $price;
$result = AssignMaterial::create($data);
if($result){
$updateActivity = Activity::find($request->activity_id);
if($updateActivity){
$costPlanOld = $updateActivity==null? 0 : (int)$updateActivity->rencana_biaya;
$costPlanNew = $costPlanOld + ($price*$request->qty_planning);
$updateActivity->rencana_biaya = $costPlanNew;
$updateActivity->save();
return response()->json(['status'=>'success','message'=>'Assign material successfull created, and update cost plan success '.$costPlanNew,'code'=>200]);
}else{
return response()->json(['status'=>'success','message'=>'Assign material successfull created','code'=>200]);
}
}else{
return response()->json(['status'=>'failed','message'=>'Assign material failed created','code'=>400]);
}
}
private function updateFromAdd($data){
$assignMaterial = AssignMaterial::where("activity_id", $data->activity_id)->where("material_id", $data->material_id)->first();
$newQty = (int)$assignMaterial->qty_planning + (int)$data->qty_planning;
$newBudget = $assignMaterial->budget > $data->budget ? $assignMaterial->budget : $data->budget;
$dataUpdate = array(
"qty_planning"=>$newQty,
"budget"=>$newBudget,
"updated_by"=>$this->currentName
);
$dataWillUpdate = AssignMaterial::where("activity_id", $data->activity_id)->where("material_id", $data->material_id);
return $dataWillUpdate->update($dataUpdate);
}
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 = AssignMaterial::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Assign material not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Assign material successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Assign material failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = AssignMaterial::find($id);
if($data){
$id = $data->material_id;
$stock = $data->qty_planning;
$materialResource = MaterialResource::find($id);
if($materialResource){
$oldStock = $materialResource->qty;
$newStock = $oldStock + $stock;
$dataUpdate = array(
"qty"=>$newStock,
"updated_by"=>$this->currentName
);
$materialResource->update($dataUpdate);
}
$activity = Activity::where('id', $data->activity_id)->first();
$activity->rencana_biaya -= $data->budget * $data->qty_planning;
$activity->save();
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'Data Assign material not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'Assign material successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Assign material failed deleted!','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);
die();
}
$result = AssignMaterial::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data Assign material, please try again later!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'assign_material_to_activity');
$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()
{
$data = AssignMaterial::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 Assign material, please try again later!','code'=>400], 400);
}
}
public function datatables(Request $request){
$id_activity = $request->query('idact');
$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)->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-material-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
public function datatablesForReportActivity(Request $request){
$id_activity = $request->query('idact');
$data = AssignMaterial::select(AssignMaterial::raw('SUM(qty_planning) as qty_planning'), "m.description as material_name", "assign_material_to_activity.activity_id as activity_id")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->groupBy("m.description")
->groupBy("assign_material_to_activity.activity_id")
->where("assign_material_to_activity.activity_id", $id_activity)->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('qty_sum', function($row){
$val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
->groupBy("m.description")
->where("m.description", strval($row->material_name))
->where("ram.activity_id", $row->activity_id)->first();
return $val_qty_act ? $val_qty_act->qty_sum : '-';
})
->addColumn('status_activity', function($row){
$val_status = AssignMaterial::select("status_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_status ? $val_status->status_activity : null;
})
->addColumn('start_activity', function($row){
$val_start = AssignMaterial::select("start_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_start ? $val_start->start_activity : null;
})
->addColumn('finish_activity', function($row){
$val_finish = AssignMaterial::select("finish_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_finish ? $val_finish->finish_activity : null;
})
->addColumn('uom', function($row){
$val_uom = RequestMaterial::select("uom")
->where('description', '=', $row->material_name)->first();
return $val_uom ? $val_uom->uom : null;
})
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" data-material-name="'.$row->material_name.'" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>';
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$row->id.'" data-material-name="'.$row->material_name.'" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
public function ForReportActivityByMaterial(Request $request){
$id_activity = $request->idact;
$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)->get();
foreach ($data as $key) {
# code...
$val_qty_sum = ReportActivityMaterial::where('assign_material_id', '=', $key->id)->sum("qty");
}
$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 Assign material, please try again later!','code'=>400], 400);
}
}
public function add(Request $request){
$this->validate($request, [
'activity_id' => 'required',
'material_id' => 'required',
'qty_planning' => 'required'
]);
$checkStock = RequestMaterial::where("id", $request->material_id)->first();
$currentStock = $checkStock->qty;
$price = $checkStock->price;
if((int)$currentStock < (int)$request->qty_planning){
return response()->json(['status'=>'failed','message'=>'Stock is not enough!','code'=> 500]);
}
$data = $request->all();
$data['created_by'] = $this->currentName;
$data['budget'] = $price;
$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]);
}
public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$data = AssignMaterial::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$result = $data->update($request->all());
if($result)
return response()->json(['status'=>'success','message'=> 'Data updated!','code'=> 200], 200);
return response()->json(['status'=>'failed','message'=>'Failed to update!','code'=> 500], 500);
}
public function delete($id)
{
$data = AssignMaterial::where('id', $id)->first();
if($data->delete())
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=> 200], 200);
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=> 500], 500);
}
public function edit($id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$result = AssignMaterial::find($id);
if($result)
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'assign_material_to_activity');
$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()
{
$data = AssignMaterial::all();
$countData = $data->count();
if($data)
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
return response()->json(['status'=>'failed','message'=>'Failed to get the data!','code'=> 500], 500);
}
public function datatables(Request $request){
$id_activity = $request->query('idact');
$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)->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-material-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
public function datatablesForReportActivity(Request $request){
$id_activity = $request->query('idact');
$data = AssignMaterial::select(AssignMaterial::raw('SUM(qty_planning) as qty_planning'), "m.description as material_name", "assign_material_to_activity.activity_id as activity_id")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->groupBy("m.description")
->groupBy("assign_material_to_activity.activity_id")
->where("assign_material_to_activity.activity_id", $id_activity)->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('qty_sum', function($row){
$val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
->groupBy("m.description")
->where("m.description", strval($row->material_name))
->where("ram.activity_id", $row->activity_id)->first();
return $val_qty_act ? $val_qty_act->qty_sum : '-';
})
->addColumn('status_activity', function($row){
$val_status = AssignMaterial::select("status_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_status ? $val_status->status_activity : null;
})
->addColumn('start_activity', function($row){
$val_start = AssignMaterial::select("start_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_start ? $val_start->start_activity : null;
})
->addColumn('finish_activity', function($row){
$val_finish = AssignMaterial::select("finish_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_finish ? $val_finish->finish_activity : null;
})
->addColumn('uom', function($row){
$val_uom = RequestMaterial::select("uom")
->where('description', '=', $row->material_name)->first();
return $val_uom ? $val_uom->uom : null;
})
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" data-material-name="'.$row->material_name.'" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>';
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$row->id.'" data-material-name="'.$row->material_name.'" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
public function ForReportActivityByMaterial(Request $request){
$id_activity = $request->idact;
$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)->get();
foreach ($data as $key) {
# code...
$val_qty_sum = ReportActivityMaterial::where('assign_material_id', '=', $key->id)->sum("qty");
}
$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 Assign material, please try again later!','code'=>400], 400);
}
}
}

135
app/Http/Controllers/AuthController.php

@ -4,85 +4,70 @@ namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use App\Models\Role;
use App\Models\Project;
use App\Models\UserProject;
class AuthController extends Controller
{
/**
* Create a new AuthController instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth:api', ['except' => ['login']]);
}
public function login(Request $request)
{
$username = $request->username;
$password = $request->password;
$is_mobile = $request->is_mobile;
if(empty($username) || empty($password)){
return response()->json(['status'=>'error','message'=>'You must fill all the fields'], 400);
}
$credentials = array(
"username"=> $username,
"password"=> md5($password)
);
$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);
die();
}
$dataUpdateFcm = array(
"fcm_token"=>$fcm_token
);
$hr = User::find($user->id);
if($hr){
$result = $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);
}
return $this->respondWithToken($token, $user);
}
protected function respondWithToken($token, $user)
{
return response()->json([
'code' => 200,
'data' => array(
'data_user' => $user,
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth()->factory()->getTTL() * 60
),
]);
}
public function __construct()
{
$this->middleware('auth:api', ['except' => ['login']]);
}
public function login(Request $request)
{
$username = $request->username;
$password = $request->password;
$remember = $request->remember;
$is_mobile = $request->is_mobile;
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,
),
]);
}
}

21
app/Http/Controllers/Controller.php

@ -10,7 +10,7 @@ class Controller extends BaseController
protected $pathImage = "assets/image/";
protected $pathDocument = "assets/file/project/";
protected $pathActivityDocument = "assets/file/activity/";
protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth',
protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth',
'sixth', 'seventh', 'eighth', 'ninth', 'tenth'];
protected $currentDate;
protected $currentName;
@ -35,14 +35,14 @@ class Controller extends BaseController
if($condition){
if(isset($condition['joins'])){
$selectColumn = [];
$no = 0;
$no = 0;
foreach($condition['joins'] as $join){
$tableJoin = isset($join['name1']) ? $join['name1'] : $alias;
$tableName = $join['name'];
$columnJoin = $join['column_join']; // foreign key table sini
$columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan
$columnResult = $join['column_results'];
foreach($columnResult as $sColumn){
$builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn);
}
@ -50,7 +50,7 @@ class Controller extends BaseController
$no++;
}
}
if(isset($condition['columns'])){
$listWhere = $condition['columns'];
@ -71,7 +71,7 @@ class Controller extends BaseController
if(isset($condition['group_column'])){
$builder = $this->groupWhere($builder, $condition['group_column'], $alias);
}
$data['count'] = clone $builder;
if(isset($condition['paging'])){
@ -225,7 +225,7 @@ class Controller extends BaseController
->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id)
->where("ahp.proyek_id", $proyek_id)
->get();
$totalCost = 0;
foreach ($dataHuman as $human) {
$uom = $human->uom_standart_rate;
@ -242,7 +242,7 @@ class Controller extends BaseController
$standarRate = $human->standart_rate;
$maxUsed = $human->max_used/100;
$totalCost = ($standarRate*$duration)*$maxUsed;
return $totalCost;
return $totalCost;
}
private function calculateMaterialCost($activity_id, $proyek_id)
@ -251,11 +251,6 @@ class Controller extends BaseController
return $totalCost;
}
private function calculateToolsCost($activity_id, $proyek_id)
{
}
protected function updatedCostPlanning($id)
{
$sumBiaya = Activity::select(DB::raw('sum(cast(rencana_biaya as double precision))'))->where("parent_id", $id)->first();
@ -272,4 +267,4 @@ class Controller extends BaseController
}
}
}
}
}

455
app/Http/Controllers/DashboardController.php

@ -6,247 +6,220 @@ use Illuminate\Http\Request;
use App\Models\Project;
use App\Models\Activity;
use App\Models\ReportActivity;
use App\Models\UserToActivity;
use DB;
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($dataPayload){
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400);
}
}
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($dataPayload){
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400);
}
}
public function list()
{
$data = Role::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 role, please try again later!','code'=>400], 400);
}
}
public function getActivityByProjectId($projectId) {
$output = [];
$data = Activity::select('id')->where('proyek_id', $projectId)->get();
if (count($data) > 0) {
foreach ($data as $actData) {
$output[] = $actData->id;
}
}
return $output;
}
/* for statusProyek, I want something output like this
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");
$progress_percentage = Activity::where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->sum("persentase_progress");
$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($dataFinal){
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>count($dataFinal)], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get status proyek, please try again later!','code'=>400], 400);
}
}
public function curvaS(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', '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');
$dataBobotPlan =[];
for ($i=0; $i < count($data); $i++) {
$tmpp = 0;
$tmpa = 0;
$tmpbc = 0;
$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;
}
}else{
$data[$i]['cal_bobot_a'] = round($tmpa,2);
}
$data[$i]['cal_budget_cost'] = round($tmpbc,2);
if($i > 0 ){
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_actual_cost'] = round($tmpac,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($dataPayload){
return response()->json(['status'=>'success','code'=>200, 'data'=>$dataFinal, 'totalRecord'=>1], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400);
}
}
}
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);
}
}

155
app/Http/Controllers/DivisiController.php

@ -6,82 +6,81 @@ use Illuminate\Http\Request;
use App\Models\Divisi;
class DivisiController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'name' => 'required',
'description' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = Divisi::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'Master divisi successfull created','code'=>200]);
}else{
return response()->json(['status'=>'failed','message'=>'Master divisi failed created','code'=>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 = Divisi::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Master divisi not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Master divisi successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Master divisi failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = Divisi::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data Master divisi not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'Master divisi successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Master divisi failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$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()
{
$data = Divisi::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 tools request, please try again later!','code'=>400], 400);
}
}
{
public function add(Request $request){
$this->validate($request, [
'name' => 'required',
'description' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = Divisi::create($data);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500]);
return response()->json(['status'=>'success','message'=>'Data created!','code'=>200]);
}
public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$data = Divisi::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
$result = $data->update($request->all());
if(!$result)
return response()->json(['status'=>'failed','message'=> 'Update failed!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200);
}
public function delete($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$data = Divisi::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
$delete = $data->delete();
if(!$delete)
return response()->json(['status'=>'failed','message'=> 'Delete failed!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200);
}
public function search(Request $request)
{
$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()
{
$data = Divisi::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

415
app/Http/Controllers/ProjectController.php

@ -14,12 +14,8 @@ use App\Models\ProjectCharter;
use App\Models\ProjectApproval;
use App\Models\ProjectMileStone;
use App\Models\ProjectParticipants;
use App\Models\UserToVersionGantt;
use App\Models\RequestMaterial;
use App\Models\ShowHideColumn;
use App\Models\ToolsProject;
use App\Models\VersionGantt;
use App\Models\MaterialProject;
use App\Models\Image;
use App\Models\CommentActivity;
use App\Models\Link;
@ -30,214 +26,205 @@ use App\Models\OfficeHours;
class ProjectController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'nama' => 'required',
'mulai_proyek' => 'required',
'akhir_proyek' => 'required',
'rencana_biaya' => 'required',
'type_proyek_id' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = Project::create($data);
if($result){
$this->createOfficeHours($result->id);
$dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first();
return response()->json(['status'=>'success','message'=>'add data project successfully!', 'data_result' =>$dataResultInsert, 'code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add data project 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);
die();
}
$result = Project::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data project, please try again later!','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 = Project::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);
}
}
private function createOfficeHours($proyek_id)
{
$dataCreate = array(
"proyek_id"=>$proyek_id,
"monday_start"=> "08:00:00",
"monday_end"=> "16:00:00",
"tuesday_start"=> "08:00:00",
"tuesday_end"=> "16:00:00",
"wednesday_start"=> "08:00:00",
"wednesday_end"=> "16:00:00",
"thursday_start"=> "08:00:00",
"thursday_end"=> "16:00:00",
"friday_start"=> "08:00:00",
"friday_end"=> "16:00:00",
"saturday_start"=> "08:00:00",
"saturday_end"=> "16:00:00",
"sunday_start"=> "08:00:00",
"sunday_end"=> "16:00:00",
"created_by"=> $this->currentName
);
OfficeHours::create($dataCreate);
return true;
}
public function delete($id)
{
$data = Project::find($id);
if($data){
$this->deleteRelative($id);
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data project not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data project successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data project failed deleted!','code'=>400], 400);
}
}
private function deleteRelative($project_id)
{
UserToProyek::where('proyek_id', $project_id)->delete();
UserToActivity::where('proyek_id', $project_id)->delete();
AssignMaterial::where('proyek_id', $project_id)->delete();
ProjectCharter::where('proyek_id', $project_id)->delete();
ProjectApproval::where('proyek_id', $project_id)->delete();
ProjectMileStone::where('proyek_id', $project_id)->delete();
ProjectParticipants::where('proyek_id', $project_id)->delete();
$this->deleteVersionGantt($project_id);
$this->deleteDokumenProject($project_id);
}
private function deleteVersionGantt($project_id)
{
$dataVg = VersionGantt::where("proyek_id", $project_id)->pluck("id");
$vhIds = $dataVg->all();
$activity = Activity::whereIn("version_gantt_id", $vhIds)->pluck('id');
$activityIds = $activity->all();
$dataRa = ReportActivity::whereIn("activity_id", $activityIds)->get();
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if(file_exists($this->pathImage.$image->image)){
unlink($this->pathImage.$image->image);
}
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
}
$dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get();
foreach ($dataAd as $ad) {
if(file_exists($this->pathActivityDocument.$ad->file)){
unlink($this->pathActivityDocument.$ad->file);
}
}
ActivityDokumen::whereIn("activity_id", $activityIds)->delete();
CommentActivity::whereIn("activity_id", $activityIds)->delete();
Holiday::where("proyek_id", $project_id)->delete();
VersionGantt::where("proyek_id", $project_id)->delete();
Link::whereIn("version_gantt_id", $vhIds)->delete();
ShowHideColumn::whereIn("version_gantt_id", $vhIds)->delete();
Activity::whereIn("version_gantt_id", $vhIds)->delete();
ReportActivity::whereIn("activity_id", $activityIds)->delete();
}
private function deleteDokumenProject($project_id)
{
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get();
foreach ($dataDokumen as $dokumen) {
if(file_exists($this->pathDocument.$dokumen->file)){
unlink($this->pathDocument.$dokumen->file);
}
}
DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete();
$dataFolder = FolderDocumentProyek::where('proyek_id', $project_id)->pluck("id");
$ref_ids = $dataFolder->all();
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get();
foreach ($dataDokumen as $dokumen) {
if(file_exists($this->pathDocument.$dokumen->file)){
unlink($this->pathDocument.$dokumen->file);
}
}
DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete();
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek');
$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()
{
$data = Project::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 project, please try again later!','code'=>400], 400);
}
}
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'=>'success','code'=>200,'data'=>$data], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list project, please try again later!','code'=>400], 400);
}
}
public function add(Request $request)
{
$this->validate($request, [
'nama' => 'required',
'mulai_proyek' => 'required',
'akhir_proyek' => 'required',
'rencana_biaya' => 'required',
'type_proyek_id' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = Project::create($data);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500], 500);
$this->createOfficeHours($result->id);
$dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first();
return response()->json(['status'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200);
}
public function edit($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);
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$data = Project::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
$result = $data->update($request->all());
if(!$result)
return response()->json(['status'=>'failed','message'=> 'Failed to update!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data updated!','code' => 200], 200);
}
private function createOfficeHours($proyek_id)
{
$dataCreate = array(
"proyek_id"=>$proyek_id,
"monday_start"=> "08:00:00",
"monday_end"=> "16:00:00",
"tuesday_start"=> "08:00:00",
"tuesday_end"=> "16:00:00",
"wednesday_start"=> "08:00:00",
"wednesday_end"=> "16:00:00",
"thursday_start"=> "08:00:00",
"thursday_end"=> "16:00:00",
"friday_start"=> "08:00:00",
"friday_end"=> "16:00:00",
"saturday_start"=> "08:00:00",
"saturday_end"=> "16:00:00",
"sunday_start"=> "08:00:00",
"sunday_end"=> "16:00:00",
"created_by"=> $this->currentName
);
OfficeHours::create($dataCreate);
return true;
}
public function delete($id)
{
$data = Project::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$this->deleteRelative($id);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Delete failed!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
}
private function deleteRelative($project_id)
{
UserToProyek::where('proyek_id', $project_id)->delete();
UserToActivity::where('proyek_id', $project_id)->delete();
AssignMaterial::where('proyek_id', $project_id)->delete();
ProjectCharter::where('proyek_id', $project_id)->delete();
ProjectApproval::where('proyek_id', $project_id)->delete();
ProjectMileStone::where('proyek_id', $project_id)->delete();
ProjectParticipants::where('proyek_id', $project_id)->delete();
$this->deleteVersionGantt($project_id);
$this->deleteDokumenProject($project_id);
}
private function deleteVersionGantt($project_id)
{
$dataVg = VersionGantt::where("proyek_id", $project_id)->pluck("id");
$vhIds = $dataVg->all();
$activity = Activity::whereIn("version_gantt_id", $vhIds)->pluck('id');
$activityIds = $activity->all();
$dataRa = ReportActivity::whereIn("activity_id", $activityIds)->get();
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if(file_exists($this->pathImage.$image->image)){
unlink($this->pathImage.$image->image);
}
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
}
$dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get();
foreach ($dataAd as $ad) {
if(file_exists($this->pathActivityDocument.$ad->file)){
unlink($this->pathActivityDocument.$ad->file);
}
}
ActivityDokumen::whereIn("activity_id", $activityIds)->delete();
CommentActivity::whereIn("activity_id", $activityIds)->delete();
Holiday::where("proyek_id", $project_id)->delete();
VersionGantt::where("proyek_id", $project_id)->delete();
Link::whereIn("version_gantt_id", $vhIds)->delete();
ShowHideColumn::whereIn("version_gantt_id", $vhIds)->delete();
Activity::whereIn("version_gantt_id", $vhIds)->delete();
ReportActivity::whereIn("activity_id", $activityIds)->delete();
}
private function deleteDokumenProject($project_id)
{
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get();
foreach ($dataDokumen as $dokumen) {
if(file_exists($this->pathDocument.$dokumen->file)){
unlink($this->pathDocument.$dokumen->file);
}
}
DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete();
$dataFolder = FolderDocumentProyek::where('proyek_id', $project_id)->pluck("id");
$ref_ids = $dataFolder->all();
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get();
foreach ($dataDokumen as $dokumen) {
if(file_exists($this->pathDocument.$dokumen->file)){
unlink($this->pathDocument.$dokumen->file);
}
}
DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete();
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek');
$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()
{
$data = Project::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 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);
}
}

179
app/Http/Controllers/ProjectDokumenController.php

@ -7,93 +7,94 @@ use App\Models\DokumenProject;
class ProjectDokumenController extends Controller
{
public function dokumenByProyekId($id){
if($id && $id!="" && (int)$id > 0){
$dataDokumen = DokumenProject::where("ref_id", $id)->get();
return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'project id is required!','code'=>400], 400);
}
}
public function delete($id)
{
if($id && $id!="" && (int)$id > 0){
$dokumen = DokumenProject::find($id);
if($dokumen){
if(file_exists($this->pathDocument.$dokumen->file)){
unlink($this->pathDocument.$dokumen->file);
}
$dokumen->delete();
return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
}
}
public function uploadProjectDokumen(Request $request)
{
if($request->hasFile('dokumen')){
$dokumen = $request->file('dokumen');
$ref_id = $request->ref_id;
$extension = $dokumen->extension();
$name = $dokumen->getClientOriginalName();
$result = $dokumen->move($this->pathDocument, $name);
if($result){
$data = [
'ref_id' => (int)$ref_id,
'file' => $name,
'type_dokumen' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document' // project-document-in-folder / project-document-out-folder
];
$result = DokumenProject::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'file upload is successfully!','code'=>200], 200);
}else{
unlink($this->pathDocument.$name);
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400);
}
}
public function searchDocProject(Request $request){
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'document_project');
$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 downloadDokumen($id)
{
if($id && $id!="" && (int)$id > 0){
$dokumen = DokumenProject::find($id);
if($dokumen){
if(file_exists($this->pathDocument.$dokumen->file)){
$pathToFile = $this->pathDocument.$dokumen->file;
return response()->download($pathToFile);
}else{
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
}
}
public function dokumenByProyekId($id){
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'project id is required!','code'=>400], 400);
}
$document = DokumenProject::where("ref_id", $id)->get();
if(count($document) == 0)
return response()->json(['status'=>'','message'=>'Data not found!' ,'code'=>404], 404);
return response()->json(['status'=>'success','data'=> $document ,'code'=>200], 200);
}
public function delete($id)
{
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$document = DokumenProject::find($id);
if(!$document){
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
}
if(file_exists($this->pathDocument.$document->file)){
unlink($this->pathDocument.$document->file);
}
$document->delete();
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
}
public function uploadProjectDokumen(Request $request)
{
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' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document'
];
$result = DokumenProject::create($data);
if(!$result){
unlink($this->pathDocument.$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload successful!','code'=>200], 200);
}
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400);
}
public function searchDocProject(Request $request){
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'document_project');
$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 downloadDokumen($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
$document = DokumenProject::find($id);
if(!$document)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if(!file_exists($this->pathDocument.$document->file))
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$pathToFile = $this->pathDocument.$document->file;
return response()->download($pathToFile);
}
}

297
app/Http/Controllers/RequestMaterialController.php

@ -8,165 +8,140 @@ use App\Models\MaterialResource;
class RequestMaterialController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'proyek_id' => 'required',
'description' => 'required',
'required_date' => 'required',
'qty' => 'required',
'uom' => 'required',
'fom_date' => 'required',
]);
$data = $request->all();
$data['status'] = "fom";
$data['created_by'] = $this->currentName;
$result = RequestMaterial::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'request material successfully!', 'data'=>$result, 'code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'request material 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);
die();
}
$result = RequestMaterial::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data request material, please try again later!','code'=>400], 400);
}
}
public function delete($id)
{
$data = RequestMaterial::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data request material not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'request material successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'request material failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_req_material');
$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()
{
$data = RequestMaterial::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 request material, please try again later!','code'=>400], 400);
}
}
public function update(Request $request, $id)
{
$dataForm = $request->all();
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$data = RequestMaterial::find($id);
if($data){
if(!isset($dataForm['status'])){
$resultUpdate = $data->update($request->all());
if($resultUpdate){
return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'request material failed updated!','code'=>400], 400);
}
die();
}
if($dataForm['status']=="receipt to warehouse"){
$dataM = MaterialResource::where('name', 'ilike', $data->description)->first();
if($dataM){
$result = $data->update($request->all());
$payloadMQty = $dataM->qty + $data->qty_received;
$resultUpdateM = MaterialResource::where('id', $dataM->id)->update(['qty' => $payloadMQty]);
return response()->json(['status'=>'success', 'code'=>200], 200);
}else{
$result = $data->update($request->all());
$dataPayloadM = array(
"name" => $dataForm['description'],
"uom" => $dataForm['uom'],
"unit_price" => 0,
"description" => $dataForm['description'],
"qty" => $data->qty_received,
"status" => "Barang tersedia",
"created_by" => $this->currentName
);
$result = MaterialResource::create($dataPayloadM);
if($result){
return response()->json(['status'=>'success','message'=>'add data material resource successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add data material resource failed!','code'=>400], 400);
}
}
}else if($dataForm['status']=="receipt to site"){
$result = $data->update($request->all());
$dataM = MaterialResource::where('name', 'ilike', $data->description)->first();
if($dataM){
$result = $data->update($request->all());
$payloadMQty = $dataM->qty - $data->qty_received;
if($payloadMQty < 0){
return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed, because material is not exist in warehouse!','code'=>400], 400);
die();
}
$resultUpdateM = MaterialResource::where('id', $dataM->id)->update(['qty' => $payloadMQty]);
return response()->json(['status'=>'success', 'message'=>'request material status receipt to site successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed, because material is not exist in warehouse!','code'=>400], 400);
}
}else{
$resultUpdate = $data->update($request->all());
if($resultUpdate){
return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'request material failed updated!','code'=>400], 400);
}
}
}else{
return response()->json(['status'=>'failed','message'=>'data request material not found!','code'=>400], 400);
die();
}
}
public function add(Request $request){
$this->validate($request, [
'proyek_id' => 'required',
'description' => 'required',
'required_date' => 'required',
'qty' => 'required',
'uom' => 'required',
'fom_date' => 'required',
]);
$data = $request->all();
$data['status'] = "fom";
$data['created_by'] = $this->currentName;
$result = RequestMaterial::create($data);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data added!', 'data'=>$result, 'code'=>200], 200);
}
public function edit($id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$result = RequestMaterial::find($id);
if($result)
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
}
public function delete($id)
{
$data = RequestMaterial::find($id);
if($data)
$delete = $data->delete();
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
if($delete)
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=> 500], 500);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_req_material');
$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()
{
$data = RequestMaterial::all();
$countData = $data->count();
if($data)
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
return response()->json(['status'=>'failed','message'=>'failed get list request material, please try again later!','code'=>400], 400);
}
public function update(Request $request, $id)
{
$dataForm = $request->all();
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$reqMaterial = RequestMaterial::find($id);
if(!$reqMaterial)
return response()->json(['status'=>'failed','message'=>'data request material not found!','code'=>400], 400);
if(!isset($dataForm['status'])){
if(!$reqMaterial->update($request->all()))
return response()->json(['status'=>'failed','message'=>'request material failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200);
}
if($dataForm['status']=="receipt to warehouse"){
$materialResource = MaterialResource::where('name', 'ilike', $reqMaterial->description)->first();
if($materialResource){
$reqMaterial->update($request->all());
$payloadMQty = $materialResource->qty + $reqMaterial->qty_received;
MaterialResource::where('id', $materialResource->id)->update(['qty' => $payloadMQty]);
return response()->json(['status'=>'success', 'code'=>200], 200);
}
$reqMaterial->update($request->all());
$preparedMaterialResource = array(
"name" => $dataForm['description'],
"uom" => $dataForm['uom'],
"unit_price" => 0,
"description" => $dataForm['description'],
"qty" => $reqMaterial->qty_received,
"status" => "Barang tersedia",
"created_by" => $this->currentName
);
if(!MaterialResource::create($preparedMaterialResource ))
return response()->json(['status'=>'failed','message'=>'add data material resource failed!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'add data material resource successfully!','code'=>200], 200);
}
if($dataForm['status']=="receipt to site"){
$reqMaterial->update($request->all());
$materialResource = MaterialResource::where('name', 'ilike', $reqMaterial->description)->first();
if(!$materialResource)
return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed, because material is not exist in warehouse!','code'=>400], 400);
$reqMaterial->update($request->all());
$payloadMQty = $materialResource->qty - $reqMaterial->qty_received;
if($payloadMQty < 0)
return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed, because material is not exist in warehouse!','code'=>400], 400);
MaterialResource::where('id', $materialResource->id)->update(['qty' => $payloadMQty]);
return response()->json(['status'=>'success', 'message'=>'request material status receipt to site successfully updated!','code'=>200], 200);
}
if(!$reqMaterial->update($request->all()))
return response()->json(['status'=>'failed','message'=>'request material failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200);
}
}

191
app/Http/Controllers/RoleController.php

@ -4,105 +4,98 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Role;
class RoleController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'description' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = Role::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'add data role successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add data role 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);
die();
}
$result = Role::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data role, please try again later!','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 = Role::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'data role not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'data role successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data role failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = Role::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data role not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data role successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data role failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_roles');
$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()
{
$data = Role::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 role, please try again later!','code'=>400], 400);
}
}
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'description' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = Role::create($data);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=>500], 500);
return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200);
}
public function edit( $id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$result = Role::find($id);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$data = Role::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
$result = $data->update($request->all());
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to update the data!','code'=>500], 500);
return response()->json(['status'=>'success','message'=>'Data updated!','code'=>200], 200);
}
public function delete($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$data = Role::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
$delete = $data->delete();
if(!$delete)
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=>500], 500);
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_roles');
$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()
{
$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);
}
}

344
app/Http/Controllers/UserToActivityController.php

@ -4,209 +4,151 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\UserToActivity;
use App\Models\ReportActivity;
use App\Models\Activity;
use App\Models\Image;
use App\Models\UserToProyek;
use Datatables;
class UserToActivityController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'activity_id' => 'required',
'user_id' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = UserToActivity::create($data);
if($result){
$updateActivity = Activity::find($request->activity_id);
$getWorkingHours = UserToProyek::where('user_id', $request->user_id)->first();
if($updateActivity && $getWorkingHours){
$costPlanOld = $updateActivity==null? 0 : (int)$updateActivity->rencana_biaya;
if($getWorkingHours->uom_standart_rate == "Day"){
$costUser = $getWorkingHours->standart_rate * $updateActivity->duration;
}else if($getWorkingHours->uom_standart_rate == "Hour"){
$costUser = ($getWorkingHours->standart_rate * 8) * $updateActivity->duration; // assumption standart working is 8 hours
}
$costPlanNew = $costPlanOld + $costUser;
$updateActivity->rencana_biaya = $costPlanNew;
$updateActivity->save();
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfull created, and cost plant successfull update '.$costPlanNew,'code'=>200]);
}else{
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfull created','code'=>200]);
}
}else{
return response()->json(['status'=>'failed','message'=>'user to activity gantt Project failed created','code'=>400]);
}
}
public function addMultiple(Request $request){
$users_id = $request->user_id;
$data = UserToActivity::where("activity_id", $request->activity_id);
if($data){
$data->delete();
}
if(is_array($users_id) && count($users_id) > 0){
$countRes = 0;
foreach($users_id as $item){
$dataInsert = array(
"user_id" => $item,
"activity_id" => $request->activity_id,
"role_proyek_id" => $request->role_proyek_id,
"proyek_id" => $request->proyek_id,
"created_by" => $this->currentName
);
$result = UserToActivity::create($dataInsert);
if($result){
$countRes++;
}else{
$countRes--;
}
}
if($countRes > 0){
$allCost = $this->calculateAllCost($request->activity_id, $request->proyek_id);
$dataUpdateCost = array(
"rencana_biaya"=>$allCost,
"updated_by"=> $this->currentName
);
$actUpdate = Activity::find($request->activity_id);
if($actUpdate){
$actUpdate->update($dataUpdateCost);
if($actUpdate->parent_id){
$this->updatedCostPlanning($actUpdate->parent_id);
}
}
return response()->json(['status'=>'success' ,'message'=>'user to activity gantt Project successfull created','code'=>200]);
}else{
return response()->json(['status'=>'success' ,'message'=>'user to activity gantt Project failed created','code'=>400]);
}
}else{
return response()->json(['status'=>'success' ,'message'=>'user to activity gantt Project successfull created','code'=>200]);
}
}
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 = UserToActivity::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'user to activity gantt Project failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = UserToActivity::find($id);
if($data){
$userId = $data->user_id;
$activityId = $data->activity_id;
$delete = $data->delete();
if($delete){
$this->deleteRelative($activityId, $userId);
}
}else{
return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'user to activity gantt Project failed deleted!','code'=>400], 400);
}
}
private function deleteRelative($id, $userId)
{
$dataRa = ReportActivity::where("activity_id", $id)->where("user_id", $userId)->get();
foreach ($dataRa as $ra) {
$image = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($image as $value) {
if(file_exists($this->pathImage.$value->image)){
unlink($this->pathImage.$value->image);
}
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
}
ReportActivity::where("activity_id", $id)->where("user_id", $userId)->delete();
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = UserToActivity::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity');
$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()
{
$data = UserToActivity::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 user to activity gantt, please try again later!','code'=>400], 400);
}
}
public function datatables(Request $request){
$id_activity = $request->query('idact');
$data = UserToActivity::select("assign_hr_to_activity.id as id", "u.name as user_name", "mrp.name as role_name")
->join("m_role_proyek as mrp", "mrp.id", "=", "assign_hr_to_activity.role_proyek_id")
->join("m_users as u", "u.id", "=", "assign_hr_to_activity.user_id")
->where('assign_hr_to_activity.activity_id', $id_activity)
->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-hr-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
{
public function add(Request $request){
$this->validate($request, [
'activity_id' => 'required',
'user_id' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
if(!UserToActivity::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500]);
return response()->json(['status'=>'success','message'=>'Data added!', 'code'=> 200]);
}
public function addMultiple(Request $request){
$users_id = $request->user_id;
$data = UserToActivity::where("activity_id", $request->activity_id);
if($data){
$data->delete();
}
if(is_array($users_id) && count($users_id) > 0){
$countRes = 0;
foreach($users_id as $item){
$dataInsert = array(
"user_id" => $item,
"activity_id" => $request->activity_id,
"role_proyek_id" => $request->role_proyek_id,
"proyek_id" => $request->proyek_id,
"created_by" => $this->currentName
);
$result = UserToActivity::create($dataInsert);
if($result){
$countRes++;
}else{
$countRes--;
}
}
if($countRes == 0)
return response()->json(['status'=>'failed' ,'message'=>'Failed to add data!','code'=> 500]);
$allCost = $this->calculateAllCost($request->activity_id, $request->proyek_id);
$dataUpdateCost = array(
"rencana_biaya"=>$allCost,
"updated_by"=> $this->currentName
);
$actUpdate = Activity::find($request->activity_id);
if($actUpdate){
$actUpdate->update($dataUpdateCost);
if($actUpdate->parent_id){
$this->updatedCostPlanning($actUpdate->parent_id);
}
}
return response()->json(['status'=>'success' ,'message'=>'Data added!','code'=>200]);
}else{
return response()->json(['status'=>'success' ,'message'=>'Data added!','code'=>200]);
}
}
public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$data = UserToActivity::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if(!$data->update($request->all()));
return response()->json(['status'=>'failed','message'=>'Failed to update!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data updated!','code'=>200], 200);
}
public function delete($id)
{
$data = UserToActivity::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400);
if($data->delete()){
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
}
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=> 500], 500);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = UserToActivity::find($id);
if(!$result)
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity');
$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()
{
$data = UserToActivity::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 user to activity gantt, please try again later!','code'=>400], 400);
}
}
public function datatables(Request $request){
$id_activity = $request->query('idact');
$data = UserToActivity::select("assign_hr_to_activity.id as id", "u.name as user_name", "mrp.name as role_name")
->join("m_role_proyek as mrp", "mrp.id", "=", "assign_hr_to_activity.role_proyek_id")
->join("m_users as u", "u.id", "=", "assign_hr_to_activity.user_id")
->where('assign_hr_to_activity.activity_id', $id_activity)
->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-hr-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
}

45
app/Models/AssignMaterial.php

@ -3,6 +3,9 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\RequestMaterial;
use App\Models\Activity;
use Carbon\Carbon;
class AssignMaterial extends Model
{
@ -13,5 +16,47 @@ class AssignMaterial extends Model
protected $fillable = [
'proyek_id', 'activity_id', 'material_id', 'qty_planning', 'budget', 'plan_date','created_at', 'created_by', 'updated_at', 'updated_by'
];
protected $casts = [
'id' => 'integer',
'budget' => 'float',
'qty_planning' => 'float',
];
public static function boot() {
parent::boot();
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);
});
}
}

36
app/Models/RequestMaterial.php

@ -11,23 +11,29 @@ class RequestMaterial extends Model
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $casts = [
'id' => 'integer',
'price' => 'float',
'qty' => 'float',
];
protected $fillable = [
'description',
'required_date',
'qty',
'uom',
'qty_received',
'fom_date',
'pr_date',
'po_date',
'received_date',
'delivery_date',
'status',
'description',
'required_date',
'qty',
'uom',
'qty_received',
'fom_date',
'pr_date',
'po_date',
'received_date',
'delivery_date',
'status',
'proyek_id',
'created_at',
'created_by',
'updated_at',
'updated_by',
'created_at',
'created_by',
'updated_at',
'updated_by',
'price'
];
}

39
app/Models/UserToActivity.php

@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Activity;
class UserToActivity extends Model
{
@ -17,9 +18,41 @@ class UserToActivity extends Model
'version_gantt_id',
'role_proyek_id',
'activity_id',
'created_at',
'created_by',
'updated_at',
'created_at',
'created_by',
'updated_at',
'updated_by'
];
public static function boot() {
parent::boot();
static::created(function($data) {
$activity = Activity::find($data->activity_id);
$getWorkingHours = UserToProyek::where('user_id', $data->user_id)->where('proyek_id', $activity->proyek_id)->first();
$salary = ($getWorkingHours->standart_rate * $activity->duration) * ($getWorkingHours->max_used / 100);
if($getWorkingHours->uom_standart_rate == "Hour")
$salary = ($getWorkingHours->standart_rate * 8) * $activity->duration * ($getWorkingHours->max_used / 100);
$activity->rencana_biaya += $salary;
$activity->save();
});
static::deleted(function($data) {
$activity = Activity::find($data->activity_id);
$getWorkingHours = UserToProyek::where('user_id', $data->user_id)->where('proyek_id', $activity->proyek_id)->first();
$salary = ($getWorkingHours->standart_rate * $activity->duration) * ($getWorkingHours->max_used / 100);
if($getWorkingHours->uom_standart_rate == "Hour"){
$salary = ($getWorkingHours->standart_rate * 8) * $activity->duration * ($getWorkingHours->max_used / 100);
}
$activity->rencana_biaya -= $salary;
$activity->save();
});
}
}

6
config/api.php

@ -1,7 +1,5 @@
<?php
<?php
return [
'golang' => env('API_GOLANG', 'http://127.0.0.1:8090'),
'paxel' => env('API_PAXEL', 'https://paxel.oslogdev.com/db/search'),
'nominatim' => env('API_NOMINATIM', 'https://nominatim.oslogdev.com')
];
?>
?>

4
config/auth.php

@ -1,4 +1,4 @@
<?php
<?php
return [
'defaults' => [
@ -19,4 +19,4 @@ return [
]
];
?>
?>

5
config/jwt.php

@ -0,0 +1,5 @@
<?php
return [
'nominatim' => env('API_NOMINATIM', 'https://nominatim.oslogdev.com')
];
?>

0
sql/001-absensi.sql → database/sql/001-absensi.sql

51
routes/web.php

@ -1,33 +1,12 @@
<?php
/** @var \Laravel\Lumen\Routing\Router $router */
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$router->get('/', function () use ($router) {
return $router->app->version();
});
$router->group(['prefix'=>'api'], function () use ($router) {
$router->post('/login', 'AuthController@login');
$router->post('/role/search', 'RoleController@search');
$router->post('/role/add', 'RoleController@add');
$router->get('/role/edit/{id}', 'RoleController@edit');
$router->put('/role/update/{id}', 'RoleController@update');
$router->delete('/role/delete/{id}', 'RoleController@delete');
$router->get('/role/list', 'RoleController@list');
$router->post('/menu/add', 'MenuController@add');
$router->get('/menu/edit/{id}', 'MenuController@edit');
$router->put('/menu/update/{id}', 'MenuController@update');
@ -41,22 +20,28 @@ $router->group(['prefix'=>'api'], function () use ($router) {
$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->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen');
$router->group(['middleware' => 'auth'], function () use ($router) {
$router->post('/role/search', 'RoleController@search');
$router->post('/role/add', 'RoleController@add');
$router->get('/role/edit/{id}', 'RoleController@edit');
$router->put('/role/update/{id}', 'RoleController@update');
$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->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');
@ -122,9 +107,9 @@ $router->group(['prefix'=>'api'], function () use ($router) {
$router->get('/request-material/list', 'RequestMaterialController@list');
$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');
@ -166,7 +151,7 @@ $router->group(['prefix'=>'api'], function () use ($router) {
$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');
@ -189,7 +174,7 @@ $router->group(['prefix'=>'api'], function () use ($router) {
$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');
@ -296,7 +281,7 @@ $router->group(['prefix'=>'api'], function () use ($router) {
$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');
@ -313,7 +298,7 @@ $router->group(['prefix'=>'api'], function () use ($router) {
$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');
@ -420,5 +405,5 @@ $router->group(['prefix'=>'api'], function () use ($router) {
$router->delete('/project-to-checklist-k3/delete/{id}', 'ProjectToChecklistK3Controller@delete');
$router->get('/project-to-checklist-k3/list', 'ProjectToChecklistK3Controller@list');
});
});
});

Loading…
Cancel
Save