farhantock 7 months ago
parent
commit
f67a33fb27
  1. 28
      app/Console/Commands/CalculateProgressGantt.php
  2. 3
      app/Console/Kernel.php
  3. 916
      app/Helpers/MasterFunctionsHelper.php
  4. 380
      app/Http/Controllers/ActivityController.php
  5. 72
      app/Http/Controllers/ActivityDokumenController.php
  6. 175
      app/Http/Controllers/AssignMaterialController.php
  7. 319
      app/Http/Controllers/AssignToolsController.php
  8. 301
      app/Http/Controllers/AuthController.php
  9. 94
      app/Http/Controllers/CompanyController.php
  10. 115
      app/Http/Controllers/ContactSalesController.php
  11. 197
      app/Http/Controllers/Controller.php
  12. 458
      app/Http/Controllers/DashboardBoDController.php
  13. 116
      app/Http/Controllers/DemoController.php
  14. 93
      app/Http/Controllers/DivisiController.php
  15. 274
      app/Http/Controllers/FolderDocumentProyekController.php
  16. 73
      app/Http/Controllers/HierarchyFtthController.php
  17. 280
      app/Http/Controllers/HolidayController.php
  18. 202
      app/Http/Controllers/HumanResourceController.php
  19. 413
      app/Http/Controllers/ImageController.php
  20. 115
      app/Http/Controllers/KanbanBoardController.php
  21. 258
      app/Http/Controllers/KanbanCardController.php
  22. 45
      app/Http/Controllers/MenuCompanyController.php
  23. 118
      app/Http/Controllers/MenuController.php
  24. 92
      app/Http/Controllers/ProductTransactionController.php
  25. 387
      app/Http/Controllers/ProjectCarausellController.php
  26. 1033
      app/Http/Controllers/ProjectController.php
  27. 236
      app/Http/Controllers/ProjectDokumenController.php
  28. 93
      app/Http/Controllers/ProjectExpenditureController.php
  29. 93
      app/Http/Controllers/ProjectFinancialHealthController.php
  30. 93
      app/Http/Controllers/ProjectInvoiceController.php
  31. 241
      app/Http/Controllers/ProjectRoleController.php
  32. 93
      app/Http/Controllers/ProjectScheduleHealthController.php
  33. 81
      app/Http/Controllers/RefferalCodeController.php
  34. 2
      app/Http/Controllers/ReportActivityController.php
  35. 31
      app/Http/Controllers/ReportActivityMaterialController.php
  36. 74
      app/Http/Controllers/RoleController.php
  37. 51
      app/Http/Controllers/RoleMenuController.php
  38. 344
      app/Http/Controllers/UserRegisterController.php
  39. 235
      app/Http/Controllers/UserToActivityController.php
  40. 38
      app/Http/Controllers/UserToProyekController.php
  41. 96
      app/Http/Controllers/VersionGanttController.php
  42. 2
      app/Models/Absent.php
  43. 89
      app/Models/Activity.php
  44. 37
      app/Models/AssignMaterial.php
  45. 2
      app/Models/Broadcast.php
  46. 13
      app/Models/ChecklistK3.php
  47. 5
      app/Models/Company.php
  48. 27
      app/Models/ContactSales.php
  49. 26
      app/Models/Demo.php
  50. 4
      app/Models/HumanResource.php
  51. 17
      app/Models/KanbanBoard.php
  52. 17
      app/Models/KanbanCard.php
  53. 4
      app/Models/PanicButton.php
  54. 6
      app/Models/Presence.php
  55. 25
      app/Models/ProductTransaction.php
  56. 8
      app/Models/Project.php
  57. 17
      app/Models/ProjectExpenditure.php
  58. 17
      app/Models/ProjectFinancialHealth.php
  59. 17
      app/Models/ProjectInvoice.php
  60. 34
      app/Models/ProjectRole.php
  61. 17
      app/Models/ProjectScheduleHealth.php
  62. 34
      app/Models/ProjectType.php
  63. 28
      app/Models/RefferalCode.php
  64. 11
      app/Models/ReportK3.php
  65. 2
      app/Models/Role.php
  66. 2
      app/Models/RoleMenu.php
  67. 34
      app/Models/Satuan.php
  68. 401
      app/Models/User.php
  69. 57
      app/Models/UserToActivity.php
  70. 15833
      composer.lock
  71. 120
      rest-client.http
  72. 130
      routes/web.php

28
app/Console/Commands/CalculateProgressGantt.php

@ -0,0 +1,28 @@
<?php
namespace App\Console\Commands;
use App\Models\HierarchyFtth;
use Illuminate\Console\Command;
use App\Helpers\MasterFunctionsHelper;
use App\Models\Project;
class CalculateProgressGantt extends Command
{
protected $signature = 'calculate:progressgantt {hierarchy_id}';
protected $description = 'Calculate Progress Gantt';
public function handle()
{
$hierarchy_id = $this->argument('hierarchy_id');
$hierarchy = HierarchyFtth::findOrFail($hierarchy_id);
$project = Project::find($hierarchy->project_id);
$data = MasterFunctionsHelper::calculateSCurveForProgressTree($hierarchy_id);
$hierarchy->bobot_planning = 100;
$hierarchy->progress =round(((int) end($data[0]['data']['percentageReal']) / (int) end($data[0]['data']['percentagePlan'])) * 100, 2);
$hierarchy->save();
}
}

3
app/Console/Kernel.php

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

916
app/Helpers/MasterFunctionsHelper.php

File diff suppressed because it is too large Load Diff

380
app/Http/Controllers/ActivityController.php

@ -1,9 +1,11 @@
<?php
namespace App\Http\Controllers;
use DateTime;
use App\Models\Link;
use App\Models\User;
use App\Models\Company;
use App\Models\Project;
use App\Models\Activity;
use App\Models\TmpImport;
@ -15,9 +17,11 @@ use App\Models\AssignMaterial;
use App\Models\UserToActivity;
use App\Models\ActivityDokumen;
use App\Models\CommentActivity;
use App\Models\ProductTransaction;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Helpers\MasterFunctionsHelper;
use Carbon\Carbon;
class ActivityController extends Controller
{
@ -37,6 +41,94 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'data' => $dataGantt, 'code' => 200], 200);
}
public function activitySCurve($proyek_id, $gantt_id)
{
// "data": [
// {
// "id": 1,
// "text": "Office itinerancy",
// "type": "project",
// "order": "10",
// "progress": 0.4,
// "open": true,
// "user":"0",
// "start_date": "02-04-2024 00:00",
// "duration": 17,
// "end_date": "19-04-2024 00:00",
// "parent": 0
// }
// ],
// "links": [
// {
// "id": "1",
// "source": "1",
// "target": "2",
// "type": "1"
// }
// ]
// }
$checkHeader = Activity::where('version_gantt_id', $gantt_id)->where('type_activity', 'header')->count();
$finalData = [];
if ($checkHeader > 0) {
$dataHeader = Activity::select('id', 'name as text', 'type_activity as type', 'persentase_progress as progress', 'start_date', 'end_date', 'duration', 'parent_id', 'sortorder as order')->where('version_gantt_id', $gantt_id)->where('type_activity', 'header')->first();
// $dataHeader->start_date1 = isset($dataHeader->start) ? date_format(date_create($dataHeader->start), "d-m-Y H:i") : NULL;
// $dataHeader->end_date1 = isset($dataHeader->end) ? date_format(date_create($dataHeader->end), "d-m-Y H:i") : NULL;
$dataHeader->progress = $dataHeader->progress / 100;
$dataHeader->type = "project";
$dataHeader->text = $dataHeader->name;
$finalData[] = $dataHeader;
$data = Activity::select('id', 'name as text', 'type_activity as type', 'persentase_progress as progress', 'start_date', 'end_date', 'duration', 'parent_id', 'sortorder as order')->where('version_gantt_id', $gantt_id)->where('parent_id', $dataHeader->id)->orderBy('sortorder', 'asc')->get();
} else {
$data = Activity::select('id', 'name as text', 'type_activity as type', 'persentase_progress as progress', 'start_date', 'end_date', 'duration', 'parent_id', 'sortorder as order')->where('version_gantt_id', $gantt_id)->whereNull('parent_id')->orderBy('sortorder', 'asc')->get();
}
foreach ($data as $objRow) {
$type = "project";
$dataChildren = $this->getChildrenSCurve($gantt_id, $objRow->id);
if ($objRow->type_activity == "milestone")
$type = $objRow->type_activity;
if (empty($dataChildren))
$type = "task";
$objRow->parent = $objRow->parent_id ? $objRow->parent_id : null;
// $objRow->start_date = isset($objRow->start) ? date_format(date_create($objRow->start), "d-m-Y H:i") : NULL;
// $objRow->end_date1 = isset($objRow->end) ? date_format(date_create($objRow->end), "d-m-Y H:i") : NULL;
$objRow->progress = $objRow->persentase_progress / 100;
$objRow->type = $type;
$finalData[] = $objRow;
$finalData = array_merge($finalData, $dataChildren);
}
$dataLink = Link::where('version_gantt_id', $gantt_id)->get();
$finalLink = [];
foreach ($dataLink as $objRow) {
$dataRow = array(
'id' => $objRow->id,
'source' => $objRow->s_activity_id,
'target' => $objRow->t_activity_id,
'type' => $objRow->type_link,
'code' => $objRow->code_link
);
if ($objRow->lag)
$dataRow['lag'] = $objRow->lag;
$finalLink[] = $dataRow;
}
$resultData = array(
"data" => $finalData,
"links" => $finalLink
);
return response()->json(['status' => 'success', 'data' => $resultData, 'code' => 200], 200);
}
private function getDataActivity($id)
{
$checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count();
@ -116,6 +208,43 @@ class ActivityController extends Controller
return $resultData;
}
private function getChildrenSCurve($gantt_id, $parent_id)
{
$finalData = [];
$data = Activity::select('id', 'name as text', 'type_activity as type', 'bobot_planning', 'persentase_progress as progress', 'start_date', 'end_date', 'duration', 'parent_id', 'sortorder as order')
->where('version_gantt_id', $gantt_id)->where('parent_id', $parent_id)->orderBy('sortorder', 'asc')->get();
foreach ($data as $objRow) {
$objRow->parent = $parent_id;
$objRow->progress = (float) $objRow->bobot_planning / 100;
// $objRow->start_date1 = isset($objRow->start) ? date_format(date_create($objRow->start), "d-m-Y H:i") : NULL;
// $objRow->end_date1 = isset($objRow->end) ? date_format(date_create($objRow->end), "d-m-Y H:i") : NULL;
$dataChildren = $this->getChildrenSCurve($gantt_id, $objRow->id);
if ($objRow->type_activity == "milestone") {
$objRow->type = $objRow->type_activity;
// $objRow->actual_start = isset($objRow->actual_start) ? date_format(date_create($objRow->actual_start), "d-m-Y") : NULL;
} elseif (empty($dataChildren)) {
$objRow->type = "task";
// $objRow->actual_start = isset($objRow->actual_start) ? date_format(date_create($objRow->actual_start), "d-m-Y") : NULL;
// $objRow->actual_end = isset($objRow->actual_end) ? date_format(date_create($objRow->actual_end), "d-m-Y") : NULL;
// if(isset($objRow->actual_start)){
// $objRow->auto_scheduling = false;
// }
} else {
$objRow->type = "project";
// $actualStart = $this->getFirstLastDateActivity($objRow->id, "start");
// $objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "d-m-Y") : NULL;
// $actualEnd = $this->getFirstLastDateActivity($objRow->id, "end");
// $objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "d-m-Y") : NULL;
}
$finalData[] = $objRow;
$finalData = array_merge($finalData, $dataChildren);
}
return $finalData;
}
private function getChildren($gantt_id, $parent_id)
{
$finalData = [];
@ -139,7 +268,7 @@ class ActivityController extends Controller
$objRow->type = "task";
$objRow->actual_start = isset($objRow->actual_start) ? date_format(date_create($objRow->actual_start), "Y-m-d") : NULL;
$objRow->actual_end = isset($objRow->actual_end) ? date_format(date_create($objRow->actual_end), "Y-m-d") : NULL;
if(isset($objRow->actual_start)){
if (isset($objRow->actual_start)) {
$objRow->auto_scheduling = false;
}
} else {
@ -156,66 +285,67 @@ class ActivityController extends Controller
return $finalData;
}
public function getActivityFirst($parentId){
public function getActivityFirst($parentId)
{
$activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_start ASC')->first();
if (!isset($activity)) {
return null;
}
if($activity->type_activity == "task"){
if ($activity->type_activity == "task") {
// Log::info("activity ", [$activity]);
return $activity->actual_start;
}else{
} else {
return $this->getActivityFirst($activity->id);
}
}
public function getFirstLastDateActivity($id, $params){
if($params == "start"){
public function getFirstLastDateActivity($id, $params)
{
if ($params == "start") {
$data = Activity::select('id', 'parent_id', 'name', 'actual_start')->where('parent_id', $id)->get();
}else{
} else {
$data = Activity::select('id', 'parent_id', 'name', 'actual_end')->where('parent_id', $id)->get();
}
$parent = Activity::findOrFail($id);
$dataFinal=[];
$parent = Activity::findOrFail($id);
$dataFinal = [];
foreach ($data as $val) {
$activity = $this->getchildActivityForActual($val->id, $params);
$dataFinal[] = $val;
$dataFinal = array_merge($dataFinal, $activity);
}
if($params == "start"){
$actualStartValues = array_column(array_filter($dataFinal, function($item) {
if ($params == "start") {
$actualStartValues = array_column(array_filter($dataFinal, function ($item) {
return isset($item['actual_start']);
}), 'actual_start');
$returnActualStartOrEnd = count($actualStartValues) > 0 ? min($actualStartValues) : null;
if (isset($parent)) {
$parent->actual_start = $returnActualStartOrEnd;
$parent->save();
}
}else{
$actualEndValues = array_column(array_filter($dataFinal, function($item) {
if (isset($parent)) {
$parent->actual_start = $returnActualStartOrEnd;
$parent->save();
}
} else {
$actualEndValues = array_column(array_filter($dataFinal, function ($item) {
return isset($item['actual_end']);
}), 'actual_end');
$returnActualStartOrEnd = count($actualEndValues) == count($dataFinal) ? max($actualEndValues) : null;
if (isset($parent)) {
$parent->actual_end = $returnActualStartOrEnd;
$parent->save();
}
$returnActualStartOrEnd = count($actualEndValues) == count($dataFinal) && count($actualEndValues) > 0 ? max($actualEndValues) : null;
if (isset($parent)) {
$parent->actual_end = $returnActualStartOrEnd;
$parent->save();
}
}
// return json_encode(["min"=>$minActualStart, "max"=>$maxActualStart]);
return $returnActualStartOrEnd;
}
public function getchildActivityForActual($parent, $params){
if($params == "start"){
public function getchildActivityForActual($parent, $params)
{
if ($params == "start") {
$activity = Activity::select('id', 'actual_start')->where('parent_id', $parent)->get();
}else{
} else {
$activity = Activity::select('id', 'actual_end')->where('parent_id', $parent)->get();
}
$temp = [];
foreach($activity as $val1){
foreach ($activity as $val1) {
$getChild = $this->getchildActivityForActual($val1->id, $params);
$temp[] = $val1;
$temp = array_merge($temp, $getChild);
@ -223,18 +353,18 @@ class ActivityController extends Controller
return $temp;
}
public function getActivityLast($parentId){
public function getActivityLast($parentId)
{
$activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_end DESC')->first();
if (!isset($activity)) {
return null;
}
if($activity->type_activity == "task"){
if ($activity->type_activity == "task") {
// Log::info("activity ", [$activity]);
return $activity->actual_end;
}else{
} else {
return $this->getActivityLast($activity->id);
}
}
private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null)
@ -422,53 +552,54 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'message' => 'Activity Updated!', 'code' => 200], 200);
}
public function updateSchedule($ganttId){
if (empty($ganttId) || !is_int((int) $ganttId))
public function updateSchedule($ganttId)
{
if (empty($ganttId) || !is_int((int) $ganttId))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$activities = Activity::where('version_gantt_id', $ganttId)->get();
$activities = Activity::where('version_gantt_id', $ganttId)->get();
if (!$activities)
return response()->json(['status' => 'failed', 'message' => 'Activities not found!', 'code' => 404], 404);
$duration = 0;
foreach ($activities as $key => $activity) {
$assignMaterial = AssignMaterial::where('activity_id', $activity->id)->first();
foreach ($activities as $key => $activity) {
$assignMaterial = AssignMaterial::where('activity_id', $activity->id)->first();
if (isset($assignMaterial)) {
$statusActivity = $assignMaterial->status_activity;
} else {
$statusActivity = '';
}
if (isset($activity->planned_start) && isset($activity->planned_end) && $statusActivity != "done") {
// todo check report for no report / progress == 0
$today = new DateTime();
$endDate = new DateTime($activity->end_date);
$startDate = new DateTime($activity->start_date);
$plannedStart = new DateTime($activity->planned_start);
$plannedEnd = new DateTime($activity->planned_end);
$duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd);
if ($today >= $endDate) {
$endDate = $today;
$bobotPlanning = (int) $activity->bobot_planning;
$rerataBobot = $duration > 0 ? $bobotPlanning / $duration : 0;
$bobotActual = (int) $activity->persentase_progress/100 * $bobotPlanning;
$sisaBobot = $bobotPlanning - $bobotActual;
$sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0;
$endDate->modify("+".ceil($sisaHari)." Days");
$actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate);
$activity->duration = $actualDuration;
$activity->end_date = $endDate;
$activity->save();
}
}
}
if (isset($activity->planned_start) && isset($activity->planned_end) && $statusActivity != "done") {
// todo check report for no report / progress == 0
$today = new DateTime();
$endDate = new DateTime($activity->end_date);
$startDate = new DateTime($activity->start_date);
$plannedStart = new DateTime($activity->planned_start);
$plannedEnd = new DateTime($activity->planned_end);
$duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd);
if ($today >= $endDate) {
$endDate = $today;
$bobotPlanning = (int) $activity->bobot_planning;
$rerataBobot = $duration > 0 ? $bobotPlanning / $duration : 0;
$bobotActual = (int) $activity->persentase_progress / 100 * $bobotPlanning;
$sisaBobot = $bobotPlanning - $bobotActual;
$sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0;
$endDate->modify("+" . ceil($sisaHari) . " Days");
$actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate);
$activity->duration = $actualDuration;
$activity->end_date = $endDate;
$activity->save();
}
}
}
return response()->json(['status' => 'success', 'message' => 'Activities Updated!', 'code' => 200], 200);
}
}
public function batchUpdate(Request $request, $ganttId)
{
$entities = $request->all();
if (empty($ganttId) || !is_int((int) $ganttId))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$activity = Activity::where('version_gantt_id',$ganttId)->get();
$activity = Activity::where('version_gantt_id', $ganttId)->get();
$link = Link::where('version_gantt_id', $ganttId)->get();
if (!$activity)
return response()->json(['status' => 'failed', 'message' => 'Activity not found!', 'code' => 404], 404);
@ -479,6 +610,7 @@ class ActivityController extends Controller
$activityToUpdate = $activity->firstWhere('id', $entity['data']['id']);
$entity['data']['name'] = $entity['data']['text'];
$entity['data']['persentase_progress'] = $entity['data']['progress'] * 100;
$entity['data']['type_activity'] = $entity['data']['type'] ?? 'task';
if (isset($entity['data']['rencana_biaya'])) {
$entity['data']['rencana_biaya'] = str_replace(",", ".", $entity['data']['rencana_biaya']);
}
@ -499,27 +631,47 @@ class ActivityController extends Controller
public function delete($id)
{
if (!$data = Activity::find($id))
DB::beginTransaction();
$activity_id = (int)$id;
$data = Activity::query()
->from('m_activity as ma')
->select('mp.company_id')
->join('m_proyek as mp','ma.proyek_id','mp.id')
->where('ma.id', $activity_id);
$cloneQuery = clone $data;
if (!$data->exists()) {
DB::rollBack();
return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'Data not found!', 'code' => 404], 404);
$this->deleteRelative($id);
if (!$data->delete())
return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'data activity failed deleted!', 'code' => 500], 500);
}
return response()->json(['status' => 'success', "action" => "deleted", 'message' => 'data activity successfully deleted!', 'code' => 200], 200);
$this->deleteRelative($activity_id, $cloneQuery->first()->company_id);
if (!$data->delete()) {
DB::rollBack();
return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'Data activity failed deleted!', 'code' => 500], 500);
}
DB::commit();
return response()->json(['status' => 'success', "action" => "deleted", 'message' => 'Data activity successfully deleted!', 'code' => 200], 200);
}
private function deleteRelative($activity_id)
private function deleteRelative($activity_id, $company_id)
{
UserToActivity::where('activity_id', $activity_id)->delete();
AssignMaterial::where('activity_id', $activity_id)->delete();
$dataAd = ActivityDokumen::where("activity_id", $activity_id)->get();
foreach ($dataAd as $ad) {
if(file_exists($this->pathActivityDocument.$ad->file)){
unlink($this->pathActivityDocument.$ad->file);
}
}
ActivityDokumen::where("activity_id", $activity_id)->delete();
}
DB::transaction(function() use($activity_id, $company_id) {
UserToActivity::where('activity_id', $activity_id)->delete();
AssignMaterial::where('activity_id', $activity_id)->delete();
$dataAd = ActivityDokumen::where("activity_id", $activity_id)->get();
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
foreach ($dataAd as $ad) {
if (file_exists($destinationPath['pathActivityDocument'] . $ad->file)) {
unlink($destinationPath['pathActivityDocument'] . $ad->file);
}
}
ActivityDokumen::where("activity_id", $activity_id)->delete();
}
});
}
public function getUpdate($id)
{
@ -541,27 +693,28 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function searchAnalysisPrep(Request $request)
public function searchAnalysisPrep(Request $request)
{
$data = $request->all();
$dataGet = DB::table('m_activity')
->select('m_activity.name')
->where('m_activity.proyek_id', $data['columns'][0]['value'])
->where('m_activity.type_activity', 'task')
// ->where('m_activity.persentase_progress', '>', 0)
->groupByRaw('m_activity.name')
->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200);
$dataGet = DB::table('m_activity')
->select('m_activity.name')
->where('m_activity.proyek_id', $data['columns'][0]['value'])
->where('m_activity.type_activity', 'task')
// ->where('m_activity.persentase_progress', '>', 0)
->groupByRaw('m_activity.name')
->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
}
public function searchAnalysis(Request $request)
public function searchAnalysis(Request $request)
{
$dataBuilder = $this->setUpPayload($request->all(), 'm_activity');
$builder = $dataBuilder['builder'];
$dataGet = $builder->select(
$dataGet = $builder->select(
'selfTable.name',
'persentase_progress',
'selfTable.start_date',
'selfTable.id',
'selfTable.end_date',
'selfTable.planned_start',
'selfTable.planned_end',
@ -571,9 +724,10 @@ class ActivityController extends Controller
'm_version_gantt.name_version',
DB::raw('user_names.user_name as user_name'),
DB::raw('SUM(report_activity_material.qty) as qty'),
'assign_material_to_activity.qty_planning',
// DB::raw('SUM(assign_material_to_activity.qty_planning) as qty_planning'),
'assign_material_to_activity.id as join_third_id'
)
->addSelect(DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = report_activity_material.activity_id) as qty_planning'))
->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id')
->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id')
->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id')
@ -584,15 +738,14 @@ class ActivityController extends Controller
GROUP BY activity_id) as user_names'), function ($join) {
$join->on('user_names.activity_id', '=', 'selfTable.id');
})
->where('assign_material_to_activity.id', '=', DB::raw('report_activity_material.assign_material_id'))
->groupBy('selfTable.id')
->groupBy('selfTable.name')
->groupBy('selfTable.persentase_progress')
->groupBy('m_version_gantt.name_version')
->groupBy('assign_material_to_activity.qty_planning')
->groupBy('assign_material_to_activity.id')
->groupBy('user_names.user_name')
->groupBy('report_activity_material.activity_id')
->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
}
// before upload file
public function importOld(Request $request)
@ -651,8 +804,7 @@ class ActivityController extends Controller
$data['activities'][$key]['weight'] = $parentWeight / $siblingsCount;
}
}
;
};
}
$projectStart = Project::select('mulai_proyek')->where('id', $projectId)->first();
foreach ($data['activities'] as $i => $activity_row) {
@ -991,13 +1143,29 @@ class ActivityController extends Controller
public function uploadTmpImport(Request $request)
{
DB::beginTransaction();
if ($request->hasFile('dokumen')) {
$document = $request->file('dokumen');
$gantt_id = $request->gantt_id;
$name = $document->getClientOriginalName();
$timeNow = Carbon::now();
$originalFilename = $document->getClientOriginalName();
$extension = pathinfo($originalFilename, PATHINFO_EXTENSION);
$filename = pathinfo($originalFilename, PATHINFO_FILENAME);
$name = $filename . '_' . $timeNow->format('d-m-y-His') . '.' . $extension;
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $document, $destinationPath['pathTmpImport'], $destinationPath);
}
if (isset($getLimitStorage)) {
if($getLimitStorage === false) {
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500);
}
$result = $document->move($this->pathTmpImport, $name);
if ($result) {
$data = [
'gantt_id' => (int) $gantt_id,
'file' => $name,
@ -1006,15 +1174,18 @@ class ActivityController extends Controller
$result = TmpImport::create($data);
if (!$result) {
unlink($this->pathTmpImport . $name);
if (!$document->move($destinationPath['pathTmpImport'], $name) && $result) {
unlink($destinationPath['pathTmpImport'].$name);
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
}
DB::commit();
return response()->json(['status' => 'success', 'message' => 'Upload successful!', 'code' => 200], 200);
}
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
}
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'File is required!', 'code' => 400], 400);
}
@ -1030,4 +1201,9 @@ class ActivityController extends Controller
}
return response()->json(['status' => 'success', 'data' => $request, 'message' => 'Update successful!', 'code' => 200], 200);
}
// public function recalculateProject($by, $id){
// // query get activity
// $cekActivity =
// }
}

