瀏覽代碼

initial

master
root 5 年之前
當前提交
d8c1b4a1be
共有 100 個文件被更改,包括 13154 次插入0 次删除
  1. 二進制
      .DS_Store
  2. 15
    0
      .editorconfig
  3. 50
    0
      .env
  4. 44
    0
      .env.
  5. 44
    0
      .env.example
  6. 13
    0
      .styleci.yml
  7. 二進制
      app/.DS_Store
  8. 42
    0
      app/Console/Kernel.php
  9. 28
    0
      app/Exceptions/CustomException.php
  10. 76
    0
      app/Exceptions/Handler.php
  11. 二進制
      app/Http/.DS_Store
  12. 二進制
      app/Http/Controllers/.DS_Store
  13. 172
    0
      app/Http/Controllers/Api/ApplicationController.php
  14. 46
    0
      app/Http/Controllers/Api/BaseController.php
  15. 1003
    0
      app/Http/Controllers/Api/CompoundController.php
  16. 542
    0
      app/Http/Controllers/Api/CompoundResourceController.php
  17. 505
    0
      app/Http/Controllers/Api/DepartmentController.php
  18. 38
    0
      app/Http/Controllers/Api/EpbtController.php
  19. 405
    0
      app/Http/Controllers/Api/InventoryController.php
  20. 114
    0
      app/Http/Controllers/Api/InvestigationController.php
  21. 104
    0
      app/Http/Controllers/Api/JobController.php
  22. 32
    0
      app/Http/Controllers/Api/KelantanPayController.php
  23. 135
    0
      app/Http/Controllers/Api/LoginController.php
  24. 164
    0
      app/Http/Controllers/Api/MemoController.php
  25. 208
    0
      app/Http/Controllers/Api/PaymentController.php
  26. 245
    0
      app/Http/Controllers/Api/RestfulapiController.php
  27. 427
    0
      app/Http/Controllers/Api/SettingController.php
  28. 311
    0
      app/Http/Controllers/Api/StaffController.php
  29. 202
    0
      app/Http/Controllers/Api/StatisticController.php
  30. 158
    0
      app/Http/Controllers/Api/TrackMapController.php
  31. 32
    0
      app/Http/Controllers/Auth/ForgotPasswordController.php
  32. 105
    0
      app/Http/Controllers/Auth/LoginController.php
  33. 72
    0
      app/Http/Controllers/Auth/RegisterController.php
  34. 39
    0
      app/Http/Controllers/Auth/ResetPasswordController.php
  35. 41
    0
      app/Http/Controllers/Auth/VerificationController.php
  36. 13
    0
      app/Http/Controllers/Controller.php
  37. 28
    0
      app/Http/Controllers/Main/ApplicationController.php
  38. 468
    0
      app/Http/Controllers/Main/CompoundController.php
  39. 210
    0
      app/Http/Controllers/Main/DepartmentController.php
  40. 23
    0
      app/Http/Controllers/Main/IndexController.php
  41. 196
    0
      app/Http/Controllers/Main/InventoryController.php
  42. 220
    0
      app/Http/Controllers/Main/InvestigationController.php
  43. 339
    0
      app/Http/Controllers/Main/MemoController.php
  44. 140
    0
      app/Http/Controllers/Main/ProfileController.php
  45. 39
    0
      app/Http/Controllers/Main/ReportController.php
  46. 830
    0
      app/Http/Controllers/Main/SettingController.php
  47. 248
    0
      app/Http/Controllers/Main/StaffController.php
  48. 344
    0
      app/Http/Controllers/Main/TaskController.php
  49. 137
    0
      app/Http/Controllers/NotificationController.php
  50. 28
    0
      app/Http/Controllers/Officer/ApplicationController.php
  51. 415
    0
      app/Http/Controllers/Officer/CompoundController.php
  52. 171
    0
      app/Http/Controllers/Officer/DepartmentController.php
  53. 23
    0
      app/Http/Controllers/Officer/IndexController.php
  54. 196
    0
      app/Http/Controllers/Officer/InventoryController.php
  55. 220
    0
      app/Http/Controllers/Officer/InvestigationController.php
  56. 340
    0
      app/Http/Controllers/Officer/MemoController.php
  57. 138
    0
      app/Http/Controllers/Officer/ProfileController.php
  58. 584
    0
      app/Http/Controllers/Officer/SettingController.php
  59. 191
    0
      app/Http/Controllers/Officer/StaffController.php
  60. 163
    0
      app/Http/Controllers/Officer/TaskController.php
  61. 142
    0
      app/Http/Controllers/PaymentController.php
  62. 81
    0
      app/Http/Controllers/ResponsiveController.php
  63. 28
    0
      app/Http/Controllers/SiteSettingController.php
  64. 84
    0
      app/Http/Kernel.php
  65. 21
    0
      app/Http/Middleware/Authenticate.php
  66. 17
    0
      app/Http/Middleware/CheckForMaintenanceMode.php
  67. 17
    0
      app/Http/Middleware/EncryptCookies.php
  68. 24
    0
      app/Http/Middleware/MobileApps.php
  69. 27
    0
      app/Http/Middleware/OfficerAuth.php
  70. 52
    0
      app/Http/Middleware/RedirectIfAuthenticated.php
  71. 26
    0
      app/Http/Middleware/SOfficerAuth.php
  72. 26
    0
      app/Http/Middleware/SysadminAuth.php
  73. 18
    0
      app/Http/Middleware/TrimStrings.php
  74. 23
    0
      app/Http/Middleware/TrustProxies.php
  75. 24
    0
      app/Http/Middleware/VerifyCsrfToken.php
  76. 38
    0
      app/Http/Resources/CompoundResource.php
  77. 65
    0
      app/Jobs/GenerateBarcode.php
  78. 144
    0
      app/Jobs/SendNoticeLetter.php
  79. 233
    0
      app/Jobs/StoreCompound.php
  80. 229
    0
      app/Jobs/StoreCompoundManual.php
  81. 185
    0
      app/Jobs/UpdateCompoundPrice.php
  82. 17
    0
      app/Model/Database/EPBT.php
  83. 23
    0
      app/Model/Module/ApiIntegration.php
  84. 22
    0
      app/Model/Module/ApiKey.php
  85. 41
    0
      app/Model/Module/Attachment.php
  86. 38
    0
      app/Model/Module/AuctionSale.php
  87. 33
    0
      app/Model/Module/Barcode.php
  88. 60
    0
      app/Model/Module/Compound.php
  89. 31
    0
      app/Model/Module/CompoundInvestigation.php
  90. 39
    0
      app/Model/Module/ConfidentialFile.php
  91. 18
    0
      app/Model/Module/CurrentLocation.php
  92. 29
    0
      app/Model/Module/DeedLaw.php
  93. 40
    0
      app/Model/Module/Department.php
  94. 18
    0
      app/Model/Module/EmergencyMarker.php
  95. 26
    0
      app/Model/Module/Faulty.php
  96. 18
    0
      app/Model/Module/FirebaseFcmToken.php
  97. 24
    0
      app/Model/Module/History.php
  98. 26
    0
      app/Model/Module/Investigation.php
  99. 31
    0
      app/Model/Module/ItemInventory.php
  100. 0
    0
      app/Model/Module/LetterNotice.php

二進制
.DS_Store 查看文件


+ 15
- 0
.editorconfig 查看文件

@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2

+ 50
- 0
.env 查看文件

@@ -0,0 +1,50 @@
APP_NAME=mbip.sipadu.my
APP_ENV=local
APP_KEY=base64:ViDhVYZaOFaZhcTuSi/LW589bbewU7FysU4d/WOP3zM=
APP_DEBUG=true
APP_URL=https://mbip.sipadu.my/

LOG_CHANNEL=stack

DB_CONNECTION=oracle
DB_HOST=210.186.146.195
DB_PORT=1091
DB_DATABASE=XE
DB_USERNAME=mkpy
DB_PASSWORD=mkpy

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MONGO_DB_HOST=172.16.2.3
MONGO_DB_PORT=27017
MONGO_DB_DATABASE=mbip
MONGO_DB_USERNAME=myUserAdmin
MONGO_DB_PASSWORD=swiss@2018@CCC

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

+ 44
- 0
.env. 查看文件

@@ -0,0 +1,44 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

+ 44
- 0
.env.example 查看文件

@@ -0,0 +1,44 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

+ 13
- 0
.styleci.yml 查看文件

@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

二進制
app/.DS_Store 查看文件


+ 42
- 0
app/Console/Kernel.php 查看文件

@@ -0,0 +1,42 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $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');
}
}

+ 28
- 0
app/Exceptions/CustomException.php 查看文件

@@ -0,0 +1,28 @@
<?php
namespace App\Exceptions;
use Exception;
class CustomException extends Exception {
/**
* Report the exception.
*
* @return void
*/
public function report()
{
}
/**
* Render the exception into an HTTP response.
*
* @param \Illuminate\Http\Request
* @return \Illuminate\Http\Response
*/
public function render($request)
{
return response()->view('errors.custom', array( 'exception' => $this ));
// return response()->view('errors.' . '500', [], 500);
}
}

+ 76
- 0
app/Exceptions/Handler.php 查看文件

@@ -0,0 +1,76 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
if ($exception instanceof ModelNotFoundException) {
return response()->view('errors.' . '404', [], 404);
}

if ($exception instanceof CustomException) {
return response()->view('errors.' . '500', [], 500);
}

if($this->isHttpException($exception)) {
switch ($exception->getStatusCode()) {
// not found
case '404':
return response()->view('errors.' . '404', [], 404);
break;
// internal server error
case '500':
return response()->view('errors.' . '500', [], 500);
break;
default:
return $this->renderHttpException($exception);
break;
}
} else {
return parent::render($request, $exception);
// return response()->view('errors.' . '500', [], 500);
}
}
}

二進制
app/Http/.DS_Store 查看文件


二進制
app/Http/Controllers/.DS_Store 查看文件


+ 172
- 0
app/Http/Controllers/Api/ApplicationController.php 查看文件

@@ -0,0 +1,172 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
class ApplicationController extends BaseController
{
/**
* Create a user list controller.
*
* @return json
*/
public function appList()
{
$nested_data = array();
$curr = Carbon::now()->getTimestamp();
$staff = Staff::with('StaffDetail')->where('roles_access','PenguatKuasa')->withTrashed()->orderBy('updated_at', 'desc')->get();
foreach($staff as $s) {
$n1 = ''; $status = 'Aktif';
$reg_time = $s->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
if ($s->trashed()) {
$status = 'Tidak Aktif';
}
array_push($nested_data, array(
'#' => $n1,
'nama' => $s->StaffDetail->full_name,
'identity' => $s->StaffDetail->identity,
'email' => $s->StaffDetail->email,
'mobile' => $s->StaffDetail->email,
'daftar' => $s->StaffDetail->created_at->format('d M Y - H:i:s a'),
'kategori' => 'PenguatKuasa',
'status' => $status,
'updated_at' => $s->StaffDetail->updated_at,
));
}
$user = User::with('UserDetail')->withTrashed()->orderBy('updated_at', 'desc')->get();
foreach($user as $u) {
$n1 = ''; $status = 'Aktif';
$reg_time = $u->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
if ($u->trashed()) {
$status = 'Tidak Aktif';
}
array_push($nested_data, array(
'#' => $n1,
'nama' => $u->UserDetail->full_name,
'identity' => $u->UserDetail->identity,
'email' => $u->UserDetail->email,
'mobile' => $u->UserDetail->email,
'daftar' => $s->UserDetail->created_at,
'kategori' => 'Pengguna',
'status' => $status,
'updated_at' => $u->UserDetail->updated_at,
));
}
array_multisort(array_map(function($element) {
return $element['updated_at'];
}, $nested_data), SORT_DESC, $nested_data);
return \DataTables::of($nested_data)->make(true);
}
public function officerAppList($jbkod)
{
$nested_data = array();
$curr = Carbon::now()->getTimestamp();
$staff = Staff::with(['StaffDetail' => function($q) use($jbkod){
$q->where('jbkod',$jbkod);
}])->where('roles_access','PenguatKuasa')->withTrashed()->orderBy('updated_at', 'desc')->get();
foreach($staff as $s) {
$n1 = ''; $status = 'Aktif';
$reg_time = $s->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
if ($s->trashed()) {
$status = 'Tidak Aktif';
}
if(!empty($s->StaffDetail)){
array_push($nested_data, array(
'#' => $n1,
'nama' => $s->StaffDetail->full_name,
'identity' => $s->StaffDetail->identity,
'email' => $s->StaffDetail->email,
'mobile' => $s->StaffDetail->email,
'daftar' => $s->StaffDetail->created_at->format('d M Y - H:i:s a'),
'kategori' => 'PenguatKuasa',
'status' => $status,
'updated_at' => $s->StaffDetail->updated_at,
));
}
}
$user = User::with('UserDetail')->withTrashed()->orderBy('updated_at', 'desc')->get();
foreach($user as $u) {
$n1 = ''; $status = 'Aktif';
$reg_time = $u->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
if ($u->trashed()) {
$status = 'Tidak Aktif';
}
array_push($nested_data, array(
'#' => $n1,
'nama' => $u->UserDetail->full_name,
'identity' => $u->UserDetail->identity,
'email' => $u->UserDetail->email,
'mobile' => $u->UserDetail->email,
'daftar' => $s->UserDetail->created_at,
'kategori' => 'Pengguna',
'status' => $status,
'updated_at' => $u->UserDetail->updated_at,
));
}
array_multisort(array_map(function($element) {
return $element['updated_at'];
}, $nested_data), SORT_DESC, $nested_data);
return \DataTables::of($nested_data)->make(true);
}
}

+ 46
- 0
app/Http/Controllers/Api/BaseController.php 查看文件

@@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers\API;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class BaseController extends Controller
{
/**
* success response method.
*
* @return \Illuminate\Http\Response
*/
public function sendResponse($result, $message)
{
$response = [
'success' => true,
'data' => $result,
'message' => $message,
];
return response()->json($response, 200);
}
/**
* return error response.
*
* @return \Illuminate\Http\Response
*/
public function sendError($error, $errorMessages = [], $code = 404)
{
$response = [
'success' => false,
'message' => $error,
];
if(!empty($errorMessages)){
$response['data'] = $errorMessages;
}
return response()->json($response, $code);
}
}

+ 1003
- 0
app/Http/Controllers/Api/CompoundController.php
文件差異過大導致無法顯示
查看文件


+ 542
- 0
app/Http/Controllers/Api/CompoundResourceController.php 查看文件

@@ -0,0 +1,542 @@
<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Carbon\Carbon;

use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Compound;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;

use App\Jobs\StoreCompound;
use App\Jobs\UpdateCompoundPrice;
use App\Http\Resources\CompoundResource;

class CompoundResourceController extends BaseController
{
/**
* @var ServiceCategory
*/
protected $compound;

/**
* ServiceController constructor.
*
* @param ServiceCategory $ServiceCategory
*/
public function __construct(Compound $compound)
{
$this->compound = $compound;
}

/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
private function searchCompoundAll($jenis,$modul,$status,$start_date,$end_date){
$dateS = Carbon::createFromFormat('Y-m-d', $start_date);
$start = $dateS->copy()->startOfDay();
if($end_date != ''){
$dateE = Carbon::createFromFormat('Y-m-d', $end_date);
$end = $dateE->copy()->endOfDay();

}else{
$end = $dateS->copy()->endOfDay();
}

if($modul == '06-07'){
$compound = Compound::where(function($q){
$q->where(function($query){
$query->where('modul', '06')->orWhere('modul','07');
});
})->where('status', $status)->where('jenis', $jenis)->whereBetween('created_at', array($start, $end));
}else if($status != 'Berbayar'){
if($status == 'All'){
$compound = Compound::where('modul', $modul)->where('status','!=','Berbayar')->where('jenis', $jenis)
->whereBetween('created_at', array($start, $end));
}else{
$compound = Compound::where('modul', $modul)->where('status', $status)->where('jenis', $jenis)
->whereBetween('created_at', array($start, $end));
}
// $compound = Compound::where('modul', $modul)->where('status', $status)->where('jenis', $jenis)
// ->whereBetween('created_at', array($start, $end));
}else{
$compound = Compound::where('status', $status)->where('jenis', $jenis)
->whereBetween('created_at', array($start, $end));
}
return $compound;
}

private function searchCompoundAllWithoutDate($jenis,$modul,$status){
if($modul == '06-07'){
$compound = Compound::where(function($q){
$q->where(function($query){
$query->where('modul', '06')->orWhere('modul','07');
});
})->where('status', $status)->where('jenis', $jenis);
}else if($status != 'Berbayar'){
if($status == 'All'){
$compound = Compound::where('modul', $modul)->where('status','!=','Berbayar')->where('jenis', $jenis);
}else{
$compound = Compound::where('modul', $modul)->where('status', $status)->where('jenis', $jenis);
}
}else{
$compound = Compound::where('status', $status)->where('jenis', $jenis);
}
return $compound;
}

private function filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date){
if(!empty($start_date)){
$compound = $this->searchCompoundAll($jenis,$modul,$status,$start_date,$end_date);
}else{
$compound = $this->searchCompoundAllWithoutDate($jenis,$modul,$status);
}

if($enforcer == 'All'){
return $compound;
}else {
$compound = $compound->where('dikeluarkan', $enforcer);
return $compound;
}
}

private function filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date){
$compound = $this->filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date);
if($faulty == 'All'){
return $compound;
}else {
$compound = $compound->where('seksyen_kesalahan', $faulty);
return $compound;
}
}

public function index(Request $request)
{
//
$per_page = $request->per_page;
$kpd = $request->kpd;

$modul = $request->modul;
$status = $request->status;
$jenis = $request->type;

$start_date = $request->start_date;
$end_date = $request->end_date;

$enforcer = $request->enforcer;
$faulty = $request->faulty;

$plate_no = strtolower($request->plate_no);
$company_no = strtolower($request->company_no);
$nric = $request->nric;

$nested_data = array();

if(!empty($plate_no)) {
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date);
$compound = $compound->where('no_plate',$plate_no)->orderBy('created_at','ASC')->get();
}else if(!empty($kpd)){
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date);
$compound = $compound->where('kpd',$kpd)->orderBy('created_at','ASC')->get();
}else if(!empty($company_no)){
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date);
$compound = $compound->where('no_daftar_syarikat',$company_no)->orderBy('created_at','ASC')->get();
}else if(!empty($nric)){
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date);
$compound = $compound->where('identity',$nric)->orderBy('created_at','ASC')->get();
}else{
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date);
$compound = $compound->orderBy('created_at','ASC')->get();
}

// return $compound;
return \DataTables::of(CompoundResource::collection($compound))->addIndexColumn()
->addColumn('index', function($row) {
$curr = Carbon::now();
$dtC = Carbon::parse($row['created_at'])->setTimezone('Asia/Kuala_Lumpur');
if($curr->diffInDays($dtC) <= 3){
$html = 'New';
}else{ $html = ''; }
return $html;
})->rawColumns(['index'])->make(true);
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
if(empty($staff)){
return $this->sendError('Invalid', 'Staff not existed');
}else {
$faulty = Faulty::where('_id',$request->get('seksyen'))->first();
if(!empty($faulty)){

$data = array();
$countKPD = $this->compound->withTrashed()->count();

do {
$countKPD = $countKPD + 1;
} while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);

$kpd = 'KP' . $countKPD;
$no_siri = date('yn').'-'.$countKPD;

$fileData = [
'no_siri' => $no_siri,
];

if($request->jenis != 'Pelbagai'){
$compoundData = [
'jenis' => 'Parkir',
'kpd' => $kpd,
'nama' => '-',
'identity' => '-',
'alamat' => '-',
"no_plate" => strtolower($request->no_plate),
"no_cukai_jalan" => $request->noCukaijalan,
"jenis_kenderaan" => $request->jenisKenderaan,
"model_kenderaan" => $request->modelKenderaan,
"warna_kenderaan" => $request->warnakenderaan,
"nama_kawasan" => $request->namaKawasan,
"nama_taman" => $request->namaTaman,
"nama_jalan" => $request->namaJalan,
"no_parking" => $request->noParking,
"catatan" => $request->catatan,
"lokasi_kejadian" => '-',
'latlong' => $request->Latlong,
'jbkod' => $request->jabatan,
'akta' => $faulty->deed_law_id,
'seksyen_kesalahan' => $faulty->_id,
'jumlah_asal_kompaun' => $faulty->amount,
'jumlah_kemaskini_kompaun' => '',
'dikeluarkan' => $staff->_id,
"status" => 'Belum Bayar',
"amount_payment" => '',
"receipt" => '',
"modul" => '03',
"penguatkuasa" => '',
];
}else{
$compoundData = [
'jenis' => 'Pelbagai',
'kpd' => $kpd,
'nama' => $request->namaP,
'identity' => $request->noIc,
'nama_syarikat' => $request->namaS,
'no_daftar_syarikat' => strtolower($request->daftarNo),
'alamat' => $request->alamat,
"no_plate" => $request->no_plate,
"no_cukai_jalan" => $request->no_cukai_jalan,
"catatan" => $request->catatan,
"lokasi_kejadian" => $request->lokasi_kejadian,
'latlong' => $request->Latlong,
'jbkod' => $request->jabatan,
'akta' => $faulty->deed_law_id,
'seksyen_kesalahan' => $faulty->_id,
'jumlah_asal_kompaun' => $faulty->amount,
'jumlah_kemaskini_kompaun' => '',
'dikeluarkan' => $staff->_id,
"status" => 'Belum Bayar',
"amount_payment" => '',
"receipt" => '',
"modul" => '03',
"penguatkuasa" => '',
"no_telefon" => $request->tel,
"no_akaun_lesen" => $request->lesen,
"maklumat_tambahan" => $request->maklumat_tambahan,
];
}

$file = ConfidentialFile::create($fileData);
$saved = $file->compound()->create($compoundData);

if($saved){
// $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
// if(!empty($compound)){
dispatch(new UpdateCompoundPrice($kpd));
// $tawaran = '';
// if($compound->jumlah_kemaskini_kompaun != ''){
// $tawaran = $compound->jumlah_kemaskini_kompaun;
// }else{
// $tawaran = $compound->jumlah_asal_kompaun;
// }
$this->dispatch(new StoreCompound($request->all(), $kpd, $staff->_id, $no_siri));
array_push($data, array('kpd' => $kpd));

return $this->sendResponse($data, 'Berjaya simpan rekod kompaun!');
// }
}
}
}
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}

public function updateStatusPaymentViaDashboard(Request $request)
{
$compound = $this->compound::with('ConfidentialFile')->find($request->id);
$staff = StaffDetail::find($request->current_id);
if(!empty($compound) && !empty($staff)){
if($staff->roles_access == "sysadmin" || $staff->roles_access == "Ketua Jabatan"){

if($compound->status != $request->status){
$compound->status = $request->status;
$compound->catatan_dari_admin = $request->remark;
$compound->amount_payment = $request->amount;
$compound->update_by = $request->current_id;
$saved = $compound->save();
if($saved){

$gDate = $compound->created_at->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Status pembayaran kompaun ".$compound->kpd. " telah dikemaskini",
'huraian' => "Status pembayaran kompaun (RM ".$request->amount.") telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
];

$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$historySaved = $compound->ConfidentialFile->history()->attach($history);
}

if($request->status == "Berbayar"){
return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun Dijelaskan" ');
}else{
return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun DiBatalkan" ');
}
}else{
$response = [
'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
];
return response()->json($response, 200);
}
}else{

if($request->remark != ''){
$compound->catatan_dari_admin = $request->remark;
$compound->update_by = $request->current_id;
$compound->save();

$saved = $compound->save();
if($saved){

$gDate = $compound->created_at->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
'huraian' => "Catatan kompaun ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
];

$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$historySaved = $compound->ConfidentialFile->history()->attach($history);
}

return $this->sendResponse('', 'Berjaya tambah catatan untuk kompaun ini');

}else{
$response = [
'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
];
return response()->json($response, 200);
}

}else{
$response = [
'success' => false, 'message' => 'Tiada kemaskini!',
];
return response()->json($response, 200);
}

}
}else{

if($compound->status != 'Berbayar' && $compound->status != $request->status){
$compound->status = $request->status;
$compound->catatan_dari_admin = $request->remark;
$compound->amount_payment = $request->amount;
$compound->update_by = $request->current_id;
$saved = $compound->save();
if($saved){

$gDate = $compound->created_at->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Status pembayaran kompaun ".$compound->kpd. " telah dikemaskini",
'huraian' => "Status pembayaran kompaun (RM ".$request->amount.") telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
];

$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$historySaved = $compound->ConfidentialFile->history()->attach($history);
}

if($request->status == "Berbayar"){
return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun Dijelaskan" ');
}else{
return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun DiBatalkan" ');
}
}else{
$response = [
'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
];
return response()->json($response, 200);
}
}else{

if($request->remark != ''){
$compound->catatan_dari_admin = $request->remark;
$compound->update_by = $request->current_id;
$compound->save();

$saved = $compound->save();
if($saved){

$gDate = $compound->created_at->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
'huraian' => "Catatan kompaun ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
];

$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$historySaved = $compound->ConfidentialFile->history()->attach($history);
}

return $this->sendResponse('', 'Berjaya tambah catatan untuk kompaun ini');

}else{
$response = [
'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
];
return response()->json($response, 200);
}

}else{
$response = [
'success' => false, 'message' => 'Tiada kemaskini!',
];
return response()->json($response, 200);
}

}
}
}else{
$response = [
'success' => false,
'message' => 'Kompaun ini tidak dijumpai / staff tidak ditemui',
];
return response()->json($response, 200);
}

}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}

+ 505
- 0
app/Http/Controllers/Api/DepartmentController.php 查看文件

