Compare commits

..

9 Commits

  1. 25
      app/Http/Controllers/AssignMaterialController.php
  2. 12
      app/Http/Controllers/DashboardBoDController.php
  3. 69
      app/Http/Controllers/ImageController.php
  4. 2
      app/Http/Controllers/ProjectController.php

25
app/Http/Controllers/AssignMaterialController.php

@ -169,16 +169,6 @@ class AssignMaterialController extends Controller
->get(); ->get();
return Datatables::of($data) return Datatables::of($data)
->addIndexColumn() ->addIndexColumn()
// ->addColumn('qty_planning', function($row){
// $val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1","m.id")
// ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
// ->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
// ->groupBy("m.description")
// ->groupBy("m.id")
// ->where("m.description", strval($row->material_name))
// ->where("ram.activity_id", $row->activity_id)->first();
// return $val_qty_act ? $val_qty_act->qty_sum : '-';
// })
->addColumn('status_activity', function ($row) { ->addColumn('status_activity', function ($row) {
$val_status = AssignMaterial::select("status_activity") $val_status = AssignMaterial::select("status_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id') ->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
@ -186,6 +176,11 @@ class AssignMaterialController extends Controller
->where("assign_material_to_activity.activity_id", $row->activity_id)->first(); ->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_status ? $val_status->status_activity : null; return $val_status ? $val_status->status_activity : null;
}) })
->addColumn('qty_sum', function($row){
$val_qty_actual = ReportActivityMaterial::where("report_activity_material.assign_material_id", $row->id)
->sum("qty");
return $val_qty_actual ? $val_qty_actual : null;
})
->addColumn('start_activity', function ($row) { ->addColumn('start_activity', function ($row) {
$val_start = AssignMaterial::select("start_activity") $val_start = AssignMaterial::select("start_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id') ->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
@ -200,11 +195,11 @@ class AssignMaterialController extends Controller
->where("assign_material_to_activity.activity_id", $row->activity_id)->first(); ->where("assign_material_to_activity.activity_id", $row->activity_id)->first();
return $val_finish ? $val_finish->finish_activity : null; return $val_finish ? $val_finish->finish_activity : null;
}) })
->addColumn('uom', function ($row) { // ->addColumn('uom', function ($row) {
$val_uom = RequestMaterial::select("uom") // $val_uom = RequestMaterial::select("uom")
->where('description', '=', $row->material_name)->first(); // ->where('description', '=', $row->material_name)->first();
return $val_uom ? $val_uom->uom : null; // return $val_uom ? $val_uom->uom : null;
}) // })
->addColumn('assign_material_id', function ($row) { ->addColumn('assign_material_id', function ($row) {
$assignMaterial = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") $assignMaterial = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first();

12
app/Http/Controllers/DashboardBoDController.php

@ -41,7 +41,6 @@ class DashboardBoDController extends Controller
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); ->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} }
$totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); $totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
dd($totalBudgets);
$projects = null; $projects = null;
if (!empty($all_project) || $role === "Super Admin") { if (!empty($all_project) || $role === "Super Admin") {
@ -380,7 +379,6 @@ class DashboardBoDController extends Controller
public function getTotalProjectPerPhase($role_name, $all_project, $hierarchy) public function getTotalProjectPerPhase($role_name, $all_project, $hierarchy)
{ {
$role = urldecode($role_name); $role = urldecode($role_name);
$projectPhases = null;
$projectPhases = ProjectPhase::orderBy('order')->get(); $projectPhases = ProjectPhase::orderBy('order')->get();
foreach ($projectPhases as $phase) { foreach ($projectPhases as $phase) {
@ -460,17 +458,15 @@ class DashboardBoDController extends Controller
} }
public function getDetailExpenditure($year = '%', $all_project, $hierarchy) public function getDetailExpenditure($all_project, $hierarchy, $role_name)
{ {
$year = $this->interpolateYear($year); // $year = $this->interpolateYear($year);
$projects = null; $projects = null;
if ($all_project) { if ($all_project) {
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::orderBy('id', 'desc')
->orderBy('id', 'desc')
->get(); ->get();
} else { } else {
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('created_by_id', $hierarchy)
->where('created_by_id', $hierarchy)
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->get(); ->get();
} }

69
app/Http/Controllers/ImageController.php

@ -25,62 +25,21 @@ class ImageController extends Controller
$extension = $dokumen->extension(); $extension = $dokumen->extension();
$category = $request->category; $category = $request->category;
$name = $ref_id.date("YmdHis").".".$extension; $name = $ref_id.date("YmdHis").".".$extension;
// Limited Storage $destinationPath = $this->setCustomeDirectoryUpload();
$company = Company::where('company_name', $request->company_name)->first(); $data = [
if($company) { 'ref_id' => (int)$ref_id,
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); 'image' => $name,
$getLimitStorage = $this->setLimitsStorage($company, $dokumen, $destinationPath['pathImage'], $destinationPath); 'category' => $category
} ];
if(isset($getLimitStorage)) {
if($getLimitStorage === false) { $result = Image::create($data);
DB::rollBack(); if($dokumen->move($destinationPath['pathImage'], $name) && $result) {
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500); DB::commit();
} return response()->json(['status' => 'success', "name_image" => $name,'message' => 'image upload is successfully!','code' => 200], 200);
$data = [
'ref_id' => (int)$ref_id,
'image' => $name,
'category' => $category
];
$result = Image::create($data);
$company = Company::find((int)$ref_id);
if($company && $category === 'company_logo_login') {
$dataArray = json_decode($company['logo_login'], true);
if(isset($dataArray['slider'])) {
$jsonImageSlider['login'] = $name;
$jsonImageSlider['slider'] = $dataArray['slider'];
} else {
$jsonImageSlider['login'] = $name;
}
$company->update([
'logo_login' => $jsonImageSlider
]);
}
if($company && $category === 'company_logo_header') {
$company->update([
'logo_header' => array('content' => $name)
]);
}
if($company && $category === 'company_favicon') {
$company->update([
'favicon_image' => array('content' => $name)
]);
}
if($dokumen->move($destinationPath['pathImage'], $name) && $result) {
DB::commit();
return response()->json(['status' => 'success', "name_image" => $name,'message' => 'image upload is successfully!','code' => 200], 200);
} else {
DB::rollBack();
unlink($destinationPath['pathImage'].$name);
return response()->json(['status' => 'failed','message' => 'image upload is failed!' ,'code' => 400], 400);
}
} else { } else {
DB::rollBack(); DB::rollBack();
return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400); unlink($destinationPath['pathImage'].$name);
return response()->json(['status' => 'failed','message' => 'image upload is failed!' ,'code' => 400], 400);
} }
} else { } else {
DB::rollBack(); DB::rollBack();
@ -123,7 +82,7 @@ class ImageController extends Controller
$totalSize += filesize($folderPath . '/' . $file); $totalSize += filesize($folderPath . '/' . $file);
} }
} }
$totalSize += $sizeFile; $totalSize += $sizeFile;
} }
foreach ($dokumen as $file) { foreach ($dokumen as $file) {
$extension = $file->extension(); $extension = $file->extension();

2
app/Http/Controllers/ProjectController.php

@ -66,6 +66,7 @@ class ProjectController extends Controller
$data = $request->all(); $data = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$data['created_by_id'] = $this->currentId; $data['created_by_id'] = $this->currentId;
$data['schedule_health'] = 'behind-schedule';
if (empty($data['phase_id'])) { if (empty($data['phase_id'])) {
$data['phase_id'] = 1; $data['phase_id'] = 1;
@ -185,7 +186,6 @@ class ProjectController extends Controller
{ {
DB::beginTransaction(); DB::beginTransaction();
$data = Project::find($id); $data = Project::find($id);
$dateNow = Carbon::now();
if ($data) { if ($data) {
$this->deleteRelative($id); $this->deleteRelative($id);
if ($data->delete()) { if ($data->delete()) {

Loading…
Cancel
Save