72
app/Http/Controllers/ActivityDokumenController.php

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Company;
use Illuminate\Http\Request;
use App\Models\ActivityDokumen;
@ -16,50 +17,53 @@ class ActivityDokumenController extends Controller
return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200);
}
public function delete($id)
public function delete($id, $company_id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
$document = ActivityDokumen::find($id);
if(!$document)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if(file_exists($this->pathActivityDocument.$document->file))
unlink($this->pathActivityDocument.$document->file);
if(!$document) {
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
}
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if(file_exists($destinationPath['pathActivityDocument'].$document->file)){
unlink($destinationPath['pathActivityDocument'].$document->file);
}
}
$document->delete();
return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200);
}
public function uploadProjectDokumen(Request $request)
{
if(!$request->hasFile('dokumen'))
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400);
if(!$request->hasFile('dokumen')) {
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400);
}
$activity_id = $request->activity_id;
$document = $request->file('dokumen');
$name = $document->getClientOriginalName();
$result = $document->move($this->pathActivityDocument, $name);
if(!$result)
$company = Company::find($request->company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$result = $document->move($destinationPath['pathActivityDocument'], $name);
}
if(!$result || !$company) {
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
$data = [
'activity_id' => (int)$activity_id,
'file' => $name,
'description' => $request->description
];
$result = ActivityDokumen::create($data);
if(!$result){
unlink($this->pathActivityDocument.$name);
if(!$result || !$company) {
unlink($destinationPath['pathActivityDocument'].$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload success!','code'=>200], 200);
}
@ -75,21 +79,23 @@ class ActivityDokumenController extends Controller
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function downloadDokumen($id)
public function downloadDokumen($id, $company_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);
}
$document = ActivityDokumen::find($id);
if(!$document)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
if(file_exists($this->pathActivityDocument.$document->file)){
$pathToFile = $this->pathActivityDocument.$document->file;
return response()->download($pathToFile);
}
$company = Company::find($company_id);
if(!$document || !$company) {
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
}
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if(file_exists($destinationPath['pathActivityDocument'].$document->file)) {
$pathToFile = $destinationPath['pathActivityDocument'].$document->file;
return response()->download($pathToFile);
}
}
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
}
}

175
app/Http/Controllers/AssignMaterialController.php

@ -7,17 +7,20 @@ use App\Models\AssignMaterial;
use App\Models\RequestMaterial;
use App\Models\Activity;
use App\Models\ReportActivityMaterial;
use Datatables;
use Illuminate\Support\Facades\DB;
use Yajra\Datatables\Datatables;
class AssignMaterialController extends Controller
{
private function sanitizeDecimal($number) {
$number = str_replace(".","",$number);
$number = str_replace(",",".",$number);
private function sanitizeDecimal($number)
{
$number = str_replace(".", "", $number);
$number = str_replace(",", ".", $number);
return $number;
}
public function add(Request $request){
public function add(Request $request)
{
$this->validate($request, [
'activity_id' => 'required',
'material_id' => 'required',
@ -28,8 +31,8 @@ class AssignMaterialController extends Controller
$checkStock = RequestMaterial::where("id", $request->material_id)->first();
$currentStock = $checkStock->qty;
if((int)$currentStock < (int)$request->qty_planning){
return response()->json(['status'=>'failed','message'=>'Stock is not enough!','code'=> 500]);
if ((int)$currentStock < (int)$request->qty_planning) {
return response()->json(['status' => 'failed', 'message' => 'Stock is not enough!', 'code' => 500]);
}
$start_date = $activity->start_date;
@ -42,56 +45,62 @@ class AssignMaterialController extends Controller
$data['budget'] = $checkStock->price;
$data['qty_planning'] = $this->sanitizeDecimal($data['qty_planning']);
if ($planDate >= $startDate) {
if ($planDate >= $startDate) {
$result = AssignMaterial::create($data);
return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 400], 400);
if($result) {
return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 400], 400);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 400], 400);
}
}
public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
public function update(Request $request, $id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = AssignMaterial::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$result = $data->update($request->all());
if($result)
return response()->json(['status'=>'success','message'=> 'Data updated!','code'=> 200], 200);
if ($result)
return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200);
return response()->json(['status'=>'failed','message'=>'Failed to update!','code'=> 500], 500);
return response()->json(['status' => 'failed', 'message' => 'Failed to update!', 'code' => 500], 500);
}
public function delete($id)
{
$data = AssignMaterial::where('id', $id)->first();
$reports = ReportActivityMaterial::where('assign_material_id', $data->id)->get();
if (isset($reports)) {
$reports = ReportActivityMaterial::where('assign_material_id', $data->id)->get();
if (isset($reports)) {
foreach ($reports as $report) {
$report->delete();
}
}
}
if($data->delete())
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=> 200], 200);
if ($data->delete())
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=> 500], 500);
return response()->json(['status' => 'failed', 'message' => 'Failed to delete!', 'code' => 500], 500);
}
public function edit($id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
public function edit($id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = AssignMaterial::find($id);
if($result)
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
if ($result)
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
}
public function search(Request $request)
@ -102,7 +111,7 @@ class AssignMaterialController extends Controller
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$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()
@ -110,18 +119,21 @@ class AssignMaterialController extends Controller
$data = AssignMaterial::all();
$countData = $data->count();
if($data)
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
if ($data)
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
return response()->json(['status'=>'failed','message'=>'Failed to get the data!','code'=> 500], 500);
return response()->json(['status' => 'failed', 'message' => 'Failed to get the data!', 'code' => 500], 500);
}
public function datatables(Request $request){
public function datatables(Request $request)
{
$id_activity = $request->query('idact');
$type = $request->query('type') ?? "material";
$data = AssignMaterial::select(
"assign_material_to_activity.*","m.description as material_name", "m.uom as uom"
)
"assign_material_to_activity.*",
"m.description as material_name",
"m.uom as uom"
)
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $id_activity)
->where('assign_material_to_activity.type', $type)
@ -129,93 +141,100 @@ class AssignMaterialController extends Controller
->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-material-delete"><i class="fa fa-trash"></i></a>';
->addColumn('action', function ($row) {
$actionBtn = '<a href="javascript:void(0)" data-id="' . $row->id . '" class="delete btn btn-danger btn-sm btn-material-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
public function datatablesForReportActivity(Request $request){
public function datatablesForReportActivity(Request $request)
{
$id_activity = $request->query('idact');
$data =
AssignMaterial::select(
AssignMaterial::raw('SUM(qty_planning) as qty_planning'),
"m.description as material_name",
"assign_material_to_activity.activity_id",
"assign_material_to_activity.type"
// "assign_material_to_activity.material_id",
)
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->groupBy("m.description")
$query = AssignMaterial::select(
DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = ram.activity_id) as qty_planning'),
DB::raw('SUM(ram.qty) as qty_sum'),
"m.description as material_name",
"assign_material_to_activity.activity_id"
)
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id");
if (!AssignMaterial::join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")->where("assign_material_to_activity.activity_id", $id_activity)->exists()) {
$query->leftJoin("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id");
} else {
$query->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id");
}
$data = $query->groupBy("m.description")
->groupBy("ram.activity_id")
->groupBy("assign_material_to_activity.activity_id")
->groupBy("assign_material_to_activity.type")
->where("assign_material_to_activity.activity_id", $id_activity)->get();
->where("assign_material_to_activity.activity_id", $id_activity)
->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('qty_sum', function($row){
$val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
->groupBy("m.description")
->where("m.description", strval($row->material_name))
->where("ram.activity_id", $row->activity_id)->first();
return $val_qty_act ? $val_qty_act->qty_sum : '-';
})
->addColumn('status_activity', function($row){
// ->addColumn('qty_planning', function($row){
// $val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1","m.id")
// ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
// ->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
// ->groupBy("m.description")
// ->groupBy("m.id")
// ->where("m.description", strval($row->material_name))
// ->where("ram.activity_id", $row->activity_id)->first();
// return $val_qty_act ? $val_qty_act->qty_sum : '-';
// })
->addColumn('status_activity', function ($row) {
$val_status = AssignMaterial::select("status_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_status ? $val_status->status_activity : null;
})
->addColumn('start_activity', function($row){
->addColumn('start_activity', function ($row) {
$val_start = AssignMaterial::select("start_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_start ? $val_start->start_activity : null;
})
->addColumn('finish_activity', function($row){
->addColumn('finish_activity', function ($row) {
$val_finish = AssignMaterial::select("finish_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
->where('m.description', '=', $row->material_name)
->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_finish ? $val_finish->finish_activity : null;
})
->addColumn('uom', function($row){
->addColumn('uom', function ($row) {
$val_uom = RequestMaterial::select("uom")
->where('description', '=', $row->material_name)->first();
return $val_uom ? $val_uom->uom : null;
})
->addColumn('assign_material_id', function($row){
$assignMaterial =AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first();
->addColumn('assign_material_id', function ($row) {
$assignMaterial = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first();
return $assignMaterial ? $assignMaterial->id : null;
})
->addColumn('action', function($row){
->addColumn('action', function ($row) {
$dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first();
$actionBtn = '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-name="'.$row->material_name.'" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>';
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-name="'.$row->material_name.'" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>';
$actionBtn = '<a href="javascript:void(0)" data-id="' . $dataPlan->id . '" data-activity_id="' . $row->activity_id . '" data-material-id="' . $row->material_id . '" data-material-name="' . $row->material_name . '" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>';
$actionBtn .= '<a href="javascript:void(0)" data-id="' . $dataPlan->id . '" data-activity_id="' . $row->activity_id . '" data-material-id="' . $row->material_id . '" data-material-name="' . $row->material_name . '" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
public function ForReportActivityByMaterial(Request $request){
public function ForReportActivityByMaterial(Request $request)
{
$id_activity = $request->idact;
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom")
$data = AssignMaterial::select("assign_material_to_activity.*", "m.description as material_name", "m.uom as uom")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $id_activity)->get();
foreach ($data as $key) {
$val_qty_sum = ReportActivityMaterial::where('assign_material_id', '=', $key->id)->sum("qty");
}
$countData = $data->count();
if($data){
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get Assign material, please try again later!','code'=>400], 400);
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get Assign material, please try again later!', 'code' => 400], 400);
}
}
}

319
app/Http/Controllers/AssignToolsController.php

@ -1,160 +1,159 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\AssignTools;
use Datatables;
use App\Models\ToolsResource;
class AssignToolsController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'activity_id' => 'required',
'tools_id' => 'required',
'qty_planning' => 'required',
]);
$checkStock = ToolsResource::where("id", $request->tools_id)->first();
$currentStock = $checkStock->qty;
if((int)$currentStock < (int)$request->qty_planning){
return response()->json(['status'=>'failed','message'=>'Not enough stock in warehouse!','code'=>400]);
die();
}
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = AssignTools::create($data);
if($result){
$checkStock = ToolsResource::find($request->tools_id);
$newStock = (int)$checkStock->qty - (int)$request->qty_planning;
$dataUpdate = array(
"qty"=>$newStock,
"updated_by"=>$this->currentName
);
$checkStock->update($dataUpdate);
return response()->json(['status'=>'success','message'=>'Assign tools success!','code'=>200]);
}else{
return response()->json(['status'=>'failed','message'=>'Assign tools failed','code'=>400]);
}
}
private function updateFromAdd($data){
$assignTools = AssignTools::where("activity_id", $data->activity_id)->where("tools_id", $data->tools_id)->first();
$newQty = (int)$assignTools->qty_planning + (int)$data->qty_planning;
$dataUpdate = array(
"qty_planning"=>$newQty,
"updated_by"=>$this->currentName
);
$dataWillUpdate = AssignMaterial::where("activity_id", $data->activity_id)->where("tools_id", $data->tools_id);
return $dataWillUpdate->update($dataUpdate);
}
public function update(Request $request, $id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = AssignTools::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Assign tools not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Assign tools successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Assign tools failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = AssignTools::find($id);
if($data){
$id = $data->tools_id;
$stock = $data->qty_planning;
$toolsResource = ToolsResource::find($id);
if($toolsResource){
$oldStock = $toolsResource->qty;
$newStock = $oldStock + $stock;
$dataUpdate = array(
"qty"=>$newStock,
"updated_by"=>$this->currentName
);
$toolsResource->update($dataUpdate);
}
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'Data Assign tools not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'Assign tools successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Assign tools failed deleted!','code'=>400], 400);
}
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = AssignTools::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data Assign tools, please try again later!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'assign_tools_to_activity');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = AssignTools::all();
$countData = $data->count();
if($data){
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get Assign tools, please try again later!','code'=>400], 400);
}
}
public function datatables(Request $request){
$id_activity = $request->query('idact');
$data = AssignTools::select("assign_tools_to_activity.*","m.name as tools_name","m.uom as uom")->join("m_tools_resource as m", "m.id", "=", "assign_tools_to_activity.tools_id")->where('assign_tools_to_activity.activity_id', $id_activity)->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-tools-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
}
<?php
namespace App\Http\Controllers;
use App\Models\{AssignMaterial,AssignTools,ToolsResource};
use Illuminate\Http\Request;
use Yajra\Datatables\Datatables;
class AssignToolsController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'activity_id' => 'required',
'tools_id' => 'required',
'qty_planning' => 'required',
]);
$checkStock = ToolsResource::where("id", $request->tools_id)->first();
$currentStock = $checkStock->qty;
if((int)$currentStock < (int)$request->qty_planning){
return response()->json(['status'=>'failed','message'=>'Not enough stock in warehouse!','code'=>400]);
die();
}
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = AssignTools::create($data);
if($result){
$checkStock = ToolsResource::find($request->tools_id);
$newStock = (int)$checkStock->qty - (int)$request->qty_planning;
$dataUpdate = array(
"qty"=>$newStock,
"updated_by"=>$this->currentName
);
$checkStock->update($dataUpdate);
return response()->json(['status'=>'success','message'=>'Assign tools success!','code'=>200]);
}else{
return response()->json(['status'=>'failed','message'=>'Assign tools failed','code'=>400]);
}
}
private function updateFromAdd($data){
$assignTools = AssignTools::where("activity_id", $data->activity_id)->where("tools_id", $data->tools_id)->first();
$newQty = (int)$assignTools->qty_planning + (int)$data->qty_planning;
$dataUpdate = array(
"qty_planning"=>$newQty,
"updated_by"=>$this->currentName
);
$dataWillUpdate = AssignMaterial::where("activity_id", $data->activity_id)->where("tools_id", $data->tools_id);
return $dataWillUpdate->update($dataUpdate);
}
public function update(Request $request, $id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = AssignTools::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Assign tools not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Assign tools successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Assign tools failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = AssignTools::find($id);
if($data){
$id = $data->tools_id;
$stock = $data->qty_planning;
$toolsResource = ToolsResource::find($id);
if($toolsResource){
$oldStock = $toolsResource->qty;
$newStock = $oldStock + $stock;
$dataUpdate = array(
"qty"=>$newStock,
"updated_by"=>$this->currentName
);
$toolsResource->update($dataUpdate);
}
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'Data Assign tools not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'Assign tools successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Assign tools failed deleted!','code'=>400], 400);
}
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = AssignTools::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data Assign tools, please try again later!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'assign_tools_to_activity');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = AssignTools::all();
$countData = $data->count();
if($data){
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get Assign tools, please try again later!','code'=>400], 400);
}
}
public function datatables(Request $request){
$id_activity = $request->query('idact');
$data = AssignTools::select("assign_tools_to_activity.*","m.name as tools_name","m.uom as uom")->join("m_tools_resource as m", "m.id", "=", "assign_tools_to_activity.tools_id")->where('assign_tools_to_activity.activity_id', $id_activity)->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-tools-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
}

301
app/Http/Controllers/AuthController.php

@ -1,97 +1,204 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use App\Models\Role;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
class AuthController extends Controller
{
public function __construct()
{
$this->middleware('auth:api', ['except' => ['login']]);
}
public function login(Request $request)
{
$username = $request->username;
$password = $request->password;
$remember = $request->remember;
$is_mobile = $request->is_mobile;
if (empty($username) || empty($password))
return response()->json(['status' => 'error', 'message' => 'You must fill all the fields'], 400);
$usernameCheck = false;
$passwordCheck = false;
if (User::where('username', $username)->exists())
$usernameCheck = true;
if (User::where('password', md5($password))->exists())
$passwordCheck = true;
if ($usernameCheck & $passwordCheck) {
$user = User::where('username', $username)->where('password', md5($password))->first();
if ($is_mobile) {
$fcm_token = $request->fcm_token;
if (!$fcm_token || $fcm_token == "")
return response()->json(['status' => 'error', 'message' => 'FCM Token is required'], 400);
$dataUpdateFcm = array(
"fcm_token" => $fcm_token
);
$hr = User::find($user->id);
if ($hr)
$hr->update($dataUpdateFcm);
}
$dataRole = Role::find($user->role_id);
$dataHierarchy = $this->getDataHierarchy($user->divisi_id, $user->id);
if ($dataRole)
$user->role = $dataRole;
if ($dataHierarchy)
$user->hierarchy = $dataHierarchy;
if (!$token = Auth::login($user))
return response()->json(['error' => 'Unauthorized'], 401);
$ttl = 60;
if ($remember)
$ttl = 10080;
// todo : change existing md5 hashed function to laravel's originally bcrypt
/* $token = auth()->setTTL($ttl)->attempt(['username' => $username, 'password' => Hash::make($password)]); */
/* dd(response()->json(['code'=>'200', 'token' => $token, 'ttl' => $ttl])); */
return response()->json([
'code' => 200,
'data' => array(
'data_user' => $user,
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth()->factory()->getTTL() * $ttl,
),
]);
} else {
if (!$usernameCheck && !$passwordCheck)
return response()->json(['code' => 201, 'message' => "username and password doesn't match"], 201);
if (!$passwordCheck)
return response()->json(['code' => 201, 'message' => "password doesn't match"], 201);
if (!$usernameCheck)
return response()->json(['code' => 201, 'message' => "username doesn't match"], 201);
}
}
}
<?php
namespace App\Http\Controllers;
use App\Models\Role;
use App\Models\User;
use App\Models\Company;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
const URL_EMAIL = 'https://notifapp.odm-iu.com/service-mail/notif_mail.php';
class AuthController extends Controller
{
public function __construct()
{
$this->middleware('auth:api', ['except' => ['login','sendEmail']]);
}
public function login(Request $request)
{
$username = $request->username;
$password = $request->password;
$remember = $request->remember;
$is_mobile = $request->is_mobile;
$usernameCheck = false;
$passwordCheck = false;
if (empty($username) || empty($password)) {
return response()->json(['status' => 'error', 'message' => 'You must fill all the fields'], 400);
}
$userQuery = User::query()
->where('username',$username);
if ($userQuery->exists()) {
$usernameCheck = true;
$passwordValue = $userQuery->first()->password;
if($passwordValue === md5($password)) {
$passwordCheck = true;
}
}
if ($usernameCheck && $passwordCheck) {
$user = User::where([['username', $username],['password', md5($password)]])->first();
$checkExpiredOspro = $this->setExpiredTimeOspro($user['company_id']);
if($checkExpiredOspro === false && $user['company_id'] != null) {
return response()->json(['status' => 'error', 'message' => 'Expired! Please update license!'], 201);
}
if ($is_mobile) {
$fcm_token = $request->fcm_token;
if (!$fcm_token || $fcm_token == "") {
return response()->json(['status' => 'error', 'message' => 'FCM Token is required'], 400);
}
$dataUpdateFcm = array(
"fcm_token" => $fcm_token
);
$hr = User::find($user->id);
if ($hr) {
$hr->update($dataUpdateFcm);
}
}
$dataRole = Role::find($user->role_id);
$dataHierarchy = $this->getDataHierarchy($user->divisi_id, $user->id);
$configApp = Company::where('id', $user->company_id)->first();
if ($configApp) {
$logoLogin = json_decode($configApp->logo_login, true);
$favicon = json_decode($configApp->favicon_image, true);
$logoHeader = json_decode($configApp->logo_header, true);
$configApp->logo_login = $logoLogin;
$configApp->favicon_image = $favicon;
$configApp->logo_header = $logoHeader;
}
if ($configApp) {
$user->configApp = $configApp;
}
if ($dataRole) {
$user->role = $dataRole;
}
if ($dataHierarchy) {
$user->hierarchy = $dataHierarchy;
}
if (!$token = Auth::login($user)) {
return response()->json(['error' => 'Unauthorized'], 401);
}
$ttl = 60;
if ($remember) {
$ttl = 10080;
}
// todo : change existing md5 hashed function to laravel's originally bcrypt
/* $token = auth()->setTTL($ttl)->attempt(['username' => $username, 'password' => Hash::make($password)]); */
/* dd(response()->json(['code'=>'200', 'token' => $token, 'ttl' => $ttl])); */
return response()->json([
'code' => 200,
'data' => array(
'data_user' => $user,
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth()->factory()->getTTL() * $ttl,
),
]);
} else {
if (!$usernameCheck || !$passwordCheck) {
return response()->json(['code' => 201, 'message' => "Username or password doesn't match"], 201);
} else {
return response()->json(['code' => 500, 'message' => "Server error"], 500);
}
}
}
public function sendEmail(Request $request)
{
if (empty($request->password)) {
$hashed = Str::random(15);
} else {
$hashed = $request->password;
}
$email = $request->email;
$user = User::select('email', 'name', 'username')->where('email', $email)->first();
if (!$user || empty($email)) {
return response()->json(['status' => 'error', 'message' => 'e-mail not found'], 400);
} else {
if($request->username) {
$username = $request->username;
$name = $request->username;
} else {
$username = $user->username;
$name = $user->name;
}
$this->reqHttpCurl($email, $hashed, $username, $name);
if(empty($request->password)) {
if (User::where('email', $email)->update(['password' => md5($hashed)])) {
return response()->json(['status' => 'success', 'code' => 200, 'message' => 'Password already sent to mail'], 200);
}
} else {
return response()->json(['status' => 'success', 'code' => 200, 'message' => 'Password already sent to mail'], 200);
}
}
}
private function reqHttpCurl($email, $password, $username, $name)
{
$postData = [
"to" => $email,
"name" => $name,
"username" => $username,
"password" => $password,
"from" => "app.integrasia@integrasiautama.com",
"alias_from" => "OSPRO",
"subject" => "Registration OSPRO",
"body" => "registration-ospro"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => URL_EMAIL, // your preferred url
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
// Set here requred headers
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
print_r(json_decode($response));
}
}
}

94
app/Http/Controllers/CompanyController.php

@ -2,28 +2,38 @@
namespace App\Http\Controllers;
use App\Models\Company;
use App\Models\{User, RoleMenu, Role, ProductTransaction, MenuCompany, Company};
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Carbon\Carbon;
class CompanyController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'description' => 'required'
'company_name' => 'required',
'registration_no' => 'required',
'template_id' => 'required',
'is_active' => 'required',
'type_paket' => 'required|in:Free,Basic,Enterprise',
'base_url' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
if(isset($data['base_url']) && $data['base_url'] != NULL) {
$data['base_url'] = json_encode($data['base_url'], true);
}
$result = Company::create($data);
$addTransaction = $this->addTransaction($result['id'],$data['type_paket']);
if ($result) {
return response()->json(['status' => 'success', 'message' => 'add Company successfully!', 'code' => 200], 200);
if ($result && $addTransaction) {
return response()->json(['status' => 'success','data' => $result, 'message' => 'Add Company successfully!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'add data Company failed!', 'code' => 400], 400);
return response()->json(['status' => 'failed', 'message' => 'Add data Company failed!', 'code' => 400], 400);
}
}
@ -51,15 +61,18 @@ class CompanyController extends Controller
$data = Company::find($id);
if(isset($data['base_url']) && $data['base_url'] != NULL) {
$data->update(['base_url'=>null]);
$data['base_url'] = json_encode($data['base_url'], true);
}
if ($data) {
$result = $data->update($request->all());
$updateTransaction = $this->updateTransaction($id,$request->type_paket);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company not found!', 'code' => 400], 400);
die();
}
if ($result) {
if ($result && $updateTransaction) {
return response()->json(['status' => 'success', 'message' => 'data Company successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company failed updated!', 'code' => 400], 400);
@ -68,20 +81,67 @@ class CompanyController extends Controller
public function delete($id)
{
$data = Company::find($id);
DB::beginTransaction();
$data = Company::find((int)$id);
if ($data) {
$delete = $data->delete();
$this->deleteRelative($data);
if ($data->delete()) {
DB::commit();
return response()->json(['status' => 'success', 'message' => 'Data Company successfully deleted!', 'code' => 200], 200);
} else {
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Data Company failed deleted!', 'code' => 400], 400);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company not found!', 'code' => 400], 400);
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Data Company not found!', 'code' => 400], 400);
die();
}
}
private function deleteRelative($data)
{
$directory = 'assets/' . $data['company_name'];
if (is_dir($directory)) {
File::deleteDirectory($directory);
}
MenuCompany::where('company_id', $data['id'])->delete();
User::where('company_id', $data['id'])->delete();
$role = Role::where('company_id', $data['id'])->first();
if ($role) {
RoleMenu::where('role_id', $role->id)->delete();
$role->delete();
}
ProductTransaction::where('company_id', $data['id'])->delete();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data Company successfully deleted!', 'code' => 200], 200);
protected function addTransaction($id_company, $type_paket)
{
$currentDate = Carbon::now();
$finalDate = $currentDate->copy()->addDays(30);
$formData = array(
'company_id' => (int)$id_company,
'type_paket' => $type_paket,
'exp_ospro' => $finalDate,
'amount' => $type_paket === 'Free' ? 0 : 250000
);
$result = ProductTransaction::create($formData);
if($result) {
return true;
} else {
return false;
}
}
protected function updateTransaction($id_company, $type_paket)
{
$result = ProductTransaction::where('company_id', (int)$id_company)->first();
$result->update(['type_paket' => $type_paket]);
if($result) {
return true;
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company failed deleted!', 'code' => 400], 400);
return false;
}
}

115
app/Http/Controllers/ContactSalesController.php

@ -0,0 +1,115 @@
<?php
namespace App\Http\Controllers;
use App\Models\ContactSales;
use Illuminate\Http\Request;
class ContactSalesController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'role' => 'required',
'email' => 'required',
'number_phone' => 'required',
'status' => 'required',
]);
$data = $request->all();
$data['created_by'] = '@System';
$data['status'] = 'New Request';
$result = ContactSales::create($data);
if ($result) {
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Your message has been successfully received by our Sales team! Someone from our team will be in touch with you shortly.', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Your message has been 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 = ContactSales::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data Contact Sales, 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 = ContactSales::find($id);
if ($data) {
$result = $data->update($request->all());
} else {
return response()->json(['status' => 'failed', 'message' => 'data Contact Sales not found!', 'code' => 400], 400);
die();
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'data Contact Sales successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Contact Sales failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = ContactSales::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data Contact Sales not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data Contact Sales successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Contact Sales failed deleted!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_contact_sales');
$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 = ContactSales::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 Contact Sales, please try again later!', 'code' => 400], 400);
}
}
}

197
app/Http/Controllers/Controller.php

@ -2,16 +2,22 @@
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use App\Models\UserToActivity;
use App\Models\Activity;
use App\Models\AssignMaterial;
use App\Models\User;
use App\Models\Divisi;
use Laravel\Lumen\Routing\Controller as BaseController;
use App\Models\Activity;
use App\Models\AssignMaterial;
use App\Models\Company;
use App\Models\ReportK3Detail;
use App\Models\UserToActivity;
use App\Models\ProductTransaction;
use App\Models\Project;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use Illuminate\Support\Facades\Http;
use Laravel\Lumen\Routing\Controller as BaseController;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
use Exception;
class Controller extends BaseController
{
@ -33,12 +39,161 @@ class Controller extends BaseController
$this->currentDate = date("Y-m-d H:i:s");
$this->currentName = auth()->user() ? auth()->user()->name : "system";
$this->currentId = auth()->user() ? auth()->user()->id : 0;
$this->companyId = auth()->user() ? auth()->user()->company_id : 0;
$this->pathImage = config('assets.image');
$this->pathDocument = config('assets.project');
$this->pathActivityDocument = config('assets.activity');
}
protected function setCustomeDirectoryUpload($company_name)
{
$current_date = date('Y-m-d');
[$year, $month] = explode('-', $current_date);
$yearMonth = $year.'-'.$month;
$pathImage = 'assets/' . $company_name .'/'. $yearMonth . '/image/';
$pathDocument = 'assets/' . $company_name .'/'. $yearMonth . '/file/project/';
$pathTmpImport = 'assets/' . $company_name .'/'. $yearMonth . '/file/tmpimport/';
$pathActivityDocument = 'assets/' . $company_name .'/'. $yearMonth . '/file/activity/';
return [
'pathImage' => $pathImage,
'pathDocument' => $pathDocument,
'pathTmpImport' => $pathTmpImport,
'pathActivityDocument' => $pathActivityDocument
];
}
public function storage($company_name)
{
$directory = 'assets/' . urldecode($company_name);
if (!is_dir($directory)) {
return "Directory not found";
}
$size = 0;
try {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
$size += $file->getSize();
}
} catch (Exception $e) {
return "Error while calculating size: " . $e->getMessage();
}
return round($size / 1048576, 2);
}
public function storageAllCompany()
{
$companies = Company::get();
$formData = [];
foreach($companies as $data) {
$size = 0;
$directory = 'assets/' . urldecode($data['company_name']);
if (is_dir($directory)) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
$size += $file->getSize();
}
}
$formData[] = [
'company_name' => $data['company_name'],
'size' => round($size / 1048576, 2),
'exp_ospro' => ProductTransaction::query()->where('company_id', $data['id'])->value('exp_ospro'),
'project_total' => Project::query()->where('company_id',$data['id'])->count()
];
}
return $formData;
}
public function setExpiredTimeOspro($company_id)
{
$currentDate = Carbon::now();
$countCreate = false;
$transaction = ProductTransaction::query()
->where('company_id', $company_id)->first();
if(!empty($transaction)) {
$dateExpired = $transaction['exp_ospro'];
if ($currentDate->gt(Carbon::parse($dateExpired))) {
$countCreate = false;
} else {
$countCreate = true;
}
return $countCreate;
} else {
return $countCreate = true;
}
}
protected function setLimitsStorage($company, $dokumen, $initPath, $destinatePath)
{
$countCreate = false;
DB::transaction(function() use($company, $dokumen, $initPath, $destinatePath, &$countCreate) {
$totalSize = 0;
$sizeFile = $dokumen->getSize();
// Path
$folderPath = $destinatePath['pathDocument'];
$folderPathImage = $destinatePath['pathImage'];
$folderPathTmpImport = $destinatePath['pathTmpImport'];
$folderPathActivityDocument = $destinatePath['pathActivityDocument'];
// Create Directory
if (!file_exists($initPath)) {
mkdir($initPath, 0777, true);
}
// Scanning & Existing Folder
if (file_exists($folderPathImage)) {
$files = scandir($folderPathImage);
foreach ($files as $file) {
if (is_file($folderPathImage . '/' . $file)) {
$totalSize += filesize($folderPathImage . '/' . $file);
}
}
}
if (file_exists($folderPath)) {
$filesImage = scandir($folderPath);
foreach ($filesImage as $file) {
if (is_file($folderPath . '/' . $file)) {
$totalSize += filesize($folderPath . '/' . $file);
}
}
}
if (file_exists($folderPathTmpImport)) {
$filesTmpImport = scandir($folderPathTmpImport);
foreach ($filesTmpImport as $file) {
if (is_file($folderPathTmpImport . '/' . $file)) {
$totalSize += filesize($folderPathTmpImport . '/' . $file);
}
}
}
if (file_exists($folderPathActivityDocument)) {
$filesActivityDocument = scandir($folderPathActivityDocument);
foreach ($filesActivityDocument as $file) {
if (is_file($folderPathActivityDocument . '/' . $file)) {
$totalSize += filesize($folderPathActivityDocument . '/' . $file);
}
}
}
// Logic
$totalSize += $sizeFile;
$transaction = ProductTransaction::query()
->where('company_id', $company['id']);
$cloneQueryTransaction = clone $transaction;
if ($transaction->where([['type_paket', 'Basic'], ['amount', '!=', null]])->exists()) {
$maximumSize = 500 * 1024 * 1024;
$countCreate = true;
} elseif ($cloneQueryTransaction->where([['type_paket', 'Free'], ['amount', 0]])->exists()) {
$maximumSize = 50 * 1024 * 1024;
$countCreate = true;
} else {
$countCreate = true;
}
if ($countCreate && isset($maximumSize)) { // kondisi $maximumSize sementara karena blm ada paket enterprise
if (floatval($totalSize) > floatval($maximumSize)) {
$countCreate = false;
}
}
});
return $countCreate;
}
protected function setUpPayload($condition, $tableSelf)
{
$alias = "selfTable";
@ -184,6 +339,10 @@ class Controller extends BaseController
$query = $query->whereIn($tableColumn . "." . $column, $value);
} else if ($operator == "notin") {
$query = $query->whereNotIn($tableColumn . "." . $column, $value);
} else if ($operator == "isnull") {
$query = $query->WhereNull($tableColumn . "." . $column);
} else if ($operator == "notnull") {
$query = $query->WhereNotNull($tableColumn . "." . $column);
} else {
$query = $query->where($tableColumn . "." . $column, $operator, $value);
}
@ -281,6 +440,28 @@ class Controller extends BaseController
return $totalCost;
}
protected function paramsMethodGet($query, $countData, $request)
{
$start = $request->start;
$length = $request->length == '-1' ? $countData : $request->length;
$orderBy = $request->orderby;
$asc = $request->asc == 'false' ? 'desc' : 'asc';
$where = $request->column;
$logicOp = $request->logic;
$valColumn = str_replace("\\", "", "$request->value");
if ($logicOp == 'like' || $logicOp == 'ilike') {
$valColumnFilter = '%' . $valColumn . '%';
} else {
$valColumnFilter = $valColumn;
}
$data = $query->where($where, $logicOp, $valColumnFilter)
->orderBy($orderBy, $asc)
->offset($start)->limit($length)->get();
return $data;
}
protected function getLoc($lat, $lng)
{
// $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json");

458
app/Http/Controllers/DashboardBoDController.php

@ -2,15 +2,19 @@
namespace App\Http\Controllers;
use App\Helpers\MasterFunctionsHelper;
use App\Models\User;
use App\Models\Divisi;
use App\Models\Project;
use App\Models\ProjectPhase;
use App\Models\User;
use App\Models\ProjectExpenditure;
use App\Models\UserToVersionGantt;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Models\ProjectScheduleHealth;
use App\Helpers\MasterFunctionsHelper;
use App\Models\ProjectFinancialHealth;
use App\Models\ProjectInvoice;
class DashboardBoDController extends Controller
{
@ -22,30 +26,51 @@ class DashboardBoDController extends Controller
}
// to do
public function getCompanyCashFlow($year = '%')
public function getCompanyCashFlow($company_id, $all_project, $hierarchy, $role_name)
{
$year = $this->interpolateYear($year);
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
// we can't use eloquent's sum() method because someone decided to use varchar as datatype in rencana_biaya field
$totalBudgets = Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))'))
->where('mulai_proyek', 'like', $year)
->pluck('sum')
->first();
$totalBudgets = null;
$role = urldecode($role_name);
if ($role === "Super Admin") {
$totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} elseif (!empty($all_project)) {
$totalBudgets = Project::where('company_id', $company_id)
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} else {
$totalBudgets = Project::where('created_by_id', $hierarchy)
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
}
$projects = null;
if ($role === "Super Admin") {
$projects = Project::get();
} elseif (!empty($all_project)) {
$projects = Project::where('company_id', $company_id)
->get();
} else {
$projects = Project::where('created_by_id', $hierarchy)
->get();
}
$projects = Project::where('mulai_proyek', 'like', $year)
->get();
foreach ($projects as $project) {
$project->expenses = 0;
$resp = null;
if ($project->kode_sortname != "") {
$cost = 0;
$cost = substr($cost, 0, strpos($cost, "."));
$totalExpenditure += (int) $cost;
$totalInvoice += 0;
$totalPaidInvoice += 0;
// $resp = $this->getInvoiceIntegration($project->kode_sortname);
// $cost = $resp->data->total_cost ?? 0;
// $cost = substr($cost, 0, strpos($cost, "."));
$cost = 0;
$totalExpenditure = 0;
$totalInvoice = 0;
$totalPaidInvoice = 0;
// $totalExpenditure += (int) $cost;
// $totalInvoice += $resp->data->total_invoice_amount ?? 0;
// $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
}
}
@ -59,11 +84,145 @@ class DashboardBoDController extends Controller
], 200);
}
public function getInvoiceOutstanding($year = '%')
public function getDetailExpenditureColor($role_name, $company_id)
{
$year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year)
->get();
$role = urldecode($role_name);
$query = null;
if ($role === 'Super Admin') {
$query = ProjectExpenditure::get();
} else {
$query = ProjectExpenditure::where('company_id', $company_id)->get();
}
$data = [];
foreach ($query as $value) {
if ($value['name'] === 'Total Budget') {
$data['total_budget'] = $value['color'];
}
if ($value['name'] === 'Expenditure') {
$data['total_expenditure'] = $value['color'];
}
if ($value['name'] === 'Invoice') {
$data['total_invoice'] = $value['color'];
}
if ($value['name'] === 'Cash In') {
$data['total_paid_invoice'] = $value['color'];
}
}
return response()->json([
'data' => [
'total_budget' => $data['total_budget'] ?? '',
'total_expenditure' => $data['total_expenditure'] ?? '',
'total_invoice' => $data['total_invoice'] ?? '',
'total_paid_invoice' => $data['total_paid_invoice'] ?? '',
]
], 200);
}
public function getDetailFinancialHealthColor($role_name, $company_id)
{
$role = urldecode($role_name);
$query = null;
if ($role === 'Super Admin') {
$query = ProjectFinancialHealth::get();
} else {
$query = ProjectFinancialHealth::where('company_id', $company_id)->get();
}
$data = [];
foreach ($query as $value) {
if ($value['name'] === 'Cost Overrun') {
$data['overrun'] = $value['color'];
}
if ($value['name'] === 'Early Warning') {
$data['warning'] = $value['color'];
}
if ($value['name'] === 'On Budget') {
$data['on-budget'] = $value['color'];
}
}
return response()->json([
'data' => [
'overrun' => $data['overrun'] ?? '',
'warning' => $data['warning'] ?? '',
'on-budget' => $data['on-budget'] ?? '',
]
], 200);
}
public function getDetailScheduleHealthColor($role_name, $company_id)
{
$role = urldecode($role_name);
$query = null;
if ($role === 'Super Admin') {
$query = ProjectScheduleHealth::get();
} else {
$query = ProjectScheduleHealth::where('company_id', $company_id)->get();
}
$data = [];
foreach ($query as $value) {
if ($value['name'] === 'Behind Schedule') {
$data['behind-schedule'] = $value['color'];
}
if ($value['name'] === 'Early Warning') {
$data['warning'] = $value['color'];
}
if ($value['name'] === 'On Schedule') {
$data['on-schedule'] = $value['color'];
}
}
return response()->json([
'data' => [
'behind-schedule' => $data['behind-schedule'] ?? '',
'warning' => $data['warning'] ?? '',
'on-schedule' => $data['on-schedule'] ?? '',
]
], 200);
}
public function getDetailInvoiceColor($role_name, $company_id)
{
$role = urldecode($role_name);
$query = null;
if ($role === 'Super Admin') {
$query = ProjectInvoice::get();
} else {
$query = ProjectInvoice::where('company_id', $company_id)->get();
}
$data = [];
foreach ($query as $value) {
if ($value['name'] === 'Invoiced') {
$data['invoiced'] = $value['color'];
}
if ($value['name'] === 'Cash In') {
$data['paid'] = $value['color'];
}
}
return response()->json([
'data' => [
'invoiced' => $data['invoiced'] ?? '',
'paid' => $data['paid'] ?? ''
]
], 200);
}
// integrasi
public function getInvoiceOutstanding($role_name, $company_id, $all_project, $hierarchy)
{
$role = urldecode($role_name);
$projects = null;
if ($role === 'Super Admin') {
$projects = Project::get();
} elseif (!empty($all_project)) {
$projects = Project::where('company_id', $company_id)
->get();
} else {
$projects = Project::where('created_by_id', $hierarchy)
->get();
}
$return = [];
foreach ($projects as $project) {
if ($project->kode_sortname != "") {
@ -81,17 +240,33 @@ class DashboardBoDController extends Controller
], 200);
}
public function getTotalProjectPerScheduleHealth($year = '%')
public function getTotalProjectPerScheduleHealth($role_name, $company_id, $all_project, $hierarchy)
{
$year = $this->interpolateYear($year);
$role = urldecode($role_name);
$replaceHierarchy = preg_replace('/[\[\]]/', '', $hierarchy);
$return = [
'behind-schedule' => 0,
'warning' => 0,
'on-schedule' => 0,
];
$divisi = Divisi::query()
->where('company_id', $company_id)
->pluck('id');
$projects = null;
if ($role === 'Super Admin') {
$projects = Project::get();
} elseif ($all_project == 'true') {
$projects = Project::whereIn('divisi_id', $divisi)
->where('company_id', $company_id)
->get();
} else {
$projects = Project::whereIn('divisi_id', $divisi)
->where('created_by_id', $replaceHierarchy)
->get();
}
$projects = Project::where('mulai_proyek', 'like', $year)->get();
foreach ($projects as $index => $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0;
@ -106,7 +281,7 @@ class DashboardBoDController extends Controller
}
$selisihProgress = $planningProgress - $actualProgress;
try {
if ($selisihProgress > 0 && $selisihProgress <= 5) {
if ($selisihProgress > 0 && $selisihProgress <= 20) {
$return['warning'] += 1;
$projects[$index]->status = 'warning';
} elseif ($selisihProgress == 0) {
@ -124,17 +299,24 @@ class DashboardBoDController extends Controller
return response()->json(['data' => $return, 'q' => $projects], 200);
}
public function getTotalProjectScheduleHealthPerDivision($year = '%')
public function getTotalProjectScheduleHealthPerDivision($role_name, $company_id)
{
$year = $this->interpolateYear($year);
$role = urldecode($role_name);
$divisions = null;
if ($role === 'Super Admin') {
$divisions = Divisi::whereNull('parent')
->get();
} else {
$divisions = Divisi::whereNull('parent')
->where('company_id', $company_id)
->get();
}
$divisions = Divisi::whereNull('parent')->get();
foreach ($divisions as $index => $division) {
$scheduleData = new Collection();
$behindSchedule = $warning = $onSchedule = 0;
$projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get();
$projects = Project::where('divisi_id', $division->id)->get();
foreach ($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0;
@ -169,51 +351,103 @@ class DashboardBoDController extends Controller
], 200);
}
public function getTotalProjectPerBudgetHealth($year = '%')
public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy)
{
$year = $this->interpolateYear($year);
return response()->json([
$role = urldecode($role_name);
$replaceHierarchy = preg_replace('/[\[\]]/', '', $hierarchy);
$response = [
'data' => [
'overrun' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'overrun')->count(),
'warning' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'warning')->count(),
'on-budget' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'on-budget')->count(),
'overrun' => 0,
'warning' => 0,
'on-budget' => 0,
]
], 200);
];
$divisi = Divisi::query()
->where('company_id', $company_id)
->pluck('id');
// arr overrun
if ($role === 'Super Admin') {
$response['data']['overrun'] = Project::where('budget_health', 'overrun')
->count();
} elseif ($all_project == 'true') {
$response['data']['overrun'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'overrun'], ['company_id', $company_id]])
->count();
} else {
$response['data']['overrun'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'overrun'], ['created_by_id', $replaceHierarchy]])
->count();
}
// arr warning
if ($role === 'Super Admin') {
$response['data']['warning'] = Project::where('budget_health', 'warning')
->count();
} elseif ($all_project == 'true') {
$response['data']['warning'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'warning'], ['company_id', $company_id]])
->count();
} else {
$response['data']['warning'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'warning'], ['created_by_id', $replaceHierarchy]])
->count();
}
// arr on-budget
if ($role === 'Super Admin') {
$response['data']['on-budget'] = Project::where('budget_health', 'on-budget')
->count();
} elseif ($all_project == 'true') {
$response['data']['on-budget'] = Project::whereIn('divisi_id', $divisi)
->where([['company_id', $company_id], ['budget_health', 'on-budget']])
->count();
} else {
$response['data']['on-budget'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'on-budget'], ['created_by_id', $replaceHierarchy]])
->count();
}
return response()->json($response, 200);
}
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health)
private function countTotalProjectByBudgetHealthInDivision($divisi, $health)
{
return Project::where('divisi_id', $divisi)
->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
->where('budget_health', $health)
->count();
$project = Project::where([['divisi_id', $divisi], ['budget_health', $health]])->count();
return $project;
}
public function getTotalProjectBudgetHealthPerDivision($year = '%')
public function getTotalProjectBudgetHealthPerDivision($role_name, $company_id)
{
$year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name')
->with('children')
->whereNull('parent')
->get();
$role = urldecode($role_name);
$divisions = null;
if ($role === 'Super Admin') {
$divisions = Divisi::select('id', 'name')
->with('children')
->whereNull('parent')
->get();
} else {
$divisions = Divisi::select('id', 'name')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
// to do : count in more than 1 level child
foreach ($divisions as $division) {
$budgetData = new Collection();
$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, 'on-budget'), 'on-budget');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'overrun'), 'overrun');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'warning'), 'warning');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'on-budget'), 'on-budget');
foreach ($division->children as $d) {
$budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'overrun');
$budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'warning');
$budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'on-budget');
$budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'overrun');
$budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'warning');
$budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'on-budget');
}
unset($division->children);
$division->budgetData = $budgetData;
}
foreach ($divisions as $division) {
}
return response()->json([
'data' => [
$divisions
@ -221,15 +455,31 @@ class DashboardBoDController extends Controller
], 200);
}
public function getTotalProjectPerPhase($year = '%')
public function getTotalProjectPerPhase($role_name, $company_id, $all_project, $hierarchy)
{
$year = $this->interpolateYear($year);
$projectPhases = ProjectPhase::orderBy('order')->get();
$role = urldecode($role_name);
$projectPhases = null;
if ($role === 'Super Admin') {
$projectPhases = ProjectPhase::orderBy('order')->get();
} else {
$projectPhases = ProjectPhase::where('company_id', $company_id)->orderBy('order')->get();
}
foreach ($projectPhases as $phase) {
$phase->totalProject = Project::where('phase_id', $phase->id)
->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
->count();
if ($role === 'Super Admin') {
$phase->totalProject = Project::where('phase_id', $phase->id)
->count();
} elseif ($all_project) {
$phase->totalProject = Project::where('phase_id', $phase->id)
->where('company_id', $company_id)
->count();
} else {
$phase->totalProject = Project::where('phase_id', $phase->id)
->where('created_by_id', $hierarchy)
->count();
}
}
return response()->json([
'data' => [
@ -238,27 +488,37 @@ class DashboardBoDController extends Controller
], 200);
}
private function countTotalProjectInDivision($id, $year)
private function countTotalProjectInDivision($id)
{
return Project::where('divisi_id', $id)
->where('mulai_proyek', 'like', $year)
->count();
}
public function getTotalProjectPerDivision($year = '%')
public function getTotalProjectPerDivision($role_name, $company_id)
{
$year = $this->interpolateYear($year);
$role = urldecode($role_name);
$divisions = null;
if ($role === 'Super Admin') {
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->get();
} else {
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->get();
// to do : count in more than 1 level child
foreach ($divisions as $v) {
$v->total = $this->countTotalProjectInDivision($v->id, $year);
$v->total = $this->countTotalProjectInDivision($v->id);
foreach ($v->children as $d) {
$v->total += $this->countTotalProjectInDivision($d->id, $year);
$v->total += $this->countTotalProjectInDivision($d->id);
}
unset($v->children);
}
@ -268,30 +528,35 @@ class DashboardBoDController extends Controller
], 200);
}
private function countTotalProjectValueInDivision($id, $year)
private function countTotalProjectValueInDivision($id)
{
return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))'))
->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
->where('divisi_id', $id)
->pluck('sum')
->first();
}
public function getTotalProjectValuePerDivision($year = '%')
public function getTotalProjectValuePerDivision($role_name, $company_id)
{
$year = $this->interpolateYear($year);
$role = urldecode($role_name);
if ($role === 'Super Admin') {
$divisions = Divisi::select('id', 'name', 'color')
->with('children')
->whereNull('parent')
->get();
} else {
$divisions = Divisi::select('id', 'name', 'color')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
$divisions = Divisi::select('id', 'name', 'color')
->with('children')
->whereNull('parent')
->get();
// to do : count in more than 1 level child
foreach ($divisions as $v) {
$v->total = $this->countTotalProjectValueInDivision($v->id, $year);
$v->total = $this->countTotalProjectValueInDivision($v->id);
foreach ($v->children as $d) {
$v->total += $this->countTotalProjectValueInDivision($d->id, $year);
$v->total += $this->countTotalProjectValueInDivision($d->id);
}
unset($v->children);
}
@ -302,13 +567,22 @@ class DashboardBoDController extends Controller
}
public function getDetailExpenditure($year = '%')
public function getDetailExpenditure($year = '%', $company_id, $all_project, $hierarchy)
{
$year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
->orderBy('id', 'desc')
->get();
$projects = null;
if ($all_project) {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('company_id', $company_id)
->orderBy('id', 'desc')
->get();
} else {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->orderBy('id', 'desc')
->get();
}
foreach ($projects as $project) {
$lastGantt = MasterFunctionsHelper::getLatestGantt($project->id);

116
app/Http/Controllers/DemoController.php

@ -0,0 +1,116 @@
<?php
namespace App\Http\Controllers;
use App\Models\Demo;
use Illuminate\Http\Request;
class DemoController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'role' => 'required',
'email' => 'required',
'number_phone' => 'required',
'status' => 'required',
'message' => 'required'
]);
$data = $request->all();
$data['created_by'] = '@System';
$data['status'] = 'New Request';
$result = Demo::create($data);
if ($result) {
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Request Demo successfully!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Request Demo 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 = Demo::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data Demo, 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 = Demo::find($id);
if ($data) {
$result = $data->update($request->all());
} else {
return response()->json(['status' => 'failed', 'message' => 'data Demo not found!', 'code' => 400], 400);
die();
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'data Demo successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Demo failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = Demo::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data Demo not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data Demo successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Demo failed deleted!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_demo');
$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 = Demo::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 Demo, please try again later!', 'code' => 400], 400);
}
}
}

