revize
c646de2a9d
100 změnil soubory, kde provedl 26457 přidání a 0 odebrání
  1. 15
    0
      .editorconfig
  2. 39
    0
      .env.
  3. 47
    0
      .env.example
  4. 5
    0
      .gitattributes
  5. 13
    0
      .gitignore
  6. 268
    0
      CHANGELOG.md
  7. 1
    0
      HEAD
  8. 32
    0
      app/Dealer.php
  9. 42
    0
      app/Exceptions/Console/Kernel.php
  10. 51
    0
      app/Exceptions/Handler.php
  11. 46
    0
      app/Http/Controllers/Api/BaseController.php
  12. 128
    0
      app/Http/Controllers/Api/DocketMobile.php
  13. 196
    0
      app/Http/Controllers/Api/FormController.php
  14. 134
    0
      app/Http/Controllers/Api/LoginMobile.php
  15. 259
    0
      app/Http/Controllers/Api/MynixController.php
  16. 289
    0
      app/Http/Controllers/Api/WorkOrderMobile.php
  17. 122
    0
      app/Http/Controllers/Auth/AdminController.php
  18. 32
    0
      app/Http/Controllers/Auth/ForgotPasswordController.php
  19. 118
    0
      app/Http/Controllers/Auth/LoginController.php
  20. 39
    0
      app/Http/Controllers/Auth/LoginController.php__
  21. 72
    0
      app/Http/Controllers/Auth/RegisterController.php
  22. 39
    0
      app/Http/Controllers/Auth/ResetPasswordController.php
  23. 112
    0
      app/Http/Controllers/Auth/StaffLoginController.php
  24. 41
    0
      app/Http/Controllers/Auth/VerificationController.php
  25. 151
    0
      app/Http/Controllers/Contractor/CalendarController.php
  26. 843
    0
      app/Http/Controllers/Contractor/ContractorController.php
  27. 821
    0
      app/Http/Controllers/Contractor/DocketController.php
  28. 766
    0
      app/Http/Controllers/Contractor/WorkOrderController.php
  29. 13
    0
      app/Http/Controllers/Controller.php
  30. 266
    0
      app/Http/Controllers/CustomerService/CalendarController.php
  31. 210
    0
      app/Http/Controllers/CustomerService/CoverageController.php
  32. 1381
    0
      app/Http/Controllers/CustomerService/CustomerController.php
  33. 190
    0
      app/Http/Controllers/CustomerService/DocketController.php
  34. 52
    0
      app/Http/Controllers/CustomerService/ProfileController.php
  35. 355
    0
      app/Http/Controllers/CustomerService/TeamController.php
  36. 1437
    0
      app/Http/Controllers/CustomerService/WorkOrderController.php
  37. 219
    0
      app/Http/Controllers/DS/DealerClaimController.php
  38. 2540
    0
      app/Http/Controllers/DS/DealerController.php
  39. 3625
    0
      app/Http/Controllers/DS/MarketingController.php
  40. 852
    0
      app/Http/Controllers/DS/MarketingDealerController.php
  41. 116
    0
      app/Http/Controllers/DS/ProfileControllerA.php
  42. 314
    0
      app/Http/Controllers/DS/SalesController.php
  43. 1276
    0
      app/Http/Controllers/DS/TestController.php
  44. 560
    0
      app/Http/Controllers/Form/BusinessController.php
  45. 42
    0
      app/Http/Controllers/Form/FormController.php
  46. 593
    0
      app/Http/Controllers/Form/ResidentialController.php
  47. 87
    0
      app/Http/Kernel.php
  48. 24
    0
      app/Http/Middleware/AgentAuth.php
  49. 21
    0
      app/Http/Middleware/Authenticate.php
  50. 24
    0
      app/Http/Middleware/CSAuth.php
  51. 17
    0
      app/Http/Middleware/CheckForMaintenanceMode.php
  52. 24
    0
      app/Http/Middleware/ContractorAuth.php
  53. 24
    0
      app/Http/Middleware/DSAuth.php
  54. 17
    0
      app/Http/Middleware/EncryptCookies.php
  55. 24
    0
      app/Http/Middleware/MarketAuth.php
  56. 24
    0
      app/Http/Middleware/MobileApps.php
  57. 52
    0
      app/Http/Middleware/RedirectIfAuthenticated.php
  58. 18
    0
      app/Http/Middleware/TrimStrings.php
  59. 23
    0
      app/Http/Middleware/TrustProxies.php
  60. 24
    0
      app/Http/Middleware/VerifyCsrfToken.php
  61. 51
    0
      app/Jobs/SendCustomerInvoice.php
  62. 51
    0
      app/Jobs/SendCustomerInvoiceB.php
  63. 54
    0
      app/Jobs/SendWorkOrder.php
  64. 87
    0
      app/Jobs/StoreDocket.php
  65. 94
    0
      app/Mail/AssignWorkOrder.php
  66. 40
    0
      app/Mail/CustomerBInvoice.php
  67. 40
    0
      app/Mail/CustomerInvoice.php
  68. 17
    0
      app/Model/AdminDetail.php
  69. 19
    0
      app/Model/Commission.php
  70. 33
    0
      app/Model/Company.php
  71. 17
    0
      app/Model/Coverage.php
  72. 19
    0
      app/Model/DealerClaim.php
  73. 23
    0
      app/Model/DealerDetail.php
  74. 23
    0
      app/Model/Docket.php
  75. 41
    0
      app/Model/Form.php
  76. 20
    0
      app/Model/FormStatus.php
  77. 13
    0
      app/Model/OldBusiness.php
  78. 13
    0
      app/Model/OldDocket.php
  79. 13
    0
      app/Model/OldResidential.php
  80. 13
    0
      app/Model/OldWorkOrder.php
  81. 13
    0
      app/Model/OrderHistory.php
  82. 20
    0
      app/Model/PackageDetail.php
  83. 19
    0
      app/Model/Product.php
  84. 15
    0
      app/Model/Question.php
  85. 21
    0
      app/Model/StaffDetail.php
  86. 20
    0
      app/Model/Subscriber.php
  87. 32
    0
      app/Model/WorkOrder.php
  88. 28
    0
      app/Providers/AppServiceProvider.php
  89. 30
    0
      app/Providers/AuthServiceProvider.php
  90. 21
    0
      app/Providers/BroadcastServiceProvider.php
  91. 34
    0
      app/Providers/EventServiceProvider.php
  92. 73
    0
      app/Providers/RouteServiceProvider.php
  93. 40
    0
      app/Staff.php
  94. 21
    0
      app/StaffOld.php
  95. 53
    0
      artisan
  96. 55
    0
      bootstrap/app.php
  97. 2
    0
      bootstrap/cache/.gitignore
  98. 71
    0
      composer.json
  99. 6043
    0
      composer.lock
  100. 0
    0
      config/app.php

+ 15
- 0
.editorconfig Zobrazit soubor

@@ -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

+ 39
- 0
.env. Zobrazit soubor

@@ -0,0 +1,39 @@
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

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}"

+ 47
- 0
.env.example Zobrazit soubor

@@ -0,0 +1,47 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:wDRcykZN8RDAYhcl9gyWb+w18UIdnN41lj+jNf9yrk4=
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

MONGO_DB_HOST=127.0.0.1
MONGO_DB_PORT=27017
MONGO_DB_DATABASE=sandbox_CBB
MONGO_DB_USERNAME=
MONGO_DB_PASSWORD=

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

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}"

JWT_SECRET=S9yDXbv8gQW3T2dG4Gm0he1sqEzTR4NO

+ 5
- 0
.gitattributes Zobrazit soubor

@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

+ 13
- 0
.gitignore Zobrazit soubor

@@ -0,0 +1,13 @@
/node_modules
/public/hot
/public/storage
/public/document
/public
/storage/*.key
/vendor
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

+ 268
- 0
CHANGELOG.md Zobrazit soubor

@@ -0,0 +1,268 @@
# Release Notes

## [v5.7.15 (2018-11-22)](https://github.com/laravel/laravel/compare/v5.7.13...v5.7.15)

### Added
- Add asset url configuration option ([63a4039](https://github.com/laravel/laravel/commit/63a403912362654962654e30cec695128d418987))
- Add `log_channel` configuration option ([#4855](https://github.com/laravel/laravel/pull/4855))
- Add env variable for compiled view path ([5ea6fe1](https://github.com/laravel/laravel/commit/5ea6fe18a89c3d0f5c0860d3777bff97510577b5))
- Use env superglobal ([071a05b](https://github.com/laravel/laravel/commit/071a05bd76ee7eca0ea15ea107b49bcbad9af925))
- Add date_equals validation message ([#4863](https://github.com/laravel/laravel/pull/4863))

### Changed
- Remove lodash dependency when auto registering Vue components ([#4853](https://github.com/laravel/laravel/pull/4853))
- Clean up auto register Vue components ([#4854](https://github.com/laravel/laravel/pull/4854))
- Normalize `composer.json` ([#4856](https://github.com/laravel/laravel/pull/4856))
- Update `Kernel.php` ([#4861](https://github.com/laravel/laravel/pull/4861))
- Change variable name ([03ac80b](https://github.com/laravel/laravel/commit/03ac80b779be0f93e6f9d2dae56533d1e5569c35))


## [v5.7.13 (2018-11-07)](https://github.com/laravel/laravel/compare/v5.7.0...v5.7.13)

### Added
- Adding papertrail log channel option ([#4749](https://github.com/laravel/laravel/pull/4749))
- Add missing Mailgun 'endpoint' option ([#4752](https://github.com/laravel/laravel/pull/4752))
- Add new Stripe webhook config values ([#4803](https://github.com/laravel/laravel/pull/4803))
- Add message for UUID validation rule ([#4834](https://github.com/laravel/laravel/pull/4834))
- Introduce sqlite foreign_key_constraints config option ([#4838](https://github.com/laravel/laravel/pull/4838))
- Auto register Vue components ([#4843](https://github.com/laravel/laravel/pull/4843))

### Changed
- Updated `QUEUE_DRIVER` env var to `QUEUE_CONNECTION` in `phpunit.xml` ([#4746](https://github.com/laravel/laravel/pull/4746))
- Update VerificationController ([#4756](https://github.com/laravel/laravel/pull/4756))
- Seeded users should be verified by default ([#4761](https://github.com/laravel/laravel/pull/4761))
- Preserve colors ([#4763](https://github.com/laravel/laravel/pull/4763))
- Set logs to daily by default ([#4767](https://github.com/laravel/laravel/pull/4767))
- Change default days to 14 for daily channel ([cd8dd76](https://github.com/laravel/laravel/commit/cd8dd76b67fb3ae9984b1477df4a9a3f0131ca87))
- Check if register route is enabled ([#4775](https://github.com/laravel/laravel/pull/4775))
- Update lang attribute ([#4781](https://github.com/laravel/laravel/pull/4781))
- Changes the translation for "required_with_all" validation rule ([#4782](https://github.com/laravel/laravel/pull/4782))
- Update database config ([#4783](https://github.com/laravel/laravel/pull/4783))
- Removing double arrow alignments ([#4830](https://github.com/laravel/laravel/pull/4830))
- Update vue version to 2.5.17 ([#4831](https://github.com/laravel/laravel/pull/4831))
- Use env value for redis queue name ([#4837](https://github.com/laravel/laravel/pull/4837))

### Fixed
- Update `HttpKernel` to use `Authenticate` middleware under `App` namespace ([#4757](https://github.com/laravel/laravel/pull/4757))
- Persist the `/storage/framework/cache/data` directory ([#4760](https://github.com/laravel/laravel/pull/4760))
- Make app path stream safe ([#4777](https://github.com/laravel/laravel/pull/4777))
- Use correct facade ([#4780](https://github.com/laravel/laravel/pull/4780))
- Revert [#4744](https://github.com/laravel/laravel/pull/4780) ([#4791](https://github.com/laravel/laravel/pull/4791))
- Don't redirect for api calls ([#4805](https://github.com/laravel/laravel/pull/4805))
- Fix bad font size render on link ([#4822](https://github.com/laravel/laravel/pull/4822))
- Changed syntax for validation ([#4820](https://github.com/laravel/laravel/pull/4820))
- Fix running mix tasks error ([#4832](https://github.com/laravel/laravel/pull/4832))

### Removed
- Remove X-UA-Compatible meta tag ([#4748](https://github.com/laravel/laravel/pull/4748))


## [v5.7.0 (2018-09-04)](https://github.com/laravel/laravel/compare/v5.6.33...v5.7.0)

### Added
- Added email verification functionality ([#4689](https://github.com/laravel/laravel/pull/4689))
- Added customizable redirect on auth failure ([a14e623](https://github.com/laravel/laravel/commit/a14e62325cbe82a615ccd2e80925c75cb0bf1eaf))
- Added possibility to make httpOnly CSRF cookie optional ([#4692](https://github.com/laravel/laravel/pull/4692))
- Added `beyondcode/laravel-dump-server` : `^1.0` to `composer.json` ([ff99e2f](https://github.com/laravel/laravel/commit/ff99e2fd5c6f868b9be53420057551c790f10785), [#4736](https://github.com/laravel/laravel/pull/4736))
- Added `argon2id` support in `hashing.php` ([28908d8](https://github.com/laravel/laravel/commit/28908d83d9f3b078ae01ed21a42b87edf1fd393d))
- Added `SESSION_CONNECTION` and `SESSION_STORE` env. variable ([#4735](https://github.com/laravel/laravel/pull/4735))

### Changed
- Changed `QUEUE_DRIVER` env variable name to `QUEUE_CONNECTION` ([c30adc8](https://github.com/laravel/laravel/commit/c30adc88c1cf3f30618145c8b698734cbe03b19c))
- Use separate cache database for Redis ([#4665](https://github.com/laravel/laravel/pull/4665))
- Upgrade Lodash to `^4.17.5` ([#4730](https://github.com/laravel/laravel/pull/4730))
- Changed font to `Nunito` from `Raleway` ([#4727](https://github.com/laravel/laravel/pull/4727))
- Defined `mix` as `const` in `webpack.mix.js` ([#4741](https://github.com/laravel/laravel/pull/4741))
- Make Asset Directory Flattened ([ff38d4e](https://github.com/laravel/laravel/commit/ff38d4e1a007c1a7709b5a614da1036adb464b32))

### Fixed
- Fixed pagination translation ([#4744](https://github.com/laravel/laravel/pull/4744))


## [v5.6.33 (2018-08-13)](https://github.com/laravel/laravel/compare/v5.6.21...v5.6.33)

### Added
- Added `Http/Middleware/CheckForMaintenanceMode.php` ([#4703](https://github.com/laravel/laravel/pull/4703))

### Changed
- Update font and colors in `scss` ([6646ad7](https://github.com/laravel/laravel/commit/6646ad7c527e2b3320661fa1d76a54dd6e896e57))
- Changed message for `alpha_dash` validation rule ([#4661](https://github.com/laravel/laravel/pull/4661))


## [v5.6.21 (2018-05-21)](https://github.com/laravel/laravel/compare/v5.6.12...v5.6.21)

### Added
- Added hashing configuration ([#4613](https://github.com/laravel/laravel/pull/4613))
- Added stderr example into `config/logging.php` ([66f5757](https://github.com/laravel/laravel/commit/66f5757d58cb3f6d1152ec2d5f12e247eb2242e2))
- Added `SES_REGION` to local environment file ([#4629](https://github.com/laravel/laravel/pull/4629))
- Added messages for `gt`/`lt`/`gte`/`lte` validation rules ([#4654](https://github.com/laravel/laravel/pull/4654))

### Changed
- Set `bcrypt rounds` using the `hashing` config ([#4643](https://github.com/laravel/laravel/pull/4643))


## v5.6.12 (2018-03-14)

### Added
- Added message for `not_regex` validation rule ([#4602](https://github.com/laravel/laravel/pull/4602))
- Added `signed` middleware alias for `ValidateSignature` ([4369e91](https://github.com/laravel/laravel/commit/4369e9144ce1062941eda2b19772dbdcb10e9027))
- Added `stderr` example to `config/logging.php` ([66f5757](https://github.com/laravel/laravel/commit/66f5757d58cb3f6d1152ec2d5f12e247eb2242e2))

### Changed
- Set `MAIL_DRIVER` in `phpunit.xml` ([#4607](https://github.com/laravel/laravel/pull/4607))

### Removed
- Removed "thanks" package ([#4593](https://github.com/laravel/laravel/pull/4593))


## v5.6.7 (2018-02-27)

### Changed
- Use `Hash::make()` in `RegisterController` ([#4570](https://github.com/laravel/laravel/pull/4570))
- Update Collision to `2.0` ([#4581](https://github.com/laravel/laravel/pull/4581))

### Removed
- Removed Bootstrap 3 variables ([#4572](https://github.com/laravel/laravel/pull/4572))


## v5.6.0 (2018-02-07)

### Added
- Added `filesystems.disks.s3.url` config parameter ([#4483](https://github.com/laravel/laravel/pull/4483))
- Added `queue.connections.redis.block_for` config parameter ([d6d0013](https://github.com/laravel/laravel/commit/d6d001356232dac4549d152baf685373a6d6c8f8))
- Added Collision package ([#4514](https://github.com/laravel/laravel/pull/4514))
- Added `SetCacheHeaders` middleware to `Kernel::$routeMiddleware` ([#4515](https://github.com/laravel/laravel/pull/4515))
- Added hashing configuration file ([bac7595](https://github.com/laravel/laravel/commit/bac7595f02835ae2d35953a2c9ba039592ed8a94))

### Changed
- Require PHP 7.1.3 or newer ([#4568](https://github.com/laravel/laravel/pull/4568))
- Upgraded PHPUnit to v7 ([f771896](https://github.com/laravel/laravel/commit/f771896c285c73fa1a2ac83c1b2770011f8e49ef))
- Upgraded Mix to v2 ([#4557](https://github.com/laravel/laravel/pull/4557))
- Upgraded `fideloper/proxy` to v4 ([#4518](https://github.com/laravel/laravel/pull/4518))
- Set hash driver in `CreatesApplication` ([7b138fe](https://github.com/laravel/laravel/commit/7b138fe39822e34e0c563462ffee6036b4bda226))
- Upgraded to Bootstrap 4 ([#4519](https://github.com/laravel/laravel/pull/4519), [c0cda4f](https://github.com/laravel/laravel/commit/c0cda4f81fd7a25851ed8069f0aa70c2d21a941c), [cd53623](https://github.com/laravel/laravel/commit/cd53623249e8b2b2d7517b1585f68e7e31be1a8a), [3926520](https://github.com/laravel/laravel/commit/3926520f730ab681462dff3275e468b6ad3f061d))
- Updated logging configuration ([acabdff](https://github.com/laravel/laravel/commit/acabdff2e3cde6bc98cc2d951a8fcadf22eb71f0), [bd5783b](https://github.com/laravel/laravel/commit/bd5783b5e9db18b353fe10f5ed8bd6f7ca7b8c6e), [ff0bec8](https://github.com/laravel/laravel/commit/ff0bec857ead9698b2783143b14b5332b96e23cc), [f6e0fd7](https://github.com/laravel/laravel/commit/f6e0fd7ac3e838985a249cd04f78b482d96f230a), [2eeca4e](https://github.com/laravel/laravel/commit/2eeca4e220254393341e25bc7e45e08480c9a683), [ebb0a2a](https://github.com/laravel/laravel/commit/ebb0a2a84fa431e30103c98cf4bed3fa3713ad59), [b78f5bd](https://github.com/laravel/laravel/commit/b78f5bd6e9f739f35383165798ad2022b8fb509c))
- Use Mix environment variables ([224f994](https://github.com/laravel/laravel/commit/224f9949c74fcea2eeceae0a1f65d9c2e7498a27), [2db1e0c](https://github.com/laravel/laravel/commit/2db1e0c5e8525f3ee4b3850f0116c13224790dff))


## v5.5.28 (2018-01-03)

### Added
- Added `symfony/thanks` ([60de3a5](https://github.com/laravel/laravel/commit/60de3a5670c4a3bf5fb96433828b6aadd7df0e53))

### Changed
- Reduced hash computations during tests ([#4517](https://github.com/laravel/laravel/pull/4517), [4bfb164](https://github.com/laravel/laravel/commit/4bfb164c26e4e15ec367912100a71b8fe1500b5c))
- Use environment variables for SQS config ([#4516](https://github.com/laravel/laravel/pull/4516), [aa4b023](https://github.com/laravel/laravel/commit/aa4b02358a018ebc35123caeb92dcca0669e2816))
- Use hard-coded password hash ([f693a20](https://github.com/laravel/laravel/commit/f693a20a3ce6d2461ca75490d44cd1b6ba09ee84))
- Updated default Echo configuration for Pusher ([#4525](https://github.com/laravel/laravel/pull/4525), [aad5940](https://github.com/laravel/laravel/commit/aad59400e2d69727224a3ca9b6aa9f9d7c87e9f7), [#4526](https://github.com/laravel/laravel/pull/4526), [a32af97](https://github.com/laravel/laravel/commit/a32af97ede49fdd57e8217a9fd484b4cb4ab1bbf))


## v5.5.22 (2017-11-21)

### Added
- Added `-Indexes` option in `.htaccess` ([#4422](https://github.com/laravel/laravel/pull/4422))

### Changed
- Load session lifetime from env file ([#4444](https://github.com/laravel/laravel/pull/4444))
- Update mockery to 1.0 ([#4458](https://github.com/laravel/laravel/pull/4458))
- Generate cache prefix from `APP_NAME` ([#4409](https://github.com/laravel/laravel/pull/4409))
- Match AWS environment variable name with AWS defaults ([#4470](https://github.com/laravel/laravel/pull/4470))
- Don't show progress for `production` command ([#4467](https://github.com/laravel/laravel/pull/4467))

### Fixed
- Fixed directive order in `.htaccess` ([#4433](https://github.com/laravel/laravel/pull/4433))


## v5.5.0 (2017-08-30)

### Added
- Added `same_site` to `session.php` config ([#4168](https://github.com/laravel/laravel/pull/4168))
- Added `TrustProxies` middleware ([e23a1d2](https://github.com/laravel/laravel/commit/e23a1d284f134bfce258cf736ea8667a407ba50c), [#4302](https://github.com/laravel/laravel/pull/4302))
- Autoload commands ([5d54c21](https://github.com/laravel/laravel/commit/5d54c21ea869a7a5b503f0899307e4728feed11b))
- Added Whoops ([#4364](https://github.com/laravel/laravel/pull/4364))

### Changed
- Refactored exception handler (_too many commits_)
- Renamed `ModelFactory.php` to `UserFactory.php` to encourage separate files ([67a8a11](https://github.com/laravel/laravel/commit/67a8a1157004c4373663ec4a9398780feb6d6fa4))
- Use `RefreshDatabase` trait ([a536402](https://github.com/laravel/laravel/commit/a536402228108da9423a0db1e0cf492f3f51c8b8), [#4373](https://github.com/laravel/laravel/pull/4373))
- Use Composer's `@php` directive ([#4278](https://github.com/laravel/laravel/pull/4278))
- Use `post-autoload-dump` ([2f4d726](https://github.com/laravel/laravel/commit/2f4d72699cdc9b7db953055287697a60b6d8b294))
- Try to build session cookie name from app name ([#4305](https://github.com/laravel/laravel/pull/4305))

### Fixed
- Fixed Apache trailing slash redirect for subdirectory installs ([#4344](https://github.com/laravel/laravel/pull/4344))

### Removed
- Dropped `bootstrap/autoload.php` ([#4226](https://github.com/laravel/laravel/pull/4226), [#4227](https://github.com/laravel/laravel/pull/4227), [100f71e](https://github.com/laravel/laravel/commit/100f71e71a24fd8f339a7687557b77dd872b054b))
- Emptied `$dontReport` array on exception handler ([758392c](https://github.com/laravel/laravel/commit/758392c30fa0b2651ca9409aebb040a64816dde4))
- Removed `TinkerServiceProvider` ([6db0f35](https://github.com/laravel/laravel/commit/6db0f350fbaa21b2acf788d10961aba983a19be2))
- Removed migrations from autoload classmap ([#4340](https://github.com/laravel/laravel/pull/4340))


## v5.4.30 (2017-07-20)

### Changed
- Simplified mix require ([#4283](https://github.com/laravel/laravel/pull/4283))
- Upgraded Laravel Mix to `^1.0` ([#4294](https://github.com/laravel/laravel/pull/4294))
- Upgraded `axios` and `cross-env` package ([#4299](https://github.com/laravel/laravel/pull/4299))
- Ignore Yarn error log ([#4322](https://github.com/laravel/laravel/pull/4322))

### Fixed
- Use `app()->getLocale()` ([#4282](https://github.com/laravel/laravel/pull/4282))
- Use quotes in `app.scss` ([#4287](https://github.com/laravel/laravel/pull/4287))


## v5.4.23 (2017-05-11)

### Added
- Added SQL Server connection ([#4253](https://github.com/laravel/laravel/pull/4253), [#4254](https://github.com/laravel/laravel/pull/4254))

### Changed
- Switch to using meta
- Use CSRF token from `meta` tag, instead of `window.Laravel` object ([#4260](https://github.com/laravel/laravel/pull/4260))
- Log console error if CSRF token cannot be found ([1155245](https://github.com/laravel/laravel/commit/1155245a596113dc2cd0e9083603fa11df2eacd9))

### Fixed
- Added missing `ipv4` and `ipv6` validation messages ([#4261](https://github.com/laravel/laravel/pull/4261))


## v5.4.21 (2017-04-28)

### Added
- Added `FILESYSTEM_DRIVER` and `FILESYSTEM_CLOUD` environment variables ([#4236](https://github.com/laravel/laravel/pull/4236))

### Changed
- Use lowercase doctype ([#4241](https://github.com/laravel/laravel/pull/4241))


## v5.4.19 (2017-04-20)

### Added
- Added `optimize-autoloader` to `config` in `composer.json` ([#4189](https://github.com/laravel/laravel/pull/4189))
- Added `.vagrant` directory to `.gitignore` ([#4191](https://github.com/laravel/laravel/pull/4191))
- Added `npm run development` and `npm run prod` commands ([#4190](https://github.com/laravel/laravel/pull/4190), [#4193](https://github.com/laravel/laravel/pull/4193))
- Added `APP_NAME` environment variable ([#4204](https://github.com/laravel/laravel/pull/4204))

### Changed
- Changed Laravel Mix version to `0.*` ([#4188](https://github.com/laravel/laravel/pull/4188))
- Add to axios defaults instead of overwriting them ([#4208](https://github.com/laravel/laravel/pull/4208))
- Added `string` validation rule to `RegisterController` ([#4212](https://github.com/laravel/laravel/pull/4212))
- Moved Vue inclusion from `bootstrap.js` to `app.js` ([17ec5c5](https://github.com/laravel/laravel/commit/17ec5c51d60bb05985f287f09041c56fcd41d9ce))
- Only load libraries if present ([d905b2e](https://github.com/laravel/laravel/commit/d905b2e7bede2967d37ed7b260cd9d526bb9cabd))
- Ignore the NPM debug log ([#4232](https://github.com/laravel/laravel/pull/4232))
- Use fluent middleware definition in `LoginController` ([#4229](https://github.com/laravel/laravel/pull/4229))


## v5.4.16 (2017-03-17)

### Added
- Added `unix_socket` to `mysql` in `config/database.php` ()[#4179](https://github.com/laravel/laravel/pull/4179))
- Added Pusher example code to `bootstrap.js` ([31c2623](https://github.com/laravel/laravel/commit/31c262301899b6cd1a4ce2631ad0e313b444b131))

### Changed
- Use `smtp.mailtrap.io` as default `MAIL_HOST` ([#4182](https://github.com/laravel/laravel/pull/4182))
- Use `resource_path()` in `config/view.php` ([#4165](https://github.com/laravel/laravel/pull/4165))
- Use `cross-env` binary ([#4167](https://github.com/laravel/laravel/pull/4167))

### Removed
- Remove index from password reset `token` column ([#4180](https://github.com/laravel/laravel/pull/4180))

+ 1
- 0
HEAD Zobrazit soubor

@@ -0,0 +1 @@
ref: refs/heads/master

+ 32
- 0
app/Dealer.php Zobrazit soubor

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

namespace App;

use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Auth\User as Authenticatable;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class DealerLaravel extends Authenticatable
{
//
use Notifiable;
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'dealer';
protected $guard = 'ds';

protected $guarded = ['_id'];
protected $hidden = [
'password', 'remember_token',
];

public function dealerdetaillaravel() {
return $this->hasOne('App\Model\DealerDetailLaravel','_id','company_id');
}

public function companylaravel() {
return $this->belongsTo('App\Model\CompanyLaravel','company_id','_id');
}
}

+ 42
- 0
app/Exceptions/Console/Kernel.php Zobrazit soubor

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

+ 51
- 0
app/Exceptions/Handler.php Zobrazit soubor

@@ -0,0 +1,51 @@
<?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)
{
return parent::render($request, $exception);
}
}

+ 46
- 0
app/Http/Controllers/Api/BaseController.php Zobrazit soubor

@@ -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);
}
}

+ 128
- 0
app/Http/Controllers/Api/DocketMobile.php Zobrazit soubor

@@ -0,0 +1,128 @@
<?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 App\Staff;
use App\Model\StaffDetail;
use App\Model\Docket;
use App\Model\WorkOrder;
use App\Model\Company;
use App\Model\Form;
use App\Model\PackageDetail;
use App\Model\Subscriber;
use App\Model\FormStatus;

use App\Jobs\StoreDocket;

use Carbon\Carbon;
use File;

class DocketMobile extends BaseController
{

function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}

function createDocketID($limit){
$allowedNumbers = range(0, 9);
shuffle($allowedNumbers);
$digits = array_rand($allowedNumbers, $limit);
$number = '';
foreach($digits as $d){
$number .= $allowedNumbers[$d];
}
$unique_id = $number;
return $unique_id;
}

public function createDocket(Request $request){

$loginUser = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
if(!empty($loginUser)) {

$wo = WorkOrder::where('wo',$request->wo)->first();

if(!empty($wo)){

$woD = Docket::where('work_order_id', $request->wo)->first();
if(empty($woD)){
$subs = Subscriber::where('_id',$wo->_id)->first();
$destinationPath = 'document/'.$subs->subscriber_id;

// create folder/dir if not exist
if(!File::exists(public_path().'/'.$destinationPath)){
File::makeDirectory(public_path().'/'.$destinationPath,0777,true);
}

$uploaded = public_path().'/'.$destinationPath;
// Signature
$signature_docket = $request->data_uris;
$signature_docket = explode(",", $signature_docket)[1];
//convert signature_form
$data = base64_decode($signature_docket);
$file = $uploaded."/signature_docket.png";
$savetoServer = file_put_contents($file,$data);
if (($savetoServer === false) || ($savetoServer == -1)) {
return $this->sendError('', "Couldn't save signature to jpeg");
}else {

do {
$do = 'DO-'.$this->createDocketID(4);
} while (Docket::where("docket_id", "=", $do)->first() instanceof Docket);

$signature = '/'.$destinationPath.'/signature_docket.png';
$this->dispatch(new StoreDocket($request->all(), $do, $wo->nature_work, $loginUser->_id, $signature));

// $docket = new Docket();
// $docket->work_order_id = $request->wo;
// $docket->docket_id = $do;
// $docket->nature_work = $wo->nature_work;
// $docket->installer_id = $loginUser->_id;
// $docket->end_job = Carbon::now()->toDateTimeString();
// $docket->router_serial_number = $request->router_serial_number;
// $docket->mac_router = $request->mac_router;
// $docket->cable_read = $request->cable_read;
// $docket->condition = $request->condition;
// $docket->Note = $request->Note;
// $docket->Rating1 = $request->Rating1;
// $docket->Rating2 = $request->Rating2;
// $docket->Rating3 = $request->Rating3;
// $docket->customer_signature = '/'.$destinationPath.'/signature_docket.png';

// $wo->docket()->save($docket);

// $wo->status = 'Completed';
// $wo->docket_id = $do;
// $wo->save();

// $fm = Form::where('_id',$wo->_id)->first();
// $stat = new FormStatus();
// $stat->form_id = $fm->_id;
// $stat->status_id = 8;
// $stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
// $stat->status = 'Completed';
// $stat->desc = 'This work order already been completed';
// $fm->formstatus()->save($stat);

return $this->sendResponse($do, 'Create Docket Successfully');
}
}else{
return $this->sendError('', 'Work Order Already Existed!');
}
}else{
return $this->sendError('', 'Work Order Not Exist!');
}
}else {
return $this->sendError('Invalid User', 'User Not Exist!');
}
}
}

+ 196
- 0
app/Http/Controllers/Api/FormController.php Zobrazit soubor

@@ -0,0 +1,196 @@
<?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 App\Model\Form;
Use App\Model\PackageDetail;
Use App\Model\Subscriber;
Use App\Model\WorkOrder;
use App\Staff;
use App\Model\StaffDetail;
use App\Model\Company;

use Carbon\Carbon;

class FormController extends BaseController
{
/**
/* Schedule Function
**/
public function getFormStatistic(Request $request)
{
$dateS = Carbon::createFromFormat('Y-m-d', '2019-12-12');
$start = $dateS->copy()->startOfDay();
$dateE = Carbon::createFromFormat('Y-m-d', '2020-02-11');
$end = $dateE->copy()->endOfDay();

$result = array();
$data = Form::with('PackageDetail', 'Subscriber')->whereBetween('created_at', array($start, $end))->get();
if(count($data) > 0) {
foreach($data as $f) {

$name = ''; $contact_no = '';
$address = ''; $building = '';
$labelD = '';

if(!empty($f->dealer_id)){
$c = Company::find($f->company_id);
$labelD = $c->name;
}else{
$labelD = "";
}

if(!empty($f->Subscriber) && !empty($f->PackageDetail)){
if($f->type_application == 'R'){
$name = $f->Subscriber->name;
$contact_no = $f->Subscriber->phone1;
$building = $f->Subscriber->building_name;
if($f->Subscriber->street != ''){
$address = $f->Subscriber->street. ' , '.$f->Subscriber->postcode. ' , '.$f->Subscriber->city. ' , '.$f->Subscriber->state;
}else {
$address = $f->Subscriber->postcode. ' , '.$f->Subscriber->city. ' , '.$f->Subscriber->state;
}
}else if($f->type_application == 'B'){
$name = $f->Subscriber->company_name;
$contact_no = $f->Subscriber->company_num;
$building = $f->Subscriber->street;
$address = $f->Subscriber->postcode. ' , '.$f->Subscriber->city. ' , '.$f->Subscriber->state;
}

if($f->Subscriber->city == 'Jasin'){
array_push($result,array(
'type_application' => $f->type_application,
"type_service" => $f->type_service,
"customer_name"=> $name,
"contact_no"=> $contact_no,
"unit_no"=>$f->Subscriber->unit_no,
"building"=>$building,
"street"=>$address,
"submitted_date" => $f->created_at->toDateTimeString(),
'dealer' => $labelD,
));
}
}

}

return json_encode($result);
// return $this->sendResponse($result, 'Get Schedule Successfully');
}else {
return $this->sendError('Invalid User', 'User Not Exist!');
}
}