@@ -0,0 +1,505 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
class DepartmentController extends BaseController
{
/**
* Create a department list controller.
*
* @return json
*/
public function departmentList()
{
$nested_data = array();
$department = Department::orderBy('updated_at', 'desc')->get();
$curr = Carbon::now()->getTimestamp();
foreach($department as $a)
{
$n1 = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
array_push($nested_data, array(
'jkod' => $n1.$a->jbkod,
'jnama' => $a->jnama,
'alam1' => $a->alam1,
'alam2' => $a->alam2,
'alam3' => $a->alam3,
'tindakan' => $a->_id
));
}
return \DataTables::of($nested_data)->make(true);
}
public function departmentDetail(Request $request)
{
$department = Department::where('_id',$request->get('id'))->first();
if(!empty($department)){
return response()->json(['status' => 'true', 'desc' => $department]);
}else{
return response()->json(['status' => 'false', 'desc' => 'Rekod ini tidak ditemui']);
}
}
public function deleteDepartment(Request $request)
{
$department = Department::where('_id',$request->get('jid'))->first();
if(!empty($department)){
$department->delete();
return response()->json(['status' => 'true', 'desc' => 'Buang rekod jabatan ( '.$department->jnama.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod jabatan ( '.$department->jnama.' )']);
}
}
public function filterDepartmentBasedFaulty($id)
{
$data = array();
$faulty = Faulty::with('Department')->where('_id',$id)->first();
if(!empty($faulty)){
if(!empty($faulty->Department)){
foreach ($faulty->Department as $key => $k) {
array_push($data, array(
'_id' => $k->_id,
'nama' => '['.$k->jbkod.'] '.$k->jnama
));
}
}
return $this->sendResponse($data, 'Rekod Ditemui');
}else{
return $this->sendError('', 'Rekod Ditemui');
}
}
/**
* Create a acts & uuk list controller.
*
* @return json
*/
public function deedLawList()
{
$nested_data = array();
$akta = DeedLaw::with('Department')->orderBy('updated_at', 'desc')->get();
$curr = Carbon::now()->getTimestamp();
foreach($akta as $key => $a)
{
$n1 = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$temp = [];
if(!empty($a->Department)){
foreach ($a->Department as $key => $d) {
$temp[] = $d->jbkod;
$jabatan = implode( ", ", $temp );
}
}else{
$jabatan = '-';
}
array_push($nested_data, array(
'tarikh' => $n1.$a->tarikh,
'jbkod' => $jabatan,
'nama' => $a->nama,
'tindakan' => $a->_id
));
}
return \DataTables::of($nested_data)->make(true);
}
public function officerDeedLawList($id)
{
$nested_data = array(); $temp = [];
$curr = Carbon::now()->getTimestamp();
$department = Department::with(['DeedLaw' => function($q){
$q->with('Department');
}])->whereHas('StaffDetail', function($q) use ($id) {
$q->where('_id', $id);
})->get();
if(!empty($department)){
foreach ($department as $key => $de) {
if(!empty($de->DeedLaw)){
foreach ($de->DeedLaw as $key => $law) {
if(!in_array($law->_id, (array)$temp)) {
$temp[] = $law;
}
}
}
}
}
if(!empty($temp)){
foreach($temp as $a) {
$n1 = ''; $jabatan = '-';
$reg_time = $a['updated_at'];
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$tempJ = [];
foreach ($a->Department as $key => $d) {
if(!empty($a->Department)){
$tempJ[] = $d->jbkod;
}
}
$jabatan = implode( ", ", $tempJ );
array_push($nested_data, array(
'tarikh' => $n1.$a->tarikh,
'jbkod' => $jabatan,
'nama' => $a->nama,
'tindakan' => $a->_id
));
}
}
return \DataTables::of($nested_data)->make(true);
}
public function deedLawDetail(Request $request)
{
$akta = DeedLaw::where('_id',$request->get('id'))->first();
if(!empty($akta)){
return response()->json(['status' => 'true', 'desc' => $akta]);
}else{
return response()->json(['status' => 'false', 'desc' => 'Rekod ini tidak ditemui']);
}
}
public function deleteDeedLaw(Request $request)
{
$akta = DeedLaw::where('_id',$request->get('aid'))->first();
if(!empty($akta)){
$akta->department()->detach();
$akta->delete();
return response()->json(['status' => 'true', 'desc' => 'Buang rekod akta/uuk ( '.$akta->nama.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => '( Buang rekod akta/uuk ( '.$akta->nama.' )']);
}
}
public function getDeedlawBasedFaulty($id)
{
$data = array();
$faulty = Faulty::with('DeedLaw')->where('_id',$id)->first();
if(!empty($faulty)){
if(!empty($faulty->DeedLaw)){
return $this->sendResponse($faulty->DeedLaw->nama, 'Rekod Ditemui');
}
}else{
return $this->sendError('', 'Rekod Ditemui');
}
}
/**
* Create a faulty list controller.
*
* @return json
*/
public function faultyList()
{
$nested_data = array(); $jabatan = '-'; $n1 = '';
$faulty = Faulty::with('DeedLaw','Department')->orderBy('updated_at', 'DESC')->get();
$curr = Carbon::now()->getTimestamp();
foreach($faulty as $k) {
$tempJ = []; $jabatan = '-';
$reg_time = $k->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
if(!empty($k->DeedLaw) && !empty($k->Department)){
foreach($k->Department as $d){
$tempJ[] = $d->jbkod;
$jabatan = implode( ", ", $tempJ );
}
array_push($nested_data, array(
'jbkod' => $n1.$jabatan,
'akkod' => $k->DeedLaw->akkod,
'sketr' => $k->sketr,
'nama' => $k->nama,
'amount14' => $k->amount_before_14,
'amount30' => $k->amount_before_30,
'amount' => $k->amount,
'tindakan' => $k->_id,
));
}
}
return \DataTables::of($nested_data)->make(true);
}
public function officerFaultyList($id)
{
$nested_data = array(); $jabatan = ''; $temp = [];
$curr = Carbon::now()->getTimestamp();
$department = Department::with(['Faulty' => function($q){
$q->with('Department');
}])->whereHas('StaffDetail', function($q) use ($id) {
$q->where('_id', $id);
})->get();
if(!empty($department)){
foreach ($department as $key => $de) {
if(!empty($de->Faulty)){
foreach ($de->Faulty as $key => $faulty) {
if(!in_array($faulty->_id, (array)$temp)) {
$temp[] = $faulty;
}
}
}
}
}
foreach($temp as $k)
{
$n1 = ''; $jabatan = '-';
$reg_time = $k->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$tempJ = [];
foreach ($k->Department as $key => $d) {
if(!empty($k->Department)){
$tempJ[] = $d->jbkod;
}
}
$jabatan = implode( ", ", $tempJ );
if(!empty($temp)){
foreach($temp as $d){
array_push($nested_data, array(
'jbkod' => $n1.$jabatan,
'akkod' => $k->DeedLaw->akkod,
'sketr' => $k->sketr,
'nama' => $k->nama,
'amount14' => $k->amount_before_14,
'amount30' => $k->amount_before_30,
'amount' => $k->amount,
'tindakan' => $k->_id,
));
}
}
}
return \DataTables::of($nested_data)->make(true);
}
public function faultyListFilter($jbkod,$akkod)
{
$faulty = Faulty::where('department_ids',$jbkod)->where('deed_law_id', $akkod)->get();
if(!empty($faulty)){
return $this->sendResponse($faulty, 'Rekod Ditemui');
}else{
return $this->sendError('', 'Rekod Ditemui');
}
}
public function faultyDetail(Request $request)
{
$jabatan = '-';
$faulty = Faulty::with('DeedLaw','Department')->where('_id',$request->get('id'))->first();
if(!empty($faulty)){
if(!empty($faulty->Department)){
foreach($faulty->Department as $d){
$tempJ[] = $d->jbkod;
$jabatan = implode( ", ", $tempJ );
}
}
$data = [
'_id' => $faulty->_id,
'jbkod' => $jabatan,
'akkod' => $faulty->DeedLaw->_id,
'itkod' => $faulty->itkod,
'sketr' => $faulty->sketr,
'nama' => $faulty->nama,
'amount14' => $faulty->amount_before_14,
'amount30' => $faulty->amount_before_30,
'amount' => $faulty->amount,
];
return response()->json(['status' => 'true', 'desc' => $data]);
}else{
return response()->json(['status' => 'false', 'desc' => 'Rekod ini tidak ditemui']);
}
}
public function deleteFaulty(Request $request)
{
$faulty = Faulty::where('_id',$request->get('kid'))->first();
if(!empty($faulty)){
$faulty->department()->detach();
$faulty->delete();
return response()->json(['status' => 'true', 'desc' => 'Buang rekod seksyen/kesalahan ( '.$faulty->nama.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod seksyen/kesalahan ( '.$faulty->nama.' )']);
}
}
/**
* Create fetch data deedlaw & faulty based on staff login.
*
* @return json
*/
public function requestStaffDepartment(Request $request){
$staff = Staff::with(['StaffDetail' => function($q){
$q->with('Department');
}])->where('api_token', $request->api_token)->first();
$department = $staff->StaffDetail->Department;
$data = array();
if(!empty($staff)){
if(!empty($department)){
foreach ($department as $key => $k) {
array_push($data, array(
'_id' => $k->_id,
'jbkod' => $k->jbkod,
'nama' => '['.$k->jbkod.'] '.$k->jnama
));
}
return $this->sendResponse($data, 'Berjaya, mendapatkan akta kesalahan');
}else{
return $this->sendError('Gagal', 'Maaf, data akta kesalahan tidak ditemui');
}
}else {
return $this->sendError('Gagal', 'Maaf, penguatkuasa tidak wujud');
}
}
public function requestStaffDeedLaw(Request $request){
$staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
// $department = $request->department;
// $deedlaw = DeedLaw::with('Department');
// $deedlaw->whereHas('Department', function($q) use ($department) {
// $q->whereIn('_id', $department);
// });
$temp = [];
if(!empty($staff)){
$data = array();
$detail = StaffDetail::with(['Department' => function($q) {
$q->with('DeedLaw');
}])->where('_id', $staff->_id)->first();
foreach ($detail->Department as $key => $d) {
foreach ($d->DeedLaw as $key => $de) {
if(!in_array($de->_id, array_column((array)$d->DeedLaw, '_id'))){
$temp[] = $de;
}
}
}
if(!empty($temp)){
foreach ($temp as $key => $k) {
array_push($data, array(
'akkod' => $k->_id,
'tarikh' => $k->tarikh,
'nama' => '['.$k->akkod.'] '.$k->nama
));
}
return $this->sendResponse($data, 'Berjaya, mendapatkan akta kesalahan');
}else{
return $this->sendError('Gagal', 'Maaf, data akta kesalahan tidak ditemui');
}
}else {
return $this->sendError('Gagal', 'Maaf, penguatkuasa tidak wujud');
}
}
public function requestStaffFaulty(Request $request){
$staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
if(!empty($staff)){
$data = array();
$faulty = Faulty::with('Department')->where('deed_law_id', $request->akkod);
$department = $request->department;
$faulty->whereHas('Department', function($q) use ($department) {
$q->where('_id', $department);
});
$faulty = $faulty->get();
if(!empty($faulty)){
foreach($faulty as $k){
array_push($data, array(
'itkod' => $k->_id,
'sketr' => $k->sketr,
'nama' => '['.$k->sketr.'] '.$k->nama,
'jumlah' => $k->amount,
'kadar_sebelum_14' => $k->amount_before_14,
'kadar_sebelum_30' => $k->amount_before_30,
));
}
return $this->sendResponse($data, 'Berjaya, mendapatkan seksyen kesalahan');
}else {
return $this->sendError('Gagal', 'Maaf, data seksyen kesalahan tidak ditemui');
}
}else {
return $this->sendError('Gagal', 'Maaf, penguatkuasa tidak wujud');
}
}
}

+ 38
- 0
app/Http/Controllers/Api/EpbtController.php 查看文件

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use App\Model\Database\EPBT;
use Carbon\Carbon;
use Config;
use File;
use DB;
class EpbtController extends BaseController
{
/**
* Create compound list controller.
*
* @return json
*/
public function getEPBTCukai(Request $request){
try {
DB::connection('oracle')->getPdo();
$data = EPBT::where('akaun', $request->acc)->get();
if(!empty($data)) {
return $this->sendResponse($data, ' Berjaya dapatkan rekod akaun');
}else{
return $this->sendError('', 'Rekod akaun tidak ditemui');
}
} catch (\Exception $e) {
die("Could not connect to the database. Please check your configuration. error:" . $e );
}
}
}

+ 405
- 0
app/Http/Controllers/Api/InventoryController.php 查看文件

@@ -0,0 +1,405 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Roles;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\ItemInventory;
use App\Model\Module\Barcode;
use App\Model\Module\Attachment;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Jobs\GenerateBarcode;
class InventoryController extends BaseController
{
/**
* Create generate kpd number controller.
*
* @return value
*/
public function iventoryList($no_siri){
$nested_data = array();
$file = ConfidentialFile::with(['ItemInventory' => function($q){
$q->with('Attachment','Barcode')->orderBy('created_at','DESC');
}])->where('no_siri',$no_siri)->first();
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($file->ItemInventory as $i)
{
$n1 = '';
$reg_time = $i->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$lokasi = '-';
if($i->lokasi_gudang != '-'){
$lokasi = $i->lokasi_gudang;
}
array_push($nested_data, array(
'tarikh' => $i->created_at->format('d/m/Y'),
'masa' => $i->created_at->format('h:i a'),
'jenis' => $i->jenis,
'bilangan' => $i->bilangan,
'harga' => $i->harga,
'lokasi' => $lokasi,
'status' => $i->status,
'tindakan' => $i->_id
));
}
return \DataTables::of($nested_data)->make(true);
}
public function getDetail(Request $request){
$empty_attach = false; $empty_barcode = false;
$itemI = ItemInventory::with('Attachment','Barcode')->where('_id',$request->id)->first();
if(!empty($itemI)){
$data = [
'_id' => $itemI->_id,
'kategori' => $itemI->kategori,
'jenis' => $itemI->jenis,
'bilangan' => $itemI->bilangan,
'harga' => $itemI->harga,
'lokasi' => $itemI->lokasi_gudang,
'status' => $itemI->status
];
return response()->json(['status' => 'true', 'desc' => $data]);
}else{
return response()->json(['status' => 'false', 'desc' => 'Rekod item ( '.$itemI->jenis.' ) tidak ditemui']);
}
}
public function deleteItem(Request $request){
$empty_attach = false; $empty_barcode = false;
$itemI = ItemInventory::with('Attachment','Barcode')->where('_id',$request->id)->first();
if(!empty($itemI)){
$user = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
if(!empty($itemI->Attachment)){
foreach($itemI->Attachment as $a){
$a->delete();
}
$empty_attach = true;
}else{
$empty_attach = true;
}
if(!empty($itemI->Barcode)){
foreach($itemI->Barcode as $b){
$b->delete();
}
$empty_barcode = true;
}else{
$empty_barcode = true;
}
if($empty_attach == true && $empty_barcode == true){
$itemI->delete();
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Pembuangan item inventori",
'huraian' => "Rekod Item inventori telah dibuang oleh ".$user->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return response()->json(['status' => 'true', 'desc' => 'Berjaya buang rekod item ( '.$itemI->jenis.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Tidak berjaya buang rekod item ( '.$itemI->jenis.' )']);
}
}else{
return response()->json(['status' => 'false', 'desc' => 'Rekod item tidak ditemui']);
}
}
/**
* Create generate kpd number controller.
*
* @return value
*/
public function iventoryListMobile(Request $request){
$nested_data = array();
$staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
if(!empty($staff)){
$file = ConfidentialFile::with(['ItemInventory' => function($q){
$q->with('Attachment','Barcode')->orderBy('created_at','DESC');
}])->where('no_siri',$request->no_siri)->first();
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($file->ItemInventory as $i) {
$n1 = '';
$reg_time = $i->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$lokasi = '-';
if($i->lokasi_gudang != '-'){
$lokasi = $i->lokasi_gudang;
}
array_push($nested_data, array(
'tarikh' => $i->created_at->format('d/m/Y'),
'masa' => $i->created_at->format('h:i a'),
'jenis' => $i->jenis,
'bilangan' => $i->bilangan,
'harga' => $i->harga,
'lokasi' => $lokasi,
'status' => $i->status,
'tindakan' => $i->_id
));
}
return $this->sendResponse($nested_data, 'Berjaya dapatkan senarai inventori');
}else{
return $this->sendError('', 'Tidak ada rekod ditemui');
}
}
public function addItemMobile(Request $request){
$data = array();
$staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
if(!empty($staff)){
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
if(!empty($compound)){
$item = [
'kategori' => 'alih',
'jenis' => $request->get('jenis'),
'bilangan' => $request->get('bilangan'),
'harga' => $request->get('harga'),
'lokasi_gudang' => $request->get('lokasi'),
'status' => 'simpan'
];
$itemI = ItemInventory::create($item);
array_push($data, $itemI);
$compound->ConfidentialFile->iteminventory()->save($itemI);
if($request->has('barcode')) {
$temp_barcode = explode(',', $request->barcode);
foreach ($temp_barcode as $key => $b) {
$this->dispatch(new GenerateBarcode($request->kpd, $b, $itemI));
}
}
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Ada penambahan item inventori dari penguatkuasa",
'huraian' => "Item inventori telah ditambah oleh ".$staff->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return $this->sendResponse($data, 'Berjaya simpan item');
}else{
return $this->sendError('', 'Tiada rekod ditemui');
}
}
else{
return $this->sendError('', 'Kakitangan tidak ditemui');
}
}
public function addItemPictureMobile(Request $request){
$staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
if(!empty($staff)){
$itemI = ItemInventory::where('_id', $request->_id)->first();
if(!empty($itemI)){
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
if(!empty($compound)){
$success_upload = 0; $count_upload = 0;
if($request->hasFile('file')) {
$i = 1;
$destinationGambarItem = 'document/'.$compound->ConfidentialFile->no_siri.'/item';
$uploaded = public_path().'/'.$destinationGambarItem;
if(!File::isDirectory($destinationGambarItem)){
File::makeDirectory($destinationGambarItem, 0777, true, true);
}
$allowedfileExtension = ['jpg','jpeg'];
$destinationPathPicture = array();
$count_upload = count($request->file('file'));
foreach($request->file('file') as $f){
$extension = $f->getClientOriginalExtension();
$check=in_array($extension,$allowedfileExtension);
if($check) {
$name = 'Item-'.$i++.'.'.$f->getClientOriginalExtension();
$destinationPathPicture[] = '/'.$destinationGambarItem.'/'.$name;
$f->move($destinationGambarItem, $name);
$attach = new Attachment();
$attach->path = '/'.$destinationGambarItem.'/'.$name;
$itemI->attachment()->save($attach);
$i++;
}
}
return $this->sendResponse($destinationPathPicture, $success_upload.'/'.$count_upload.' picture compound successfully been uploaded');
}else{
return $this->sendError('', 'Tidak ada fail dimuatnaik');
}
}else{
return $this->sendError('', 'Tidak ada rekod ditemui');
}
}else{
return $this->sendError('', 'Tidak ada rekod ditemui');
}
}
else{
return $this->sendError('', 'Tidak ada rekod ditemui');
}
}
public function deleteItemMobile(Request $request){
$empty_attach = false; $empty_barcode = false;
$staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
if(!empty($staff)){
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
$itemI = ItemInventory::with('Attachment','Barcode')->where('_id',$request->id)->first();
if(!empty($itemI)){
if(!empty($itemI->Attachment)){
foreach($itemI->Attachment as $a){
$a->delete();
}
$empty_attach = true;
}else{
$empty_attach = true;
}
if(!empty($itemI->Barcode)){
foreach($itemI->Barcode as $b){
$b->delete();
}
$empty_barcode = true;
}else{
$empty_barcode = true;
}
if($empty_attach == true && $empty_barcode == true){
$itemI->delete();
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Pembuangan item inventori",
'huraian' => "Rekod Item inventori telah dibuang oleh ".$staff->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return $this->sendResponse('','Buang rekod item ( '.$itemI->jenis.' )');
}else{
return $this->sendError('','Buang rekod item ( '.$itemI->jenis.' )');
}
}else{
return $this->sendError('','Rekod item tidak ditemui');
}
}
}
public function getDetailMobile(Request $request){
$data = array();
$staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
if(!empty($staff)){
$barcode = Barcode::where('barcode_id',$request->barcode)->first();
if(!empty($barcode)){
$itemI = ItemInventory::with('Attachment')->where('_id',$barcode->item_inventory_id)->first();
if(!empty($itemI)){
array_push($data, $itemI);
return $this->sendResponse($data, 'Rekod item ditemui');
}else{
return $this->sendError('','Rekod item ditemui');
}
}else{
return $this->sendError('','Barcode tidak ditemui');
}
}else{
return $this->sendError('','Kakitangan tidak ditemui');
}
}
}

+ 114
- 0
app/Http/Controllers/Api/InvestigationController.php 查看文件

@@ -0,0 +1,114 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Validator;
use Session;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\CompoundInvestigation;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Investigation;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
class InvestigationController extends BaseController
{
/**
* Create a investigation list controller.
*
* @return json
*/
public function investigationAttachmentList($no_siri)
{
$nested_data = array();
$file = ConfidentialFile::with(['Investigation' => function($q){
$q->orderBy('updated_at', 'desc');
}])->where('no_siri',$no_siri)->first();
$curr = Carbon::now()->getTimestamp();
if(!empty($file->Investigation)){
foreach($file->Investigation as $a)
{
$n1 = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
array_push($nested_data, array(
'tarikh' => $n1.$a->updated_at->format('d/m/Y'),
'masa' => $a->updated_at->format('h:i A'),
'subjek' => $a->subjek,
'kategori' => $a->kategori,
'tindakan' => $a->_id
));
}
}
return \DataTables::of($nested_data)->make(true);
}
public function deleteAttachment(Request $request)
{
$staff = Staff::with('StaffDetail')->where('_id',$request->staff)->first();
if(!empty($staff)){
$attach = Investigation::with('Attachment')->where('_id',$request->id)->first();
if(!empty($attach->Attachment)){
foreach($attach->Attachment as $a){
$a->delete();
}
$attach->delete();
$file = ConfidentialFile::where('no_siri',$request->no_siri)->first();
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $file->no_siri,
'tajuk' => $staff->StaffDetail->roles_access." ".$staff->StaffDetail->full_name." mengemaskini pengesahan kompaun ".$request->kpd,
'huraian' => "Rekod lampiran ".$attach->kategori." (".$attach->subjek.") dikemaskini/di buang oleh ".$staff->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$file->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$file->history()->attach($history);
}
return response()->json(['status' => 'true', 'desc' => 'Buang rekod lampiran ( '.$attach->subjek.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod lampiran ( '.$attach->subjek.' )']);
}
}
}
}

+ 104
- 0
app/Http/Controllers/Api/JobController.php 查看文件

@@ -0,0 +1,104 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Requests\RegisterRequest;
use App\Http\Controllers\Api\BaseController;
use Illuminate\Support\Facades\Auth;
use Hash;
use Carbon\Carbon;
use Crypt;
use File;
use Mail;
use App\Model\Module\Compound;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\Memo;
use App\Jobs\UpdateCompoundPrice;
use App\Jobs\SendNoticeLetter;
class JobController extends BaseController
{
/**
* Create a cron job list controller.
*
* @return json
*/
public function JobMemo(){
$kpd = 'null';
Compound::with('ConfidentialFile','Faulty')->where('status','Belum Bayar')->chunk(300, function($compounds){
foreach ($compounds as $key => $c) {
$curr = Carbon::now()->getTimestamp();
$tarikh_keluar = $c->created_at;
$tempoh_hari7 = $tarikh_keluar->addDays(7)->getTimestamp();
$tempoh_hari14 = $tarikh_keluar->addDays(14)->getTimestamp();
$tempoh_hari30 = $tarikh_keluar->addDays(30)->getTimestamp();
if($curr <= $tempoh_hari7){
if($c->Faulty->amount_before_14 != '0'){
$c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_14;
$c->save();
}
}else if($curr > $tempoh_hari7 && $curr <= $tempoh_hari14){
if($c->Faulty->amount_before_14 != '0'){
$c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_30;
$c->save();
}
}else if($curr > $tempoh_hari14 && $curr <= $tempoh_hari30){
if($c->Faulty->amount_before_30 != '0'){
$c->jumlah_kemaskini_kompaun = '';
$c->save();
}
}else if($curr > $tempoh_hari30){
$c->jumlah_kemaskini_kompaun = '';
$c->save();
}
// //Update Memo
// if(!empty($c->ConfidentialFile)){
// foreach ($c->ConfidentialFile->memo as $key => $m) {
// $start = $m->tarikh_mula;
// $akhir = $m->tarikh_akhir;
// $start_date = strtotime($start);
// $expiry_date = strtotime($akhir);
// if($m->disahkan != ''){
// if($curr >= $start_date && $curr <= $expiry_date) {
// if($m->jenis_memo == "Tambahan"){
// $price = (float)$c->jumlah_asal_kompaun;
// $addition = (int)$m->tawaran_kompaun;
// $harga_tawaran = number_format( $price + ($price * ($addition / 100)) , 2);
// $c->jumlah_kemaskini_kompaun = $harga_tawaran;
// $c->save();
// }else if($m->jenis_memo == "Lain-lain"){
// }
// }else{
// $c->jumlah_kemaskini_kompaun = '';
// $c->save();
// }
// }
// }
// }
}
});
echo 'finished';
// $this->dispatch(new UpdateCompoundPrice($kpd));
}
public function sendLetterNotice(){
$this->dispatch(new SendNoticeLetter());
}
}

+ 32
- 0
app/Http/Controllers/Api/KelantanPayController.php 查看文件

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
class KelantanPayController extends BaseController
{
/**
* Create compound list controller for kelantanpay.
*
* @return json
*/
public function viewCompoundPersonal(Request $request)
{
$compound = Compound::with('ConfidentialFile')->where('identity',$request->data)->orWhere('kpd',$request->data)->get();
if(count($compound) > 0){
return $this->sendResponse($compound, 'Result Found');
}else {
return $this->sendResponse('', 'No Result');
}
}
}

+ 135
- 0
app/Http/Controllers/Api/LoginController.php 查看文件

@@ -0,0 +1,135 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Requests\RegisterRequest;
use App\Http\Controllers\Api\BaseController;
use Illuminate\Support\Facades\Auth;
use Hash;
use Carbon\Carbon;
use Crypt;
use File;
use Mail;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\User;
use App\Model\UserDetail;
class LoginController extends BaseController
{
/**
* Create a login list controller.
*
* @return json
*/
public function requestStaffLogin(Request $request) {
$user = ''; $data = array();
$rememberMe = false;
$user = Staff::with(['StaffDetail' => function($q){
$q->select('_id','full_name','identity','mobile','address','gred','no_badan','roles_access','profile_img');
}])->where('no_badan',$request->no_badan)->where(function($q){
$q->where('roles_access','PenguatKuasa')->orWhere('roles_access','PPenguatKuasa');
})->first();
if (!empty($user)) {
if(Hash::check($request->password, $user->password)){
// Check authorized
do {
$user->last_login_at = Carbon::now(new \DateTimeZone('Asia/Kuala_Lumpur'))->toDateTimeString();
$user->last_login_ip = $request->getClientIp();
$user->api_token = '';
$user->authorized = false;
$user->save();
}while($user->authorized);
$token_id = '';
do {
$token_id = str_random(32);
} while (Staff::where("token_id", "=", $token_id)->first() instanceof Staff);
$user->api_token = $token_id;
$user->last_login_at = Carbon::now(new \DateTimeZone('Asia/Kuala_Lumpur'))->toDateTimeString();
$user->last_login_ip = $request->getClientIp();
$user->authorized = true;
$user->token_firebase = '';
$user->save();
$staff = StaffDetail::with('Department')->where('_id', $user->_id)->first();
if(!empty($staff->Department)){
foreach ($staff->Department as $key => $d) {
$tempJ[] = $d->_id;
}
$jabatan = implode( ", ", $tempJ );
}
array_push($data, array(
'User' => $user->StaffDetail,
'token' => $user->api_token,
'jawatan' => $user->StaffDetail->gred,
'token_firebase' => $user->token_firebase,
'jbkod' => $jabatan
));
return $this->sendResponse($data, 'Berjaya log masuk');
}else {
return $this->sendError('Gagal', 'Emel atau kata-laluan tidak tepat');
}
}else {
return $this->sendError('Gagal', 'Rekod tidak dijumpai');
}
}
public function requestStaffLogout(Request $request){
$loginUser = Staff::where('api_token', $request->api_token)->first();
if(!empty($loginUser)){
$loginUser->last_login_at = Carbon::now(new \DateTimeZone('Asia/Kuala_Lumpur'))->toDateTimeString();
$loginUser->last_login_ip = $request->getClientIp();
$loginUser->api_token = '';
$loginUser->authorized = false;
$loginUser->save();
return $this->sendResponse('Berjaya', 'Berjaya log keluar');
}else {
return $this->sendError('Gagal', 'Maaf, penguatkuasa tidak dapat log keluar');
}
}
// public function resetPassword(Request $request)
// {
// $data = array();
// $staff = Staff::where('api_token', $request->api_token)->first();
// if(!empty($staff))
// {
// $ic_num = StaffDetail::with('Staff')->where('identity', $request->ic_number)->first();
// $id = $ic_num->_id;
// if(!empty($id))
// {
// $staffID = Staff::where('_id', $id)->first();
// $staffID->password = $request->new_password;
// }
// else
// {
// return $this->sendError('Gagal', 'Identiti tidak dijumpai');
// }
// }
// else
// {
// return $this->sendError('Gagal', 'penguatkuasa tidak wujud');
// }
// }
}

+ 164
- 0
app/Http/Controllers/Api/MemoController.php 查看文件

@@ -0,0 +1,164 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
use App\Model\Module\Attachment;
use App\Model\Module\Faulty;
use App\Model\Module\Memo;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Compound;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Jobs\UpdateCompoundPrice;
class MemoController extends BaseController
{
/**
* Create a memo list controller.
*
* @return json
*/
public function memoList($no_siri){
$nested_data = array();
$memo = ConfidentialFile::with(['Memo' => function($q){
$q->orderBy('updated_at', 'desc');
}])->where('no_siri',$no_siri)->first();
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($memo->Memo as $a)
{
$n1 = ''; $dikeluarkan = ''; $disahkan = ''; $modul = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$staffD = Staff::with('StaffDetail')->where('_id',$a->dikeluarkan)->first();
if(!empty($staffD)){
$dikeluarkan = $staffD->StaffDetail->full_name;
}
$staffS = Staff::with('StaffDetail')->where('_id',$a->disahkan)->first();
if(!empty($staffS)){
$disahkan = $staffD->StaffDetail->full_name;
}
if($a->modul != '-'){
$modul = Roles::where('kod',$a->modul)->first();
$modul = $modul->name;
}else{
$modul = '-';
}
array_push($nested_data, array(
'index' => $n1.$i,
'modul' => $modul,
'jenis' => $a->jenis_memo,
'no_rujukan' => $a->no_rujukan,
'mula' => date('d/m/Y h:i a', strtotime($a->tarikh_mula)),
'akhir' => date('d/m/Y h:i a', strtotime($a->tarikh_akhir)),
'dikeluakan' => $dikeluarkan,
'disahkan' => $disahkan,
'tindakan' => $a->_id
));
$i++;
}
return \DataTables::of($nested_data)->make(true);
}
public function deleteMemo(Request $request){
$staff = Staff::with('StaffDetail')->where('_id',$request->staff)->first();
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
$memo = Memo::with('Attachment')->where('_id',$request->id)->first();
$compound->ConfidentialFile->memo()->detach($memo);
if(!empty($memo)){
if($memo->jenis_data == "pdf"){
$memo->attachment()->delete();
$memo->delete();
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => $staff->StaffDetail->roles_access." ".$staff->StaffDetail->full_name." mengemaskini memo ".$memo->no_rujukan,
'huraian' => "Rekod memo (".$memo->no_rujukan.") dikemaskini/di buang oleh ".$staff->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
$this->dispatch(new UpdateCompoundPrice($request->kpd));
return response()->json(['status' => 'true', 'desc' => 'Buang rekod memo ( '.$memo->no_rujukan.' )']);
}else if($memo->jenis_data == "manual"){
$memo->delete();
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => $staff->StaffDetail->roles_access." ".$staff->StaffDetail->full_name." mengemaskini memo ".$memo->no_rujukan,
'huraian' => "Rekod memo (".$memo->no_rujukan.") dikemaskini/di buang oleh ".$staff->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
$this->dispatch(new UpdateCompoundPrice($request->kpd));
return response()->json(['status' => 'true', 'desc' => 'Buang rekod memo ( '.$memo->no_rujukan.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod memo ( '.$memo->no_rujukan.' )']);
}
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod memo ( '.$memo->no_rujukan.' )']);
}
}
}

+ 208
- 0
app/Http/Controllers/Api/PaymentController.php 查看文件

@@ -0,0 +1,208 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\ReportPayment;
use App\Model\Module\ApiIntegration;
class PaymentController extends BaseController
{
/**
* Create compound list controller for kelantanpay.
*
* @return json
*/
public function paymentCompound(Request $request)
{
$data = array();
$staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
if(empty($staff)){
return $this->sendError('Gagal', 'penguatkuasa tidak wujud');
}else {
$compound = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
if (!empty($compound)) {
$jumlah = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$jumlah = $compound->jumlah_asal_kompaun;
}else{
$jumlah = $compound->jumlah_kemaskini_kompaun;
}
if($request->jumlah_bayar != $jumlah){
array_push($data, array(
'kpd' => $request->kpd,
'jumlah_kompaun' => $jumlah,
'jumlah_bayar' => $request->jumlah_bayar,
));
return $this->sendError($data, 'Jumlah yang dibayar tidak sama dengan jumlah kompaun!');
}else{
if($compound->status == 'Belum Bayar'){
$kompaun = Compound::where('kpd', $request->kpd)->first();
$kesalahan = Faulty::where('itkod', $kompaun->seksyen_kesalahan)->first();
$reportData = [
'name' => $request->name,
'kesalahan' => $kesalahan->nama,
'kpd' => $request->kpd,
'nric' => $request->ic,
'mobile' => $request->telefon,
'email' => $request->email,
'total' => $request->jumlah_bayar,
'penguatkuasa' => $staff->no_badan,
];
$report = ReportPayment::create($reportData);
$compound->status = 'Berbayar';
$compound->receipt = $request->receipt;
$compound->amount_payment = $jumlah;
$compound->save();
array_push($data, array(
'kpd' => $request->kpd,
'amount' => $jumlah,
));
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Pembayaran kompaun ".$request->kpd." telah dibuat secara tunai",
'huraian' => "Pembayaran tunai diserahkan kepada ".$staff->roles_access." <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return $this->sendResponse($data, 'Kompaun ini berjaya dibayar!');
}else if($compound->status == 'Berbayar'){
array_push($data, array(
'kpd' => $request->kpd,
'amount' => $jumlah,
));
return $this->sendError($data, 'Kompaun ini dah dibayar!');
}
}
}else {
return $this->sendError($data, 'Tiada data');
}
}
}
public function updatePayment(Request $request){
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->orderid)->first();
if(!empty($compound)){
$compound->status = 'Berbayar';
$compound->save();
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Pembayaran kompaun ".$request->orderid." telah dibuat secara 'online'",
'huraian' => "Pembayaran kompaun ".$request->orderid." telah dijelaskan pada hari ini.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return $this->sendResponse('', 'status pembayaran kompaun berjaya dikemaskini dari BELUM BAYAR ke BERBAYAR');
}else{
return $this->sendError('', 'status pembayaran kompaun tidak dapat dikemaskini sebab rekod tidak dijumpai');
}
}
public function reportpaymentList(){
$nested_data = array();
$report = ReportPayment::orderBy('updated_at','DESC')->get();
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($report as $a)
{
$n1 = ''; $enforcer = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$staff = Staff::with('StaffDetail')->where('_id',$a->penguatkuasa)->first();
if(!empty($staff)){
$enforcer = '['.$staff->no_badan.'] '.$staff->StaffDetail->full_name;
}
// $noKPD = Compound::where('kpd', $a->kpd)->first();
// $namaSeksyen = Faulty::where('itkod',$a->seksyen_kesalahan)->first();
array_push($nested_data, array(
'#' => $n1.$i,
'kpd' => $a->kpd,
'nama' => $a->name,
'kesalahan' => $a->kesalahan,
'identity' => $a->nric,
'mobile' => $a->mobile,
'email' => $a->email,
'jumlah' => 'Rm '.$a->total,
'no_badan' => $enforcer,
));
$i++;
}
return \DataTables::of($nested_data)->make(true);
}
}

+ 245
- 0
app/Http/Controllers/Api/RestfulapiController.php 查看文件

@@ -0,0 +1,245 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Compound;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
use App\Model\Module\ApiIntegration;
use App\Jobs\StoreCompound;
use App\Jobs\UpdateCompoundPrice;
class RestfulapiController extends BaseController
{
/**
* Create search compound by category controller.
*
* @return json
*/
public function searchIdentity($request){
$compound = Compound::with('Faulty','Department','DeedLaw')->where('identity',$request)->get();
return $compound;
}
public function searchKpd($request){
$compound = Compound::with('Faulty','Department','DeedLaw')->where('kpd','like',$request)->get();
return $compound;
}
public function searchSyarikat($request){
$compound = Compound::with('Faulty','Department','DeedLaw')->where('no_daftar_syarikat','like',$request)->get();
return $compound;
}
public function searchPlate($request){
$compound = Compound::with('Faulty','Department','DeedLaw')->where('no_plate','like',$request)->get();
return $compound;
}
/**
* Create search compound controller.
*
* @return json
*/
public function viewCompoundPersonal(Request $request)
{
$compound = array();
$search = $request->search;
$api_integrasi = ApiIntegration::where('key', $request->key)->first();
if(!empty($api_integrasi)){
if($api_integrasi->status == 'active'){
if($search != '' && $search != '-'){
if(count($this->searchIdentity($search)) > 0){
$compound = $this->searchIdentity($search);
}
if(count($this->searchKpd($search)) > 0){
$compound = $this->searchKpd($search);
}
if(count($this->searchSyarikat($search)) > 0){
$compound = $this->searchSyarikat($search);
}
if(count($this->searchPlate($search)) > 0){
$compound = $this->searchPlate($search);
}
$data = array();
if(count($compound) > 0){
foreach($compound as $c){
// $department = Department::where('_id',$c->jbkod)->first();
// $faulty = Faulty::where('_id',$c->seksyen_kesalahan)->first();
// $akta = DeedLaw::where('_id',$faulty->deed_law_id)->first();
if($c->jenis == 'Pelbagai'){
array_push($data,array(
"_id" => $c->_id,
"jenis" => $c->jenis,
"kpd"=> $c->kpd,
"nama"=> $c->nama,
"identity" => $c->identity,
"nama_syarikat" => $c->nama_syarikat,
"no_daftar_syarikat" => strtoupper($c->no_daftar_syarikat),
"alamat" => $c->alamat,
"no_plate" => strtoupper($c->no_plate),
"no_cukai_jalan" => $c->no_cukai_jalan,
"latlong" => $c->latlong,
"jbkod" => $c->Department->jnama,
"akta" => $c->DeedLaw->nama,
"seksyen_kesalahan" => "[".$c->Faulty->sketr."] ".$c->Faulty->nama,
"jumlah_asal_kompaun" => $c->jumlah_asal_kompaun,
"jumlah_kemaskini_kompaun" => $c->jumlah_kemaskini_kompaun,
"amount_payment" => $c->amount_payment,
"receipt" => $c->receipt,
"dikeluarkan" => $c->dikeluarkan,
"status" => $c->status,
"updated_at" => $c->updated_at->toDateTimeString(),
"created_at" => $c->created_at->toDateTimeString(),
));
}else if($c->jenis == 'Parkir'){
array_push($data,array(
"_id" => $c->_id,
"jenis" => $c->jenis,
"kpd"=> $c->kpd,
"no_plate" => strtoupper($c->no_plate),
"no_cukai_jalan" => $c->no_cukai_jalan,
"jenis_kenderaan" => $c->jenis_kenderaan,
"model_kenderaan" => $c->model_kenderaan,
"warna_kenderaan" => $c->warna_kenderaan,
"nama_taman" => $c->nama_taman,
"nama_jalan" => $c->nama_jalan,
"no_parking" => $c->no_parking,
"latlong" => $c->latlong,
"jbkod" => $c->Department->jnama,
"akta" => $c->DeedLaw->nama,
"seksyen_kesalahan" => "[".$c->Faulty->sketr."] ".$c->Faulty->nama,
"jumlah_asal_kompaun" => $c->jumlah_asal_kompaun,
"jumlah_kemaskini_kompaun" => $c->jumlah_kemaskini_kompaun,
"amount_payment" => $c->amount_payment,
"receipt" => $c->receipt,
"dikeluarkan" => $c->dikeluarkan,
"status" => $c->status,
"updated_at" => $c->updated_at->toDateTimeString(),
"created_at" => $c->created_at->toDateTimeString(),
));
}
}
return $this->sendResponse($data, 'Result Found');
}else {
return $this->sendResponse('', 'No Result');
}
}else{
return $this->sendError('Search field is compulsory!', '');
}
}else{
return $this->sendError('Invalid Api Key', '');
}
}else{
return $this->sendError('Invalid Api Key', '');
}
}
/**
* Create update compound controller.
*
* @return json
*/
public function updatePaymentIntegrasi(Request $request){
$api_integrasi = ApiIntegration::where('key', $request->key)->first();
if(!empty($api_integrasi)){
if($api_integrasi->status == 'active'){
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kp)->first();
if(!empty($compound)){
if($compound->status != 'Berbayar'){
$compound->status = 'Berbayar';
$compound->receipt = $request->receipt;
$compound->amount_payment = $request->amount;
$compound->save();
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Pembayaran kompaun ".$request->orderid." telah dibuat secara 'online'",
'huraian' => "Pembayaran kompaun ".$request->orderid." telah dijelaskan pada hari ini.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
$kpd = Compound::where('kpd', $request->kp)->first();
$department = Department::where('_id',$kpd->jbkod)->first();
$faulty = Faulty::where('_id',$kpd->seksyen_kesalahan)->first();
$akta = DeedLaw::where('_id',$faulty->deed_law_id)->first();
$data = [
"_id" => $kpd->_id,
"kpd"=> $kpd->kpd,
"nama"=> $kpd->nama,
"identity" => $kpd->identity,
"nama_syarikat" => $kpd->nama_syarikat,
"no_daftar_syarikat" => $kpd->no_daftar_syarikat,
"alamat" => $kpd->alamat,
"no_plate" => $kpd->no_plate,
"latlong" => $kpd->latlong,
"jbkod" => $department->jnama,
"akta" => "[".$akta->akkod."] ".$akta->nama,
"seksyen_kesalahan" => "[".$faulty->sketr."] ".$faulty->nama,
"jumlah_asal_kompaun" => $kpd->jumlah_asal_kompaun,
"jumlah_kemaskini_kompaun" => $kpd->jumlah_kemaskini_kompaun,
"amount_payment" => $kpd->amount_payment,
"receipt" => $kpd->receipt,
"dikeluarkan" => $kpd->dikeluarkan,
"status" => $kpd->status,
"updated_at" => $kpd->updated_at->toDateTimeString(),
"created_at" => $kpd->created_at->toDateTimeString(),
];
return $this->sendResponse($data, 'Successfully update compound status');
}else{
return $this->sendResponse('', 'This compound already been paid');
}
}else{
return $this->sendError('Record compound not found!', '');
}
}else{
return $this->sendError('Invalid Api Key', '');
}
}else{
return $this->sendError('Invalid Api Key', '');
}
}
}

+ 427
- 0
app/Http/Controllers/Api/SettingController.php 查看文件

@@ -0,0 +1,427 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\Faulty;
use App\Model\Module\Memo;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\TemplateNotice;
use App\Model\Module\Attachment;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\LetterNotice;
use App\Model\Module\ApiKey;
use App\Model\Module\ApiIntegration;
use App\Jobs\UpdateCompoundPrice;
use App\Jobs\SendNoticeLetter;
class SettingController extends BaseController
{
/**
* Create a memo list controller.
*
* @return json
*/
public function memoList(){
$nested_data = array();
$memo = Memo::with('Attachment')->where('modul','-')->orderBy('updated_at', 'desc')->get();
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($memo as $a)
{
$n1 = ''; $dikeluarkan = ''; $disahkan = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$staffD = Staff::with('StaffDetail')->where('_id',$a->dikeluarkan)->first();
if(!empty($staffD)){
$dikeluarkan = $staffD->StaffDetail->full_name;
}
$staffS = Staff::with('StaffDetail')->where('_id',$a->disahkan)->first();
if(!empty($staffS)){
$disahkan = $staffD->StaffDetail->full_name;
}
array_push($nested_data, array(
'index' => $n1.$i,
'itkod' => $a->itkod,
'jenis' => $a->jenis_memo,
'no_rujukan' => $a->no_rujukan,
'mula' => date('d/m/Y h:i a', strtotime($a->tarikh_mula)),
'akhir' => date('d/m/Y h:i a', strtotime($a->tarikh_akhir)),
'dikeluakan' => $dikeluarkan,
'disahkan' => $disahkan,
'tindakan' => $a->_id
));
$i++;
}
return \DataTables::of($nested_data)->make(true);
}
public function deleteMemo(Request $request){
$staff = Staff::with('StaffDetail')->where('_id',$request->staff)->first();
$memo = Memo::with('Attachment')->where('_id',$request->id)->first();
if(!empty($memo)){
if($memo->jenis_data == "pdf"){
$memo->attachment()->delete();
$memo->delete();
$compound = Compound::with('ConfidentialFile')->where('seksyen_kesalahan', $memo->itkod)->get();
$faulty = Faulty::where('itkod', $memo->itkod )->first();
if(count($compound) > 0){
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
foreach($compound as $c){
$subHistory = [
'no_siri' => $c->ConfidentialFile->no_siri,
'tajuk' => $staff->StaffDetail->roles_access." ".$staff->StaffDetail->full_name." mengemaskini memo ".$memo->no_rujukan,
'huraian' => "Rekod memo (".$memo->no_rujukan.") dikemaskini/di buang oleh ".$staff->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($history);
}
}
}
if($memo->disahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return response()->json(['status' => 'true', 'desc' => 'Buang rekod memo ( '.$memo->no_rujukan.' )']);
}else if($memo->jenis_data == "manual"){
$memo->delete();
$compound = Compound::with('ConfidentialFile')->where('seksyen_kesalahan', $memo->itkod)->get();
$faulty = Faulty::where('itkod', $memo->itkod )->first();
if(count($compound) > 0){
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
foreach($compound as $c){
$subHistory = [
'no_siri' => $c->ConfidentialFile->no_siri,
'tajuk' => $staff->StaffDetail->roles_access." ".$staff->StaffDetail->full_name." mengemaskini memo ".$memo->no_rujukan,
'huraian' => "Rekod memo (".$memo->no_rujukan.") dikemaskini/di buang oleh ".$staff->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($history);
}
}
}
if($memo->disahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return response()->json(['status' => 'true', 'desc' => 'Buang rekod memo ( '.$memo->no_rujukan.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod memo']);
}
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod memo']);
}
}
public function confirmMemo(Request $request){
$memo = Memo::with('Attachment')->where('_id',$request->id)->first();
if(!empty($memo)){
$staffD = Staff::with('StaffDetail')->where('_id',$request->confirm_id)->first();
if(!empty($staffD)){
$kpd = $request->kpd;
$tajuk = ""; $huraian = "";
if($memo->disahkan == ""){
$memo->disahkan = $staffD->_id;
$memo->save();
$tajuk = "Memo[ ".$memo->no_rujukan." ] : ".$memo->subjek ." telah disahkan oleh ".$staffD->roles_access;
$huraian = "Memo ini telah disahkan oleh ".$staffD->roles_access." <a href='".url('/main/staff')."/".$staffD->_id."/profile'>".$staffD->StaffDetail->full_name."</a> dan telah berkuat kuasa serta merta";
}else{
$memo->disahkan = "";
$memo->save();
$tajuk = "Memo[ ".$memo->no_rujukan." ] : ".$memo->subjek ." tidak disahkan oleh ".$staffD->roles_access;
$huraian = "Memo ini tidak disahkan oleh ".$staffD->roles_access." <a href='".url('/main/staff')."/".$staffD->_id."/profile'>".$staffD->StaffDetail->full_name."</a>.";
}
$this->dispatch(new UpdateCompoundPrice($kpd));
$now = Carbon::now();
$gDate = $now->format('F Y');
$compound = Compound::with('ConfidentialFile')->where('seksyen_kesalahan', $memo->itkod)->get();
$faulty = Faulty::where('itkod', $memo->itkod )->first();
if(!empty($compound)){
$historyData = [
'tarikh_kumpulan' => $gDate,
];
foreach($compound as $c){
$subHistory = [
'no_siri' => $c->ConfidentialFile->no_siri,
'tajuk' => $tajuk,
'huraian' => $huraian,
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($history);
}
}
return response()->json(['status' => 'true', 'desc' => 'Memo ini telah disahkan dan dikuat kuasakan serta merta']);
}
}else{
return response()->json(['status' => 'false', 'desc' => 'Data kakitangan ( '.$staff->StaffDetail->full_name.' ) ini tidak ditemui']);
}
}else{
return response()->json(['status' => 'false', 'desc' => 'Rekod memo tidak ditemui']);
}
}
/**
* Create template notice list controller.
*
* @return json
*/
public function templateList($_id, $status){
$nested_data = array();
$curr = Carbon::now()->getTimestamp();
if($status == 'aktif'){
$compound = Compound::with('LetterNotice')->where('kpd', $_id)->first();
if(!empty($compound->LetterNotice)){
foreach ($compound->LetterNotice as $key => $a) {
$n1 = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
array_push($nested_data, array(
'index' => $n1.$a->jenis_amaran,
'no_rujukan' => $a->no_rujukan,
'alasan' => $a->alasan,
'tindakan1' => $a->no_pos,
'tindakan2' => $a->_id
));
}
}
}else{
$template = TemplateNotice::all();
foreach($template as $key => $a) {
$n1 = ''; $aktif = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
array_push($nested_data, array(
'index' => $n1.$a->jenis_amaran,
'no_rujukan' => $a->no_rujukan,
'tempoh' => $a->tempoh_hantar,
'status' => $a->status,
'tindakan' => $a->_id
));
}
}
return \DataTables::of($nested_data)->make(true);
}
public function confirmTemplate(Request $request){
$template = TemplateNotice::where('_id',$request->id)->first();
if(!empty($template)){
$template->status = $request->status;
$template->save();
return response()->json(['status' => 'true', 'desc' => 'Status templat notis amaran ini telah "'.$request->status.'"']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Rekod notis amaran tidak ditemui']);
}
}
public function deleteTemplate(Request $request){
$template = TemplateNotice::with('Attachment')->where('_id',$request->id)->first();
if(!empty($template)){
if(!empty($template->Attachment)){
$template->attachment()->delete();
}
$template->delete();
return response()->json(['status' => 'true', 'desc' => 'Buang rekod template notis amaran ( '.$template->no_rujukan.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod template notis amaran']);
}
}
public function sendNotice(Request $request){
$template = TemplateNotice::with('Attachment')->where('_id',$request->id)->first();
if(!empty($template)){
return response()->json(['status' => 'true', 'desc' => 'Percubaan Hantar email ( '.$template->no_rujukan.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod template notis amaran ( '.$template->no_rujukan.' )']);
}
}
/**
* Create API list controller.
*
* @return json
*/
public function apiKeyList(){
$nested_data = array();
$api = ApiKey::orderBy('updated_at', 'desc')->get();
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($api as $a)
{
$n1 = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "New/";
}else{
$n1 = "";
}
array_push($nested_data, array(
'index' => $n1.$a->name,
'key_prefix' => $a->key_prefix,
'scopes' => count($a->scopes). ' scopes enabled',
'action' => $a->_id,
));
$i++;
}
return \DataTables::of($nested_data)->make(true);
}
public function deleteApiKey(Request $request){
$apiKey = ApiKey::where('_id', $request->id)->first();
if(!empty($apiKey)){
$apiKey->delete();
return response()->json(['status' => 'true', 'desc' => 'Successfully delete Api Key']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Record Api Key not found!']);
}
}
public function apiKeyIntegrationList(){
$nested_data = array();
$curr = Carbon::now()->getTimestamp();
$i = 1;
$api = ApiIntegration::with('ApiKey')->orderBy('created_at', 'desc')->get();
foreach($api as $a)
{
$n1 = '';
$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "New/";
}else{
$n1 = "";
}
if(!empty($a->ApiKey)){
array_push($nested_data, array(
'index' => $n1.$a->updated_at->toDateTimeString(),
'client' => $a->client,
'api' => $a->ApiKey->scopes,
'key' => $a->key,
'status' => $a->status
));
$i++;
}
}
return \DataTables::of($nested_data)->make(true);
}
}

+ 311
- 0
app/Http/Controllers/Api/StaffController.php 查看文件

@@ -0,0 +1,311 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
class StaffController extends BaseController
{
/**
* Create a staff list controller.
*
* @return json
*/
public function staffList($roles)
{
$nested_data = array();
if($roles == 'sysadmin'){
$staff = Staff::with(['StaffDetail' => function($q){
$q->with('Department');
}])->orderBy('updated_at', 'desc')->get();
}else{
$staff = Staff::with(['StaffDetail' => function($q){
$q->with('Department');
}])->orderBy('updated_at', 'desc')->where('roles_access','!=','sysadmin')->where('roles_access','!=','PPegawai')->where('roles_access','!=','PPenguatKuasa')->get();
}
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($staff as $a)
{
$n1 = ''; $jabatan = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$temp = [];
if(!empty($a->StaffDetail->department_ids)){
foreach ($a->StaffDetail->Department as $key => $d) {
$temp[] = $d->jbkod;
$jabatan = implode( ", ", $temp );
}
}else{
$jabatan = '-';
}
array_push($nested_data, array(
'index' => $n1.$i,
'nama' => $a->StaffDetail->full_name,
'ic' => $a->StaffDetail->identity,
'phone' => $a->StaffDetail->mobile,
'no_badan' => $a->StaffDetail->no_badan,
'jawatan' => $a->roles_access,
'jabatan' => $jabatan,
'tindakan' => $a->_id
));
$i++;
}
return \DataTables::of($nested_data)->make(true);
}
public function officerStaffList($jbkod,$roles)
{
$nested_data = array();
if($roles == 'sysadmin'){
$staff = Staff::with(['StaffDetail' => function($q) use($jbkod){
$q->where('department_ids',$jbkod);
}])->orderBy('updated_at', 'desc')->where('roles_access','PenguatKuasa')->orWhere('roles_access','PPenguatKuasa')->get();
}else if($jbkod == 'null'){
$staff = Staff::with(['StaffDetail' => function($q){
$q->with('Department');
}])->orderBy('updated_at', 'desc')->where('roles_access','PenguatKuasa')->get();
}else{
$staff = Staff::with(['StaffDetail' => function($q) use($jbkod){
$q->where('department_ids',$jbkod);
}])->orderBy('updated_at', 'desc')->where('roles_access','PenguatKuasa')->get();
}
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($staff as $a) {
$n1 = ''; $jabatan = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
if(!empty($a->StaffDetail)){
if($jbkod == 'null'){
$temp = [];
$user = StaffDetail::with('Department')->where('_id', $roles)->first();
if(!empty($a->StaffDetail->department_ids)){
foreach ($a->StaffDetail->Department as $key => $d) {
$temp[] = $d->jbkod;
$jabatan = implode( ", ", $temp );
}
foreach ($a->StaffDetail->department_ids as $key => $d) {
if (in_array($d, (array)$user->department_ids)) {
array_push($nested_data, array(
'index' => $n1.$i,
'nama' => $a->StaffDetail->full_name,
'ic' => $a->StaffDetail->identity,
'phone' => $a->StaffDetail->mobile,
'no_badan' => $a->StaffDetail->no_badan,
'jawatan' => $a->roles_access,
'jabatan' => $jabatan,
'tindakan' => $a->_id
));
$i++; break;
}else{
continue;
}
}
}
}else{
$temp = [];
if(!empty($a->StaffDetail->department_ids)){
foreach ($a->StaffDetail->department_ids as $key => $d) {
$department = Department::where('_id',$d)->first();
if(!empty($department)){
$temp[] = '['.$department->jbkod.'] '.$department->jnama;
$jabatan = implode( ", ", $temp );
}
}
}else{
$jabatan = '-';
}
array_push($nested_data, array(
'index' => $n1.$i,
'nama' => $a->StaffDetail->full_name,
'ic' => $a->StaffDetail->identity,
'phone' => $a->StaffDetail->mobile,
'no_badan' => $a->StaffDetail->no_badan,
'jawatan' => $a->roles_access,
'jabatan' => $jabatan,
'tindakan' => $a->_id
));
$i++;
}
}
}
return \DataTables::of($nested_data)->make(true);
}
public function staffFilterList($department,$position,$module)
{
$nested_data = array();
if($department == "null" && $position == "null" && $module == "null"){
$staff = StaffDetail::orderBy('updated_at', 'desc')->get();
}else if($department != "null" && $position == "null" && $module == "null"){
$staff = StaffDetail::orderBy('updated_at', 'desc')->where('department_ids',$department)->get();
}else if($department != "null" && $position != "null" && $module == "null"){
$staff = StaffDetail::orderBy('updated_at', 'desc')->where('department_ids',$department)->where('roles_access',$position)->get();
}
else if($department != "null" && $position != "null" && $module != "null"){
$staff = StaffDetail::whereHas('roles', function($q) use($module) {
$q->where('_id', $module)->first();
})->orderBy('updated_at', 'desc')->where('department_ids',$department)->where('roles_access',$position)->get();
}
else if($department == "null" && $position != "null" && $module == "null"){
$staff = StaffDetail::orderBy('updated_at', 'desc')->where('roles_access',$position)->get();
}
else if($department == "null" && $position != "null" && $module != "null"){
$staff = StaffDetail::whereHas('roles', function($q) use($module) {
$q->where('_id', $module)->first();
})->orderBy('updated_at', 'desc')->where('roles_access',$position)->get();
}
else if($department == "null" && $position == "null" && $module != "null"){
$staff = StaffDetail::whereHas('roles', function($q) use($module) {
$q->where('_id', $module)->first();
})->orderBy('updated_at', 'desc')->where('roles_access',$position)->get();
}
$curr = Carbon::now()->getTimestamp();
$i = 1;
foreach($staff as $a)
{
$n1 = ''; $jabatan = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();
if($curr < $expiry_date) {
$n1 = "Baru/";
}else{
$n1 = "";
}
$temp = [];
if(!empty($a->department_ids)){
foreach ($a->department_ids as $key => $d) {
$department = Department::where('_id',$d)->first();
if(!empty($department)){
$temp[] = '['.$department->jbkod.'] '.$department->jnama;
$jabatan = implode( ", ", $temp );
}
}
}else{
$jabatan = '-';
}
array_push($nested_data, array(
'index' => $n1.$i,
'nama' => $a->full_name,
'ic' => $a->identity,
'phone' => $a->mobile,
'no_badan' => $a->no_badan,
'jawatan' => $a->roles_access,
'jabatan' => $jabatan,
'tindakan' => $a->_id
));
$i++;
}
return \DataTables::of($nested_data)->make(true);
}
public function staffDetail(Request $request)
{
$staff = StaffDetail::with('Roles')->where('_id', $request->id)->first();
if(!empty($staff)){
$akses = '';
if($staff->roles_access == "Pegawai"){
foreach($staff->roles_ids as $r){
$role = Roles::where('_id',$r)->first();
$akses .= $role->name . ", ";
}
$akses = rtrim($akses, ", ");
}
$department = '';$temp = [];
if(!empty($staff->department_ids)){
foreach ($staff->department_ids as $key => $d) {
$depart = Department::where('_id',$d)->first();
if(!empty($depart)){
$temp[] = '['.$depart->jbkod.'] '.$depart->jnama;
$department = implode( ", ", $temp );
}
}
}else{
$department = '-';
}
$data = [
'profile_img' => $staff->profile_img,
'full_name' => $staff->full_name,
'username' => $staff->username,
'identity' => $staff->identity,
'mobile' => $staff->mobile,
'jbkod' => $department,
'roles_access' => $staff->roles_access,
'gred' => $staff->gred,
'no_badan' => $staff->no_badan,
'email' => $staff->email,
'address' => $staff->address,
'access' => $akses
];
return response()->json(['status' => 'true', 'desc' => $data]);
}else{
return response()->json(['status' => 'false', 'desc' => 'Rekod ini tidak ditemui']);
}
}
public function deleteStaff(Request $request) {
$staff = Staff::with('StaffDetail')->where('_id',$request->id)->first();
if(!empty($staff)){
$staff->StaffDetail->department()->detach();
if($staff->roles_access == "Pegawai"){
$staff->StaffDetail->roles()->detach();
}
$staff->staffdetail()->delete();
$staff->delete();
return response()->json(['status' => 'true', 'desc' => 'Buang rekod kakitangan ( '.$staff->email.' )']);
}else{
return response()->json(['status' => 'false', 'desc' => 'Buang rekod kakitangan ( '.$staff->email.' )']);
}
}
}

+ 202
- 0
app/Http/Controllers/Api/StatisticController.php 查看文件

@@ -0,0 +1,202 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Department;
use App\Model\Module\Faulty;
class StatisticController extends BaseController
{
/**
* Create compound report controller for kelantanpay.
*
* @return json
*/
public function compoundBasedFaulty($start_date, $end_date){
$temp = [];
if($start_date == 'null'){
$compound = Compound::with('Faulty')->distinct('seksyen_kesalahan')->groupBy('seksyen_kesalahan')->get();
foreach ($compound as $key => $c) {
$temp[] = $c->faulty;
}
}else {
$dateS = Carbon::createFromFormat('Y-m-d', $start_date);
$start = $dateS->copy()->startOfDay();
if($end_date != 'null'){
$dateE = Carbon::createFromFormat('Y-m-d', $end_date);
$end = $dateE->copy()->endOfDay();
}else{
$end = $dateS->copy()->endOfDay();
}
$compound = Compound::with('Faulty')->distinct('seksyen_kesalahan')->whereBetween('created_at', array($start, $end))
->groupBy('seksyen_kesalahan')->get();
foreach ($compound as $key => $c) {
$temp[] = $c->faulty;
}
}
return $temp;
}
private function kadarKompaunDiBayar($id,$start_date,$end_date){
$total = 0;
if($start_date == 'null'){
$compound = Compound::where('seksyen_kesalahan', $id)->where('status','Berbayar')->get();
foreach ($compound as $key => $c) {
$total += $c->amount_payment;
}
}else{
$dateS = Carbon::createFromFormat('Y-m-d', $start_date);
$start = $dateS->copy()->startOfDay();
if($end_date != 'null'){
$dateE = Carbon::createFromFormat('Y-m-d', $end_date);
$end = $dateE->copy()->endOfDay();
}else{
$end = $dateS->copy()->endOfDay();
}
$compound = Compound::with('Faulty')->where('seksyen_kesalahan', $id)->where('status','Berbayar')
->whereBetween('created_at', array($start, $end))->get();
foreach ($compound as $key => $c) {
$total += ($c->Faulty->amount - $c->amount_payment);
}
}
return $total;
}
private function kadarKompaunKurang($id,$start_date,$end_date){
$total = 0;
if($start_date == 'null'){
$compound = Compound::with('Faulty')->where('seksyen_kesalahan', $id)->where('status','Berbayar')->get();
foreach ($compound as $key => $c) {
$total += ($c->Faulty->amount - $c->amount_payment);
}
}else{
$dateS = Carbon::createFromFormat('Y-m-d', $start_date);
$start = $dateS->copy()->startOfDay();
if($end_date != 'null'){
$dateE = Carbon::createFromFormat('Y-m-d', $end_date);
$end = $dateE->copy()->endOfDay();
}else{
$end = $dateS->copy()->endOfDay();
}
$compound = Compound::with('Faulty')->where('seksyen_kesalahan', $id)->where('status','Berbayar')
->whereBetween('created_at', array($start, $end))->get();
foreach ($compound as $key => $c) {
$total += ($c->Faulty->amount - $c->amount_payment);
}
}
return $total;
}
public function reportCompoundList($start_date, $end_date)
{
$nested_data = array();
$noFaulty = $this->compoundBasedFaulty($start_date, $end_date);
if($start_date == 'null'){
foreach ($noFaulty as $key => $f) {
$jumlah_kompaun = 0; $jumlah_kadar_kompaun = 0;
$jumlah_kompaun_dibayar = 0; $jumlah_kadar_kompaun_dibayar = 0;
$jumlah_kompaun_belum_bayar = 0; $jumlah_tunggakkan = 0;
$jumlah_kompaun_kurg = 0; $jumlah_kadar_kompaun_kurg = 0;
$jumlah_kompaun = count(Compound::where('seksyen_kesalahan', $f->_id)->get());
$jumlah_kadar_kompaun = floatval($f->amount) * $jumlah_kompaun;
$jumlah_kompaun_dibayar = count(Compound::where('seksyen_kesalahan', $f->_id)->where('status','Berbayar')->get());
$jumlah_kompaun_belum_bayar = count(Compound::where('seksyen_kesalahan', $f->_id)->where('status','Belum Bayar')->get());
$jumlah_tunggakkan = ($jumlah_kompaun_belum_bayar - $jumlah_kompaun_dibayar) * floatval($f->amount);
$jumlah_kompaun_kurg = count(Compound::where('seksyen_kesalahan', $f->_id)->where('jumlah_kemaskini_kompaun','!=','')->get());
$jumlah_kadar_kompaun_dibayar = $this->kadarKompaunDiBayar($f->_id,$start_date,$end_date);
$jumlah_kadar_kompaun_kurg = $this->kadarKompaunKurang($f->_id,$start_date,$end_date);
array_push($nested_data, array(
'kesalahan' => $f->nama,
'jumlahK' => $jumlah_kompaun,
'amaunK' => $jumlah_kadar_kompaun,
'jumlahB' => $jumlah_kompaun_dibayar,
'amaunB' => $jumlah_kadar_kompaun_dibayar,
'belumB' => $jumlah_kompaun_belum_bayar,
'amaunT' => $jumlah_tunggakkan,
'kBatal' => '0',
'amaunBatal' => '0',
'kompaunKurang' => $jumlah_kompaun_kurg,
'amaunKurang' => $jumlah_kadar_kompaun_kurg,
));
}
}else{
$dateS = Carbon::createFromFormat('Y-m-d', $start_date);
$start = $dateS->copy()->startOfDay();
if($end_date != 'null'){
$dateE = Carbon::createFromFormat('Y-m-d', $end_date);
$end = $dateE->copy()->endOfDay();
}else{
$end = $dateS->copy()->endOfDay();
}
foreach ($noFaulty as $key => $f) {
$jumlah_kompaun = 0; $jumlah_kadar_kompaun = 0;
$jumlah_kompaun_dibayar = 0; $jumlah_kadar_kompaun_dibayar = 0;
$jumlah_kompaun_belum_bayar = 0; $jumlah_tunggakkan = 0;
$jumlah_kompaun_kurg = 0; $jumlah_kadar_kompaun_kurg = 0;
$jumlah_kompaun = count(Compound::where('seksyen_kesalahan', $f->_id)->whereBetween('created_at', array($start, $end))->get());
$jumlah_kadar_kompaun = floatval($f->amount) * $jumlah_kompaun;
$jumlah_kompaun_dibayar = count(Compound::where('seksyen_kesalahan', $f->_id)->where('status','Berbayar')->whereBetween('created_at', array($start, $end))->get());
$jumlah_kompaun_belum_bayar = count(Compound::where('seksyen_kesalahan', $f->_id)->where('status','Belum Bayar')->whereBetween('created_at', array($start, $end))->get());
$jumlah_tunggakkan = ($jumlah_kompaun_belum_bayar - $jumlah_kompaun_dibayar) * floatval($f->amount);
$jumlah_kompaun_kurg = count(Compound::where('seksyen_kesalahan', $f->_id)->where('jumlah_kemaskini_kompaun','!=','')->whereBetween('created_at', array($start, $end))->get());
$jumlah_kadar_kompaun_dibayar = $this->kadarKompaunDiBayar($f->_id,$start_date,$end_date);
$jumlah_kadar_kompaun_kurg = $this->kadarKompaunKurang($f->_id,$start_date,$end_date);
array_push($nested_data, array(
'kesalahan' => $f->nama,
'jumlahK' => $jumlah_kompaun,
'amaunK' => $jumlah_kadar_kompaun,
'jumlahB' => $jumlah_kompaun_dibayar,
'amaunB' => $jumlah_kadar_kompaun_dibayar,
'belumB' => $jumlah_kompaun_belum_bayar,
'amaunT' => $jumlah_tunggakkan,
'kBatal' => '0',
'amaunBatal' => '0',
'kompaunKurang' => $jumlah_kompaun_kurg,
'amaunKurang' => $jumlah_kadar_kompaun_kurg,
));
}
}
return \DataTables::of($nested_data)->addIndexColumn()->make(true);
}
}

+ 158
- 0
app/Http/Controllers/Api/TrackMapController.php 查看文件

@@ -0,0 +1,158 @@
<?php
namespace App\Http\Controllers\api;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\TrackLocation;
use App\Model\Module\CurrentLocation;
use App\Model\Module\EmergencyMarker;
class TrackMapController extends BaseController
{
/**
* Create Location controller.
*
* @return json
*/
public function save_updateLocation(Request $request)
{
$staff = Staff::with('StaffDetail','TrackLocation','CurrentLocation')->where('api_token',$request->api_token)->first();
if(empty($staff)){
return $this->sendError('Gagal', 'Kakitangan tidak wujud');
}else {
$dataLatLong = [
'latitude' => $request->latitude,
'longitude' => $request->longitude,
'status' => 'normal',
];
$staff->tracklocation()->create($dataLatLong);
if(!empty($staff->CurrentLocation)){
$staff->CurrentLocation->latitude = $request->latitude;
$staff->CurrentLocation->longitude = $request->longitude;
$staff->CurrentLocation->save();
}else{
$staff->currentlocation()->create($dataLatLong);
}
return $this->sendResponse('Berjaya', 'Koordinat berjaya direkod');
}
}
public function getStaffList(){
$data = array();
$location = CurrentLocation::all();
foreach ($location as $key => $l) {
$staff = Staff::with('StaffDetail')->where('_id',$l->staff_id)->first();
if(!empty($staff)){
array_push($data, array(
'id' => $l->staff_id,
'nama' => $staff->StaffDetail->full_name,
'no_badan' => $staff->StaffDetail->no_badan,
));
}
}
return $this->sendResponse($data, 'Berjaya dapatkan senarai penguatkuasa');
}
public function getNearestLocation($id){
$data = array();
$latitude = 4.4695721; $longitude = 101.376383;
$location = CurrentLocation::all();
foreach ($location as $key => $l) {
$last_update = $l->updated_at;
$now = now();
$diff = $now->diffInMinutes($last_update);
$status = '';
if($diff <= 5){
$status = '<span style="color:green"><b>Di Atas Talian</b></span>';
}else{
$status = '<span style="color:red"><b>Di Luar Talian</b></span>';
}
$staff = Staff::with('StaffDetail')->where('_id',$l->staff_id)->first();
if($l->staff_id == ''){
array_push($data, array(
'_id' => $l->_id,
'latitude' => '4.4695721',
'longitude' => '101.376383',
'title' => 'Majlis Daerah Cameron Highlands',
'content' => '<b>Ibu Pejabat</b>',
'icon' => url('/uploads/map_marker/mdch_map.png'),
'status' => 'main',
'zindex' => $key+1
));
}else{
if(!empty($staff)){
array_push($data, array(
'_id' => $staff->_id,
'latitude' => $l->latitude,
'longitude' => $l->longitude,
'title' => $staff->StaffDetail->full_name,
'content' => $status,
'icon' => url('/uploads/map_marker/officer.png'),
'status' => $l->status,
'zindex' => $key+1
));
}
}
}
return $this->sendResponse($data, 'Berjaya dapatkan senarai Koordinat');
}
/**
* Create Emergency controller.
*
* @return json
*/
public function postEmergency(Request $request){
$staff = Staff::with('StaffDetail','TrackLocation','CurrentLocation')->where('api_token', $request->api_token)->first();
if(!empty($staff)){
$dataLatLong = [
'latitude' => $request->latitude,
'longitude' => $request->longitude,
'status' => 'emergency',
];
$staff->tracklocation()->create($dataLatLong);
$staff->CurrentLocation->latitude = $request->latitude;
$staff->CurrentLocation->longitude = $request->longitude;
$staff->CurrentLocation->status = 'emergency';
$staff->CurrentLocation->save();
return $this->sendResponse($staff->CurrentLocation, 'Berjaya hantar kecemasan');
}else{
return $this->sendError('', 'Tidak dapat hantar kecemasan');
}
}
public function returnNormal(Request $request){
$current = CurrentLocation::where('status','emergency')->get();
if(count($current) > 0){
foreach($current as $c){
$c->status = 'normal';
$c->save();
}
return $this->sendResponse('', 'Berjaya kembali kepada asal');
}else{
return $this->sendError('', 'Tidak dapat kembali keadaan asal');
}
}
}

+ 32
- 0
app/Http/Controllers/Auth/ForgotPasswordController.php 查看文件

@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

+ 105
- 0
app/Http/Controllers/Auth/LoginController.php 查看文件

@@ -0,0 +1,105 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

use App\Model\Staff;
use Carbon\Carbon;
Use Hash;
use Session;

class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/

/**
* Create a get_guard controller for multiple user
*
* @return guard
*/
public function get_guard(){
if(Auth::guard('sadmin')->check())
{return "sadmin";}
elseif(Auth::guard('ofr')->check())
{return "ofr";}
}

/**
* Create a request login controller for multiple user
*
* @return guard
*/

public function requestLogin(Request $request) {
$this->validate($request, [
'no_badan' => 'required',
'password' => 'required|min:6'
]);
$rememberMe = false; $user = '';
if ($request->has('remember')) {
$rememberMe = true;
}
try {
$message = trans('messages.invalid_login_credentials');

$access = explode ("/", $request->roles_access);
$user = Staff::where('no_badan', $request->no_badan)->where(function($q) use($access){
$q->where('roles_access',$access[0])->orWhere('roles_access',$access[1]);
})->first();
if (!empty($user)) {
if(Hash::check($request->password, $user->password)){

// Update last_login & last ip
$user->last_login_at = Carbon::now(new \DateTimeZone('Asia/Kuala_Lumpur'))->toDateTimeString();
$user->last_login_ip = $request->getClientIp();
$user->authorized = true;
$user->token_firebase = '';
$user->save();

// Proceed to Login
if($user->roles_access == 'sysadmin' || $user->roles_access == 'Ketua Jabatan' || $user->roles_access == "PenguatKuasa"){
Auth::guard('sadmin')->loginUsingId($user->_id, $rememberMe);
return redirect('/main/index');
}else if($user->roles_access == 'psysadmin' || $user->roles_access == 'Pegawai'){
Auth::guard('ofr')->loginUsingId($user->_id, $rememberMe);
return redirect('/officer/index');
}
}
}
}catch (\Exception $e) {
Log::error(__CLASS__ . "::" . __METHOD__ . " " . $e->getMessage() . "on line" . $e->getLine());
}
return redirect('/')->with('error_msg', $message);
}
public function requestLogout(){
$id = Auth::guard($this->get_guard())->id();
$user = Staff::find($id);
// Update last_login & last ip
$user->last_login_at = Carbon::now(new \DateTimeZone('Asia/Kuala_Lumpur'))->toDateTimeString();
$user->last_login_ip = \Request::getClientIp();
$user->authorized = false;
$user->save();
// Proceed to Log Out
$log = Auth::guard($this->get_guard())->logout();
Session::flush();
return redirect('/');
}
}

+ 72
- 0
app/Http/Controllers/Auth/RegisterController.php 查看文件

@@ -0,0 +1,72 @@
<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/

use RegistersUsers;

/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}

/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}

+ 39
- 0
app/Http/Controllers/Auth/ResetPasswordController.php 查看文件

@@ -0,0 +1,39 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;

class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/

use ResetsPasswords;

/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

+ 41
- 0
app/Http/Controllers/Auth/VerificationController.php 查看文件

@@ -0,0 +1,41 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;

class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/

use VerifiesEmails;

/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

+ 13
- 0
app/Http/Controllers/Controller.php 查看文件

@@ -0,0 +1,13 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

+ 28
- 0
app/Http/Controllers/Main/ApplicationController.php 查看文件

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
class ApplicationController extends Controller
{
public function userIndex(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.user_index',compact('user','site'));
}
public function applicationIndex(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.application_index',compact('user','site'));
}
}

+ 468
- 0
app/Http/Controllers/Main/CompoundController.php 查看文件

@@ -0,0 +1,468 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\CompoundInvestigation;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
use App\Jobs\StoreCompound;
use App\Jobs\StoreCompoundManual;
use App\Jobs\UpdateCompoundPrice;
class CompoundController extends Controller
{
/**
* Create compound list interface controller.
*
* @return json
*/
public function index(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
$invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
$notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
$inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
$collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
$comp = count(Compound::where('status','Berbayar')->get());
// $department = Department::all();
$site = SiteSetting::first();
$staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
$faulty = Deedlaw::with('Faulty')->get();
return view('main-dashboard.compound.compound_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
}
public function investigation_index(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
$invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
$notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
$inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
$collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
$comp = count(Compound::where('status','Berbayar')->get());
// $department = Department::all();
$site = SiteSetting::first();
$staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
$faulty = Deedlaw::with('Faulty')->get();
return view('main-dashboard.compound.investigation_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
}
public function notice_index(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
$invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
$notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
$inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
$collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
$comp = count(Compound::where('status','Berbayar')->get());
// $department = Department::all();
$site = SiteSetting::first();
$staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
$faulty = Deedlaw::with('Faulty')->get();
return view('main-dashboard.compound.notice_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
}
public function confiscated_index(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
$invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
$notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
$inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
$collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
$comp = count(Compound::where('status','Berbayar')->get());
// $department = Department::all();
$site = SiteSetting::first();
$staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
$faulty = Deedlaw::with('Faulty')->get();
return view('main-dashboard.compound.confiscated_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
}
public function collapsed_index(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
$invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
$notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
$inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
$collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
$comp = count(Compound::where('status','Berbayar')->get());
// $department = Department::all();
$site = SiteSetting::first();
$staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
$faulty = Deedlaw::with('Faulty')->get();
return view('main-dashboard.compound.collapsed_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
}
public function completed_index(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
$invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
$notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
$inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
$collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
$comp = count(Compound::where('status','Berbayar')->get());
// $department = Department::all();
$site = SiteSetting::first();
$staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
$faulty = Deedlaw::with('Faulty')->get();
return view('main-dashboard.compound.completed_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
}
public function viewCompoundHistoryDetail($kpd){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::with('History','History.SubHistory')->where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$role = Roles::where('kod',$file->modul)->first();
$site = SiteSetting::first();
return view('main-dashboard.compound_detail.history_detail', compact('user','compound','file','role','site'));
}
public function viewCompoundDetail($kpd){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$faulty = Faulty::with(['DeedLaw' => function($q){
$q->with('Department');
}])->where('_id',$compound->seksyen_kesalahan)->first();
$role = Roles::where('kod',$compound->modul)->first();
$total = ''; $enforcer = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$total = $compound->jumlah_asal_kompaun;
}else{
$total = $compound->jumlah_kemaskini_kompaun;
}
$site = SiteSetting::first();
$enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
return view('main-dashboard.compound_detail.compound_detail', compact('user','compound','file','faulty','role','total','enforcer','site'));
}
public function viewCompoundMemoDetail($kpd){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$roles = Roles::all();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('main-dashboard.compound_detail.memo_detail', compact('user','compound','file','roles','role','site'));
}
public function viewCompoundEditMemoDetail($kpd, $memo){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$memo = Memo::where('_id',$memo)->first();
$roles = Roles::all();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('main-dashboard.compound_detail.compound_memo_edit', compact('user','compound','file','roles','role','memo','site'));
}
public function viewCompoundInvestigationDetail($kpd){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$investigation = Compound::with('CompoundInvestigation')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$faulty = Faulty::where('_id',$compound->seksyen_kesalahan)->first();
$akta = DeedLaw::where('akkod',$faulty->akkod)->first();
$role = Roles::where('kod',$compound->modul)->first();
$total = ''; $enforcer = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$total = $compound->jumlah_asal_kompaun;
}else{
$total = $compound->jumlah_kemaskini_kompaun;
}
$site = SiteSetting::first();
$enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
return view('main-dashboard.compound_detail.investigation_detail', compact('user','compound','investigation','file','akta','faulty','role','total','enforcer','site'));
}
public function viewCompoundNoticeDetail($kpd){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('main-dashboard.compound_detail.notice_detail', compact('user','compound','file','role','site'));
}
public function viewCompoundInventoryDetail($kpd){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('main-dashboard.compound_detail.inventory_detail', compact('user','compound','file','role','site'));
}
public function viewCompoundAuctionDetail($kpd){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('main-dashboard.compound_detail.auction_detail', compact('user','compound','file','role','site'));
}
public function viewTaskIndex($kpd){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$staffs = StaffDetail::where('roles_access','PenguatKuasa')->where('department_ids',$compound->jbkod)->get();
$roles = Roles::get();
$role = Roles::where('kod',$compound->modul)->first();
$department = Department::get();
$site = SiteSetting::first();
$currentS = '';
$s = StaffDetail::where('roles_access','PenguatKuasa')->where('_id',$compound->penguatkuasa)->first();
if(!empty($s)){
$currentS = '['.$s->no_badan.'] '.$s->full_name;
}
return view('main-dashboard.compound_detail.compound_job',compact('user','compound','file','roles','staffs','role','department','currentS','site'));
}
public function manualCompound(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
$faulty = Faulty::with('DeedLaw','Department')->get();
$staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
return view('main-dashboard.compound.compound_form',compact('user','site','faulty','staff'));
}
/**
* Create generate kpd number controller.
*
* @return value
*/
public function generateKPD(){
$count = 0;
do {
$count = Compound::count();
$count = $count + 1;
} while (Compound::where("kpd", "=", 'KP'.$count)->first() instanceof Compound);
return $count;
}
public function storemanualCompound(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::where('kpd', $request->kpd)->first();
if(empty($compound)){
$faulty = Faulty::where('_id',$request->get('seksyen'))->first();
if(!empty($faulty)){
$kpd = $request->kpd;
$no_siri = date('yn',strtotime($request->tarikh_dikeluarkan)).'-'.$kpd;
$fileData = [
'no_siri' => $no_siri,
];
if($request->jenisKompaun == 'Parkir'){
$compoundData = [
'jenis' => 'Parkir',
'kpd' => $kpd,
'nama' => '-',
'identity' => '-',
'alamat' => '-',
"no_plate" => strtolower($request->no_plate),
"no_cukai_jalan" => $request->noCukaijalan,
"jenis_kenderaan" => $request->jenisKenderaan,
"model_kenderaan" => $request->modelKenderaan,
"warna_kenderaan" => $request->warnakenderaan,
"nama_taman" => $request->namaTaman,
"nama_jalan" => $request->namaJalan,
"no_parking" => $request->noParking,
"maklumat_tambahan" => $request->catatan,
"catatan" => $request->butiran_kesalahan,
"lokasi_kejadian" => '-',
'latlong' => $request->Latlong,
'jbkod' => $request->jabatan,
'akta' => $faulty->deed_law_id,
'seksyen_kesalahan' => $faulty->_id,
'jumlah_asal_kompaun' => $faulty->amount,
'jumlah_kemaskini_kompaun' => '',
'dikeluarkan' => $request->staff,
"status" => 'Belum Bayar',
"amount_payment" => '',
"receipt" => '',
"modul" => '03',
"penguatkuasa" => '',
"created_at" => new Carbon($request->tarikh_dikeluarkan),
];
}else if($request->jenisKompaun == 'Pelbagai'){
$compoundData = [
'jenis' => 'Pelbagai',
'kpd' => $kpd,
'nama' => $request->namaP,
'identity' => $request->noIc,
'nama_syarikat' => $request->namaS,
'no_daftar_syarikat' => strtolower($request->daftarNo),
'alamat' => $request->alamat,
'no_telefon' => $request->tel,
'no_akaun_lesen' =>$request->lesen,
"no_plate" => strtolower($request->no_plate),
"no_cukai_jalan" => $request->noCukaijalan,
"maklumat_tambahan" => $request->catatan,
"catatan" => $request->butiran_kesalahan,
"lokasi_kejadian" => $request->lokasi_kejadian,
'latlong' => $request->Latlong,
'jbkod' => $request->jabatan,
'akta' => $faulty->deed_law_id,
'seksyen_kesalahan' => $faulty->_id,
'jumlah_asal_kompaun' => $faulty->amount,
'jumlah_kemaskini_kompaun' => '',
'dikeluarkan' => $request->staff,
"status" => 'Belum Bayar',
"amount_payment" => '',
"receipt" => '',
"modul" => '03',
"penguatkuasa" => '',
"created_at" => new Carbon($request->tarikh_dikeluarkan),
];
}
$file = ConfidentialFile::create($fileData);
$saved = $file->compound()->create($compoundData);
if($saved){
$this->dispatch(new StoreCompoundManual($request->all(), $kpd, $request->staff, $no_siri));
return redirect()->back()->with('success_msg', 'Berjaya simpan rekod kompaun!');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod seksyen kesalahan tidak ditemui!');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' telah wujud!');
}
}
public function manualCompoundEdit($_id){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
$faulty = Faulty::with('DeedLaw','Department')->get();
$staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
$compound = Compound::with('Faulty','Department','Deedlaw')->find($_id);
return view('main-dashboard.compound.compound_form_edit',compact('user','site','faulty','staff','compound'));
}
public function editmanualCompound(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::find($request->_id);
if(!empty($compound)){
if($compound->jenis == 'Parkir'){
// $compound->kpd = $request->kpd;
$compound->no_plate = strtolower($request->no_plate);
$compound->no_cukai_jalan = $request->noCukaijalan;
$compound->jenis_kenderaan = $request->jenisKenderaan;
$compound->model_kenderaan = $request->modelKenderaan;
$compound->warna_kenderaan = $request->warnakenderaan;
$compound->nama_taman = $request->namaTaman;
$compound->nama_jalan = $request->namaJalan;
$compound->no_parking = $request->noParking;
$compound->maklumat_tambahan = $request->catatan;
$compound->catatan = $request->butiran_kesalahan;
$compound->lokasi_kejadian = $request->lokasi_kejadian;
$compound->created_at = new Carbon($request->tarikh_dikeluarkan);
$compound->save();
return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
}else if($compound->jenis == 'Pelbagai'){
// $compound->kpd = $request->kpd;
$compound->nama = $request->namaP;
$compound->identity = $request->noIc;
$compound->nama_syarikat = $request->namaS;
$compound->no_daftar_syarikat = strtolower($request->daftarNo);
$compound->alamat = $request->alamat;
$compound->no_telefon = $request->tel;
$compound->no_akaun_lesen = $request->lesen;
$compound->no_plate = strtolower($request->no_plate);
$compound->no_cukai_jalan = $request->noCukaijalan;
$compound->no_plate = strtolower($request->no_plate);
$compound->maklumat_tambahan = $request->catatan;
$compound->catatan = $request->butiran_kesalahan;
$compound->lokasi_kejadian = $request->lokasi_kejadian;
$compound->created_at = new Carbon($request->tarikh_dikeluarkan);
$compound->save();
return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' tidak wujud!');
}
}
}

+ 210
- 0
app/Http/Controllers/Main/DepartmentController.php 查看文件

@@ -0,0 +1,210 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
class DepartmentController extends Controller
{
/**
* Create a department controller.
*
* @return value
*/
public function index(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.department_index', compact('user','site'));
}
public function addDepartment(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$jabatan = new Department;
$jabatan->jbkod = $request->get('jbkod');
$jabatan->jnama = $request->get('jnama');
$jabatan->alam1 = $request->get('alam1');
$jabatan->alam2 = $request->get('alam2');
$jabatan->alam3 = $request->get('alam3');
$jabatan->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan rekod jabatan <strong>'.$request->get('jnama').'</strong>');
}
public function updateDepartment(Request $request)
{
$department = Department::where('_id',$request->get('_id'))->first();
if(!empty($department)){
$department->jbkod = $request->get('jbkod');
$department->jnama = $request->get('jnama');
$department->alam1 = $request->get('alam1');
$department->alam2 = $request->get('alam2');
$department->alam3 = $request->get('alam3');
$department->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini rekod jabatan ( '.$request->get('jnama').' )');
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> kemaskini rekod jabatan ( '.$request->get('jnama').' )');
}
}
/**
* Create a deed law controller.
*
* @return value
*/
public function actIndex(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
$department = Department::all();
return view('main-dashboard.act_uuk_index', compact('user','site','department'));
}
public function addDeedLaw(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
if(!empty($request->jabatan)){
$deedlaw = DeedLaw::create([
'akkod' => $request->get('akkod'),
'tarikh' => $request->get('tarikh'),
'nama' => $request->get('nama'),
]);
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$deedlaw->department()->attach($department);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan rekod akta <strong>'.$request->get('nama').'</strong> baru');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod jabatan yg dipilih tidak wujud');
}
}
public function updateDeedLaw(Request $request)
{
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$akta = DeedLaw::where('_id',$request->get('_id'))->first();
if(!empty($akta)){
if(!empty($request->jabatan)){
$akta->akkod = $request->get('akkod');
$akta->tarikh = $request->get('tarikh');
$akta->nama = $request->get('nama');
$akta->save();
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$department_array[] = $department->_id;
}
$akta->department()->sync($department_array);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod akta/uuk ( '.$request->get('nama').' )');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod jabatan yg dipilih tidak wujud');
}
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> Kemaskini rekod akta/uuk ( '.$request->get('nama').' )');
}
}
/**
* Create a department controller.
*
* @return value
*/
public function faultyIndex(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
$deed = DeedLaw::all();
$department = Department::all();
return view('main-dashboard.faulty_index', compact('user','site','deed','department'));
}
public function requestAddFaulty(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$temp = Faulty::where('itkod',$request->get('itkod'))->first();
if(empty($temp)) {
$akta = Deedlaw::where('_id', $request->get('akkod'))->first();
if(!empty($akta)) {
$seksyen = new Faulty;
$seksyen->itkod = $request->get('itkod');
$seksyen->sketr = $request->get('sketr');
$seksyen->nama = $request->get('nama');
$seksyen->amount_before_14 = $request->get('amount_14');
$seksyen->amount_before_30 = $request->get('amount_30');
$seksyen->amount = $request->get('amount');
$akta->faulty()->save($seksyen);
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$seksyen->department()->attach($department);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan rekod seksyen/kesalahan <strong>'.$request->get('nama').'</strong>');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod akta yg dipilih tidak wujud');
}
}else {
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> kod seksyen/kesalahan telah wujud');
}
}
public function updateFaulty(Request $request)
{
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$faulty = Faulty::with('DeedLaw')->where('_id',$request->get('_id'))->first();
if(!empty($faulty)){
$akta = Deedlaw::where('_id', $request->get('akkod'))->first();
if(!empty($akta)) {
$faulty->itkod = $request->get('itkod');
$faulty->sketr = $request->get('sketr');
$faulty->nama = $request->get('nama');
$faulty->amount_before_14 = $request->get('amount_14');
$faulty->amount_before_30 = $request->get('amount_30');
$faulty->amount = $request->get('amount');
$akta->faulty()->save($faulty);
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$department_array[] = $department->_id;
}
$faulty->department()->sync($department_array);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini rekod seksyen/kesalahan <strong>'.$request->get('nama').'</strong>');
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod akta yg dipilih tidak wujud');
}
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod seksyen/kesalahan <strong>'.$request->get('nama').'</strong> tidak ditemui');
}
}
}

+ 23
- 0
app/Http/Controllers/Main/IndexController.php 查看文件

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
class IndexController extends Controller
{
public function index(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.index', compact('user','site'));
}
}

+ 196
- 0
app/Http/Controllers/Main/InventoryController.php 查看文件

@@ -0,0 +1,196 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use Carbon\Carbon;
use PDF;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\ItemInventory;
use App\Model\Module\Barcode;
use App\Model\Module\Attachment;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Jobs\GenerateBarcode;
class InventoryController extends Controller
{
/**
* Create Inventory ID controller.
*
* @return json
*/
public function generateBR($uniq_id,$range){
$allowedNumbers = range(0, 9);
shuffle($allowedNumbers);
$digits = array_rand($allowedNumbers, $range);
$number = '';
foreach($digits as $d){
$number .= $allowedNumbers[$d];
}
return $uniq_id.$number;
}
/**
* Create Inventory list controller.
*
* @return json
*/
public function addItem(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
if(!empty($compound)){
$item = [
'kategori' => $request->get('kategori'),
'jenis' => $request->get('jenis'),
'bilangan' => $request->get('bilangan'),
'harga' => $request->get('harga'),
'lokasi_gudang' => $request->get('lokasi'),
'status' => 'simpan'
];
$itemI = ItemInventory::create($item);
$compound->ConfidentialFile->iteminventory()->save($itemI);
$l = 0;
while($l != $request->get('bilangan')) {
$name = '';
do {
$name = $this->generateBR('BR', 5);
} while (Barcode::where("barcode_id", "=", $name)->first() instanceof Barcode);
$this->dispatch(new GenerateBarcode($request->kpd, $name, $itemI));
$l++;
}
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Ada penambahan item inventori dari 'dashboard'",
'huraian' => "Item inventori telah ditambah oleh ".$user->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Rekod item inventori berjaya ditambah');
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kertas kompaun tidak ditemui');
}
}
public function editItem(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$data_barcode_empty = false;
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
$itemI = ItemInventory::with('Attachment','Barcode')->where('_id',$request->_id)->first();
if(!empty($itemI)){
if($request->has('lokasi')){
$itemI->jenis = $request->get('jenis');
$itemI->bilangan = $request->get('bilangan');
$itemI->harga = $request->get('harga');
$itemI->lokasi_gudang = $request->get('lokasi');
$itemI->save();
}else{
$itemI->jenis = $request->get('jenis');
$itemI->bilangan = $request->get('bilangan');
$itemI->harga = $request->get('harga');
$itemI->save();
}
if(!empty($itemI->Barcode)){
foreach ($itemI->Barcode as $b) {
$b->forceDelete();
}
$data_barcode_empty = true;
}
if($data_barcode_empty == true){
$l = 0;
while($l != $request->get('bilangan')) {
$name = $this->generateBR('BR', 5);
$this->dispatch(new GenerateBarcode($request->kpd, $name, $itemI));
$l++;
}
}
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Item inventori dikemaskini",
'huraian' => "Item inventori diekmaskini oleh ".$user->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini Rekod item inventori');
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod item tidak ditemui');
}
}
public function requestViewInventoryPdf($kpd) {
$compound = Compound::with('ConfidentialFile')->where('kpd', $kpd)->first();
$file = ConfidentialFile::with(['ItemInventory' => function($q){
$q->with('Attachment','Barcode')->orderBy('created_at','DESC');
}])->where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$now = Carbon::now()->format('d/m/Y h:i:s A');
$site = SiteSetting::first();
$pdf = PDF::loadView('pdf.inventory', compact('compound','file','now','site'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}
}

+ 220
- 0
app/Http/Controllers/Main/InvestigationController.php 查看文件

@@ -0,0 +1,220 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Validator;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\CompoundInvestigation;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Investigation;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
class InvestigationController extends Controller
{
/**
* Create compound list interface controller.
*
* @return json
*/
public function updateCompoundInvestigation(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'jumlah_kompaun' => 'numeric',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$save = false;
$compound = Compound::with('CompoundInvestigation')->where('kpd',$request->kpd)->first();
$file = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
$now = Carbon::now();
$gDate = $now->format('F Y');
if(!empty($compound->CompoundInvestigation)){
$compound->CompoundInvestigation->nama = $request->full_name;
$compound->CompoundInvestigation->identity = $request->ic;
$compound->CompoundInvestigation->nama_syarikat = $request->nama_syarikat;
$compound->CompoundInvestigation->no_daftar_syarikat = $request->no_syarikat;
$compound->CompoundInvestigation->alamat = $request->alamat;
$compound->CompoundInvestigation->save();
if($request->has('jumlah_kompaun')){
$compound->jumlah_kemaskini_kompaun = $request->jumlah_kompaun;
$compound->save();
}
$save = true;
}else{
$compoundData = [
'nama' => $request->full_name,
'identity' => $request->ic,
'nama_syarikat' => $request->nama_syarikat,
'no_daftar_syarikat' => $request->no_syarikat,
'alamat' => $request->alamat,
];
$compound->compoundinvestigation()->create($compoundData);
if($request->has('jumlah_kompaun')){
$compound->jumlah_kemaskini_kompaun = $request->jumlah_kompaun;
$compound->save();
}
$save = true;
}
if($save == true){
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $file->ConfidentialFile->no_siri,
'tajuk' => $user->StaffDetail->roles_access." ".$user->StaffDetail->full_name." mengemaskini data kompaun ".$request->kpd,
'huraian' => "Data kompaun ".$request->kpd." dikemaskini oleh ".$user->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a> di bawah kategori modul <b>Kertas Siasatan</b>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Rekod kompaun berjaya dikemaskini untuk siasatan');
}
}
public function addAttachInvestigation(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'attachment' => 'mimes:pdf|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$now = Carbon::now();
$gDate = $now->format('F Y');
$file = ConfidentialFile::where('no_siri', $request->nosiri)->first();
if(!empty($file)){
if($request->hasFile('attachment')) {
$upload = [];
$a = $request->file('attachment');
$upload[] = [
'name' => 'attachment',
'contents' => fopen( $a->getPathname(), 'r' ),
'filename' => $a->getClientOriginalName()
];
$upload [] = [
'name' => 'no_siri',
'contents' => $request->nosiri
];
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/investigation/file', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
$investigationData = [
'subjek' => $request->subjek,
'kategori' => $request->kategori,
];
$invest = $file->investigation()->create($investigationData);
$attach = new Attachment();
$attach->path = $response->data;
$invest->attachment()->save($attach);
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $file->no_siri,
'tajuk' => $user->StaffDetail->roles_access." ".$user->StaffDetail->full_name." memuat naik lampiran SSM / JPJ",
'huraian' => "Lampiran SSM/JPJ telah dimuat naik oleh ".$user->StaffDetail->roles_access." <b><a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a></b>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$file->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$file->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Rekod lampiran berjaya di simpan');
}else if($response->success == false){
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> '.$response->message);
}
}else {
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila pastikan anda muat naik pdf sebelum hantar data');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' tidak ditemui');
}
}
public function attachmentView($_id){
$attach = Investigation::with('Attachment')->where('_id',$_id)->first();
if(!empty($attach->Attachment)){
$path = $attach->Attachment->first()->path;
return \Response::make(file_get_contents($path), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename=""'
]);
}
}
}

+ 339
- 0
app/Http/Controllers/Main/MemoController.php 查看文件

@@ -0,0 +1,339 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use Carbon\Carbon;
use Validator;
use PDF;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
use App\Model\Module\Attachment;
use App\Model\Module\Faulty;
use App\Model\Module\Memo;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Jobs\UpdateCompoundPrice;
class MemoController extends Controller
{
public function requestAddMemo(Request $request) {
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
if($request->jenis_memo == "Tambahan" || $request->jenis_memo == "Potongan"){
if($request->has('tawaran')){
if (preg_match("/^100+%$|[0-9]+%/", $request->get('tawaran'))){
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila isikan ruangan tawaran dengan format yang betul');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila isikan ruangan tawaran sekiranya anda memilih memo jenis potongan mahupun tambahan');
}
}
$validator = Validator::make($request->all(), [
'attachment.*' => 'mimes:pdf|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$sahkan = '';
if($user->StaffDetail->roles_access == "Ketua Jabatan"){
$sahkan = $user->_id;
}
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
if($compound->ConfidentialFile->modul != '-'){
$modul = Roles::where('kod', $compound->modul)->first();
$now = Carbon::now();
$gDate = $now->format('F Y');
if($request->hasfile('attachment')){
$memo = Memo::create([
'itkod' => '-',
'modul' => $compound->modul,
'jenis_memo' => $request->get('jenis_memo'),
'no_rujukan' => $request->get('no_rujukan'),
'tawaran_kompaun' => $request->get('tawaran'),
'tarikh_mula' => $request->get('tarikh_mula'),
'tarikh_akhir' => $request->get('tarikh_akhir'),
'dikeluarkan' => $user->_id,
'disahkan' => $sahkan,
'jenis_data' => 'pdf',
'subjek' => $request->get('subjek'),
'penerangan' => $request->get('penerangan'),
'created_at' => $now,
]);
$compound->ConfidentialFile->memo()->attach($memo);
$this->dispatch(new UpdateCompoundPrice($request->kpd));
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penambahan Memo[ ".$request->get('no_rujukan')." ] : ".$request->get('subjek'),
'huraian' => $request->get('penerangan'),
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
$upload = [];
foreach($request->file('attachment') as $f){
$upload[] = [
'name' => 'file[]',
'contents' => fopen( $f->getPathname(), 'r' ),
'filename' => $f->getClientOriginalName()
];
}
$upload[] = [
'name' => 'no_siri',
'contents' => $compound->ConfidentialFile->no_siri,
];
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/file/memo/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
foreach ($response->data as $key => $d) {
$attach = new Attachment();
$attach->path = $d;
$memo->attachment()->save($attach);
}
}else if($response->success == false){
return redirect()->back()->with('error_msg', '<strong>Gagal!</strong> memuatnaik pdf');
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod memo di kategori modul <strong>('.$modul->name.')</strong>');
}else{
$memo = Memo::create([
'itkod' => '-',
'modul' => $compound->modul,
'jenis_memo' => $request->get('jenis_memo'),
'no_rujukan' => $request->get('no_rujukan'),
'tawaran_kompaun' => $request->get('tawaran'),
'tarikh_mula' => $request->get('tarikh_mula'),
'tarikh_akhir' => $request->get('tarikh_akhir'),
'dikeluarkan' => $user->_id,
'disahkan' => $sahkan,
'jenis_data' => 'manual',
'subjek' => $request->get('subjek'),
'penerangan' => $request->get('penerangan'),
'created_at' => $now,
]);
$compound->ConfidentialFile->memo()->attach($memo);
$this->dispatch(new UpdateCompoundPrice($request->kpd));
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penambahan Memo[ ".$request->get('no_rujukan')." ] : ".$request->get('subjek'),
'huraian' => $request->get('penerangan'),
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod memo di kategori modul <strong>('.$modul->name.')</strong>');
}
}
}
public function requestEditMemo(Request $request) {
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
if($request->jenis_memo == "Tambahan" || $request->jenis_memo == "Potongan"){
if($request->has('tawaran')){
if (preg_match("/^100+%$|[0-9]+%/", $request->get('tawaran'))){
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila isikan ruangan tawaran dengan format yang betul');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila isikan ruangan tawaran sekiranya anda memilih memo jenis potongan mahupun tambahan');
}
}
$sahkan = '';
if($user->StaffDetail->roles_access == "Ketua Jabatan"){
$sahkan = $user->_id;
}
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
$memo = Memo::where('_id', $request->memo_id)->first();
if(!empty($memo)){
$now = Carbon::now();
$gDate = $now->format('F Y');
if($request->hasfile('attachment')){
$uploadNew = false;
if($memo->jenis_data == "pdf"){
foreach ($memo->Attachment as $m) {
$m->forceDelete();
}
$uploadNew = true;
}else if($memo->jenis_data == "manual"){
$uploadNew = true;
}
if($uploadNew == true){
$memo->jenis_memo = $request->get('jenis_memo');
$memo->no_rujukan = $request->get('no_rujukan');
$memo->tawaran_kompaun = $request->get('tawaran');
$memo->tarikh_mula = $request->get('tarikh_mula');
$memo->tarikh_akhir = $request->get('tarikh_akhir');
$memo->jenis_data = 'pdf';
$memo->subjek = $request->get('subjek');
$memo->penerangan = $request->get('penerangan');
$memo->disahkan = $sahkan;
$memo->save();
$this->dispatch(new UpdateCompoundPrice($request->kpd));
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Kemaskini Memo[ ".$request->get('no_rujukan')." ] : ".$request->get('subjek'),
'huraian' => $request->get('penerangan'),
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
$upload = [];
foreach($request->file('attachment') as $f){
$upload[] = [
'name' => 'file[]',
'contents' => fopen( $f->getPathname(), 'r' ),
'filename' => $f->getClientOriginalName()
];
}
$upload[] = [
'name' => 'no_siri',
'contents' => $compound->ConfidentialFile->no_siri,
];
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/file/memo/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
foreach ($response->data as $key => $d) {
$attach = new Attachment();
$attach->path = $d;
$memo->attachment()->save($attach);
}
}else if($response->success == false){
return redirect()->back()->with('error_msg', '<strong>Gagal!</strong> memuatnaik pdf');
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod memo <strong>('.$memo->no_rujukan.')</strong>. Untuk berkuat serta merta, sila sahkan semula memo nie jika perlu.');
}
}else{
$memo->jenis_memo = $request->get('jenis_memo');
$memo->no_rujukan = $request->get('no_rujukan');
$memo->tawaran_kompaun = $request->get('tawaran');
$memo->tarikh_mula = $request->get('tarikh_mula');
$memo->tarikh_akhir = $request->get('tarikh_akhir');
$memo->jenis_data = 'manual';
$memo->subjek = $request->get('subjek');
$memo->penerangan = $request->get('penerangan');
$memo->disahkan = $sahkan;
$memo->save();
$this->dispatch(new UpdateCompoundPrice($request->kpd));
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Kemaskini Memo[ ".$request->get('no_rujukan')." ] : ".$request->get('subjek'),
'huraian' => $request->get('penerangan'),
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod memo <strong>('.$memo->no_rujukan.')</strong>. Untuk berkuat serta merta, sila sahkan semula memo nie jika perlu.');
}
}
}
}

+ 140
- 0
app/Http/Controllers/Main/ProfileController.php 查看文件

@@ -0,0 +1,140 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Validator;
use Hash;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
class ProfileController extends Controller
{
/**
* Create a profile controller.
*
* @return value
*/
public function staffProfile($_id){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$staff = StaffDetail::where('_id',$_id)->first();
$site = SiteSetting::first();
$department = Department::all();
$roles = Roles::all();
$access = array();
if($staff->roles_access == "Pegawai"){
foreach($staff->roles_ids as $r){
$role = Roles::where('_id',$r)->first();
array_push($access, array(
'kod' => $role->kod
));
}
// $access = json_encode($access);
}
if(empty($access)){
$access = 'null';
}
$myDepartment = Department::whereHas('StaffDetail', function($q) use ($_id) {
$q->where('_id', $_id);
})->select('jbkod', 'jnama')->get();
return view('main-dashboard.profile', compact('user','_id','department','staff','access','roles','myDepartment','site'));
}
public function updateBasic(Request $request){
$validator = Validator::make($request->all(), [
'profil' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
if(!empty($staff)) {
if($request->hasFile('profil')){
$destinationPath = 'uploads/profile';
$uploaded = public_path().'/'.$destinationPath;
$allowedfileExtension = ['jpeg','jpg'];
$a = $request->file('profil');
$extension = $a->getClientOriginalExtension();
$filename = $staff->StaffDetail->no_badan;
$a->move($destinationPath,$filename.'.'.$extension);
$profile_img = '/'.$destinationPath.'/'.$filename.'.'.$extension;
$staff->StaffDetail->profile_img = $profile_img;
$staff->StaffDetail->save();
}
$staff->StaffDetail->full_name = $request->get('full_name');
$staff->StaffDetail->identity = $request->get('identity');
$staff->StaffDetail->mobile = $request->get('mobile');
$staff->StaffDetail->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini maklumat asas anda');
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> kemaskini maklumat asas anda');
}
}
public function updateWork(Request $request){
$staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
if(!empty($staff)) {
$staff->StaffDetail->gred = $request->get('gred');
$staff->StaffDetail->no_badan = $request->get('no_badan');
// $staff->StaffDetail->jbkod = $request->get('jbkod');
$staff->StaffDetail->save();
$staff->no_badan = $request->get('no_badan');
$staff->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini kerjaya anda');
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> kemaskini kerjaya anda');
}
}
public function updatePassword(Request $request){
$validator = Validator::make($request->all(), [
'password' => 'min:8|confirmed',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
if(!empty($staff)) {
$encryptP = Hash::make($request->get('password'));
$staff->password = $encryptP;
$staff->save();
$staff->StaffDetail->password = $encryptP;
$staff->StaffDetail->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini kata laluan anda');
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> kemaskini kata laluan anda');
}
}
}

+ 39
- 0
app/Http/Controllers/Main/ReportController.php 查看文件

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\ReportPayment;
class ReportController extends Controller
{
/**
* Create payment report list controller.
*
* @return json
*/
public function reportList(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.report_payment_index',compact('user','site'));
}
public function reportCompoundList(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.report_compound_index',compact('user','site'));
}
}

+ 830
- 0
app/Http/Controllers/Main/SettingController.php 查看文件

@@ -0,0 +1,830 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use Carbon\Carbon;
use Validator;
use PDF;
use File;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
use App\Model\Module\TemplateNotice;
use App\Model\Module\LetterNotice;
use App\Model\Module\Attachment;
use App\Model\Module\Faulty;
use App\Model\Module\Memo;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\ApiKey;
use App\Model\Module\ApiIntegration;
use App\Jobs\UpdateCompoundPrice;
class SettingController extends Controller
{
/**
* Create a memo list controller.
*
* @return json
*/
public function memoIndex(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.setting.memo_index',compact('user','site'));
}
public function memoAdd(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$roles = Roles::all();
$site = SiteSetting::first();
return view('main-dashboard.setting.memo_detail_add',compact('user','department','roles','site'));
}
public function requestAddMemo(Request $request) {
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'tawaran' => ['required','regex:/^100+%$|[0-9]+%/'],
'attachment.*' => 'mimes:pdf|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$kesalahan = $request->get('kesalahan');
if(!empty($kesalahan)){
$sahkan = '';
if($user->StaffDetail->roles_access == "Ketua Jabatan"){
$sahkan = $user->_id;
}
$faulty = Faulty::where('itkod', $request->get('kesalahan'))->first();
if(!empty($faulty)){
if($request->hasfile('attachment')){
$memo = Memo::create([
'itkod' => $request->get('kesalahan'),
'modul' => $request->get('kategori_modul'),
'jenis_memo' => $request->get('jenis_memo'),
'no_rujukan' => $request->get('no_rujukan'),
'tawaran_kompaun' => $request->get('tawaran'),
'tarikh_mula' => $request->get('tarikh_mula'),
'tarikh_akhir' => $request->get('tarikh_akhir'),
'dikeluarkan' => $user->_id,
'disahkan' => $sahkan,
'jenis_data' => 'pdf',
'subjek' => $request->get('subjek'),
'penerangan' => $request->get('penerangan'),
]);
$upload = [];
foreach($request->file('attachment') as $f){
$upload[] = [
'name' => 'file[]',
'contents' => fopen( $f->getPathname(), 'r' ),
'filename' => $f->getClientOriginalName()
];
}
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/memo/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
foreach ($response->data as $key => $d) {
$attach = new Attachment();
$attach->path = $d;
$memo->attachment()->save($attach);
}
}else if($response->success == false){
return redirect()->back()->with('error_msg', '<strong>Gagal!</strong> memuatnaik pdf');
}
if($sahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod memo di kategori akta kesalahan <strong>('.$faulty->nama.')</strong>');
}else{
$memo = Memo::create([
'itkod' => $request->get('kesalahan'),
'modul' => $request->get('kategori_modul'),
'jenis_memo' => $request->get('jenis_memo'),
'no_rujukan' => $request->get('no_rujukan'),
'tawaran_kompaun' => $request->get('tawaran'),
'tarikh_mula' => $request->get('tarikh_mula'),
'tarikh_akhir' => $request->get('tarikh_akhir'),
'dikeluarkan' => $user->_id,
'disahkan' => $sahkan,
'jenis_data' => 'manual',
'subjek' => $request->get('subjek'),
'penerangan' => $request->get('penerangan'),
]);
if($sahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod memo di kategori akta kesalahan <strong>('.$faulty->nama.')</strong>');
}
}else{
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya Simpan Rekod!</strong> Rekod Akta Kesalahan <b>'.$request->get('kesalahan').'</b> tidak ditemui');
}
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya Simpan Rekod!</strong> Pastikan anda pilih ketegori/akta kesalahan untuk memo berjalan dengan lancar');
}
}
public function memoEdit($_id){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$roles = Roles::all();
$memo = Memo::where('_id',$_id)->first();
$faulty = Faulty::where('itkod',$memo->itkod)->first();
$site = SiteSetting::first();
return view('main-dashboard.setting.memo_detail_edit',compact('user','department','roles','memo','faulty','site'));
}
public function requestEditMemo(Request $request) {
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'tawaran' => ['required','regex:/^100+%$|[0-9]+%/'],
'attachment.*' => 'mimes:pdf|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$sahkan = '';
if($user->StaffDetail->roles_access == "Ketua Jabatan"){
$sahkan = $user->_id;
}
$memo = Memo::with('Attachment')->where('_id',$request->memo_id)->first();
$now = Carbon::now();
$gDate = $now->format('F Y');
if(!empty($memo)){
$faulty = Faulty::where('itkod', $memo->itkod)->first();
if(!empty($faulty)){
if($request->hasfile('attachment')){
$uploadNew = false;
if($memo->jenis_data == "pdf"){
foreach ($memo->Attachment as $m) {
$m->delete();
}
$uploadNew = true;
}else if($memo->jenis_data == "manual"){
$uploadNew = true;
}
if($uploadNew == true){
$memo->jenis_memo = $request->get('jenis_memo');
$memo->no_rujukan = $request->get('no_rujukan');
$memo->tawaran_kompaun = $request->get('tawaran');
$memo->tarikh_mula = $request->get('tarikh_mula');
$memo->tarikh_akhir = $request->get('tarikh_akhir');
$memo->dikeluarkan = $user->_id;
$memo->jenis_data = 'pdf';
$memo->subjek = $request->get('subjek');
$memo->penerangan = $request->get('penerangan');
$memo->save();
$upload = [];
foreach($request->file('attachment') as $f){
$upload[] = [
'name' => 'file[]',
'contents' => fopen( $f->getPathname(), 'r' ),
'filename' => $f->getClientOriginalName()
];
}
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/memo/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
foreach ($response->data as $key => $d) {
$attach = new Attachment();
$attach->path = $d;
$memo->attachment()->save($attach);
}
}else if($response->success == false){
return redirect()->back()->with('error_msg', '<strong>Gagal!</strong> memuatnaik pdf');
}
$compound = Compound::with('ConfidentialFile')->where('seksyen_kesalahan', $memo->itkod)->get();
$faulty = Faulty::where('itkod', $memo->itkod )->first();
if(count($compound) > 0){
$historyData = [
'tarikh_kumpulan' => $gDate,
];
foreach($compound as $c){
$subHistory = [
'no_siri' => $c->ConfidentialFile->no_siri,
'tajuk' => "Kemaskini Memo[ ".$memo->no_rujukan." ] : ".$memo->subjek,
'huraian' => "Memo ini telah dikemaskini oleh ".$user->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($history);
}
}
}
if($memo->disahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod memo di kategori akta kesalahan <strong>('.$faulty->nama.')</strong>');
}
}else{
$uploadNew = false;
if($memo->jenis_data == "pdf"){
foreach ($memo->Attachment as $m) {
$m->delete();
}
$uploadNew = true;
}else if($memo->jenis_data == "manual"){
$uploadNew = true;
}
if($uploadNew == true){
$memo->jenis_memo = $request->get('jenis_memo');
$memo->no_rujukan = $request->get('no_rujukan');
$memo->tawaran_kompaun = $request->get('tawaran');
$memo->tarikh_mula = $request->get('tarikh_mula');
$memo->tarikh_akhir = $request->get('tarikh_akhir');
$memo->dikeluarkan = $user->_id;
$memo->jenis_data = 'manual';
$memo->subjek = $request->get('subjek');
$memo->penerangan = $request->get('penerangan');
$memo->save();
$compound = Compound::with('ConfidentialFile')->where('seksyen_kesalahan', $memo->itkod)->get();
$faulty = Faulty::where('itkod', $memo->itkod )->first();
if(count($compound) > 0){
$historyData = [
'tarikh_kumpulan' => $gDate,
];
foreach($compound as $c){
$subHistory = [
'no_siri' => $c->ConfidentialFile->no_siri,
'tajuk' => "Kemaskini Memo[ ".$memo->no_rujukan." ] : ".$memo->subjek,
'huraian' => "Memo ini telah dikemaskini oleh ".$user->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($history);
}
}
}
if($memo->disahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod memo di kategori akta kesalahan <strong>('.$faulty->nama.')</strong>');
}
}
}else{
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya Kemaskini Rekod!</strong> Rekod Akta Kesalahan <b>'.$request->get('kesalahan').'</b> tidak ditemui');
}
}else{
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya Kemaskini Rekod!</strong> Rekod memo tidak ditemui');
}
}
public function requestViewMemoPdf($_id) {
$site = SiteSetting::first();
$memo = Memo::with('Attachment')->where('_id',$_id)->first();
$staffD = Staff::with('StaffDetail')->where('_id',$memo->dikeluarkan)->first();
$staffS = Staff::with('StaffDetail')->where('_id',$memo->disahkan)->first();
$kesalahan = Faulty::where('itkod', $memo->itkod)->first();
$dikeluarkan = ''; $disahkan = ''; $faulty = ''; $modul = '';
if(!empty($staffD)){
$dikeluarkan = $staffD->StaffDetail->full_name;
}
if(!empty($staffS)){
$disahkan = $staffD->StaffDetail->full_name;
}
if(!empty($kesalahan)){
$faulty ='['.$kesalahan->itkod.'] '.$kesalahan->nama;
}
if($memo->modul != '-'){
$r = Roles::where('kod',$memo->modul)->first();
if(!empty($r)){
$modul = $r->name;
}
}
$update = Carbon::parse($memo->updated)->toDateTimeString();
$mula = date('d/m/Y h:i a', strtotime($memo->tarikh_mula));
$akhir = date('d/m/Y', strtotime($memo->tarikh_akhir));
$pdf = PDF::loadView('pdf.memo', compact('memo','dikeluarkan','disahkan','update','mula','akhir','faulty','modul','site'));
$pdf->setPaper('A4', 'potrait');
$destinationPath = 'document/memo';
if(!File::exists(public_path().'/'.$destinationPath)) {
File::makeDirectory(public_path().'/'.$destinationPath, $mode = 0777, true, true);
}
if($memo->jenis_data == "manual"){
return $pdf->stream();
}else if($memo->jenis_data == "pdf"){
$pdf->save(public_path().'/'.$destinationPath.'/'.$memo->_id.'.pdf');
$availablePDF[] = public_path().'/'.$destinationPath.'/'.$memo->_id.'.pdf';
$merges = PDFMerger::init();
foreach($memo->Attachment as $key => $a){
$temp = file_put_contents(public_path().'/'.$destinationPath.'/temp-'.$memo->_id.'-'.$key.'.pdf', fopen($a->path, 'r'));
$availablePDF[] = public_path().'/'.$destinationPath.'/temp-'.$memo->_id.'-'.$key.'.pdf';
}
foreach($availablePDF as $a){
$merges->addPDF($a, 'all');
}
$merges->merge();
foreach($availablePDF as $i => $in){
File::delete($in);
}
File::deleteDirectory(public_path().'/'.$destinationPath);
$merges->save(public_path().'/'.$destinationPath.'/'.$memo->_id.'.pdf',"browser");
}
}
/**
* Create a memo list controller.
*
* @return json
*/
public function noticeIndex(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.setting.template_notice_index', compact('user','site'));
}
public function viewNoticeAdd(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$site = SiteSetting::first();
return view('main-dashboard.setting.template_notice_add',compact('user', 'department','site'));
}
public function viewNoticeEdit($_id){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$template = TemplateNotice::with('Attachment')->where('_id',$_id)->first();
$de = Department::where('_id', $template->department_id)->first();
$seksyen = Faulty::where('jbkod', $de->jbkod)->where('akkod', $template->akta_kesalahan)->get();
return view('main-dashboard.setting.template_notice_edit',compact('user','template','department','seksyen'));
}
public function addTemplateNotice(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'attachment' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$dataTemplate = [
'akta_kesalahan' => $request->acts,
'seksyen_kesalahan' => $request->seksyen,
'jenis_amaran' => $request->jenis_amaran,
'tempoh_hantar' => $request->tempoh,
'no_rujukan' => $request->no_rujukan,
'subjek' => $request->subjek,
'kandungan' => $request->kandungan,
// 'nama_pengirim' => $request->nama_pengirim,
// 'jawatan_pengirim' => $request->jawatan_pengirim,
'status' => 'tidak aktif'
];
$department = Department::where('jbkod', $request->department)->first();
if(!empty($department)){
$template = TemplateNotice::create($dataTemplate);
$department->templatenotice()->save($template);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod templat notis amaran');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Simpan rekod templat notis amaran');
}
// if($request->hasfile('attachment')){
// $destinationPath = 'document/notis-amaran';
// $uploaded = public_path().'/'.$destinationPath;
// $allowedfileExtension = ['jpg','jpeg'];
// $a = $request->file('attachment');
// $extension = $a->getClientOriginalExtension();
// $check=in_array($extension,$allowedfileExtension);
// if($check) {
// $filename = $template->_id;
// $a->move($destinationPath, $filename.'.'.$extension);
// $pathImage = '/'.$destinationPath.'/'.$filename.'.'.$extension;
// $attach = new Attachment();
// $attach->path = $pathImage;
// $template->attachment()->save($attach);
// }
// }else{
// return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Simpan rekod templat notis amaran');
// }
}
public function editTemplateNotice(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'attachment' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$template = TemplateNotice::where('_id',$request->_id)->first();
if(!empty($template)){
$department = Department::where('jbkod', $request->department)->first();
if(!empty($department)){
$template->department_id = $department->_id;
$template->akta_kesalahan = $request->acts;
$template->seksyen_kesalahan = $request->seksyen;
$template->jenis_amaran = $request->jenis_amaran;
$template->tempoh_hantar = $request->tempoh;
$template->no_rujukan = $request->no_rujukan;
$template->subjek = $request->subjek;
$template->kandungan = $request->kandungan;
$template->status = 'tidak aktif';
$template->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod templat notis amaran. Anda boleh "aktifkan" notis amaran ini di "Senarai Templat Notis Amaran"');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod jabatan tidak ditemui');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod templat notis amaran tidak ditemui');
}
}
public function viewLetterPDF($_id,$kpd){
$compound = Compound::where('kpd',$kpd)->first();
$site = SiteSetting::first();
$template = TemplateNotice::where('_id',$_id)->first();
if(!empty($template)){
$now = Carbon::now()->format('d/m/Y h:i:s A');
$pdf = PDF::loadView('pdf.template_letter', compact('template','now','compound','site'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}else{
$template = LetterNotice::with('Attachment')->where('_id',$_id)->first();
if(!empty($template)){
$now = Carbon::now()->format('d/m/Y h:i:s A');
$pdf = PDF::loadView('pdf.template_letter', compact('template','now','compound','site'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}
}
}
public function updatePosNumber(Request $request){
$letter = LetterNotice::where('_id',$request->letter_id)->first();
if(!empty($letter)){
$compound = Compound::with('ConfidentialFile')->where('_id', $letter->compound_id)->first();
if($request->hasFile('gambar_pos')){
$validator = Validator::make($request->all(), [
'gambar_pos' => 'mimes:jpg,jpeg',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$path = '';
$destinationPath = 'document/'.$compound->ConfidentialFile->no_siri.'/notice';
$a = $request->file('gambar_pos');
$extension = $a->getClientOriginalExtension();
$filename = 'pos_notice_'.$letter->_id;
$a->move($destinationPath,$filename.'.'.$extension);
$path = $destinationPath.'/'.$filename.'.'.$extension;
$letter->no_pos = $request->no_pos;
$letter->save();
$attach = new Attachment();
$attach->path = $path;
$letter->attachment()->save($attach);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan nombor pos');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> sila masukkan gamabr pos sekali');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod surat notis amaran tidak ditemui');
}
}
/**
* Laman web controller.
*
* @return json
*/
public function generalSetting(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.setting.general_setting', compact('user','site'));
}
public function letterSetting(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.setting.letter_setting', compact('user','site'));
}
public function compoundSetting(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.setting.compound_setting', compact('user','site'));
}
public function updateSettingVariables(Request $request){
$site = SiteSetting::first();
if($request->umum == "true"){
$site->site_title = $request->site_title;
$site->site_tagline = $request->site_tagline;
$site->save();
if($request->hasFile('favicon')){
$path = '';
$validator = Validator::make($request->all(), [
'favicon' => 'mimes:png|dimensions:width=32,height=32',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$destinationPath = 'uploads';
$a = $request->file('favicon');
$extension = $a->getClientOriginalExtension();
$filename = 'favicon';
$a->move($destinationPath,$filename.'.'.$extension);
$path = $destinationPath.'/'.$filename.'.'.$extension;
$site->favicon = $path;
$site->save();
}
if($request->hasFile('logo')){
$path = '';
$validator = Validator::make($request->all(), [
'logo' => 'mimes:png|dimensions:width=614,height=167',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$destinationPath = 'uploads';
$a = $request->file('logo');
$extension = $a->getClientOriginalExtension();
$filename = 'logo';
$a->move($destinationPath,$filename.'.'.$extension);
$path = $destinationPath.'/'.$filename.'.'.$extension;
$site->logo = $path;
$site->save();
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan perubahan');
}
if($request->letter == "true"){
$site->building_name = $request->building_name;
$site->address = $request->address;
$site->state_code = $request->postcode;
$site->no_tel = $request->no_tel;
$site->no_fax = $request->no_faks;
$site->email = $request->email;
$site->save();
if($request->hasFile('letter_head')){
$path = '';
$validator = Validator::make($request->all(), [
'letter_head' => 'mimes:png|dimensions:max_width=700,max_height=109',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$destinationPath = 'uploads';
$a = $request->file('letter_head');
$extension = $a->getClientOriginalExtension();
$filename = 'letter_head';
$a->move($destinationPath,$filename.'.'.$extension);
$path = $destinationPath.'/'.$filename.'.'.$extension;
$site->letter_head = $path;
$site->save();
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan perubahan');
}
if($request->compound == "true"){
if($request->hasFile('bg_compound')){
$path = '';
$validator = Validator::make($request->all(), [
'bg_compound' => 'mimes:png|dimensions:width=450,height=450',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$destinationPath = 'uploads';
$a = $request->file('bg_compound');
$extension = $a->getClientOriginalExtension();
$filename = 'bg_compound';
$a->move($destinationPath,$filename.'.'.$extension);
$path = $destinationPath.'/'.$filename.'.'.$extension;
$site->bg_compound = $path;
$site->save();
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan perubahan');
}
}
/**
* Api Integration controller.
*
* @return json
*/
public function viewApiKey(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('main-dashboard.api.view_api_key', compact('user','site'));
}
public function viewApiIntegration(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
$api = ApiKey::all();
return view('main-dashboard.api.view_api_integration_index', compact('user','site','api'));
}
public function addApiKey(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$scopes = array();
if($request->has('compound_search')){
array_push($scopes, 'compound.search');
}
if($request->has('compound_update')){
array_push($scopes, 'compound.update.status');
}
do {
$api_key = str_random(7);
} while (ApiKey::where("key_prefix", "=", $api_key)->first() instanceof Api);
$data = [
'name' => $request->name,
'key_prefix' => $api_key,
'scopes' => $scopes
];
$api = ApiKey::create($data);
return redirect()->back()->with('success_msg', 'Successfully store new Api Key');
}
public function addIntegrasi(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$api = ApiKey::where('_id',$request->type_api)->first();
if(!empty($api)){
$api_key = $api->key_prefix.'.'.str_random(32);
$data = [
'client' => $request->client,
'key' => $api_key,
'status' => 'active'
];
$apiI = $api->apiintegrasi()->create($data);
return redirect()->back()->with('success_msg', 'Successfully store clients');
}
}
}

+ 248
- 0
app/Http/Controllers/Main/StaffController.php 查看文件

@@ -0,0 +1,248 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Validator;
use Hash;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
class StaffController extends Controller
{
/**
* Create a staff controller.
*
* @return value
*/
public function staffIndex(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$roles = Roles::all();
$site = SiteSetting::first();
$my_jabatan = Department::where('_id', $user->StaffDetail->jbkod)->first();
if(!empty($my_jabatan)){
$my_jabatan = '['.$my_jabatan->jbkod.'] '.$my_jabatan->jnama;
}else{
$my_jabatan = 'null';
}
return view('main-dashboard.team.staff_index', compact('user','department','roles','my_jabatan','site'));
}
public function staffAdd(){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$roles = Roles::where('kod','!=','03')->get();
$site = SiteSetting::first();
return view('main-dashboard.team.staff_add', compact('user','department','roles','site'));
}
public function staffEdit($cid){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$staff = StaffDetail::where('_id',$cid)->first();
$access = array();
if($staff->roles_access == "Pegawai"){
foreach($staff->roles_ids as $r){
$role = Roles::where('_id',$r)->first();
array_push($access, array(
'kod' => $role->kod
));
}
// $access = json_encode($access);
}
if(empty($access)){
$access = 'null';
}
$roles = Roles::where('kod','!=','03')->get();
$site = SiteSetting::first();
return view('main-dashboard.team.staff_edit', compact('user','department','staff','access','roles','site'));
}
public function requestAddStaff(Request $request)
{
$validator = Validator::make($request->all(), [
'password' => 'min:8|confirmed',
'profil' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
if($request->get('jawatan') == "Pegawai"){
if(empty($request->get('modul'))){
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Sila pilih <strong>modul</strong> fail kulit/kompaun untuk pegawai akses');
}
}
$staff = Staff::where('no_badan', $request->badan)->where('roles_access',$request->jawatan)->first();
if(empty($staff)) {
$encryptP = Hash::make($request->get('password'));
$profile_img = '/uploads/profile.jpg';
$saveData = false;
if($request->hasfile('profil')){
$destinationPath = 'uploads/profile';
$uploaded = public_path().'/'.$destinationPath;
$allowedfileExtension = ['jpeg','jpg'];
$a = $request->file('profil');
$extension = $a->getClientOriginalExtension();
$check=in_array($extension,$allowedfileExtension);
if($check) {
$filename = $request->get('badan');
$a->move($destinationPath,$filename.'.'.$extension);
$profile_img = '/'.$destinationPath.'/'.$filename.'.'.$extension;
$saveData = true;
}
}else{
$saveData = true;
}
if($saveData == true){
$sl = Staff::create([
'no_badan' => $request->get('badan'),
'password' => $encryptP,
'api_token' => '',
'roles_access' => $request->get('jawatan'),
'device' => '',
'remember_token' => '',
'last_login_at' => '',
'last_login_ip'=> '',
'authorized' => false,
'token_firebase' => '',
]);
$detail = new StaffDetail();
$detail->full_name = $request->get('nama');
$detail->identity = $request->get('pengenalan');
$detail->mobile = $request->get('telefon');
$detail->gred = $request->get('gred');
$detail->no_badan = $request->get('badan');
// $detail->jbkod = $request->get('jabatan');
$detail->roles_access = $request->get('jawatan');
$detail->profile_img = $profile_img;
$detail->password = $encryptP;
$sl->staffdetail()->save($detail);
if($request->get('jawatan') == 'Pegawai'){
foreach($request->modul as $m){
$roles = Roles::where('kod',$m)->first();
$detail->roles()->attach($roles);
}
}
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$detail->department()->attach($department);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> daftar pegawai <strong> No.Badan '.$request->get('badan').', Nama '.$request->get('nama').'</strong>');
}
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Berjaya!</strong> No.Badan <strong>'.$request->get('badan').'</strong> ini telah wujud');
}
}
public function requestEditStaff(Request $request)
{
$validator = Validator::make($request->all(), [
'profil' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
if($request->get('jawatan') == "Pegawai"){
if(empty($request->get('modul'))){
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Sila pilih <strong>modul</strong> fail kulit/kompaun untuk pegawai akses');
}
}
$staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
if(!empty($staff)) {
if($request->hasfile('profil')){
$destinationPath = 'uploads/profile';
$uploaded = public_path().'/'.$destinationPath;
$allowedfileExtension = ['jpeg','jpg'];
$a = $request->file('profil');
$extension = $a->getClientOriginalExtension();
$check=in_array($extension,$allowedfileExtension);
if($check) {
$filename = $request->get('badan');
$a->move($destinationPath,$filename.'.'.$extension);
$profile_img = '/'.$destinationPath.'/'.$filename.'.'.$extension;
$staff->StaffDetail->profile_img = $profile_img;
$staff->StaffDetail->save();
}
}
$staff->roles_access = $request->get('jawatan');
$staff->no_badan = $request->get('badan');
$staff->save();
$jabatan = "-";
if($request->get('jawatan') == 'sysadmin'){
$jabatan = "-";
}else{
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$department_array[] = $department->_id;
}
$staff->StaffDetail->department()->sync($department_array);
}
$staff->StaffDetail->full_name = $request->get('nama');
$staff->StaffDetail->identity = $request->get('pengenalan');
$staff->StaffDetail->mobile = $request->get('telefon');
$staff->StaffDetail->gred = $request->get('gred');
$staff->StaffDetail->no_badan = $request->get('badan');
$staff->StaffDetail->roles_access = $request->get('jawatan');
$staff->StaffDetail->save();
$roles_array = array();
if($staff->StaffDetail->roles_access == 'Pegawai' && $request->get('jawatan') == 'Pegawai'){
foreach($request->modul as $m){
$roles = Roles::where('kod',$m)->first();
$roles_array[] = $roles->_id;
}
$staff->StaffDetail->roles()->sync($roles_array);
}else{
$staff->StaffDetail->roles()->detach();
$staff->StaffDetail->roles_ids = [];
$staff->StaffDetail->save();
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini pegawai <strong> No.Badan '.$request->get('badan').', Nama '.$request->get('nama').'</strong>');
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Berjaya!</strong> Rekod No.Badan '.$request->get('badan').' tidak ditemui');
}
}
}

+ 344
- 0
app/Http/Controllers/Main/TaskController.php 查看文件

@@ -0,0 +1,344 @@
<?php
namespace App\Http\Controllers\Main;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use File;
use Carbon\Carbon;
use PDF;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\CompoundInvestigation;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Investigation;
use App\Model\Module\ItemInventory;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
use App\Jobs\UpdateCompoundPrice;
class TaskController extends Controller
{
/**
* Create Task list controller.
*
* @return json
*/
public function requestUpdateTask(Request $request){
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$jbkod = $compound->jbkod;
$now = Carbon::now();
$gDate = $now->format('F Y');
if($request->dashboard == "true"){
$roles = Roles::where('kod', $request->kategori_modul)->first();
if($compound->modul == $request->kategori_modul){
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Kompaun ini sudah berada di dalam kategori modul '.$roles->name);
}else{
$reg_id = array();
if(!empty($roles->staff_detail_ids)){
foreach($roles->staff_detail_ids as $s){
$staff = Staff::with(['StaffDetail' => function($q) use($jbkod){
$q->where('jbkod', $jbkod);
}])->where('_id', $s)->first();
if(!empty($staff->StaffDetail)){
if($staff->token_firebase != ''){
$reg_id[] = $staff->token_firebase;
}
}
}
}
if(count($reg_id) > 0) {
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', url('api/push/notification'), [
'verify' => false,
'form_params' => [
'title' => $roles->name.' '.$compound->kpd,
'msg' => 'Kompaun ini telah di pindahkan ke modul '.$roles->name,
'register_id' => $reg_id,
]
]);
}
$compound->modul = $request->kategori_modul;
$compound->save();
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Serahan Modul",
'huraian' => $compound->kpd. " / Fail Kulit (".$compound->ConfidentialFile->no_siri.") telah diserahkan ke modul ".$roles->name,
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya Kemaskini!</strong> Kompaun ini berjaya diserahkan ke kategori modul '.$roles->name);
}
}else if($request->dashboard == "false"){
if($compound->penguatkuasa == $request->penguatkuasa){
$staff = StaffDetail::where('_id',$request->penguatkuasa)->first();
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Kompaun ini sudah diserahkan kepada penguatkuasa ['.$staff->no_badan.'] '.$staff->full_name);
}else{
$staff = Staff::with('StaffDetail')->where('_id',$request->penguatkuasa)->where(function($q){
$q->where('roles_access','PenguatKuasa')->orWhere('roles_access','PPenguatKuasa');
})->first();
$role = Roles::where('kod', $compound->modul)->first();
if(!empty($staff)){
if($staff->token_firebase != '') {
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', url('api/push/notification'), [
'verify' => false,
'form_params' => [
'title' => $role->name.' '.$compound->kpd,
'msg' => 'Kompaun ini berada di ruangan '.$role->name,
'register_id[]' => $staff->token_firebase,
]
]);
}
$compound->penguatkuasa = $request->penguatkuasa;
$compound->save();
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Menugaskan Penguatkuasa ".$staff->StaffDetail->full_name,
'huraian' => $compound->kpd. " / Fail Kulit (".$compound->ConfidentialFile->no_siri.") telah ditugaskan kepada penguatkuasa <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya Kemaskini!</strong> Kompaun ini berjaya ditugaskan kepada penguatkuasa ['.$staff->no_badan.'] '.$staff->StaffDetail->full_name);
}else{
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Data penguatkuasa tidak ditemui');
}
}
}
}
public function requestViewAllPdf($kpd) {
$ready_view_pdf = false;
$availablePDF = array();
$now = Carbon::now()->format('d/m/Y h:i:s A');
$site = SiteSetting::first();
$compound = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('kpd', $kpd)->first();
$file = ConfidentialFile::with(['Memo' => function($q){
$q->orderBy('updated_at','ASC');
}],['Investigation' => function($q){
$q->with(['Attachment' => function($w){
$w->first();
}])->orderBy('updated_at','ASC');
}],['ItemInventory' => function($w){
$w->with('Barcode');
}])->where('_id',$compound->ConfidentialFile->_id)->first();
/**
** Compound
**/
$tawaran = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$tawaran = $compound->jumlah_asal_kompaun;
}else{
$tawaran = $compound->jumlah_kemaskini_kompaun;
}
$staff = Staff::with('StaffDetail')->where('_id', $compound->dikeluarkan)->first();
$faulty = Faulty::with('DeedLaw')->where('_id',$compound->seksyen_kesalahan)->first();
$department = Department::where('_id', $compound->jbkod)->first();
$upload [] = [ 'name' => 'compound', 'contents' => $compound ];
$upload [] = [ 'name' => 'faulty', 'contents' => $faulty ];
$upload [] = [ 'name' => 'staff', 'contents' => $staff ];
$upload [] = [ 'name' => 'department', 'contents' => $department ];
$upload [] = [ 'name' => 'tawaran', 'contents' => $tawaran ];
$upload [] = [ 'name' => 'site', 'contents' => $site ];
$upload [] = [ 'name' => 'type', 'contents' => 'mbip' ];
$upload [] = [ 'name' => 'file', 'contents' => $file ];
$upload [] = [ 'name' => 'now', 'contents' => $now ];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/compound/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
$compound->pdf_path = $response->data;
$compound->save();
}
/**
** Investigation
**/
$upload [] = [ 'name' => 'file', 'contents' => $file ]; $temp = [];
if(!empty($file->Investigation)){
foreach($file->Investigation as $i => $in){
$attach = Investigation::with('Attachment')->where('_id',$in->_id)->first();
foreach ($attach->Attachment as $key => $p) {
$temp[] = $p->path;
}
}
$upload [] = [ 'name' => 'fileInvest', 'contents' => json_encode($temp)];
}
/**
** All Memo in file
**/
if(!empty($file->Memo)){
$memoData = array();
foreach($file->Memo as $i => $m){
$memo = Memo::with('Attachment')->where('_id',$m->_id)->first();
$staffD = Staff::with('StaffDetail')->where('_id',$memo->dikeluarkan)->first();
$staffS = Staff::with('StaffDetail')->where('_id',$memo->disahkan)->first();
$kesalahan = Faulty::where('itkod', $memo->itkod)->first();
$dikeluarkan = ''; $disahkan = ''; $faulty = ''; $modul = '';
if(!empty($staffD)){
$dikeluarkan = $staffD->StaffDetail->full_name;
}
if(!empty($staffS)){
$disahkan = $staffD->StaffDetail->full_name;
}
if(!empty($kesalahan)){
$faulty ='['.$kesalahan->skter.'] '.$kesalahan->nama;
}
if($memo->modul != '-'){
$r = Roles::where('kod',$memo->modul)->first();
if(!empty($r)){
$modul = $r->name;
}
}
$update = Carbon::parse($memo->updated)->toDateTimeString();
$mula = date('d/m/Y h:i a', strtotime($memo->tarikh_mula));
$akhir = date('d/m/Y', strtotime($memo->tarikh_akhir));
if($memo->jenis_data == "manual"){
$dataM = [
'memo' => $memo,
'dikeluarkan' => $dikeluarkan,
'disahkan' => $disahkan,
'update' => $update,
'mula' => $mula,
'akhir' => $akhir,
'faulty' => $faulty,
'modul' => $modul,
'attachment' => [],
];
$memoData[] = $dataM;
}else if($memo->jenis_data == "pdf"){
foreach($m->Attachment as $key => $a){
$pdf[] = $a->path;
}
$dataM = [
'memo' => $memo,
'dikeluarkan' => $dikeluarkan,
'disahkan' => $disahkan,
'update' => $update,
'mula' => $mula,
'akhir' => $akhir,
'faulty' => $faulty,
'modul' => $modul,
'attachment' => $pdf,
];
$memoData[] = $dataM;
}
}
$upload [] = [ 'name' => 'memo', 'contents' => json_encode($memoData)];
}
/**
** Inventory
**/
if(count($file->ItemInventory) > 0){
$dataItem = array();
foreach ($file->ItemInventory as $key => $b) {
$barcode = '';
foreach ($b->Barcode as $key => $br) {
$barcode .= ', '.$br->barcode_id;
$data = [
'item' => $b,
'barcode' => $barcode,
];
}
$dataItem[] = $data;
}
$upload [] = [ 'name' => 'inventori', 'contents' => json_encode($dataItem)];
}
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/store/compound/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
return redirect($response->data);
}else if($response->success == false){
return response()->json($response->message);
}
}
}

+ 137
- 0
app/Http/Controllers/NotificationController.php 查看文件

@@ -0,0 +1,137 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Notification;
class NotificationController extends BaseController
{
/**
* Create save firebase token controller.
*
* @return json
*/
public function saveToken(Request $request) {
$staff = Staff::where('_id', $request->_id)->first();
if(!empty($staff)){
$staff->token_firebase = $request->token;
$staff->save();
return $this->sendResponse($staff,'Berjaya kemaskini firebase token');
}else{
return $this->sendError('','Tidak berjaya kemaskini firebase token');
}
}
/**
* Create notification controller.
*
* @return json
*/
public function createNotifications($title, $msg, array $token) {
$fcmUrl = 'https://fcm.googleapis.com/fcm/send';
$notification = [
'title' => $title,
'body' => $msg,
'icon' => '',
'sound' => true,
];
$extraNotificationData = ["message" => $notification];
$fcmNotification = [
'registration_ids' => $token, //multple token array
'notification' => $notification,
'data' => $extraNotificationData
];
$headers = [
'Authorization: key=AIzaSyCJQ2HZW7dr1l1ZEcM__Ywd3fyF832eoOc',
'Content-Type: application/json'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$fcmUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fcmNotification));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
public function sendNotification(Request $request){
$title = $request->title;
$msg = $request->msg;
$register_id = $request->register_id;
if($register_id != null){
$result = $this->createNotifications($title, $msg, $register_id);
$response = json_decode($result);
foreach ($response->results as $key => $r) {
if(!empty($r->error)){}
else if(!empty($r->message_id)){
$staff = Staff::with('StaffDetail')->where('token_firebase',$register_id[$key])->first();
if(!empty($staff)){
$dataNoti = [
'title' => $request->title,
'body' => $request->msg,
];
$staff->notification()->create($dataNoti);
}
}
}
return $this->sendResponse($response,'Berjaya hantar notifikasi');
}
}
public function getNotificationMobile(Request $request){
$staff = Staff::with('StaffDetail','Notification')->where('api_token', $request->api_token)->first();
if(!empty($staff)){
$noti = $staff->Notification;
return $this->sendResponse($noti,'Berjaya dapatkan notifikasi');
}else{
return $this->sendError('','Kakitangan tidak ditemui!');
}
}
public function getNotificationWeb(Request $request){
$staff = Staff::with('StaffDetail','Notification')->where('_id', $request->_id)->first();
if(!empty($staff)){
$noti = $staff->Notification;
return $this->sendResponse($noti,'Berjaya dapatkan notifikasi');
}else{
return $this->sendError('','Kakitangan tidak ditemui!');
}
}
public function deleteNotification(Request $request){
$noti = Notification::where('_id', $request->_id)->first();
if(!empty($noti)){
$noti->delete();
return $this->sendResponse($noti,'Berjaya buang notifikasi');
}else{
return $this->sendError('','Data tidak ditemui!');
}
}
}

+ 28
- 0
app/Http/Controllers/Officer/ApplicationController.php 查看文件

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
class ApplicationController extends Controller
{
public function userIndex(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('officer.user_index',compact('user','site'));
}
public function applicationIndex(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('officer.application_index',compact('user','site'));
}
}

+ 415
- 0
app/Http/Controllers/Officer/CompoundController.php 查看文件

@@ -0,0 +1,415 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\CompoundInvestigation;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
use App\Jobs\StoreCompound;
use App\Jobs\StoreCompoundManual;
use App\Jobs\UpdateCompoundPrice;
class CompoundController extends Controller
{
public function returnDepartment($id){
$department = StaffDetail::where("_id", $id)->first();
return $department->department_ids;
}
public function returnCompound($modul,$id, $status){
$department = $this->returnDepartment($id);
if($status == 'Belum Bayar'){
if($modul == '06-07'){
$compound = Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get();
}else{
$compound = Compound::where('modul',$modul)->where('status','Belum Bayar')->get();
}
}else{
$compound = Compound::where('status','Berbayar')->get();
}
$temp = [];
foreach($compound as $c){
if(in_array($c->jbkod, (array)$department)) {
$temp[] = $c;
}
}
return $temp;
}
/**
* Create compound list interface controller.
*
* @return json
*/
public function index(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles','Department');
}])->find($id);
$roles = $user->StaffDetail->Roles->toArray();
$department = $user->StaffDetail->Department;
$site = SiteSetting::first();
$baru = count($this->returnCompound('03', $id,'Belum Bayar'));
$invest = count($this->returnCompound('04', $id, 'Belum Bayar'));
$notice = count($this->returnCompound('05', $id, 'Belum Bayar'));
$inven = count($this->returnCompound('06-07', $id, 'Belum Bayar'));
$collap = count($this->returnCompound('08', $id, 'Belum Bayar'));
$comp = count($this->returnCompound('', $id, 'Berbayar'));
return view('officer.compound.compound_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles'));
}
public function investigation_index(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$roles = $user->StaffDetail->Roles->toArray();
$department = $user->StaffDetail->Department;
$site = SiteSetting::first();
$baru = count($this->returnCompound('03', $id,'Belum Bayar'));
$invest = count($this->returnCompound('04', $id, 'Belum Bayar'));
$notice = count($this->returnCompound('05', $id, 'Belum Bayar'));
$inven = count($this->returnCompound('06-07', $id, 'Belum Bayar'));
$collap = count($this->returnCompound('08', $id, 'Belum Bayar'));
$comp = count($this->returnCompound('', $id, 'Berbayar'));
return view('officer.compound.investigation_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles'));
}
public function notice_index(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$roles = $user->StaffDetail->Roles->toArray();
$department = $user->StaffDetail->Department;
$site = SiteSetting::first();
$baru = count($this->returnCompound('03', $id,'Belum Bayar'));
$invest = count($this->returnCompound('04', $id, 'Belum Bayar'));
$notice = count($this->returnCompound('05', $id, 'Belum Bayar'));
$inven = count($this->returnCompound('06-07', $id, 'Belum Bayar'));
$collap = count($this->returnCompound('08', $id, 'Belum Bayar'));
$comp = count($this->returnCompound('', $id, 'Berbayar'));
return view('officer.compound.notice_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles'));
}
public function confiscated_index(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$roles = $user->StaffDetail->Roles->toArray();
$department = $user->StaffDetail->Department;
$site = SiteSetting::first();
$baru = count($this->returnCompound('03', $id,'Belum Bayar'));
$invest = count($this->returnCompound('04', $id, 'Belum Bayar'));
$notice = count($this->returnCompound('05', $id, 'Belum Bayar'));
$inven = count($this->returnCompound('06-07', $id, 'Belum Bayar'));
$collap = count($this->returnCompound('08', $id, 'Belum Bayar'));
$comp = count($this->returnCompound('', $id, 'Berbayar'));
return view('officer.compound.confiscated_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles'));
}
public function collapsed_index(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$roles = $user->StaffDetail->Roles->toArray();
$department = $user->StaffDetail->Department;
$site = SiteSetting::first();
$baru = count($this->returnCompound('03', $id,'Belum Bayar'));
$invest = count($this->returnCompound('04', $id, 'Belum Bayar'));
$notice = count($this->returnCompound('05', $id, 'Belum Bayar'));
$inven = count($this->returnCompound('06-07', $id, 'Belum Bayar'));
$collap = count($this->returnCompound('08', $id, 'Belum Bayar'));
$comp = count($this->returnCompound('', $id, 'Berbayar'));
return view('officer.compound.collapsed_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles'));
}
public function completed_index(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$roles = $user->StaffDetail->Roles->toArray();
$department = $user->StaffDetail->Department;
$site = SiteSetting::first();
$baru = count($this->returnCompound('03', $id,'Belum Bayar'));
$invest = count($this->returnCompound('04', $id, 'Belum Bayar'));
$notice = count($this->returnCompound('05', $id, 'Belum Bayar'));
$inven = count($this->returnCompound('06-07', $id, 'Belum Bayar'));
$collap = count($this->returnCompound('08', $id, 'Belum Bayar'));
$comp = count($this->returnCompound('', $id, 'Berbayar'));
return view('officer.compound.completed_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles'));
}
public function viewCompoundHistoryDetail($kpd){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::with('History','History.SubHistory')->where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('officer.compound_detail.history_detail', compact('user','compound','file','role','site'));
}
public function viewCompoundDetail($kpd){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles','Department');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$faulty = Faulty::with(['DeedLaw' => function($q){
$q->with('Department');
}])->where('_id',$compound->seksyen_kesalahan)->first();
$role = Roles::where('kod',$compound->modul)->first();
$total = ''; $enforcer = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$total = $compound->jumlah_asal_kompaun;
}else{
$total = $compound->jumlah_kemaskini_kompaun;
}
$site = SiteSetting::first();
$enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
return view('officer.compound_detail.compound_detail', compact('user','compound','akta','faulty','role','total','enforcer','site'));
}
public function viewCompoundMemoDetail($kpd){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$roles = Roles::all();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('officer.compound_detail.memo_detail', compact('user','compound','file','roles','role','site'));
}
public function viewCompoundEditMemoDetail($kpd, $memo){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$memo = Memo::where('_id',$memo)->first();
$roles = Roles::all();
$site = SiteSetting::first();
return view('officer.compound_detail.compound_memo_edit', compact('user','compound','file','roles','memo','site'));
}
public function viewCompoundInvestigationDetail($kpd){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$investigation = Compound::with('CompoundInvestigation')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$faulty = Faulty::where('_id',$compound->seksyen_kesalahan)->first();
$akta = DeedLaw::where('akkod',$faulty->akkod)->first();
$role = Roles::where('kod',$compound->modul)->first();
$total = ''; $enforcer = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$total = $compound->jumlah_asal_kompaun;
}else{
$total = $compound->jumlah_kemaskini_kompaun;
}
$site = SiteSetting::first();
$enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
return view('officer.compound_detail.investigation_detail', compact('user','compound','investigation','file','akta','faulty','role','total','enforcer','site'));
}
public function viewCompoundNoticeDetail($kpd){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('officer.compound_detail.notice_detail', compact('user','compound','file','role','site'));
}
public function viewCompoundInventoryDetail($kpd){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('officer.compound_detail.inventory_detail', compact('user','compound','file','role','site'));
}
public function viewCompoundAuctionDetail($kpd){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
return view('officer.compound_detail.auction_detail', compact('user','compound','file','role','site'));
}
public function viewTaskIndex($kpd){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Roles');
}])->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
$roles = Roles::all();
$staffs = StaffDetail::where('roles_access','PenguatKuasa')->where('jbkod',$user->StaffDetail->jbkod)->get();
$role = Roles::where('kod',$compound->modul)->first();
$site = SiteSetting::first();
$currentS = '';
$s = StaffDetail::where('roles_access','PenguatKuasa')->where('no_badan',$compound->penguatkuasa)->first();
if(!empty($s)){
$currentS = '['.$s->no_badan.'] '.$s->full_name;
}
return view('officer.compound_detail.compound_job',compact('user','compound','roles','staffs','role','currentS','site'));
}
public function manualCompound(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Department');
}])->find($id);
$finalFaulty = [];
$site = SiteSetting::first();
$faulty = Faulty::with('Department');
$department = $user->StaffDetail->department_ids;
$faulty->whereHas('Department', function($q) use ($department) {
$q->whereIn('_id', $department);
});
$akta = DeedLaw::orderBy('nama','ASC')->get();
$staff = StaffDetail::whereHas('Department', function($q) use ($department) {
$q->whereIn('_id', $department);
})->where('roles_access', 'PenguatKuasa');
$faulty = $faulty->get();
$staff = $staff->get();
return view('officer.compound.compound_form',compact('user','site','department','akta','faulty','staff'));
}
/**
* Create generate kpd number controller.
*
* @return value
*/
public function generateKPD($uniq_id,$range){
$allowedNumbers = range(0, 9);
shuffle($allowedNumbers);
$digits = array_rand($allowedNumbers, $range);
$number = '';
foreach($digits as $d){
$number .= $allowedNumbers[$d];
}
return $uniq_id.$number;
}
public function storemanualCompound(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$faulty = Faulty::where('_id',$request->get('seksyen'))->first();
if(!empty($faulty)){
$kpd = 'KP' . $this->generateKPD($request->get('uniq_id'), 5);
$no_siri = $this->generateKPD('', 5);
$this->dispatch(new StoreCompoundManual($request->all(), $kpd, $request->staff, $no_siri));
$data = array();
$dataExist = false;
do {
$compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
if(!empty($compound)){
$tawaran = '';
if($compound->jumlah_kemaskini_kompaun != ''){
$tawaran = $compound->jumlah_kemaskini_kompaun;
}else{
$tawaran = $compound->jumlah_asal_kompaun;
}
array_push($data, array('kpd' => $kpd, 'jumlah_kompoun' => $tawaran));
$dataExist = true;
}
}while(!$dataExist);
return redirect()->back()->with('success_msg', 'Berjaya simpan rekod kompaun!');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod seksyen kesalahan tidak ditemui!');
}
}
}

+ 171
- 0
app/Http/Controllers/Officer/DepartmentController.php 查看文件

@@ -0,0 +1,171 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
class DepartmentController extends Controller
{
/**
* Create a deed law controller.
*
* @return value
*/
public function actIndex(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Department');
}])->find($id);
$site = SiteSetting::first();
$department = $user->StaffDetail->Department;
return view('officer.act_uuk_index', compact('user','site','department'));
}
public function addDeedLaw(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
if(!empty($request->jabatan)){
$deedlaw = DeedLaw::create([
'akkod' => $request->get('akkod'),
'tarikh' => $request->get('tarikh'),
'nama' => $request->get('nama'),
]);
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$deedlaw->department()->attach($department);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan rekod akta <strong>'.$request->get('nama').'</strong> baru');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod jabatan yg dipilih tidak wujud');
}
}
public function updateDeedLaw(Request $request)
{
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$akta = DeedLaw::where('_id',$request->get('_id'))->first();
if(!empty($akta)){
if(!empty($request->jabatan)){
$akta->akkod = $request->get('akkod');
$akta->tarikh = $request->get('tarikh');
$akta->nama = $request->get('nama');
$akta->save();
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$department_array[] = $department->_id;
}
$akta->department()->sync($department_array);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod akta/uuk ( '.$request->get('nama').' )');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod jabatan yg dipilih tidak wujud');
}
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> Kemaskini rekod akta/uuk ( '.$request->get('nama').' )');
}
}
/**
* Create a department controller.
*
* @return value
*/
public function faultyIndex(){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Department');
}])->find($id);
$department = $user->StaffDetail->Department;
$site = SiteSetting::first();
$deed = DeedLaw::all();
$department = Department::orderBy('jnama','ASC')->get();
return view('officer.faulty_index', compact('user','site','deed','department'));
}
public function requestAddFaulty(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$temp = Faulty::where('itkod',$request->get('itkod'))->first();
if(empty($temp)) {
$akta = Deedlaw::where('_id', $request->get('akkod'))->first();
if(!empty($akta)) {
$seksyen = new Faulty;
$seksyen->itkod = $request->get('itkod');
$seksyen->sketr = $request->get('sketr');
$seksyen->nama = $request->get('nama');
$seksyen->amount_before_14 = $request->get('amount_14');
$seksyen->amount_before_30 = $request->get('amount_30');
$seksyen->amount = $request->get('amount');
$akta->faulty()->save($seksyen);
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$seksyen->department()->attach($department);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan rekod seksyen/kesalahan <strong>'.$request->get('nama').'</strong>');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod akta yg dipilih tidak wujud');
}
}
else {
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod seksyen/kesalahan <strong>'.$request->get('nama').'</strong> telah wujud');
}
}
public function updateFaulty(Request $request)
{
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$faulty = Faulty::with('DeedLaw')->where('_id',$request->get('_id'))->first();
if(!empty($faulty)){
$akta = Deedlaw::where('_id', $request->get('akkod'))->first();
if(!empty($akta)) {
$faulty->itkod = $request->get('itkod');
$faulty->sketr = $request->get('sketr');
$faulty->nama = $request->get('nama');
$faulty->amount_before_14 = $request->get('amount_14');
$faulty->amount_before_30 = $request->get('amount_30');
$faulty->amount = $request->get('amount');
$akta->faulty()->save($faulty);
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$department_array[] = $department->_id;
}
$faulty->department()->sync($department_array);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini rekod seksyen/kesalahan <strong>'.$request->get('nama').'</strong>');
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod akta yg dipilih tidak wujud');
}
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> kemaskini rekod seksyen/kesalahan <strong>'.$request->get('nama').'</strong>');
}
}
}

+ 23
- 0
app/Http/Controllers/Officer/IndexController.php 查看文件

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
class IndexController extends Controller
{
public function index(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('officer.index', compact('user','site'));
}
}

+ 196
- 0
app/Http/Controllers/Officer/InventoryController.php 查看文件

@@ -0,0 +1,196 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use Carbon\Carbon;
use PDF;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\ItemInventory;
use App\Model\Module\Barcode;
use App\Model\Module\Attachment;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Jobs\GenerateBarcode;
class InventoryController extends Controller
{
/**
* Create Inventory ID controller.
*
* @return json
*/
public function generateBR($uniq_id,$range){
$allowedNumbers = range(0, 9);
shuffle($allowedNumbers);
$digits = array_rand($allowedNumbers, $range);
$number = '';
foreach($digits as $d){
$number .= $allowedNumbers[$d];
}
return $uniq_id.$number;
}
/**
* Create Inventory list controller.
*
* @return json
*/
public function addItem(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
if(!empty($compound)){
$item = [
'kategori' => $request->get('kategori'),
'jenis' => $request->get('jenis'),
'bilangan' => $request->get('bilangan'),
'harga' => $request->get('harga'),
'lokasi_gudang' => $request->get('lokasi'),
'status' => 'simpan'
];
$itemI = ItemInventory::create($item);
$compound->ConfidentialFile->iteminventory()->save($itemI);
$l = 0;
while($l != $request->get('bilangan')) {
$name = '';
do {
$name = $this->generateBR('BR', 5);
} while (Barcode::where("barcode_id", "=", $name)->first() instanceof Barcode);
$this->dispatch(new GenerateBarcode($request->kpd, $name, $itemI));
$l++;
}
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Ada penambahan item inventori dari 'dashboard'",
'huraian' => "Item inventori telah ditambah oleh ".$user->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Rekod item inventori berjaya ditambah');
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kertas kompaun tidak ditemui');
}
}
public function editItem(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$data_barcode_empty = false;
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
$itemI = ItemInventory::with('Attachment','Barcode')->where('_id',$request->_id)->first();
if(!empty($itemI)){
if($request->has('lokasi')){
$itemI->jenis = $request->get('jenis');
$itemI->bilangan = $request->get('bilangan');
$itemI->harga = $request->get('harga');
$itemI->lokasi_gudang = $request->get('lokasi');
$itemI->save();
}else{
$itemI->jenis = $request->get('jenis');
$itemI->bilangan = $request->get('bilangan');
$itemI->harga = $request->get('harga');
$itemI->save();
}
if(!empty($itemI->Barcode)){
foreach ($itemI->Barcode as $b) {
$b->forceDelete();
}
$data_barcode_empty = true;
}
if($data_barcode_empty == true){
$l = 0;
while($l != $request->get('bilangan')) {
$name = $this->generateBR('BR', 5);
$this->dispatch(new GenerateBarcode($request->kpd, $name, $itemI));
$l++;
}
}
$now = Carbon::now();
$gDate = $now->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Item inventori dikemaskini",
'huraian' => "Item inventori diekmaskini oleh ".$user->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini Rekod item inventori');
}else{
return redirect()->back()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod item tidak ditemui');
}
}
public function requestViewInventoryPdf($kpd) {
$compound = Compound::with('ConfidentialFile')->where('kpd', $kpd)->first();
$file = ConfidentialFile::with(['ItemInventory' => function($q){
$q->with('Attachment','Barcode')->orderBy('created_at','DESC');
}])->where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$site = SiteSetting::first();
$now = Carbon::now()->format('d/m/Y h:i:s A');
$pdf = PDF::loadView('pdf.inventory', compact('compound','file','now','site'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}
}

+ 220
- 0
app/Http/Controllers/Officer/InvestigationController.php 查看文件

@@ -0,0 +1,220 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Validator;
use File;
use Carbon\Carbon;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\CompoundInvestigation;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Investigation;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
class InvestigationController extends Controller
{
/**
* Create compound list interface controller.
*
* @return json
*/
public function updateCompoundInvestigation(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'jumlah_kompaun' => 'numeric',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$save = false;
$compound = Compound::with('CompoundInvestigation')->where('kpd',$request->kpd)->first();
$file = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
$now = Carbon::now();
$gDate = $now->format('F Y');
if(!empty($compound->CompoundInvestigation)){
$compound->CompoundInvestigation->nama = $request->full_name;
$compound->CompoundInvestigation->identity = $request->ic;
$compound->CompoundInvestigation->nama_syarikat = $request->nama_syarikat;
$compound->CompoundInvestigation->no_daftar_syarikat = $request->no_syarikat;
$compound->CompoundInvestigation->alamat = $request->alamat;
$compound->CompoundInvestigation->save();
if($request->has('jumlah_kompaun')){
$compound->jumlah_kemaskini_kompaun = $request->jumlah_kompaun;
$compound->save();
}
$save = true;
}else{
$compoundData = [
'nama' => $request->full_name,
'identity' => $request->ic,
'nama_syarikat' => $request->nama_syarikat,
'no_daftar_syarikat' => $request->no_syarikat,
'alamat' => $request->alamat,
];
$compound->compoundinvestigation()->create($compoundData);
if($request->has('jumlah_kompaun')){
$compound->jumlah_kemaskini_kompaun = $request->jumlah_kompaun;
$compound->save();
}
$save = true;
}
if($save == true){
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $file->ConfidentialFile->no_siri,
'tajuk' => $user->StaffDetail->roles_access." ".$user->StaffDetail->full_name." mengemaskini data kompaun ".$request->kpd,
'huraian' => "Data kompaun ".$request->kpd." dikemaskini oleh ".$user->StaffDetail->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a> di bawah kategori modul <b>Kertas Siasatan</b>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Rekod kompaun berjaya dikemaskini untuk siasatan');
}
}
public function addAttachInvestigation(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'attachment' => 'mimes:pdf|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$now = Carbon::now();
$gDate = $now->format('F Y');
$file = ConfidentialFile::where('no_siri', $request->nosiri)->first();
if(!empty($file)){
if($request->hasFile('attachment')) {
$upload = [];
$a = $request->file('attachment');
$upload[] = [
'name' => 'attachment',
'contents' => fopen( $a->getPathname(), 'r' ),
'filename' => $a->getClientOriginalName()
];
$upload [] = [
'name' => 'no_siri',
'contents' => $request->nosiri
];
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/investigation/file', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
$investigationData = [
'subjek' => $request->subjek,
'kategori' => $request->kategori,
];
$invest = $file->investigation()->create($investigationData);
$attach = new Attachment();
$attach->path = $response->data;
$invest->attachment()->save($attach);
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $file->no_siri,
'tajuk' => $user->StaffDetail->roles_access." ".$user->StaffDetail->full_name." memuat naik lampiran SSM / JPJ",
'huraian' => "Lampiran SSM/JPJ telah dimuat naik oleh ".$user->StaffDetail->roles_access." <b><a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a></b>",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$file->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$file->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Rekod lampiran berjaya di simpan');
}else if($response->success == false){
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> '.$response->message);
}
}else {
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila pastikan anda muat naik pdf sebelum hantar data');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' tidak ditemui');
}
}
public function attachmentView($_id){
$attach = Investigation::with('Attachment')->where('_id',$_id)->first();
if(!empty($attach->Attachment)){
$path = $attach->Attachment->first()->path;
return \Response::make(file_get_contents($path), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename=""'
]);
}
}
}

+ 340
- 0
app/Http/Controllers/Officer/MemoController.php 查看文件

@@ -0,0 +1,340 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use Carbon\Carbon;
use Validator;
use PDF;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
use App\Model\Module\Attachment;
use App\Model\Module\Faulty;
use App\Model\Module\Memo;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Jobs\UpdateCompoundPrice;
class MemoController extends Controller
{
public function requestAddMemo(Request $request) {
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
if($request->jenis_memo == "Tambahan" || $request->jenis_memo == "Potongan"){
if($request->has('tawaran')){
if (preg_match("/^100+%$|[0-9]+%/", $request->get('tawaran'))){
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila isikan ruangan tawaran dengan format yang betul');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila isikan ruangan tawaran sekiranya anda memilih memo jenis potongan mahupun tambahan');
}
}
$validator = Validator::make($request->all(), [
'attachment.*' => 'mimes:pdf|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$sahkan = '';
if($user->StaffDetail->roles_access == "Ketua Jabatan"){
$sahkan = $user->_id;
}
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
if($compound->ConfidentialFile->modul != '-'){
$modul = Roles::where('kod', $compound->modul)->first();
$now = Carbon::now();
$gDate = $now->format('F Y');
if($request->hasfile('attachment')){
$memo = Memo::create([
'itkod' => '-',
'modul' => $compound->modul,
'jenis_memo' => $request->get('jenis_memo'),
'no_rujukan' => $request->get('no_rujukan'),
'tawaran_kompaun' => $request->get('tawaran'),
'tarikh_mula' => $request->get('tarikh_mula'),
'tarikh_akhir' => $request->get('tarikh_akhir'),
'dikeluarkan' => $user->_id,
'disahkan' => $sahkan,
'jenis_data' => 'pdf',
'subjek' => $request->get('subjek'),
'penerangan' => $request->get('penerangan'),
'created_at' => $now,
]);
$compound->ConfidentialFile->memo()->attach($memo);
$this->dispatch(new UpdateCompoundPrice($request->kpd));
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penambahan Memo[ ".$request->get('no_rujukan')." ] : ".$request->get('subjek'),
'huraian' => $request->get('penerangan'),
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
$upload = [];
foreach($request->file('attachment') as $f){
$upload[] = [
'name' => 'file[]',
'contents' => fopen( $f->getPathname(), 'r' ),
'filename' => $f->getClientOriginalName()
];
}
$upload[] = [
'name' => 'no_siri',
'contents' => $compound->ConfidentialFile->no_siri,
];
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/file/memo/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
foreach ($response->data as $key => $d) {
$attach = new Attachment();
$attach->path = $d;
$memo->attachment()->save($attach);
}
}else if($response->success == false){
return redirect()->back()->with('error_msg', '<strong>Gagal!</strong> memuatnaik pdf');
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod memo di kategori modul <strong>('.$modul->name.')</strong>');
}else{
$memo = Memo::create([
'itkod' => '-',
'modul' => $compound->modul,
'jenis_memo' => $request->get('jenis_memo'),
'no_rujukan' => $request->get('no_rujukan'),
'tawaran_kompaun' => $request->get('tawaran'),
'tarikh_mula' => $request->get('tarikh_mula'),
'tarikh_akhir' => $request->get('tarikh_akhir'),
'dikeluarkan' => $user->_id,
'disahkan' => $sahkan,
'jenis_data' => 'manual',
'subjek' => $request->get('subjek'),
'penerangan' => $request->get('penerangan'),
'created_at' => $now,
]);
$compound->ConfidentialFile->memo()->attach($memo);
$this->dispatch(new UpdateCompoundPrice($request->kpd));
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penambahan Memo[ ".$request->get('no_rujukan')." ] : ".$request->get('subjek'),
'huraian' => $request->get('penerangan'),
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod memo di kategori modul <strong>('.$modul->name.')</strong>');
}
}
}
public function requestEditMemo(Request $request) {
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
if($request->jenis_memo == "Tambahan" || $request->jenis_memo == "Potongan"){
if($request->has('tawaran')){
if (preg_match("/^100+%$|[0-9]+%/", $request->get('tawaran'))){
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila isikan ruangan tawaran dengan format yang betul');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Sila isikan ruangan tawaran sekiranya anda memilih memo jenis potongan mahupun tambahan');
}
}
$sahkan = '';
if($user->StaffDetail->roles_access == "Ketua Jabatan"){
$sahkan = $user->_id;
}
$compound = Compound::with('ConfidentialFile')->where('kpd', $request->kpd)->first();
$memo = Memo::where('_id', $request->memo_id)->first();
if(!empty($memo)){
$now = Carbon::now();
$gDate = $now->format('F Y');
if($request->hasfile('attachment')){
$uploadNew = false;
if($memo->jenis_data == "pdf"){
foreach ($memo->Attachment as $m) {
$m->forceDelete();
}
$uploadNew = true;
}else if($memo->jenis_data == "manual"){
$uploadNew = true;
}
if($uploadNew == true){
$memo->jenis_memo = $request->get('jenis_memo');
$memo->no_rujukan = $request->get('no_rujukan');
$memo->tawaran_kompaun = $request->get('tawaran');
$memo->tarikh_mula = $request->get('tarikh_mula');
$memo->tarikh_akhir = $request->get('tarikh_akhir');
$memo->jenis_data = 'pdf';
$memo->subjek = $request->get('subjek');
$memo->penerangan = $request->get('penerangan');
$memo->disahkan = $sahkan;
$memo->save();
$this->dispatch(new UpdateCompoundPrice($request->kpd));
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Kemaskini Memo[ ".$request->get('no_rujukan')." ] : ".$request->get('subjek'),
'huraian' => $request->get('penerangan'),
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
$upload = [];
foreach($request->file('attachment') as $f){
$upload[] = [
'name' => 'file[]',
'contents' => fopen( $f->getPathname(), 'r' ),
'filename' => $f->getClientOriginalName()
];
}
$upload[] = [
'name' => 'no_siri',
'contents' => $compound->ConfidentialFile->no_siri,
];
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/file/memo/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
foreach ($response->data as $key => $d) {
$attach = new Attachment();
$attach->path = $d;
$memo->attachment()->save($attach);
}
}else if($response->success == false){
return redirect()->back()->with('error_msg', '<strong>Gagal!</strong> memuatnaik pdf');
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod memo <strong>('.$memo->no_rujukan.')</strong>. Untuk berkuat serta merta, sila sahkan semula memo nie jika perlu.');
}
}else{
$memo->jenis_memo = $request->get('jenis_memo');
$memo->no_rujukan = $request->get('no_rujukan');
$memo->tawaran_kompaun = $request->get('tawaran');
$memo->tarikh_mula = $request->get('tarikh_mula');
$memo->tarikh_akhir = $request->get('tarikh_akhir');
$memo->jenis_data = 'manual';
$memo->subjek = $request->get('subjek');
$memo->penerangan = $request->get('penerangan');
$memo->disahkan = $sahkan;
$memo->save();
$this->dispatch(new UpdateCompoundPrice($request->kpd));
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Kemaskini Memo[ ".$request->get('no_rujukan')." ] : ".$request->get('subjek'),
'huraian' => $request->get('penerangan'),
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod memo <strong>('.$memo->no_rujukan.')</strong>. Untuk berkuat serta merta, sila sahkan semula memo nie jika perlu.');
}
}
}
}

+ 138
- 0
app/Http/Controllers/Officer/ProfileController.php 查看文件

@@ -0,0 +1,138 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Validator;
use Hash;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
class ProfileController extends Controller
{
/**
* Create a profile controller.
*
* @return value
*/
public function staffProfile($_id){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$staff = StaffDetail::where('_id',$_id)->first();
$site = SiteSetting::first();
$department = Department::all();
$roles = Roles::all();
$access = array();
if($staff->roles_access == "Pegawai"){
foreach($staff->roles_ids as $r){
$role = Roles::where('_id',$r)->first();
array_push($access, array(
'kod' => $role->kod
));
}
// $access = json_encode($access);
}
if(empty($access)){
$access = 'null';
}
$myDepartment = Department::whereHas('StaffDetail', function($q) use ($_id) {
$q->where('_id', $_id);
})->select('jbkod', 'jnama')->get();
return view('officer.profile', compact('user','_id','department','staff','access','roles','myDepartment','site'));
}
public function updateBasic(Request $request){
$validator = Validator::make($request->all(), [
'profil' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
if(!empty($staff)) {
if($request->hasFile('profil')){
$destinationPath = 'uploads/profile';
$uploaded = public_path().'/'.$destinationPath;
$allowedfileExtension = ['jpeg','jpg'];
$a = $request->file('profil');
$extension = $a->getClientOriginalExtension();
$filename = $staff->StaffDetail->no_badan;
$a->move($destinationPath,$filename.'.'.$extension);
$profile_img = '/'.$destinationPath.'/'.$filename.'.'.$extension;
$staff->StaffDetail->profile_img = $profile_img;
$staff->StaffDetail->save();
}
$staff->StaffDetail->full_name = $request->get('full_name');
$staff->StaffDetail->identity = $request->get('identity');
$staff->StaffDetail->mobile = $request->get('mobile');
$staff->StaffDetail->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini maklumat asas anda');
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> kemaskini maklumat asas anda');
}
}
public function updateWork(Request $request){
$staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
if(!empty($staff)) {
$staff->StaffDetail->gred = $request->get('gred');
$staff->StaffDetail->no_badan = $request->get('no_badan');
$staff->StaffDetail->save();
$staff->no_badan = $request->get('no_badan');
$staff->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini kerjaya anda');
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> kemaskini kerjaya anda');
}
}
public function updatePassword(Request $request){
$validator = Validator::make($request->all(), [
'password' => 'min:8|confirmed',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
if(!empty($staff)) {
$encryptP = Hash::make($request->get('password'));
$staff->password = $encryptP;
$staff->save();
$staff->StaffDetail->password = $encryptP;
$staff->StaffDetail->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini kata laluan anda');
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> kemaskini kata laluan anda');
}
}
}

+ 584
- 0
app/Http/Controllers/Officer/SettingController.php 查看文件

@@ -0,0 +1,584 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use Carbon\Carbon;
use Validator;
use PDF;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
use App\Model\Module\TemplateNotice;
use App\Model\Module\LetterNotice;
use App\Model\Module\Attachment;
use App\Model\Module\Faulty;
use App\Model\Module\Memo;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Jobs\UpdateCompoundPrice;
class SettingController extends Controller
{
/**
* Create a memo list controller.
*
* @return json
*/
public function memoIndex(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('officer.setting.memo_index',compact('user','site'));
}
public function memoAdd(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::where('_id', $user->StaffDetail->jbkod)->first();
$roles = Roles::all();
$site = SiteSetting::first();
return view('officer.setting.memo_detail_add',compact('user','department','roles','site'));
}
public function requestAddMemo(Request $request) {
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'tawaran' => ['required','regex:/^100+%$|[0-9]+%/'],
'attachment.*' => 'mimes:pdf|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$kesalahan = $request->get('kesalahan');
if(!empty($kesalahan)){
$sahkan = '';
if($user->StaffDetail->roles_access == "Ketua Jabatan"){
$sahkan = $user->_id;
}
$faulty = Faulty::where('itkod', $request->get('kesalahan'))->first();
if(!empty($faulty)){
if($request->hasfile('attachment')){
$memo = Memo::create([
'itkod' => $request->get('kesalahan'),
'modul' => $request->get('kategori_modul'),
'jenis_memo' => $request->get('jenis_memo'),
'no_rujukan' => $request->get('no_rujukan'),
'tawaran_kompaun' => $request->get('tawaran'),
'tarikh_mula' => $request->get('tarikh_mula'),
'tarikh_akhir' => $request->get('tarikh_akhir'),
'dikeluarkan' => $user->_id,
'disahkan' => $sahkan,
'jenis_data' => 'pdf',
'subjek' => $request->get('subjek'),
'penerangan' => $request->get('penerangan'),
]);
$upload = [];
foreach($request->file('attachment') as $f){
$upload[] = [
'name' => 'file[]',
'contents' => fopen( $f->getPathname(), 'r' ),
'filename' => $f->getClientOriginalName()
];
}
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/memo/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
foreach ($response->data as $key => $d) {
$attach = new Attachment();
$attach->path = $d;
$memo->attachment()->save($attach);
}
}else if($response->success == false){
return redirect()->back()->with('error_msg', '<strong>Gagal!</strong> memuatnaik pdf');
}
if($sahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod memo di kategori akta kesalahan <strong>('.$faulty->nama.')</strong>');
}else{
$memo = Memo::create([
'itkod' => $request->get('kesalahan'),
'modul' => $request->get('kategori_modul'),
'jenis_memo' => $request->get('jenis_memo'),
'no_rujukan' => $request->get('no_rujukan'),
'tawaran_kompaun' => $request->get('tawaran'),
'tarikh_mula' => $request->get('tarikh_mula'),
'tarikh_akhir' => $request->get('tarikh_akhir'),
'dikeluarkan' => $user->_id,
'disahkan' => $sahkan,
'jenis_data' => 'manual',
'subjek' => $request->get('subjek'),
'penerangan' => $request->get('penerangan'),
]);
if($sahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod memo di kategori akta kesalahan <strong>('.$faulty->nama.')</strong>');
}
}else{
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya Simpan Rekod!</strong> Rekod Akta Kesalahan <b>'.$request->get('kesalahan').'</b> tidak ditemui');
}
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya Simpan Rekod!</strong> Pastikan anda pilih ketegori/akta kesalahan untuk memo berjalan dengan lancar');
}
}
public function memoEdit($_id){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$roles = Roles::all();
$memo = Memo::where('_id',$_id)->first();
$faulty = Faulty::where('itkod',$memo->itkod)->first();
$site = SiteSetting::first();
return view('officer.setting.memo_detail_edit',compact('user','department','roles','memo','faulty','site'));
}
public function requestEditMemo(Request $request) {
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'tawaran' => ['required','regex:/^100+%$|[0-9]+%/'],
'attachment.*' => 'mimes:pdf|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$sahkan = '';
if($user->StaffDetail->roles_access == "Ketua Jabatan"){
$sahkan = $user->_id;
}
$memo = Memo::with('Attachment')->where('_id',$request->memo_id)->first();
$now = Carbon::now();
$gDate = $now->format('F Y');
if(!empty($memo)){
$faulty = Faulty::where('itkod', $memo->itkod)->first();
if(!empty($faulty)){
if($request->hasfile('attachment')){
$uploadNew = false;
if($memo->jenis_data == "pdf"){
foreach ($memo->Attachment as $m) {
$m->delete();
}
$uploadNew = true;
}else if($memo->jenis_data == "manual"){
$uploadNew = true;
}
if($uploadNew == true){
$memo->jenis_memo = $request->get('jenis_memo');
$memo->no_rujukan = $request->get('no_rujukan');
$memo->tawaran_kompaun = $request->get('tawaran');
$memo->tarikh_mula = $request->get('tarikh_mula');
$memo->tarikh_akhir = $request->get('tarikh_akhir');
$memo->dikeluarkan = $user->_id;
$memo->jenis_data = 'pdf';
$memo->subjek = $request->get('subjek');
$memo->penerangan = $request->get('penerangan');
$memo->save();
$upload = [];
foreach($request->file('attachment') as $f){
$upload[] = [
'name' => 'file[]',
'contents' => fopen( $f->getPathname(), 'r' ),
'filename' => $f->getClientOriginalName()
];
}
$upload [] = [
'name' => 'type',
'contents' => 'mbip'
];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://files.sipadu.my/api/upload/memo/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
foreach ($response->data as $key => $d) {
$attach = new Attachment();
$attach->path = $d;
$memo->attachment()->save($attach);
}
}else if($response->success == false){
return redirect()->back()->with('error_msg', '<strong>Gagal!</strong> memuatnaik pdf');
}
$compound = Compound::with('ConfidentialFile')->where('seksyen_kesalahan', $memo->itkod)->get();
$faulty = Faulty::where('itkod', $memo->itkod )->first();
if(count($compound) > 0){
$historyData = [
'tarikh_kumpulan' => $gDate,
];
foreach($compound as $c){
$subHistory = [
'no_siri' => $c->ConfidentialFile->no_siri,
'tajuk' => "Kemaskini Memo[ ".$memo->no_rujukan." ] : ".$memo->subjek,
'huraian' => "Memo ini telah dikemaskini oleh ".$user->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($history);
}
}
}
if($memo->disahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod memo di kategori akta kesalahan <strong>('.$faulty->nama.')</strong>');
}
}else{
$uploadNew = false;
if($memo->jenis_data == "pdf"){
foreach ($memo->Attachment as $m) {
$m->delete();
}
$uploadNew = true;
}else if($memo->jenis_data == "manual"){
$uploadNew = true;
}
if($uploadNew == true){
$memo->jenis_memo = $request->get('jenis_memo');
$memo->no_rujukan = $request->get('no_rujukan');
$memo->tawaran_kompaun = $request->get('tawaran');
$memo->tarikh_mula = $request->get('tarikh_mula');
$memo->tarikh_akhir = $request->get('tarikh_akhir');
$memo->dikeluarkan = $user->_id;
$memo->jenis_data = 'manual';
$memo->subjek = $request->get('subjek');
$memo->penerangan = $request->get('penerangan');
$memo->save();
$compound = Compound::with('ConfidentialFile')->where('seksyen_kesalahan', $memo->itkod)->get();
$faulty = Faulty::where('itkod', $memo->itkod )->first();
if(count($compound) > 0){
$historyData = [
'tarikh_kumpulan' => $gDate,
];
foreach($compound as $c){
$subHistory = [
'no_siri' => $c->ConfidentialFile->no_siri,
'tajuk' => "Kemaskini Memo[ ".$memo->no_rujukan." ] : ".$memo->subjek,
'huraian' => "Memo ini telah dikemaskini oleh ".$user->roles_access." <a href='".url('/main/staff')."/".$user->_id."/profile'>".$user->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$c->ConfidentialFile->history()->attach($history);
}
}
}
if($memo->disahkan != ''){
$kpd = 'null';
$this->dispatch(new UpdateCompoundPrice($kpd));
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod memo di kategori akta kesalahan <strong>('.$faulty->nama.')</strong>');
}
}
}else{
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya Kemaskini Rekod!</strong> Rekod Akta Kesalahan <b>'.$request->get('kesalahan').'</b> tidak ditemui');
}
}else{
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya Kemaskini Rekod!</strong> Rekod memo tidak ditemui');
}
}
public function requestViewMemoPdf($_id) {
$site = SiteSetting::first();
$memo = Memo::with('Attachment')->where('_id',$_id)->first();
$staffD = Staff::with('StaffDetail')->where('_id',$memo->dikeluarkan)->first();
$staffS = Staff::with('StaffDetail')->where('_id',$memo->disahkan)->first();
$kesalahan = Faulty::where('itkod', $memo->itkod)->first();
$dikeluarkan = ''; $disahkan = ''; $faulty = ''; $modul = '';
if(!empty($staffD)){
$dikeluarkan = $staffD->StaffDetail->full_name;
}
if(!empty($staffS)){
$disahkan = $staffD->StaffDetail->full_name;
}
if(!empty($kesalahan)){
$faulty ='['.$kesalahan->itkod.'] '.$kesalahan->nama;
}
if($memo->modul != '-'){
$r = Roles::where('kod',$memo->modul)->first();
if(!empty($r)){
$modul = $r->name;
}
}
$update = Carbon::parse($memo->updated)->toDateTimeString();
$mula = date('d/m/Y h:i a', strtotime($memo->tarikh_mula));
$akhir = date('d/m/Y', strtotime($memo->tarikh_akhir));
$pdf = PDF::loadView('pdf.memo', compact('memo','dikeluarkan','disahkan','update','mula','akhir','faulty','modul','site'));
$pdf->setPaper('A4', 'potrait');
$destinationPath = 'document/memo';
if($memo->jenis_data == "manual"){
return $pdf->stream();
}else if($memo->jenis_data == "pdf"){
$pdf->save(public_path().'/'.$destinationPath.'/'.$memo->_id.'.pdf');
$merges = PDFMerger::init();
$merges->addPDF(public_path().'/'.$destinationPath.'/'.$memo->_id.'.pdf', 'all');
foreach($memo->Attachment as $a){
$merges->addPDF(public_path().$a->path,'all');
}
$merges->merge();
$merges->save(public_path().'/'.$destinationPath.'/'.$memo->_id.'.pdf',"browser");
}
}
/**
* Create a notice list controller.
*
* @return json
*/
public function noticeIndex(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
return view('officer.setting.template_notice_index', compact('user','site'));
}
public function viewNoticeAdd(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
$department = Department::where('_id',$user->StaffDetail->jbkod)->first();
return view('officer.setting.template_notice_add',compact('user','site','department'));
}
public function viewNoticeEdit($_id){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$site = SiteSetting::first();
$template = TemplateNotice::with('Attachment')->where('_id',$_id)->first();
$seksyen = Faulty::where('jbkod', $user->StaffDetail->jbkod)->where('akkod', $template->akta_kesalahan)->get();
$department = Department::where('_id',$user->StaffDetail->jbkod)->first();
return view('officer.setting.template_notice_edit',compact('user','template','site','seksyen','department'));
}
public function addTemplateNotice(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'attachment' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$dataTemplate = [
'akta_kesalahan' => $request->acts,
'seksyen_kesalahan' => $request->seksyen,
'jenis_amaran' => $request->jenis_amaran,
'tempoh_hantar' => $request->tempoh,
'no_rujukan' => $request->no_rujukan,
'subjek' => $request->subjek,
'kandungan' => $request->kandungan,
// 'nama_pengirim' => $request->nama_pengirim,
// 'jawatan_pengirim' => $request->jawatan_pengirim,
'status' => 'tidak aktif'
];
$department = Department::where('_id', $request->department)->first();
if(!empty($department)){
$template = TemplateNotice::create($dataTemplate);
$department->templatenotice()->save($template);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Simpan rekod templat notis amaran');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Simpan rekod templat notis amaran');
}
}
public function editTemplateNotice(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'attachment' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$template = TemplateNotice::where('_id',$request->_id)->first();
if(!empty($template)){
$department = Department::where('_id', $user->StaffDetail->jbkod)->first();
if(!empty($department)){
$template->department_id = $department->_id;
$template->akta_kesalahan = $request->acts;
$template->seksyen_kesalahan = $request->seksyen;
$template->jenis_amaran = $request->jenis_amaran;
$template->tempoh_hantar = $request->tempoh;
$template->no_rujukan = $request->no_rujukan;
$template->subjek = $request->subjek;
$template->kandungan = $request->kandungan;
$template->status = 'tidak aktif';
$template->save();
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> Kemaskini rekod templat notis amaran. Anda boleh "aktifkan" notis amaran ini di "Senarai Templat Notis Amaran"');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod jabatan tidak ditemui');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod templat notis amaran tidak ditemui');
}
}
public function viewLetterPDF($_id,$kpd){
$compound = Compound::where('kpd',$kpd)->first();
$site = SiteSetting::first();
$template = TemplateNotice::where('_id',$_id)->first();
if(!empty($template)){
$now = Carbon::now()->format('d/m/Y h:i:s A');
$pdf = PDF::loadView('pdf.template_letter', compact('template','now','compound','site'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}else{
$template = LetterNotice::with('Attachment')->where('_id',$_id)->first();
if(!empty($template)){
$now = Carbon::now()->format('d/m/Y h:i:s A');
$pdf = PDF::loadView('pdf.template_letter', compact('template','now','compound','site'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}
}
}
public function updatePosNumber(Request $request){
$letter = LetterNotice::where('_id',$request->letter_id)->first();
if(!empty($letter)){
$compound = Compound::with('ConfidentialFile')->where('_id', $letter->compound_id)->first();
if($request->hasFile('gambar_pos')){
$validator = Validator::make($request->all(), [
'gambar_pos' => 'mimes:jpg,jpeg',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$path = '';
$destinationPath = 'document/'.$compound->ConfidentialFile->no_siri.'/notice';
$a = $request->file('gambar_pos');
$extension = $a->getClientOriginalExtension();
$filename = 'pos_notice_'.$letter->_id;
$a->move($destinationPath,$filename.'.'.$extension);
$path = $destinationPath.'/'.$filename.'.'.$extension;
$letter->no_pos = $request->no_pos;
$letter->save();
$attach = new Attachment();
$attach->path = $path;
$letter->attachment()->save($attach);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> simpan nombor pos');
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> sila masukkan gamabr pos sekali');
}
}else{
return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> rekod surat notis amaran tidak ditemui');
}
}
}

+ 191
- 0
app/Http/Controllers/Officer/StaffController.php 查看文件

@@ -0,0 +1,191 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Validator;
use Hash;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\Roles;
class StaffController extends Controller
{
/**
* Create a staff controller.
*
* @return value
*/
public function staffIndex(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::all();
$roles = Roles::all();
$site = SiteSetting::first();
return view('officer.team.staff_index', compact('user','department','roles','site'));
}
public function staffAdd(){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$department = Department::whereHas('StaffDetail', function($q) use ($id) {
$q->where('_id', $id);
})->get();
$roles = Roles::all();
$site = SiteSetting::first();
return view('officer.team.staff_add', compact('user','department','roles','site'));
}
public function staffEdit($cid){
$id = Auth::guard('ofr')->id();
$user = Staff::with(['StaffDetail' => function($q){
$q->with('Department');
}])->find($id);
$department = Department::all();
$staff = StaffDetail::with('Department')->where('_id',$cid)->first();
$site = SiteSetting::first();
return view('officer.team.staff_edit', compact('user','department','staff','site'));
}
public function requestAddStaff(Request $request)
{
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$validator = Validator::make($request->all(), [
'password' => 'min:8|confirmed',
'profil' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$staff = Staff::where('no_badan', $request->badan)->where('roles_access','PenguatKuasa')->first();
if(empty($staff)) {
$encryptP = Hash::make($request->get('password'));
$profile_img = '/uploads/profile.jpg';
$saveData = false;
if($request->hasfile('profil')){
$destinationPath = 'uploads/profile';
$uploaded = public_path().'/'.$destinationPath;
$allowedfileExtension = ['jpeg','jpg'];
$a = $request->file('profil');
$extension = $a->getClientOriginalExtension();
$check=in_array($extension,$allowedfileExtension);
if($check) {
$filename = $request->get('badan');
$a->move($destinationPath,$filename.'.'.$extension);
$profile_img = '/'.$destinationPath.'/'.$filename.'.'.$extension;
$saveData = true;
}
}else{
$saveData = true;
}
if($saveData == true){
$sl = Staff::create([
'no_badan' => $request->get('badan'),
'password' => $encryptP,
'api_token' => '',
'roles_access' => 'PenguatKuasa',
'device' => '',
'remember_token' => '',
'last_login_at' => '',
'last_login_ip'=> '',
'authorized' => false,
'token_firebase' => '',
]);
$detail = new StaffDetail();
$detail->full_name = $request->get('nama');
$detail->identity = $request->get('pengenalan');
$detail->mobile = $request->get('telefon');
$detail->gred = $request->get('gred');
$detail->no_badan = $request->get('badan');
// $detail->jbkod = $user->StaffDetail->jbkod;
$detail->roles_access = 'PenguatKuasa';
$detail->profile_img = $profile_img;
$detail->password = $encryptP;
$sl->staffdetail()->save($detail);
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$detail->department()->attach($department);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> daftar pegawai <strong> No.Badan '.$request->get('badan').', Nama '.$request->get('nama').'</strong>');
}
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Berjaya!</strong> No.Badan <strong>'.$request->get('badan').'</strong> ini telah wujud');
}
}
public function requestEditStaff(Request $request)
{
$validator = Validator::make($request->all(), [
'profil' => 'mimes:jpeg,jpg|max:2048',
]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
if(!empty($staff)) {
if($request->hasfile('profil')){
$destinationPath = 'uploads/profile';
$uploaded = public_path().'/'.$destinationPath;
$allowedfileExtension = ['jpeg','jpg'];
$a = $request->file('profil');
$extension = $a->getClientOriginalExtension();
$check=in_array($extension,$allowedfileExtension);
if($check) {
$filename = $request->get('badan');
$a->move($destinationPath,$filename.'.'.$extension);
$profile_img = '/'.$destinationPath.'/'.$filename.'.'.$extension;
$staff->StaffDetail->profile_img = $profile_img;
$staff->StaffDetail->save();
}
}
$staff->no_badan = $request->get('badan');
$staff->save();
$staff->StaffDetail->full_name = $request->get('nama');
$staff->StaffDetail->identity = $request->get('pengenalan');
$staff->StaffDetail->mobile = $request->get('telefon');
$staff->StaffDetail->gred = $request->get('gred');
$staff->StaffDetail->no_badan = $request->get('badan');
$staff->StaffDetail->save();
foreach($request->jabatan as $j){
$department = Department::where('_id', $j)->first();
$department_array[] = $department->_id;
}
$staff->StaffDetail->department()->sync($department_array);
return redirect()->back()->with('success_msg', '<strong>Berjaya!</strong> kemaskini pegawai <strong> No.Badan '.$request->get('badan').', Nama '.$request->get('nama').'</strong>');
}else {
return redirect()->back()->withInput()->with('error_msg','<strong>Berjaya!</strong> Rekod No.Badan '.$request->get('badan').' tidak ditemui');
}
}
}

+ 163
- 0
app/Http/Controllers/Officer/TaskController.php 查看文件

@@ -0,0 +1,163 @@
<?php
namespace App\Http\Controllers\Officer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use File;
use Carbon\Carbon;
use PDF;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\CompoundInvestigation;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Investigation;
use App\Model\Module\ItemInventory;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
use App\Jobs\UpdateCompoundPrice;
class TaskController extends Controller
{
/**
* Create Task list controller.
*
* @return json
*/
public function requestUpdateTask(Request $request){
$id = Auth::guard('ofr')->id();
$user = Staff::with('StaffDetail')->find($id);
$compound = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$jbkod = $compound->jbkod;
$now = Carbon::now();
$gDate = $now->format('F Y');
if($request->dashboard == "true"){
$roles = Roles::where('kod', $request->kategori_modul)->first();
if($compound->modul == $request->kategori_modul){
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Kompaun ini sudah berada di dalam kategori modul '.$roles->name);
}else{
$reg_id = array();
if(count($roles->staff_detail_ids) > 0){
foreach($roles->staff_detail_ids as $s){
$staff = Staff::with(['StaffDetail' => function($q) use($jbkod){
$q->where('jbkod', $jbkod);
}])->where('_id', $s)->first();
if(!empty($staff->StaffDetail)){
if($staff->token_firebase != ''){
$reg_id[] = $staff->token_firebase;
}
}
}
}
if(count($reg_id) > 0) {
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', url('api/push/notification'), [
'verify' => false,
'form_params' => [
'title' => $roles->name.' '.$compound->kpd,
'msg' => 'Kompaun ini telah di pindahkan ke modul '.$roles->name,
'register_id' => $reg_id,
]
]);
}
$compound->modul = $request->kategori_modul;
$compound->save();
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Serahan Modul",
'huraian' => $compound->kpd. " / Fail Kulit (".$compound->ConfidentialFile->no_siri.") telah diserahkan ke modul ".$roles->name,
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya Kemaskini!</strong> Kompaun ini berjaya diserahkan ke kategori modul '.$roles->name);
}
}else if($request->dashboard == "false"){
if($compound->penguatkuasa == $request->penguatkuasa){
$staff = StaffDetail::where('_id',$request->penguatkuasa)->first();
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Kompaun ini sudah diserahkan kepada penguatkuasa ['.$staff->no_badan.'] '.$staff->full_name);
}else{
$staff = Staff::with('StaffDetail')->where('_id',$request->penguatkuasa)->where(function($q){
$q->where('roles_access','PenguatKuasa')->orWhere('roles_access','PPenguatKuasa');
})->first();
$role = Roles::where('kod', $compound->modul)->first();
if(!empty($staff)){
if($staff->token_firebase != '') {
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', url('api/push/notification'), [
'verify' => false,
'form_params' => [
'title' => $role->name.' '.$compound->kpd,
'msg' => 'Kompaun ini berada di ruangan '.$role->name,
'register_id[]' => $staff->token_firebase,
]
]);
}
$compound->penguatkuasa = $request->penguatkuasa;
$compound->save();
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Menugaskan Penguatkuasa ".$staff->StaffDetail->full_name,
'huraian' => $compound->kpd. " / Fail Kulit (".$compound->ConfidentialFile->no_siri.") telah ditugaskan kepada penguatkuasa <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a>.",
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
return redirect()->back()->with('success_msg', '<strong>Berjaya Kemaskini!</strong> Kompaun ini berjaya ditugaskan kepada penguatkuasa ['.$staff->no_badan.'] '.$staff->StaffDetail->full_name);
}else{
return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Data penguatkuasa tidak ditemui');
}
}
}
}
}

+ 142
- 0
app/Http/Controllers/PaymentController.php 查看文件

@@ -0,0 +1,142 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use Validator;
use Session;
use Config;
use File;
use Carbon\Carbon;
use PDF;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\CompoundInvestigation;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Investigation;
use App\Model\Module\ItemInventory;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
use App\Jobs\UpdateCompoundPrice;
class PaymentController extends Controller
{
/**
* Create payment controller.
*
* @return json
*/
public function requestCompoundPaymentPdf($kpd) {
$ready_view_pdf = false;
$availablePDF = array();
$now = Carbon::now()->format('d/m/Y h:i:s A');
$compound = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('kpd', $kpd)->first();
$file = ConfidentialFile::with(['Memo' => function($q){
$q->orderBy('updated_at','ASC');
}],['Investigation' => function($q){
$q->orderBy('updated_at','ASC');
}],'ItemInventory')->where('_id',$compound->ConfidentialFile->_id)->first();
$destinationPath = 'document/'.$compound->ConfidentialFile->no_siri.'/pdf';
if(!File::exists(public_path().'/'.$destinationPath)) {
File::makeDirectory(public_path().'/'.$destinationPath, $mode = 0777, true, true);
}
/**
** Compound
**/
$tawaran = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$tawaran = $compound->jumlah_asal_kompaun;
}else{
$tawaran = $compound->jumlah_kemaskini_kompaun;
}
$staff = Staff::with('StaffDetail')->where('no_badan', $compound->dikeluarkan)->first();
$department = Department::where('_id', $staff->StaffDetail->jbkod)->first();
$akta = DeedLaw::where('_id', $compound->akta)->first();
$faulty = Faulty::with('DeedLaw')->where('itkod',$compound->seksyen_kesalahan)->first();
$site = SiteSetting::first();
return view('pdf.compound_payment', compact('compound','staff','department','akta','faulty','picArray','tawaran','site'));
}
public function makeWebPayment(Request $request){
$crypt = new \Illuminate\Encryption\Encrypter('F1339A1149AB6FFA9BDDDC6AE677EA90', Config::get( 'app.cipher' ));
$encry = $crypt->encrypt('mpkb:0c79ba6d11631e9619d5ff46711867dc:'.$request->orderid.':'.$request->amount);
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://staging.kelantanpay.com.my/api/payment/mobile/request', [
'verify' => false,
'form_params' => [
'amount' => $request->amount,
'orderid' => $request->orderid,
'userid' => $request->userid,
'name' => $request->name,
'email' => $request->email,
'mobile' => $request->mobile,
'description' => $request->orderid,
'merchantid' => 'mpkb',
'country' => 'MY',
'key'=> $encry,
'returnurl' => 'https://mdch1.sipadu.my/compound/'.$request->orderid.'/view/details',
'update_payment' => 'https://mdch1.sipadu.my/api/update/payment/compound',
]
]);
$response = json_decode($result->getBody()->getContents());
if($response->status == true){
return redirect($response->url);
}else if($response->status == false){
return redirect('https://mdch1.sipadu.my/compound/'.$request->orderid.'/view/details');
}
}
public function makeMobilePayment(Request $request){
$crypt = new \Illuminate\Encryption\Encrypter('F1339A1149AB6FFA9BDDDC6AE677EA90', Config::get( 'app.cipher' ));
$encry = $crypt->encrypt('mpkb:0c79ba6d11631e9619d5ff46711867dc:'.$request->orderid.':'.$request->amount);
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'https://staging.kelantanpay.com.my/api/payment/mobile/request', [
'verify' => false,
'form_params' => [
'amount' => $request->amount,
'orderid' => $request->orderid,
'userid' => $request->userid,
'name' => $request->name,
'email' => $request->email,
'mobile' => $request->mobile,
'description' => $request->orderid,
'merchantid' => 'mpkb',
'country' => 'MY',
'key'=> $encry,
'returnurl' => 'https://demo.sipadu.my/compound/'.$request->orderid.'/view/details',
'update_payment' => 'https://demo.sipadu.my/api/update/payment/compound',
]
]);
$response = $result->getBody()->getContents();
return $response;
}
}

+ 81
- 0
app/Http/Controllers/ResponsiveController.php 查看文件

@@ -0,0 +1,81 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use LynX39\LaraPdfMerger\Facades\PdfMerger;
use Validator;
use Session;
use Config;
use File;
use Carbon\Carbon;
use PDF;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\User;
use App\Model\UserDetail;
use App\Model\Module\Roles;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Attachment;
class ResponsiveController extends Controller
{
/**
* Create responsive controller.
*
* @return json
*/
public function showCompoundPage($ic) {
$site = SiteSetting::first();
$compound = Compound::with('ConfidentialFile')->where('identity',$ic)->get();
return view('mobile-responsive.compound_list_result', compact('compound','site'));
}
public function requestCompoundPaymentPdf($kpd) {
$ready_view_pdf = false;
$availablePDF = array();
$now = Carbon::now()->format('d/m/Y h:i:s A');
$compound = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('kpd', $kpd)->first();
$file = ConfidentialFile::with(['Memo' => function($q){
$q->orderBy('updated_at','ASC');
}],['Investigation' => function($q){
$q->orderBy('updated_at','ASC');
}],'ItemInventory')->where('_id',$compound->ConfidentialFile->_id)->first();
$destinationPath = 'document/'.$compound->ConfidentialFile->no_siri.'/pdf';
if(!File::exists(public_path().'/'.$destinationPath)) {
File::makeDirectory(public_path().'/'.$destinationPath, $mode = 0777, true, true);
}
/**
** Compound
**/
$tawaran = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$tawaran = $compound->jumlah_asal_kompaun;
}else{
$tawaran = $compound->jumlah_kemaskini_kompaun;
}
$site = SiteSetting::first();
$staff = Staff::with('StaffDetail')->where('no_badan', $compound->dikeluarkan)->first();
$department = Department::where('jbkod', $staff->StaffDetail->jbkod)->first();
$akta = DeedLaw::where('akkod', $compound->akta)->first();
$faulty = Faulty::where('itkod',$compound->seksyen_kesalahan)->first();
return view('mobile-responsive.compound_detail', compact('compound','staff','department','akta','faulty','picArray','tawaran','site'));
}
}

+ 28
- 0
app/Http/Controllers/SiteSettingController.php 查看文件

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;
use Config;
use File;
use Carbon\Carbon;
use App\SiteSetting;
class SiteSettingController extends BaseController
{
/**
* site setting controller.
*
* @return value
*/
public function loginIndex(){
$site = SiteSetting::first();
return view('index', compact('site'));
}
}

+ 84
- 0
app/Http/Kernel.php 查看文件

@@ -0,0 +1,84 @@
<?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
*/
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\CheckForMaintenanceMode::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
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],

'api' => [
\App\Http\Middleware\MobileApps::class,
'throttle:60,1',
'bindings',
],
];

/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'officerauth' => \App\Http\Middleware\OfficerAuth::class,
'sysadminauth' => \App\Http\Middleware\SysadminAuth::class,
'mobileapps' => \App\Http\Middleware\MobileApps::class,
];

/**
* The priority-sorted list of middleware.
*
* This forces non-global middleware to always be in the given order.
*
* @var array
*/
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
];
}

+ 21
- 0
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
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

+ 17
- 0
app/Http/Middleware/CheckForMaintenanceMode.php 查看文件

@@ -0,0 +1,17 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;

class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

+ 17
- 0
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
*/
protected $except = [
//
];
}

+ 24
- 0
app/Http/Middleware/MobileApps.php 查看文件

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
class MobileApps
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
$response->header('Access-Control-Allow-Methods', 'HEAD, GET, POST, PUT, DELETE');
$response->header('Access-Control-Allow-Headers', $request->header('Access-Control-Request-Headers'));
$response->header('Access-Control-Allow-Origin', '*');
return $response;
}
}

+ 27
- 0
app/Http/Middleware/OfficerAuth.php 查看文件

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
use App\Model\Staff;
class OfficerAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'ofr')
{
if (!Auth::guard($guard)->check()) {
return redirect()->guest('/');
}
return $next($request);
}
}

+ 52
- 0
app/Http/Middleware/RedirectIfAuthenticated.php 查看文件

@@ -0,0 +1,52 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

use App\Model\Staff;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/');
}

