farhantock
10 months ago
14 changed files with 890 additions and 259 deletions
@ -0,0 +1,115 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\KanbanBoard; |
||||
|
||||
class KanbanBoardController extends Controller |
||||
{ |
||||
public function add(Request $request){ |
||||
$this->validate($request, [ |
||||
'name_board' => 'required', |
||||
'header_color' => 'required', |
||||
'body_color' => 'required', |
||||
'proyek_id' => 'required', |
||||
'version_gantt_id' => 'required', |
||||
'status_progress' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
$statusCount = KanbanBoard::where('version_gantt_id', $request->version_gantt_id) |
||||
->where('status_progress', $request->status_progress) |
||||
->get() |
||||
->count(); |
||||
|
||||
if ($statusCount < 1 || $request->status_progress == 'none') { |
||||
$result = KanbanBoard::create($data); |
||||
} else { |
||||
return response()->json(['status'=>'failed','message'=>'Board kanban failed created','code'=>400], 400); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Board kanban successfull created','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Board kanban failed created','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function update(Request $request, $id){ |
||||
|
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
} |
||||
$data = KanbanBoard::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Board kanban not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Board kanban successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Board kanban failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = KanbanBoard::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Board kanban not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Board kanban successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Board kanban failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = KanbanBoard::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data Board kanban, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'kanban_board'); |
||||
$builder = $dataBuilder['builder']; |
||||
$countBuilder = $dataBuilder['count']; |
||||
$dataGet = $builder->get(); |
||||
$totalRecord = $countBuilder->count(); |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list(Request $request) |
||||
{ |
||||
$query = KanbanBoard::select("*"); |
||||
$countData = $query->count(); |
||||
$data = $this->paramsMethodGet($query, $countData, $request); |
||||
|
||||
if($data) |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>count($data)], 200); |
||||
|
||||
return response()->json(['status'=>'failed','message'=>'failed get Board kanban, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
@ -0,0 +1,258 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\User; |
||||
use App\Models\Project; |
||||
use App\Models\Activity; |
||||
use App\Models\KanbanCard; |
||||
use App\Models\KanbanBoard; |
||||
// use Illuminate\Support\Arr; |
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
class KanbanCardController extends Controller |
||||
{ |
||||
private function add($board_id, $gantt_id, $type_activity, $status_progress) |
||||
{ |
||||
$dataActivity = Activity::where("version_gantt_id", $gantt_id) |
||||
->where("type_activity", $type_activity) |
||||
->get(); |
||||
foreach ($dataActivity as $keyA) { |
||||
// $this->add($keyA->id, $gantt_id, $board_id); |
||||
$data = array( |
||||
'activity_id' => $keyA->id, |
||||
'kanban_board_id' => $board_id, |
||||
'version_gantt_id' => $gantt_id, |
||||
'created_by' => $this->currentName |
||||
); |
||||
switch ($status_progress) { |
||||
case 'open': |
||||
if ($keyA->persentase_progress == 0) { |
||||
$add = KanbanCard::create($data); |
||||
} |
||||
break; |
||||
case 'on-progress': |
||||
if ($keyA->persentase_progress > 0 && $keyA->persentase_progress < 100) { |
||||
$cardIds = DB::table('kanban_card as kc') |
||||
->join('m_activity as ma', 'kc.activity_id', '=', 'ma.id') |
||||
->where('kc.activity_id', '=', $keyA->id) |
||||
->select('kc.id') |
||||
->get(); |
||||
foreach ($cardIds as $cardId) { |
||||
$this->delete($cardId->id); |
||||
} |
||||
$add = KanbanCard::create($data); |
||||
} |
||||
break; |
||||
case 'done': |
||||
if ($keyA->persentase_progress == 100) { |
||||
$cardIds = DB::table('kanban_card as kc') |
||||
->join('m_activity as ma', 'kc.activity_id', '=', 'ma.id') |
||||
->where('kc.activity_id', '=', $keyA->id) |
||||
->select('kc.id') |
||||
->get(); |
||||
foreach ($cardIds as $cardId) { |
||||
$this->delete($cardId->id); |
||||
} |
||||
$add = KanbanCard::create($data); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
return "success"; |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
|
||||
if (!$id || (int) $id < 0 || $id == "") { |
||||
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
||||
} |
||||
$data = KanbanCard::where("activity_id", $id); |
||||
if ($data) { |
||||
$result = $data->update($request->all()); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Data Card kanban not found!', 'code' => 400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$board = KanbanBoard::find($request->kanban_board_id); |
||||
$activity = Activity::find($id); |
||||
if ($board->status_progress == "done" && $activity) { |
||||
$activity->update(['persentase_progress' => 100]); |
||||
} else{ |
||||
if($activity['persentase_progress'] != 95 && $activity['persentase_progress'] != 100){ |
||||
$activity->update(['persentase_progress' => 0]); |
||||
}else{ |
||||
$activity->update(['persentase_progress' => 95]); |
||||
} |
||||
|
||||
} |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'message' => 'Board kanban successfully updated!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Board kanban failed updated!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = KanbanCard::find($id); |
||||
|
||||
if ($data) { |
||||
$delete = $data->delete(); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Data Board kanban not found!', 'code' => 400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if ($delete) { |
||||
return response()->json(['status' => 'success', 'message' => 'Board kanban successfully deleted!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Board kanban failed deleted!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
|
||||
public function edit($id) |
||||
{ |
||||
if (!$id || (int) $id < 0 || $id == "") { |
||||
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = KanbanCard::find($id); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'failed get data Board kanban, please try again later!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'kanban_board'); |
||||
$builder = $dataBuilder['builder']; |
||||
$countBuilder = $dataBuilder['count']; |
||||
$dataGet = $builder->get(); |
||||
$totalRecord = $countBuilder->count(); |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); |
||||
} |
||||
|
||||
public function getData($project_id, $gantt_id, $board_id, Request $request) |
||||
{ |
||||
// cek ketika dia owner dari project maka |
||||
$SESSIONID = $request->session; |
||||
$status_progress = KanbanBoard::select("status_progress")->where('id', $board_id)->first(); |
||||
if ($status_progress) { |
||||
if (DB::table('user_to_version_gantt')->where('user_id', $SESSIONID)->where('version_gantt_id', $gantt_id)->exists()) { |
||||
$dataCard = $this->getDataAll($project_id, $gantt_id, $board_id, $status_progress->status_progress, true); |
||||
} else { |
||||
$dataCard = $this->getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress->status_progress, true); |
||||
} |
||||
} else { |
||||
return response()->json(['status' => 'empty', 'message' => 'data board is empty, please you insert!', 'code' => 200], 200); |
||||
} |
||||
|
||||
if ($dataCard && count($dataCard) > 0){ |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataCard, "totalRecord" => count($dataCard)], 200); |
||||
}else{ |
||||
return response()->json(['status' => 'empty', 'message' => 'data card is empty, please you insert!', 'code' => 200], 200); |
||||
} |
||||
|
||||
} |
||||
|
||||
private function getDataAll($project_id, $gantt_id, $board_id, $status_progress, $status) |
||||
{ |
||||
$dataFinal = []; |
||||
if($status == true){ |
||||
if ($status_progress != 'none') { |
||||
if (KanbanCard::where('kanban_board_id', $board_id)->where("version_gantt_id", $gantt_id)->count() == 0) { |
||||
$this->add($board_id, $gantt_id, 'task', $status_progress); |
||||
$this->getDataAll($project_id, $gantt_id, $board_id, $status_progress, false); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$dataCard = DB::table("kanban_card as kc") |
||||
->select("ma.id as activity_id", "ma.name", "ma.start_date", "ma.end_date", "ma.persentase_bobot", "ma.jumlah_pekerjaan", "ma.bobot_planning", "ma.persentase_progress") |
||||
->join("m_activity as ma", "ma.id", "=", "kc.activity_id") |
||||
->where("kc.kanban_board_id", $board_id) |
||||
->where("kc.version_gantt_id", $gantt_id) |
||||
->orderBy('ma.sortorder') |
||||
->get(); |
||||
|
||||
foreach ($dataCard as $keyCard) { |
||||
$query = DB::table("assign_hr_to_activity as ahta") |
||||
->select("ahta.id", "mu.name", "mu.id as id_hr") |
||||
->join("m_users as mu", "mu.id", "=", "ahta.user_id") |
||||
->where("ahta.activity_id", $keyCard->activity_id) |
||||
->get(); |
||||
|
||||
$dataArray = array( |
||||
"id" => $keyCard->activity_id, |
||||
"assign_hr" => $query, |
||||
"activity" => $keyCard->name, |
||||
"start_date" => $keyCard->start_date, |
||||
"end_date" => $keyCard->end_date, |
||||
"jumlah_pekerjaan" => $keyCard->jumlah_pekerjaan, |
||||
"bobot_planning" => $keyCard->bobot_planning, |
||||
"persentase_progress" => $keyCard->persentase_progress |
||||
); |
||||
$dataFinal[] = $dataArray; |
||||
} |
||||
// } |
||||
return $dataFinal; |
||||
} |
||||
|
||||
private function getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress, $status) |
||||
{ |
||||
$dataFinal = []; |
||||
if($status == true){ |
||||
if ($status_progress != 'none') { |
||||
if (KanbanCard::where('kanban_board_id', $board_id)->where("version_gantt_id", $gantt_id)->count() == 0) { |
||||
$this->add($board_id, $gantt_id, 'task', $status_progress); |
||||
$this->getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress, false); |
||||
} |
||||
} |
||||
$dataUser = User::whereId($request->session)->first(); |
||||
$dataCard = DB::table("kanban_card as kc") |
||||
->select("ma.id as activity_id", "ma.name", "ma.start_date", "ma.end_date", "ma.persentase_bobot", "ma.jumlah_pekerjaan", "ma.bobot_planning", "ma.persentase_progress") |
||||
->join("m_activity as ma", "ma.id", "=", "kc.activity_id") |
||||
->where([ |
||||
["kc.created_by", $dataUser['name']], |
||||
["kc.kanban_board_id", $board_id], |
||||
["kc.version_gantt_id", $gantt_id] |
||||
]) |
||||
->orderBy('ma.sortorder') |
||||
->get(); |
||||
foreach ($dataCard as $keyCard) { |
||||
$query = DB::table("assign_hr_to_activity as ahta") |
||||
->select("ahta.id", "mu.name", "mu.id as id_hr") |
||||
->join("m_users as mu", "mu.id", "=", "ahta.user_id") |
||||
->where("ahta.activity_id", $keyCard->activity_id) |
||||
->get(); |
||||
|
||||
$dataArray = array( |
||||
"id" => $keyCard->activity_id, |
||||
"assign_hr" => $query, |
||||
"activity" => $keyCard->name, |
||||
"start_date" => $keyCard->start_date, |
||||
"end_date" => $keyCard->end_date, |
||||
"jumlah_pekerjaan" => $keyCard->jumlah_pekerjaan, |
||||
"bobot_planning" => $keyCard->bobot_planning, |
||||
"persentase_progress" => $keyCard->persentase_progress, |
||||
"test" => $request->session |
||||
); |
||||
$dataFinal[] = $dataArray; |
||||
} |
||||
} |
||||
|
||||
return $dataFinal; |
||||
} |
||||
|
||||
} |
@ -1,105 +1,114 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\DokumenProject; |
||||
|
||||
class ProjectDokumenController extends Controller |
||||
{ |
||||
public function dokumenByProyekId($id){ |
||||
if(empty($id) || !is_int((int)$id)) { |
||||
return response()->json(['status'=>'failed','message'=>'project id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$document = DokumenProject::where("ref_id", $id)->get(); |
||||
|
||||
if(count($document) == 0) |
||||
return response()->json(['status'=>'','message'=>'Data not found!' ,'code'=>404], 404); |
||||
|
||||
return response()->json(['status'=>'success','data'=> $document ,'code'=>200], 200); |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
if(empty($id) || !is_int((int)$id)) { |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$document = DokumenProject::find($id); |
||||
if(!$document){ |
||||
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400); |
||||
} |
||||
|
||||
if(file_exists($this->pathDocument.$document->file)){ |
||||
unlink($this->pathDocument.$document->file); |
||||
} |
||||
|
||||
$document->delete(); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200); |
||||
} |
||||
|
||||
public function uploadProjectDokumen(Request $request) |
||||
{ |
||||
if($request->hasFile('dokumen')){ |
||||
$document = $request->file('dokumen'); |
||||
$ref_id = $request->ref_id; |
||||
$name = $document->getClientOriginalName(); |
||||
|
||||
$result = $document->move($this->pathDocument, $name); |
||||
if($result){ |
||||
$data = [ |
||||
'ref_id' => (int)$ref_id, |
||||
'file' => $name, |
||||
'type_dokumen' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document' |
||||
]; |
||||
|
||||
$result = DokumenProject::create($data); |
||||
|
||||
if(!$result){ |
||||
unlink($this->pathDocument.$name); |
||||
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); |
||||
} |
||||
return response()->json(['status'=>'success','message'=>'Upload successful!','code'=>200], 200); |
||||
|
||||
} |
||||
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); |
||||
} |
||||
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400); |
||||
} |
||||
|
||||
public function searchDocProject(Request $request){ |
||||
$payload = $request->all(); |
||||
|
||||
$dataBuilder = $this->setUpPayload($payload, 'document_project'); |
||||
$builder = $dataBuilder['builder']; |
||||
$countBuilder = $dataBuilder['count']; |
||||
$dataGet = $builder->get(); |
||||
$totalRecord = $countBuilder->count(); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function downloadDokumen($id) |
||||
{ |
||||
if(empty($id) || !is_int((int)$id)) |
||||
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); |
||||
|
||||
$document = DokumenProject::find($id); |
||||
|
||||
if(!$document) |
||||
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
||||
|
||||
if(!file_exists($this->pathDocument.$document->file)) |
||||
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
||||
|
||||
$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); |
||||
} |
||||
} |
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\Company; |
||||
use Illuminate\Http\Request; |
||||
use App\Models\DokumenProject; |
||||
use App\Models\ProductTransaction; |
||||
|
||||
class ProjectDokumenController extends Controller |
||||
{ |
||||
public function dokumenByProyekId($id){ |
||||
if(empty($id) || !is_int((int)$id)) { |
||||
return response()->json(['status'=>'failed','message'=>'project id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$document = DokumenProject::where("ref_id", $id)->get(); |
||||
|
||||
if(count($document) == 0) |
||||
return response()->json(['status'=>'','message'=>'Data not found!' ,'code'=>404], 404); |
||||
|
||||
return response()->json(['status'=>'success','data'=> $document ,'code'=>200], 200); |
||||
} |
||||
|
||||
public function delete($id, $company_id) |
||||
{ |
||||
if(empty($id) || !is_int((int)$id)) { |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$document = DokumenProject::find($id); |
||||
if(!$document){ |
||||
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400); |
||||
} |
||||
$company = Company::find($company_id); |
||||
if($company) { |
||||
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); |
||||
if(file_exists($destinationPath['pathDocument'].$document->file)){ |
||||
unlink($destinationPath['pathDocument'].$document->file); |
||||
} |
||||
} |
||||
$document->delete(); |
||||
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200); |
||||
} |
||||
|
||||
public function uploadProjectDokumen(Request $request) |
||||
{ |
||||
if($request->hasFile('dokumen')){ |
||||
$document = $request->file('dokumen'); |
||||
$ref_id = $request->ref_id; |
||||
$name = $document->getClientOriginalName(); |
||||
// Limited Storage |
||||
$company = Company::where('company_name', $request->company_name)->first(); |
||||
if($company) { |
||||
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); |
||||
$getLimitStorage = $this->setLimitsStorage($company, $document, $name, $destinationPath['pathDocument'],$destinationPath); |
||||
} |
||||
if(isset($getLimitStorage) && $getLimitStorage['resultMove']) { |
||||
$data = [ |
||||
'ref_id' => (int)$ref_id, |
||||
'file' => $name, |
||||
'type_dokumen' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document' |
||||
]; |
||||
|
||||
$getLimitStorage['resultMove'] = DokumenProject::create($data); |
||||
|
||||
if(!$getLimitStorage['resultMove']){ |
||||
unlink($destinationPath['pathDocument'].$name); |
||||
return response()->json(['status'=>'failed','message'=>'Dokumen project gagal diupload!','code'=> 500], 500); |
||||
} |
||||
return response()->json(['status'=>'success','message'=>'Dokumen project berhasil diupload!','code'=>200], 200); |
||||
} |
||||
return response()->json(['status'=>'failed','message'=>'Dokumen project gagal diupload!','code'=> 500], 500); |
||||
} |
||||
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400); |
||||
} |
||||
|
||||
public function searchDocProject(Request $request){ |
||||
$payload = $request->all(); |
||||
|
||||
$dataBuilder = $this->setUpPayload($payload, 'document_project'); |
||||
$builder = $dataBuilder['builder']; |
||||
$countBuilder = $dataBuilder['count']; |
||||
$dataGet = $builder->get(); |
||||
$totalRecord = $countBuilder->count(); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function downloadDokumen($id, $company_id) |
||||
{ |
||||
if(empty($id) || !is_int((int)$id)) { |
||||
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); |
||||
} |
||||
$document = DokumenProject::find($id); |
||||
$company = Company::find($company_id); |
||||
if(!$document || !$company) { |
||||
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
||||
} |
||||
if(!file_exists($this->pathDocument.$document->file)) { |
||||
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
||||
} |
||||
if($company) { |
||||
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); |
||||
$pathToFile = $destinationPath['pathDocument'].$document->file; |
||||
$name = pathinfo($pathToFile, PATHINFO_FILENAME) . "." . pathinfo($pathToFile, PATHINFO_EXTENSION); |
||||
} |
||||
$headers = [ |
||||
'Content-Disposition' => 'attachment; filename="'.$name.'"' |
||||
]; |
||||
|
||||
return response()->download($pathToFile, $name, $headers); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class KanbanBoard extends Model |
||||
{ |
||||
protected $table = 'kanban_board'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name_board', 'header_color', 'body_color', 'status_progress', 'proyek_id', 'version_gantt_id', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class KanbanCard extends Model |
||||
{ |
||||
protected $table = 'kanban_card'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'activity_id', 'kanban_board_id', 'version_gantt_id', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -1,17 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Satuan extends Model |
||||
{ |
||||
protected $table = 'm_satuan'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Satuan extends Model |
||||
{ |
||||
protected $table = 'm_satuan'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' |
||||
]; |
||||
} |
||||
|
Loading…
Reference in new issue