public function get_data_form(){

$dateS = Carbon::createFromFormat('Y-m-d', '2020-01-01');
$start = $dateS->copy()->startOfDay();
$dateE = Carbon::createFromFormat('Y-m-d', '2020-04-31');
$end = $dateE->copy()->endOfDay();

$result = array();
// $data = Form::with('PackageDetail', 'Subscriber')->where('dealer_id', 'exists', false)->whereBetween('created_at', array($start, $end))->get();

// $data = Form::with('PackageDetail', 'Subscriber','WorkOrder')->where('type_service', '!=', 'Rectification')->whereBetween('created_at', array($start, $end))->get();

$data = Form::with('PackageDetail', 'Subscriber','WorkOrder')->where('type_service','New')->whereBetween('created_at', array($start, $end))->get();

if(count($data) > 0) {
foreach($data as $f) {

$name = ''; $contact_no = '';
$address = ''; $building = '';
$labelD = '';

if(!empty($f->dealer_id)){
$c = Company::find($f->company_id);
$labelD = $c->name;
}else{
$labelD = "";
}

if(!empty($f->Subscriber) && !empty($f->PackageDetail)){
if($f->type_application == 'R'){
$name = $f->Subscriber->name;
$contact_no = $f->Subscriber->phone1;
$building = $f->Subscriber->building_name;
if($f->Subscriber->street != ''){
$address = $f->Subscriber->street. ' , '.$f->Subscriber->postcode. ' , '.$f->Subscriber->city. ' , '.$f->Subscriber->state;
}else {
$address = $f->Subscriber->postcode. ' , '.$f->Subscriber->city. ' , '.$f->Subscriber->state;
}
}else if($f->type_application == 'B'){
$name = $f->Subscriber->company_name;
$contact_no = $f->Subscriber->company_num;
$building = $f->Subscriber->street;
$address = $f->Subscriber->postcode. ' , '.$f->Subscriber->city. ' , '.$f->Subscriber->state;
}

$woD = '-'; $woId = 'none';
if(!empty($f->WorkOrder)){
$woId = $f->WorkOrder->wo;
if(!empty($f->WorkOrder->Docket)){
$woD = $f->WorkOrder->Docket->end_job;

// array_push($result,array(
// 'type_application' => $f->type_application,
// "type_service" => $f->type_service,
// "customer_name"=> $name,
// "contact_no"=> $contact_no,
// "unit_no"=>$f->Subscriber->unit_no,
// "building"=>$building,
// "street"=>$address,
// "submitted_date" => $f->created_at->toDateTimeString(),
// "package_contract" => $f->PackageDetail->contract,
// "package_name" => $f->PackageDetail->name,
// 'dealer' => $labelD,
// 'wo' => $woId,
// 'activated_date' => $woD,
// ));
}
}
array_push($result,array(
'type_application' => $f->type_application,
"type_service" => $f->type_service,
"customer_name"=> $name,
"contact_no"=> $contact_no,
"unit_no"=>$f->Subscriber->unit_no,
"building"=>$building,
"street"=>$address,
"submitted_date" => $f->created_at->toDateTimeString(),
"package_contract" => $f->PackageDetail->contract,
"package_name" => $f->PackageDetail->name,
'dealer' => $labelD,
'wo' => $woId,
'activated_date' => $woD,
));
}

}
}

// return json_encode(count($result));
return json_encode($result);
}

/***********************************
/* Form Deleted by Company
***********************************/
public function get_deleted_by_company($company_id)
{

$data = Form::with('PackageDetail', 'Subscriber')->withTrashed()->where('company_id', $company_id)->get();


return $this->sendResponse($data, 'Form deleted by specific company');
}

}

+ 134
- 0
app/Http/Controllers/Api/LoginMobile.php Zobrazit soubor

@@ -0,0 +1,134 @@
<?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 App\Staff;
Use App\Model\StaffDetail;

Use Hash;
use Carbon\Carbon;
use Crypt;
use File;
use Mail;

class LoginMobile extends BaseController
{
function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}
public function encryptPassword($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '28472B4B6250655368566D5970337336';
$secret_iv = md5(md5($string)); //'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if( $action == 'decrypt' ) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}
/**
/* Login Function
**/
public function requestLogin(Request $request) {
$user = ''; $data = array();
$rememberMe = false;
$user = Staff::where('email', $request->email)->where('roles_access','Installer')->first();
if (!empty($user)) {
if($this->encryptPassword('encrypt', $request->password) == $user->password || $this->encryptPassword('encrypt', $request->password) == $user->password2){
$token_id = '';
do {
$token_id = str_random(32);
} while (Staff::where("api_token", "=", $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->device_id = $request->deviceID;
$user->password2 = Hash::make($request->password);
$user->save();
$loginDetail = StaffDetail::where('email',$user->email)->first();
// login
array_push($data, array(
'User' => $loginDetail,
'token' => $token_id
));
return $this->sendResponse($data, 'Login Successfull');
}else {
return $this->sendError('Invalid Login Detail', 'Failed');
}
}else{
return $this->sendError('User not found', 'Failed');
}
}
/**
/* Logout Function
**/
public function requestLogout(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->save();
return $this->sendResponse('Success', 'User logged out successfully');
}else {
return $this->sendError('Failed', 'Sorry, the user cannot be logged out');
}
}
/**
/* Update Profile && Generate QR
**/
public function updateProfile(Request $request){
}
/**
/* Update Profile Image
**/
public function updateProfileImage(Request $request){
}
/**
/* Update Password
**/
public function updatePassword(Request $request) {
$user = Staff::where('email', $request->email)->where('roles_access','Installer')->first();
if(!empty($user)){
$user->password = $this->encryptPassword('encrypt', $request->password);
$user->save();
return $this->sendResponse('Success', 'Your password successfully updated');
}else{
return $this->sendError('Failed', 'Sorry, user not found');
}
}
}

+ 259
- 0
app/Http/Controllers/Api/MynixController.php Zobrazit soubor

@@ -0,0 +1,259 @@
<?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 App\Staff;
use App\Model\StaffDetail;
use App\Model\Docket;
use App\Model\WorkOrder;
use App\Model\Company;
Use App\Model\Form;
Use App\Model\PackageDetail;
Use App\Model\Subscriber;

Use Hash;
use Carbon\Carbon;
use Crypt;
use File;
use Mail;

class MynixController extends BaseController
{

public function workOrderStatistics(){

$pc = count(WorkOrder::where('status','Pending Contractor')->get());
$pi = count(WorkOrder::where('status','Pending Installer')->get());
$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

$data = array();
$data[] = array("status" => "Pending Contractor", "statistic" => $pc);
$data[] = array("status" => "Pending Installer", "statistic" => $pi);
$data[] = array("status" => "Pending Non Prelaid", "statistic" => $pp);
$data[] = array("status" => "Success Non Prelaid", "statistic" => $sp);
$data[] = array("status" => "Reschedule", "statistic" => $rs);
$data[] = array("status" => "Suspend", "statistic" => $ss);
$data[] = array("status" => "Completed", "statistic" => $cm);

return $this->sendResponse($data, 'Get Statistic Successfully');

}

public function workOrderList(){

$data = array();
$installer = ''; $type = ''; $n1 = '';
$curr = Carbon::now()->getTimestamp();

$work_order = WorkOrder::orderBy('created_at', 'desc')->get();
if(!empty($work_order)){
foreach ($work_order as $key => $w) {
$reg_time = $w->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}else{
$n1 = "";
}

$form = Form::with('PackageDetail','Subscriber')->first();
if(!empty($form)){
$company = Company::where('_id',$w->contractor_id)->first();

$staff = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
if(!empty($staff)){
$installer = $staff->StaffDetail->name;
}else{
$installer = '';
}
$address = '';
if($form->type_application == 'R'){
if($form->Subscriber->street != ''){
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}
}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$address = $form->Subscriber->unit_no. ', '.$form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}
}

if($form->type_application == 'R'){
$type = 'Residential';
}else if($form->type_application == 'B'){
$type = 'Business';
}

array_push($data,array(
"work_order_id" => $n1.$w->wo,
"type" => $type,
"contractor" => $company->name,
"installer" => $installer,
"title" => $w->nature_work,
"appoint_date_time"=>date("m/d/Y H:i", strtotime($w->dateTimeStart)),
"cus_name"=> $form->Subscriber->name,
"contact_person" => $form->Subscriber->name,
"contact_no"=> $form->Subscriber->phone1,
"technical" => $form->Subscriber->name,
"address"=> $address,
"status" => $w->status,
));
}
}

return $this->sendResponse($data, 'Get Work Order List Successfully');
}
}


public function getCustomerList(){

$data = array(); $i = 1;
$n1 = ''; $address = ''; $building = ''; $status = '';
$curr = Carbon::now()->getTimestamp();

$form_submitted = Form::with('PackageDetail','Subscriber','WorkOrder')->withTrashed()->orderBy('created_at', 'desc')->get();
if(!empty($form_submitted)){
foreach ($form_submitted as $key => $v) {

if(!empty($v->Subscriber)){
if(empty($v->WorkOrder)){

$i++;
$reg_time = $v->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}else{
$n1 = "";
}

if($v->type_application == 'R'){
if($v->Subscriber->street != ''){
$address = $v->Subscriber->unit_no. ' , '.$v->Subscriber->building_name. ' , '.$v->Subscriber->street. ' , '.$v->Subscriber->postcode. ' , '.$v->Subscriber->city. ' , '.$v->Subscriber->state;
$building = $v->Subscriber->building_name;
}else {
$address = $v->Subscriber->unit_no. ' , '.$v->Subscriber->building_name. ' , '.$v->Subscriber->postcode. ' , '.$v->Subscriber->city. ' , '.$v->Subscriber->state;
$building = $v->Subscriber->building_name;
}
}else if($v->type_application == 'B'){

if($v->Subscriber->unit_no != ''){
$address = $v->Subscriber->unit_no. ', '.$v->Subscriber->company_name. ', '.$v->Subscriber->street. ' , '.$v->Subscriber->postcode. ' , '.$v->Subscriber->city. ' , '.$v->Subscriber->state;
$building = $v->Subscriber->company_name;
}else {
$address = $v->Subscriber->company_name. ', '.$v->Subscriber->street. ' , '.$v->Subscriber->postcode. ' , '.$v->Subscriber->city. ' , '.$v->Subscriber->state;
$building = $v->Subscriber->company_name;
}
}
}

if(!empty($v->deleted_at)){
$status = 'Rejected';
}else if($v->status_email == 'unverified') {
$status = 'New';
}else if($v->status_email == 'verified') {
$status = 'Accepted';
}

array_push($data, array(
'formT' => $n1.$i.$v->type_application,
'type' => $v->type_service,
'subscriber_id' => $v->Subscriber->subscriber_id,
'name' => $v->Subscriber->name,
'phone' => $v->Subscriber->phone1,
'email' => $v->Subscriber->email,
'address' => $address,
'postcode' => $v->Subscriber->postcode,
'city' => $v->Subscriber->city,
'status' => $status,
'date_submitted' => Carbon::parse($v->created_at)->toDateTimeString()
));
}
}

return $this->sendResponse($data, 'Get Customer List Successfully');

}else{
return $this->sendError('', 'No Data Been Found!');
}
}

public function customerStatistic(){

$finalD1 = array(); $finalD2 = array(); $finalD3 = array(); $finalD4 = array();
$form_submitted1 = Form::with('PackageDetail','Subscriber','WorkOrder')->withTrashed()->orderBy('created_at', 'desc')->get();
if(!empty($form_submitted1)){
foreach ($form_submitted1 as $key => $v) {
if(!empty($v->Subscriber)){
if(empty($v->WorkOrder)){
$finalD1[] = $v;
}
}
}
}

$form_submitted2= Form::onlyTrashed()->get();
if(!empty($form_submitted2)){
foreach ($form_submitted2 as $key => $v) {
if(!empty($v->Subscriber)){
if(empty($v->WorkOrder)){
$finalD2[] = $v;
}
}
}
}

$form_submitted3= Form::get();
if(!empty($form_submitted3)){
foreach ($form_submitted3 as $key => $v) {
if(!empty($v->Subscriber)){
if(empty($v->WorkOrder)){
if($v->status_email == 'verified') {
$finalD3[] = $v;
}else if($v->status_email == 'unverified'){
$finalD4[] = $v;
}
}
}
}
}

$total = count($finalD1);
$new = count($finalD4);
$reject = count($finalD2);
$accepted = count($finalD3);

$data = array();
$data[] = array("status" => "New", "statistic" => $new);
$data[] = array("status" => "Rejected", "statistic" => $reject);
$data[] = array("status" => "Accepted", "statistic" => $accepted);
$data[] = array("status" => "Total", "statistic" => $total);

return $this->sendResponse($data, 'Get Registration Statistic Successfully');

}
}

+ 289
- 0
app/Http/Controllers/Api/WorkOrderMobile.php Zobrazit soubor

@@ -0,0 +1,289 @@
<?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 App\Staff;
Use App\Model\StaffDetail;
use App\Model\Docket;
use App\Model\WorkOrder;
use App\Model\Company;
Use App\Model\Form;
Use App\Model\PackageDetail;
Use App\Model\Subscriber;
use App\Model\Question;


Use Hash;
use Carbon\Carbon;
use Crypt;
use File;
use Mail;

class WorkOrderMobile extends BaseController
{

function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}

/**
/* Schedule Function
**/
public function getSchedule(Request $request)
{
$data = array();
$loginUser = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
if(!empty($loginUser)) {
$schedule = WorkOrder::where('installer_id',$loginUser->_id)->where('status','Pending Installer')->get();
foreach($schedule as $b) {

array_push($data,array(
"Title" => $b->nature_work,
"Date"=>date("m/d/Y", strtotime($b->dateTimeStart)),
"Time"=>date("H:i", strtotime($b->dateTimeStart)),
"DateTimeStart"=>$b->dateTimeStart,
"DateTimeEnd"=>$b->dateTimeEnd,
"status" => $b->status,
));

}

return $this->sendResponse($data, 'Get Schedule Successfully');
}else {
return $this->sendError('Invalid User', 'User Not Exist!');
}
}

public function getWorkOrderDetail(Request $request){
$data = array();

$loginUser = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();

if(!empty($loginUser)) {

$wo = WorkOrder::where('installer_id',$loginUser->_id)->where('status','Pending Installer')->get();

if(!empty($wo)){
foreach($wo as $w){
$form = Form::with('Subscriber','PackageDetail')->where('_id',$w->_id)->first();
$company = Company::where('_id',$w->contractor_id)->first();
$address = '';
if($form->type_application == 'R'){
if($form->Subscriber->street != ''){
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}
}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$address = $form->Subscriber->unit_no. ', '.$form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}
}

$pp = ''; $noP = 'N/A'; $nP = '';

if($w->no_phone != ''){
$noP = $w->no_phone;
}

if($w->need_phone != ''){
$nP = $w->need_phone;
}

array_push($data,array(
"id" => $w->wo,
"formT" => $form->type_application,
"contractor_id" => $company->name,
"installer_id" => $loginUser->StaffDetail->name,
"title" => $w->nature_work,
"address"=> $address,
"imageUrl"=>'assets/activation_icon_nRead1.png',
"appoint_date"=>date("m/d/Y", strtotime($w->dateTimeStart)),
"appoint_time"=>date("H:i", strtotime($w->dateTimeStart)),
"cus_name"=> $form->Subscriber->name,
"contact_person" => $form->Subscriber->name,
"contact_no"=> $form->Subscriber->phone1,
"technical" => $form->Subscriber->name,
"status" => $w->status,
'pppoe' => $w->pppoe_username,
'package' => $form->PackageDetail->name,
'onu' => $w->onu,
'router' => $w->router,
'no_phone' => $noP,
'n_phone' => $nP,
"note" => $w->remarks_custservice,
));
}

return $this->sendResponse($data, 'Get Work Order Successfully');

}else {
return $this->sendResponse('', 'No Data');
}
}else {
return $this->sendError('Invalid User', 'User Not Exist!');
}
}

public function getDocketDetail(Request $request)
{

$data = array(); $installer = '';
$loginUser = Staff::with('StaffDetail')->where('api_token', $request->api_token)->where('roles_access','Installer')->first();
if(!empty($loginUser)) {

$docket = Docket::with('WorkOrder')->where('installer_id',$loginUser->_id)->where('docket_id', $request->docket_id)->first();
if(!empty($docket)){
$form = Form::with('PackageDetail','Subscriber')->where("_id",$docket->WorkOrder->_id)->first();
if(!empty($form)){

$company = Company::where('_id',$docket->WorkOrder->contractor_id)->first();
$staff = Staff::with('StaffDetail')->where('_id',$docket->installer_id)->first();
if(!empty($staff)){
$installer = $staff->StaffDetail->name;
}else{
$installer = '';
}

$address = '';
if($form->type_application == 'R'){
if($form->Subscriber->street != ''){
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}
}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$address = $form->Subscriber->unit_no. ', '.$form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}
}

$total =array($docket->Rating1, $docket->Rating2, $docket->Rating3);
$total_rating = array_sum($total);

$data = array(
// "contractor_id" => $company->name,
// "installer_id" => $installer,
// "customer_id" => $customer_id,
// "status" => $status,
"cus_name"=> $form->Subscriber->name,
"address"=> $address,
"contact_no"=> $form->Subscriber->phone1,
"technical" => $company->name,
"installer_name" => $installer,
"title" => $docket->nature_work,
"docket_id" => $docket->docket_id,
"wo_id" => $docket->work_order_id,
"status" => $docket->WorkOrder->status,
"start_datetime"=> $docket->WorkOrder->dateTimeStart,
"end_datetime" => $docket->end_job,
"cable_read" => $docket->cable_read,
"router" => $docket->router_serial_number,
"mac_router" => $docket->mac_router,
"condition" => $docket->condition,
"note" => $docket->Note,
"total_rating" => $total_rating,
);

return $this->sendResponse($data, 'Successfull Get Docket Detail');
}
}
}else {
return $this->sendError('Invalid User', 'User Not Exist!');
}
}

public function getDocket(Request $request)
{

$data = array();
$loginUser = Staff::with('StaffDetail')->where('api_token', $request->api_token)->where('roles_access','Installer')->first();
if(!empty($loginUser)) {

$docket = Docket::with('WorkOrder')->where('installer_id',$loginUser->_id)->get();
$company = Company::where('_id',$loginUser->StaffDetail->company_id)->first();

if(!empty($docket)){
foreach($docket as $a) {

$nw = '';
if(!empty($a->WorkOrder->nature_work)){
$nw = $a->WorkOrder->nature_work;
}

array_push($data,array(
"docket_id" => $a->docket_id,
"wo_id" => $a->work_order_id,
"contractor_id" => $company,
"installer_id" => $loginUser->StaffDetail->name,
"title" => $nw,
"imageUrl"=>'assets/activation_icon_nRead1.png',
"end_date"=>date("m/d/Y", strtotime($a->end_job)),
"end_time"=>date("H:i", strtotime($a->end_job)),
"cable_read" => $a->cable_read
));
}
return $this->sendResponse($data, 'Successfull');
}
}else {
return $this->sendError('Invalid User', 'User Not Exist!');
}
}

public function updateWorkOrder(Request $request){

$loginUser = Staff::with('StaffDetail')->where('api_token', $request->api_token)->where('roles_access','Installer')->first();
if(!empty($loginUser)) {

$wo = WorkOrder::where('wo',$request->nid)->first();
if(!empty($wo)){

$wo->remarks_installer = $request->postres.". ".$request->note;
$wo->status = $request->type;
$wo->save();

return $this->sendResponse('Success', 'Work Order '.$request->nid.' been update successfull');

}else{
return $this->sendError('Failed', 'Work Order Not Exist!');
}

}else {
return $this->sendError('Invalid User', 'User Not Exist!');
}
}

public function getQuestions(){

$question = Question::all();
if(!empty($question)) {
return $this->sendResponse($question, 'Get all questions successfull');
}else{
return $this->sendError('', 'No Questions!');
}
}
}

+ 122
- 0
app/Http/Controllers/Auth/AdminController.php Zobrazit soubor

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

namespace App\Http\Controllers\Auth;

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

use App\Staff;
use App\Model\StaffDetail;

Use Hash;
use Carbon\Carbon;
use Gate;