switch($guard)
{
case 'sadmin' :
if (Auth::guard($guard)->check()) {
return redirect('/main/index');
}
break;
case 'ketua_jabatan' :
if (Auth::guard($guard)->check()) {
return redirect('/main/index');
}
break;
case 'ofr' :
if (Auth::guard($guard)->check()) {
return redirect('/officer/index');
}
break;
case 'spegawai' :
if (Auth::guard($guard)->check()) {
return redirect('/officer/index');
}
break;
}

return $next($request);
}
}

+ 26
- 0
app/Http/Middleware/SOfficerAuth.php 查看文件

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
use App\Model\Staff;
class SOfficerAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'spegawai')
{
if (!Auth::guard($guard)->check()) {
return redirect()->guest('/sysadmin/login');
}
return $next($request);
}
}

+ 26
- 0
app/Http/Middleware/SysadminAuth.php 查看文件

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
use App\Model\Staff;
class SysadminAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'sadmin')
{
if (!Auth::guard($guard)->check()) {
return redirect()->guest('/');
}
return $next($request);
}
}

+ 18
- 0
app/Http/Middleware/TrimStrings.php 查看文件

@@ -0,0 +1,18 @@
<?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
*/
protected $except = [
'password',
'password_confirmation',
];
}

+ 23
- 0
app/Http/Middleware/TrustProxies.php 查看文件

