Пример #1
0
 public function init()
 {
     parent::init();
     $this->_config = $this->getConfig();
     $pathBANNER = $this->_config->app->jsonBanner;
     $totalBanners = json_decode(file_get_contents($pathBANNER), true);
     $util = new App_Util();
     $SoapBanner = $util->groupArray($totalBanners, 'codtbanner');
     foreach (array(1, 2, 3, 4, 5) as $i) {
         $Banners[] = $SoapBanner[$i][0]['norder'];
     }
     //        var_dump($Banners);exit;
     $perfil = $this->obtenerPerfil($Banners);
     $this->view->perfil = $perfil;
     switch ('3') {
         case '1':
             $this->forward('basico');
             break;
         case '2':
             $this->forward('basico128');
             break;
         case '3':
             $this->forward('basico240');
             break;
         case '4':
             $this->forward('basico360');
             break;
         case '5':
             $this->forward('avanzado');
             break;
         default:
             $this->forward('basico240');
             break;
     }
     $bannerMovistar = $util->filter_by_value($totalBanners, 'codtbanner', 11);
     $this->view->SoapMovistarBanners = $bannerMovistar[0];
     $this->view->SoapBanners = $SoapBanner;
 }
Пример #2
0
 function write($filename = null, $dataConfig = null)
 {
     if (null == $filename) {
         $filename = $this->configfilename;
     }
     if (null == $dataConfig) {
         $dataConfig = $this->iniData;
     }
     $content = "";
     foreach ($dataConfig as $section => $data) {
         $content .= "[{$section}]\n";
         foreach ($data as $key => $value) {
             if (is_string($value)) {
                 $chk = explode('"', $value);
                 if (count($chk) > 1) {
                     $content .= "{$key} = {$value} \n";
                 } else {
                     $content .= "{$key} = \"{$value}\" \n";
                 }
             } elseif (is_array($value)) {
                 foreach ($value as $val) {
                     if (is_string($val) and trim($val) != '') {
                         $chk = explode('"', $val);
                         if (count($chk) > 1) {
                             $content .= "{$key}[] =  {$val} \n";
                         } else {
                             $content .= "{$key}[] =  \"{$val}\" \n";
                         }
                     }
                 }
             }
         }
     }
     App_Util::writefile($filename, $content);
     //$this->configfilename
 }
Пример #3
0
 /**
  * TOAN LE
  * 'payment' . DS . Zend_Registry::get ( 'lang' ) . DS . 'manager.phtml'
  * Enter description here ...
  * @param unknown_type $datas
  * @param unknown_type $templateMail
  */
 public function sendMailAction($subject, $email, $name, $datas, $templateMail, $logger = null)
 {
     $translate = Zend_Registry::get('Zend_Translate');
     if ($logger == null) {
         $logger = App_Util::getLogger("/data/logs/register-email.log");
     }
     $flashMessenger = $this->_helper->getHelper('Messenger');
     $this->view->assign('datas', $datas);
     $this->view->assign('config', $this->config);
     // 2. Request
     switch ($this->config->resources->mail->transport->type) {
         case 'smtp':
             $smtp_config = array('username' => $this->config->resources->mail->transport->username, 'password' => $this->config->resources->mail->transport->password);
             if ($this->config->resources->mail->transport->auth) {
                 $smtp_config['auth'] = 'login';
             }
             $transport = new Zend_Mail_Transport_Smtp($this->config->resources->mail->transport->host, $smtp_config);
             break;
         default:
             break;
     }
     try {
         // 5. Send mail to Administrator
         $email_content = $this->view->render($templateMail);
         try {
             $mail = new Zend_Mail('UTF-8');
             $mail->clearRecipients();
             $mail->setBodyHtml($email_content);
             $mail->setFrom('*****@*****.**', 'Saga Viet Nam');
             $mail->addTo($email, $name);
             $mail->setSubject($subject);
             $sent = $mail->send();
             //				$mail->send ( $transport );
             $message = "Sent mail success to \n";
             $message .= "\n\nParams: \n" . var_export($datas, true) . "\n";
             $message .= "-------------------------------\n\n\n";
             $status = 1;
             $flashMessenger->addMessage($translate->translate('SEND_MAIL_SUCCESS'));
         } catch (Zend_Exception $e) {
             $message = $e->getMessage() . "\n" . $e->getTraceAsString() . "\n\nParams: \n" . var_export($datas, true) . "\n";
             $message .= "-------------------------------\n\n\n";
             $status = 0;
             $flashMessenger->addMessage($translate->translate('SEND_MAIL_FAILED'));
         }
     } catch (Zend_Exception $e) {
         $message = $e->getMessage() . "\n" . $e->getTraceAsString() . "\n\nParams: \n" . var_export($datas, true) . "\n";
         $message .= "-------------------------------\n\n\n";
         $status = 0;
         $flashMessenger->addMessage($translate->translate('SEND_MAIL_FAILED'));
     }
     $this->setFlashMessenger($flashMessenger);
     $logger->log($message, Zend_Log::DEBUG);
     return $status;
 }
