InfoModal.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /* * ********************************************************************
  3. * Wordpress_Manager Product developed. (Dec 19, 2017)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\ProxmoxAddon\App\UI\Jobs\Modals;
  20. use ModulesGarden\ProxmoxAddon\App\Models\Whmcs\Hosting;
  21. use ModulesGarden\ProxmoxAddon\App\UI\Jobs\Others\StatusLabel;
  22. use ModulesGarden\ProxmoxAddon\Core\Queue\Models\Job;
  23. use ModulesGarden\ProxmoxAddon\Core\Queue\Models\JobLog;
  24. use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
  25. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Buttons\ModalActionButtons\BaseCancelButton;
  26. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Modals\BaseEditModal;
  27. /**
  28. * Description of CloneModal
  29. *
  30. * @author Pawel Kopec <pawelk@modulesgarden.com>
  31. */
  32. class InfoModal extends BaseEditModal implements AdminArea
  33. {
  34. /**
  35. *
  36. * @var Job
  37. */
  38. protected $job;
  39. public function initContent()
  40. {
  41. $this->initIds('infoModal');
  42. if (!$this->getRequestValue('actionElementId'))
  43. {
  44. return;
  45. }
  46. /**
  47. * @var \ModulesGarden\ProxmoxAddon\App\Models\Job
  48. */
  49. $this->job = Job::findOrFail($this->getRequestValue('actionElementId'));
  50. $this->customTplVars['job'] = $this->job->toArray();
  51. //Job status
  52. $status = $this->job->status ? $this->job->status : 'pending';
  53. $this->customTplVars['status'] = (new StatusLabel())->setStatus($status)->getHtml();
  54. $this->customTplVars['data'] = unserialize($this->job->data);
  55. if ($this->job->rel_type == "hosting" && $this->job->rel_id)
  56. {
  57. /*@var $hosting Hosting*/
  58. $hosting = Hosting::findOrFail($this->job->rel_id);
  59. $this->customTplVars['productName'] = $hosting->product->name;
  60. }
  61. //JobLogs
  62. foreach (JobLog::where('job_id', $this->job->id)->orderBy('id', 'desc')->get() as $jobLog)
  63. {
  64. $log = $jobLog->toArray();
  65. $log['status'] = (new StatusLabel())->setStatus($jobLog->type)->getHtml();
  66. $log['created_at'] = fromMySQLDate($jobLog->created_at, true);
  67. $this->customTplVars['jobLogs'][] = $log;
  68. }
  69. }
  70. protected function initActionButtons()
  71. {
  72. if (!empty($this->actionButtons))
  73. {
  74. return $this;
  75. }
  76. $this->addActionButton(new BaseCancelButton);
  77. return $this;
  78. }
  79. }