|
|
@ -14,6 +14,7 @@ use App\Models\User; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
use DateTime; |
|
|
|
|
|
|
|
|
|
|
|
class ActivityController extends Controller |
|
|
|
class ActivityController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
@ -250,18 +251,29 @@ class ActivityController extends Controller |
|
|
|
$updateBobot = true; |
|
|
|
$updateBobot = true; |
|
|
|
if(!$data = Activity::find($id)) |
|
|
|
if(!$data = Activity::find($id)) |
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
|
|
|
|
$link = Link::where('t_activity_id', $data->id)->get(); |
|
|
|
|
|
|
|
if ($link) { |
|
|
|
|
|
|
|
foreach ($link as $linkData) { |
|
|
|
|
|
|
|
$predecessor = Activity::find($linkData->s_activity_id); |
|
|
|
|
|
|
|
$start = new DateTime($data->start_date); |
|
|
|
|
|
|
|
$end = new DateTime($predecessor->end_date); |
|
|
|
|
|
|
|
$lag = $start->diff($end)->format('%a'); |
|
|
|
|
|
|
|
$linkData->lag = $lag; |
|
|
|
|
|
|
|
$linkData->save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
$dataUpdate = $request->all(); |
|
|
|
$dataUpdate = $request->all(); |
|
|
|
|
|
|
|
|
|
|
|
$dataUpdate['name'] = $request->text; |
|
|
|
$dataUpdate['name'] = $request->text; |
|
|
|
$dataUpdate['persentase_progress'] = $request->progress*100; |
|
|
|
$dataUpdate['persentase_progress'] = $request->progress*100; |
|
|
|
$dataUpdate['updated_by'] = $this->currentName; |
|
|
|
$dataUpdate['updated_by'] = $this->currentName; |
|
|
|
unset($dataUpdate['sortorder']); |
|
|
|
unset($dataUpdate['sortorder']); |
|
|
|
if($data->type_activity!='header') |
|
|
|
if($data->type_activity!='header') |
|
|
|
$dataUpdate['type_activity'] = $request->type; |
|
|
|
$dataUpdate['type_activity'] = $request->type; |
|
|
|
|
|
|
|
|
|
|
|
if($request->has("target")){ |
|
|
|
if($request->has("target")){ |
|
|
|
$this->updateOrder($id, $request->target); |
|
|
|
$this->updateOrder($id, $request->target); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!$data->update($dataUpdate)) |
|
|
|
if(!$data->update($dataUpdate)) |
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'data activity failed updated!','code'=>400], 400); |
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'data activity failed updated!','code'=>400], 400); |
|
|
|