Пример #4
0
 function templateDesignAction()
 {
     $this->setLayout("templatedesign");
     $this->_showTabs(4);
     $this->addSaveButton();
     $modelName = $this->_request->getParam("model", 'Eau_Model_Company');
     $uiName = $this->_request->getParam("uiName", 'default');
     $config = App_Model_Config::get($modelName);
     $templeatLocation = TEMPLATES_DIR . "/" . $modelName;
     $templateFileList = App_Util::getFileListOfDir($templeatLocation);
     if (count($templateFileList) == 0) {
         $templateFileList = array("{$templeatLocation}/default.txt");
     }
     $this->view->templateData = file_get_contents($templateFileList[0]);
     $this->view->templateFileList = $templateFileList;
     $this->view->uiName = $uiName;
     $this->view->config = $config;
 }
Пример #5
0
 public function delete($where = null)
 {
     $cache_dir = PRIVATE_PATH . '/data/cache/' . $this->getModelName();
     App_Util::remove_dir($cache_dir);
     App_Util::remove_dir(CACHE_OUTPUT_DIR);
     if ($where == null) {
         $pkcol = $this->getPkColumn();
         $pkpop = $this->getPKName();
         $pkval = $this->{$pkpop};
         $where = "{$pkcol} = '{$pkval}'";
     }
     $this->getMapper()->delete($where, $this);
     $this->_handleAffterDeleted($this);
     if ("Sys_Model_AppLog" != $this->getModelName()) {
         $models = explode("_Model_", $this->getModelName());
         $modelName = strtolower($models[1]);
         $id = $this->getMapper()->getLastInsertId();
         $message = "deleted {$modelName} {$pkcol}:{$pkval}";
         App_Log::get()->addlog(array("remark" => $where, "message" => $message, "activity" => "delete", "refType" => $this->getModelName(), "refId" => $id));
     }
     return $this;
 }
Пример #6
0
 static function getFileListOfDir($dir)
 {
     $fileList = array();
     $dir = substr($dir, -1) != "/" ? $dir . "/" : $dir;
     chmod($dir, 0777);
     $openDir = opendir($dir);
     //echo $openDir;
     while ($file = readdir($openDir)) {
         if (!in_array($file, array(".", ".."))) {
             if (!is_dir($dir . $file)) {
                 $fileList[] = $dir . $file;
             } else {
                 App_Util::getFileListOfDir($dir . $file);
             }
         }
     }
     closedir($openDir);
     return $fileList;
 }
