<?php
 namespace App\Form\Input; class Remarks extends \Engine\Form\Input\Textarea { protected $class = "remarks"; protected $remarksType = null; protected $gdsProfileButton = null; protected $gdsProfileIdOrder = null; public function __construct($label=null, $name=null, $value=null) { parent::__construct($label, $name, $value); } public function setRemarksType($rmType) { $this->remarksType=$rmType; return $this; } public function getRemarksType() { return $this->remarksType; } public function addGdsProfileButton($idOrder) { if ($this->remarksType!='service') { throw new \Exception('You must set the remarks type as `service` before calling '.__METHOD__); } $this->gdsProfileButton = true; $this->gdsProfileIdOrder = $idOrder; } protected function getTemplateParams($templateClass = null, $parentElement = null) { $params = parent::getTemplateParams($templateClass, $parentElement); $params['remarksType'] = $this->getRemarksType(); $params['assistedInputButton'] = \App\Config\Remarks::getInstance()->remarkTypeHasAssistedRemarks($this->remarksType); $_LANG = \App\Loader_Lang::getInstance()->getGlobal(); $optionsObj = $this->getOptionsMenu(); if ($this->gdsProfileButton) { $optionsObj->append( \App\Mvc\View\Utils\RowOptions\Option\Popup::create("gdsProfile") ->setIcon('profile') ->setDescription('define GDS profile') ->setDimensions(800, 500) ->setModule('Modules/Utils/GdsProfileFill') ->setAction('index') ->addParamFromJs('idOrder', $this->gdsProfileIdOrder) ->addParamFromJs('idCustomer', "getFirstDefinedPax()") ->addParamFromJs('remarksFieldId', "'{$params['id']}'") ->addParamFromJs('remarks', "\$F('{$params['id']}')") ); } $optionsObj->append( \App\Mvc\View\Utils\RowOptions\Option\Option::create("view") ->setIcon('view') ->setDescription($_LANG['globalEntityMessages']['viewRemarks']) ->setJsCallback("RemoteLoad.load(this, MVC.appUrl('RemoteData/ProcessRemarks', 'viewRemarks', { 'type': '{$params['remarksType']}' }), { 'text': \$F('{$params['id']}') }).attach(this);" ) ); $optionsObj->append( \App\Mvc\View\Utils\RowOptions\Option\Option::create("edit") ->setIcon('edit') ->setDisabled(!$params['assistedInputButton']) ->setDescription($_LANG['globalEntityMessages']['inputRemarks']) ->setJsCallback("remarksAssistedInputs(\$F('{$params['id']}'), '{$params['remarksType']}', '{$params['id']}');") ); $params['optionsMenu'] = $this->optionsMenu; return $params; } } 