Browse Source

Merge branch 'master' of https://git.oslog.id/ibnu/generic-ospro-backend into Dev-Farhan

pull/1/head
farhantock 10 months ago
parent
commit
1c8c41f885
  1. 40
      app/Http/Controllers/ActivityController.php
  2. 71
      app/Http/Controllers/ActivityDokumenController.php
  3. 122
      app/Http/Controllers/Controller.php
  4. 42
      app/Http/Controllers/HumanResourceController.php
  5. 78
      app/Http/Controllers/ImageController.php
  6. 115
      app/Http/Controllers/KanbanBoardController.php
  7. 258
      app/Http/Controllers/KanbanCardController.php
  8. 75
      app/Http/Controllers/ProjectController.php
  9. 219
      app/Http/Controllers/ProjectDokumenController.php
  10. 81
      app/Http/Controllers/RefferalCodeController.php
  11. 37
      app/Http/Controllers/RoleMenuController.php
  12. 31
      app/Http/Controllers/UserToProyekController.php
  13. 17
      app/Models/KanbanBoard.php
  14. 17
      app/Models/KanbanCard.php
  15. 29
      app/Models/RefferalCode.php
  16. 34
      app/Models/Satuan.php
  17. 37
      routes/web.php

40
app/Http/Controllers/ActivityController.php

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use DateTime;
use App\Models\Link;
use App\Models\User;
use App\Models\Company;
use App\Models\Project;
use App\Models\Activity;
use App\Models\TmpImport;
@ -16,6 +17,7 @@ use App\Models\AssignMaterial;
use App\Models\UserToActivity;
use App\Models\ActivityDokumen;
use App\Models\CommentActivity;
use App\Models\ProductTransaction;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Helpers\MasterFunctionsHelper;
@ -626,28 +628,32 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'message' => 'Activity Updated!', 'code' => 200], 200);
}
public function delete($id)
public function delete($id, $company_id)
{
if (!$data = Activity::find($id))
return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'Data not found!', 'code' => 404], 404);
$this->deleteRelative($id);
$this->deleteRelative($id, $company_id);
if (!$data->delete())
return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'data activity failed deleted!', 'code' => 500], 500);
return response()->json(['status' => 'success', "action" => "deleted", 'message' => 'data activity successfully deleted!', 'code' => 200], 200);
}
private function deleteRelative($activity_id)
private function deleteRelative($activity_id, $company_id)
{
UserToActivity::where('activity_id', $activity_id)->delete();
AssignMaterial::where('activity_id', $activity_id)->delete();
$dataAd = ActivityDokumen::where("activity_id", $activity_id)->get();
foreach ($dataAd as $ad) {
if (file_exists($this->pathActivityDocument . $ad->file)) {
unlink($this->pathActivityDocument . $ad->file);
}
}
ActivityDokumen::where("activity_id", $activity_id)->delete();
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
foreach ($dataAd as $ad) {
if (file_exists($destinationPath['pathActivityDocument'] . $ad->file)) {
unlink($destinationPath['pathActivityDocument'] . $ad->file);
}
}
ActivityDokumen::where("activity_id", $activity_id)->delete();
}
}
public function getUpdate($id)
@ -1124,18 +1130,22 @@ class ActivityController extends Controller
$document = $request->file('dokumen');
$gantt_id = $request->gantt_id;
$name = $document->getClientOriginalName();
$result = $document->move($this->pathTmpImport, $name);
if ($result) {
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $document, $name, $destinationPath['pathTmpImport'], $destinationPath);
}
if (isset($getLimitStorage) && $getLimitStorage['resultMove']) {
$data = [
'gantt_id' => (int) $gantt_id,
'file' => $name,
'type_dokumen' => $request->type_dokumen
];
$result = TmpImport::create($data);
$getLimitStorage['resultMove'] = TmpImport::create($data);
if (!$result) {
if (!$getLimitStorage['resultMove']) {
unlink($this->pathTmpImport . $name);
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
}
@ -1161,6 +1171,6 @@ class ActivityController extends Controller
// public function recalculateProject($by, $id){
// // query get activity
// $cekActivity =
// $cekActivity =
// }
}

71
app/Http/Controllers/ActivityDokumenController.php

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Company;
use Illuminate\Http\Request;
use App\Models\ActivityDokumen;
@ -16,50 +17,52 @@ class ActivityDokumenController extends Controller
return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200);
}
public function delete($id)
public function delete($id, $company_id)
{
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);
if(file_exists($this->pathActivityDocument.$document->file))
unlink($this->pathActivityDocument.$document->file);
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);
}
}
$document->delete();
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);
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();
$result = $document->move($this->pathActivityDocument, $name);
if(!$result)
$company = Company::find($request->company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$result = $document->move($destinationPath['pathActivityDocument'], $name);
}
if(!$result || !$company)
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
$data = [
'activity_id' => (int)$activity_id,
'file' => $name,
'description' => $request->description
];
$result = ActivityDokumen::create($data);
if(!$result){
unlink($this->pathActivityDocument.$name);
if(!$result || !$company){
unlink($destinationPath['pathActivityDocument'].$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload success!','code'=>200], 200);
}
@ -75,21 +78,23 @@ class ActivityDokumenController extends Controller
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function downloadDokumen($id)
public function downloadDokumen($id, $company_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'=>400], 400);
if(file_exists($this->pathActivityDocument.$document->file)){
$pathToFile = $this->pathActivityDocument.$document->file;
return response()->download($pathToFile);
}
$company = Company::find($company_id);
if(!$document || !$company) {
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;
return response()->download($pathToFile);
}
}
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400);
}
}

