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. 304
      app/Http/Controllers/ActivityController.php
  4. 90
      app/Http/Controllers/ActivityDokumenController.php
  5. 147
      app/Http/Controllers/AssignMaterialController.php
  6. 49
      app/Http/Controllers/AuthController.php
  7. 5
      app/Http/Controllers/Controller.php
  8. 83
      app/Http/Controllers/DashboardController.php
  9. 63
      app/Http/Controllers/DivisiController.php
  10. 87
      app/Http/Controllers/ProjectController.php
  11. 87
      app/Http/Controllers/ProjectDokumenController.php
  12. 135
      app/Http/Controllers/RequestMaterialController.php
  13. 71
      app/Http/Controllers/RoleController.php
  14. 108
      app/Http/Controllers/UserToActivityController.php
  15. 45
      app/Models/AssignMaterial.php
  16. 6
      app/Models/RequestMaterial.php
  17. 33
      app/Models/UserToActivity.php
  18. 2
      config/api.php
  19. 5
      config/jwt.php
  20. 0
      database/sql/001-absensi.sql
  21. 31
      routes/web.php

1
.gitignore vendored

@ -1,5 +1,6 @@
/vendor /vendor
/.idea /.idea
/assets
/storage /storage
Homestead.json Homestead.json
Homestead.yaml 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
------

304
app/Http/Controllers/ActivityController.php

