farhantock
1 year ago
56 changed files with 9719 additions and 4652 deletions
@ -0,0 +1,29 @@
|
||||
<?php |
||||
|
||||
namespace App\Console\Commands; |
||||
|
||||
use Illuminate\Console\Command; |
||||
use App\Helpers\MasterFunctionsHelper; |
||||
use App\Models\Project; |
||||
|
||||
class CalculateSCurve extends Command |
||||
{ |
||||
protected $signature = 'calculate:scurve {project_id}'; |
||||
|
||||
protected $description = 'Calculate S Curve'; |
||||
|
||||
public function handle() |
||||
{ |
||||
$project_id = $this->argument('project_id'); |
||||
$project = Project::find($project_id); |
||||
|
||||
$project->calculation_status = true; |
||||
$project->save(); |
||||
|
||||
$data = MasterFunctionsHelper::CalculateSCurve($project_id); |
||||
|
||||
$project->scurve = json_encode($data); |
||||
$project->calculation_status = true; |
||||
$project->save(); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,355 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\{ |
||||
User, |
||||
Project, |
||||
Activity, |
||||
HierarchyFtth, |
||||
ProjectComment, |
||||
VersionGantt, |
||||
UserToProyek, |
||||
UserToActivity, |
||||
Presence |
||||
}; |
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Support\Facades\DB; |
||||
use App\Helpers\MasterFunctionsHelper; |
||||
use Carbon\Carbon; |
||||
|
||||
class ProjectCarausellController extends Controller |
||||
{ |
||||
// public function invoke($id) |
||||
// { |
||||
// $dateStart = Carbon::now()->startOfDay(); |
||||
// $dateEnd = Carbon::now()->endOfDay(); |
||||
// // Mengatur waktu awal bulan dan mengurangkan 1 tahun |
||||
// $startDate = Carbon::now()->startOfMonth()->subYear()->format('Y-m-d'); |
||||
// // Mengatur waktu saat ini dan mengurangkan 1 tahun |
||||
// $endDate = Carbon::now()->subYear()->format('Y-m-d'); |
||||
|
||||
// if(empty($id) || !is_int((int)$id)){ |
||||
// return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
// } |
||||
|
||||
// $result = Project::select('id','nama','budget_health','kode_sortname','pm_id','rencana_biaya','company','scurve','calculation_status')->find($id); |
||||
// if(!$result){ |
||||
// return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); |
||||
// } |
||||
// $ganttData = VersionGantt::where('proyek_id', $id) |
||||
// ->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete') |
||||
// ->get(); |
||||
|
||||
// // Get Id Gantt & hierarchy_ftth_id |
||||
// $gantt_id = $ganttData->pluck('id')->toArray(); |
||||
// $hierarchy_ftth_id = $ganttData->pluck('hierarchy_ftth_id')->toArray(); |
||||
|
||||
// // Heararchy |
||||
// $finalData = []; |
||||
// if($hierarchy_ftth_id){ |
||||
// $ftth = HierarchyFtth::whereIn('id',$hierarchy_ftth_id)->get(); |
||||
// if($ftth->first() != null) |
||||
// { |
||||
// array_push($finalData, $ftth->first()); |
||||
// } |
||||
// if($ftth->where('parent_id','!=', null)->first()){ |
||||
// $this->getParents($finalData, $ftth->pluck('parent_id')->toArray()); |
||||
// } |
||||
// } else { |
||||
// return $finalData; |
||||
// } |
||||
|
||||
// // SCurve |
||||
// $SCurve = MasterFunctionsHelper::getSCurveCarausell($result['id'],$gantt_id,'week'); |
||||
|
||||
// // Overdue Activities |
||||
// $endDate = Activity::where('proyek_id', $result['id']) |
||||
// ->orderByDesc('end_date') |
||||
// ->value('end_date'); |
||||
// $overdueActivities = Activity::whereIn('version_gantt_id', $gantt_id)->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$endDate)->orderBy('end_date', 'asc')->get(); |
||||
|
||||
// // Project Comment |
||||
// $projectComment = ProjectComment::query() |
||||
// ->select('project_id','gantt_id','comment','created_at') |
||||
// ->where('project_id',$result['id']) |
||||
// ->whereIn('gantt_id',$gantt_id) |
||||
// ->get(); |
||||
|
||||
// // Manpower |
||||
// $manCount = UserToProyek::where('proyek_id', $result['id'])->count(); |
||||
// // Assigned |
||||
// $utAct = UserToActivity::query() |
||||
// ->whereIn('version_gantt_id', $gantt_id) |
||||
// ->get(); |
||||
// // Actual |
||||
// $presence = Presence::whereBetween('clock_in', [$dateStart, $dateEnd]) |
||||
// ->select('m_users.name','m_users.ktp_number') |
||||
// ->join('m_users','t_clock_in_out.user_id','m_users.id') |
||||
// ->get(); |
||||
|
||||
// // Report distribution |
||||
// $reportsDistribution = DB::table('assign_material_to_activity as ama') |
||||
// ->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit', |
||||
// 'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date') |
||||
// ->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id') |
||||
// ->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id') |
||||
// ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
||||
// ->join('m_users as u', 'u.id', '=', 'ram.user_id') |
||||
// ->where('ama.proyek_id', '=', $result['id']) |
||||
// ->whereNotNull('ram.lat') |
||||
// ->whereBetween('ram.report_date', [$startDate, $startDate]); |
||||
|
||||
// // Check Existing |
||||
// $actualStartExist = Activity::whereIn('version_gantt_id',$gantt_id)->whereNotNull('actual_start')->exists(); |
||||
// $actualEndExist = Activity::whereIn('version_gantt_id',$gantt_id)->exists(); |
||||
|
||||
// $query = Activity::query()->whereIn('version_gantt_id', $gantt_id); |
||||
// // Start |
||||
// if ($actualStartExist) { |
||||
// $startDate = $query->select('version_gantt_id',DB::raw('MIN(start_date) as min_start')) |
||||
// ->groupBy('version_gantt_id') |
||||
// ->get(); |
||||
// } else { |
||||
// $startDate = $query->select('version_gantt_id',DB::raw('MIN(start_date) as min_start','version_gantt_id')) |
||||
// ->groupBy('version_gantt_id') |
||||
// ->orderBy('min_start', 'ASC') |
||||
// ->get(); |
||||
// } |
||||
// // End |
||||
// if($actualEndExist) |
||||
// { |
||||
// $maxIds = $query->selectRaw('MAX(id) as max_id') |
||||
// ->groupBy('version_gantt_id') |
||||
// ->pluck('max_id', 'version_gantt_id'); |
||||
|
||||
// $endDate = Activity::whereIn('id', $maxIds)->select('end_date','version_gantt_id')->get(); |
||||
// } |
||||
|
||||
// $plannedStart = $query->selectRaw('MIN(planned_start) as min_planned_start, version_gantt_id') |
||||
// ->groupBy('version_gantt_id') |
||||
// ->orderBy('min_planned_start') |
||||
// ->get(); |
||||
// $plannedEnd = $query->selectRaw('MAX(planned_end) as max_planned_end, version_gantt_id') |
||||
// ->groupBy('version_gantt_id') |
||||
// ->orderByDesc('max_planned_end') |
||||
// ->get(); |
||||
|
||||
// $projectManager = User::whereId($result['pm_id'])->value('name'); |
||||
// $key =1; |
||||
// foreach($ganttData as $gantt) |
||||
// { |
||||
// $pStart =$plannedStart->where('version_gantt_id',$gantt['id'])->first(); |
||||
// $actStart =$startDate->where('version_gantt_id',$gantt['id'])->first(); |
||||
// $actEnd =$endDate->where('version_gantt_id',$gantt['id'])->first(); |
||||
// $pEnd =$plannedEnd->where('version_gantt_id',$gantt['id'])->first(); |
||||
// $matchingActivities = $overdueActivities->where('version_gantt_id', $gantt['id']); |
||||
// $matchingProjectComment = $projectComment->where('version_gantt_id', $gantt['id']); |
||||
// $usAtc = $utAct->where('version_gantt_id', $gantt['id']); |
||||
// $arr[] = |
||||
// [ |
||||
// 'gantt_id'=>$gantt['id'], |
||||
// 'projectManager'=>$projectManager, |
||||
// 'name_version'=>$gantt['name_version'], |
||||
// 'cost_to_complete'=>$gantt['cost_to_complete'], |
||||
// 'schedule' => [ |
||||
// 'plannedStart'=> $pStart['min_planned_start'], |
||||
// 'actual_start'=>$actStart['min_start'], |
||||
// 'plannedFinish'=>$pEnd['max_planned_end'], |
||||
// 'estimatedFinish'=>$actEnd['end_date'] |
||||
// ], |
||||
// 'manpower'=>$manCount, |
||||
// 'assigned'=>$usAtc->toArray(), |
||||
// 'actual'=>count($presence->toArray()), |
||||
// 'overdue_activities'=>$matchingActivities->toArray(), |
||||
// 'project_comment'=>$matchingProjectComment->toArray(), |
||||
// 'hierarchy'=>$finalData, |
||||
// 'proyek'=>$result, |
||||
// 'key'=>$key++ |
||||
// ]; |
||||
// } |
||||
// return response()->json(['status'=>'success','code'=> 200,'data'=>$arr,'report_distribution'=>$reportsDistribution,'sCurve'=>$SCurve, 'count'=>count($arr)], 200); |
||||
// } |
||||
|
||||
// public function getParents(&$data, $id){ |
||||
// $ftth = HierarchyFtth::whereIn('id',$id)->get(); |
||||
// array_push($data, $ftth); |
||||
// if ($ftth->pluck('parent_id')->toArray()) { |
||||
// $this->getParents($data, $ftth->pluck('parent_id')->toArray()); |
||||
// } |
||||
// } |
||||
|
||||
public function invoke() |
||||
{ |
||||
// Data Master |
||||
// Mengatur waktu awal bulan dan mengurangkan 1 tahun |
||||
$startDate = Carbon::now()->startOfMonth()->subYear()->format('Y-m-d'); |
||||
// Mengatur waktu saat ini dan mengurangkan 1 tahun |
||||
$endDate = Carbon::now()->subYear()->format('Y-m-d'); |
||||
$ganttData = VersionGantt::query() |
||||
->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete','proyek_id') |
||||
->get(); |
||||
$projectData = Project::query() |
||||
->select("id","nama","kode_sortname","pm_id","budget_health","calculation_status","mulai_proyek","akhir_proyek","rencana_biaya","company","scurve") |
||||
->get(); |
||||
// nested looping |
||||
$arr = []; |
||||
foreach($projectData as $project) { |
||||
$ganttForProject = []; |
||||
foreach ($ganttData as $gantt) { |
||||
if ($gantt['proyek_id'] === $project['id']) { |
||||
// Gantt |
||||
$ganttForProject[] = [ |
||||
"gantt_id" => $gantt['id'], |
||||
'proyek_id' => $gantt['proyek_id'], |
||||
"name_version" => $gantt['name_version'], |
||||
"hierarchy_ftth_id" => $gantt['hierarchy_ftth_id'], |
||||
"cost_to_complete" => $gantt['cost_to_complete'], |
||||
]; |
||||
// Activity |
||||
$activity = Activity::query() |
||||
->select('id','name','proyek_id','version_gantt_id','type_activity','parent_id','kode_sortname','rencana_biaya','start_date','end_date','biaya_actual','persentase_bobot','persentase_progress','planned_start','planned_end','actual_start','actual_end') |
||||
->whereNull('parent_id') |
||||
->where([ |
||||
["proyek_id", $project['id']], |
||||
["version_gantt_id", $gantt['id']] |
||||
]) |
||||
->first(); |
||||
$actualStartExist = Activity::query() |
||||
->where('version_gantt_id', $gantt['id']) |
||||
->whereNotNull('actual_start') |
||||
->exists(); |
||||
$actualEndExist = Activity::query() |
||||
->where('version_gantt_id', $gantt['id']) |
||||
->exists(); |
||||
$query = Activity::where('version_gantt_id', $gantt['id']); |
||||
|
||||
if ($actualStartExist) { |
||||
$startDate = $query->orderBy('actual_start')->value('start_date'); |
||||
} else { |
||||
$startDate = $query->orderBy('start_date')->value('start_date'); |
||||
} |
||||
if($actualEndExist) |
||||
{ |
||||
$maxEndDate = $query->max('id'); |
||||
$endDate = $query->where('id',$maxEndDate)->first()->end_date; |
||||
} |
||||
|
||||
$plannedStart = Activity::where('version_gantt_id', $gantt['id']) |
||||
->orderBy('planned_start') |
||||
->value('planned_start'); |
||||
$plannedEnd = Activity::where('version_gantt_id', $gantt['id']) |
||||
->orderByDesc('planned_end') |
||||
->value('planned_end'); |
||||
|
||||
// SCurve |
||||
$req = (object)[ |
||||
'project_id' => $project['id'], |
||||
'gantt_id' => $gantt['id'], |
||||
'period' => 'week', |
||||
]; |
||||
$SCurve = MasterFunctionsHelper::getSCurveCarausell($req); |
||||
|
||||
// Overdue |
||||
$endDate = Activity::where('proyek_id', $project['id']) |
||||
->orderByDesc('end_date') |
||||
->value('end_date'); |
||||
$overdueActivities = Activity::query() |
||||
->where([ |
||||
['version_gantt_id', $gantt['id']], |
||||
['persentase_progress', '!=', 100] |
||||
]) |
||||
->whereNotNull('parent_id') |
||||
->whereDate('end_date','<=',$endDate) |
||||
->orderBy('end_date', 'asc') |
||||
->get(); |
||||
|
||||
// Manpower |
||||
$manCount = UserToProyek::where('proyek_id', $project['id'])->count(); |
||||
// Assigned |
||||
$assigned = UserToActivity::query() |
||||
->select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date') |
||||
->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id') |
||||
->where('assign_hr_to_activity.version_gantt_id', $gantt['id']) |
||||
->get(); |
||||
// Project Comment |
||||
$projectComment = ProjectComment::query() |
||||
->select('m_users.name','m_users.username','m_project_comment.project_id','m_project_comment.gantt_id','m_project_comment.comment','m_project_comment.created_at') |
||||
->join('m_users','m_project_comment.sender_id','m_users.id') |
||||
->where([ |
||||
['project_id',$project['id']], |
||||
['gantt_id',$gantt['id']] |
||||
]) |
||||
->get(); |
||||
// Hierarchy |
||||
$finalData = []; |
||||
$ganttHierarchy = VersionGantt::find($gantt['id']); |
||||
if ($ganttHierarchy->hierarchy_ftth_id) { |
||||
$ftth = HierarchyFtth::find($ganttHierarchy->hierarchy_ftth_id); |
||||
array_push($finalData, $ftth); |
||||
if($ftth->parent_id){ |
||||
$this->getParents($finalData, $ftth->parent_id); |
||||
} |
||||
}else{ |
||||
$finalData = $finalData; |
||||
} |
||||
|
||||
$reports = DB::table('assign_material_to_activity as ama') |
||||
->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit', |
||||
'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date') |
||||
->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id') |
||||
->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id') |
||||
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
||||
->join('m_users as u', 'u.id', '=', 'ram.user_id') |
||||
->where('ama.proyek_id', '=', $project['id']) |
||||
->whereNotNull('ram.lat') |
||||
->whereBetween('ram.report_date', [$startDate, $endDate]); |
||||
} |
||||
} |
||||
|
||||
$projectManager = User::where('id', $project['pm_id'])->value('name'); |
||||
|
||||
$arr[]= [ |
||||
"project"=> [ |
||||
"id"=>$project['id'], |
||||
"pm_id"=>$project['pm_id'], |
||||
"nama"=>$project['nama'], |
||||
"kode_sortname"=>$project['kode_sortname'], |
||||
"budget_health"=>$project['budget_health'], |
||||
"calculation_status"=>$project['calculation_status'], |
||||
"mulai_proyek"=>$project['mulai_proyek'], |
||||
"akhir_proyek"=>$project['akhir_proyek'], |
||||
"rencana_biaya"=>$project['rencana_biaya'], |
||||
"company"=>$project['company'], |
||||
"scurve"=>$project['scurve'], |
||||
"gantt"=>$ganttForProject |
||||
], |
||||
"hierarchy"=>$finalData, |
||||
"manpower"=>$manCount, |
||||
"assigned"=>$assigned, |
||||
"actual"=>0, |
||||
"project_comment"=>$projectComment, |
||||
"project_manager"=> $projectManager, |
||||
"activity" => [ |
||||
"data" => $activity, |
||||
"start_date"=>$startDate, |
||||
"end_date"=>$endDate, |
||||
"planned_start"=>$plannedStart, |
||||
"planned_end"=>$plannedEnd |
||||
], |
||||
"report_distribution"=>$reports, |
||||
"overdueActivities"=>$overdueActivities, |
||||
"SCurve"=>$SCurve |
||||
]; |
||||
} |
||||
return response()->json(['status'=>'success','code'=> 200,'data'=>$arr, "count"=>count($arr)], 200); |
||||
} |
||||
|
||||
public function getParents(&$data, $id){ |
||||
$ftth = HierarchyFtth::find($id); |
||||
array_push($data, $ftth); |
||||
if ($ftth->parent_id) { |
||||
$this->getParents($data, $ftth->parent_id); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,136 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectChecklists; |
||||
|
||||
class ProjectChecklistsController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
if ($request->status_exist==="") { |
||||
$request->merge(['status_exist' => true]); |
||||
} |
||||
|
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'item' => 'required|string', |
||||
'status_exist' => 'boolean' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectChecklists::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data project participants successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project participants failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = ProjectChecklists::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project participants, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$data = ProjectChecklists::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectChecklists::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function deleteByProyek($id) |
||||
{ |
||||
$data = ProjectChecklists::where('proyek_id', $id)->delete(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project participants failed deleted, because data not found!','code'=>200], 200); |
||||
} |
||||
} |
||||
|
||||
public function customWhere($where, $val) |
||||
{ |
||||
$data = ProjectChecklists::where($where, $val)->orderBy('id', 'asc')->get(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','data'=> $data,'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project participants not found!','code'=>400], 40); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'project_charter_checklist'); |
||||
$builder = $dataBuilder['builder']; |
||||
$countBuilder = $dataBuilder['count']; |
||||
$dataGet = $builder->get(); |
||||
$totalRecord = $countBuilder->count(); |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectChecklists::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project participants, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,136 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectIssues; |
||||
|
||||
class ProjectIssuesController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
if ($request->level_issue === "") { |
||||
$request->merge(['level_issue' => 0]); |
||||
} |
||||
|
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'description' => 'required|string', |
||||
'level_issue' => 'required|integer' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectIssues::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data project participants successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project participants failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = ProjectIssues::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project participants, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$data = ProjectIssues::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectIssues::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function deleteByProyek($id) |
||||
{ |
||||
$data = ProjectIssues::where('proyek_id', $id)->delete(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project participants failed deleted, because data not found!','code'=>200], 200); |
||||
} |
||||
} |
||||
|
||||
public function customWhere($where, $val) |
||||
{ |
||||
$data = ProjectIssues::where($where, $val)->orderBy('id', 'asc')->get(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','data'=> $data,'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project participants not found!','code'=>400], 40); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'project_charter_issue'); |
||||
$builder = $dataBuilder['builder']; |
||||
$countBuilder = $dataBuilder['count']; |
||||
$dataGet = $builder->get(); |
||||
$totalRecord = $countBuilder->count(); |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectIssues::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project participants, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,137 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectRisks; |
||||
|
||||
class ProjectRisksController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
if ($request->level_risk === "") { |
||||
$request->merge(['level_risk' => 0]); |
||||
} |
||||
|
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'level_risk' => 'required|integer', |
||||
'description' => 'required|string', |
||||
'preventive_risk' => 'required|string' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectRisks::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data project participants successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project participants failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = ProjectRisks::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project participants, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$data = ProjectRisks::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectRisks::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function deleteByProyek($id) |
||||
{ |
||||
$data = ProjectRisks::where('proyek_id', $id)->delete(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project participants failed deleted, because data not found!','code'=>200], 200); |
||||
} |
||||
} |
||||
|
||||
public function customWhere($where, $val) |
||||
{ |
||||
$data = ProjectRisks::where($where, $val)->orderBy('id', 'asc')->get(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','data'=> $data,'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project participants not found!','code'=>400], 40); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'project_charter_risk'); |
||||
$builder = $dataBuilder['builder']; |
||||
$countBuilder = $dataBuilder['count']; |
||||
$dataGet = $builder->get(); |
||||
$totalRecord = $countBuilder->count(); |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectRisks::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project participants, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
<?php |
||||
|
||||
namespace App\Jobs; |
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue; |
||||
use Illuminate\Support\Facades\Queue; |
||||
use App\Helpers\MasterFunctionsHelper; |
||||
use App\Models\Project; |
||||
|
||||
class ProcessSCurve extends Job |
||||
{ |
||||
protected $project; |
||||
/** |
||||
* Create a new job instance. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function __construct(Project $project) |
||||
{ |
||||
$this->project = $project; |
||||
} |
||||
|
||||
/** |
||||
* Execute the job. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle() |
||||
{ |
||||
$data = MasterFunctionsHelper::CalculateSCurve($this->project->id); |
||||
|
||||
$this->project->scurve = json_encode($data); |
||||
$this->project->calculation_status = true; |
||||
$this->project->save(); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ProjectChecklists extends Model |
||||
{ |
||||
protected $table = 'project_charter_checklist'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'proyek_id', |
||||
'item', |
||||
'status_exist', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,23 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ProjectIssues extends Model |
||||
{ |
||||
protected $table = 'project_charter_issue'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'proyek_id', |
||||
'description', |
||||
'level_issue', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,24 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ProjectRisks extends Model |
||||
{ |
||||
protected $table = 'project_charter_risk'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'proyek_id', |
||||
'description', |
||||
'level_risk', |
||||
'preventive_risk', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,49 @@
|
||||
<?php |
||||
|
||||
namespace App\Services; |
||||
|
||||
use Illuminate\Support\Facades\Http; |
||||
|
||||
class FCMService |
||||
{ |
||||
public static function send($fcm_token, $notification) |
||||
{ |
||||
$url = 'https://fcm.googleapis.com/fcm/send'; |
||||
// $url = 'https://fcm.googleapis.com/v1/projects/594814396007/messages:send'; |
||||
|
||||
$serverKey = config('fcm.server_key'); |
||||
$data = [ |
||||
"registration_ids" => [$fcm_token], |
||||
"notification" => [ |
||||
"title" => $notification['title'], |
||||
"body" => $notification['body'], |
||||
] |
||||
]; |
||||
$encodedData = json_encode($data); |
||||
|
||||
$headers = [ |
||||
'Authorization:key=' . $serverKey, |
||||
'Content-Type: application/json', |
||||
]; |
||||
|
||||
$ch = curl_init(); |
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url); |
||||
curl_setopt($ch, CURLOPT_POST, true); |
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
||||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
||||
// Disabling SSL Certificate support temporarly |
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $encodedData); |
||||
|
||||
$result = curl_exec($ch); |
||||
if ($result === FALSE) { |
||||
return array("success"=> false, "message"=> curl_error($ch)); |
||||
} |
||||
// Close connection |
||||
curl_close($ch); |
||||
return array("success"=> true, "message"=> $result); |
||||
} |
||||
} |
@ -0,0 +1,5 @@
|
||||
<?php |
||||
|
||||
return [ |
||||
'server_key' => "AAAAin2zZmc:APA91bHFIYDzZGyVyXvt2C8I09wC2k8siWPQIo4b1Db0QjxCzQR5SRQU9KY1iNRIUhTL6OoLUs2x6UAiP1BNv-mwOlSR7C_405msoNL2p33JVBxrtqc7hdMc5TEdTBB4ZGRVH7ltQzSe", |
||||
]; |
@ -0,0 +1,36 @@
|
||||
<?php |
||||
|
||||
use Illuminate\Database\Migrations\Migration; |
||||
use Illuminate\Database\Schema\Blueprint; |
||||
use Illuminate\Support\Facades\Schema; |
||||
|
||||
class CreateJobsTable extends Migration |
||||
{ |
||||
/** |
||||
* Run the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function up() |
||||
{ |
||||
Schema::create('jobs', function (Blueprint $table) { |
||||
$table->bigIncrements('id'); |
||||
$table->string('queue')->index(); |
||||
$table->longText('payload'); |
||||
$table->unsignedTinyInteger('attempts'); |
||||
$table->unsignedInteger('reserved_at')->nullable(); |
||||
$table->unsignedInteger('available_at'); |
||||
$table->unsignedInteger('created_at'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Reverse the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function down() |
||||
{ |
||||
Schema::dropIfExists('jobs'); |
||||
} |
||||
} |
Loading…
Reference in new issue