@@ -0,0 +1,23 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string
*/
protected $proxies;

/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

+ 24
- 0
app/Http/Middleware/VerifyCsrfToken.php 查看文件

@@ -0,0 +1,24 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends Middleware
{
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
*/
protected $addHttpCookie = true;

/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

+ 38
- 0
app/Http/Resources/CompoundResource.php 查看文件

@@ -0,0 +1,38 @@
<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class CompoundResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'_id' => $this->_id,
'jenis' => $this->jenis,
'kpd' => $this->kpd,
'no_plate' => $this->no_plate,
'nric' => $this->identity,
'no_daftar_syarikat' => $this->no_daftar_syarikat,
'nama' => $this->nama,
'tarikh_masa' => $this->created_at->format('d/m/Y H:i:s A'),
'kesalahan' => $this->faulty,
'enforcer' => $this->staffdetail,
'status' => $this->status,
'jumlah_asal_kompaun' => $this->jumlah_asal_kompaun,
'jumlah_kemaskini_kompaun' => $this->jumlah_kemaskini_kompaun,
'catatan_dari_admin' => $this->catatan_dari_admin,
'updated_by' => $this->updateby,
'amount_payment' => $this->amount_payment,
'created_at' => $this->created_at->format('Y-m-d H:i:s'),
'updated_at' => $this->updated_at->format('Y-m-d H:i'),
];
}
}

