Browse Source

Merge pull request 'Merge branch 'staging' of https://git.oslog.id/ordo/adw-backend into Dev-Farhan' (#226) from Dev-Farhan into general

Reviewed-on: ordo/adw-backend#226
pull/3/head
farhantock 1 year ago
parent
commit
c5d0b6dc0d
  1. 6
      app/Helpers/MasterFunctionsHelper.php
  2. 13
      app/Http/Controllers/ActivityController.php
  3. 12
      app/Models/Activity.php
  4. 14
      app/Models/HierarchyFtth.php
  5. 7
      app/Models/VersionGantt.php
  6. 1
      routes/web.php

6
app/Helpers/MasterFunctionsHelper.php

@ -708,6 +708,9 @@ class MasterFunctionsHelper
$tempTtlPercentPlan += $sumPercentagePlan; $tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual; $tempTtlPercentActual += $sumPercentageActual;
if ($tempTtlPercentPlan >= 100)
$tempTtlPercentPlan = 100;
$currentACWP += $totalACWP; $currentACWP += $totalACWP;
$currentBCWP += $totalBCWP; $currentBCWP += $totalBCWP;
@ -715,6 +718,9 @@ class MasterFunctionsHelper
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2); $tempPercentagePlan[] = round($tempTtlPercentPlan, 2);
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan];
$tempPercentageReal[] = round($tempTtlPercentActual, 2); $tempPercentageReal[] = round($tempTtlPercentActual, 2);
if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) {
break;
}
} else { } else {
$tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2)); $tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2));
$tempPercentagePlan[] = round($sumPercentagePlan, 2); $tempPercentagePlan[] = round($sumPercentagePlan, 2);

13
app/Http/Controllers/ActivityController.php

@ -527,6 +527,19 @@ class ActivityController extends Controller
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 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);
}
public function searchAnalysis(Request $request) public function searchAnalysis(Request $request)
{ {
$dataBuilder = $this->setUpPayload($request->all(), 'm_activity'); $dataBuilder = $this->setUpPayload($request->all(), 'm_activity');

12
app/Models/Activity.php

@ -79,8 +79,14 @@ class Activity extends Model
}); });
static::deleted(function($data) { static::deleted(function($data) {
if(Activity::where("parent_id", $data->parent_id)->count() == 0) if (isset($data->parent_id)) {
Activity::find($data->parent_id)->update(["type_activity"=>"task"]); 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->updateBobot(true);
$data->updateCostPlanning(); $data->updateCostPlanning();
@ -100,7 +106,7 @@ class Activity extends Model
->whereNull('parent_id') ->whereNull('parent_id')
->first(); ->first();
if($root->rencana_biaya > 0){ if(isset($root) && $root->rencana_biaya > 0){
$activities = Activity::where("proyek_id", $this->proyek_id)->where("version_gantt_id", $this->version_gantt_id)->get(); $activities = Activity::where("proyek_id", $this->proyek_id)->where("version_gantt_id", $this->version_gantt_id)->get();
foreach ($activities as $activity) { foreach ($activities as $activity) {
if($isDelete && $activity->id == $this->id) if($isDelete && $activity->id == $this->id)

14
app/Models/HierarchyFtth.php

@ -3,6 +3,7 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\VersionGantt;
class HierarchyFtth extends Model class HierarchyFtth extends Model
{ {
@ -19,10 +20,15 @@ class HierarchyFtth extends Model
parent::boot(); parent::boot();
static::deleted(function($data) { static::deleted(function($data) {
$ftths = HierarchyFtth::where('parent_id', $data->id)->get(); $ftths = HierarchyFtth::where('parent_id', $data->id)->get();
foreach ($ftths as $ftth) { foreach ($ftths as $ftth) {
$ftth->delete(); $ftth->delete();
} }
$gantts = VersionGantt::where('hierarchy_ftth_id', $data->id)->get();
foreach ($gantts as $gantt) {
$gantt->delete();
}
}); });
} }
} }

7
app/Models/VersionGantt.php

@ -38,6 +38,13 @@ class VersionGantt extends Model
static::updated(function($data) { static::updated(function($data) {
$data->updateActDuration(); $data->updateActDuration();
});
static::deleted(function ($data) {
$activities = Activity::where('version_gantt_id', $data->id)->get();
foreach ($activities as $activity) {
$activity->delete();
}
}); });
} }

1
routes/web.php

@ -207,6 +207,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId');
$router->post('/activity/search', 'ActivityController@search'); $router->post('/activity/search', 'ActivityController@search');
$router->post('/activity/search-analysis', 'ActivityController@searchAnalysis'); $router->post('/activity/search-analysis', 'ActivityController@searchAnalysis');
$router->post('/activity/search-analysis-prep', 'ActivityController@searchAnalysisPrep');
$router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import', 'ActivityController@import');
$router->post('/activity/import-update', 'ActivityController@importUpdate'); $router->post('/activity/import-update', 'ActivityController@importUpdate');
$router->post('/activity/import-old', 'ActivityController@importOld'); $router->post('/activity/import-old', 'ActivityController@importOld');

Loading…
Cancel
Save