Пример #7
0
 protected function _getHeaderNoSort(array $widths, array $titles, $visibirity = 'display')
 {
     //$request = Zend_Controller_Front::getInstance()->getRequest();
     //$controller = $request->getControllerName();
     $page = $this->filter()->getPage();
     $dir = strtolower($this->filter()->getDirection());
     if ($visibirity == 'hidden') {
         $style = " display:none ";
     }
     $header = '';
     //$header .="<thead style='$style'  >";
     $header .= "<tr class='header'   >";
     foreach ($titles as $index => $title) {
         //$link = $this->_getLink($page,$index,$dir);
         //style=\"background-color: rgb(255, 0, 0); color: rgb(255, 255, 255);\"
         $header .= "<td width=\"{$widths[$index]}\"  >";
         $header .= ucfirst(App_Util::splitByCaps($this->_translate($titles[$index])));
         $header .= '</td>';
         $this->_totalCell++;
     }
     if (!$this->_filter->isActionDisabled() and $this->_filter->totalAction() > 0) {
         $header .= $this->_getActionsHeahder();
         // if(Sam_Acl::getInstance()->isAllowed($controller,'delete')==true){
         //if($this->_filter->totalAction() > 1 ){
         //$header .= "<th width='5%' >".$this->_translate('Action')."</th>";
         // }//else{
         //$header .= "<th width='5%' >".$this->_translate('Delete')."</th>";
         //}
         $this->_genActionsScript();
         //}
     }
     $header .= '</tr>';
     $header .= '<tr class="header-separator"></td>';
     //$header .= '</thead>';
     $header .= '';
     return $header;
 }
