Browse Source

migration route & progress DasboardBoDController

master
wahyuun 1 year ago
commit
1721dda1a0
  1. 18
      .editorconfig
  2. 58
      .env.example
  3. 11
      .gitattributes
  4. 18
      .gitignore
  5. 49
      Dockerfile
  6. 66
      README.md
  7. 32
      app/Console/Kernel.php
  8. 50
      app/Exceptions/Handler.php
  9. 955
      app/Helpers/MasterFunctionsHelper.php
  10. 11
      app/Http/Controllers/API/AbsentController.php
  11. 11
      app/Http/Controllers/API/ActivityController.php
  12. 11
      app/Http/Controllers/API/ActivityDokumenController.php
  13. 11
      app/Http/Controllers/API/AssignMaterialController.php
  14. 11
      app/Http/Controllers/API/AssignToolsController.php
  15. 95
      app/Http/Controllers/API/AuthController.php
  16. 11
      app/Http/Controllers/API/ChecklistK3Controller.php
  17. 11
      app/Http/Controllers/API/CommentActivityController.php
  18. 11
      app/Http/Controllers/API/ConfigAlertController.php
  19. 11
      app/Http/Controllers/API/ConfigAlertUserController.php
  20. 11
      app/Http/Controllers/API/ControlMonitoringController.php
  21. 350
      app/Http/Controllers/API/DashboardBoDController.php
  22. 11
      app/Http/Controllers/API/DivisiController.php
  23. 11
      app/Http/Controllers/API/FolderDocumentProyekController.php
  24. 11
      app/Http/Controllers/API/HierarchyFtthController.php
  25. 11
      app/Http/Controllers/API/HolidayController.php
  26. 11
      app/Http/Controllers/API/HumanResourceController.php
  27. 11
      app/Http/Controllers/API/ImageController.php
  28. 11
      app/Http/Controllers/API/LinkController.php
  29. 11
      app/Http/Controllers/API/MapMonitoringController.php
  30. 11
      app/Http/Controllers/API/MaterialProjectController.php
  31. 11
      app/Http/Controllers/API/MaterialResourceController.php
  32. 158
      app/Http/Controllers/API/MenuController.php
  33. 11
      app/Http/Controllers/API/OfficeHoursController.php
  34. 11
      app/Http/Controllers/API/PanicButtonController.php
  35. 11
      app/Http/Controllers/API/PresenceController.php
  36. 11
      app/Http/Controllers/API/ProjectApprovalController.php
  37. 11
      app/Http/Controllers/API/ProjectCharterController.php
  38. 11
      app/Http/Controllers/API/ProjectCommentController.php
  39. 11
      app/Http/Controllers/API/ProjectController.php
  40. 11
      app/Http/Controllers/API/ProjectDokumenController.php
  41. 11
      app/Http/Controllers/API/ProjectMileStoneController.php
  42. 11
      app/Http/Controllers/API/ProjectParticipantsController.php
  43. 11
      app/Http/Controllers/API/ProjectPhaseController.php
  44. 11
      app/Http/Controllers/API/ProjectRoleController.php
  45. 11
      app/Http/Controllers/API/ProjectToChecklistK3Controller.php
  46. 11
      app/Http/Controllers/API/ProjectTypeController.php
  47. 11
      app/Http/Controllers/API/RateSallaryController.php
  48. 11
      app/Http/Controllers/API/ReportActivityController.php
  49. 11
      app/Http/Controllers/API/ReportActivityMaterialController.php
  50. 11
      app/Http/Controllers/API/ReportK3Controller.php
  51. 11
      app/Http/Controllers/API/ReportK3DetailController.php
  52. 11
      app/Http/Controllers/API/RequestMaterialController.php
  53. 11
      app/Http/Controllers/API/RoleController.php
  54. 93
      app/Http/Controllers/API/RoleMenuController.php
  55. 11
      app/Http/Controllers/API/SatuanController.php
  56. 11
      app/Http/Controllers/API/ShiftController.php
  57. 11
      app/Http/Controllers/API/ShowHideColumnController.php
  58. 11
      app/Http/Controllers/API/TemplateGanttController.php
  59. 11
      app/Http/Controllers/API/ToolsProjectController.php
  60. 11
      app/Http/Controllers/API/ToolsRequestController.php
  61. 11
      app/Http/Controllers/API/ToolsResourceController.php
  62. 11
      app/Http/Controllers/API/UserMonthlyShiftController.php
  63. 11
      app/Http/Controllers/API/UserProyekController.php
  64. 11
      app/Http/Controllers/API/UserToActivityController.php
  65. 11
      app/Http/Controllers/API/UserToProyekController.php
  66. 11
      app/Http/Controllers/API/UserToShiftController.php
  67. 11
      app/Http/Controllers/API/UserToVersionGanttController.php
  68. 11
      app/Http/Controllers/API/VersionGanttController.php
  69. 11
      app/Http/Controllers/API/WaypointController.php
  70. 312
      app/Http/Controllers/Controller.php
  71. 68
      app/Http/Kernel.php
  72. 21
      app/Http/Middleware/Authenticate.php
  73. 38
      app/Http/Middleware/CorsMiddleware.php
  74. 17
      app/Http/Middleware/EncryptCookies.php
  75. 17
      app/Http/Middleware/PreventRequestsDuringMaintenance.php
  76. 32
      app/Http/Middleware/RedirectIfAuthenticated.php
  77. 19
      app/Http/Middleware/TrimStrings.php
  78. 20
      app/Http/Middleware/TrustHosts.php
  79. 28
      app/Http/Middleware/TrustProxies.php
  80. 22
      app/Http/Middleware/ValidateSignature.php
  81. 17
      app/Http/Middleware/VerifyCsrfToken.php
  82. 13
      app/Models/Absent.php
  83. 233
      app/Models/Activity.php
  84. 17
      app/Models/ActivityDokumen.php
  85. 19
      app/Models/ActivityProgressLog.php
  86. 17
      app/Models/Alert.php
  87. 44
      app/Models/AssignMaterial.php
  88. 17
      app/Models/AssignTools.php
  89. 17
      app/Models/Broadcast.php
  90. 22
      app/Models/ChecklistK3.php
  91. 22
      app/Models/CommentActivity.php
  92. 17
      app/Models/ConfigAlert.php
  93. 17
      app/Models/ConfigAlertUser.php
  94. 41
      app/Models/Divisi.php
  95. 17
      app/Models/DokumenProject.php
  96. 23
      app/Models/FolderDocumentProyek.php
  97. 10
      app/Models/GanttColumnByType.php
  98. 28
      app/Models/HierarchyFtth.php
  99. 17
      app/Models/Holiday.php
  100. 38
      app/Models/HumanResource.php
  101. Some files were not shown because too many files have changed in this diff Show More

18
.editorconfig

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

58
.env.example

@ -0,0 +1,58 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=adw
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

11
.gitattributes vendored

@ -0,0 +1,11 @@
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

18
.gitignore vendored

@ -0,0 +1,18 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode

49
Dockerfile