class AdminController extends Controller
{
//
public function get_guard(){
if(Auth::guard('contractor')->check())
{return "contractor";}
elseif(Auth::guard('cs')->check()){
{return "cs";}
}
elseif(Auth::guard('ms')->check())
{return "ms";}
}

public function showFormAdmin(){
return view('login_cs_co');
}

public function encryptPassword($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '28472B4B6250655368566D5970337336';
$secret_iv = md5(md5($string)); //'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if( $action == 'decrypt' ) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}

public function requestLoginAdmin(Request $request) {
$this->validate($request, [
'email' => 'required|email'
// 'password' => 'required|min:6'
]);
$user = '';
$roles_access = '';
if($request->roles == 'contractor'){
$roles_access = 'Contractor';
}else if($request->roles == 'customer-service'){
$roles_access = 'Customer Service';
}else if($request->roles == 'marketing'){
$roles_access = 'Marketing';
}

try {
$message = trans('messages.invalid_login_credentials');
$rememberMe = false;
$user = Staff::where('email', $request->email)->where('roles_access',$roles_access)->first();
if (!empty($user)) {
if($this->encryptPassword('encrypt', $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->save();

if($user->roles_access == "Contractor"){
Auth::guard('contractor')->loginUsingId($user->_id, $rememberMe);
return redirect('/contractor');
}
else if($user->roles_access == "Customer Service"){
Auth::guard('cs')->loginUsingId($user->_id, $rememberMe);
return redirect('/customer-service');
}else if($user->roles_access == "Developer"){
Auth::guard('cs')->loginUsingId($user->_id, $rememberMe);
return redirect('/customer-service');
}else if($user->roles_access == "Marketing"){
Auth::guard('ms')->loginUsingId($user->_id, $rememberMe);
return redirect('/marketing');
}
}
}
} catch (\Exception $e) {
Log::error(__CLASS__ . "::" . __METHOD__ . " " . $e->getMessage() . "on line" . $e->getLine());
}
return redirect('/login/dashboard/admin')->with('error_msg', $message);
}

public function requestlogout(){
// Get Current member id
$id = Auth::guard($this->get_guard())->id();

if (Auth::guard($this->get_guard())->check()) {
$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->save();
// Proceed to Log Out
Auth::guard($this->get_guard())->logout();
return redirect('/');
}
}
}

+ 32
- 0
app/Http/Controllers/Auth/ForgotPasswordController.php Zobrazit soubor

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

+ 118
- 0
app/Http/Controllers/Auth/LoginController.php Zobrazit soubor

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

namespace App\Http\Controllers\Auth;

use App\Dealer;
Use App\StaffLaravel;
Use Hash;
use Carbon\Carbon;
use Gate;

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

class LoginController extends Controller
{
//
public function get_guard(){
if(Auth::guard('ds')->check())
{return "ds";}
elseif(Auth::guard('agent')->check())
{return "agent";}
elseif(Auth::guard('ms')->check())
{return "ms";}
}

public function showFormStaff(){
return view('login');
}

public function encryptPassword($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '28472B4B6250655368566D5970337336';
$secret_iv = md5(md5($string)); //'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if( $action == 'decrypt' ) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}

public function requestLoginStaff(Request $request) {
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:6'
]);
$user = '';
try {
$message = trans('messages.invalid_login_credentials');
$rememberMe = false;
$user = Dealer::where('email', $request->email)->first();
if (!empty($user)) {
if($this->encryptPassword('encrypt', $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->password2 = Hash::make($request->password);
$user->save();

if($user->roles_access == "Dealer"){
Auth::guard('ds')->loginUsingId($user->_id, $rememberMe);
return redirect('/Dealer');
}else if($user->roles_access == "Sales"){
Auth::guard('agent')->loginUsingId($user->_id, $rememberMe);
return redirect('/sales');
}else if($user->roles_access == "Marketing"){
Auth::guard('ms')->loginUsingId($user->_id, $rememberMe);
return redirect('/Marketing');
}

}
}
} catch (\Exception $e) {
Log::error(__CLASS__ . "::" . __METHOD__ . " " . $e->getMessage() . "on line" . $e->getLine());
}
return redirect('/login/dashboard')->with('error_msg', $message);
}

public function logout(){
// Get Current member id
$id = Auth::guard($this->get_guard())->id();

if (Auth::guard($this->get_guard())->check()) {
$user = Dealer::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->save();
// Proceed to Log Out
Auth::guard($this->get_guard())->logout();
// return redirect('/login/dashboard');

return redirect('http://db.citybroadband.my');
}
}

public function hmmm() {
$output = $this->encryptPassword('encrypt', 'admin123');
dd($output);
}

}

+ 39
- 0
app/Http/Controllers/Auth/LoginController.php__ Zobrazit soubor

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

namespace App\Http\Controllers\Auth;

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

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.
|
*/

use AuthenticatesUsers;

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

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

+ 72
- 0
app/Http/Controllers/Auth/RegisterController.php Zobrazit soubor

@@ -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:6', '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 Zobrazit soubor

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

+ 112
- 0
app/Http/Controllers/Auth/StaffLoginController.php Zobrazit soubor

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

namespace App\Http\Controllers\Auth;

Use App\Staff;
Use App\Model\StaffDetail;
Use Hash;
use Carbon\Carbon;
use Gate;

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

class StaffLoginController extends Controller
{
//
public function get_guard(){
if(Auth::guard('ds')->check())
{return "ds";}
elseif(Auth::guard('agent')->check())
{return "agent";}
}

public function showFormStaff(){
return view('login');
}

public function encryptPassword($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '28472B4B6250655368566D5970337336';
$secret_iv = md5(md5($string)); //'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if( $action == 'decrypt' ) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}

public function requestLoginStaff(Request $request) {
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:5'
]);
$user = '';
try {
$message = trans('messages.invalid_login_credentials');
$rememberMe = false;
$user = Staff::where('email', $request->email)->where('roles_access','!=','Installer')->first();
if (!empty($user)) {
if($this->encryptPassword('encrypt', $request->password) == $user->password || $this->encryptPassword('encrypt', $request->password) == $user->password2){
// Update last_login & last ip
$user->last_login_at = Carbon::now(new \DateTimeZone('Asia/Kuala_Lumpur'))->toDateTimeString();
$user->last_login_ip = $request->getClientIp();
$user->save();

if($user->roles_access == "Dealer"){
Auth::guard('ds')->loginUsingId($user->_id, $rememberMe);
return redirect('/dealer');
}else if($user->roles_access == "Sales"){
Auth::guard('agent')->loginUsingId($user->_id, $rememberMe);
return redirect('/sales');
}

}
}
} catch (\Exception $e) {
Log::error(__CLASS__ . "::" . __METHOD__ . " " . $e->getMessage() . "on line" . $e->getLine());
}
return redirect('/login/dashboard/staff')->with('error_msg', $message);
}

public function requestlogout(){
// Get Current member id
$id = Auth::guard($this->get_guard())->id();

if (Auth::guard($this->get_guard())->check()) {
$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->save();
// Proceed to Log Out
Auth::guard($this->get_guard())->logout();
return redirect('/');
// return redirect('http://cbb.swisslink.com.my/v2/');

// return redirect('/login/dashboard/staff');
}
}

public function hmmm() {
$output = $this->encryptPassword('encrypt', 'admin123');
dd($output);
}

}

+ 41
- 0
app/Http/Controllers/Auth/VerificationController.php Zobrazit soubor

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

+ 151
- 0
app/Http/Controllers/Contractor/CalendarController.php Zobrazit soubor

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

namespace App\Http\Controllers\Contractor;

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

use Carbon\Carbon;
use Validator;
use PDF;

use App\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\WorkOrder;
use App\Model\PackageDetail;
use App\Model\Company;

class CalendarController extends Controller
{

public function viewContractorDashboard()
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
$ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
$cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());

$today = Carbon::today();

return view('contractor.view_dashboard', compact('user','pp','sp','rs','ss','cm','today'));
}

public function getAllCalendar(Request $request){

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$event = array(); $color = '';
$cuw = $request->wk;

if($request->status == ''){

$wo = WorkOrder::where('contractor_id',$user->StaffDetail->company_id)->get();
if(!empty($wo)){
foreach ($wo as $key => $w) {

if($w->wo == $cuw){
$color = '#5C2983';
}else if($w->wo != $cuw) {
if($w->status == "Completed") {
$color = '#00C853';
}else if($w->status == "Suspend") {
$color = '#DE006E';
}else if($w->status == "Reschedule") {
$color = '#FF6D00';
}else if($w->status == "Success Non Prelaid"){
$color = '#2962FF';
}else if($w->status == "Pending Non Prelaid"){
$color = '#FFD600';
}else if($w->status == "Pending Contractor") {
$color = '#6D4C41';
}else if($w->status == "Pending Installer"){
$color = '#546E7A';
}
}

array_push($event, array(
'id' => $w->wo,
'title' => $w->wo,
'start' => Carbon::createFromTimestamp(strtotime($w->dateTimeStart))->toRfc2822String(),
'end' => Carbon::createFromTimestamp(strtotime($w->dateTimeEnd))->toRfc2822String(),
'url' => url('/contractor/work-order/generate-pdf/'.$w->wo),
'color' => $color,
'allDay' => false
));
}
}

}else if($request->status != ''){

$wo = WorkOrder::where('status',$request->status)->where('contractor_id',$user->StaffDetail->company_id)->get();
if(!empty($wo)){
foreach ($wo as $key => $w) {

if($w->wo == $cuw){
$color = '#5C2983';
}else if($w->wo != $cuw) {
if($w->status == "Completed") {
$color = '#00C853';
}else if($w->status == "Suspend") {
$color = '#DE006E';
}else if($w->status == "Reschedule") {
$color = '#FF6D00';
}else if($w->status == "Success Non Prelaid"){
$color = '#2962FF';
}else if($w->status == "Pending Non Prelaid"){
$color = '#FFD600';
}else if($w->status == "Pending Contractor") {
$color = '#6D4C41';
}else if($w->status == "Pending Installer"){
$color = '#546E7A';
}
}

array_push($event, array(
'id' => $w->wo,
'title' => $w->wo,
'start' => Carbon::createFromTimestamp(strtotime($w->dateTimeStart))->toRfc2822String(),
'end' => Carbon::createFromTimestamp(strtotime($w->dateTimeEnd))->toRfc2822String(),
'url' => url('/contractor/work-order/generate-pdf/'.$w->wo),
'color' => $color,
'allDay' => false
));
}
}

}

return response()->json($event);
}

public function getCompanyColor(Request $request){

$datass = array();
$company = Company::where("_id",$request->company)->first();

if(!empty($company)){
array_push($datass, array(
'name' => '('.$company->name.')',
'bg' => $company->color,
'text' => '#fff'
));

}else {
array_push($datass, array(
'name' => '',
'bg' => '#fff',
'text' => '#5F5F5F'
));
}

return response()->json($datass);
}
}

+ 843
- 0
app/Http/Controllers/Contractor/ContractorController.php Zobrazit soubor

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

namespace App\Http\Controllers\Contractor;

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

use Carbon\Carbon;
use Validator;
use PDF;

use App\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\Coverage;
use App\Model\FormStatus;
use App\Model\WorkOrder;
use App\Model\Docket;
Use App\Model\DealerClaim;
use App\Model\Commission;
use App\Model\Company;

class ContractorController extends Controller
{

//
// public function get_guard(){
// if(Auth::guard('contractor')->check())
// {return "contractor";}
// }

// public function showFormDLogin(){
// return view('login_cs_co');
// }

public function encryptPassword($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '28472B4B6250655368566D5970337336';
$secret_iv = md5(md5($string)); //'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if( $action == 'decrypt' ) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}

// public function requestLogin(Request $request) {
// $this->validate($request, [
// 'email' => 'required|email'
// // 'password' => 'required|min:6'
// ]);
// $user = '';
// try {
// $message = trans('messages.invalid_login_credentials');
// $rememberMe = false;
// $user = StaffLaravel::where('email', $request->email)->where('roles_access','Contractor')->first();
// if (!empty($user)) {
// if($this->encryptPassword('encrypt', $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->save();

// if($user->roles_access == "Contractor"){
// Auth::guard('contractor')->loginUsingId($user->_id, $rememberMe);
// return redirect('/Contractor');
// }
// }
// }
// } catch (\Exception $e) {
// Log::error(__CLASS__ . "::" . __METHOD__ . " " . $e->getMessage() . "on line" . $e->getLine());
// }
// return redirect('/login/dashboard/admin')->with('error_msg', $message);
// }

// public function logout(){
// // Get Current member id
// $id = Auth::guard('contractor')->id();

// if (Auth::guard('contractor')->check()) {
// $user = StaffLaravel::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->save();
// // Proceed to Log Out
// Auth::guard('contractor')->logout();
// // return redirect('/login/dashboard');

// return redirect('http://cbblaravel.swisslink.com.my/login/dashboard/admin');
// }
// }

/************************************************************************************* Next Step *************************************************************************************/

public function viewContractorTeam()
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
$ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
$cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());

return view('contractor.view_team',compact('user','pp','sp','rs','ss','cm','pc','pi'));
}

public function viewEditContractorTeam($i_id)
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
$ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
$cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());

$staff = Staff::with('StaffDetail')->where('_id',$i_id)->first();

return view('contractor.edit_contractor',compact('user','pp','sp','rs','ss','cm','pc','pi','staff'));
}

public function getContractorWork()
{

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetailLaravel')->find($id);
$curr = Carbon::now()->getTimestamp();

$work_detail= WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->get();

$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
return \DataTables::of($nested_data)->make(true);
}

public function filterContractorWork($year, $month, $status)
{

$id = Auth::guard('contractor')->id();
$user = StaffLaravel::with('StaffDetailLaravel')->find($id);
$curr = Carbon::now()->getTimestamp();

if($year == 'null' && $month == 'null' & $status !='null')
{
$nested_data = array();
$work_detail = WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->where('status', $status)->get();
$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
}

if($year=='null' && $month == 'null' & $status == 'null')
{
$nested_data = array();
$work_detail = WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->get();
$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
}

if($year!='null' && $month!='nulll' && $status !='null')
{
$nested_data = array();
$start_month = $year."-".$month."-01 00:00:00";
$end_month = $year."-".$month."-32 23:59:59";

$work_detail = WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->whereBetween('dateTimeStart', [$start_month, $end_month])->where('status',$status)->get();
$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
}

if($year!='null' && $month!='null' && $status =='null')
{
$nested_data = array();
$start_month = $year."-".$month."-01 00:00:00";
$end_month = $year."-".$month."-32 23:59:59";

$work_detail = WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->whereBetween('dateTimeStart', [$start_month, $end_month])->get();
$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
}

return \DataTables::of($nested_data)->make(true);
}

public function filterContractorDocket($year, $month)
{
$year = $year;
$month = $month;
$nested_data = array();
$arr = array();
$i=0;

if($year=='null' && $month=='null')
{
$docket= DocketLaravel::orderBy('created_at', 'desc')->get();

if(!empty($docket))
{
foreach ($docket as $a)
{
$customer = Subscriber::where('_id', $a->customer_id)->first();
$business = Business::where('_id', $a->customer_id)->first();

if(!empty($customer))
{
$arr[]=$a;
}

if(!empty($business))
{
$arr[]=$a;
}
}
}

foreach($arr as $b)
{
$i++; $n1 = '';

$tempContractor = CompanyLaravel::where('_id', $b->contractor_id)->first();
$contractor = $tempContractor->name;

$tempInstaller = StaffDetailLaravel::where('_id', $b->installer_id)->first();

$tempCustomer = Subscriber::where('_id', $b->customer_id)->first();
$tempBusiness = Business::where('_id', $b->customer_id)->first();

if(!empty($tempCustomer))
{
$building = $tempCustomer->building;
}
else
{
$building = $tempBusiness->company_name;
}

if(!empty($tempInstaller))
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $b->docket_id,
'work_order_id' => $b->work_order_id,
'nature_work' => $b->nature_work,
'contractor_id' => $contractor,
'installer_name' => $tempInstaller->name,
'customer_id' => $building,
'installer_id' => $tempInstaller->phone,
'end_job' => $b->end_job,
'rating' => $b->Rating1
));
}
else
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $a->docket_id,
'work_order_id' => $a->work_order_id,
'nature_work' => $a->nature_work,
'contractor_id' => $contractor,
'installer_name' => '',
'customer_id' => $building,
'installer_id' => '',
'end_job' => $a->end_job,
'rating' => $a->Rating1
));
}
}
}

elseif($year!='' && $month=='null')
{
$timestamp = $year."-01-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfYear();
// $time = Carbon::createFromTimeString($timestamp);
// echo $month;

$docket = DocketLaravel::whereBetween('created_at', [$go, $end_year])->get();
if(!empty($docket))
{
foreach ($docket as $a)
{
$customer = Subscriber::where('_id', $a->customer_id)->first();
$business = Business::where('_id', $a->customer_id)->first();

if(!empty($customer))
{
$arr[]=$a;
}

if(!empty($business))
{
$arr[]=$a;
}
}
}

foreach($arr as $b)
{
$i++; $n1 = '';

$tempContractor = CompanyLaravel::where('_id', $b->contractor_id)->first();
$contractor = $tempContractor->name;

$tempInstaller = StaffDetailLaravel::where('_id', $b->installer_id)->first();

$tempCustomer = Subscriber::where('_id', $b->customer_id)->first();
$tempBusiness = Business::where('_id', $b->customer_id)->first();

if(!empty($tempCustomer))
{
$building = $tempCustomer->building;
}
else
{
$building = $tempBusiness->company_name;
}

if(!empty($tempInstaller))
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $b->docket_id,
'work_order_id' => $b->work_order_id,
'nature_work' => $b->nature_work,
'contractor_id' => $contractor,
'installer_name' => $tempInstaller->name,
'customer_id' => $building,
'installer_id' => $tempInstaller->phone,
'end_job' => $b->end_job,
'rating' => $b->Rating1
));
}
else
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $a->docket_id,
'work_order_id' => $a->work_order_id,
'nature_work' => $a->nature_work,
'contractor_id' => $contractor,
'installer_name' => '',
'customer_id' => $building,
'installer_id' => '',
'end_job' => $a->end_job,
'rating' => $a->Rating1
));
}
}
}

elseif($year!='' && $month !='')
{
$timestamp = $year."-".$month."-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfMonth();
// $time = Carbon::createFromTimeString($timestamp);

$docket = DocketLaravel::whereBetween('created_at', [$go, $end_year])->get();
if(!empty($docket))
{
foreach ($docket as $a)
{
$customer = Subscriber::where('_id', $a->customer_id)->first();
$business = Business::where('_id', $a->customer_id)->first();

if(!empty($customer))
{
$arr[]=$a;
}

if(!empty($business))
{
$arr[]=$a;
}
}
}

foreach($arr as $b)
{
$i++; $n1 = '';

$tempContractor = CompanyLaravel::where('_id', $b->contractor_id)->first();
$contractor = $tempContractor->name;

$tempInstaller = StaffDetailLaravel::where('_id', $b->installer_id)->first();

$tempCustomer = Subscriber::where('_id', $b->customer_id)->first();
$tempBusiness = Business::where('_id', $b->customer_id)->first();

if(!empty($tempCustomer))
{
$building = $tempCustomer->building;
}
else
{
$building = $tempBusiness->company_name;
}

if(!empty($tempInstaller))
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $b->docket_id,
'work_order_id' => $b->work_order_id,
'nature_work' => $b->nature_work,
'contractor_id' => $contractor,
'installer_name' => $tempInstaller->name,
'customer_id' => $building,
'installer_id' => $tempInstaller->phone,
'end_job' => $b->end_job,
'rating' => $b->Rating1
));
}
// else
// {
// array_push($nested_data, array(
// 'index' => $n1.$i,
// 'docket_id' => $a->docket_id,
// 'work_order_id' => $a->work_order_id,
// 'nature_work' => $a->nature_work,
// 'contractor_id' => $contractor,
// 'installer_name' => '',
// 'customer_id' => $building,
// 'installer_id' => '',
// 'end_job' => $a->end_job,
// 'rating' => $a->Rating1
// ));
// }
}
}

return \DataTables::of($nested_data)->make(true);
}

public function getContractorTeam()
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);
$agent = Staff::with('Company','StaffDetail')->where('roles_access','Installer')->orderBy('updated_at','desc')->get();
$i = 0;
$nested_data = array();
$curr = Carbon::now()->getTimestamp();
foreach ($agent 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/";
}

if($a->company_id == $user->StaffDetail->company_id){
array_push($nested_data, array(
'index' => $n1.$i,
'user_pic' => $a->StaffDetail->user_pic,
'name' => $a->StaffDetail->name,
'ic' => $a->StaffDetail->ic,
'email' => $a->StaffDetail->email,
'phone' => $a->StaffDetail->phone,
'company_id' => $a->Company->name,
'position' => $a->StaffDetail->position,
'action' => $a->_id
));

}
$i++;
}
return \DataTables::of($nested_data)->make(true);
}
public function addContractorTeam()
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
$ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
$cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());

return view('contractor.add_contractor',compact('user','pp','sp','rs','ss','cm','pc','pi'));
}

public function requestAddContractorTeam(Request $request)
{
$validator = Validator::make($request->all(), [
'password' => 'min:8|confirmed',
]);

if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}

$staff = Staff::where('email', $request->get('email'))->first();
if(empty($staff))
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pass = $this->encryptPassword('encrypt', $request->get('password'));

$dealerD = new StaffDetail;
$dealerD->name = $request->get('aname');
$dealerD->ic = $request->get('ic');
$dealerD->email = $request->get('email');
$dealerD->phone = $request->get('phone');
$dealerD->company_id = $user->StaffDetail->company_id;
$dealerD->color = '';
$dealerD->position = 'Installer';
$dealerD->password = $pass;
$dealerD->user_pic = 'assets/avatar/user.png';

// Save Login Dealer
$loginD = new Staff;
$loginD->email = $request->get('email');
$loginD->password = $pass;
$loginD->roles_access = 'Installer';
$loginD->company_id = $user->StaffDetail->company_id;
$loginD->last_login_at = '';
$loginD->last_login_ip = '';

// $loginData = [
// 'email' => $request->get('email'),
// 'password' => $pass,
// 'roles_access' => 'Sales',
// 'last_login_at' => '',
// 'last_login_ip' => '',
// ];

$company = Company::where('_id', $user->StaffDetail->company_id)->first();
$company->staff()->save($loginD);
$loginD->staffdetail()->save($dealerD);

return redirect()->back()->with('success_msg', '<strong>Success!</strong> register <strong>'.$request->get('email').'</strong>');
}
else
{
return redirect()->back()->withInput()->withErrors('Email already exist!');
}
}

public function requestEditInstaller(Request $request)
{

$staff = Staff::with('StaffDetail')->where('_id', $request->get('_id'))->first();

if(!empty($staff))
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

if($request->get('password') != ''){

$validator = Validator::make($request->all(), [
'password' => 'min:8',
]);

if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
$pass = $this->encryptPassword('encrypt', $request->get('password'));
$staff->email = $request->get('email');
$staff->password = $pass;
$staff->save();

$staff->StaffDetail->name = $request->get('aname');
$staff->StaffDetail->ic = $request->get('ic');
$staff->StaffDetail->email = $request->get('email');
$staff->StaffDetail->phone = $request->get('phone');
$staff->StaffDetail->save();

return redirect()->back()->with('success_msg', '<strong>Success!</strong> register <strong>'.$request->get('email').'</strong>');

}else {

$staff->email = $request->get('email');
$staff->save();

$staff->StaffDetail->name = $request->get('aname');
$staff->StaffDetail->ic = $request->get('ic');
$staff->StaffDetail->email = $request->get('email');
$staff->StaffDetail->phone = $request->get('phone');
$staff->StaffDetail->save();

return redirect()->back()->with('success_msg', '<strong>Success!</strong> register <strong>'.$request->get('email').'</strong>');
}

}
else
{
return redirect()->back()->withInput()->withErrors('Email already exist!');
}
}

public function deleteInstaller(Request $request){

$staff = Staff::where('_id',$request->id)->first();
if(!empty($staff)){
$st = StaffDetail::where('email',$staff->email)->first();
if(!empty($st)){
$st->delete();
$staff->delete();
return 'true';
}
}else {
return 'false';
}
}
}

+ 821
- 0
app/Http/Controllers/Contractor/DocketController.php Zobrazit soubor

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

namespace App\Http\Controllers\Contractor;

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

use Carbon\Carbon;
use Validator;
use PDF;

use App\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\Coverage;
use App\Model\FormStatus;
use App\Model\WorkOrder;
use App\Model\Docket;
Use App\Model\DealerClaim;
use App\Model\Commission;
use App\Model\Company;
use App\Model\Product;

class DocketController extends Controller
{

public function encryptPassword($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '28472B4B6250655368566D5970337336';
$secret_iv = md5(md5($string)); //'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if( $action == 'decrypt' ) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}

/************************************************************************************* Next Step *************************************************************************************/


public function viewContractorDocket()
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
$ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
$cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());

$installer = StaffDetail::where('company_id',$user->StaffDetail->company_id)->get();

return view('contractor.view_docket',compact('user','pp','sp','rs','ss','cm'));
}

public function viewContractorTeam()
{
$id = Auth::guard('contractor')->id();
$user = StaffLaravel::with('StaffDetailLaravel')->find($id);

return view('contractor.view_team',compact('user'));
}

public function getContractorWork()
{

$id = Auth::guard('contractor')->id();
$user = StaffLaravel::with('StaffDetailLaravel')->find($id);
$curr = Carbon::now()->getTimestamp();

$work_detail= WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->get();

$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
return \DataTables::of($nested_data)->make(true);
}

public function filterContractorWork($year, $month, $status)
{

$id = Auth::guard('contractor')->id();
$user = StaffLaravel::with('StaffDetailLaravel')->find($id);
$curr = Carbon::now()->getTimestamp();

if($year == 'null' && $month == 'null' & $status !='null')
{
$nested_data = array();
$work_detail = WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->where('status', $status)->get();
$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
}

if($year=='null' && $month == 'null' & $status == 'null')
{
$nested_data = array();
$work_detail = WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->get();
$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
}

if($year!='null' && $month!='nulll' && $status !='null')
{
$nested_data = array();
$start_month = $year."-".$month."-01 00:00:00";
$end_month = $year."-".$month."-32 23:59:59";

$work_detail = WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->whereBetween('dateTimeStart', [$start_month, $end_month])->where('status',$status)->get();
$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
}

if($year!='null' && $month!='null' && $status =='null')
{
$nested_data = array();
$start_month = $year."-".$month."-01 00:00:00";
$end_month = $year."-".$month."-32 23:59:59";

$work_detail = WorkOrderLaravel::with('FormLaravel')->where('contractor_id',$user->StaffDetailLaravel->company_id)->orderBy('dateTimeStart', 'desc')->whereBetween('dateTimeStart', [$start_month, $end_month])->get();
$i = 0;
$nested_data = array();
if(!empty($work_detail)){
foreach ($work_detail as $a)
{
$i++; $y = ''; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$formDetail = FormLaravel::with('SubscribersLaravel','PackageDetailLaravel')->first();
$installer = StaffDetailLaravel::where('_id', $a->installer_id)->where('position','Installer')->first();
$contractor = CompanyLaravel::where('_id', $a->contractor_id)->first();

$inst_name = '';
if(!empty($installer)){
$inst_name = $installer->name;
}

array_push($nested_data, array(
'index' => $i.$n1,
'nature_work' => $a->nature_work,
'wo'=>$a->wo,
'customer_name' => $formDetail->SubscribersLaravel->name,
'customer_phone' => $formDetail->SubscribersLaravel->phone1,
'customer_unit' => $formDetail->SubscribersLaravel->unit_no,
'customer_building' => $formDetail->SubscribersLaravel->building_name,
'customer_postcode' => $formDetail->SubscribersLaravel->postcode,
'customer_city' => $formDetail->SubscribersLaravel->city,
'contractor_id' => $contractor->name,
'installer_id' => $inst_name,
'dateTimeEnd' => $a->dateTimeEnd,
'status' => $a->status,
'action' => $a->id,
));
}
}
}

return \DataTables::of($nested_data)->make(true);
}