Пример #8
0
    function render($RecordSet, $titleArray, $fields, $fileName)
    {
        echo <<<STYLE
<style>
table.excel {
\tborder-style:ridge;
\tborder-width:1;
\tborder-collapse:collapse;
\tfont-family:sans-serif;
\tfont-size:12px;
}
table.excel thead th, table.excel tbody th {
\tbackground:#CCCCCC;
\tborder-style:ridge;
\tborder-width:1;
\ttext-align: center;
\tvertical-align:bottom;
}
table.excel tbody th {
\ttext-align:center;
\twidth:20px;
}
table.excel tbody td {
\tvertical-align:bottom;
}
table.excel tbody td {
    padding: 0 3px;
\tborder: 1px solid #EEEEEE;
}
table.excel tr:hover {
\tcolor: #09F;
\tbackground-color: #D6D6D6;
}
</style>
STYLE;
        try {
            error_reporting(E_ALL ^ E_NOTICE);
            ini_set('display_errors', 0);
            if ('' == $fileName) {
                $fileName = uniqid();
            }
            $filePath = App_Env::getPathOfUserTemporaryFolder() . "/" . $fileName . '.xls';
            $workbook = new Excel_Writer($filePath);
            $workbook->setLandscape();
            $workbook->setTitle($this->filter()->getCaptionText());
            // query
            $i = 0;
            $dataSet = array();
            foreach ($RecordSet as $rows) {
                //array_unique ( $row );
                $j = 0;
                foreach ($fields as $filed) {
                    $dataSet[$i][$j++] = $this->filter()->fieldTranform($rows, $filed);
                }
                ++$i;
            }
            // set data
            $workbook->setData($dataSet);
            $lastcol = $j - 1;
            $columnConfig = $this->_columnConfig;
            $widths = array();
            $tableWidth = $this->filter()->getTableWidth();
            if (false != strpos($tableWidth, "%")) {
                $tableWidth = "100";
            }
            //echo $tableWidth;
            $counter_blank_cell = 0;
            $total_cell_width = 0;
            foreach ($fields as $filed) {
                $width = $columnConfig->fields[$filed]->width;
                if (false != strpos($width, "%")) {
                    $width = str_replace("%", "", $width);
                    $w = $width * $tableWidth / 100;
                } else {
                    $w = str_replace("px", "", $width);
                }
                if ($w == '') {
                    $counter_blank_cell += 1;
                }
                $total_cell_width += $w;
                $widths[] = $w;
            }
            if ($counter_blank_cell == 0) {
                $counter_blank_cell = 1;
            }
            for ($i = 0; $i < count($widths); $i++) {
                if ($widths[$i] == '') {
                    $widths[$i] = ($tableWidth - $total_cell_width) / $counter_blank_cell;
                }
            }
            $format = array('right' => 1, 'left' => 1, 'border' => 1);
            $i = 0;
            foreach ($fields as $filed) {
                $align = in_array($columnConfig->fields[$filed]->align, App_Model_Config::$alignList) ? $columnConfig->fields[$filed]->align : 'left';
                $workbook->setColumn($i, $i, $widths[$i], array_merge($format, array('align' => $align)));
                ++$i;
            }
            //$workbook->setColumn(0,0,15 ,array_merge($format,array( 'align'=>'center')) );
            //$workbook->setColumn(1,1,35,array_merge($format,array('align'=>'left')));
            //$workbook->setColumn(2,4,20,array_merge($format,array('align'=>'center','NumFormat'=>'_-* #,##0.00_-')));
            //$workbook->setColumn(5,$lastcol,10,array_merge($format,array('align'=>'right','NumFormat'=>'_-* #,##0.00_-')));
            //set header
            for ($i = 0; $i < count($titleArray); $i++) {
                $titleArray[$i] = ucfirst(App_Util::splitByCaps($this->_translate($titleArray[$i])));
            }
            $header[0] = $titleArray;
            //$header[0] = array('เธฃเธซเธฑเธชเธงเธดเธ—เธขเธฒเธฅเธฑเธข','เธงเธดเธ—เธขเธฒเธฅเธฑเธขเธ�เธธเธกเธ�เธ�',"เธงเธ�เน€เธ�เธดเธ�เธ—เธตเน�เน�เธ”เน�เธฃเธฑเธ� \n เธ�เธฑเธ”เธชเธฃเธฃ","เธฃเธงเธกเน€เธ�เธดเธ� \nเธ�เธ�เธ�เธฃเธฐเธกเธฒเธ“เธ—เธตเน� \nเน�เธ”เน�เธฃเธฑเธ�เน�เธญเธ�","เธฃเน�เธญเธขเธฅเธฐ\n เธ•เน�เธญ \nเธงเธ�เน€เธ�เธดเธ�เธ—เธตเน� เน�เธ”เน�เธฃเธฑเธ�เธ�เธฑเธ”เธชเธฃเธฃ",'เธ�เธณเธ�เธงเธ�เน€เธ�เธดเธ�เธ—เธตเน�เน�เธ”เน�เธฃเธฑเธ�เน�เธญเธ�');
            //$header[1] = array('','','','','');
            //for($i=1;$i<=$lastcol-4;$i++){
            ///    $header[0][] ='';
            //	$header[1][] =  'เธ�เธฃเธฑเน�เธ�เธ—เธตเน� '.$i ;
            //}
            //array_pop( $header[0]);
            $workbook->setHeader($header);
            //$first_row , $first_col , $last_row , $last_col
            $firstRow = $workbook->getFirstRow();
            ///echo $lastcol;
            //$workbook->mergeCells($firstRow,0,$firstRow+1,0);
            //$workbook->mergeCells($firstRow,1,$firstRow+1,1);
            //$workbook->mergeCells($firstRow,2,$firstRow+1,2);
            //$workbook->mergeCells($firstRow,3,$firstRow+1,3);
            //$workbook->mergeCells($firstRow,4,$firstRow+1,4);
            //$workbook->mergeCells($firstRow,5,$firstRow,$lastcol);
            //addLastRow;
            //$workbook->setFormula ('lastrow',0,0,'' );
            //$workbook->setFormula ('lastrow',1,1,'เธฃเธงเธกเธ—เธธเธ�เธงเธดเธ—เธขเธฒเธฅเธฑเธข' );
            //$workbook->setFormula ('lastrow',2,3,'SUMCOLUMN');
            //$workbook->setFormula ('lastrow',4,4,'=(D[row]/C[row])*100');
            //$workbook->setFormula ('lastrow',5,$lastcol,'SUMCOLUMN');
            echo $workbook->render();
        } catch (Exception $e) {
            echo $e->getCode(), 'error : ', $e->getMessage();
            echo $e->getTraceAsString();
        }
    }