@ -11,7 +11,6 @@ use App\Models\UserToActivity;
use App\Models\CommentActivity; use App\Models\CommentActivity;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
use App\Models\AssignTools; use App\Models\AssignTools;
use App\Models\OfficeHours;
use App\Models\VersionGantt; use App\Models\VersionGantt;
use App\Models\Holiday; use App\Models\Holiday;
use App\Models\ReportActivity; use App\Models\ReportActivity;
@ -534,128 +533,13 @@ class ActivityController extends Controller
public function calculateAllCost($activity_id, $proyek_id) public function calculateAllCost($activity_id, $proyek_id)
{ {
$humanCostPlanning = $this->calculateHuman($activity_id, $proyek_id);
$materialCostPlanning = 0; $materialCostPlanning = 0;
$toolsCostPlanning = 0; $toolsCostPlanning = 0;
$allCost = $humanCostPlanning + $materialCostPlanning + $toolsCostPlanning; $allCost = $materialCostPlanning + $toolsCostPlanning;
return $allCost; 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) public function getPercentagePerDay(Request $request)
{ {
$dataPayload = $request->all(); $dataPayload = $request->all();
@ -928,6 +812,11 @@ class ActivityController extends Controller
$estimatedCost = ($totalRencanaBudget+0); $estimatedCost = ($totalRencanaBudget+0);
} }
$costDeviation = $totalRencanaBudget - $estimatedCost; $costDeviation = $totalRencanaBudget - $estimatedCost;
if($costDeviation > 0){
$potential = "SAVING";
} else {
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
}
$dataResponse = array( $dataResponse = array(
"date" =>$tempDate, "date" =>$tempDate,
@ -940,7 +829,7 @@ class ActivityController extends Controller
"add_cost_to_complete" => 0, "add_cost_to_complete" => 0,
"estimated_at_completion" => $estimatedCost, "estimated_at_completion" => $estimatedCost,
"cost_deviation" => $costDeviation, "cost_deviation" => $costDeviation,
"potential" => $costDeviation > 0 ? "SAVING" : $costDeviation == 0 ? "ON BUDGET" : "OVERRUN" "potential" => $potential,
) )
); );
@ -955,185 +844,6 @@ class ActivityController extends Controller
} }
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) public function getCalculateCurvaSDays(Request $request)
{ {
$dataPayload = $request->all(); $dataPayload = $request->all();

90
app/Http/Controllers/ActivityDokumenController.php

@ -7,44 +7,46 @@ use App\Models\ActivityDokumen;
class ActivityDokumenController extends Controller class ActivityDokumenController extends Controller
{ {
public function dokumenByActivityId($id){ public function dokumenByActivityId($id){
if($id && $id!="" && (int)$id > 0){ if(empty($id) || !is_int((int)$id))
$dataDokumen = ActivityDokumen::where("activity_id", $id)->get(); 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); 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) public function delete($id)
{ {
if($id && $id!="" && (int)$id > 0){ if(empty($id) || !is_int((int)$id))
$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); 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) public function uploadProjectDokumen(Request $request)
{ {
if($request->hasFile('dokumen')){ if(!$request->hasFile('dokumen'))
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400);
$activity_id = $request->activity_id; $activity_id = $request->activity_id;
$dokumen = $request->file('dokumen'); $document = $request->file('dokumen');
$extension = $dokumen->extension(); $name = $document->getClientOriginalName();
$name = $dokumen->getClientOriginalName();
$result = $document->move($this->pathActivityDocument, $name);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
$result = $dokumen->move($this->pathActivityDocument, $name);
if($result){
$data = [ $data = [
'activity_id' => (int)$activity_id, 'activity_id' => (int)$activity_id,
'file' => $name, 'file' => $name,
@ -53,47 +55,41 @@ class ActivityDokumenController extends Controller
$result = ActivityDokumen::create($data); $result = ActivityDokumen::create($data);
if($result){ if(!$result){
return response()->json(['status'=>'success','message'=>'file upload is successfully!','code'=>200], 200);
}else{
unlink($this->pathActivityDocument.$name); unlink($this->pathActivityDocument.$name);
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
} }
}else{ return response()->json(['status'=>'success','message'=>'Upload success!','code'=>200], 200);
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){ public function searchDocProject(Request $request){
$payload = $request->all(); $payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_document_activity'); $dataBuilder = $this->setUpPayload($payload, 'm_document_activity');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
} }
public function downloadDokumen($id) public function downloadDokumen($id)
{ {
if($id && $id!="" && (int)$id > 0){ if(empty($id) || !is_int((int)$id))
$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); 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);
} }
} }

147
app/Http/Controllers/AssignMaterialController.php

@ -4,50 +4,12 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
use App\Models\MaterialResource;
use App\Models\RequestMaterial; use App\Models\RequestMaterial;
use App\Models\Activity;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use Datatables; use Datatables;
class AssignMaterialController extends Controller 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){ public function add(Request $request){
$this->validate($request, [ $this->validate($request, [
@ -60,117 +22,57 @@ class AssignMaterialController extends Controller
$currentStock = $checkStock->qty; $currentStock = $checkStock->qty;
$price = $checkStock->price; $price = $checkStock->price;
if((int)$currentStock < (int)$request->qty_planning){ if((int)$currentStock < (int)$request->qty_planning){
return response()->json(['status'=>'failed','message'=>'Not enough stock !','code'=>400]); return response()->json(['status'=>'failed','message'=>'Stock is not enough!','code'=> 500]);
die();
} }
$data = $request->all(); $data = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$data['budget'] = $price; $data['budget'] = $price;
$result = AssignMaterial::create($data); $result = AssignMaterial::create($data);
if($result){ if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500]);
$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; return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200]);
$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){ public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = AssignMaterial::find($id); $data = AssignMaterial::find($id);
if($data){ if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$result = $data->update($request->all()); $result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Assign material not found!','code'=>400], 400);
die();
}
if($result){ if($result)
return response()->json(['status'=>'success','message'=>'Assign material successfully updated!','code'=>200], 200); return response()->json(['status'=>'success','message'=> 'Data updated!','code'=> 200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Assign material failed updated!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'Failed to update!','code'=> 500], 500);
}
} }
public function delete($id) public function delete($id)
{ {
$data = AssignMaterial::find($id); $data = AssignMaterial::where('id', $id)->first();
if($data){ if($data->delete())
$id = $data->material_id; return response()->json(['status'=>'success','message'=>'Data deleted!','code'=> 200], 200);
$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'=>'failed','message'=>'Failed to delete!','code'=> 500], 500);
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){ public function edit($id){
if(!$id || (int) $id < 0 || $id==""){ if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = AssignMaterial::find($id); $result = AssignMaterial::find($id);
if($result){ if($result)
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); 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); return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
}
} }
public function search(Request $request) public function search(Request $request)
@ -189,11 +91,10 @@ class AssignMaterialController extends Controller
$data = AssignMaterial::all(); $data = AssignMaterial::all();
$countData = $data->count(); $countData = $data->count();
if($data){ if($data)
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); 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); return response()->json(['status'=>'failed','message'=>'Failed to get the data!','code'=> 500], 500);
}
} }
public function datatables(Request $request){ public function datatables(Request $request){

49
app/Http/Controllers/AuthController.php

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

5
app/Http/Controllers/Controller.php

@ -251,11 +251,6 @@ class Controller extends BaseController
return $totalCost; return $totalCost;
} }
private function calculateToolsCost($activity_id, $proyek_id)
{
}
protected function updatedCostPlanning($id) protected function updatedCostPlanning($id)
{ {
$sumBiaya = Activity::select(DB::raw('sum(cast(rencana_biaya as double precision))'))->where("parent_id", $id)->first(); $sumBiaya = Activity::select(DB::raw('sum(cast(rencana_biaya as double precision))'))->where("parent_id", $id)->first();

83
app/Http/Controllers/DashboardController.php

@ -6,8 +6,7 @@ use Illuminate\Http\Request;
use App\Models\Project; use App\Models\Project;
use App\Models\Activity; use App\Models\Activity;
use App\Models\ReportActivity; use App\Models\ReportActivity;
use App\Models\UserToActivity; use App\Models\Role;
use DB;
class DashboardController extends Controller class DashboardController extends Controller
{ {
@ -25,11 +24,10 @@ class DashboardController extends Controller
$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); $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){ 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); 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){ public function getMaxVersionGantt($id){
@ -48,14 +46,12 @@ class DashboardController extends Controller
foreach ($dataMaxVersionGantt as $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', '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(); $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); $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){ if(!$dataFinal)
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); 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() public function list()
@ -63,30 +59,22 @@ class DashboardController extends Controller
$data = Role::all(); $data = Role::all();
$countData = $data->count(); $countData = $data->count();
if($data){ 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); 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) { public function getActivityByProjectId($projectId) {
$output = []; $output = [];
$data = Activity::select('id')->where('proyek_id', $projectId)->get(); $data = Activity::select('id')->where('proyek_id', $projectId)->get();
if (count($data) > 0) {
foreach ($data as $actData) { foreach ($data as $actData) {
$output[] = $actData->id; $output[] = $actData->id;
} }
}
return $output; return $output;
} }
/* for statusProyek, I want something output like this /*
const statusProyek = [ const statusProyek = [
{ {
"id": "1", "id": "1",
@ -109,17 +97,14 @@ class DashboardController extends Controller
*/ */
public function statusProyek(Request $request) { public function statusProyek(Request $request) {
$dataPayload = $request->all(); $dataPayload = $request->all();
$reqProject = []; $reqProject = $dataFinal = [];
$dataFinal = [];
if (!isset($dataPayload['project_id'])) { if (!isset($dataPayload['project_id']))
return response()->json(['status'=>'failed','message'=>'Undefined project_id','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'Undefined project_id','code'=>400], 400);
}
foreach ($dataPayload['project_id'] as $val) { foreach ($dataPayload['project_id'] as $val) {
$prj["project_id"] = $val; $prj["project_id"] = $val;
$prj["activity_id"] = $this->getActivityByProjectId($val); $prj["activity_id"] = $this->getActivityByProjectId($val);
$reqProject[] = $prj; $reqProject[] = $prj;
} }
@ -133,24 +118,20 @@ class DashboardController extends Controller
$sum_jumlah_pekerjaan = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->sum("jumlah_pekerjaan"); $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 = 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_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"); $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(); $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; $current_progress = 0;
foreach($progress_actual as $objRow) { foreach($progress_actual as $objRow) {
$current_progress += ($objRow->bobot_planning * $objRow->persentase_progress) / 100; $current_progress += ($objRow->bobot_planning * $objRow->persentase_progress) / 100;
} }
if (count($reqProject[$i]['activity_id']) > 0) { if (count($reqProject[$i]['activity_id']) > 0) {
for ($j=0; $j < count($reqProject[$i]['activity_id']); $j++) { 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"); $sum_job_count_report = ReportActivity::whereIn('activity_id', $reqProject[$i]['activity_id'])->sum("job_count_report");
} }
} }
if (!isset($queryProject->id))
if (!isset($queryProject->id)) {
return response()->json(['status'=>'failed','message'=>'Project with id='.$reqProject[$i]['project_id'].' is not found!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'Project with id='.$reqProject[$i]['project_id'].' is not found!','code'=>400], 400);
}
$now = time(); $now = time();
$akhir_proyek = strtotime($queryProject->akhir_proyek); $akhir_proyek = strtotime($queryProject->akhir_proyek);
@ -176,31 +157,28 @@ class DashboardController extends Controller
} }
} }
if($dataFinal){ if(empty($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); 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) public function curvaS(Request $request)
{ {
$dataPayload = $request->all(); $dataPayload = $request->all();
$dataMaxVersionGantt = []; $dataMaxVersionGantt = [];
$dataFinal=[];
foreach ($dataPayload['project_id'] as $val) { foreach ($dataPayload['project_id'] as $val) {
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); $dataMaxVersionGantt[] = $this->getMaxVersionGantt($val);
} }
$dataFinal=[];
foreach ($dataMaxVersionGantt as $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(); $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'); $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++) { for ($i=0; $i < count($data); $i++) {
$tmpp = 0; $tmpp = $tmpa = $tmpbc = $tmpac = 0;
$tmpa = 0;
$tmpbc = 0;
$tmpac = 0;
for ($x=$i; $x >= 0 ; $x--) { for ($x=$i; $x >= 0 ; $x--) {
$tmpp += $data[$x]['bobot_planning']; $tmpp += $data[$x]['bobot_planning'];
$tmpa += ($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100; $tmpa += ($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100;
@ -209,6 +187,7 @@ class DashboardController extends Controller
} }
$data[$i]['cal_bobot_p'] = round($tmpp,2); $data[$i]['cal_bobot_p'] = round($tmpp,2);
if($i > 0 ){ if($i > 0 ){
if($data[$i-1]['cal_bobot_a'] != null){ if($data[$i-1]['cal_bobot_a'] != null){
if($data[$i-1]['cal_bobot_a'] == round($tmpa,2)){ if($data[$i-1]['cal_bobot_a'] == round($tmpa,2)){
@ -219,12 +198,6 @@ class DashboardController extends Controller
}else{ }else{
$data[$i]['cal_bobot_a'] = null; $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'] != null){
if($data[$i-1]['cal_actual_cost'] == round($tmpac,2)){ if($data[$i-1]['cal_actual_cost'] == round($tmpac,2)){
$data[$i]['cal_actual_cost'] = null; $data[$i]['cal_actual_cost'] = null;
@ -235,18 +208,18 @@ class DashboardController extends Controller
$data[$i]['cal_actual_cost'] = null; $data[$i]['cal_actual_cost'] = null;
} }
}else{ }else{
$data[$i]['cal_bobot_a'] = round($tmpa,2);
$data[$i]['cal_actual_cost'] = round($tmpac,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); $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){ if(!$dataFinal)
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); 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);
} }
} }

63
app/Http/Controllers/DivisiController.php

@ -12,64 +12,64 @@ class DivisiController extends Controller
'name' => 'required', 'name' => 'required',
'description' => 'required' 'description' => 'required'
]); ]);
$data = $request->all(); $data = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$result = Divisi::create($data); $result = Divisi::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'Master divisi successfull created','code'=>200]); if(!$result)
}else{ return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500]);
return response()->json(['status'=>'failed','message'=>'Master divisi failed created','code'=>400]);
} return response()->json(['status'=>'success','message'=>'Data created!','code'=>200]);
} }
public function update(Request $request, $id){ public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = Divisi::find($id); $data = Divisi::find($id);
if($data){
if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
$result = $data->update($request->all()); $result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Master divisi not found!','code'=>400], 400);
die();
}
if($result){ if(!$result)
return response()->json(['status'=>'success','message'=>'Master divisi successfully updated!','code'=>200], 200); return response()->json(['status'=>'failed','message'=> 'Update failed!','code'=> 500], 500);
}else{
return response()->json(['status'=>'failed','message'=>'Master divisi failed updated!','code'=>400], 400); return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200);
}
} }
public function delete($id) 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); $data = Divisi::find($id);
if($data){ if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
$delete = $data->delete(); $delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data Master divisi not found!','code'=>400], 400);
die();
}
if($delete){ if(!$delete)
return response()->json(['status'=>'success','message'=>'Master divisi successfully deleted!','code'=>200], 200); return response()->json(['status'=>'failed','message'=> 'Delete failed!','code'=> 500], 500);
}else{
return response()->json(['status'=>'failed','message'=>'Master divisi failed deleted!','code'=>400], 400); return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200);
}
} }
public function search(Request $request) public function search(Request $request)
{ {
$payload = $request->all(); $payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_divisi'); $dataBuilder = $this->setUpPayload($payload, 'm_divisi');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
} }
@ -78,10 +78,9 @@ class DivisiController extends Controller
$data = Divisi::all(); $data = Divisi::all();
$countData = $data->count(); $countData = $data->count();
if($data){ 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); 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);
}
} }
} }