public function getContractorDocket($year,$month,$day)
{

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

if($year == 'null' && $month == 'null' && $day == 'null'){
$docket= Docket::with('WorkOrder')->orderBy('created_at', 'desc')->get();
}else if($year != 'null' && $month == 'null' && $day == 'null'){

$timestamp = $year."-01-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfYear();

$docket = Docket::with('WorkOrder')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();

}else if($year != 'null' && $month != 'null' && $day == 'null'){

$timestamp = $year."-".$month."-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfMonth();

$docket = Docket::with('WorkOrder')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
}

$i = 0; $n1 = ''; $building = '';
$curr = Carbon::now()->getTimestamp();
$tempD = array();
$nested_data = array();
if(!empty($docket)){
foreach($docket as $d){

if(!empty($d->WorkOrder->_id)){
if($d->WorkOrder->contractor_id == $user->StaffDetail->company_id){
$i++;
$form = Form::with('Subscriber','PackageDetail')->where('_id',$d->WorkOrder->_id)->first();
$company = Company::where('_id', $d->WorkOrder->contractor_id)->first();
$installer = Staff::with('StaffDetail')->withTrashed()->where('_id', $d->installer_id)->first();

if($form->type_application == 'R'){
$building = $form->Subscriber->building_name;
}else if($form->type_application == 'B'){
$building = $form->Subscriber->company_name;
}

$reg_time = $d->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

array_push($tempD, array(
'index' => $n1.$i,
'docket_id' => $d->docket_id,
'work_order_id' => $d->work_order_id,
'nature_work' => $d->nature_work,
'contractor_id' => $company->name,
'installer_name' => $installer->StaffDetail->name,
'customer_id' => $building,
'installer_id' => $installer->StaffDetail->phone,
'end_job' => date('d/m/Y H:i', strtotime($d->end_job)),
'rating' => round((($d->Rating1 + $d->Rating2 + $d->Rating3)/15) * 100)."%",
'action' => $d->docket_id.'/'.$d->work_order_id
));
}
}
}
}

foreach($tempD as $t){
array_push($nested_data, array(
'index' => $t['index'],
'docket_id' => $t['docket_id'],
'work_order_id' => $t['work_order_id'],
'nature_work' => $t['nature_work'],
'contractor_id' => $t['contractor_id'],
'installer_name' => $t['installer_name'],
'customer_id' => $t['customer_id'],
'installer_id' => $t['installer_id'],
'end_job' => $t['end_job'],
'rating' =>$t['rating'],
'action' =>$t['action'],
));
}

return \DataTables::of($nested_data)->make(true);
}

public function filterContractorDocket($year, $month)
{
$year = $year;
$month = $month;
$nested_data = array();
$arr = array();
$i=0;

if($year=='null' && $month=='null')
{
$docket= DocketLaravel::orderBy('created_at', 'desc')->get();

if(!empty($docket))
{
foreach ($docket as $a)
{
$customer = Subscriber::where('_id', $a->customer_id)->first();
$business = Business::where('_id', $a->customer_id)->first();

if(!empty($customer))
{
$arr[]=$a;
}

if(!empty($business))
{
$arr[]=$a;
}
}
}

foreach($arr as $b)
{
$i++; $n1 = '';

$tempContractor = CompanyLaravel::where('_id', $b->contractor_id)->first();
$contractor = $tempContractor->name;

$tempInstaller = StaffDetailLaravel::where('_id', $b->installer_id)->first();

$tempCustomer = Subscriber::where('_id', $b->customer_id)->first();
$tempBusiness = Business::where('_id', $b->customer_id)->first();

if(!empty($tempCustomer))
{
$building = $tempCustomer->building;
}
else
{
$building = $tempBusiness->company_name;
}

if(!empty($tempInstaller))
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $b->docket_id,
'work_order_id' => $b->work_order_id,
'nature_work' => $b->nature_work,
'contractor_id' => $contractor,
'installer_name' => $tempInstaller->name,
'customer_id' => $building,
'installer_id' => $tempInstaller->phone,
'end_job' => $b->end_job,
'rating' => $b->Rating1
));
}
else
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $a->docket_id,
'work_order_id' => $a->work_order_id,
'nature_work' => $a->nature_work,
'contractor_id' => $contractor,
'installer_name' => '',
'customer_id' => $building,
'installer_id' => '',
'end_job' => $a->end_job,
'rating' => $a->Rating1
));
}
}
}

elseif($year!='' && $month=='null')
{
$timestamp = $year."-01-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfYear();
// $time = Carbon::createFromTimeString($timestamp);
// echo $month;

$docket = DocketLaravel::whereBetween('created_at', [$go, $end_year])->get();
if(!empty($docket))
{
foreach ($docket as $a)
{
$customer = Subscriber::where('_id', $a->customer_id)->first();
$business = Business::where('_id', $a->customer_id)->first();

if(!empty($customer))
{
$arr[]=$a;
}

if(!empty($business))
{
$arr[]=$a;
}
}
}

foreach($arr as $b)
{
$i++; $n1 = '';

$tempContractor = CompanyLaravel::where('_id', $b->contractor_id)->first();
$contractor = $tempContractor->name;

$tempInstaller = StaffDetailLaravel::where('_id', $b->installer_id)->first();

$tempCustomer = Subscriber::where('_id', $b->customer_id)->first();
$tempBusiness = Business::where('_id', $b->customer_id)->first();

if(!empty($tempCustomer))
{
$building = $tempCustomer->building;
}
else
{
$building = $tempBusiness->company_name;
}

if(!empty($tempInstaller))
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $b->docket_id,
'work_order_id' => $b->work_order_id,
'nature_work' => $b->nature_work,
'contractor_id' => $contractor,
'installer_name' => $tempInstaller->name,
'customer_id' => $building,
'installer_id' => $tempInstaller->phone,
'end_job' => $b->end_job,
'rating' => $b->Rating1
));
}
else
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $a->docket_id,
'work_order_id' => $a->work_order_id,
'nature_work' => $a->nature_work,
'contractor_id' => $contractor,
'installer_name' => '',
'customer_id' => $building,
'installer_id' => '',
'end_job' => $a->end_job,
'rating' => $a->Rating1
));
}
}
}

elseif($year!='' && $month !='')
{
$timestamp = $year."-".$month."-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfMonth();
// $time = Carbon::createFromTimeString($timestamp);

$docket = DocketLaravel::whereBetween('created_at', [$go, $end_year])->get();
if(!empty($docket))
{
foreach ($docket as $a)
{
$customer = Subscriber::where('_id', $a->customer_id)->first();
$business = Business::where('_id', $a->customer_id)->first();

if(!empty($customer))
{
$arr[]=$a;
}

if(!empty($business))
{
$arr[]=$a;
}
}
}

foreach($arr as $b)
{
$i++; $n1 = '';

$tempContractor = CompanyLaravel::where('_id', $b->contractor_id)->first();
$contractor = $tempContractor->name;

$tempInstaller = StaffDetailLaravel::where('_id', $b->installer_id)->first();

$tempCustomer = Subscriber::where('_id', $b->customer_id)->first();
$tempBusiness = Business::where('_id', $b->customer_id)->first();

if(!empty($tempCustomer))
{
$building = $tempCustomer->building;
}
else
{
$building = $tempBusiness->company_name;
}

if(!empty($tempInstaller))
{
array_push($nested_data, array(
'index' => $n1.$i,
'docket_id' => $b->docket_id,
'work_order_id' => $b->work_order_id,
'nature_work' => $b->nature_work,
'contractor_id' => $contractor,
'installer_name' => $tempInstaller->name,
'customer_id' => $building,
'installer_id' => $tempInstaller->phone,
'end_job' => $b->end_job,
'rating' => $b->Rating1
));
}
// else
// {
// array_push($nested_data, array(
// 'index' => $n1.$i,
// 'docket_id' => $a->docket_id,
// 'work_order_id' => $a->work_order_id,
// 'nature_work' => $a->nature_work,
// 'contractor_id' => $contractor,
// 'installer_name' => '',
// 'customer_id' => $building,
// 'installer_id' => '',
// 'end_job' => $a->end_job,
// 'rating' => $a->Rating1
// ));
// }
}
}

return \DataTables::of($nested_data)->make(true);
}

public function getContractorTeam()
{
$id = Auth::guard('contractor')->id();
$user = StaffLaravel::with('StaffDetailLaravel')->find($id);
$agent = StaffLaravel::with('CompanyLaravel','StaffDetailLaravel')->where('roles_access','Installer')->get();
$i = 0;
$nested_data = array();
foreach ($agent as $a)
{
$i++; $n1 = '';
if($a->company_id == $user->StaffDetailLaravel->company_id){
array_push($nested_data, array(
'index' => $n1.$i,
'user_pic' => $a->StaffDetailLaravel->user_pic,
'name' => $a->StaffDetailLaravel->name,
'ic' => $a->StaffDetailLaravel->ic,
'email' => $a->StaffDetailLaravel->email,
'phone' => $a->StaffDetailLaravel->phone,
'company_id' => $a->CompanyLaravel->name,
'position' => $a->StaffDetailLaravel->position,
'action' => $a->_id
));

}
}
return \DataTables::of($nested_data)->make(true);
}
public function addContractorTeam()
{
return view('contractor.add_contractor');
}

public function requestAddContractorTeam(Request $request)
{
$validator = Validator::make($request->all(), [
'password' => 'min:8|confirmed',
]);

if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}

$user = StaffLaravel::where('email', $request->get('email'))->first();
if(empty($user))
{
$pass = $this->encryptPassword('encrypt', $request->get('password'));

$dealerD = new StaffDetailLaravel;
$dealerD->name = $request->get('aname');
$dealerD->ic = $request->get('ic');
$dealerD->email = $request->get('email');
$dealerD->phone = $request->get('phone');
$dealerD->company_id = $request->get('vendor');
$dealerD->color = '';
$dealerD->position = 'Installer';
$dealerD->password = $pass;
$dealerD->user_pic = 'assets/avatar/user.png';

// Save Login Dealer
$loginD = new StaffLaravel;
$loginD->email = $request->get('email');
$loginD->password = $pass;
$loginD->roles_access = 'Installer';
$loginD->company_id = $request->get('vendor');
$loginD->last_login_at = '';
$loginD->last_login_ip = '';

// $loginData = [
// 'email' => $request->get('email'),
// 'password' => $pass,
// 'roles_access' => 'Sales',
// 'last_login_at' => '',
// 'last_login_ip' => '',
// ];

$company = CompanyLaravel::where('_id', $request->get('vendor'))->first();
$company->stafflaravel()->save($loginD);
$loginD->staffdetaillaravel()->save($dealerD);

return redirect()->back()->with('success_msg', '<strong>Success!</strong> register <strong>'.$request->get('email').'</strong>');
}
else
{
return redirect()->back()->withInput()->withErrors('Email already exist!');
}
}

public function generateDocketPDF($do)
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);
$docket = Docket::with('WorkOrder')->where('docket_id',$do)->first();
if(!empty($docket)){
$form = Form::with('Subscriber','PackageDetail')->where('_id',$docket->WorkOrder->_id)->first();

$address = '';
if($form->type_application == 'R'){
if($form->Subscriber->street != ''){
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}

}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$address = $form->Subscriber->unit_no. ', '.$form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}

}

$product = Product::where('formT',$form->type_application)->where('speed',$form->PackageDetail->name)->first();
$installer = Staff::with('StaffDetail')->where('_id',$docket->installer_id)->withTrashed()->first();

if(empty($product)){
$product = 'RMbps';
}else {
$product = $product->package_name;
}

$dateTime = Carbon::parse($docket->WorkOrder->dateTimeStart)->toDateTimeString();
$edateTime = Carbon::parse($docket->end_job)->toDateTimeString();

$pdf = PDF::loadView('pdf.docket-pdf',compact('docket','form','address','product','installer','dateTime','edateTime'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}
}
}

+ 766
- 0
app/Http/Controllers/Contractor/WorkOrderController.php Zobrazit soubor

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

namespace App\Http\Controllers\Contractor;

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

use Carbon\Carbon;
use Validator;
use PDF;

use App\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\WorkOrder;
use App\Model\PackageDetail;
use App\Model\Company;
use App\Model\Coverage;
use App\Model\Product;
use App\Model\Docket;
use App\Model\FormStatus;

class WorkOrderController extends Controller
{

function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}

function createWorkID($limit){
$allowedNumbers = range(0, 9);
shuffle($allowedNumbers);
$digits = array_rand($allowedNumbers, $limit);
$number = '';
foreach($digits as $d){
$number .= $allowedNumbers[$d];
}
$unique_id = $number;
return $unique_id;
}

public function viewContractorWork()
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
$ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
$cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());

$pc = count(WorkOrder::where('status','Pending Contractor')->where('contractor_id',$user->StaffDetail->company_id)->get());
$pi = count(WorkOrder::where('status','Pending Installer')->where('contractor_id',$user->StaffDetail->company_id)->get());

return view('contractor.view_wo', compact('user','pp','sp','rs','ss','cm','pc','pi'));
}

public function editContractorWork($wo)
{
$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
$ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
$cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());

$w = WorkOrder::where('wo',$wo)->first();
$form = Form::with('Subscriber','WorkOrder')->where('_id',$w->_id)->first();
$coverage = Coverage::all();

$installer = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
if(empty($installer)){
$installer = '';
}else {
$installer = $installer->StaffDetail->name;
}

$company = Company::where('_id',$w->contractor_id)->first();

return view('contractor.edit_wo', compact('user','pp','sp','rs','ss','cm','pc','pi','form','coverage','installer','company'));
}

public function updateCustomerDetail(Request $request){
$form = Subscriber::with('Form')->where('subscriber_id',$request->subscriber_id)->first();

$phone = ''; $street = ''; $fax = '';
if($request->phone2 != null){
$phone = $request->phone2;
}

if($form->Form->type_application == 'R'){

if($request->street != null){
$street = $request->street;
}

$cov = Coverage::where('building_name',$request->building)->first();

$form->name = $request->name;
$form->ic = $request->ic;
$form->email = $request->email;
$form->phone1 = $request->phone1;
$form->phone2 = $phone;
$form->unit_no = $request->unit_no;
$form->building_name = $cov->building_name;
$form->street = $street;
$form->city = $cov->city;
$form->postcode = $cov->postcode;
$form->state = $cov->state;
$form->save();

return redirect()->back()->with('success_msg', 'Success! Update customer '.$request->get('name'));

}else if($form->Form->type_application == 'B'){

if($request->company_fax != null){
$fax = $request->company_fax;
}

$form->company_reg = $request->company_reg;
$form->company_num = $request->company_num;
$form->company_fax = $fax;
$form->company_name = $request->company_name;
$form->unit_no = $request->unit_no;
$form->street = $request->address;
$form->city = $request->city;
$form->postcode = $request->postcode;
$form->state = $request->state;

$form->name = $request->name;
$form->ic = $request->ic;
$form->designation = $request->designation;
$form->email = $request->email;
$form->phone1 = $request->phone1;
$form->phone2 = $phone;
$form->save();

return redirect()->back()->with('success_msg', 'Success! Update customer '.$request->get('name'));
}
}


public function viewRescheduleCalendar($wo){

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
$rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
$ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
$cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());

$installer = StaffDetail::where('company_id',$user->StaffDetail->company_id)->where('position','Installer')->get();
$today = Carbon::today();

return view('contractor.reschedule_work_order', compact('user','pp','sp','rs','ss','cm','company','wo','today','installer'));
}

public function getAllPendingContractor($year,$month,$day){

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$i = 0; $n1 = '';
$curr = Carbon::now()->getTimestamp();
$nested_data = array();

if($month == 'null' && $day == 'null'){
$wo = WorkOrder::with('Form')->where('status','Pending Contractor')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->get();
}else if($year != 'null' && $month == 'null' && $day == 'null'){

$timestamp = $year."-01-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfYear();

$wo = WorkOrder::with('Form')->where('status','Pending Contractor')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();

}else if($year != 'null' && $month != 'null' && $day == 'null'){

$timestamp = $year."-".$month."-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfMonth();

$wo = WorkOrder::with('Form')->where('status','Pending Contractor')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
}

if(!empty($wo)){
foreach ($wo as $key => $w) {
$i++;

$n1 = '';
$reg_time = $w->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$installer = '';
$form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
$product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
$company = Company::where('_id',$w->contractor_id)->first();

$building = ''; $unit = '-'; $name = '';
if($form->type_application == 'R'){
$building = $form->Subscriber->building_name;
$unit = $form->Subscriber->unit_no;
$name = $form->Subscriber->name;

}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$unit = '-';
}else {
$unit = $form->Subscriber->unit_no;
}

$building = '-';
$name = $form->Subscriber->company_name;

}

if($w->installer_id != ''){
$installer = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
$installer = $installer->StaffDetail->name;
}

if(empty($product)){
$product = 'R Mbps';
}else {
$product = $product->package_name;
}

array_push($nested_data, array(
'formT' => $n1.$i.$w->Form->type_application,
'service' => $w->nature_work,
'wo' => $w->wo,
'name' => $name,
'phone' => $form->Subscriber->phone1,
'unit' => $unit,
'building' => $building,
'city' => $form->Subscriber->city,
'package' => $product,
'contractor' => $company->name,
'installer' => $installer,
'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
'time' => date("h:i A", strtotime($w->dateTimeStart)),
'status' => $w->status,
'action' => $w->wo,
));
}
}

return \DataTables::of($nested_data)->make(true);
}

public function getAllPendingNonPrelaid($year,$month,$day){

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$i = 0; $n1 = '';
$curr = Carbon::now()->getTimestamp();
$nested_data = array();

if($year == 'null' && $month == 'null' && $day == 'null'){
$wo = WorkOrder::with('Form')->where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->get();
}else if($year != 'null' && $month == 'null' && $day == 'null'){

$timestamp = $year."-01-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfYear();

$wo = WorkOrder::with('Form')->where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();

}else if($year != 'null' && $month != 'null' && $day == 'null'){

$timestamp = $year."-".$month."-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfMonth();

$wo = WorkOrder::with('Form')->where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
}

if(!empty($wo)){
foreach ($wo as $key => $w) {
$i++;

$n1 = '';
$reg_time = $w->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$installer = '';
$form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
$product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
$company = Company::where('_id',$w->contractor_id)->first();

if($w->installer_id != ''){
$installer = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
if(!empty($installer)){
$installer = $installer->StaffDetail->name;
}
}

$building = ''; $unit = '-'; $name = '';
if($form->type_application == 'R'){
$building = $form->Subscriber->building_name;
$unit = $form->Subscriber->unit_no;
$name = $form->Subscriber->name;

}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$unit = '-';
}else {
$unit = $form->Subscriber->unit_no;
}

$building = '-';
$name = $form->Subscriber->company_name;

}

if(empty($product)){
$product = 'R Mbps';
}else {
$product = $product->package_name;
}

$date = ''; $time = '';
if($w->dateTimeStart == ''){
$date = '';
$time = '';
}else {
$date = date("d/m/Y", strtotime($w->dateTimeStart));
$time = date("h:i A", strtotime($w->dateTimeStart));
}

array_push($nested_data, array(
'formT' => $n1.$i.$w->Form->type_application,
'service' => $w->nature_work,
'wo' => $w->wo,
'name' => $name,
'phone' => $form->Subscriber->phone1,
'unit' => $unit,
'building' => $building,
'city' => $form->Subscriber->city,
'package' => $product,
'contractor' => $company->name,
'installer' => $installer,
'date' => $date,
'time' => $time,
'status' => $w->status,
'action' => $w->wo,
));
}
}

return \DataTables::of($nested_data)->make(true);
}

public function getAllPendingInstaller($year,$month,$day){

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$i = 0; $n1 = '';
$curr = Carbon::now()->getTimestamp();
$nested_data = array();

if($year == 'null' && $month == 'null' && $day == 'null'){
$wo = WorkOrder::with('Form')->where('status','Pending Installer')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->get();
}else if($year != 'null' && $month == 'null' && $day == 'null'){

$timestamp = $year."-01-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfYear();

$wo = WorkOrder::with('Form')->where('status','Pending Installer')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();

}else if($year != 'null' && $month != 'null' && $day == 'null'){

$timestamp = $year."-".$month."-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfMonth();

$wo = WorkOrder::with('Form')->where('status','Pending Installer')->where('contractor_id',$user->StaffDetail->company_id)->orderBy('updated_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
}

if(!empty($wo)){
foreach ($wo as $key => $w) {
$i++;

$n1 = '';
$reg_time = $w->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$installer = '';
$form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
$product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
$company = Company::where('_id',$w->contractor_id)->first();

if($w->installer_id != ''){
$installer = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
if(!empty($installer)){
$installer = $installer->StaffDetail->name;
}
}

$building = ''; $unit = '-'; $name = '';
if($form->type_application == 'R'){
$building = $form->Subscriber->building_name;
$unit = $form->Subscriber->unit_no;
$name = $form->Subscriber->name;

}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$unit = '-';
}else {
$unit = $form->Subscriber->unit_no;
}

$building = '-';
$name = $form->Subscriber->company_name;
}

if(empty($product)){
$product = 'R Mbps';
}else {
$product = $product->package_name;
}

array_push($nested_data, array(
'formT' => $n1.$i.$w->Form->type_application,
'service' => $w->nature_work,
'wo' => $w->wo,
'name' => $name,
'phone' => $form->Subscriber->phone1,
'unit' => $unit,
'building' => $building,
'city' => $form->Subscriber->city,
'package' => $product,
'contractor' => $company->name,
'installer' => $installer,
'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
'time' => date("h:i A", strtotime($w->dateTimeStart)),
'status' => $w->status,
'action' => $w->wo,
));
}
}

return \DataTables::of($nested_data)->make(true);
}

public function getAllCompleted($year,$month,$day){

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$i = 0; $n1 = '';
$curr = Carbon::now()->getTimestamp();
$nested_data = array();

if($year == 'null' && $month == 'null' && $day == 'null'){
$doc = Docket::with('WorkOrder')->orderBy('updated_at', 'desc')->get();
}else if($year != 'null' && $month == 'null' && $day == 'null'){

$timestamp = $year."-01-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfYear();

$doc = Docket::with('WorkOrder')->orderBy('updated_at', 'desc')->whereBetween('dateTimeStart', [$go, $end_year])->get();

}else if($year != 'null' && $month != 'null' && $day == 'null'){

$timestamp = $year."-".$month."-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfMonth();

$doc = Docket::with('WorkOrder')->orderBy('updated_at', 'desc')->whereBetween('dateTimeStart', [$go, $end_year])->get();
}

if(!empty($doc)){
foreach ($doc as $key => $w) {
$i++;

$n1 = '';
if(!empty($w->updated_at)) {
$reg_time = $w->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}
}else {
$n1 = '';
}

$installer = '';
if(!empty($w->WorkOrder->_id)){
$form = Form::with('Subscriber','PackageDetail')->where('_id',$w->WorkOrder->_id)->first();
$product = Product::where('speed',$form->PackageDetail->name)->where('formT',$form->type_application)->first();
$company = Company::where('_id',$w->WorkOrder->contractor_id)->first();

if($w->WorkOrder->installer_id != ''){
$installer = Staff::with('StaffDetail')->withTrashed()->where('_id',$w->WorkOrder->installer_id)->first();
$installer = $installer->StaffDetail->name;
}

if(empty($product)){
$product = 'R Mbps';
}else {
$product = $product->package_name;
}

$building = ''; $unit = '-'; $name = '';
if($form->type_application == 'R'){
$building = $form->Subscriber->building_name;
$unit = $form->Subscriber->unit_no;
$name = $form->Subscriber->name;

}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$unit = '-';
}else {
$unit = $form->Subscriber->unit_no;
}

$building = '-';
$name = $form->Subscriber->company_name;
}

if($w->WorkOrder->contractor_id == $user->StaffDetail->company_id){
array_push($nested_data, array(
'formT' => $n1.$i.$form->type_application,
'service' => $w->nature_work,
'wo' => $w->WorkOrder->wo,
'name' => $name,
'phone' => $form->Subscriber->phone1,
'unit' => $unit,
'building' => $building,
'city' => $form->Subscriber->city,
'package' => $product,
'contractor' => $company->name,
'installer' => $installer,
'date' => date("d/m/Y", strtotime($w->end_job)),
'time' => date("h:i A", strtotime($w->end_job)),
'status' => $w->WorkOrder->status,
'docket' => $w->docket_id,
'action' => $w->WorkOrder->wo,
));
}
}
}
}

return \DataTables::of($nested_data)->make(true);
}

public function generateWorkOrderPDF($wo){

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$wo = WorkOrder::where('wo',$wo)->first();
$form = Form::with('PackageDetail','Subscriber')->where('_id',$wo->_id)->first();
$product = Product::where('formT',$form->type_application)->where('speed',$form->PackageDetail->name)->first();

if(empty($product)){
if($form->PackageDetail->name == "30"){
$product = '30Mbps';
}else{
$product = 'RMbps';
}
}else {
$product = $product->package_name;
}

$created_by = Staff::with('StaffDetail')->find($wo->created_by)->first();
if(empty($created_by)){
$created_by = '';
}

$created_at = Carbon::parse($wo->created_at)->toDateTimeString();

$address = '';
if($form->type_application == 'R'){
if($form->Subscriber->street != ''){
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}

}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$address = $form->Subscriber->unit_no. ', '.$form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}

}


$pdf = PDF::loadView('pdf.workorder-pdf',compact('wo','form','product','created_at','created_by','address'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}

public function updateWorkOrder(Request $request){

$id = Auth::guard('contractor')->id();
$user = Staff::with('StaffDetail')->find($id);

$wo = WorkOrder::where('wo',$request->work_order)->first();
if(!empty($wo)){
$wo->nature_work = $request->task;
$wo->pppoe_username = $request->pppoe_username;
$wo->onu = $request->onu_ont;
$wo->router = $request->router;
$wo->n_phone = $request->n_phone;
$wo->no_phone = $request->no_phone;
$wo->remarks_custservice = $request->remark;
$wo->created_by = $user->_id;
$wo->save();

return redirect('/contractor/work-order/list');
// return redirect()->back()->with('success_msg', 'Success! Update work order '.$request->get('work_order'));
}else {
return redirect()->back()->with('error_msg', 'Cant update work order '.$request->get('work_order'));
}
}

public function rescheduleWorkOrder(Request $request){

$wod = WorkOrder::where('wo',$request->wo)->first();
if(!empty($wod)){

$wod->dateTimeStart = $request->start;
$wod->dateTimeEnd = $request->end;
$wod->installer_id = $request->installer;
$wod->status = $request->type_work;
$wod->save();

return 'success';

}else{
return 'false';
}
}

public function cancelCreateWorkOrder(Request $request){
$wod = WorkOrder::where('wo',$request->wo)->first();
if(!empty($wod)){
$wod->delete();
return 'true';
}else{
return 'false';
}
}

public function updateWorkOrderReschedule(Request $request)
{
$data = array();
$wod = WorkOrder::where('wo',$request->wo)->first();
$form = Form::where('_id',$wod->_id)->first();
$installer = Staff::with('StaffDetail')->where('_id',$wod->installer_id)->first();

if(!empty($wod)){

if($wod->status == 'Pending Contractor'){

$wod->status = $request->type_work;
$wod->installer_id = $request->installer;
$wod->save();

$formH = new FormStatus;
$formH->form_id = $form->_id;
$formH->status_id = 6;
$formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$formH->status = 'Pending Installer';
$formH->desc = 'This work order been assigned to particular installer ('.$installer->name.')';
$form->formstatus()->save($formH);

array_push($data, array(
'result' => 'yes',
));

}else {

$wod->status = $request->type_work;
$wod->installer_id = $request->installer;
$wod->save();

array_push($data, array(
'result' => 'yes',
));
}

}else{
array_push($data, array(
'result' => 'no',
));
}

return response()->json($data);
}

public function updateStatusWorkOrder($wo){

$wod = WorkOrder::where('wo',$wo)->first();
if(!empty($wod)){
$wod->status = 'Success Non Prelaid';
$wod->save();

$form = Form::where('_id',$wod->_id)->first();
$formH = new FormStatus;
$formH->form_id = $form->_id;
$formH->status_id = 7;
$formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$formH->status = 'Success Prelaid';
$formH->desc = 'Prelaid successfully';
$form->formstatus()->save($formH);

return redirect('/contractor/work-order/list');
}
}
}

