DetailModal.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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\Vms\Modals;
  20. use ModulesGarden\ProxmoxAddon\Core\Helper;
  21. use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
  22. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Buttons\ModalActionButtons\BaseCancelButton;
  23. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Modals\BaseEditModal;
  24. use WHMCS\Database\Capsule as DB;
  25. use WHMCS\Service\Service;
  26. /**
  27. * Description of CloneModal
  28. *
  29. * @author Pawel Kopec <pawelk@modulesgarden.com>
  30. */
  31. class DetailModal extends BaseEditModal implements AdminArea
  32. {
  33. public function initContent()
  34. {
  35. $this->initIds('vmsDetailModal');
  36. /* @var $request \ModulesGarden\ProxmoxAddon\Core\Http\Request */
  37. $request = Helper\sl('request');
  38. if (!$request->get('actionElementId'))
  39. {
  40. return;
  41. }
  42. $hosting = Service::findOrFail($request->get('actionElementId'));
  43. if ($hosting->product->module == "ProxmoxCloudVps")
  44. {
  45. $this->customTplVars['vms'] = DB::table('ProxmoxAddon_Vm')
  46. ->where('hosting_id', $hosting->id)
  47. ->select('node', 'vmid', 'virtualization')->get();
  48. }
  49. else
  50. {
  51. if ($hosting->product->module == "proxmoxVPS")
  52. {
  53. $vm = new \stdClass;
  54. foreach ($hosting->customFieldValues as $cf)
  55. {
  56. if ($cf->value && preg_match("/node/", $cf->customField->fieldName))
  57. {
  58. $vm->node = $cf->value;
  59. }
  60. if ($cf->value && preg_match("/vmid/", $cf->customField->fieldName))
  61. {
  62. $vm->vmid = $cf->value;
  63. }
  64. }
  65. if ($vm->vmid)
  66. {
  67. $this->customTplVars['vms'][] = $vm;
  68. }
  69. }
  70. }
  71. }
  72. protected function initActionButtons()
  73. {
  74. if (!empty($this->actionButtons))
  75. {
  76. return $this;
  77. }
  78. $this->addActionButton(new BaseCancelButton);
  79. return $this;
  80. }
  81. }