Browse Source

Merge branch 'staging' of https://git.oslog.id/ordo/adw-backend into Dev-Farhan

pull/3/head
farhan048 1 year ago
parent
commit
0d8752646b
  1. 3
      Dockerfile
  2. 29
      app/Console/Commands/CalculateSCurve.php
  3. 6
      app/Console/Commands/syncHumanResourceIntegration.php
  4. 3
      app/Console/Kernel.php
  5. 823
      app/Helpers/MasterFunctionsHelper.php
  6. 674
      app/Http/Controllers/ActivityController.php
  7. 8
      app/Http/Controllers/AssignMaterialController.php
  8. 168
      app/Http/Controllers/BroadcastController.php
  9. 9
      app/Http/Controllers/Controller.php
  10. 144
      app/Http/Controllers/DashboardBoDController.php
  11. 25
      app/Http/Controllers/DivisiController.php
  12. 31
      app/Http/Controllers/HierarchyFtthController.php
  13. 143
      app/Http/Controllers/HumanResourceController.php
  14. 44
      app/Http/Controllers/MapMonitoringController.php
  15. 16
      app/Http/Controllers/MenuController.php
  16. 201
      app/Http/Controllers/PresenceController.php
  17. 136
      app/Http/Controllers/ProjectChecklistsController.php
  18. 352
      app/Http/Controllers/ProjectController.php
  19. 136
      app/Http/Controllers/ProjectIssuesController.php
  20. 137
      app/Http/Controllers/ProjectRisksController.php
  21. 53
      app/Http/Controllers/ReportActivityMaterialController.php
  22. 2
      app/Http/Controllers/RequestMaterialController.php
  23. 10
      app/Http/Controllers/RoleController.php
  24. 6
      app/Http/Controllers/ShowHideColumnController.php
  25. 40
      app/Http/Controllers/UserToActivityController.php
  26. 44
      app/Http/Controllers/UserToProyekController.php
  27. 3
      app/Http/Controllers/VersionGanttController.php
  28. 36
      app/Jobs/ProcessSCurve.php
  29. 18
      app/Models/Activity.php
  30. 2
      app/Models/AssignMaterial.php
  31. 2
      app/Models/Broadcast.php
  32. 1
      app/Models/Divisi.php
  33. 13
      app/Models/HierarchyFtth.php
  34. 10
      app/Models/Project.php
  35. 23
      app/Models/ProjectChecklists.php
  36. 23
      app/Models/ProjectIssues.php
  37. 24
      app/Models/ProjectRisks.php
  38. 7
      app/Models/ReportActivityMaterial.php
  39. 2
      app/Models/Role.php
  40. 2
      app/Models/UserToActivity.php
  41. 2
      app/Models/UserToProyek.php
  42. 46
      app/Models/VersionGantt.php
  43. 49
      app/Services/FCMService.php
  44. 1
      bootstrap/app.php
  45. 2
      config/api.php
  46. 5
      config/fcm.php
  47. 36
      database/migrations/2023_08_29_130624_create_jobs_table.php
  48. 9
      docker/nginx/conf.d/default.conf
  49. 1947
      docker/php/php.ini
  50. 72
      rest-client.http
  51. 46
      routes/web.php

3
Dockerfile

@ -29,6 +29,9 @@ RUN docker-php-ext-install \
pgsql \ pgsql \
tokenizer tokenizer
# Copy php.ini to the container
COPY /docker/php/php.ini /usr/local/etc/php/
#Install Extensions #Install Extensions
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql

29
app/Console/Commands/CalculateSCurve.php

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

6
app/Console/Commands/syncHumanResourceIntegration.php

