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()
{
$url = config('api.adw').'/employees?page=1';
echo "Requesting to " . $url;
$response = MasterFunctionsHelper::curlReq($url);
// $url = config('api.adw').'/employees?page=1';
// echo "Requesting to " . $url;
$response = null;
if(!$response)
return;

23
app/Helpers/MasterFunctionsHelper.php

@ -6,6 +6,7 @@ use App\Models\Activity;
use App\Models\Project;
use App\Models\VersionGantt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class MasterFunctionsHelper {
@ -34,10 +35,16 @@ class MasterFunctionsHelper {
public function getLatestGantt($id){
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id");
if(!$maxGanttId){
$data = array(
"proyek_id" => $id
);
} else {
$data = array(
"last_gantt_id" => $maxGanttId,
"proyek_id" => $id
);
}
return $data;
}
@ -47,7 +54,7 @@ class MasterFunctionsHelper {
if(!is_int($request)){
$dataPayload = $request->all();
if(isset($dataPayload['gantt_id'])){
$allGantt = $dataPayload['gantt_id'];
$allGantt[] = $dataPayload['gantt_id'];
}else{
$allGantt[] = MasterFunctionsHelper::getLatestGantt($dataPayload['project_id']);
}
@ -55,7 +62,15 @@ class MasterFunctionsHelper {
$allGantt[] = MasterFunctionsHelper::getLatestGantt($request);
}
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') {
// to do
return MasterFunctionsHelper::calculateProgressBasedOnSimple($gantt);
@ -102,7 +117,8 @@ class MasterFunctionsHelper {
$begin = new \DateTime($minDate.' Monday');
if(isset($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 = new \DateInterval('P7D');
} else {
@ -112,6 +128,7 @@ class MasterFunctionsHelper {
->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
$end = new \DateTime($maxDate. ' Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D');
}
$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 Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class ActivityController extends Controller
{
@ -348,16 +349,60 @@ class ActivityController extends Controller
$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) {
$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['proyek_id'] = $projectId;
$input['version_gantt_id'] = $data['ganttId'];
$input['parent_id'] = null;
$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['bobot_planning'] = $activity_row['weight'];
$input['persentase_progress'] = 0;

30
app/Http/Controllers/DashboardBoDController.php

@ -37,17 +37,17 @@ class DashboardBoDController extends Controller
}
private function getInvoiceIntegration($search) {
if(empty($search))
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
$token = config('api.adw_token');
$response = $this->curlReq($url, $token);
if(@$response->data->project_no == "")
return null;
return $response;
// if(empty($search))
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
//
// $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
// $token = config('api.adw_token');
// $response = $this->curlReq($url, $token);
//
// if(@$response->data->project_no == "")
// return null;
//
return null;
}
// to do
@ -319,8 +319,12 @@ class DashboardBoDController extends Controller
$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->scurve = MasterFunctionsHelper::getSCurve($project->id);
$project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count();
if(!isset($lastGantt['last_gantt_id'])){
$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);
}

2
app/Http/Controllers/ProjectController.php

@ -394,7 +394,7 @@ class ProjectController extends Controller
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
// $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'=> '', 'code'=>200], 200);

9
app/Http/Controllers/ProjectDokumenController.php

@ -94,7 +94,12 @@ class ProjectDokumenController extends Controller
if(!file_exists($this->pathDocument.$document->file))
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$pathToFile = $this->pathDocument.$document->file;
return response()->download($pathToFile);
$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);
}
}

2
app/Http/Controllers/RequestMaterialController.php

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

Loading…
Cancel
Save