@ -0,0 +1,49 @@
FROM php:7.4-fpm-alpine
RUN apk add --update libzip-dev curl-dev &&\
apk del gcc g++
RUN apk add --no-cache \
zlib-dev \
icu-dev \
libpng-dev \
oniguruma-dev \
libpq-dev \
libpng-dev \
libzip-dev \
zip \
vim \
unzip \
git \
curl
RUN rm -rf /var/cache/apk/*
RUN docker-php-ext-install \
curl \
mbstring \
intl \
pdo \
pdo_pgsql \
pgsql \
tokenizer
#Install Extensions
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www/html
COPY . .
RUN chmod +x artisan
RUN composer install --ignore-platform-reqs --prefer-dist --no-scripts --no-progress --no-interaction --no-dev --no-autoloader
RUN composer dump-autoload --optimize
RUN chown -R www-data:www-data .
WORKDIR /home/www-data
USER www-data

66
README.md

@ -0,0 +1,66 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

32
app/Console/Kernel.php

@ -0,0 +1,32 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

50
app/Exceptions/Handler.php

@ -0,0 +1,50 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

955
app/Helpers/MasterFunctionsHelper.php

@ -0,0 +1,955 @@
<?php
namespace App\Helpers;
use App\Models\Activity;
use App\Models\Project;
use App\Models\VersionGantt;
use App\Models\HierarchyFtth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class MasterFunctionsHelper
{
public static function curlReq($url, $token = "")
{
if (!$token)
$token = config('api.adw_token');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$headers = [
'Authorization: ' . $token
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w'));
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output);
}
public function getLatestGantt($id)
{
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id");
if (!$maxGanttId) {
$data = array(
"proyek_id" => $id
);
} else {
$data = array(
"last_gantt_id" => $maxGanttId,
"proyek_id" => $id
);
}
return $data;
}
// dipake di dashboard project & bod
public function getSCurve($request)
{
$allGantt = [];
if (!is_int($request)) {
$dataPayload = $request->all();
if (isset($dataPayload['gantt_id'])) {
$allGantt[] = $dataPayload['gantt_id'];
} else {
$allGantt[] = MasterFunctionsHelper::getLatestGantt($dataPayload['project_id']);
}
} else {
$allGantt[] = MasterFunctionsHelper::getLatestGantt($request);
}
foreach ($allGantt as $gantt) {
if (!isset($gantt['last_gantt_id'])) {
$ganttId = $gantt;
} else {
$ganttId = $gantt['last_gantt_id'];
}
$gantt = VersionGantt::find($ganttId)->toArray();
// foreach ($gantt as $key => $value) {
// Log::info('gantt '.$value.' index '.$key);
// }
if (isset($gantt['calculation_type'])) {
if ($gantt['calculation_type'] == 'simple') {
// to do
return MasterFunctionsHelper::calculateProgressBasedOnSimple($gantt);
} else {
return MasterFunctionsHelper::calculateProgressBasedOnReportMaterial($gantt);
}
}
}
}
public function getLinearSCurve($request)
{
$ftths = HierarchyFtth::where('project_id', $request->project_id)->get();
$ttlProgress = 0;
$ttlPlanning = 0;
foreach ($ftths as $ftth) {
$progress = VersionGantt::where('hierarchy_ftth_id', $ftth->id)->sum('progress');
$planning = VersionGantt::where('hierarchy_ftth_id', $ftth->id)->sum('bobot');
$ttlProgress += $progress;
$ttlPlanning += $planning;
}
$minDate = Project::select('mulai_proyek')->where('id', $request->project_id)->first();
$maxDate = Project::select('akhir_proyek')->where('id', $request->project_id)->first();
$begin = new \DateTime($minDate->mulai_proyek . ' Monday');
$end = new \DateTime($maxDate->akhir_proyek . ' Friday');
$interval = new \DateInterval('P7D');
$period = new \DatePeriod($begin, $interval, $end);
$dates = iterator_to_array($period);
$count = count($dates);
$avgProgress = $ttlProgress / $ttlPlanning / $count * 100;
$avgPlanning = $ttlPlanning / $ttlPlanning / $count * 100;
$progressData = [];
$planningData = [];
$dates = [];
$tempProgress = 0;
$tempPlanning = 0;
array_push($progressData, round($tempProgress, 2));
array_push($planningData, round($tempPlanning, 2));
foreach ($period as $p) {
$tempProgress += $avgProgress;
$tempPlanning += $avgPlanning;
array_push($progressData, round($tempProgress, 2));
array_push($planningData, round($tempPlanning, 2));
array_push($dates, $p->format("Y-m-d"));
}
$dataResponse = array(
"percentagePlan" => $planningData,
"percentageReal" => $progressData,
"date" => $dates,
);
$dataFinal[] = array(
"data" => $dataResponse,
);
return $dataFinal;
}
public function calculateProgressBasedOnReportMaterial($keyGantt)
{
DB::enableQueryLog();
$dataFinal = [];
$dataPayload = [];
$dataPayload['period'] = 'week';
$totalACWP = 0;
$totalBCWP = 0;
$tempPercentage = [];
$dataProject = Project::find($keyGantt['proyek_id']);
$dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->first();
if (isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek) {
$dataPayload['end_date'] = $dataProject->akhir_proyek;
}
if ($dataHeader) {
$totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya");
} else {
$totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya");
}
if (!Activity::where("version_gantt_id", $keyGantt['id'])->first())
return $dataFinal;
$alreadyHasReport = DB::table('report_activity_material as a')
->select('a.id')
->join('m_activity as b', 'b.id', '=', 'a.activity_id')
->where('b.version_gantt_id', '=', $keyGantt['id'])
->exists();
// note : delete this
// if(!$alreadyHasReport)
// return $dataFinal;
$minDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('start_date')->first();
$begin = new \DateTime($minDate . ' Monday');
$begin->modify('last Monday');
if (isset($dataPayload['end_date'])) {
$maxDate = $dataPayload['end_date'];
$end = new \DateTime($maxDate . ' Friday');
$end->modify('next Friday');
$end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged
$interval = new \DateInterval('P7D');
} else {
$maxDate = DB::table('assign_material_to_activity as ama')
->where("ama.proyek_id", $keyGantt['proyek_id'])
->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['id'])
->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's
$end = new \DateTime($maxDate . ' Friday');
$end->modify('next Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D');
}
$period = new \DatePeriod($begin, $interval, $end);
$arr_ActualM = [];
$tempDate = [];
$tempPercentagePlan = [];
$tempPercentagePlanWhr = [];
$tempPercentageReal = [];
$tempTtlPercentPlan = 0;
$tempTtlPercentActual = 0;
$currentACWP = 0;
$currentBCWP = 0;
foreach ($period as $dt) {
$minSevenDays = new \Datetime($dt->format("Y-m-d"));
$minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d");
$tempDate[] = array($dt->format("Y-m-d"));
// $dataPlanM = DB::table('assign_material_to_activity as ama')
// ->select('ama.activity_id', 'ama.qty_planning', 'ama.plan_date', 'ama.start_activity', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
// ->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
// ->where('ama.proyek_id', '=', $keyGantt['proyek_id'])
// ->where('a.version_gantt_id', '=', $keyGantt['id'])
// ->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d"))
// ->whereDate('ama.plan_date', '>', $minSevenDays)
// ->get();
$activities = DB::table('m_activity AS a')
->join('assign_material_to_activity AS amta', 'amta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->where('a.version_gantt_id', $keyGantt['id'])
->whereDate('amta.plan_date', '<=', $dt->format("Y-m-d"))
->whereDate('amta.plan_date', '>', $minSevenDays)
->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id');
$dataPlanM = DB::table('m_activity AS a')
->join('assign_hr_to_activity AS ahta', 'ahta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->where('a.version_gantt_id', $keyGantt['id'])
->whereDate('a.start_date', '<=', $dt->format("Y-m-d"))
->whereDate('a.start_date', '>', $minSevenDays)
->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id')
->union($activities)
->get();
$dataActualM = DB::table('report_activity_material as ram')
->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
->join('m_activity as a', 'a.id', '=', 'ram.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['id'])
->where('a.proyek_id', '=', $keyGantt['proyek_id'])
->whereDate('ram.report_date', '<=', $dt->format("Y-m-d"))
->whereDate('ram.report_date', '>', $minSevenDays)
->get();
$dataTempPlan = [];
$x = 0;
$sumPercentagePlan = 0;
$totalACWP = isset($totalACWP) ? $totalACWP : 0;
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
foreach ($dataPlanM as $keyPlanM) {
$sumVolPlan = DB::table(function ($query) use ($keyGantt) {
$query->select('a.*')
->from('m_activity AS a')
->join('assign_material_to_activity as amta', 'amta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->where('a.version_gantt_id', $keyGantt['id'])
->unionAll(function ($query) use ($keyGantt) {
$query->select('a.*')
->from('m_activity AS a')
->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->where('a.version_gantt_id', $keyGantt['id']);
})
->orderBy('id', 'asc');
}, 'subquery')
->sum('bobot_planning');
$dataTempPlan[$x]['activity_id'] = $keyPlanM->id;
$dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning;
$dataTempPlan[$x]['ttl_plan'] = $sumVolPlan;
$dataTempPlan[$x]['biaya_actual'] = $keyPlanM->biaya_actual;
$dataTempPlan[$x]['duration'] = $keyPlanM->duration;
$dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress;
try {
$dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning;
$sumPercentagePlan += $keyPlanM->bobot_planning;
if (isset($keyPlanM->duration) && $keyPlanM->duration > 0)
$totalBCWP += (((($keyPlanM->persentase_progress * $keyPlanM->bobot_planning) / 100) / $keyPlanM->duration) * $totalRencanaBudget) / 100;
else
$totalBCWP = 0;
$dataTempPlan[$x]['totalBCWP'] = $totalBCWP;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$x++;
}
$w = 0;
$dataTempReport = [];
$sumPercentageActual = 0;
foreach ($dataActualM as $keyActualM) {
$sumVolActual = DB::table('assign_material_to_activity')
->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan'))
->where('activity_id', '=', $keyActualM->activity_id)
->groupBy('activity_id')
->first();
$sumReportActual = DB::table('report_activity_material')
->where('activity_id', $keyActualM->activity_id)
->sum('qty');
$reportCount = DB::table('report_activity_material')->where('activity_id', '=', $keyActualM->activity_id)->count();
$dataTempReport[$w]['activity_id'] = $keyActualM->activity_id;
$dataTempReport[$w]['qty'] = $keyActualM->qty;
$dataTempReport[$w]['report_date'] = $keyActualM->report_date;
$dataTempReport[$w]['bobot_planning'] = $keyActualM->bobot_planning;
$dataTempReport[$w]['ttl_plan'] = $sumVolActual->ttl_qty_plan;
$dataTempReport[$w]['biaya_actual'] = $keyActualM->biaya_actual;
$dataTempReport[$w]['duration'] = $keyActualM->duration;
$dataTempReport[$w]['persentase_progress'] = $keyActualM->persentase_progress;
try {
// assign_material_to_activity
$checkStatusActivity = DB::table('assign_material_to_activity')
->select('activity_id', 'status_activity')
->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC')
->first();
$dataTempReport[$w]['percentage'] = ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning;
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
if ($checkStatusActivity->status_activity == 'done') {
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else {
if ($keyActualM->qty / $sumVolActual->ttl_qty_plan >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) {
$sumPercentageActual += (($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning) * (95 / 100);
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else {
$sumPercentageActual += ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
}
}
// }else {
// if($checkStatusActivity->status_activity == 'done'){
// $sumPercentageActual+=($keyActualM->qty/$keyActualM->qty)*$keyActualM->bobot_planning;
// }else{
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// }
// }
$totalACWP += $keyActualM->biaya_actual / $keyActualM->duration;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$dataTempReport[$w]['totalacwp'] = $totalACWP;
$w++;
}
$arr_ActualM[] = array(
'date' => $dt->format("Y-m-d"),
'percentPlan' => $sumPercentagePlan,
'percentActual' => $sumPercentageActual,
'plan' => $dataTempPlan,
'actual' => $dataTempReport,
);
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual;
// if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= $keyGantt['progress'];){
// if($tempTtlPercentActual >= 100)
// $tempTtlPercentActual = 100;
// if($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100;
// if($tempTtlPercentActual >= $keyGantt['progress'])
// $tempTtlPercentActual = $keyGantt['progress'];
if ($tempTtlPercentPlan >= 100)
$tempTtlPercentPlan = 100;
// $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual
// }
$currentACWP += $totalACWP;
$currentBCWP += $totalBCWP;
$tempPercentage[] = array(round($tempTtlPercentPlan, 2), round($tempTtlPercentActual, 2));
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2);
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan];
$tempPercentageReal[] = round($tempTtlPercentActual, 2);
if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) {
break;
}
} else {
$tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2));
$tempPercentagePlan[] = round($sumPercentagePlan, 2);
$tempPercentageReal[] = round($sumPercentageActual, 2);
}
}
try {
if (round($totalACWP, 0) > $totalRencanaBudget) {
$estimatedCost = round($totalACWP, 0) + 0;
} else {
$estimatedCost = ($totalRencanaBudget + 0);
}
} catch (\DivisionByZeroError $e) {
return response()->json([
'message' => $e->getMessage(),
"line" => 566,
'gantt' => $keyGantt,
]);
}
$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget;
$costDeviation = $totalRencanaBudget - $estimatedCost;
if ($costDeviation > 0) {
$potential = "SAVING";
} else {
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
}
$dataResponse = array(
"date" => $tempDate,
"percentage" => $tempPercentage,
"percentagePlan" => $tempPercentagePlan,
"percentageReal" => $tempPercentageReal,
"data_details" => $arr_ActualM,
"budget_control" => array(
"current_budget" => $totalRencanaBudget,
"acwp" => round($totalACWP, 0),
"bcwp" => round($totalBCWP, 0),
"rem_to_complete" => ($totalRencanaBudget - round($totalACWP, 0)),
"add_cost_to_complete" => 0,
"estimated_at_completion" => $estimatedCost,
"cost_deviation" => $costDeviation,
"potential" => $potential,
)
);
$dataFinal[] = array(
"proyek_name" => $dataProject->nama,
"data" => $dataResponse,
"gantt" => $keyGantt
);
return $dataFinal;
}
public function calculateSCurve($projectId)
{
DB::enableQueryLog();
$dataFinal = [];
$dataPayload = [];
$dataPayload['period'] = 'week';
$totalACWP = 0;
$totalBCWP = 0;
$tempPercentage = [];
$dataProject = Project::find($projectId);
$dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $projectId)->first();
if (isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek) {
$dataPayload['end_date'] = $dataProject->akhir_proyek;
}
if ($dataHeader) {
$totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $projectId)->sum("rencana_biaya");
} else {
$totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $projectId)->sum("rencana_biaya");
}
$alreadyHasReport = DB::table('report_activity_material as a')
->select('a.id')
->join('m_activity as b', 'b.id', '=', 'a.activity_id')
->exists();
$minDate = $dataProject->mulai_proyek;
$begin = new \DateTime($minDate);
$begin->modify('last Monday');
if (isset($dataPayload['end_date'])) {
$maxDate = $dataPayload['end_date'];
$end = new \DateTime($maxDate);
$end->modify('next Friday');
$end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged
$interval = new \DateInterval('P7D');
} else {
// $maxDate = DB::table('assign_material_to_activity as ama')
// ->where("ama.proyek_id", $projectId)
// ->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
// ->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's
$maxDate = $dataProject->akhir_proyek;
$end = new \DateTime($maxDate);
$end->modify('next Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D');
}
$period = new \DatePeriod($begin, $interval, $end);
$arr_ActualM = [];
$tempDate = [];
$tempPercentagePlan = [];
$tempPercentagePlanWhr = [];
$tempPercentageReal = [];
$tempTtlPercentPlan = 0;
$tempTtlPercentActual = 0;
$currentACWP = 0;
$currentBCWP = 0;
foreach ($period as $dt) {
$minSevenDays = new \Datetime($dt->format("Y-m-d"));
$minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d");
// $dataPlanM = DB::table('assign_material_to_activity as ama')
// ->select('ama.activity_id', 'ama.qty_planning', 'ama.plan_date', 'ama.start_activity', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
// ->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
// ->where('ama.proyek_id', '=', $keyGantt['proyek_id'])
// ->where('a.version_gantt_id', '=', $keyGantt['id'])
// ->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d"))
// ->whereDate('ama.plan_date', '>', $minSevenDays)
// ->get();
$activities = DB::table('m_activity AS a')
->join('assign_material_to_activity AS amta', 'amta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->whereDate('amta.plan_date', '<=', $dt->format("Y-m-d"))
->whereDate('amta.plan_date', '>', $minSevenDays)
->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id');
$dataPlanM = DB::table('m_activity AS a')
->join('assign_hr_to_activity AS ahta', 'ahta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->whereDate('a.start_date', '<=', $dt->format("Y-m-d"))
->whereDate('a.start_date', '>', $minSevenDays)
->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id')
->union($activities)
->get();
$dataActualM = DB::table('report_activity_material as ram')
->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
->join('m_activity as a', 'a.id', '=', 'ram.activity_id')
->where('a.proyek_id', '=', $projectId)
->whereDate('ram.report_date', '<=', $dt->format("Y-m-d"))
->whereDate('ram.report_date', '>', $minSevenDays)
->get();
$dataTempPlan = [];
$x = 0;
$sumPercentagePlan = 0;
$totalACWP = isset($totalACWP) ? $totalACWP : 0;
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
foreach ($dataPlanM as $keyPlanM) {
$sumVolPlan = DB::table(function ($query) {
$query->select('a.*')
->from('m_activity AS a')
->join('assign_material_to_activity as amta', 'amta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->unionAll(function ($query) {
$query->select('a.*')
->from('m_activity AS a')
->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0);
})->orderBy('id', 'asc');
}, 'subquery')
->sum('bobot_planning');
$dataTempPlan[$x]['activity_id'] = $keyPlanM->id;
$dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning;
$dataTempPlan[$x]['ttl_plan'] = $sumVolPlan;
$dataTempPlan[$x]['biaya_actual'] = $keyPlanM->biaya_actual;
$dataTempPlan[$x]['duration'] = $keyPlanM->duration;
$dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress;
try {
$dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning;
$sumPercentagePlan += $keyPlanM->bobot_planning;
if (isset($keyPlanM->duration) && $keyPlanM->duration > 0)
$totalBCWP += (((($keyPlanM->persentase_progress * $keyPlanM->bobot_planning) / 100) / $keyPlanM->duration) * $totalRencanaBudget) / 100;
else
$totalBCWP = 0;
$dataTempPlan[$x]['totalBCWP'] = $totalBCWP;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$x++;
}
$w = 0;
$dataTempReport = [];
$sumPercentageActual = 0;
foreach ($dataActualM as $keyActualM) {
$sumVolActual = DB::table('assign_material_to_activity')
->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan'))
->where('activity_id', '=', $keyActualM->activity_id)
->groupBy('activity_id')
->first();
$sumReportActual = DB::table('report_activity_material')
->where('activity_id', $keyActualM->activity_id)
->sum('qty');
$reportCount = DB::table('report_activity_material')->where('activity_id', '=', $keyActualM->activity_id)->count();
$dataTempReport[$w]['activity_id'] = $keyActualM->activity_id;
$dataTempReport[$w]['qty'] = $keyActualM->qty;
$dataTempReport[$w]['report_date'] = $keyActualM->report_date;
$dataTempReport[$w]['bobot_planning'] = $keyActualM->bobot_planning;
$dataTempReport[$w]['ttl_plan'] = $sumVolActual->ttl_qty_plan;
$dataTempReport[$w]['biaya_actual'] = $keyActualM->biaya_actual;
$dataTempReport[$w]['duration'] = $keyActualM->duration;
$dataTempReport[$w]['persentase_progress'] = $keyActualM->persentase_progress;
try {
// assign_material_to_activity
$checkStatusActivity = DB::table('assign_material_to_activity')
->select('activity_id', 'status_activity')
->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC')
->first();
$dataTempReport[$w]['percentage'] = ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning;
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
if ($checkStatusActivity->status_activity == 'done') {
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else {
if ($keyActualM->qty / $sumVolActual->ttl_qty_plan >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) {
$sumPercentageActual += (($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning) * (95 / 100);
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else {
$sumPercentageActual += ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
}
}
// }else {
// if($checkStatusActivity->status_activity == 'done'){
// $sumPercentageActual+=($keyActualM->qty/$keyActualM->qty)*$keyActualM->bobot_planning;
// }else{
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// }
// }
$totalACWP += $keyActualM->biaya_actual / $keyActualM->duration;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$dataTempReport[$w]['totalacwp'] = $totalACWP;
$w++;
}
$arr_ActualM[] = array(
'date' => $dt->format("Y-m-d"),
'percentPlan' => $sumPercentagePlan,
'percentActual' => $sumPercentageActual,
'plan' => $dataTempPlan,
'actual' => $dataTempReport,
);
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual;
$currentACWP += $totalACWP;
$currentBCWP += $totalBCWP;
$tempPercentage[] = array(round($tempTtlPercentPlan, 2), round($tempTtlPercentActual, 2));
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2);
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan];
$tempPercentageReal[] = round($tempTtlPercentActual, 2);
} else {
$tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2));
$tempPercentagePlan[] = round($sumPercentagePlan, 2);
$tempPercentageReal[] = round($sumPercentageActual, 2);
}
$tempDate[] = array($dt->format("Y-m-d"));
}
try {
if (round($totalACWP, 0) > $totalRencanaBudget) {
$estimatedCost = round($totalACWP, 0) + 0;
} else {
$estimatedCost = ($totalRencanaBudget + 0);
}
} catch (\DivisionByZeroError $e) {
return response()->json([
'message' => $e->getMessage(),
"line" => 566,
]);
}
$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget;
$costDeviation = $totalRencanaBudget - $estimatedCost;
if ($costDeviation > 0) {
$potential = "SAVING";
} else {
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
}
$dataResponse = array(
"date" => $tempDate,
"percentage" => $tempPercentage,
"percentagePlan" => $tempPercentagePlan,
"percentageReal" => $tempPercentageReal,
"data_details" => $arr_ActualM,
"budget_control" => array(
"current_budget" => $totalRencanaBudget,
"acwp" => round($totalACWP, 0),
"bcwp" => round($totalBCWP, 0),
"rem_to_complete" => ($totalRencanaBudget - round($totalACWP, 0)),
"add_cost_to_complete" => 0,
"estimated_at_completion" => $estimatedCost,
"cost_deviation" => $costDeviation,
"potential" => $potential,
)
);
$dataFinal[] = array(
"proyek_name" => $dataProject->nama,
"data" => $dataResponse,
);
return $dataFinal;
}
public function calculateProgressBasedOnSimple($keyGantt)
{
DB::enableQueryLog();
$dataFinal = [];
$dataPayload = [];
$dataPayload['period'] = 'week';
$dataProject = Project::find($keyGantt['proyek_id']);
$dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->first();
if (isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek) {
$dataPayload['end_date'] = $dataProject->akhir_proyek;
}
if ($dataHeader) {
$totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya");
} else {
$totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya");
}
if (!Activity::where("version_gantt_id", $keyGantt['id'])->first())
return $dataFinal;
// $alreadyHasReport = DB::table('report_activity_material as a')
// ->select('a.id')
// ->join('m_activity as b', 'b.id', '=', 'a.activity_id')
// ->where('b.version_gantt_id', '=', $keyGantt['id'])
// ->exists();
// if(!$alreadyHasReport)
// return $dataFinal;
$minDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('start_date')->first();
$begin = new \DateTime($minDate . ' Monday');
if (isset($dataPayload['end_date'])) {
$maxDate = $dataPayload['end_date'];
$end = new \DateTime($maxDate);
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged
$interval = new \DateInterval('P7D');
} else {
// $maxDate = DB::table('assign_material_to_activity as ama')
// ->where("ama.proyek_id", $keyGantt['proyek_id'])
// ->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
// ->where('a.version_gantt_id', '=', $keyGantt['id'])
// ->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's
$maxDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('end_date')->first();
$end = new \DateTime($maxDate . ' Friday');
$interval = new \DateInterval('P7D');
}
$period = new \DatePeriod($begin, $interval, $end);
$arr_ActualM = [];
$tempDate = [];
$tempPercentagePlan = [];
$tempPercentagePlanWhr = [];
$tempPercentageReal = [];
$tempTtlPercentPlan = 0;
$tempTtlPercentActual = 0;
$currentACWP = 0;
$currentBCWP = 0;
foreach ($period as $dt) {
$minSevenDays = new \Datetime($dt->format("Y-m-d"));
$minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d");
$dataPlanM = DB::table('m_activity')
->select('id as activity_id', 'bobot_planning', 'start_date', 'biaya_actual', 'duration', 'persentase_progress')
// ->join('m_activity as a', 'a.id', '=', 'activity_id')
->where('proyek_id', '=', $keyGantt['proyek_id'])
->where('type_activity', '=', 'task')
->where('version_gantt_id', '=', $keyGantt['id'])
->whereDate('start_date', '<=', $dt->format("Y-m-d"))
->whereDate('start_date', '>', $minSevenDays)
->get();
$dataActualM = DB::table('m_activity as a')
->select('mapl.id as id_progress_log', 'mapl.activity_id', 'mapl.variance', 'mapl.created_at', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
->join('m_activity_progress_log as mapl', 'a.id', '=', 'mapl.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['id'])
->where('a.type_activity', '=', 'task')
->where('mapl.variance', '>', 0)
->where('a.proyek_id', '=', $keyGantt['proyek_id'])
->whereDate('mapl.created_at', '<=', $dt->format("Y-m-d"))
->whereDate('mapl.created_at', '>', $minSevenDays)
->get();
$dataTempPlan = [];
$x = 0;
$sumPercentagePlan = 0;
$totalACWP = isset($totalACWP) ? $totalACWP : 0;
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
foreach ($dataPlanM as $keyPlanM) {
$dataTempPlan[$x]['activity_id'] = $keyPlanM->activity_id;
$dataTempPlan[$x]['qty_plan'] = $keyPlanM->bobot_planning;
$dataTempPlan[$x]['plan_date'] = $keyPlanM->start_date;
$dataTempPlan[$x]['start_activity'] = $keyPlanM->start_date;
$dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning;
$dataTempPlan[$x]['ttl_plan'] = $keyPlanM->bobot_planning;
$dataTempPlan[$x]['biaya_actual'] = $keyPlanM->biaya_actual;
$dataTempPlan[$x]['duration'] = $keyPlanM->duration;
$dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress;
try {
$dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning;
$sumPercentagePlan += $keyPlanM->bobot_planning;
$totalBCWP += 0;
$dataTempPlan[$x]['totalBCWP'] = $totalBCWP;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$x++;
}
$w = 0;
$dataTempReport = [];
$sumPercentageActual = 0;
foreach ($dataActualM as $keyActualM) {
$sumVolActual = DB::table('m_activity_progress_log')
->select('id', DB::raw('SUM(variance) as ttl_percen_act'))
->where('id', '=', $keyActualM->id_progress_log)
->groupBy('id')
->first();
$dataTempReport[$w]['id_progress_log'] = $keyActualM->id_progress_log;
// $dataTempReport [$w]['qty'] = $keyActualM->qty;
$dataTempReport[$w]['report_date'] = $keyActualM->created_at;
$dataTempReport[$w]['bobot_planning'] = $keyActualM->bobot_planning;
// $dataTempReport [$w]['ttl_plan'] = $sumVolActual->ttl_percen_act ? $sumVolActual->ttl_percen_act : 0;
$dataTempReport[$w]['biaya_actual'] = $keyActualM->biaya_actual;
$dataTempReport[$w]['duration'] = $keyActualM->duration;
$dataTempReport[$w]['persentase_progress'] = $keyActualM->persentase_progress;
try {
$dataTempReport[$w]['percentage'] = $sumVolActual->ttl_percen_act ? ($sumVolActual->ttl_percen_act / 100) * $keyActualM->bobot_planning : 0;
$sumPercentageActual += $sumVolActual->ttl_percen_act ? ($sumVolActual->ttl_percen_act / 100) * $keyActualM->bobot_planning : 0;
$totalACWP += $keyActualM->biaya_actual / $keyActualM->duration;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$dataTempReport[$w]['totalacwp'] = $totalACWP;
$w++;
}
$arr_ActualM[] = array(
'date' => $dt->format("Y-m-d"),
'percentPlan' => $sumPercentagePlan,
'percentActual' => $sumPercentageActual,
'plan' => $dataTempPlan,
'actual' => $dataTempReport,
);
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual;
if ($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= 100) {
if ($tempTtlPercentActual >= 100)
$tempTtlPercentActual = 100;
if ($tempTtlPercentPlan >= 100)
$tempTtlPercentPlan = 100;
}
$currentACWP += $totalACWP;
$currentBCWP += $totalBCWP;
$tempPercentage[] = array(round($tempTtlPercentPlan, 2), round($tempTtlPercentActual, 2));
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2);
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan];
$tempPercentageReal[] = round($tempTtlPercentActual, 2);
if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) {
break;
}
} else {
$tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2));
$tempPercentagePlan[] = round($sumPercentagePlan, 2);
$tempPercentageReal[] = round($sumPercentageActual, 2);
}
$tempDate[] = array($dt->format("Y-m-d"));
}
try {
if (round($totalACWP, 0) > $totalRencanaBudget) {
$estimatedCost = round($totalACWP, 0) + 0;
} else {
$estimatedCost = ($totalRencanaBudget + 0);
}
} catch (\DivisionByZeroError $e) {
return response()->json([
'message' => $e->getMessage(),
"line" => 566,
'gantt' => $keyGantt,
]);
}
$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget;
$costDeviation = $totalRencanaBudget - $estimatedCost;
if ($costDeviation > 0) {
$potential = "SAVING";
} else {
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
}
$dataResponse = array(
"date" => $tempDate,
"percentage" => $tempPercentage,
"percentagePlan" => $tempPercentagePlan,
"percentageReal" => $tempPercentageReal,
"data_details" => $arr_ActualM,
"budget_control" => array(
"current_budget" => $totalRencanaBudget,
"acwp" => round($totalACWP, 0),
"bcwp" => round($totalBCWP, 0),
"rem_to_complete" => ($totalRencanaBudget - round($totalACWP, 0)),
"add_cost_to_complete" => 0,
"estimated_at_completion" => $estimatedCost,
"cost_deviation" => $costDeviation,
"potential" => $potential,
)
);
$dataFinal[] = array(
"proyek_name" => $dataProject->nama,
"data" => $dataResponse,
"gantt" => $keyGantt,
);
return $dataFinal;
}
}

11
app/Http/Controllers/API/AbsentController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class AbsentController extends Controller
{
//
}

11
app/Http/Controllers/API/ActivityController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ActivityController extends Controller
{
//
}

11
app/Http/Controllers/API/ActivityDokumenController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ActivityDokumenController extends Controller
{
//
}

11
app/Http/Controllers/API/AssignMaterialController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class AssignMaterialController extends Controller
{
//
}

11
app/Http/Controllers/API/AssignToolsController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class AssignToolsController extends Controller
{
//
}

95
app/Http/Controllers/API/AuthController.php

@ -0,0 +1,95 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\{User, Role};
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\{Auth, Validator};
class AuthController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request)
{
$validator = Validator::make($request->all(), [
'username' => 'required|string',
'password' => 'required|string',
'remember' => '',
'is_mobile' => ''
]);
if ($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'You must fill all the fields'], 400);
}
$validated = $validator->safe()->only(['username', 'password']);
$username = $validated['username'];
$password = $validated['password'];
$remember = $request->remember;
$is_mobile = $request->is_mobile;
$usernameCheck = false;
$passwordCheck = false;
if (User::query()->where('username', '=', $username)->exists()) :
$usernameCheck = true;
endif;
if (User::query()->where('password', '=', md5($password))->exists()) :
$passwordCheck = true;
endif;
if ($usernameCheck & $passwordCheck) {
$user = User::query()->where([
['username', '=', $username],
['password', '=', md5($password)]
])->first();
if ($is_mobile) {
$fcm_token = $request->fcm_token;
if (!$fcm_token || empty($fcm_token)) :
return response()->json(['status' => 'error', 'message' => 'FCM Token is required'], 400);
endif;
$hr = User::query()->findOrFail($user['id']);
if ($hr->exists()) {
$hr->update(["fcm_token" => $fcm_token]);
}
}
$dataRole = Role::query()->findOrFail($user['role_id']);
if ($dataRole->exists()) {
$user['role'] = $dataRole;
}
if (!$token = Auth::login($user)) {
return response()->json(['error' => 'Unauthorized'], 401);
}
$ttl = 60;
if ($remember) {
$ttl = 10080;
}
return response()->json([
'code' => 200,
'data' => array(
'data_user' => $user,
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth()->factory()->getTTL() * $ttl
)
]);
} else {
return response()->json(['code' => 201, 'message' => "username or password doesn't match"], 201);
}
}
}

11
app/Http/Controllers/API/ChecklistK3Controller.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ChecklistK3Controller extends Controller
{
//
}

11
app/Http/Controllers/API/CommentActivityController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class CommentActivityController extends Controller
{
//
}

11
app/Http/Controllers/API/ConfigAlertController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ConfigAlertController extends Controller
{
//
}

11
app/Http/Controllers/API/ConfigAlertUserController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ConfigAlertUserController extends Controller
{
//
}

11
app/Http/Controllers/API/ControlMonitoringController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ControlMonitoringController extends Controller
{
//
}

350
app/Http/Controllers/API/DashboardBoDController.php

@ -0,0 +1,350 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Helpers\MasterFunctionsHelper;
use App\Models\{Divisi, UserToVersionGantt, Project, ProjectPhase, User};
use Illuminate\Support\Collection;
class DashboardBoDController extends Controller
{
private function interpolateYear($year)
{
if ($year)
$year = '%' . $year . '%';
return $year;
}
private function curlReq($url, $token)
{
$ch = curl_init();
$headers = [
'Authorization: ' . $token
];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
if ($response === false)
$response = curl_error($ch);
curl_close($ch);
return json_decode($response);
}
private function getInvoiceIntegration($search)
{
return null;
}
// to do
public function getCompanyCashFlow($year = '%')
{
$year = $this->interpolateYear($year);
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
// we can't use eloquent's sum() method because someone decided to use varchar as datatype in rencana_biaya field
$totalBudgets = Project::query()
->selectRaw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')
->where('mulai_proyek', 'LIKE', '%' . $year . '%')
->pluck('sum')
->first();
$projects = Project::query()
->where('mulai_proyek', 'LIKE', '%' . $year . '%')
->get();
foreach ($projects as $project) {
$project->expenses = 0;
$resp = null;
if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname);
/* $resp = $project->kode_sortname; */
$cost = $resp->data->total_cost ?? 0;
$cost = substr($cost, 0, strpos($cost, "."));
$totalExpenditure += (int) $cost;
$totalInvoice += $resp->data->total_invoice_amount ?? 0;
$totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
}
}
return response()->json([
'data' => [
'total_budget' => (int) $totalBudgets ?? 0,
'total_expenditure' => $totalExpenditure,
'total_invoice' => $totalInvoice,
'total_paid_invoice' => $totalPaidInvoice,
]
], 200);
}
public function getInvoiceOutstanding($year = '%')
{
$year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'LIKE', '%' . $year . '%')
->get();
$return = [];
foreach ($projects as $project) {
$resp = null;
if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname);
array_push($return, [
'project' => $project->nama,
'project_code' => $project->kode_sortname,
'invoiced' => $resp->data->total_invoice_amount ?? 0,
'paid' => $resp->data->total_invoice_paid_amount ?? 0,
'response' => $resp,
]);
}
}
return response()->json([
'data' => $return
], 200);
}
public function getTotalProjectPerScheduleHealth($year = '%')
{
$year = $this->interpolateYear($year);
$return = [
'behind-schedule' => 0,
'warning' => 0,
'on-schedule' => 0,
];
$projects = Project::where('mulai_proyek', 'LIKE', '%' . $year . '%')->get();
foreach ($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0;
if ($project->scurve && $project->scurve[0]) {
$planningArray = $project->scurve[0]['data']['percentagePlan'];
$actualArray = $project->scurve[0]['data']['percentageReal'];
$planningProgress = !empty($planningArray) ? $planningArray[count($planningArray) - 1] : 0;
$actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0;
}
$selisihProgress = $planningProgress - $actualProgress;
try {
if ($selisihProgress > 0 && $selisihProgress <= 5)
$return['warning'] += 1;
elseif ($selisihProgress == 0)
$return['on-schedule'] += 1;
else
$return['behind-schedule'] += 1;
} catch (\Error $e) {
return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200);
}
}
return response()->json(['data' => $return, 'q' => $projects], 200);
}
public function getTotalProjectScheduleHealthPerDivision($year = '%')
{
$year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')->get();
foreach ($divisions as $division) {
$scheduleData = new Collection();
$behindSchedule = $warning = $onSchedule = 0;
$projects = Project::where('mulai_proyek', 'LIKE', '%' . $year . '%')->where('divisi_id', $division->id)->get();
foreach ($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
if (@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5)
$warning++;
elseif (@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100)
$behindSchedule++;
elseif (@$project->scurve['difference'] == 0)
$onSchedule++;
}
$scheduleData->prepend($behindSchedule, 'behindSchedule');
$scheduleData->prepend($warning, 'warning');
$scheduleData->prepend($onSchedule, 'onSchedule');
$division->scheduleData = $scheduleData;
}
return response()->json([
'data' => [
$divisions
]
], 200);
}
public function getTotalProjectPerBudgetHealth($year = '%')
{
$year = $this->interpolateYear($year);
return response()->json([
'data' => [
'overrun' => Project::where([['mulai_proyek', 'LIKE', '%' . $year . '%'], ['budget_health', 'overrun']])->count(),
'warning' => Project::where([['mulai_proyek', 'LIKE', '%' . $year . '%'], ['budget_health', 'warning']])->count(),
'on-budget' => Project::where([['mulai_proyek', 'LIKE', '%' . $year . '%'], ['budget_health', 'on-budget']])->count(),
]
], 200);
}
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health)
{
return Project::query()
->where([
['divisi_id', $divisi],
['mulai_proyek', 'LIKE', '%' . $year . '%'],
['budget_health', $health]
])
->count();
}
public function getTotalProjectBudgetHealthPerDivision($year = '%')
{
$year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name')
->with('children')
->whereNull('parent')
->get();
// to do : count in more than 1 level child
foreach ($divisions as $division) {
$budgetData = new Collection();
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'overrun'), 'overrun');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'warning'), 'warning');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'on-budget'), 'on-budget');
foreach ($division->children as $d) {
$budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'overrun');
$budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'warning');
$budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'on-budget');
}
unset($division->children);
$division->budgetData = $budgetData;
}
foreach ($divisions as $division) {
}
return response()->json([
'data' => [
$divisions
]
], 200);
}
public function getTotalProjectPerPhase($year = '%')
{
$year = $this->interpolateYear($year);
$projectPhases = ProjectPhase::orderBy('order')->get();
foreach ($projectPhases as $phase) {
$phase->totalProject = Project::query()
->where([
['phase_id', $phase->id],
['mulai_proyek', 'like', '%' . $year . '%']
])
->count();
}
return response()->json([
'data' => [
$projectPhases
]
], 200);
}
private function countTotalProjectInDivision($id, $year)
{
return Project::query()
->where([
['divisi_id', $id],
['mulai_proyek', 'like', '%' . $year . '%']
])
->count();
}
public function getTotalProjectPerDivision($year = '%')
{
$year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name')
->with('children')
->whereNull('parent')
->get();
// to do : count in more than 1 level child
foreach ($divisions as $v) {
$v->total = $this->countTotalProjectInDivision($v->id, $year);
foreach ($v->children as $d) {
$v->total += $this->countTotalProjectInDivision($d->id, $year);
}
unset($v->children);
}
return response()->json([
'data' => $divisions
], 200);
}
private function countTotalProjectValueInDivision($id, $year)
{
return Project::selectRaw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')
->where([
['mulai_proyek', 'like', '%' . $year . '%'],
['divisi_id', $id]
])
->pluck('sum')
->first();
}
public function getTotalProjectValuePerDivision($year = '%')
{
$year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name')
->with('children')
->whereNull('parent')
->get();
// to do : count in more than 1 level child
foreach ($divisions as $v) {
$v->total = $this->countTotalProjectValueInDivision($v->id, $year);
foreach ($v->children as $d) {
$v->total += $this->countTotalProjectValueInDivision($d->id, $year);
}
unset($v->children);
}
return response()->json([
'data' => $divisions
], 200);
}
public function getDetailExpenditure($year = '%')
{
$year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', '%' . $year . '%')
->orderByDesc('id')
->get();
foreach ($projects as $project) {
$lastGantt = MasterFunctionsHelper::getLatestGantt($project->id);
if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname);
$project->invoice = [
'invoiced' => $resp->data->total_invoice_amount ?? 0,
'paid' => $resp->data->total_invoice_paid_amount ?? 0,
];
}
$project->pm = User::find($project->pm_id);
if (!isset($lastGantt['last_gantt_id'])) {
$project->manPowers = 0;
} else {
$project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count();
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
}
$project->lastGanttId = MasterFunctionsHelper::getLatestGantt($project->id);
}
return response()->json([
'data' => $projects,
'total_manpowers' => User::count()
], 200);
}
}