122
app/Http/Controllers/Controller.php

@ -2,16 +2,17 @@
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use App\Models\UserToActivity;
use App\Models\User;
use App\Models\Divisi;
use App\Models\Activity;
use App\Models\AssignMaterial;
use App\Models\Divisi;
use App\Models\User;
use Laravel\Lumen\Routing\Controller as BaseController;
use App\Models\ReportK3Detail;
use App\Models\UserToActivity;
use App\Models\ProductTransaction;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
@ -38,6 +39,91 @@ class Controller extends BaseController
$this->pathActivityDocument = config('assets.activity');
}
protected function setCustomeDirectoryUpload($company_name)
{
$pathImage = 'assets/'.$company_name.'/image/';
$pathDocument = 'assets/'.$company_name.'/file/project/';
$pathTmpImport = 'assets/'.$company_name.'/file/tmpimport/';
$pathActivityDocument = 'assets/'.$company_name.'/file/activity/';
return [
'pathImage' => $pathImage,
'pathDocument' => $pathDocument,
'pathTmpImport' => $pathTmpImport,
'pathActivityDocument' => $pathActivityDocument
];
}
protected function setLimitsStorage($company, $dokumen, $name, $initPath, $destinatePath) {
$totalSize = 0;
$sizeFile = $dokumen->getSize();
// Path
$folderPath = $destinatePath['pathDocument'];
$folderPathImage = $destinatePath['pathImage'];
$folderPathTmpImport = $destinatePath['pathTmpImport'];
$folderPathActivityDocument = $destinatePath['pathActivityDocument'];
// Create Directory
if(!file_exists($initPath)) {
mkdir($initPath, 0777, true);
}
// Scanning & Existing Folder
if(file_exists($folderPathImage)) {
$files = scandir($folderPathImage);
foreach ($files as $file) {
if (is_file($folderPathImage . '/' . $file)) {
$totalSize += filesize($folderPathImage . '/' . $file);
}
}
}
if(file_exists($folderPath)) {
$filesImage = scandir($folderPath);
foreach ($filesImage as $file) {
if (is_file($folderPath . '/' . $file)) {
$totalSize += filesize($folderPath . '/' . $file);
}
}
}
if(file_exists($folderPathTmpImport)) {
$filesTmpImport = scandir($folderPathTmpImport);
foreach ($filesTmpImport as $file) {
if (is_file($folderPathTmpImport . '/' . $file)) {
$totalSize += filesize($folderPathTmpImport . '/' . $file);
}
}
}
if(file_exists($folderPathActivityDocument)) {
$filesActivityDocument = scandir($folderPathActivityDocument);
foreach ($filesActivityDocument as $file) {
if (is_file($folderPathActivityDocument . '/' . $file)) {
$totalSize += filesize($folderPathActivityDocument . '/' . $file);
}
}
}
// Logic
$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);
}
}
$resultMove = $dokumen->move($folderPath, $name);
return [
'resultMove' => $resultMove
];
}
protected function setUpPayload($condition, $tableSelf)
{
$alias = "selfTable";
@ -280,6 +366,28 @@ class Controller extends BaseController
return $totalCost;
}
protected function paramsMethodGet($query, $countData, $request)
{
$start = $request->start;
$length = $request->length == '-1' ? $countData : $request->length;
$orderBy = $request->orderby;
$asc = $request->asc == 'false' ? 'desc' : 'asc';
$where = $request->column;
$logicOp = $request->logic;
$valColumn = str_replace("\\", "", "$request->value");
if ($logicOp == 'like' || $logicOp == 'ilike') {
$valColumnFilter = '%' . $valColumn . '%';
} else {
$valColumnFilter = $valColumn;
}
$data = $query->where($where, $logicOp, $valColumnFilter)
->orderBy($orderBy, $asc)
->offset($start)->limit($length)->get();
return $data;
}
protected function getLoc($lat, $lng)
{
// $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json");

42
app/Http/Controllers/HumanResourceController.php

@ -41,7 +41,7 @@ class HumanResourceController extends Controller
->where('company_id', $request->company_id)
->first();
if($transaction->where([['type_paket','Basic'],['amount','!=',null]])->exists()) {
if($projectResult['total_hr'] < 10) {
if($projectResult['total_hr'] < 50) {
$countCreate = true;
}
} elseif ($cloneQueryTransaction->where([['type_paket','Free'],['amount',0]])->exists()) {
@ -74,7 +74,7 @@ class HumanResourceController extends Controller
'employee_type' => 'required',
'company_id' => 'required',
'username' => 'required',
'email' => 'required'
'email' => 'required|unique:m_users,email|email'
]);
$data = $request->all();
@ -113,10 +113,38 @@ class HumanResourceController extends Controller
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400);
}
$humanresource = HumanResource::find($id);
if(empty($humanresource)) {
return response()->json(['status' => 'failed', 'message' => 'Data Human Resource not found!', 'code' => 400], 400);
}
$transaction = ProductTransaction::query()
->where('company_id', $request->company_id);
$cloneQueryTransaction = clone $transaction;
if($request->company_id && isset($request->password) && isset($request->username)) :
$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;
}
endif;
$request->ktp_number !== $humanresource['ktp_number'] ? $this->validate($request,['ktp_number'=>'unique:m_users,ktp_number|string']) : '';
$request->email !== $humanresource['email'] ? $this->validate($request,['email'=>'unique:m_users,email|email']) : '';
$request->password ? $this->validate($request,['password'=>'required|min:8']) : '';
@ -131,11 +159,10 @@ class HumanResourceController extends Controller
return response()->json(['status' => 'failed', 'message' => 'Username already exists!', 'code' => 400], 400);
}
if ($humanresource) {
if ($countCreate) {
$result = $humanresource->update($data);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Human Resource Pool not found!', 'code' => 400], 400);
die();
} else {
return response()->json(['status' => 'failed', 'message' => 'Limited to create human resource!', 'code' => 500], 500);
}
if ($result) {
@ -153,7 +180,6 @@ class HumanResourceController extends Controller
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data Human Resource Pool not found!', 'code' => 400], 400);
die();
}

78
app/Http/Controllers/ImageController.php

@ -2,9 +2,10 @@
namespace App\Http\Controllers;
use App\Models\Image;
use App\Models\Company;
use Illuminate\Http\Request;
use App\Models\Image;
use App\Models\ProductTransaction;
class ImageController extends Controller
{
@ -22,10 +23,13 @@ class ImageController extends Controller
$extension = $dokumen->extension();
$category = $request->category;
$name = $ref_id.date("YmdHis").".".$extension;
$resultMove = $dokumen->move($this->pathImage, $name);
if($resultMove){
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $dokumen, $name, $destinationPath['pathImage'], $destinationPath);
}
if(isset($getLimitStorage) && $getLimitStorage['resultMove']) {
$data = [
'ref_id' => (int)$ref_id,
'image' => $name,
@ -63,7 +67,7 @@ class ImageController extends Controller
if($result){
return response()->json(['status'=>'success', "name_image"=>$name,'message'=>'image upload is successfully!','code'=>200], 200);
}else{
unlink($this->pathImage.$name);
unlink($destinationPath['pathImage'].$name);
return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400);
}
@ -88,11 +92,50 @@ class ImageController extends Controller
$dokumen = $request->file('files');
$successCount = 0;
$imageSlider = [];
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
$totalSize = 0;
$sizeFile = $dokumen->getSize();
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$folderPath = $destinationPath['pathImage'];
if (!file_exists($folderPath)) {
mkdir($folderPath, 0777, true);
}
$files = scandir($folderPath);
$totalSize = 0;
foreach ($files as $file) {
if (is_file($folderPath . '/' . $file)) {
$totalSize += filesize($folderPath . '/' . $file);
}
}
$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();
$name = $ref_id.date("YmdHis").$successCount.".".$extension;
$resultMove = $file->move($this->pathImage, $name);
$resultMove = $file->move($folderPath, $name);
if ($resultMove) {
$data = [
@ -107,7 +150,7 @@ class ImageController extends Controller
if ($result) {
$successCount++;
} else {
unlink($this->pathImage . $name);
unlink($folderPath . $name);
}
}
}
@ -147,8 +190,6 @@ class ImageController extends Controller
return response()->json(['status'=>'failed','message'=>'data image not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'data image successfully deleted!','code'=>200], 200);
}else{
@ -167,12 +208,13 @@ class ImageController extends Controller
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function deleteByRef($id, $category)
public function deleteByRef($id, $category, $company_id)
{
$data = Image::where("ref_id", intval($id))->where("category", $category)->first();
if($data){
unlink($this->pathImage.$data->image);
$company = Company::find($company_id);
if($data && $company){
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
unlink($destinationPath['pathImage'].$data->image);
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data image not found!','code'=>400], 400);
@ -187,16 +229,18 @@ class ImageController extends Controller
}
}
public function deleteByRefMultiple($id, $category)
public function deleteByRefMultiple($id, $category, $company_id)
{
$successCount = 0;
$data = Image::where([
["ref_id", intval($id)],
["category", $category]
])->get();
if($data->isNotEmpty()) {
$company = Company::find($company_id);
if($data->isNotEmpty() && $company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
foreach($data as $img) {
unlink($this->pathImage.$img->image);
unlink($destinationPath['pathImage'].$img->image);
$delete = $img->delete();
if($delete){
$successCount++;

115
app/Http/Controllers/KanbanBoardController.php

@ -0,0 +1,115 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\KanbanBoard;
class KanbanBoardController extends Controller
{
public function add(Request $request){
$this->validate($request, [
'name_board' => 'required',
'header_color' => 'required',
'body_color' => 'required',
'proyek_id' => 'required',
'version_gantt_id' => 'required',
'status_progress' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$statusCount = KanbanBoard::where('version_gantt_id', $request->version_gantt_id)
->where('status_progress', $request->status_progress)
->get()
->count();
if ($statusCount < 1 || $request->status_progress == 'none') {
$result = KanbanBoard::create($data);
} else {
return response()->json(['status'=>'failed','message'=>'Board kanban failed created','code'=>400], 400);
}
if($result){
return response()->json(['status'=>'success','message'=>'Board kanban successfull created','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Board kanban failed created','code'=>400], 400);
}
}
public function update(Request $request, $id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
}
$data = KanbanBoard::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Data Board kanban not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Board kanban successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Board kanban failed updated!','code'=>400], 400);
}
}
public function delete($id)
{
$data = KanbanBoard::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'Data Board kanban not found!','code'=>400], 400);
die();
}
if($delete){
return response()->json(['status'=>'success','message'=>'Board kanban successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Board kanban failed deleted!','code'=>400], 400);
}
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
die();
}
$result = KanbanBoard::find($id);
if($result){
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}else{
return response()->json(['status'=>'failed','message'=>'failed get data Board kanban, please try again later!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'kanban_board');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list(Request $request)
{
$query = KanbanBoard::select("*");
$countData = $query->count();
$data = $this->paramsMethodGet($query, $countData, $request);
if($data)
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>count($data)], 200);
return response()->json(['status'=>'failed','message'=>'failed get Board kanban, please try again later!','code'=>400], 400);
}
}

258
app/Http/Controllers/KanbanCardController.php

@ -0,0 +1,258 @@
<?php
namespace App\Http\Controllers;
use App\Models\User;
use App\Models\Project;
use App\Models\Activity;
use App\Models\KanbanCard;
use App\Models\KanbanBoard;
// use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class KanbanCardController extends Controller
{
private function add($board_id, $gantt_id, $type_activity, $status_progress)
{
$dataActivity = Activity::where("version_gantt_id", $gantt_id)
->where("type_activity", $type_activity)
->get();
foreach ($dataActivity as $keyA) {
// $this->add($keyA->id, $gantt_id, $board_id);
$data = array(
'activity_id' => $keyA->id,
'kanban_board_id' => $board_id,
'version_gantt_id' => $gantt_id,
'created_by' => $this->currentName
);
switch ($status_progress) {
case 'open':
if ($keyA->persentase_progress == 0) {
$add = KanbanCard::create($data);
}
break;
case 'on-progress':
if ($keyA->persentase_progress > 0 && $keyA->persentase_progress < 100) {
$cardIds = DB::table('kanban_card as kc')
->join('m_activity as ma', 'kc.activity_id', '=', 'ma.id')
->where('kc.activity_id', '=', $keyA->id)
->select('kc.id')
->get();
foreach ($cardIds as $cardId) {
$this->delete($cardId->id);
}
$add = KanbanCard::create($data);
}
break;
case 'done':
if ($keyA->persentase_progress == 100) {
$cardIds = DB::table('kanban_card as kc')
->join('m_activity as ma', 'kc.activity_id', '=', 'ma.id')
->where('kc.activity_id', '=', $keyA->id)
->select('kc.id')
->get();
foreach ($cardIds as $cardId) {
$this->delete($cardId->id);
}
$add = KanbanCard::create($data);
}
break;
}
}
return "success";
}
public function update(Request $request, $id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$data = KanbanCard::where("activity_id", $id);
if ($data) {
$result = $data->update($request->all());
} else {
return response()->json(['status' => 'failed', 'message' => 'Data Card kanban not found!', 'code' => 400], 400);
die();
}
$board = KanbanBoard::find($request->kanban_board_id);
$activity = Activity::find($id);
if ($board->status_progress == "done" && $activity) {
$activity->update(['persentase_progress' => 100]);
} else{
if($activity['persentase_progress'] != 95 && $activity['persentase_progress'] != 100){
$activity->update(['persentase_progress' => 0]);
}else{
$activity->update(['persentase_progress' => 95]);
}
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'Board kanban successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Board kanban failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = KanbanCard::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'Data Board kanban not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'Board kanban successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Board kanban failed deleted!', 'code' => 400], 400);
}
}
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = KanbanCard::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data Board kanban, please try again later!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'kanban_board');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function getData($project_id, $gantt_id, $board_id, Request $request)
{
// cek ketika dia owner dari project maka
$SESSIONID = $request->session;
$status_progress = KanbanBoard::select("status_progress")->where('id', $board_id)->first();
if ($status_progress) {
if (DB::table('user_to_version_gantt')->where('user_id', $SESSIONID)->where('version_gantt_id', $gantt_id)->exists()) {
$dataCard = $this->getDataAll($project_id, $gantt_id, $board_id, $status_progress->status_progress, true);
} else {
$dataCard = $this->getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress->status_progress, true);
}
} else {
return response()->json(['status' => 'empty', 'message' => 'data board is empty, please you insert!', 'code' => 200], 200);
}
if ($dataCard && count($dataCard) > 0){
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataCard, "totalRecord" => count($dataCard)], 200);
}else{
return response()->json(['status' => 'empty', 'message' => 'data card is empty, please you insert!', 'code' => 200], 200);
}
}
private function getDataAll($project_id, $gantt_id, $board_id, $status_progress, $status)
{
$dataFinal = [];
if($status == true){
if ($status_progress != 'none') {
if (KanbanCard::where('kanban_board_id', $board_id)->where("version_gantt_id", $gantt_id)->count() == 0) {
$this->add($board_id, $gantt_id, 'task', $status_progress);
$this->getDataAll($project_id, $gantt_id, $board_id, $status_progress, false);
}
}
}
$dataCard = DB::table("kanban_card as kc")
->select("ma.id as activity_id", "ma.name", "ma.start_date", "ma.end_date", "ma.persentase_bobot", "ma.jumlah_pekerjaan", "ma.bobot_planning", "ma.persentase_progress")
->join("m_activity as ma", "ma.id", "=", "kc.activity_id")
->where("kc.kanban_board_id", $board_id)
->where("kc.version_gantt_id", $gantt_id)
->orderBy('ma.sortorder')
->get();
foreach ($dataCard as $keyCard) {
$query = DB::table("assign_hr_to_activity as ahta")
->select("ahta.id", "mu.name", "mu.id as id_hr")
->join("m_users as mu", "mu.id", "=", "ahta.user_id")
->where("ahta.activity_id", $keyCard->activity_id)
->get();
$dataArray = array(
"id" => $keyCard->activity_id,
"assign_hr" => $query,
"activity" => $keyCard->name,
"start_date" => $keyCard->start_date,
"end_date" => $keyCard->end_date,
"jumlah_pekerjaan" => $keyCard->jumlah_pekerjaan,
"bobot_planning" => $keyCard->bobot_planning,
"persentase_progress" => $keyCard->persentase_progress
);
$dataFinal[] = $dataArray;
}
// }
return $dataFinal;
}
private function getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress, $status)
{
$dataFinal = [];
if($status == true){
if ($status_progress != 'none') {
if (KanbanCard::where('kanban_board_id', $board_id)->where("version_gantt_id", $gantt_id)->count() == 0) {
$this->add($board_id, $gantt_id, 'task', $status_progress);
$this->getDataContributor($project_id, $gantt_id, $board_id, $request, $status_progress, false);
}
}
$dataUser = User::whereId($request->session)->first();
$dataCard = DB::table("kanban_card as kc")
->select("ma.id as activity_id", "ma.name", "ma.start_date", "ma.end_date", "ma.persentase_bobot", "ma.jumlah_pekerjaan", "ma.bobot_planning", "ma.persentase_progress")
->join("m_activity as ma", "ma.id", "=", "kc.activity_id")
->where([
["kc.created_by", $dataUser['name']],
["kc.kanban_board_id", $board_id],
["kc.version_gantt_id", $gantt_id]
])
->orderBy('ma.sortorder')
->get();
foreach ($dataCard as $keyCard) {
$query = DB::table("assign_hr_to_activity as ahta")
->select("ahta.id", "mu.name", "mu.id as id_hr")
->join("m_users as mu", "mu.id", "=", "ahta.user_id")
->where("ahta.activity_id", $keyCard->activity_id)
->get();
$dataArray = array(
"id" => $keyCard->activity_id,
"assign_hr" => $query,
"activity" => $keyCard->name,
"start_date" => $keyCard->start_date,
"end_date" => $keyCard->end_date,
"jumlah_pekerjaan" => $keyCard->jumlah_pekerjaan,
"bobot_planning" => $keyCard->bobot_planning,
"persentase_progress" => $keyCard->persentase_progress,
"test" => $request->session
);
$dataFinal[] = $dataArray;
}
}
return $dataFinal;
}
}

75
app/Http/Controllers/ProjectController.php

@ -6,6 +6,7 @@ use DateTime;
use App\Models\Link;
use App\Models\User;
use App\Models\Image;
use App\Models\Company;
use App\Models\Holiday;
use App\Models\Project;
use App\Models\Activity;
@ -33,15 +34,15 @@ use App\Models\ProjectApproval;
use App\Models\RequestMaterial;
use App\Models\ProjectMileStone;
use App\Models\ProjectChecklists;
use App\Models\ProductTransaction;
use Illuminate\Support\Facades\DB;
use App\Models\ProjectParticipants;
use App\Models\FolderDocumentProyek;
use App\Models\ProjectToChecklistK3;
use App\Helpers\MasterFunctionsHelper;
use App\Models\ProductTransaction;
use App\Models\ReportActivityMaterial;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\Artisan;
const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1";
@ -206,14 +207,14 @@ class ProjectController extends Controller
return true;
}
public function delete($id)
public function delete($id, $company_id)
{
$data = Project::find($id);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$this->deleteRelative($id);
$this->deleteRelative($id, $company_id);
if (!$data->delete())
return response()->json(['status' => 'failed', 'message' => 'Delete failed!', 'code' => 500], 500);
@ -221,7 +222,7 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
}
private function deleteRelative($project_id)
private function deleteRelative($project_id, $company_id)
{
UserToProyek::where('proyek_id', $project_id)->delete();
UserToActivity::where('proyek_id', $project_id)->delete();
@ -239,32 +240,36 @@ 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);
$this->deleteDokumenProject($project_id);
$this->deleteVersionGantt($project_id, $company_id);
$this->deleteDokumenProject($project_id, $company_id);
}
private function deleteVersionGantt($project_id)
private function deleteVersionGantt($project_id, $company_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();
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if (file_exists($this->pathImage . $image->image)) {
unlink($this->pathImage . $image->image);
}
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
}
$dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get();
foreach ($dataAd as $ad) {
if (file_exists($this->pathActivityDocument . $ad->file)) {
unlink($this->pathActivityDocument . $ad->file);
}
}
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if (file_exists($destinationPath['pathImage'] . $image->image)) {
unlink($destinationPath['pathImage'] . $image->image);
}
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
}
$dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get();
foreach ($dataAd as $ad) {
if (file_exists($destinationPath['pathActivityDocument'] . $ad->file)) {
unlink($destinationPath['pathActivityDocument'] . $ad->file);
}
}
}
ActivityDokumen::whereIn("activity_id", $activityIds)->delete();
CommentActivity::whereIn("activity_id", $activityIds)->delete();
Holiday::where("proyek_id", $project_id)->delete();
@ -275,23 +280,26 @@ class ProjectController extends Controller
ReportActivity::whereIn("activity_id", $activityIds)->delete();
}
private function deleteDokumenProject($project_id)
private function deleteDokumenProject($project_id, $company_id)
{
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get();
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
foreach ($dataDokumen as $dokumen) {
if (file_exists($destinationPath['pathDocument'] . $dokumen->file)) {
unlink($destinationPath['pathDocument'] . $dokumen->file);
}
}
}
foreach ($dataDokumen as $dokumen) {
if (file_exists($this->pathDocument . $dokumen->file)) {
unlink($this->pathDocument . $dokumen->file);
}
}
DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete();
$dataFolder = FolderDocumentProyek::where('proyek_id', $project_id)->pluck("id");
$ref_ids = $dataFolder->all();
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get();
foreach ($dataDokumen as $dokumen) {
if (file_exists($this->pathDocument . $dokumen->file)) {
unlink($this->pathDocument . $dokumen->file);
if (file_exists($destinationPath['pathDocument'] . $dokumen->file)) {
unlink($destinationPath['pathDocument'] . $dokumen->file);
}
}
@ -520,9 +528,6 @@ class ProjectController extends Controller
}
$activity->save();
}
/* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */
/* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */
for ($i = 0; $i < count($reports); $i++) {
$activity = Activity::find($reports[$i]['activity_id']);
if ($reports[$i]['status'] != 'done') {

219
app/Http/Controllers/ProjectDokumenController.php

@ -1,105 +1,114 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\DokumenProject;
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);
}
$document = DokumenProject::where("ref_id", $id)->get();
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);
}
public function delete($id)
{
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);
}
if(file_exists($this->pathDocument.$document->file)){
unlink($this->pathDocument.$document->file);
}
$document->delete();
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
}
public function uploadProjectDokumen(Request $request)
{
if($request->hasFile('dokumen')){
$document = $request->file('dokumen');
$ref_id = $request->ref_id;
$name = $document->getClientOriginalName();
$result = $document->move($this->pathDocument, $name);
if($result){
$data = [
'ref_id' => (int)$ref_id,
'file' => $name,
'type_dokumen' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document'
];
$result = DokumenProject::create($data);
if(!$result){
unlink($this->pathDocument.$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload successful!','code'=>200], 200);
}
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400);
}
public function searchDocProject(Request $request){
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'document_project');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function downloadDokumen($id)
{
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'=> 404], 404);
if(!file_exists($this->pathDocument.$document->file))
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
$pathToFile = $this->pathDocument.$document->file;
$name = pathinfo($pathToFile, PATHINFO_FILENAME) . "." . pathinfo($pathToFile, PATHINFO_EXTENSION);
$headers = [
'Content-Disposition' => 'attachment; filename="'.$name.'"'
];
// dd($name, $headers);
return response()->download($pathToFile, $name, $headers);
}
}
<?php
namespace App\Http\Controllers;
use App\Models\Company;
use Illuminate\Http\Request;
use App\Models\DokumenProject;
use App\Models\ProductTransaction;
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);
}
$document = DokumenProject::where("ref_id", $id)->get();
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);
}
public function delete($id, $company_id)
{
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);
}
}
$document->delete();
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200);
}
public function uploadProjectDokumen(Request $request)
{
if($request->hasFile('dokumen')){
$document = $request->file('dokumen');
$ref_id = $request->ref_id;
$name = $document->getClientOriginalName();
// Limited Storage
$company = Company::where('company_name', $request->company_name)->first();
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$getLimitStorage = $this->setLimitsStorage($company, $document, $name, $destinationPath['pathDocument'],$destinationPath);
}
if(isset($getLimitStorage) && $getLimitStorage['resultMove']) {
$data = [
'ref_id' => (int)$ref_id,
'file' => $name,
'type_dokumen' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document'
];
$getLimitStorage['resultMove'] = DokumenProject::create($data);
if(!$getLimitStorage['resultMove']){
unlink($destinationPath['pathDocument'].$name);
return response()->json(['status'=>'failed','message'=>'Dokumen project gagal diupload!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Dokumen project berhasil diupload!','code'=>200], 200);
}
return response()->json(['status'=>'failed','message'=>'Dokumen project gagal diupload!','code'=> 500], 500);
}
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400);
}
public function searchDocProject(Request $request){
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'document_project');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function downloadDokumen($id, $company_id)
{
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(!file_exists($this->pathDocument.$document->file)) {
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
}
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$pathToFile = $destinationPath['pathDocument'].$document->file;
$name = pathinfo($pathToFile, PATHINFO_FILENAME) . "." . pathinfo($pathToFile, PATHINFO_EXTENSION);
}
$headers = [
'Content-Disposition' => 'attachment; filename="'.$name.'"'
];
return response()->download($pathToFile, $name, $headers);
}
}