93
app/Http/Controllers/DivisiController.php

@ -4,25 +4,28 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Divisi;
use Illuminate\Support\Facades\Log;
class DivisiController extends Controller
{
private function getAllChildren($divisi, $depth = 0, $array = []) {
private function getAllChildren($divisi, $depth = 0, $array = [])
{
$divisi->depth = $depth;
array_push($array, $divisi);
foreach($divisi->children as $child){
foreach ($divisi->children as $child) {
$array = $this->getAllChildren($child, $depth + 1, $array);
}
return $array;
}
public function add(Request $request){
public function add(Request $request)
{
$this->validate($request, [
'name' => 'string|required|unique:m_divisi,name',
'name' => 'string|required|unique:m_divisi,name,NULL,id,company_id,' . $request->input('company_id'),
'description' => 'nullable|string',
'parent' => 'nullable|integer',
'color'=>'nullable|string|max:10'
'color' => 'nullable|string|max:10'
]);
$data = $request->all();
@ -30,15 +33,16 @@ class DivisiController extends Controller
$result = Divisi::create($data);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500]);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Failed to add data', 'code' => 500]);
return response()->json(['status'=>'success','message'=>'Data created!','code'=>200]);
return response()->json(['status' => 'success', 'message' => 'Data created!', 'code' => 200]);
}
public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
public function update(Request $request, $id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$this->validate($request, [
'name' => 'string|required',
@ -47,68 +51,75 @@ class DivisiController extends Controller
]);
$data = Divisi::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_divisi,name']) : '';
$request->name !== $data['name'] ? $this->validate($request, ['name' => 'unique:m_divisi,name']) : '';
if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$result = $data->update($request->all());
if(!$result)
return response()->json(['status'=>'failed','message'=> 'Update failed!','code'=> 500], 500);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Update failed!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200);
return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200], 200);
}
public function delete($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = Divisi::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$delete = $data->delete();
if(!$delete)
return response()->json(['status'=>'failed','message'=> 'Delete failed!','code'=> 500], 500);
if (!$delete)
return response()->json(['status' => 'failed', 'message' => 'Delete failed!', 'code' => 500], 500);
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(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_divisi');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
//return $this->list();
// cant use builder for this case
{
$companyId = $request->input('columns.0.value');
$parentDivisi = Divisi::whereNull('parent')
->where('company_id', $companyId)
->with('children')
->get();
$divisions = [];
foreach ($parentDivisi as $objRow) {
$objRow->children = $this->getAllChildren($objRow);
// $objRow->key = rand(1, 1000);
$divisions[] = $objRow;
}
$countData = count($divisions);
if ($countData == 0)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200);
}
public function list()
{
$parentMenus = Divisi::whereNull('parent')->with('children')->get();
$divisions = [];
foreach($parentMenus as $menu){
foreach ($parentMenus as $menu) {
$childs = $this->getAllChildren($menu);
foreach($childs as $d){
foreach ($childs as $d) {
$d->displayName = ' ' . $d->name;
for($i=0; $i < $d->depth; $i++){
$d->displayName = '--' . $d->displayName ;
for ($i = 0; $i < $d->depth; $i++) {
$d->displayName = '--' . $d->displayName;
}
array_push($divisions, $d);
}
}
$countData = count($divisions);
if($countData == 0)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if ($countData == 0)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=> $divisions, 'totalRecord'=> $countData], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200);
}
}

274
app/Http/Controllers/FolderDocumentProyekController.php

@ -1,131 +1,143 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\FolderDocumentProyek;
use App\Models\DokumenProject;
class FolderDocumentProyekController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'name_folder' => 'required',
'proyek_id' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = FolderDocumentProyek::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfull created','code'=>200]);
}else{
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed created','code'=>400]);
}
}
public function update(Request $request, $id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = FolderDocumentProyek::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Folder Document Proyek not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = FolderDocumentProyek::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data Folder Document Proyek not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_FolderDocumentProyek');
$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 = FolderDocumentProyek::all();
$countData = $data->count();
if($data){
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400);
}
}
public function getTree($id)
{
$data = FolderDocumentProyek::where('proyek_id', $id)->whereNull('parent_id')->orderByRaw('id ASC')->get();
$dataFile = DokumenProject::where('type_dokumen', 'project-document-out-folder')->where('ref_id', $id)->orderByRaw('id ASC')->get();
$finalData = [];
foreach($data as $objRow){
$objRow->children = $this->getChildren($id, $objRow->id);
$objRow->key = rand(1, 1000);
$objRow->isDir = true;
$finalData[] = $objRow;
}
foreach($dataFile as $objRowFile) {
$objRowFile->key = rand(1, 1000);
$objRowFile->isDir = false;
$objRowFile->proyek_id = $id;
$finalData[] = $objRowFile;
}
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200);
}
private function getChildren($proyek_id, $parent_id)
{
$finalData = [];
$data = FolderDocumentProyek::where('proyek_id', $proyek_id)->where('parent_id', $parent_id)->orderByRaw('id ASC')->get();
$dataFile = DokumenProject::where('type_dokumen', 'project-document-in-folder')->where('ref_id', $parent_id)->orderByRaw('id ASC')->get();
foreach($data as $objRow){
$objRow->key = rand(1, 1000);
$objRow->children = $this->getChildren($proyek_id, $objRow->id);
$objRow->isDir = true;
$finalData[] = $objRow;
}
foreach($dataFile as $objRowFile) {
$objRowFile->key = rand(1, 1000);
$objRowFile->isDir = false;
$objRowFile->proyek_id = $proyek_id;
$finalData[] = $objRowFile;
}
return $finalData;
}
}
<?php
namespace App\Http\Controllers;
use App\Models\Company;
use Illuminate\Http\Request;
use App\Models\DokumenProject;
use App\Models\FolderDocumentProyek;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class FolderDocumentProyekController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'name_folder' => 'required',
'proyek_id' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = FolderDocumentProyek::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfull created','code'=>200]);
}else{
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed created','code'=>400]);
}
}
public function update(Request $request, $id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = FolderDocumentProyek::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Folder Document Proyek not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed updated!','code'=>400], 400);
}
}
public function delete($id, $company_id)
{
DB::beginTransaction();
$data = FolderDocumentProyek::find($id);
$company = Company::find($company_id);
if($data && $company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$dir = $destinationPath['pathDocument'];
$dataFile = DokumenProject::where([['type_dokumen', 'project-document-in-folder'],['ref_id', $data['id']]])->orderByRaw('id ASC')->get();
if (is_dir($dir)) {
foreach ($dataFile as $file) {
unlink($dir.$file['file']);
}
}
if($data->delete()) {
DB::commit();
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfully deleted!','code'=>200], 200);
} else {
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed deleted!','code'=>400], 400);
}
} else {
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'Data Folder Document Proyek not found!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_FolderDocumentProyek');
$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 = FolderDocumentProyek::all();
$countData = $data->count();
if($data){
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400);
}
}
public function getTree($id)
{
$data = FolderDocumentProyek::where('proyek_id', $id)->whereNull('parent_id')->orderByRaw('id ASC')->get();
$dataFile = DokumenProject::where('type_dokumen', 'project-document-out-folder')->where('ref_id', $id)->orderByRaw('id ASC')->get();
$finalData = [];
foreach($data as $objRow){
$objRow->children = $this->getChildren($id, $objRow->id);
$objRow->key = rand(1, 1000);
$objRow->isDir = true;
$finalData[] = $objRow;
}
foreach($dataFile as $objRowFile) {
$objRowFile->key = rand(1, 1000);
$objRowFile->isDir = false;
$objRowFile->proyek_id = (int)$id;
$finalData[] = $objRowFile;
}
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200);
}
private function getChildren($proyek_id, $parent_id)
{
$finalData = [];
$data = FolderDocumentProyek::where('proyek_id', $proyek_id)->where('parent_id', $parent_id)->orderByRaw('id ASC')->get();
$dataFile = DokumenProject::where('type_dokumen', 'project-document-in-folder')->where('ref_id', $parent_id)->orderByRaw('id ASC')->get();
foreach($data as $objRow){
$objRow->key = rand(1, 1000);
$objRow->children = $this->getChildren($proyek_id, $objRow->id);
$objRow->isDir = true;
$finalData[] = $objRow;
}
foreach($dataFile as $objRowFile) {
$objRowFile->key = rand(1, 1000);
$objRowFile->isDir = false;
$objRowFile->proyek_id = (int)$proyek_id;
$finalData[] = $objRowFile;
}
return $finalData;
}
}

