Browse Source

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

Reviewed-on: ordo/adw-backend#190
pull/3/head
ibnu 1 year ago
parent
commit
d76dc2e8d8
  1. 6
      app/Http/Controllers/AssignMaterialController.php
  2. 12
      app/Http/Controllers/BroadcastController.php
  3. 2
      app/Http/Controllers/DashboardBoDController.php
  4. 26
      app/Http/Controllers/DivisiController.php
  5. 7
      app/Http/Controllers/HumanResourceController.php
  6. 16
      app/Http/Controllers/MenuController.php
  7. 136
      app/Http/Controllers/ProjectChecklistsController.php
  8. 134
      app/Http/Controllers/ProjectController.php
  9. 136
      app/Http/Controllers/ProjectIssuesController.php
  10. 137
      app/Http/Controllers/ProjectRisksController.php
  11. 14
      app/Http/Controllers/ReportActivityMaterialController.php
  12. 7
      app/Http/Controllers/RoleController.php
  13. 21
      app/Http/Controllers/UserToActivityController.php
  14. 39
      app/Http/Controllers/UserToProyekController.php
  15. 8
      app/Models/Project.php
  16. 23
      app/Models/ProjectChecklists.php
  17. 23
      app/Models/ProjectIssues.php
  18. 24
      app/Models/ProjectRisks.php
  19. 30
      routes/web.php

6
app/Http/Controllers/AssignMaterialController.php

@ -69,6 +69,12 @@ class AssignMaterialController extends Controller
public function delete($id) public function delete($id)
{ {
$data = AssignMaterial::where('id', $id)->first(); $data = AssignMaterial::where('id', $id)->first();
$reports = ReportActivityMaterial::where('assign_material_id', $data->id)->get();
if (isset($reports)) {
foreach ($reports as $report) {
$report->delete();
}
}
if($data->delete()) if($data->delete())
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=> 200], 200); return response()->json(['status'=>'success','message'=>'Data deleted!','code'=> 200], 200);

12
app/Http/Controllers/BroadcastController.php

