Compare commits

..

No commits in common. '59623f835853b5890974174a68484c8887ed59e1' and 'a52ae3e7eb1cdf04c769f288110d2f0d93cce64e' have entirely different histories.

  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,6 +169,16 @@ 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')
@ -176,11 +186,6 @@ 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')
@ -195,11 +200,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,6 +41,7 @@ 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") {
@ -379,6 +380,7 @@ 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) {
@ -458,15 +460,17 @@ class DashboardBoDController extends Controller
}
public function getDetailExpenditure($all_project, $hierarchy, $role_name)
public function getDetailExpenditure($year = '%', $all_project, $hierarchy)
{
// $year = $this->interpolateYear($year);
$year = $this->interpolateYear($year);
$projects = null;
if ($all_project) {
$projects = Project::orderBy('id', 'desc')
$projects = Project::where('mulai_proyek', 'like', $year)
->orderBy('id', 'desc')
->get();
} else {
$projects = Project::where('created_by_id', $hierarchy)
$projects = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->orderBy('id', 'desc')
->get();
}

69
app/Http/Controllers/ImageController.php

@ -25,21 +25,62 @@ class ImageController extends Controller
$extension = $dokumen->extension();
$category = $request->category;
$name = $ref_id.date("YmdHis").".".$extension;
$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);
// 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);
}
} else {
DB::rollBack();
unlink($destinationPath['pathImage'].$name);
return response()->json(['status' => 'failed','message' => 'image upload is failed!' ,'code' => 400], 400);
return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400);
}
} else {
DB::rollBack();
@ -82,7 +123,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,7 +66,6 @@ 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;
@ -186,6 +185,7 @@ class ProjectController extends Controller
{
DB::beginTransaction();
$data = Project::find($id);
$dateNow = Carbon::now();
if ($data) {
$this->deleteRelative($id);
if ($data->delete()) {

Loading…
Cancel
Save