73
app/Http/Controllers/HierarchyFtthController.php

@ -6,6 +6,7 @@ use Illuminate\Http\Request;
use App\Models\HierarchyFtth;
use App\Models\VersionGantt;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Artisan;
class HierarchyFtthController extends Controller
{
@ -102,36 +103,41 @@ class HierarchyFtthController extends Controller
}
}
public function countProgress($project_id) {
$ftthIds = VersionGantt::select('hierarchy_ftth_id')
->where('proyek_id', $project_id)
->groupBy('hierarchy_ftth_id')
->get();
if($ftthIds){
foreach ($ftthIds as $ftthId) {
$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();
$ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id);
if($ftth){
$round = $gantts/$ganttCount;
$round_bobot = $bobot_planning/$ganttCount;
$ftth->progress = round($round, 2);
$ftth->bobot_planning = round($round_bobot, 2);
try {
$ftth->save();
} catch (\Exception $e) {
// Log the error or handle it in some other way
Log::error($e->getMessage());
}
public function countProgress($hierarchy_id) {
// $ftthIds = VersionGantt::select('hierarchy_ftth_id')
// ->where('proyek_id', $project_id)
// ->groupBy('hierarchy_ftth_id')
// ->get();
// if($ftthIds){
// foreach ($ftthIds as $ftthId) {
// $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();
if($ftth->parent_id){
$this->countParent($ftth);
}
}
}
}
// $ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id);
// if($ftth){
// $round = $gantts/$ganttCount;
// $round_bobot = $bobot_planning/$ganttCount;
// $ftth->progress = round($round, 2);
// $ftth->bobot_planning = round($round_bobot, 2);
// try {
// $ftth->save();
// } catch (\Exception $e) {
// // Log the error or handle it in some other way
// Log::error($e->getMessage());
// }
// if($ftth->parent_id){
// $this->countParent($ftth);
// }
// }
// }
// }
// calculate ke curva berdasarkan site
Artisan::call('calculate:progressgantt', [
'hierarchy_id' => $hierarchy_id
]);
}
public function countParent($ftth){
@ -179,7 +185,6 @@ class HierarchyFtthController extends Controller
public function getTreeByProject($project_id)
{
$this->countProgress(intval($project_id));
$data = HierarchyFtth::where('project_id', $project_id)->whereNull('parent_id')->orderByRaw('id ASC')->get();
$finalData = [];
foreach($data as $objRow){
@ -204,7 +209,13 @@ class HierarchyFtthController extends Controller
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200);
}
public function countProgressTree($hierarchy_id)
{
Artisan::call('calculate:progressgantt', [
'hierarchy_id' => $hierarchy_id
]);
return response()->json(['status'=>'success','code'=>200], 200);
}
private function getChildren($project_id, $parent_id)
{
$finalData = [];

280
app/Http/Controllers/HolidayController.php

@ -1,140 +1,140 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Holiday;
use Datatables;
class HolidayController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'proyek_id' => 'required',
'version_gantt_id' => 'required',
'date' => 'required'
]);
$data = $request->all();
$duration = $request->duration;
if(!$duration){
$data['duration'] = 1;
}
$data['created_by'] = $this->currentName;
$result = Holiday::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'add holiday successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add holiday 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 = Holiday::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data holiday, 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 = Holiday::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'data holiday not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'data holiday successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data holiday failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = Holiday::find($id);
if($data){
$deletedData = $data;
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data holiday not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success', 'data'=>$deletedData,'message'=>'data holiday successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data holiday failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_holidays');
$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 = Holiday::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 holiday, please try again later!','code'=>400], 400);
}
}
public function datatables(Request $request){
$proyek_id = $request->query('proyek_id');
$gantt_id = $request->query('gantt_id');
$data = Holiday::where('proyek_id', $proyek_id)->where('version_gantt_id', $gantt_id)->get();
return Datatables::of($data)
->editColumn('date', function($row) {
$date = date_create($row->date);
$dateFormat = date_format($date,"d-m-Y");
return $dateFormat;
})
->editColumn('duration', function($row) {
$day = (int)$row->duration > 1 ? "days" : "day";
return $row->duration." ".$day;
})
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-holiday-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Holiday;
use Yajra\Datatables\Datatables;
class HolidayController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'proyek_id' => 'required',
'version_gantt_id' => 'required',
'date' => 'required'
]);
$data = $request->all();
$duration = $request->duration;
if(!$duration){
$data['duration'] = 1;
}
$data['created_by'] = $this->currentName;
$result = Holiday::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'add holiday successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add holiday 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 = Holiday::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data holiday, 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 = Holiday::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'data holiday not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'data holiday successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data holiday failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = Holiday::find($id);
if($data){
$deletedData = $data;
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data holiday not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success', 'data'=>$deletedData,'message'=>'data holiday successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data holiday failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_holidays');
$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 = Holiday::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 holiday, please try again later!','code'=>400], 400);
}
}
public function datatables(Request $request){
$proyek_id = $request->query('proyek_id');
$gantt_id = $request->query('gantt_id');
$data = Holiday::where('proyek_id', $proyek_id)->where('version_gantt_id', $gantt_id)->get();
return Datatables::of($data)
->editColumn('date', function($row) {
$date = date_create($row->date);
$dateFormat = date_format($date,"d-m-Y");
return $dateFormat;
})
->editColumn('duration', function($row) {
$day = (int)$row->duration > 1 ? "days" : "day";
return $row->duration." ".$day;
})
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-holiday-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
}
}

202
app/Http/Controllers/HumanResourceController.php

@ -3,20 +3,82 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\HumanResource;
use App\Models\UserToActivity;
use App\Models\UserToProyek;
use App\Models\{HumanResource,ProductTransaction,UserToActivity,UserToProyek,User};
use Illuminate\Support\Facades\Artisan;
const URL_EMAIL = 'https://notifapp.odm-iu.com/service-mail/notif_mail.php';
class HumanResourceController extends Controller
{
public function add(Request $request)
{
$messages = [
'ktp_number.unique' => 'Nomor KTP/ID Card tidak boleh sama',
'username.unique' => 'Username tidak boleh sama',
'required' => 'Data tidak boleh kosong'
];
$this->validate($request, [
'name' => 'required|string',
'ktp_number' => 'required|string|unique:m_users,ktp_number',
'employee_type' => 'required|in:employee,subcon,freelance',
'company_id' => 'required|integer',
'username' => 'string|unique:m_users,username',
'email' => 'string|unique:m_users,email'
], $messages);
$data = $request->all();
!$request->is_customer ? $this->validate($request,['role_id' => 'required','divisi_id' => 'required'], $messages) : '';
if (isset($request->password) && $request->password != "") {
$data['password'] = md5($request->password);
}
$transaction = ProductTransaction::query()
->where('company_id', (int) $request->company_id);
$cloneQueryTransaction = clone $transaction;
$countCreate = false;
$projectResult = HumanResource::query()
->selectRaw('count(*) as total_hr')
->where('company_id', (int) $request->company_id)
->first();
if($transaction->where([['type_paket','Basic'],['amount','!=',null]])->exists()) {
if($projectResult['total_hr'] < 50) {
$countCreate = true;
}
} elseif ($cloneQueryTransaction->where([['type_paket','Free'],['amount',0]])->exists()) {
if($projectResult['total_hr'] < 1) {
$countCreate = true;
}
} else {
$countCreate = true;
}
if($countCreate) {
$result = HumanResource::create($data);
} else {
return response()->json(['status' => 'failed', 'message' => 'Limited to create human resource!', 'code' => 500], 500);
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfull created', 'code' => 200]);
} else {
return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed created', 'code' => 400]);
}
}
public function add_user(Request $request)
{
$this->validate($request, [
'role_id' => 'required',
'name' => 'required',
'ktp_number' => 'required|numeric|unique:m_users,ktp_number',
'employee_type' => 'required'
'ktp_number' => 'required|string|unique:m_users,ktp_number',
'employee_type' => 'required',
'company_id' => 'required',
'username' => 'required',
'email' => 'required|unique:m_users,email|email'
]);
$data = $request->all();
@ -28,6 +90,7 @@ class HumanResourceController extends Controller
$result = HumanResource::create($data);
if ($result) {
$this->sendEmail($request->email, $request->password);
return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfull created', 'code' => 200]);
} else {
return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed created', 'code' => 400]);
@ -52,35 +115,75 @@ class HumanResourceController extends Controller
public function update(Request $request, $id)
{
$messages = [
'ktp_number.unique' => 'Nomor KTP/ID Card tidak boleh sama',
'username.unique' => 'Username tidak boleh sama',
'required' => 'Data tidak boleh kosong'
];
$request->validate($request, [
'name' => 'required|string',
'ktp_number' => 'required|string|unique:m_users,ktp_number,'.$id . ',id',
'employee_type' => 'required|in:employee,subcon,freelance',
'company_id' => 'required|integer',
'username' => 'unique:m_users,username,'.$id . ',id',
'email' => 'string|unique:m_users,email,'.$id . ',id'
], $messages);
!$request->is_customer ? $this->validate($request,['role_id'=>'required', 'divisi_id'=>'required'], $messages) : '';
$request->password ? $this->validate($request,['password'=>'required|min:8']) : '';
$data = $request->all();
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);
$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']) : '';
$humanresource = HumanResource::find($id);
if(empty($humanresource)) {
return response()->json(['status' => 'failed', 'message' => 'Data Human Resource not found!', 'code' => 400], 400);
}
$data = $request->all();
if($request->company_id && isset($request->password) && isset($request->username)) {
$transaction = ProductTransaction::query()
->where('company_id', $request->company_id);
$cloneQueryTransaction = clone $transaction;
$countCreate = false;
$projectResult = HumanResource::query()
->selectRaw('count(*) as total_hr')
->where([
['company_id', $request->company_id],
['username', '!=', null],
['password', '!=', null]
])
->first();
if($transaction->where([['type_paket','Basic'],['amount','!=',null]])->exists()) {
if($projectResult['total_hr'] < 10) {
$countCreate = true;
}
} elseif ($cloneQueryTransaction->where([['type_paket','Free'],['amount',0]])->exists()) {
if($projectResult['total_hr'] < 1) {
$countCreate = true;
}
} else {
$countCreate = true;
}
} else {
$countCreate = true;
}
if (isset($request->password) && $request->password != "") {
$data['password'] = md5($request->password);
}
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);
}
if ($humanresource) {
if ($countCreate) {
$result = $humanresource->update($data);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Human Resource Pool not found!', 'code' => 400], 400);
die();
} else {
return response()->json(['status' => 'failed', 'message' => 'Limited to create human resource!', 'code' => 500], 500);
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfully updated!', 'code' => 200], 200);
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Human Resource Pool successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed updated!', 'code' => 400], 400);
}
@ -94,7 +197,6 @@ class HumanResourceController extends Controller
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data Human Resource Pool not found!', 'code' => 400], 400);
die();
}
@ -118,7 +220,7 @@ class HumanResourceController extends Controller
public function list()
{
$data = HumanResource::select('id', 'name', 'role_id')->get();
$data = HumanResource::select('id', 'name', 'role_id','company_id')->get();
$countData = $data->count();
if ($data) {
@ -196,4 +298,60 @@ class HumanResourceController extends Controller
{
Artisan::call('sync:integration-human-resources');
}
public function sendEmail($email, $password)
{
$user = User::select('email', 'name', 'username')->where('email', $email)->first();
if (!$user) {
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400);
} else {
$this->reqHttpCurl($email, $password, $user->username, $user->name);
return response()->json(['status' => 'error', 'code'=>400, 'message' => 'e-mail not found '], 400);
}
}
private function reqHttpCurl($email, $password, $username, $name)
{
$postData = [
"to" => $email,
"name" => $name,
"username" => $username,
"password" => $password,
"from" => "app.integrasia@integrasiautama.com",
"alias_from" => "OSPRO",
"subject" => "Registration OSPRO",
"body" => "registration-ospro"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => URL_EMAIL,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
// Set here requred headers
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
print_r(json_decode($response));
}
}
}

413
app/Http/Controllers/ImageController.php

@ -1,121 +1,292 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Image;
class ImageController extends Controller
{
public function uploadImage(Request $request){
if($request->hasFile('files')){
$this->validate($request, [
'ref_id' => 'required',
'category' => 'required'
]);
$ref_id = $request->ref_id;
$dokumen = $request->file('files');
$extension = $dokumen->extension();
$name = $ref_id.date("YmdHis").".".$extension;
$resultMove = $dokumen->move($this->pathImage, $name);
if($resultMove){
$data = [
'ref_id' => (int)$ref_id,
'image' => $name,
'category' => $request->category
];
$result = Image::create($data);
if($result){
return response()->json(['status'=>'success', "name_image"=>$name,'message'=>'image upload is successfully!','code'=>200], 200);
}else{
unlink($this->pathImage.$name);
return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400);
}
}else{
return response()->json(['status'=>'failed','message'=>'image is required!','code'=>400], 400);
}
}
public function delete($id)
{
$data = Image::find($id);
if($data){
unlink($this->pathImage.$data->image);
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data image not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data image successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data image failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_image');
$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 deleteByRef($id, $category)
{
$data = Image::where("ref_id", $id)->where("category", $category)->first();
if($data){
unlink($this->pathImage.$data->image);
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data image not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data image successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data image failed deleted!','code'=>400], 400);
}
}
public function getByRefId($id, $category)
{
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
if(!$category || $category==""){
return response()->json(['status'=>'failed','message'=>'category is required!','code'=>400], 400);
die();
}
$result = Image::where("ref_id", $id)->where("category", $category)->first();
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data image, please try again later!','code'=>400], 400);
}
}
}
<?php
namespace App\Http\Controllers;
use App\Models\Image;
use App\Models\Company;
use Illuminate\Http\Request;
use App\Models\ProductTransaction;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class ImageController extends Controller
{
public function uploadImage(Request $request){
DB::beginTransaction();
if($request->hasFile('files')){
$this->validate($request, [
'ref_id' => 'required',
'category' => 'required'
]);
$ref_id = $request->ref_id;
$dokumen = $request->file('files');
$extension = $dokumen->extension();
$category = $request->category;
$name = $ref_id.date("YmdHis").".".$extension;
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $dokumen, $destinationPath['pathImage'], $destinationPath);
}
if(isset($getLimitStorage)) {
if($getLimitStorage === false) {
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500);
}
$data = [
'ref_id' => (int)$ref_id,
'image' => $name,
'category' => $category
];
$result = Image::create($data);
$company = Company::find((int)$ref_id);
if($company && $category === 'company_logo_login') {
$dataArray = json_decode($company['logo_login'], true);
if(isset($dataArray['slider'])) {
$jsonImageSlider['login'] = $name;
$jsonImageSlider['slider'] = $dataArray['slider'];
} else {
$jsonImageSlider['login'] = $name;
}
$company->update([
'logo_login' => $jsonImageSlider
]);
}
if($company && $category === 'company_logo_header') {
$company->update([
'logo_header' => array('content' => $name)
]);
}
if($company && $category === 'company_favicon') {
$company->update([
'favicon_image' => array('content' => $name)
]);
}
if($dokumen->move($destinationPath['pathImage'], $name) && $result) {
DB::commit();
return response()->json(['status' => 'success', "name_image" => $name,'message' => 'image upload is successfully!','code' => 200], 200);
} else {
DB::rollBack();
unlink($destinationPath['pathImage'].$name);
return response()->json(['status' => 'failed','message' => 'image upload is failed!' ,'code' => 400], 400);
}
} else {
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400);
}
} else {
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'image is required!','code'=>400], 400);
}
}
public function uploadMultipleImage(Request $request) {
$this->validate($request, [
'ref_id' => 'required',
'category' => 'required',
'files.*' => 'required|file|mimes:jpeg,png,jpg,gif|max:2048',
]);
if ($request->hasFile('files')) {
$ref_id = $request->ref_id;
$category = $request->category;
$dokumen = $request->file('files');
$successCount = 0;
$imageSlider = [];
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
$totalSize = 0;
$sizeFile = 0;
foreach ($dokumen as $file) {
$sizeFile += $file->getSize();
}
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$folderPath = $destinationPath['pathImage'];
if (!file_exists($folderPath)) {
mkdir($folderPath, 0777, true);
}
$files = scandir($folderPath);
foreach ($files as $file) {
if (is_file($folderPath . '/' . $file)) {
$totalSize += filesize($folderPath . '/' . $file);
}
}
$totalSize += $sizeFile;
$transaction = ProductTransaction::query()
->where('company_id', $company['id']);
$cloneQueryTransaction = clone $transaction;
$countCreate = false;
if($transaction->where([['type_paket','Basic'], ['amount','!=',null]])->exists()) {
$maximumSize = 500 * 1024 * 1024;
$countCreate = true;
} elseif ($cloneQueryTransaction->where([['type_paket','Free'], ['amount', 0]])->exists()) {
$maximumSize = 50 * 1024 * 1024;
$countCreate = true;
}
if($countCreate) {
if ($totalSize > $maximumSize) {
return response()->json(['status'=>'failed','message'=>'Limited storage maximum!','code'=> 500], 500);
}
}
}
foreach ($dokumen as $file) {
$extension = $file->extension();
$name = $ref_id.date("YmdHis").$successCount.".".$extension;
$resultMove = $file->move($folderPath, $name);
if ($resultMove) {
$data = [
'ref_id' => (int) $ref_id,
'image' => $name,
'category' => $category
];
$imageSlider[] = [
'content' => $name
];
$result = Image::create($data);
if ($result) {
$successCount++;
} else {
unlink($folderPath . $name);
}
}
}
$company = Company::find((int)$ref_id);
if($company && $category === 'company_slider_login') {
$dataArray = json_decode($company['logo_login'], true);
if(isset($dataArray['login'])) {
$jsonImageSlider['login'] = $dataArray['login'];
$jsonImageSlider['slider'] = $imageSlider;
} else {
$jsonImageSlider['slider'] = $imageSlider;
}
$company->update([
'logo_login' => $jsonImageSlider
]);
}
if ($successCount > 0 && $company) {
return response()->json(['status' => 'success', 'message' => "$successCount images uploaded successfully!", 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'No images uploaded successfully!', 'code' => 400], 400);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'Image is required!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = Image::find($id);
if($data){
unlink($this->pathImage.$data->image);
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data image not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data image successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data image failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_image');
$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 deleteByRef($id, $category, $company_id)
{
$data = Image::where("ref_id", (int)$id)->where("category", $category)->first();
$company = Company::find($company_id);
if($data && $company){
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
unlink($destinationPath['pathImage'].$data->image);
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data image not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data image successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data image failed deleted!','code'=>400], 400);
}
}
public function deleteByRefMultiple($id, $category, $company_id)
{
$successCount = 0;
$data = Image::where([
["ref_id", intval($id)],
["category", $category]
])->get();
$company = Company::find($company_id);
if($data->isNotEmpty() && $company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
foreach($data as $img) {
unlink($destinationPath['pathImage'].$img->image);
$delete = $img->delete();
if($delete){
$successCount++;
}
}
} else {
return response()->json(['status'=>'failed','message'=>'data image not found!','code'=>400], 400);
die();
}
if($successCount > 0) {
return response()->json(['status'=>'success','message'=>'data image successfully deleted!','code'=>200], 200);
} else {
return response()->json(['status'=>'failed','message'=>'data image failed deleted!','code'=>400], 400);
}
}
public function getByRefId($id, $category)
{
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
if(!$category || $category==""){
return response()->json(['status'=>'failed','message'=>'category is required!','code'=>400], 400);
die();
}
$result = Image::where("ref_id", $id)->where("category", $category)->first();
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data image, please try again later!','code'=>400], 400);
}
}
}

115
app/Http/Controllers/KanbanBoardController.php

@ -0,0 +1,115 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\KanbanBoard;
class KanbanBoardController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'name_board' => 'required',
'header_color' => 'required',
'body_color' => 'required',
'proyek_id' => 'required',
'version_gantt_id' => 'required',
'status_progress' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$statusCount = KanbanBoard::where('version_gantt_id', $request->version_gantt_id)
->where('status_progress', $request->status_progress)
->get()
->count();
if ($statusCount < 1 || $request->status_progress == 'none') {
$result = KanbanBoard::create($data);
} else {
return response()->json(['status'=>'failed','message'=>'Board kanban failed created','code'=>400], 400);
}
if($result){
return response()->json(['status'=>'success','message'=>'Board kanban successfull created','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Board kanban failed created','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 = KanbanBoard::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Board kanban not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Board kanban successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Board kanban failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = KanbanBoard::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'Data Board kanban not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'Board kanban successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Board kanban failed deleted!','code'=>400], 400);
}
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = KanbanBoard::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data Board kanban, please try again later!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'kanban_board');
$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(Request $request)
{
$query = KanbanBoard::select("*");
$countData = $query->count();
$data = $this->paramsMethodGet($query, $countData, $request);
if($data)
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>count($data)], 200);
return response()->json(['status'=>'failed','message'=>'failed get Board kanban, please try again later!','code'=>400], 400);
}
}

258
app/Http/Controllers/KanbanCardController.php

