Browse Source

update conflict

pull/3/head
ibnu 2 years ago
parent
commit
1f086ea51c
  1. 31
      app/Http/Controllers/ActivityController.php

31
app/Http/Controllers/ActivityController.php

@ -6,9 +6,9 @@ use App\Models\CommentActivity;
use App\Models\Link;
use App\Models\Project;
use App\Models\TemplateGantt;
use App\Models\TmpImport;
use App\Models\VersionGantt;
use App\Models\UserToActivity;
use App\Models\TmpImport;
use Illuminate\Http\Request;
class ActivityController extends Controller
@ -279,9 +279,10 @@ class ActivityController extends Controller
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
}
public function import(Request $request)
// before upload file
public function importOld(Request $request)
{
$data = $request->all();
@ -307,7 +308,7 @@ class ActivityController extends Controller
$input['bobot_planning'] = $activity_row['weight'];
$input['persentase_progress'] = 0;
$input['type_activity'] = $i == 0 ? "header" : "task";
$input['created_by'] = $this->currentName;
$input['created_by'] = $this->currentName;
if (!$activity = Activity::create($input)) {
Activity::where('version_gantt_id', $data['ganttId'])->delete();
@ -388,17 +389,29 @@ class ActivityController extends Controller
return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200);
}
public function import(Request $request)
{
$data = $request->all();
$data['created_by'] = $this->currentName;
Activity::where('version_gantt_id', $data['gantt_id'])->delete();
$projectId = VersionGantt::where('id', $data['gantt_id'])->first()->proyek_id;
// get data excel
$excel = TmpImport::latest('id')->first();
return response()->json(['stack' => $excel, 'status' => 'success', 'message' => 'Data imported!', 'data' => $data, 'code' => 200], 200);
}
public function uploadTmpImport(Request $request)
{
if($request->hasFile('dokumen')){
$document = $request->file('dokumen');
$ref_id = $request->ref_id;
$document = $request->file('dokumen');
$gantt_id = $request->gantt_id;
$name = $document->getClientOriginalName();
$result = $document->move($this->pathDocument, $name);
$result = $document->move($this->pathTmpImport, $name);
if($result){
$data = [
'ref_id' => (int)$ref_id,
'gantt_id' => (int)$gantt_id,
'file' => $name,
'type_dokumen' => $request->type_dokumen
];
@ -406,7 +419,7 @@ class ActivityController extends Controller
$result = TmpImport::create($data);
if(!$result){
unlink($this->pathDocument.$name);
unlink($this->pathTmpImport.$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload successful!','code'=>200], 200);

Loading…
Cancel
Save