@ -13,7 +13,6 @@ class BroadcastController extends Controller
{ {
$data = $request->all(); $data = $request->all();
$data['status_send'] = true;
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
if (isset($data['send_to_id'])) { if (isset($data['send_to_id'])) {
$idArray = $data['send_to_id']; $idArray = $data['send_to_id'];
@ -21,10 +20,9 @@ class BroadcastController extends Controller
$data['send_to_id'] = implode(", ", $idArray); $data['send_to_id'] = implode(", ", $idArray);
} }
} }
// dd($data);
$result = Broadcast::create($data); $result = Broadcast::create($data);
if($result){ if($result){
$this->sendNotification($data); $data['status_send'] !== "registered" ? $this->sendNotification($data) : '';
return response()->json(['status'=>'success','message'=>'add broadcast successfully!','code'=>200], 200); return response()->json(['status'=>'success','message'=>'add broadcast successfully!','code'=>200], 200);
}else{ }else{
return response()->json(['status'=>'failed','message'=>'add broadcast failed!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'add broadcast failed!','code'=>400], 400);
@ -54,6 +52,14 @@ class BroadcastController extends Controller
$data = Broadcast::find($id); $data = Broadcast::find($id);
$status_send = $request->status_send;
if($status_send === 'resend' || $status_send === 'send' && !empty($data))
{
$data['status_send'] = $status_send;
$this->sendNotification($data);
}
if($data){ if($data){
$result = $data->update($request->all()); $result = $data->update($request->all());
}else{ }else{

2
app/Http/Controllers/DashboardBoDController.php

@ -271,7 +271,7 @@ class DashboardBoDController extends Controller
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name','parent')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();

26
app/Http/Controllers/DivisiController.php

@ -19,9 +19,9 @@ class DivisiController extends Controller
public function add(Request $request){ public function add(Request $request){
$this->validate($request, [ $this->validate($request, [
'name' => 'required', 'name' => 'string|required|unique:m_divisi,name',
'description' => 'string', 'description' => 'nullable|string',
'parent' => 'integer' 'parent' => 'nullable|integer'
]); ]);
$data = $request->all(); $data = $request->all();
@ -39,8 +39,15 @@ class DivisiController extends Controller
if(empty($id) || !is_int((int)$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);
$this->validate($request, [
'name' => 'string|required',
'description' => 'nullable|string',
'parent' => 'nullable|integer'
]);
$data = Divisi::find($id); $data = Divisi::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_divisi,name']) : '';
if(!$data) if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
@ -70,15 +77,22 @@ class DivisiController extends Controller
return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200); return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200);
} }
public function search() public function search(Request $request)
{ {
return $this->list(); $payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_divisi');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
//return $this->list();
// cant use builder for this case // cant use builder for this case
} }
public function list() public function list()
{ {
$parentMenus = Divisi::whereNull('parent')->with('children')->get(); $parentMenus = Divisi::with('children')->whereNull('parent')->get();
$divisions = []; $divisions = [];
foreach($parentMenus as $menu){ foreach($parentMenus as $menu){
$childs = $this->getAllChildren($menu); $childs = $this->getAllChildren($menu);

7
app/Http/Controllers/HumanResourceController.php

@ -15,7 +15,7 @@ class HumanResourceController extends Controller
$this->validate($request, [ $this->validate($request, [
'role_id' => 'required', 'role_id' => 'required',
'name' => 'required', 'name' => 'required',
'ktp_number' => 'required', 'ktp_number' => 'required|numeric|unique:m_users,ktp_number',
'employee_type' => 'required' 'employee_type' => 'required'
]); ]);
@ -56,9 +56,12 @@ class HumanResourceController extends Controller
if (!$id || (int) $id < 0 || $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);
} }
$humanresource = HumanResource::find($id); $humanresource = HumanResource::find($id);
$request->ktp_number !== $humanresource['ktp_number'] ? $this->validate($request,['ktp_number'=>'unique:m_users,ktp_number|numeric']) : '';
$request->email !== $humanresource['email'] ? $this->validate($request,['email'=>'unique:m_users,email|email']) : '';
$request->password ? $this->validate($request,['password'=>'required|min:8']) : '';
$data = $request->all(); $data = $request->all();
if (isset($request->password) && $request->password != "") { if (isset($request->password) && $request->password != "") {

16
app/Http/Controllers/MenuController.php

@ -12,9 +12,9 @@ class MenuController extends Controller
{ {
$this->validate($request, [ $this->validate($request, [
'icon' => 'required', 'icon' => 'required',
'name' => 'required', 'name' => 'string|required|unique:m_menu,name',
'url' => 'required', 'url' => 'required|unique:m_menu,url',
'sequence' => 'required', 'sequence' => 'required|integer',
]); ]);
$data = $request->all(); $data = $request->all();
@ -50,9 +50,17 @@ class MenuController extends Controller
if(!$id || (int) $id < 0 || $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);
} }
$this->validate($request, [
'icon' => 'required',
'name' => 'string|required',
'url' => 'required',
'sequence' => 'required|integer',
]);
$data = Menu::find($id); $data = Menu::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_menu,name']) : '';
$request->url !== $data['url'] ? $this->validate($request,['url'=>'unique:m_menu,url']) : '';
if($data){ if($data){
$result = $data->update($request->all()); $result = $data->update($request->all());
}else{ }else{

136
app/Http/Controllers/ProjectChecklistsController.php

@ -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);
}
}
}

134
app/Http/Controllers/ProjectController.php

@ -2,35 +2,39 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use DateTime;
use App\Models\Link;
use App\Models\User;
use App\Models\Image;
use App\Models\Holiday;
use App\Models\Project; use App\Models\Project;
use App\Models\UserToProyek;
use App\Models\Activity; use App\Models\Activity;
use App\Models\UserToActivity; use App\Jobs\ProcessSCurve;
use App\Models\User; use App\Models\OfficeHours;
use App\Models\ProjectType;
use App\Models\ProjectPhase;
use App\Models\UserToProyek;
use App\Models\VersionGantt;
use Illuminate\Http\Request;
use App\Models\ProjectIssues;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
use App\Models\DokumenProject; use App\Models\DokumenProject;
use App\Models\FolderDocumentProyek;
use App\Models\ProjectCharter; use App\Models\ProjectCharter;
use App\Models\ProjectApproval; use App\Models\ReportActivity;
use App\Models\ProjectPhase;
use App\Models\ProjectType;
use App\Models\ProjectMileStone;
use App\Models\ProjectParticipants;
use App\Models\ShowHideColumn; use App\Models\ShowHideColumn;
use App\Models\VersionGantt; use App\Models\UserToActivity;
use App\Models\Image;
use App\Models\CommentActivity;
use App\Models\Link;
use App\Models\ActivityDokumen; use App\Models\ActivityDokumen;
use App\Models\Holiday; use App\Models\CommentActivity;
use App\Models\ReportActivity; use App\Models\ProjectApproval;
use App\Models\OfficeHours; use App\Models\ProjectMileStone;
use App\Models\ProjectChecklists;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use App\Models\ProjectParticipants;
use App\Models\FolderDocumentProyek;
use App\Helpers\MasterFunctionsHelper; use App\Helpers\MasterFunctionsHelper;
use App\Models\ProjectRisks;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use App\Jobs\ProcessSCurve;
const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1";
@ -65,11 +69,22 @@ class ProjectController extends Controller
return response()->json(['status'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200); return response()->json(['status'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200);
} }
public function edit($id){ public function edit($id)
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Project::find($id); $result = Project::query()
->from('m_proyek AS mp')
->where('mp.id', $id)
->selectRaw('kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,area_kerja,lokasi_kantor,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status');
if (!is_null($result->first()['divisi_id'])) {
$result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
}
$result = $result->first();
if(!$result) if(!$result)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
@ -145,6 +160,9 @@ class ProjectController extends Controller
ProjectApproval::where('proyek_id', $project_id)->delete(); ProjectApproval::where('proyek_id', $project_id)->delete();
ProjectMileStone::where('proyek_id', $project_id)->delete(); ProjectMileStone::where('proyek_id', $project_id)->delete();
ProjectParticipants::where('proyek_id', $project_id)->delete(); ProjectParticipants::where('proyek_id', $project_id)->delete();
ProjectChecklists::where('proyek_id', $project_id)->delete();
ProjectIssues::where('proyek_id', $project_id)->delete();
ProjectRisks::where('proyek_id', $project_id)->delete();
$this->deleteVersionGantt($project_id); $this->deleteVersionGantt($project_id);
$this->deleteDokumenProject($project_id); $this->deleteDokumenProject($project_id);
} }
@ -349,7 +367,16 @@ class ProjectController extends Controller
} }
public static function setSyncDate($activity_id, $activity, $report) { public static function setSyncDate($activity_id, $activity, $report) {
$status = AssignMaterial::select('status_activity')->where('activity_id', $activity_id)->first(); $status = AssignMaterial::where('activity_id', $activity_id)->first();
if (!isset($status)) {
$reports = array(
'activity_id' => $activity_id,
'min_date' => new DateTime($activity->start_date),
'max_date' => new DateTime($activity->end_date),
'status' => 'open'
);
return $reports;
}
if (!isset($status->status_activity)) { if (!isset($status->status_activity)) {
$status->status_activity = 'open'; $status->status_activity = 'open';
} }
@ -389,7 +416,6 @@ class ProjectController extends Controller
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); $firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first();
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $firstReport); $reports[] = ProjectController::setSyncDate($activity_id, $activity, $firstReport);
} }
$activity->reports = $reports;
} }
/* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */ /* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */
/* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */ /* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */
@ -412,6 +438,18 @@ class ProjectController extends Controller
$activity->save(); $activity->save();
} }
foreach($activities as $activity) {
$successor = Link::where('t_activity_id', $activity->id)->first();
if ($successor) {
$predecessor = Activity::find($successor->s_activity_id);
$activity->start_date = $predecessor->end_date;
$end_date = new DateTime($activity->start_date);
$end_date->modify("+" . $activity->duration . " days");
$activity->end_date = $end_date->format("Y-m-d H:i:sO");
}
$activity->save();
}
return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200);
} }
@ -459,7 +497,7 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
} }
public function detail($id){ public function detail(Request $request, $id, $gantt_id = null, $s_curve = null){
if(empty($id) || !is_int((int)$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);
@ -467,37 +505,49 @@ class ProjectController extends Controller
if(!$result) if(!$result)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
if (!isset($gantt_id)) {
$gantt = MasterFunctionsHelper::getLatestGantt($id); $gantt = MasterFunctionsHelper::getLatestGantt($id);
$result->projectManager = User::where('id', $result->pm_id)->value('name');
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first();
// dd($result->header->start_date);
$ganttId = $gantt['last_gantt_id']; $ganttId = $gantt['last_gantt_id'];
} else {
$ganttId = $gantt_id;
}
$result->projectManager = User::where('id', $result->pm_id)->value('name');
if (isset($s_curve)) {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first();
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
$actualEndExist = Activity::where('proyek_id', $id)->whereNotNull('actual_end')->exists();
$query = Activity::where('proyek_id', $id);
} else {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first();
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists();
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists(); $actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists();
$query = Activity::where('version_gantt_id', $ganttId);
}
if ($actualStartExist) { if ($actualStartExist) {
$startDate = Activity::where('version_gantt_id', $ganttId) $startDate = $query->orderBy('actual_start')->value('start_date');
->orderBy('actual_start')
->value('start_date');
} else { } else {
$startDate = Activity::where('version_gantt_id', $ganttId) $startDate = $query->orderBy('start_date')->value('start_date');
->orderBy('start_date')
->value('start_date');
} }
if ($actualEndExist) { if ($actualEndExist) {
$endDate = Activity::where('version_gantt_id', $ganttId) $endDate = $query->orderByDesc('actual_end')->value('end_date');
->orderByDesc('actual_end')
->value('end_date');
} else { } else {
$endDate = Activity::where('version_gantt_id', $ganttId) $endDate = $query->orderByDesc('end_date')->value('end_date');
->orderByDesc('end_date')
->value('end_date');
} }
$plannedStart = Activity::where('version_gantt_id', $ganttId)
->orderBy('planned_start')
->value('planned_start');
$plannedEnd = Activity::where('version_gantt_id', $ganttId)
->orderByDesc('planned_end')
->value('planned_end');
$result->header->start_date = $startDate; $result->header->start_date = $startDate;
$result->header->end_date = $endDate; $result->header->end_date = $endDate;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$gantt], 200); $result->header->planned_start = $plannedStart;
$result->header->planned_end = $plannedEnd;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200);
} }
public function getOverdueActivities(Request $request){ public function getOverdueActivities(Request $request){

136
app/Http/Controllers/ProjectIssuesController.php

@ -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);
}
}
}