81
app/Http/Controllers/RefferalCodeController.php

@ -0,0 +1,81 @@
<?php
namespace App\Http\Controllers;
use App\Models\RefferalCode;
use Illuminate\Http\Request;
class RefferalCodeController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'code' => 'required|unique:refferal_code,code',
'exp' => 'nullable',
'type' => 'nullable',
'allocation' => 'nullable'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = RefferalCode::create($data);
if($result){
return response()->json(['status'=>'success','message'=>'Add refferal code successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Add refferal Code failed!','code'=>400], 400);
}
}
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400);
die();
}
$result = RefferalCode::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Failed get refferal code, please try again later!', 'code' => 400], 400);
}
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
}
$data = RefferalCode::find($id);
if($data){
$result = $data->update($request->all());
}else{
return response()->json(['status'=>'failed','message'=>'Refferal code not found!','code'=>400], 400);
die();
}
if($result){
return response()->json(['status'=>'success','message'=>'Refferal code successfully updated!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'Refferal code failed updated!','code'=>400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'refferal_code');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
}

37
app/Http/Controllers/RoleMenuController.php

@ -28,6 +28,43 @@ class RoleMenuController extends Controller
}
}
public function addMultiple(Request $request)
{
$menus = $request->all();
if (is_array($menus) && count($menus) > 0 && isset($menus[0]['menu_id'])) {
$countRes = 0;
foreach ($menus as $menu) {
$dataInsert = array(
"menu_id" => $menu['menu_id'],
"role_id" => $menu['role_id'],
);
$result = RoleMenu::create($dataInsert);
if ($result) {
$countRes++;
} else {
$countRes--;
}
}
if ($countRes > 0) {
return response()->json(['status' => 'success', 'message' => 'Add data menu role successfully!', 'code' => 200]);
} else {
return response()->json(['status' => 'failed', 'message' => 'Add data menu role failed created!', 'code' => 500]);
}
} else {
if(isset($data))
{
return response()->json(['status' => 'success', 'message' => 'Add data menu role successfully!', 'code' => 200]);
}else{
return response()->json(['status' => 'failed', 'message' => 'Add data menu role failed created!', 'code' => 500]);
}
}
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id==""){

31
app/Http/Controllers/UserToProyekController.php

@ -2,11 +2,12 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Image;
use App\Models\Company;
use App\Models\UserToProyek;
use App\Models\UserToActivity;
use Illuminate\Http\Request;
use App\Models\ReportActivity;
use App\Models\Image;
use App\Models\UserToActivity;
class UserToProyekController extends Controller
{
@ -111,7 +112,7 @@ class UserToProyekController extends Controller
}
}
public function delete($id)
public function delete($id, $company_id)
{
$data = UserToProyek::find($id);
if($data){
@ -119,7 +120,7 @@ class UserToProyekController extends Controller
$proyekId = $data->proyek_id;
$delete = $data->delete();
if($delete){
$this->deleteRelative($proyekId, $userId);
$this->deleteRelative($proyekId, $userId, $company_id);
}
}else{
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400);
@ -134,21 +135,25 @@ class UserToProyekController extends Controller
}
}
private function deleteRelative($proyekId, $userId)
private function deleteRelative($proyekId, $userId, $company_id)
{
$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();
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if(file_exists($this->pathImage.$image->image)){
unlink($this->pathImage.$image->image);
$company = Company::find($company_id);
if($company) {
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if(file_exists($destinationPath['pathImage'].$image->image)){
unlink($destinationPath['pathImage'].$image->image);
}
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
ReportActivity::where("activity_id", $value->activity_id)->where("user_id", $value->user_id)->delete();
}
ReportActivity::where("activity_id", $value->activity_id)->where("user_id", $value->user_id)->delete();
}
UserToActivity::where("proyek_id", $proyekId)->where("user_id", $userId)->delete();
}