@ -0,0 +1,258 @@
<?php
namespace App\Http\Controllers;
use App\Models\User;
use App\Models\Project;
use App\Models\Activity;
use App\Models\KanbanCard;
use App\Models\KanbanBoard;
// use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class KanbanCardController extends Controller
{
private function add($board_id, $gantt_id, $type_activity, $status_progress)
{
$dataActivity = Activity::where("version_gantt_id", $gantt_id)
->where("type_activity", $type_activity)
->get();
foreach ($dataActivity as $keyA) {
// $this->add($keyA->id, $gantt_id, $board_id);
$data = array(
'activity_id' => $keyA->id,
'kanban_board_id' => $board_id,
'version_gantt_id' => $gantt_id,
'created_by' => $this->currentName
);
switch ($status_progress) {
case 'open':
if ($keyA->persentase_progress == 0) {
$add = KanbanCard::create($data);
}
break;
case 'on-progress':
if ($keyA->persentase_progress > 0 && $keyA->persentase_progress < 100) {
$cardIds = DB::table('kanban_card as kc')
->join('m_activity as ma', 'kc.activity_id', '=', 'ma.id')
->where('kc.activity_id', '=', $keyA->id)
->select('kc.id')
->get();
foreach ($cardIds as $cardId) {
$this->delete($cardId->id);
}
$add = KanbanCard::create($data);
}
break;
case 'done':
if ($keyA->persentase_progress == 100) {
$cardIds = DB::table('kanban_card as kc')
->join('m_activity as ma', 'kc.activity_id', '=', 'ma.id')
->where('kc.activity_id', '=', $keyA->id)
->select('kc.id')
->get();
foreach ($cardIds as $cardId) {
$this->delete($cardId->id);
}
$add = KanbanCard::create($data);
}
break;
}
}
return "success";
}
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 = KanbanCard::where("activity_id", $id);
if ($data) {
$result = $data->update($request->all());
} else {
return response()->json(['status' => 'failed', 'message' => 'Data Card kanban not found!', 'code' => 400], 400);
die();
}
$board = KanbanBoard::find($request->kanban_board_id);
$activity = Activity::find($id);
if ($board->status_progress == "done" && $activity) {
$activity->update(['persentase_progress' => 100]);
} else{
if($activity['persentase_progress'] != 95 && $activity['persentase_progress'] != 100){
$activity->update(['persentase_progress' => 0]);
}else{
$activity->update(['persentase_progress' => 95]);
}
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'Board kanban successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Board kanban failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = KanbanCard::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'Data Board kanban not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'Board kanban successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Board kanban failed deleted!', 'code' => 400], 400);
}
}
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = KanbanCard::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data Board kanban, please try again later!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'kanban_board');
$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 getData($project_id, $gantt_id, $board_id, Request $request)
{
// cek ketika dia owner dari project maka
$SESSIONID = $request->session;
$status_progress = KanbanBoard::select("status_progress")->where('id', $board_id)->first();
if ($status_progress) {
if (DB::table('user_to_version_gantt')->where('user_id', $SESSIONID)->where('version_gantt_id', $gantt_id)->exists()) {
$dataCard = $this->getDataAll($project_id, $gantt_id, $board_id, $status_progress->status_progress, true);
} else {
$dataCard = $this->getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress->status_progress, true);
}
} else {
return response()->json(['status' => 'empty', 'message' => 'data board is empty, please you insert!', 'code' => 200], 200);
}
if ($dataCard && count($dataCard) > 0){
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataCard, "totalRecord" => count($dataCard)], 200);
}else{
return response()->json(['status' => 'empty', 'message' => 'data card is empty, please you insert!', 'code' => 200], 200);
}
}
private function getDataAll($project_id, $gantt_id, $board_id, $status_progress, $status)
{
$dataFinal = [];
if($status == true){
if ($status_progress != 'none') {
if (KanbanCard::where('kanban_board_id', $board_id)->where("version_gantt_id", $gantt_id)->count() == 0) {
$this->add($board_id, $gantt_id, 'task', $status_progress);
$this->getDataAll($project_id, $gantt_id, $board_id, $status_progress, false);
}
}
}
$dataCard = DB::table("kanban_card as kc")
->select("ma.id as activity_id", "ma.name", "ma.start_date", "ma.end_date", "ma.persentase_bobot", "ma.jumlah_pekerjaan", "ma.bobot_planning", "ma.persentase_progress")
->join("m_activity as ma", "ma.id", "=", "kc.activity_id")
->where("kc.kanban_board_id", $board_id)
->where("kc.version_gantt_id", $gantt_id)
->orderBy('ma.sortorder')
->get();
foreach ($dataCard as $keyCard) {
$query = DB::table("assign_hr_to_activity as ahta")
->select("ahta.id", "mu.name", "mu.id as id_hr")
->join("m_users as mu", "mu.id", "=", "ahta.user_id")
->where("ahta.activity_id", $keyCard->activity_id)
->get();
$dataArray = array(
"id" => $keyCard->activity_id,
"assign_hr" => $query,
"activity" => $keyCard->name,
"start_date" => $keyCard->start_date,
"end_date" => $keyCard->end_date,
"jumlah_pekerjaan" => $keyCard->jumlah_pekerjaan,
"bobot_planning" => $keyCard->bobot_planning,
"persentase_progress" => $keyCard->persentase_progress
);
$dataFinal[] = $dataArray;
}
// }
return $dataFinal;
}
private function getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress, $status)
{
$dataFinal = [];
if($status == true){
if ($status_progress != 'none') {
if (KanbanCard::where('kanban_board_id', $board_id)->where("version_gantt_id", $gantt_id)->count() == 0) {
$this->add($board_id, $gantt_id, 'task', $status_progress);
$this->getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress, false);
}
}
$dataUser = User::whereId($request->session)->first();
$dataCard = DB::table("kanban_card as kc")
->select("ma.id as activity_id", "ma.name", "ma.start_date", "ma.end_date", "ma.persentase_bobot", "ma.jumlah_pekerjaan", "ma.bobot_planning", "ma.persentase_progress")
->join("m_activity as ma", "ma.id", "=", "kc.activity_id")
->where([
["kc.created_by", $dataUser['name']],
["kc.kanban_board_id", $board_id],
["kc.version_gantt_id", $gantt_id]
])
->orderBy('ma.sortorder')
->get();
foreach ($dataCard as $keyCard) {
$query = DB::table("assign_hr_to_activity as ahta")
->select("ahta.id", "mu.name", "mu.id as id_hr")
->join("m_users as mu", "mu.id", "=", "ahta.user_id")
->where("ahta.activity_id", $keyCard->activity_id)
->get();
$dataArray = array(
"id" => $keyCard->activity_id,
"assign_hr" => $query,
"activity" => $keyCard->name,
"start_date" => $keyCard->start_date,
"end_date" => $keyCard->end_date,
"jumlah_pekerjaan" => $keyCard->jumlah_pekerjaan,
"bobot_planning" => $keyCard->bobot_planning,
"persentase_progress" => $keyCard->persentase_progress,
"test" => $request->session
);
$dataFinal[] = $dataArray;
}
}
return $dataFinal;
}
}

45
app/Http/Controllers/MenuCompanyController.php

@ -9,33 +9,15 @@ use Illuminate\Support\Facades\Log;
class MenuCompanyController extends Controller
{
// public function add(Request $request)
// {
// $this->validate($request, [
// 'icon' => 'required',
// 'name' => 'string|required',
// 'url' => 'required|unique:m_company_menu,url',
// 'sequence' => 'required|integer',
// ]);
// $data = $request->all();
// $data['created_by'] = $this->currentName;
// $result = MenuCompany::create($data);
// if ($result) {
// return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200], 200);
// } else {
// return response()->json(['status' => 'failed', 'message' => 'add data menu failed!', 'code' => 400], 400);
// }
// }
public function addMultiple(Request $request)
{
$menus = $request->all();
if (is_array($menus) && count($menus) > 0) {
$data = MenuCompany::where('company_id',$menus[0]['company_id']);
if($data){
$data->delete();
}
if (is_array($menus) && count($menus) > 0 && isset($menus)) {
$countRes = 0;
foreach ($menus as $menu) {
@ -60,12 +42,17 @@ class MenuCompanyController extends Controller
}
if ($countRes > 0) {
return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200]);
return response()->json(['status' => 'success', 'message' => 'Add data menu successfully!', 'code' => 200]);
} else {
return response()->json(['status' => 'failed', 'message' => 'add data menu failed created!', 'code' => 400]);
return response()->json(['status' => 'failed', 'message' => 'Add data menu failed created!', 'code' => 500]);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'add data menu failed created!', 'code' => 400]);
if(isset($data))
{
return response()->json(['status' => 'success', 'message' => 'Add data menu successfully!', 'code' => 200]);
}else{
return response()->json(['status' => 'failed', 'message' => 'Add data menu failed created!', 'code' => 500]);
}
}
}
@ -120,15 +107,15 @@ class MenuCompanyController extends Controller
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
return response()->json(['status' => 'failed', 'message' => 'Data menu not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data menu successfully deleted!', 'code' => 200], 200);
return response()->json(['status' => 'success', 'message' => 'Data menu successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu failed deleted!', 'code' => 400], 400);
return response()->json(['status' => 'failed', 'message' => 'Data menu failed deleted!', 'code' => 400], 400);
}
}

118
app/Http/Controllers/MenuController.php

@ -23,32 +23,33 @@ class MenuController extends Controller
$result = Menu::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'add data menu successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add data menu failed!','code'=>400], 400);
if ($result) {
return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'add data menu 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);
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = Menu::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data menu, please try again later!','code'=>400], 400);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data menu, 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);
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$this->validate($request, [
'icon' => 'required',
@ -58,21 +59,21 @@ class MenuController extends Controller
]);
$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']) : '';
$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());
}else{
return response()->json(['status'=>'failed','message'=>'data menu not found!','code'=>400], 400);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'data menu successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data menu failed updated!','code'=>400], 400);
if ($result) {
return response()->json(['status' => 'success', 'message' => 'data menu successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu failed updated!', 'code' => 400], 400);
}
}
@ -80,18 +81,18 @@ class MenuController extends Controller
{
$data = Menu::find($id);
if($data){
if ($data) {
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data menu not found!','code'=>400], 400);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data menu successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data menu failed deleted!','code'=>400], 400);
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data menu successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu failed deleted!', 'code' => 400], 400);
}
}
@ -103,41 +104,52 @@ class MenuController extends Controller
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$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 listMenu($id)
{
$dataParent = RoleMenu::select("m_menu.*")
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id')
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
->whereNull('m_menu.parent_id')
->where('m_roles.id', $id)
->orderBy('m_menu.sequence', 'ASC')
->get();
$dataParent = RoleMenu::select(
'm_menu.*',
"t_roles_menu.create",
"t_roles_menu.read",
"t_roles_menu.update",
"t_roles_menu.delete"
)
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id')
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
->whereNull('m_menu.parent_id')
->where('m_roles.id', $id)
->orderBy('m_menu.sequence', 'ASC')
->get();
$finalData = [];
foreach($dataParent as $data){
foreach ($dataParent as $data) {
$data->children = $this->getChildrenMenu($data->id, $id);
$finalData[] = $data;
}
return response()->json(['status'=>'success','code'=>200,'data'=>$finalData], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $finalData], 200);
}
protected function getChildrenMenu($id, $role_id)
{
$dataChildren = RoleMenu::select("m_menu.*")
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id')
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
->where('m_roles.id', $role_id)
->where('m_menu.parent_id', $id)
->orderBy('m_menu.sequence', 'ASC')
->get();
$dataChildren = RoleMenu::select(
'm_menu.*',
"t_roles_menu.create",
"t_roles_menu.read",
"t_roles_menu.update",
"t_roles_menu.delete"
)
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id')
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
->where('m_roles.id', $role_id)
->where('m_menu.parent_id', $id)
->orderBy('m_menu.sequence', 'ASC')
->get();
$children = [];
if($dataChildren){
foreach($dataChildren as $data)
{
if ($dataChildren) {
foreach ($dataChildren as $data) {
$data->children = $this->getChildrenMenu($data->id, $role_id);
$children[] = $data;
}
@ -150,10 +162,10 @@ class MenuController extends Controller
$data = Menu::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 menu, please try again later!','code'=>400], 400);
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get list menu, please try again later!', 'code' => 400], 400);
}
}
}

92
app/Http/Controllers/ProductTransactionController.php

@ -0,0 +1,92 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProductTransaction;
class ProductTransactionController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'company_id' => 'required|integer',
'type_paket' => 'required|string',
'amount' => 'required',
'exp_ospro' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = ProductTransaction::create($data);
if ($result) {
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Add Transaction successfully!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Add Transaction 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 = ProductTransaction::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Failed get data transaction, 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 = ProductTransaction::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data transaction not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Data transaction successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Data transaction failed updated!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 't_transaction');
$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 = ProductTransaction::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 Transaction, please try again later!', 'code' => 400], 400);
}
}
}

387
app/Http/Controllers/ProjectCarausellController.php

@ -2,354 +2,73 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\{
User,
Project,
Activity,
HierarchyFtth,
ProjectComment,
VersionGantt,
UserToProyek,
UserToActivity,
Presence
ProjectIssues,
ProjectRisks
};
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Helpers\MasterFunctionsHelper;
use Carbon\Carbon;
class ProjectCarausellController extends Controller
{
// public function invoke($id)
// {
// $dateStart = Carbon::now()->startOfDay();
// $dateEnd = Carbon::now()->endOfDay();
// // Mengatur waktu awal bulan dan mengurangkan 1 tahun
// $startDate = Carbon::now()->startOfMonth()->subYear()->format('Y-m-d');
// // Mengatur waktu saat ini dan mengurangkan 1 tahun
// $endDate = Carbon::now()->subYear()->format('Y-m-d');
// if(empty($id) || !is_int((int)$id)){
// return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
// }
// $result = Project::select('id','nama','budget_health','kode_sortname','pm_id','rencana_biaya','company','scurve','calculation_status')->find($id);
// if(!$result){
// return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404);
// }
// $ganttData = VersionGantt::where('proyek_id', $id)
// ->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete')
// ->get();
// // Get Id Gantt & hierarchy_ftth_id
// $gantt_id = $ganttData->pluck('id')->toArray();
// $hierarchy_ftth_id = $ganttData->pluck('hierarchy_ftth_id')->toArray();
// // Heararchy
// $finalData = [];
// if($hierarchy_ftth_id){
// $ftth = HierarchyFtth::whereIn('id',$hierarchy_ftth_id)->get();
// if($ftth->first() != null)
// {
// array_push($finalData, $ftth->first());
// }
// if($ftth->where('parent_id','!=', null)->first()){
// $this->getParents($finalData, $ftth->pluck('parent_id')->toArray());
// }
// } else {
// return $finalData;
// }
// // SCurve
// $SCurve = MasterFunctionsHelper::getSCurveCarausell($result['id'],$gantt_id,'week');
// // Overdue Activities
// $endDate = Activity::where('proyek_id', $result['id'])
// ->orderByDesc('end_date')
// ->value('end_date');
// $overdueActivities = Activity::whereIn('version_gantt_id', $gantt_id)->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$endDate)->orderBy('end_date', 'asc')->get();
// // Project Comment
// $projectComment = ProjectComment::query()
// ->select('project_id','gantt_id','comment','created_at')
// ->where('project_id',$result['id'])
// ->whereIn('gantt_id',$gantt_id)
// ->get();
// // Manpower
// $manCount = UserToProyek::where('proyek_id', $result['id'])->count();
// // Assigned
// $utAct = UserToActivity::query()
// ->whereIn('version_gantt_id', $gantt_id)
// ->get();
// // Actual
// $presence = Presence::whereBetween('clock_in', [$dateStart, $dateEnd])
// ->select('m_users.name','m_users.ktp_number')
// ->join('m_users','t_clock_in_out.user_id','m_users.id')
// ->get();
// // Report distribution
// $reportsDistribution = DB::table('assign_material_to_activity as ama')
// ->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit',
// 'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date')
// ->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id')
// ->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id')
// ->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
// ->join('m_users as u', 'u.id', '=', 'ram.user_id')
// ->where('ama.proyek_id', '=', $result['id'])
// ->whereNotNull('ram.lat')
// ->whereBetween('ram.report_date', [$startDate, $startDate]);
// // Check Existing
// $actualStartExist = Activity::whereIn('version_gantt_id',$gantt_id)->whereNotNull('actual_start')->exists();
// $actualEndExist = Activity::whereIn('version_gantt_id',$gantt_id)->exists();
// $query = Activity::query()->whereIn('version_gantt_id', $gantt_id);
// // Start
// if ($actualStartExist) {
// $startDate = $query->select('version_gantt_id',DB::raw('MIN(start_date) as min_start'))
// ->groupBy('version_gantt_id')
// ->get();
// } else {
// $startDate = $query->select('version_gantt_id',DB::raw('MIN(start_date) as min_start','version_gantt_id'))
// ->groupBy('version_gantt_id')
// ->orderBy('min_start', 'ASC')
// ->get();
// }
// // End
// if($actualEndExist)
// {
// $maxIds = $query->selectRaw('MAX(id) as max_id')
// ->groupBy('version_gantt_id')
// ->pluck('max_id', 'version_gantt_id');
// $endDate = Activity::whereIn('id', $maxIds)->select('end_date','version_gantt_id')->get();
// }
// $plannedStart = $query->selectRaw('MIN(planned_start) as min_planned_start, version_gantt_id')
// ->groupBy('version_gantt_id')
// ->orderBy('min_planned_start')
// ->get();
// $plannedEnd = $query->selectRaw('MAX(planned_end) as max_planned_end, version_gantt_id')
// ->groupBy('version_gantt_id')
// ->orderByDesc('max_planned_end')
// ->get();
// $projectManager = User::whereId($result['pm_id'])->value('name');
// $key =1;
// foreach($ganttData as $gantt)
// {
// $pStart =$plannedStart->where('version_gantt_id',$gantt['id'])->first();
// $actStart =$startDate->where('version_gantt_id',$gantt['id'])->first();
// $actEnd =$endDate->where('version_gantt_id',$gantt['id'])->first();
// $pEnd =$plannedEnd->where('version_gantt_id',$gantt['id'])->first();
// $matchingActivities = $overdueActivities->where('version_gantt_id', $gantt['id']);
// $matchingProjectComment = $projectComment->where('version_gantt_id', $gantt['id']);
// $usAtc = $utAct->where('version_gantt_id', $gantt['id']);
// $arr[] =
// [
// 'gantt_id'=>$gantt['id'],
// 'projectManager'=>$projectManager,
// 'name_version'=>$gantt['name_version'],
// 'cost_to_complete'=>$gantt['cost_to_complete'],
// 'schedule' => [
// 'plannedStart'=> $pStart['min_planned_start'],
// 'actual_start'=>$actStart['min_start'],
// 'plannedFinish'=>$pEnd['max_planned_end'],
// 'estimatedFinish'=>$actEnd['end_date']
// ],
// 'manpower'=>$manCount,
// 'assigned'=>$usAtc->toArray(),
// 'actual'=>count($presence->toArray()),
// 'overdue_activities'=>$matchingActivities->toArray(),
// 'project_comment'=>$matchingProjectComment->toArray(),
// 'hierarchy'=>$finalData,
// 'proyek'=>$result,
// 'key'=>$key++
// ];
// }
// return response()->json(['status'=>'success','code'=> 200,'data'=>$arr,'report_distribution'=>$reportsDistribution,'sCurve'=>$SCurve, 'count'=>count($arr)], 200);
// }
// public function getParents(&$data, $id){
// $ftth = HierarchyFtth::whereIn('id',$id)->get();
// array_push($data, $ftth);
// if ($ftth->pluck('parent_id')->toArray()) {
// $this->getParents($data, $ftth->pluck('parent_id')->toArray());
// }
// }
public function invoke()
public function invoke(Request $request)
{
// Data Master
// Mengatur waktu awal bulan dan mengurangkan 1 tahun
$startDate = Carbon::now()->startOfMonth()->subYear()->format('Y-m-d');
// Mengatur waktu saat ini dan mengurangkan 1 tahun
$endDate = Carbon::now()->subYear()->format('Y-m-d');
$ganttData = VersionGantt::query()
->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete','proyek_id')
->get();
$projectData = Project::query()
->select("id","nama","kode_sortname","pm_id","budget_health","calculation_status","mulai_proyek","akhir_proyek","rencana_biaya","company","scurve")
->get();
// nested looping
$arr = [];
foreach($projectData as $project) {
$ganttForProject = [];
foreach ($ganttData as $gantt) {
if ($gantt['proyek_id'] === $project['id']) {
// Gantt
$ganttForProject[] = [
"gantt_id" => $gantt['id'],
'proyek_id' => $gantt['proyek_id'],
"name_version" => $gantt['name_version'],
"hierarchy_ftth_id" => $gantt['hierarchy_ftth_id'],
"cost_to_complete" => $gantt['cost_to_complete'],
];
// Activity
$activity = Activity::query()
->select('id','name','proyek_id','version_gantt_id','type_activity','parent_id','kode_sortname','rencana_biaya','start_date','end_date','biaya_actual','persentase_bobot','persentase_progress','planned_start','planned_end','actual_start','actual_end')
->whereNull('parent_id')
->where([
["proyek_id", $project['id']],
["version_gantt_id", $gantt['id']]
])
->first();
$actualStartExist = Activity::query()
->where('version_gantt_id', $gantt['id'])
->whereNotNull('actual_start')
->exists();
$actualEndExist = Activity::query()
->where('version_gantt_id', $gantt['id'])
->exists();
$query = Activity::where('version_gantt_id', $gantt['id']);
if ($actualStartExist) {
$startDate = $query->orderBy('actual_start')->value('start_date');
} else {
$startDate = $query->orderBy('start_date')->value('start_date');
}
if($actualEndExist)
{
$maxEndDate = $query->max('id');
$endDate = $query->where('id',$maxEndDate)->first()->end_date;
}
$plannedStart = Activity::where('version_gantt_id', $gantt['id'])
->orderBy('planned_start')
->value('planned_start');
$plannedEnd = Activity::where('version_gantt_id', $gantt['id'])
->orderByDesc('planned_end')
->value('planned_end');
// SCurve
$req = (object)[
'project_id' => $project['id'],
'gantt_id' => $gantt['id'],
'period' => 'week',
];
$SCurve = MasterFunctionsHelper::getSCurveCarausell($req);
// Overdue
$endDate = Activity::where('proyek_id', $project['id'])
->orderByDesc('end_date')
->value('end_date');
$overdueActivities = Activity::query()
->where([
['version_gantt_id', $gantt['id']],
['persentase_progress', '!=', 100]
])
->whereNotNull('parent_id')
->whereDate('end_date','<=',$endDate)
->orderBy('end_date', 'asc')
->get();
// Manpower
$manCount = UserToProyek::where('proyek_id', $project['id'])->count();
// Assigned
$assigned = UserToActivity::query()
->select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date')
->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id')
->where('assign_hr_to_activity.version_gantt_id', $gantt['id'])
->get();
// Project Comment
$projectComment = ProjectComment::query()
->select('m_users.name','m_users.username','m_project_comment.project_id','m_project_comment.gantt_id','m_project_comment.comment','m_project_comment.created_at')
->join('m_users','m_project_comment.sender_id','m_users.id')
->where([
['project_id',$project['id']],
['gantt_id',$gantt['id']]
])
->get();
// Hierarchy
$finalData = [];
$ganttHierarchy = VersionGantt::find($gantt['id']);
if ($ganttHierarchy->hierarchy_ftth_id) {
$ftth = HierarchyFtth::find($ganttHierarchy->hierarchy_ftth_id);
array_push($finalData, $ftth);
if($ftth->parent_id){
$this->getParents($finalData, $ftth->parent_id);
}
}else{
$finalData = $finalData;
}
// Master Data
$company_id = $request->route('company_id');
$all_project = $request->route('all_project');
$hierarchy = $request->route('hierarchy');
$query = Project::query()
->select("id", "nama", "kode_sortname", "pm_id", "budget_health", "calculation_status", "mulai_proyek", "akhir_proyek", "rencana_biaya", "company", "scurve");
if ($all_project) {
$query->where('company_id', $company_id);
} else {
$query->where('created_by_id', $hierarchy);
}
$reports = DB::table('assign_material_to_activity as ama')
->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit',
'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date')
->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id')
->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id')
->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
->join('m_users as u', 'u.id', '=', 'ram.user_id')
->where('ama.proyek_id', '=', $project['id'])
->whereNotNull('ram.lat')
->whereBetween('ram.report_date', [$startDate, $endDate]);
}
}
$projectData = $query->get();
$arr = [];
foreach ($projectData as $project) {
$projectRisk = ProjectRisks::query()
->select('proyek_id', 'description', 'level_risk', 'preventive_risk')
->where('proyek_id', $project['id'])
->get()
->toArray();
$projectIssue = ProjectIssues::query()
->select('proyek_id', 'description', 'level_issue')
->where('proyek_id', $project['id'])
->get()
->toArray();
$ganttData = VersionGantt::query()
->select('id', 'name_version', 'hierarchy_ftth_id', 'cost_to_complete', 'proyek_id', 'calculation_type')
->where('proyek_id', $project['id'])
->orderByDesc('id')
->first();
$projectManager = User::where('id', $project['pm_id'])->value('name');
$arr[]= [
"project"=> [
"id"=>$project['id'],
"pm_id"=>$project['pm_id'],
"nama"=>$project['nama'],
"kode_sortname"=>$project['kode_sortname'],
"budget_health"=>$project['budget_health'],
"calculation_status"=>$project['calculation_status'],
"mulai_proyek"=>$project['mulai_proyek'],
"akhir_proyek"=>$project['akhir_proyek'],
"rencana_biaya"=>$project['rencana_biaya'],
"company"=>$project['company'],
"scurve"=>$project['scurve'],
"gantt"=>$ganttForProject
],
"hierarchy"=>$finalData,
"manpower"=>$manCount,
"assigned"=>$assigned,
"actual"=>0,
"project_comment"=>$projectComment,
"project_manager"=> $projectManager,
"activity" => [
"data" => $activity,
"start_date"=>$startDate,
"end_date"=>$endDate,
"planned_start"=>$plannedStart,
"planned_end"=>$plannedEnd
$arr[] = [
"project" => [
"id" => $project['id'],
"pm_id" => $project['pm_id'],
"nama" => $project['nama'],
"kode_sortname" => $project['kode_sortname'],
"budget_health" => $project['budget_health'],
"calculation_status" => $project['calculation_status'],
"mulai_proyek" => $project['mulai_proyek'],
"akhir_proyek" => $project['akhir_proyek'],
"rencana_biaya" => $project['rencana_biaya'],
"company" => $project['company'],
"scurve" => $project['scurve'],
],
"report_distribution"=>$reports,
"overdueActivities"=>$overdueActivities,
"SCurve"=>$SCurve
"project_manager" => $projectManager,
"project_risk" => $projectRisk,
"project_issue" => $projectIssue,
"gantt" => $ganttData
];
}
return response()->json(['status'=>'success','code'=> 200,'data'=>$arr, "count"=>count($arr)], 200);
}
public function getParents(&$data, $id){
$ftth = HierarchyFtth::find($id);
array_push($data, $ftth);
if ($ftth->parent_id) {
$this->getParents($data, $ftth->parent_id);
}
return response()->json(['status' => 'success', 'code' => 200, 'data' => $arr, "total_project" => count($arr)], 200);
}
}

1033
app/Http/Controllers/ProjectController.php

File diff suppressed because it is too large Load Diff

236
app/Http/Controllers/ProjectDokumenController.php

@ -1,105 +1,131 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\DokumenProject;
class ProjectDokumenController extends Controller
{
public function dokumenByProyekId($id){
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'project id is required!','code'=>400], 400);
}
$document = DokumenProject::where("ref_id", $id)->get();
if(count($document) == 0)
return response()->json(['status'=>'','message'=>'Data not found!' ,'code'=>404], 404);
return response()->json(['status'=>'success','data'=> $document ,'code'=>200], 200);
}
public function delete($id)
{
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$document = DokumenProject::find($id);
if(!$document){
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
}
if(file_exists($this->pathDocument.$document->file)){
unlink($this->pathDocument.$document->file);
}
$document->delete();
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
}
public function uploadProjectDokumen(Request $request)
{
if($request->hasFile('dokumen')){
$document = $request->file('dokumen');
$ref_id = $request->ref_id;
$name = $document->getClientOriginalName();
$result = $document->move($this->pathDocument, $name);
if($result){
$data = [
'ref_id' => (int)$ref_id,
'file' => $name,
'type_dokumen' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document'
];
$result = DokumenProject::create($data);
if(!$result){
unlink($this->pathDocument.$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload successful!','code'=>200], 200);
}
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400);
}
public function searchDocProject(Request $request){
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'document_project');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function downloadDokumen($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
$document = DokumenProject::find($id);
if(!$document)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if(!file_exists($this->pathDocument.$document->file))
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$pathToFile = $this->pathDocument.$document->file;
$name = pathinfo($pathToFile, PATHINFO_FILENAME) . "." . pathinfo($pathToFile, PATHINFO_EXTENSION);
$headers = [
'Content-Disposition' => 'attachment; filename="'.$name.'"'
];
// dd($name, $headers);
return response()->download($pathToFile, $name, $headers);
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\{DokumenProject,Company};
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
class ProjectDokumenController extends Controller
{
public function dokumenByProyekId($id){
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'project id is required!','code'=>400], 400);
}
$document = DokumenProject::where("ref_id", $id)->get();
if(count($document) == 0)
return response()->json(['status'=>'','message'=>'Data not found!' ,'code'=>404], 404);
return response()->json(['status'=>'success','data'=> $document ,'code'=>200], 200);
}
public function delete($id, $company_id)
{
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$document = DokumenProject::find($id);
if(!$document){
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
}
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if(file_exists($destinationPath['pathDocument'].$document['file'])){
unlink($destinationPath['pathDocument'].$document['file']);
}
}
$document->delete();
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
}
public function uploadProjectDokumen(Request $request)
{
DB::beginTransaction();
$timeNow = Carbon::now();
if($request->hasFile('dokumen')){
$document = $request->file('dokumen');
$ref_id = $request->ref_id;
$originalFilename = $document->getClientOriginalName();
$extension = pathinfo($originalFilename, PATHINFO_EXTENSION);
$filename = pathinfo($originalFilename, PATHINFO_FILENAME);
$name = $filename . '_' . $timeNow->format('d-m-y-His') . '.' . $extension;
// Limited Storage
$company = Company::whereId($request->company_id)->first();
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $document, $destinationPath['pathDocument'],$destinationPath);
}
if(isset($getLimitStorage)) {
if($getLimitStorage === false) {
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500);
}
$data = [
'ref_id' => (int)$ref_id,
'file' => $name,
'type_dokumen' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document'
];
$result = DokumenProject::create($data);
if(!$document->move($destinationPath['pathDocument'], $name) && $result) {
unlink($destinationPath['pathDocument'].$name);
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'Dokumen project gagal diupload!','code'=> 500], 500);
}
DB::commit();
return response()->json(['status'=>'success','message'=>'Dokumen project berhasil diupload!','code'=>200], 200);
}
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'Dokumen project gagal diupload!','code'=> 500], 500);
}
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400);
}
public function searchDocProject(Request $request){
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'document_project');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function downloadDokumen($id, $company_id)
{
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
}
$document = DokumenProject::find($id);
$company = Company::find($company_id);
if(!$document || !$company) {
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
}
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$pathToFile = $destinationPath['pathDocument'].$document['file'];
if(!file_exists($pathToFile)) {
return response()->json(['status'=>'failed','message'=>'Directory not found!','code'=> 404], 404);
}
if($company) {
$name = pathinfo($pathToFile, PATHINFO_FILENAME) . "." . pathinfo($pathToFile, PATHINFO_EXTENSION);
}
$headers = [
'Content-Disposition' => 'attachment; filename="'.$name.'"'
];
return response()->download($pathToFile, $name, $headers);
}
}