+ 65
- 0
app/Jobs/GenerateBarcode.php 查看文件

@@ -0,0 +1,65 @@
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

use File;

use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\ItemInventory;
use App\Model\Module\Barcode;
use App\Model\Module\Attachment;
use App\Model\Module\History;
use App\Model\Module\SubHistory;

class GenerateBarcode implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $kpd, $name, $item;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct($kpd, $name, ItemInventory $item)
{
$this->kpd = $kpd;
$this->name = $name;
$this->item = $item;
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$compound = Compound::with('ConfidentialFile')->where('kpd', $this->kpd)->first();
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'http://filegoforce.sipadu.my/api/generate/barcode', [
'verify' => false,
'form_params' => [
'barcode' => $this->name,
'no_siri' => $compound->ConfidentialFile->no_siri,
'type' => 'proxy',
]
]);

$response = json_decode($result->getBody()->getContents());
if($response->success == true){
$barcode = new Barcode();
$barcode->barcode_id = $this->name;
$barcode->path = $response->data;
$barcode->status = 'simpan';
$this->item->barcode()->save($barcode);
}
}
}

+ 144
- 0
app/Jobs/SendNoticeLetter.php 查看文件

@@ -0,0 +1,144 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;
use Carbon\Carbon;
use App\Model\Module\Compound;
use App\Model\Module\LetterNotice;
use App\Model\Module\TemplateNotice;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
class SendNoticeLetter implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$template = TemplateNotice::all();
$now = Carbon::now();
$compound = Compound::with('LetterNotice')->get();
foreach($template as $key => $a) {
foreach($compound as $c){
$tempoh = new Carbon($c->created_at);
$diff = $tempoh->diffInDays($now);
if($a->status == 'aktif'){
if(count($c->LetterNotice) > 0){
foreach ($c->LetterNotice as $key => $l) {
if($l->no_rujukan != $a->no_rujukan){
if($a->tempoh_hantar == "13"){
if($diff < 14){
$dataLetter = [
"tempoh_hantar" => $a->tempoh_hantar,
"jenis_amaran" => $a->jenis_amaran,
"alasan" => "Sebelum tempoh 14 hari",
"no_rujukan" => $a->no_rujukan,
"subjek" => $a->subjek,
"kandungan" => $a->kandungan,
"no_pos" => "",
];
$c->letternotice()->create($dataLetter);
}
}else if($a->tempoh_hantar == "14"){
if($diff >= 14){
$dataLetter = [
"tempoh_hantar" => $a->tempoh_hantar,
"jenis_amaran" => $a->jenis_amaran,
"alasan" => "Selepas tempoh 14 hari",
"no_rujukan" => $a->no_rujukan,
"subjek" => $a->subjek,
"kandungan" => $a->kandungan,
"no_pos" => "",
];
$c->letternotice()->create($dataLetter);
}
}else if($a->tempoh_hantar == "28"){
if($diff > 28){
$dataLetter = [
"tempoh_hantar" => $a->tempoh_hantar,
"jenis_amaran" => $a->jenis_amaran,
"alasan" => "Selepas tempoh 28 hari",
"no_rujukan" => $a->no_rujukan,
"subjek" => $a->subjek,
"kandungan" => $a->kandungan,
"no_pos" => "",
];
$c->letternotice()->create($dataLetter);
}
}
}
}
}else {
if($a->tempoh_hantar == "13"){
if($diff < 14){
$dataLetter = [
"tempoh_hantar" => $a->tempoh_hantar,
"jenis_amaran" => $a->jenis_amaran,
"alasan" => "Selepas tempoh 28 hari",
"no_rujukan" => $a->no_rujukan,
"subjek" => $a->subjek,
"kandungan" => $a->kandungan,
"no_pos" => "",
];
$c->letternotice()->create($dataLetter);
}
}else if($a->tempoh_hantar == "14"){
if($diff >= 14){
$dataLetter = [
"tempoh_hantar" => $a->tempoh_hantar,
"jenis_amaran" => $a->jenis_amaran,
"alasan" => "Selepas tempoh 28 hari",
"no_rujukan" => $a->no_rujukan,
"subjek" => $a->subjek,
"kandungan" => $a->kandungan,
"no_pos" => "",
];
$c->letternotice()->create($dataLetter);
}
}else if($a->tempoh_hantar == "28"){
if($diff > 28){
$dataLetter = [
"tempoh_hantar" => $a->tempoh_hantar,
"jenis_amaran" => $a->jenis_amaran,
"alasan" => "Selepas tempoh 28 hari",
"no_rujukan" => $a->no_rujukan,
"subjek" => $a->subjek,
"kandungan" => $a->kandungan,
"no_pos" => "",
];
$c->letternotice()->create($dataLetter);
}
}
}
}
}
}
}
}