@ -39,9 +39,9 @@ class syncHumanResourceIntegration extends Command
*/ */
public function handle() public function handle()
{ {
// $url = config('api.adw').'/employees?page=1'; $url = config('api.adw').'/employees?page=1';
// echo "Requesting to " . $url; echo "Requesting to " . $url;
$response = null; $response = MasterFunctionsHelper::curlReq($url);
if(!$response) if(!$response)
return; return;

3
app/Console/Kernel.php

@ -13,7 +13,8 @@ class Kernel extends ConsoleKernel
* @var array * @var array
*/ */
protected $commands = [ protected $commands = [
Commands\syncHumanResourceIntegration::class Commands\syncHumanResourceIntegration::class,
Commands\CalculateSCurve::class
]; ];
/** /**

823
app/Helpers/MasterFunctionsHelper.php

File diff suppressed because it is too large Load Diff

674
app/Http/Controllers/ActivityController.php

File diff suppressed because it is too large Load Diff

8
app/Http/Controllers/AssignMaterialController.php

@ -42,7 +42,7 @@ class AssignMaterialController extends Controller
$data['budget'] = $checkStock->price; $data['budget'] = $checkStock->price;
$data['qty_planning'] = $this->sanitizeDecimal($data['qty_planning']); $data['qty_planning'] = $this->sanitizeDecimal($data['qty_planning']);
if ($planDate > $startDate) { if ($planDate >= $startDate) {
$result = AssignMaterial::create($data); $result = AssignMaterial::create($data);
return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200], 200); return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200], 200);
}else{ }else{
@ -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);

168
app/Http/Controllers/BroadcastController.php

@ -3,7 +3,175 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Broadcast;
use App\Models\User;
use App\Services\FCMService;
class BroadcastController extends Controller class BroadcastController extends Controller
{ {
public function add(Request $request)
{
$data = $request->all();
$data['created_by'] = $this->currentName;
if (isset($data['send_to_id'])) {
$idArray = $data['send_to_id'];
if (is_array($data['send_to_id'])) {
$data['send_to_id'] = implode(", ", $idArray);
}
}
$result = Broadcast::create($data);
if($result){
$data['status_send'] !== "registered" ? $this->sendNotification($data) : '';
return response()->json(['status'=>'success','message'=>'add broadcast successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add broadcast 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 = Broadcast::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data broadcast, 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 = 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){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'data broadcast not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'data broadcast successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data broadcast failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = Broadcast::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data broadcast not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data broadcast successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data broadcast failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_broadcast');
$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 = Broadcast::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 broadcast, please try again later!','code'=>400], 400);
}
}
public function sendNotification($data)
{
// send_to_type (all, roles, user)
if (isset($data['send_to_type'])) {
switch ($data['send_to_type']) {
case 'all':
$users = User::whereNotNull('fcm_token')->get();
if (isset($users)) {
foreach ($users as $user) {
FCMService::send(
$user->fcm_token,
[
'title' => $data['title_notif'],
'body' => $data['message_notif'],
]
);
}
}
break;
case 'roles':
$users = User::where("role_id", $data['send_to_id'])->whereNotNull('fcm_token')->get();
if (isset($users)) {
foreach ($users as $user) {
FCMService::send(
$user->fcm_token,
[
'title' => $data['title_notif'],
'body' => $data['message_notif'],
]
);
}
}
break;
case 'users':
$idArray = explode(", ", $data['send_to_id']);
foreach ($idArray as $key => $value) {
$user = User::where("id", $value)->whereNotNull('fcm_token')->first();
if (isset($user)) {
FCMService::send(
$user->fcm_token,
[
'title' => $data['title_notif'],
'body' => $data['message_notif'],
]
);
}
}
break;
default:
# code...
break;
}
}
}
} }

9
app/Http/Controllers/Controller.php

@ -37,8 +37,15 @@ class Controller extends BaseController
{ {
$alias = "selfTable"; $alias = "selfTable";
$builder = DB::table($tableSelf." AS ".$alias); $builder = DB::table($tableSelf." AS ".$alias);
$builder = $builder->select($alias.".*"); // $builder = $builder->select($alias.".*");
if($condition){ if($condition){
if(isset($condition['select'])){
foreach($condition['select'] as $select){
$builder = $builder->addSelect($alias.".".$select);
}
}else{
$builder = $builder->addSelect($alias.".*");
}
if(isset($condition['joins'])){ if(isset($condition['joins'])){
$selectColumn = []; $selectColumn = [];
$no = 0; $no = 0;

144
app/Http/Controllers/DashboardBoDController.php

@ -10,19 +10,22 @@ use App\Models\User;
use App\Models\UserToVersionGantt; use App\Models\UserToVersionGantt;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class DashboardBoDController extends Controller class DashboardBoDController extends Controller
{ {
private function interpolateYear($year){ private function interpolateYear($year)
if($year) {
$year = '%'.$year.'%'; if ($year)
$year = '%' . $year . '%';
return $year; return $year;
} }
private function curlReq($url, $token){ private function curlReq($url, $token)
{
$ch = curl_init(); $ch = curl_init();
$headers = [ $headers = [
'Authorization: '.$token 'Authorization: ' . $token
]; ];
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
@ -36,22 +39,24 @@ class DashboardBoDController extends Controller
return json_decode($response); return json_decode($response);
} }
private function getInvoiceIntegration($search) { private function getInvoiceIntegration($search)
// if(empty($search)) {
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); if(empty($search))
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
// $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
// $token = config('api.adw_token'); $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
// $response = $this->curlReq($url, $token); $token = config('api.adw_token');
// $response = $this->curlReq($url, $token);
// if(@$response->data->project_no == "")
// return null; if(@$response->data->project_no == "")
//
return null; return null;
return $response;
} }
// to do // to do
public function getCompanyCashFlow($year = '%') { public function getCompanyCashFlow($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
@ -65,16 +70,16 @@ class DashboardBoDController extends Controller
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
->get(); ->get();
foreach($projects as $project){ foreach ($projects as $project) {
$project->expenses = 0; $project->expenses = 0;
$resp = null; $resp = null;
if($project->kode_sortname != ""){ if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname); $resp = $this->getInvoiceIntegration($project->kode_sortname);
/* $resp = $project->kode_sortname; */ /* $resp = $project->kode_sortname; */
$cost = $resp->data->total_cost ?? 0; $cost = $resp->data->total_cost ?? 0;
$cost = substr($cost, 0, strpos($cost, ".")); $cost = substr($cost, 0, strpos($cost, "."));
$totalExpenditure+= (int) $cost; $totalExpenditure += (int) $cost;
$totalInvoice += $resp->data->total_invoice_amount ?? 0; $totalInvoice += $resp->data->total_invoice_amount ?? 0;
$totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0; $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
} }
@ -86,20 +91,21 @@ class DashboardBoDController extends Controller
'total_budget' => (int) $totalBudgets ?? 0, 'total_budget' => (int) $totalBudgets ?? 0,
'total_expenditure' => $totalExpenditure, 'total_expenditure' => $totalExpenditure,
'total_invoice' => $totalInvoice, 'total_invoice' => $totalInvoice,
'total_paid_invoice' => $totalPaidInvoice , 'total_paid_invoice' => $totalPaidInvoice,
] ]
], 200); ], 200);
} }
public function getInvoiceOutstanding($year = '%'){ public function getInvoiceOutstanding($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
->get(); ->get();
$return = []; $return = [];
foreach($projects as $project){ foreach ($projects as $project) {
$resp = null; $resp = null;
if($project->kode_sortname != ""){ if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname); $resp = $this->getInvoiceIntegration($project->kode_sortname);
array_push($return, [ array_push($return, [
'project' => $project->nama, 'project' => $project->nama,
@ -116,7 +122,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerScheduleHealth($year = '%'){ public function getTotalProjectPerScheduleHealth($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$return = [ $return = [
@ -126,15 +133,23 @@ class DashboardBoDController extends Controller
]; ];
$projects = Project::where('mulai_proyek', 'like', $year)->get(); $projects = Project::where('mulai_proyek', 'like', $year)->get();
foreach($projects as $project) { foreach ($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); $project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0;
if ($project->scurve && $project->scurve[0]) {
$planningArray = $project->scurve[0]['data']['percentagePlan'];
$actualArray = $project->scurve[0]['data']['percentageReal'];
$planningProgress = !empty($planningArray) ? $planningArray[count($planningArray) - 1] : 0;
$actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0;
}
$selisihProgress = $planningProgress - $actualProgress;
try { try {
if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) if ($selisihProgress > 0 && $selisihProgress <= 5)
$return['warning'] += 1; $return['warning'] += 1;
elseif(@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) elseif ($selisihProgress == 0)
$return['behind-schedule'] += 1;
elseif(@$project->scurve['difference'] == 0)
$return['on-schedule'] += 1; $return['on-schedule'] += 1;
else
$return['behind-schedule'] += 1;
} catch (\Error $e) { } catch (\Error $e) {
return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200); return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200);
} }
@ -143,23 +158,24 @@ class DashboardBoDController extends Controller
return response()->json(['data' => $return, 'q' => $projects], 200); return response()->json(['data' => $return, 'q' => $projects], 200);
} }
public function getTotalProjectScheduleHealthPerDivision($year = '%'){ public function getTotalProjectScheduleHealthPerDivision($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')->get(); $divisions = Divisi::whereNull('parent')->get();
foreach($divisions as $division){ foreach ($divisions as $division) {
$scheduleData = new Collection(); $scheduleData = new Collection();
$behindSchedule = $warning = $onSchedule = 0; $behindSchedule = $warning = $onSchedule = 0;
$projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get(); $projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get();
foreach($projects as $project) { foreach ($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); $project->scurve = MasterFunctionsHelper::getSCurve($project->id);
if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) if (@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5)
$warning++; $warning++;
elseif(@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) elseif (@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100)
$behindSchedule++; $behindSchedule++;
elseif(@$project->scurve['difference'] == 0) elseif (@$project->scurve['difference'] == 0)
$onSchedule++; $onSchedule++;
} }
@ -175,7 +191,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerBudgetHealth($year = '%'){ public function getTotalProjectPerBudgetHealth($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
return response()->json([ return response()->json([
'data' => [ 'data' => [
@ -186,7 +203,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health){ private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health)
{
return Project::where('divisi_id', $divisi) return Project::where('divisi_id', $divisi)
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
@ -195,19 +213,20 @@ class DashboardBoDController extends Controller
} }
public function getTotalProjectBudgetHealthPerDivision($year = '%'){ public function getTotalProjectBudgetHealthPerDivision($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id','name') $divisions = Divisi::select('id', 'name')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach($divisions as $division){ foreach ($divisions as $division) {
$budgetData = new Collection(); $budgetData = new Collection();
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'overrun'), 'overrun'); $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'overrun'), 'overrun');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'warning'), 'warning'); $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'warning'), 'warning');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'on-budget'), 'on-budget'); $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'on-budget'), 'on-budget');
foreach($division->children as $d){ foreach ($division->children as $d) {
$budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'overrun'); $budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'overrun');
$budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'warning'); $budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'warning');
$budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'on-budget'); $budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'on-budget');
@ -215,7 +234,7 @@ class DashboardBoDController extends Controller
unset($division->children); unset($division->children);
$division->budgetData = $budgetData; $division->budgetData = $budgetData;
} }
foreach($divisions as $division){ foreach ($divisions as $division) {
} }
return response()->json([ return response()->json([
'data' => [ 'data' => [
@ -224,10 +243,11 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerPhase($year = '%'){ public function getTotalProjectPerPhase($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projectPhases = ProjectPhase::orderBy('order')->get(); $projectPhases = ProjectPhase::orderBy('order')->get();
foreach($projectPhases as $phase){ foreach ($projectPhases as $phase) {
$phase->totalProject = Project::where('phase_id', $phase->id) $phase->totalProject = Project::where('phase_id', $phase->id)
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
@ -240,24 +260,26 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
private function countTotalProjectInDivision($id, $year){ private function countTotalProjectInDivision($id, $year)
{
return Project::where('divisi_id', $id) return Project::where('divisi_id', $id)
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
->count(); ->count();
} }
public function getTotalProjectPerDivision($year = '%') { public function getTotalProjectPerDivision($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id','name') $divisions = Divisi::select('id', 'name','parent','color')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach($divisions as $v){ foreach ($divisions as $v) {
$v->total = $this->countTotalProjectInDivision($v->id, $year); $v->total = $this->countTotalProjectInDivision($v->id, $year);
foreach($v->children as $d){ foreach ($v->children as $d) {
$v->total += $this->countTotalProjectInDivision($d->id, $year); $v->total += $this->countTotalProjectInDivision($d->id, $year);
} }
unset($v->children); unset($v->children);
@ -268,7 +290,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
private function countTotalProjectValueInDivision($id, $year){ private function countTotalProjectValueInDivision($id, $year)
{
return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))'))
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
@ -277,18 +300,19 @@ class DashboardBoDController extends Controller
->first(); ->first();
} }
public function getTotalProjectValuePerDivision($year = '%') { public function getTotalProjectValuePerDivision($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id','name') $divisions = Divisi::select('id', 'name')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach($divisions as $v){ foreach ($divisions as $v) {
$v->total = $this->countTotalProjectValueInDivision($v->id, $year); $v->total = $this->countTotalProjectValueInDivision($v->id, $year);
foreach($v->children as $d){ foreach ($v->children as $d) {
$v->total += $this->countTotalProjectValueInDivision($d->id, $year); $v->total += $this->countTotalProjectValueInDivision($d->id, $year);
} }
unset($v->children); unset($v->children);
@ -300,16 +324,17 @@ class DashboardBoDController extends Controller
} }
public function getDetailExpenditure($year = '%'){ public function getDetailExpenditure($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->get(); ->get();
foreach($projects as $project){ foreach ($projects as $project) {
$lastGantt = MasterFunctionsHelper::getLatestGantt($project->id); $lastGantt = MasterFunctionsHelper::getLatestGantt($project->id);
if($project->kode_sortname != ""){ if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname); $resp = $this->getInvoiceIntegration($project->kode_sortname);
$project->invoice = [ $project->invoice = [
'invoiced' => $resp->data->total_invoice_amount ?? 0, 'invoiced' => $resp->data->total_invoice_amount ?? 0,
@ -319,7 +344,7 @@ class DashboardBoDController extends Controller
$project->pm = User::find($project->pm_id); $project->pm = User::find($project->pm_id);
/* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */ /* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */
if(!isset($lastGantt['last_gantt_id'])){ if (!isset($lastGantt['last_gantt_id'])) {
$project->manPowers = 0; $project->manPowers = 0;
} else { } else {
$project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count(); $project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count();
@ -334,4 +359,3 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
} }

25
app/Http/Controllers/DivisiController.php

@ -19,9 +19,10 @@ 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',
'color'=>'nullable|string|max:10'
]); ]);
$data = $request->all(); $data = $request->all();
@ -39,8 +40,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,9 +78,16 @@ 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
} }

31
app/Http/Controllers/HierarchyFtthController.php

@ -110,12 +110,15 @@ class HierarchyFtthController extends Controller
if($ftthIds){ if($ftthIds){
foreach ($ftthIds as $ftthId) { foreach ($ftthIds as $ftthId) {
$gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress'); $gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress');
$bobot_planning = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('bobot');
$ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count(); $ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count();
$ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id); $ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id);
if($ftth){ if($ftth){
$round = $gantts/$ganttCount; $round = $gantts/$ganttCount;
$round_bobot = $bobot_planning/$ganttCount;
$ftth->progress = round($round, 2); $ftth->progress = round($round, 2);
$ftth->bobot_planning = round($round_bobot, 2);
try { try {
$ftth->save(); $ftth->save();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -150,6 +153,30 @@ class HierarchyFtthController extends Controller
} }
} }
public function getTreeByGantt($gantt_id)
{
$finalData = [];
$gantt = VersionGantt::find($gantt_id);
if ($gantt->hierarchy_ftth_id) {
$ftth = HierarchyFtth::find($gantt->hierarchy_ftth_id);
array_push($finalData, $ftth);
if($ftth->parent_id){
$this->getParents($finalData, $ftth->parent_id);
}
} else {
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200);
}
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200);
}
public function getParents(&$data, $id){
$ftth = HierarchyFtth::find($id);
array_push($data, $ftth);
if ($ftth->parent_id) {
$this->getParents($data, $ftth->parent_id);
}
}
public function getTreeByProject($project_id) public function getTreeByProject($project_id)
{ {
$this->countProgress(intval($project_id)); $this->countProgress(intval($project_id));
@ -165,6 +192,7 @@ class HierarchyFtthController extends Controller
foreach ($progress as $p) { foreach ($progress as $p) {
if ($p->id == $gantt->id) { if ($p->id == $gantt->id) {
$gantt->progress = $p->persentase_progress; $gantt->progress = $p->persentase_progress;
$gantt->bobot_planning = $p->bobot_planning ? $p->bobot_planning : 0;
} }
} }
} }
@ -192,6 +220,7 @@ class HierarchyFtthController extends Controller
foreach ($progress as $p) { foreach ($progress as $p) {
if ($p->id == $gantt->id) { if ($p->id == $gantt->id) {
$gantt->progress = $p->persentase_progress; $gantt->progress = $p->persentase_progress;
$gantt->bobot_planning = $p->bobot_planning ? $p->bobot_planning : 0;
} }
} }
} }
@ -204,7 +233,7 @@ class HierarchyFtthController extends Controller
} }
public function ganttProgress($column, $value){ public function ganttProgress($column, $value){
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress') $progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning')
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id') ->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id')
->where("m_version_gantt.".$column, $value) ->where("m_version_gantt.".$column, $value)
->where('m_activity.type_activity', "project") ->where('m_activity.type_activity', "project")

143
app/Http/Controllers/HumanResourceController.php

@ -10,73 +10,79 @@ use Illuminate\Support\Facades\Artisan;
class HumanResourceController extends Controller class HumanResourceController extends Controller
{ {
public function add(Request $request){ public function add(Request $request)
{
$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'
]); ]);
$data = $request->all(); $data = $request->all();
if(isset($request->password) && $request->password!=""){ if (isset($request->password) && $request->password != "") {
$data['password'] = md5($request->password); $data['password'] = md5($request->password);
} }
$result = HumanResource::create($data); $result = HumanResource::create($data);
if($result){ if ($result) {
return response()->json(['status'=>'success','message'=>'Human Resource Pool successfull created','code'=>200]); return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfull created', 'code' => 200]);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'Human Resource Pool failed created','code'=>400]); return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed created', 'code' => 400]);
} }
} }
public function edit($id){ public function edit($id)
if(!$id || (int) $id < 0 || $id==""){ {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die(); die();
} }
$result = HumanResource::find($id); $result = HumanResource::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{ } else {
return response()->json(['status'=>'failed','message'=>'failed get data human resource, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get data human resource, 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 (!$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 != "") {
$data['password'] = md5($request->password); $data['password'] = md5($request->password);
} }
if(isset($data['username']) && HumanResource::where('username', $data['username'])->where('id', '<>', $id)->exists()){ if (isset($data['username']) && HumanResource::where('username', $data['username'])->where('id', '<>', $id)->exists()) {
return response()->json(['status'=>'failed','message'=>'Username already exists!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'Username already exists!', 'code' => 400], 400);
} }
if($humanresource){ if ($humanresource) {
$result = $humanresource->update($data); $result = $humanresource->update($data);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'data Human Resource Pool not found!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'data Human Resource Pool not found!', 'code' => 400], 400);
die(); die();
} }
if($result){ if ($result) {
return response()->json(['status'=>'success','message'=>'Human Resource Pool successfully updated!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfully updated!', 'code' => 200], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'Human Resource Pool failed updated!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed updated!', 'code' => 400], 400);
} }
} }
@ -84,18 +90,18 @@ class HumanResourceController extends Controller
{ {
$data = HumanResource::find($id); $data = HumanResource::find($id);
if($data){ if ($data) {
$delete = $data->delete(); $delete = $data->delete();
}else{ } else {
return response()->json(['status'=>'failed','message'=>'data Human Resource Pool not found!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'data Human Resource Pool not found!', 'code' => 400], 400);
die(); die();
} }
if($delete){ if ($delete) {
return response()->json(['status'=>'success','message'=>'Human Resource Pool successfully deleted!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfully deleted!', 'code' => 200], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'Human Resource Pool failed deleted!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed deleted!', 'code' => 400], 400);
} }
} }
@ -107,22 +113,23 @@ class HumanResourceController extends Controller
$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 list() public function list()
{ {
$data = HumanResource::all(); $data = HumanResource::select('id', 'name', 'role_id')->get();
$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{ } else {
return response()->json(['status'=>'failed','message'=>'failed get list human resource, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get list human resource, please try again later!', 'code' => 400], 400);
} }
} }
public function select(Request $request){ public function select(Request $request)
{
$search = $request->query('search'); $search = $request->query('search');
@ -131,18 +138,33 @@ class HumanResourceController extends Controller
$forbidden = []; $forbidden = [];
if($idActivity && $idActivity > 0){ if ($idActivity && $idActivity > 0) {
$dataF = UserToActivity::select("user_id")->where("activity_id", $idActivity)->get(); $dataF = UserToActivity::select("user_id")->where("activity_id", $idActivity)->get();
foreach($dataF as $val){ foreach ($dataF as $val) {
$forbidden[] = $val->user_id; $forbidden[] = $val->user_id;
} }
} }
if($search && !empty($search)){ if ($search && !empty($search)) {
$data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id') $data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")
->where("assign_hr_to_proyek.proyek_id", $idProyek)->where("m_users.name", 'like', '%'.$search.'%')->whereNotIn("m_users.id", $forbidden)->get(); ->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id')
}else{ ->where("assign_hr_to_proyek.proyek_id", $idProyek)
$data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")->where("assign_hr_to_proyek.proyek_id", $idProyek)->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id')->whereNotIn("m_users.id", $forbidden)->get(); ->where(function ($query) {
$query->where("assign_hr_to_proyek.is_customer", "!=", true)
->orWhereNull("assign_hr_to_proyek.is_customer");
})
->where("m_users.name", 'like', '%' . $search . '%')
->whereNotIn("m_users.id", $forbidden)->get();
} else {
$data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")
->where("assign_hr_to_proyek.proyek_id", $idProyek)
->where(function ($query) {
$query->where("assign_hr_to_proyek.is_customer", "!=", true)
->orWhereNull("assign_hr_to_proyek.is_customer");
})
->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id')
->whereNotIn("m_users.id", $forbidden)
->get();
} }
return response()->json($data); return response()->json($data);
@ -150,29 +172,28 @@ class HumanResourceController extends Controller
public function checkOldPassword(Request $request, $id) public function checkOldPassword(Request $request, $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);
die(); die();
} }
$data = $request->all(); $data = $request->all();
if(isset($request->old_password) && $request->old_password!="" ){ if (isset($request->old_password) && $request->old_password != "") {
$result = HumanResource::find($id); $result = HumanResource::find($id);
$data['old_password'] = md5($request->old_password); $data['old_password'] = md5($request->old_password);
if($data['old_password'] !== $result->password) { if ($data['old_password'] !== $result->password) {
return response()->json(['status'=>'failed','message'=>"old password seems doesn't match in records. please try again.",'code'=>400], 400); return response()->json(['status' => 'failed', 'message' => "old password seems doesn't match in records. please try again.", 'code' => 400], 400);
} } elseif ($data['old_password'] === $result->password) {
elseif($data['old_password'] === $result->password) { return response()->json(['status' => 'success', 'message' => "old password match", 'data' => $result, 'code' => 200], 200);
return response()->json(['status'=>'success','message'=>"old password match",'data'=>$result,'code'=>200], 200);
} }
} } else {
else { return response()->json(['status' => 'failed', 'message' => 'old_password is required!', 'code' => 400], 400);
return response()->json(['status'=>'failed','message'=>'old_password is required!','code'=>400], 400);
} }
} }
public function sync(){ public function sync()
{
Artisan::call('sync:integration-human-resources'); Artisan::call('sync:integration-human-resources');
} }
} }