137
app/Http/Controllers/ProjectRisksController.php

@ -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);
}
}
}

14
app/Http/Controllers/ReportActivityMaterialController.php

@ -59,6 +59,14 @@ class ReportActivityMaterialController extends Controller
"updated_by" => $this->currentName "updated_by" => $this->currentName
); );
Activity::where('id', $request->activity_id)->update($dataUpdate); Activity::where('id', $request->activity_id)->update($dataUpdate);
} else {
$sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning');
$sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty');
$dataUpdate = array(
"persentase_progress" => $sumReportActivityMaterial/$sumAssignMaterial*100,
"updated_by" => $this->currentName
);
Activity::where('id', $request->activity_id)->update($dataUpdate);
} }
return response()->json(['status'=>'success','message'=>'Update data status successfully ', 'code'=>200]); return response()->json(['status'=>'success','message'=>'Update data status successfully ', 'code'=>200]);
@ -114,12 +122,14 @@ class ReportActivityMaterialController extends Controller
->addIndexColumn() ->addIndexColumn()
->addColumn('action', function($row){ ->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="info btn btn-info btn-sm btn-ram-image" data-toggle="tooltip" title="Lihat Foto Report" data-placement="top"><i class="fa fa-image"></i></a>'; $actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="info btn btn-info btn-sm btn-ram-image" data-toggle="tooltip" title="Lihat Foto Report" data-placement="top"><i class="fa fa-image"></i></a>';
if ($row->status_activity != 'done') {
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-ram-delete" data-toggle="tooltip" title="Hapus Report" data-placement="top"><i class="fa fa-trash"></i></a>'; $actionBtn .= '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-ram-delete" data-toggle="tooltip" title="Hapus Report" data-placement="top"><i class="fa fa-trash"></i></a>';
}
return $actionBtn; return $actionBtn;
}) })
->rawColumns(['action'])->make(true); ->rawColumns(['action'])->make(true);
}else{ }else{
$data = ReportActivityMaterial::select("report_activity_material.*", "u.name as human_resource") $data = ReportActivityMaterial::select("report_activity_material.*", "u.name as human_resource", "amta.status_activity")
->join("assign_material_to_activity as amta", "amta.id", "=", "report_activity_material.assign_material_id") ->join("assign_material_to_activity as amta", "amta.id", "=", "report_activity_material.assign_material_id")
->join("m_req_material as m", "m.id", "=", "amta.material_id") ->join("m_req_material as m", "m.id", "=", "amta.material_id")
->join("m_users as u", "u.id", "=", "report_activity_material.user_id") ->join("m_users as u", "u.id", "=", "report_activity_material.user_id")
@ -131,7 +141,9 @@ class ReportActivityMaterialController extends Controller
->addIndexColumn() ->addIndexColumn()
->addColumn('action', function($row){ ->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="info btn btn-info btn-sm btn-ram-image" data-toggle="tooltip" title="Lihat Foto Report" data-placement="top"><i class="fa fa-image"></i></a>'; $actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="info btn btn-info btn-sm btn-ram-image" data-toggle="tooltip" title="Lihat Foto Report" data-placement="top"><i class="fa fa-image"></i></a>';
if ($row->status_activity != 'done') {
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-ram-delete" data-toggle="tooltip" title="Hapus Report" data-placement="top"><i class="fa fa-trash"></i></a>'; $actionBtn .= '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-ram-delete" data-toggle="tooltip" title="Hapus Report" data-placement="top"><i class="fa fa-trash"></i></a>';
}
return $actionBtn; return $actionBtn;
}) })
->rawColumns(['action'])->make(true); ->rawColumns(['action'])->make(true);