93
app/Http/Controllers/ProjectExpenditureController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectExpenditure;
class ProjectExpenditureController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required'
]);
$data = $request->all();
// Set Unique
$result = ProjectExpenditure::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500);
die;
}
$data['created_by'] = $this->currentName;
if(!ProjectExpenditure::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectExpenditure::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectExpenditure::find($id))
return response()->json(['status'=>'failed','message'=>'data project expenditure not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'data project expenditure failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectExpenditure::find($id))
return response()->json(['status'=>'failed','message'=>'data project expenditure not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_expenditure');
$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 = ProjectExpenditure::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list project expenditure, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

93
app/Http/Controllers/ProjectFinancialHealthController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectFinancialHealth;
class ProjectFinancialHealthController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required'
]);
$data = $request->all();
// Set Unique
$result = ProjectFinancialHealth::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500);
die;
}
$data['created_by'] = $this->currentName;
if(!ProjectFinancialHealth::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectFinancialHealth::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectFinancialHealth::find($id))
return response()->json(['status'=>'failed','message'=>'data financial health not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'Data financial health failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectFinancialHealth::find($id))
return response()->json(['status'=>'failed','message'=>'data financial health not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_financial_health');
$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 = ProjectFinancialHealth::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list financial health, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

93
app/Http/Controllers/ProjectInvoiceController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectInvoice;
class ProjectInvoiceController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required'
]);
$data = $request->all();
// Set Unique
$result = ProjectInvoice::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500);
die;
}
$data['created_by'] = $this->currentName;
if(!ProjectInvoice::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectInvoice::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectInvoice::find($id))
return response()->json(['status'=>'failed','message'=>'data project invoice not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'data project invoice failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectInvoice::find($id))
return response()->json(['status'=>'failed','message'=>'data project invoice not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_invoice');
$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 = ProjectInvoice::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list project invoice, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

241
app/Http/Controllers/ProjectRoleController.php

@ -1,120 +1,121 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectRole;
class ProjectRoleController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'description' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = ProjectRole::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'add data project role successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add data project role failed!','code'=>400], 400);
}
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = ProjectRole::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 role, please try again later!','code'=>400], 400);
}
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = ProjectRole::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'data project role not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'data project role successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data project role failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = ProjectRole::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data project role not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data project role successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data project role failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_role_proyek');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = ProjectRole::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 role, please try again later!','code'=>400], 400);
}
}
public function select(Request $request){
$search = $request->query('search');
if($search && !empty($search)){
$data = ProjectRole::where("name", 'like', '%'.$search.'%')->get();
}else{
$data = ProjectRole::all();
}
return response()->json($data);
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectRole;
class ProjectRoleController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'description' => 'required',
'company_id' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = ProjectRole::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'add data project role successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add data project role failed!','code'=>400], 400);
}
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = ProjectRole::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 role, please try again later!','code'=>400], 400);
}
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = ProjectRole::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'data project role not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'data project role successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data project role failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = ProjectRole::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data project role not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data project role successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data project role failed deleted!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_role_proyek');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = ProjectRole::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 role, please try again later!','code'=>400], 400);
}
}
public function select(Request $request){
$search = $request->query('search');
if($search && !empty($search)){
$data = ProjectRole::where("name", 'like', '%'.$search.'%')->get();
}else{
$data = ProjectRole::all();
}
return response()->json($data);
}
}

93
app/Http/Controllers/ProjectScheduleHealthController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectScheduleHealth;
class ProjectScheduleHealthController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required'
]);
$data = $request->all();
// Set Unique
$result = ProjectScheduleHealth::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500);
die;
}
$data['created_by'] = $this->currentName;
if(!ProjectScheduleHealth::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectScheduleHealth::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectScheduleHealth::find($id))
return response()->json(['status'=>'failed','message'=>'data schedule health not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'data schedule health failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectScheduleHealth::find($id))
return response()->json(['status'=>'failed','message'=>'data schedule health not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_schedule_health');
$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 = ProjectScheduleHealth::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list schedule health, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

81
app/Http/Controllers/RefferalCodeController.php

@ -0,0 +1,81 @@
<?php
namespace App\Http\Controllers;
use App\Models\RefferalCode;
use Illuminate\Http\Request;
class RefferalCodeController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'code' => 'required|unique:refferal_code,code',
'exp' => 'nullable',
'type' => 'nullable',
'allocation' => 'nullable'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = RefferalCode::create($data);
if($result){
return response()->json(['status'=>'success', 'data'=> $result, 'message'=>'Add refferal code successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Add refferal Code 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 = RefferalCode::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Failed get refferal code, 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 = RefferalCode::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Refferal code not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Refferal code successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Refferal code failed updated!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'refferal_code');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
}

2
app/Http/Controllers/ReportActivityController.php

@ -6,7 +6,7 @@ use Illuminate\Http\Request;
use App\Models\ReportActivity;
use App\Models\Activity;
use App\Models\Image;
use Datatables;
use Yajra\Datatables\Datatables;
class ReportActivityController extends Controller
{

31
app/Http/Controllers/ReportActivityMaterialController.php

@ -4,10 +4,13 @@ namespace App\Http\Controllers;
use App\Helpers\MasterFunctionsHelper;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\ReportActivityMaterial;
use App\Models\Activity;
use App\Models\AssignMaterial;
use Datatables;
use App\Models\Company;
use App\Models\Image;
use Yajra\Datatables\Datatables;
use DateTime;
class ReportActivityMaterialController extends Controller
@ -64,10 +67,18 @@ class ReportActivityMaterialController extends Controller
} else {
$sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning');
$sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty');
// if actual >= plan
if ($sumReportActivityMaterial >= $sumAssignMaterial){
$persentaseProgress = 95;
}else{
// actual < plan
$persentaseProgress = $sumReportActivityMaterial/$sumAssignMaterial*100;
}
$dataUpdate = array(
"actual_start" => null,
"actual_end" => null,
"persentase_progress" => $sumReportActivityMaterial/$sumAssignMaterial*100,
"persentase_progress" => $persentaseProgress,
"updated_by" => $this->currentName
);
if ($sumReportActivityMaterial > 0) {
@ -91,10 +102,19 @@ class ReportActivityMaterialController extends Controller
}
}
public function delete($id)
public function delete($id, $company_id)
{
if(!ReportActivityMaterial::findOrFail($id)->delete())
$data = ReportActivityMaterial::findOrFail($id);
$company = Company::find($company_id);
$image = Image::where([['ref_id', $id],['category','report_activity']])->first();
if($data && $company && $image) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
unlink($destinationPath['pathImage'].$image['image']);
}
if(!$data->delete()) {
return response()->json(['status'=>'failed','message'=>'Failed to deleted the data!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=>200], 200);
}
@ -124,8 +144,10 @@ class ReportActivityMaterialController extends Controller
public function datatables(Request $request){
$id_activity = $request->query('idAct');
$id_am = $request->query('idAmi');
$type = $request->query('type');
$materialName = $request->query('materialName');
$materialId = $request->query('materialId');
if($type == 'plan'){
$activity = Activity::findOrFail($id_activity);
$baselineDuration = 0;
@ -135,6 +157,7 @@ class ReportActivityMaterialController extends Controller
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $id_activity)
->where('assign_material_to_activity.id', $id_am)
->where('m.description', $materialName)
->orderBy('assign_material_to_activity.id', 'asc')
->get();

74
app/Http/Controllers/RoleController.php

@ -11,76 +11,78 @@ class RoleController extends Controller
public function add(Request $request)
{
$this->validate($request, [
'name' => 'string|required|unique:m_roles,name',
'description' => 'required'
'name' => 'string|required|unique:m_roles,name,NULL,id,company_id,' . $request->input('company_id'),
'description' => 'required',
'company_id' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
if (!isset($data['default_page'])) {
$data['default_page'] = 29; // dashboard
}
if (!isset($data['default_page'])) {
$data['default_page'] = 29; // dashboard
}
$result = Role::create($data);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=>500], 500);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200);
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Data added!', 'code' => 200], 200);
}
public function edit( $id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
public function edit($id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Role::find($id);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
}
public function update(Request $request, $id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$this->validate($request, [
'name' => 'string|required',
'description' => 'required'
$this->validate($request, [
'name' => 'string|required',
'description' => 'required'
]);
$data = Role::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_roles,name']) : '';
$request->name !== $data['name'] ? $this->validate($request, ['name' => 'unique:m_roles,name']) : '';
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$result = $data->update($request->all());
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to update the data!','code'=>500], 500);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Failed to update the data!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data updated!','code'=>200], 200);
return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200);
}
public function delete($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = Role::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$delete = $data->delete();
if(!$delete)
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=>500], 500);
if (!$delete)
return response()->json(['status' => 'failed', 'message' => 'Failed to delete!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
}
public function search(Request $request)
@ -93,7 +95,7 @@ class RoleController extends Controller
$dataGet = $builder->get();
$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()
@ -101,9 +103,9 @@ class RoleController extends Controller
$data = Role::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'failed get list role, please try again later!', 'code' => 400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
}
}

51
app/Http/Controllers/RoleMenuController.php

@ -5,29 +5,64 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Menu;
use App\Models\RoleMenu;
use Illuminate\Support\Facades\Log;
class RoleMenuController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'role_id' => 'required',
'menu_id' => 'required',
'role_id.*' => 'required',
'menu_id.*' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = RoleMenu::create($data);
if($result){
$countData = 0;
foreach($data as $arrData) {
$arrData['created_by'] = $this->currentName;
$result = RoleMenu::create($arrData);
$countData++;
}
if($result && $countData > 0) {
return response()->json(['status'=>'success','message'=>'add data role menu successfully!','code'=>200], 200);
}else{
} else {
return response()->json(['status'=>'failed','message'=>'add data role menu failed!','code'=>400], 400);
}
}
public function addMultiple(Request $request)
{
$menus = $request->all();
if (is_array($menus) && count($menus) > 0 && isset($menus)) {
$countRes = 0;
foreach ($menus as $menu) {
$dataInsert = array(
"menu_id" => $menu['menu_id'],
"role_id" => $menu['role_id'],
);
$result = RoleMenu::create($dataInsert);
if ($result) {
$countRes++;
} else {
$countRes--;
}
}
if ($countRes > 0) {
return response()->json(['status' => 'success', 'message' => 'Add data menu role successfully!', 'code' => 200]);
} else {
return response()->json(['status' => 'failed', 'message' => 'Add data menu role failed created!', 'code' => 500]);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'Add data menu role failed created!', 'code' => 500]);
}
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id==""){

344
app/Http/Controllers/UserRegisterController.php

@ -0,0 +1,344 @@
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\{DB,Log};
use App\Models\{User, Company, HumanResource, Menu, ProductTransaction, RefferalCode, Role, RoleMenu, MenuCompany};
const URL_EMAIL = 'https://notifapp.odm-iu.com/service-mail/notif_mail.php';
class UserRegisterController extends Controller
{
public function add(Request $request)
{
DB::beginTransaction();
$this->validate($request, [
'cluster' => 'required|string',
'address' => 'required|string',
'email' => 'required|string',
'type_paket' => ($request->type_account === 'Personal' ? 'required' : 'nullable') . '|in:Basic,Free',
'phone_no' => 'required',
'type_account' => 'string|in:Personal,Company',
'company_name' => 'required|string',
'username' => 'required|string'
]);
try {
$data = $request->all();
$company_name = $data['company_name'];
$type_account = $data['type_account'];
$refferal = $request->refferal ? $data['refferal'] : null;
$cluster = $data['cluster'];
$address = $data['address'];
$phone_no = $data['phone_no'];
$email = $data['email'];
$username = $data['username'];
$type_paket = $data['type_paket'];
$company_address = $request->type_account === 'Company' ? $data['companyAddress'] : '';
$full_name = $request->type_account === 'Personal' ? $data['full_name'] : '';
// check email & username already exist
$emailExists = Company::where('email', $email)->exists() || User::where('email', $email)->exists();
if ($emailExists) {
return response()->json(['status' => 'failed', 'message' => 'Email already exists, please check again!', 'code' => 500], 500);
}
$usernameExists = User::where('username', $username)->exists();
if ($usernameExists) {
return response()->json(['status' => 'failed', 'message' => 'Username already exists, please check again!', 'code' => 500], 500);
}
// Get last registration number
$getCompany = $this->getCompany();
$formDataCompany = array(
'company_name' => $company_name,
'newRegistrationNumber' => $getCompany['newRegistrationNumber'],
'cluster' => $cluster,
'phone_no' => $phone_no,
'email' => $email,
'address' => $address,
'type_account' => $type_account,
'username' => $username,
'type_paket' => $type_paket,
'companyAddress' => $company_address,
'full_name' => $full_name
);
if(empty($refferal)) {
$addCompany = $this->addCompany($formDataCompany, null);
} else {
$getRefferal = $this->getRefferalCode($refferal);
if(empty($getRefferal)) {
return response()->json(['status' => 'failed', 'message' => 'Refferal code not found!', 'code' => 404], 404);
}
$addCompany = $this->addCompany($formDataCompany, (int)$getRefferal['id']);
}
if(empty($addCompany)) {
return;
}
$addRole = $this->addRole((int)$addCompany['id']);
if(empty($addRole)) {
return;
}
$addHR = $this->addHR((int)$addCompany['id'], (int)$addRole['id'], $formDataCompany);
if(empty($addHR)) {
return;
}
$getMenu = $this->getMenu();
if(empty($getMenu)) {
return;
}
$this->addTransaction((int)$addCompany['id'], $formDataCompany);
$addMenuCompany = $this->addMenuCompany($getMenu, (int)$addCompany['id']);
if(empty($addMenuCompany)) {
return;
}
$addMenuRole = $this->addMenuRole($getMenu, (int)$addRole['id']);
if(empty($addMenuRole)) {
return;
}
DB::commit();
return response()->json(['status' => 'success', 'message' => 'Register is successful, please check your email!', 'generateRandom' => $addHR['generateRandom'], 'code' => 200], 200);
} catch (\Throwable $th) {
DB::rollBack();
Log::channel('daily')->error($th->getMessage());
return response()->json(['status' => 'failed', 'message' => 'Failed to register, please check again!', 'code' => 500], 500);
}
}
protected function getRefferalCode($refferal)
{
$result = RefferalCode::query()
->select('id','code','amount','exp','type','allocation','description')
->where('code', $refferal)
->first();
return $result;
}
protected function addCompany($formData, $id_refferal)
{
$formData = array(
'company_name' => $formData['company_name'],
'registration_no' => $formData['newRegistrationNumber'],
'cluster' => $formData['cluster'],
'date_register' => Carbon::now(),
'template_id' => 1,
'email' => $formData['email'],
'address' => $formData['type_account'] === 'Company' ? $formData['companyAddress'] : $formData['address'],
'phone_no' => $formData['phone_no'],
'type_account' => $formData['type_account'],
'is_active' => true,
'discount_id' => $id_refferal === null ? null : $id_refferal
);
$result = Company::create($formData);
return $result;
}
protected function addRole($id_company)
{
$formData = [
'name' => 'Admin',
'company_id' => $id_company,
'description' => '-'
];
$result = Role::create($formData);
return $result;
}
protected function addHR($id_company, $id_role, $data)
{
$generateRandom = Str::random(8);
$formData = array(
'name'=> $data['type_account'] === 'Company' ? $data['username'] : $data['full_name'],
'phone_number'=> $data['phone_no'],
'email'=> $data['email'],
'username' => $data['username'],
'password'=> md5($generateRandom),
'role_id'=> $id_role,
'ktp_number'=> $data['type_account'] === 'Company' ? 'CP-'. $generateRandom : 'PR-' . $generateRandom,
'employee_type'=> 'employee',
'address' => $data['address'],
'status_resource'=> 'active',
'company_id'=> $id_company
);
$result = HumanResource::create($formData);
if(!empty($result)) {
$this->sendEmail($data['email'], $generateRandom);
}
return [
'result' => $result,
'generateRandom' => $generateRandom
];
}
protected function addMenuCompany($baseDataMenu, $id_company)
{
$data = MenuCompany::where('company_id', $id_company);
if($data->exists()){
$data->delete();
}
if (is_object($baseDataMenu) && count($baseDataMenu) > 0 && isset($baseDataMenu)) {
$countRes = 0;
foreach ($baseDataMenu as $menu) {
$dataInsert = array(
"menu_id" => $menu['id'],
"parent_menu_id" => $menu['parent_id'],
"company_id" => $id_company,
"icon" => $menu['icon'],
"alias_name" => $menu['alias_name'],
"url" => $menu['url'],
"sequence" => $menu['sequence'],
"created_by" => $this->currentName
);
$result = MenuCompany::create($dataInsert);
if ($result) {
$countRes++;
} else {
$countRes--;
}
}
if ($countRes > 0) {
return $result;
} else {
die();
}
} else {
die();
}
}
protected function addMenuRole($baseDataMenu, $id_role)
{
if (is_object($baseDataMenu) && count($baseDataMenu) > 0 && isset($baseDataMenu)) {
$countRes = 0;
foreach ($baseDataMenu as $menu) {
$dataInsert = array(
"menu_id" => $menu['id'],
"role_id" => $id_role,
);
$result = RoleMenu::create($dataInsert);
if ($result) {
$countRes++;
} else {
$countRes--;
}
}
if ($countRes > 0) {
return $result;
} else {
die();
}
} else {
die();
}
}
protected function addTransaction($id_company, $data)
{
$currentDate = Carbon::now();
$finalDate = $currentDate->copy()->addDays(30);
if(is_array($data)) {
$formData = array(
'company_id' => $id_company,
'type_paket' => $data['type_paket'],
'exp_ospro' => $finalDate,
'amount' => $data['type_paket'] === 'Free' ? 0 : 250000
);
$result = ProductTransaction::create($formData);
return $result;
}
}
protected function getMenu()
{
$result = Menu::query()
->select("id", "name", "parent_id", "alias_name", "icon", "url", "sequence")
->whereNotIn('alias_name', ['Dashboard Customer', 'Registration Management', 'Demo Management'])
->get();
return $result;
}
protected function getCompany()
{
$newRegistrationNumber = '';
$company = Company::query()
->select('id','type_account','registration_no','discount_id')
->orderByDesc('id')
->first();
if(!empty($company)) {
$lastRegistrationNumber = $company['registration_no'];
$lastNumber = (int)preg_replace('/\D/', '', $lastRegistrationNumber);
$newNumber = $lastNumber + 1;
$newRegistrationNumber = 'RG-'. $newNumber;
} else{
return false;
}
return [
'newRegistrationNumber' => $newRegistrationNumber
];
}
public function sendEmail($email, $password)
{
$user = User::select('email', 'name', 'username')->where('email', $email)->first();
if (!$user) {
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400);
} else {
$this->reqHttpCurl($email, $password, $user->username, $user->name);
return response()->json(['status' => 'error', 'code'=>400, 'message' => 'e-mail not found '], 400);
}
}
private function reqHttpCurl($email, $password, $username, $name)
{
$postData = [
"to" => $email,
"name" => $name,
"username" => $username,
"password" => $password,
"from" => "app.integrasia@integrasiautama.com",
"alias_from" => "OSPRO",
"subject" => "Registration OSPRO",
"body" => "registration-ospro"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => URL_EMAIL,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
// Set here requred headers
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
print_r(json_decode($response));
}
}
}

235
app/Http/Controllers/UserToActivityController.php

@ -7,11 +7,12 @@ use App\Models\UserToActivity;
use App\Models\Activity;
use App\Models\AssignMaterial;
use Illuminate\Support\Facades\DB;
use Datatables;
use Yajra\Datatables\Datatables;
class UserToActivityController extends Controller
{
public function add(Request $request){
public function add(Request $request)
{
$this->validate($request, [
'activity_id' => 'required',
'user_id' => 'required'
@ -20,24 +21,25 @@ class UserToActivityController extends Controller
$data = $request->all();
$data['created_by'] = $this->currentName;
if(!UserToActivity::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500]);
if (!UserToActivity::create($data))
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500]);
return response()->json(['status'=>'success','message'=>'Data added!', 'code'=> 200]);
return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200]);
}
public function addMultiple(Request $request){
public function addMultiple(Request $request)
{
$users_id = $request->user_id;
$users_role = $request->role_proyek_id;
$users_role = $request->role_proyek_id;
// $data = UserToActivity::where("activity_id", $request->activity_id);
// if($data){
// $data->delete();
// }
if(is_array($users_id) && count($users_id) > 0){
if (is_array($users_id) && count($users_id) > 0) {
$countRes = 0;
foreach($users_id as $index => $item){
foreach ($users_id as $index => $item) {
$dataInsert = array(
"user_id" => $item,
"activity_id" => $request->activity_id,
@ -45,89 +47,91 @@ class UserToActivityController extends Controller
"proyek_id" => $request->proyek_id,
"start_date" => $request->start_date,
"end_date" => $request->end_date,
"created_by" => $this->currentName,
"version_gantt_id" => $request->version_gantt_id
"created_by" => $this->currentName,
"version_gantt_id" => $request->version_gantt_id
);
$result = UserToActivity::create($dataInsert);
if($result){
if ($result) {
$countRes++;
}else{
} else {
$countRes--;
}
}
if($countRes == 0)
return response()->json(['status'=>'failed' ,'message'=>'Failed to add data!','code'=> 500]);
if ($countRes == 0)
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500]);
$allCost = $this->calculateAllCost($request->activity_id, $request->proyek_id);
$dataUpdateCost = array(
"rencana_biaya"=>$allCost,
"updated_by"=> $this->currentName
"rencana_biaya" => $allCost,
"updated_by" => $this->currentName
);
$actUpdate = Activity::find($request->activity_id);
if($actUpdate){
if ($actUpdate) {
$actUpdate->update($dataUpdateCost);
if($actUpdate->parent_id){
if ($actUpdate->parent_id) {
$this->updatedCostPlanning($actUpdate->parent_id);
}
}
return response()->json(['status'=>'success' ,'message'=>'Data added!','code'=>200]);
}else{
return response()->json(['status'=>'success' ,'message'=>'Data added!','code'=>200]);
return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200]);
} else {
return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200]);
}
}
private function updatedCostPlanning($parent_id) {
private function updatedCostPlanning($parent_id)
{
$sumBiaya = Activity::selectRaw('sum(cast(rencana_biaya as double precision))')
->where("parent_id", $parent_id)
->first();
if($parent = Activity::find($parent_id)){
if ($parent = Activity::find($parent_id)) {
$parent->update([
"rencana_biaya" => $sumBiaya->sum,
]);
}
}
}
public function update(Request $request, $id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
public function update(Request $request, $id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = UserToActivity::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
if(!$data->update($request->all()));
return response()->json(['status'=>'failed','message'=>'Failed to update!','code'=> 500], 500);
if (!$data->update($request->all()));
return response()->json(['status' => 'failed', 'message' => 'Failed to update!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data updated!','code'=>200], 200);
return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200);
}
public function delete($id)
{
$data = UserToActivity::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'data user to activity gantt Project not found!', 'code' => 400], 400);
if($data->delete()){
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
if ($data->delete()) {
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
}
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=> 500], 500);
return response()->json(['status' => 'failed', 'message' => 'Failed to delete!', 'code' => 500], 500);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = UserToActivity::find($id);
if(!$result)
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'failed get data tools resource, please try again later!', 'code' => 400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
}
public function searchAnalysis(Request $request)
@ -135,14 +139,22 @@ class UserToActivityController extends Controller
$dataBuilder = $this->setUpPayload($request->all(), 'assign_hr_to_activity');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$builder->addSelect(DB::raw('SUM(report_activity_material.qty) as volume_actual'));
$builder->groupBy("m_activity.id");
$builder->groupBy("selfTable.id");
$builder->groupBy("selfTable.start_date");
$builder->groupBy("selfTable.end_date");
$builder->groupBy("m_users.name");
$builder->addSelect(DB::raw('SUM(report_activity_material.qty) as volume_actual'));
$builder->groupBy("m_activity.name");
$builder->groupBy("m_activity.persentase_progress");
$builder->groupBy("m_activity.actual_start");
$builder->groupBy("m_activity.actual_end");
$builder->groupBy("m_activity.planned_start");
$builder->groupBy("m_activity.planned_end");
$builder->groupBy("m_activity.start_date");
$builder->groupBy("m_activity.end_date");
$builder->groupBy("m_activity.duration");
$builder->groupBy("selfTable.id");
$builder->groupBy("selfTable.start_date");
$builder->groupBy("selfTable.end_date");
$builder->groupBy("assign_material_to_activity.qty_planning");
$builder->groupBy("assign_material_to_activity.id");
$builder->groupBy("m_version_gantt.name_version");
$builder->groupBy("m_version_gantt.name_version");
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
@ -158,14 +170,14 @@ class UserToActivityController extends Controller
$dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity');
$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) {
$builder->where(function ($query) use ($startDate, $endDate) {
$query
->where('m_proyek.mulai_proyek', '>=', $startDate)
->where('m_proyek.akhir_proyek', '<=', $endDate)
@ -187,8 +199,46 @@ class UserToActivityController extends Controller
}
$dataGet = $filteredData;
}
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
// $totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => count($dataGet)], 200);
}
public function activityUser(Request $request)
{
$payload = $request->all();
$activity = DB::table('m_activity as ma')
->select(
'ahta.id',
'ma.id as activity_id',
'ma.proyek_id',
'ma.name as join_second_name',
'ma.start_date as join_second_start_date',
'ma.end_date as join_second_end_date',
'ma.persentase_progress',
'mvg.name_version',
'mp.nama as nama_proyek',
'mp.type_proyek_id'
)
->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'ma.id')
->join('m_version_gantt as mvg', 'mvg.id', '=', 'ma.version_gantt_id')
->join('m_proyek as mp', 'mp.id', '=', 'ma.proyek_id')
->where('ahta.user_id', $payload['user_id'])
->where('ma.start_date', '<=', $payload['end_date'])
->where('ma.end_date', '>=', $payload['start_date'])
->where('ma.proyek_id', $payload['proyek_id'])
->get();
if ($payload['status'] != "") {
$filteredData = [];
foreach ($activity as $value) {
$assignMaterial = AssignMaterial::where('activity_id', $value->activity_id)->first();
if ($assignMaterial->status_activity == $payload['status']) {
$filteredData[] = $value;
}
}
$activity = $filteredData;
}
return response()->json(['status' => 'success', 'code' => 200, 'data' => $activity, 'totalRecord' => count($activity)], 200);
}
public function list()
@ -196,46 +246,47 @@ class UserToActivityController extends Controller
$data = UserToActivity::all();
$countData = $data->count();
if($data){
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list user to activity gantt, please try again later!','code'=>400], 400);
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get list user to activity gantt, please try again later!', 'code' => 400], 400);
}
}
}
public function listFiltered(Request $request)
public function listFiltered(Request $request)
{
$startDate = $request->start_date;
$endDate = $request->end_date;
$userId = $request->user_id;
$proyekId = $request->proyek_id;
if (isset($proyekId)) {
$data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date')
->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id')
->where('m_activity.start_date', '=', $startDate)
->where('m_activity.end_date', '=', $endDate)
->where('assign_hr_to_activity.user_id', '=', $userId)
->where('assign_hr_to_activity.proyek_id', '=', $proyekId)
->get();
}else {
$data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date')
->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id')
->where('m_activity.start_date', '=', $startDate)
->where('m_activity.end_date', '=', $endDate)
->where('assign_hr_to_activity.user_id', '=', $userId)
->get();
}
$countData = $data->count();
if($data){
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get list user to activity gantt, please try again later!','code'=>400], 400);
$startDate = $request->start_date;
$endDate = $request->end_date;
$userId = $request->user_id;
$proyekId = $request->proyek_id;
if (isset($proyekId)) {
$data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date')
->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id')
->where('m_activity.start_date', '=', $startDate)
->where('m_activity.end_date', '=', $endDate)
->where('assign_hr_to_activity.user_id', '=', $userId)
->where('assign_hr_to_activity.proyek_id', '=', $proyekId)
->get();
} else {
$data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date')
->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id')
->where('m_activity.start_date', '=', $startDate)
->where('m_activity.end_date', '=', $endDate)
->where('assign_hr_to_activity.user_id', '=', $userId)
->get();
}
$countData = $data->count();
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get list user to activity gantt, please try again later!', 'code' => 400], 400);
}
}
public function datatables(Request $request){
public function datatables(Request $request)
{
$id_activity = $request->query('idact');
$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")
@ -244,8 +295,8 @@ class UserToActivityController extends Controller
->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-hr-delete"><i class="fa fa-trash"></i></a>';
->addColumn('action', function ($row) {
$actionBtn = '<a href="javascript:void(0)" data-id="' . $row->id . '" class="delete btn btn-danger btn-sm btn-hr-delete"><i class="fa fa-trash"></i></a>';
return $actionBtn;
})
->rawColumns(['action'])->make(true);

38
app/Http/Controllers/UserToProyekController.php

@ -2,11 +2,12 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Image;
use App\Models\Company;
use App\Models\UserToProyek;
use App\Models\UserToActivity;
use Illuminate\Http\Request;
use App\Models\ReportActivity;
use App\Models\Image;
use App\Models\UserToActivity;
class UserToProyekController extends Controller
{
@ -51,7 +52,8 @@ class UserToProyekController extends Controller
"user_id" => $item,
"proyek_id" => $request->proyek_id,
"created_by" => $this->currentName,
'is_customer' => true
'is_customer' => true,
'project_role' => $request->project_role
);
$result = UserToProyek::create($dataInsert);
@ -65,10 +67,10 @@ class UserToProyekController extends Controller
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]);
return response()->json(['status' => 'failed', 'message' => 'Project customer failed created', 'code' => 400]);
}
} else {
return response()->json(['status' => 'success', 'message' => 'Project customer successfull created', 'code' => 200]);
return response()->json(['status' => 'failed', 'message' => 'Project customer failed created', 'code' => 200]);
}
}
@ -111,7 +113,7 @@ class UserToProyekController extends Controller
}
}
public function delete($id)
public function delete($id, $company_id)
{
$data = UserToProyek::find($id);
if ($data) {
@ -119,7 +121,7 @@ class UserToProyekController extends Controller
$proyekId = $data->proyek_id;
$delete = $data->delete();
if ($delete) {
$this->deleteRelative($proyekId, $userId);
$this->deleteRelative($proyekId, $userId, $company_id);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'data assign hr to proyek not found!', 'code' => 400], 400);
@ -134,21 +136,25 @@ class UserToProyekController extends Controller
}
}
private function deleteRelative($proyekId, $userId)
private function deleteRelative($proyekId, $userId, $company_id)
{
$uta = UserToActivity::where("proyek_id", $proyekId)->where("user_id", $userId)->get();
foreach ($uta as $value) {
$dataRa = ReportActivity::where("activity_id", $value->activity_id)->where("user_id", $value->user_id)->get();
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if (file_exists($this->pathImage . $image->image)) {
unlink($this->pathImage . $image->image);
$company = Company::find($company_id);
if ($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if (file_exists($destinationPath['pathImage'] . $image->image)) {
unlink($destinationPath['pathImage'] . $image->image);
}
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
ReportActivity::where("activity_id", $value->activity_id)->where("user_id", $value->user_id)->delete();
}
ReportActivity::where("activity_id", $value->activity_id)->where("user_id", $value->user_id)->delete();
}
UserToActivity::where("proyek_id", $proyekId)->where("user_id", $userId)->delete();
}

96
app/Http/Controllers/VersionGanttController.php

@ -14,7 +14,8 @@ use App\Models\ActivityProgressLog;
class VersionGanttController extends Controller
{
public function add(Request $request){
public function add(Request $request)
{
$this->validate($request, [
'name_version' => 'required',
'proyek_id' => 'required'
@ -23,30 +24,31 @@ class VersionGanttController extends Controller
$data['created_by'] = $this->currentName;
$result = VersionGantt::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'version gantt Project successfull created','code'=>200]);
}else{
return response()->json(['status'=>'failed','message'=>'version gantt Project failed created','code'=>400]);
if ($result) {
return response()->json(['status' => 'success', 'message' => 'version gantt Project successfull created', 'code' => 200, 'id' => $result->id]);
} else {
return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed created', 'code' => 400]);
}
}
public function update(Request $request, $id){
public function update(Request $request, $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);
}
$data = VersionGantt::find($id);
if($data){
if ($data) {
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400);
} else {
return response()->json(['status' => 'failed', 'message' => 'data version gantt Project not found!', 'code' => 400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'version gantt Project successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'version gantt Project failed updated!','code'=>400], 400);
if ($result) {
return response()->json(['status' => 'success', 'message' => 'version gantt Project successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed updated!', 'code' => 400], 400);
}
}
@ -54,19 +56,19 @@ class VersionGanttController extends Controller
{
$data = VersionGantt::find($id);
if($data){
if ($data) {
$delete = $data->delete();
$this->deleteRelative($data['id']);
}else{
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400);
} else {
return response()->json(['status' => 'failed', 'message' => 'data version gantt Project not found!', 'code' => 400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'version gantt Project successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'version gantt Project failed deleted!','code'=>400], 400);
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'version gantt Project successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed deleted!', 'code' => 400], 400);
}
}
@ -81,18 +83,19 @@ class VersionGanttController extends Controller
ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete();
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','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 = VersionGantt::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data version gantt, please try again later!','code'=>400], 400);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data version gantt, please try again later!', 'code' => 400], 400);
}
}
@ -106,23 +109,22 @@ class VersionGanttController extends Controller
$dataGet = $builder->get();
// $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
}
public function ganttProgress($column, $value){
$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')
->where("m_version_gantt.".$column, $value)
// ->where('m_activity.type_activity', "project")
->where('m_activity.parent_id', null)
->get();
foreach($progress as $item) {
if($item->persentase_progress){
$item->progress = $item->persentase_progress;
$item->bobot = $item->bobot_planning;
$item->save();
public function ganttProgress($column, $value)
{
$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')
->where("m_version_gantt." . $column, $value)
// ->where('m_activity.type_activity', "project")
->where('m_activity.parent_id', null)
->get();
foreach ($progress as $item) {
$item->progress = $item->persentase_progress;
$item->bobot = $item->bobot_planning;
$item->save();
}
}
}
public function list()
@ -130,10 +132,10 @@ class VersionGanttController extends Controller
$data = VersionGantt::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 version gantt, please try again later!','code'=>400], 400);
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get list version gantt, please try again later!', 'code' => 400], 400);
}
}
}