+ 13
- 0
app/Http/Controllers/Controller.php Zobrazit soubor

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

+ 266
- 0
app/Http/Controllers/CustomerService/CalendarController.php Zobrazit soubor

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

namespace App\Http\Controllers\CustomerService;

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

use Carbon\Carbon;
use Validator;
use PDF;

use App\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\WorkOrder;
use App\Model\PackageDetail;
use App\Model\Company;

class CalendarController extends Controller
{

public function index()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

$company = Company::where('team','CBB')->get();
$today = Carbon::today();
return view('customer-service.view_calendar', compact('user','pp','sp','rs','ss','cm', 'company','today'));
}

public function getAllCalendar(Request $request){

$event = array(); $color = '';

$cuw = $request->wk;

if($request->customer == ''){

if($request->status == '' && $request->company == ''){

$wo = WorkOrder::all();
if(!empty($wo)){
foreach ($wo as $key => $w) {
if($w->wo == $cuw){
$color = '#5C2983';
}else if($w->wo != $cuw) {
if($w->status == "Completed") {
$color = '#00C853';
}else if($w->status == "Suspend") {
$color = '#DE006E';
}else if($w->status == "Reschedule") {
$color = '#FF6D00';
}else if($w->status == "Success Non Prelaid"){
$color = '#2962FF';
}else if($w->status == "Pending Non Prelaid"){
$color = '#FFD600';
}else if($w->status == "Pending Contractor") {
$color = '#6D4C41';
}else if($w->status == "Pending Installer"){
$color = '#546E7A';
}
}

array_push($event, array(
'id' => $w->wo,
'title' => $w->wo,
'start' => Carbon::createFromTimestamp(strtotime($w->dateTimeStart))->toRfc2822String(),
'end' => Carbon::createFromTimestamp(strtotime($w->dateTimeEnd))->toRfc2822String(),
'url' => url('/customer-service/work-order/generate-pdf/'.$w->wo),
'color' => $color,
'allDay' => false
));
}
}

}else if($request->status != '' && $request->company == ''){

$wo = WorkOrder::where('status',$request->status)->get();
if(!empty($wo)){
foreach ($wo as $key => $w) {

if($w->wo == $cuw){
$color = '#5C2983';
}else if($w->wo != $cuw) {
if($w->status == "Completed") {
$color = '#00C853';
}else if($w->status == "Suspend") {
$color = '#DE006E';
}else if($w->status == "Reschedule") {
$color = '#FF6D00';
}else if($w->status == "Success Non Prelaid"){
$color = '#2962FF';
}else if($w->status == "Pending Non Prelaid"){
$color = '#FFD600';
}else if($w->status == "Pending Contractor") {
$color = '#6D4C41';
}else if($w->status == "Pending Installer"){
$color = '#546E7A';
}
}

array_push($event, array(
'id' => $w->wo,
'title' => $w->wo,
'start' => Carbon::createFromTimestamp(strtotime($w->dateTimeStart))->toRfc2822String(),
'end' => Carbon::createFromTimestamp(strtotime($w->dateTimeEnd))->toRfc2822String(),
'url' => url('/customer-service/work-order/generate-pdf/'.$w->wo),
'color' => $color,
'allDay' => false
));
}
}

}else if($request->status == '' && $request->company != ''){

$wo = WorkOrder::where('contractor_id', $request->company)->get();
$cuw = '';

if($request->has('wk')){
$cuw = $request->wk;
}

if(!empty($wo)){
foreach ($wo as $key => $w) {

if($w->wo == $cuw){
$color = '#5C2983';
}else if($w->wo != $cuw) {
if($w->status == "Completed") {
$color = '#00C853';
}else if($w->status == "Suspend") {
$color = '#DE006E';
}else if($w->status == "Reschedule") {
$color = '#FF6D00';
}else if($w->status == "Success Non Prelaid"){
$color = '#2962FF';
}else if($w->status == "Pending Non Prelaid"){
$color = '#FFD600';
}else if($w->status == "Pending Contractor") {
$color = '#6D4C41';
}else if($w->status == "Pending Installer"){
$color = '#546E7A';
}
}

array_push($event, array(
'id' => $w->wo,
'title' => $w->wo,
'start' => Carbon::createFromTimestamp(strtotime($w->dateTimeStart))->toRfc2822String(),
'end' => Carbon::createFromTimestamp(strtotime($w->dateTimeEnd))->toRfc2822String(),
'url' => url('/customer-service/work-order/generate-pdf/'.$w->wo),
'color' => $color,
'allDay' => false
));
}
}

}else if($request->status != '' && $request->company != ''){

$wo = WorkOrder::where('contractor_id', $request->company)->where('status',$request->status)->get();
if(!empty($wo)){
foreach ($wo as $key => $w) {
if($w->wo == $cuw){
$color = '#5C2983';
}else if($w->wo != $cuw) {
if($w->status == "Completed") {
$color = '#00C853';
}else if($w->status == "Suspend") {
$color = '#DE006E';
}else if($w->status == "Reschedule") {
$color = '#FF6D00';
}else if($w->status == "Success Non Prelaid"){
$color = '#2962FF';
}else if($w->status == "Pending Non Prelaid"){
$color = '#FFD600';
}else if($w->status == "Pending Contractor") {
$color = '#6D4C41';
}else if($w->status == "Pending Installer"){
$color = '#546E7A';
}
}

array_push($event, array(
'id' => $w->wo,
'title' => $w->wo,
'start' => Carbon::createFromTimestamp(strtotime($w->dateTimeStart))->toRfc2822String(),
'end' => Carbon::createFromTimestamp(strtotime($w->dateTimeEnd))->toRfc2822String(),
'url' => url('/customer-service/work-order/generate-pdf/'.$w->wo),
'color' => $color,
'allDay' => false
));
}
}

}

}else if($request->customer == 'New Customer'){

$form = Form::with('Subscriber','WorkOrder','PackageDetail')->get();
$url = '';

if(!empty($form)){
foreach($form as $f){
if(empty($f->WorkOrder)){
if($f->type_application == 'R' && !empty($f->Subscriber->subscriber_id)){
$color = '#582483';
$url = '/customer-service/residential/generate-pdf/'.$f->Subscriber->subscriber_id;
}else if($f->type_application == 'B' && !empty($f->Subscriber->subscriber_id)){
$color = '#E07027';
$url = '/customer-service/business/generate-pdf/'.$f->Subscriber->subscriber_id;
}

if(!empty($f->PackageDetail)){
array_push($event, array(
'id' => $f->Subscriber->subscriber_id,
'title' => $f->Subscriber->subscriber_id,
'start' => Carbon::createFromTimestamp(strtotime($f->PackageDetail->rfs))->toRfc2822String(),
'end' => '',
'url' => url($url),
'color' => $color,
'allDay' => false
));
}
}
}
}

}

return response()->json($event);
}

public function getCompanyColor(Request $request){

$datass = array();
$company = Company::where("_id",$request->company)->first();

if(!empty($company)){
array_push($datass, array(
'name' => '('.$company->name.')',
'bg' => $company->color,
'text' => '#fff'
));

}else {
array_push($datass, array(
'name' => '',
'bg' => '#fff',
'text' => '#5F5F5F'
));
}

return response()->json($datass);
}
}

+ 210
- 0
app/Http/Controllers/CustomerService/CoverageController.php Zobrazit soubor

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

namespace App\Http\Controllers\CustomerService;

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\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\WorkOrder;
use App\Model\PackageDetail;
use App\Model\Company;
use App\Model\Coverage;
use App\Model\Product;
use App\Model\Docket;

class CoverageController extends Controller
{

function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}

function createWorkID($limit){
$allowedNumbers = range(0, 9);
shuffle($allowedNumbers);
$digits = array_rand($allowedNumbers, $limit);
$number = '';
foreach($digits as $d){
$number .= $allowedNumbers[$d];
}
$unique_id = $number;
return $unique_id;
}

public function viewCoverageR()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

return view('customer-service.view_coverageR', compact('user','pp','sp','rs','ss','cm'));
}

public function viewCoverageB()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

return view('customer-service.view_coverageB', compact('user','pp','sp','rs','ss','cm'));
}

public function viewCoverageForm()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

return view('customer-service.view_coverage_form',compact('user','pp','sp','rs','ss','cm'));
}

public function editCoverage($cov)
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

$coverage = Coverage::where('_id', $cov)->first();

return view('customer-service.view_coverage_edit', compact('user','pp','sp','rs','ss','cm','coverage'));
}

public function getCoverageR()
{
$coverage = Coverage::where('Type', 'R')->get();

$i=0;
$curr = Carbon::now()->getTimestamp();
$nested_data = array();
foreach ($coverage as $a) {
$i++; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}
array_push($nested_data, array(
'index' => $n1.$i,
'address' => $a->building_name,
// 'street' => $a->street,
'city' => $a->city,
'state' => $a->state,
'postcode' => $a->postcode,
'status_building' => $a->status_building,
'action' => $a->_id
));
}
return \DataTables::of($nested_data)->make(true);
}

public function getCoverageB()
{
$coverage = Coverage::where('Type', 'B')->get();

$i=0;
$curr = Carbon::now()->getTimestamp();
$nested_data = array();
foreach ($coverage as $a) {
$i++; $n1 = '';

$reg_time = $a->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}
array_push($nested_data, array(
'index' => $n1.$i,
'address' => $a->building_name,
// 'street' => $a->street,
'city' => $a->city,
'state' => $a->state,
'postcode' => $a->postcode,
'status_building' => $a->status_building,
'action' => $a->_id
));
}
return \DataTables::of($nested_data)->make(true);
}

public function addCoverage(Request $request)
{
$coverage = [
'Type' => $request->get('tapp'),
'building_name' => $request->get('name'),
'city' => $request->get('city'),
'state' => $request->get('state'),
'postcode' => $request->get('postcode'),
'installation_fee' => $request->get('fee'),
'status_building' => $request->get('status'),
'jmb_email' => $request->get('jmb'),
];

$coverageUpdate = Coverage::create($coverage);

return redirect()->back()->with('success_msg', 'message');
}

public function updateCoverage(Request $request)
{
$coverage = Coverage::where('_id', $request->get('coverage_id'))->first();

$coverage->building_name = $request->get('name');
$coverage->city = $request->get('city');
$coverage->state = $request->get('state');
$coverage->status_building = $request->get('status');
$coverage->postcode = $request->get('postcode');
$coverage->save();

return redirect()->back()->with('success_msg', 'Success! Update coverage '.$request->get('name'));
}

public function deleteCoverage(Request $request)
{
$coverage = Coverage::where('_id',$request->id)->first();
if(!empty($coverage)){
$coverage->delete();
return 'true';
}else {
return 'false';
}
}
}

+ 1381
- 0
app/Http/Controllers/CustomerService/CustomerController.php
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 190
- 0
app/Http/Controllers/CustomerService/DocketController.php Zobrazit soubor

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

namespace App\Http\Controllers\CustomerService;

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\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\WorkOrder;
use App\Model\PackageDetail;
use App\Model\Company;
use App\Model\Coverage;
use App\Model\Product;
use App\Model\Docket;

class DocketController extends Controller
{

function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}

function createWorkID($limit){
$allowedNumbers = range(0, 9);
shuffle($allowedNumbers);
$digits = array_rand($allowedNumbers, $limit);
$number = '';
foreach($digits as $d){
$number .= $allowedNumbers[$d];
}
$unique_id = $number;
return $unique_id;
}

public function viewDocket()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

return view('customer-service.view_docket',compact('user','pp','sp','rs','ss','cm'));
}

public function getCustomerDocket($year,$month,$day)
{
if($year == 'null' && $month == 'null' && $day == 'null'){
$docket= Docket::with('WorkOrder')->orderBy('created_at', 'desc')->get();
}else if($year != 'null' && $month == 'null' && $day == 'null'){

$timestamp = $year."-01-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfYear();

$docket = Docket::with('WorkOrder')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();

}else if($year != 'null' && $month != 'null' && $day == 'null'){

$timestamp = $year."-".$month."-01 00:00:00.000Z";
$masa = strtotime($timestamp);
$go = Carbon::createFromTimestamp($masa);
$go2 = Carbon::createFromTimestamp($masa);
$end_year = $go2->endOfMonth();

$docket = Docket::with('WorkOrder')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
}

$i = 0; $n1 = ''; $building = '';
$curr = Carbon::now()->getTimestamp();
$tempD = array();
$nested_data = array();
if(!empty($docket)){
foreach($docket as $d){

$i++;
if(!empty($d->WorkOrder->_id)){
$form = Form::with('Subscriber','PackageDetail')->where('_id',$d->WorkOrder->_id)->first();
$company = Company::where('_id', $d->WorkOrder->contractor_id)->first();
$installer = Staff::with('StaffDetail')->withTrashed()->where('_id', $d->installer_id)->first();

if($form->type_application == 'R'){
$building = $form->Subscriber->building_name;
}else if($form->type_application == 'B'){
$building = $form->Subscriber->company_name;
}

$reg_time = $d->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

array_push($tempD, array(
'index' => $n1.$i,
'docket_id' => $d->docket_id,
'work_order_id' => $d->work_order_id,
'nature_work' => $d->nature_work,
'contractor_id' => $company->name,
'installer_name' => $installer->StaffDetail->name,
'customer_id' => $building,
'installer_id' => $installer->StaffDetail->phone,
'end_job' => date('d/m/Y H:i', strtotime($d->end_job)),
'rating' => round((($d->Rating1 + $d->Rating2 + $d->Rating3)/15) * 100)."%",
'action' => $d->docket_id.'/'.$d->work_order_id
));
}
}
}

foreach($tempD as $t){
array_push($nested_data, array(
'index' => $t['index'],
'docket_id' => $t['docket_id'],
'work_order_id' => $t['work_order_id'],
'nature_work' => $t['nature_work'],
'contractor_id' => $t['contractor_id'],
'installer_name' => $t['installer_name'],
'customer_id' => $t['customer_id'],
'installer_id' => $t['installer_id'],
'end_job' => $t['end_job'],
'rating' =>$t['rating'],
'action' =>$t['action'],
));
}

return \DataTables::of($nested_data)->make(true);
}

public function generateDocketPDF($do)
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);
$docket = Docket::with('WorkOrder')->where('docket_id',$do)->first();
if(!empty($docket)){
$form = Form::with('Subscriber','PackageDetail')->where('_id',$docket->WorkOrder->_id)->first();

$address = '';
if($form->type_application == 'R'){
if($form->Subscriber->street != ''){
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}

}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$address = $form->Subscriber->unit_no. ', '.$form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}

}

$product = Product::where('formT',$form->type_application)->where('speed',$form->PackageDetail->name)->first();
$installer = Staff::with('StaffDetail')->where('_id',$docket->installer_id)->withTrashed()->first();

if(empty($product)){
$product = 'RMbps';
}else {
$product = $product->package_name;
}

$dateTime = Carbon::parse($docket->WorkOrder->dateTimeStart)->toDateTimeString();
$edateTime = Carbon::parse($docket->end_job)->toDateTimeString();

$pdf = PDF::loadView('pdf.docket-pdf',compact('docket','form','address','product','installer','dateTime','edateTime'));
$pdf->setPaper('A4', 'potrait');
return $pdf->stream();
}
}
}

+ 52
- 0
app/Http/Controllers/CustomerService/ProfileController.php Zobrazit soubor

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

namespace App\Http\Controllers\CustomerService;

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\Staff;
use App\Model\StaffDetail;
use App\Model\WorkOrder;

class ProfileController extends Controller
{
public function viewProfile(){

$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

return view('customer-service.view_profile',compact('user','pp','sp','rs','ss','cm'));
}

public function updateProfilePicture(Request $request){
$this->validate($request, [
'prof_img' => 'mimes:jpeg,jpg,png|required|dimensions:width=128,height=128'
]);

if($request->hasfile('prof_img')){
// Move / Upload Icon into server
$destinationPath = 'assets/avatar';
// create folder/dir if not exist
if(!File::exists(public_path().$destinationPath)){
File::makeDirectory(public_path().$destinationPath,0777,true);
}

$icon = $request->file('prof_img');
$icon->move($destinationPath,$request->id.'.'.$icon->getClientOriginalExtension());
$pathIcon = $destinationPath.'/'.$request->id.'.'.$icon->getClientOriginalExtension();
}
}
}

+ 355
- 0
app/Http/Controllers/CustomerService/TeamController.php Zobrazit soubor

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

namespace App\Http\Controllers\CustomerService;

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\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\WorkOrder;
use App\Model\PackageDetail;
use App\Model\Company;
use App\Model\Coverage;
use App\Model\Product;
use App\Model\Docket;

class TeamController extends Controller
{

function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}

function createWorkID($limit){
$allowedNumbers = range(0, 9);
shuffle($allowedNumbers);
$digits = array_rand($allowedNumbers, $limit);
$number = '';
foreach($digits as $d){
$number .= $allowedNumbers[$d];
}
$unique_id = $number;
return $unique_id;
}

public function encryptPassword($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '28472B4B6250655368566D5970337336';
$secret_iv = md5(md5($string)); //'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if( $action == 'decrypt' ) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}

public function viewCustomerTeam()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

return view('customer-service.view_contractor',compact('user','pp','sp','rs','ss','cm'));
}

public function getCustomerContractor()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$agent = Staff::with('Company','StaffDetail')->where('roles_access','Contractor')->orderBy('created_at', 'desc')->get();
$curr = Carbon::now()->getTimestamp();
$i = 0;
$nested_data = array();
foreach ($agent as $a)
{
$i++;
$n1 = '';
$reg_time = $a->updated_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

array_push($nested_data, array(
'index' => $n1.$i,
'user_pic' => $a->StaffDetail->user_pic,
'name' => $a->StaffDetail->name,
'ic' => $a->StaffDetail->ic,
'email' => $a->StaffDetail->email,
'phone' => $a->StaffDetail->phone,
'company_id' => $a->Company->name,
'position' => $a->StaffDetail->position,
'action' => $a->_id
));
}
return \DataTables::of($nested_data)->make(true);
}

public function viewCustomerContractorForm()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

$company = Company::where('team','CBB')->get();

return view('customer-service.view_contractor_form',compact('user','pp','sp','rs','ss','cm','company'));
}

public function requestAddContractor(Request $request){

$validator = Validator::make($request->all(), [
'password' => 'min:5|confirmed',
]);

if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}

$encrP = $this->encryptPassword('encrypt', $request->password);
$company = Company::where('_id',$request->vendor)->first();

$exist = Staff::with('StaffDetail')->where('email',$request->email)->where('roles_access','Contractor')->first();
if(empty($exist)){
$sl = Staff::create([
'email' => $request->email,
'password' => $encrP,
'roles_access' => 'Contractor',
'company_id' => $request->vendor,
'last_login_at' => '',
'last_login_ip'=> ''
]);

$sdl = new StaffDetail();
$sdl->name = $request->aname;
$sdl->ic = $request->ic;
$sdl->email = $request->email;
$sdl->phone = $request->phone;
$sdl->company_id = $request->vendor;
$sdl->color = $company->color;
$sdl->position = 'Contractor';
$sdl->password = $encrP;
$sdl->user_pic = 'assets/avatar/user.png';

$company->staff()->save($sl);
$company->save();
$sl->staffdetail()->save($sdl);

return redirect()->back()->with('success_msg', '<strong>Success!</strong> add <strong>'.$request->get('aname').'</strong> as new contractor ');

}else {
return redirect()->back()->withInput()->withErrors('Email already exist');
}
}

public function editContractor($contractor)
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

$company = Company::where('team','CBB')->get();
$contractor = Staff::with('StaffDetail')->where('_id',$contractor)->first();

return view('customer-service.edit_contractor',compact('user','pp','sp','rs','ss','cm','company','contractor'));
}

public function requestEditContractor(Request $request){

$exist = Staff::with('StaffDetail')->where('_id',$request->contractor_id)->first();
$company = Company::where('_id',$request->vendor)->first();

if(empty($exist)){
return redirect()->back()->withInput()->withErrors('Contractor not found');
}else {

$exist->email = $request->email;
$exist->company_id = $request->vendor;
$exist->save();

$exist->StaffDetail->name = $request->aname;
$exist->StaffDetail->ic = $request->ic;
$exist->StaffDetail->email = $request->email;
$exist->StaffDetail->phone = $request->phone;
$exist->StaffDetail->company_id = $request->vendor;
$exist->StaffDetail->save();
$company->staff()->save($exist);
$company->save();

return redirect()->back()->with('success_msg', '<strong>Success!</strong> update <strong>'.$request->get('aname').'</strong> as new contractor ');
}
}

public function viewCustomerVendor()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

return view('customer-service.view_vendor',compact('user','pp','sp','rs','ss','cm'));
}

public function getCustomerVendor() {
$i=0;
$team = Company::where('team','CBB')->get();
$nested_data = array();
foreach ($team as $a)
{
$i++; $n1 = '';
array_push($nested_data, array(
'index' => $n1.$i,
'name' => $a->name,
'address' => $a->address,
'city' => $a->city,
'state' => $a->state,
'postcode' => $a->postcode,
'action' => $a->_id
));
}
return \DataTables::of($nested_data)->make(true);
}

function random_color_part() {
return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}

function random_color() {
return $this->random_color_part() . $this->random_color_part() . $this->random_color_part();
}

public function viewCustomerVendorForm()
{
$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

$colors = array();
for($i = 0; $i < 19; $i++){
$colors[] = '#'.$this->random_color();
}

return view('customer-service.view_vendor_form', compact('user','pp','sp','rs','ss','cm','colors'));
}

public function requesAddVendor(Request $request){

$sl = Company::create([
'name' => $request->cname,
"address" => $request->address,
"city" => $request->city,
"state" => $request->state,
"postcode" => $request->postcode,
"color" => $request->color,
"team" => "CBB",
]);

return redirect()->back()->with('success_msg', '<strong>Success!</strong> add <strong>'.$request->get('cname').'</strong> as new vendor ');
}

public function editVendor($vendor){

$id = Auth::guard('cs')->id();
$user = Staff::with('StaffDetail')->find($id);

$pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
$sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
$rs = count(WorkOrder::where('status','Reschedule')->get());
$ss = count(WorkOrder::where('status','Suspend')->get());
$cm = count(WorkOrder::where('status','Completed')->get());

$vendor = Company::find($vendor);

return view('customer-service.edit_vendor', compact('user','pp','sp','rs','ss','cm','vendor'));
}

public function requesEditVendor(Request $request){

$company = Company::where('_id',$request->company_id)->first();
if(!empty($company)){
$company->name = $request->cname;
$company->address = $request->address;
$company->city = $request->city;
$company->state = $request->state;
$company->postcode = $request->postcode;
$company->save();

return redirect()->back()->with('success_msg', '<strong>Success!</strong> update <strong>'.$request->get('cname').'</strong> detail ');

}else {
return redirect()->back()->with('error_msg', '<strong>Failed!</strong> update <strong>'.$request->get('cname').'</strong> detail. No company exist!');
}
}

public function requestDeleteVendor(Request $request)
{
$company = Company::where('_id',$request->id)->first();
if(!empty($company)){
$company->delete();
return 'true';
}else {
return 'false';
}
}

public function requestDeleteContractor(Request $request)
{
$staff = Staff::where('_id',$request->id)->first();
if(!empty($staff)){
$staff->delete();
return 'true';
}else {
return 'false';
}
}

}

+ 1437
- 0
app/Http/Controllers/CustomerService/WorkOrderController.php
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 219
- 0
app/Http/Controllers/DS/DealerClaimController.php Zobrazit soubor

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

namespace App\Http\Controllers\DS;

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

use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Company;
Use App\Model\Commission;

use App\Model\Form;
use App\Model\PackageDetail;
use App\Model\Subscriber;
use App\Model\WorkOrder;
use App\Model\Docket;
use App\Model\DealerClaim;
use App\Model\Product;

class DealerClaimController extends Controller
{
public function getCompleted(){

$cdata = array(); $finalData = array();

$dealerclaim = DealerClaim::get()->toArray();

$form = Form::with('Subscriber','PackageDetail','WorkOrder')->get();
foreach($form as $f){
if(!empty($f->dealer_id)){
if(!empty($f->WorkOrder)){
if($f->WorkOrder->status == 'Completed' && $f->WorkOrder->nature_work == 'Activation'){
$cdata[] = $f->_id;
}
}
}
}

$notExist = array();
foreach($cdata as $c){
if(array_search($c, array_column($dealerclaim, 'customer_id')) !== False) {
} else {
$notExist[] = $c;

$formD = Form::with('Subscriber','PackageDetail','WorkOrder')->where('_id',$c)->first();
$product = Product::where('speed', $formD->PackageDetail->name)->where('formT',$formD->type_application)->first();
$docket = Docket::where('work_order_id',$formD->WorkOrder->wo)->first();

if(!empty($docket->docket_id)){
$subsData = [
'formT' => $formD->type_application,
'contract' => $formD->PackageDetail->contract,
'submission_dt' => Carbon::parse($formD->created_at)->setTimezone('Asia/Kuala_Lumpur')->toDateTimeString(),
'submission_my' => date('m/Y', strtotime(Carbon::parse($formD->created_at)->setTimezone('Asia/Kuala_Lumpur'))),
'wo' => $formD->WorkOrder->wo,
'customer_id' => $formD->_id,
'package' => $formD->PackageDetail->name,
'retail_price' => (int)$product->retail_price,
'docket' => $docket->docket_id,
'activated_dt' => $docket->end_job,
'activated_my' => date('m/Y', strtotime($docket->end_job)),
'claim_dt' => '',
'total_form_by_month' => '',
'agent' => $formD->dealer_id,
'dealer' => $formD->company_id,
];

DealerClaim::create($subsData);
}
}
}
return $notExist;
}

public function storeDealerClaim(){

$data = $this->getCompleted();
return $data;
}


public function test1(){
$d = DealerClaim::where('formT' == 'R')->all();

$data12 = array(); $data24 = array(); $final = array();
foreach($d as $dc){
if($dc->activated_my == $mY){
if($dc->contract == "12"){
$data12[] = $dc;
}else if($dc->contract == "24"){
$data24[] = $dc;
}
}
}

$countD24 = count($data24);
$countD12 = count($data12);

$comm = Commission::where('formT','R')->get();
$commV12 = 0; $commV24 = 0;
$comm12 = ''; $comm24 = '';

foreach($comm as $c){
if($c->contract =='12'){
if(strpos($c->ranges, '>') !== false) {

$pieces = explode(">", $c->ranges);

if($countD12 >= intval($pieces[1])){
$commV12 = floatval($c->comm)/100;
$comm12 = $c->comm.'%';
}
}
if(strpos($c->ranges,'-') !== false){

$pieces = explode("-", $c->ranges);

if($countD12 >= intval($pieces[0]) && $countD12 <= intval($pieces[1])){
$commV12 = floatval($c->comm)/100;
$comm12 = $c->comm.'%';
}

}

}else if($c->contract =='24'){
// Contract => 24
if($countD24 != 0){
if(strpos($c->ranges, '>') !== false) {

$pieces = explode(">", $c->ranges);

if($countD24 > intval($pieces[1])){
$commV24 = floatval($c->comm)/100;
$comm24 = $c->comm.'%';
}
}
if(strpos($c->ranges,'-') !== false){

$pieces = explode("-", $c->ranges);

if($countD24 >= intval($pieces[0]) && $countD24 <= intval($pieces[1])){
$commV24 = floatval($c->comm)/100;
$comm24 = $c->comm.'%';
}
}
}
}
}

foreach ($data12 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm12,
'incentives2' => '',
'total' => 'RM '.number_format($d['retail_price']*$commV12,2),
'claim' => $d['claim_dt'],
);
}

foreach ($data24 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm24,
'incentives2' => '',
'total' => 'RM '.number_format($d['retail_price']*$commV24,2),
'claim' => $d['claim_dt'],
);
}