17
app/Models/KanbanBoard.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class KanbanBoard extends Model
{
protected $table = 'kanban_board';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name_board', 'header_color', 'body_color', 'status_progress', 'proyek_id', 'version_gantt_id', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
}

17
app/Models/KanbanCard.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class KanbanCard extends Model
{
protected $table = 'kanban_card';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'activity_id', 'kanban_board_id', 'version_gantt_id', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
}

29
app/Models/RefferalCode.php

@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class RefferalCode extends Model
{
protected $table = 'refferal_code';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'id',
'code',
'amount',
'exp',
'type',
'allocation',
'description',
'created_at',
'created_by',
'updated_at',
'updated_by',
'deleted_at',
'deleted_by'
];
}

34
app/Models/Satuan.php

@ -1,17 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Satuan extends Model
{
protected $table = 'm_satuan';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Satuan extends Model
{
protected $table = 'm_satuan';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

37
routes/web.php

@ -16,6 +16,8 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/demo-management-user/add', 'DemoController@add');
$router->post('/role-user/add', 'RoleController@add');
$router->post('/menu-company-user/add-multiple', 'MenuCompanyController@addMultiple');
$router->post('/role-menu-user/add-multiple', 'RoleMenuController@addMultiple');
$router->post('/refferal-code/search', 'RefferalCodeController@search');
$router->post('/menu/add', 'MenuController@add');
$router->get('/menu/edit/{id}', 'MenuController@edit');
@ -57,15 +59,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}', 'ProjectDokumenController@delete');
$router->delete('/document-project/delete/{id}/{company_id}', 'ProjectDokumenController@delete');
$router->post('/document-project/search', 'ProjectDokumenController@searchDocProject');
$router->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen');
$router->get('/document-project/download/{id}/{company_id}', 'ProjectDokumenController@downloadDokumen');
$router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen');
$router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId');
$router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete');
$router->delete('/document-activity/delete/{id}/{company_id}', 'ActivityDokumenController@delete');
$router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject');
$router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/document-activity/download/{id}/{company_id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/project-by-customer/{id}', 'ProjectController@getByUser');
$router->post('/project/search', 'ProjectController@search');
@ -73,7 +75,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}', 'ProjectController@delete');
$router->delete('/project/delete/{id}/{company_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');
@ -133,6 +135,11 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/human-resource/check-old-password/{id}', 'HumanResourceController@checkOldPassword');
$router->get('/human-resource/sync', 'HumanResourceController@sync');
$router->post('/refferal-code/search', 'RefferalCodeController@search');
$router->post('/refferal-code/add', 'RefferalCodeController@add');
$router->get('/refferal-code/edit/{id}', 'RefferalCodeController@edit');
$router->put('/refferal-code/update/{id}', 'RefferalCodeController@update');
$router->post('/project-role/search', 'ProjectRoleController@search');
$router->post('/project-role/add', 'ProjectRoleController@add');
$router->get('/project-role/edit/{id}', 'ProjectRoleController@edit');
@ -263,7 +270,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/task/edit/{id}', 'ActivityController@edit');
$router->put('/task/{id}', 'ActivityController@update');
$router->put('/task/update-regular/{id}', 'ActivityController@updateRegular');
$router->delete('/task/{id}', 'ActivityController@delete');
$router->delete('/task/{id}/{company_id}', 'ActivityController@delete');
$router->get('/task/get-update/{id}', 'ActivityController@getUpdate');
$router->post('/tmp-import/upload', 'ActivityController@uploadTmpImport');
@ -324,8 +331,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}', 'ImageController@deleteByRef');
$router->delete('/image/multiple-delete/{id}/{category}', 'ImageController@deleteByRefMultiple');
$router->delete('/image/delete/{id}/{category}/{company_id}', 'ImageController@deleteByRef');
$router->delete('/image/multiple-delete/{id}/{category}/{company_id}', 'ImageController@deleteByRefMultiple');
$router->post('/image/upload', 'ImageController@uploadImage');
$router->post('/image/multiple-upload', 'ImageController@uploadMultipleImage');
$router->get('/image/{id}/{category}', 'ImageController@getByRefId');
@ -362,6 +369,18 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/project-issues/list', 'ProjectIssuesController@list');
$router->get('/project-issues/{where}/{val}', 'ProjectIssuesController@customWhere');
$router->get('/kanban-board/list', 'KanbanBoardController@list');
$router->post('/kanban-board/add', 'KanbanBoardController@add');
$router->put('/kanban-board/update/{id}', 'KanbanBoardController@update');
$router->delete('/kanban-board/delete/{id}', 'KanbanBoardController@delete');
$router->post('/kanban-board/search', 'KanbanBoardController@search');
$router->get('/kanban-card/get-data/{project_id}/{gantt_id}/{board_id}', 'KanbanCardController@getData');
$router->post('/kanban-card/add', 'KanbanCardController@add');
$router->put('/kanban-card/update/{id}', 'KanbanCardController@update');
$router->delete('/kanban-card/delete/{id}', 'KanbanCardController@delete');
$router->post('/kanban-card/search', 'KanbanCardController@search');
$router->post('/project-risks/add', 'ProjectRisksController@add');
$router->get('/project-risks/edit/{id}', 'ProjectRisksController@edit');
$router->put('/project-issues/update/{id}', 'ProjectRisksController@update');
@ -464,7 +483,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}', 'UserToProyekController@delete');
$router->delete('/user-to-proyek/delete/{id}/{company_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');

Loading…
Cancel
Save