Browse Source

Merge pull request 'dev-wahyun' (#5) from dev-wahyun into staging

Reviewed-on: #5
pull/6/head
ibnu 5 months ago
parent
commit
35ad12e80a
  1. 1
      .gitignore
  2. 920
      app/Helpers/MasterFunctionsHelper.php
  3. 1693
      app/Helpers/MasterFunctionsHelperOld.php
  4. 24
      app/Http/Controllers/ActivityController.php
  5. 90
      app/Http/Controllers/ActivityDokumenController.php
  6. 12
      app/Http/Controllers/Controller.php
  7. 125
      app/Http/Controllers/DashboardBoDController.php
  8. 4
      app/Http/Controllers/DivisiController.php
  9. 7
      app/Http/Controllers/FolderDocumentProyekController.php
  10. 77
      app/Http/Controllers/HumanResourceController.php
  11. 31
      app/Http/Controllers/ImageController.php
  12. 1
      app/Http/Controllers/ProductTransactionController.php
  13. 5
      app/Http/Controllers/ProjectCarausellController.php
  14. 59
      app/Http/Controllers/ProjectController.php
  15. 96
      app/Http/Controllers/ProjectDokumenController.php
  16. 1
      app/Http/Controllers/ProjectExpenditureController.php
  17. 1
      app/Http/Controllers/ProjectFinancialHealthController.php
  18. 1
      app/Http/Controllers/ProjectInvoiceController.php
  19. 2
      app/Http/Controllers/ProjectRoleController.php
  20. 1
      app/Http/Controllers/ProjectScheduleHealthController.php
  21. 7
      app/Http/Controllers/ReportActivityMaterialController.php
  22. 4
      app/Http/Controllers/RoleController.php
  23. 11
      app/Http/Controllers/UserToProyekController.php
  24. 8163
      composer.lock
  25. 50
      routes/web.php

1
.gitignore vendored

@ -12,3 +12,4 @@ bootstrap/backup
.config-prod.json
activity_log.txt
.swp
composer.lock

920
app/Helpers/MasterFunctionsHelper.php

File diff suppressed because it is too large Load Diff

1693
app/Helpers/MasterFunctionsHelperOld.php

File diff suppressed because it is too large Load Diff

24
app/Http/Controllers/ActivityController.php

@ -635,41 +635,37 @@ class ActivityController extends Controller
$activity_id = (int)$id;
$data = Activity::query()
->from('m_activity as ma')
->select('mp.company_id')
->join('m_proyek as mp','ma.proyek_id','mp.id')
->select('ma.id')
->join('m_proyek as mp', 'ma.proyek_id', 'mp.id')
->where('ma.id', $activity_id);
$cloneQuery = clone $data;
if (!$data->exists()) {
DB::rollBack();
return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'Data not found!', 'code' => 404], 404);
}
$this->deleteRelative($activity_id, $cloneQuery->first()->company_id);
$this->deleteRelative($activity_id);
if (!$data->delete()) {
DB::rollBack();
return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'Data activity failed deleted!', 'code' => 500], 500);
}
DB::commit();
DB::rollBack();
return response()->json(['status' => 'success', "action" => "deleted", 'message' => 'Data activity successfully deleted!', 'code' => 200], 200);
}
private function deleteRelative($activity_id, $company_id)
private function deleteRelative($activity_id)
{
DB::transaction(function() use($activity_id, $company_id) {
DB::transaction(function () use ($activity_id) {
UserToActivity::where('activity_id', $activity_id)->delete();
AssignMaterial::where('activity_id', $activity_id)->delete();
$dataAd = ActivityDokumen::where("activity_id", $activity_id)->get();
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$destinationPath = $this->setCustomeDirectoryUpload();
foreach ($dataAd as $ad) {
if (file_exists($destinationPath['pathActivityDocument'] . $ad->file)) {
unlink($destinationPath['pathActivityDocument'] . $ad->file);
}
}
ActivityDokumen::where("activity_id", $activity_id)->delete();
}
});
}
@ -1156,12 +1152,12 @@ class ActivityController extends Controller
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
if ($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $document, $destinationPath['pathTmpImport'], $destinationPath);
}
if (isset($getLimitStorage)) {
if($getLimitStorage === false) {
if ($getLimitStorage === false) {
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500);
}
@ -1175,7 +1171,7 @@ class ActivityController extends Controller
$result = TmpImport::create($data);
if (!$document->move($destinationPath['pathTmpImport'], $name) && $result) {
unlink($destinationPath['pathTmpImport'].$name);
unlink($destinationPath['pathTmpImport'] . $name);
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
}

90
app/Http/Controllers/ActivityDokumenController.php

@ -8,51 +8,57 @@ use App\Models\ActivityDokumen;
class ActivityDokumenController extends Controller
{
public $directories;
public function __construct() {
$this->directories = $this->setCustomeDirectoryUpload();
}
public function dokumenByActivityId($id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'activity id is required!','code'=>400], 400);
public function dokumenByActivityId($id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'activity id is required!', 'code' => 400], 400);
$dataDokumen = ActivityDokumen::where("activity_id", $id)->get();
return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200);
return response()->json(['status' => 'success', 'data' => $dataDokumen, 'code' => 200], 200);
}
public function delete($id, $company_id)
public function delete($id)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400);
$document = ActivityDokumen::find($id);
if(!$document) {
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
}
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if(file_exists($destinationPath['pathActivityDocument'].$document->file)){
unlink($destinationPath['pathActivityDocument'].$document->file);
if (!$document) {
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
}
$destinationPath = $this->setCustomeDirectoryUpload();
if (file_exists($destinationPath['pathActivityDocument'] . $document->file)) {
unlink($destinationPath['pathActivityDocument'] . $document->file);
}
$document->delete();
return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200);
return response()->json(['status' => 'success', 'message' => 'Dokumen deleted successfully!', 'code' => 200], 200);
}
public function uploadProjectDokumen(Request $request)
{
if(!$request->hasFile('dokumen')) {
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400);
}
$activity_id = $request->activity_id;
$document = $request->file('dokumen');
$name = $document->getClientOriginalName();
$company = Company::find($request->company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$result = $document->move($destinationPath['pathActivityDocument'], $name);
$fileSize = $document->getSize();
$maximumSizeFile = $fileSize > 15 * 1024 * 1024; // 15 MB
if ($maximumSizeFile) {
return response()->json(['status' => 'failed', 'message' => 'This file is too large. Allowed maximum size is 15MB', 'code' => 500], 500);
}
if(!$result || !$company) {
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
$this->validate($request, [
'dokumen' => 'required|file|max:15360'
]);
if (!$request->hasFile('dokumen')) {
return response()->json(['status' => 'failed', 'message' => 'file is required!', 'code' => 400], 400);
}
$result = $document->move($this->directories['pathActivityDocument'], $name);
if (!$result) {
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
}
$data = [
'activity_id' => (int)$activity_id,
@ -60,14 +66,15 @@ class ActivityDokumenController extends Controller
'description' => $request->description
];
$result = ActivityDokumen::create($data);
if(!$result || !$company) {
unlink($destinationPath['pathActivityDocument'].$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
if (!$result) {
unlink($this->directories['pathActivityDocument'] . $name);
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload success!','code'=>200], 200);
return response()->json(['status' => 'success', 'message' => 'Upload success!', 'code' => 200], 200);
}
public function searchDocProject(Request $request){
public function searchDocProject(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_document_activity');
@ -76,26 +83,23 @@ class ActivityDokumenController extends Controller
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function downloadDokumen($id, $company_id)
public function downloadDokumen($id)
{
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
if (empty($id) || !is_int((int)$id)) {
return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400);
}
$document = ActivityDokumen::find($id);
$company = Company::find($company_id);
if(!$document || !$company) {
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
if (!$document) {
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 400], 400);
}
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if(file_exists($destinationPath['pathActivityDocument'].$document->file)) {
$pathToFile = $destinationPath['pathActivityDocument'].$document->file;
$destinationPath = $this->setCustomeDirectoryUpload();
if (file_exists($destinationPath['pathActivityDocument'] . $document->file)) {
$pathToFile = $destinationPath['pathActivityDocument'] . $document->file;
return response()->download($pathToFile);
}
}
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 400], 400);
}
}

12
app/Http/Controllers/Controller.php

@ -44,17 +44,15 @@ class Controller extends BaseController
$this->pathActivityDocument = config('assets.activity');
}
protected function setCustomeDirectoryUpload($company_name)
protected function setCustomeDirectoryUpload()
{
$current_date = date('Y-m-d');
[$year, $month] = explode('-', $current_date);
$yearMonth = $year.'-'.$month;
$pathImage = 'assets/' . $company_name .'/'. $yearMonth . '/image/';
$pathDocument = 'assets/' . $company_name .'/'. $yearMonth . '/file/project/';
$pathTmpImport = 'assets/' . $company_name .'/'. $yearMonth . '/file/tmpimport/';
$pathActivityDocument = 'assets/' . $company_name .'/'. $yearMonth . '/file/activity/';
$pathImage = 'assets/image/';
$pathDocument = 'assets/file/project/';
$pathTmpImport = 'assets/file/tmpimport/';
$pathActivityDocument = 'assets/file/activity/';
return [
'pathImage' => $pathImage,
'pathDocument' => $pathDocument,

125
app/Http/Controllers/DashboardBoDController.php

@ -28,29 +28,23 @@ class DashboardBoDController extends Controller
public function getCompanyCashFlow($company_id, $all_project, $hierarchy, $role_name)
public function getCompanyCashFlow($all_project, $hierarchy, $role_name)
{
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
$totalBudgets = null;
$role = urldecode($role_name);
if ($role === "Super Admin") {
if (!empty($all_project) || $role === "Super Admin") {
$totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} elseif (!empty($all_project)) {
$totalBudgets = Project::where('company_id', $company_id)
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} else {
$totalBudgets = Project::where('created_by_id', $hierarchy)
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
}
$totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
$projects = null;
if ($role === "Super Admin") {
if (!empty($all_project) || $role === "Super Admin") {
$projects = Project::get();
} elseif (!empty($all_project)) {
$projects = Project::where('company_id', $company_id)
->get();
} else {
$projects = Project::where('created_by_id', $hierarchy)
->get();
@ -85,15 +79,11 @@ class DashboardBoDController extends Controller
], 200);
}
public function getDetailExpenditureColor($role_name, $company_id)
public function getDetailExpenditureColor($role_name)
{
$role = urldecode($role_name);
$query = null;
if ($role === 'Super Admin') {
$query = ProjectExpenditure::get();
} else {
$query = ProjectExpenditure::where('company_id', $company_id)->get();
}
$data = [];
foreach ($query as $value) {
@ -120,16 +110,11 @@ class DashboardBoDController extends Controller
], 200);
}
public function getDetailFinancialHealthColor($role_name, $company_id)
public function getDetailFinancialHealthColor($role_name)
{
$role = urldecode($role_name);
$query = null;
if ($role === 'Super Admin') {
$query = ProjectFinancialHealth::get();
} else {
$query = ProjectFinancialHealth::where('company_id', $company_id)->get();
}
$data = [];
foreach ($query as $value) {
@ -152,15 +137,11 @@ class DashboardBoDController extends Controller
], 200);
}
public function getDetailScheduleHealthColor($role_name, $company_id)
public function getDetailScheduleHealthColor($role_name)
{
$role = urldecode($role_name);
$query = null;
if ($role === 'Super Admin') {
$query = ProjectScheduleHealth::get();
} else {
$query = ProjectScheduleHealth::where('company_id', $company_id)->get();
}
$data = [];
foreach ($query as $value) {
@ -183,15 +164,11 @@ class DashboardBoDController extends Controller
], 200);
}
public function getDetailInvoiceColor($role_name, $company_id)
public function getDetailInvoiceColor($role_name)
{
$role = urldecode($role_name);
$query = null;
if ($role === 'Super Admin') {
$query = ProjectInvoice::get();
} else {
$query = ProjectInvoice::where('company_id', $company_id)->get();
}
$data = [];
foreach ($query as $value) {
if ($value['name'] === 'Invoiced') {
@ -210,15 +187,12 @@ class DashboardBoDController extends Controller
}
// integrasi
public function getInvoiceOutstanding($role_name, $company_id, $all_project, $hierarchy)
public function getInvoiceOutstanding($role_name, $all_project, $hierarchy)
{
$role = urldecode($role_name);
$projects = null;
if ($role === 'Super Admin') {
if (!empty($all_project) || $role === 'Super Admin') {
$projects = Project::get();
} elseif (!empty($all_project)) {
$projects = Project::where('company_id', $company_id)
->get();
} else {
$projects = Project::where('created_by_id', $hierarchy)
->get();
@ -241,7 +215,7 @@ class DashboardBoDController extends Controller
], 200);
}
public function getTotalProjectPerScheduleHealth($role_name, $company_id, $all_project, $hierarchy)
public function getTotalProjectPerScheduleHealth($role_name, $all_project, $hierarchy)
{
$role = urldecode($role_name);
$replaceHierarchy = preg_replace('/[\[\]]/', '', $hierarchy);
@ -253,11 +227,8 @@ class DashboardBoDController extends Controller
];
$projects = null;
if ($role === 'Super Admin') {
if ($all_project == 'true' || $role === 'Super Admin') {
$projects = Project::get();
} elseif ($all_project == 'true') {
$projects = Project::where('company_id', $company_id)
->get();
} else {
$projects = Project::where('created_by_id', $replaceHierarchy)
->get();
@ -274,18 +245,11 @@ class DashboardBoDController extends Controller
}
public function getTotalProjectScheduleHealthPerDivision($role_name, $company_id)
public function getTotalProjectScheduleHealthPerDivision($role_name)
{
$role = urldecode($role_name);
$divisions = null;
if ($role === 'Super Admin') {
$divisions = Divisi::whereNull('parent')
->get();
} else {
$divisions = Divisi::whereNull('parent')
->where('company_id', $company_id)
->get();
}
foreach ($divisions as $index => $division) {
$behindSchedule = $warning = $onSchedule = 0;
@ -311,7 +275,7 @@ class DashboardBoDController extends Controller
return response()->json(['data' => $divisions], 200);
}
public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy)
public function getTotalProjectPerBudgetHealth($role_name, $all_project, $hierarchy)
{
$role = urldecode($role_name);
$replaceHierarchy = preg_replace('/[\[\]]/', '', $hierarchy);
@ -324,7 +288,6 @@ class DashboardBoDController extends Controller
]
];
$divisi = Divisi::query()
->where('company_id', $company_id)
->pluck('id');
// arr overrun
@ -333,7 +296,7 @@ class DashboardBoDController extends Controller
->count();
} elseif ($all_project == 'true') {
$response['data']['overrun'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'overrun'], ['company_id', $company_id]])
->where([['budget_health', 'overrun']])
->count();
} else {
$response['data']['overrun'] = Project::whereIn('divisi_id', $divisi)
@ -346,7 +309,7 @@ class DashboardBoDController extends Controller
->count();
} elseif ($all_project == 'true') {
$response['data']['warning'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'warning'], ['company_id', $company_id]])
->where([['budget_health', 'warning']])
->count();
} else {
$response['data']['warning'] = Project::whereIn('divisi_id', $divisi)
@ -359,7 +322,7 @@ class DashboardBoDController extends Controller
->count();
} elseif ($all_project == 'true') {
$response['data']['on-budget'] = Project::whereIn('divisi_id', $divisi)
->where([['company_id', $company_id], ['budget_health', 'on-budget']])
->where([['budget_health', 'on-budget']])
->count();
} else {
$response['data']['on-budget'] = Project::whereIn('divisi_id', $divisi)
@ -376,7 +339,7 @@ class DashboardBoDController extends Controller
}
public function getTotalProjectBudgetHealthPerDivision($role_name, $company_id)
public function getTotalProjectBudgetHealthPerDivision($role_name)
{
$role = urldecode($role_name);
$divisions = null;
@ -389,7 +352,6 @@ class DashboardBoDController extends Controller
$divisions = Divisi::select('id', 'name')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
@ -414,25 +376,15 @@ class DashboardBoDController extends Controller
], 200);
}
public function getTotalProjectPerPhase($role_name, $company_id, $all_project, $hierarchy)
public function getTotalProjectPerPhase($role_name, $all_project, $hierarchy)
{
$role = urldecode($role_name);
$projectPhases = null;
if ($role === 'Super Admin') {
$projectPhases = ProjectPhase::orderBy('order')->get();
} else {
$projectPhases = ProjectPhase::where('company_id', $company_id)->orderBy('order')->get();
}
foreach ($projectPhases as $phase) {
if ($role === 'Super Admin') {
$phase->totalProject = Project::where('phase_id', $phase->id)
->count();
} elseif ($all_project) {
if ($role === 'Super Admin' || $all_project) {
$phase->totalProject = Project::where('phase_id', $phase->id)
->where('company_id', $company_id)
->count();
} else {
$phase->totalProject = Project::where('phase_id', $phase->id)
@ -453,25 +405,14 @@ class DashboardBoDController extends Controller
->count();
}
public function getTotalProjectPerDivision($role_name, $company_id)
public function getTotalProjectPerDivision($role_name)
{
$role = urldecode($role_name);
$divisions = null;
if ($role === 'Super Admin') {
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->get();
} else {
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
// to do : count in more than 1 level child
foreach ($divisions as $v) {
@ -495,22 +436,13 @@ class DashboardBoDController extends Controller
->first();
}
public function getTotalProjectValuePerDivision($role_name, $company_id)
public function getTotalProjectValuePerDivision($role_name)
{
$role = urldecode($role_name);
if ($role === 'Super Admin') {
$divisions = Divisi::select('id', 'name', 'color')
->with('children')
->whereNull('parent')
->get();
} else {
$divisions = Divisi::select('id', 'name', 'color')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
foreach ($divisions as $v) {
$v->total = $this->countTotalProjectValueInDivision($v->id);
@ -526,18 +458,15 @@ class DashboardBoDController extends Controller
}
public function getDetailExpenditure($year = '%', $company_id, $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)
->where('company_id', $company_id)
->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();
}
@ -562,7 +491,7 @@ class DashboardBoDController extends Controller
return response()->json([
'data' => $projects,
'total_manpowers' => User::where('company_id', $company_id)->count()
'total_manpowers' => User::count()
], 200);
}
}

4
app/Http/Controllers/DivisiController.php

@ -22,7 +22,7 @@ class DivisiController extends Controller
public function add(Request $request)
{
$this->validate($request, [
'name' => 'string|required|unique:m_divisi,name,NULL,id,company_id,' . $request->input('company_id'),
'name' => 'string|required|unique:m_divisi,name,NULL,id',
'description' => 'nullable|string',
'parent' => 'nullable|integer',
'color' => 'nullable|string|max:10'
@ -32,7 +32,6 @@ class DivisiController extends Controller
$data['created_by'] = $this->currentName;
$result = Divisi::create($data);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Failed to add data', 'code' => 500]);
@ -86,7 +85,6 @@ class DivisiController extends Controller
{
$companyId = $request->input('columns.0.value');
$parentDivisi = Divisi::whereNull('parent')
->where('company_id', $companyId)
->with('children')
->get();
$divisions = [];

7
app/Http/Controllers/FolderDocumentProyekController.php

@ -47,13 +47,12 @@ class FolderDocumentProyekController extends Controller
}
}
public function delete($id, $company_id)
public function delete($id)
{
DB::beginTransaction();
$data = FolderDocumentProyek::find($id);
$company = Company::find($company_id);
if($data && $company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if($data) {
$destinationPath = $this->setCustomeDirectoryUpload();
$dir = $destinationPath['pathDocument'];
$dataFile = DokumenProject::where([['type_dokumen', 'project-document-in-folder'],['ref_id', $data['id']]])->orderByRaw('id ASC')->get();
if (is_dir($dir)) {

77
app/Http/Controllers/HumanResourceController.php

@ -3,7 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\{HumanResource,ProductTransaction,UserToActivity,UserToProyek,User};
use App\Models\{HumanResource, ProductTransaction, UserToActivity, UserToProyek, User};
use Illuminate\Support\Facades\Artisan;
const URL_EMAIL = 'https://notifapp.odm-iu.com/service-mail/notif_mail.php';
@ -22,44 +22,18 @@ class HumanResourceController extends Controller
'name' => 'required|string',
'ktp_number' => 'required|string|unique:m_users,ktp_number',
'employee_type' => 'required|in:employee,subcon,freelance',
'company_id' => 'required|integer',
'username' => 'string|unique:m_users,username',
'email' => 'string|unique:m_users,email'
], $messages);
$data = $request->all();
!$request->is_customer ? $this->validate($request,['role_id' => 'required','divisi_id' => 'required'], $messages) : '';
!$request->is_customer ? $this->validate($request, ['role_id' => 'required', 'divisi_id' => 'required'], $messages) : '';
if (isset($request->password) && $request->password != "") {
$data['password'] = md5($request->password);
}
$transaction = ProductTransaction::query()
->where('company_id', (int) $request->company_id);
$cloneQueryTransaction = clone $transaction;
$countCreate = false;
$projectResult = HumanResource::query()
->selectRaw('count(*) as total_hr')
->where('company_id', (int) $request->company_id)
->first();
if($transaction->where([['type_paket','Basic'],['amount','!=',null]])->exists()) {
if($projectResult['total_hr'] < 50) {
$countCreate = true;
}
} elseif ($cloneQueryTransaction->where([['type_paket','Free'],['amount',0]])->exists()) {
if($projectResult['total_hr'] < 1) {
$countCreate = true;
}
} else {
$countCreate = true;
}
if($countCreate) {
$result = HumanResource::create($data);
} else {
return response()->json(['status' => 'failed', 'message' => 'Limited to create human resource!', 'code' => 500], 500);
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfull created', 'code' => 200]);
@ -76,7 +50,6 @@ class HumanResourceController extends Controller
'name' => 'required',
'ktp_number' => 'required|string|unique:m_users,ktp_number',
'employee_type' => 'required',
'company_id' => 'required',
'username' => 'required',
'email' => 'required|unique:m_users,email|email'
]);
@ -121,15 +94,13 @@ class HumanResourceController extends Controller
'required' => 'Data tidak boleh kosong'
];
$request->validate($request, [
$this->validate($request, [
'name' => 'required|string',
'ktp_number' => 'required|string|unique:m_users,ktp_number,'.$id . ',id',
'employee_type' => 'required|in:employee,subcon,freelance',
'company_id' => 'required|integer',
'username' => 'unique:m_users,username,'.$id . ',id',
'email' => 'string|unique:m_users,email,'.$id . ',id'
], $messages);
!$request->is_customer ? $this->validate($request,['role_id'=>'required', 'divisi_id'=>'required'], $messages) : '';
$request->password ? $this->validate($request,['password'=>'required|min:8']) : '';
@ -140,47 +111,16 @@ class HumanResourceController extends Controller
}
$humanresource = HumanResource::find($id);
if(empty($humanresource)) {
if (empty($humanresource)) {
return response()->json(['status' => 'failed', 'message' => 'Data Human Resource not found!', 'code' => 400], 400);
}
if($request->company_id && isset($request->password) && isset($request->username)) {
$transaction = ProductTransaction::query()
->where('company_id', $request->company_id);
$cloneQueryTransaction = clone $transaction;
$countCreate = false;
$projectResult = HumanResource::query()
->selectRaw('count(*) as total_hr')
->where([
['company_id', $request->company_id],
['username', '!=', null],
['password', '!=', null]
])
->first();
if($transaction->where([['type_paket','Basic'],['amount','!=',null]])->exists()) {
if($projectResult['total_hr'] < 10) {
$countCreate = true;
}
} elseif ($cloneQueryTransaction->where([['type_paket','Free'],['amount',0]])->exists()) {
if($projectResult['total_hr'] < 1) {
$countCreate = true;
}
} else {
$countCreate = true;
}
} else {
$countCreate = true;
}
if (isset($request->password) && $request->password != "") {
$data['password'] = md5($request->password);
}
if ($countCreate) {
$result = $humanresource->update($data);
} else {
return response()->json(['status' => 'failed', 'message' => 'Limited to create human resource!', 'code' => 500], 500);
}
// $result = $humanresource->update($data);
$result = true;
if ($result) {
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Human Resource Pool successfully updated!', 'code' => 200], 200);
@ -220,7 +160,7 @@ class HumanResourceController extends Controller
public function list()
{
$data = HumanResource::select('id', 'name', 'role_id','company_id')->get();
$data = HumanResource::select('id', 'name', 'role_id')->get();
$countData = $data->count();
if ($data) {
@ -306,7 +246,7 @@ class HumanResourceController extends Controller
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400);
} else {
$this->reqHttpCurl($email, $password, $user->username, $user->name);
return response()->json(['status' => 'error', 'code'=>400, 'message' => 'e-mail not found '], 400);
return response()->json(['status' => 'error', 'code' => 400, 'message' => 'e-mail not found '], 400);
}
}
@ -352,6 +292,5 @@ class HumanResourceController extends Controller
} else {
print_r(json_decode($response));
}
}
}

31
app/Http/Controllers/ImageController.php

@ -124,23 +124,6 @@ class ImageController extends Controller
}
}
$totalSize += $sizeFile;
$transaction = ProductTransaction::query()
->where('company_id', $company['id']);
$cloneQueryTransaction = clone $transaction;
$countCreate = false;
if($transaction->where([['type_paket','Basic'], ['amount','!=',null]])->exists()) {
$maximumSize = 500 * 1024 * 1024;
$countCreate = true;
} elseif ($cloneQueryTransaction->where([['type_paket','Free'], ['amount', 0]])->exists()) {
$maximumSize = 50 * 1024 * 1024;
$countCreate = true;
}
if($countCreate) {
if ($totalSize > $maximumSize) {
return response()->json(['status'=>'failed','message'=>'Limited storage maximum!','code'=> 500], 500);
}
}
}
foreach ($dokumen as $file) {
$extension = $file->extension();
@ -219,12 +202,11 @@ class ImageController extends Controller
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function deleteByRef($id, $category, $company_id)
public function deleteByRef($id, $category)
{
$data = Image::where("ref_id", (int)$id)->where("category", $category)->first();
$company = Company::find($company_id);
if($data && $company){
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if($data){
$destinationPath = $this->setCustomeDirectoryUpload();
unlink($destinationPath['pathImage'].$data->image);
$delete = $data->delete();
}else{
@ -240,16 +222,15 @@ class ImageController extends Controller
}
}
public function deleteByRefMultiple($id, $category, $company_id)
public function deleteByRefMultiple($id, $category)
{
$successCount = 0;
$data = Image::where([
["ref_id", intval($id)],
["category", $category]
])->get();
$company = Company::find($company_id);
if($data->isNotEmpty() && $company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if($data->isNotEmpty()) {
$destinationPath = $this->setCustomeDirectoryUpload();
foreach($data as $img) {
unlink($destinationPath['pathImage'].$img->image);
$delete = $img->delete();

1
app/Http/Controllers/ProductTransactionController.php

@ -10,7 +10,6 @@ class ProductTransactionController extends Controller
public function add(Request $request)
{
$this->validate($request, [
'company_id' => 'required|integer',
'type_paket' => 'required|string',
'amount' => 'required',
'exp_ospro' => 'required'

5
app/Http/Controllers/ProjectCarausellController.php

@ -16,16 +16,13 @@ class ProjectCarausellController extends Controller
public function invoke(Request $request)
{
// Master Data
$company_id = $request->route('company_id');
$all_project = $request->route('all_project');
$hierarchy = $request->route('hierarchy');
$query = Project::query()
->select("id", "nama", "kode_sortname", "pm_id", "budget_health", "calculation_status", "mulai_proyek", "akhir_proyek", "rencana_biaya", "company", "scurve");
if ($all_project) {
$query->where('company_id', $company_id);
} else {
if (!$all_project) {
$query->where('created_by_id', $hierarchy);
}

59
app/Http/Controllers/ProjectController.php

@ -60,7 +60,6 @@ class ProjectController extends Controller
'akhir_proyek' => 'required',
'rencana_biaya' => 'required',
'type_proyek_id' => 'required',
'company_id' => 'required'
]);
DB::beginTransaction();
try {
@ -72,29 +71,9 @@ class ProjectController extends Controller
if (empty($data['phase_id'])) {
$data['phase_id'] = 1;
}
$transaction = ProductTransaction::query()
->where('company_id', $request->company_id);
$cloneQueryTransaction = clone $transaction;
$countCreate = false;
$projectResult = Project::query()
->selectRaw('count(*) as total_project')
->where('company_id', $request->company_id)
->first();
if ($transaction->where([['type_paket', 'Basic'], ['amount', '!=', null]])->exists()) {
if ($projectResult['total_project'] < 10) {
$countCreate = true;
}
} elseif ($cloneQueryTransaction->where([['type_paket', 'Free'], ['amount', 0]])->exists()) {
if ($projectResult['total_project'] < 1) {
$countCreate = true;
}
} else {
$countCreate = true;
}
if ($countCreate) {
$result = Project::create($data);
if (!$result) {
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500);
} else {
@ -103,9 +82,6 @@ class ProjectController extends Controller
DB::commit();
return response()->json(['status' => 'success', 'message' => 'Data added!', 'data_result' => $dataResultInsert, 'code' => 200], 200);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'Limited to create project!', 'code' => 500], 500);
}
} catch (\Throwable $th) {
DB::rollBack();
}
@ -150,7 +126,6 @@ class ProjectController extends Controller
'phase_id',
'calculation_status',
'md.name as divisi_name',
'm_proyek.company_id'
)
->leftJoin('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id')
->where('m_proyek.id', $id)
@ -207,15 +182,13 @@ class ProjectController extends Controller
return true;
}
public function delete($id, $company_id)
public function delete($id)
{
DB::beginTransaction();
$data = Project::find($id);
$dateNow = Carbon::now();
if ($data) {
$this->deleteRelative($id, $company_id);
$this->deleteRelative($id);
if ($data->delete()) {
// if ($data->update(['deleted_at' => $dateNow, 'deleted_by_id' => $this->currentId])) {
DB::commit();
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
} else {
@ -228,9 +201,9 @@ class ProjectController extends Controller
}
}
private function deleteRelative($project_id, $company_id)
private function deleteRelative($project_id)
{
DB::transaction(function () use ($project_id, $company_id) {
DB::transaction(function () use ($project_id) {
UserToProyek::where('proyek_id', $project_id)->delete();
UserToActivity::where('proyek_id', $project_id)->delete();
AssignMaterial::where('proyek_id', $project_id)->delete();
@ -247,22 +220,20 @@ class ProjectController extends Controller
OfficeHours::where('proyek_id', $project_id)->delete();
ReportK3::where('proyek_id', $project_id)->delete();
RequestMaterial::where('proyek_id', $project_id)->delete();
$this->deleteVersionGantt($project_id, $company_id);
$this->deleteDokumenProject($project_id, $company_id);
$this->deleteVersionGantt($project_id);
$this->deleteDokumenProject($project_id);
}, 5);
}
private function deleteVersionGantt($project_id, $company_id)
private function deleteVersionGantt($project_id)
{
DB::transaction(function () use ($project_id, $company_id) {
DB::transaction(function () use ($project_id) {
$dataVg = VersionGantt::where("proyek_id", $project_id)->pluck("id");
$vhIds = $dataVg->all();
$activity = Activity::whereIn("version_gantt_id", $vhIds)->pluck('id');
$activityIds = $activity->all();
$dataRa = ReportActivity::whereIn("activity_id", $activityIds)->get();
$company = Company::find($company_id);
if ($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$destinationPath = $this->setCustomeDirectoryUpload();
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
@ -278,7 +249,6 @@ class ProjectController extends Controller
unlink($destinationPath['pathActivityDocument'] . $ad->file);
}
}
}
ActivityDokumen::whereIn("activity_id", $activityIds)->delete();
CommentActivity::whereIn("activity_id", $activityIds)->delete();
Holiday::where("proyek_id", $project_id)->delete();
@ -290,19 +260,16 @@ class ProjectController extends Controller
}, 5);
}
private function deleteDokumenProject($project_id, $company_id)
private function deleteDokumenProject($project_id)
{
DB::transaction(function () use ($project_id, $company_id) {
DB::transaction(function () use ($project_id) {
$dataDokumen = DokumenProject::where([['type_dokumen', 'project-document-out-folder'], ['ref_id', $project_id]])->get();
$company = Company::find($company_id);
if ($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$destinationPath = $this->setCustomeDirectoryUpload();
foreach ($dataDokumen as $dokumen) {
if (file_exists($destinationPath['pathDocument'] . $dokumen->file)) {
unlink($destinationPath['pathDocument'] . $dokumen->file);
}
}
}
DokumenProject::where([['type_dokumen', 'project-document-out-folder'], ['ref_id', $project_id]])->delete();
$dataFolder = FolderDocumentProyek::where('proyek_id', $project_id)->pluck("id");
$ref_ids = $dataFolder->all();

96
app/Http/Controllers/ProjectDokumenController.php

@ -3,51 +3,49 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\{DokumenProject,Company};
use App\Models\{DokumenProject, Company};
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
class ProjectDokumenController extends Controller
{
public function dokumenByProyekId($id){
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'project id is required!','code'=>400], 400);
public function dokumenByProyekId($id)
{
if (empty($id) || !is_int((int)$id)) {
return response()->json(['status' => 'failed', 'message' => 'project id is required!', 'code' => 400], 400);
}
$document = DokumenProject::where("ref_id", $id)->get();
if(count($document) == 0)
return response()->json(['status'=>'','message'=>'Data not found!' ,'code'=>404], 404);
if (count($document) == 0)
return response()->json(['status' => '', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status'=>'success','data'=> $document ,'code'=>200], 200);
return response()->json(['status' => 'success', 'data' => $document, 'code' => 200], 200);
}
public function delete($id, $company_id)
public function delete($id)
{
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if (empty($id) || !is_int((int)$id)) {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$document = DokumenProject::find($id);
if(!$document){
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
}
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if(file_exists($destinationPath['pathDocument'].$document['file'])){
unlink($destinationPath['pathDocument'].$document['file']);
if (!$document) {
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 400], 400);
}
$destinationPath = $this->setCustomeDirectoryUpload();
if (file_exists($destinationPath['pathDocument'] . $document['file'])) {
unlink($destinationPath['pathDocument'] . $document['file']);
}
$document->delete();
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
}
public function uploadProjectDokumen(Request $request)
{
DB::beginTransaction();
$timeNow = Carbon::now();
if($request->hasFile('dokumen')){
if ($request->hasFile('dokumen')) {
$document = $request->file('dokumen');
$ref_id = $request->ref_id;
@ -55,17 +53,8 @@ class ProjectDokumenController extends Controller
$extension = pathinfo($originalFilename, PATHINFO_EXTENSION);
$filename = pathinfo($originalFilename, PATHINFO_FILENAME);
$name = $filename . '_' . $timeNow->format('d-m-y-His') . '.' . $extension;
// Limited Storage
$company = Company::whereId($request->company_id)->first();
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $document, $destinationPath['pathDocument'],$destinationPath);
}
if(isset($getLimitStorage)) {
if($getLimitStorage === false) {
DB::rollBack();
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500);
}
$destinationPath = $this->setCustomeDirectoryUpload();
$data = [
'ref_id' => (int)$ref_id,
'file' => $name,
@ -73,23 +62,20 @@ class ProjectDokumenController extends Controller
];
$result = DokumenProject::create($data);
if(!$document->move($destinationPath['pathDocument'], $name) && $result) {
unlink($destinationPath['pathDocument'].$name);
if (!$document->move($destinationPath['pathDocument'], $name) && $result) {
unlink($destinationPath['pathDocument'] . $name);
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'Dokumen project gagal diupload!','code'=> 500], 500);
return response()->json(['status' => 'failed', 'message' => 'Dokumen project gagal diupload!', 'code' => 500], 500);
}
DB::commit();
return response()->json(['status'=>'success','message'=>'Dokumen project berhasil diupload!','code'=>200], 200);
return response()->json(['status' => 'success', 'message' => 'Dokumen project berhasil diupload!', 'code' => 200], 200);
}
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'Dokumen project gagal diupload!','code'=> 500], 500);
}
DB::rollBack();
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400);
return response()->json(['status' => 'failed', 'message' => 'File is required!', 'code' => 400], 400);
}
public function searchDocProject(Request $request){
public function searchDocProject(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'document_project');
@ -98,32 +84,30 @@ class ProjectDokumenController extends Controller
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function downloadDokumen($id, $company_id)
public function downloadDokumen($id)
{
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
if (empty($id) || !is_int((int)$id)) {
return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400);
}
$document = DokumenProject::find($id);
$company = Company::find($company_id);
if(!$document || !$company) {
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if (!$document) {
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
}
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$pathToFile = $destinationPath['pathDocument'].$document['file'];
if(!file_exists($pathToFile)) {
return response()->json(['status'=>'failed','message'=>'Directory not found!','code'=> 404], 404);
$destinationPath = $this->setCustomeDirectoryUpload();
$pathToFile = $destinationPath['pathDocument'] . $document['file'];
if (!file_exists($pathToFile)) {
return response()->json(['status' => 'failed', 'message' => 'Directory not found!', 'code' => 404], 404);
}
if($company) {
$name = pathinfo($pathToFile, PATHINFO_FILENAME) . "." . pathinfo($pathToFile, PATHINFO_EXTENSION);
}
$headers = [
'Content-Disposition' => 'attachment; filename="'.$name.'"'
'Content-Disposition' => 'attachment; filename="' . $name . '"'
];
return response()->download($pathToFile, $name, $headers);

1
app/Http/Controllers/ProjectExpenditureController.php

@ -16,7 +16,6 @@ class ProjectExpenditureController extends Controller
// Set Unique
$result = ProjectExpenditure::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {

1
app/Http/Controllers/ProjectFinancialHealthController.php

@ -16,7 +16,6 @@ class ProjectFinancialHealthController extends Controller
// Set Unique
$result = ProjectFinancialHealth::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {

1
app/Http/Controllers/ProjectInvoiceController.php

@ -16,7 +16,6 @@ class ProjectInvoiceController extends Controller
// Set Unique
$result = ProjectInvoice::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {

2
app/Http/Controllers/ProjectRoleController.php

@ -12,7 +12,6 @@ class ProjectRoleController extends Controller
$this->validate($request, [
'name' => 'required',
'description' => 'required',
'company_id' => 'required'
]);
$data = $request->all();
@ -20,7 +19,6 @@ class ProjectRoleController extends Controller
$data['created_by'] = $this->currentName;
$result = ProjectRole::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'add data project role successfully!','code'=>200], 200);
}else{

1
app/Http/Controllers/ProjectScheduleHealthController.php

@ -16,7 +16,6 @@ class ProjectScheduleHealthController extends Controller
// Set Unique
$result = ProjectScheduleHealth::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {

7
app/Http/Controllers/ReportActivityMaterialController.php

@ -102,14 +102,13 @@ class ReportActivityMaterialController extends Controller
}
}
public function delete($id, $company_id)
public function delete($id)
{
$data = ReportActivityMaterial::findOrFail($id);
$company = Company::find($company_id);
$image = Image::where([['ref_id', $id],['category','report_activity']])->first();
if($data && $company && $image) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
if($data && $image) {
$destinationPath = $this->setCustomeDirectoryUpload();
unlink($destinationPath['pathImage'].$image['image']);
}
if(!$data->delete()) {

4
app/Http/Controllers/RoleController.php

@ -11,9 +11,8 @@ class RoleController extends Controller
public function add(Request $request)
{
$this->validate($request, [
'name' => 'string|required|unique:m_roles,name,NULL,id,company_id,' . $request->input('company_id'),
'name' => 'string|required|unique:m_roles,name,NULL,id',
'description' => 'required',
'company_id' => 'required'
]);
$data = $request->all();
@ -24,7 +23,6 @@ class RoleController extends Controller
}
$result = Role::create($data);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500);

11
app/Http/Controllers/UserToProyekController.php

@ -113,7 +113,7 @@ class UserToProyekController extends Controller
}
}
public function delete($id, $company_id)
public function delete($id)
{
$data = UserToProyek::find($id);
if ($data) {
@ -121,7 +121,7 @@ class UserToProyekController extends Controller
$proyekId = $data->proyek_id;
$delete = $data->delete();
if ($delete) {
$this->deleteRelative($proyekId, $userId, $company_id);
$this->deleteRelative($proyekId, $userId);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'data assign hr to proyek not found!', 'code' => 400], 400);
@ -136,14 +136,12 @@ class UserToProyekController extends Controller
}
}
private function deleteRelative($proyekId, $userId, $company_id)
private function deleteRelative($proyekId, $userId)
{
$uta = UserToActivity::where("proyek_id", $proyekId)->where("user_id", $userId)->get();
foreach ($uta as $value) {
$dataRa = ReportActivity::where("activity_id", $value->activity_id)->where("user_id", $value->user_id)->get();
$company = Company::find($company_id);
if ($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$destinationPath = $this->setCustomeDirectoryUpload();
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
@ -155,7 +153,6 @@ class UserToProyekController extends Controller
}
ReportActivity::where("activity_id", $value->activity_id)->where("user_id", $value->user_id)->delete();
}
}
UserToActivity::where("proyek_id", $proyekId)->where("user_id", $userId)->delete();
}

8163
composer.lock generated

File diff suppressed because it is too large Load Diff

50
routes/web.php

@ -42,20 +42,20 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->group(['middleware' => ['auth', 'cors']], function () use ($router) {
$router->get('/dashboard/get-company-cashflow/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure
$router->get('/dashboard/get-invoice-outstanding/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in
$router->get('/dashboard/get-total-project-per-schedule-health/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerScheduleHealth');
$router->get('/dashboard/get-total-project-per-budget-health/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerBudgetHealth');
$router->get('/dashboard/get-total-project-schedule-health-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision');
$router->get('/dashboard/get-total-project-budget-health-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision');
$router->get('/dashboard/get-total-project-per-phase/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerPhase');
$router->get('/dashboard/get-total-project-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerDivision');
$router->get('/dashboard/get-total-project-value-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectValuePerDivision');
$router->get('/dashboard/get-detail-expenditure/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getDetailExpenditure');
$router->get('/dashboard/get-detail-expenditure-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailExpenditureColor');
$router->get('/dashboard/get-detail-financial-health-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailFinancialHealthColor');
$router->get('/dashboard/get-detail-schedule-health-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailScheduleHealthColor');
$router->get('/dashboard/get-detail-invoice-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailInvoiceColor');
$router->get('/dashboard/get-company-cashflow/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure
$router->get('/dashboard/get-invoice-outstanding/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in
$router->get('/dashboard/get-total-project-per-schedule-health/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerScheduleHealth');
$router->get('/dashboard/get-total-project-per-budget-health/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerBudgetHealth');
$router->get('/dashboard/get-total-project-schedule-health-per-division/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision');
$router->get('/dashboard/get-total-project-budget-health-per-division/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision');
$router->get('/dashboard/get-total-project-per-phase/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerPhase');
$router->get('/dashboard/get-total-project-per-division/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerDivision');
$router->get('/dashboard/get-total-project-value-per-division/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectValuePerDivision');
$router->get('/dashboard/get-detail-expenditure/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getDetailExpenditure');
$router->get('/dashboard/get-detail-expenditure-color/{role_name}', 'DashboardBoDController@getDetailExpenditureColor');
$router->get('/dashboard/get-detail-financial-health-color/{role_name}', 'DashboardBoDController@getDetailFinancialHealthColor');
$router->get('/dashboard/get-detail-schedule-health-color/{role_name}', 'DashboardBoDController@getDetailScheduleHealthColor');
$router->get('/dashboard/get-detail-invoice-color/{role_name}', 'DashboardBoDController@getDetailInvoiceColor');
$router->post('/role/search', 'RoleController@search');
$router->post('/role/add', 'RoleController@add');
@ -66,15 +66,15 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen');
$router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId');
$router->delete('/document-project/delete/{id}/{company_id}', 'ProjectDokumenController@delete');
$router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete');
$router->post('/document-project/search', 'ProjectDokumenController@searchDocProject');
$router->get('/document-project/download/{id}/{company_id}', 'ProjectDokumenController@downloadDokumen');
$router->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen');
$router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen');
$router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId');
$router->delete('/document-activity/delete/{id}/{company_id}', 'ActivityDokumenController@delete');
$router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete');
$router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject');
$router->get('/document-activity/download/{id}/{company_id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/project-by-customer/{id}', 'ProjectController@getByUser');
$router->post('/project/search', 'ProjectController@search');
@ -82,7 +82,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->put('/project/update/{id}', 'ProjectController@update');
$router->get('/project/edit/{id}', 'ProjectController@edit');
$router->get('/project/detail/{id}[/{gantt_id}[/{s_curve}]]', 'ProjectController@detail');
$router->delete('/project/delete/{id}/{company_id}', 'ProjectController@delete');
$router->delete('/project/delete/{id}', 'ProjectController@delete');
$router->get('/project/list', 'ProjectController@list');
$router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline');
$router->get('/project/set-baseline-activity/{activity_id}/{gantt_id}', 'ProjectController@setBaselineActivity');
@ -106,7 +106,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
/* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */
/* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */
$router->get('/project-carausell/{company_id}/{all_project}/{hierarchy}', 'ProjectCarausellController@invoke');
$router->get('/project-carausell/{all_project}/{hierarchy}', 'ProjectCarausellController@invoke');
$router->post('/project-charter/search', 'ProjectCharterController@search');
$router->post('/project-charter/add', 'ProjectCharterController@add');
@ -333,8 +333,8 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/image/search', 'ImageController@search');
$router->delete('/image/delete/{id}', 'ImageController@delete');
$router->delete('/image/delete/{id}/{category}/{company_id}', 'ImageController@deleteByRef');
$router->delete('/image/multiple-delete/{id}/{category}/{company_id}', 'ImageController@deleteByRefMultiple');
$router->delete('/image/delete/{id}/{category}', 'ImageController@deleteByRef');
$router->delete('/image/multiple-delete/{id}/{category}', 'ImageController@deleteByRefMultiple');
$router->post('/image/upload', 'ImageController@uploadImage');
$router->post('/image/multiple-upload', 'ImageController@uploadMultipleImage');
$router->get('/image/{id}/{category}', 'ImageController@getByRefId');
@ -431,7 +431,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/report-activity-material/add', 'ReportActivityMaterialController@add');
$router->post('/report-activity-material/search', 'ReportActivityMaterialController@search');
$router->delete('/report-activity-material/delete/{id}/{company_id}', 'ReportActivityMaterialController@delete');
$router->delete('/report-activity-material/delete/{id}', 'ReportActivityMaterialController@delete');
$router->get('/report-activity-material/list', 'ReportActivityMaterialController@list');
$router->get('/report-activity-material/datatables', 'ReportActivityMaterialController@datatables');
$router->post('/report-activity-material/update-status', 'ReportActivityMaterialController@updateStatusStartFinish');
@ -485,7 +485,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit');
$router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update');
$router->post('/user-to-proyek/search', 'UserToProyekController@search');
$router->delete('/user-to-proyek/delete/{id}/{company_id}', 'UserToProyekController@delete');
$router->delete('/user-to-proyek/delete/{id}', 'UserToProyekController@delete');
$router->get('/user-to-proyek/list', 'UserToProyekController@list');
$router->get('/user-to-proyek/select', 'UserToProyekController@select');
$router->get('/user-to-proyek/get-employee-integration', 'UserToProyekController@getEmployeeIntegration');
@ -494,7 +494,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/folder-document-proyek/edit/{id}', 'FolderDocumentProyekController@edit');
$router->put('/folder-document-proyek/update/{id}', 'FolderDocumentProyekController@update');
$router->post('/folder-document-proyek/search', 'FolderDocumentProyekController@search');
$router->delete('/folder-document-proyek/delete/{id}/{company_id}', 'FolderDocumentProyekController@delete');
$router->delete('/folder-document-proyek/delete/{id}', 'FolderDocumentProyekController@delete');
$router->get('/folder-document-proyek/list', 'FolderDocumentProyekController@list');
$router->get('/folder-document-proyek/get-tree/{id}', 'FolderDocumentProyekController@getTree');

Loading…
Cancel
Save