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();
return Datatables::of($data)
->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) {
$val_status = AssignMaterial::select("status_activity")
->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();
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) {
$val_start = AssignMaterial::select("start_activity")
->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();
return $val_finish ? $val_finish->finish_activity : null;
})
->addColumn('uom', function ($row) {
$val_uom = RequestMaterial::select("uom")
->where('description', '=', $row->material_name)->first();
return $val_uom ? $val_uom->uom : null;
})
// ->addColumn('uom', function ($row) {
// $val_uom = RequestMaterial::select("uom")
// ->where('description', '=', $row->material_name)->first();
// return $val_uom ? $val_uom->uom : null;
// })
->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")
->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)'));
}
$totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
dd($totalBudgets);
$projects = null;
if (!empty($all_project) || $role === "Super Admin") {
@ -380,7 +379,6 @@ class DashboardBoDController extends Controller
public function getTotalProjectPerPhase($role_name, $all_project, $hierarchy)
{
$role = urldecode($role_name);
$projectPhases = null;
$projectPhases = ProjectPhase::orderBy('order')->get();
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;
if ($all_project) {
$projects = Project::where('mulai_proyek', 'like', $year)
->orderBy('id', 'desc')
$projects = Project::orderBy('id', 'desc')
->get();
} else {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
$projects = Project::where('created_by_id', $hierarchy)
->orderBy('id', 'desc')
->get();
}

69
app/Http/Controllers/ImageController.php

@ -25,62 +25,21 @@ class ImageController extends Controller
$extension = $dokumen->extension();
$category = $request->category;
$name = $ref_id.date("YmdHis").".".$extension;
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $dokumen, $destinationPath['pathImage'], $destinationPath);
}
if(isset($getLimitStorage)) {
if($getLimitStorage === false) {
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500);
}
$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);
}
$destinationPath = $this->setCustomeDirectoryUpload();
$data = [
'ref_id' => (int)$ref_id,
'image' => $name,
'category' => $category
];
$result = Image::create($data);
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();
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 {
DB::rollBack();
@ -123,7 +82,7 @@ class ImageController extends Controller
$totalSize += filesize($folderPath . '/' . $file);
}
}
$totalSize += $sizeFile;
$totalSize += $sizeFile;
}
foreach ($dokumen as $file) {
$extension = $file->extension();

2
app/Http/Controllers/ProjectController.php

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

Loading…
Cancel
Save