SuspendedRow.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxAddon product developed. (Oct 2, 2018)
  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\Servers\Pages;
  20. use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
  21. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Others\AjaxFieldForDataTable;
  22. /**
  23. * Description of ResourcesRow
  24. *
  25. * @author Pawel Kopec <pawelk@modulesgardne.com>
  26. */
  27. class SuspendedRow extends AjaxFieldForDataTable implements AdminArea
  28. {
  29. use ServerResources;
  30. public function prepareAjaxData()
  31. {
  32. session_write_close();
  33. try
  34. {
  35. session_write_close();
  36. $serverId = $this->getRequestValue('index', '0');
  37. $this->setServerId($serverId);
  38. $this->setHostingStatus(["Suspended"]);
  39. if ($this->getServer()->disabled != 1)
  40. {
  41. $this->getApi()->setInstance();
  42. $this->ramDetails();
  43. }
  44. if ($this->errors)
  45. {
  46. throw new \Exception(implode("<br/> ", $this->errors));
  47. }
  48. $this->ajaxData = "{$this->ramAssignedToSring()} / {$this->ramSuspendedToSring()}</span>";
  49. }
  50. catch (\Exception $ex)
  51. {
  52. $this->ajaxData = sprintf('<span style="color:red;">%s</span>', $ex->getMessage());
  53. }
  54. }
  55. }