44
app/Http/Controllers/MapMonitoringController.php

@ -25,14 +25,23 @@ class MapMonitoringController extends Controller
->get(); ->get();
// get position hr in presensi // get position hr in presensi
$tmp = []; $tmp = [];
foreach($hr_assign_project as $key){ foreach ($hr_assign_project as $key) {
$presensi = DB::table('t_clock_in_out as tcio') $presensi = DB::table('t_clock_in_out as tcio')
->select('tcio.id as clock_in_out_id','mu.id as user_id', 'mu.name as fullname', 'tcio.clock_in', 'tcio.clock_out', 'tcio.clock_in_lat', 'tcio.clock_in_lng', ->select(
'tcio.clock_out_lat', 'tcio.clock_out_lng', 'tcio.clock_in_loc', 'tcio.clock_out_loc', 'tcio.clock_in_boundary', 'tcio.id as clock_in_out_id',
'tcio.clock_out_boundary', 'mu.username', 'tcio.date_presence', 'tcio.created_at') 'mu.id as user_id',
'mu.name as fullname',
'tcio.clock_in',
'tcio.clock_out',
'tcio.clock_in_lat',
'tcio.clock_in_lng',
'tcio.clock_in_loc',
'tcio.clock_out_loc',
'tcio.date_presence'
)
->join('m_users as mu', 'mu.id', '=', 'tcio.user_id') ->join('m_users as mu', 'mu.id', '=', 'tcio.user_id')
->where('mu.id', $key->user_id) ->where('mu.id', $key->user_id)
->orderBy('tcio.id', 'DESC') ->orderBy('tcio.clock_in', 'DESC')
->first(); ->first();
$project = DB::table('assign_hr_to_proyek as ahtp') $project = DB::table('assign_hr_to_proyek as ahtp')
->select('ahtp.proyek_id as id', 'mp.nama as project_name') ->select('ahtp.proyek_id as id', 'mp.nama as project_name')
@ -40,31 +49,28 @@ class MapMonitoringController extends Controller
->whereIn('ahtp.proyek_id', $request->project_id) ->whereIn('ahtp.proyek_id', $request->project_id)
->where('ahtp.user_id', $key->user_id) ->where('ahtp.user_id', $key->user_id)
->get(); ->get();
if($presensi && isset($presensi->user_id)){ if ($presensi && isset($presensi->user_id)) {
$image = DB::table('m_image')->select('image')->where('category', 'presensi')->where('ref_id', $presensi->clock_in_out_id)->first(); $image = DB::table('m_image')->select('image')->where('category', 'presensi')->where('ref_id', $presensi->clock_in_out_id)->first();
$waypoint = DB::table('m_waypoint')->select('lat', 'lon', 'wptime')->where('user_id', $presensi->user_id)->orderBy('wptime', 'DESC')->first();
$tmp[] = array( $tmp[] = array(
'user_id' => $presensi->user_id, 'user_id' => $presensi->user_id,
'wp_lat' => isset($waypoint) ? $waypoint->lat : $presensi->clock_in_lat,
'wp_lon' => isset($waypoint) ? $waypoint->lon : $presensi->clock_in_lng,
'wp_time' => isset($waypoint) ? $waypoint->wptime : $presensi->clock_in,
'clock_in' => $presensi->clock_in, 'clock_in' => $presensi->clock_in,
'clock_out' => $presensi->clock_out, 'clock_out' => $presensi->clock_out,
'date_presence' => $presensi->date_presence,
'clock_in_lat' => $presensi->clock_in_lat, 'clock_in_lat' => $presensi->clock_in_lat,
'clock_in_lng' => $presensi->clock_in_lng, 'clock_in_lng' => $presensi->clock_in_lng,
'clock_out_lat' => $presensi->clock_out_lat,
'clock_out_lng' => $presensi->clock_out_lng,
'clock_in_loc' => $presensi->clock_in_loc, 'clock_in_loc' => $presensi->clock_in_loc,
'clock_out_loc' => $presensi->clock_out_loc, 'clock_out_loc' => $presensi->clock_out_loc,
'clock_in_boundary' => $presensi->clock_in_boundary,
'clock_out_boundary' => $presensi->clock_out_boundary,
'username' => $presensi->username,
'name' => $presensi->fullname, 'name' => $presensi->fullname,
'image_selfie' => isset($image->image) ? $image->image : '-', 'image_selfie' => isset($image->image) ? $image->image : '-',
'created_at' => $presensi->created_at, 'presence_status' => $presensi->date_presence == $dateNow ? true : false, //true, //status date_presence,
'presence_status' => $presensi->date_presence == $dateNow ? true : false,//true, //status date_presence,
'projects' => $project 'projects' => $project
); );
} }
} }
return response()->json(['status'=>'success','code'=>200, 'data' => $tmp, 'totalRecord'=>count($tmp)], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $tmp, 'totalRecord' => count($tmp)], 200);
} }
public function list() public function list()
@ -72,10 +78,10 @@ class MapMonitoringController extends Controller
$data = Presence::all(); $data = Presence::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{ } else {
return response()->json(['status'=>'failed','message'=>'failed get list presence, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get list presence, please try again later!', 'code' => 400], 400);
} }
} }

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{

201
app/Http/Controllers/PresenceController.php

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\HumanResource;
use Log; use Log;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Presence; use App\Models\Presence;
@ -24,9 +25,12 @@ class PresenceController extends Controller
if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){
$statusBoundary = true; $statusBoundary = true;
} }
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if (!$statusRestriction->status_boundary) {
$statusBoundary = true;
}
// not assign // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => $statusBoundary
@ -34,7 +38,7 @@ class PresenceController extends Controller
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200);
} }
// assign and not in boundary // assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => true 'boundary' => true
@ -61,7 +65,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate, "clock_in_out_id" => $resultUpdate,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->type, "type" => $request->type,
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName
@ -82,7 +86,8 @@ class PresenceController extends Controller
} }
$onlyDate = date_format($date,"Y-m-d"); $onlyDate = date_format($date,"Y-m-d");
$clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; // $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name;
$clock_in_loc = "test";
$dataAdd = array( $dataAdd = array(
'user_id'=> $request->user_id, 'user_id'=> $request->user_id,
@ -134,9 +139,12 @@ class PresenceController extends Controller
if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){
$statusBoundary = true; $statusBoundary = true;
} }
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if (!$statusRestriction->status_boundary) {
$statusBoundary = true;
}
// not assign // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => $statusBoundary
@ -144,7 +152,7 @@ class PresenceController extends Controller
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200);
} }
// assign and not in boundary // assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => true 'boundary' => true
@ -171,7 +179,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate, "clock_in_out_id" => $resultUpdate,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->clock_in_out['type'], "type" => $request->clock_in_out['type'],
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName
@ -225,7 +233,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $result->id, "clock_in_out_id" => $result->id,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->type, "type" => $request->type,
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName
@ -251,6 +259,138 @@ class PresenceController extends Controller
// cek user tersebut apakah punya assign task yang ada bondary nya // cek user tersebut apakah punya assign task yang ada bondary nya
// geom ada di table activity // geom ada di table activity
// $clock_time = // $clock_time =
$user = HumanResource::find($params->user_id);
$geomQuery = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id")
->join("m_activity as ma", "ma.id", "=", "ahta.activity_id")
->where("ahta.user_id", $params->user_id)
->whereNotNull("ma.geom")
->whereDate("ma.start_date", "<=", $params->time)
->whereDate("ma.end_date", ">=", $params->time);
if (isset($params->report_k3['proyek_id'])) {
$geom = $geomQuery->where("ma.proyek_id", $params->report_k3['proyek_id'])->get();
} else {
$geom = $geomQuery->get();
}
$temp = [];
if (count($geom) > 0) {
foreach($geom as $dataGeom){
$valGeom = json_decode($dataGeom->geom);
if($params->clock_in_out['type']=="out"){
if($valGeom->type == "FeatureCollection"){
$multiArea = $valGeom->features;
foreach($multiArea as $area){
if ($area->geometry->type === "Point") {
$pointCoordinates = $area->geometry->coordinates;
$pointLng = $pointCoordinates[0];
$pointLat = $pointCoordinates[1];
$check = DB::select(DB::raw("SELECT ST_Distance(
ST_GeomFromGeoJSON('" . json_encode($area->geometry) . "'),
ST_GeomFromText('POINT(" . $params->clock_in_out['clock_in_lng'] . " " . $params->clock_in_out['clock_in_lat'] . ")', 4326)
) <= " . $area->properties->radius . " as within_radius"));
if ($check[0]->within_radius) {
break;
}
}
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary"));
if($check[0]->boundary){
break;
}
}
}else{
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary"));
}
}else{
if($valGeom->type == "FeatureCollection"){
$multiArea = $valGeom->features;
foreach($multiArea as $area){
if ($area->geometry->type === "Point") {
$pointCoordinates = $area->geometry->coordinates;
$pointLng = $pointCoordinates[0];
$pointLat = $pointCoordinates[1];
$check = DB::select(DB::raw("SELECT ST_Distance(
ST_GeomFromGeoJSON('" . json_encode($area->geometry) . "'),
ST_GeomFromText('POINT(" . $params->clock_in_out['clock_in_lng'] . " " . $params->clock_in_out['clock_in_lat'] . ")', 4326)
) <= " . $area->properties->radius . " as within_radius"));
if ($check[0]->within_radius) {
break;
}
}
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary"));
if($check[0]->boundary){
break;
}
}
}else{
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary"));
}
}
if(!$user->status_boundary || count($check)>0){
if(!$user->status_boundary || (isset($check[0]->boundary) && $check[0]->boundary)){
$temp[]=array(
"activity_id" => $dataGeom->id,
"boundary" => $check[0]->boundary,
"status_assign" => true
);
} else if (!$user->status_boundary || (isset($check[0]->within_radius) && $check[0]->within_radius)) {
$temp[]=array(
"activity_id" => $dataGeom->id,
"boundary" => $check[0]->within_radius,
"status_assign" => true
);
}
} else {
// bypass work area restriction
$temp[]=array(
"activity_id" => null,
"boundary" => true,
"status_assign" => true
);
}
}
// assign and not in boundary
if(count($temp) < 1){
$temp[]=array(
"activity_id" => null,
"boundary" => false,
"status_assign" => true
// "geom" => $geom,
// "cek" => $check[0]->boundary
);
}
}
else{
if ($user->status_boundary) {
// bypass work area restriction
$temp[]=array(
"activity_id" => null,
"boundary" => true,
"status_assign" => true
);
} else {
// not assign
$temp[]=array(
"activity_id" => null,
"boundary" => false,
"status_assign" => false
);
}
}
return $temp;
}
public function checkLocationTest(Request $request){
// cek user tersebut apakah punya assign task yang ada bondary nya
// geom ada di table activity
// $clock_time =
$params = $request;
$geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id") $geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id")
->join("m_activity as ma", "ma.id", "=", "ahta.activity_id") ->join("m_activity as ma", "ma.id", "=", "ahta.activity_id")
->where("ahta.user_id", $params->user_id) ->where("ahta.user_id", $params->user_id)
@ -259,24 +399,51 @@ class PresenceController extends Controller
->whereDate("ma.end_date", ">=", $params->time) ->whereDate("ma.end_date", ">=", $params->time)
->get(); ->get();
$temp = []; $temp = [];
// return json_encode($geom);
if (count($geom) > 0) { if (count($geom) > 0) {
foreach($geom as $dataGeom){ foreach($geom as $dataGeom){
$valGeom = json_decode($dataGeom->geom); $valGeom = json_decode($dataGeom->geom);
if($params->clock_in_out['type']=="out"){ if($params->clock_in_out['type']=="out"){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary")); if($valGeom->type == "FeatureCollection"){
// return count($valGeom->features);
$multiArea = $valGeom->features;
foreach($multiArea as $area){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary"));
if($check[0]->boundary){
break;
}
}
}else{ }else{
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary"));
} }
foreach ($check as $key) { }else{
// assign and in boundary if($valGeom->type == "FeatureCollection"){
if($key->boundary){ // return count($valGeom->features);
$multiArea = $valGeom->features;
foreach($multiArea as $area){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary"));
if($check[0]->boundary){
break;
}
}
}else{
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary"));
}
}
if(count($check)>0){
if($check[0]->boundary){
$temp[]=array( $temp[]=array(
"activity_id" => $dataGeom->id, "activity_id" => $dataGeom->id,
"boundary" => $key->boundary, "boundary" => $check[0]->boundary,
"status_assign" => true "status_assign" => true
); );
} }
} }
}
// assign and not in boundary // assign and not in boundary
if(count($temp) < 1){ if(count($temp) < 1){
$temp[]=array( $temp[]=array(
@ -288,7 +455,7 @@ class PresenceController extends Controller
); );
} }
} }
}else{ else{
// not assign // not assign
$temp[]=array( $temp[]=array(
"activity_id" => null, "activity_id" => null,

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

352
app/Http/Controllers/ProjectController.php

@ -2,33 +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;
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";
@ -63,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('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,area_kerja,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);
@ -143,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);
} }
@ -217,64 +237,53 @@ class ProjectController extends Controller
public function list() public function list()
{ {
$data = Project::orderBy('id', 'desc')->get(); $data = Project::select(
'id',
'kode_sortname',
'jumlah_stakeholder',
'nama',
'mulai_proyek',
'akhir_proyek',
'area_kerja',
'lokasi_kantor',
'rencana_biaya',
'biaya_actual',
'company',
'pm_id',
'type_proyek_id',
'divisi_id',
'persentase_progress',
'keterangan',
'durasi_proyek',
'progress_by_worklog',
'status',
'currency_symbol',
'currency_code',
'currency_name',
'project_objectives',
'considered_success_when',
'potential_risk',
'testing_environment',
'currency_code',
'currency_symbol',
'currency_name',
'budget_health',
'phase_id',
'calculation_status',
'created_at',
'created_by',
'updated_at',
'updated_by'
)->orderBy('id', 'desc')->get();
$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'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$scheduleWarningThreshold = 10;
$scheduleDangerThreshold = 5;
foreach($data as $d){
$progress = $costVariance = $actualCost = 0;
$lastActivity = null;
$scheduleHealth = "on-track";
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $d->id)->orderBy('version_gantt_id', 'desc')->first();
if($rootActivity){
$costVariance = (int)$d->rencana_biaya - (int)$rootActivity->biaya_actual;
$actualCost = $rootActivity->biaya_actual ?? 0;
$progress = $rootActivity->persentase_progress ?? 0;
$timeleft = strtotime($d->mulai_proyek) - strtotime($rootActivity->end_date);
$date1 = new \DateTime(date("Y-m-d", strtotime($d->mulai_proyek)));
$date2 = new \DateTime(date("Y-m-d", strtotime($rootActivity->end_date)));
$daysRemaining = $date2->diff($date1);
$daysRemaining = $daysRemaining->d;
if($daysRemaining <= $scheduleDangerThreshold) {
$scheduleHealth = "danger";
} elseif ($daysRemaining <= $scheduleWarningThreshold) {
$scheduleHealth = "warning";
}
$lastActivity = date("d/m/Y", strtotime($rootActivity->end_date));
}
$d->plannedInterval = date("d/m/Y", strtotime($d->mulai_proyek)) . " - " . date("d/m/Y", strtotime($d->akhir_proyek));
$d->plannedCost = $d->rencana_biaya;
$d->actualCost = $actualCost;
$d->lastActivity = $lastActivity ?? "-";
$d->costVariance = $costVariance;
$d->costHealth = $d->budget_health;
$d->scheduleHealth = $scheduleHealth;
$d->progress = $progress;
$d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null;
$d->manpower = UserToProyek::where("proyek_id", $d->id)->count() ?? 0;
$d->projectManager = DB::table('m_proyek')
->join('m_users', 'm_users.id', '=', 'm_proyek.pm_id')
->where('m_proyek.id', $d->id)
->pluck('m_users.name')
->first();
if($d->area_kerja != ''){
$d->geolocation = $this->httpReq($d->area_kerja);
$d->geolocation = [];
} else {
$d->geolocation = [];
}
}
$totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost'))); $totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost')));
$totalActualCost = $data->sum('actualCost'); $totalActualCost = $data->sum('actualCost');
$manpowers = User::count(); $manpowers = User::count();
$projectsOnDanger = Project::where('budget_health', 'danger')->count(); $projectsOnDanger = Project::where('budget_health', 'overrun')->count();
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); $projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name');
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); $projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name');
try { try {
@ -288,7 +297,7 @@ class ProjectController extends Controller
} }
try { try {
$projectsByType = DB::table('m_proyek') $projectsByType = DB::table('m_proyek')
->select('m_type_proyek.name', DB::raw('count(*) as total')) ->select('m_type_proyek.name', DB::raw('count(m_type_proyek.id) as total'))
->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') ->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id')
->groupBy('m_type_proyek.name') ->groupBy('m_type_proyek.name')
->get(); ->get();
@ -332,6 +341,63 @@ class ProjectController extends Controller
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
} }
public function calculateSCurve(Request $request){
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first();
return response()->json(['status'=>'success','code'=>200, 'data' => json_decode($sCurve->scurve)], 200);
}
public function sCurveCommand(Request $request){
Artisan::call('calculate:scurve', [
'project_id' => $request->project_id
]);
// $project = Project::find($request->project_id);
// if ($project) {
// dispatch(new ProcessSCurve($project));
// return response()->json(['message' => 'S Curve calculation queued']);
// }
// return response()->json(['message' => 'Project not found'], 404);
}
public function getLinearSCurve(Request $request){
$data = MasterFunctionsHelper::getLinearSCurve($request);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
}
public static function setSyncDate($activity_id, $activity, $report) {
$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)) {
$status->status_activity = 'open';
}
if ($status->status_activity != 'done') {
$minDate = date_create($report->report_date);
$maxDate = date_create($report->report_date);
date_add($maxDate, date_interval_create_from_date_string($activity->duration . " days"));
} else {
$material = AssignMaterial::where('activity_id', $activity_id)->first();
$minDate = date_create($material->start_activity);
$maxDate = date_create($material->finish_activity);
}
$reports = array(
'activity_id' => $activity_id,
'min_date' => $minDate,
'max_date' => $maxDate,
'status' => $status->status_activity
);
return $reports;
}
public function synchronizeReport($gantt_id) public function synchronizeReport($gantt_id)
{ {
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); $activities = Activity::where("version_gantt_id", $gantt_id)->get();
@ -343,31 +409,40 @@ class ProjectController extends Controller
if ($countReports === 1) { if ($countReports === 1) {
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); $dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get();
foreach($dataReports as $dr) { foreach($dataReports as $dr) {
$reports[] = array( $reports[] = ProjectController::setSyncDate($activity_id, $activity, $dr);
'activity_id'=>$activity_id,
'min_date'=>$dr->report_date,
'max_date'=>date_modify(date_create($dr->report_date), "1 days")
);
} }
} }
if ($countReports > 1) { if ($countReports > 1) {
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); $firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first();
$lastReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); $reports[] = ProjectController::setSyncDate($activity_id, $activity, $firstReport);
$reports[] = array( }
'activity_id'=>$activity_id, $successor = Link::where('t_activity_id', $activity->id)->first();
'min_date'=>$firstReport->report_date, if ($successor) {
'max_date'=>date_modify(date_create($lastReport->report_date), "1 days") $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->reports = $reports; $activity->save();
} }
/* 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); */
for ($i=0; $i < count($reports); $i++) { for ($i=0; $i < count($reports); $i++) {
$activity = Activity::find($reports[$i]['activity_id']); $activity = Activity::find($reports[$i]['activity_id']);
$activity->start_date = $reports[$i]['min_date']; if($reports[$i]['status'] != 'done'){
$activity->end_date = $reports[$i]['max_date']; $reports[$i]['max_date']->modify('-1 day');
}else if($reports[$i]['status'] == 'done'){
$activity->actual_end = $reports[$i]['max_date']->setTime(23,59,59);
}
$activity->start_date = $reports[$i]['min_date']; //same early
$activity->end_date = $reports[$i]['max_date']->setTime(23,59,59); // same early
$startDate = new DateTime($activity->start_date);
$endDate = new DateTime($activity->end_date);
$duration = MasterFunctionsHelper::countDays($activity->version_gantt_id, $startDate, $endDate);
$activity->duration = $duration;
$activity->actual_start = $reports[$i]['min_date'];
$activity->save(); $activity->save();
} }
@ -382,6 +457,8 @@ class ProjectController extends Controller
$activity->update([ $activity->update([
"planned_start"=>$activity->start_date, "planned_start"=>$activity->start_date,
"planned_end"=>$activity->end_date, "planned_end"=>$activity->end_date,
"early_start"=>$activity->start_date,
"early_end"=>$activity->end_date,
]); ]);
} }
@ -389,18 +466,38 @@ class ProjectController extends Controller
} }
public function getInvoiceIntegration(Request $request) { public function getInvoiceIntegration(Request $request) {
// $search = urlencode($request->search); $ganttCount = VersionGantt::where('proyek_id', $request->id)->count();
// if(empty($search)) $search = urlencode($request->search);
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); if(empty($search))
// $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
$response = null;
$response = MasterFunctionsHelper::curlReq($url);
if (isset($request->gantt_id)) {
$response->data->total_cost = $response->data->total_cost / $ganttCount;
}
return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200);
} }
public function getByUser($id)
{
$alias = "utp";
$userProyek = UserToProyek::query()
->from('assign_hr_to_proyek AS ' . $alias)
->where([
['is_customer', true],
['user_id', $id]
])
->leftJoin('m_users', $alias.'.user_id', '=', 'm_users.id')
->leftJoin('m_proyek', $alias.'.proyek_id', '=', 'm_proyek.id')
->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id')
->select('m_proyek.*', 'm_type_proyek.name AS join_second_name','m_users.name AS join_first_name')
->get();
$totalRecord = $userProyek->count();
public function detail($id){ return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
}
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);
@ -408,11 +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);
$ganttId = $gantt['last_gantt_id'];
} else {
$ganttId = $gantt_id;
}
$result->projectManager = User::where('id', $result->pm_id)->value('name'); $result->projectManager = User::where('id', $result->pm_id)->value('name');
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first();
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); 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();
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists();
$query = Activity::where('version_gantt_id', $ganttId);
}
if ($actualStartExist) {
$startDate = $query->orderBy('actual_start')->value('start_date');
} else {
$startDate = $query->orderBy('start_date')->value('start_date');
}
if ($actualEndExist) {
$endDate = $query->orderByDesc('actual_end')->value('end_date');
} else {
$endDate = $query->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->end_date = $endDate;
$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){
@ -425,11 +560,23 @@ class ProjectController extends Controller
if(!$result) if(!$result)
return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404);
//TODO possible overdue bug //TODO possible overdue bug
if(isset($payload['till_date'])) $endDate = Activity::where('proyek_id', $payload['id'])
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); ->orderByDesc('end_date')
else ->value('end_date');
if(isset($payload['till_date'])) {
if (isset($payload['scurve'])) {
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$endDate)->orderBy('end_date', 'asc')->get();
} else {
$overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$endDate)->orderBy('end_date', 'asc')->get();
}
}
else {
if (isset($payload['scurve'])) {
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get();
} else {
$overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get();
}
}
$result->overdueActivities = $overdueActivities; $result->overdueActivities = $overdueActivities;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200);
@ -456,9 +603,8 @@ class ProjectController extends Controller
} }
public function getManpower($proyek_id){ public function getManpower($proyek_id){
$manPower = UserToProyek::where('proyek_id', $proyek_id)->get(); $manCount = UserToProyek::where('proyek_id', $proyek_id)->count();
$manCount = $manPower->count(); return response()->json(['totalRecord'=>$manCount]);
return response()->json(['data'=>$manPower, 'totalRecord'=>$manCount]);
} }
public function getAssignedHR($gantt_id){ public function getAssignedHR($gantt_id){

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

53
app/Http/Controllers/ReportActivityMaterialController.php

@ -2,11 +2,13 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Helpers\MasterFunctionsHelper;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use App\Models\Activity; use App\Models\Activity;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
use Datatables; use Datatables;
use DateTime;
class ReportActivityMaterialController extends Controller class ReportActivityMaterialController extends Controller
{ {
@ -35,11 +37,11 @@ class ReportActivityMaterialController extends Controller
/* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */ /* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */
$data['assign_material_id'] = $request->assign_material_id; $data['assign_material_id'] = $request->assign_material_id;
$data['qty'] = $this->sanitizeDecimal($data['qty']); $data['qty'] = $this->sanitizeDecimal($data['qty']);
if($reportDate > $startDate){ if($reportDate >= $startDate || isset($data['force']) && $data['force'] == "true"){
$created = ReportActivityMaterial::create($data); $created = ReportActivityMaterial::create($data);
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]); return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]);
} else { } else {
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null], 400); return response()->json(['status'=>'failed','message'=>'Report date is before early start, still wanna add data ?','code'=>400,'data'=>$data], 400);
} }
} }
@ -59,6 +61,27 @@ 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(
"actual_start" => null,
"actual_end" => null,
"persentase_progress" => $sumReportActivityMaterial/$sumAssignMaterial*100,
"updated_by" => $this->currentName
);
if ($sumReportActivityMaterial > 0) {
$data = [];
$reportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->get();
foreach ($reportActivityMaterial as $value) {
$data[] = $value;
}
$actualStartValues = array_column(array_filter($data, function($item) {
return isset($item['report_date']);
}), 'report_date');
$dataUpdate["actual_start"] = min($actualStartValues);
}
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]);
@ -104,22 +127,39 @@ class ReportActivityMaterialController extends Controller
$type = $request->query('type'); $type = $request->query('type');
$materialName = $request->query('materialName'); $materialName = $request->query('materialName');
if($type == 'plan'){ if($type == 'plan'){
$activity = Activity::findOrFail($id_activity);
$baselineDuration = 0;
if (isset($activity->planned_start) && isset($activity->planned_end)) {
$baselineDuration = MasterFunctionsHelper::countDays($activity->version_gantt_id, new DateTime($activity->planned_start), new DateTime($activity->planned_end));
}
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") $data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $id_activity) ->where('assign_material_to_activity.activity_id', $id_activity)
->where('m.description', $materialName) ->where('m.description', $materialName)
->orderBy('assign_material_to_activity.id', 'asc') ->orderBy('assign_material_to_activity.id', 'asc')
->get(); ->get();
if ($baselineDuration > 0) {
foreach ($data as $key => $value) {
$data[$key]->qty_planning = number_format($value->qty_planning / $baselineDuration, 1);
}
}
return Datatables::of($data) return Datatables::of($data)
->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") $activity = Activity::findOrFail($id_activity);
$baselineDuration = 0;
if (isset($activity->planned_start) && isset($activity->planned_end)) {
$baselineDuration = MasterFunctionsHelper::countDays($activity->version_gantt_id, new DateTime($activity->planned_start), new DateTime($activity->planned_end));
}
$data = ReportActivityMaterial::select("report_activity_material.*", "u.name as human_resource", "amta.status_activity", "amta.qty_planning")
->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")
@ -127,11 +167,18 @@ class ReportActivityMaterialController extends Controller
->where('m.description', $materialName) ->where('m.description', $materialName)
->orderBy('report_activity_material.report_date', 'asc') ->orderBy('report_activity_material.report_date', 'asc')
->get(); ->get();
if ($baselineDuration > 0) {
foreach ($data as $key => $value) {
$data[$key]->qty_planning = number_format($value->qty_planning / $baselineDuration, 1);
}
}
return Datatables::of($data) return Datatables::of($data)
->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);

2
app/Http/Controllers/RequestMaterialController.php

@ -170,7 +170,7 @@ class RequestMaterialController extends Controller
} }
public function getMaterialIntegration(Request $request) { public function getMaterialIntegration(Request $request) {
$search = null; $search = urlencode($request->name);
if(empty($search)) if(empty($search))
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/stock_master?name=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw').'/stock_master?name=SEARCH');

10
app/Http/Controllers/RoleController.php

@ -11,13 +11,16 @@ 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'
]); ]);
$data = $request->all(); $data = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
if (!isset($data['default_page'])) {
$data['default_page'] = 29; // dashboard
}
$result = Role::create($data); $result = Role::create($data);
@ -44,7 +47,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);