7
app/Http/Controllers/RoleController.php

@ -11,7 +11,7 @@ class RoleController extends Controller
public function add(Request $request) public function add(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'name' => 'required', 'name' => 'string|required|unique:m_roles,name',
'description' => 'required' 'description' => 'required'
]); ]);
@ -44,7 +44,12 @@ class RoleController extends Controller
if(empty($id) || !is_int((int)$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);
$this->validate($request, [
'name' => 'string|required',
'description' => 'required'
]);
$data = Role::find($id); $data = Role::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_roles,name']) : '';
if(!$data) if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404); return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);

21
app/Http/Controllers/UserToActivityController.php

@ -129,9 +129,30 @@ class UserToActivityController extends Controller
public function search(Request $request) public function search(Request $request)
{ {
$payload = $request->all(); $payload = $request->all();
if (isset($payload['join_column'])) {
$join_column = $payload['join_column'];
unset($payload['join_column']);
}
$dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity'); $dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
if (isset($join_column)) {
$startDate = $join_column['start_date'];
$endDate = $join_column['end_date'];
$startDate = date("Y-m-d H:i:sO", strtotime($startDate));
$endDate = date("Y-m-d H:i:sO", strtotime($endDate));
$builder->where(function ($query) use ($startDate, $endDate) {
$query
->where('m_proyek.mulai_proyek', '>=', $startDate)
->where('m_proyek.akhir_proyek', '<=', $endDate)
->where(function ($query) use ($endDate, $startDate) {
$query
->where('m_activity.start_date', '>=', $startDate)
->where('m_activity.end_date', '<=', $endDate);
});
});
}
$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);

39
app/Http/Controllers/UserToProyekController.php

@ -30,6 +30,45 @@ class UserToProyekController extends Controller
} }
} }
public function addMultiple(Request $request){
$user_IDs = $request->user_id;
$data = UserToProyek::where("proyek_id", $request->proyek_id);
if($data){
$data->delete();
}
if(is_array($user_IDs) && count($user_IDs) > 0){
$countRes = 0;
foreach($user_IDs as $item){
$dataInsert = array(
"user_id" => $item,
"proyek_id" => $request->proyek_id,
"created_by" => $this->currentName,
'is_customer'=>true
);
$result = UserToProyek::create($dataInsert);
if($result){
$countRes++;
}else{
$countRes--;
}
}
if($countRes > 0){
return response()->json(['status'=>'success' ,'message'=>'Project customer successfull created','code'=>200]);
}else{
return response()->json(['status'=>'success' ,'message'=>'Project customer failed created','code'=>400]);
}
}else{
return response()->json(['status'=>'success' ,'message'=>'Project customer successfull created','code'=>200]);
}
}
public function edit($id){ public function edit($id){
if(!$id || (int) $id < 0 || $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);

8
app/Models/Project.php

@ -30,19 +30,19 @@ class Project extends Model
'durasi_proyek', 'durasi_proyek',
'progress_by_worklog', 'progress_by_worklog',
'status', 'status',
'currency_simbol', 'currency_symbol',
'currency_code', 'currency_code',
'currency_name', 'currency_name',
'project_objectives', 'project_objectives',
'considered_success_when', 'considered_success_when',
'potential_risk', 'potential_risk',
'testing_environment', 'testing_environment',
'currency_code',
'currency_symbol',
'currency_name',
'budget_health', 'budget_health',
'phase_id', 'phase_id',
'late_consequence',
'assumtion',
'calculation_status', 'calculation_status',
'structur_organization',
'scurve', 'scurve',
'created_at', 'created_at',
'created_by', 'created_by',

23
app/Models/ProjectChecklists.php

@ -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'
];
}