87
app/Http/Controllers/ProjectController.php

@ -14,12 +14,8 @@ use App\Models\ProjectCharter;
use App\Models\ProjectApproval; use App\Models\ProjectApproval;
use App\Models\ProjectMileStone; use App\Models\ProjectMileStone;
use App\Models\ProjectParticipants; use App\Models\ProjectParticipants;
use App\Models\UserToVersionGantt;
use App\Models\RequestMaterial;
use App\Models\ShowHideColumn; use App\Models\ShowHideColumn;
use App\Models\ToolsProject;
use App\Models\VersionGantt; use App\Models\VersionGantt;
use App\Models\MaterialProject;
use App\Models\Image; use App\Models\Image;
use App\Models\CommentActivity; use App\Models\CommentActivity;
use App\Models\Link; use App\Models\Link;
@ -30,6 +26,7 @@ use App\Models\OfficeHours;
class ProjectController extends Controller class ProjectController extends Controller
{ {
public function add(Request $request) public function add(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
@ -46,51 +43,43 @@ class ProjectController extends Controller
$result = Project::create($data); $result = Project::create($data);
if($result){ if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500], 500);
$this->createOfficeHours($result->id); $this->createOfficeHours($result->id);
$dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first(); $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'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200);
return response()->json(['status'=>'failed','message'=>'add data project failed!','code'=>400], 400);
}
} }
public function edit($id){ public function edit($id){
if(!$id || (int) $id < 0 || $id==""){ if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = Project::find($id); $result = Project::find($id);
if($result){ if(!$result)
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data project, please try again later!','code'=>400], 400); return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200);
}
} }
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
if(!$id || (int) $id < 0 || $id==""){ if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = Project::find($id); $data = Project::find($id);
if($data){ if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
$result = $data->update($request->all()); $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'=>'failed','message'=> 'Failed to update!','code'=> 500], 500);
if($result){ return response()->json(['status'=>'success','message'=>'Data updated!','code' => 200], 200);
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) private function createOfficeHours($proyek_id)
@ -123,20 +112,15 @@ class ProjectController extends Controller
{ {
$data = Project::find($id); $data = Project::find($id);
if($data){ if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$this->deleteRelative($id); $this->deleteRelative($id);
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data project not found!','code'=>400], 400);
die();
}
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Delete failed!','code'=> 500], 500);
if($delete){ return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
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) private function deleteRelative($project_id)
@ -210,11 +194,13 @@ class ProjectController extends Controller
public function search(Request $request) public function search(Request $request)
{ {
$payload = $request->all(); $payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek'); $dataBuilder = $this->setUpPayload($payload, 'm_proyek');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
} }
@ -223,21 +209,22 @@ class ProjectController extends Controller
$data = Project::all(); $data = Project::all();
$countData = $data->count(); $countData = $data->count();
if($data){ 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); 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){ 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') $data = UserToActivity::select("assign_hr_to_activity.user_id as user_id","m_proyek.*")
->groupBy("m_proyek.proyek_id")->get(); ->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);
if($data){
return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); 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);
}
} }
} }

