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

3
app/Http/Controllers/DivisiController.php

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

21
app/Http/Controllers/PresenceController.php

@ -26,11 +26,11 @@ class PresenceController extends Controller
$statusBoundary = true;
}
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) {
if (!$statusRestriction->status_boundary) {
$statusBoundary = true;
}
// not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array(
'id' => null,
'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);
}
// 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(
'id' => null,
'boundary' => true
@ -65,7 +65,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate,
"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,
"created_at" => $date,
"created_by" => $this->currentName
@ -86,7 +86,8 @@ class PresenceController extends Controller
}
$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(
'user_id'=> $request->user_id,
@ -139,11 +140,11 @@ class PresenceController extends Controller
$statusBoundary = true;
}
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) {
if (!$statusRestriction->status_boundary) {
$statusBoundary = true;
}
// not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array(
'id' => null,
'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);
}
// 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(
'id' => null,
'boundary' => true
@ -178,7 +179,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate,
"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'],
"created_at" => $date,
"created_by" => $this->currentName
@ -232,7 +233,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $result->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,
"created_at" => $date,
"created_by" => $this->currentName

2
app/Http/Controllers/ProjectController.php

@ -77,7 +77,7 @@ class ProjectController extends Controller
$result = Project::query()
->from('m_proyek AS mp')
->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'])) {
$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){
$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){
$data->delete();

83
app/Models/Divisi.php

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

Loading…
Cancel
Save