11
app/Http/Controllers/API/DivisiController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class DivisiController extends Controller
{
//
}

11
app/Http/Controllers/API/FolderDocumentProyekController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class FolderDocumentProyekController extends Controller
{
//
}

11
app/Http/Controllers/API/HierarchyFtthController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class HierarchyFtthController extends Controller
{
//
}

11
app/Http/Controllers/API/HolidayController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class HolidayController extends Controller
{
//
}

11
app/Http/Controllers/API/HumanResourceController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class HumanResourceController extends Controller
{
//
}

11
app/Http/Controllers/API/ImageController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ImageController extends Controller
{
//
}

11
app/Http/Controllers/API/LinkController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class LinkController extends Controller
{
//
}

11
app/Http/Controllers/API/MapMonitoringController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class MapMonitoringController extends Controller
{
//
}

11
app/Http/Controllers/API/MaterialProjectController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class MaterialProjectController extends Controller
{
//
}

11
app/Http/Controllers/API/MaterialResourceController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class MaterialResourceController extends Controller
{
//
}

158
app/Http/Controllers/API/MenuController.php

@ -0,0 +1,158 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\{Menu, RoleMenu};
use Illuminate\Support\Facades\Validator;
class MenuController extends Controller
{
public function add(Request $request)
{
$validator = Validator::make($request->all(), [
'icon' => 'required',
'name' => 'required|string',
'url' => 'required',
'sequence' => 'required',
'created_by' => ''
]);
if ($validator->fails()) {
return response()->json(['status' => 'failed', 'message' => 'add data menu failed!', 'code' => 400], 400);
}
$validated = $validator->validated();
$validated['created_by'] = $this->currentName;
Menu::create($validated);
return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200], 200);
}
public function edit($id)
{
if (!$id || (int) $id < 0 || empty($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 || empty($id)) {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$data = Menu::find($id);
$validator = Validator::make($request->all(), [
'icon' => 'required',
'name' => 'required|string',
'url' => 'required',
'sequence' => 'required'
]);
if ($validator->fails()) {
return response()->json(['status' => 'failed', 'message' => 'data menu failed updated!', 'code' => 400], 400);
}
$validated = $validator->validated();
if ($data) {
$result = $data->update($validated);
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);
endif;
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = Menu::find($id);
if ($data) {
$delete = $data->delete();
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);
endif;
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_menu');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function listMenu($id)
{
$dataParent = RoleMenu::query()
->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::query()
->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::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 list menu, please try again later!', 'code' => 400], 400);
}
}
}

11
app/Http/Controllers/API/OfficeHoursController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class OfficeHoursController extends Controller
{
//
}

11
app/Http/Controllers/API/PanicButtonController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class PanicButtonController extends Controller
{
//
}

11
app/Http/Controllers/API/PresenceController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class PresenceController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectApprovalController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectApprovalController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectCharterController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectCharterController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectCommentController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectCommentController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectDokumenController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectDokumenController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectMileStoneController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectMileStoneController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectParticipantsController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectParticipantsController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectPhaseController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectPhaseController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectRoleController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectRoleController extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectToChecklistK3Controller.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectToChecklistK3Controller extends Controller
{
//
}

11
app/Http/Controllers/API/ProjectTypeController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectTypeController extends Controller
{
//
}

11
app/Http/Controllers/API/RateSallaryController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class RateSallaryController extends Controller
{
//
}

11
app/Http/Controllers/API/ReportActivityController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ReportActivityController extends Controller
{
//
}

11
app/Http/Controllers/API/ReportActivityMaterialController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ReportActivityMaterialController extends Controller
{
//
}

11
app/Http/Controllers/API/ReportK3Controller.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ReportK3Controller extends Controller
{
//
}

11
app/Http/Controllers/API/ReportK3DetailController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ReportK3DetailController extends Controller
{
//
}

11
app/Http/Controllers/API/RequestMaterialController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class RequestMaterialController extends Controller
{
//
}

11
app/Http/Controllers/API/RoleController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class RoleController extends Controller
{
//
}

93
app/Http/Controllers/API/RoleMenuController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\RoleMenu;
use Illuminate\Support\Facades\Validator;
class RoleMenuController extends Controller
{
public function add(Request $request)
{
$validator = Validator::make($request->all(), [
'role_id' => 'required',
'menu_id' => 'required',
'created_by' => ''
]);
if ($validator->fails()) {
return response()->json(['status' => 'failed', 'message' => 'add data role menu failed!', 'code' => 400], 400);
}
$validated = $validator->validated();
$validated['created_by'] = $this->currentName;
RoleMenu::create($validated);
return response()->json(['status' => 'success', 'message' => 'add data role menu successfully!', 'code' => 200], 200);
}
public function update(Request $request, $id)
{
if (!$id || (int) $id < 0 || empty($id)) {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$data = RoleMenu::find($id);
if ($data) {
$result = $data->update($request->all());
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);
endif;
} else {
return response()->json(['status' => 'failed', 'message' => 'data role menu not found!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = RoleMenu::find($id);
if ($data) {
$delete = $data->delete();
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);
endif;
} else {
return response()->json(['status' => 'failed', 'message' => 'data role menu not found!', 'code' => 400], 400);
}
}
public function deleteByRole($id)
{
$data = RoleMenu::where("role_id", $id);
if ($data) {
$delete = $data->delete();
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);
endif;
} else {
return response()->json(['status' => 'failed', 'message' => 'data role menu not found!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 't_roles_menu');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
}

11
app/Http/Controllers/API/SatuanController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class SatuanController extends Controller
{
//
}

11
app/Http/Controllers/API/ShiftController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ShiftController extends Controller
{
//
}

11
app/Http/Controllers/API/ShowHideColumnController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ShowHideColumnController extends Controller
{
//
}

11
app/Http/Controllers/API/TemplateGanttController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class TemplateGanttController extends Controller
{
//
}

11
app/Http/Controllers/API/ToolsProjectController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ToolsProjectController extends Controller
{
//
}

11
app/Http/Controllers/API/ToolsRequestController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ToolsRequestController extends Controller
{
//
}

11
app/Http/Controllers/API/ToolsResourceController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ToolsResourceController extends Controller
{
//
}

11
app/Http/Controllers/API/UserMonthlyShiftController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserMonthlyShiftController extends Controller
{
//
}

11
app/Http/Controllers/API/UserProyekController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserProyekController extends Controller
{
//
}

11
app/Http/Controllers/API/UserToActivityController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserToActivityController extends Controller
{
//
}

11
app/Http/Controllers/API/UserToProyekController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserToProyekController extends Controller
{
//
}

11
app/Http/Controllers/API/UserToShiftController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserToShiftController extends Controller
{
//
}

11
app/Http/Controllers/API/UserToVersionGanttController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserToVersionGanttController extends Controller
{
//
}

11
app/Http/Controllers/API/VersionGanttController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class VersionGanttController extends Controller
{
//
}

11
app/Http/Controllers/API/WaypointController.php

@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class WaypointController extends Controller
{
//
}

312
app/Http/Controllers/Controller.php

@ -0,0 +1,312 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\DB;
use App\Models\{UserToActivity, Activity, AssignMaterial};
class Controller extends BaseController
{
protected $pathImage = "assets/image/";
protected $pathDocument = "assets/file/project/";
protected $pathTmpImport = "assets/file/tmpimport/";
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()
{
$this->currentDate = date("Y-m-d H:i:s");
$this->currentName = auth()->user() ? auth()->user()->name : "system";
$this->currentId = auth()->user() ? auth()->user()->id : 0;
$this->pathImage = config('assets.image');
$this->pathDocument = config('assets.project');
$this->pathActivityDocument = config('assets.activity');
}
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);
}
$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
$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;
}
protected function calculateAllCost($activity_id, $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) {
$totalCost += $this->calculateHumanCost($human, $activity_id);
}
return $totalCost;
}
private function calculateHumanCost($human, $activity_id)
{
$activity = Activity::find($activity_id);
$duration = $activity->duration;
$standarRate = $human->standart_rate;
$maxUsed = $human->max_used / 100;
if ($human->uom_standart_rate == "Hour") {
$totalCost = ($standarRate * 8 * $duration) * $maxUsed;
return $totalCost;
}
$totalCost = ($standarRate * $duration) * $maxUsed;
return $totalCost;
}
private function calculateMaterialCost($activity_id, $proyek_id)
{
$totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost")
->where("proyek_id", $proyek_id)
->where("activity_id", $activity_id)
->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)"));
return $totalCost;
}
protected function getLoc($lat, $lng)
{
// $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json");
// return $response->json;
$url = config('api.nominatim') . "/reverse?lat=" . $lat . "&lon=" . $lng . "&format=json";
// $token = config('api.adw_token');
$response = $this->curlRequest($url);
return $response;
}
private function curlRequest($url)
{
$ch = curl_init();
// $headers = [
// 'Authorization: '.$token
// ];
curl_setopt($ch, CURLOPT_URL, $url);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
if ($response === false)
$response = curl_error($ch);
curl_close($ch);
return json_decode($response);
}
protected 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);
}
}
}