6
app/Http/Controllers/ShowHideColumnController.php

@ -45,12 +45,12 @@ class ShowHideColumnController extends Controller
$success = 0; $success = 0;
foreach ($columns as $column) { foreach ($columns as $key => $column) {
$dataAdd = array( $dataAdd = array(
'version_gantt_id'=>$request->version_gantt_id, 'version_gantt_id'=>$request->version_gantt_id,
'user_id'=>$this->currentId, 'user_id'=>$this->currentId,
'column_name'=>$column, 'column_name'=>$key,
'show'=>true, 'show'=>$column,
'created_by'=>$this->currentName 'created_by'=>$this->currentName
); );

40
app/Http/Controllers/UserToActivityController.php

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\UserToActivity; use App\Models\UserToActivity;
use App\Models\Activity; use App\Models\Activity;
use App\Models\AssignMaterial;
use Datatables; use Datatables;
class UserToActivityController extends Controller class UserToActivityController extends Controller
@ -41,7 +42,10 @@ class UserToActivityController extends Controller
"activity_id" => $request->activity_id, "activity_id" => $request->activity_id,
"role_proyek_id" => $users_role[$index], "role_proyek_id" => $users_role[$index],
"proyek_id" => $request->proyek_id, "proyek_id" => $request->proyek_id,
"created_by" => $this->currentName "start_date" => $request->start_date,
"end_date" => $request->end_date,
"created_by" => $this->currentName,
"version_gantt_id" => $request->version_gantt_id
); );
$result = UserToActivity::create($dataInsert); $result = UserToActivity::create($dataInsert);
if($result){ if($result){
@ -128,10 +132,42 @@ 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'];
$status = $join_column['status'];
$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();
if (isset($status) && $status != "") {
$filteredData = [];
foreach ($dataGet as $value) {
$assignMaterial = AssignMaterial::where('activity_id', $value->activity_id)->first();
if ($assignMaterial->status_activity == $status) {
$filteredData[] = $value;
}
}
$dataGet = $filteredData;
}
$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);
} }
@ -182,7 +218,7 @@ class UserToActivityController extends Controller
public function datatables(Request $request){ public function datatables(Request $request){
$id_activity = $request->query('idact'); $id_activity = $request->query('idact');
$data = UserToActivity::select("assign_hr_to_activity.id as id", "u.name as user_name", "mrp.name as role_name") $data = UserToActivity::select("assign_hr_to_activity.id as id", "assign_hr_to_activity.start_date", "assign_hr_to_activity.end_date", "u.name as user_name", "mrp.name as role_name")
->join("m_role_proyek as mrp", "mrp.id", "=", "assign_hr_to_activity.role_proyek_id") ->join("m_role_proyek as mrp", "mrp.id", "=", "assign_hr_to_activity.role_proyek_id")
->join("m_users as u", "u.id", "=", "assign_hr_to_activity.user_id") ->join("m_users as u", "u.id", "=", "assign_hr_to_activity.user_id")
->where('assign_hr_to_activity.activity_id', $id_activity) ->where('assign_hr_to_activity.activity_id', $id_activity)

44
app/Http/Controllers/UserToProyekController.php

@ -30,6 +30,48 @@ class UserToProyekController extends Controller
} }
} }
public function addMultiple(Request $request){
$user_IDs = $request->user_id;
$data = UserToProyek::where([
["proyek_id" , $request->proyek_id],
['is_customer',true]
]);
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);
@ -185,7 +227,7 @@ class UserToProyekController extends Controller
} }
public function getEmployeeIntegration(Request $request) { public function getEmployeeIntegration(Request $request) {
$search = null; $search = urlencode($request->name);
if(empty($search)) if(empty($search))
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/employees?emp_name=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw').'/employees?emp_name=SEARCH');

3
app/Http/Controllers/VersionGanttController.php

@ -91,7 +91,7 @@ class VersionGanttController extends Controller
} }
public function ganttProgress($column, $value){ public function ganttProgress($column, $value){
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress') $progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning')
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id') ->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id')
->where("m_version_gantt.".$column, $value) ->where("m_version_gantt.".$column, $value)
// ->where('m_activity.type_activity', "project") // ->where('m_activity.type_activity', "project")
@ -100,6 +100,7 @@ class VersionGanttController extends Controller
foreach($progress as $item) { foreach($progress as $item) {
if($item->persentase_progress){ if($item->persentase_progress){
$item->progress = $item->persentase_progress; $item->progress = $item->persentase_progress;
$item->bobot = $item->bobot_planning;
$item->save(); $item->save();
} }
} }

