public function isAllowed($resource, $action) { list($m, $c) = explode(":", $resource); if (trim($c) == "") { $resource = $m; } elseif ($c == 'index') { $resource = $m; } //echo $resource,"<br/>"; if (App_Env::isAdmin()) { return true; } //echo $resource; if ($resource == 'menu-header') { $resource = 'menu'; } if ($action == 'index' or $action == 'preview') { $action = 'view'; } if (!in_array($action, array('view', 'edit', 'new', 'delete'))) { $action = 'view'; } $permissions = $this->getPermissions(); //echo"[$resource][$action] ". $permissions[$resource][$action]; if (isset($permissions[$resource][$action])) { return $permissions[$resource][$action] == 'Yes' ? true : false; } else { return true; } }
public function exportSetingPanel($modelName, $template = 'default') { $this->_exportFileName = uniqid(); $this->_modelName = $modelName; $this->_template = $template; $url = $this->view->url('export-preview'); $text .= "<form id='form_moel_setting' action={$url} target='export-preview-iframe'>"; $text .= "<input id='exportFileName' name='exportFileName' type='hidden' value='{$this->_exportFileName}'/> "; $text .= "<div class='listmenu-container left-menu1 hide-on-print' >"; $text .= "Render style : "; $text .= "<input class='export-view-radio' id='export-view-grid' name='export-view' type='radio' value='grid' checked='checked' /> grid "; $text .= "<input class='export-view-radio' id='export-view-detail' name='export-view' type='radio' value='view' />detail "; $text .= "<hr/>"; $text .= "File Type : "; $text .= "<input class='export-output-radio' id='export-output-pdf' name='export-output' type='radio' value='pdf' checked='checked' /> pdf "; $text .= "<input class='export-output-radio' id='export-output-excel' name='export-output' type='radio' value='excel' />excel "; $text .= "<input class='export-output-radio' id='export-output-csv' name='export-output' type='radio' value='csv' /> csv "; $text .= "<hr/>"; $text .= "template : " . $this->randerTemplateSelectInput(); if (App_Env::isAdmin()) { $text .= "<button id='CreateNewTempleteButton' onclick='return false;'>+</button>"; } $text .= "<hr/>"; $text .= "Layout : "; $text .= " <input name='exportlayout' type='radio' value='P' checked='checked' /> Portrait "; $text .= " <input name='exportlayout' type='radio' value='L'/> Landscape "; $text .= "<hr/>"; $text .= "Rows : <input name='rowsperpage' type='text' value='20' style='width:20px'/> /Page"; $text .= "<br/>Pages :<br/> \n <input name='page' type='radio' value='all'checked='checked' /> All "; $text .= "<br/> <input name='page' type='radio' value='custom'/> <input name='startpage' type='text' style='width:50px' /> to <input name='endpage' type='text' style='width:50px' />"; $text .= "<hr/>"; if (App_Env::isAdmin()) { $text .= "<button id='DesignButton' onclick='return false'>Design</button>"; } // $text .= "<button id='ExportButton'>Render</button>"; $text .= "<button id='ExportButton'>Preview</button>"; $text .= "</div>"; $text .= "</form>"; $this->globalScript(); return $text; }
function redertable(App_Grid_Filter $filter, array $list = null) { if ($this->_processController == '') { $req = Zend_Controller_Front::getInstance()->getRequest(); $this->_processController = $req->getControllerName(); } //if(trim($this->_gridid) ==''){ //} //print_r($this->_columnConfig); $widths = $filter->getRowWidths(); $titles = $filter->getheaderTitles(); $tWidth = $filter->getTableWidth(); $view = $this->view; if (!$filter->isDisableHeader()) { // $view->headLink()->appendStylesheet('/scripts/jq-ingrid/css/ingrid.css'); // $view->headScript()->appendFile('/scripts/jq-ingrid/js/jquery.ingrid.js'); // $view->headScript()->appendFile('/scripts/jq-ingrid/js/jquery.cookie.js'); //$view->headScript()->appendScript($this->_getScript()); } $gridwidth = $filter->getGridWidth(); // SETTING $this->_enabledScollbar = false; $table = "<div class='table-actionbar-container hide-on-print' align='right' id='tablePane_{$this->getGridId()}' ><div class='table-actionbar-inner'>"; foreach ($this->_butonOnActionBarList as $id => $options) { $table .= $this->renderButtonOnActionBar($id, $options); } $appconfigurl = $this->view->url(array('action' => 'grid-config', 'module' => 'appconfig', 'controller' => 'model-setting', 'model' => $this->_modelName, 'uiName' => $this->filter()->getUiName()), true); if (App_Env::isAdmin() and APPLICATION_ENV == 'development') { $table .= "<a id='ModelConfigButton' name='ModelConfigButton' onclick=\"openWindows('{$appconfigurl}','appconfig')\" title='click to config page' class='btn btn-default btn-xs config-page-button'><i class='glyphicon glyphicon-wrench'></i></a>"; } $table .= '</div></div>'; $innerTableVisibirity = 'display'; //$table .= '<div id="issues-preview-table" align="left" >'; if ($this->_enabledScollbar == true) { $table .= "<div class='table-header-container hide-on-print ' > "; //if($this->_enabledScollbar ==true){ // $table.="<div id='tableHeadContianer' style='height: 20%; overflow-y: scroll;overflow-x: hidden;padding-right:2px;'>"; $table .= "<table border='0' style='width:{$gridwidth}' class=' extensions listing table-head default' cellpadding='0' cellspacing='0' >"; $table .= $this->_getHeader($widths, $titles); $table .= "</table>"; $table .= '</div>'; $tableBobyContainerStyleClass = 'table-body-scoll-container'; } //$table.='<form id="'.$this->_formid.'" >'; if (1) { if (!isset($tableBobyContainerStyleClass)) { $tableBobyContainerStyleClass = 'table-container'; } $table .= "<div class='{$tableBobyContainerStyleClass} div-table-body ' >"; // $innerTableVisibirity = 'display'; //}else{ //$table.='<form id="'.$this->_formid.'" >'; //$innerTableVisibirity = 'display'; //} $table .= '<form id="' . $this->_formid . '" class="webgridform" >'; $table .= "<table id='{$this->_gridid}' style='width:{$gridwidth}' class='table table-bordered table-hover tableBodyContianer listing {$this->_tablebodyClass}'>"; if ($this->_enabledScollbar != true) { $table .= $this->_getHeader($widths, $titles); } if (is_array($list)) { $table .= $this->_getRows($list, $widths); } else { $table .= $this->_getBlankRows(count($titles)); } if ($this->_enabledScollbar == true) { $table .= $this->_getHeaderAtFooter($widths, $titles); } //if( !$filter->isDisableHeader() ){ // $table .= $this->_getFooter(count($titles)); //} $table .= '</table>'; $table .= '</form>'; //if($this->_enabledScollbar ==true){ //$table .= '</div>'; //} $table .= '</div>'; } //$table .= '</form>'; //echo $this->_enabledPagination ; if ($this->_enabledPagination == true) { $table .= "<div class='table-pagination-container hide-on-print'>"; $table .= $this->_genPagination(); $table .= "</div>"; } //$table .= '</div>'; //if (! $filter->isDisableScript ()) { //$table .='<script type="text/javascript">'; $this->addDefaultScript(); //$table .= '</script> '; //} return $table; }
function __construct($modelname, $formoptions = array()) { try { if (isset($formoptions['modelIdSelected'])) { $this->modelIdSelected = $formoptions['modelIdSelected']; } //echo "__construct App_Form_Default"; $this->_ignoreAuthorize = @($formoptions['ignore_authorize'] == true) ? true : false; parent::__construct(); //echo "__construct App_Form_Default"; $this->setModel($modelname); $config = $this->_getConfig($modelname); $req = Zend_Controller_Front::getInstance()->getRequest(); $action = $req->getActionName(); // echo $action; foreach ($config->prop as $prop) { if ($prop->disabledOnForm == 'true' or $prop->form == 'false') { continue; } elseif ($action == 'new') { if ($prop->disabledOnInsert == 'true') { continue; } elseif ($prop->autoIncrement == "true") { continue; } } elseif ($action != 'new') { if ($prop->disabledOnEdit == 'true') { continue; } } $elementType = ''; $options = array(); $options['id'] = $prop->name; $elementType = $options['type'] = isset($prop->input) ? $prop->input : "text"; $fieldtype = isset($prop->type) ? $prop->type : "text"; $input = isset($prop->input) ? $prop->input : "text"; $options['filters'] = isset($prop->filters) ? explode(",", $prop->filters) : array('StringTrim'); $options['required'] = (isset($prop->required) and $prop->required == 'true') ? true : false; $options['alt'] = isset($prop->suffix) ? $prop->suffix : $prop->sufix; $options['label'] = isset($prop->label) ? $prop->label : ucfirst($prop->name); $options['label'] = $this->getView()->translate($options['label']); $options['class'] = isset($prop->class) ? $prop->class : ""; $options['style'] = isset($prop->style) ? $prop->style : "width:80%"; $options['value'] = isset($prop->default) ? $prop->default : ""; $options['decorators'] = $this->{"elementDecorators"}; if (isset($prop->minlength)) { $options['minlength'] = (int) $prop->minlength; } if (isset($prop->maxlength)) { $options['maxlength'] = (int) $prop->maxlength; } if (isset($prop->min)) { $options['min'] = (int) $prop->min; } if (isset($prop->max)) { $options['max'] = (int) $prop->max; } if ('readonly' == $prop->modification and $this->isEditForm()) { $input = "text"; $options['type'] = "text"; } if (0) { switch (strtolower($fieldtype)) { case 'int': $options['validators'] = array('Digits'); $options['class'] = 'valid-number'; $options['style'] = isset($prop->style) ? $prop->style : "width:100px"; break; case 'float': case 'decimal': $options['type'] = 'text'; $options['input'] = 'text'; $options['class'] .= ' currency '; $options['validators'] = array('Float'); $options['style'] = isset($prop->style) ? $prop->style : "width:100px"; break; case 'date': case 'datepicker': case 'datetime': $options['input'] = 'text'; if (!in_array($options['class'], array('datepicker-from', 'datepicker-to'))) { $options['class'] = 'datepicker'; } $options['type'] = 'text'; $options['validators'] = array(array('Date', array('format' => 'dd/mm/yyyy'))); break; case 'bool': case 'boolean': $options['style'] = isset($prop->style) ? $prop->style : "width:100px"; $options['type'] = 'select'; $options['input'] = 'select'; break; } } switch ($input) { case 'date': case 'datepicker': case 'datetime': $options['input'] = 'text'; if (!in_array($options['class'], array('datepicker-from', 'datepicker-to'))) { $options['class'] = 'datepicker'; } $options['type'] = 'text'; $options['validators'] = array(array('Date', array('format' => 'dd/mm/yyyy'))); break; case 'editor': $options['type'] = 'textarea'; $options['class'] = 'editor-full'; $options['style'] = "width:600px;height:100px;"; break; case 'money': $options['type'] = 'text'; $options['input'] = 'text'; $options['class'] = 'valid-number'; $options['validators'] = array('Digits'); break; break; case 'spin': $options['type'] = 'text'; $options['input'] = 'text'; $options['class'] = 'valid-number'; $options['validators'] = array('Digits'); break; case 'currency': $options['type'] = 'text'; $options['input'] = 'text'; $options['class'] .= ' currency '; //$options['validators']= array('Digits' ); break; case 'filepicker': $options['type'] = 'filepicker'; $options['input'] = 'filepicker'; $options['class'] .= ' filepicker '; $options['PrefixPath'] .= 'App_Form_Element '; break; case 'acccodepicker': $options['type'] = 'text'; $options['input'] = 'text'; $options['class'] .= ' acccodepicker '; //$options['validators']= array('Digits' ); break; case 'email': $options['input'] = 'email'; $options['type'] = 'email'; $options['class'] .= ' validemail '; break; case 'textarea': //$options['type']='text'; if ($options['style'] == '') { $options['style'] = "width:70%;height:40px;"; } break; case 'autocomplete': $options['class'] = 'autocomplete'; $options['readonly'] = 'readonly'; $elementName = $elementId = $options['id']; @($options['callBackAffterSelect'] = $prop->autocompleteOptions->callBackSelectedFunction); @($options['resource'] = $prop->autocompleteOptions->resource); break; case 'reference': $options['type'] = 'select'; list($RefmodelName, $fk) = explode(".", $prop->reference); $model = new $RefmodelName(); $condition = $prop->multiOptions->condition; $paramsString = $prop->multiOptions->conditionParams; $where = ''; if ('' != trim($condition)) { $select = str_replace(array_keys($model->PROPS_TO_COLUMS_LIST), array_keys($model->COLUMS_TO_PROPS_LIST), $condition); $selectParams = array(); $paramsAr = explode(",", $paramsString); $formModel = clone $this->_model; if ($formModel instanceof Eau_Model_Client_Assessment) { $clientId = App_Env::getRequest()->getParam("clientId"); $formModel->setClientId($clientId); } if (!empty($paramsAr)) { foreach ($paramsAr as $attr) { $attr = str_replace("()", "", $attr); $selectParams[] = $formModel->{$attr}(); } $where = App_Util::bindSqlParam($select, $selectParams); } } elseif ($model instanceof Sam_Model_User_Group) { if (false == App_Env::isAdmin()) { $where = " id != '3' "; } } if ($where != '') { $result = $model->fetchAll($where); } else { $result = $model->fetchAll(); } foreach ($result as $item) { $pk = $item->{$fk}; $options['multiOptions'][$pk] = "" . $item; } break; } if ($options['type'] == 'radio') { $options['decorators'] = $this->redioDecorators; } if ($input != 'reference' and ($options['type'] == 'select' or $options['type'] == 'radio')) { $options['Separator'] = ""; if (!is_string($prop->multiOptions->model)) { // var_dump($prop->multiOptions); $multiOptions = $prop->multiOptions->toArray(); if (isset($multiOptions['option'])) { foreach ($multiOptions['option'] as $option) { $value = $option['id']; $label = $option['label']; $options['multiOptions'][$value] = $label; } } } else { // สร้าง model จาก ตาราง $modelName = $prop->multiOptions->model; $pkCol = $prop->multiOptions->pk; $labelCol = $prop->multiOptions->label; $model = new $modelName(); // $cacheId = $modelName; //$cache = Zend_Registry::get('cache'); //if( ($result = $cache->load($cacheId)) === false ) { //echo "noCach"; $result = $model->fetchAll(); // $cache->save($result, $cacheId); //} foreach ($result as $item) { $pk = $item->{$pkCol}; $label = $item->{$labelCol}; $options['multiOptions'][$pk] = $label; } } } if ($options['class'] == 'acccodepicker') { $elementName = $elementId = $options['id']; $selectedId = $this->getElement($elementId)->getValue(); @($options['callBackAffterSelect'] = $prop->datapickerOptions->callBackSelectedFunction); @($options['value'] = $prop->datapickerOptions->value); @($options['display'] = $prop->datapickerOptions->display); $resource = $prop->datapickerOptions->resource; $this->getView()->formAutocomplete($elementId, $elementName, $selectedId, $resource, $options); } elseif ($prop->proptype == 'view' and $options['class'] != 'datapicker') { $options['readonly'] = 'readonly'; //$options['disabled'] = 'disabled'; $options['required'] = false; $options['class'] .= " element-readonly "; } elseif ($prop->readonly == 'true') { $options['readonly'] = 'readonly'; //$options['disabled'] = 'disabled'; $options['required'] = false; if ($options['class'] == 'datepicker') { $options['class'] = ''; } $options['class'] .= " element-readonly "; } if ($prop->disabled == 'true') { $options['readonly'] = 'readonly'; //$options['disabled'] = 'disabled'; $options['required'] = false; if ($options['class'] == 'datepicker') { $options['class'] = ''; } $options['class'] .= " element-readonly "; } if ($action == 'edit') { if ($prop->pk == "true") { $options['readonly'] = 'readonly'; $options['class'] .= " element-readonly "; } } if ($options['required'] == true and $elementType != 'filepicker') { $options['class'] .= " required "; } //if($options['type']=='')$options['type']='text'; try { $element = $this->_setElement($options); } catch (Exception $e) { echo $e->getMessage(); } if ($options['class'] == 'datapicker') { $elementName = $elementId = $options['id']; $selectedId = $this->getElement($elementId)->getValue(); @($options['callBackAffterSelect'] = $prop->datapickerOptions->callBackSelectedFunction); @($options['value'] = $prop->datapickerOptions->value); @($options['display'] = $prop->datapickerOptions->display); $resource = $prop->datapickerOptions->resource; $this->getView()->formAutocomplete($elementId, $elementName, $selectedId, $resource, $options); } elseif ($elementType == 'spin') { $elementName = $elementId = $options['id']; $selectedId = $this->getElement($elementId)->getValue(); $this->getView()->formSpin($elementId, $elementName, $selectedId); } elseif ($options['class'] == 'joint-renters-picker') { $req = Zend_Controller_Front::getInstance()->getRequest(); $elementName = $elementId = $options['id']; $selectedId = $req->getParam('id', ''); if ($selectedId == '') { $selectedId = $this->modelIdSelected; } //echo $this->getModel()->id; $this->getView()->formRenterPicker($elementId, $elementName, $selectedId); } elseif (trim($options['class']) == 'filepicker') { //echo 'filepicker'; //$this->getView()->formFilePicker($options['id'],$options['id']); } elseif (trim($options['class']) == 'acccodepicker') { $this->getView()->formAcccodepickerPicker($options['id'], $options['id']); } } $this->_addSaveButton(); $this->_addDecorators(); } catch (Exception $e) { //echo $e->getMessage(); // echo $e->getLine(); // echo str_replace("\n", "<br/>", $e->getTraceAsString()); } }