+ 233
- 0
app/Jobs/StoreCompound.php 查看文件

@@ -0,0 +1,233 @@
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;

use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;

use App\Jobs\UpdateCompoundPrice;

class StoreCompound implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $request, $kpd, $no_badan, $no_siri;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct(array $request, $kpd, $no_badan, $no_siri)
{
//
// $countKPD = 0;
// do {
// $countKPD = Compound::count();
// $countKPD = $countKPD + 1;
// } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);

// $kpd = 'KP' . $countKPD;

$this->request = $request;
$this->kpd = $kpd;
$this->no_badan = $no_badan;
$this->no_siri = $no_siri;
}

/**
* Execute the job.
*
* @return void
*/
public function handle(ConfidentialFile $file)
{
// $success_save_data = false;
// $faulty = Faulty::where('_id', $this->request['seksyen'])->first();
// if($success_save_data == false){
// $count = $file->count();
// if($count == 0){
// $count = $count + 1;
// $siri = str_pad($count, 5, '0', STR_PAD_LEFT);
// }else {
// $count = $count + 1;
// $siri = str_pad($count, 5, '0', STR_PAD_LEFT);
// }

// $no_siri = date('yn').'-'.$count;

// $kpd = $this->kpd;
// // $no_siri = date('yn').'-'.$this->no_siri;

// $fileData = [
// 'no_siri' => $no_siri,
// ];

// if($this->request['no_plate'] != '-'){
// $compoundData = [
// 'jenis' => 'Parkir',
// 'kpd' => $kpd,
// 'nama' => '-',
// 'identity' => '-',
// 'alamat' => '-',
// "no_plate" => strtolower($this->request['no_plate']),
// "no_cukai_jalan" => $this->request['noCukaijalan'],
// "jenis_kenderaan" => $this->request['jenisKenderaan'],
// "model_kenderaan" => $this->request['modelKenderaan'],
// "warna_kenderaan" => $this->request['warnakenderaan'],
// "nama_taman" => $this->request['namaTaman'],
// "nama_jalan" => $this->request['namaJalan'],
// "no_parking" => $this->request['noParking'],
// "catatan" => $this->request['catatan'],
// "lokasi_kejadian" => '-',
// 'latlong' => $this->request['Latlong'],
// 'jbkod' => $this->request['jabatan'],
// 'akta' => $faulty->deed_law_id,
// 'seksyen_kesalahan' => $faulty->_id,
// 'jumlah_asal_kompaun' => $faulty->amount,
// 'jumlah_kemaskini_kompaun' => '',
// 'dikeluarkan' => $this->no_badan,
// "status" => 'Belum Bayar',
// "amount_payment" => '',
// "receipt" => '',
// "modul" => '03',
// "penguatkuasa" => '',
// ];
// }else{
// $compoundData = [
// 'jenis' => 'Pelbagai',
// 'kpd' => $kpd,
// 'nama' => $this->request['namaP'],
// 'identity' => $this->request['noIc'],
// 'nama_syarikat' => $this->request['namaS'],
// 'no_daftar_syarikat' => strtolower($this->request['daftarNo']),
// 'alamat' => $this->request['alamat'],
// "no_plate" => $this->request['no_plate'],
// "catatan" => $this->request['catatan'],
// "lokasi_kejadian" => $this->request['lokasi_kejadian'],
// 'latlong' => $this->request['Latlong'],
// 'jbkod' => $this->request['jabatan'],
// 'akta' => $faulty->deed_law_id,
// 'seksyen_kesalahan' => $faulty->_id,
// 'jumlah_asal_kompaun' => $faulty->amount,
// 'jumlah_kemaskini_kompaun' => '',
// 'dikeluarkan' => $this->no_badan,
// "status" => 'Belum Bayar',
// "amount_payment" => '',
// "receipt" => '',
// "modul" => '03',
// "penguatkuasa" => '',
// ];
// }

// $file = $file->create($fileData);
// $file->compound()->create($compoundData);

// $success_save_data = true;
// }

// if($success_save_data == true){

// dispatch(new UpdateCompoundPrice($this->kpd));

$staff = Staff::with('StaffDetail')->where('_id', $this->no_badan)->first();
$compound = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('kpd',$this->kpd)->first();

$site = SiteSetting::first();
$faulty = Faulty::with('DeedLaw')->where('_id',$compound->seksyen_kesalahan)->first();
$department = Department::where('_id', $compound->jbkod)->first();

$tawaran = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$tawaran = $compound->jumlah_asal_kompaun;
}else{
$tawaran = $compound->jumlah_kemaskini_kompaun;
}