Пример #9
0
     $userFolderPath = self::getSession("pathOfUserTemporaryFolder", "");
     if (!is_dir($userFolderPath)) {
         self::createUserTemporaryFolder();
     }
     return self::getSession("pathOfUserTemporaryFolder", "");
 }
 static function createUserTemporaryFolder()
 {
     $userFolderName = strtolower(App_Formatter::cleanFileNames(App_Env::getUser()->getLoginid()));
     $userFolderPath = TEM_DOCUMENTS . "/" . $userFolderName;
     if (!is_dir($userFolderPath)) {
         @mkdir($userFolderPath, 0777, true);
Пример #10
0
 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());
     }
 }
Пример #11
0
 public function ajaxSwopAction()
 {
     try {
         $this->_helper->layout->disableLayout();
         $request = $this->getRequest();
         $id1 = $request->getParam('id1');
         $id2 = $request->getParam('id2');
         $mode = $request->getParam('mode', '');
         $newIndex = $request->getParam('newIndex');
         $model1 = $this->getObject($this->_model);
         $model2 = $this->getObject($this->_model);
         $dbTable = $model1->getDbTable();
         $model1->find($id1);
         $model2->find($id2);
         $index1 = $model1->ordering;
         $index2 = $model2->ordering;
         $pkcol = $model1->getPkColumn();
         $db = $dbTable->getAdapter();
         $tableName = $dbTable->getName();
         //die('pkcol'.$pkcol);
         if ($mode == 'top') {
             //ย้ายมาไว้ที่0
             //	echo "UPDATE $tableName SET odering = 0 WHERE $pkcol = $id1";
             $dbTable->update(array('ordering' => '0'), "{$pkcol} = '{$id1}' ");
             // move ทราต่ำกว่า ขึ้น 1 ระดับ
             $where = array();
             $where1 = $where2 = '';
             if ($this->_section != '') {
                 $where1 = '  secid=' . $this->_section;
                 $where[] = $where1;
             }
             $where2 = ' ordering > ' . $index1;
             $where[] = $where2;
             $db->query("UPDATE {$tableName} SET ordering = ordering-1 WHERE " . join(' AND ', $where));
             // move ทั้งหมดลง
             if (trim($where1) == '') {
                 $db->query("UPDATE {$tableName} SET ordering = ordering+1");
             } else {
                 $db->query("UPDATE {$tableName} SET ordering = ordering+1 WHERE " . $where1);
             }
             //$db->query ( "UPDATE $tableName SET ordering = ordering+1 WHERE " . $where1 );
             //$db->query("UPDATE $tableName SET odering = 1 WHERE $pkcol = $id1");
             //$dbTable->update(array('odering'=>$index2+1),"$pkcol = $id1 ");
         } elseif ($mode == 'bottom') {
             // move id ที่ต่ำกว่า ขึ้นมา 1
             $dbTable->update(array('ordering' => $index2 + 1), "{$pkcol} = '{$id1}' ");
             $where = 'ordering > ' . $index1;
             if ($this->_section != '') {
                 $where .= ' and secid=' . $this->_section;
             }
             $db = $dbTable->getAdapter();
             $tableName = $dbTable->getName();
             $db->query("UPDATE {$tableName} SET ordering = ordering-1 WHERE " . $where);
         } else {
             $dbTable->update(array('ordering' => $index2), "{$pkcol} = '{$id1}' ");
             $dbTable->update(array('ordering' => $index1), "{$pkcol} = '{$id2}' ");
         }
         //  exit();
         $result = array('result' => 'success');
     } catch (Exception $e) {
         $result = array('result' => 'failed');
     }
     $cache_dir = PRIVATE_PATH . '/data/cache';
     App_Util::remove_dir($cache_dir);
     App_Util::remove_dir(CACHE_OUTPUT_DIR);
     echo json_encode($result);
     $this->render('blank', null, true);
 }