87
app/Http/Controllers/ProjectDokumenController.php

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

135
app/Http/Controllers/RequestMaterialController.php

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

71
app/Http/Controllers/RoleController.php

@ -4,8 +4,10 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Role; use App\Models\Role;
class RoleController extends Controller class RoleController extends Controller
{ {
public function add(Request $request) public function add(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
@ -19,78 +21,70 @@ class RoleController extends Controller
$result = Role::create($data); $result = Role::create($data);
if($result){ if(!$result)
return response()->json(['status'=>'success','message'=>'add data role successfully!','code'=>200], 200); return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=>500], 500);
}else{
return response()->json(['status'=>'failed','message'=>'add data role failed!','code'=>400], 400); return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200);
}
} }
public function edit($id){ public function edit( $id){
if(!$id || (int) $id < 0 || $id==""){ if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = Role::find($id); $result = Role::find($id);
if($result){ if(!$result)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); 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) public function update(Request $request, $id)
{ {
if(!$id || (int) $id < 0 || $id==""){ if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = Role::find($id); $data = Role::find($id);
if($data){ if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
$result = $data->update($request->all()); $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'=>'failed','message'=>'Failed to update the data!','code'=>500], 500);
if($result){ return response()->json(['status'=>'success','message'=>'Data updated!','code'=>200], 200);
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) 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); $data = Role::find($id);
if($data){ if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
$delete = $data->delete(); $delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data role not found!','code'=>400], 400);
die();
}
if(!$delete)
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=>500], 500);
if($delete){ return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
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) public function search(Request $request)
{ {
$payload = $request->all(); $payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_roles'); $dataBuilder = $this->setUpPayload($payload, 'm_roles');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
} }
@ -99,10 +93,9 @@ class RoleController extends Controller
$data = Role::all(); $data = Role::all();
$countData = $data->count(); $countData = $data->count();
if($data){ 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); 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);
} }
} }