2
app/Models/Absent.php

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

89
app/Models/Activity.php

@ -33,6 +33,9 @@ class Activity extends Model
'jobs_done', 'assign_hr', 'assign_material', 'assign_tools', 'assign_expense'
];
protected $casts = [
'rencana_biaya' => 'double'
];
public function getStartDateAttribute($value)
{
@ -61,58 +64,60 @@ class Activity extends Model
public static function boot() {
parent::boot();
static::updating(function($data) {
$data->logPersentaseProgress();
});
static::updated(function($data) {
$data->updateBobot();
$data->updateCostPlanning();
if($data->bobot_planning){
$data->updatePersentaseProgress();
}
$data->updateCostActual();
// if($data->start_date != request()->start_date || $data->end_date != request()->end_date) {
// $data->updateStartEndDateHeader();
// }
});
static::deleted(function($data) {
if (isset($data->parent_id)) {
if(Activity::where("parent_id", $data->parent_id)->count() == 0) {
$activity = Activity::find($data->parent_id);
if ($activity) {
$activity->update(["type_activity"=>"task"]);
}
}
}
$data->updateBobot(true);
$data->updateCostPlanning();
if($data->bobot_planning){
$data->updatePersentaseProgress();
}
$data->updateCostActual();
$data->updateStartEndDateHeader();
});
DB::transaction(function() {
static::updating(function($data) {
$data->logPersentaseProgress();
});
static::updated(function($data) {
$data->updateBobot();
$data->updateCostPlanning();
if($data->bobot_planning){
$data->updatePersentaseProgress();
}
$data->updateCostActual();
// if($data->start_date != request()->start_date || $data->end_date != request()->end_date) {
// $data->updateStartEndDateHeader();
// }
});
static::deleted(function($data) {
if (isset($data->parent_id)) {
if(Activity::where("parent_id", $data->parent_id)->count() == 0) {
$activity = Activity::find($data->parent_id);
if ($activity) {
$activity->update(["type_activity"=>"task"]);
}
}
}
$data->updateBobot(true);
$data->updateCostPlanning();
if($data->bobot_planning){
$data->updatePersentaseProgress();
}
$data->updateCostActual();
$data->updateStartEndDateHeader();
});
},5);
}
private function updateBobot($isDelete = false)
{
$root = Activity::where('version_gantt_id', $this->version_gantt_id)
->where("proyek_id", $this->proyek_id)
->whereNull('parent_id')
$root = Activity::where([
['version_gantt_id', $this->version_gantt_id],
['proyek_id', $this->proyek_id]
])
->whereNull('parent_id')
->first();
if(isset($root) && $root->rencana_biaya > 0){
$activities = Activity::where("proyek_id", $this->proyek_id)->where("version_gantt_id", $this->version_gantt_id)->get();
if(isset($root) && doubleval($root->rencana_biaya) > 0){
$activities = Activity::where([['proyek_id', $this->proyek_id],['version_gantt_id', $this->version_gantt_id]])->get();
foreach ($activities as $activity) {
if($isDelete && $activity->id == $this->id)
continue;
$activity->bobot_planning = ( (int)$activity->rencana_biaya / $root->rencana_biaya) * 100;
$activity->bobot_planning = ( doubleval($activity->rencana_biaya) / doubleval($root->rencana_biaya)) * 100;
$activity->updated_by = auth()->user() ? auth()->user()->name : "system";
$activity->saveQuietly();

37
app/Models/AssignMaterial.php

@ -3,10 +3,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\RequestMaterial;
use App\Models\Activity;
use App\Models\ReportActivityMaterial;
use App\Models\{Activity,RequestMaterial,ReportActivityMaterial};
use Illuminate\Support\Facades\DB;
class AssignMaterial extends Model
{
protected $table = 'assign_material_to_activity';
@ -23,24 +21,25 @@ class AssignMaterial extends Model
protected $casts = [
'id' => 'integer',
'budget' => 'string',
'qty_planning' => 'float'
];
public static function boot() {
parent::boot();
static::created(function($data) {
$activity = Activity::find($data->activity_id);
$material = RequestMaterial::where("id", $data->material_id)->first();
$activity->rencana_biaya += floatval($material->price) * floatval($data->qty_planning);
$activity->save();
});
static::deleted(function($data) {
$reportActivities = ReportActivityMaterial::where('assign_material_id', $data->id)->delete();
$activity = Activity::where('id', $data->activity_id)->first();
$activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning);
$activity->save();
});
DB::transaction(function () {
static::created(function($data) {
$activity = Activity::find((int)$data->activity_id);
$material = RequestMaterial::find((int)$data->material_id);
$activity->rencana_biaya += (doubleval($material->price) * doubleval($data->qty_planning));
$activity->save();
});
static::deleted(function($data) {
ReportActivityMaterial::where('assign_material_id', $data->id)->delete();
$activity = Activity::find($data->activity_id);
$activity->rencana_biaya -= (doubleval($data->budget) * doubleval($data->qty_planning));
$activity->save();
});
}, 5);
}
}

2
app/Models/Broadcast.php

@ -12,6 +12,6 @@ class Broadcast extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'title_notif', 'message_notif', 'description', 'send_to_type', 'send_to_id', 'status_send', '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', 'company_id'
];
}

13
app/Models/ChecklistK3.php

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

5
app/Models/Company.php

@ -32,6 +32,9 @@ class Company extends Model
'created_by',
'updated_at',
'updated_by',
'company_id'
'cluster',
'type_account',
'date_register',
'discount_id'
];
}

27
app/Models/ContactSales.php

@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ContactSales extends Model
{
protected $table = 'm_contact_sales';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name',
'company_name',
'email',
'role',
'number_phone',
'status',
'message',
'created_at',
'created_by',
'updated_at',
'updated_by',
];
}

26
app/Models/Demo.php

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Demo extends Model
{
protected $table = 'm_demo';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name',
'email',
'role',
'number_phone',
'status',
'message',
'created_at',
'created_by',
'updated_at',
'updated_by',
];
}

4
app/Models/HumanResource.php

@ -14,6 +14,7 @@ class HumanResource extends Model
protected $fillable = [
'role_id',
'username',
'discount_id',
'password',
'session_login',
'name',
@ -26,6 +27,7 @@ class HumanResource extends Model
'birth_date',
'blood_type',
'ktp_number',
'company_id',
'employee_type',
'status_resource',
'created_at',
@ -34,6 +36,6 @@ class HumanResource extends Model
'updated_by',
'divisi_id',
'status_boundary',
'company_id'
'is_customer'
];
}

17
app/Models/KanbanBoard.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class KanbanBoard extends Model
{
protected $table = 'kanban_board';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name_board', 'header_color', 'body_color', 'status_progress', 'proyek_id', 'version_gantt_id', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
}

17
app/Models/KanbanCard.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class KanbanCard extends Model
{
protected $table = 'kanban_card';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'activity_id', 'kanban_board_id', 'version_gantt_id', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
}

4
app/Models/PanicButton.php

@ -12,6 +12,6 @@ class PanicButton extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'user_id', 'lat', 'lon', 'status_response', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
'user_id', 'lat', 'lon', 'status_response', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

6
app/Models/Presence.php

@ -13,9 +13,9 @@ class Presence extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'user_id', 'clock_in', 'clock_out', 'date_presence',
'user_id', 'clock_in', 'clock_out', 'date_presence',
'clock_in_lat', 'clock_in_lng', 'clock_out_lat', 'clock_out_lng',
'clock_in_loc', 'clock_out_loc','clock_in_boundary', 'clock_out_boundary',
'created_at', 'created_by', 'updated_at', 'updated_by'
'clock_in_loc', 'clock_out_loc', 'clock_in_boundary', 'clock_out_boundary',
'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

25
app/Models/ProductTransaction.php

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProductTransaction extends Model
{
protected $table = 't_transaction';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'company_id',
'type_paket',
'amount',
'exp_ospro',
'pay_date',
'created_at',
'updated_at',
'created_by',
'updated_by'
];
}

8
app/Models/Project.php

@ -15,6 +15,7 @@ class Project extends Model
'kode_sortname',
'jumlah_stakeholder',
'nama',
'nickname',
'mulai_proyek',
'akhir_proyek',
'area_kerja',
@ -23,8 +24,10 @@ class Project extends Model
'biaya_actual',
'company',
'pm_id',
'scoupe_of_work',
'type_proyek_id',
'divisi_id',
'value_proyek',
'persentase_progress',
'keterangan',
'durasi_proyek',
@ -48,6 +51,9 @@ class Project extends Model
'created_by',
'updated_at',
'updated_by',
'created_by_id'
'created_by_id',
'company_id',
'deleted_at',
'deleted_by_id'
];
}

17
app/Models/ProjectExpenditure.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectExpenditure extends Model
{
protected $table = 'm_proyek_expenditure';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

17
app/Models/ProjectFinancialHealth.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectFinancialHealth extends Model
{
protected $table = 'm_proyek_financial_health';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

17
app/Models/ProjectInvoice.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectInvoice extends Model
{
protected $table = 'm_proyek_invoice';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

34
app/Models/ProjectRole.php

@ -1,17 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectRole extends Model
{
protected $table = 'm_role_proyek';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectRole extends Model
{
protected $table = 'm_role_proyek';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'company_id', 'updated_by'
];
}

17
app/Models/ProjectScheduleHealth.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectScheduleHealth extends Model
{
protected $table = 'm_proyek_schedule_health';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

34
app/Models/ProjectType.php

@ -1,17 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectType extends Model
{
protected $table = 'm_type_proyek';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectType extends Model
{
protected $table = 'm_type_proyek';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', 'is_multiLocation'
];
}

28
app/Models/RefferalCode.php

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class RefferalCode extends Model
{
protected $table = 'refferal_code';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'code',
'amount',
'exp',
'type',
'allocation',
'description',
'created_at',
'created_by',
'updated_at',
'updated_by',
'deleted_at',
'deleted_by'
];
}

11
app/Models/ReportK3.php

@ -12,14 +12,15 @@ class ReportK3 extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'user_id',
'user_id',
'description',
'proyek_id',
'report_date',
'description',
'created_at',
'created_by',
'updated_at',
'updated_by'
'created_at',
'created_by',
'updated_at',
'updated_by',
'company_id'
];
}

2
app/Models/Role.php

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

2
app/Models/RoleMenu.php

@ -12,6 +12,6 @@ class RoleMenu extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', "create", "read", "update", "delete"
'role_id', 'menu_id', 'create', 'read', 'update', 'delete', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
}

34
app/Models/Satuan.php

