Browse Source

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

Reviewed-on: ordo/adw-backend#154
pull/3/head
ibnu 1 year ago
parent
commit
4ba6516308
  1. 6
      app/Console/Commands/syncHumanResourceIntegration.php
  2. 45
      app/Http/Controllers/ActivityController.php
  3. 22
      app/Http/Controllers/DashboardBoDController.php
  4. 11
      app/Http/Controllers/PresenceController.php
  5. 10
      app/Http/Controllers/ProjectController.php
  6. 2
      app/Http/Controllers/RequestMaterialController.php
  7. 2
      app/Http/Controllers/UserToProyekController.php
  8. 2
      config/api.php

6
app/Console/Commands/syncHumanResourceIntegration.php

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

45
app/Http/Controllers/ActivityController.php

@ -48,8 +48,10 @@ class ActivityController extends Controller
$dataHeader->planned_start = isset($dataHeader->planned_start) ? date_format(date_create($dataHeader->planned_start), "Y-m-d H:i:s") : NULL; $dataHeader->planned_start = isset($dataHeader->planned_start) ? date_format(date_create($dataHeader->planned_start), "Y-m-d H:i:s") : NULL;
$dataHeader->planned_end = isset($dataHeader->planned_end) ? date_format(date_create($dataHeader->planned_end), "Y-m-d H:i:s") : NULL; $dataHeader->planned_end = isset($dataHeader->planned_end) ? date_format(date_create($dataHeader->planned_end), "Y-m-d H:i:s") : NULL;
$dataHeader->actual_start = isset($dataHeader->actual_start) ? date_format(date_create($dataHeader->actual_start), "Y-m-d") : NULL; $actualStart = $this->getActivityFirst($dataHeader->id);
$dataHeader->actual_end = isset($dataHeader->actual_end) ? date_format(date_create($dataHeader->actual_end), "Y-m-d") : NULL; $dataHeader->actual_start = date_format(date_create($actualStart), "Y-m-d");
$actualEnd = $this->getActivityLast($dataHeader->id);
$dataHeader->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL;
$dataHeader->type = "header"; $dataHeader->type = "header";
$dataHeader->text = $dataHeader->name; $dataHeader->text = $dataHeader->name;
@ -77,8 +79,10 @@ class ActivityController extends Controller
$objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start), "Y-m-d H:i:s") : NULL; $objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start), "Y-m-d H:i:s") : NULL;
$objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end), "Y-m-d H:i:s") : NULL; $objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end), "Y-m-d H:i:s") : NULL;
$objRow->actual_start = isset($objRow->actual_start) ? date_format(date_create($objRow->actual_start), "Y-m-d") : NULL; $actualStart = $this->getActivityFirst($objRow->id);
$objRow->actual_end = isset($objRow->actual_end) ? date_format(date_create($objRow->actual_end), "Y-m-d") : NULL; $objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL;
$actualEnd = $this->getActivityLast($objRow->id);
$objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL;
$objRow->progress = $objRow->persentase_progress / 100; $objRow->progress = $objRow->persentase_progress / 100;
$objRow->type = $type; $objRow->type = $type;
@ -124,16 +128,21 @@ class ActivityController extends Controller
$objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start), "Y-m-d H:i:s") : NULL; $objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start), "Y-m-d H:i:s") : NULL;
$objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end), "Y-m-d H:i:s") : NULL; $objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end), "Y-m-d H:i:s") : NULL;
$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;
$dataChildren = $this->getChildren($gantt_id, $objRow->id); $dataChildren = $this->getChildren($gantt_id, $objRow->id);
if ($objRow->type_activity == "milestone") { if ($objRow->type_activity == "milestone") {
$objRow->type = $objRow->type_activity; $objRow->type = $objRow->type_activity;
$objRow->actual_start = isset($objRow->actual_start) ? date_format(date_create($objRow->actual_start), "Y-m-d") : NULL;
} elseif (empty($dataChildren)) { } elseif (empty($dataChildren)) {
$objRow->type = "task"; $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;
} else { } else {
$objRow->type = "project"; $objRow->type = "project";
$actualStart = $this->getActivityFirst($objRow->id);
$objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL;
$actualEnd = $this->getActivityLast($objRow->id);
$objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL;
} }
$finalData[] = $objRow; $finalData[] = $objRow;
$finalData = array_merge($finalData, $dataChildren); $finalData = array_merge($finalData, $dataChildren);
@ -141,6 +150,28 @@ class ActivityController extends Controller
return $finalData; return $finalData;
} }
public function getActivityFirst($parentId){
$activity = Activity::where('parent_id', $parentId)->orderByRaw('start_date ASC')->first();
if($activity->type_activity == "task"){
// Log::info("activity ", [$activity]);
return $activity->actual_start;
}else{
return $this->getActivityFirst($activity->id);
}
}
public function getActivityLast($parentId){
$activity = Activity::where('parent_id', $parentId)->orderByRaw('start_date DESC')->first();
if($activity->type_activity == "task"){
// Log::info("activity ", [$activity]);
return $activity->actual_end;
}else{
return $this->getActivityLast($activity->id);
}
}
private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null) private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null)
{ {
$project = Project::find($proyek_id); $project = Project::find($proyek_id);

22
app/Http/Controllers/DashboardBoDController.php

@ -41,17 +41,17 @@ class DashboardBoDController extends Controller
private function getInvoiceIntegration($search) private function getInvoiceIntegration($search)
{ {
// if(empty($search)) if(empty($search))
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
//
// $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
// $token = config('api.adw_token'); $token = config('api.adw_token');
// $response = $this->curlReq($url, $token); $response = $this->curlReq($url, $token);
//
// if(@$response->data->project_no == "") if(@$response->data->project_no == "")
// return null; return null;
//
return null; return $response;
} }
// to do // to do

11
app/Http/Controllers/PresenceController.php

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\HumanResource;
use Log; use Log;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Presence; use App\Models\Presence;
@ -24,7 +25,10 @@ class PresenceController extends Controller
if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){
$statusBoundary = true; $statusBoundary = true;
} }
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) {
$statusBoundary = true;
}
// not assign // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array( $data=array(
@ -134,7 +138,10 @@ class PresenceController extends Controller
if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){
$statusBoundary = true; $statusBoundary = true;
} }
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) {
$statusBoundary = true;
}
// not assign // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array( $data=array(

10
app/Http/Controllers/ProjectController.php

@ -422,12 +422,12 @@ class ProjectController extends Controller
} }
public function getInvoiceIntegration(Request $request) { public function getInvoiceIntegration(Request $request) {
// $search = urlencode($request->search); $search = urlencode($request->search);
// if(empty($search)) if(empty($search))
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
// $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
$response = null; $response = MasterFunctionsHelper::curlReq($url);
// return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); // return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200);
return response()->json(['status'=>'success', 'data'=> '', 'code'=>200], 200); return response()->json(['status'=>'success', 'data'=> '', 'code'=>200], 200);

2
app/Http/Controllers/RequestMaterialController.php

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

2
app/Http/Controllers/UserToProyekController.php

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

2
config/api.php

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

Loading…
Cancel
Save