68
app/Http/Kernel.php

@ -0,0 +1,68 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array<int, class-string|string>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array<string, array<int, class-string|string>>
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'cors' => \App\Http\Middleware\CorsMiddleware::class,
];
}

21
app/Http/Middleware/Authenticate.php

@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

38
app/Http/Middleware/CorsMiddleware.php

@ -0,0 +1,38 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class CorsMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $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;
}
}

17
app/Http/Middleware/EncryptCookies.php

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

17
app/Http/Middleware/PreventRequestsDuringMaintenance.php

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

32
app/Http/Middleware/RedirectIfAuthenticated.php

@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

19
app/Http/Middleware/TrimStrings.php

@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
}

20
app/Http/Middleware/TrustHosts.php

@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

28
app/Http/Middleware/TrustProxies.php

@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array<int, string>|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}

22
app/Http/Middleware/ValidateSignature.php

@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
class ValidateSignature extends Middleware
{
/**
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $except = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source',
// 'utm_term',
];
}

17
app/Http/Middleware/VerifyCsrfToken.php

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

13
app/Models/Absent.php

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Absent extends Model
{
protected $table = 't_absensi', $guarded = ['id'];
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
}

233
app/Models/Activity.php

@ -0,0 +1,233 @@
<?php
namespace App\Models;
use App\Models\AssignMaterial;
use App\Models\ActivityProgressLog;
use App\Models\AssignTools;
use App\Models\ReportActivityMaterial;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class Activity extends Model
{
// persentase bobot gak kepake yg dipakenya bobot_planning
protected $table = 'm_activity', $guarded = ['id'];
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $appends = [
'jobs_done', 'assign_hr', 'assign_material', 'assign_tools', 'assign_expense'
];
public function getStartDateAttribute($value)
{
if ($value instanceof \DateTime) {
return Carbon::instance($value)
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
public function getEndDateAttribute($value)
{
if ($value instanceof \DateTime) {
return Carbon::instance($value)
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
public static function boot()
{
parent::boot();
static::updating(function ($data) {
$data->logPersentaseProgress();
});
static::updated(function ($data) {
$data->updateBobot();
$data->updateCostPlanning();
if ($data->bobot_planning) {
$data->updatePersentaseProgress();
$data->updateCostActual();
}
});
static::deleted(function ($data) {
if (Activity::where("parent_id", $data->parent_id)->count() == 0)
Activity::find($data->parent_id)->update(["type_activity" => "task"]);
$data->updateBobot(true);
$data->updateCostPlanning();
if ($data->bobot_planning) {
$data->updatePersentaseProgress();
$data->updateCostActual();
}
$data->updateStartEndDateHeader();
});
}
private function updateBobot($isDelete = false)
{
$root = Activity::where('version_gantt_id', $this->version_gantt_id)
->where("proyek_id", $this->proyek_id)
->whereNull('parent_id')
->first();
if ($root->rencana_biaya > 0) {
$activities = Activity::where("proyek_id", $this->proyek_id)->where("version_gantt_id", $this->version_gantt_id)->get();
foreach ($activities as $activity) {
if ($isDelete && $activity->id == $this->id)
continue;
$activity->bobot_planning = ((int)$activity->rencana_biaya / $root->rencana_biaya) * 100;
$activity->updated_by = auth()->user() ? auth()->user()->name : "system";
$activity->saveQuietly();
}
} else {
if ($parent = Activity::find($this->parent_id)) {
$totalChildWeight = Activity::where("parent_id", $this->parent_id)->sum('bobot_planning');
$parent->update([
"bobot_planning" => $totalChildWeight
]);
}
}
}
private function updateCostActual()
{
$actualCost = Activity::where("parent_id", $this->parent_id)->sum("biaya_actual");
$this->biaya_actual = $actualCost;
if ($parent = Activity::find($this->parent_id)) {
$parent->update([
"biaya_actual" => $actualCost
]);
}
}
private function updatePersentaseProgress()
{
if ($parent = Activity::find($this->parent_id)) {
$parentActWeight = $parent->bobot_planning;
if ($parentActWeight == 0) {
$parent->update([
"persentase_progress" => 0
]);
return;
}
$totalChildProportionalProgress = 0;
$childs = Activity::where("parent_id", $parent->id)->get();
foreach ($childs as $child) {
$currentActWeight = $child->bobot_planning;
$currentActProportionalProgress = ($currentActWeight / $parentActWeight) * $child->persentase_progress;
$totalChildProportionalProgress += $currentActProportionalProgress;
}
$parent->update([
"persentase_progress" => $totalChildProportionalProgress
]);
}
}
private function updateCostPlanning()
{
$sumBiaya = Activity::select(DB::raw('sum(cast(rencana_biaya as double precision))'))
->where("parent_id", $this->parent_id)
->first();
$this->rencana_biaya = $sumBiaya->sum;
if ($parent = Activity::find($this->parent_id)) {
$parent->update([
"rencana_biaya" => $sumBiaya->sum,
]);
}
}
private function logPersentaseProgress()
{
ActivityProgressLog::create([
'version_gantt_id' => $this->version_gantt_id,
'activity_id' => request()->id,
'old_percentage' => $this->persentase_progress,
'new_percentage' => request()->persentase_progress,
'variance' => $this->persentase_progress - request()->persentase_progress,
'created_by' => "system"
]);
}
private function updateStartEndDateHeader()
{
$earliestStartDate = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNotNull('parent_id')->oldest('start_date')->pluck('start_date')->first();
$latestEndDate = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNotNull('parent_id')->latest('end_date')->pluck('end_date')->first();
if ($header = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNull('parent_id')->first()) {
$header->start_date = $earliestStartDate;
$header->end_date = $latestEndDate;
$header->saveQuietly();
}
}
public function getJobsDoneAttribute()
{
if (!ReportActivityMaterial::where('activity_id', $this->id)->first())
return 0;
if (!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get())
return 0;
if ($dataPlan->isEmpty())
return 0;
if ($dataPlan[0]->status_activity == 'done')
return 100;
return $this->persentase_progress;
}
public function getAssignHrAttribute()
{
return Arr::flatten(UserToActivity::select("u.name as name")
->join("m_users as u", "u.id", "=", "assign_hr_to_activity.user_id")
->where('assign_hr_to_activity.activity_id', $this->id)
->get()
->toArray());
}
public function getAssignMaterialAttribute()
{
return Arr::flatten(AssignMaterial::select("m.description as name")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $this->id)
->where('assign_material_to_activity.type', "material")
->get()
->toArray());
}
public function getAssignExpenseAttribute()
{
return Arr::flatten(AssignMaterial::select("m.description as name")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $this->id)
->where('assign_material_to_activity.type', "expense")
->get()
->toArray());
}
public function getAssignToolsAttribute()
{
return Arr::flatten(AssignTools::select("m.name as name")
->join("m_tools_resource as m", "m.id", "=", "assign_tools_to_activity.tools_id")
->where('assign_tools_to_activity.activity_id', $this->id)
->get()
->toArray());
}
}

17
app/Models/ActivityDokumen.php

@ -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'
];
}

19
app/Models/ActivityProgressLog.php

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ActivityProgressLog extends Model
{
protected $table = 'm_activity_progress_log';
const CREATED_AT = 'created_at';
const UPDATED_AT = null;
protected $fillable = [
'version_gantt_id', 'activity_id', 'old_percentage', 'new_percentage', 'variance',
'created_at', 'created_by'
];
}

17
app/Models/Alert.php

@ -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'
];
}

44
app/Models/AssignMaterial.php

@ -0,0 +1,44 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\RequestMaterial;
use App\Models\Activity;
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', 'status_activity', 'type',
'created_at', 'created_by', 'updated_at', 'updated_by'
];
protected $casts = [
'id' => 'integer',
'budget' => 'string',
];
public static function boot() {
parent::boot();
static::created(function($data) {
$activity = Activity::find($data->activity_id);
$material = RequestMaterial::where("id", $data->material_id)->first();
$activity->rencana_biaya += floatval($material->price) * floatval($data->qty_planning);
$activity->save();
});
static::deleted(function($data) {
$activity = Activity::where('id', $data->activity_id)->first();
$activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning);
$activity->save();
});
}
}

17
app/Models/AssignTools.php

@ -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'
];
}

17
app/Models/Broadcast.php

@ -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'
];
}

22
app/Models/ChecklistK3.php

@ -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'
];
}

22
app/Models/CommentActivity.php

@ -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'
];
}

17
app/Models/ConfigAlert.php

@ -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'
];
}

17
app/Models/ConfigAlertUser.php

@ -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'
];
}

41
app/Models/Divisi.php

@ -0,0 +1,41 @@
<?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',
'parent',
'description',
'created_at',
'created_by',
'updated_at',
'updated_by'
];
public static function boot() {
parent::boot();
static::deleting(function($data) {
$data->children()->delete();
});
}
public function parent()
{
return $this->belongsTo('App\Models\Divisi','parent')->where('parent', null)->with('parent');
}
public function children()
{
return $this->hasMany('App\Models\Divisi','parent')->with('children');
}
}

17
app/Models/DokumenProject.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DokumenProject extends Model
{
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'
];
}

23
app/Models/FolderDocumentProyek.php

@ -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'
];
}

10
app/Models/GanttColumnByType.php

@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class GanttColumnByType extends Model
{
protected $table = 't_gantt_column_to_type';
}

28
app/Models/HierarchyFtth.php

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class HierarchyFtth extends Model
{
protected $table = "m_hierarchy_ftth";
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress', 'bobot_planning'
];
public static function boot() {
parent::boot();
static::deleted(function($data) {
$ftths = HierarchyFtth::where('parent_id', $data->id)->get();
foreach ($ftths as $ftth) {
$ftth->delete();
}
});
}
}

17
app/Models/Holiday.php

@ -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'
];
}

38
app/Models/HumanResource.php

@ -0,0 +1,38 @@
<?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',
'status_boundary'
];
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save