36
app/Jobs/ProcessSCurve.php

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

18
app/Models/Activity.php

@ -25,7 +25,7 @@ class Activity extends Model
'buffer_radius', 'duration', 'color_progress', 'jumlah_pekerjaan', 'satuan', 'buffer_radius', 'duration', 'color_progress', 'jumlah_pekerjaan', 'satuan',
'description', 'priority', 'bobot_planning', 'type_activity', 'open', 'geom', 'description', 'priority', 'bobot_planning', 'type_activity', 'open', 'geom',
'version_gantt_id', 'budget_plan', 'biaya_material_plan', 'biaya_human_plan', 'biaya_tools_plan', 'version_gantt_id', 'budget_plan', 'biaya_material_plan', 'biaya_human_plan', 'biaya_tools_plan',
'planned_start', 'planned_end', 'satuan_id', 'planned_start', 'planned_end', 'satuan_id', 'actual_start', 'actual_end',
'created_at', 'created_by', 'updated_at', 'updated_by', 'sortorder' 'created_at', 'created_by', 'updated_at', 'updated_by', 'sortorder'
]; ];
@ -36,6 +36,11 @@ class Activity extends Model
public function getStartDateAttribute($value) public function getStartDateAttribute($value)
{ {
if ($value instanceof \DateTime) {
return Carbon::instance($value)
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
return Carbon::createFromTimestamp(strtotime($value)) return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE')) ->timezone(env('APP_TIMEZONE'))
->toDateTimeString(); ->toDateTimeString();
@ -43,6 +48,11 @@ class Activity extends Model
public function getEndDateAttribute($value) public function getEndDateAttribute($value)
{ {
if ($value instanceof \DateTime) {
return Carbon::instance($value)
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
return Carbon::createFromTimestamp(strtotime($value)) return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE')) ->timezone(env('APP_TIMEZONE'))
->toDateTimeString(); ->toDateTimeString();
@ -61,8 +71,8 @@ class Activity extends Model
$data->updateCostPlanning(); $data->updateCostPlanning();
if($data->bobot_planning){ if($data->bobot_planning){
$data->updatePersentaseProgress(); $data->updatePersentaseProgress();
$data->updateCostActual();
} }
$data->updateCostActual();
// if($data->start_date != request()->start_date || $data->end_date != request()->end_date) { // if($data->start_date != request()->start_date || $data->end_date != request()->end_date) {
// $data->updateStartEndDateHeader(); // $data->updateStartEndDateHeader();
// } // }
@ -76,8 +86,8 @@ class Activity extends Model
$data->updateCostPlanning(); $data->updateCostPlanning();
if($data->bobot_planning){ if($data->bobot_planning){
$data->updatePersentaseProgress(); $data->updatePersentaseProgress();
$data->updateCostActual();
} }
$data->updateCostActual();
$data->updateStartEndDateHeader(); $data->updateStartEndDateHeader();
}); });
@ -188,6 +198,8 @@ class Activity extends Model
return 0; return 0;
if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get()) if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get())
return 0; return 0;
if($dataPlan->isEmpty())
return 0;
if($dataPlan[0]->status_activity == 'done') if($dataPlan[0]->status_activity == 'done')
return 100; return 100;
return $this->persentase_progress; return $this->persentase_progress;