108
app/Http/Controllers/UserToActivityController.php

@ -4,10 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\UserToActivity; use App\Models\UserToActivity;
use App\Models\ReportActivity;
use App\Models\Activity; use App\Models\Activity;
use App\Models\Image;
use App\Models\UserToProyek;
use Datatables; use Datatables;
class UserToActivityController extends Controller class UserToActivityController extends Controller
@ -17,37 +14,20 @@ class UserToActivityController extends Controller
'activity_id' => 'required', 'activity_id' => 'required',
'user_id' => 'required' 'user_id' => 'required'
]); ]);
$data = $request->all(); $data = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$result = UserToActivity::create($data); if(!UserToActivity::create($data))
if($result){ return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500]);
$updateActivity = Activity::find($request->activity_id);
$getWorkingHours = UserToProyek::where('user_id', $request->user_id)->first(); return response()->json(['status'=>'success','message'=>'Data added!', 'code'=> 200]);
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){ public function addMultiple(Request $request){
$users_id = $request->user_id; $users_id = $request->user_id;
$data = UserToActivity::where("activity_id", $request->activity_id); $data = UserToActivity::where("activity_id", $request->activity_id);
if($data){ if($data){
$data->delete(); $data->delete();
} }
@ -55,7 +35,6 @@ class UserToActivityController extends Controller
if(is_array($users_id) && count($users_id) > 0){ if(is_array($users_id) && count($users_id) > 0){
$countRes = 0; $countRes = 0;
foreach($users_id as $item){ foreach($users_id as $item){
$dataInsert = array( $dataInsert = array(
"user_id" => $item, "user_id" => $item,
"activity_id" => $request->activity_id, "activity_id" => $request->activity_id,
@ -63,9 +42,7 @@ class UserToActivityController extends Controller
"proyek_id" => $request->proyek_id, "proyek_id" => $request->proyek_id,
"created_by" => $this->currentName "created_by" => $this->currentName
); );
$result = UserToActivity::create($dataInsert); $result = UserToActivity::create($dataInsert);
if($result){ if($result){
$countRes++; $countRes++;
}else{ }else{
@ -73,7 +50,9 @@ class UserToActivityController extends Controller
} }
} }
if($countRes > 0){ if($countRes == 0)
return response()->json(['status'=>'failed' ,'message'=>'Failed to add data!','code'=> 500]);
$allCost = $this->calculateAllCost($request->activity_id, $request->proyek_id); $allCost = $this->calculateAllCost($request->activity_id, $request->proyek_id);
$dataUpdateCost = array( $dataUpdateCost = array(
"rencana_biaya"=>$allCost, "rencana_biaya"=>$allCost,
@ -86,74 +65,38 @@ class UserToActivityController extends Controller
$this->updatedCostPlanning($actUpdate->parent_id); $this->updatedCostPlanning($actUpdate->parent_id);
} }
} }
return response()->json(['status'=>'success' ,'message'=>'Data added!','code'=>200]);
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{ }else{
return response()->json(['status'=>'success' ,'message'=>'user to activity gantt Project successfull created','code'=>200]); return response()->json(['status'=>'success' ,'message'=>'Data added!','code'=>200]);
} }
} }
public function update(Request $request, $id){ public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = UserToActivity::find($id); $data = UserToActivity::find($id);
if($data){ if(!$data)
$result = $data->update($request->all()); return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
}else{
return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400);
die();
}
if($result){ if(!$data->update($request->all()));
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfully updated!','code'=>200], 200); return response()->json(['status'=>'failed','message'=>'Failed to update!','code'=> 500], 500);
}else{
return response()->json(['status'=>'failed','message'=>'user to activity gantt Project failed updated!','code'=>400], 400); return response()->json(['status'=>'success','message'=>'Data updated!','code'=>200], 200);
}
} }
public function delete($id) public function delete($id)
{ {
$data = UserToActivity::find($id); $data = UserToActivity::find($id);
if($data){ 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); return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400);
die();
}
if($data->delete()){
if($delete){ return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
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) return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=> 500], 500);
{
$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){ public function edit($id){
@ -164,11 +107,10 @@ class UserToActivityController extends Controller
$result = UserToActivity::find($id); $result = UserToActivity::find($id);
if($result){ 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); 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) public function search(Request $request)

45
app/Models/AssignMaterial.php

@ -3,6 +3,9 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\RequestMaterial;
use App\Models\Activity;
use Carbon\Carbon;
class AssignMaterial extends Model class AssignMaterial extends Model
{ {
@ -14,4 +17,46 @@ class AssignMaterial extends Model
protected $fillable = [ protected $fillable = [
'proyek_id', 'activity_id', 'material_id', 'qty_planning', 'budget', 'plan_date','created_at', 'created_by', 'updated_at', 'updated_by' 'proyek_id', 'activity_id', 'material_id', 'qty_planning', 'budget', 'plan_date','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);
});
}
} }

