farhantock
7 months ago
72 changed files with 14838 additions and 10556 deletions
@ -0,0 +1,28 @@
|
||||
<?php |
||||
|
||||
namespace App\Console\Commands; |
||||
|
||||
use App\Models\HierarchyFtth; |
||||
use Illuminate\Console\Command; |
||||
use App\Helpers\MasterFunctionsHelper; |
||||
use App\Models\Project; |
||||
|
||||
class CalculateProgressGantt extends Command |
||||
{ |
||||
protected $signature = 'calculate:progressgantt {hierarchy_id}'; |
||||
|
||||
protected $description = 'Calculate Progress Gantt'; |
||||
|
||||
public function handle() |
||||
{ |
||||
$hierarchy_id = $this->argument('hierarchy_id'); |
||||
$hierarchy = HierarchyFtth::findOrFail($hierarchy_id); |
||||
$project = Project::find($hierarchy->project_id); |
||||
|
||||
$data = MasterFunctionsHelper::calculateSCurveForProgressTree($hierarchy_id); |
||||
|
||||
$hierarchy->bobot_planning = 100; |
||||
$hierarchy->progress =round(((int) end($data[0]['data']['percentageReal']) / (int) end($data[0]['data']['percentagePlan'])) * 100, 2); |
||||
$hierarchy->save(); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,115 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\ContactSales; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class ContactSalesController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'role' => 'required', |
||||
'email' => 'required', |
||||
'number_phone' => 'required', |
||||
'status' => 'required', |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = '@System'; |
||||
$data['status'] = 'New Request'; |
||||
|
||||
$result = ContactSales::create($data); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Your message has been successfully received by our Sales team! Someone from our team will be in touch with you shortly.', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Your message has been failed!', '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 = ContactSales::find($id); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'failed get data Contact Sales, please try again later!', '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 = ContactSales::find($id); |
||||
|
||||
|
||||
if ($data) { |
||||
$result = $data->update($request->all()); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'data Contact Sales not found!', 'code' => 400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'message' => 'data Contact Sales successfully updated!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'data Contact Sales failed updated!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ContactSales::find($id); |
||||
|
||||
if ($data) { |
||||
$delete = $data->delete(); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'data Contact Sales not found!', 'code' => 400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if ($delete) { |
||||
return response()->json(['status' => 'success', 'message' => 'data Contact Sales successfully deleted!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'data Contact Sales failed deleted!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_contact_sales'); |
||||
$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() |
||||
{ |
||||
$data = ContactSales::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if ($data) { |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'failed get list Contact Sales, please try again later!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,116 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\Demo; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class DemoController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'role' => 'required', |
||||
'email' => 'required', |
||||
'number_phone' => 'required', |
||||
'status' => 'required', |
||||
'message' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = '@System'; |
||||
$data['status'] = 'New Request'; |
||||
|
||||
$result = Demo::create($data); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Request Demo successfully!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Request Demo failed!', '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 = Demo::find($id); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'failed get data Demo, please try again later!', '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 = Demo::find($id); |
||||
|
||||
|
||||
if ($data) { |
||||
$result = $data->update($request->all()); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'data Demo not found!', 'code' => 400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'message' => 'data Demo successfully updated!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'data Demo failed updated!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Demo::find($id); |
||||
|
||||
if ($data) { |
||||
$delete = $data->delete(); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'data Demo not found!', 'code' => 400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if ($delete) { |
||||
return response()->json(['status' => 'success', 'message' => 'data Demo successfully deleted!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'data Demo failed deleted!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_demo'); |
||||
$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() |
||||
{ |
||||
$data = Demo::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if ($data) { |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'failed get list Demo, please try again later!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,92 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProductTransaction; |
||||
|
||||
class ProductTransactionController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'company_id' => 'required|integer', |
||||
'type_paket' => 'required|string', |
||||
'amount' => 'required', |
||||
'exp_ospro' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
$result = ProductTransaction::create($data); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Add Transaction successfully!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Add Transaction failed!', '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 = ProductTransaction::find($id); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Failed get data transaction, please try again later!', '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 = ProductTransaction::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data transaction not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Data transaction successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data transaction failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 't_transaction'); |
||||
$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() |
||||
{ |
||||
$data = ProductTransaction::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if ($data) { |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'failed get list Transaction, please try again later!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectExpenditure; |
||||
|
||||
class ProjectExpenditureController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
// Set Unique |
||||
$result = ProjectExpenditure::query() |
||||
->where([ |
||||
['company_id',$data['company_id']], |
||||
['name', $data['name']] |
||||
])->first(); |
||||
if($result) { |
||||
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500); |
||||
die; |
||||
} |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
if(!ProjectExpenditure::create($data)) |
||||
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200); |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id=="") |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
|
||||
if(!$result = ProjectExpenditure::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id=="") |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
|
||||
if(!$data = ProjectExpenditure::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'data project expenditure not found!','code'=>400], 400); |
||||
|
||||
if(!$data->update($request->all())) |
||||
return response()->json(['status'=>'failed','message'=>'data project expenditure failed updated!','code'=>400], 400); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200); |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
|
||||
if(!$data = ProjectExpenditure::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'data project expenditure not found!','code'=>400], 400); |
||||
|
||||
if(!$data->delete()) |
||||
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200); |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_expenditure'); |
||||
$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() |
||||
{ |
||||
$data = ProjectExpenditure::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if(!$data) |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project expenditure, please try again later!','code'=>400], 400); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectFinancialHealth; |
||||
|
||||
class ProjectFinancialHealthController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
// Set Unique |
||||
$result = ProjectFinancialHealth::query() |
||||
->where([ |
||||
['company_id',$data['company_id']], |
||||
['name', $data['name']] |
||||
])->first(); |
||||
if($result) { |
||||
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500); |
||||
die; |
||||
} |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
if(!ProjectFinancialHealth::create($data)) |
||||
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200); |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id=="") |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
|
||||
if(!$result = ProjectFinancialHealth::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id=="") |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
|
||||
if(!$data = ProjectFinancialHealth::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'data financial health not found!','code'=>400], 400); |
||||
|
||||
if(!$data->update($request->all())) |
||||
return response()->json(['status'=>'failed','message'=>'Data financial health failed updated!','code'=>400], 400); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200); |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
|
||||
if(!$data = ProjectFinancialHealth::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'data financial health not found!','code'=>400], 400); |
||||
|
||||
if(!$data->delete()) |
||||
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200); |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_financial_health'); |
||||
$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() |
||||
{ |
||||
$data = ProjectFinancialHealth::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if(!$data) |
||||
return response()->json(['status'=>'failed','message'=>'failed get list financial health, please try again later!','code'=>400], 400); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectInvoice; |
||||
|
||||
class ProjectInvoiceController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
// Set Unique |
||||
$result = ProjectInvoice::query() |
||||
->where([ |
||||
['company_id',$data['company_id']], |
||||
['name', $data['name']] |
||||
])->first(); |
||||
if($result) { |
||||
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500); |
||||
die; |
||||
} |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
if(!ProjectInvoice::create($data)) |
||||
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200); |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id=="") |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
|
||||
if(!$result = ProjectInvoice::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id=="") |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
|
||||
if(!$data = ProjectInvoice::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'data project invoice not found!','code'=>400], 400); |
||||
|
||||
if(!$data->update($request->all())) |
||||
return response()->json(['status'=>'failed','message'=>'data project invoice failed updated!','code'=>400], 400); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200); |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
|
||||
if(!$data = ProjectInvoice::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'data project invoice not found!','code'=>400], 400); |
||||
|
||||
if(!$data->delete()) |
||||
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200); |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_invoice'); |
||||
$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() |
||||
{ |
||||
$data = ProjectInvoice::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if(!$data) |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project invoice, please try again later!','code'=>400], 400); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectScheduleHealth; |
||||
|
||||
class ProjectScheduleHealthController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
// Set Unique |
||||
$result = ProjectScheduleHealth::query() |
||||
->where([ |
||||
['company_id',$data['company_id']], |
||||
['name', $data['name']] |
||||
])->first(); |
||||
if($result) { |
||||
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500); |
||||
die; |
||||
} |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
if(!ProjectScheduleHealth::create($data)) |
||||
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200); |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id=="") |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
|
||||
if(!$result = ProjectScheduleHealth::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id=="") |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
|
||||
if(!$data = ProjectScheduleHealth::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'data schedule health not found!','code'=>400], 400); |
||||
|
||||
if(!$data->update($request->all())) |
||||
return response()->json(['status'=>'failed','message'=>'data schedule health failed updated!','code'=>400], 400); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200); |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
|
||||
if(!$data = ProjectScheduleHealth::find($id)) |
||||
return response()->json(['status'=>'failed','message'=>'data schedule health not found!','code'=>400], 400); |
||||
|
||||
if(!$data->delete()) |
||||
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200); |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_schedule_health'); |
||||
$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() |
||||
{ |
||||
$data = ProjectScheduleHealth::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if(!$data) |
||||
return response()->json(['status'=>'failed','message'=>'failed get list schedule health, please try again later!','code'=>400], 400); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,81 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\RefferalCode; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class RefferalCodeController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'code' => 'required|unique:refferal_code,code', |
||||
'exp' => 'nullable', |
||||
'type' => 'nullable', |
||||
'allocation' => 'nullable' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = RefferalCode::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success', 'data'=> $result, 'message'=>'Add refferal code successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Add refferal Code failed!','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 = RefferalCode::find($id); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'Failed get refferal code, please try again later!', '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 = RefferalCode::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Refferal code not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Refferal code successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Refferal code failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
$payload = $request->all(); |
||||
$dataBuilder = $this->setUpPayload($payload, 'refferal_code'); |
||||
$builder = $dataBuilder['builder']; |
||||
$countBuilder = $dataBuilder['count']; |
||||
$dataGet = $builder->get(); |
||||
$totalRecord = $countBuilder->count(); |
||||
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); |
||||
} |
||||
} |
@ -0,0 +1,344 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Carbon\Carbon; |
||||
use Illuminate\Support\Str; |
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Support\Facades\{DB,Log}; |
||||
use App\Models\{User, Company, HumanResource, Menu, ProductTransaction, RefferalCode, Role, RoleMenu, MenuCompany}; |
||||
|
||||
const URL_EMAIL = 'https://notifapp.odm-iu.com/service-mail/notif_mail.php'; |
||||
class UserRegisterController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
DB::beginTransaction(); |
||||
$this->validate($request, [ |
||||
'cluster' => 'required|string', |
||||
'address' => 'required|string', |
||||
'email' => 'required|string', |
||||
'type_paket' => ($request->type_account === 'Personal' ? 'required' : 'nullable') . '|in:Basic,Free', |
||||
'phone_no' => 'required', |
||||
'type_account' => 'string|in:Personal,Company', |
||||
'company_name' => 'required|string', |
||||
'username' => 'required|string' |
||||
]); |
||||
try { |
||||
$data = $request->all(); |
||||
|
||||
$company_name = $data['company_name']; |
||||
$type_account = $data['type_account']; |
||||
$refferal = $request->refferal ? $data['refferal'] : null; |
||||
$cluster = $data['cluster']; |
||||
$address = $data['address']; |
||||
$phone_no = $data['phone_no']; |
||||
$email = $data['email']; |
||||
$username = $data['username']; |
||||
$type_paket = $data['type_paket']; |
||||
$company_address = $request->type_account === 'Company' ? $data['companyAddress'] : ''; |
||||
$full_name = $request->type_account === 'Personal' ? $data['full_name'] : ''; |
||||
|
||||
// check email & username already exist |
||||
$emailExists = Company::where('email', $email)->exists() || User::where('email', $email)->exists(); |
||||
if ($emailExists) { |
||||
return response()->json(['status' => 'failed', 'message' => 'Email already exists, please check again!', 'code' => 500], 500); |
||||
} |
||||
$usernameExists = User::where('username', $username)->exists(); |
||||
if ($usernameExists) { |
||||
return response()->json(['status' => 'failed', 'message' => 'Username already exists, please check again!', 'code' => 500], 500); |
||||
} |
||||
|
||||
// Get last registration number |
||||
$getCompany = $this->getCompany(); |
||||
|
||||
$formDataCompany = array( |
||||
'company_name' => $company_name, |
||||
'newRegistrationNumber' => $getCompany['newRegistrationNumber'], |
||||
'cluster' => $cluster, |
||||
'phone_no' => $phone_no, |
||||
'email' => $email, |
||||
'address' => $address, |
||||
'type_account' => $type_account, |
||||
'username' => $username, |
||||
'type_paket' => $type_paket, |
||||
'companyAddress' => $company_address, |
||||
'full_name' => $full_name |
||||
); |
||||
|
||||
if(empty($refferal)) { |
||||
$addCompany = $this->addCompany($formDataCompany, null); |
||||
} else { |
||||
$getRefferal = $this->getRefferalCode($refferal); |
||||
if(empty($getRefferal)) { |
||||
return response()->json(['status' => 'failed', 'message' => 'Refferal code not found!', 'code' => 404], 404); |
||||
} |
||||
$addCompany = $this->addCompany($formDataCompany, (int)$getRefferal['id']); |
||||
} |
||||
|
||||
if(empty($addCompany)) { |
||||
return; |
||||
} |
||||
|
||||
$addRole = $this->addRole((int)$addCompany['id']); |
||||
if(empty($addRole)) { |
||||
return; |
||||
} |
||||
|
||||
$addHR = $this->addHR((int)$addCompany['id'], (int)$addRole['id'], $formDataCompany); |
||||
if(empty($addHR)) { |
||||
return; |
||||
} |
||||
|
||||
$getMenu = $this->getMenu(); |
||||
if(empty($getMenu)) { |
||||
return; |
||||
} |
||||
$this->addTransaction((int)$addCompany['id'], $formDataCompany); |
||||
|
||||
$addMenuCompany = $this->addMenuCompany($getMenu, (int)$addCompany['id']); |
||||
if(empty($addMenuCompany)) { |
||||
return; |
||||
} |
||||
$addMenuRole = $this->addMenuRole($getMenu, (int)$addRole['id']); |
||||
if(empty($addMenuRole)) { |
||||
return; |
||||
} |
||||
DB::commit(); |
||||
return response()->json(['status' => 'success', 'message' => 'Register is successful, please check your email!', 'generateRandom' => $addHR['generateRandom'], 'code' => 200], 200); |
||||
} catch (\Throwable $th) { |
||||
DB::rollBack(); |
||||
Log::channel('daily')->error($th->getMessage()); |
||||
return response()->json(['status' => 'failed', 'message' => 'Failed to register, please check again!', 'code' => 500], 500); |
||||
} |
||||
} |
||||
|
||||
protected function getRefferalCode($refferal) |
||||
{ |
||||
$result = RefferalCode::query() |
||||
->select('id','code','amount','exp','type','allocation','description') |
||||
->where('code', $refferal) |
||||
->first(); |
||||
return $result; |
||||
} |
||||
|
||||
protected function addCompany($formData, $id_refferal) |
||||
{ |
||||
$formData = array( |
||||
'company_name' => $formData['company_name'], |
||||
'registration_no' => $formData['newRegistrationNumber'], |
||||
'cluster' => $formData['cluster'], |
||||
'date_register' => Carbon::now(), |
||||
'template_id' => 1, |
||||
'email' => $formData['email'], |
||||
'address' => $formData['type_account'] === 'Company' ? $formData['companyAddress'] : $formData['address'], |
||||
'phone_no' => $formData['phone_no'], |
||||
'type_account' => $formData['type_account'], |
||||
'is_active' => true, |
||||
'discount_id' => $id_refferal === null ? null : $id_refferal |
||||
); |
||||
$result = Company::create($formData); |
||||
return $result; |
||||
} |
||||
|
||||
protected function addRole($id_company) |
||||
{ |
||||
$formData = [ |
||||
'name' => 'Admin', |
||||
'company_id' => $id_company, |
||||
'description' => '-' |
||||
]; |
||||
$result = Role::create($formData); |
||||
return $result; |
||||
} |
||||
|
||||
protected function addHR($id_company, $id_role, $data) |
||||
{ |
||||
$generateRandom = Str::random(8); |
||||
$formData = array( |
||||
'name'=> $data['type_account'] === 'Company' ? $data['username'] : $data['full_name'], |
||||
'phone_number'=> $data['phone_no'], |
||||
'email'=> $data['email'], |
||||
'username' => $data['username'], |
||||
'password'=> md5($generateRandom), |
||||
'role_id'=> $id_role, |
||||
'ktp_number'=> $data['type_account'] === 'Company' ? 'CP-'. $generateRandom : 'PR-' . $generateRandom, |
||||
'employee_type'=> 'employee', |
||||
'address' => $data['address'], |
||||
'status_resource'=> 'active', |
||||
'company_id'=> $id_company |
||||
); |
||||
$result = HumanResource::create($formData); |
||||
if(!empty($result)) { |
||||
$this->sendEmail($data['email'], $generateRandom); |
||||
} |
||||
return [ |
||||
'result' => $result, |
||||
'generateRandom' => $generateRandom |
||||
]; |
||||
} |
||||
|
||||
protected function addMenuCompany($baseDataMenu, $id_company) |
||||
{ |
||||
$data = MenuCompany::where('company_id', $id_company); |
||||
if($data->exists()){ |
||||
$data->delete(); |
||||
} |
||||
if (is_object($baseDataMenu) && count($baseDataMenu) > 0 && isset($baseDataMenu)) { |
||||
$countRes = 0; |
||||
foreach ($baseDataMenu as $menu) { |
||||
$dataInsert = array( |
||||
"menu_id" => $menu['id'], |
||||
"parent_menu_id" => $menu['parent_id'], |
||||
"company_id" => $id_company, |
||||
"icon" => $menu['icon'], |
||||
"alias_name" => $menu['alias_name'], |
||||
"url" => $menu['url'], |
||||
"sequence" => $menu['sequence'], |
||||
"created_by" => $this->currentName |
||||
); |
||||
$result = MenuCompany::create($dataInsert); |
||||
if ($result) { |
||||
$countRes++; |
||||
} else { |
||||
$countRes--; |
||||
} |
||||
} |
||||
if ($countRes > 0) { |
||||
return $result; |
||||
} else { |
||||
die(); |
||||
} |
||||
} else { |
||||
die(); |
||||
} |
||||
} |
||||
|
||||
protected function addMenuRole($baseDataMenu, $id_role) |
||||
{ |
||||
if (is_object($baseDataMenu) && count($baseDataMenu) > 0 && isset($baseDataMenu)) { |
||||
$countRes = 0; |
||||
foreach ($baseDataMenu as $menu) { |
||||
$dataInsert = array( |
||||
"menu_id" => $menu['id'], |
||||
"role_id" => $id_role, |
||||
); |
||||
$result = RoleMenu::create($dataInsert); |
||||
if ($result) { |
||||
$countRes++; |
||||
} else { |
||||
$countRes--; |
||||
} |
||||
} |
||||
if ($countRes > 0) { |
||||
return $result; |
||||
} else { |
||||
die(); |
||||
} |
||||
} else { |
||||
die(); |
||||
} |
||||
} |
||||
|
||||
protected function addTransaction($id_company, $data) |
||||
{ |
||||
$currentDate = Carbon::now(); |
||||
$finalDate = $currentDate->copy()->addDays(30); |
||||
if(is_array($data)) { |
||||
$formData = array( |
||||
'company_id' => $id_company, |
||||
'type_paket' => $data['type_paket'], |
||||
'exp_ospro' => $finalDate, |
||||
'amount' => $data['type_paket'] === 'Free' ? 0 : 250000 |
||||
); |
||||
$result = ProductTransaction::create($formData); |
||||
return $result; |
||||
} |
||||
} |
||||
|
||||
protected function getMenu() |
||||
{ |
||||
$result = Menu::query() |
||||
->select("id", "name", "parent_id", "alias_name", "icon", "url", "sequence") |
||||
->whereNotIn('alias_name', ['Dashboard Customer', 'Registration Management', 'Demo Management']) |
||||
->get(); |
||||
return $result; |
||||
} |
||||
|
||||
protected function getCompany() |
||||
{ |
||||
$newRegistrationNumber = ''; |
||||
$company = Company::query() |
||||
->select('id','type_account','registration_no','discount_id') |
||||
->orderByDesc('id') |
||||
->first(); |
||||
|
||||
if(!empty($company)) { |
||||
$lastRegistrationNumber = $company['registration_no']; |
||||
$lastNumber = (int)preg_replace('/\D/', '', $lastRegistrationNumber); |
||||
$newNumber = $lastNumber + 1; |
||||
$newRegistrationNumber = 'RG-'. $newNumber; |
||||
} else{ |
||||
return false; |
||||
} |
||||
return [ |
||||
'newRegistrationNumber' => $newRegistrationNumber |
||||
]; |
||||
} |
||||
|
||||
public function sendEmail($email, $password) |
||||
{ |
||||
$user = User::select('email', 'name', 'username')->where('email', $email)->first(); |
||||
if (!$user) { |
||||
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400); |
||||
} else { |
||||
$this->reqHttpCurl($email, $password, $user->username, $user->name); |
||||
return response()->json(['status' => 'error', 'code'=>400, 'message' => 'e-mail not found '], 400); |
||||
} |
||||
} |
||||
|
||||
private function reqHttpCurl($email, $password, $username, $name) |
||||
{ |
||||
$postData = [ |
||||
"to" => $email, |
||||
"name" => $name, |
||||
"username" => $username, |
||||
"password" => $password, |
||||
"from" => "app.integrasia@integrasiautama.com", |
||||
"alias_from" => "OSPRO", |
||||
"subject" => "Registration OSPRO", |
||||
"body" => "registration-ospro" |
||||
]; |
||||
|
||||
$curl = curl_init(); |
||||
|
||||
curl_setopt_array($curl, array( |
||||
CURLOPT_URL => URL_EMAIL, |
||||
CURLOPT_RETURNTRANSFER => true, |
||||
CURLOPT_ENCODING => "", |
||||
CURLOPT_MAXREDIRS => 10, |
||||
CURLOPT_TIMEOUT => 30000, |
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
||||
CURLOPT_CUSTOMREQUEST => "POST", |
||||
CURLOPT_POSTFIELDS => json_encode($postData), |
||||
CURLOPT_HTTPHEADER => array( |
||||
// Set here requred headers |
||||
"accept: */*", |
||||
"accept-language: en-US,en;q=0.8", |
||||
"content-type: application/json", |
||||
), |
||||
)); |
||||
|
||||
$response = curl_exec($curl); |
||||
$err = curl_error($curl); |
||||
|
||||
curl_close($curl); |
||||
|
||||
if ($err) { |
||||
echo "cURL Error #:" . $err; |
||||
} else { |
||||
print_r(json_decode($response)); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ContactSales extends Model |
||||
{ |
||||
protected $table = 'm_contact_sales'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', |
||||
'company_name', |
||||
'email', |
||||
'role', |
||||
'number_phone', |
||||
'status', |
||||
'message', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by', |
||||
]; |
||||
} |
@ -0,0 +1,26 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Demo extends Model |
||||
{ |
||||
protected $table = 'm_demo'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', |
||||
'email', |
||||
'role', |
||||
'number_phone', |
||||
'status', |
||||
'message', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by', |
||||
]; |
||||
} |
@ -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' |
||||
]; |
||||
} |
@ -0,0 +1,25 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ProductTransaction extends Model |
||||
{ |
||||
protected $table = 't_transaction'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'company_id', |
||||
'type_paket', |
||||
'amount', |
||||
'exp_ospro', |
||||
'pay_date', |
||||
'created_at', |
||||
'updated_at', |
||||
'created_by', |
||||
'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ProjectExpenditure extends Model |
||||
{ |
||||
protected $table = 'm_proyek_expenditure'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ProjectFinancialHealth extends Model |
||||
{ |
||||
protected $table = 'm_proyek_financial_health'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ProjectInvoice extends Model |
||||
{ |
||||
protected $table = 'm_proyek_invoice'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ProjectScheduleHealth extends Model |
||||
{ |
||||
protected $table = 'm_proyek_schedule_health'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' |
||||
]; |
||||
} |
@ -0,0 +1,28 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class RefferalCode extends Model |
||||
{ |
||||
protected $table = 'refferal_code'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'code', |
||||
'amount', |
||||
'exp', |
||||
'type', |
||||
'allocation', |
||||
'description', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by', |
||||
'deleted_at', |
||||
'deleted_by' |
||||
]; |
||||
} |
Loading…
Reference in new issue