2
app/Models/AssignMaterial.php

@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\RequestMaterial; use App\Models\RequestMaterial;
use App\Models\Activity; use App\Models\Activity;
use App\Models\ReportActivityMaterial;
class AssignMaterial extends Model class AssignMaterial extends Model
{ {
@ -35,6 +36,7 @@ class AssignMaterial extends Model
}); });
static::deleted(function($data) { static::deleted(function($data) {
$reportActivities = ReportActivityMaterial::where('assign_material_id', $data->id)->delete();
$activity = Activity::where('id', $data->activity_id)->first(); $activity = Activity::where('id', $data->activity_id)->first();
$activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning); $activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning);
$activity->save(); $activity->save();

2
app/Models/Broadcast.php

@ -12,6 +12,6 @@ class Broadcast extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'title_notif', 'message_notif', 'description', 'send_to_type', 'created_at', 'created_by', 'updated_at', 'updated_by' 'title_notif', 'message_notif', 'description', 'send_to_type', 'send_to_id', 'status_send', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

1
app/Models/Divisi.php

@ -15,6 +15,7 @@ class Divisi extends Model
'name', 'name',
'parent', 'parent',
'description', 'description',
'color',
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',

13
app/Models/HierarchyFtth.php

@ -12,6 +12,17 @@ class HierarchyFtth extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress' 'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress', 'bobot_planning'
]; ];
public static function boot() {
parent::boot();
static::deleted(function($data) {
$ftths = HierarchyFtth::where('parent_id', $data->id)->get();
foreach ($ftths as $ftth) {
$ftth->delete();
}
});
}
} }