@ -1,17 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Satuan extends Model
{
protected $table = 'm_satuan';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Satuan extends Model
{
protected $table = 'm_satuan';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

401
app/Models/User.php

@ -1,203 +1,198 @@
<?php
namespace App\Models;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable;
use Carbon\Carbon;
class User extends Model implements AuthenticatableContract, AuthorizableContract,JWTSubject
{
use Authenticatable, Authorizable, HasFactory;
protected $table = 'm_users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'role_id', 'username', 'session_login', 'phone_number', 'email', 'address',
'fcm_token', 'gender', 'birth_place', 'birth_date', 'blood_type', 'ktp_number', 'working_hours',
'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource'
];
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
const DEFAULT_TZ = 'Asia/Jakarta';
const INSIDE = "INSIDE";
const OUTSIDE = "OUTSIDE";
const HOLIDAY = "HOLIDAY";
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password',
];
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
/**
* Get working hours for given timestamp
*
* @return array of carbon or NULL in case HOLIDAY
*/
public function getWorkingTime(Carbon $ts, $f = "08:00", $t = "17:00", $tz = self::DEFAULT_TZ)
{
$workingTime = array(
"from"=> Carbon::createFromTimeString($f, $tz),
"to"=> Carbon::createFromTimeString($t, $tz)
);
$userShift = UserShift::where('user_id', )
->orderByDesc('from_date')
->first();
$shift = null;
if ($userShift !== null)
{
$shiftId = null;
switch ($ts->shortEnglishDayOfWeek)
{
case "Mon":
$shiftId = $userShift->mon_shift_id;
break;
case "Tue":
$shiftId = $userShift->tue_shift_id;
break;
case "Wed":
$shiftId = $userShift->wed_shift_id;
break;
case "Thu":
$shiftId = $userShift->thu_shift_id;
break;
case "Fri":
$shiftId = $userShift->fri_shift_id;
break;
case "Sat":
$shiftId = $userShift->sat_shift_id;
break;
case "Sun":
$shiftId = $userShift->sun_shift_id;
break;
}
if ($shiftId === null) {
return null;
}
$shift = Shift::where('id', $shiftId)->first();
} else {
$shift = Shift::where('is_non_shift', true)
->orderByDesc('created_at')
->first();
}
if ($shift !== null)
{
$from = Carbon::createFromTimeString($shift->start_time, $tz)
->subMinutes($shift->flex_time_minute);
$to = Carbon::createFromTimeString($shift->end_time, $tz)
->addMinutes($shift->flex_time_minute);
/*
if ($to->lessThan($from))
{
$to->addDay();
}
*/
$workingTime['from'] = $from;
$workingTime['to'] = $to;
}
return $workingTime;
}
/**
* Get presence status
*/
public function presenceStatus(Carbon $at = null, $tz = self::DEFAULT_TZ)
{
$ts = $at;
if ($at !== null)
{
$ts = Carbon::now($tz);
}
$tsSec = $ts->secondsSinceMidnight();
$status = "";
$wt = $this->getWorkingTime($ts, $tz);
if ($wt === null)
{
$status = self::HOLIDAY;
} else {
$from = $wt->from;
$to = $wt->to;
$tsFrom = $from->secondsSinceMidnight();
$tsTo = $to->secondsSinceMidnight();
if ($from->greaterThan($to)) {
$tsMid = 24*60*60 - $tsFrom;
if ($tsSec >= $tsFrom || $tsSec < $tsTo) {
$status = self::INSIDE;
} else {
$status = self::OUTSIDE;
}
} else {
if ($tsSec < $tsFrom || $tsSec > $tsTo) {
$status = self::OUTSIDE;
} else {
$status = self::INSIDE;
}
}
}
$clockIn = null;
$clockOut = null;
$inout = Presence::where('user_id', $this->id)
->orderByDesc('clock_in')
->first();
if ($inout !== null) {
$clockIn = Carbon::parse($inout->clock_in, $tz);
$clockOut = Carbon::parse($inout->clock_out, $tz);
}
return array(
"status"=>$status,
"ts" => $ts,
"clock_in" => $clockIn,
"clock_out" => $clockOut
);
}
}
<?php
namespace App\Models;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable;
use Carbon\Carbon;
class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
{
use Authenticatable, Authorizable, HasFactory;
protected $table = 'm_users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'role_id', 'username', 'session_login', 'phone_number', 'email', 'address',
'fcm_token', 'gender', 'birth_place', 'birth_date', 'blood_type', 'ktp_number', 'working_hours',
'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource', 'discount_id','company_id','is_customer'
];
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
const DEFAULT_TZ = 'Asia/Jakarta';
const INSIDE = "INSIDE";
const OUTSIDE = "OUTSIDE";
const HOLIDAY = "HOLIDAY";
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password',
];
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
/**
* Get working hours for given timestamp
*
* @return array of carbon or NULL in case HOLIDAY
*/
public function getWorkingTime(Carbon $ts, $f = "08:00", $t = "17:00", $tz = self::DEFAULT_TZ)
{
$workingTime = array(
"from" => Carbon::createFromTimeString($f, $tz),
"to" => Carbon::createFromTimeString($t, $tz)
);
$userShift = UserShift::where('user_id',)
->orderByDesc('from_date')
->first();
$shift = null;
if ($userShift !== null) {
$shiftId = null;
switch ($ts->shortEnglishDayOfWeek) {
case "Mon":
$shiftId = $userShift->mon_shift_id;
break;
case "Tue":
$shiftId = $userShift->tue_shift_id;
break;
case "Wed":
$shiftId = $userShift->wed_shift_id;
break;
case "Thu":
$shiftId = $userShift->thu_shift_id;
break;
case "Fri":
$shiftId = $userShift->fri_shift_id;
break;
case "Sat":
$shiftId = $userShift->sat_shift_id;
break;
case "Sun":
$shiftId = $userShift->sun_shift_id;
break;
}
if ($shiftId === null) {
return null;
}
$shift = Shift::where('id', $shiftId)->first();
} else {
$shift = Shift::where('is_non_shift', true)
->orderByDesc('created_at')
->first();
}
if ($shift !== null) {
$from = Carbon::createFromTimeString($shift->start_time, $tz)
->subMinutes($shift->flex_time_minute);
$to = Carbon::createFromTimeString($shift->end_time, $tz)
->addMinutes($shift->flex_time_minute);
/*
if ($to->lessThan($from))
{
$to->addDay();
}
*/
$workingTime['from'] = $from;
$workingTime['to'] = $to;
}
return $workingTime;
}
/**
* Get presence status
*/
public function presenceStatus(Carbon $at = null, $tz = self::DEFAULT_TZ)
{
$ts = $at;
if ($at !== null) {
$ts = Carbon::now($tz);
}
$tsSec = $ts->secondsSinceMidnight();
$status = "";
$wt = $this->getWorkingTime($ts, $tz);
if ($wt === null) {
$status = self::HOLIDAY;
} else {
$from = $wt->from;
$to = $wt->to;
$tsFrom = $from->secondsSinceMidnight();
$tsTo = $to->secondsSinceMidnight();
if ($from->greaterThan($to)) {
$tsMid = 24 * 60 * 60 - $tsFrom;
if ($tsSec >= $tsFrom || $tsSec < $tsTo) {
$status = self::INSIDE;
} else {
$status = self::OUTSIDE;
}
} else {
if ($tsSec < $tsFrom || $tsSec > $tsTo) {
$status = self::OUTSIDE;
} else {
$status = self::INSIDE;
}
}
}
$clockIn = null;
$clockOut = null;
$inout = Presence::where('user_id', $this->id)
->orderByDesc('clock_in')
->first();
if ($inout !== null) {
$clockIn = Carbon::parse($inout->clock_in, $tz);
$clockOut = Carbon::parse($inout->clock_out, $tz);
}
return array(
"status" => $status,
"ts" => $ts,
"clock_in" => $clockIn,
"clock_out" => $clockOut
);
}
}

57
app/Models/UserToActivity.php

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Activity;
use Illuminate\Support\Facades\DB;
class UserToActivity extends Model
{
@ -29,35 +30,37 @@ class UserToActivity extends Model
public static function boot() {
parent::boot();
static::created(function($data) {
$activity = Activity::find($data->activity_id);
$getWorkingHours = UserToProyek::where('user_id', $data->user_id)->where('proyek_id', $activity->proyek_id)->first();
DB::transaction(function(){
static::created(function($data) {
$activity = Activity::find($data->activity_id);
$getWorkingHours = UserToProyek::where([['user_id', $data->user_id],['proyek_id', $activity->proyek_id]])->first();
$salary = 0;
if($getWorkingHours->uom_standart_rate == "Hour") {
$salary = (doubleval($getWorkingHours->standart_rate) * 8) * (int)$activity->duration * ($getWorkingHours->max_used / 100);
} else {
$salary = (doubleval($getWorkingHours->standart_rate) * (int)$activity->duration) * ($getWorkingHours->max_used / 100);
}
$activity->rencana_biaya += doubleval($salary);
$activity->save();
});
$salary = ($getWorkingHours->standart_rate * $activity->duration) * ($getWorkingHours->max_used / 100);
if($getWorkingHours->uom_standart_rate == "Hour")
$salary = ($getWorkingHours->standart_rate * 8) * $activity->duration * ($getWorkingHours->max_used / 100);
$activity->rencana_biaya += $salary;
$activity->save();
});
static::deleted(function($data) {
$activity = Activity::find($data->activity_id);
$getWorkingHours = UserToProyek::where('user_id', $data->user_id)->where('proyek_id', $activity->proyek_id)->first();
$salary = ($getWorkingHours->standart_rate * $activity->duration) * ($getWorkingHours->max_used / 100);
if($getWorkingHours->uom_standart_rate == "Hour"){
$salary = ($getWorkingHours->standart_rate * 8) * $activity->duration * ($getWorkingHours->max_used / 100);
}
$activity->rencana_biaya -= $salary;
if ($activity->rencana_biaya < 0) {
$activity->rencana_biaya = 0;
}
$activity->save();
});
static::deleted(function($data) {
$activity = Activity::find($data->activity_id);
$getWorkingHours = UserToProyek::where([['user_id', $data->user_id],['proyek_id', $activity->proyek_id]])->first();
$salary = 0;
if($getWorkingHours->uom_standart_rate == "Hour"){
$salary = (doubleval($getWorkingHours->standart_rate) * 8) * (int)$activity->duration * ($getWorkingHours->max_used / 100);
} else {
$salary = (doubleval($getWorkingHours->standart_rate) * (int)$activity->duration) * ($getWorkingHours->max_used / 100);
}
$activity->rencana_biaya -= doubleval($salary);
if ($activity->rencana_biaya < 0) {
$activity->rencana_biaya = 0;
}
$activity->save();
});
}, 5);
}
}

15833
composer.lock generated

File diff suppressed because it is too large Load Diff

120
rest-client.http

@ -1,4 +1,5 @@
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY5MTc2MDYyNCwiZXhwIjoxNjkyMzY1NDI0LCJuYmYiOjE2OTE3NjA2MjQsImp0aSI6Ikd2bEFPTE4yZ2FuRFdVbjEiLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.XNGbsmcgQ-CkV8vLlvnItGKM0R1am5X5b6qUFOR1DRo
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9iYWNrZW5kLnRlc3RcL2FwaVwvbG9naW4iLCJpYXQiOjE3MDEzNzMzNzQsImV4cCI6MTcwMTk3ODE3NCwibmJmIjoxNzAxMzczMzc0LCJqdGkiOiJhbkJWOHIwUDZndFRXZk5KIiwic3ViIjoxNzg4LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.QCiXq-62da7Sdk7sEb_J0apEij_R6IQgZVYG9iL6M8g
@tokenS = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjkxNTcyMTIwLCJleHAiOjE2OTIxNzY5MjAsIm5iZiI6MTY5MTU3MjEyMCwianRpIjoiVUdqbnhLRVdlZzYyTTBnayIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.5QqK0dLW5jzbVOkSCSW0mFo0K7ycGOBW9NCG_2Zldm4
@ -6,7 +7,7 @@
# @hostname = https://ospro-api.ospro.id/api
# @hostname = https://api-iu.ospro.id/api
# @hostname = https://api-staging-adw.ospro.id/api
@hostname = http://localhost:8444/api
@hostname = http://backend.test/api
# @hostname = http://103.73.125.81:8444/api
# @hostname = http://localhost:8444/adw-backend/api
@ -17,8 +18,8 @@ POST {{hostname}}/login
content-type: application/json
{
"username": "admin",
"password": "1nt3gr4s14"
"username": "testing",
"password": "testing123"
}
###### Tools Req
@ -418,7 +419,7 @@ content-type: application/json
"operator": "AND"
}
],
"select": ["kode_sortname", "nama", "mulai_proyek"],
"select": ["id", "nama", "rencana_biaya", "type_proyek_id", "currency_symbol", "mulai_proyek", "akhir_proyek"],
"joins": [
{
"name": "m_users",
@ -455,7 +456,43 @@ 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}
"columns": [
{
"name": "nama",
"logic_operator": "ilike",
"value": "",
"operator": "AND"
}
],
"select": ["id", "nama", "rencana_biaya", "color_progress", "currency_symbol", "mulai_proyek", "akhir_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
}
}
### add
@ -529,7 +566,7 @@ content-type: application/json
###### Activity
### get data by id version
GET {{hostname}}/activity/33/29/get
GET {{hostname}}/activity/550/137/get
Authorization: Bearer {{token}}
content-type: application/json
@ -785,24 +822,44 @@ content-type: application/json
###
POST {{hostname}}/activity/get-curva-s
POST {{hostname}}/dashboard/curva-s
Authorization: Bearer {{token}}
content-type: application/json
{
"project_id": [47],
"period": "week"
"project_id": [15]
}
###
POST {{hostname}}/project/s-curve-command-test
Authorization: Bearer {{token}}
content-type: application/json
# {"period":"week","project_id":"137","gantt_id":"916"}
# {"period":"week","project_id":"129","gantt_id":"862"}
{"period":"week","project_id":"140","gantt_id":"1103"}
###
POST {{hostname}}/dashboard/curva-s
POST {{hostname}}/project/calculate-s-curve
Authorization: Bearer {{token}}
content-type: application/json
{"period":"week","project_id":"129","gantt_id":"862"}
### {"period":"week","project_id":"135","gantt_id":"891"}
#######
POST {{hostname}}/project/get-s-curve
Authorization: Bearer {{token}}
content-type: application/json
{"project_id":"164","gantt_id":"973","period":"week"}
### {"period":"week","project_id":"129","gantt_id":"800"}
#######
GET {{hostname}}/activity/s-curve/137/892
Authorization: Bearer {{token}}
content-type: application/json
{
"project_id": [15]
}
###
GET https://adw-api.ospro.id/api/request-material/get-material-integration?name=c
@ -957,6 +1014,27 @@ content-type: application/json
"user_id": 1247
}
# -6.226761,106.809311 jkarta
# -6.465806,106.760559
# -6.356175,108.336182 indramayu
# -6.266805,106.468048, tigaraksa
# -6.205115,106.918373 jatinegara
######
POST {{hostname}}/presence/test
Authorization: Bearer {{token}}
content-type: application/json
{
"clock_in_out": {
"clock_out_lat": -6.356175,
"clock_out_lng": 108.336182,
"type" : "out"
},
"time": "2023-08-15T14:48:17+07:00",
"user_id": 1566
}
######
POST {{hostname}}/presence/add
Authorization: Bearer {{token}}
@ -1016,9 +1094,7 @@ POST {{hostname}}/map-monitoring/search
Authorization: Bearer {{token}}
content-type: application/json
{
"project_id" : [75, 76, 78]
}
{"project_id":[140,138,132,130]}
######
POST {{hostname}}/waypoint/add-bulk
@ -1159,13 +1235,3 @@ 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"
}

130
routes/web.php

@ -6,6 +6,19 @@ $router->get('/', function () use ($router) {
$router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($router) {
$router->post('/login', 'AuthController@login');
// Landing Route
$router->post('/send-email', 'AuthController@sendEmail');
$router->post('/user-register','UserRegisterController@add');
$router->post('/company-management-user/add', 'CompanyController@add');
$router->post('/product-transaction-user/add', 'ProductTransactionController@add');
$router->post('/company-management-user/search', 'CompanyController@search');
$router->post('/human-resource-user/add', 'HumanResourceController@add_user');
$router->get('/company-management-user/edit/{id}', 'CompanyController@edit');
$router->post('/demo-management-user/add', 'DemoController@add');
$router->post('/role-user/add', 'RoleController@add');
$router->post('/menu-company-user/add-multiple', 'MenuCompanyController@addMultiple');
$router->post('/role-menu-user/add-multiple', 'RoleMenuController@addMultiple');
$router->post('/refferal-code-user/search', 'RefferalCodeController@search');
$router->post('/menu/add', 'MenuController@add');
$router->get('/menu/edit/{id}', 'MenuController@edit');
@ -21,18 +34,28 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/role-menu/search', 'RoleMenuController@search');
$router->get('/role-menu/get-role/{id}', 'RoleMenuController@listMenu');
$router->post('/sales-contact/add', 'ContactSalesController@add');
$router->get('/sales-contact/edit/{id}', 'ContactSalesController@edit');
$router->put('/sales-contact/update/{id}', 'ContactSalesController@update');
$router->post('/sales-contact/search', 'ContactSalesController@search');
$router->delete('/sales-contact/delete/{id}', 'ContactSalesController@delete');
$router->group(['middleware' => ['auth', 'cors']], function () use ($router) {
$router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure
$router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in
$router->get('/dashboard/get-total-project-per-schedule-health[/{year}]', 'DashboardBoDController@getTotalProjectPerScheduleHealth');
$router->get('/dashboard/get-total-project-per-budget-health[/{year}]', 'DashboardBoDController@getTotalProjectPerBudgetHealth');
$router->get('/dashboard/get-total-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision');
$router->get('/dashboard/get-total-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision');
$router->get('/dashboard/get-total-project-per-phase[/{year}]', 'DashboardBoDController@getTotalProjectPerPhase');
$router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision');
$router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision');
$router->get('/dashboard/get-detail-expenditure[/{year}]', 'DashboardBoDController@getDetailExpenditure');
$router->get('/dashboard/get-company-cashflow/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure
$router->get('/dashboard/get-invoice-outstanding/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in
$router->get('/dashboard/get-total-project-per-schedule-health/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerScheduleHealth');
$router->get('/dashboard/get-total-project-per-budget-health/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerBudgetHealth');
$router->get('/dashboard/get-total-project-schedule-health-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision');
$router->get('/dashboard/get-total-project-budget-health-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision');
$router->get('/dashboard/get-total-project-per-phase/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerPhase');
$router->get('/dashboard/get-total-project-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerDivision');
$router->get('/dashboard/get-total-project-value-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectValuePerDivision');
$router->get('/dashboard/get-detail-expenditure/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getDetailExpenditure');
$router->get('/dashboard/get-detail-expenditure-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailExpenditureColor');
$router->get('/dashboard/get-detail-financial-health-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailFinancialHealthColor');
$router->get('/dashboard/get-detail-schedule-health-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailScheduleHealthColor');
$router->get('/dashboard/get-detail-invoice-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailInvoiceColor');
$router->post('/role/search', 'RoleController@search');
$router->post('/role/add', 'RoleController@add');
@ -43,15 +66,15 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen');
$router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId');
$router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete');
$router->delete('/document-project/delete/{id}/{company_id}', 'ProjectDokumenController@delete');
$router->post('/document-project/search', 'ProjectDokumenController@searchDocProject');
$router->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen');
$router->get('/document-project/download/{id}/{company_id}', 'ProjectDokumenController@downloadDokumen');
$router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen');
$router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId');
$router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete');
$router->delete('/document-activity/delete/{id}/{company_id}', 'ActivityDokumenController@delete');
$router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject');
$router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/document-activity/download/{id}/{company_id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/project-by-customer/{id}', 'ProjectController@getByUser');
$router->post('/project/search', 'ProjectController@search');
@ -59,9 +82,10 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->put('/project/update/{id}', 'ProjectController@update');
$router->get('/project/edit/{id}', 'ProjectController@edit');
$router->get('/project/detail/{id}[/{gantt_id}[/{s_curve}]]', 'ProjectController@detail');
$router->delete('/project/delete/{id}', 'ProjectController@delete');
$router->delete('/project/delete/{id}/{company_id}', 'ProjectController@delete');
$router->get('/project/list', 'ProjectController@list');
$router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline');
$router->get('/project/set-baseline-activity/{activity_id}/{gantt_id}', 'ProjectController@setBaselineActivity');
$router->get('/project/synchronize-report/{gantt_id}', 'ProjectController@synchronizeReport');
$router->get('/project/manpower/{proyek_id}', 'ProjectController@getManpower');
$router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR');
@ -69,17 +93,20 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$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/s-curve-command-test', 'ProjectController@calculateSCurvetest');
$router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve');
$router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities');
$router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration');
$router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution');
$router->get('/project/get-integration-project-cost={name}', 'ProjectController@getProjectCostIntegration');
/* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */
/* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */
/* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */
/* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */
$router->get('/project-carausell','ProjectCarausellController@invoke');
$router->get('/project-carausell/{company_id}/{all_project}/{hierarchy}', 'ProjectCarausellController@invoke');
$router->post('/project-charter/search', 'ProjectCharterController@search');
$router->post('/project-charter/add', 'ProjectCharterController@add');
@ -137,6 +164,30 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete');
$router->get('/project-phase/list', 'ProjectPhaseController@list');
$router->post('/project-expenditure/add', 'ProjectExpenditureController@add');
$router->post('/project-expenditure/search', 'ProjectExpenditureController@search');
$router->get('/project-expenditure/edit/{id}', 'ProjectExpenditureController@edit');
$router->put('/project-expenditure/update/{id}', 'ProjectExpenditureController@update');
$router->delete('/project-expenditure/delete/{id}', 'ProjectExpenditureController@delete');
$router->post('/project-financial-health/add', 'ProjectFinancialHealthController@add');
$router->post('/project-financial-health/search', 'ProjectFinancialHealthController@search');
$router->get('/project-financial-health/edit/{id}', 'ProjectFinancialHealthController@edit');
$router->put('/project-financial-health/update/{id}', 'ProjectFinancialHealthController@update');
$router->delete('/project-financial-health/delete/{id}', 'ProjectFinancialHealthController@delete');
$router->post('/project-schedule-health/add', 'ProjectScheduleHealthController@add');
$router->post('/project-schedule-health/search', 'ProjectScheduleHealthController@search');
$router->get('/project-schedule-health/edit/{id}', 'ProjectScheduleHealthController@edit');
$router->put('/project-schedule-health/update/{id}', 'ProjectScheduleHealthController@update');
$router->delete('/project-schedule-health/delete/{id}', 'ProjectScheduleHealthController@delete');
$router->post('/project-invoice/add', 'ProjectInvoiceController@add');
$router->post('/project-invoice/search', 'ProjectInvoiceController@search');
$router->get('/project-invoice/edit/{id}', 'ProjectInvoiceController@edit');
$router->put('/project-invoice/update/{id}', 'ProjectInvoiceController@update');
$router->delete('/project-invoice/delete/{id}', 'ProjectInvoiceController@delete');
$router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek');
$router->post('/request-material/add', 'RequestMaterialController@add');
@ -198,6 +249,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit');
$router->put('/user-to-activity/update/{id}', 'UserToActivityController@update');
$router->post('/user-to-activity/search', 'UserToActivityController@search');
$router->post('/user-to-activity/by-date-status', 'UserToActivityController@activityUser');
$router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis');
$router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered');
$router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete');
@ -214,6 +266,8 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/activity/import-old', 'ActivityController@importOld');
$router->post('/activity/batch-update/{ganttId}', 'ActivityController@batchUpdate');
$router->get('/activity/update-schedule/{ganttId}', 'ActivityController@updateSchedule');
$router->get('/activity/s-curve/{proyek_id}/{gantt_id}', 'ActivityController@activitySCurve');
$router->post('/task', 'ActivityController@add');
$router->get('/task/edit/{id}', 'ActivityController@edit');
$router->put('/task/{id}', 'ActivityController@update');
@ -279,8 +333,10 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/image/search', 'ImageController@search');
$router->delete('/image/delete/{id}', 'ImageController@delete');
$router->delete('/image/delete/{id}/{category}', 'ImageController@deleteByRef');
$router->delete('/image/delete/{id}/{category}/{company_id}', 'ImageController@deleteByRef');
$router->delete('/image/multiple-delete/{id}/{category}/{company_id}', 'ImageController@deleteByRefMultiple');
$router->post('/image/upload', 'ImageController@uploadImage');
$router->post('/image/multiple-upload', 'ImageController@uploadMultipleImage');
$router->get('/image/{id}/{category}', 'ImageController@getByRefId');
$router->post('/panic-button/add', 'PanicButtonController@add');
@ -315,6 +371,18 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/project-issues/list', 'ProjectIssuesController@list');
$router->get('/project-issues/{where}/{val}', 'ProjectIssuesController@customWhere');
$router->get('/kanban-board/list', 'KanbanBoardController@list');
$router->post('/kanban-board/add', 'KanbanBoardController@add');
$router->put('/kanban-board/update/{id}', 'KanbanBoardController@update');
$router->delete('/kanban-board/delete/{id}', 'KanbanBoardController@delete');
$router->post('/kanban-board/search', 'KanbanBoardController@search');
$router->get('/kanban-card/get-data/{project_id}/{gantt_id}/{board_id}', 'KanbanCardController@getData');
$router->post('/kanban-card/add', 'KanbanCardController@add');
$router->put('/kanban-card/update/{id}', 'KanbanCardController@update');
$router->delete('/kanban-card/delete/{id}', 'KanbanCardController@delete');
$router->post('/kanban-card/search', 'KanbanCardController@search');
$router->post('/project-risks/add', 'ProjectRisksController@add');
$router->get('/project-risks/edit/{id}', 'ProjectRisksController@edit');
$router->put('/project-issues/update/{id}', 'ProjectRisksController@update');
@ -363,7 +431,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/report-activity-material/add', 'ReportActivityMaterialController@add');
$router->post('/report-activity-material/search', 'ReportActivityMaterialController@search');
$router->delete('/report-activity-material/delete/{id}', 'ReportActivityMaterialController@delete');
$router->delete('/report-activity-material/delete/{id}/{company_id}', 'ReportActivityMaterialController@delete');
$router->get('/report-activity-material/list', 'ReportActivityMaterialController@list');
$router->get('/report-activity-material/datatables', 'ReportActivityMaterialController@datatables');
$router->post('/report-activity-material/update-status', 'ReportActivityMaterialController@updateStatusStartFinish');
@ -417,7 +485,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit');
$router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update');
$router->post('/user-to-proyek/search', 'UserToProyekController@search');
$router->delete('/user-to-proyek/delete/{id}', 'UserToProyekController@delete');
$router->delete('/user-to-proyek/delete/{id}/{company_id}', 'UserToProyekController@delete');
$router->get('/user-to-proyek/list', 'UserToProyekController@list');
$router->get('/user-to-proyek/select', 'UserToProyekController@select');
$router->get('/user-to-proyek/get-employee-integration', 'UserToProyekController@getEmployeeIntegration');
@ -426,7 +494,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/folder-document-proyek/edit/{id}', 'FolderDocumentProyekController@edit');
$router->put('/folder-document-proyek/update/{id}', 'FolderDocumentProyekController@update');
$router->post('/folder-document-proyek/search', 'FolderDocumentProyekController@search');
$router->delete('/folder-document-proyek/delete/{id}', 'FolderDocumentProyekController@delete');
$router->delete('/folder-document-proyek/delete/{id}/{company_id}', 'FolderDocumentProyekController@delete');
$router->get('/folder-document-proyek/list', 'FolderDocumentProyekController@list');
$router->get('/folder-document-proyek/get-tree/{id}', 'FolderDocumentProyekController@getTree');
@ -488,6 +556,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update');
$router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy');
$router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject');
$router->get('/hierarchy-ftths/count-tree/{hierarchy_id}', 'HierarchyFtthController@countProgressTree');
$router->get('/hierarchy-ftths/tree-gantt/{gantt_id}', 'HierarchyFtthController@getTreeByGantt');
$router->post('/map-monitoring/search', 'MapMonitoringController@search');
@ -513,5 +582,26 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/menu-company/search', 'MenuCompanyController@search');
$router->get('/menu-company/management/{id}', 'MenuCompanyController@listMenu');
$router->get('/menu-company/list', 'MenuCompanyController@list');
$router->post('/demo-management/add', 'DemoController@add');
$router->get('/demo-management/edit/{id}', 'DemoController@edit');
$router->put('/demo-management/update/{id}', 'DemoController@update');
$router->post('/demo-management/search', 'DemoController@search');
$router->delete('/demo-management/delete/{id}', 'DemoController@delete');
$router->get('/demo-management/list', 'DemoController@list');
$router->get('/information-storage/{company_name}', 'Controller@storage');
$router->get('/information-storage-all-company','Controller@storageAllCompany');
$router->post('/refferal-code/search', 'RefferalCodeController@search');
$router->post('/refferal-code/add', 'RefferalCodeController@add');
$router->get('/refferal-code/edit/{id}', 'RefferalCodeController@edit');
$router->put('/refferal-code/update/{id}', 'RefferalCodeController@update');
$router->post('/product-transaction/edit/{id}', 'ProductTransactionController@add');
$router->put('/product-transaction/update/{id}', 'ProductTransactionController@update');
$router->post('/product-transaction/search', 'ProductTransactionController@search');
$router->delete('/product-transaction/delete/{id}', 'ProductTransactionController@delete');
$router->get('/product-transaction/list', 'ProductTransactionController@list');
});
});

Loading…
Cancel
Save