Ibnu hamdani
3 years ago
commit
f8a19c4ac6
170 changed files with 21602 additions and 0 deletions
@ -0,0 +1,15 @@
|
||||
root = true |
||||
|
||||
[*] |
||||
charset = utf-8 |
||||
end_of_line = lf |
||||
insert_final_newline = true |
||||
indent_style = space |
||||
indent_size = 4 |
||||
trim_trailing_whitespace = true |
||||
|
||||
[*.md] |
||||
trim_trailing_whitespace = false |
||||
|
||||
[*.{yml,yaml}] |
||||
indent_size = 2 |
@ -0,0 +1,10 @@
|
||||
/vendor |
||||
/.idea |
||||
Homestead.json |
||||
Homestead.yaml |
||||
.env |
||||
.env.production |
||||
.phpunit.result.cache |
||||
api-testing.http |
||||
bootstrap/backup |
||||
.config-prod.json |
@ -0,0 +1,21 @@
|
||||
<IfModule mod_rewrite.c> |
||||
<IfModule mod_negotiation.c> |
||||
Options -MultiViews -Indexes |
||||
</IfModule> |
||||
|
||||
RewriteEngine On |
||||
|
||||
# Handle Authorization Header |
||||
RewriteCond %{HTTP:Authorization} . |
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] |
||||
|
||||
# Redirect Trailing Slashes If Not A Folder... |
||||
RewriteCond %{REQUEST_FILENAME} !-d |
||||
RewriteCond %{REQUEST_URI} (.+)/$ |
||||
RewriteRule ^ %1 [L,R=301] |
||||
|
||||
# Handle Front Controller... |
||||
RewriteCond %{REQUEST_FILENAME} !-d |
||||
RewriteCond %{REQUEST_FILENAME} !-f |
||||
RewriteRule ^ index.php [L] |
||||
</IfModule> |
@ -0,0 +1,6 @@
|
||||
php: |
||||
preset: laravel |
||||
disabled: |
||||
- unused_use |
||||
js: true |
||||
css: true |
@ -0,0 +1,58 @@
|
||||
# How To Run This Project |
||||
Need PHP >= 7.3 |
||||
1. Clone this project to your htdocs |
||||
2. After clone, run command |
||||
```sh |
||||
$ composer install |
||||
``` |
||||
3. Then rename .env.example to .env |
||||
4. After rename run command |
||||
```sh |
||||
$ php artisan key:generate |
||||
``` |
||||
and |
||||
```sh |
||||
$ php artisan jwt:secret |
||||
``` |
||||
6. URL to access the API is |
||||
```sh |
||||
`localhost/simpro-lumen/api/${api-url}` |
||||
``` |
||||
# Usefull Command |
||||
- Create model |
||||
```sh |
||||
$ php artisan make:model ModelName |
||||
``` |
||||
- Create Controller |
||||
```sh |
||||
$ php artisan make:controller ControllerName |
||||
``` |
||||
# List Documentation Url |
||||
- Query builder |
||||
```sh |
||||
https://laravel.com/docs/8.x/queries |
||||
``` |
||||
# Lumen PHP Framework |
||||
|
||||
[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) |
||||
[![Total Downloads](https://img.shields.io/packagist/dt/laravel/framework)](https://packagist.org/packages/laravel/lumen-framework) |
||||
[![Latest Stable Version](https://img.shields.io/packagist/v/laravel/framework)](https://packagist.org/packages/laravel/lumen-framework) |
||||
[![License](https://img.shields.io/packagist/l/laravel/framework)](https://packagist.org/packages/laravel/lumen-framework) |
||||
|
||||
Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. |
||||
|
||||
## Official Documentation |
||||
|
||||
Documentation for the framework can be found on the [Lumen website](https://lumen.laravel.com/docs). |
||||
|
||||
## Contributing |
||||
|
||||
Thank you for considering contributing to Lumen! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). |
||||
|
||||
## Security Vulnerabilities |
||||
|
||||
If you discover a security vulnerability within Lumen, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. |
||||
|
||||
## License |
||||
|
||||
The Lumen framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
@ -0,0 +1,29 @@
|
||||
<?php |
||||
|
||||
namespace App\Console; |
||||
|
||||
use Illuminate\Console\Scheduling\Schedule; |
||||
use Laravel\Lumen\Console\Kernel as ConsoleKernel; |
||||
|
||||
class Kernel extends ConsoleKernel |
||||
{ |
||||
/** |
||||
* The Artisan commands provided by your application. |
||||
* |
||||
* @var array |
||||
*/ |
||||
protected $commands = [ |
||||
// |
||||
]; |
||||
|
||||
/** |
||||
* Define the application's command schedule. |
||||
* |
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule |
||||
* @return void |
||||
*/ |
||||
protected function schedule(Schedule $schedule) |
||||
{ |
||||
// |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
<?php |
||||
|
||||
namespace App\Events; |
||||
|
||||
use Illuminate\Queue\SerializesModels; |
||||
|
||||
abstract class Event |
||||
{ |
||||
use SerializesModels; |
||||
} |
@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Events; |
||||
|
||||
class ExampleEvent extends Event |
||||
{ |
||||
/** |
||||
* Create a new event instance. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
// |
||||
} |
||||
} |
@ -0,0 +1,54 @@
|
||||
<?php |
||||
|
||||
namespace App\Exceptions; |
||||
|
||||
use Illuminate\Auth\Access\AuthorizationException; |
||||
use Illuminate\Database\Eloquent\ModelNotFoundException; |
||||
use Illuminate\Validation\ValidationException; |
||||
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler; |
||||
use Symfony\Component\HttpKernel\Exception\HttpException; |
||||
use Throwable; |
||||
|
||||
class Handler extends ExceptionHandler |
||||
{ |
||||
/** |
||||
* A list of the exception types that should not be reported. |
||||
* |
||||
* @var array |
||||
*/ |
||||
protected $dontReport = [ |
||||
AuthorizationException::class, |
||||
HttpException::class, |
||||
ModelNotFoundException::class, |
||||
ValidationException::class, |
||||
]; |
||||
|
||||
/** |
||||
* Report or log an exception. |
||||
* |
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
||||
* |
||||
* @param \Throwable $exception |
||||
* @return void |
||||
* |
||||
* @throws \Exception |
||||
*/ |
||||
public function report(Throwable $exception) |
||||
{ |
||||
parent::report($exception); |
||||
} |
||||
|
||||
/** |
||||
* Render an exception into an HTTP response. |
||||
* |
||||
* @param \Illuminate\Http\Request $request |
||||
* @param \Throwable $exception |
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse |
||||
* |
||||
* @throws \Throwable |
||||
*/ |
||||
public function render($request, Throwable $exception) |
||||
{ |
||||
return parent::render($request, $exception); |
||||
} |
||||
} |
@ -0,0 +1,110 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Absent; |
||||
|
||||
class AbsentController extends Controller |
||||
{ |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Absent::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Absent successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Absent failed created','code'=>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 = Absent::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Absent not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Absent successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Absent failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Absent::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Absent not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Absent successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Absent 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 = Absent::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data Absent, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in golang API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 't_absensi'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Absent::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get Absent, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,106 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ActivityDokumen; |
||||
|
||||
class ActivityDokumenController extends Controller |
||||
{ |
||||
public function dokumenByActivityId($id){ |
||||
if($id && $id!="" && (int)$id > 0){ |
||||
$dataDokumen = ActivityDokumen::where("activity_id", $id)->get(); |
||||
|
||||
return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'activity id is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
if($id && $id!="" && (int)$id > 0){ |
||||
$dokumen = ActivityDokumen::find($id); |
||||
if($dokumen){ |
||||
if(file_exists($this->pathActivityDocument.$dokumen->file)){ |
||||
unlink($this->pathActivityDocument.$dokumen->file); |
||||
} |
||||
$dokumen->delete(); |
||||
return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function uploadProjectDokumen(Request $request) |
||||
{ |
||||
if($request->hasFile('dokumen')){ |
||||
$activity_id = $request->activity_id; |
||||
$dokumen = $request->file('dokumen'); |
||||
$extension = $dokumen->extension(); |
||||
$name = $dokumen->getClientOriginalName(); |
||||
|
||||
$result = $dokumen->move($this->pathActivityDocument, $name); |
||||
if($result){ |
||||
$data = [ |
||||
'activity_id' => (int)$activity_id, |
||||
'file' => $name, |
||||
'description' => $request->description |
||||
]; |
||||
|
||||
$result = ActivityDokumen::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'file upload is successfully!','code'=>200], 200); |
||||
}else{ |
||||
unlink($this->pathActivityDocument.$name); |
||||
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400); |
||||
} |
||||
|
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function searchDocProject(Request $request){ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_document_activity'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function downloadDokumen($id) |
||||
{ |
||||
if($id && $id!="" && (int)$id > 0){ |
||||
$dokumen = ActivityDokumen::find($id); |
||||
if($dokumen){ |
||||
if(file_exists($this->pathActivityDocument.$dokumen->file)){ |
||||
$pathToFile = $this->pathActivityDocument.$dokumen->file; |
||||
return response()->download($pathToFile); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,325 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\AssignMaterial; |
||||
use App\Models\MaterialResource; |
||||
use App\Models\RequestMaterial; |
||||
use App\Models\Activity; |
||||
use App\Models\ReportActivityMaterial; |
||||
use Datatables; |
||||
|
||||
class AssignMaterialController extends Controller |
||||
{ |
||||
public function add_backup(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'activity_id' => 'required', |
||||
'material_id' => 'required', |
||||
'qty_planning' => 'required', |
||||
'budget' => 'required' |
||||
]); |
||||
|
||||
$checkStock = MaterialResource::where("id", $request->material_id)->first(); |
||||
$currentStock = $checkStock->qty; |
||||
if((int)$currentStock < (int)$request->qty_planning){ |
||||
return response()->json(['status'=>'failed','message'=>'Not enough stock in warehouse!','code'=>400]); |
||||
die(); |
||||
} |
||||
|
||||
// $checkData = AssignMaterial::where("activity_id", $request->activity_id)->where("material_id", $request->material_id) |
||||
// ->count(); |
||||
|
||||
// if($checkData > 0){ |
||||
// $update = $this->updateFromAdd($request->all()); |
||||
// if($update){ |
||||
// return response()->json(['status'=>'success','message'=>'Assign material success!','code'=>200]); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'Assign material failed','code'=>400]); |
||||
// } |
||||
// die(); |
||||
// } |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = AssignMaterial::create($data); |
||||
if($result){ |
||||
$checkStock = MaterialResource::find($request->material_id); |
||||
$newStock = (int)$checkStock->qty - (int)$request->qty_planning; |
||||
$dataUpdate = array( |
||||
"qty"=>$newStock, |
||||
"updated_by"=>$this->currentName |
||||
); |
||||
$checkStock->update($dataUpdate); |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Assign material successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Assign material failed created','code'=>400]); |
||||
} |
||||
} |
||||
|
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'activity_id' => 'required', |
||||
'material_id' => 'required', |
||||
'qty_planning' => 'required' |
||||
// 'budget' => 'required' |
||||
]); |
||||
|
||||
$checkStock = RequestMaterial::where("id", $request->material_id)->first(); |
||||
$currentStock = $checkStock->qty; |
||||
$price = $checkStock->price; |
||||
if((int)$currentStock < (int)$request->qty_planning){ |
||||
return response()->json(['status'=>'failed','message'=>'Not enough stock !','code'=>400]); |
||||
die(); |
||||
} |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
$data['budget'] = $price; |
||||
|
||||
$result = AssignMaterial::create($data); |
||||
if($result){ |
||||
// comment untill fix flow |
||||
// $checkStock = MaterialResource::find($request->material_id); |
||||
// $newStock = (int)$checkStock->qty - (int)$request->qty_planning; |
||||
// $dataUpdate = array( |
||||
// "qty"=>$newStock, |
||||
// "updated_by"=>$this->currentName |
||||
// ); |
||||
// $checkStock->update($dataUpdate); |
||||
|
||||
// update cost planning |
||||
$updateActivity = Activity::find($request->activity_id); |
||||
if($updateActivity){ |
||||
$costPlanOld = $updateActivity==null? 0 : (int)$updateActivity->rencana_biaya; |
||||
$costPlanNew = $costPlanOld + ($price*$request->qty_planning); |
||||
$updateActivity->rencana_biaya = $costPlanNew; |
||||
$updateActivity->save(); |
||||
// $updateActivity->update(array("rencana_biaya"=>$costPlanNew)); |
||||
return response()->json(['status'=>'success','message'=>'Assign material successfull created, and update cost plan success '.$costPlanNew,'code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'Assign material successfull created','code'=>200]); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Assign material failed created','code'=>400]); |
||||
} |
||||
} |
||||
|
||||
private function updateFromAdd($data){ |
||||
$assignMaterial = AssignMaterial::where("activity_id", $data->activity_id)->where("material_id", $data->material_id)->first(); |
||||
|
||||
$newQty = (int)$assignMaterial->qty_planning + (int)$data->qty_planning; |
||||
|
||||
$newBudget = $assignMaterial->budget > $data->budget ? $assignMaterial->budget : $data->budget; |
||||
|
||||
$dataUpdate = array( |
||||
"qty_planning"=>$newQty, |
||||
"budget"=>$newBudget, |
||||
"updated_by"=>$this->currentName |
||||
); |
||||
|
||||
$dataWillUpdate = AssignMaterial::where("activity_id", $data->activity_id)->where("material_id", $data->material_id); |
||||
|
||||
return $dataWillUpdate->update($dataUpdate); |
||||
} |
||||
|
||||
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 = AssignMaterial::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Assign material not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Assign material successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Assign material failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = AssignMaterial::find($id); |
||||
|
||||
if($data){ |
||||
$id = $data->material_id; |
||||
$stock = $data->qty_planning; |
||||
$materialResource = MaterialResource::find($id); |
||||
if($materialResource){ |
||||
$oldStock = $materialResource->qty; |
||||
$newStock = $oldStock + $stock; |
||||
$dataUpdate = array( |
||||
"qty"=>$newStock, |
||||
"updated_by"=>$this->currentName |
||||
); |
||||
$materialResource->update($dataUpdate); |
||||
} |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Assign material not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Assign material successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Assign material 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 = AssignMaterial::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data Assign material, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in golang API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'assign_material_to_activity'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = AssignMaterial::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get Assign material, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function datatables(Request $request){ |
||||
$id_activity = $request->query('idact'); |
||||
// $data = AssignMaterial::select("assign_material_to_activity.*","m.name as material_name", "m.uom as uom")->join("m_material_resource as m", "m.id", "=", "assign_material_to_activity.material_id")->where('assign_material_to_activity.activity_id', $id_activity)->get(); |
||||
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom")->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")->where('assign_material_to_activity.activity_id', $id_activity)->get(); |
||||
return Datatables::of($data) |
||||
->addIndexColumn() |
||||
->addColumn('action', function($row){ |
||||
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-material-delete"><i class="fa fa-trash"></i></a>'; |
||||
return $actionBtn; |
||||
}) |
||||
->rawColumns(['action'])->make(true); |
||||
} |
||||
|
||||
public function datatablesForReportActivity(Request $request){ |
||||
$id_activity = $request->query('idact'); |
||||
// $data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") |
||||
// ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") |
||||
// // ->groupBy("assign_material_to_activity.activity_id") |
||||
// ->where("assign_material_to_activity.activity_id", $id_activity)->get(); |
||||
$data = AssignMaterial::select(AssignMaterial::raw('SUM(qty_planning) as qty_planning'), "m.description as material_name", "assign_material_to_activity.activity_id as activity_id") |
||||
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") |
||||
->groupBy("m.description") |
||||
->groupBy("assign_material_to_activity.activity_id") |
||||
->where("assign_material_to_activity.activity_id", $id_activity)->get(); |
||||
return Datatables::of($data) |
||||
->addIndexColumn() |
||||
->addColumn('qty_sum', function($row){ |
||||
$val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1") |
||||
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") |
||||
->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id") |
||||
->groupBy("m.description") |
||||
->where("m.description", strval($row->material_name)) |
||||
->where("ram.activity_id", $row->activity_id)->first(); |
||||
return $val_qty_act ? $val_qty_act->qty_sum : '-'; |
||||
}) |
||||
->addColumn('status_activity', function($row){ |
||||
$val_status = AssignMaterial::select("status_activity") |
||||
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id') |
||||
->where('m.description', '=', $row->material_name) |
||||
->where("assign_material_to_activity.activity_id", $row->activity_id)->first(); |
||||
return $val_status ? $val_status->status_activity : null; |
||||
}) |
||||
->addColumn('start_activity', function($row){ |
||||
$val_start = AssignMaterial::select("start_activity") |
||||
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id') |
||||
->where('m.description', '=', $row->material_name) |
||||
->where("assign_material_to_activity.activity_id", $row->activity_id)->first(); |
||||
return $val_start ? $val_start->start_activity : null; |
||||
}) |
||||
->addColumn('finish_activity', function($row){ |
||||
$val_finish = AssignMaterial::select("finish_activity") |
||||
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id') |
||||
->where('m.description', '=', $row->material_name) |
||||
->where("assign_material_to_activity.activity_id", $row->activity_id)->first(); |
||||
return $val_finish ? $val_finish->finish_activity : null; |
||||
}) |
||||
->addColumn('uom', function($row){ |
||||
$val_uom = RequestMaterial::select("uom") |
||||
->where('description', '=', $row->material_name)->first(); |
||||
return $val_uom ? $val_uom->uom : null; |
||||
}) |
||||
->addColumn('action', function($row){ |
||||
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" data-material-name="'.$row->material_name.'" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>'; |
||||
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$row->id.'" data-material-name="'.$row->material_name.'" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>'; |
||||
// $actionBtn .= '<a href="javascript:void(0)" style="margin-left:5px;" data-id="'.$row->id.'" data-material-name="'.$row->material_name.'" class="success btn btn-success btn-sm btn-update-status" data-toggle="tooltip" title="Input Update Status" data-placement="top"><i class="fa fa-edit"></i></a>'; |
||||
return $actionBtn; |
||||
}) |
||||
->rawColumns(['action'])->make(true); |
||||
} |
||||
|
||||
public function ForReportActivityByMaterial(Request $request){ |
||||
$id_activity = $request->idact; |
||||
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") |
||||
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") |
||||
->where('assign_material_to_activity.activity_id', $id_activity)->get(); |
||||
foreach ($data as $key) { |
||||
// for ($i=0; $i < count($data); $i++) { |
||||
# code... |
||||
|
||||
$val_qty_sum = ReportActivityMaterial::where('assign_material_id', '=', $key->id)->sum("qty"); |
||||
// $data[] = ['qty' =>$val_qty_sum ? $val_qty_sum : 0]; |
||||
// array_push($data[$i], ['qty' =>$val_qty_sum ? $val_qty_sum : 0]); |
||||
} |
||||
// $data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") |
||||
// ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") |
||||
// ->where('assign_material_to_activity.activity_id', $id_activity, function ($query) { |
||||
// $query->sum('qty') |
||||
// ->from('report_activity_material') |
||||
// ->where('report_activity_material.assign_material_id', 'assign_material_to_activity.id'); |
||||
// })->get(); |
||||
$countData = $data->count(); |
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get Assign material, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,179 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\AssignTools; |
||||
use Datatables; |
||||
use App\Models\ToolsResource; |
||||
class AssignToolsController extends Controller |
||||
{ |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'activity_id' => 'required', |
||||
'tools_id' => 'required', |
||||
'qty_planning' => 'required', |
||||
]); |
||||
|
||||
$checkStock = ToolsResource::where("id", $request->tools_id)->first(); |
||||
$currentStock = $checkStock->qty; |
||||
if((int)$currentStock < (int)$request->qty_planning){ |
||||
return response()->json(['status'=>'failed','message'=>'Not enough stock in warehouse!','code'=>400]); |
||||
die(); |
||||
} |
||||
// $checkData = AssignTools::where("activity_id", $request->activity_id)->where("tools_id", $request->tools_id) |
||||
// ->count(); |
||||
|
||||
// if($checkData > 0){ |
||||
// $update = $this->updateFromAdd($request->all()); |
||||
// if($update){ |
||||
// return response()->json(['status'=>'success','message'=>'Assign tools success!','code'=>200]); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'Assign tools failed','code'=>400]); |
||||
// } |
||||
// die(); |
||||
// } |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = AssignTools::create($data); |
||||
if($result){ |
||||
$checkStock = ToolsResource::find($request->tools_id); |
||||
$newStock = (int)$checkStock->qty - (int)$request->qty_planning; |
||||
$dataUpdate = array( |
||||
"qty"=>$newStock, |
||||
"updated_by"=>$this->currentName |
||||
); |
||||
$checkStock->update($dataUpdate); |
||||
return response()->json(['status'=>'success','message'=>'Assign tools success!','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Assign tools failed','code'=>400]); |
||||
} |
||||
} |
||||
|
||||
private function updateFromAdd($data){ |
||||
$assignTools = AssignTools::where("activity_id", $data->activity_id)->where("tools_id", $data->tools_id)->first(); |
||||
|
||||
$newQty = (int)$assignTools->qty_planning + (int)$data->qty_planning; |
||||
$dataUpdate = array( |
||||
"qty_planning"=>$newQty, |
||||
"updated_by"=>$this->currentName |
||||
); |
||||
|
||||
$dataWillUpdate = AssignMaterial::where("activity_id", $data->activity_id)->where("tools_id", $data->tools_id); |
||||
|
||||
return $dataWillUpdate->update($dataUpdate); |
||||
} |
||||
|
||||
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 = AssignTools::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Assign tools not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Assign tools successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Assign tools failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = AssignTools::find($id); |
||||
|
||||
if($data){ |
||||
$id = $data->tools_id; |
||||
$stock = $data->qty_planning; |
||||
$toolsResource = ToolsResource::find($id); |
||||
if($toolsResource){ |
||||
$oldStock = $toolsResource->qty; |
||||
$newStock = $oldStock + $stock; |
||||
$dataUpdate = array( |
||||
"qty"=>$newStock, |
||||
"updated_by"=>$this->currentName |
||||
); |
||||
$toolsResource->update($dataUpdate); |
||||
} |
||||
|
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Assign tools not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Assign tools successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Assign tools 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 = AssignTools::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data Assign tools, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in golang API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'assign_tools_to_activity'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = AssignTools::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get Assign tools, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function datatables(Request $request){ |
||||
$id_activity = $request->query('idact'); |
||||
$data = AssignTools::select("assign_tools_to_activity.*","m.name as tools_name","m.uom as uom")->join("m_tools_resource as m", "m.id", "=", "assign_tools_to_activity.tools_id")->where('assign_tools_to_activity.activity_id', $id_activity)->get(); |
||||
return Datatables::of($data) |
||||
->addIndexColumn() |
||||
->addColumn('action', function($row){ |
||||
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-tools-delete"><i class="fa fa-trash"></i></a>'; |
||||
return $actionBtn; |
||||
}) |
||||
->rawColumns(['action'])->make(true); |
||||
} |
||||
} |
@ -0,0 +1,94 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Support\Facades\Auth; |
||||
use Illuminate\Http\Request; |
||||
|
||||
use App\Models\User; |
||||
use App\Models\Role; |
||||
use App\Models\Project; |
||||
use App\Models\UserProject; |
||||
|
||||
class AuthController extends Controller |
||||
{ |
||||
/** |
||||
* Create a new AuthController instance. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
$this->middleware('auth:api', ['except' => ['login']]); |
||||
} |
||||
|
||||
public function login(Request $request) |
||||
{ |
||||
$username = $request->username; |
||||
$password = $request->password; |
||||
$is_mobile = $request->is_mobile; |
||||
|
||||
if(empty($username) || empty($password)){ |
||||
return response()->json(['status'=>'error','message'=>'You must fill all the fields'], 400); |
||||
} |
||||
|
||||
$credentials = array( |
||||
"username"=> $username, |
||||
"password"=> md5($password) |
||||
); |
||||
|
||||
$user = User::where('username', $username)->where('password', md5($password)) |
||||
->first(); |
||||
|
||||
if($is_mobile){ |
||||
$fcm_token = $request->fcm_token; |
||||
|
||||
if(!$fcm_token || $fcm_token==""){ |
||||
return response()->json(['status'=>'error','message'=>'FCM Token is required'], 400); |
||||
die(); |
||||
} |
||||
|
||||
$dataUpdateFcm = array( |
||||
"fcm_token"=>$fcm_token |
||||
); |
||||
|
||||
$hr = User::find($user->id); |
||||
|
||||
if($hr){ |
||||
$result = $hr->update($dataUpdateFcm); |
||||
} |
||||
} |
||||
|
||||
$dataRole = Role::find($user->role_id); |
||||
|
||||
if($dataRole){ |
||||
$user->role = $dataRole; |
||||
} |
||||
|
||||
// if($user->role_id!=1){ |
||||
// $dataProject = UserProject::where('user_id', $user->id)->first(); |
||||
// if($dataProject){ |
||||
// $user->project = $dataProject; |
||||
// } |
||||
// } |
||||
|
||||
if (! $token =Auth::login($user)) { |
||||
return response()->json(['error' => 'Unauthorized'], 401); |
||||
} |
||||
|
||||
return $this->respondWithToken($token, $user); |
||||
} |
||||
|
||||
protected function respondWithToken($token, $user) |
||||
{ |
||||
return response()->json([ |
||||
'code' => 200, |
||||
'data' => array( |
||||
'data_user' => $user, |
||||
'access_token' => $token, |
||||
'token_type' => 'bearer', |
||||
'expires_in' => auth()->factory()->getTTL() * 60 |
||||
), |
||||
]); |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
|
||||
class BroadcastController extends Controller |
||||
{ |
||||
// |
||||
} |
@ -0,0 +1,96 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ChecklistK3; |
||||
|
||||
class ChecklistK3Controller extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ChecklistK3::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Master checklist K3 successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master checklist K3 failed created','code'=>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 = ChecklistK3::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Master checklist K3 not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Master checklist K3 successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master checklist K3 failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ChecklistK3::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Master checklist K3 not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Master checklist K3 successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master checklist K3 failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_checklist_k3'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ChecklistK3::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,111 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\CommentActivity; |
||||
|
||||
class CommentActivityController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'activity_id' => 'required', |
||||
'comment' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = CommentActivity::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Comment Activity Project successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Comment Activity Project failed created','code'=>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 = CommentActivity::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Comment Activity Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Comment Activity Project successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Comment Activity Project failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = CommentActivity::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Comment Activity Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Comment Activity Project successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Comment Activity Project 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 = CommentActivity::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_comment_activity'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = CommentActivity::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list version gantt, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,116 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ConfigAlert; |
||||
|
||||
class ConfigAlertController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'keterangan' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ConfigAlert::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data config alert successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data config alert 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 = ConfigAlert::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data config alert, 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 = ConfigAlert::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data config alert not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data config alert successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data config alert failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ConfigAlert::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data config alert not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data config alert successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data config alert failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'config_alert'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ConfigAlert::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list config alert, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,100 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ConfigAlertUser; |
||||
|
||||
class ConfigAlertUserController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'config_alert_id' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ConfigAlertUser::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data config alert user successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data config alert user failed!','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 = ConfigAlertUser::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data config alert user not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data config alert user successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data config alert user failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ConfigAlertUser::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data config alert user not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data config alert user successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data config alert user failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'config_alert_to_user'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function getConfigUser($id) |
||||
{ |
||||
$getData = ConfigAlertUser::where('user_id', $id)->get(); |
||||
|
||||
if($getData){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$getData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'config alert for this user not found!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ReportActivity; |
||||
use App\Models\Activity; |
||||
use App\Models\Project; |
||||
|
||||
use DB; |
||||
|
||||
class ControlMonitoringController extends Controller |
||||
{ |
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_proyek'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// get another child data |
||||
if($request->has("child_data")){ |
||||
$newDataGet = []; |
||||
$child_data = $request->child_data; |
||||
$date_start = $child_data['start_date']; |
||||
$date_end = $child_data['date_end']; |
||||
foreach ($dataGet as $value) { |
||||
$ganttId = $this->getMaxVersionGantt($value->id); |
||||
$allActivityIds = Activity::where("version_gantt_id", $ganttId)->where("proyek_id", $value->id)->pluck("id"); |
||||
$value->volume_planning = Activity::where("version_gantt_id", $ganttId)->where("proyek_id", $value->id)->sum("jumlah_pekerjaan"); |
||||
$value->biaya_actual = Activity::where("version_gantt_id", $ganttId)->where("proyek_id", $value->id)->sum("biaya_actual"); |
||||
$value->volume_actual = ReportActivity::where("activity_id", $allActivityIds->all())->sum("job_count_report"); |
||||
$listAct = []; |
||||
$activityIds = ReportActivity::select("ma.id as id")->join("m_activity as ma", "ma.id", "=", "report_activity.activity_id")->where("ma.version_gantt_id", $ganttId)->where("ma.proyek_id", $value->id)->whereBetween("report_activity.report_date", [$date_start, $date_end])->groupBy("ma.id")->get()->pluck('id'); |
||||
$dataActivity = Activity::select("m_activity.*", "ms.name as uom")->leftJoin("m_satuan as ms", "ms.id","=","m_activity.satuan_id")->whereIn("m_activity.id", $activityIds->all())->get(); |
||||
foreach($dataActivity as $act){ |
||||
$act->list_report = ReportActivity::select("report_activity.*", "mu.name as user_name", "mi.image as image_url")->leftJoin("m_users as mu", "mu.id", "=", "report_activity.user_id")->leftJoin("m_image as mi", function($join){ |
||||
$join->on("mi.ref_id", "=", "report_activity.id")->where("mi.category", "report_activity"); |
||||
})->where("report_activity.activity_id", $act->id)->whereBetween("report_activity.report_date", [$date_start, $date_end])->get(); |
||||
// $act->list_report = ReportActivity::select("report_activity.*", "mu.name as user_name")->leftJoin("m_users as mu", "mu.id", "=", "report_activity.user_id")->where("report_activity.activity_id", $act->id)->whereBetween("report_activity.report_date", [$date_start, $date_end])->get(); |
||||
$listAct[] = $act; |
||||
} |
||||
$value->report_data = $listAct; |
||||
$newDataGet[] = $value; |
||||
} |
||||
$dataGet = $newDataGet; |
||||
} |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
private function getMaxVersionGantt($id){ |
||||
return Activity::where("proyek_id", $id)->max("version_gantt_id"); |
||||
} |
||||
} |
@ -0,0 +1,289 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
use Laravel\Lumen\Routing\Controller as BaseController; |
||||
|
||||
// you can add function or variable in this class and can access from controller who has |
||||
// extend this class example 'class ProjectDokumenController extends Controller' |
||||
// if you make controller with command 'php artisan make:controller nameController' |
||||
// its automatically extend the controller with this class |
||||
// access like this '$this->functionName($param)' or '$this->variableName' |
||||
class Controller extends BaseController |
||||
{ |
||||
// here is the global variabel |
||||
protected $pathImage = "assets/image/"; |
||||
protected $pathDocument = "assets/file/project/"; |
||||
protected $pathActivityDocument = "assets/file/activity/"; |
||||
protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth', |
||||
'sixth', 'seventh', 'eighth', 'ninth', 'tenth']; |
||||
protected $currentDate; |
||||
protected $currentName; |
||||
protected $currentId; |
||||
|
||||
public function __construct() |
||||
{ |
||||
// datetime now |
||||
$this->currentDate = date("Y-m-d H:i:s"); |
||||
// current user auth |
||||
$this->currentName = auth()->user() ? auth()->user()->name : "system"; |
||||
$this->currentId = auth()->user() ? auth()->user()->id : 0; |
||||
|
||||
// configure assets |
||||
$this->pathImage = config('assets.image'); |
||||
$this->pathDocument = config('assets.project'); |
||||
$this->pathActivityDocument = config('assets.activity'); |
||||
} |
||||
|
||||
// every single param in this function is required |
||||
protected function setUpPayload($condition, $tableSelf) |
||||
{ |
||||
$alias = "selfTable"; |
||||
$builder = DB::table($tableSelf." AS ".$alias); |
||||
$builder = $builder->select($alias.".*"); |
||||
if($condition){ |
||||
if(isset($condition['joins'])){ |
||||
$selectColumn = []; |
||||
$no = 0; |
||||
foreach($condition['joins'] as $join){ |
||||
$tableJoin = isset($join['name1']) ? $join['name1'] : $alias; |
||||
$tableName = $join['name']; |
||||
$columnJoin = $join['column_join']; // foreign key table sini |
||||
$columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan |
||||
$columnResult = $join['column_results']; |
||||
|
||||
foreach($columnResult as $sColumn){ |
||||
$builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn); |
||||
} |
||||
// need to make dinamic join option |
||||
$builder = $builder->leftJoin($tableName, $tableJoin.".".$columnJoin, '=', $tableName.'.'.$columnSelf); |
||||
$no++; |
||||
} |
||||
} |
||||
|
||||
if(isset($condition['columns'])){ |
||||
$listWhere = $condition['columns']; |
||||
|
||||
$builder = $builder->where(function ($query) use($listWhere, $alias){ |
||||
foreach($listWhere as $where){ |
||||
$value = $where['value']; |
||||
if($value && $value!="" && $value!=" "){ |
||||
$column = $where['name']; |
||||
$operator = strtolower($where['logic_operator']); // like, =, <>, range |
||||
//$whereCondition = $where['operator']; // AND , OR |
||||
$value2 = isset($where['value1']) ? $where['value1'] : ""; |
||||
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; |
||||
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
if(isset($condition['group_column'])){ |
||||
$builder = $this->groupWhere($builder, $condition['group_column'], $alias); |
||||
} |
||||
|
||||
$data['count'] = clone $builder; |
||||
|
||||
if(isset($condition['paging'])){ |
||||
$builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']); |
||||
} |
||||
|
||||
if(isset($condition['orders'])){ |
||||
$orders = $condition['orders']; |
||||
$sortBy = $orders['ascending'] ? "ASC" : "DESC"; |
||||
$columnOrder = $orders['columns']; |
||||
foreach($columnOrder as $column){ |
||||
$builder = $builder->orderBy($alias.".".$column, $sortBy); |
||||
} |
||||
} |
||||
} |
||||
$data['builder'] = $builder; |
||||
return $data; |
||||
} |
||||
|
||||
private function groupWhere($oldBuilder, $groupWhere, $alias) |
||||
{ |
||||
$builder = $oldBuilder; |
||||
$listGroupWhere = $groupWhere; |
||||
$operator = $listGroupWhere['operator']; |
||||
$operatorGroup = $listGroupWhere['group_operator']; |
||||
$listWhere = $listGroupWhere['where']; |
||||
if(strtolower($operator)=="and"){ |
||||
$builder = $builder->where(function($query) use($operatorGroup, $listWhere, $alias){ |
||||
$no = 1; |
||||
foreach ($listWhere as $where) { |
||||
$value = $where['value']; |
||||
$column = $where['name']; |
||||
$operator = strtolower($where['logic_operator']); |
||||
$value2 = isset($where['value1']) ? $where['value1'] : ""; |
||||
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; |
||||
if($value && $value!="" && $value!=" "){ |
||||
if($operatorGroup=="and"){ |
||||
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); |
||||
}else{ |
||||
if($no==1){ |
||||
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); |
||||
}else{ |
||||
$query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); |
||||
} |
||||
} |
||||
} |
||||
$no = $no+1; |
||||
} |
||||
}); |
||||
}else if(strtolower($operator)=="or"){ |
||||
$builder = $builder->orWhere(function($query) use($operatorGroup, $listWhere, $alias){ |
||||
$no = 1; |
||||
foreach ($listWhere as $where) { |
||||
$value = $where['value']; |
||||
$column = $where['name']; |
||||
$operator = strtolower($where['logic_operator']); |
||||
$value2 = isset($where['value1']) ? $where['value1'] : ""; |
||||
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; |
||||
if($value && $value!="" && $value!=" "){ |
||||
if($operatorGroup=="and"){ |
||||
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); |
||||
}else{ |
||||
if($no==1){ |
||||
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); |
||||
}else{ |
||||
$query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); |
||||
} |
||||
} |
||||
} |
||||
$no++; |
||||
} |
||||
}); |
||||
} |
||||
return $builder; |
||||
} |
||||
|
||||
private function whereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) |
||||
{ |
||||
$query = $oldQuery; |
||||
if($operator=="range"){ |
||||
$query = $query->whereBetween($tableColumn.".".$column, [$value, $value2]); |
||||
}else if($operator=="like"){ |
||||
$query = $query->where($tableColumn.".".$column, 'like', '%'.$value.'%'); |
||||
}else if($operator=="ilike"){ |
||||
$query = $query->where($tableColumn.".".$column, '~*', $value); |
||||
}else if($operator=="="){ |
||||
$query = $query->where($tableColumn.".".$column, $value); |
||||
}else if($operator=="in"){ |
||||
$query = $query->whereIn($tableColumn.".".$column, $value); |
||||
}else if($operator=="notin"){ |
||||
$query = $query->whereNotIn($tableColumn.".".$column, $value); |
||||
}else{ |
||||
$query = $query->where($tableColumn.".".$column, $operator, $value); |
||||
} |
||||
return $query; |
||||
} |
||||
|
||||
private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2){ |
||||
$query = $oldQuery; |
||||
if($operator=="range"){ |
||||
$query = $query->whereBetween($column, [$value, $value2]); |
||||
}else if($operator=="like"){ |
||||
$query = $query->where($column, 'like', '%'.$value.'%'); |
||||
}else if($operator=="ilike"){ |
||||
$query = $query->where($column, '~*', $value); |
||||
}else if($operator=="="){ |
||||
$query = $query->where($column, $value); |
||||
}else if($operator=="in"){ |
||||
$query = $query->whereIn($column, $value); |
||||
}else if($operator=="notin"){ |
||||
$query = $query->whereNotIn($column, $value); |
||||
}else{ |
||||
$query = $query->where($column, $operator, $value); |
||||
} |
||||
return $query; |
||||
} |
||||
|
||||
private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) |
||||
{ |
||||
$query = $oldQuery; |
||||
if($operator=="range"){ |
||||
$query = $query->orWhereBetween($tableColumn.".".$column, [$value, $value2]); |
||||
}else if($operator=="like"){ |
||||
$query = $query->orWhere($tableColumn.".".$column, 'like', '%'.$value.'%'); |
||||
}else if($operator=="ilike"){ |
||||
$query = $query->where($tableColumn.".".$column, '~*', $value); |
||||
}else if($operator=="="){ |
||||
$query = $query->orWhere($tableColumn.".".$column, $value); |
||||
}else if($operator=="in"){ |
||||
$query = $query->orWhereIn($tableColumn.".".$column, $value); |
||||
}else if($operator=="notin"){ |
||||
$query = $query->orWhereNotIn($tableColumn.".".$column, $value); |
||||
}else{ |
||||
$query = $query->orWhere($tableColumn.".".$column, $operator, $value); |
||||
} |
||||
return $query; |
||||
} |
||||
|
||||
// need call when update userToActivity / materialToActivity / toolsToActivity |
||||
protected function calculateAllCost($activity, $proyek_id){ |
||||
$humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id); |
||||
$materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id); |
||||
$toolsCostPlanning = 0; |
||||
|
||||
$allCost = $humanCostPlanning + $materialCostPlanning + $toolsCostPlanning; |
||||
return $allCost; |
||||
} |
||||
|
||||
private function calculateAllHumanCost($activity_id, $proyek_id) |
||||
{ |
||||
$dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate","ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate")->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id") |
||||
->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id) |
||||
->where("ahp.proyek_id", $proyek_id) |
||||
->get(); |
||||
|
||||
$totalCost = 0; |
||||
foreach ($dataHuman as $human) { |
||||
$uom = $human->uom_standart_rate; |
||||
$totalCost += $this->calculateHumanCost($human, $activity_id); |
||||
} |
||||
|
||||
return $totalCost; |
||||
} |
||||
|
||||
private function calculateHumanCost($human, $activity_id) |
||||
{ |
||||
$activity = Activity::find($activity_id); |
||||
$duration = $activity->duration; |
||||
// $costPerUsed = $human->cost_per_used; |
||||
$standarRate = $human->standart_rate; |
||||
$maxUsed = $human->max_used/100; |
||||
$totalCost = ($standarRate*$duration)*$maxUsed; |
||||
return $totalCost; |
||||
} |
||||
|
||||
private function calculateMaterialCost($activity_id, $proyek_id) |
||||
{ |
||||
$totalCost = AssignMaterial::selectRaw("ISNULL(qty_planning,0)*ISNULL(budget,0) as totalCost")->where("proyek_id", $proyek_id)->where("activity_id", $activity_id)->sum("totalCost"); |
||||
return $totalCost; |
||||
} |
||||
|
||||
private function calculateToolsCost($activity_id, $proyek_id) |
||||
{ |
||||
|
||||
} |
||||
|
||||
protected function updatedCostPlanning($id) |
||||
{ |
||||
$sumBiaya = Activity::select(DB::raw('sum(cast(rencana_biaya as double precision))'))->where("parent_id", $id)->first(); |
||||
$dataActivity = Activity::find($id); |
||||
$dataUpdate = array( |
||||
"rencana_biaya" => $sumBiaya->sum, |
||||
"updated_by" => $this->currentName |
||||
); |
||||
$dataActivity->update($dataUpdate); |
||||
if($dataActivity){ |
||||
$parent = $dataActivity->parent_id; |
||||
if($parent && (int)$parent > 0){ |
||||
$this->updateCostPlanning($parent); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,172 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
|
||||
class CurrencyController extends Controller |
||||
{ |
||||
|
||||
public function list() { |
||||
$CURRENCY_DATA = array( |
||||
// array("cc" => "AED", "symbol" => "\u062f.\u0625;", "name" => "UAE dirham"), |
||||
// array("cc" => "AFN", "symbol" => "Afs", "name" => "Afghan afghani"), |
||||
// array("cc" => "ALL", "symbol" => "L", "name" => "Albanian lek"), |
||||
// array("cc" => "AMD", "symbol" => "AMD", "name" => "Armenian dram"), |
||||
// array("cc" => "ANG", "symbol" => "NA\u0192", "name" => "Netherlands Antillean gulden"), |
||||
// array("cc" => "AOA", "symbol" => "Kz", "name" => "Angolan kwanza"), |
||||
// array("cc" => "ARS", "symbol" => "$", "name" => "Argentine peso"), |
||||
// array("cc" => "AUD", "symbol" => "$", "name" => "Australian dollar"), |
||||
// array("cc" => "AWG", "symbol" => "\u0192", "name" => "Aruban florin"), |
||||
// array("cc" => "AZN", "symbol" => "AZN", "name" => "Azerbaijani manat"), |
||||
// array("cc" => "BAM", "symbol" => "KM", "name" => "Bosnia and Herzegovina konvertibilna marka"), |
||||
// array("cc" => "BBD", "symbol" => "Bds$", "name" => "Barbadian dollar"), |
||||
// array("cc" => "BDT", "symbol" => "\u09f3", "name" => "Bangladeshi taka"), |
||||
// array("cc" => "BGN", "symbol" => "BGN", "name" => "Bulgarian lev"), |
||||
// array("cc" => "BHD", "symbol" => ".\u062f.\u0628", "name" => "Bahraini dinar"), |
||||
// array("cc" => "BIF", "symbol" => "FBu", "name" => "Burundi franc"), |
||||
// array("cc" => "BMD", "symbol" => "BD$", "name" => "Bermudian dollar"), |
||||
// array("cc" => "BND", "symbol" => "B$", "name" => "Brunei dollar"), |
||||
// array("cc" => "BOB", "symbol" => "Bs.", "name" => "Bolivian boliviano"), |
||||
// array("cc" => "BRL", "symbol" => "R$", "name" => "Brazilian real"), |
||||
// array("cc" => "BSD", "symbol" => "B$", "name" => "Bahamian dollar"), |
||||
// array("cc" => "BTN", "symbol" => "Nu.", "name" => "Bhutanese ngultrum"), |
||||
// array("cc" => "BWP", "symbol" => "P", "name" => "Botswana pula"), |
||||
// array("cc" => "BYR", "symbol" => "Br", "name" => "Belarusian ruble"), |
||||
// array("cc" => "BZD", "symbol" => "BZ$", "name" => "Belize dollar"), |
||||
// array("cc" => "CAD", "symbol" => "$", "name" => "Canadian dollar"), |
||||
// array("cc" => "CDF", "symbol" => "F", "name" => "Congolese franc"), |
||||
// array("cc" => "CHF", "symbol" => "Fr.", "name" => "Swiss franc"), |
||||
// array("cc" => "CLP", "symbol" => "$", "name" => "Chilean peso"), |
||||
// array("cc" => "CNY", "symbol" => "\u00a5", "name" => "Chinese/Yuan renminbi"), |
||||
// array("cc" => "COP", "symbol" => "Col$", "name" => "Colombian peso"), |
||||
// array("cc" => "CRC", "symbol" => "\u20a1", "name" => "Costa Rican colon"), |
||||
// array("cc" => "CUC", "symbol" => "$", "name" => "Cuban peso"), |
||||
// array("cc" => "CVE", "symbol" => "Esc", "name" => "Cape Verdean escudo"), |
||||
// array("cc" => "CZK", "symbol" => "K\u010d", "name" => "Czech koruna"), |
||||
// array("cc" => "DJF", "symbol" => "Fdj", "name" => "Djiboutian franc"), |
||||
// array("cc" => "DKK", "symbol" => "Kr", "name" => "Danish krone"), |
||||
// array("cc" => "DOP", "symbol" => "RD$", "name" => "Dominican peso"), |
||||
// array("cc" => "DZD", "symbol" => "\u062f.\u062c", "name" => "Algerian dinar"), |
||||
// array("cc" => "EEK", "symbol" => "KR", "name" => "Estonian kroon"), |
||||
// array("cc" => "EGP", "symbol" => "\u00a3", "name" => "Egyptian pound"), |
||||
// array("cc" => "ERN", "symbol" => "Nfa", "name" => "Eritrean nakfa"), |
||||
// array("cc" => "ETB", "symbol" => "Br", "name" => "Ethiopian birr"), |
||||
// array("cc" => "EUR", "symbol" => "\u20ac", "name" => "European Euro"), |
||||
// array("cc" => "FJD", "symbol" => "FJ$", "name" => "Fijian dollar"), |
||||
// array("cc" => "FKP", "symbol" => "\u00a3", "name" => "Falkland Islands pound"), |
||||
// array("cc" => "GBP", "symbol" => "\u00a3", "name" => "British pound"), |
||||
// array("cc" => "GEL", "symbol" => "GEL", "name" => "Georgian lari"), |
||||
// array("cc" => "GHS", "symbol" => "GH\u20b5", "name" => "Ghanaian cedi"), |
||||
// array("cc" => "GIP", "symbol" => "\u00a3", "name" => "Gibraltar pound"), |
||||
// array("cc" => "GMD", "symbol" => "D", "name" => "Gambian dalasi"), |
||||
// array("cc" => "GNF", "symbol" => "FG", "name" => "Guinean franc"), |
||||
// array("cc" => "GQE", "symbol" => "CFA", "name" => "Central African CFA franc"), |
||||
// array("cc" => "GTQ", "symbol" => "Q", "name" => "Guatemalan quetzal"), |
||||
// array("cc" => "GYD", "symbol" => "GY$", "name" => "Guyanese dollar"), |
||||
// array("cc" => "HKD", "symbol" => "HK$", "name" => "Hong Kong dollar"), |
||||
// array("cc" => "HNL", "symbol" => "L", "name" => "Honduran lempira"), |
||||
// array("cc" => "HRK", "symbol" => "kn", "name" => "Croatian kuna"), |
||||
// array("cc" => "HTG", "symbol" => "G", "name" => "Haitian gourde"), |
||||
// array("cc" => "HUF", "symbol" => "Ft", "name" => "Hungarian forint"), |
||||
array("cc" => "IDR", "symbol" => "Rp", "name" => "Indonesian rupiah"), |
||||
// array("cc" => "ILS", "symbol" => "\u20aa", "name" => "Israeli new sheqel"), |
||||
// array("cc" => "INR", "symbol" => "\u20B9", "name" => "Indian rupee"), |
||||
// array("cc" => "IQD", "symbol" => "\u062f.\u0639", "name" => "Iraqi dinar"), |
||||
// array("cc" => "IRR", "symbol" => "IRR", "name" => "Iranian rial"), |
||||
// array("cc" => "ISK", "symbol" => "kr", "name" => "Icelandic kr\u00f3na"), |
||||
// array("cc" => "JMD", "symbol" => "J$", "name" => "Jamaican dollar"), |
||||
// array("cc" => "JOD", "symbol" => "JOD", "name" => "Jordanian dinar"), |
||||
// array("cc" => "JPY", "symbol" => "\u00a5", "name" => "Japanese yen"), |
||||
// array("cc" => "KES", "symbol" => "KSh", "name" => "Kenyan shilling"), |
||||
// array("cc" => "KGS", "symbol" => "\u0441\u043e\u043c", "name" => "Kyrgyzstani som"), |
||||
// array("cc" => "KHR", "symbol" => "\u17db", "name" => "Cambodian riel"), |
||||
// array("cc" => "KMF", "symbol" => "KMF", "name" => "Comorian franc"), |
||||
// array("cc" => "KPW", "symbol" => "W", "name" => "North Korean won"), |
||||
// array("cc" => "KRW", "symbol" => "W", "name" => "South Korean won"), |
||||
// array("cc" => "KWD", "symbol" => "KWD", "name" => "Kuwaiti dinar"), |
||||
// array("cc" => "KYD", "symbol" => "KY$", "name" => "Cayman Islands dollar"), |
||||
// array("cc" => "KZT", "symbol" => "T", "name" => "Kazakhstani tenge"), |
||||
// array("cc" => "LAK", "symbol" => "KN", "name" => "Lao kip"), |
||||
// array("cc" => "LBP", "symbol" => "\u00a3", "name" => "Lebanese lira"), |
||||
// array("cc" => "LKR", "symbol" => "Rs", "name" => "Sri Lankan rupee"), |
||||
// array("cc" => "LRD", "symbol" => "L$", "name" => "Liberian dollar"), |
||||
// array("cc" => "LSL", "symbol" => "M", "name" => "Lesotho loti"), |
||||
// array("cc" => "LTL", "symbol" => "Lt", "name" => "Lithuanian litas"), |
||||
// array("cc" => "LVL", "symbol" => "Ls", "name" => "Latvian lats"), |
||||
// array("cc" => "LYD", "symbol" => "LD", "name" => "Libyan dinar"), |
||||
// array("cc" => "MAD", "symbol" => "MAD", "name" => "Moroccan dirham"), |
||||
// array("cc" => "MDL", "symbol" => "MDL", "name" => "Moldovan leu"), |
||||
// array("cc" => "MGA", "symbol" => "FMG", "name" => "Malagasy ariary"), |
||||
// array("cc" => "MKD", "symbol" => "MKD", "name" => "Macedonian denar"), |
||||
// array("cc" => "MMK", "symbol" => "K", "name" => "Myanma kyat"), |
||||
// array("cc" => "MNT", "symbol" => "\u20ae", "name" => "Mongolian tugrik"), |
||||
// array("cc" => "MOP", "symbol" => "P", "name" => "Macanese pataca"), |
||||
// array("cc" => "MRO", "symbol" => "UM", "name" => "Mauritanian ouguiya"), |
||||
// array("cc" => "MUR", "symbol" => "Rs", "name" => "Mauritian rupee"), |
||||
// array("cc" => "MVR", "symbol" => "Rf", "name" => "Maldivian rufiyaa"), |
||||
// array("cc" => "MWK", "symbol" => "MK", "name" => "Malawian kwacha"), |
||||
// array("cc" => "MXN", "symbol" => "$", "name" => "Mexican peso"), |
||||
// array("cc" => "MYR", "symbol" => "RM", "name" => "Malaysian ringgit"), |
||||
// array("cc" => "MZM", "symbol" => "MTn", "name" => "Mozambican metical"), |
||||
// array("cc" => "NAD", "symbol" => "N$", "name" => "Namibian dollar"), |
||||
// array("cc" => "NGN", "symbol" => "\u20a6", "name" => "Nigerian naira"), |
||||
// array("cc" => "NIO", "symbol" => "C$", "name" => "Nicaraguan c\u00f3rdoba"), |
||||
// array("cc" => "NOK", "symbol" => "kr", "name" => "Norwegian krone"), |
||||
// array("cc" => "NPR", "symbol" => "NRs", "name" => "Nepalese rupee"), |
||||
// array("cc" => "NZD", "symbol" => "NZ$", "name" => "New Zealand dollar"), |
||||
// array("cc" => "OMR", "symbol" => "OMR", "name" => "Omani rial"), |
||||
// array("cc" => "PAB", "symbol" => "B./", "name" => "Panamanian balboa"), |
||||
// array("cc" => "PEN", "symbol" => "S/.", "name" => "Peruvian nuevo sol"), |
||||
// array("cc" => "PGK", "symbol" => "K", "name" => "Papua New Guinean kina"), |
||||
// array("cc" => "PHP", "symbol" => "\u20b1", "name" => "Philippine peso"), |
||||
// array("cc" => "PKR", "symbol" => "Rs.", "name" => "Pakistani rupee"), |
||||
// array("cc" => "PLN", "symbol" => "z\u0142", "name" => "Polish zloty"), |
||||
// array("cc" => "PYG", "symbol" => "\u20b2", "name" => "Paraguayan guarani"), |
||||
// array("cc" => "QAR", "symbol" => "QR", "name" => "Qatari riyal"), |
||||
// array("cc" => "RON", "symbol" => "L", "name" => "Romanian leu"), |
||||
// array("cc" => "RSD", "symbol" => "din.", "name" => "Serbian dinar"), |
||||
// array("cc" => "RUB", "symbol" => "R", "name" => "Russian ruble"), |
||||
// array("cc" => "SAR", "symbol" => "SR", "name" => "Saudi riyal"), |
||||
// array("cc" => "SBD", "symbol" => "SI$", "name" => "Solomon Islands dollar"), |
||||
// array("cc" => "SCR", "symbol" => "SR", "name" => "Seychellois rupee"), |
||||
// array("cc" => "SDG", "symbol" => "SDG", "name" => "Sudanese pound"), |
||||
// array("cc" => "SEK", "symbol" => "kr", "name" => "Swedish krona"), |
||||
// array("cc" => "SGD", "symbol" => "S$", "name" => "Singapore dollar"), |
||||
// array("cc" => "SHP", "symbol" => "\u00a3", "name" => "Saint Helena pound"), |
||||
// array("cc" => "SLL", "symbol" => "Le", "name" => "Sierra Leonean leone"), |
||||
// array("cc" => "SOS", "symbol" => "Sh.", "name" => "Somali shilling"), |
||||
// array("cc" => "SRD", "symbol" => "$", "name" => "Surinamese dollar"), |
||||
// array("cc" => "SYP", "symbol" => "LS", "name" => "Syrian pound"), |
||||
// array("cc" => "SZL", "symbol" => "E", "name" => "Swazi lilangeni"), |
||||
// array("cc" => "THB", "symbol" => "\u0e3f", "name" => "Thai baht"), |
||||
// array("cc" => "TJS", "symbol" => "TJS", "name" => "Tajikistani somoni"), |
||||
// array("cc" => "TMT", "symbol" => "m", "name" => "Turkmen manat"), |
||||
// array("cc" => "TND", "symbol" => "DT", "name" => "Tunisian dinar"), |
||||
// array("cc" => "TRY", "symbol" => "TRY", "name" => "Turkish new lira"), |
||||
// array("cc" => "TTD", "symbol" => "TT$", "name" => "Trinidad and Tobago dollar"), |
||||
// array("cc" => "TWD", "symbol" => "NT$", "name" => "New Taiwan dollar"), |
||||
// array("cc" => "TZS", "symbol" => "TZS", "name" => "Tanzanian shilling"), |
||||
// array("cc" => "UAH", "symbol" => "UAH", "name" => "Ukrainian hryvnia"), |
||||
// array("cc" => "UGX", "symbol" => "USh", "name" => "Ugandan shilling"), |
||||
array("cc" => "USD", "symbol" => "US$", "name" => "United States dollar"), |
||||
// array("cc" => "UYU", "symbol" => '$U', "name" => "Uruguayan peso"), |
||||
// array("cc" => "UZS", "symbol" => "UZS", "name" => "Uzbekistani som"), |
||||
// array("cc" => "VEB", "symbol" => "Bs", "name" => "Venezuelan bolivar"), |
||||
// array("cc" => "VND", "symbol" => "\u20ab", "name" => "Vietnamese dong"), |
||||
// array("cc" => "VUV", "symbol" => "VT", "name" => "Vanuatu vatu"), |
||||
// array("cc" => "WST", "symbol" => "WS$", "name" => "Samoan tala"), |
||||
// array("cc" => "XAF", "symbol" => "CFA", "name" => "Central African CFA franc"), |
||||
// array("cc" => "XCD", "symbol" => "EC$", "name" => "East Caribbean dollar"), |
||||
// array("cc" => "XDR", "symbol" => "SDR", "name" => "Special Drawing Rights"), |
||||
// array("cc" => "XOF", "symbol" => "CFA", "name" => "West African CFA franc"), |
||||
// array("cc" => "XPF", "symbol" => "F", "name" => "CFP franc"), |
||||
// array("cc" => "YER", "symbol" => "YER", "name" => "Yemeni rial"), |
||||
// array("cc" => "ZAR", "symbol" => "R", "name" => "South African rand"), |
||||
// array("cc" => "ZMK", "symbol" => "ZK", "name" => "Zambian kwacha"), |
||||
// array("cc" => "ZWR", "symbol" => "Z$", "name" => "Zimbabwean dollar") |
||||
); |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$CURRENCY_DATA, 'totalRecord'=>count($CURRENCY_DATA)], 200); |
||||
} |
||||
} |
@ -0,0 +1,297 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Project; |
||||
use App\Models\Activity; |
||||
use App\Models\ReportActivity; |
||||
use App\Models\UserToActivity; |
||||
use DB; |
||||
|
||||
class DashboardController extends Controller |
||||
{ |
||||
public function costPlanningActual(Request $request) |
||||
{ |
||||
$dataPayload = $request->all(); |
||||
$dataMaxVersionGantt = []; |
||||
foreach ($dataPayload['project_id'] as $val) { |
||||
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
||||
} |
||||
|
||||
$dataFinal=[]; |
||||
foreach ($dataMaxVersionGantt as $val) { |
||||
$data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.rencana_biaya', 'm_activity.biaya_actual', 'mp.nama as proyek_name')->join("m_proyek as mp", "m_activity.proyek_id", "=", "mp.id")->where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->orderBy('id', 'asc')->get(); |
||||
$dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); |
||||
} |
||||
|
||||
if($dataPayload){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function getMaxVersionGantt($id){ |
||||
$data = Activity::select(Activity::raw('MAX(version_gantt_id) as last_version_gantt'))->where("proyek_id", $id)->first(); |
||||
return array("last_version_gantt"=>$data->last_version_gantt, "proyek_id" => $id, "proyek_name" => $data->proyek_name); |
||||
} |
||||
|
||||
public function percentagePlanningActual(Request $request) |
||||
{ |
||||
$dataPayload = $request->all(); |
||||
$dataMaxVersionGantt = []; |
||||
foreach ($dataPayload['project_id'] as $val) { |
||||
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
||||
} |
||||
// SELECT * FROM public.m_activity where proyek_id = 11 and version_gantt_id=12 and parent_id IS NULL; |
||||
$dataFinal=[]; |
||||
foreach ($dataMaxVersionGantt as $val) { |
||||
$data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.persentase_progress', 'm_activity.persentase_bobot', 'm_activity.bobot_planning', 'mp.nama as proyek_name')->join("m_proyek as mp", "m_activity.proyek_id", "=", "mp.id")->where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->orderBy('id', 'asc')->get(); |
||||
// loop |
||||
// hitung persentase_progress = persentase_progress*bobot_planning/100 |
||||
$dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); |
||||
|
||||
} |
||||
|
||||
if($dataPayload){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Role::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
// // cari titik last waypoint dari user di masing-masing project terpilih dari front end |
||||
// public function searchUserPresencePoints(Request $request) { |
||||
// $dataPayload = $request->all(); |
||||
// $reqActivityId = []; |
||||
// foreach ($dataPayload['project_id'] as $val) { |
||||
// $reqActivityId[] = $this->getActivityByProjectId($val); |
||||
// } |
||||
|
||||
// // var_dump(count($reqActivityId)); |
||||
// $activity_id = []; |
||||
// $getPoints = false; |
||||
|
||||
// if (count($reqActivityId) > 0) { |
||||
// for ($i=0; $i < count($reqActivityId); $i++) { |
||||
// if (count($reqActivityId[$i]) > 0) { |
||||
// foreach($reqActivityId[$i] as $reqAct) { |
||||
// array_push($activity_id, $reqAct->id); |
||||
// } |
||||
// } |
||||
// } |
||||
// } |
||||
|
||||
// if (count($activity_id) > 0) { |
||||
// // $getPoints = ReportActivity::select('report_activity.*', 'm_activity.name as activity_name', 'm_proyek.nama as proyek_name') |
||||
// // ->leftJoin('m_activity', 'm_activity.id', '=', 'report_activity.activity_id') |
||||
// // ->leftJoin('m_proyek', 'm_proyek.id', '=', 'm_activity.proyek_id') |
||||
// // ->whereIn('report_activity.activity_id', $activity_id)->get(); |
||||
// // $getPoints = |
||||
// } |
||||
|
||||
// if($getPoints){ |
||||
// return response()->json(['status'=>'success','code'=>200,'data'=>$getPoints, 'totalRecord'=>count($getPoints)], 200); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'failed get list points, please try again later!','code'=>400], 400); |
||||
// } |
||||
// } |
||||
|
||||
public function getActivityByProjectId($projectId) { |
||||
$output = []; |
||||
$data = Activity::select('id')->where('proyek_id', $projectId)->get(); |
||||
if (count($data) > 0) { |
||||
foreach ($data as $actData) { |
||||
$output[] = $actData->id; |
||||
} |
||||
} |
||||
return $output; |
||||
} |
||||
|
||||
/* for statusProyek, I want something output like this |
||||
const statusProyek = [ |
||||
{ |
||||
"id": "1", |
||||
"proyek_name": "Pembuatan Aplikasi Survey Covid Varian Baru", // ambil dari m_proyek |
||||
"total_task": 80, // ambil dari m_activity -> SUM(jumlah_pekerjaan) where proyek_id berdasarkan proyek_id terpilih |
||||
"task_on_progress": 60, // ambil dari report_activity -> SUM(job_count_report) where activity_id berdasarkan activity_id terpilih |
||||
"day_left": 7, // ambil dari m_proyek, cari sisa hari (end_date - hari ini) |
||||
"percentage": 75 // (task_on_progress / total_task * 100) |
||||
}, |
||||
{ |
||||
"id": "2", |
||||
"proyek_name": "Pembangunan Jembatan Layang", |
||||
"total_task": 70, // SELECT SUM(jumlah_pekerjaan) FROM public.m_activity WHERE proyek_id IN (11); |
||||
"task_on_progress": 70, // SELECT SUM(job_count_report) FROM public.report_activity WHERE activity_id IN (349, 355); |
||||
"day_left": 0, |
||||
"percentage": 100 |
||||
}, |
||||
... |
||||
] |
||||
*/ |
||||
public function statusProyek(Request $request) { |
||||
$dataPayload = $request->all(); |
||||
$reqProject = []; |
||||
$dataFinal = []; |
||||
|
||||
if (!isset($dataPayload['project_id'])) { |
||||
return response()->json(['status'=>'failed','message'=>'Undefined project_id','code'=>400], 400); |
||||
} |
||||
|
||||
foreach ($dataPayload['project_id'] as $val) { |
||||
$prj["project_id"] = $val; |
||||
$prj["activity_id"] = $this->getActivityByProjectId($val); |
||||
|
||||
$reqProject[] = $prj; |
||||
} |
||||
|
||||
if (count($reqProject) > 0) { |
||||
$row = []; |
||||
|
||||
for ($i=0; $i < count($reqProject); $i++) { |
||||
$dataMaxVersionGantt = Activity::select(Activity::raw('MAX(version_gantt_id) as last_version_gantt'))->where("proyek_id", $reqProject[$i]['project_id'])->first(); |
||||
$last_version_gantt = $dataMaxVersionGantt->last_version_gantt; |
||||
$queryProject = Project::select('id', 'nama', 'mulai_proyek', 'akhir_proyek')->where('id',$reqProject[$i]['project_id'])->first(); |
||||
$sum_jumlah_pekerjaan = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->sum("jumlah_pekerjaan"); |
||||
$count_activity = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->count("id"); |
||||
$count_activity_done = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('persentase_progress', '100')->where('version_gantt_id', $last_version_gantt)->count("id"); |
||||
$progress_percentage = Activity::where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->sum("persentase_progress"); |
||||
$count_progress_percentage = Activity::where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->count("persentase_progress"); |
||||
|
||||
// progress_actual = bobot_planning * persentase_progress |
||||
$progress_actual = Activity::select('id', 'bobot_planning', 'persentase_progress')->where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->get(); |
||||
$current_progress = 0; |
||||
foreach($progress_actual as $objRow) { |
||||
// $total_current = ($objRow->bobot_planning * $objRow->persentase_progress) / 100; |
||||
$current_progress += ($objRow->bobot_planning * $objRow->persentase_progress) / 100; |
||||
} |
||||
|
||||
// yang sudah difilter dengan max_version_gantt |
||||
if (count($reqProject[$i]['activity_id']) > 0) { |
||||
for ($j=0; $j < count($reqProject[$i]['activity_id']); $j++) { |
||||
$sum_job_count_report = ReportActivity::whereIn('activity_id', $reqProject[$i]['activity_id'])->sum("job_count_report"); |
||||
} |
||||
} |
||||
|
||||
if (!isset($queryProject->id)) { |
||||
return response()->json(['status'=>'failed','message'=>'Project with id='.$reqProject[$i]['project_id'].' is not found!','code'=>400], 400); |
||||
} |
||||
|
||||
// sisa hari |
||||
$now = time(); |
||||
$akhir_proyek = strtotime($queryProject->akhir_proyek); |
||||
$datediff = $akhir_proyek - $now; |
||||
|
||||
$mulai_proyek = strtotime($queryProject->mulai_proyek); |
||||
$total_kontrak = $akhir_proyek - $mulai_proyek; |
||||
|
||||
$row["id"] = $queryProject->id; |
||||
$row["proyek_name"] = $queryProject->nama; |
||||
$row["mulai_proyek"] = $queryProject->mulai_proyek; |
||||
$row["akhir_proyek"] = $queryProject->akhir_proyek; |
||||
$row["total_kontrak"] = round($total_kontrak / (60 * 60 * 24)); |
||||
$row["total_task"] = $sum_jumlah_pekerjaan; |
||||
$row["task_on_progress"] = $sum_job_count_report; |
||||
$row["count_activity"] = $count_activity; |
||||
$row["count_activity_done"] = $count_activity_done; |
||||
$row["day_left"] = round($datediff / (60 * 60 * 24)); |
||||
$row["percentage"] = round($current_progress,3); |
||||
$row["count_progress_percentage"] = $count_progress_percentage; |
||||
|
||||
$dataFinal[] = $row; |
||||
} |
||||
} |
||||
|
||||
if($dataFinal){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>count($dataFinal)], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get status proyek, please try again later!','code'=>400], 400); |
||||
} |
||||
|
||||
} |
||||
|
||||
public function curvaS(Request $request) |
||||
{ |
||||
$dataPayload = $request->all(); |
||||
$dataMaxVersionGantt = []; |
||||
foreach ($dataPayload['project_id'] as $val) { |
||||
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
||||
} |
||||
// SELECT * FROM public.m_activity where proyek_id = 11 and version_gantt_id=12 and parent_id IS NULL; |
||||
$dataFinal=[]; |
||||
foreach ($dataMaxVersionGantt as $val) { |
||||
$data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.persentase_progress', 'm_activity.persentase_bobot', 'm_activity.bobot_planning', 'm_activity.biaya_actual', 'mp.nama as proyek_name')->join("m_proyek as mp", "m_activity.proyek_id", "=", "mp.id")->where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->orderBy('id', 'asc')->get(); |
||||
$totalCostPlanning = Activity::where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->sum('rencana_biaya'); |
||||
// loop |
||||
$dataBobotPlan =[]; |
||||
for ($i=0; $i < count($data); $i++) { |
||||
// if($i) |
||||
$tmpp = 0; |
||||
$tmpa = 0; |
||||
$tmpbc = 0; |
||||
$tmpac = 0; |
||||
for ($x=$i; $x >= 0 ; $x--) { |
||||
$tmpp += $data[$x]['bobot_planning']; |
||||
$tmpa += ($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100; |
||||
$tmpbc += ((($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100)*$totalCostPlanning)/100; |
||||
$tmpac += $data[$x]['biaya_actual']; |
||||
} |
||||
|
||||
// $dataBobotPlan[] = $tmp; |
||||
$data[$i]['cal_bobot_p'] = round($tmpp,2); |
||||
if($i > 0 ){ |
||||
if($data[$i-1]['cal_bobot_a'] != null){ |
||||
if($data[$i-1]['cal_bobot_a'] == round($tmpa,2)){ |
||||
$data[$i]['cal_bobot_a'] = null; |
||||
}else{ |
||||
$data[$i]['cal_bobot_a'] = round($tmpa,2); |
||||
} |
||||
}else{ |
||||
$data[$i]['cal_bobot_a'] = null; |
||||
} |
||||
}else{ |
||||
$data[$i]['cal_bobot_a'] = round($tmpa,2); |
||||
} |
||||
$data[$i]['cal_budget_cost'] = round($tmpbc,2); |
||||
|
||||
// $data[$i]['cal_actual_cost']=round($tmpac,2); |
||||
if($i > 0 ){ |
||||
if($data[$i-1]['cal_actual_cost'] != null){ |
||||
if($data[$i-1]['cal_actual_cost'] == round($tmpac,2)){ |
||||
$data[$i]['cal_actual_cost'] = null; |
||||
}else{ |
||||
$data[$i]['cal_actual_cost'] = round($tmpac,2); |
||||
} |
||||
}else{ |
||||
$data[$i]['cal_actual_cost'] = null; |
||||
} |
||||
}else{ |
||||
$data[$i]['cal_actual_cost'] = round($tmpac,2); |
||||
} |
||||
} |
||||
// hitung persentase_progress = persentase_progress*bobot_planning/100 |
||||
|
||||
$dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); |
||||
|
||||
} |
||||
|
||||
if($dataPayload){ |
||||
return response()->json(['status'=>'success','code'=>200, 'data'=>$dataFinal, 'totalRecord'=>1], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,96 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Divisi; |
||||
|
||||
class DivisiController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Divisi::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Master divisi successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master divisi failed created','code'=>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 = Divisi::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Master divisi not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Master divisi successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master divisi failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Divisi::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Master divisi not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Master divisi successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master divisi failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_divisi'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Divisi::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
class ExampleController extends Controller |
||||
{ |
||||
/** |
||||
* Create a new controller instance. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
// |
||||
} |
||||
|
||||
// |
||||
} |
@ -0,0 +1,140 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\FolderDocumentProyek; |
||||
use App\Models\DokumenProject; |
||||
|
||||
class FolderDocumentProyekController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
$this->validate($request, [ |
||||
'name_folder' => 'required', |
||||
'proyek_id' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = FolderDocumentProyek::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed created','code'=>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 = FolderDocumentProyek::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Folder Document Proyek not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = FolderDocumentProyek::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Folder Document Proyek not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Folder Document Proyek successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Folder Document Proyek failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_FolderDocumentProyek'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = FolderDocumentProyek::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
public function getTree($id) |
||||
{ |
||||
$data = FolderDocumentProyek::where('proyek_id', $id)->whereNull('parent_id')->orderByRaw('id ASC')->get(); |
||||
$dataFile = DokumenProject::where('type_dokumen', 'project-document-out-folder')->where('ref_id', $id)->orderByRaw('id ASC')->get(); |
||||
// var_dump($dataFile); |
||||
$finalData = []; |
||||
foreach($data as $objRow){ |
||||
$objRow->children = $this->getChildren($id, $objRow->id); |
||||
$objRow->key = rand(1, 1000); |
||||
$objRow->isDir = true; |
||||
$finalData[] = $objRow; |
||||
} |
||||
|
||||
foreach($dataFile as $objRowFile) { |
||||
$objRowFile->key = rand(1, 1000); |
||||
$objRowFile->isDir = false; |
||||
$objRowFile->proyek_id = $id; |
||||
$finalData[] = $objRowFile; |
||||
} |
||||
|
||||
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200); |
||||
} |
||||
|
||||
private function getChildren($proyek_id, $parent_id) |
||||
{ |
||||
$finalData = []; |
||||
$data = FolderDocumentProyek::where('proyek_id', $proyek_id)->where('parent_id', $parent_id)->orderByRaw('id ASC')->get(); |
||||
$dataFile = DokumenProject::where('type_dokumen', 'project-document-in-folder')->where('ref_id', $parent_id)->orderByRaw('id ASC')->get(); |
||||
foreach($data as $objRow){ |
||||
$objRow->key = rand(1, 1000); |
||||
$objRow->children = $this->getChildren($proyek_id, $objRow->id); |
||||
$objRow->isDir = true; |
||||
$finalData[] = $objRow; |
||||
} |
||||
|
||||
foreach($dataFile as $objRowFile) { |
||||
$objRowFile->key = rand(1, 1000); |
||||
$objRowFile->isDir = false; |
||||
$objRowFile->proyek_id = $proyek_id; |
||||
$finalData[] = $objRowFile; |
||||
} |
||||
|
||||
return $finalData; |
||||
} |
||||
} |
@ -0,0 +1,148 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Holiday; |
||||
use Datatables; |
||||
|
||||
class HolidayController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'version_gantt_id' => 'required', |
||||
'date' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
$duration = $request->duration; |
||||
if(!$duration){ |
||||
$data['duration'] = 1; |
||||
} |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Holiday::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add holiday successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add holiday 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 = Holiday::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data holiday, 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 = Holiday::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data holiday not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data holiday successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data holiday failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Holiday::find($id); |
||||
|
||||
if($data){ |
||||
$deletedData = $data; |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data holiday not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success', 'data'=>$deletedData,'message'=>'data holiday successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data holiday failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_holidays'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Holiday::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list holiday, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function datatables(Request $request){ |
||||
$proyek_id = $request->query('proyek_id'); |
||||
$gantt_id = $request->query('gantt_id'); |
||||
|
||||
$data = Holiday::where('proyek_id', $proyek_id)->where('version_gantt_id', $gantt_id)->get(); |
||||
|
||||
return Datatables::of($data) |
||||
->editColumn('date', function($row) { |
||||
$date = date_create($row->date); |
||||
$dateFormat = date_format($date,"d-m-Y"); |
||||
return $dateFormat; |
||||
}) |
||||
->editColumn('duration', function($row) { |
||||
$day = (int)$row->duration > 1 ? "days" : "day"; |
||||
return $row->duration." ".$day; |
||||
}) |
||||
->addIndexColumn() |
||||
->addColumn('action', function($row){ |
||||
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-holiday-delete"><i class="fa fa-trash"></i></a>'; |
||||
return $actionBtn; |
||||
}) |
||||
|
||||
->rawColumns(['action'])->make(true); |
||||
} |
||||
} |
@ -0,0 +1,183 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\HumanResource; |
||||
use App\Models\UserToActivity; |
||||
use App\Models\UserToProyek; |
||||
|
||||
class HumanResourceController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'role_id' => 'required', |
||||
// 'username' => 'required', |
||||
// 'password' => 'required', |
||||
'name' => 'required', |
||||
// 'phone_number' => 'required', |
||||
// 'email' => 'required', |
||||
// 'address' => 'required', |
||||
'ktp_number' => 'required', |
||||
'employee_type' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
if(isset($request->password) && $request->password!=""){ |
||||
$data['password'] = md5($request->password); |
||||
} |
||||
|
||||
$result = HumanResource::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Human Resource Pool successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Human Resource Pool failed created','code'=>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 = HumanResource::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data human resource, 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); |
||||
} |
||||
|
||||
$humanresource = HumanResource::find($id); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
if(isset($request->password) && $request->password!="" ){ |
||||
$data['password'] = md5($request->password); |
||||
} |
||||
|
||||
if($humanresource){ |
||||
$result = $humanresource->update($data); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Human Resource Pool not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Human Resource Pool successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Human Resource Pool failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = HumanResource::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Human Resource Pool not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Human Resource Pool successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Human Resource Pool failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_users'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = HumanResource::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list human resource, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function select(Request $request){ |
||||
|
||||
$search = $request->query('search'); |
||||
|
||||
$idActivity = (int)$request->query('idact'); |
||||
$idProyek = (int)$request->query('idProyek'); |
||||
|
||||
$forbidden = []; |
||||
|
||||
if($idActivity && $idActivity > 0){ |
||||
$dataF = UserToActivity::select("user_id")->where("activity_id", $idActivity)->get(); |
||||
foreach($dataF as $val){ |
||||
$forbidden[] = $val->user_id; |
||||
} |
||||
} |
||||
|
||||
if($search && !empty($search)){ |
||||
$data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id') |
||||
->where("assign_hr_to_proyek.proyek_id", $idProyek)->where("m_users.name", 'like', '%'.$search.'%')->whereNotIn("m_users.id", $forbidden)->get(); |
||||
}else{ |
||||
$data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")->where("assign_hr_to_proyek.proyek_id", $idProyek)->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id')->whereNotIn("m_users.id", $forbidden)->get(); |
||||
} |
||||
|
||||
return response()->json($data); |
||||
} |
||||
|
||||
public function checkOldPassword(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$data = $request->all(); |
||||
|
||||
if(isset($request->old_password) && $request->old_password!="" ){ |
||||
$result = HumanResource::find($id); |
||||
$data['old_password'] = md5($request->old_password); |
||||
if($data['old_password'] !== $result->password) { |
||||
return response()->json(['status'=>'failed','message'=>"old password seems doesn't match in records. please try again.",'code'=>400], 400); |
||||
} |
||||
elseif($data['old_password'] === $result->password) { |
||||
return response()->json(['status'=>'success','message'=>"old password match",'data'=>$result,'code'=>200], 200); |
||||
} |
||||
} |
||||
else { |
||||
return response()->json(['status'=>'failed','message'=>'old_password is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,128 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Image; |
||||
|
||||
class ImageController extends Controller |
||||
{ |
||||
public function uploadImage(Request $request){ |
||||
|
||||
if($request->hasFile('files')){ |
||||
|
||||
$this->validate($request, [ |
||||
'ref_id' => 'required', |
||||
'category' => 'required' |
||||
]); |
||||
|
||||
$ref_id = $request->ref_id; |
||||
$dokumen = $request->file('files'); |
||||
$extension = $dokumen->extension(); |
||||
$name = $ref_id.date("YmdHis").".".$extension; |
||||
|
||||
$resultMove = $dokumen->move($this->pathImage, $name); |
||||
|
||||
if($resultMove){ |
||||
$data = [ |
||||
'ref_id' => (int)$ref_id, |
||||
'image' => $name, |
||||
'category' => $request->category |
||||
]; |
||||
|
||||
$result = Image::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success', "name_image"=>$name,'message'=>'image upload is successfully!','code'=>200], 200); |
||||
}else{ |
||||
unlink($this->pathImage.$name); |
||||
return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400); |
||||
} |
||||
|
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'image is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Image::find($id); |
||||
|
||||
if($data){ |
||||
unlink($this->pathImage.$data->image); |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
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{ |
||||
return response()->json(['status'=>'failed','message'=>'data image failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_image'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function deleteByRef($id, $category) |
||||
{ |
||||
$data = Image::where("ref_id", $id)->where("category", $category)->first(); |
||||
|
||||
if($data){ |
||||
unlink($this->pathImage.$data->image); |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
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{ |
||||
return response()->json(['status'=>'failed','message'=>'data image failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function getByRefId($id, $category) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if(!$category || $category==""){ |
||||
return response()->json(['status'=>'failed','message'=>'category is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = Image::where("ref_id", $id)->where("category", $category)->first(); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data image, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,116 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Link; |
||||
|
||||
class LinkController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'source' => 'required', |
||||
'target' => 'required', |
||||
'type' => 'required', |
||||
'version_gantt_id' => 'required' |
||||
]); |
||||
|
||||
$code = $this->getCodeByType($request->type); |
||||
|
||||
$data = array( |
||||
's_activity_id'=> $request->source, |
||||
't_activity_id'=> $request->target, |
||||
'type_link'=> $request->type, |
||||
'code_link'=> $code, |
||||
'version_gantt_id'=>$request->version_gantt_id |
||||
); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Link::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success', 'tid'=>$result->id, 'action'=>'inserted','message'=>'add data project successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'add data project failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$data = Link::find($id); |
||||
|
||||
$code = $this->getCodeByType($request->type); |
||||
|
||||
$dataUpdate = array( |
||||
's_activity_id'=> $request->source, |
||||
't_activity_id'=> $request->target, |
||||
'type_link'=> $request->type, |
||||
'code_link'=> $code, |
||||
'lag'=> $request->lag, |
||||
'updated_by'=> $this->currentName |
||||
); |
||||
|
||||
if($data){ |
||||
$result = $data->update($dataUpdate); |
||||
}else{ |
||||
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'activity link not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success', 'action'=>'updated','message'=>'activity link successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'activity link failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$data = Link::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'activity link not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
$deletAll = Link::where("parent_id", $id); |
||||
$deletAll->delete(); |
||||
return response()->json(['status'=>'success', 'action'=>'deleted','message'=>'activity link successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'activity link failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
private function getCodeByType($code){ |
||||
switch ($code) { |
||||
case 1: |
||||
return "SS"; |
||||
break; |
||||
case 2: |
||||
return "FF"; |
||||
break; |
||||
case 3: |
||||
return "SF"; |
||||
break; |
||||
default: |
||||
return "FS"; |
||||
break; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,54 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\MaterialProject; |
||||
|
||||
class MaterialProjectController extends Controller |
||||
{ |
||||
public function assignMaterial(Request $request) |
||||
{ |
||||
$projectId = $request->project_id; |
||||
$subproyekId = $request->subproyek_id; |
||||
$listMaterialId = $request->material_id; |
||||
|
||||
if(!$projectId && !$subproyekId){ |
||||
return response()->json(['status'=>'failed','message'=>'Required proyek_id or subproyek id','code'=>400]); |
||||
} |
||||
|
||||
if(is_array($listMaterialId) && count($listMaterialId) > 0){ |
||||
$result = 0; |
||||
MaterialProject::where('proyek_id', $projectId)->delete(); |
||||
MaterialProject::where('proyek_id', $subproyekId)->delete(); |
||||
foreach($listMaterialId as $material_id){ |
||||
$data = [ |
||||
'material_resource_id'=>(int)$material_id |
||||
]; |
||||
|
||||
if($projectId && $projectId!="" && (int)$projectId > 0){ |
||||
$data['proyek_id'] = $projectId; |
||||
}else if($subproyekId && $subproyekId!="" && (int)$subproyekId > 0){ |
||||
$data['subproyek_id'] = $subproyekId; |
||||
} |
||||
|
||||
$insert = MaterialProject::create($data); |
||||
if($insert){ |
||||
$result++; |
||||
}else{ |
||||
$result--; |
||||
} |
||||
} |
||||
if($result > 0){ |
||||
return response()->json(['status'=>'success','message'=>'Material Project successfull updated','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Material Project failed updated','code'=>400]); |
||||
} |
||||
}else{ |
||||
MaterialProject::where('proyek_id', $projectId)->delete(); |
||||
MaterialProject::where('proyek_id', $subproyekId)->delete(); |
||||
return response()->json(['status'=>'success','message'=>'Material Project Successfull updated','code'=>200]); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,136 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\MaterialResource; |
||||
use App\Models\RequestMaterial; |
||||
|
||||
class MaterialResourceController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'uom' => 'required', |
||||
'unit_price' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = MaterialResource::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data material resource successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data material resource 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 = MaterialResource::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data material resource, 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 = MaterialResource::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data material resource not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data material resource successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data material resource failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = MaterialResource::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data material resource not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data material resource successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data material resource failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_material_resource'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = MaterialResource::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list material resource, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function select(Request $request){ |
||||
|
||||
$search = $request->query('search'); |
||||
$projectId = $request->idProyek; |
||||
|
||||
if($search && !empty($search)){ |
||||
// $data = MaterialResource::where("name", 'ilike', '%'.$search.'%')->get(); |
||||
$data = RequestMaterial::where("description", 'ilike', '%'.$search.'%')->get(); |
||||
}else{ |
||||
// $data = MaterialResource::all(); |
||||
$data = RequestMaterial::Where("proyek_id", $projectId)->get(); |
||||
} |
||||
|
||||
return response()->json($data); |
||||
} |
||||
} |
@ -0,0 +1,159 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Menu; |
||||
use App\Models\RoleMenu; |
||||
|
||||
class MenuController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'icon' => 'required', |
||||
'name' => 'required', |
||||
'url' => 'required', |
||||
'sequence' => 'required', |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Menu::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data menu successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data menu 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 = Menu::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data menu, 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 = Menu::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data menu not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data menu successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data menu failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Menu::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data menu not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data menu successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data menu failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_menu'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function listMenu($id) |
||||
{ |
||||
$dataParent = RoleMenu::select("m_menu.*") |
||||
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id') |
||||
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id') |
||||
->whereNull('m_menu.parent_id') |
||||
->where('m_roles.id', $id) |
||||
->orderBy('m_menu.sequence', 'ASC') |
||||
->get(); |
||||
|
||||
$finalData = []; |
||||
foreach($dataParent as $data){ |
||||
$data->children = $this->getChildrenMenu($data->id, $id); |
||||
$finalData[] = $data; |
||||
} |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$finalData], 200); |
||||
} |
||||
|
||||
protected function getChildrenMenu($id, $role_id) |
||||
{ |
||||
$dataChildren = RoleMenu::select("m_menu.*") |
||||
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id') |
||||
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id') |
||||
->where('m_roles.id', $role_id) |
||||
->where('m_menu.parent_id', $id) |
||||
->orderBy('m_menu.sequence', 'ASC') |
||||
->get(); |
||||
$children = []; |
||||
if($dataChildren){ |
||||
foreach($dataChildren as $data) |
||||
{ |
||||
$data->children = $this->getChildrenMenu($data->id, $role_id); |
||||
$children[] = $data; |
||||
} |
||||
} |
||||
return $children; |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Menu::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list menu, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,116 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\OfficeHours; |
||||
|
||||
class OfficeHoursController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = OfficeHours::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data office hours successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data office hours 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 = OfficeHours::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data office hours, 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 = OfficeHours::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data office hours not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data office hours successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data office hours failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = OfficeHours::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data office hours not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data office hours successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data office hours failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_office_hours'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = OfficeHours::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list office hours, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,118 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\PanicButton; |
||||
|
||||
class PanicButtonController extends Controller |
||||
{ |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'lat' => 'required', |
||||
'lon' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$status_response = $request->status_response ? $request->status_response : "active"; |
||||
|
||||
$data['status_response'] = $status_response; |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = PanicButton::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Panic button successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Panic button failed created','code'=>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 = PanicButton::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Panic button not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Panic button successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Panic button failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = PanicButton::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Panic button not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Panic button successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Panic button 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 = PanicButton::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data Panic button, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in golang API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 't_panic_button'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = PanicButton::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get Panic button, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,351 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Log; |
||||
use Illuminate\Http\Request; |
||||
use App\Models\Presence; |
||||
use GuzzleHttp\Client; |
||||
use Illuminate\Support\Facades\Http; |
||||
use Carbon\Carbon; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
class PresenceController extends Controller |
||||
{ |
||||
//const NOMINATIM_ADDR = "https://nominatim.oslogdev.com"; // https://nominatim.oslogdev.com/reverse?lat=-6.010201&lon=106.0162715&format=json |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'user_id' => 'required' |
||||
]); |
||||
|
||||
//var_dump($request); |
||||
|
||||
if($request->type=="out"){ |
||||
|
||||
$clock_out_loc = "-"; |
||||
// if (isset($request->clock_out_lat) && isset($request->clock_out_lng)) { |
||||
// $response = Http::get(config('api.nominatim') . "/reverse?lat=".$request->clock_out_lat."&lon=".$request->clock_out_lng."&format=json"); |
||||
// $clock_out_loc = $response->json()["display_name"]; |
||||
// } |
||||
$dataUpdate = array( |
||||
"clock_out"=>$request->clock_time, |
||||
"clock_out_lat" => $request->clock_out_lat, |
||||
"clock_out_lng" => $request->clock_out_lng, |
||||
"updated_by"=>$this->currentName, |
||||
"clock_out_loc" => $clock_out_loc |
||||
); |
||||
|
||||
$resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); |
||||
if($resultUpdate && $resultUpdate > 0){ |
||||
return response()->json(['status'=>'success', 'id'=>$resultUpdate,'message'=>'clock out success!','code'=>200], 200); |
||||
} |
||||
// enable multiple clock out at same day, so I commented this |
||||
// else if($resultUpdate=="has presence"){ |
||||
// return response()->json(['status'=>'failed','message'=>'clock in failed, user has made presence today!','code'=>400], 400); |
||||
// } |
||||
else{ |
||||
return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); |
||||
} |
||||
die(); |
||||
} |
||||
|
||||
$date = date_create($request->clock_time); |
||||
$onlyDate = date_format($date,"Y-m-d"); |
||||
|
||||
// enable multiple clock in at same day, so I commented this |
||||
// $cek = Presence::where('user_id',$request->user_id)->where("date_presence", $onlyDate)->count(); |
||||
// if($cek > 0){ |
||||
// return response()->json(['status'=>'failed','message'=>'clock in failed, user has made presence today!','code'=>400], 400); |
||||
// die(); |
||||
// } |
||||
|
||||
$clock_in_loc = "-"; |
||||
// if (isset($request->clock_in_lat) && isset($request->clock_in_lng)) { |
||||
// $response = Http::get(config('api.nominatim') . "/reverse?lat=".$request->clock_in_lat."&lon=".$request->clock_in_lng."&format=json"); |
||||
// $clock_in_loc = $response->json()["display_name"]; |
||||
// } |
||||
|
||||
$dataAdd = array( |
||||
'user_id'=> $request->user_id, |
||||
'clock_in'=> $request->clock_time, |
||||
'date_presence'=> $onlyDate, |
||||
'created_by' =>$this->currentName, |
||||
'clock_in_lat' => $request->clock_in_lat, |
||||
'clock_in_lng' => $request->clock_in_lng, |
||||
'clock_in_loc' => $clock_in_loc |
||||
); |
||||
|
||||
$result = Presence::create($dataAdd); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success', 'id'=>$result->id,'message'=>'clock in successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'clock in 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 = Presence::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
// public function clockinout($id) { |
||||
// $client = new Client(); |
||||
// $res = $client->request('GET', config('api.golang') . "/clockinout/{$id}"); |
||||
// if ($res->getStatusCode() != 200) { |
||||
// return response()->json(['status'=>'failed','message'=>'failed get data clockinout, please try again later!','code'=>400], 400); |
||||
// } |
||||
|
||||
// $result= $res->getBody(); |
||||
// return response($result, 200) |
||||
// ->header("content-type", $res->getHeaderLine('content-type')); |
||||
// } |
||||
|
||||
public function clockinout($id) { |
||||
$dateTimeNow = Carbon::now()->addHour(7); |
||||
// ambil data t_clockinout where user_id |
||||
$dataPresence = Presence::where('user_id', $id)->orderBy('id', 'DESC')->first(); |
||||
// ambil data working hour shift |
||||
// $dataShift = DB::table('t_users_monthly_shift')->where('user_id', $id)->orderBy('id', 'DESC')->first(); |
||||
// if($dataShift){ |
||||
// // cek ke jsonb |
||||
// }else{ |
||||
// $dataWorkingHour = DB::table('m_shift')->where('is_non_shift', 't')->first(); |
||||
// } |
||||
|
||||
// $dataWorkingHour->start_time; |
||||
// $dataWorkingHour->end_time; |
||||
// $dataWorkingHour->flex_time_minute; |
||||
|
||||
// if(Carbon::now()->format('H') == ){ |
||||
// $in_working_time = |
||||
// } |
||||
|
||||
if($dataPresence){ |
||||
|
||||
// "id": 131, |
||||
// "at": "2022-04-13T02:31:44.913587582+07:00", |
||||
// "user_id": 330, |
||||
// "clock_in": null, |
||||
// "clock_out": null, |
||||
// "last_clock_in": "2022-04-11T07:44:05+07:00", |
||||
// "last_clock_out": "2022-04-11T16:05:01+07:00", |
||||
// "start_at": "2022-04-12T04:59:59+07:00", |
||||
// "end_at": "2022-04-14T00:59:01+07:00", |
||||
// "in_working_time": true |
||||
$dateNow = date("Y-m-d"); |
||||
$dateA = strtotime($dataPresence->clock_in); |
||||
$dayClockin = date("Y-m-d", $dateA); |
||||
if($dayClockin == $dateNow){ |
||||
$clock_in = $dataPresence->clock_in; |
||||
$clock_out = $dataPresence->clock_out; |
||||
}else{ |
||||
$clock_in = null; |
||||
$clock_out = null; |
||||
} |
||||
// new \DateTime($minDate) |
||||
$res_data = array( |
||||
"id" => $dataPresence->id, |
||||
// "at"=> Carbon::now()->timezone('Asia/Jakarta'), |
||||
"at" => $dateTimeNow, |
||||
"user_id"=> $id, |
||||
"clock_in"=> $clock_in, |
||||
"clock_out"=> $clock_out, |
||||
"last_clock_in"=> $dataPresence->clock_in, |
||||
"last_clock_out"=> $dataPresence->clock_out, |
||||
// "start_at"=> "2022-04-12T04=>59=>59+07=>00", |
||||
// "end_at"=> "2022-04-14T00=>59=>01+07=>00", |
||||
"in_working_time"=> true |
||||
); |
||||
return response()->json(['status'=>'success','data'=>$res_data,'code'=>200], 200); |
||||
} |
||||
$res_data = array( |
||||
"id" => null, |
||||
"at" => $dateTimeNow, |
||||
"user_id"=> $id, |
||||
"clock_in"=> null, |
||||
"clock_out"=> null, |
||||
"last_clock_in"=> null, |
||||
"last_clock_out"=> null, |
||||
// "start_at"=> "2022-04-12T04=>59=>59+07=>00", |
||||
// "end_at"=> "2022-04-14T00=>59=>01+07=>00", |
||||
"in_working_time"=> true |
||||
); |
||||
return response()->json(['status'=>'success','data'=>$res_data,'code'=>200], 200); |
||||
} |
||||
|
||||
private function updateFormAdd($data, $id){ |
||||
|
||||
$date = date_create($data['clock_out']); |
||||
|
||||
$onlyDate = date_format($date,"Y-m-d"); |
||||
|
||||
// enable multiple clock out at same day, so I commented this |
||||
// $cek = Presence::where('user_id', $id)->where("date_presence", $onlyDate)->whereNotNull('clock_out')->count(); |
||||
// if($cek > 0){ |
||||
// return "has presence"; |
||||
// die(); |
||||
// } |
||||
|
||||
$dataPresence = Presence::where('user_id',$id) |
||||
->where("clock_in", "<=", $data["clock_out"]) |
||||
->orderByDesc("id") |
||||
->first(); |
||||
|
||||
if($dataPresence){ |
||||
$queryUpdate = $dataPresence->update($data); |
||||
if($queryUpdate){ |
||||
$getDataUpdate = Presence::where('user_id', $id)->where("date_presence", $onlyDate)->first(); |
||||
return $getDataUpdate->id; |
||||
}else{ |
||||
return false; |
||||
} |
||||
}else{ |
||||
return false; |
||||
} |
||||
die(); |
||||
} |
||||
|
||||
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 = Presence::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data presence not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data presence successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data presence failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Presence::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data presence not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data presence successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data presence failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 't_clock_in_out'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
$finalData = []; |
||||
// foreach ($dataGet as $objRow) { |
||||
// // each clock_in_lat, clock_in_lng request to Address API and push clock_in_location to $dataGet |
||||
// // format clock_in_loc (full address / display_name) for now |
||||
// $clock_in_lat = $objRow->clock_in_lat; |
||||
// $clock_in_lng = $objRow->clock_in_lng; |
||||
// $objRow->clock_in_loc = ""; |
||||
// if (isset($clock_in_lat) && isset($clock_in_lng)) { |
||||
// $response = Http::get(self::NOMINATIM_ADDR . "/reverse?lat=".$clock_in_lat."&lon=".$clock_in_lng."&format=json"); |
||||
// $objRow->clock_in_loc = $response->json()["display_name"]; |
||||
// } |
||||
|
||||
// // each clock_out_lat, clock_out_lng request to Address API and push clock_out_location to $dataGet |
||||
// // format clock_out_loc (full adrress / display_name) for now |
||||
// $clock_out_lat = $objRow->clock_out_lat; |
||||
// $clock_out_lng = $objRow->clock_out_lng; |
||||
// $objRow->clock_out_loc = ""; |
||||
// if (isset($clock_out_lat) && isset($clock_out_lng)) { |
||||
// $response = Http::get(self::NOMINATIM_ADDR . "/reverse?lat=".$clock_out_lat."&lon=".$clock_out_lng."&format=json"); |
||||
// $objRow->clock_out_loc = $response->json()["display_name"]; |
||||
// } |
||||
|
||||
// $finalData[] = $objRow; |
||||
// } |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Presence::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list presence, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function bulkUpdateLocation() |
||||
{ |
||||
$data = Presence::all(); |
||||
$finalData = []; |
||||
foreach($data as $objRow) { |
||||
$presence = Presence::find($objRow->id); |
||||
|
||||
// each clock_in_lat, clock_in_lng request to Address API and push clock_in_location to $dataGet |
||||
// format clock_in_loc (full address / display_name) for now |
||||
$clock_in_lat = $objRow->clock_in_lat; |
||||
$clock_in_lng = $objRow->clock_in_lng; |
||||
$objRow->clock_in_loc = ""; |
||||
if (isset($clock_in_lat) && isset($clock_in_lng)) { |
||||
$response = Http::get(config('api.nominatim') . "/reverse?lat=".$clock_in_lat."&lon=".$clock_in_lng."&format=json"); |
||||
$objRow->clock_in_loc = $response->json()["display_name"]; |
||||
} |
||||
|
||||
// each clock_out_lat, clock_out_lng request to Address API and push clock_out_location to $dataGet |
||||
// format clock_out_loc (full adrress / display_name) for now |
||||
$clock_out_lat = $objRow->clock_out_lat; |
||||
$clock_out_lng = $objRow->clock_out_lng; |
||||
$objRow->clock_out_loc = ""; |
||||
if (isset($clock_out_lat) && isset($clock_out_lng)) { |
||||
$response = Http::get(config('api.nominatim') . "/reverse?lat=".$clock_out_lat."&lon=".$clock_out_lng."&format=json"); |
||||
$objRow->clock_out_loc = $response->json()["display_name"]; |
||||
} |
||||
|
||||
// $finalData[] = $objRow; |
||||
|
||||
$presence->clock_in_loc = $objRow->clock_in_loc; |
||||
$presence->clock_out_loc = $objRow->clock_out_loc; |
||||
$presence->save(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,140 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectApproval; |
||||
class ProjectApprovalController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'tittle' => 'required', |
||||
'name' => 'required', |
||||
'date_approval' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectApproval::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data project approval successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project approval 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 = ProjectApproval::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project approval, 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 = ProjectApproval::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project approval not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project approval successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project approval failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectApproval::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project approval not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project approval successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project approval failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function deleteByProyek($id) |
||||
{ |
||||
$data = ProjectApproval::where('proyek_id', $id)->delete(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','message'=>'data project approval successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project approval failed deleted, because data not found!','code'=>200], 200); |
||||
} |
||||
} |
||||
|
||||
public function customWhere($where, $val) |
||||
{ |
||||
$data = ProjectApproval::where($where, $val)->orderBy('id', 'asc')->get(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','data'=> $data,'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project approval not found!','code'=>400], 40); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'project_approval'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectApproval::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project approval, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,119 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectCharter; |
||||
|
||||
class ProjectCharterController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
// $this->validate($request, [ |
||||
// 'nama' => 'required', |
||||
// 'keterangan' => 'required', |
||||
// 'mulai_proyek' => 'required', |
||||
// 'akhir_proyek' => 'required' |
||||
// ]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectCharter::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data project charter successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project charter 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 = Project::find($id); |
||||
|
||||
// if($result){ |
||||
// return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'failed get data project, 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 = ProjectCharter::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
// public function delete($id) |
||||
// { |
||||
// $data = Project::find($id); |
||||
|
||||
// if($data){ |
||||
// $delete = $data->delete(); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'data project not found!','code'=>400], 400); |
||||
// die(); |
||||
// } |
||||
|
||||
|
||||
// if($delete){ |
||||
// return response()->json(['status'=>'success','message'=>'data project successfully deleted!','code'=>200], 200); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'data project failed deleted!','code'=>400], 400); |
||||
// } |
||||
// } |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'project_charter'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
// public function list() |
||||
// { |
||||
// $data = Project::all(); |
||||
// $countData = $data->count(); |
||||
|
||||
// if($data){ |
||||
// return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'failed get list project, please try again later!','code'=>400], 400); |
||||
// } |
||||
// } |
||||
} |
@ -0,0 +1,252 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Project; |
||||
use App\Models\UserToProyek; |
||||
use App\Models\Activity; |
||||
use App\Models\UserToActivity; |
||||
use App\Models\AssignMaterial; |
||||
use App\Models\DokumenProject; |
||||
use App\Models\FolderDocumentProyek; |
||||
use App\Models\ProjectCharter; |
||||
use App\Models\ProjectApproval; |
||||
use App\Models\ProjectMileStone; |
||||
use App\Models\ProjectParticipants; |
||||
use App\Models\UserToVersionGantt; |
||||
use App\Models\RequestMaterial; |
||||
use App\Models\ShowHideColumn; |
||||
use App\Models\ToolsProject; |
||||
use App\Models\VersionGantt; |
||||
use App\Models\MaterialProject; |
||||
use App\Models\Image; |
||||
use App\Models\CommentActivity; |
||||
use App\Models\Link; |
||||
use App\Models\ActivityDokumen; |
||||
use App\Models\Holiday; |
||||
use App\Models\ReportActivity; |
||||
use App\Models\OfficeHours; |
||||
|
||||
class ProjectController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'nama' => 'required', |
||||
// 'keterangan' => 'required', |
||||
'mulai_proyek' => 'required', |
||||
'akhir_proyek' => 'required', |
||||
'rencana_biaya' => 'required', |
||||
'type_proyek_id' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Project::create($data); |
||||
|
||||
if($result){ |
||||
$this->createOfficeHours($result->id); |
||||
$dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first(); |
||||
return response()->json(['status'=>'success','message'=>'add data project successfully!', 'data_result' =>$dataResultInsert, 'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project 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 = Project::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project, 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 = Project::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
private function createOfficeHours($proyek_id) |
||||
{ |
||||
$dataCreate = array( |
||||
"proyek_id"=>$proyek_id, |
||||
"monday_start"=> "08:00:00", |
||||
"monday_end"=> "16:00:00", |
||||
"tuesday_start"=> "08:00:00", |
||||
"tuesday_end"=> "16:00:00", |
||||
"wednesday_start"=> "08:00:00", |
||||
"wednesday_end"=> "16:00:00", |
||||
"thursday_start"=> "08:00:00", |
||||
"thursday_end"=> "16:00:00", |
||||
"friday_start"=> "08:00:00", |
||||
"friday_end"=> "16:00:00", |
||||
"saturday_start"=> "08:00:00", |
||||
"saturday_end"=> "16:00:00", |
||||
"sunday_start"=> "08:00:00", |
||||
"sunday_end"=> "16:00:00", |
||||
"created_by"=> $this->currentName |
||||
); |
||||
|
||||
OfficeHours::create($dataCreate); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Project::find($id); |
||||
|
||||
if($data){ |
||||
$this->deleteRelative($id); |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
private function deleteRelative($project_id) |
||||
{ |
||||
UserToProyek::where('proyek_id', $project_id)->delete(); |
||||
UserToActivity::where('proyek_id', $project_id)->delete(); |
||||
AssignMaterial::where('proyek_id', $project_id)->delete(); |
||||
ProjectCharter::where('proyek_id', $project_id)->delete(); |
||||
ProjectApproval::where('proyek_id', $project_id)->delete(); |
||||
ProjectMileStone::where('proyek_id', $project_id)->delete(); |
||||
ProjectParticipants::where('proyek_id', $project_id)->delete(); |
||||
$this->deleteVersionGantt($project_id); |
||||
$this->deleteDokumenProject($project_id); |
||||
} |
||||
|
||||
private function deleteVersionGantt($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(); |
||||
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); |
||||
} |
||||
} |
||||
ActivityDokumen::whereIn("activity_id", $activityIds)->delete(); |
||||
CommentActivity::whereIn("activity_id", $activityIds)->delete(); |
||||
Holiday::where("proyek_id", $project_id)->delete(); |
||||
VersionGantt::where("proyek_id", $project_id)->delete(); |
||||
Link::whereIn("version_gantt_id", $vhIds)->delete(); |
||||
ShowHideColumn::whereIn("version_gantt_id", $vhIds)->delete(); |
||||
Activity::whereIn("version_gantt_id", $vhIds)->delete(); |
||||
ReportActivity::whereIn("activity_id", $activityIds)->delete(); |
||||
} |
||||
|
||||
private function deleteDokumenProject($project_id) |
||||
{ |
||||
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get(); |
||||
|
||||
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); |
||||
} |
||||
} |
||||
|
||||
DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete(); |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_proyek'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Project::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function getListProjectTask($id){ |
||||
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id","m_proyek.*")->where("assign_hr_to_activity.user_id", $id)->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id') |
||||
->groupBy("m_proyek.proyek_id")->get(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,108 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\DokumenProject; |
||||
|
||||
class ProjectDokumenController extends Controller |
||||
{ |
||||
public function dokumenByProyekId($id){ |
||||
if($id && $id!="" && (int)$id > 0){ |
||||
$dataDokumen = DokumenProject::where("ref_id", $id)->get(); |
||||
|
||||
return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'project id is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
if($id && $id!="" && (int)$id > 0){ |
||||
$dokumen = DokumenProject::find($id); |
||||
if($dokumen){ |
||||
if(file_exists($this->pathDocument.$dokumen->file)){ |
||||
unlink($this->pathDocument.$dokumen->file); |
||||
} |
||||
$dokumen->delete(); |
||||
return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function uploadProjectDokumen(Request $request) |
||||
{ |
||||
if($request->hasFile('dokumen')){ |
||||
// $project_id = $request->project_id; |
||||
$dokumen = $request->file('dokumen'); |
||||
$ref_id = $request->ref_id; |
||||
$extension = $dokumen->extension(); |
||||
$name = $dokumen->getClientOriginalName(); |
||||
|
||||
$result = $dokumen->move($this->pathDocument, $name); |
||||
if($result){ |
||||
$data = [ |
||||
// 'ref_id' => (int)$project_id, |
||||
'ref_id' => (int)$ref_id, |
||||
'file' => $name, |
||||
'type_dokumen' => isset($request->type_dokumen) ? $request->type_dokumen : 'project-document' // project-document-in-folder / project-document-out-folder |
||||
]; |
||||
|
||||
$result = DokumenProject::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'file upload is successfully!','code'=>200], 200); |
||||
}else{ |
||||
unlink($this->pathDocument.$name); |
||||
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400); |
||||
} |
||||
|
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'file upload is failed!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function searchDocProject(Request $request){ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'document_project'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function downloadDokumen($id) |
||||
{ |
||||
if($id && $id!="" && (int)$id > 0){ |
||||
$dokumen = DokumenProject::find($id); |
||||
if($dokumen){ |
||||
if(file_exists($this->pathDocument.$dokumen->file)){ |
||||
$pathToFile = $this->pathDocument.$dokumen->file; |
||||
return response()->download($pathToFile); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Dokumen not found!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,166 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectMileStone; |
||||
use App\Models\Activity; |
||||
|
||||
class ProjectMileStoneController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'status' => 'required', |
||||
'due_date' => 'required', |
||||
'deadline' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectMileStone::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data project milestone successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project milestone 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 = ProjectMileStone::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project milestone, 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 = ProjectMileStone::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project milestone not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project milestone successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project milestone failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectMileStone::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project milestone not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project milestone successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project milestone failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function deleteByProyek($id) |
||||
{ |
||||
$data = ProjectMileStone::where('proyek_id', $id)->delete(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','message'=>'data project milestone successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project milestone failed deleted, because data not found!','code'=>200], 200); |
||||
} |
||||
} |
||||
|
||||
public function customWhere($where, $val) |
||||
{ |
||||
$data = ProjectMileStone::where($where, $val)->orderBy('id', 'asc')->get(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','data'=> $data,'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project milestone not found!','code'=>400], 40); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'project_milestone'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectMileStone::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project milestone, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function select(Request $request) |
||||
{ |
||||
$search = $request->query('search'); |
||||
$idProject = (int)$request->query('idProject'); |
||||
$ganttId = (int)$request->query('idGantt'); |
||||
|
||||
$forbidden = []; |
||||
|
||||
if($idProject && $idProject > 0 && $ganttId && $ganttId > 0){ |
||||
$dataF = Activity::select("name")->where("type_activity", "milestone")->where("version_gantt_id", $ganttId)->where("proyek_id", $idProject)->get(); |
||||
foreach($dataF as $val){ |
||||
$forbidden[] = $val->name; |
||||
} |
||||
} |
||||
|
||||
if($search && !empty($search)){ |
||||
$data = ProjectMileStone::where("proyek_id", $idProject)->where("status", 'like', '%'.$search.'%')->whereNotIn("status", $forbidden)->get(); |
||||
}else{ |
||||
$data = ProjectMileStone::where("proyek_id", $idProject)->whereNotIn("status", $forbidden)->get(); |
||||
} |
||||
|
||||
return response()->json($data); |
||||
} |
||||
} |
@ -0,0 +1,139 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectParticipants; |
||||
class ProjectParticipantsController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'tittle' => 'required', |
||||
'name' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectParticipants::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data project participants successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project participants 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 = ProjectParticipants::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project participants, 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 = ProjectParticipants::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectParticipants::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project participants failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function deleteByProyek($id) |
||||
{ |
||||
$data = ProjectParticipants::where('proyek_id', $id)->delete(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','message'=>'data project participants successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project participants failed deleted, because data not found!','code'=>200], 200); |
||||
} |
||||
} |
||||
|
||||
public function customWhere($where, $val) |
||||
{ |
||||
$data = ProjectParticipants::where($where, $val)->orderBy('id', 'asc')->get(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','data'=> $data,'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'data project participants not found!','code'=>400], 40); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'project_participants'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectParticipants::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project participants, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,128 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectRole; |
||||
|
||||
class ProjectRoleController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$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{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project role 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 = ProjectRole::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project role, 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 = ProjectRole::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project role not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project role successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project role failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectRole::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project role not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project role successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project role failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_role_proyek'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectRole::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project role, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function select(Request $request){ |
||||
$search = $request->query('search'); |
||||
if($search && !empty($search)){ |
||||
$data = ProjectRole::where("name", 'like', '%'.$search.'%')->get(); |
||||
}else{ |
||||
$data = ProjectRole::all(); |
||||
} |
||||
|
||||
return response()->json($data); |
||||
} |
||||
} |
@ -0,0 +1,149 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectToChecklistK3; |
||||
|
||||
class ProjectToChecklistK3Controller extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'checklist_k3_id' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectToChecklistK3::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'user to version gantt Project successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to version gantt Project failed created','code'=>400]); |
||||
} |
||||
} |
||||
|
||||
public function addMultiple(Request $request){ |
||||
$checklist_k3_ids = $request->checklist_k3_id; |
||||
|
||||
$data = ProjectToChecklistK3::where("proyek_id", $request->proyek_id); |
||||
|
||||
if($data){ |
||||
$data->delete(); |
||||
} |
||||
|
||||
if(is_array($checklist_k3_ids) && count($checklist_k3_ids) > 0){ |
||||
$countRes = 0; |
||||
foreach($checklist_k3_ids as $item){ |
||||
|
||||
$dataInsert = array( |
||||
"checklist_k3_id" => $item, |
||||
"proyek_id" => $request->proyek_id, |
||||
"created_by" => $this->currentName |
||||
); |
||||
|
||||
$result = ProjectToChecklistK3::create($dataInsert); |
||||
|
||||
if($result){ |
||||
$countRes++; |
||||
}else{ |
||||
$countRes--; |
||||
} |
||||
} |
||||
if($countRes > 0){ |
||||
return response()->json(['status'=>'success' ,'message'=>'Project to Checklist K3 successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'success' ,'message'=>'Project to Checklist K3 failed created','code'=>400]); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'success' ,'message'=>'Project to Checklist K3 successfull created','code'=>200]); |
||||
} |
||||
|
||||
} |
||||
|
||||
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 = ProjectToChecklistK3::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data user to version gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'user to version gantt Project successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to version gantt Project failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectToChecklistK3::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data user to version gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'user to version gantt Project successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to version gantt Project 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 = ProjectToChecklistK3::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'proyek_to_checklist_k3'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectToChecklistK3::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project to checklist K3, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,117 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ProjectType; |
||||
|
||||
class ProjectTypeController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ProjectType::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data project type successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data project type 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 = ProjectType::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data project type, 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 = ProjectType::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data project type successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project type failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ProjectType::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project type not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data project type successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data project type failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_type_proyek'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ProjectType::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list project type, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,117 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\RateSallary; |
||||
class RateSallaryController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'project_role_id' => 'required', |
||||
'cost' => 'required', |
||||
'type_rate' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = RateSallary::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data rate sallary successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data rate sallary 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 = RateSallary::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data rate sallary, 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 = RateSallary::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data rate sallary not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data rate sallary successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data rate sallary failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = RateSallary::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data rate sallary not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data rate sallary successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data rate sallary failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'rate_cost_hr'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = RateSallary::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list rate sallary, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,279 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ReportActivity; |
||||
use App\Models\Activity; |
||||
use App\Models\Image; |
||||
use Datatables; |
||||
|
||||
class ReportActivityController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
if($request->has('gantt')){ |
||||
$this->validate($request, [ |
||||
'activity_id' => 'required', |
||||
'user_id' => 'required', |
||||
'report_date' => 'required', |
||||
'job_count_report' => 'required' |
||||
]); |
||||
}else{ |
||||
$this->validate($request, [ |
||||
'activity_id' => 'required', |
||||
'user_id' => 'required', |
||||
'report_date' => 'required', |
||||
'job_count_report' => 'required', |
||||
'lat' => 'required', |
||||
'lon' => 'required', |
||||
]); |
||||
} |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ReportActivity::create($data); |
||||
|
||||
if($result){ |
||||
$this->countForProgress($request->activity_id); |
||||
if($request->hasFile("files")){ |
||||
$this->uploadImage($request->file('files'), $result->id); |
||||
} |
||||
return response()->json(['status'=>'success','message'=>'add report activity, update progress activity successfully!','code'=>200,'last_inserted_id'=>$result->id], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add report activity failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
private function uploadImage($files, $ref_id) |
||||
{ |
||||
$dokumen = $files; |
||||
$extension = $dokumen->extension(); |
||||
$name = $ref_id.date("YmdHis").".".$extension; |
||||
$resultMove = $dokumen->move($this->pathImage, $name); |
||||
if($resultMove){ |
||||
$data = [ |
||||
'ref_id' => (int)$ref_id, |
||||
'image' => $name, |
||||
'category' => "report_activity" |
||||
]; |
||||
|
||||
$result = Image::create($data); |
||||
|
||||
if($result){ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = ReportActivity::select("report_activity.*", "u.name as user_name")->where("report_activity.id", $id)->join("m_users as u", "u.id", "=", "report_activity.user_id")->first(); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data report activity, 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 = ReportActivity::find($id); |
||||
|
||||
if($data){ |
||||
$dataUpdate = $request->all(); |
||||
$result = $data->update($dataUpdate); |
||||
if($result){ |
||||
if($request->hasFile("files")){ |
||||
$this->updateImage($request->file('files'), $id); |
||||
} |
||||
$this->countForProgress($data->activity_id); |
||||
return response()->json(['status'=>'success','message'=>'data report activity successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report activity failed updated!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report activity not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
} |
||||
|
||||
public function updateImage($files, $ref_id) |
||||
{ |
||||
$image = Image::where("ref_id", $ref_id)->where("category", "report_activity")->first(); |
||||
if($image){ |
||||
if(file_exists($this->pathImage.$image->image)){ |
||||
unlink($this->pathImage.$image->image); |
||||
} |
||||
$image->delete(); |
||||
} |
||||
$dokumen = $files; |
||||
$extension = $dokumen->extension(); |
||||
$name = $ref_id.date("YmdHis").".".$extension; |
||||
$resultMove = $dokumen->move($this->pathImage, $name); |
||||
if($resultMove){ |
||||
$data = [ |
||||
'ref_id' => (int)$ref_id, |
||||
'image' => $name, |
||||
'category' => "report_activity" |
||||
]; |
||||
|
||||
$result = Image::create($data); |
||||
|
||||
if($result){ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ReportActivity::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report activity not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
$image = Image::where("ref_id", $id)->where("category", "report_activity")->first(); |
||||
if($image){ |
||||
if(file_exists($this->pathImage.$image->image)){ |
||||
unlink($this->pathImage.$image->image); |
||||
} |
||||
$image->delete(); |
||||
} |
||||
return response()->json(['status'=>'success','message'=>'data report activity successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report activity failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
private function countForProgress($id) |
||||
{ |
||||
|
||||
$totalJobs = ReportActivity::where('activity_id', $id)->sum("job_count_report"); |
||||
$dataActivity = Activity::find($id); |
||||
$jobsActivity = (int)$dataActivity->jumlah_pekerjaan; |
||||
|
||||
if ($jobsActivity < 1) { |
||||
return false; |
||||
} |
||||
|
||||
if ($totalJobs < 1) { |
||||
return false; |
||||
} |
||||
|
||||
$persentaseActual = ($totalJobs/$jobsActivity)*100; |
||||
$dataUpdate = array( |
||||
"persentase_progress" => $persentaseActual, |
||||
"updated_by" => $this->currentName |
||||
); |
||||
return $dataActivity->update($dataUpdate); |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'report_activity'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ReportActivity::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list report activity, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function searchPoint(Request $request) { |
||||
$dataPayload = $request->all(); |
||||
$reqActivityId = []; |
||||
foreach ($dataPayload['project_id'] as $val) { |
||||
$reqActivityId[] = $this->getActivityByProjectId($val); |
||||
} |
||||
|
||||
// var_dump(count($reqActivityId)); |
||||
$activity_id = []; |
||||
$getPoints = false; |
||||
|
||||
if (count($reqActivityId) > 0) { |
||||
for ($i=0; $i < count($reqActivityId); $i++) { |
||||
if (count($reqActivityId[$i]) > 0) { |
||||
foreach($reqActivityId[$i] as $reqAct) { |
||||
array_push($activity_id, $reqAct->id); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (count($activity_id) > 0) { |
||||
$getPoints = ReportActivity::select('report_activity.*', 'm_activity.name as activity_name', 'm_activity.jumlah_pekerjaan', 'm_proyek.nama as proyek_name') |
||||
->leftJoin('m_activity', 'm_activity.id', '=', 'report_activity.activity_id') |
||||
->leftJoin('m_proyek', 'm_proyek.id', '=', 'm_activity.proyek_id') |
||||
->whereIn('report_activity.activity_id', $activity_id)->get(); |
||||
} |
||||
|
||||
if($getPoints){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$getPoints, 'totalRecord'=>count($getPoints)], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list points, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function getActivityByProjectId($projectId) { |
||||
$data = Activity::select('id')->where('proyek_id', $projectId)->get(); |
||||
return $data; |
||||
} |
||||
|
||||
public function datatables(Request $request){ |
||||
$id_activity = $request->query('idact'); |
||||
$data = ReportActivity::select("report_activity.*", "u.name as user_name") |
||||
->join("m_users as u", "u.id", "=", "report_activity.user_id") |
||||
->where('report_activity.activity_id', $id_activity) |
||||
->get(); |
||||
return Datatables::of($data) |
||||
->addIndexColumn() |
||||
->addColumn('action', function($row){ |
||||
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn_report_delete"><i class="fa fa-trash"></i></a>'; |
||||
$actionBtn .= ' <a href="javascript:void(0)" data-id="'.$row->id.'" class="edit btn btn-primary btn-sm btn_report_edit"><i class="fa fa-edit"></i></a>'; |
||||
return $actionBtn; |
||||
}) |
||||
->editColumn('report_date', function($row) { |
||||
$date = date_create($row->report_date); |
||||
return date_format($date,"d-m-Y H:i:s"); |
||||
}) |
||||
->rawColumns(['action'])->make(true); |
||||
} |
||||
} |
@ -0,0 +1,269 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ReportActivityMaterial; |
||||
use App\Models\Activity; |
||||
use App\Models\AssignMaterial; |
||||
use Datatables; |
||||
|
||||
class ReportActivityMaterialController extends Controller |
||||
{ |
||||
|
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'activity_id' => 'required', |
||||
// 'assign_material_id' => 'required', |
||||
'qty' => 'required' |
||||
// 'budget' => 'required' |
||||
]); |
||||
|
||||
$valAssignMaterialId = AssignMaterial::where('activity_id', $request->activity_id)->first(); |
||||
|
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
$data['assign_material_id'] = $valAssignMaterialId->id; |
||||
|
||||
$checkPrice = AssignMaterial::where("id", $valAssignMaterialId->id)->first(); |
||||
$price = $checkPrice->budget; |
||||
|
||||
$updateActivity = Activity::find($request->activity_id); |
||||
if($updateActivity){ |
||||
$costActualOld = $updateActivity->biaya_actual == null ? 0 : (int)$updateActivity->biaya_actual; |
||||
$costActualNew = $costActualOld + ($price*$request->qty); |
||||
$updateActivity->biaya_actual = $costActualNew; |
||||
$updateActivity->save(); |
||||
// return response()->json(['status'=>'success','message'=>'Assign material successfull created, and update cost plan success '.$costPlanNew,'code'=>200]); |
||||
$result = ReportActivityMaterial::create($data); |
||||
if($result){ |
||||
$this->countForProgress($request->activity_id); |
||||
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400]); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'Update cost actual failed','code'=>400]); |
||||
} |
||||
} |
||||
|
||||
public function updateStatusStartFinish(Request $request){ |
||||
// $updateData = AssignMaterial::find($request->assign_material_id); |
||||
// if($updateData){ |
||||
// $updateData->start_activity = $request->start_activity; |
||||
// $updateData->finish_activity = $request->finish_activity; |
||||
// $updateData->status_activity = $request->status_activity; |
||||
// $updateData->save(); |
||||
// if($request->status_activity == 'done'){ |
||||
// $dataUpdate = array( |
||||
// "persentase_progress" => 100, |
||||
// "updated_by" => $this->currentName |
||||
// ); |
||||
// Activity::where('id', $updateData->activity_id)->update($dataUpdate); |
||||
// } |
||||
|
||||
// return response()->json(['status'=>'success','message'=>'Update data status successfully ', 'code'=>200]); |
||||
// } |
||||
$payloadUpdate = array( |
||||
'start_activity' => $request->start_activity, |
||||
'finish_activity' => $request->finish_activity, |
||||
'status_activity' => $request->status_activity |
||||
); |
||||
$updateData = AssignMaterial::where('activity_id',$request->activity_id) |
||||
->update($payloadUpdate); |
||||
if($updateData){ |
||||
// $updateData->start_activity = $request->start_activity; |
||||
// $updateData->finish_activity = $request->finish_activity; |
||||
// $updateData->status_activity = $request->status_activity; |
||||
// $updateData->save(); |
||||
if($request->status_activity == 'done'){ |
||||
$dataUpdate = array( |
||||
"persentase_progress" => 100, |
||||
"updated_by" => $this->currentName |
||||
); |
||||
Activity::where('id', $request->activity_id)->update($dataUpdate); |
||||
} |
||||
|
||||
return response()->json(['status'=>'success','message'=>'Update data status successfully ', 'code'=>200]); |
||||
} |
||||
else{ |
||||
return response()->json(['status'=>'failed','message'=>'Update data status failed', 'code'=>400]); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ReportActivityMaterial::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data menu not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data menu successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data menu failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
private function countForProgress($id) |
||||
{ |
||||
|
||||
// $totalJobs = ReportActivityMaterial::where('activity_id', $id)->sum("qty"); |
||||
$dataActivity = Activity::find($id); |
||||
$dataPlan = AssignMaterial::where('activity_id', $id)->get(); |
||||
$tmpPercentage1 = []; |
||||
if(!$dataPlan->isEmpty()){ |
||||
|
||||
foreach ($dataPlan as $value) { |
||||
# code... |
||||
$price = $value->material_id; |
||||
$qty_plan = $value->qty_planning; |
||||
$status_activity = $value->status_activity; |
||||
|
||||
// get volume actual |
||||
$getDataVolActual = ReportActivityMaterial::where('assign_material_id', '=', $value->id)->sum("qty"); |
||||
$percentage1 = ($getDataVolActual * 100) / $qty_plan; |
||||
|
||||
if($status_activity == 'done'){ |
||||
$tmpPercentage1[] = $percentage1 > 100 ? 100 : $percentage1; |
||||
}else if($status_activity == 'on-progress'){ |
||||
$tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; |
||||
}else{ |
||||
$tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; |
||||
} |
||||
} |
||||
$totalPercentage = array_sum($tmpPercentage1) / count($tmpPercentage1); |
||||
}else{ |
||||
$totalPercentage = 0; |
||||
} |
||||
|
||||
// if ($jobsActivity < 1) { |
||||
// return false; |
||||
// } |
||||
|
||||
// if ($totalJobs < 1) { |
||||
// return false; |
||||
// } |
||||
|
||||
// $persentaseActual = ($totalJobs/$jobsActivity)*100; |
||||
|
||||
$dataUpdate = array( |
||||
"persentase_progress" => $totalPercentage, |
||||
"updated_by" => $this->currentName |
||||
); |
||||
return $dataActivity->update($dataUpdate); |
||||
} |
||||
|
||||
public function countForProgressTest() |
||||
{ |
||||
$dataPlan = AssignMaterial::where('activity_id', 807)->get(); |
||||
// $jobsActivity = (int)$dataActivity->qty_planning; |
||||
$tmpPercentage1 = []; |
||||
|
||||
if(!$dataPlan->isEmpty()){ |
||||
foreach ($dataPlan as $value) { |
||||
# code... |
||||
// price per material |
||||
$price = $value->material_id; |
||||
$qty_plan = $value->qty_planning; |
||||
$status_activity = $value->status_activity; |
||||
|
||||
// get volume actual |
||||
$getDataVolActual = ReportActivityMaterial::where('assign_material_id', '=', $value->id)->sum("qty"); |
||||
$percentage1 = ($getDataVolActual * 100) / $qty_plan; |
||||
// if($qty_plan == null){ |
||||
// $tmpPercentage1[] = 0 |
||||
// }else{ |
||||
$percentage1 = ($getDataVolActual * 100) / $qty_plan; |
||||
if($status_activity == 'done'){ |
||||
$tmpPercentage1[] = $percentage1 > 100 ? 100 : $percentage1; |
||||
}else if($status_activity == 'on-progress'){ |
||||
$tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; |
||||
}else{ |
||||
$tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; |
||||
} |
||||
// } |
||||
|
||||
|
||||
} |
||||
$totalPercentage = array_sum($tmpPercentage1) / count($tmpPercentage1); |
||||
}else{ |
||||
$totalPercentage = 0; |
||||
} |
||||
|
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataPlan, 'tmpPercentage1'=> $tmpPercentage1, 'totalPercentage'=> $totalPercentage], 200); |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in golang API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'report_activity_material'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ReportActivityMaterial::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get Repport Activity material, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function datatables(Request $request){ |
||||
$id_activity = $request->query('idAct'); |
||||
$id_assign_material_id= $request->query('idAmi'); |
||||
$type = $request->query('type'); |
||||
if($type == 'plan'){ |
||||
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") |
||||
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") |
||||
->where('assign_material_to_activity.activity_id', $id_activity) |
||||
->orderBy('assign_material_to_activity.id', 'asc') |
||||
->get(); |
||||
return Datatables::of($data) |
||||
->addIndexColumn() |
||||
->addColumn('action', function($row){ |
||||
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-ram-delete"><i class="fa fa-trash"></i></a>'; |
||||
return $actionBtn; |
||||
}) |
||||
->rawColumns(['action'])->make(true); |
||||
}else{ |
||||
// $data = AssignMaterial::select("assign_material_to_activity.*","m.name as material_name", "m.uom as uom")->join("m_material_resource as m", "m.id", "=", "assign_material_to_activity.material_id")->where('assign_material_to_activity.activity_id', $id_activity)->get(); |
||||
$data = ReportActivityMaterial::select("report_activity_material.*", "u.name as human_resource") |
||||
// ->join("assign_material_to_activity as am_ta", "am_ta.id","=", "report_activity_material.assign_material_id") |
||||
// ->join("m_req_material as m", "m.id", "=", "am_ta.material_id") |
||||
->join("m_users as u", "u.id", "=", "report_activity_material.user_id") |
||||
// ->where('report_activity_material.assign_material_id', $id_assign_material_id) |
||||
->where('report_activity_material.activity_id', $id_activity) |
||||
->orderBy('report_activity_material.report_date', 'asc') |
||||
->get(); |
||||
return Datatables::of($data) |
||||
->addIndexColumn() |
||||
->addColumn('action', function($row){ |
||||
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-ram-delete"><i class="fa fa-trash"></i></a>'; |
||||
return $actionBtn; |
||||
}) |
||||
->rawColumns(['action'])->make(true); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,165 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ReportK3; |
||||
use App\Models\ReportK3Detail; |
||||
use App\Models\ProjectToChecklistK3; |
||||
use App\Models\ChecklistK3; |
||||
use App\Models\Image; |
||||
use DB; |
||||
|
||||
class ReportK3Controller extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'report_date' => 'required', |
||||
'proyek_id' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ReportK3::create($data); |
||||
|
||||
if($result){ |
||||
if($request->has("detail")){ |
||||
$this->addDetailK3($request->detail, $result->id); |
||||
} |
||||
return response()->json(['status'=>'success', 'report_id'=>$result->id,'message'=>'add report k3 successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data report k3 failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
private function addDetailK3($dataDetail, $report_id){ |
||||
foreach ($dataDetail as $value) { |
||||
$dataNew = array( |
||||
"report_k3_id"=>$report_id, |
||||
"checklist_k3_id"=>$value['checklist_id'], |
||||
"name_checklist_k3"=>$value['checklist_name'], |
||||
"created_by"=>$this->currentName |
||||
); |
||||
|
||||
ReportK3Detail::create($dataNew); |
||||
} |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = ReportK3::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data report k3, 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 = ReportK3::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report k3 not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data report k3 successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report k3 failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ReportK3::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report k3 not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data report k3 successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report k3 failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 't_report_k3'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// get another child data |
||||
if($request->has("child_data")){ |
||||
$newDataGet = []; |
||||
$dataChild = $request->child_data; |
||||
if(isset($dataChild['table_name']) && isset($dataChild['column_name']) && isset($dataChild['column_table'])){ |
||||
$columnForeign = $dataChild['column_name']; |
||||
$columnSelf = $dataChild['column_table']; |
||||
foreach ($dataGet as $value) { |
||||
$resultData = DB::table($dataChild['table_name'])->where($columnSelf,$value->{$columnForeign})->get(); |
||||
$value->childData = $resultData; |
||||
// only for report k3 |
||||
$value->k3_checked = $resultData->pluck("name_checklist_k3")->all(); |
||||
$dataImage = Image::where("category", "report_k3")->where("ref_id", $value->id)->first(); |
||||
if($dataImage){ |
||||
$value->image = $dataImage->image; |
||||
}else{ |
||||
$value->image = null; |
||||
} |
||||
$idsChecklist = $resultData->pluck("checklist_k3_id")->all(); |
||||
$CheklistK3Ids = ProjectToChecklistK3::whereNotIn("checklist_k3_id", $idsChecklist)->where("proyek_id", $value->proyek_id)->pluck("checklist_k3_id"); |
||||
$value->k3_not_checked = ChecklistK3::whereIn("id", $CheklistK3Ids)->pluck("name")->all(); |
||||
// === // |
||||
$newDataGet[] = $value; |
||||
} |
||||
$dataGet = $newDataGet; |
||||
} |
||||
} |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ReportK3::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list report k3, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,118 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ReportK3Detail; |
||||
|
||||
class ReportK3DetailController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'report_k3_id' => 'required', |
||||
'checklist_k3_id' => 'required', |
||||
'name_checklist_k3' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ReportK3Detail::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add report k3 detail successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add report k3 detail 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 = ReportK3Detail::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data report k3 detail, 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 = ReportK3Detail::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report k3 detail not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data report k3 detail successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report k3 detail failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ReportK3Detail::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report k3 detail not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data report k3 detail successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data report k3 detail failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 't_report_k3_detail'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ReportK3Detail::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list report k3 detail, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,206 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\RequestMaterial; |
||||
use App\Models\MaterialResource; |
||||
|
||||
class RequestMaterialController extends Controller |
||||
{ |
||||
public function add(Request $request){ |
||||
|
||||
$this->validate($request, [ |
||||
'proyek_id' => 'required', |
||||
'description' => 'required', |
||||
'required_date' => 'required', |
||||
'qty' => 'required', |
||||
'uom' => 'required', |
||||
'fom_date' => 'required', |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['status'] = "fom"; |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = RequestMaterial::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'request material successfully!', 'data'=>$result, 'code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'request material 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 = RequestMaterial::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data request material, 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 = RequestMaterial::find($id); |
||||
|
||||
// if($data){ |
||||
// $result = $data->update($request->all()); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'data request material not found!','code'=>400], 400); |
||||
// die(); |
||||
// } |
||||
|
||||
|
||||
// if($result){ |
||||
// return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'request material failed updated!','code'=>400], 400); |
||||
// } |
||||
// } |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = RequestMaterial::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data request material not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'request material successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'request material failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_req_material'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = RequestMaterial::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list request material, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
$dataForm = $request->all(); |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
$data = RequestMaterial::find($id); |
||||
if($data){ |
||||
if(!isset($dataForm['status'])){ |
||||
// return response()->json(['status'=>'failed','message'=>'status is required!','code'=>400], 400); |
||||
$resultUpdate = $data->update($request->all()); |
||||
if($resultUpdate){ |
||||
return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'request material failed updated!','code'=>400], 400); |
||||
} |
||||
die(); |
||||
} |
||||
if($dataForm['status']=="receipt to warehouse"){ |
||||
// $result = $data->update($request->all()); |
||||
// if($result){ |
||||
$dataM = MaterialResource::where('name', 'ilike', $data->description)->first(); |
||||
if($dataM){ |
||||
$result = $data->update($request->all()); |
||||
$payloadMQty = $dataM->qty + $data->qty_received; |
||||
$resultUpdateM = MaterialResource::where('id', $dataM->id)->update(['qty' => $payloadMQty]); |
||||
return response()->json(['status'=>'success', 'code'=>200], 200); |
||||
}else{ |
||||
$result = $data->update($request->all()); |
||||
$dataPayloadM = array( |
||||
"name" => $dataForm['description'], |
||||
"uom" => $dataForm['uom'], |
||||
"unit_price" => 0, |
||||
"description" => $dataForm['description'], |
||||
"qty" => $data->qty_received, |
||||
"status" => "Barang tersedia", |
||||
"created_by" => $this->currentName |
||||
); |
||||
$result = MaterialResource::create($dataPayloadM); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data material resource successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data material resource failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'update status receipt to warehouse request material resource failed!','code'=>400], 400); |
||||
// } |
||||
}else if($dataForm['status']=="receipt to site"){ |
||||
$result = $data->update($request->all()); |
||||
// if($result){ |
||||
$dataM = MaterialResource::where('name', 'ilike', $data->description)->first(); |
||||
if($dataM){ |
||||
$result = $data->update($request->all()); |
||||
$payloadMQty = $dataM->qty - $data->qty_received; |
||||
|
||||
if($payloadMQty < 0){ |
||||
return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed, because material is not exist in warehouse!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
$resultUpdateM = MaterialResource::where('id', $dataM->id)->update(['qty' => $payloadMQty]); |
||||
return response()->json(['status'=>'success', 'message'=>'request material status receipt to site successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed, because material is not exist in warehouse!','code'=>400], 400); |
||||
} |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed!','code'=>400], 400); |
||||
// } |
||||
}else{ |
||||
$resultUpdate = $data->update($request->all()); |
||||
if($resultUpdate){ |
||||
return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'request material failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data request material not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,116 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Role; |
||||
class RoleController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Role::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data role successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data role 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 = Role::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data role, 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 = Role::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data role successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Role::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data role successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_roles'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Role::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,109 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Menu; |
||||
use App\Models\RoleMenu; |
||||
|
||||
class RoleMenuController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'role_id' => 'required', |
||||
'menu_id' => 'required', |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = RoleMenu::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data role menu successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data role menu failed!','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 = RoleMenu::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role menu not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data role menu successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role menu failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = RoleMenu::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role menu not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data role menu successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role menu failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function deleteByRole($id) |
||||
{ |
||||
$data = RoleMenu::where("role_id", $id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role menu not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data role menu successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data role menu failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 't_roles_menu'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
} |
@ -0,0 +1,117 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Satuan; |
||||
|
||||
class SatuanController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Satuan::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add satuan successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data satuan 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 = Satuan::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data satuan, 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 = Satuan::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data satuan not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data satuan successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data satuan failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Satuan::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data satuan not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data satuan successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data satuan failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_satuan'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Satuan::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list satuan, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,98 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Shift; |
||||
|
||||
class ShiftController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'label' => 'required', |
||||
'flex_time_minute' => 'required', |
||||
'start_time' => 'required', |
||||
'end_time' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Shift::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Master shift successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master shift failed created','code'=>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 = Shift::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data Master shift not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Master shift successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master shift failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Shift::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Master shift not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Master shift successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Master shift failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_shift'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Shift::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,121 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\UserToVersionGantt; |
||||
use App\Models\ShowHideColumn; |
||||
|
||||
class ShowHideColumnController extends Controller |
||||
{ |
||||
public function getByUserGantt($gantt_id) |
||||
{ |
||||
$user_id = $this->currentId; |
||||
if($user_id > 0){ |
||||
$cekData = UserToVersionGantt::where("version_gantt_id", $gantt_id)->where("user_id", $user_id)->count(); |
||||
if($cekData <=0){ |
||||
$data = array( |
||||
"status"=>"not have access" |
||||
); |
||||
}else{ |
||||
$cekAvailable = ShowHideColumn::where("version_gantt_id", $gantt_id)->where("user_id", $user_id)->count(); |
||||
if($cekAvailable > 0){ |
||||
$data = ShowHideColumn::where("version_gantt_id", $gantt_id)->where("user_id", $user_id)->get(); |
||||
}else{ |
||||
$data = array( |
||||
"status"=>"not yet have" |
||||
); |
||||
} |
||||
} |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list user to version gantt, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'version_gantt_id' => 'required', |
||||
'columns'=> 'required' |
||||
]); |
||||
|
||||
$columns = $request->columns; |
||||
|
||||
$success = 0; |
||||
|
||||
foreach ($columns as $column) { |
||||
$dataAdd = array( |
||||
'version_gantt_id'=>$request->version_gantt_id, |
||||
'user_id'=>$this->currentId, |
||||
'column_name'=>$column, |
||||
'show'=>true, |
||||
'created_by'=>$this->currentName |
||||
); |
||||
|
||||
$result = ShowHideColumn::create($dataAdd); |
||||
|
||||
if($result){ |
||||
$success++; |
||||
}else{ |
||||
$success--; |
||||
} |
||||
} |
||||
|
||||
if($success > 0){ |
||||
return response()->json(['status'=>'success','message'=>'add show hide column successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add show hide column failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function update(Request $request, $gantt_id) |
||||
{ |
||||
$this->validate($request, [ |
||||
'columns'=> 'required' |
||||
]); |
||||
|
||||
if(!$gantt_id || (int) $gantt_id < 0 || $gantt_id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'gantt id is required!','code'=>400], 400); |
||||
} |
||||
|
||||
$user_id = $this->currentId; |
||||
|
||||
$columns = $request->columns; |
||||
|
||||
$success = 0; |
||||
foreach ($columns as $column => $show) { |
||||
$check = ShowHideColumn::where("column_name", $column)->where("version_gantt_id", $gantt_id)->where("user_id", $user_id)->count(); |
||||
if($check > 0){ |
||||
$dataUpdate = array( |
||||
"show"=>$show |
||||
); |
||||
|
||||
$result = ShowHideColumn::where("column_name", $column)->where("version_gantt_id", $gantt_id)->where("user_id", $user_id) |
||||
->update($dataUpdate); |
||||
}else{ |
||||
$dataNew = array( |
||||
'version_gantt_id'=>$gantt_id, |
||||
'user_id'=>$user_id, |
||||
'column_name'=>$column, |
||||
'show'=>$show, |
||||
'created_by'=>$this->currentName |
||||
); |
||||
|
||||
$result = ShowHideColumn::create($dataNew); |
||||
} |
||||
|
||||
if($result){ |
||||
$success++; |
||||
}else{ |
||||
$success--; |
||||
} |
||||
} |
||||
|
||||
if($success > 0){ |
||||
return response()->json(['status'=>'success','message'=>'data show hide column successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data show hide column failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
|
||||
class TBroadcastController extends Controller |
||||
{ |
||||
// |
||||
} |
@ -0,0 +1,136 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\TemplateGantt; |
||||
|
||||
class TemplateGanttController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'proyek_type_id' => 'required', |
||||
'name_activity' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = TemplateGantt::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Template Gantt Project successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Template Gantt Project failed created','code'=>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 = TemplateGantt::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Template Gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Template Gantt Project successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Template Gantt Project failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = TemplateGantt::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Template Gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Template Gantt Project successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Template Gantt Project 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 = TemplateGantt::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_template_gantt'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = TemplateGantt::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list version gantt, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function getTreeByTypeProject($id) |
||||
{ |
||||
$data = TemplateGantt::where('proyek_type_id', $id)->whereNull('parent_id')->orderByRaw('id ASC')->get(); |
||||
$finalData = []; |
||||
foreach($data as $objRow){ |
||||
$objRow->children = $this->getChildren($id, $objRow->id); |
||||
$objRow->key = rand(1, 1000); |
||||
$finalData[] = $objRow; |
||||
} |
||||
|
||||
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200); |
||||
} |
||||
|
||||
private function getChildren($type_project, $parent_id) |
||||
{ |
||||
$finalData = []; |
||||
$data = TemplateGantt::where('proyek_type_id', $type_project)->where('parent_id', $parent_id)->orderByRaw('id ASC')->get(); |
||||
foreach($data as $objRow){ |
||||
$objRow->key = rand(1, 1000); |
||||
$objRow->children = $this->getChildren($type_project, $objRow->id); |
||||
$finalData[] = $objRow; |
||||
} |
||||
return $finalData; |
||||
} |
||||
} |
@ -0,0 +1,53 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ToolsProject; |
||||
|
||||
class ToolsProjectController extends Controller |
||||
{ |
||||
public function assignTools(Request $request) |
||||
{ |
||||
$projectId = $request->project_id; |
||||
$subproyekId = $request->subproyek_id; |
||||
$listToolsId = $request->tools_id; |
||||
|
||||
if(!$projectId && !$subproyekId){ |
||||
return response()->json(['status'=>'failed','message'=>'Required proyek_id or subproyek id','code'=>400]); |
||||
} |
||||
|
||||
if(is_array ($listToolsId) && count($listToolsId) > 0){ |
||||
$result = 0; |
||||
ToolsProject::where('proyek_id', $projectId)->delete(); |
||||
ToolsProject::where('proyek_id', $subproyekId)->delete(); |
||||
foreach($listToolsId as $tool_id){ |
||||
$data = [ |
||||
'tools_id'=>(int)$tool_id |
||||
]; |
||||
|
||||
if($projectId && $projectId!="" && (int)$projectId > 0){ |
||||
$data['proyek_id'] = $projectId; |
||||
}else if($subproyekId && $subproyekId!="" && (int)$subproyekId > 0){ |
||||
$data['subproyek_id'] = $subproyekId; |
||||
} |
||||
|
||||
$insert = ToolsProject::create($data); |
||||
if($insert){ |
||||
$result++; |
||||
}else{ |
||||
$result--; |
||||
} |
||||
} |
||||
if($result > 0){ |
||||
return response()->json(['status'=>'success','message'=>'Tools Project successfull updated','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Tools Project failed updated','code'=>400]); |
||||
} |
||||
}else{ |
||||
ToolsProject::where('proyek_id', $projectId)->delete(); |
||||
ToolsProject::where('proyek_id', $subproyekId)->delete(); |
||||
return response()->json(['status'=>'success','message'=>'Tools Project Successfull updated','code'=>200]); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,171 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ToolsRequest; |
||||
use App\Models\ToolsResource; |
||||
|
||||
class ToolsRequestController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'asset_type' => 'required', |
||||
'asset_name' => 'required', |
||||
'required_date' => 'required', |
||||
'qty' => 'required', |
||||
'uom' => 'required', |
||||
'description' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['status'] = "fot"; |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ToolsRequest::create($data); |
||||
// return response()->json($author, 201); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'Tools Request Project successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Tools Request Project failed created','code'=>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 = ToolsRequest::find($id); |
||||
// if($data){ |
||||
// $result = $data->update($request->all()); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'data Tools Request Project not found!','code'=>400], 400); |
||||
// die(); |
||||
// } |
||||
|
||||
// if($result){ |
||||
// return response()->json(['status'=>'success','message'=>'Tools Request Project successfully updated!','code'=>200], 200); |
||||
// }else{ |
||||
// return response()->json(['status'=>'failed','message'=>'Tools Request Project failed updated!','code'=>400], 400); |
||||
// } |
||||
// } |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
$dataForm = $request->all(); |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
if(!isset($dataForm['status'])){ |
||||
return response()->json(['status'=>'failed','message'=>'status is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
$data = ToolsRequest::find($id); |
||||
if($data){ |
||||
if($dataForm['status']=="receipt to warehouse"){ |
||||
|
||||
$dataT = ToolsResource::where('name', $data->asset_name)->first(); |
||||
if($dataT){ |
||||
$result = $data->update($request->all()); |
||||
$payloadMQty = $dataT->qty + $data->qty_received; |
||||
$resultUpdateM = ToolsResource::where('id', $dataT->id)->update(['qty' => $payloadMQty]); |
||||
return response()->json(['status'=>'success', 'message'=>'request material successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
$result = $data->update($request->all()); |
||||
$dataPayloadM = array( |
||||
"name" => $dataForm['asset_name'], |
||||
"uom" => $dataForm['uom'], |
||||
"unit_price" => 0, |
||||
"description" => $dataForm['description'], |
||||
"qty" => $data->qty_received, |
||||
"asset_type" => $dataForm['asset_type'], |
||||
"created_by" => $this->currentName |
||||
); |
||||
$result = ToolsResource::create($dataPayloadM); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data material resource successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data material resource failed!','code'=>400], 400); |
||||
} |
||||
} |
||||
}else if($dataForm['status']=="receipt to site"){ |
||||
|
||||
$dataT = ToolsResource::where('name', $data->asset_name)->first(); |
||||
if($dataT){ |
||||
$result = $data->update($request->all()); |
||||
$payloadMQty = $dataT->qty - $data->qty_received; |
||||
if($payloadMQty < 0){ |
||||
return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed, because material is not exist in warehouse!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
$resultUpdateM = ToolsResource::where('id', $dataT->id)->update(['qty' => $payloadMQty]); |
||||
return response()->json(['status'=>'success', 'message'=>'request material status receipt to site successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'update status receipt to site request material resource failed, because tools is not exist in warehouse!','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
$resultUpdate = $data->update($request->all()); |
||||
if($resultUpdate){ |
||||
return response()->json(['status'=>'success','message'=>'request material successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'request material failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data request material not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ToolsRequest::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data Tools Request Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Tools Request Project successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Tools Request Project failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_req_tools'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ToolsRequest::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,132 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\ToolsResource; |
||||
|
||||
class ToolsResourceController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'qty'=> 'required', |
||||
'uom'=> 'required', |
||||
'asset_type'=> 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = ToolsResource::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add data tools resource successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add data tools resource 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 = ToolsResource::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, 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 = ToolsResource::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data tools resource not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data tools resource successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data tools resource failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = ToolsResource::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data tools resource not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data tools resource successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data tools resource failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_tools_resource'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = ToolsResource::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list material resource, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function select(Request $request){ |
||||
|
||||
$search = $request->query('search'); |
||||
|
||||
if($search && !empty($search)){ |
||||
$data = ToolsResource::where("name", 'like', '%'.$search.'%')->get(); |
||||
}else{ |
||||
$data = ToolsResource::all(); |
||||
} |
||||
|
||||
return response()->json($data); |
||||
} |
||||
} |
@ -0,0 +1,137 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\UserMonthlyShift; |
||||
use GuzzleHttp\Client; |
||||
|
||||
class UserMonthlyShiftController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'schedules' => 'required', |
||||
'start_time' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = UserMonthlyShift::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'monthly shift schedule successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'monthly shift schedule failed created','code'=>400]); |
||||
} |
||||
} |
||||
|
||||
public function import(Request $request) |
||||
{ |
||||
$client = new Client(); |
||||
$res = $client->request('POST', config('api.golang') . "/monthly-shift-schedules/import", |
||||
['json' => $request->all()] |
||||
); |
||||
if ($res->getStatusCode() != 200) { |
||||
return response()->json(['status'=>'failed','message'=>'failed to import schedules, please try again later!','code'=>400], 400); |
||||
} |
||||
|
||||
$result= $res->getBody(); |
||||
return response($result, 200) |
||||
->header("content-type", $res->getHeaderLine('content-type')); |
||||
} |
||||
|
||||
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 = UserMonthlyShift::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data monthly shift schedule not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'monthly shift schedule successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'monthly shift schedule failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = UserMonthlyShift::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data monthly shift schedule not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Shift schedule successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Shift schedule failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
public function deleteYYYYMM($yyyymm) |
||||
{ |
||||
$delete = UserMonthlyShift::deleteYYYYMM($yyyymm); |
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'Shift schedule successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Shift schedule failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_shift'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
// List this month's shift schedule |
||||
public function list() |
||||
{ |
||||
return $this->listYYYYMM(date('Ym')); |
||||
} |
||||
|
||||
public function listYYYYMM($yyyymm) |
||||
{ |
||||
// Kadang start_time bisa jadi tanggal awal-bulan - 1 hari |
||||
/* |
||||
$data = UserMonthlyShift::where("to_char(start_at+INTERVAL '1 day', 'YYYYMM')", $yyyymm) |
||||
->all(); |
||||
*/ |
||||
$data = UserMonthlyShift::monthlyWithUserInfo($yyyymm); |
||||
$countData = $data->count(); |
||||
if($data){ |
||||
return response()->json([ |
||||
'status'=>'success', |
||||
'code'=>200, |
||||
'data'=>$data, |
||||
'yyyymm' => $yyyymm, |
||||
'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,53 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\UserProject; |
||||
|
||||
class UserProyekController extends Controller |
||||
{ |
||||
public function assignUserProyek(Request $request) |
||||
{ |
||||
$projectId = $request->project_id; |
||||
$subproyekId = $request->subproyek_id; |
||||
$listUser = $request->user_id; |
||||
|
||||
if(!$projectId && !$subproyekId){ |
||||
return response()->json(['status'=>'failed','message'=>'Required proyek_id or subproyek id','code'=>400],400); |
||||
} |
||||
|
||||
if(is_array($listUser) && count($listUser) > 0){ |
||||
$result = 0; |
||||
UserProject::where('proyek_id', $projectId)->delete(); |
||||
UserProject::where('proyek_id', $subproyekId)->delete(); |
||||
foreach($listUser as $id){ |
||||
$data = [ |
||||
'user_id'=>(int)$id |
||||
]; |
||||
|
||||
if($projectId && $projectId!="" && (int)$projectId > 0){ |
||||
$data['proyek_id'] = $projectId; |
||||
}else if($subproyekId && $subproyekId!="" && (int)$subproyekId > 0){ |
||||
$data['subproyek_id'] = $subproyekId; |
||||
} |
||||
|
||||
$insert = UserProject::create($data); |
||||
if($insert){ |
||||
$result++; |
||||
}else{ |
||||
$result--; |
||||
} |
||||
} |
||||
if($result > 0){ |
||||
return response()->json(['status'=>'success','message'=>'User Project successfull updated','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'User Project failed updated','code'=>400], 400); |
||||
} |
||||
}else{ |
||||
UserProject::where('proyek_id', $projectId)->delete(); |
||||
UserProject::where('proyek_id', $subproyekId)->delete(); |
||||
return response()->json(['status'=>'success','message'=>'User Project Successfull updated','code'=>200], 200); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,222 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\UserToActivity; |
||||
use App\Models\ReportActivity; |
||||
use App\Models\Activity; |
||||
use App\Models\Image; |
||||
use App\Models\UserToProyek; |
||||
use Datatables; |
||||
|
||||
class UserToActivityController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'activity_id' => 'required', |
||||
'user_id' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = UserToActivity::create($data); |
||||
if($result){ |
||||
$updateActivity = Activity::find($request->activity_id); |
||||
$getWorkingHours = UserToProyek::where('user_id', $request->user_id)->first(); |
||||
if($updateActivity && $getWorkingHours){ |
||||
$costPlanOld = $updateActivity==null? 0 : (int)$updateActivity->rencana_biaya; |
||||
if($getWorkingHours->uom_standart_rate == "Day"){ |
||||
$costUser = $getWorkingHours->standart_rate * $updateActivity->duration; |
||||
}else if($getWorkingHours->uom_standart_rate == "Hour"){ |
||||
$costUser = ($getWorkingHours->standart_rate * 8) * $updateActivity->duration; // assumption standart working is 8 hours |
||||
} |
||||
$costPlanNew = $costPlanOld + $costUser; |
||||
$updateActivity->rencana_biaya = $costPlanNew; |
||||
$updateActivity->save(); |
||||
// UserToProyek::where('user_id', $request->user_id)->update(['rencana_biaya' => $costPlanNew]); |
||||
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfull created, and cost plant successfull update '.$costPlanNew,'code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfull created','code'=>200]); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to activity gantt Project failed created','code'=>400]); |
||||
} |
||||
} |
||||
|
||||
public function addMultiple(Request $request){ |
||||
$users_id = $request->user_id; |
||||
|
||||
$data = UserToActivity::where("activity_id", $request->activity_id); |
||||
|
||||
if($data){ |
||||
$data->delete(); |
||||
} |
||||
|
||||
if(is_array($users_id) && count($users_id) > 0){ |
||||
$countRes = 0; |
||||
foreach($users_id as $item){ |
||||
|
||||
$dataInsert = array( |
||||
"user_id" => $item, |
||||
"activity_id" => $request->activity_id, |
||||
"role_proyek_id" => $request->role_proyek_id, |
||||
"proyek_id" => $request->proyek_id, |
||||
"created_by" => $this->currentName |
||||
); |
||||
|
||||
$result = UserToActivity::create($dataInsert); |
||||
|
||||
if($result){ |
||||
$countRes++; |
||||
}else{ |
||||
$countRes--; |
||||
} |
||||
} |
||||
|
||||
if($countRes > 0){ |
||||
$allCost = $this->calculateAllCost($request->activity_id, $request->proyek_id); |
||||
$dataUpdateCost = array( |
||||
"rencana_biaya"=>$allCost, |
||||
"updated_by"=> $this->currentName |
||||
); |
||||
$actUpdate = Activity::find($request->activity_id); |
||||
if($actUpdate){ |
||||
$actUpdate->update($dataUpdateCost); |
||||
if($actUpdate->parent_id){ |
||||
$this->updatedCostPlanning($actUpdate->parent_id); |
||||
} |
||||
} |
||||
|
||||
return response()->json(['status'=>'success' ,'message'=>'user to activity gantt Project successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'success' ,'message'=>'user to activity gantt Project failed created','code'=>400]); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'success' ,'message'=>'user to activity gantt Project successfull created','code'=>200]); |
||||
} |
||||
|
||||
} |
||||
|
||||
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 = UserToActivity::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to activity gantt Project failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = UserToActivity::find($id); |
||||
if($data){ |
||||
$userId = $data->user_id; |
||||
$activityId = $data->activity_id; |
||||
$delete = $data->delete(); |
||||
if($delete){ |
||||
$this->deleteRelative($activityId, $userId); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data user to activity gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'user to activity gantt Project successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to activity gantt Project failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
private function deleteRelative($id, $userId) |
||||
{ |
||||
$dataRa = ReportActivity::where("activity_id", $id)->where("user_id", $userId)->get(); |
||||
foreach ($dataRa as $ra) { |
||||
$image = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get(); |
||||
foreach ($image as $value) { |
||||
if(file_exists($this->pathImage.$value->image)){ |
||||
unlink($this->pathImage.$value->image); |
||||
} |
||||
} |
||||
|
||||
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete(); |
||||
} |
||||
ReportActivity::where("activity_id", $id)->where("user_id", $userId)->delete(); |
||||
} |
||||
|
||||
public function edit($id){ |
||||
if(!$id || (int) $id < 0 || $id==""){ |
||||
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
$result = UserToActivity::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = UserToActivity::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list user to activity gantt, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function datatables(Request $request){ |
||||
$id_activity = $request->query('idact'); |
||||
$data = UserToActivity::select("assign_hr_to_activity.id as id", "u.name as user_name", "mrp.name as role_name") |
||||
->join("m_role_proyek as mrp", "mrp.id", "=", "assign_hr_to_activity.role_proyek_id") |
||||
->join("m_users as u", "u.id", "=", "assign_hr_to_activity.user_id") |
||||
->where('assign_hr_to_activity.activity_id', $id_activity) |
||||
->get(); |
||||
return Datatables::of($data) |
||||
->addIndexColumn() |
||||
->addColumn('action', function($row){ |
||||
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="delete btn btn-danger btn-sm btn-hr-delete"><i class="fa fa-trash"></i></a>'; |
||||
return $actionBtn; |
||||
}) |
||||
->rawColumns(['action'])->make(true); |
||||
} |
||||
} |
@ -0,0 +1,176 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\UserToProyek; |
||||
use App\Models\UserToActivity; |
||||
use App\Models\ReportActivity; |
||||
use App\Models\Image; |
||||
|
||||
class UserToProyekController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'proyek_id' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = UserToProyek::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'assign hr to proyek successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'assign hr to proyek 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 = UserToProyek::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data assign hr to proyek, 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 = UserToProyek::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data assign hr to proyek successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = UserToProyek::find($id); |
||||
if($data){ |
||||
$userId = $data->user_id; |
||||
$proyekId = $data->proyek_id; |
||||
$delete = $data->delete(); |
||||
if($delete){ |
||||
$this->deleteRelative($proyekId, $userId); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data assign hr to proyek successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
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(); |
||||
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(); |
||||
} |
||||
ReportActivity::where("activity_id", $value->activity_id)->where("user_id", $value->user_id)->delete(); |
||||
} |
||||
UserToActivity::where("proyek_id", $proyekId)->where("user_id", $userId)->delete(); |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_proyek'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = UserToProyek::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list assign hr to proyek, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function select(Request $request){ |
||||
|
||||
$search = $request->query('search'); |
||||
|
||||
$idProyek = (int)$request->query('idProyek'); |
||||
$idActivity = (int)$request->query('idact'); |
||||
|
||||
$include = []; |
||||
|
||||
if($idActivity && $idActivity > 0){ |
||||
$dataF = UserToActivity::select("user_id")->where("activity_id", $idActivity)->get(); |
||||
foreach($dataF as $val){ |
||||
$include[] = $val->user_id; |
||||
} |
||||
} |
||||
|
||||
if($search && !empty($search)){ |
||||
$data = UserToProyek::select("m_users.id as id", "m_users.name as name")->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id') |
||||
->where("assign_hr_to_proyek.proyek_id", $idProyek)->where("m_users.name", 'like', '%'.$search.'%')->whereIn("m_users.id", $include)->get(); |
||||
}else{ |
||||
$data = UserToProyek::select("m_users.id as id", "m_users.name as name")->where("assign_hr_to_proyek.proyek_id", $idProyek)->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id')->whereIn("m_users.id", $include)->get(); |
||||
} |
||||
|
||||
if($data instanceof \Illuminate\Database\Eloquent\Collection){ |
||||
$pm = array( |
||||
"id"=>$this->currentId, |
||||
"name"=> "Project Manager" |
||||
); |
||||
$data->push($pm); |
||||
} |
||||
|
||||
return response()->json($data); |
||||
} |
||||
} |
@ -0,0 +1,97 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\UserShift; |
||||
|
||||
class UserToShiftController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'from_date' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = UserShift::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'User shift assignment successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'User shift assignment failed created','code'=>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 = UserShift::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'Data User Shift not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'User Shift successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'User Shift failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = UserShift::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data User shift assignment not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'User shift assignment successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'User shift assignment failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 't_users_shift'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = UserShift::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list tools request, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,167 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\UserToVersionGantt; |
||||
|
||||
class UserToVersionGanttController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'version_gantt_id' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = UserToVersionGantt::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'user to version gantt Project successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to version gantt Project failed created','code'=>400]); |
||||
} |
||||
} |
||||
|
||||
public function addMultiple(Request $request){ |
||||
$users_id = $request->user_id; |
||||
|
||||
$data = UserToVersionGantt::where("version_gantt_id", $request->version_gantt_id); |
||||
|
||||
if($data){ |
||||
$data->delete(); |
||||
} |
||||
|
||||
if(is_array($users_id) && count($users_id) > 0){ |
||||
$countRes = 0; |
||||
foreach($users_id as $item){ |
||||
|
||||
$dataInsert = array( |
||||
"user_id" => $item, |
||||
"version_gantt_id" => $request->version_gantt_id, |
||||
"created_by" => $this->currentName |
||||
); |
||||
|
||||
$result = UserToVersionGantt::create($dataInsert); |
||||
|
||||
if($result){ |
||||
$countRes++; |
||||
}else{ |
||||
$countRes--; |
||||
} |
||||
} |
||||
if($countRes > 0){ |
||||
return response()->json(['status'=>'success' ,'message'=>'user to version gantt Project successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'success' ,'message'=>'user to version gantt Project failed created','code'=>400]); |
||||
} |
||||
}else{ |
||||
return response()->json(['status'=>'success' ,'message'=>'user to version gantt Project successfull created','code'=>200]); |
||||
} |
||||
|
||||
} |
||||
|
||||
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 = UserToVersionGantt::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data user to version gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'user to version gantt Project successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to version gantt Project failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = UserToVersionGantt::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data user to version gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'user to version gantt Project successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'user to version gantt Project 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 = UserToVersionGantt::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data tools resource, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'user_to_version_gantt'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = UserToVersionGantt::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list user to version gantt, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function getByUserGantt($gantt_id) |
||||
{ |
||||
$user_id = $this->currentId; |
||||
if($user_id > 0){ |
||||
$cekData = UserToVersionGantt::where("version_gantt_id", $gantt_id)->where("user_id", $user_id)->count(); |
||||
if($cekData <=0){ |
||||
$data = array( |
||||
"status"=>"not have" |
||||
); |
||||
}else{ |
||||
$data = UserToVersionGantt::where("version_gantt_id", $gantt_id)->where("user_id", $user_id)->first(); |
||||
} |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list user to version gantt, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,112 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\VersionGantt; |
||||
|
||||
class VersionGanttController extends Controller |
||||
{ |
||||
//insert data |
||||
public function add(Request $request){ |
||||
//validasi |
||||
$this->validate($request, [ |
||||
'name_version' => 'required', |
||||
'description' => 'required', |
||||
'proyek_id' => 'required' |
||||
]); |
||||
$data = $request->all(); |
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = VersionGantt::create($data); |
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'version gantt Project successfull created','code'=>200]); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'version gantt Project failed created','code'=>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 = VersionGantt::find($id); |
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'version gantt Project successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'version gantt Project failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = VersionGantt::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'version gantt Project successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'version gantt Project 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 = VersionGantt::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data version gantt, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_version_gantt'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = VersionGantt::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list version gantt, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,118 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Waypoint; |
||||
|
||||
class WaypointController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'user_id' => 'required', |
||||
'lat' => 'required', |
||||
'lon' => 'required', |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
|
||||
$result = Waypoint::create($data); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'add waypoint successfully!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'add waypoint 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 = Waypoint::find($id); |
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get data waypoint, 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 = Waypoint::find($id); |
||||
|
||||
if($data){ |
||||
$result = $data->update($request->all()); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data waypoint not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($result){ |
||||
return response()->json(['status'=>'success','message'=>'data waypoint successfully updated!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data waypoint failed updated!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function delete($id) |
||||
{ |
||||
$data = Waypoint::find($id); |
||||
|
||||
if($data){ |
||||
$delete = $data->delete(); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data waypoint not found!','code'=>400], 400); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($delete){ |
||||
return response()->json(['status'=>'success','message'=>'data waypoint successfully deleted!','code'=>200], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'data waypoint failed deleted!','code'=>400], 400); |
||||
} |
||||
} |
||||
|
||||
public function search(Request $request) |
||||
{ |
||||
// payload same like in goland API oke |
||||
$payload = $request->all(); |
||||
// second parameter is table name |
||||
$dataBuilder = $this->setUpPayload($payload, 'm_waypoint'); |
||||
// builder for get data |
||||
$builder = $dataBuilder['builder']; |
||||
// builder for count data |
||||
$countBuilder = $dataBuilder['count']; |
||||
// execute builder |
||||
$dataGet = $builder->get(); |
||||
// execute count builder |
||||
$totalRecord = $countBuilder->count(); |
||||
// dd($totalRecord); |
||||
// send response about the result |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||
} |
||||
|
||||
public function list() |
||||
{ |
||||
$data = Waypoint::all(); |
||||
$countData = $data->count(); |
||||
|
||||
if($data){ |
||||
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||
}else{ |
||||
return response()->json(['status'=>'failed','message'=>'failed get list waypoint, please try again later!','code'=>400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Closure; |
||||
use Illuminate\Contracts\Auth\Factory as Auth; |
||||
|
||||
class Authenticate |
||||
{ |
||||
/** |
||||
* The authentication guard factory instance. |
||||
* |
||||
* @var \Illuminate\Contracts\Auth\Factory |
||||
*/ |
||||
protected $auth; |
||||
|
||||
/** |
||||
* Create a new middleware instance. |
||||
* |
||||
* @param \Illuminate\Contracts\Auth\Factory $auth |
||||
* @return void |
||||
*/ |
||||
public function __construct(Auth $auth) |
||||
{ |
||||
$this->auth = $auth; |
||||
} |
||||
|
||||
/** |
||||
* Handle an incoming request. |
||||
* |
||||
* @param \Illuminate\Http\Request $request |
||||
* @param \Closure $next |
||||
* @param string|null $guard |
||||
* @return mixed |
||||
*/ |
||||
public function handle($request, Closure $next, $guard = null) |
||||
{ |
||||
if ($this->auth->guard($guard)->guest()) { |
||||
return response('Unauthorized Request\n', 401); |
||||
} |
||||
|
||||
return $next($request); |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Closure; |
||||
|
||||
class CorsMiddleware |
||||
{ |
||||
/** |
||||
* Handle an incoming request. |
||||
* |
||||
* @param \Illuminate\Http\Request $request |
||||
* @param \Closure $next |
||||
* @return mixed |
||||
*/ |
||||
public function handle($request, Closure $next) |
||||
{ |
||||
$headers = [ |
||||
'Access-Control-Allow-Origin' => '*', |
||||
'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE', |
||||
'Access-Control-Allow-Credentials' => 'true', |
||||
'Access-Control-Max-Age' => '86400', |
||||
'Access-Control-Allow-Headers' => 'Content-Type, Accept, Authorization, X-Requested-With, Application' |
||||
]; |
||||
|
||||
if ($request->isMethod('OPTIONS')) |
||||
{ |
||||
return response()->json('{"method":"OPTIONS"}', 200, $headers); |
||||
} |
||||
|
||||
$response = $next($request); |
||||
foreach($headers as $key => $value) |
||||
{ |
||||
$response->headers->set($key, $value); |
||||
} |
||||
|
||||
return $response; |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Closure; |
||||
|
||||
class ExampleMiddleware |
||||
{ |
||||
/** |
||||
* Handle an incoming request. |
||||
* |
||||
* @param \Illuminate\Http\Request $request |
||||
* @param \Closure $next |
||||
* @return mixed |
||||
*/ |
||||
public function handle($request, Closure $next) |
||||
{ |
||||
return $next($request); |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
<?php |
||||
|
||||
namespace App\Jobs; |
||||
|
||||
class ExampleJob extends Job |
||||
{ |
||||
/** |
||||
* Create a new job instance. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
// |
||||
} |
||||
|
||||
/** |
||||
* Execute the job. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle() |
||||
{ |
||||
// |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
<?php |
||||
|
||||
namespace App\Jobs; |
||||
|
||||
use Illuminate\Bus\Queueable; |
||||
use Illuminate\Contracts\Queue\ShouldQueue; |
||||
use Illuminate\Queue\InteractsWithQueue; |
||||
use Illuminate\Queue\SerializesModels; |
||||
|
||||
abstract class Job implements ShouldQueue |
||||
{ |
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Queueable Jobs |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| This job base class provides a central location to place any logic that |
||||
| is shared across all of your jobs. The trait included with the class |
||||
| provides access to the "queueOn" and "delay" queue helper methods. |
||||
| |
||||
*/ |
||||
|
||||
use InteractsWithQueue, Queueable, SerializesModels; |
||||
} |
@ -0,0 +1,46 @@
|
||||
<?php |
||||
|
||||
namespace App\Libs\CustomHash; |
||||
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract; |
||||
|
||||
class CustomHasher implements HasherContract { |
||||
|
||||
/** |
||||
* Hash the given value. |
||||
* |
||||
* @param string $value |
||||
* @return array $options |
||||
* @return string |
||||
*/ |
||||
public function make($value, array $options = array()) { |
||||
//I have custom encoding / encryption here// |
||||
//Define your custom hashing logic here// |
||||
return base64_encode(base64_encode($value)); |
||||
} |
||||
|
||||
/** |
||||
* Check the given plain value against a hash. |
||||
* |
||||
* @param string $value |
||||
* @param string $hashedValue |
||||
* @param array $options |
||||
* @return bool |
||||
*/ |
||||
public function check($value, $hashedValue, array $options = array()) { |
||||
return $this->make($value) === $hashedValue; |
||||
} |
||||
|
||||
/** |
||||
* Check if the given hash has been hashed using the given options. |
||||
* |
||||
* @param string $hashedValue |
||||
* @param array $options |
||||
* @return bool |
||||
*/ |
||||
public function needsRehash($hashedValue, array $options = array()) { |
||||
return false; |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,31 @@
|
||||
<?php |
||||
|
||||
namespace App\Listeners; |
||||
|
||||
use App\Events\ExampleEvent; |
||||
use Illuminate\Contracts\Queue\ShouldQueue; |
||||
use Illuminate\Queue\InteractsWithQueue; |
||||
|
||||
class ExampleListener |
||||
{ |
||||
/** |
||||
* Create the event listener. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
// |
||||
} |
||||
|
||||
/** |
||||
* Handle the event. |
||||
* |
||||
* @param \App\Events\ExampleEvent $event |
||||
* @return void |
||||
*/ |
||||
public function handle(ExampleEvent $event) |
||||
{ |
||||
// |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Absent extends Model |
||||
{ |
||||
protected $table = 't_absensi'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'user_id', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,23 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Activity extends Model |
||||
{ |
||||
protected $table = 'm_activity'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'proyek_id', 'parent_id', 'kode_sortname', 'name', 'rencana_biaya', 'start_date', |
||||
'end_date', 'area_kerja', 'biaya_actual', 'persentase_bobot', 'persentase_progress', |
||||
'buffer_radius', 'duration', 'color_progress', 'jumlah_pekerjaan', 'satuan', |
||||
'description', 'priority', 'bobot_planning', 'type_activity', 'open', 'geom', |
||||
'version_gantt_id', 'budget_plan', 'biaya_material_plan', 'biaya_human_plan', 'biaya_tools_plan', |
||||
'planned_start', 'planned_end', 'satuan_id', |
||||
'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ActivityDokumen extends Model |
||||
{ |
||||
protected $table = 'm_document_activity'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'file', 'description', 'activity_id', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Alert extends Model |
||||
{ |
||||
protected $table = 'alert'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'nama', 'config_alert_id', 'keterangan', 'subproyek_id', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class AssignMaterial extends Model |
||||
{ |
||||
protected $table = 'assign_material_to_activity'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'proyek_id', 'activity_id', 'material_id', 'qty_planning', 'budget', 'plan_date','created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class AssignTools extends Model |
||||
{ |
||||
protected $table = 'assign_tools_to_activity'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'proyek_id', 'activity_id', 'tools_id', 'qty_planning', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Broadcast extends Model |
||||
{ |
||||
protected $table = 'm_broadcast'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'title_notif', 'message_notif', 'description', 'send_to_type', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,22 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ChecklistK3 extends Model |
||||
{ |
||||
protected $table = 'm_checklist_k3'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', |
||||
'description', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,22 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class CommentActivity extends Model |
||||
{ |
||||
protected $table = 'm_comment_activity'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'activity_id', |
||||
'comment', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ConfigAlert extends Model |
||||
{ |
||||
protected $table = 'config_alert'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'nama', 'keterangan', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class ConfigAlertUser extends Model |
||||
{ |
||||
protected $table = 'config_alert_to_user'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'user_id', 'config_alert_id', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,22 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Divisi extends Model |
||||
{ |
||||
protected $table = 'm_divisi'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', |
||||
'description', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class DokumenProject extends Model |
||||
{ |
||||
// define table |
||||
protected $table = 'document_project'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'file', 'type_dokumen', 'ref_id', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,23 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class FolderDocumentProyek extends Model |
||||
{ |
||||
protected $table = 'folder_document_proyek'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'parent_id', |
||||
'proyek_id', |
||||
'name_folder', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Holiday extends Model |
||||
{ |
||||
protected $table = 'm_holidays'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'proyek_id', 'duration', 'version_gantt_id', 'date', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,37 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class HumanResource extends Model |
||||
{ |
||||
protected $table = 'm_users'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'role_id', |
||||
'username', |
||||
'password', |
||||
'session_login', |
||||
'name', |
||||
'phone_number', |
||||
'email', |
||||
'address', |
||||
'fcm_token', |
||||
'gender', |
||||
'birth_place', |
||||
'birth_date', |
||||
'blood_type', |
||||
'ktp_number', |
||||
'employee_type', |
||||
'status_resource', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by', |
||||
'divisi_id' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Image extends Model |
||||
{ |
||||
protected $table = 'm_image'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'image', 'ref_id', 'category', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Link extends Model |
||||
{ |
||||
protected $table = 'm_activity_link'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
's_activity_id', 't_activity_id', 'type_link', 'code_link', 'version_gantt_id', 'lag', |
||||
'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class MaterialProject extends Model |
||||
{ |
||||
// define table |
||||
protected $table = 'material_to_proyek'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'material_resource_id', 'proyek_id', 'subproyek_id', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class MaterialResource extends Model |
||||
{ |
||||
protected $table = 'm_material_resource'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', 'uom', 'unit_price', 'description', 'status', 'qty', 'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Menu extends Model |
||||
{ |
||||
protected $table = 'm_menu'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'parent_id', 'icon', 'name', 'alias_name', 'url', 'sequence', |
||||
'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
@ -0,0 +1,20 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class OfficeHours extends Model |
||||
{ |
||||
protected $table = 'm_office_hours'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'proyek_id', 'monday_start', 'monday_end', 'tuesday_start', 'tuesday_end', |
||||
'wednesday_start', 'wednesday_end', 'thursday_start', 'thursday_end', |
||||
'friday_start', 'friday_end', 'saturday_start', 'saturday_end', 'sunday_start', 'sunday_end', |
||||
'created_at', 'created_by', 'updated_at', 'updated_by' |
||||
]; |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue