diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php
index dad48a9..540dd40 100644
--- a/app/Http/Controllers/DivisiController.php
+++ b/app/Http/Controllers/DivisiController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Divisi;
+use Illuminate\Support\Facades\Log;
class DivisiController extends Controller
{
@@ -83,7 +84,11 @@ class DivisiController extends Controller
public function search(Request $request)
{
- $parentDivisi = Divisi::whereNull('parent')->with('children')->get();
+ $companyId = $request->input('columns.0.value');
+ $parentDivisi = Divisi::whereNull('parent')
+ ->where('company_id', $companyId)
+ ->with('children')
+ ->get();
$divisions = [];
foreach ($parentDivisi as $objRow) {
$objRow->children = $this->getAllChildren($objRow);
@@ -95,16 +100,6 @@ class DivisiController extends Controller
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200);
-
- // $payload = $request->all();
- // $dataBuilder = $this->setUpPayload($payload, 'm_divisi');
- // $builder = $dataBuilder['builder'];
- // $countBuilder = $dataBuilder['count'];
- // $dataGet = $builder->get();
- // $totalRecord = $countBuilder->count();
- // return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
- //return $this->list();
- // cant use builder for this case
}
public function list()
diff --git a/app/Http/Controllers/MenuController.php b/app/Http/Controllers/MenuController.php
index 6ff9324..2aa418e 100644
--- a/app/Http/Controllers/MenuController.php
+++ b/app/Http/Controllers/MenuController.php
@@ -23,32 +23,33 @@ class MenuController extends Controller
$result = Menu::create($data);
- if($result){
- return response()->json(['status'=>'success','message'=>'add data menu successfully!','code'=>200], 200);
- }else{
- return response()->json(['status'=>'failed','message'=>'add data menu failed!','code'=>400], 400);
+ if ($result) {
+ return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200], 200);
+ } else {
+ return response()->json(['status' => 'failed', 'message' => 'add data menu 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);
+ public function edit($id)
+ {
+ if (!$id || (int) $id < 0 || $id == "") {
+ return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = Menu::find($id);
- if($result){
- return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
- }else{
- return response()->json(['status'=>'failed','message'=>'failed get data menu, please try again later!','code'=>400], 400);
+ if ($result) {
+ return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
+ } else {
+ return response()->json(['status' => 'failed', 'message' => 'failed get data menu, 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);
+ if (!$id || (int) $id < 0 || $id == "") {
+ return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$this->validate($request, [
'icon' => 'required',
@@ -58,21 +59,21 @@ class MenuController extends Controller
]);
$data = Menu::find($id);
- $request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_menu,name']) : '';
- $request->url !== $data['url'] ? $this->validate($request,['url'=>'unique:m_menu,url']) : '';
+ $request->name !== $data['name'] ? $this->validate($request, ['name' => 'unique:m_menu,name']) : '';
+ $request->url !== $data['url'] ? $this->validate($request, ['url' => 'unique:m_menu,url']) : '';
- if($data){
+ if ($data) {
$result = $data->update($request->all());
- }else{
- return response()->json(['status'=>'failed','message'=>'data menu not found!','code'=>400], 400);
+ } else {
+ return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
die();
}
- if($result){
- return response()->json(['status'=>'success','message'=>'data menu successfully updated!','code'=>200], 200);
- }else{
- return response()->json(['status'=>'failed','message'=>'data menu failed updated!','code'=>400], 400);
+ if ($result) {
+ return response()->json(['status' => 'success', 'message' => 'data menu successfully updated!', 'code' => 200], 200);
+ } else {
+ return response()->json(['status' => 'failed', 'message' => 'data menu failed updated!', 'code' => 400], 400);
}
}
@@ -80,18 +81,18 @@ class MenuController extends Controller
{
$data = Menu::find($id);
- if($data){
+ if ($data) {
$delete = $data->delete();
- }else{
- return response()->json(['status'=>'failed','message'=>'data menu not found!','code'=>400], 400);
+ } else {
+ return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
die();
}
- if($delete){
- return response()->json(['status'=>'success','message'=>'data menu successfully deleted!','code'=>200], 200);
- }else{
- return response()->json(['status'=>'failed','message'=>'data menu failed deleted!','code'=>400], 400);
+ if ($delete) {
+ return response()->json(['status' => 'success', 'message' => 'data menu successfully deleted!', 'code' => 200], 200);
+ } else {
+ return response()->json(['status' => 'failed', 'message' => 'data menu failed deleted!', 'code' => 400], 400);
}
}
@@ -103,41 +104,52 @@ class MenuController extends Controller
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
- return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
+ return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function listMenu($id)
{
- $dataParent = RoleMenu::select("m_menu.*")
- ->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id')
- ->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
- ->whereNull('m_menu.parent_id')
- ->where('m_roles.id', $id)
- ->orderBy('m_menu.sequence', 'ASC')
- ->get();
+ $dataParent = RoleMenu::select(
+ 'm_menu.*',
+ "t_roles_menu.create",
+ "t_roles_menu.read",
+ "t_roles_menu.update",
+ "t_roles_menu.delete"
+ )
+ ->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id')
+ ->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
+ ->whereNull('m_menu.parent_id')
+ ->where('m_roles.id', $id)
+ ->orderBy('m_menu.sequence', 'ASC')
+ ->get();
$finalData = [];
- foreach($dataParent as $data){
+ foreach ($dataParent as $data) {
$data->children = $this->getChildrenMenu($data->id, $id);
$finalData[] = $data;
}
- return response()->json(['status'=>'success','code'=>200,'data'=>$finalData], 200);
+ return response()->json(['status' => 'success', 'code' => 200, 'data' => $finalData], 200);
}
protected function getChildrenMenu($id, $role_id)
{
- $dataChildren = RoleMenu::select("m_menu.*")
- ->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id')
- ->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
- ->where('m_roles.id', $role_id)
- ->where('m_menu.parent_id', $id)
- ->orderBy('m_menu.sequence', 'ASC')
- ->get();
+ $dataChildren = RoleMenu::select(
+ 'm_menu.*',
+ "t_roles_menu.create",
+ "t_roles_menu.read",
+ "t_roles_menu.update",
+ "t_roles_menu.delete"
+ )
+ ->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id')
+ ->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
+ ->where('m_roles.id', $role_id)
+ ->where('m_menu.parent_id', $id)
+ ->orderBy('m_menu.sequence', 'ASC')
+ ->get();
$children = [];
- if($dataChildren){
- foreach($dataChildren as $data)
- {
+ if ($dataChildren) {
+ foreach ($dataChildren as $data) {
$data->children = $this->getChildrenMenu($data->id, $role_id);
$children[] = $data;
}
@@ -150,10 +162,10 @@ class MenuController extends Controller
$data = Menu::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 menu, please try again later!','code'=>400], 400);
+ if ($data) {
+ return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
+ } else {
+ return response()->json(['status' => 'failed', 'message' => 'failed get list menu, please try again later!', 'code' => 400], 400);
}
}
}
diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php
index bfe4f22..b6f9926 100644
--- a/app/Http/Controllers/UserToActivityController.php
+++ b/app/Http/Controllers/UserToActivityController.php
@@ -11,7 +11,8 @@ use Datatables;
class UserToActivityController extends Controller
{
- public function add(Request $request){
+ public function add(Request $request)
+ {
$this->validate($request, [
'activity_id' => 'required',
'user_id' => 'required'
@@ -20,24 +21,25 @@ class UserToActivityController extends Controller
$data = $request->all();
$data['created_by'] = $this->currentName;
- if(!UserToActivity::create($data))
- return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500]);
+ if (!UserToActivity::create($data))
+ return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500]);
- return response()->json(['status'=>'success','message'=>'Data added!', 'code'=> 200]);
+ return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200]);
}
- public function addMultiple(Request $request){
+ public function addMultiple(Request $request)
+ {
$users_id = $request->user_id;
- $users_role = $request->role_proyek_id;
+ $users_role = $request->role_proyek_id;
// $data = UserToActivity::where("activity_id", $request->activity_id);
// if($data){
// $data->delete();
// }
- if(is_array($users_id) && count($users_id) > 0){
+ if (is_array($users_id) && count($users_id) > 0) {
$countRes = 0;
- foreach($users_id as $index => $item){
+ foreach ($users_id as $index => $item) {
$dataInsert = array(
"user_id" => $item,
"activity_id" => $request->activity_id,
@@ -45,89 +47,91 @@ class UserToActivityController extends Controller
"proyek_id" => $request->proyek_id,
"start_date" => $request->start_date,
"end_date" => $request->end_date,
- "created_by" => $this->currentName,
- "version_gantt_id" => $request->version_gantt_id
+ "created_by" => $this->currentName,
+ "version_gantt_id" => $request->version_gantt_id
);
$result = UserToActivity::create($dataInsert);
- if($result){
+ if ($result) {
$countRes++;
- }else{
+ } else {
$countRes--;
}
}
- if($countRes == 0)
- return response()->json(['status'=>'failed' ,'message'=>'Failed to add data!','code'=> 500]);
+ if ($countRes == 0)
+ return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500]);
$allCost = $this->calculateAllCost($request->activity_id, $request->proyek_id);
$dataUpdateCost = array(
- "rencana_biaya"=>$allCost,
- "updated_by"=> $this->currentName
+ "rencana_biaya" => $allCost,
+ "updated_by" => $this->currentName
);
$actUpdate = Activity::find($request->activity_id);
- if($actUpdate){
+ if ($actUpdate) {
$actUpdate->update($dataUpdateCost);
- if($actUpdate->parent_id){
+ if ($actUpdate->parent_id) {
$this->updatedCostPlanning($actUpdate->parent_id);
}
}
- return response()->json(['status'=>'success' ,'message'=>'Data added!','code'=>200]);
- }else{
- return response()->json(['status'=>'success' ,'message'=>'Data added!','code'=>200]);
+ return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200]);
+ } else {
+ return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200]);
}
-
}
- private function updatedCostPlanning($parent_id) {
+ private function updatedCostPlanning($parent_id)
+ {
$sumBiaya = Activity::selectRaw('sum(cast(rencana_biaya as double precision))')
->where("parent_id", $parent_id)
->first();
- if($parent = Activity::find($parent_id)){
+ if ($parent = Activity::find($parent_id)) {
$parent->update([
"rencana_biaya" => $sumBiaya->sum,
]);
}
- }
+ }
- public function update(Request $request, $id){
- if(empty($id) || !is_int((int)$id))
- return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
+ public function update(Request $request, $id)
+ {
+ if (empty($id) || !is_int((int)$id))
+ return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = UserToActivity::find($id);
- if(!$data)
- return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
+ if (!$data)
+ return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
- if(!$data->update($request->all()));
- return response()->json(['status'=>'failed','message'=>'Failed to update!','code'=> 500], 500);
+ if (!$data->update($request->all()));
+ return response()->json(['status' => 'failed', 'message' => 'Failed to update!', 'code' => 500], 500);
- return response()->json(['status'=>'success','message'=>'Data updated!','code'=>200], 200);
+ return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200);
}
public function delete($id)
{
$data = UserToActivity::find($id);
- if(!$data)
- return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400);
+ if (!$data)
+ return response()->json(['status' => 'failed', 'message' => 'data user to activity gantt Project not found!', 'code' => 400], 400);
- if($data->delete()){
- return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
+ if ($data->delete()) {
+ return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
}
- return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=> 500], 500);
+ return response()->json(['status' => 'failed', 'message' => 'Failed to delete!', 'code' => 500], 500);
}
- public function edit($id){
- if(!$id || (int) $id < 0 || $id==""){
- return response()->json(['status'=>'failed','message'=>'id is required!','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 = UserToActivity::find($id);
- if(!$result)
- return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400);
+ if (!$result)
+ return response()->json(['status' => 'failed', 'message' => 'failed get data tools resource, please try again later!', 'code' => 400], 400);
- return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
+ return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
}
public function searchAnalysis(Request $request)
@@ -135,14 +139,21 @@ class UserToActivityController extends Controller
$dataBuilder = $this->setUpPayload($request->all(), 'assign_hr_to_activity');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
- $builder->addSelect(DB::raw('SUM(report_activity_material.qty) as volume_actual'));
- $builder->groupBy("m_activity.id");
- $builder->groupBy("selfTable.id");
- $builder->groupBy("selfTable.start_date");
- $builder->groupBy("selfTable.end_date");
- $builder->groupBy("m_users.name");
- $builder->groupBy("assign_material_to_activity.id");
- $builder->groupBy("m_version_gantt.name_version");
+ $builder->addSelect(DB::raw('SUM(report_activity_material.qty) as volume_actual'));
+ $builder->groupBy("m_activity.name");
+ $builder->groupBy("m_activity.persentase_progress");
+ $builder->groupBy("m_activity.actual_start");
+ $builder->groupBy("m_activity.actual_end");
+ $builder->groupBy("m_activity.planned_start");
+ $builder->groupBy("m_activity.planned_end");
+ $builder->groupBy("m_activity.start_date");
+ $builder->groupBy("m_activity.end_date");
+ $builder->groupBy("m_activity.duration");
+ $builder->groupBy("selfTable.id");
+ $builder->groupBy("selfTable.start_date");
+ $builder->groupBy("selfTable.end_date");
+ $builder->groupBy("assign_material_to_activity.qty_planning");
+ $builder->groupBy("m_version_gantt.name_version");
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
@@ -165,7 +176,7 @@ class UserToActivityController extends Controller
$status = $join_column['status'];
$startDate = date("Y-m-d H:i:sO", strtotime($startDate));
$endDate = date("Y-m-d H:i:sO", strtotime($endDate));
- $builder->where(function ($query) use ($startDate, $endDate) {
+ $builder->where(function ($query) use ($startDate, $endDate) {
$query
->where('m_proyek.mulai_proyek', '>=', $startDate)
->where('m_proyek.akhir_proyek', '<=', $endDate)
@@ -188,22 +199,33 @@ class UserToActivityController extends Controller
$dataGet = $filteredData;
}
// $totalRecord = $countBuilder->count();
- return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>count($dataGet)], 200);
+ return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => count($dataGet)], 200);
}
- public function activityUser(Request $request){
+ public function activityUser(Request $request)
+ {
$payload = $request->all();
$activity = DB::table('m_activity as ma')
- ->select('ahta.id', 'ma.id as activity_id', 'ma.proyek_id', 'ma.name as join_second_name', 'ma.start_date as join_second_start_date',
- 'ma.end_date as join_second_end_date', 'ma.persentase_progress', 'mvg.name_version', 'mp.nama as nama_proyek', 'mp.type_proyek_id')
- ->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'ma.id')
- ->join('m_version_gantt as mvg', 'mvg.id', '=', 'ma.version_gantt_id')
- ->join('m_proyek as mp', 'mp.id', '=', 'ma.proyek_id')
- ->where('ahta.user_id', $payload['user_id'])
- ->where('ma.start_date', '<=', $payload['end_date'])
- ->where('ma.end_date', '>=', $payload['start_date'])
- ->where('ma.proyek_id', $payload['proyek_id'])
- ->get();
+ ->select(
+ 'ahta.id',
+ 'ma.id as activity_id',
+ 'ma.proyek_id',
+ 'ma.name as join_second_name',
+ 'ma.start_date as join_second_start_date',
+ 'ma.end_date as join_second_end_date',
+ 'ma.persentase_progress',
+ 'mvg.name_version',
+ 'mp.nama as nama_proyek',
+ 'mp.type_proyek_id'
+ )
+ ->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'ma.id')
+ ->join('m_version_gantt as mvg', 'mvg.id', '=', 'ma.version_gantt_id')
+ ->join('m_proyek as mp', 'mp.id', '=', 'ma.proyek_id')
+ ->where('ahta.user_id', $payload['user_id'])
+ ->where('ma.start_date', '<=', $payload['end_date'])
+ ->where('ma.end_date', '>=', $payload['start_date'])
+ ->where('ma.proyek_id', $payload['proyek_id'])
+ ->get();
if ($payload['status'] != "") {
$filteredData = [];
@@ -215,7 +237,7 @@ class UserToActivityController extends Controller
}
$activity = $filteredData;
}
- return response()->json(['status'=>'success','code'=>200,'data'=>$activity, 'totalRecord'=>count($activity)], 200);
+ return response()->json(['status' => 'success', 'code' => 200, 'data' => $activity, 'totalRecord' => count($activity)], 200);
}
public function list()
@@ -223,46 +245,47 @@ class UserToActivityController extends Controller
$data = UserToActivity::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 user to activity gantt, please try again later!','code'=>400], 400);
+ if ($data) {
+ return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
+ } else {
+ return response()->json(['status' => 'failed', 'message' => 'failed get list user to activity gantt, please try again later!', 'code' => 400], 400);
}
- }
+ }
- public function listFiltered(Request $request)
+ public function listFiltered(Request $request)
{
- $startDate = $request->start_date;
- $endDate = $request->end_date;
- $userId = $request->user_id;
- $proyekId = $request->proyek_id;
-
- if (isset($proyekId)) {
- $data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date')
- ->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id')
- ->where('m_activity.start_date', '=', $startDate)
- ->where('m_activity.end_date', '=', $endDate)
- ->where('assign_hr_to_activity.user_id', '=', $userId)
- ->where('assign_hr_to_activity.proyek_id', '=', $proyekId)
- ->get();
- }else {
- $data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date')
- ->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id')
- ->where('m_activity.start_date', '=', $startDate)
- ->where('m_activity.end_date', '=', $endDate)
- ->where('assign_hr_to_activity.user_id', '=', $userId)
- ->get();
- }
- $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 user to activity gantt, please try again later!','code'=>400], 400);
+ $startDate = $request->start_date;
+ $endDate = $request->end_date;
+ $userId = $request->user_id;
+ $proyekId = $request->proyek_id;
+
+ if (isset($proyekId)) {
+ $data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date')
+ ->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id')
+ ->where('m_activity.start_date', '=', $startDate)
+ ->where('m_activity.end_date', '=', $endDate)
+ ->where('assign_hr_to_activity.user_id', '=', $userId)
+ ->where('assign_hr_to_activity.proyek_id', '=', $proyekId)
+ ->get();
+ } else {
+ $data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date')
+ ->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id')
+ ->where('m_activity.start_date', '=', $startDate)
+ ->where('m_activity.end_date', '=', $endDate)
+ ->where('assign_hr_to_activity.user_id', '=', $userId)
+ ->get();
+ }
+ $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 user to activity gantt, please try again later!', 'code' => 400], 400);
}
}
- public function datatables(Request $request){
+ public function datatables(Request $request)
+ {
$id_activity = $request->query('idact');
$data = UserToActivity::select("assign_hr_to_activity.id as id", "assign_hr_to_activity.start_date", "assign_hr_to_activity.end_date", "u.name as user_name", "mrp.name as role_name")
->join("m_role_proyek as mrp", "mrp.id", "=", "assign_hr_to_activity.role_proyek_id")
@@ -271,8 +294,8 @@ class UserToActivityController extends Controller
->get();
return Datatables::of($data)
->addIndexColumn()
- ->addColumn('action', function($row){
- $actionBtn = '';
+ ->addColumn('action', function ($row) {
+ $actionBtn = '';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
diff --git a/app/Models/Company.php b/app/Models/Company.php
index 85e5868..86d97fd 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -34,6 +34,7 @@ class Company extends Model
'updated_by',
'cluster',
'type_account',
- 'date_register'
+ 'date_register',
+ 'discount_id'
];
}
diff --git a/app/Models/RoleMenu.php b/app/Models/RoleMenu.php
index 3540ea6..70fa437 100644
--- a/app/Models/RoleMenu.php
+++ b/app/Models/RoleMenu.php
@@ -12,6 +12,6 @@ class RoleMenu extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
- 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by'
+ 'role_id', 'menu_id', 'create', 'read', 'update', 'delete', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
}
diff --git a/app/Models/User.php b/app/Models/User.php
index d6fe343..fe591b3 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable;
use Carbon\Carbon;
-class User extends Model implements AuthenticatableContract, AuthorizableContract,JWTSubject
+class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
{
use Authenticatable, Authorizable, HasFactory;
@@ -24,7 +24,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
protected $fillable = [
'name', 'email', 'role_id', 'username', 'session_login', 'phone_number', 'email', 'address',
'fcm_token', 'gender', 'birth_place', 'birth_date', 'blood_type', 'ktp_number', 'working_hours',
- 'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource'
+ 'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource', 'discount_id'
];
const CREATED_AT = 'created_at';
@@ -71,44 +71,42 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
* @return array of carbon or NULL in case HOLIDAY
*/
- public function getWorkingTime(Carbon $ts, $f = "08:00", $t = "17:00", $tz = self::DEFAULT_TZ)
+ public function getWorkingTime(Carbon $ts, $f = "08:00", $t = "17:00", $tz = self::DEFAULT_TZ)
{
$workingTime = array(
- "from"=> Carbon::createFromTimeString($f, $tz),
- "to"=> Carbon::createFromTimeString($t, $tz)
+ "from" => Carbon::createFromTimeString($f, $tz),
+ "to" => Carbon::createFromTimeString($t, $tz)
);
- $userShift = UserShift::where('user_id', )
+ $userShift = UserShift::where('user_id',)
->orderByDesc('from_date')
->first();
$shift = null;
- if ($userShift !== null)
- {
+ if ($userShift !== null) {
$shiftId = null;
- switch ($ts->shortEnglishDayOfWeek)
- {
- case "Mon":
- $shiftId = $userShift->mon_shift_id;
- break;
- case "Tue":
- $shiftId = $userShift->tue_shift_id;
- break;
- case "Wed":
- $shiftId = $userShift->wed_shift_id;
- break;
- case "Thu":
- $shiftId = $userShift->thu_shift_id;
- break;
- case "Fri":
- $shiftId = $userShift->fri_shift_id;
- break;
- case "Sat":
- $shiftId = $userShift->sat_shift_id;
- break;
- case "Sun":
- $shiftId = $userShift->sun_shift_id;
- break;
+ switch ($ts->shortEnglishDayOfWeek) {
+ case "Mon":
+ $shiftId = $userShift->mon_shift_id;
+ break;
+ case "Tue":
+ $shiftId = $userShift->tue_shift_id;
+ break;
+ case "Wed":
+ $shiftId = $userShift->wed_shift_id;
+ break;
+ case "Thu":
+ $shiftId = $userShift->thu_shift_id;
+ break;
+ case "Fri":
+ $shiftId = $userShift->fri_shift_id;
+ break;
+ case "Sat":
+ $shiftId = $userShift->sat_shift_id;
+ break;
+ case "Sun":
+ $shiftId = $userShift->sun_shift_id;
+ break;
}
if ($shiftId === null) {
@@ -123,8 +121,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
- if ($shift !== null)
- {
+ if ($shift !== null) {
$from = Carbon::createFromTimeString($shift->start_time, $tz)
->subMinutes($shift->flex_time_minute);
$to = Carbon::createFromTimeString($shift->end_time, $tz)
@@ -146,20 +143,18 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
/**
* Get presence status
*/
- public function presenceStatus(Carbon $at = null, $tz = self::DEFAULT_TZ)
+ public function presenceStatus(Carbon $at = null, $tz = self::DEFAULT_TZ)
{
$ts = $at;
- if ($at !== null)
- {
+ if ($at !== null) {
$ts = Carbon::now($tz);
}
$tsSec = $ts->secondsSinceMidnight();
$status = "";
$wt = $this->getWorkingTime($ts, $tz);
- if ($wt === null)
- {
+ if ($wt === null) {
$status = self::HOLIDAY;
} else {
$from = $wt->from;
@@ -168,7 +163,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
$tsTo = $to->secondsSinceMidnight();
if ($from->greaterThan($to)) {
- $tsMid = 24*60*60 - $tsFrom;
+ $tsMid = 24 * 60 * 60 - $tsFrom;
if ($tsSec >= $tsFrom || $tsSec < $tsTo) {
$status = self::INSIDE;
} else {
@@ -194,10 +189,10 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
return array(
- "status"=>$status,
- "ts" => $ts,
+ "status" => $status,
+ "ts" => $ts,
"clock_in" => $clockIn,
"clock_out" => $clockOut
);
- }
+ }
}