CreateForm.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product developed. (27.03.19)
  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\Servers\ProxmoxVps\App\UI\Disk\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
  21. use ModulesGarden\Servers\ProxmoxVps\App\Enum\ConfigurableOption;
  22. use ModulesGarden\Servers\ProxmoxVps\App\UI\Validators\NumberValidator;
  23. use ModulesGarden\Servers\ProxmoxVps\App\UI\Disk\Providers\DiskProvider;
  24. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\ClientArea;
  25. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\BaseForm;
  26. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Select;
  27. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Switcher;
  28. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Text;
  29. use function ModulesGarden\Servers\ProxmoxVps\Core\Helper\sl;
  30. class CreateForm extends BaseForm implements ClientArea
  31. {
  32. use ProductService;
  33. public function initContent()
  34. {
  35. $this->initIds('createForm');
  36. $this->setFormType('create');
  37. $this->setProvider(new DiskProvider());
  38. $this->initFields();
  39. $this->loadDataToForm();
  40. }
  41. public function getAllowedActions()
  42. {
  43. return ['create'];
  44. }
  45. private function initFields()
  46. {
  47. $max = $this->getWhmcsConfigOption(ConfigurableOption::ADDITIONAL_DISKS_SIZE , $this->configuration()->getAdditionalDiskSize()) ;
  48. //size
  49. $field = new Text('size');
  50. $field->addValidator(new NumberValidator(1, $max, true));
  51. $this->addField($field);
  52. //bus
  53. $field = new Select('bus');
  54. $options=[];
  55. foreach( $this->configuration()->getAdditionalDiskType() as $entery){
  56. $options[$entery] = sl("lang")->tr($entery);
  57. }
  58. $field->setAvailableValues($options);
  59. $this->addField($field);
  60. //format
  61. $field = new Select('format');
  62. $options=[];
  63. foreach( $this->configuration()->getAdditionalDiskFormat() as $entery){
  64. $options[$entery] = sl("lang")->tr($entery);
  65. }
  66. $field->setAvailableValues($options);
  67. $this->addField($field);
  68. //backup
  69. if ($this->configuration()->isPermissionAdditionalDiskBackup())
  70. {
  71. $field = new Switcher('backup');
  72. $this->addField($field);
  73. }
  74. }
  75. }