/******************************************************************/
$gDate = $compound->created_at->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penguatkuasa ".$staff->StaffDetail->full_name." mengeluarkan kompaun ".$this->kpd,
'huraian' => "Kompaun ".$this->kpd." telah dikeluarkan oleh penguatkuasa <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a> di bawah akta seksyen kesalahan [".$faulty->sketr."] ".$faulty->nama,
];

$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}

$memo = Memo::where('itkod', $compound->seksyen_kesalahan)->get();
if(!empty($memo)){
foreach ($memo as $key => $m) {
$staffD = StaffDetail::where('_id',$m->dikeluarkan)->first();
if($m->disahkan != ''){
$compound->ConfidentialFile->memo()->attach($m);

$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penambahan Memo[ ".$m->no_rujukan." ] : ".$m->subjek." oleh ".$staffD->roles_access." ".$staffD->full_name,
'huraian' => $m->penerangan,
];

$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
}
}
}

// Convert To Pdf
// $upload [] = [ 'name' => 'compound', 'contents' => $compound ];
// $upload [] = [ 'name' => 'faulty', 'contents' => $faulty ];
// $upload [] = [ 'name' => 'staff', 'contents' => $staff ];
// $upload [] = [ 'name' => 'department', 'contents' => $department ];
// $upload [] = [ 'name' => 'site', 'contents' => $site ];
// $upload [] = [ 'name' => 'type', 'contents' => 'proxy' ];