10
app/Models/Project.php

@ -30,18 +30,20 @@ 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',
'structur_organization',
'scurve',
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',

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

7
app/Models/ReportActivityMaterial.php

@ -59,17 +59,14 @@ class ReportActivityMaterial extends Model
$assignedMaterial = AssignMaterial::find($data->assign_material_id); $assignedMaterial = AssignMaterial::find($data->assign_material_id);
$activity->biaya_actual -= floatval($assignedMaterial->budget) * floatval($data->qty); $activity->biaya_actual -= floatval($assignedMaterial->budget) * floatval($data->qty);
$activity->actual_start = null;
$activity->actual_end = null;
$dataPlan = AssignMaterial::where('activity_id', $activity->id)->get(); $dataPlan = AssignMaterial::where('activity_id', $activity->id)->get();
if($dataPlan[0]->status_activity == 'done'){
$activity->persentase_progress = 100;
} else {
$totalPlan = $dataPlan->sum('qty_planning'); $totalPlan = $dataPlan->sum('qty_planning');
$totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $activity->id)->sum("qty"); $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $activity->id)->sum("qty");
$percentage = ($totalVolumeActual * 100) / $totalPlan; $percentage = ($totalVolumeActual * 100) / $totalPlan;
$activity->persentase_progress = $percentage >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; $activity->persentase_progress = $percentage >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage;
}
$activity->save(); $activity->save();
}); });

2
app/Models/Role.php

@ -12,6 +12,6 @@ class Role extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

2
app/Models/UserToActivity.php

@ -18,6 +18,8 @@ class UserToActivity extends Model
'version_gantt_id', 'version_gantt_id',
'role_proyek_id', 'role_proyek_id',
'activity_id', 'activity_id',
'start_date',
'end_date',
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',

2
app/Models/UserToProyek.php

@ -14,6 +14,6 @@ class UserToProyek extends Model
protected $fillable = [ protected $fillable = [
'user_id', 'proyek_id', 'rbs', 'project_role', 'group_r', 'max_used', 'standart_rate', 'user_id', 'proyek_id', 'rbs', 'project_role', 'group_r', 'max_used', 'standart_rate',
'uom_standart_rate', 'overtime_rate', 'uom_overtime_rate', 'cost_per_used', 'accrue_at', 'uom_standart_rate', 'overtime_rate', 'uom_overtime_rate', 'cost_per_used', 'accrue_at',
'base_calender', 'created_at', 'created_by', 'updated_at', 'updated_by' 'base_calender', 'is_customer', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

46
app/Models/VersionGantt.php

@ -3,6 +3,9 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\Activity;
use App\Models\Link;
use DateTime;
class VersionGantt extends Model class VersionGantt extends Model
{ {
@ -22,10 +25,53 @@ class VersionGantt extends Model
'committed_cost', 'committed_cost',
'cost_to_complete', 'cost_to_complete',
'progress', 'progress',
'bobot',
'hierarchy_ftth_id', 'hierarchy_ftth_id',
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by' 'updated_by'
]; ];
public static function boot() {
parent::boot();
static::updated(function($data) {
$data->updateActDuration();
});
}
public function updateActDuration(){
$daysOff = explode(',', $this->config_dayoff);
if (in_array('0', $daysOff)) {
$key = array_search('0', $daysOff, false);
$daysOff[$key] = '7';
}
$activities = Activity::where('version_gantt_id', $this->id)->get();
foreach ($activities as $value) {
$exist = Link::where('t_activity_id', $value->id)->exists();
$startDate = new DateTime($value->start_date);
$endDate = new DateTime($value->end_date);
$duration = $endDate->diff($startDate)->days + 1;
if ($exist) {
$duration--;
}
// Iterate through each day and subtract the days off
for ($i = 0; $i < $duration; $i++) {
$currentDate = clone $startDate;
$currentDate->modify("+$i day");
$currentDayOfWeek = $currentDate->format('N'); // Get the day of the week (1 - Monday, 7 - Sunday)
if (in_array($currentDayOfWeek, $daysOff)) {
$duration--; // Subtract one day from the duration for each day off
}
}
// Update the activity duration
$value->duration = $duration;
$value->save();
}
}
} }