6
app/Models/RequestMaterial.php

@ -11,6 +11,12 @@ class RequestMaterial extends Model
const CREATED_AT = 'created_at'; const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $casts = [
'id' => 'integer',
'price' => 'float',
'qty' => 'float',
];
protected $fillable = [ protected $fillable = [
'description', 'description',
'required_date', 'required_date',

33
app/Models/UserToActivity.php

@ -3,6 +3,7 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\Activity;
class UserToActivity extends Model class UserToActivity extends Model
{ {
@ -22,4 +23,36 @@ class UserToActivity extends Model
'updated_at', 'updated_at',
'updated_by' '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();
});
}
} }

2
config/api.php

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

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

31
routes/web.php

@ -1,18 +1,5 @@
<?php <?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) { $router->get('/', function () use ($router) {
return $router->app->version(); return $router->app->version();
}); });
@ -20,14 +7,6 @@ $router->get('/', function () use ($router) {
$router->group(['prefix'=>'api'], function () use ($router) { $router->group(['prefix'=>'api'], function () use ($router) {
$router->post('/login', 'AuthController@login'); $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->post('/menu/add', 'MenuController@add');
$router->get('/menu/edit/{id}', 'MenuController@edit'); $router->get('/menu/edit/{id}', 'MenuController@edit');
$router->put('/menu/update/{id}', 'MenuController@update'); $router->put('/menu/update/{id}', 'MenuController@update');
@ -41,15 +20,21 @@ $router->group(['prefix'=>'api'], function () use ($router) {
$router->delete('/role-menu/delete-byrole/{id}', 'RoleMenuController@deleteByRole'); $router->delete('/role-menu/delete-byrole/{id}', 'RoleMenuController@deleteByRole');
$router->post('/role-menu/search', 'RoleMenuController@search'); $router->post('/role-menu/search', 'RoleMenuController@search');
$router->get('/role-menu/get-role/{id}', 'RoleMenuController@listMenu'); $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->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->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen');
$router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId'); $router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId');
$router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete'); $router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete');
$router->post('/document-project/search', 'ProjectDokumenController@searchDocProject'); $router->post('/document-project/search', 'ProjectDokumenController@searchDocProject');
$router->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen');
$router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen'); $router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen');
$router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId'); $router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId');

Loading…
Cancel
Save