Browse Source

Merge branch 'staging' of https://git.oslog.id/ordo/adw-backend into dev-wahyu

pull/3/head
wahyu 1 year ago
parent
commit
f970fb37bc
  1. 6
      app/Http/Controllers/DashboardBoDController.php
  2. 3
      app/Http/Controllers/DivisiController.php
  3. 21
      app/Http/Controllers/PresenceController.php
  4. 2
      app/Http/Controllers/ProjectController.php
  5. 5
      app/Http/Controllers/UserToProyekController.php
  6. 83
      app/Models/Divisi.php

6
app/Http/Controllers/DashboardBoDController.php

@ -271,7 +271,7 @@ class DashboardBoDController extends Controller
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name','parent','color')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();
@ -304,7 +304,7 @@ class DashboardBoDController extends Controller
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name', 'color')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();
@ -358,4 +358,4 @@ class DashboardBoDController extends Controller
'total_manpowers' => User::count() 'total_manpowers' => User::count()
], 200); ], 200);
} }
} }

3
app/Http/Controllers/DivisiController.php

@ -21,7 +21,8 @@ class DivisiController extends Controller
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required|unique:m_divisi,name', 'name' => 'string|required|unique:m_divisi,name',
'description' => 'nullable|string', 'description' => 'nullable|string',
'parent' => 'nullable|integer' 'parent' => 'nullable|integer',
'color'=>'nullable|string|max:10'
]); ]);
$data = $request->all(); $data = $request->all();

21
app/Http/Controllers/PresenceController.php

@ -26,11 +26,11 @@ class PresenceController extends Controller
$statusBoundary = true; $statusBoundary = true;
} }
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first(); $statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) { if (!$statusRestriction->status_boundary) {
$statusBoundary = true; $statusBoundary = true;
} }
// not assign // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => $statusBoundary
@ -38,7 +38,7 @@ class PresenceController extends Controller
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200);
} }
// assign and not in boundary // assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => true 'boundary' => true
@ -65,7 +65,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate, "clock_in_out_id" => $resultUpdate,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->type, "type" => $request->type,
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName
@ -86,7 +86,8 @@ class PresenceController extends Controller
} }
$onlyDate = date_format($date,"Y-m-d"); $onlyDate = date_format($date,"Y-m-d");
$clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; // $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name;
$clock_in_loc = "test";
$dataAdd = array( $dataAdd = array(
'user_id'=> $request->user_id, 'user_id'=> $request->user_id,
@ -139,11 +140,11 @@ class PresenceController extends Controller
$statusBoundary = true; $statusBoundary = true;
} }
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first(); $statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) { if (!$statusRestriction->status_boundary) {
$statusBoundary = true; $statusBoundary = true;
} }
// not assign // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => $statusBoundary
@ -151,7 +152,7 @@ class PresenceController extends Controller
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200);
} }
// assign and not in boundary // assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => true 'boundary' => true
@ -178,7 +179,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate, "clock_in_out_id" => $resultUpdate,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->clock_in_out['type'], "type" => $request->clock_in_out['type'],
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName
@ -232,7 +233,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $result->id, "clock_in_out_id" => $result->id,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->type, "type" => $request->type,
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName

2
app/Http/Controllers/ProjectController.php

@ -77,7 +77,7 @@ class ProjectController extends Controller
$result = Project::query() $result = Project::query()
->from('m_proyek AS mp') ->from('m_proyek AS mp')
->where('mp.id', $id) ->where('mp.id', $id)
->selectRaw('kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,area_kerja,lokasi_kantor,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status'); ->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status');
if (!is_null($result->first()['divisi_id'])) { if (!is_null($result->first()['divisi_id'])) {
$result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id') $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')

5
app/Http/Controllers/UserToProyekController.php

@ -33,7 +33,10 @@ class UserToProyekController extends Controller
public function addMultiple(Request $request){ public function addMultiple(Request $request){
$user_IDs = $request->user_id; $user_IDs = $request->user_id;
$data = UserToProyek::where("proyek_id", $request->proyek_id); $data = UserToProyek::where([
["proyek_id" , $request->proyek_id],
['is_customer',true]
]);
if($data){ if($data){
$data->delete(); $data->delete();

83
app/Models/Divisi.php

@ -1,41 +1,42 @@
<?php <?php
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Divisi extends Model class Divisi extends Model
{ {
protected $table = 'm_divisi'; protected $table = 'm_divisi';
const CREATED_AT = 'created_at'; const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'name',
'parent', 'parent',
'description', 'description',
'created_at', 'color',
'created_by', 'created_at',
'updated_at', 'created_by',
'updated_by' 'updated_at',
]; 'updated_by'
];
public static function boot() {
parent::boot(); public static function boot() {
parent::boot();
static::deleting(function($data) {
$data->children()->delete(); static::deleting(function($data) {
}); $data->children()->delete();
} });
}
public function parent()
{ public function parent()
return $this->belongsTo('App\Models\Divisi','parent')->where('parent', null)->with('parent'); {
} return $this->belongsTo('App\Models\Divisi','parent')->where('parent', null)->with('parent');
}
public function children()
{ public function children()
return $this->hasMany('App\Models\Divisi','parent')->with('children'); {
} return $this->hasMany('App\Models\Divisi','parent')->with('children');
} }
}

Loading…
Cancel
Save