49
app/Services/FCMService.php

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

1
bootstrap/app.php

@ -63,6 +63,7 @@ $app->configure('auth');
$app->configure('api'); $app->configure('api');
$app->configure('assets'); $app->configure('assets');
$app->configure('app'); $app->configure('app');
$app->configure('fcm');
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

2
config/api.php

@ -2,6 +2,6 @@
return [ return [
'nominatim' => env('API_NOMINATIM', 'https://nominatim.oslogdev.com'), 'nominatim' => env('API_NOMINATIM', 'https://nominatim.oslogdev.com'),
'adw' => env('API_ADW', 'http://ospro-api.adyawinsa.com:9083/api'), 'adw' => env('API_ADW', 'http://ospro-api.adyawinsa.com:9083/api'),
'adw_token' => env('API_ADW_TOKEN', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxMjAyIiwiZXhwIjoxNjkxODMwNDkzfQ.DvBQIOZsdFndWsliPCZT65Y6G5Xx4vWBKz8Rhe7rvRA') 'adw_token' => env('API_ADW_TOKEN', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxMjAyIiwiZXhwIjoxNzI0Mzk1NTExfQ.z9_Q7vjZbcbr8Mook4EmlOuOByNP12_DEDSabf0zanU')
]; ];
?> ?>

5
config/fcm.php

@ -0,0 +1,5 @@
<?php
return [
'server_key' => "AAAAin2zZmc:APA91bHFIYDzZGyVyXvt2C8I09wC2k8siWPQIo4b1Db0QjxCzQR5SRQU9KY1iNRIUhTL6OoLUs2x6UAiP1BNv-mwOlSR7C_405msoNL2p33JVBxrtqc7hdMc5TEdTBB4ZGRVH7ltQzSe",
];

36
database/migrations/2023_08_29_130624_create_jobs_table.php

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

9
docker/nginx/conf.d/default.conf

@ -15,6 +15,15 @@ server {
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;
client_max_body_size 100M;
client_body_buffer_size 5M;
fastcgi_read_timeout 900;
keepalive_timeout 900;
send_timeout 300;
proxy_read_timeout 900;
proxy_connect_timeout 900;
proxy_send_timeout 900;
} }
location / { location / {

1947
docker/php/php.ini

File diff suppressed because it is too large Load Diff

72
rest-client.http

@ -1,10 +1,12 @@
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NzQ3NzIzMSwiZXhwIjoxNjc4MDgyMDMxLCJuYmYiOjE2Nzc0NzcyMzEsImp0aSI6ImR5WWhRY3ZIbUJEcmFKMG0iLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.9zT6CBbQholzIdQ9ZBDoxMvrR-PKvIYkGzdNB6bim0Y @token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY5MTc2MDYyNCwiZXhwIjoxNjkyMzY1NDI0LCJuYmYiOjE2OTE3NjA2MjQsImp0aSI6Ikd2bEFPTE4yZ2FuRFdVbjEiLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.XNGbsmcgQ-CkV8vLlvnItGKM0R1am5X5b6qUFOR1DRo
@tokenS = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjkxNTcyMTIwLCJleHAiOjE2OTIxNzY5MjAsIm5iZiI6MTY5MTU3MjEyMCwianRpIjoiVUdqbnhLRVdlZzYyTTBnayIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.5QqK0dLW5jzbVOkSCSW0mFo0K7ycGOBW9NCG_2Zldm4
@hostname = https://adw-api.ospro.id/api
# @hostname = https://adw-api.ospro.id/api
# @hostname = https://ospro-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api
# @hostname = https://api-iu.ospro.id/api # @hostname = https://api-iu.ospro.id/api
# @hostname = https://api-staging-adw.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api
# @hostname = http://localhost:8444/api @hostname = http://localhost:8444/api
# @hostname = http://103.73.125.81:8444/api # @hostname = http://103.73.125.81:8444/api
# @hostname = http://localhost:8444/adw-backend/api # @hostname = http://localhost:8444/adw-backend/api
@ -402,6 +404,59 @@ GET {{hostname}}/project/list
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
###
POST {{hostname}}/project/search
Authorization: Bearer {{token}}
content-type: application/json
{
"columns": [
{
"name": "nama",
"logic_operator": "ilike",
"value": "",
"operator": "AND"
}
],
"select": ["kode_sortname", "nama", "mulai_proyek"],
"joins": [
{
"name": "m_users",
"column_join": "pm_id",
"column_results": [
"name",
"username"
]
},
{
"name": "m_type_proyek",
"column_join": "type_proyek_id",
"column_results": [
"name",
"description"
]
}
],
"orders": {
"columns": [
"id"
],
"ascending": false
},
"paging": {
"start": 0,
"length": 10
}
}
###
POST https://adw-api.ospro.id/api/project/search
Authorization: Bearer {{tokenS}}
content-type: application/json
{
"columns":[{"name":"nama","logic_operator":"ilike","value":"","operator":"AND"}],"joins":[{"name":"m_users","column_join":"pm_id","column_results":["name","username"]},{"name":"m_type_proyek","column_join":"type_proyek_id","column_results":["name","description"]}],"orders":{"columns":["id"],"ascending":false},"paging":{"start":0,"length":10}
}
### add ### add
POST {{hostname}}/project/add POST {{hostname}}/project/add
@ -1103,3 +1158,14 @@ content-type: application/json
} }
} }
#######
POST {{hostname}}/project/get-s-curve
Authorization: Bearer {{token}}
content-type: application/json
{
"period":"week",
"project_id":"118",
"gantt_id":"287"
}

46
routes/web.php

@ -53,11 +53,12 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject'); $router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject');
$router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen'); $router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/project-by-customer/{id}','ProjectController@getByUser');
$router->post('/project/search', 'ProjectController@search'); $router->post('/project/search', 'ProjectController@search');
$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');
@ -66,6 +67,9 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR'); $router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR');
$router->post('/project/get-s-curve', 'ProjectController@getSCurve'); $router->post('/project/get-s-curve', 'ProjectController@getSCurve');
$router->post('/project/calculate-s-curve', 'ProjectController@calculateSCurve');
$router->post('/project/s-curve-command', 'ProjectController@sCurveCommand');
$router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve');
$router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities');
$router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration');
$router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution');
@ -202,7 +206,10 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId');
$router->get('/activity/search', 'ActivityController@search'); $router->get('/activity/search', 'ActivityController@search');
$router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import', 'ActivityController@import');
$router->post('/activity/import-update', 'ActivityController@importUpdate');
$router->post('/activity/import-old', 'ActivityController@importOld'); $router->post('/activity/import-old', 'ActivityController@importOld');
$router->post('/activity/batch-update/{ganttId}', 'ActivityController@batchUpdate');
$router->get('/activity/update-schedule/{ganttId}', 'ActivityController@updateSchedule');
$router->post('/task', 'ActivityController@add'); $router->post('/task', 'ActivityController@add');
$router->get('/task/edit/{id}', 'ActivityController@edit'); $router->get('/task/edit/{id}', 'ActivityController@edit');
$router->put('/task/{id}', 'ActivityController@update'); $router->put('/task/{id}', 'ActivityController@update');
@ -231,6 +238,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/comment-activity/list', 'CommentActivityController@list'); $router->get('/comment-activity/list', 'CommentActivityController@list');
$router->post('/presence/add', 'PresenceController@add'); $router->post('/presence/add', 'PresenceController@add');
$router->post('/presence/test', 'PresenceController@checkLocationTest');
$router->get('/presence/edit/{id}', 'PresenceController@edit'); $router->get('/presence/edit/{id}', 'PresenceController@edit');
$router->put('/presence/update/{id}', 'PresenceController@update'); $router->put('/presence/update/{id}', 'PresenceController@update');
$router->post('/presence/search', 'PresenceController@search'); $router->post('/presence/search', 'PresenceController@search');
@ -285,6 +293,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');
@ -374,6 +409,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');
@ -448,8 +484,16 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update'); $router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update');
$router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy'); $router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy');
$router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject'); $router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject');
$router->get('/hierarchy-ftths/tree-gantt/{gantt_id}', 'HierarchyFtthController@getTreeByGantt');
$router->post('/map-monitoring/search', 'MapMonitoringController@search'); $router->post('/map-monitoring/search', 'MapMonitoringController@search');
$router->post('/broadcast/add', 'BroadcastController@add');
$router->get('/broadcast/edit/{id}', 'BroadcastController@edit');
$router->put('/broadcast/update/{id}', 'BroadcastController@update');
$router->post('/broadcast/search', 'BroadcastController@search');
$router->delete('/broadcast/delete/{id}', 'BroadcastController@delete');
$router->get('/broadcast/list', 'BroadcastController@list');
}); });
}); });

Loading…
Cancel
Save