dd($final);
}


public function getDealerCompany(){
$dataD = $this->storeDealerClaim();
dd($dataD);
}

public function updateIncentives(){
$data_not_activated = array();
$dealerclaim = DealerClaim::get();
foreach ($dealerclaim as $key => $d) {
$wo = WorkOrder::where('wo',$d->wo)->first();
if(!empty($wo)){
if($wo->nature_work !== 'Activation'){
$data_not_activated[] = $d;
}
}
}
dd($data_not_activated);
}

}

+ 2540
- 0
app/Http/Controllers/DS/DealerController.php
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 3625
- 0
app/Http/Controllers/DS/MarketingController.php
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 852
- 0
app/Http/Controllers/DS/MarketingDealerController.php Zobrazit soubor

@@ -0,0 +1,852 @@
<?php
namespace App\Http\Controllers\DS;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use Validator;
use PDF;

use App\Staff;
use App\Model\StaffDetail;

Use App\Model\Coverage;
use App\Model\DealerClaim;
use App\Model\Company;
use App\Model\Commission;

use App\Model\Form;
use App\Model\Subscriber;
use App\Model\PackageDetail;
use App\Model\WorkOrder;
use App\Model\Docket;

class MarketingDealerController extends Controller {

// Return view

/**
Calculate Claim R
**/
public function returnDataR(array $dataRR, $year,$month){

$dataCR = $dataRR;
$final = array();

// Month & Year
$mY = '';
if($year != 'null' && $month != 'null'){
$mY = $month.'/'.$year;
}

if($mY != ''){

$data12 = array(); $data24 = array();
$countD12 = 0; $countD24 = 0;

foreach($dataCR as $dc){
if($dc->activated_my == $mY){
if($dc->contract == "12"){
$data12[] = $dc;
}else if($dc->contract == "24"){
$data24[] = $dc;
}
}
}

$countD24 = count($data24);
$countD12 = count($data12);

$comm = Commission::where('formT','R')->get();
$commV12 = 0; $commV24 = 0;
$comm12 = ''; $comm24 = '';

foreach($comm as $c){
if($c->contract =='12'){
if(strpos($c->ranges, '>') !== false) {

$pieces = explode(">", $c->ranges);

if($countD12 >= intval($pieces[1])){
$commV12 = floatval($c->comm)/100;
$comm12 = $c->comm.'%';
}
}
if(strpos($c->ranges,'-') !== false){

$pieces = explode("-", $c->ranges);

if($countD12 >= intval($pieces[0]) && $countD12 <= intval($pieces[1])){
$commV12 = floatval($c->comm)/100;
$comm12 = $c->comm.'%';
}

}

}else if($c->contract =='24'){
// Contract => 24
if($countD24 != 0){
if(strpos($c->ranges, '>') !== false) {

$pieces = explode(">", $c->ranges);

if($countD24 > intval($pieces[1])){
$commV24 = floatval($c->comm)/100;
$comm24 = $c->comm.'%';
}
}
if(strpos($c->ranges,'-') !== false){

$pieces = explode("-", $c->ranges);

if($countD24 >= intval($pieces[0]) && $countD24 <= intval($pieces[1])){
$commV24 = floatval($c->comm)/100;
$comm24 = $c->comm.'%';
}
}
}
}
}

foreach ($data12 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm12,
'incentives2' => '',
'total' => 'RM '.number_format($d['retail_price']*$commV12,2),
'claim' => $d['claim_dt'],
);
}

foreach ($data24 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm24,
'incentives2' => '',
'total' => 'RM '.number_format($d['retail_price']*$commV24,2),
'claim' => $d['claim_dt'],
);
}

}else {

foreach ($dataCR as $c){

$customer = Subscriber::where('_id', $c['customer_id'])->first();
$address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;

$final[] = array(
'index' => $c['formT'],
'contract' => $c['contract'],
'wo' => $c['wo'],
'activation' => $c['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $c['package'],
'retail_price' => 'RM '.$c['retail_price'],
'incentives1' => '',
'incentives2' => '',
'total' => '',
'claim' => $c['claim_dt'],
);
}

}

return $final;
}

/**
Get Claim B
**/
public function returnDataB(array $dataBB, $year,$month){

$dataCB = $dataBB;
$final = array();

// Month & Year
$mY = '';
if($year != 'null' && $month != 'null'){
$mY = $month.'/'.$year;
}

if($mY != ''){

/** Contract 12
// 1=>10-100 2=>300 3=>500 4=>1
**/
$data12_1 = array(); $data12_2 = array();
$data12_3 = array(); $data12_4 = array();

$countD12_1 = 0; $countD12_2 = 0;
$countD12_3 = 0; $countD12_4 = 0;
/** Contract 24
// 1=>10-100 2=>300 3=>500 4=>1
**/
$data24_1 = array(); $data24_2 = array();
$data24_3 = array(); $data24_4 = array();

$countD24_1 = 0; $countD24_2 = 0;
$countD24_3 = 0; $countD24_4 = 0;

foreach($dataCB as $dc){
if($dc->activated_my == $mY){

if($dc->contract == "12" && ($dc->package == "10" || $dc->package == "30" || $dc->package == "50" || $dc->package == "100")){
$data12_1[] = $dc;
}else if($dc->contract == "12" && $dc->package == "300"){
$data12_2[] = $dc;
}else if($dc->contract == "12" && $dc->package == "500"){
$data12_3[] = $dc;
}else if($dc->contract == "12" && $dc->package == "1"){
$data12_4[] = $dc;
}else if($dc->contract == "24" && ($dc->package == "10" || $dc->package == "30" || $dc->package == "50" || $dc->package == "100")){
$data24_1[] = $dc;
}else if($dc->contract == "24" && $dc->package == "300"){
$countD24_2[] = $dc;
}else if($dc->contract == "24" && $dc->package == "500"){
$countD24_3[] = $dc;
}else if($dc->contract == "24" && $dc->package == "1"){
$countD24_4[] = $dc;
}

}
}

$countD12_1 = count($data12_1); $countD12_2 = count($data12_2);
$countD12_3 = count($data12_3); $countD12_4 = count($data12_4);

$countD24_1 = count($data24_1); $countD24_2 = count($data24_2);
$countD24_3 = count($data24_3); $countD24_4 = count($data24_4);

$comm = Commission::where('formT','B')->get();

$commV12_1 = 0; $commV12_2 = 0;
$commV12_3 = 0; $commV12_4 = 0;

$commV24_2 = 0; $commV24_2 = 0;
$commV24_3 = 0; $commV24_4 = 0;

$comm12_1 = ''; $comm12_2 = '';
$comm12_3 = ''; $comm12_4 = '';

$comm24_1 = ''; $comm24_2 = '';
$comm24_3 = ''; $comm24_4 = '';

$addRM12_1 = ''; $addRM12_2 = '';
$addRM12_3 = ''; $addRM12_4 = '';

$addRM24_1 = ''; $addRM24_2 = '';
$addRM24_3 = ''; $addRM24_4 = '';

foreach($comm as $c){

/*** Contract 24 **/
if($c->contract =='24' && $c->packageR == "300"){

if(strpos($c->ranges, '>') !== false) {
$pieces = explode(">", $c->ranges);

if($countD24_2 >= intval($pieces[1])){
if(strpos($c->comm, 'RM') !== false) {
$comm24_2 = '+ ' .$c->comm;
$commV24_2 = '';
$addRM24_2 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm24_2 = 'RM '.$comms[1];
$commV24_2 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm24_2 = $comms[0].'%';
$commV24_2 = floatval($comms[0])/100;
}
}
}
}
}

}else if($c->contract =='24' && $c->packageR == "500"){

if(strpos($c->ranges, '>') !== false) {
$pieces = explode(">", $c->ranges);

if($countD24_3 >= intval($pieces[1])){
if(strpos($c->comm, 'RM') !== false) {
$comm24_3 = '+ ' .$c->comm;
$commV24_3 = '';
$addRM24_3 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm24_3 = 'RM '.$comms[1];
$commV24_3 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm24_3 = $comms[0].'%';
$commV24_3 = floatval($comms[0])/100;
}
}
}
}
}

}else if($c->contract =='24' && $c->packageR == "1"){

if(strpos($c->ranges, '>') !== false) {
$pieces = explode(">", $c->ranges);

if($countD24_4 >= intval($pieces[1])){
if(strpos($c->comm, 'RM') !== false) {
$comm24_4 = '+ ' .$c->comm;
$commV24_4 = '';
$addRM24_4 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm24_4 = 'RM '.$comms[1];
$commV24_4 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm24_4 = $comms[0].'%';
$commV24_4 = floatval($comms[0])/100;
}
}
}
}
}

}else if($c->contract =='24' && $c->packageR == "10,30,50,100"){

if(strpos($c->ranges, '>') !== false) {
$pieces = explode(">", $c->ranges);

if($countD24_1 >= intval($pieces[1])){

if(strpos($c->comm, 'RM') !== false) {
$comm24_1 = '+ ' .$c->comm;
$commV24_1 = '';
$addRM24_1 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm24_1 = 'RM '.$comms[1];
$commV24_1 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm24_1 = $comms[0].'%';
$commV24_1 = floatval($comms[0])/100;
}
}
}
}
}

if(strpos($c->ranges,'-') !== false){

$pieces = explode("-", $c->ranges);

if($countD24_1 >= intval($pieces[0]) && $countD24_1 <= intval($pieces[1])){

if(strpos($c->comm, 'RM') !== false) {
$comm24_1 = '+ ' .$c->comm;
$commV24_1 = '';
$addRM24_1 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm24_1 = 'RM '.$comms[1];
$commV24_1 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm24_1 = $comms[0].'%';
$commV24_1 = floatval($comms[0])/100;
}
}
}
}
}

}

/*** Contract 12 **/
else if($c->contract =='12' && $c->packageR == "10,30,50,100"){

if(strpos($c->ranges, '>') !== false) {
$pieces = explode(">", $c->ranges);

if($countD12_1 >= intval($pieces[1])){

if(strpos($c->comm, 'RM') !== false) {
$comm12_1 = '+ ' .$c->comm;
$commV12_1 = '';
$addRM12_1 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm12_1 = 'RM '.$comms[1];
$commV12_1 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm12_1 = $comms[0].'%';
$commV12_1 = floatval($comms[0])/100;
}
}
}
}
}

if(strpos($c->ranges,'-') !== false){

$pieces = explode("-", $c->ranges);

if($countD12_1 >= intval($pieces[0]) && $countD12_1 <= intval($pieces[1])){

if(strpos($c->comm, 'RM') !== false) {
$comm12_1 = '+ ' .$c->comm;
$commV12_1 = '';
$addRM12_1 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm12_1 = 'RM '.$comms[1];
$commV12_1 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm12_1 = $comms[0].'%';
$commV12_1 = floatval($comms[0])/100;
}
}
}
}
}

}else if($c->contract =='12' && $c->packageR == "300"){

if(strpos($c->ranges, '>') !== false) {
$pieces = explode(">", $c->ranges);

if($countD12_2 >= intval($pieces[1])){
if(strpos($c->comm, 'RM') !== false) {
$comm12_2 = '+ ' .$c->comm;
$commV12_2 = '';
$addRM12_2 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm12_2 = 'RM '.$comms[1];
$commV12_2 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm12_2 = $comms[0].'%';
$commV12_2 = floatval($comms[0])/100;
}
}
}
}
}

}else if($c->contract =='12' && $c->packageR == "500"){

if(strpos($c->ranges, '>') !== false) {
$pieces = explode(">", $c->ranges);

if($countD12_3 >= intval($pieces[1])){
if(strpos($c->comm, 'RM') !== false) {
$comm12_3 = '+ ' .$c->comm;
$commV12_3 = '';
$addRM12_3 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm12_3 = 'RM '.$comms[1];
$commV12_3 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm12_3 = $comms[0].'%';
$commV12_3 = floatval($comms[0])/100;
}
}
}
}
}

}else if($c->contract =='12' && $c->packageR == "1"){

if(strpos($c->ranges, '>') !== false) {
$pieces = explode(">", $c->ranges);

if($countD12_4 >= intval($pieces[1])){
if(strpos($c->comm, 'RM') !== false) {
$comm12_4 = '+ ' .$c->comm;
$commV12_4 = '';
$addRM12_4 = $c->comm;
}else {
$comms = explode("RM", $c->comm);
if(isset($comms[1])){
$comm12_4 = 'RM '.$comms[1];
$commV12_4 = floatval($comms[1]);
}else {
if($comms[0] != ''){
$comm12_4 = $comms[0].'%';
$commV12_4 = floatval($comms[0])/100;
}
}
}
}
}

}
}

// Category 10,30,50,100
foreach ($data12_1 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;
$total = '';
if($commV12_1 == ''){
$total = $addRM12_1;
}else {
$total = number_format($d['retail_price']*$commV12_1,2);
}

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm12_1,
'incentives2' => $addRM12_1,
'total' => 'RM '.$total,
'claim' => $c['claim_dt'],
);

}

foreach ($data24_1 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;
$total = '';
if($commV24_1 == ''){
$total = $addRM24_1;
}else {
$total = number_format($d['retail_price']*$commV24_1,2);
}

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm24_1,
'incentives2' => $addRM24_1,
'total' => 'RM '.$total,
'claim' => $c['claim_dt'],
);

}

// Category 300
foreach ($data12_2 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;
$total = '';
if($commV12_2 == ''){
$total = $addRM12_2;
}else {
$total = number_format($d['retail_price']*$commV12_2,2);
}

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm12_2,
'incentives2' => $addRM12_2,
'total' => 'RM '.$total,
'claim' => $c['claim_dt'],
);

}

foreach ($data24_2 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;
$total = '';
if($commV24_2 == ''){
$total = $addRM24_2;
}else {
$total = number_format($d['retail_price']*$commV24_2,2);
}

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm24_2,
'incentives2' => $addRM24_2,
'total' => 'RM '.$total,
'claim' => $c['claim_dt'],
);

}

// Category 500
foreach ($data12_3 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;
$total = '';
if($commV12_3 == ''){
$total = $addRM12_3;
}else {
$total = number_format($d['retail_price']*$commV12_3,2);
}

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm12_3,
'incentives2' => $addRM12_3,
'total' => 'RM '.$total,
'claim' => $c['claim_dt'],
);

}

foreach ($data24_3 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;
$total = '';
if($commV24_3 == ''){
$total = $addRM24_3;
}else {
$total = number_format($d['retail_price']*$commV24_3,2);
}

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm24_3,
'incentives2' => $addRM24_3,
'total' => 'RM '.$total,
'claim' => $c['claim_dt'],
);

}

// Category 1
foreach ($data12_4 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;
$total = '';
if($commV12_4 == ''){
$total = $addRM12_4;
}else {
$total = number_format($d['retail_price']*$commV12_4,2);
}

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm12_4,
'incentives2' => $addRM12_4,
'total' => 'RM '.$total,
'claim' => $c['claim_dt'],
);

}

