|
|
@ -3,6 +3,7 @@ |
|
|
|
namespace App\Models; |
|
|
|
namespace App\Models; |
|
|
|
|
|
|
|
|
|
|
|
use App\Models\AssignMaterial; |
|
|
|
use App\Models\AssignMaterial; |
|
|
|
|
|
|
|
use App\Models\ActivityProgressLog; |
|
|
|
use App\Models\AssignTools; |
|
|
|
use App\Models\AssignTools; |
|
|
|
use App\Models\ReportActivityMaterial; |
|
|
|
use App\Models\ReportActivityMaterial; |
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
|
@ -50,11 +51,17 @@ class Activity extends Model |
|
|
|
public static function boot() { |
|
|
|
public static function boot() { |
|
|
|
parent::boot(); |
|
|
|
parent::boot(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static::updating(function($data) { |
|
|
|
|
|
|
|
$data->logPersentaseProgress(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
static::updated(function($data) { |
|
|
|
static::updated(function($data) { |
|
|
|
$data->updateBobot(); |
|
|
|
$data->updateBobot(); |
|
|
|
$data->updateCostPlanning(); |
|
|
|
$data->updateCostPlanning(); |
|
|
|
$data->updatePersentaseProgress(); |
|
|
|
if($data->persentase_bobot){ |
|
|
|
$data->updateCostActual(); |
|
|
|
$data->updatePersentaseProgress(); |
|
|
|
|
|
|
|
$data->updateCostActual(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
static::deleted(function($data) { |
|
|
|
static::deleted(function($data) { |
|
|
@ -63,8 +70,10 @@ class Activity extends Model |
|
|
|
|
|
|
|
|
|
|
|
$data->updateBobot(true); |
|
|
|
$data->updateBobot(true); |
|
|
|
$data->updateCostPlanning(); |
|
|
|
$data->updateCostPlanning(); |
|
|
|
$data->updatePersentaseProgress(); |
|
|
|
if($data->persentase_bobot){ |
|
|
|
$data->updateCostActual(); |
|
|
|
$data->updatePersentaseProgress(); |
|
|
|
|
|
|
|
$data->updateCostActual(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -138,6 +147,18 @@ class Activity extends Model |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function logPersentaseProgress() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ActivityProgressLog::create([ |
|
|
|
|
|
|
|
'version_gantt_id' => $this->version_gantt_id, |
|
|
|
|
|
|
|
'activity_id' => request()->id, |
|
|
|
|
|
|
|
'old_percentage' => $this->persentase_progress, |
|
|
|
|
|
|
|
'new_percentage' => request()->persentase_progress, |
|
|
|
|
|
|
|
'variance' => $this->persentase_progress - request()->persentase_progress, |
|
|
|
|
|
|
|
'created_by'=> "system" |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getJobsDoneAttribute() |
|
|
|
public function getJobsDoneAttribute() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!ReportActivityMaterial::where('activity_id', $this->id)->first()) |
|
|
|
if(!ReportActivityMaterial::where('activity_id', $this->id)->first()) |
|
|
|