You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StoreDocket.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App\Jobs;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Queue\SerializesModels;
  5. use Illuminate\Queue\InteractsWithQueue;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Http\Request;
  9. use App\Staff;
  10. use App\Model\StaffDetail;
  11. use App\Model\Docket;
  12. use App\Model\WorkOrder;
  13. use App\Model\Company;
  14. use App\Model\Form;
  15. use App\Model\PackageDetail;
  16. use App\Model\Subscriber;
  17. use App\Model\FormStatus;
  18. use Carbon\Carbon;
  19. class StoreDocket implements ShouldQueue
  20. {
  21. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  22. protected $request, $do, $nature_work, $staff, $signature;
  23. /**
  24. * Create a new job instance.
  25. *
  26. * @return void
  27. */
  28. public function __construct(array $request, $do, $nature_work, $staff, $signature)
  29. {
  30. //
  31. $this->request = $request;
  32. $this->do = $do;
  33. $this->nature_work = $nature_work;
  34. $this->staff = $staff;
  35. $this->signature = $signature;
  36. }
  37. /**
  38. * Execute the job.
  39. *
  40. * @return void
  41. */
  42. public function handle(Docket $docket)
  43. {
  44. $note = '';
  45. if(isset($this->request['Note'])){
  46. $note = $this->request['Note'];
  47. }
  48. $docket->work_order_id = $this->request['wo'];
  49. $docket->docket_id = $this->do;
  50. $docket->nature_work = $this->nature_work;
  51. $docket->installer_id = $this->staff;
  52. $docket->end_job = Carbon::now()->toDateTimeString();
  53. $docket->router_serial_number = $this->request['router_serial_number'];
  54. $docket->mac_router = $this->request['mac_router'];
  55. $docket->cable_read = $this->request['cable_read'];
  56. $docket->condition = $this->request['condition'];
  57. $docket->Note = $note;
  58. $docket->Rating1 = $this->request['Rating1'];
  59. $docket->Rating2 = $this->request['Rating2'];
  60. $docket->Rating3 = $this->request['Rating3'];
  61. $docket->customer_signature = $this->signature;
  62. $work_order = WorkOrder::where('wo',$this->request['wo'])->first();
  63. $work_order->docket()->save($docket);
  64. $work_order->status = 'Completed';
  65. $work_order->docket_id = $this->do;
  66. $work_order->save();
  67. $fm = Form::where('_id',$work_order->_id)->first();
  68. $stat = new FormStatus();
  69. $stat->form_id = $fm->_id;
  70. $stat->status_id = 8;
  71. $stat->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
  72. $stat->status = 'Completed';
  73. $stat->desc = 'This work order already been completed';
  74. $fm->formstatus()->save($stat);
  75. }
  76. }