EditGeneralSection.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Sections;
  3. use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
  4. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
  5. use ThurData\Servers\KerioEmail\App\Traits\FormExtendedTrait;
  6. use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Sections\FreeFieldsSection;
  7. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
  8. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
  9. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;
  10. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\InputGroup;
  11. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements;
  12. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Validators\Decimal;
  13. /**
  14. *
  15. * Created by PhpStorm.
  16. * User: ThurData
  17. * Date: 12.11.19
  18. * Time: 13:52
  19. * Class EditGeneralSection
  20. */
  21. class EditGeneralSection extends FreeFieldsSection
  22. {
  23. protected $id = 'editGeneralSection';
  24. protected $name = 'editGeneralSection';
  25. use FormExtendedTrait;
  26. public function initContent()
  27. {
  28. /**
  29. * hosting id
  30. */
  31. $hid = $this->getRequestValue('id');
  32. /**
  33. * product manager allow to check product settings
  34. */
  35. $productManager = new ProductManager();
  36. $productManager->loadByHostingId($hid);
  37. /**
  38. * add fields
  39. */
  40. $field = new Hidden('id');
  41. $this->addField($field);
  42. $this->generateDoubleSection([new Text('firstname'), new Text('lastname')]);
  43. $email =new InputGroup('usernameGroup');
  44. $email->addInputComponent((new InputGroupElements\Text('username'))->addHtmlAttribute('readonly','true'));
  45. $email->addInputAddon('emailSign', false, '@');
  46. $email->addInputComponent((new InputGroupElements\Text('domain'))->addHtmlAttribute('readonly','true'));
  47. $this->addSection($email);
  48. $this->generateDoubleSection([new Text('display_name'), new Select('status')]);
  49. $quota = new Text('quota');
  50. $quota->setDescription('description');
  51. $quota->addValidator(new Decimal(0));
  52. $this->generateDoubleSection([$quota, new Select('unit')]);
  53. if($productManager->get('cos_name') === ClassOfServices::CLASS_OF_SERVICE_QUOTA)
  54. {
  55. $field = new Hidden('currentCosId');
  56. $this->addField($field);
  57. $field = new Select('cosId');
  58. $this->addField($field);
  59. }
  60. }
  61. }