// $client = new \GuzzleHttp\Client();
// $result = $client->request('POST', 'http://filegoforce.sipadu.my/api/compound/pdf', [
// 'multipart' => $upload
// ]);

// $response = json_decode($result->getBody()->getContents());
// if($response->success == true){
// $compound->pdf_path = $response->data;
// $compound->save();
// }
// }
}
}

+ 229
- 0
app/Jobs/StoreCompoundManual.php 查看文件

@@ -0,0 +1,229 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;
use Carbon\Carbon;
use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\History;
use App\Model\Module\SubHistory;
use App\Model\Module\Memo;
use App\Model\Module\Attachment;
use App\Jobs\UpdateCompoundPrice;
class StoreCompoundManual implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $request, $kpd, $no_badan, $no_siri;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(array $request, $kpd, $no_badan, $no_siri)
{
//
$this->request = $request;
$this->kpd = $kpd;
$this->no_badan = $no_badan;
$this->no_siri = $no_siri;
}
/**
* Execute the job.
*
* @return void
*/
public function handle(ConfidentialFile $file)
{
// $success_save_data = false;
// $faulty = Faulty::where('_id', $this->request['seksyen'])->first();
// if($success_save_data == false){
// $count = $file->count();
// if($count == 0){
// $count = $count + 1;
// $siri = str_pad($count, 5, '0', STR_PAD_LEFT);
// }else {
// $count = $count + 1;
// $siri = str_pad($count, 5, '0', STR_PAD_LEFT);
// }
// $kpd = $this->kpd;
// $no_siri = date('yn').'-'.$count;
// $fileData = [
// 'no_siri' => $no_siri,
// ];
// if($this->request['no_plate'] != '-'){
// $compoundData = [
// 'jenis' => 'Parkir',
// 'kpd' => $this->request['kpd'],
// 'nama' => '-',
// 'identity' => '-',
// 'alamat' => '-',
// "no_plate" => strtolower($this->request['no_plate']),
// "no_cukai_jalan" => $this->request['noCukaijalan'],
// "jenis_kenderaan" => $this->request['jenisKenderaan'],
// "model_kenderaan" => $this->request['modelKenderaan'],
// "warna_kenderaan" => $this->request['warnakenderaan'],
// "nama_taman" => $this->request['namaTaman'],
// "nama_jalan" => $this->request['namaJalan'],
// "no_parking" => $this->request['noParking'],
// "catatan" => $this->request['catatan'],
// "lokasi_kejadian" => '-',
// 'latlong' => $this->request['Latlong'],
// 'jbkod' => $this->request['jabatan'],
// 'akta' => $faulty->deed_law_id,
// 'seksyen_kesalahan' => $faulty->_id,
// 'jumlah_asal_kompaun' => $faulty->amount,
// 'jumlah_kemaskini_kompaun' => '',
// 'dikeluarkan' => $this->no_badan,
// "status" => 'Belum Bayar',
// "amount_payment" => '',
// "receipt" => '',
// "modul" => '03',
// "penguatkuasa" => '',
// "created_at" => new Carbon($this->request['tarikh_dikeluarkan']),
// ];
// }else{
// $compoundData = [
// 'jenis' => 'Pelbagai',
// 'kpd' => $this->request['kpd'],
// 'nama' => $this->request['namaP'],
// 'identity' => $this->request['noIc'],
// 'nama_syarikat' => $this->request['namaS'],
// 'no_daftar_syarikat' => strtolower($this->request['daftarNo']),
// 'alamat' => $this->request['alamat'],
// 'no_telefon' => $this->request['tel'],
// 'no_akaun_lesen' =>$this->request['lesen'],
// "no_plate" => $this->request['no_plate'],
// "catatan" => $this->request['catatan'],
// "lokasi_kejadian" => $this->request['lokasi_kejadian'],
// 'latlong' => $this->request['Latlong'],
// 'jbkod' => $this->request['jabatan'],
// 'akta' => $faulty->deed_law_id,
// 'seksyen_kesalahan' => $faulty->_id,
// 'jumlah_asal_kompaun' => $faulty->amount,
// 'jumlah_kemaskini_kompaun' => '',
// 'dikeluarkan' => $this->no_badan,
// "status" => 'Belum Bayar',
// "amount_payment" => '',
// "receipt" => '',
// "modul" => '03',
// "penguatkuasa" => '',
// "created_at" => new Carbon($this->request['tarikh_dikeluarkan']),
// ];
// }
// $file = $file->create($fileData);
// $file->compound()->create($compoundData);
// $success_save_data = true;
// }
// if($success_save_data == true){
// dispatch(new UpdateCompoundPrice($this->kpd));
$staff = Staff::with('StaffDetail')->where('_id', $this->no_badan)->first();
$compound = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('kpd',$this->request['kpd'])->first();
$site = SiteSetting::first();
$faulty = Faulty::with('DeedLaw')->where('_id',$compound->seksyen_kesalahan)->first();
$department = Department::where('_id', $compound->jbkod)->first();
$tawaran = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$tawaran = $compound->jumlah_asal_kompaun;
}else{
$tawaran = $compound->jumlah_kemaskini_kompaun;
}
/******************************************************************/
$gDate = $compound->created_at->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penguatkuasa ".$staff->StaffDetail->full_name." mengeluarkan kompaun ".$this->request['kpd'],
'huraian' => "Kompaun ".$this->request['kpd']." telah dihasilkan oleh penguatkuasa <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a> di bawah akta seksyen kesalahan [".$faulty->sketr."] ".$faulty->nama,
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
$memo = Memo::where('itkod', $compound->seksyen_kesalahan)->get();
if(!empty($memo)){
foreach ($memo as $key => $m) {
$staffD = StaffDetail::where('_id',$m->dikeluarkan)->first();
if($m->disahkan != ''){
$compound->ConfidentialFile->memo()->attach($m);
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penambahan Memo[ ".$m->no_rujukan." ] : ".$m->subjek." oleh ".$staffD->roles_access." ".$staffD->full_name,
'huraian' => $m->penerangan,
];
$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
}
}
}
// Convert To Pdf
$upload [] = [ 'name' => 'compound', 'contents' => $compound ];
$upload [] = [ 'name' => 'faulty', 'contents' => $faulty ];
$upload [] = [ 'name' => 'staff', 'contents' => $staff ];
$upload [] = [ 'name' => 'department', 'contents' => $department ];
$upload [] = [ 'name' => 'site', 'contents' => $site ];
$upload [] = [ 'name' => 'type', 'contents' => 'proxy' ];
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', 'http://filegoforce.sipadu.my/api/compound/pdf', [
'multipart' => $upload
]);
$response = json_decode($result->getBody()->getContents());
if($response->success == true){
$compound->pdf_path = $response->data;
$compound->save();
}
// }
}
}

+ 185
- 0
app/Jobs/UpdateCompoundPrice.php 查看文件

@@ -0,0 +1,185 @@
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

use Config;
use File;
use Carbon\Carbon;

use App\Model\Module\Compound;
use App\Model\Module\ConfidentialFile;
use App\Model\Module\Memo;
use App\Model\Module\Faulty;

class UpdateCompoundPrice implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $kpd;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($kpd)
{
//
$this->kpd = $kpd;
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
$curr = Carbon::now()->getTimestamp();
$harga_tawaran = '';

// invididu Kompoun
if($this->kpd != 'null'){
$compound = Compound::with('ConfidentialFile')->where('kpd', $this->kpd)->first();
$file = ConfidentialFile::with(['Memo' => function($q){
$q->orderBy('updated_at','ASC');
}])->where('no_siri',$compound->ConfidentialFile->no_siri)->first();

// Update Harga
if($compound->status == "Belum Bayar"){

$faulty = Faulty::where('_id',$compound->seksyen_kesalahan)->first();
if(!empty($faulty)){
$tarikh_keluar = $compound->created_at;
$tempoh_hari7 = $tarikh_keluar->addDays(7)->getTimestamp();
$tempoh_hari14 = $tarikh_keluar->addDays(14)->getTimestamp();
$tempoh_hari30 = $tarikh_keluar->addDays(30)->getTimestamp();

if($curr <= $tempoh_hari7){
if($faulty->amount_before_14 != '0'){
$compound->jumlah_kemaskini_kompaun = $faulty->amount_before_14;
$compound->save();
}
}else if($curr > $tempoh_hari7 && $curr <= $tempoh_hari14){
if($faulty->amount_before_14 != '0'){
$compound->jumlah_kemaskini_kompaun = $faulty->amount_before_14;
$compound->save();
}
}else if($curr > $tempoh_hari14 && $curr <= $tempoh_hari30){
if($faulty->amount_before_30 != '0'){
$compound->jumlah_kemaskini_kompaun = $faulty->amount_before_30;
$compound->save();
}
}else if($curr > $tempoh_hari30){
$compound->jumlah_kemaskini_kompaun = '';
$compound->save();
}
}

}else{
$compound->jumlah_kemaskini_kompaun = '';
$compound->save();
}

// Update Memo
if(!empty($file)){
foreach ($file->memo as $key => $m) {
$start = $m->tarikh_mula;
$akhir = $m->tarikh_akhir;

$start_date = strtotime($start);
$expiry_date = strtotime($akhir);

if($m->disahkan != ''){
if($curr >= $start_date && $curr <= $expiry_date) {
if($m->jenis_memo == "Tambahan"){
$price = (float)$compound->jumlah_asal_kompaun;
$addition = (int)$m->tawaran_kompaun;
$harga_tawaran = number_format( $price + ($price * ($addition / 100)) , 2);

$compound->jumlah_kemaskini_kompaun = $harga_tawaran;
$compound->save();
}else if($m->jenis_memo == "Lain-lain"){
}
}else{
$compound->jumlah_kemaskini_kompaun = '';
$compound->save();
}
}
}
}
}else if($this->kpd == 'null'){
$compound = Compound::with('ConfidentialFile','Faulty')->get();
if(!empty($compound)){
foreach($compound as $c){
if($c->status == "Belum Bayar"){
// $faulty = Faulty::where('_id',$c->seksyen_kesalahan)->first();
if(!empty($faulty)){
$tarikh_keluar = $c->created_at;
$tempoh_hari7 = $tarikh_keluar->addDays(7)->getTimestamp();
$tempoh_hari14 = $tarikh_keluar->addDays(14)->getTimestamp();
$tempoh_hari30 = $tarikh_keluar->addDays(30)->getTimestamp();

if($curr <= $tempoh_hari7){
if($c->Faulty->amount_before_14 != '0'){
$c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_14;
$c->save();
}
}else if($curr > $tempoh_hari7 && $curr <= $tempoh_hari14){
if($c->Faulty->amount_before_14 != '0'){
$c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_14;
$c->save();
}
}else if($curr > $tempoh_hari14 && $curr <= $tempoh_hari30){
if($c->Faulty->amount_before_30 != '0'){
$c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_30;
$c->save();
}
}else if($curr > $tempoh_hari30){
$c->jumlah_kemaskini_kompaun = '';
$c->save();
}
}

}else{
$c->jumlah_kemaskini_kompaun = '';
$c->save();
}
// Update Memo
if(!empty($c->ConfidentialFile)){
foreach ($c->ConfidentialFile->memo as $key => $m) {
$start = $m->tarikh_mula;
$akhir = $m->tarikh_akhir;

$start_date = strtotime($start);
$expiry_date = strtotime($akhir);

if($m->disahkan != ''){
if($curr >= $start_date && $curr <= $expiry_date) {
if($m->jenis_memo == "Tambahan"){
$price = (float)$c->jumlah_asal_kompaun;
$addition = (int)$m->tawaran_kompaun;
$harga_tawaran = number_format( $price + ($price * ($addition / 100)) , 2);

$c->jumlah_kemaskini_kompaun = $harga_tawaran;
$c->save();
}else if($m->jenis_memo == "Lain-lain"){
}
}else{
$c->jumlah_kemaskini_kompaun = '';
$c->save();
}
}
}
}
}
}
}
}
}

+ 17
- 0
app/Model/Database/EPBT.php 查看文件

@@ -0,0 +1,17 @@
<?php
namespace App\Model\Database;
use Illuminate\Notifications\Notifiable;
use Yajra\Oci8\Eloquent\OracleEloquent as Eloquent;
use App\Model\Database\Kelantanpay;
class EPBT extends Eloquent
{
//
use Notifiable;
protected $connection = 'oracle';
protected $table = 'KELANTANPAY';
}

+ 23
- 0
app/Model/Module/ApiIntegration.php 查看文件

@@ -0,0 +1,23 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class ApiIntegration extends Eloquent
{
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'api_integration';
protected $guarded = ['_id'];
public function apikey()
{
return $this->belongsTo('App\Model\Module\ApiKey', 'api_key_id', '_id');
}
}

+ 22
- 0
app/Model/Module/ApiKey.php 查看文件

@@ -0,0 +1,22 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class ApiKey extends Eloquent
{
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'api_key_list';
protected $guarded = ['_id'];
public function apiintegrasi() {
return $this->hasMany('App\Model\Module\ApiIntegration');
}
}

+ 41
- 0
app/Model/Module/Attachment.php 查看文件

@@ -0,0 +1,41 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class Attachment extends Eloquent
{
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'attachment';
protected $guarded = ['_id'];
protected $hidden = [
'password', 'remember_token',
];
public function memo() {
return $this->belongsToMany('App\Model\Module\Memo');
}
public function compound() {
return $this->belongsToMany('App\Model\Module\Compound');
}
public function confidentialfile() {
return $this->belongsToMany('App\Model\Module\ConfidentialFile');
}
public function iteminventory() {
return $this->belongsTo('App\Model\Module\ItemInventory');
}
public function templatenotice() {
return $this->belongsTo('App\Model\Module\TemplateNotice');
}
}

+ 38
- 0
app/Model/Module/AuctionSale.php 查看文件

@@ -0,0 +1,38 @@
<?php
namespace App\Model\Module;
Use App\Model\Module\Inventori;
class AuctionSale
{
public $items = null;
public $totalQty = 0;
public $totalPrice = 0;
public function __construct($oldCart)
{
if ($oldCart){
$this->items=$oldCart->items;
$this->totalQty=$oldCart->totalQty;
$this->totalPrice=$oldCart->totalPrice;
}
}
public function add($item, $id, $harga, $barcode){
// $inv = Inventori::where('_id',$id)->first();
$storedItem = ['qty'=>0,'price'=>$harga, 'item'=>$item, 'barcode'=>array()];
if($this->items){
if(array_key_exists($id, $this->items))
{
$storedItem = $this->items[$id];
}
}
$storedItem['qty']++;
$storedItem['price'] = $harga * $storedItem['qty'];
array_push($storedItem['barcode'], $barcode);
$this->items[$id] = $storedItem;
$this->totalQty++;
$this->totalPrice += $harga;
}
}

+ 33
- 0
app/Model/Module/Barcode.php 查看文件

@@ -0,0 +1,33 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class Barcode extends Eloquent
{
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'barcode';
protected $guarded = ['_id'];
public function memo() {
return $this->belongsToMany('App\Model\Module\Memo');
}
public function compound() {
return $this->belongsToMany('App\Model\Module\Compound');
}
public function confidentialfile() {
return $this->belongsToMany('App\Model\Module\ConfidentialFile');
}
public function iteminventory() {
return $this->belongsToMany('App\Model\Module\ItemInventory');
}
}

+ 60
- 0
app/Model/Module/Compound.php 查看文件

@@ -0,0 +1,60 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class Compound extends Eloquent
{
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'compound';
protected $guarded = ['_id'];
public function attachment(){
return $this->hasMany('App\Model\Module\Attachment');
}
public function staff()
{
return $this->belongsTo('App\Model\Staff','no_badan','dikeluarkan');
}
public function staffdetail()
{
return $this->belongsTo('App\Model\StaffDetail','dikeluarkan','_id');
}
public function updateby(){
return $this->belongsTo('App\Model\StaffDetail','update_by','_id');
}
public function confidentialfile()
{
return $this->belongsTo('App\Model\Module\ConfidentialFile', 'confidential_file_id', '_id');
}
public function compoundinvestigation(){
return $this->hasOne('App\Model\Module\CompoundInvestigation');
}
public function letternotice(){
return $this->hasMany('App\Model\Module\LetterNotice');
}
public function faulty(){
return $this->belongsTo('App\Model\Module\Faulty', 'seksyen_kesalahan', '_id');
}
public function department(){
return $this->belongsTo('App\Model\Module\Department', 'jbkod', '_id');
}
public function deedlaw(){
return $this->belongsTo('App\Model\Module\DeedLaw', 'akta', '_id');
}
}

+ 31
- 0
app/Model/Module/CompoundInvestigation.php 查看文件

@@ -0,0 +1,31 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class CompoundInvestigation extends Eloquent
{
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'compound_investigation';
protected $guarded = ['_id'];
public function attachment(){
return $this->hasMany('App\Model\Module\Attachment');
}
public function staff()
{
return $this->belongsTo('App\Model\Staff','no_badan','dikeluarkan');
}
public function compound()
{
return $this->belongsTo('App\Model\Module\Compound');
}
}

+ 39
- 0
app/Model/Module/ConfidentialFile.php 查看文件

@@ -0,0 +1,39 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class ConfidentialFile extends Eloquent
{
//
protected $connection = 'mongodb';
protected $collection = 'confidential_file';
protected $guarded = ['_id'];
public function staff(){
return $this->belongsTo('App\Model\Staff', 'no_badan', 'penguatkuasa');
}
public function compound(){
return $this->hasOne('App\Model\Module\Compound');
}
public function memo()
{
return $this->belongsToMany('App\Model\Module\Memo');
}
public function history(){
return $this->belongsToMany('App\Model\Module\History');
}
public function investigation(){
return $this->hasMany('App\Model\Module\Investigation');
}
public function iteminventory(){
return $this->hasMany('App\Model\Module\ItemInventory');
}
}

+ 18
- 0
app/Model/Module/CurrentLocation.php 查看文件

@@ -0,0 +1,18 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class CurrentLocation extends Eloquent
{
//
protected $connection = 'mongodb';
protected $collection = 'current_location';
protected $guarded = ['_id'];
public function staff(){
return $this->belongsTo('App\Model\Staff');
}
}

+ 29
- 0
app/Model/Module/DeedLaw.php 查看文件

@@ -0,0 +1,29 @@
<?php
namespace App\Model\Module;
use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class DeedLaw extends Eloquent
{
//
use Notifiable;
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'deedlaw';
protected $guarded = ['_id'];
public function faulty()
{
return $this->hasMany('App\Model\Module\Faulty');
}
public function department()
{
return $this->belongsToMany('App\Model\Module\Department');
}
}

+ 40
- 0
app/Model/Module/Department.php 查看文件

@@ -0,0 +1,40 @@
<?php
namespace App\Model\Module;
use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
use App\Model\Staff;
class Department extends Eloquent
{
//
use Notifiable;
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'department';
protected $guarded = ['_id'];
public function staffdetail()
{
return $this->belongsToMany('App\Model\StaffDetail');
}
public function templatenotice(){
return $this->hasMany('App\Model\Module\TemplateNotice');
}
public function deedlaw()
{
return $this->belongsToMany('App\Model\Module\DeedLaw');
}
public function faulty()
{
return $this->belongsToMany('App\Model\Module\Faulty');
}
}

+ 18
- 0
app/Model/Module/EmergencyMarker.php 查看文件

@@ -0,0 +1,18 @@
<?php
namespace App\Model\Module;
use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class EmergencyMarker extends Eloquent
{
//
use Notifiable;
protected $connection = 'mongodb';
protected $collection = 'temp_emergency';
protected $guarded = ['_id'];
}

+ 26
- 0
app/Model/Module/Faulty.php 查看文件

@@ -0,0 +1,26 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class Faulty extends Eloquent
{
use SoftDeletes;
//
protected $connection = 'mongodb';
protected $collection = 'section_faulty';
protected $guarded = ['_id'];
public function deedlaw()
{
return $this->belongsTo('App\Model\Module\DeedLaw','deed_law_id','_id');
}
public function department()
{
return $this->belongsToMany('App\Model\Module\Department');
}
}

+ 18
- 0
app/Model/Module/FirebaseFcmToken.php 查看文件

@@ -0,0 +1,18 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class FirebaseFcmToken extends Eloquent
{
//
protected $connection = 'mongodb';
protected $collection = 'firebase_token_fcm';
protected $guarded = ['_id'];
public function staff(){
return $this->belongsTo('App\Model\Staff');
}
}

+ 24
- 0
app/Model/Module/History.php 查看文件

@@ -0,0 +1,24 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class History extends Eloquent
{
//
protected $connection = 'mongodb';
protected $collection = 'history';
protected $guarded = ['_id'];
public function confidentialfile(){
// 1: Referrer Parent, 2: Referer Current Class
return $this->belongsToMany('App\Model\Module\ConfidentialFile');
}
public function subhistory(){
// 1: Referrer Parent, 2: Referer Current Class
return $this->hasMany('App\Model\Module\SubHistory');
}
}

+ 26
- 0
app/Model/Module/Investigation.php 查看文件

@@ -0,0 +1,26 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class Investigation extends Eloquent
{
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'investigation';
protected $guarded = ['_id'];
public function confidentialfile()
{
return $this->belongsTo('App\Model\Module\ConfidentialFile');
}
public function attachment(){
return $this->hasMany('App\Model\Module\Attachment');
}
}

+ 31
- 0
app/Model/Module/ItemInventory.php 查看文件

@@ -0,0 +1,31 @@
<?php
namespace App\Model\Module;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class ItemInventory extends Eloquent
{
use SoftDeletes;
//
protected $connection = 'mongodb';
protected $collection = 'inventory';
protected $guarded = ['_id'];
public function confidentialfile()
{
return $this->belongsTo('App\Model\Module\Inventory');
}
public function attachment()
{
return $this->hasMany('App\Model\Module\Attachment');
}
public function barcode()
{
return $this->hasMany('App\Model\Module\Barcode');
}
}

+ 0
- 0
app/Model/Module/LetterNotice.php 查看文件


部分文件因文件數量過多而無法顯示

Loading…
取消
儲存