foreach ($data24_4 as $key => $d) {

$customer = Subscriber::where('_id', $d['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;
$total = '';
if($commV24_4 == ''){
$total = $addRM24_4;
}else {
$total = number_format($d['retail_price']*$commV24_4,2);
}

$final[] = array(
'index' => $d['formT'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $d['package'],
'retail_price' => 'RM '.$d['retail_price'],
'incentives1' => $comm24_4,
'incentives2' => $addRM24_4,
'total' => 'RM '.$total,
'claim' => $c['claim_dt'],
);

}

}else {

foreach ($dataCB as $c){

$customer = Subscriber::where('_id', $c['customer_id'])->first();
$address = $customer->company_name.', '.$customer->address.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;

$final[] = array(
'index' => $c['formT'],
'contract' => $c['contract'],
'wo' => $c['wo'],
'activation' => $c['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $c['package'],
'retail_price' => 'RM '.$c['retail_price'],
'incentives1' => '',
'incentives2' => '',
'total' => '',
'claim' => $c['claim_dt'],
);
}

}

return $final;
}

//Show claim list by company
public function mClaimList($company)
{
$id = Auth::guard('ms')->id();
$user = Staff::with('StaffDetail')->find($id);

$dealer_claimAll = DealerClaim::where('dealer',$company)->get();
$dealer_claimR = DealerClaim::where('formT','R')->where('dealer',$company)->get()->toArray();
$dealer_claimB = DealerClaim::where('formT','B')->where('dealer',$company)->get()->toArray();

foreach ($dealer_claimAll as $c){

$customer = Subscriber::where('_id', $c['customer_id'])->first();
$address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state;

$final[] = array(
'index' => $c['formT'],
'contract' => $c['contract'],
'wo' => $c['wo'],
'activation' => $c['activated_dt'],
'name' => $customer->name,
'address' => $address,
'package' => $c['package'],
'retail_price' => 'RM '.$c['retail_price'],
'incentives1' => '',
'incentives2' => '',
'total' => '',
'claim' => $c['claim_dt'],
);
}

dd($dealer_claimR);

$dataR = $this->returnDataR($dealer_claimR, 'null','null');
$dataB = $this->returnDataB($dealer_claimB, 'null','null');

$combineData = array();
foreach($dataR as $r){
$combineData[] = $r;
}

foreach($dataB as $b){
$combineData[] = $b;
}

dd($dataR);
$i = 0;
$nested_data = array();
if(!empty($combineData)){
foreach ($combineData as $c){
$i++;
array_push($nested_data, array(
'index' => $i.$c['index'],
'contract' => $c['contract'],
'wo' => $c['wo'],
'activated_dt' => $c['activation'],
'name' => $c['name'],
'address' => $c['address'],
'package' => $c['package'],
'retail_price' => $c['retail_price'],
'incentives1' => $c['incentives1'],
'incentives2' => $c['incentives2'],
'total' => $c['total'],
'claim' => $c['claim'],
));
}
}
return \DataTables::of($nested_data)->make(true);
}
}

+ 116
- 0
app/Http/Controllers/DS/ProfileControllerA.php Zobrazit soubor

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

namespace App\Http\Controllers\DS;

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\Staff;
use App\Model\StaffDetail;
use App\Model\WorkOrder;
use File;

class ProfileControllerA extends Controller
{

public function encryptPassword($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '28472B4B6250655368566D5970337336';
$secret_iv = md5(md5($string)); //'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if( $action == 'decrypt' ) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}


public function viewProfile(){

$id = Auth::guard('agent')->id();
$user = Staff::with('StaffDetail')->find($id);

return view('sales.view_profile',compact('user'));
}

public function updateProfilePicture(Request $request){
$this->validate($request, [
'prof_img' => 'mimes:jpeg,jpg,png|required|dimensions:width=128,height=128'
]);


$pathIcon = '';
if($request->hasfile('prof_img')){
// Move / Upload Icon into server
$destinationPath = 'assets/avatar';
// create folder/dir if not exist
if(!File::exists(public_path().$destinationPath)){
File::makeDirectory(public_path().$destinationPath,0777,true);
}

$icon = $request->file('prof_img');
$icon->move($destinationPath,$request->id.'.'.$icon->getClientOriginalExtension());
$pathIcon = $destinationPath.'/'.$request->id.'.'.$icon->getClientOriginalExtension();
}

$user = Staff::with('StaffDetail')->where('_id',$request->id)->first();
$user->StaffDetail->user_pic = $pathIcon;
$user->StaffDetail->save();

if($pathIcon != ''){
return redirect()->back()->with('success_msg', 'Success update your image profile');
}else{
return redirect()->back()->with('error_msg', 'Cant update your image profile');
}
}

public function updateFullName(Request $request){
$user = Staff::with('StaffDetail')->where('_id',$request->id)->first();
$user->StaffDetail->name = $request->name;
$user->StaffDetail->save();

return redirect()->back()->with('success_msg', 'Success update your full name');
}

public function updateIdentity(Request $request){
$user = Staff::with('StaffDetail')->where('_id',$request->id)->first();
$user->StaffDetail->ic = $request->ic;
$user->StaffDetail->save();

return redirect()->back()->with('success_msg', 'Success update your indentity/NRIC');
}

public function updatePhone(Request $request){
$user = Staff::with('StaffDetail')->where('_id',$request->id)->first();
$user->StaffDetail->phone = $request->phone;
$user->StaffDetail->save();

return redirect()->back()->with('success_msg', 'Success update your phone');
}

public function updatePassword(Request $request){
$user = Staff::with('StaffDetail')->where('_id',$request->id)->first();

$enc_pass = $this->encryptPassword('encrypt',$request->password);
$user->password = $enc_pass;
$user->save();
$user->StaffDetail->password = $enc_pass;
$user->StaffDetail->save();

return redirect()->back()->with('success_msg', 'Success update your password');
}
}

+ 314
- 0
app/Http/Controllers/DS/SalesController.php Zobrazit soubor

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

namespace App\Http\Controllers\DS;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use Validator;
use PDF;

use App\Staff;
use App\Model\StaffDetail;
use App\Model\Form;
use App\Model\Subscriber;
use App\Model\PackageDetail;
use App\Model\FormStatus;
use App\Model\WorkOrder;
use App\Model\Docket;
use App\Model\Coverage;
use App\Model\DealerClaim;
use App\Model\Commission;
use App\Model\Company;

class SalesController extends Controller
{
/***
/ Application Form List
***/
public function viewAppList(){

$id = Auth::guard('agent')->id();
$user = Staff::with('StaffDetail')->find($id);
return view('sales.application-form-list',compact('user'));
}


public function gApplicationList1(){

$id = Auth::guard('agent')->id();
$user = Staff::with('StaffDetail')->find($id);

$forms = Form::with('Subscriber','PackageDetail','WorkOrder')->where('dealer_id', $user->_id)->orderBy('created_at','desc')->get();

$i = 0; $street = ''; $n1 = '';
$curr = Carbon::now()->getTimestamp();
$nested_data = array();
if(!empty($forms)){
foreach ($forms as $c){
if(empty($c->WorkOrder)){
$i++;

if($c->Subscriber->street != null){
$street = $c->Subscriber->street;
}

$agentName = StaffDetail::where('_id',$c->dealer_id)->first();

$n1 = '';
$reg_time = $c->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$address = ''; $name = '';
if($c->type_application == 'R'){
$address = $c->Subscriber->building_name;
$name = $c->Subscriber->name;
}else if($c->type_application == 'B'){
$address = '-';
$name = $c->Subscriber->company_name;
}

array_push($nested_data, array(
'index' => $n1.$i.$c->type_application,
'name' => $name,
'phone' => $c->Subscriber->phone1,
'unit' => $c->Subscriber->unit_no,
'building' => $address,
'street' => $street,
'postcode' => $c->Subscriber->postcode,
'city' => $c->Subscriber->city,
'sales' => $agentName->name,
'action' => $c->_id
));
}
}
}
return \DataTables::of($nested_data)->make(true);
}

public function gApplicationList2(){

$id = Auth::guard('agent')->id();
$user = Staff::with('StaffDetail')->find($id);

$forms = Form::with('Subscriber','PackageDetail','WorkOrder')->where('dealer_id', $user->_id)->orderBy('created_at','desc')->get();

$i = 0; $street = ''; $n1 = '';
$curr = Carbon::now()->getTimestamp();
$nested_data = array();
if(!empty($forms)){
foreach ($forms as $c){
if(!empty($c->WorkOrder)){

if($c->WorkOrder->status != 'Completed') {
$i++;

if($c->Subscriber->street != null){
$street = $c->Subscriber->street;
}

$agentName = StaffDetail::where('_id',$c->dealer_id)->first();

$n1 = '';
$reg_time = $c->created_at;
$expiry_date = $reg_time->addDays(3);
$expiry_date = $expiry_date->getTimestamp();

if($curr < $expiry_date) {
$n1 = "New/";
}

$address = ''; $name = '';
if($c->type_application == 'R'){
$address = $c->Subscriber->building_name;
$name = $c->Subscriber->name;
}else if($c->type_application == 'B'){
$address = '-';
$name = $c->Subscriber->company_name;
}

array_push($nested_data, array(
'index' => $n1.$i.$c->type_application,
'name' => $name,
'phone' => $c->Subscriber->phone1,
'unit' => $c->Subscriber->unit_no,
'building' => $address,
'street' => $street,
'postcode' => $c->Subscriber->postcode,
'city' => $c->Subscriber->city,
'sales' => $agentName->name,
'action' => $c->_id
));
}
}
}
}
return \DataTables::of($nested_data)->make(true);
}

public function gApplicationList3($year, $month){

$id = Auth::guard('agent')->id();
$user = Staff::with('StaffDetail')->find($id);

$forms = Form::with('Subscriber','PackageDetail','WorkOrder')->where('dealer_id', $user->_id)->orderBy('created_at','desc')->get();

$mY = '';
if($year != 'null' && $month != 'null'){
$mY = $year.'-'.$month;
}

$i = 0; $street = ''; $n1 = '';
$final = array(); $filter = array();

$curr = Carbon::now()->getTimestamp();
$nested_data = array();
if(!empty($forms)){
foreach ($forms as $f){
if(!empty($f->WorkOrder)){

if($f->WorkOrder->status == 'Completed') {

$w = WorkOrder::with('Docket')->where('wo', $f->WorkOrder->wo)->first();
if(!empty($w->Docket)){
$dealer = StaffDetail::where('_id', $f->dealer_id)->first();
$i++;

$address = ''; $name = '';
if($f->type_application == 'R'){
$address = $f->Subscriber->building_name;
$name = $f->Subscriber->name;
}else if($f->type_application == 'B'){
$address = '-';
$name = $f->Subscriber->company_name;
}

array_push($nested_data, array(
'index' => $i.$f->type_application,
'wo' => $w->wo,
'do' => $f->WorkOrder->docket_id,
'activated' => $w->Docket->end_job,
'name' => $name,
'phone' => $f->Subscriber->phone1,
'unit' => $f->Subscriber->unit_no,
'building' => $address,
'street' => $f->Subscriber->street,
'postcode' => $f->Subscriber->postcode,
'city' => $f->Subscriber->city,
'sales' => $dealer->name,
'action' => $f->_id
));
// }else {
// $nested_data[] = $w;
// }


// if($mY != ''){
// $docket = Docket::where('work_order_id', $c->WorkOrder->wo)->first();
// $cDate = date('Y-m', strtotime($docket->end_job));
// if($mY == $cDate){
// $filter[] = $c->_id;
// }
// $filter[] = $c->_id;
// }else {
// }

}
}

// if(!empty($filter)){

// if(array_search($c->_id,$filter) !== False) {

// $i++;

// if($c->Subscriber->street != null){
// $street = $c->Subscriber->street;
// }

// $agentName = StaffDetail::where('_id',$c->dealer_id)->first();

// $n1 = '';
// $reg_time = $c->created_at;
// $expiry_date = $reg_time->addDays(3);
// $expiry_date = $expiry_date->getTimestamp();

// if($curr < $expiry_date) {
// $n1 = "New/";
// }

// $docket = Docket::where('work_order_id',$c->WorkOrder->wo)->first();
// array_push($nested_data, array(
// 'index' => $n1.$i.$c->type_application,
// 'wo' => $c->WorkOrder->wo,
// 'do' => $docket->docket_id,
// 'activated' => $docket->end_job,
// 'name' => $c->Subscriber->name,
// 'phone' => $c->Subscriber->phone1,
// 'unit' => $c->Subscriber->unit_no,
// 'building' => $c->Subscriber->building_name,
// 'street' => $street,
// 'postcode' => $c->Subscriber->postcode,
// 'city' => $c->Subscriber->city,
// 'sales' => $agentName->name,
// 'action' => $c->_id
// ));

// }
}
}
}
return \DataTables::of($nested_data)->make(true);
}

/***
/ Application Form
***/
public function showResidentialForm(){

$id = Auth::guard('agent')->id();
$user = Staff::with('StaffDetail')->find($id);

return view('sales.residential-form',compact('user'));
}

public function showBusinessForm(){

$id = Auth::guard('agent')->id();
$user = Staff::with('StaffDetail')->find($id);

return view('sales.business-form',compact('user'));
}

/***
/ Form
***/

public function getOrderHistory($id){

$data = array();
$order_history = FormStatus::where('form_id', $id)->get();

foreach($order_history as $oh) {

$data[] = array(
'date' => Carbon::parse($oh->created_at)->setTimezone('Asia/Kuala_Lumpur')->toDateTimeString(),
'status' => $oh->status,
'desc' => $oh->desc
);
}

$json = json_encode($data);
return $json;
}
}

+ 1276
- 0
app/Http/Controllers/DS/TestController.php
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 560
- 0
app/Http/Controllers/Form/BusinessController.php Zobrazit soubor

@@ -0,0 +1,560 @@
<?php
namespace App\Http\Controllers\Form;

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

use App\Mail\CustomerBInvoice;
use App\Jobs\SendCustomerInvoiceB;

use Carbon\Carbon;
use Validator;
use File;

use App\Model\Coverage;
use App\Model\Product;

use App\Model\Form;
use App\Model\Subscriber;
use App\Model\PackageDetail;
use App\Model\FormStatus;

use App\Staff;
use App\Model\StaffDetail;

class BusinessController extends Controller
{
public function successSubmit(){
return view('sales.form.after_submit_form');
}

public function successVerified(){
return view('sales.form.success_verify');
}

public function sendInvoice($subscriber_id) {

$subscriber = Subscriber::with('Form')->where('subscriber_id',$subscriber_id)->first();
$form = Form::with('Subscriber','PackageDetail')->where('_id',$subscriber->_id)->first();
$product = Product::where('speed',$form->PackageDetail->name)->where('formT',$form->type_application)->first();
SendCustomerInvoiceB::dispatch($form, $product, $form->Subscriber->email);

return $form->_id;
}

function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}


public function viewFormAddress($package) {

$dealer_id = '';
return view('sales.form.business_address', compact('package','dealer_id'));
}

public function viewFormApplication(Request $request) {
$data = array();

array_push($data, array(
'unit_no' => $request->unit_no,
'caddress' => $request->caddress,
'ccity' => $request->ccity,
'cstate' => $request->cstate,
'postcode' => $request->postcode,
'package' => $request->package
));
return view('sales.form.business_application_information', compact('data'));
}

public function viewFormPackage(Request $request)
{
$data = array();
array_push($data, array(
'unit_no' => $request->unit_no,
'caddress' => $request->caddress,
'ccity' => $request->ccity,
'cstate' => $request->cstate,
'postcode' => $request->postcode,
'package' => $request->package,
'application' => $request->application,
'company_name' => $request->company_name,
'company_register' => $request->company_register,
'company_number' => $request->company_number,
'company_fax' => $request->company_fax,
'full_name' => $request->full_name,
'nric_passport' => $request->nric_passport,
'designation' => $request->designation,
'contact_primary' => $request->contact_primary,
'contact_secondary' => $request->contact_secondary,
'email' => $request->email,
));

$pg = $request->package;

return view('sales.form.business_package', compact('data','pg'));
}

public function viewFormPreview(Request $request){
$data = array();

$product = Product::where('formT','B')->where('package_name',$request->package)->first();
$otc = 0.0;

$deposit = $product->deposit;

if($request->subscription == '24'){
$otc = 0.0;
}else {
$otc = 300;
}

$gst = number_format(floatval($product->retail_price) * 1.06,2);

$voice = "No";
if($request->has('voice')){
$voice = $request->voice;
if($request->voice == 'Yes' && $request->subscription == '12'){
$otc += 100;
}
}else {
$voice = "No";
}

$IP = '';
if($request->ip == 'custom'){
$IP = $request->custom;
}else{
$IP = $request->ip;
}


$total = number_format((floatval($product->retail_price) * 1.06) + ($otc * 1.06) + $deposit, 2);

array_push($data, array(
'unit_no' => $request->unit_no,
'caddress' => $request->caddress,
'ccity' => $request->ccity,
'cstate' => $request->cstate,
'postcode' => $request->postcode,
'package' => $request->package,
'application' => $request->application,
'company_name' => $request->company_name,
'company_register' => $request->company_register,
'company_number' => $request->company_number,
'company_fax' => $request->company_fax,
'full_name' => $request->full_name,
'nric_passport' => $request->nric_passport,
'designation' => $request->designation,
'contact_primary' => $request->contact_primary,
'contact_secondary' => $request->contact_secondary,
'email' => $request->email,
'subscription' => $request->subscription,
'billing' => $request->billing,
'voice' => $voice,
'ip' => $IP,
'thedate' => $request->thedate,
));

return view('sales.form.business_preview', compact('data','product','deposit','otc','gst','total'));
}

public function storeFormData(Request $request){

$su_id = ''; $pathIconF = ''; $pathIconB = ''; $pathForm9 = ''; $pathForm24 = '';
$pathVisaF = ''; $pathVisaB = '';

do {
$su_id = strtoupper('CBB-'.$this->random_code(6).'B');
} while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);

$destinationPath = 'document/'.$su_id;
// create folder/dir if not exist
if(!File::exists(public_path().'/'.$destinationPath)){
File::makeDirectory(public_path().'/'.$destinationPath,0777,true);
}


if($request->hasfile('front_ic')){

$icon = $request->file('front_ic');
$icon->move($destinationPath,'frontic.'.$icon->getClientOriginalExtension());
$pathIconF = '/'.$destinationPath.'/frontic.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('back_ic')){

$icon = $request->file('back_ic');
$icon->move($destinationPath,'backic.'.$icon->getClientOriginalExtension());
$pathIconB = '/'.$destinationPath.'/backic.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('form9')){

$icon = $request->file('form9');
$icon->move($destinationPath,'formD.'.$icon->getClientOriginalExtension());
$pathForm9 = '/'.$destinationPath.'/formD.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('form_24')){

$icon = $request->file('form_24');
$icon->move($destinationPath,'formA_B.'.$icon->getClientOriginalExtension());
$pathForm24 = '/'.$destinationPath.'/formA_B.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('visaF')){

$icon = $request->file('visaF');
$icon->move($destinationPath,'visaF.'.$icon->getClientOriginalExtension());
$pathVisaF = '/'.$destinationPath.'/visaF.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('visaB')){

$icon = $request->file('visaB');
$icon->move($destinationPath,'visaB.'.$icon->getClientOriginalExtension());
$pathVisaB = '/'.$destinationPath.'/visaB.'.$icon->getClientOriginalExtension();
}

if($pathForm9 != '' && $pathIconB != '' && $pathIconF != ''){

$sl = Form::create([
'type_service' => $request->application,
'type_application' => 'B',
'status_payment' => 'paid',
'status_email' => 'unverified',
'remark_form' => ''
]);

$product = Product::where('formT','B')->where('package_name',$request->package)->first();

$sdl = new Subscriber();
$sdl->subscriber_id = $su_id;
$sdl->name = $request->full_name;
$sdl->ic = $request->nric_passport;
$sdl->company_name = $request->company_name;
$sdl->company_reg = $request->company_register;
$sdl->company_num = $request->company_number;
$sdl->company_fax = $request->company_fax;
$sdl->designation = $request->designation;
$sdl->email = $request->email;
$sdl->phone1 = $request->contact_primary;
$sdl->phone2 = $request->contact_secondary;
$sdl->unit_no = $request->unit_no;
$sdl->street = $request->caddress;
$sdl->postcode = $request->postcode;
$sdl->city = $request->ccity;
$sdl->state = $request->cstate;
$sdl->front_ic = $pathIconF;
$sdl->back_ic = $pathIconB;
$sdl->form24_49 = $pathForm24;
$sdl->form9_44 = $pathForm9;
$sdl->visaF = $pathVisaF;
$sdl->visaB = $pathVisaB;
$packageD = new PackageDetail();
$packageD->contract = $request->subscription;
$packageD->name = $product->speed;
if($request->subscription == '24' && $product->speed == '100'){
$packageD->montly_fee = '1 Month FREE';
}else {
$packageD->montly_fee = $request->gst;
}
$packageD->voice_fee = $request->voice;
$packageD->ip = $request->ip;
$packageD->deposit = $request->deposit;
$packageD->upfront_payment = $request->otc;
$packageD->rfs = $request->rfs;

$sl->subscriber()->save($sdl);
$sl->packagedetail()->save($packageD);

$f_id = $this->sendInvoice($su_id);
$stat = new FormStatus();
$stat->form_id = $f_id;
$stat->status_id = 1;
$stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$stat->status = 'Sumbitted';
$stat->desc = 'The form already been submit';
$sl->formstatus()->save($stat);

return redirect('http://db.citybroadband.my/business/application-form/success-submit');
}
}

/***
** Dealer
***/

public function viewFormAddressD($package,$dealer_id) {
return view('sales.form.dealer.business_address', compact('package','dealer_id'));
}

public function viewFormApplicationD(Request $request) {
$data = array();

array_push($data, array(
'unit_no' => $request->unit_no,
'caddress' => $request->caddress,
'ccity' => $request->ccity,
'cstate' => $request->cstate,
'postcode' => $request->postcode,
'package' => $request->package,
'dealer_id' => $request->dealer_id,
));
return view('sales.form.dealer.business_application_information', compact('data'));
}

public function viewFormPackageD(Request $request)
{
$data = array();
array_push($data, array(
'unit_no' => $request->unit_no,
'caddress' => $request->caddress,
'ccity' => $request->ccity,
'cstate' => $request->cstate,
'postcode' => $request->postcode,
'package' => $request->package,
'application' => $request->application,
'company_name' => $request->company_name,
'company_register' => $request->company_register,
'company_number' => $request->company_number,
'company_fax' => $request->company_fax,
'full_name' => $request->full_name,
'nric_passport' => $request->nric_passport,
'ip' => $request->ip,
'designation' => $request->designation,
'contact_primary' => $request->contact_primary,
'contact_secondary' => $request->contact_secondary,
'email' => $request->email,
'dealer_id' => $request->dealer_id,
));

$pg = $request->package;

return view('sales.form.dealer.business_package', compact('data','pg'));
}

public function viewFormPreviewD(Request $request){
$data = array();

$product = Product::where('formT','B')->where('package_name',$request->package)->first();
$otc = 0.0;

$deposit = $product->deposit;

if($request->subscription == '24'){
$otc = 0.0;
}else {
$otc = 300;
}

$gst = number_format(floatval($product->retail_price) * 1.06,2);

$voice = "No";
if($request->has('voice')){
$voice = $request->voice;
if($request->voice == 'Yes' && $request->subscription == '12'){
$otc += 100;
}
}else {
$voice = "No";
}

$IP = '';
if($request->ip == 'custom'){
$IP = $request->custom;
}else{
$IP = $request->ip;
}
$total = number_format((floatval($product->retail_price) * 1.06) + ($otc * 1.06) + $deposit, 2);

array_push($data, array(
'unit_no' => $request->unit_no,
'caddress' => $request->caddress,
'ccity' => $request->ccity,
'cstate' => $request->cstate,
'postcode' => $request->postcode,
'package' => $request->package,
'application' => $request->application,
'company_name' => $request->company_name,
'company_register' => $request->company_register,
'company_number' => $request->company_number,
'company_fax' => $request->company_fax,
'full_name' => $request->full_name,
'nric_passport' => $request->nric_passport,
'designation' => $request->designation,
'contact_primary' => $request->contact_primary,
'contact_secondary' => $request->contact_secondary,
'email' => $request->email,
'subscription' => $request->subscription,
'billing' => $request->billing,
'voice' => $voice,
'ip' => $IP,
'thedate' => $request->thedate,
'dealer_id' => $request->dealer_id,
));

return view('sales.form.dealer.business_preview', compact('data','product','deposit','otc','gst','total'));
}

public function storeFormDataD(Request $request){

$su_id = ''; $pathIconF = ''; $pathIconB = ''; $pathForm9 = ''; $pathForm24 = '';
$pathVisaF = ''; $pathVisaB = '';

do {
$su_id = strtoupper('CBB-'.$this->random_code(6).'B');
} while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);

$destinationPath = 'document/'.$su_id;
// create folder/dir if not exist
if(!File::exists(public_path().'/'.$destinationPath)){
File::makeDirectory(public_path().'/'.$destinationPath,0777,true);
}


if($request->hasfile('front_ic')){

$icon = $request->file('front_ic');
$icon->move($destinationPath,'frontic.'.$icon->getClientOriginalExtension());
$pathIconF = '/'.$destinationPath.'/frontic.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('back_ic')){

$icon = $request->file('back_ic');
$icon->move($destinationPath,'backic.'.$icon->getClientOriginalExtension());
$pathIconB = '/'.$destinationPath.'/backic.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('form9')){

$icon = $request->file('form9');
$icon->move($destinationPath,'formD.'.$icon->getClientOriginalExtension());
$pathForm9 = '/'.$destinationPath.'/formD.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('form_24')){

$icon = $request->file('form_24');
$icon->move($destinationPath,'formA_B.'.$icon->getClientOriginalExtension());
$pathForm24 = '/'.$destinationPath.'/formA_B.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('visaF')){

$icon = $request->file('visaF');
$icon->move($destinationPath,'visaF.'.$icon->getClientOriginalExtension());
$pathVisaF = '/'.$destinationPath.'/visaF.'.$icon->getClientOriginalExtension();
}

if($request->hasfile('visaB')){

$icon = $request->file('visaB');
$icon->move($destinationPath,'visaB.'.$icon->getClientOriginalExtension());
$pathVisaB = '/'.$destinationPath.'/visaB.'.$icon->getClientOriginalExtension();
}

if($pathForm9 != '' && $pathIconB != '' && $pathIconF != ''){

$staff = Staff::with('StaffDetail')->where('_id',$request->dealer_id)->first();
if(!empty($staff)){

$sl = new Form();
$sl->type_service = $request->application;
$sl->type_application = 'B';
$sl->status_payment = 'paid';
$sl->status_email = 'unverified';
$sl->remark_form = '';
$sl->dealer_id = $request->dealer_id;
$sl->company_id = $staff->StaffDetail->company_id;
$staff->form()->save($sl);
$coverage = Coverage::where('_id',$request->coverage)->first();

$product = Product::where('formT','B')->where('package_name',$request->package)->first();

$sdl = new Subscriber();
$sdl->subscriber_id = $su_id;
$sdl->name = $request->full_name;
$sdl->ic = $request->nric_passport;
$sdl->company_name = $request->company_name;
$sdl->company_reg = $request->company_register;
$sdl->company_num = $request->company_number;
$sdl->company_fax = $request->company_fax;
$sdl->designation = $request->designation;
$sdl->email = $request->email;
$sdl->phone1 = $request->contact_primary;
$sdl->phone2 = $request->contact_secondary;
$sdl->unit_no = $request->unit_no;
$sdl->street = $request->caddress;
$sdl->postcode = $request->postcode;
$sdl->city = $request->ccity;
$sdl->state = $request->cstate;
$sdl->front_ic = $pathIconF;
$sdl->back_ic = $pathIconB;
$sdl->form24_49 = $pathForm24;
$sdl->form9_44 = $pathForm9;
$sdl->visaF = $pathVisaF;
$sdl->visaB = $pathVisaB;
$packageD = new PackageDetail();
$packageD->contract = $request->subscription;
$packageD->name = $product->speed;
if($request->subscription == '24' && $product->speed == '100'){
$packageD->montly_fee = '1 Month FREE';
}else {
$packageD->montly_fee = $request->gst;
}
$packageD->voice_fee = $request->voice;
$packageD->ip = $request->ip;
$packageD->deposit = $request->deposit;
$packageD->upfront_payment = $request->otc;
$packageD->rfs = $request->rfs;

$sl->subscriber()->save($sdl);
$sl->packagedetail()->save($packageD);

$f_id = $this->sendInvoice($su_id);
$stat = new FormStatus();
$stat->form_id = $f_id;
$stat->status_id = 1;
$stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$stat->status = 'Sumbitted';
$stat->desc = 'The form already been submit';
$sl->formstatus()->save($stat);

return redirect('http://db.citybroadband.my/business/application-form/success-submit');
}
}
}

public function verifyEmail($subscriber_id){
$subscriber = Subscriber::where('subscriber_id',$subscriber_id)->first();
if(!empty($subscriber)){
$form = Form::where('_id',$subscriber->_id)->first();
if(!empty($form)){
if($form->status_email == 'unverified'){
$form->status_email = 'verified';
$form->save();

$stat = new FormStatus();
$stat->form_id = $form->_id;
$stat->status_id = 2;
$stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$stat->status = 'Verified';
$stat->desc = 'Email already been verified by customer';
$form->formstatus()->save($stat);

return redirect('http://db.citybroadband.my/business/application-form/success-verified');
}
}
}
}
}

+ 42
- 0
app/Http/Controllers/Form/FormController.php Zobrazit soubor

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers\Form;

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

use App\Mail\CustomerInvoice;
use App\Jobs\SendCustomerInvoice;

use Carbon\Carbon;
use Validator;
use File;

use App\Model\Coverage;
use App\Model\Product;

use App\Model\Form;
use App\Model\Subscriber;
use App\Model\PackageDetail;
use App\Model\FormStatus;

class FormController extends Controller
{
public function updateStatus($f_id){
$fm = Form::where('_id',$f_id)->first();
if(!empty($fm)){
$fm->status_email = 'verified';
$fm->save();

$formH = new FormStatus;
$formH->form_id = $fm->_id;
$formH->status_id = 2;
$formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$formH->status = 'Verified';
$formH->desc = 'Email already been verified by Customer Service';

$fm->formstatus()->save($formH);
return redirect('/customer-service/new/customer/list');
}
}
}

+ 593
- 0
app/Http/Controllers/Form/ResidentialController.php Zobrazit soubor

@@ -0,0 +1,593 @@
<?php
namespace App\Http\Controllers\Form;

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

use App\Mail\CustomerInvoice;
use App\Jobs\SendCustomerInvoice;

use Carbon\Carbon;
use Validator;
use File;

use App\Model\Coverage;
use App\Model\Product;

use App\Model\Form;
use App\Model\Subscriber;
use App\Model\PackageDetail;
use App\Model\FormStatus;

use App\Staff;
use App\Model\StaffDetail;

class ResidentialController extends Controller
{

public function successSubmit(){
return view('sales.form.after_submit_form');
}

public function successVerified(){
return view('sales.form.success_verify');
}

public function sendInvoice($subscriber_id) {

$subscriber = Subscriber::with('Form')->where('subscriber_id',$subscriber_id)->first();
$form = Form::with('Subscriber','PackageDetail')->where('_id',$subscriber->_id)->first();
$product = Product::where('speed',$form->PackageDetail->name)->where('formT',$form->type_application)->first();
SendCustomerInvoice::dispatch($form, $product, $form->Subscriber->email);

return $form->_id;
}

public function sendInvoice1($subscriber_id) {

$subscriber = Subscriber::with('Form')->where('subscriber_id',$subscriber_id)->first();
$form = Form::with('Subscriber','PackageDetail')->where('_id',$subscriber->_id)->first();
$product = Product::where('speed',$form->PackageDetail->name)->where('formT',$form->type_application)->first();
SendCustomerInvoice::dispatch($form, $product, 'nsakinahs1991@gmail.com');

return $form->_id;
}

function random_code($limit) {
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}

public function viewFormAddress($package) {

$dealer_id = '';
$coverage = Coverage::where('Type','R')->orderBy('building_name')->get();
return view('sales.form.residential_address', compact('coverage','package','dealer_id'));
}

public function viewFormApplication(Request $request) {
$data = array();

array_push($data, array(
'coverage' => $request->coverage,
'unit' => $request->unit,
'street' => $request->street,
'package' => $request->package
));
return view('sales.form.residential_application_information', compact('data'));
}

public function viewFormPackage(Request $request) {
$data = array();

$citizen = ''; $street = '';
if($request->citizenship == "Malaysian"){
$citizen = $request->citizenship;
}
else {
$citizen = $request->citizenlist;
}

if($request->street != null){
$street = $request->street;
}

array_push($data, array(
'coverage' => $request->coverage,
'unit' => $request->unit,
'street' => $street,
'package' => $request->package,
'application' => $request->application,
'name' => $request->name,
'nric_passport' => $request->nric_passport,
'gender' => $request->gender,
'race' => $request->race,
'contact_primary' => $request->contact_primary,
'contact_secondary' => $request->contact_secondary,
'citizenship' => $citizen,
'email' => $request->email
));

$pg = $request->package;

return view('sales.form.residential_package', compact('data','pg','citizen'));
}

public function viewFormPreview(Request $request){
$data = array();

$coverage = Coverage::where('_id',$request->coverage)->first();
$product = Product::where('formT','R')->where('package_name',$request->package)->first();
$otc = 0.0; $deposit = 0.0;

$voice = "No";
if($request->has('voice')){
$voice = $request->voice;
}else {
$voice = "No";
}

if($request->citizenship != 'Malaysian' && $request->subscription == '12' && $voice == 'No'){
$otc = 300;
$deposit = $product->deposit;
}else if($request->citizenship != 'Malaysian' && $request->subscription == '12' && $voice == 'Yes'){
$otc = 300 + 100;
$deposit = $product->deposit;
}else if($request->citizenship != 'Malaysian' && $request->subscription == '24' && $voice == 'No'){
$otc = 0.0;
$deposit = 300;
}else if($request->citizenship != 'Malaysian' && $request->subscription == '24' && $voice == 'Yes') {
$otc = 0.0;
$deposit = 300 + 100;
}else if($request->citizenship == 'Malaysian' && $request->subscription == '24'){
$otc = 0.0;
$deposit = $product->deposit;
}else if($request->citizenship == 'Malaysian' && $request->subscription == '12'){
$otc = 300;
$deposit = $product->deposit;
}

$gst = 0; $total = 0;
if($product->promotion_price != '0' && $request->subscription == '24'){

$gst = number_format(floatval($product->promotion_price) * 1.06,2);
$total = number_format((floatval($product->promotion_price) * 1.06) + ($otc * 1.06) + $deposit, 2);

}else if($product->promotion_price == '0'){

$gst = number_format(floatval($product->retail_price) * 1.06,2);
$total = number_format((floatval($product->retail_price) * 1.06) + ($otc * 1.06) + $deposit, 2);
}


array_push($data, array(
'coverage' => $request->coverage,
'unit' => $request->unit,
'street' => $request->street,
'package' => $request->package,
'application' => $request->application,
'name' => $request->name,
'nric_passport' => $request->nric_passport,
'gender' => $request->gender,
'race' => $request->race,
'contact_primary' => $request->contact_primary,
'contact_secondary' => $request->contact_secondary,
'citizenship' => $request->citizenship,
'email' => $request->email,
'subscription' => $request->subscription,
'billing' => $request->billing,
'voice' => $voice,
'thedate' => $request->thedate,
));

return view('sales.form.residential_preview', compact('data','coverage','product','deposit','otc','gst','total'));
}

public function storeFormData(Request $request){

$su_id = ''; $pathIconF = ''; $pathIconB = ''; $pathVisaF = ''; $pathVisaB = '';

do {
$su_id = strtoupper('CBB-'.$this->random_code(6).'R');
} while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);

$destinationPath = 'document/'.$su_id;
// create folder/dir if not exist
if(!File::exists(public_path().'/'.$destinationPath)){
File::makeDirectory(public_path().'/'.$destinationPath,0777,true);
}

$uploaded = public_path().'/'.$destinationPath;
// Signature
$signature_form = $request->cuss_signature;
$signature_form = str_replace('data:image/jpeg;base64,','',$signature_form);
$signature_form = str_replace('','+',$signature_form);
//convert signature_form
$data = base64_decode($signature_form);
$file = $uploaded."/signature_form.jpg";
$savetoServer = file_put_contents($file,$data);
if (($savetoServer === false) || ($savetoServer == -1)) {
print "Couldn't save signature to jpeg";
}else {

if($request->hasfile('front_ic')){

$icon = $request->file('front_ic');
$icon->move($destinationPath,'frontic.'.strtolower($icon->getClientOriginalExtension()));
$pathIconF = '/'.$destinationPath.'/frontic.'.strtolower($icon->getClientOriginalExtension());
}

if($request->hasfile('back_ic')){

$icon = $request->file('back_ic');
$icon->move($destinationPath,'backic.'.strtolower($icon->getClientOriginalExtension()));
$pathIconB = '/'.$destinationPath.'/backic.'.strtolower($icon->getClientOriginalExtension());
}

if($request->hasfile('visaF')){

$icon = $request->file('visaF');
$icon->move($destinationPath,'visaF.'.strtolower($icon->getClientOriginalExtension()));
$pathVisaF = '/'.$destinationPath.'/visaF.'.strtolower($icon->getClientOriginalExtension());
}

if($request->hasfile('visaB')){

$icon = $request->file('visaB');
$icon->move($destinationPath,'visaB.'.strtolower($icon->getClientOriginalExtension()));
$pathVisaB = '/'.$destinationPath.'/visaB.'.strtolower($icon->getClientOriginalExtension());
}

$sl = Form::create([
'type_service' => $request->application,
'type_application' => 'R',
'status_payment' => 'paid',
'status_email' => 'unverified',
'remark_form' => ''
]);

$coverage = Coverage::where('_id',$request->coverage)->first();
$product = Product::where('formT','R')->where('package_name',$request->package)->first();

$sdl = new Subscriber();
$sdl->subscriber_id = $su_id;
$sdl->name = $request->name;
$sdl->ic = $request->nric_passport;
$sdl->citizen = $request->citizenship;
$sdl->gender = $request->gender;
$sdl->race = $request->race;
$sdl->email = $request->email;
$sdl->phone1 = $request->contact_primary;
$sdl->phone2 = $request->contact_secondary;
$sdl->unit_no = $request->unit;
$sdl->building_name = $coverage->building_name;
$sdl->street = $request->street;
$sdl->postcode = $coverage->postcode;
$sdl->city = $coverage->city;
$sdl->state = $coverage->state;
$sdl->front_ic = $pathIconF;
$sdl->back_ic = $pathIconB;
$sdl->visaF = $pathVisaF;
$sdl->visaB = $pathVisaB;
$sdl->signature = '/'.$destinationPath.'/signature_form.jpg';

$packageD = new PackageDetail();
$packageD->contract = $request->subscription;
$packageD->name = $product->speed;
if($request->subscription == '24' && $product->speed == '100'){
$packageD->montly_fee = '1 Month FREE';
}else {
$packageD->montly_fee = $request->gst;
}
$packageD->voice_fee = $request->voice;
$packageD->deposit = $request->deposit;
$packageD->upfront_payment = $request->otc;
$packageD->rfs = $request->rfs;

$sl->subscriber()->save($sdl);
$sl->packagedetail()->save($packageD);

$f_id = $this->sendInvoice($su_id);
$stat = new FormStatus();
$stat->form_id = $f_id;
$stat->status_id = 1;
$stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$stat->status = 'Sumbitted';
$stat->desc = 'The form already been submit';
$sl->formstatus()->save($stat);

return redirect('http://db.citybroadband.my/residential/application-form/success-submit');
}
}

/**
** Dealer
**/
public function viewFormAddressD($package,$dealer_id) {

$coverage = Coverage::where('Type','R')->orderBy('building_name')->get();
return view('sales.form.dealer.residential_address', compact('coverage','package','dealer_id'));
}

public function viewFormApplicationD(Request $request) {
$data = array();

array_push($data, array(
'coverage' => $request->coverage,
'unit' => $request->unit,
'street' => $request->street,
'package' => $request->package,
'dealer_id' => $request->dealer_id
));

return view('sales.form.dealer.residential_application_information', compact('data'));
}

