Browse Source

update conflict

pull/3/head
ibnu 2 years ago
parent
commit
b02c6564ad
  1. 6
      app/Console/Commands/syncHumanResourceIntegration.php
  2. 23
      app/Helpers/MasterFunctionsHelper.php
  3. 51
      app/Http/Controllers/ActivityController.php
  4. 30
      app/Http/Controllers/DashboardBoDController.php
  5. 2
      app/Http/Controllers/ProjectController.php
  6. 9
      app/Http/Controllers/ProjectDokumenController.php
  7. 2
      app/Http/Controllers/RequestMaterialController.php
  8. 2
      app/Http/Controllers/UserToProyekController.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 = MasterFunctionsHelper::curlReq($url); $response = null;
if(!$response) if(!$response)
return; return;

23
app/Helpers/MasterFunctionsHelper.php

@ -6,6 +6,7 @@ use App\Models\Activity;
use App\Models\Project; use App\Models\Project;
use App\Models\VersionGantt; use App\Models\VersionGantt;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class MasterFunctionsHelper { class MasterFunctionsHelper {
@ -34,10 +35,16 @@ class MasterFunctionsHelper {
public function getLatestGantt($id){ public function getLatestGantt($id){
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); $maxGanttId = VersionGantt::where("proyek_id", $id)->max("id");
if(!$maxGanttId){
$data = array(
"proyek_id" => $id
);
} else {
$data = array( $data = array(
"last_gantt_id" => $maxGanttId, "last_gantt_id" => $maxGanttId,
"proyek_id" => $id "proyek_id" => $id
); );
}
return $data; return $data;
} }
@ -47,7 +54,7 @@ class MasterFunctionsHelper {
if(!is_int($request)){ if(!is_int($request)){
$dataPayload = $request->all(); $dataPayload = $request->all();
if(isset($dataPayload['gantt_id'])){ if(isset($dataPayload['gantt_id'])){
$allGantt = $dataPayload['gantt_id']; $allGantt[] = $dataPayload['gantt_id'];
}else{ }else{
$allGantt[] = MasterFunctionsHelper::getLatestGantt($dataPayload['project_id']); $allGantt[] = MasterFunctionsHelper::getLatestGantt($dataPayload['project_id']);
} }
@ -55,7 +62,15 @@ class MasterFunctionsHelper {
$allGantt[] = MasterFunctionsHelper::getLatestGantt($request); $allGantt[] = MasterFunctionsHelper::getLatestGantt($request);
} }
foreach($allGantt as $gantt){ foreach($allGantt as $gantt){
$gantt = VersionGantt::where('id', $gantt['last_gantt_id'])->first()->toArray(); if (!isset($gantt['last_gantt_id'])) {
$ganttId = $gantt;
} else {
$ganttId = $gantt['last_gantt_id'];
}
$gantt = VersionGantt::find($ganttId)->toArray();
// foreach ($gantt as $key => $value) {
// Log::info('gantt '.$value.' index '.$key);
// }
if($gantt['calculation_type'] == 'simple') { if($gantt['calculation_type'] == 'simple') {
// to do // to do
return MasterFunctionsHelper::calculateProgressBasedOnSimple($gantt); return MasterFunctionsHelper::calculateProgressBasedOnSimple($gantt);
@ -102,7 +117,8 @@ class MasterFunctionsHelper {
$begin = new \DateTime($minDate.' Monday'); $begin = new \DateTime($minDate.' Monday');
if(isset($dataPayload['end_date'])){ if(isset($dataPayload['end_date'])){
$maxDate = $dataPayload['end_date']; $maxDate = $dataPayload['end_date'];
$end = new \DateTime($maxDate); $end = new \DateTime($maxDate. ' Friday');
$end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
@ -112,6 +128,7 @@ class MasterFunctionsHelper {
->where('a.version_gantt_id', '=', $keyGantt['id']) ->where('a.version_gantt_id', '=', $keyGantt['id'])
->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's ->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's
$end = new \DateTime($maxDate. ' Friday'); $end = new \DateTime($maxDate. ' Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} }
$period = new \DatePeriod($begin, $interval, $end); $period = new \DatePeriod($begin, $interval, $end);

51
app/Http/Controllers/ActivityController.php

@ -11,6 +11,7 @@ use App\Models\VersionGantt;
use App\Models\UserToActivity; use App\Models\UserToActivity;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class ActivityController extends Controller class ActivityController extends Controller
{ {
@ -348,16 +349,60 @@ class ActivityController extends Controller
$activityStack = []; $activityStack = [];
$hasWeight = false;
foreach ($data['activities'] as $key => $value) {
if(isset($value['weight']) && $value['weight'] != null && $value['weight'] != 0){
$hasWeight = true;
break;
}
}
if(!$hasWeight){
foreach ($data['activities'] as $key => $value) {
if($key == 0){
$data['activities'][$key]['weight'] = 100;
} else {
$parentWeight = 0;
$siblingsCount = 1;
$i = $key;
while($i > 0){
if ($data['activities'][$i - 1]['level'] == $data['activities'][$key]['level']-1){
$parentWeight = $data['activities'][$i - 1]['weight'];
break;
}
if ($data['activities'][$key]['level'] == $data['activities'][$i]['level']){
$siblingsCount++;
}
$i--;
}
$i = $key+1;
while($i < count($data['activities'])){
if ($data['activities'][$i]['level'] == $data['activities'][$key]['level']-1){
break;
}
// Log::info('level '.$data['activities'][$key]['level'].' i level '.$data['activities'][$i]['level']);
if ($data['activities'][$key]['level'] == $data['activities'][$i]['level']){
$siblingsCount++;
}
$i++;
}
$data['activities'][$key]['weight'] = $parentWeight / $siblingsCount;
}
};
}
foreach ($data['activities'] as $i => $activity_row) { foreach ($data['activities'] as $i => $activity_row) {
$startDate = \DateTime::createFromFormat('d-m-y', $activity_row['start_date']); $startDate = \DateTime::createFromFormat('d-m-y', $activity_row['start_date']);
$endDate = \DateTime::createFromFormat('d-m-y', $activity_row['end_date']); $endDate = \DateTime::createFromFormat('d-m-y H:i:sO', $activity_row['end_date']);
$input['name'] = $activity_row['name']; $input['name'] = $activity_row['name'];
$input['proyek_id'] = $projectId; $input['proyek_id'] = $projectId;
$input['version_gantt_id'] = $data['ganttId']; $input['version_gantt_id'] = $data['ganttId'];
$input['parent_id'] = null; $input['parent_id'] = null;
$input['start_date'] = $startDate->format('Y-m-d'); $input['start_date'] = $startDate->format('Y-m-d');
$input['end_date'] = $endDate->format('Y-m-d'); $input['end_date'] = $endDate->format('Y-m-d H:i:sO');
$input['duration'] = $activity_row['duration']; $input['duration'] = $activity_row['duration'];
$input['bobot_planning'] = $activity_row['weight']; $input['bobot_planning'] = $activity_row['weight'];
$input['persentase_progress'] = 0; $input['persentase_progress'] = 0;

30
app/Http/Controllers/DashboardBoDController.php

@ -37,17 +37,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 $response; return null;
} }
// to do // to do
@ -319,8 +319,12 @@ class DashboardBoDController extends Controller
$project->pm = User::find($project->pm_id); $project->pm = User::find($project->pm_id);
/* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */ /* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); if(!isset($lastGantt['last_gantt_id'])){
$project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count(); $project->manPowers = 0;
} else {
$project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count();
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
}
$project->lastGanttId = MasterFunctionsHelper::getLatestGantt($project->id); $project->lastGanttId = MasterFunctionsHelper::getLatestGantt($project->id);
} }

2
app/Http/Controllers/ProjectController.php

@ -394,7 +394,7 @@ class ProjectController extends Controller
// 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 = MasterFunctionsHelper::curlReq($url); $response = null;
// 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);

9
app/Http/Controllers/ProjectDokumenController.php

@ -94,7 +94,12 @@ class ProjectDokumenController extends Controller
if(!file_exists($this->pathDocument.$document->file)) if(!file_exists($this->pathDocument.$document->file))
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$pathToFile = $this->pathDocument.$document->file; $pathToFile = $this->pathDocument.$document->file;
return response()->download($pathToFile); $name = pathinfo($pathToFile, PATHINFO_FILENAME) . "." . pathinfo($pathToFile, PATHINFO_EXTENSION);
$headers = [
'Content-Disposition' => 'attachment; filename="'.$name.'"'
];
// dd($name, $headers);
return response()->download($pathToFile, $name, $headers);
} }
} }

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 = urlencode($request->name); $search = null;
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 = urlencode($request->name); $search = null;
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');

Loading…
Cancel
Save