23
app/Models/ProjectIssues.php

@ -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'
];
}

24
app/Models/ProjectRisks.php

@ -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'
];
}

30
routes/web.php

@ -58,7 +58,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/project/add', 'ProjectController@add'); $router->post('/project/add', 'ProjectController@add');
$router->put('/project/update/{id}', 'ProjectController@update'); $router->put('/project/update/{id}', 'ProjectController@update');
$router->get('/project/edit/{id}', 'ProjectController@edit'); $router->get('/project/edit/{id}', 'ProjectController@edit');
$router->get('/project/detail/{id}', 'ProjectController@detail'); $router->get('/project/detail/{id}[/{gantt_id}[/{s_curve}]]', 'ProjectController@detail');
$router->delete('/project/delete/{id}', 'ProjectController@delete'); $router->delete('/project/delete/{id}', 'ProjectController@delete');
$router->get('/project/list', 'ProjectController@list'); $router->get('/project/list', 'ProjectController@list');
$router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline'); $router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline');
@ -292,6 +292,33 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->delete('/rate-sallary/delete/{id}', 'RateSallaryController@delete'); $router->delete('/rate-sallary/delete/{id}', 'RateSallaryController@delete');
$router->get('/rate-sallary/list', 'RateSallaryController@list'); $router->get('/rate-sallary/list', 'RateSallaryController@list');
$router->post('/project-checklists/add', 'ProjectChecklistsController@add');
$router->get('/project-checklists/edit/{id}', 'ProjectChecklistsController@edit');
$router->put('/project-checklists/update/{id}', 'ProjectChecklistsController@update');
$router->post('/project-checklists/search', 'ProjectChecklistsController@search');
$router->delete('/project-checklists/delete/{id}', 'ProjectChecklistsController@delete');
$router->delete('/project-checklists/delete-by-proyek/{id}', 'ProjectChecklistsController@deleteByProyek');
$router->get('/project-checklists/list', 'ProjectChecklistsController@list');
$router->get('/project-checklists/{where}/{val}', 'ProjectChecklistsController@customWhere');
$router->post('/project-issues/add', 'ProjectIssuesController@add');
$router->get('/project-issues/edit/{id}', 'ProjectIssuesController@edit');
$router->put('/project-issues/update/{id}', 'ProjectIssuesController@update');
$router->post('/project-issues/search', 'ProjectIssuesController@search');
$router->delete('/project-issues/delete/{id}', 'ProjectIssuesController@delete');
$router->delete('/project-issues/delete-by-proyek/{id}', 'ProjectIssuesController@deleteByProyek');
$router->get('/project-issues/list', 'ProjectIssuesController@list');
$router->get('/project-issues/{where}/{val}', 'ProjectIssuesController@customWhere');
$router->post('/project-risks/add', 'ProjectRisksController@add');
$router->get('/project-risks/edit/{id}', 'ProjectRisksController@edit');
$router->put('/project-issues/update/{id}', 'ProjectRisksController@update');
$router->post('/project-risks/search', 'ProjectRisksController@search');
$router->delete('/project-risks/delete/{id}', 'ProjectRisksController@delete');
$router->delete('/project-risks/delete-by-proyek/{id}', 'ProjectRisksController@deleteByProyek');
$router->get('/project-risks/list', 'ProjectRisksController@list');
$router->get('/project-risks/{where}/{val}', 'ProjectRisksController@customWhere');
$router->post('/project-participants/add', 'ProjectParticipantsController@add'); $router->post('/project-participants/add', 'ProjectParticipantsController@add');
$router->get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit'); $router->get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit');
$router->put('/project-participants/update/{id}', 'ProjectParticipantsController@update'); $router->put('/project-participants/update/{id}', 'ProjectParticipantsController@update');
@ -381,6 +408,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/report-k3-detail/list', 'ReportK3DetailController@list'); $router->get('/report-k3-detail/list', 'ReportK3DetailController@list');
$router->post('/user-to-proyek/add', 'UserToProyekController@add'); $router->post('/user-to-proyek/add', 'UserToProyekController@add');
$router->post('/user-to-proyek/add-multiple', 'UserToProyekController@addMultiple');
$router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit'); $router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit');
$router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update'); $router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update');
$router->post('/user-to-proyek/search', 'UserToProyekController@search'); $router->post('/user-to-proyek/search', 'UserToProyekController@search');

Loading…
Cancel
Save