public function viewFormPackageD(Request $request) {
$data = array();

$citizen = ''; $street = '';
if($request->citizenship == "Malaysian"){
$citizen = $request->citizenship;
}
else {
$citizen = $request->citizenlist;
}

if($request->street != null){
$street = $request->street;
}

array_push($data, array(
'dealer_id' => $request->dealer_id,
'coverage' => $request->coverage,
'unit' => $request->unit,
'street' => $street,
'package' => $request->package,
'application' => $request->application,
'name' => $request->name,
'nric_passport' => $request->nric_passport,
'ip' => $request->ip,
'gender' => $request->gender,
'race' => $request->race,
'contact_primary' => $request->contact_primary,
'contact_secondary' => $request->contact_secondary,
'citizenship' => $citizen,
'email' => $request->email
));

$pg = $request->package;
return view('sales.form.dealer.residential_package', compact('data','pg','citizen'));
}

public function viewFormPreviewD(Request $request){
$data = array();

$coverage = Coverage::where('_id',$request->coverage)->first();
$product = Product::where('formT','R')->where('package_name',$request->package)->first();
$otc = 0.0; $deposit = 0.0;

$voice = "No";
if($request->has('voice')){
$voice = $request->voice;
}else {
$voice = "No";
}

if($request->citizenship != 'Malaysian' && $request->subscription == '12' && $voice == 'No'){
$otc = 300;
$deposit = $product->deposit;
}else if($request->citizenship != 'Malaysian' && $request->subscription == '12' && $voice == 'Yes'){
$otc = 300 + 100;
$deposit = $product->deposit;
}else if($request->citizenship != 'Malaysian' && $request->subscription == '24' && $voice == 'No'){
$otc = 0.0;
$deposit = 300;
}else if($request->citizenship != 'Malaysian' && $request->subscription == '24' && $voice == 'Yes') {
$otc = 0.0;
$deposit = 300 + 100;
}else if($request->citizenship == 'Malaysian' && $request->subscription == '24'){
$otc = 0.0;
$deposit = $product->deposit;
}else if($request->citizenship == 'Malaysian' && $request->subscription == '12'){
$otc = 300;
$deposit = $product->deposit;
}

$gst = 0; $total = 0;
if($product->promotion_price != '0' && $request->subscription == '24'){

$gst = number_format(floatval($product->promotion_price) * 1.06,2);

$total = number_format((floatval($product->promotion_price) * 1.06) + ($otc * 1.06) + $deposit, 2);

}else if($product->promotion_price == '0'){

$gst = number_format(floatval($product->retail_price) * 1.06,2);
$total = number_format((floatval($product->retail_price) * 1.06) + ($otc * 1.06) + $deposit, 2);
}

array_push($data, array(
'dealer_id' => $request->dealer_id,
'coverage' => $request->coverage,
'unit' => $request->unit,
'street' => $request->street,
'package' => $request->package,
'application' => $request->application,
'name' => $request->name,
'nric_passport' => $request->nric_passport,
'gender' => $request->gender,
'race' => $request->race,
'contact_primary' => $request->contact_primary,
'contact_secondary' => $request->contact_secondary,
'citizenship' => $request->citizenship,
'email' => $request->email,
'subscription' => $request->subscription,
'billing' => $request->billing,
'voice' => $voice,
'ip' => $request->ip,
'thedate' => $request->thedate,
));

return view('sales.form.dealer.residential_preview', compact('data','coverage','product','deposit','otc','gst','total'));
}

public function storeFormDataD(Request $request){

$su_id = ''; $pathIconF = ''; $pathIconB = ''; $pathVisaF = ''; $pathVisaB = '';

do {
$su_id = strtoupper('CBB-'.$this->random_code(6).'R');
} while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);

$destinationPath = 'document/'.$su_id;
// create folder/dir if not exist
if(!File::exists(public_path().'/'.$destinationPath)){
File::makeDirectory(public_path().'/'.$destinationPath,0777,true);
}

$uploaded = public_path().'/'.$destinationPath;
// Signature
$signature_form = $request->cuss_signature;
$signature_form = str_replace('data:image/jpeg;base64,','',$signature_form);
$signature_form = str_replace('','+',$signature_form);
//convert signature_form
$data = base64_decode($signature_form);
$file = $uploaded."/signature_form.jpg";
$savetoServer = file_put_contents($file,$data);
if (($savetoServer === false) || ($savetoServer == -1)) {
print "Couldn't save signature to jpeg";
}else {

if($request->hasfile('front_ic')){

$icon = $request->file('front_ic');
$icon->move($destinationPath,'frontic.'.strtolower($icon->getClientOriginalExtension()));
$pathIconF = '/'.$destinationPath.'/frontic.'.strtolower($icon->getClientOriginalExtension());
}

if($request->hasfile('back_ic')){

$icon = $request->file('back_ic');
$icon->move($destinationPath,'backic.'.strtolower($icon->getClientOriginalExtension()));
$pathIconB = '/'.$destinationPath.'/backic.'.strtolower($icon->getClientOriginalExtension());
}

if($request->hasfile('visaF')){

$icon = $request->file('visaF');
$icon->move($destinationPath,'visaF.'.strtolower($icon->getClientOriginalExtension()));
$pathVisaF = '/'.$destinationPath.'/visaF.'.strtolower($icon->getClientOriginalExtension());
}

if($request->hasfile('visaB')){

$icon = $request->file('visaB');
$icon->move($destinationPath,'visaB.'.strtolower($icon->getClientOriginalExtension()));
$pathVisaB = '/'.$destinationPath.'/visaB.'.strtolower($icon->getClientOriginalExtension());
}

// staff
$staff = Staff::with('StaffDetail')->where('_id',$request->dealer_id)->first();
if(!empty($staff)){
$sl = new Form();
$sl->type_service = $request->application;
$sl->type_application = 'R';
$sl->status_payment = 'paid';
$sl->status_email = 'unverified';
$sl->remark_form = '';
$sl->dealer_id = $request->dealer_id;
$sl->company_id = $staff->StaffDetail->company_id;
$staff->form()->save($sl);
$coverage = Coverage::where('_id',$request->coverage)->first();
$product = Product::where('formT','R')->where('package_name',$request->package)->first();

$sdl = new Subscriber();
$sdl->subscriber_id = $su_id;
$sdl->name = $request->name;
$sdl->ic = $request->nric_passport;
$sdl->citizen = $request->citizenship;
$sdl->gender = $request->gender;
$sdl->race = $request->race;
$sdl->email = $request->email;
$sdl->phone1 = $request->contact_primary;
$sdl->phone2 = $request->contact_secondary;
$sdl->unit_no = $request->unit;
$sdl->building_name = $coverage->building_name;
$sdl->street = $request->street;
$sdl->postcode = $coverage->postcode;
$sdl->city = $coverage->city;
$sdl->state = $coverage->state;
$sdl->front_ic = $pathIconF;
$sdl->back_ic = $pathIconB;
$sdl->visaF = $pathVisaF;
$sdl->visaB = $pathVisaB;
$sdl->signature = '/'.$destinationPath.'/signature_form.jpg';

$packageD = new PackageDetail();
$packageD->contract = $request->subscription;
$packageD->name = $product->speed;
if($request->subscription == '24' && $product->speed == '100'){
$packageD->montly_fee = '1 Month FREE';
}else {
$packageD->montly_fee = $request->gst;
}
$packageD->voice_fee = $request->voice;
$packageD->deposit = $request->deposit;
$packageD->upfront_payment = $request->otc;
$packageD->rfs = $request->rfs;

$sl->subscriber()->save($sdl);
$sl->packagedetail()->save($packageD);

$f_id = $this->sendInvoice($su_id);
$stat = new FormStatus();
$stat->form_id = $f_id;
$stat->status_id = 1;
$stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$stat->status = 'Sumbitted';
$stat->desc = 'The form already been submit';
$sl->formstatus()->save($stat);

return redirect('http://db.citybroadband.my/residential/application-form/success-submit');
}
}
}

public function verifyEmail($subscriber_id){
$subscriber = Subscriber::where('subscriber_id',$subscriber_id)->first();
if(!empty($subscriber)){
$form = Form::where('_id',$subscriber->_id)->first();
if(!empty($form)){
if($form->status_email == 'unverified'){
$form->status_email = 'verified';
$form->save();

$stat = new FormStatus();
$stat->form_id = $form->_id;
$stat->status_id = 2;
$stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$stat->status = 'Verified';
$stat->desc = 'Email already been verified by customer';
$form->formstatus()->save($stat);

return redirect('http://db.citybroadband.my/residential/application-form/success-verified');
}
}
}
}


public function resendEmail($subscriber_id){
$f_id = $this->sendInvoice($subscriber_id);
return $f_id;
}
}


+ 87
- 0
app/Http/Kernel.php Zobrazit soubor

@@ -0,0 +1,87 @@
<?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\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::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' => [
'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,

'marketAuth' => \App\Http\Middleware\MarketAuth::class,
'dsAuth' => \App\Http\Middleware\DSAuth::class,
'agentAuth' => \App\Http\Middleware\AgentAuth::class,
'mobileapps' => \App\Http\Middleware\MobileApps::class,
'contractorAuth' => \App\Http\Middleware\ContractorAuth::class,
'csAuth' => \App\Http\Middleware\CSAuth::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,
];
}

+ 24
- 0
app/Http/Middleware/AgentAuth.php Zobrazit soubor

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

namespace App\Http\Middleware;

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

class AgentAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'agent')
{
if (!Auth::guard($guard)->check()) {
return redirect()->guest('/login/dashboard/staff');
}
return $next($request);
}
}

+ 21
- 0
app/Http/Middleware/Authenticate.php Zobrazit soubor

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

+ 24
- 0
app/Http/Middleware/CSAuth.php Zobrazit soubor

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

namespace App\Http\Middleware;

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

class CSAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'cs')
{
if (!Auth::guard($guard)->check()) {
return redirect()->guest('/login/dashboard/admin');
}
return $next($request);
}
}

+ 17
- 0
app/Http/Middleware/CheckForMaintenanceMode.php Zobrazit soubor

@@ -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 = [
//
];
}

+ 24
- 0
app/Http/Middleware/ContractorAuth.php Zobrazit soubor

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

namespace App\Http\Middleware;

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

class ContractorAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'contractor')
{
if (!Auth::guard($guard)->check()) {
return redirect()->guest('/login/dashboard/contractor');
}
return $next($request);
}
}

+ 24
- 0
app/Http/Middleware/DSAuth.php Zobrazit soubor

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

namespace App\Http\Middleware;

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

class DSAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'ds')
{
if (!Auth::guard($guard)->check()) {
return redirect()->guest('/login/dashboard');
}
return $next($request);
}
}

+ 17
- 0
app/Http/Middleware/EncryptCookies.php Zobrazit soubor

@@ -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/MarketAuth.php Zobrazit soubor

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

namespace App\Http\Middleware;

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

class MarketAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'ms')
{
if (!Auth::guard($guard)->check()) {
return redirect()->guest('/login/dashboard/admin');
}
return $next($request);
}
}

+ 24
- 0
app/Http/Middleware/MobileApps.php Zobrazit soubor

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

+ 52
- 0
app/Http/Middleware/RedirectIfAuthenticated.php Zobrazit soubor

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

namespace App\Http\Middleware;

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

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('/home');
// }
switch ($guard) {
case 'cs' :
if (Auth::guard($guard)->check()) {
return redirect()->route('csHome');
}
break;
case 'ms' :
if (Auth::guard($guard)->check()) {
return redirect()->route('mHome');
}
break;
case 'ds' :
if (Auth::guard($guard)->check()) {
return redirect()->route('dHome');
}
break;
case 'agent' :
if (Auth::guard($guard)->check()) {
return redirect()->route('aHome');
}
break;
default:
if (Auth::guard($guard)->check()) {
return redirect()->route('home');
}
break;
}
return $next($request);
}
}

+ 18
- 0
app/Http/Middleware/TrimStrings.php Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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
*/
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 Zobrazit soubor

@@ -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 = [
//
];
}

+ 51
- 0
app/Jobs/SendCustomerInvoice.php Zobrazit soubor

@@ -0,0 +1,51 @@
<?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\Support\Facades\Mail;
use Exception;

use App\Mail\CustomerInvoice;
use App\Model\Form;
use App\Model\Product;
use App\Model\Subscriber;

class SendCustomerInvoice implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $form,$recipient,$product;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Form $form, Product $product, $recipient)
{
//
$this->form = $form;
$this->recipient = $recipient;
$this->product = $product;
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
Mail::to($this->recipient)->send(new CustomerInvoice($this->form,$this->product));
}

public function failed(Exception $exception)
{
//
}
}

+ 51
- 0
app/Jobs/SendCustomerInvoiceB.php Zobrazit soubor

@@ -0,0 +1,51 @@
<?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\Support\Facades\Mail;
use Exception;

use App\Mail\CustomerBInvoice;
use App\Model\Form;
use App\Model\Product;
use App\Model\Subscriber;

class SendCustomerInvoiceB implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $form,$recipient,$product;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Form $form, Product $product, $recipient)
{
//
$this->form = $form;
$this->recipient = $recipient;
$this->product = $product;
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
Mail::to($this->recipient)->send(new CustomerBInvoice($this->form,$this->product));
}

public function failed(Exception $exception)
{
//
}
}

+ 54
- 0
app/Jobs/SendWorkOrder.php Zobrazit soubor

@@ -0,0 +1,54 @@
<?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\Support\Facades\Mail;
use Exception;

use App\Mail\AssignWorkOrder;
use App\Model\WorkOrder;
use App\Model\StaffDetail;
use App\Model\Subscriber;
use App\Model\Company;

class SendWorkOrder implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $work_order,$staff,$recipient,$customer,$company;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct(WorkOrder $work_order,StaffDetail $staff, $recipient,Subscriber $customer,Company $company)
{
//
$this->work_order = $work_order;
$this->recipient = $recipient;
$this->staff = $staff;
$this->customer = $customer;
$this->company = $company;
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
Mail::to($this->recipient)->send(new AssignWorkOrder($this->work_order,$this->staff,$this->customer,$this->company));
}

public function failed(Exception $exception)
{
//
}
}

+ 87
- 0
app/Jobs/StoreDocket.php Zobrazit soubor

@@ -0,0 +1,87 @@
<?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\Staff;
use App\Model\StaffDetail;
use App\Model\Docket;
use App\Model\WorkOrder;
use App\Model\Company;
use App\Model\Form;
use App\Model\PackageDetail;
use App\Model\Subscriber;
use App\Model\FormStatus;

use Carbon\Carbon;


class StoreDocket implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $request, $do, $nature_work, $staff, $signature;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct(array $request, $do, $nature_work, $staff, $signature)
{
//
$this->request = $request;
$this->do = $do;
$this->nature_work = $nature_work;
$this->staff = $staff;
$this->signature = $signature;
}

/**
* Execute the job.
*
* @return void
*/
public function handle(Docket $docket)
{
$note = '';
if(isset($this->request['Note'])){
$note = $this->request['Note'];
}
$docket->work_order_id = $this->request['wo'];
$docket->docket_id = $this->do;
$docket->nature_work = $this->nature_work;
$docket->installer_id = $this->staff;
$docket->end_job = Carbon::now()->toDateTimeString();
$docket->router_serial_number = $this->request['router_serial_number'];
$docket->mac_router = $this->request['mac_router'];
$docket->cable_read = $this->request['cable_read'];
$docket->condition = $this->request['condition'];
$docket->Note = $note;
$docket->Rating1 = $this->request['Rating1'];
$docket->Rating2 = $this->request['Rating2'];
$docket->Rating3 = $this->request['Rating3'];
$docket->customer_signature = $this->signature;

$work_order = WorkOrder::where('wo',$this->request['wo'])->first();
$work_order->docket()->save($docket);
$work_order->status = 'Completed';
$work_order->docket_id = $this->do;
$work_order->save();

$fm = Form::where('_id',$work_order->_id)->first();
$stat = new FormStatus();
$stat->form_id = $fm->_id;
$stat->status_id = 8;
$stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
$stat->status = 'Completed';
$stat->desc = 'This work order already been completed';
$fm->formstatus()->save($stat);
}
}

+ 94
- 0
app/Mail/AssignWorkOrder.php Zobrazit soubor

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

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

use App\Model\WorkOrder;
use App\Staff;
use App\Model\StaffDetail;
use App\Model\Product;
use App\Model\Subscriber;
use App\Model\Company;
use App\Model\Form;
use App\Model\PackageDetail;

use Carbon\Carbon;
use PDF;

class AssignWorkOrder extends Mailable
{
use Queueable, SerializesModels;
public $work_order,$staff,$customer,$company;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct(WorkOrder $work_order,StaffDetail $staff,Subscriber $customer,Company $company)
{
//
$this->work_order = $work_order;
$this->staff = $staff;
$this->customer = $customer;
$this->company = $company;
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{

$wo = WorkOrder::where('wo',$this->work_order->wo)->first();
$form = Form::with('PackageDetail','Subscriber')->where('_id',$wo->_id)->first();
$product = Product::where('formT',$form->type_application)->where('speed',$form->PackageDetail->name)->first();

if(empty($product)){
if($form->PackageDetail->name == "30"){
$product = '30Mbps';
}else{
$product = 'RMbps';
}
}else {
$product = $product->package_name;
}

$created_by = Staff::with('StaffDetail')->where("_id",$wo->created_by)->first();
if(empty($created_by)){
$created_by = '';
}

$created_at = Carbon::parse($wo->created_at)->toDateTimeString();

$address = '';
if($form->type_application == 'R'){
if($form->Subscriber->street != ''){
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}

}else if($form->type_application == 'B'){

if($form->Subscriber->unit_no != ''){
$address = $form->Subscriber->unit_no. ', '.$form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}else {
$address = $form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
}

}

$pdf = PDF::loadView('pdf.workorder-pdf',compact('wo','form','product','created_at','created_by','address'));
$pdf->setPaper('A4', 'potrait');

return $this->from('no-reply@citybroadband.my','no-reply@citybroadband.my')->subject('You Have New Work Order')->view('email.assign_wo')
->attachData($pdf->output(), $wo->wo.'.pdf', ['mime' => 'application/pdf',]);
}
}

+ 40
- 0
app/Mail/CustomerBInvoice.php Zobrazit soubor

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

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

use App\Model\Form;
use App\Model\Subscriber;
use App\Model\Product;

class CustomerBInvoice extends Mailable
{
use Queueable, SerializesModels;
public $form,$product;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Form $form,Product $product)
{
//
$this->form = $form;
$this->product = $product;
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('no-reply@citybroadband.my','no-reply@citybroadband.my')->subject('Verify your City Broadband (CBB) Subscription')->view('email.invoiceb');
}
}

+ 40
- 0
app/Mail/CustomerInvoice.php Zobrazit soubor

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

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

use App\Model\Form;
use App\Model\Subscriber;
use App\Model\Product;

class CustomerInvoice extends Mailable
{
use Queueable, SerializesModels;
public $form,$product;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Form $form,Product $product)
{
//
$this->form = $form;
$this->product = $product;
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('no-reply@citybroadband.my','no-reply@citybroadband.my')->subject('Verify your City Broadband (CBB) Subscription')->view('email.invoice');
}
}

+ 17
- 0
app/Model/AdminDetail.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class AdminDetail extends Eloquent {
//
protected $connection = 'mongodb';
protected $collection = 'dealer_detail';
protected $guarded = ['_id'];

public function dealers() {
return $this->belongsTo('App\Dealer','email','email');
}
}

+ 19
- 0
app/Model/Commission.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class Commission extends Eloquent {
//

use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'commission';
protected $guarded = ['_id'];


}

+ 33
- 0
app/Model/Company.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class Company extends Eloquent {
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'company';
protected $guarded = ['_id'];

public function staff() {
return $this->hasMany('App\Staff','company_id','_id');
}

public function dealer()
{
return $this->hasMany('App\DealerLaravel','company_id','_id');
}

public function workorder() {
return $this->hasMany('App\Model\WorkOrderLaravel','contractor_id','_id');
}

public function form() {
return $this->hasMany('App\Model\FormLaravel','company_id','_id');
}
}

+ 17
- 0
app/Model/Coverage.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class Coverage extends Eloquent {
//

use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'coverage';

protected $guarded = ['_id'];
}

+ 19
- 0
app/Model/DealerClaim.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class DealerClaim extends Eloquent {
//

use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'dealer_claim';
protected $guarded = ['_id'];


}

+ 23
- 0
app/Model/DealerDetail.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class DealerDetailLaravel extends Eloquent {
//
use SoftDeletes;

protected $connection = 'mongodb';
protected $collection = 'dealer_detail';
protected $guarded = ['_id'];


public function dealerlaravel() {
return $this->belongsTo('App\DealerLaravel','company_id','_id');
}


}

+ 23
- 0
app/Model/Docket.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class Docket extends Eloquent {
//

use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'docket';
// protected $fillable = ['_id','docket_id','work_order_id','nature_work','contractor_id','installer_id','customer_id','end_job','router_serial_number','mac_router','cable_read','condition','Note','Rating1','Rating2','Rating3','customer_signature','status','created_at'];

protected $guarded = ['_id'];

public function workorder() {
return $this->belongsTo('App\Model\WorkOrder','work_order_id','wo');
}
}

+ 41
- 0
app/Model/Form.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class Form extends Eloquent {
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'form_submitted';
// protected $guarded = ['_id'];
protected $fillable = ['_id','type_service','type_application','status_payment','status_email','remark_form','created_at'];

public function staff() {
return $this->belongsTo('App\Model\Staff','_id','dealer_id');
}

public function subscriber() {
return $this->hasOne('App\Model\Subscriber','_id','_id');
}

public function packagedetail(){
return $this->hasOne('App\Model\PackageDetail','_id','_id');
}

public function workorder(){
return $this->hasOne('App\Model\WorkOrder','_id','_id');
}

public function formstatus(){
return $this->hasMany('App\Model\FormStatus','form_id','_id');
}

public function company(){
return $this->belongsTo('App\Model\Company','_id','company_id');
}
}

+ 20
- 0
app/Model/FormStatus.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class FormStatus extends Eloquent {
//
use SoftDeletes;

protected $connection = 'mongodb';
protected $collection = 'form_history';
protected $guarded = ['_id'];

public function form() {
return $this->belongsTo('App\Model\Form','_id','form_id');
}
}

+ 13
- 0
app/Model/OldBusiness.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class OldBusiness extends Eloquent {
//
protected $connection = 'mongodb2';
protected $collection = 'business';
protected $guarded = ['_id'];
}

+ 13
- 0
app/Model/OldDocket.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class OldDocket extends Eloquent {
//
protected $connection = 'mongodb2';
protected $collection = 'docket';
protected $guarded = ['_id'];
}

+ 13
- 0
app/Model/OldResidential.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class OldResidential extends Eloquent {
//
protected $connection = 'mongodb2';
protected $collection = 'subscriber';
protected $guarded = ['_id'];
}

+ 13
- 0
app/Model/OldWorkOrder.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class OldWorkOrder extends Eloquent {
//
protected $connection = 'mongodb2';
protected $collection = 'work_details';
protected $guarded = ['_id'];
}

+ 13
- 0
app/Model/OrderHistory.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class OrderHistory extends Eloquent {
//
protected $connection = 'mongodb2';
protected $collection = 'order_history';
protected $guarded = ['_id'];
}

+ 20
- 0
app/Model/PackageDetail.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class PackageDetail extends Eloquent {
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'form_package';
protected $guarded = ['_id'];

public function form() {
return $this->belongsTo('App\Model\Form','_id','_id');
}
}

+ 19
- 0
app/Model/Product.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class Product extends Eloquent {
//

use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'product';
protected $fillable = ['_id','formT','speed','package_name','retail_price','deposit','promotion_price','service_tax','created_at'];


}

+ 15
- 0
app/Model/Question.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class Question extends Eloquent {
//

use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'questions';
}

+ 21
- 0
app/Model/StaffDetail.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\SoftDeletes;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class StaffDetail extends Eloquent {
//
use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'staff_detail';
// protected $guarded = ['_id'];
protected $fillable = ['_id'];

public function staff() {
return $this->belongsTo('App\Staff','_id','_id')->withTrashed();
}
}

+ 20
- 0
app/Model/Subscriber.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class Subscriber extends Eloquent {
//
use SoftDeletes;

protected $connection = 'mongodb';
protected $collection = 'subscribers';
protected $guarded = ['_id'];

public function form() {
return $this->belongsTo('App\Model\Form','_id','_id');
}
}

+ 32
- 0
app/Model/WorkOrder.php Zobrazit soubor

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

namespace App\Model;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class WorkOrder extends Eloquent {
//
// use SoftDeletes;
protected $connection = 'mongodb';
protected $collection = 'work_order';
protected $guarded = ['_id'];

public function form() {
return $this->belongsTo('App\Model\Form','_id','_id');
}

public function staff() {
return $this->belongsTo('App\Model\Staff','_id','installer_id')->withTrashed();
}

public function company() {
return $this->belongsTo('App\Model\Company','_id','contractor_id')->withTrashed();
}

public function docket() {
return $this->hasOne('App\Model\Docket','work_order_id','wo')->withTrashed();
}
}

+ 28
- 0
app/Providers/AppServiceProvider.php Zobrazit soubor

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

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}

/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

+ 30
- 0
app/Providers/AuthServiceProvider.php Zobrazit soubor

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

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];

/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();

//
}
}

+ 21
- 0
app/Providers/BroadcastServiceProvider.php Zobrazit soubor

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

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;

class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();

require base_path('routes/channels.php');
}
}

+ 34
- 0
app/Providers/EventServiceProvider.php Zobrazit soubor

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

namespace App\Providers;

use Illuminate\Support\Facades\Event;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];

/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();

//
}
}

+ 73
- 0
app/Providers/RouteServiceProvider.php Zobrazit soubor

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

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';

/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//

parent::boot();
}

/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();

$this->mapWebRoutes();

//
}

/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}

/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}

+ 40
- 0
app/Staff.php Zobrazit soubor

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

namespace App;

use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
use Jenssegers\Mongodb\Auth\User as Authenticatable;

class Staff extends Authenticatable
{
//
use SoftDeletes;
use Notifiable;
protected $connection = 'mongodb';
protected $collection = 'staff';

// protected $guarded = ['_id'];
protected $fillable = ['_id', 'email', 'password', 'roles_access', 'last_login_at', 'last_login_ip'];
protected $hidden = [
'password', 'remember_token',
];

public function staffdetail() {
return $this->hasOne('App\Model\StaffDetail','_id','_id')->withTrashed();
}

public function company() {
return $this->belongsTo('App\Model\Company','company_id','_id');
}

public function form() {
return $this->hasMany('App\Model\Form','dealer_id','_id');
}

public function workorder() {
return $this->hasMany('App\Model\WorkOrder','installer_id','_id')->withTrashed();
}
}

+ 21
- 0
app/StaffOld.php Zobrazit soubor

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

namespace App;

use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Auth\User as Authenticatable;

class StaffOld extends Authenticatable
{
//
use Notifiable;
protected $connection = 'mongodb2';
protected $collection = 'staff';

protected $guarded = ['_id'];
protected $hidden = [
'password', 'remember_token',
];
}

+ 53
- 0
artisan Zobrazit soubor

@@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);

/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/

$kernel->terminate($input, $status);

exit($status);

+ 55
- 0
bootstrap/app.php Zobrazit soubor

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

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/

$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);

/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);

$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);

$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/

return $app;

+ 2
- 0
bootstrap/cache/.gitignore Zobrazit soubor

@@ -0,0 +1,2 @@
*
!.gitignore

+ 71
- 0
composer.json Zobrazit soubor

@@ -0,0 +1,71 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"barryvdh/laravel-cors": "^0.11.2",
"barryvdh/laravel-dompdf": "^0.8.3",
"daltcore/lara-pdf-merger": "^2.0",
"davejamesmiller/laravel-breadcrumbs": "5.x",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"jenssegers/mongodb": "^3.4",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"lynx39/lara-pdf-merger": "^1.0",
"tymon/jwt-auth": "dev-develop",
"yajra/laravel-datatables-oracle": "~8.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}

+ 6043
- 0
composer.lock
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 0
- 0
config/app.php Zobrazit soubor


Některé soubory nejsou zobrazny, neboť je v této revizi změněno mnoho souborů

Načítá se…
Zrušit
Uložit