Example #1
0
 function getCondition($collegefield, $datefield)
 {
     // รับค่า parameter //
     $collegeId = $_GET['collegeId'];
     $college = App_Env::getCollege($collegeId);
     $collegeName = iconv('TIS-620', 'UTF-8', $college->collegeName);
     $getparams[] = "collegeId={$collegeId}";
     $WHERES[] = "{$collegefield}=?";
     $dataWhere[] = $collegeId;
     $dateto = trim($_GET['date-to']);
     $dateform = trim($_GET['date-from']);
     $getparams[] = "date-to={$dateto}";
     $getparams[] = "date-from={$dateform}";
     $titledate = '';
     if ($dateto != '' and $dateform != '') {
         $titledate .= 'จาก ' . App_Formatter::thaidate($dateform) . ' ถึง ' . App_Formatter::thaidate($dateto);
         //$WHERES[]    = "$collegefield=?";
         //$dataWhere[] = "";
     } elseif ($dateto != '' and $dateform == '') {
         $titledate .= ' ณ  ' . App_Formatter::thaidate($dateto);
     } elseif ($dateto == '' and $dateform != '') {
         $titledate .= ' ตั้งแต่ ' . App_Formatter::thaidate($dateform);
     }
     // จบช่วงรับค่่า parameter
     return array('where' => $WHERES, 'param' => $dataWhere, 'collegeName' => $collegeName, 'collegeID' => $collegeId, 'collegeId' => $collegeId, 'titleDate' => $titledate, 'getparam' => join("&", $getparams));
 }
Example #2
0
 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;
     }
 }
Example #3
0
 function genMenu($config, $module = '')
 {
     //echo $module;
     //print_r($config->$module);
     $iconstyle = 'style="width: 40px; height: 40px; vertical-align: middle" ';
     //global $request;
     //$module = 'admin';
     /**  BEGIN GEN MAIN TAB **/
     $i = 0;
     foreach ($config as $module => $nav) {
         //	echo $controller;
         // print_r($nav);
         if (count($nav->sub) == 0) {
             if ($nav->nolink == 'true') {
                 $link = "";
             } else {
                 $link = "onclick=location.href='/{$module}/{$controller}'";
             }
             // echo $controller," ",(int)Sam_Acl::getInstance()->isAllowed($controller,'view'),"<br/>";
             // echo $resource;
             if ($link == '' or $this->isAllowAccess($module, $controller, 'view') == true) {
                 $text .= '<li $link class="">';
                 $text .= '<a href="#"><span ><img $iconstyle src="' . $nav->icon . '" /> ' . $nav->label . '</a>';
                 $text .= "</li>";
             }
         } else {
             //print_r($nav);
             //$text .= "<table class='statistics'  width='100%' border='0' cellspacing='0' cellpadding='0' class='welcome-menu'><tr></td>";
             if ($module == App_Env::getModuleName()) {
                 $text .= '<li class="expand">';
             } else {
                 $text .= '<li class="">';
             }
             $text .= '<a href="#"><img $iconstyle src="' . $nav->icon . '" /> ' . $nav->label . '<span class="num">' . count($nav->sub) . '</span></a>';
             $text .= '<ul class="acitem" >';
             $text .= $this->genSubMenu($nav, $module);
             $text .= "</ul>";
             $text .= "</li>";
             /*
             	
             		        $text .="<tr><th><img src='{$nav->icon}' /> {$this->view->translate($nav->label)} </th></tr>";
             		        $text .="<tr><td>";
             		        $text .="<ul class='welcome-menu' >";
             		
             		         $text .= $this->genSubMenu($nav,$module);
             		         $text .= "</ul>";
             		        $text .= "</td></tr>";*/
             // $text .= "</table>";
         }
         ++$i;
     }
     return $text;
 }
Example #4
0
 public function getMyDocumentFolder($ownerId)
 {
     $folder = new Sys_Model_File_Folder();
     $folder = $folder->fetchRow($folder->select()->where("folder_type=?", Sys_Model_File_Folder::FOLDER_TYPE_MY_DOCUMRNT)->where('owner=?', $ownerId)->order('id')->limit(1));
     //echo( $folder->select()->where("folder_type=?",Sys_Model_File_Folder::FOLDER_TYPE_MY_DOCUMRNT)->where( 'owner=?',$ownerId )->order('id')->limit(1) );
     //   echo $folder->id;
     //die();
     if (trim($folder->id) == '') {
         $folder = new Sys_Model_File_Folder();
         $folder->setName("My Documents");
         $folder->setFolderType(Sys_Model_File_Folder::FOLDER_TYPE_MY_DOCUMRNT);
         $folder->setOwner(App_Env::getUserId());
         $folder->setIsActive(1);
         $folder = $folder->save();
     }
     return $folder;
 }
Example #5
0
 function init()
 {
     parent::init();
     $fileid = $this->_fileName;
     $this->SetFont('freeserif', '', 14);
     $this->AddPage();
     $name = App_Env::getUserFullName();
     $wartermark = 'ผู้พิมพ์รายงาน ' . $name . ' ' . date('d/m/Y h i s') . 'เลขที่เอกสาร ' . $fileid . '  www.thaidxc.org ';
     $this->SetKeywords($wartermark);
     $this->StartTransform();
     $this->SetAlpha(0.1, 'Screen');
     $this->Rotate(45, 0, 200);
     for ($i = 0; $i <= 10; $i++) {
         $this->Text(-$i * 10, 88 + $i * 20, $wartermark . $wartermark);
         //. $wartermark . $wartermark
     }
     $this->StopTransform();
 }
Example #6
0
 public function mainNavigation2($beginModule = '')
 {
     //$this->view->headLink()->appendStylesheet('/css/express-table/style.css');
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $currentModule = $request->getModuleName();
     $currentControler = $request->getControllerName();
     $currentAction = $request->getActionName();
     $beginModule = $request->getModuleName();
     $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation-admin.xml', 'nav');
     $text = '';
     foreach ($config as $module => $data) {
         if ($module == $beginModule) {
             $navTexe .= '   
                         <li class="dropdown">
                         <a href="#" class="dropdown-toggle" data-toggle="dropdown">  ' . $data->label . ' <b class="caret"></b></a>
                         <ul class="dropdown-menu">';
             $navTexe .= $this->genMenu($config, $module);
             $newControllerUrl = $this->view->url('new-controller', 'controller-setting', 'appconfig', array('con' => App_Env::getControllerName(), "mdl" => App_Env::getModuleName(), 'act' => App_Env::getActionName()));
             $navTexe .= '<li class="divider"></li><li><a class="colorbox-iframe" href="' . $newControllerUrl . '"><i class="glyphicon glyphicon-plus-sign"></i> Add Controler</a></li> ' . '</ul></li>';
         }
     }
     if ($currentAction != 'index' and $currentAction != '') {
         $navTexe .= " <li> <a href='/{$currentModule}/{$currentControler}'> {$currentControler} </a> </li>";
         $currentAction = ucwords(str_replace("-", " ", $currentAction));
         $navTexe .= " <li class='active'> {$currentAction} </li>";
     } else {
         $navTexe .= " <li class='active'> {$currentControler} </li>";
     }
     /*
     		 $id = $request->getParam('id','');
     		 if($id != ''){
     		 	$model = $this->view->defaultmodel;
     		 	if($model Instanceof App_Model_Abstract){
     		 		$navTexe .= " of id : $id ($model)";
     		 	}else{
     		 		$navTexe .= " of id : $id ";
     		 	}
     		 	
     		 }*/
     return ' <ol class="breadcrumb">' . '<li><a href="/"> <i class="glyphicon glyphicon-home"></i> หนัาหลัก</a></li>' . $navTexe . '</ol>';
 }
Example #7
0
 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                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input  name='page' type='radio' value='all'checked='checked' /> All ";
     $text .= "<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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 updateSchemaAction()
 {
     try {
         $apiID = $this->_request->getParam(api);
         $api = new Api_Model_Profile();
         $api->find($apiID);
         $sql = $api->sql;
         $conn = App_Env::getDb();
         $dbh = $conn->getConnection();
         print_r($dbh);
         $sth = $dbh->prepare($sql);
         $sth->execute();
         $colcount = $sth->columnCount();
         $typelist = array("LONG" => 'int', "VAR_STRING" => 'string', 'DATETIME' => 'datetime', 'BLOB' => 'text', 'DATE' => 'date');
         $inputlist = array("LONG" => 'text', "VAR_STRING" => 'text', 'DATETIME' => 'text', 'BLOB' => 'textarea', 'DATE' => 'datepicker');
         for ($i = 0; $i < $colcount; $i++) {
             $coll = $sth->getColumnMeta($i);
             $collName = $coll['name'];
             $propName = strtolower($collName);
             $propName = str_replace("_", " ", $propName);
             $propName = ucwords($propName);
             $propName = str_replace(" ", "", $propName);
             $propName = lcfirst($propName);
             $type = $coll['native_type'];
             if ($type == '') {
                 $type = 'text';
             }
             $schema = new Api_Model_Service_Schema();
             $result = $schema->fetchRow($schema->select()->where('attribute_name=?', $propName)->where('api_id=?', $apiID));
             if (trim($result->id) == '') {
                 $schema->setApiId($apiID)->setAttributeName($propName)->setColumnName($collName)->setType($typelist)->save();
             }
         }
         $this->_helper->redirector('index', null, null, array('api' => $apiID, 'info' => 101));
     } catch (Exception $e) {
         $this->_helper->redirector('index', null, null, array('api' => $apiID, 'info' => $e->getMessage()));
         echo "ERROR" . $e->getMessage();
     }
 }
Example #9
0
 /**
  * This method is used to render the page footer. 
  * It is automatically called by AddPage() and could be overwritten in your own inherited class.
  */
 public function Footer()
 {
     $cur_y = $this->GetY();
     $ormargins = $this->getOriginalMargins();
     $this->SetTextColor(0, 0, 0);
     //set style for cell border
     $line_width = 0.85 / $this->getScaleFactor();
     $this->SetLineStyle(array('width' => $line_width, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)));
     //print document barcode
     $barcode = $this->getBarcode();
     if (!empty($barcode)) {
         $this->Ln($line_width);
         $barcode_width = round(($this->getPageWidth() - $ormargins['left'] - $ormargins['right']) / 3);
         $this->write1DBarcode($barcode, 'C128B', $this->GetX(), $cur_y + $line_width, $barcode_width, $this->getFooterMargin() / 3 - $line_width, 0.3, '', '');
         $this->Text($this->GetX(), $cur_y + $line_width + 10, $barcode);
         $this->StartTransform();
         $this->SetFont('freeserif', '', 12);
         $name = App_Env::getUserFullName();
         $date = date('d/m/Y');
         $time = date('H:i');
         $this->Text($this->GetX(), $cur_y + $line_width + 16, "ผู้พิมพ์   {$name} วันที่  {$date} เวลา {$time}น.");
         $this->StopTransform();
     }
     if (empty($this->pagegroups)) {
         $pagenumtxt = $this->l['w_page'] . ' ' . $this->getAliasNumPage() . ' / ' . $this->getAliasNbPages();
     } else {
         $pagenumtxt = $this->l['w_page'] . ' ' . $this->getPageNumGroupAlias() . ' / ' . $this->getPageGroupAlias();
     }
     $this->SetY($cur_y);
     //Print page number
     if ($this->getRTL()) {
         $this->SetX($ormargins['right']);
         $this->Cell(0, 0, $pagenumtxt, 'T', 0, 'L');
     } else {
         $this->SetX($ormargins['left']);
         $this->Cell(0, 0, $pagenumtxt, 'T', 0, 'R');
     }
 }
Example #10
0
 /**
  * @return null|ControllerConfig
  * Enter description here ...
  * @param unknown_type $module
  * @param unknown_type $controller
  * @param unknown_type $action
  */
 function getConfig($module = null, $controller = null, $action = null)
 {
     $request = App_Env::getRequest();
     $controller = null != $controller ? $controller : $request->getControllerName();
     $module = null != $module ? $module : $request->getModuleName();
     $action = null != $action ? $action : $request->getActionName();
     //echo($module.":".$controller.":".$action);
     if (!isset($this->_cache_config[$module][$controller][$action])) {
         $config = $this->loadConfig(APPLICATION_ENV);
         $config = $config->toArray();
         // print_r($config);
         $aConfig = $config["{$module}"]["{$controller}"]["{$action}"];
         //print_r($cConfig);
         if (isset($aConfig)) {
             //print_r($cConfig);
             //die();
             //$aConfig = $cConfig->toArray();
             $controllerConfig = new ControllerConfig();
             foreach ($aConfig['actionbutton'] as $key => $value) {
                 if ($value == "on") {
                     $controllerConfig->addButton($key);
                 }
             }
             foreach ($aConfig['componance'] as $key => $value) {
                 if ($value == "on") {
                     $controllerConfig->addComponance($key);
                 }
             }
             $this->_cache_config[$module][$controller][$action] = $controllerConfig;
         } else {
             $emptyConfig = new ControllerConfig();
             $emptyConfig->isEmpty = true;
             $this->_cache_config[$module][$controller][$action] = $emptyConfig;
         }
     }
     return $this->_cache_config[$module][$controller][$action];
 }
Example #11
0
 public function getBodyContent()
 {
     try {
         $this->setIsNullParam('COMPANY_INFO', $this->_info());
         $this->setIsNullParam('COMPANY_NAME_TH', $this->_info(false));
         $this->setIsNullParam('CUSTOMER_NAME', App_Env::getUserFullName());
         if (count($this->_to) == 0) {
             $this->addTo(App_Env::getUserEmail());
         }
         if (count($this->_bcc) == 0) {
             $this->addBcc(App_Env::getSystemEmail());
         }
         // $mail = new Zend_Mail('utf-8');
         //$mail->setHeaderEncoding();
         ob_start();
         // ดึง layout ออกมา
         if ($this->_templete_id != '') {
             $templtet = new Sys_Model_Template();
             $templtet->find($this->_templete_id);
             $this->_subject = $templtet->name;
             //หา ค่า posible value
             $possibleAttributes = $templtet->possibleAttributes;
             $possibleAttributes_tmp1 = str_replace(array("<ul>", '</ul>', '<li>', '</li>'), ' ', $possibleAttributes);
             $possibleAttributes_tmp1 = preg_replace(array('/\\s\\s+/'), " ", $possibleAttributes_tmp1);
             $possibleAttributes_tmp2 = explode(" ", $possibleAttributes_tmp1);
             $data_key = array();
             $data_value = array();
             foreach ($possibleAttributes_tmp2 as $attr) {
                 $attr = trim($attr);
                 if ($attr != '') {
                     $value = trim($this->_templete_params[$attr]);
                     if ($value == '') {
                         $value = 'N/A';
                     }
                     $data_value[] = $value;
                     $data_key[] = $attr;
                 }
             }
             //print_r($data_key);
             //print_r($data_value);
             echo str_replace($data_key, $data_value, $templtet->getContent());
         } else {
             // กำหนดค่าโดยตรง
             echo $content = $this->_content;
             echo $footer = $this->_footer;
         }
         $html = ob_get_clean();
         $html = str_replace("http://www.dev2.scimaxthailand.com", WEB_DOMAIN, $html);
         return $html;
         //  exit();
     } catch (Exception $e) {
         //	$this->view->stat = 'error';
         //	$this->view->msg = $e->getMessage ();
         echo $e->getMessage();
         // throw new Exception($e->getMessage());
     }
 }
Example #12
0
 protected function _getConfig($modelname)
 {
     return App_Env::getConfig($modelname);
 }
Example #13
0
 function isEditForm()
 {
     if (in_array(App_Env::getActionName(), array('edit', 'edit-dialog'))) {
         return true;
     }
     return $this->_iseditform;
 }
 function syncDbAction()
 {
     $this->_helper->layout()->disableLayout();
     $modelName = $modelname = $this->_request->getParam("model", '');
     $configXml = App_Model_Config::get($modelName)->getConfigXML();
     $modelConfig = $configXml->production->classes->{$modelName};
     $table = $modelConfig->table;
     $conn = App_Env::getDb();
     $dbh = $conn->getConnection();
     // print_r($DB);
     $sth = $dbh->prepare('SELECT * FROM ' . $table);
     $sth->execute();
     $colcount = $sth->columnCount();
     $typelist = array("LONG" => 'int', "VAR_STRING" => 'string', 'DATETIME' => 'datetime', 'BLOB' => 'text', 'DATE' => 'date');
     $inputlist = array("LONG" => 'text', "VAR_STRING" => 'text', 'DATETIME' => 'text', 'BLOB' => 'textarea', 'DATE' => 'datepicker');
     for ($i = 0; $i < $colcount; $i++) {
         $coll = $sth->getColumnMeta($i);
         $collName = $coll['name'];
         $propName = strtolower($collName);
         $propName = str_replace("_", " ", $propName);
         $propName = ucwords($propName);
         $propName = str_replace(" ", "", $propName);
         $propName = lcfirst($propName);
         $type = $coll['native_type'];
         if ($type == '') {
             $type = 'text';
         }
         //	print_r($coll);
         $propNode = $doc->createElement("prop");
         $formNode = $doc->createElement("field");
         $gridNode = $doc->createElement("field");
         $propNode->setAttribute('name', $propName);
         $propNode->setAttribute('column', $collName);
         $propNode->setAttribute('label', $propName);
         $propNode->setAttribute('sqltype', $type);
         $propNode->setAttribute('type', isset($typelist[$type]) ? $typelist[$type] : $type);
         $propNode->setAttribute('input', $inputlist[$type]);
         if (in_array("not_null", $coll['flags'])) {
             $propNode->setAttribute('required', 'false');
         }
         if ($coll['len'] < 4 and $typelist[$type] == 'int') {
             $propNode->setAttribute('input', 'spin');
         }
         if (in_array("primary_key", $coll['flags'])) {
             $propNode->setAttribute('pk', 'true');
             $propNode->setAttribute('pk', 'true');
             $propNode->setAttribute('name', 'id');
             if ($typelist[$type] == 'int') {
                 $propNode->setAttribute('form', 'false');
                 $propNode->setAttribute('autoIncrement', 'true');
             } else {
                 $propNode->setAttribute('autoIncrement', 'false');
             }
         }
     }
 }
Example #15
0
 function getMsg($infocode)
 {
     $this->arrinfo[0] = "";
     $this->arrinfo[91] = "Login Id or Email was not found ";
     $this->arrinfo[1] = "Login Id was not found or Password was not correct";
     $this->arrinfo[2] = "Password was not correct";
     $this->arrinfo[3] = "Your login has been disabled";
     $this->arrinfo[4] = "Session expired , you need to Login";
     $this->arrinfo[5] = "Logout was successfull.";
     $this->arrinfo[6] = "Password was sended to your email successfully.";
     $this->arrinfo[7] = "New record was inserted.";
     $this->arrinfo[8] = "Record updated successfully.";
     $this->arrinfo[9] = "Record deleted successfully.";
     $this->arrinfo[10] = "Unable to insert new record.";
     $this->arrinfo[11] = "Unable to update the record.";
     $this->arrinfo[12] = "Unable to delete record.";
     $this->arrinfo[13] = "Record was not found.";
     $this->arrinfo[14] = "Payment has been approved and order was updated.";
     $this->arrinfo[15] = "Registration completed, Login to countinue.";
     $this->arrinfo[16] = "Style was updated.";
     $this->arrinfo[17] = "Style was restored.";
     $this->arrinfo[18] = "You were not allowed to the page.";
     $this->arrinfo[19] = "Nothing was transfered";
     $this->arrinfo[20] = "Record transfered successfully";
     $this->arrinfo[20] = "Record transfered successfully";
     $this->arrinfo[21] = "Thank you for Signup.";
     $this->arrinfo[22] = "Document has been Updated Successfully";
     $this->arrinfo[23] = "You have already enter your IN timing";
     $this->arrinfo[24] = "No Such entries found";
     $this->arrinfo[25] = "Attached File has been Deleted Successfully";
     $this->arrinfo[26] = "Your group has been disabled";
     $this->arrinfo[27] = "Your are already out!";
     $this->arrinfo[28] = "User Information has been Updated Successfully";
     $this->arrinfo[29] = "Email sent successfully";
     $this->arrinfo[30] = "Record Already exists!";
     //------------- new info------------------------
     $this->arrinfo[31] = "User Status has been Changed";
     $this->arrinfo[32] = "Order Product Details Updated Successfully.";
     $this->arrinfo[33] = "Order Payment Details Updated Successfully.";
     $this->arrinfo[33] = "Order Note Updated Successfully.";
     $this->arrinfo[34] = "Order Qty Updated Successfully.";
     $this->arrinfo[35] = "Parts Successfully Add in your Order.";
     $this->arrinfo[36] = "Order Products Update Successfully.";
     $this->arrinfo[37] = "Order PCS can't be Decrease! Use Delete PC.";
     $this->arrinfo[38] = "PC was Deleted Successfully.";
     $this->arrinfo[39] = "Payment Entry was Deleted Successfully.";
     $this->arrinfo[40] = "Secure e-Payments Card Process Successfully.";
     $this->arrinfo[41] = "Order Reviewed Successfully.";
     $this->arrinfo[42] = "Order Note Deleted Successfully.";
     $this->arrinfo[43] = "Mail has been Successfully Save as Draft.";
     $this->arrinfo[44] = "Document(s) has been Uploaded Successfully.";
     //------------- end new info------------------------
     $this->arrinfo[44] = "An email was sent to " . App_Env::getUserEmail();
     $this->arrinfo[45] = "Error : System cound not send email!!";
     //Curr error
     $this->arrinfo[101] = "Service Schema has been Updated Successfully!!";
     $this->arrinfo[102] = "Unable to update Service Schema !!";
     //Eorditor
     $this->arrinfo[103] = "Assessment Approved!!";
     $this->arrinfo[104] = "Assessment Reseted!!";
     $output = '';
     if (isset($this->arrinfo[$infocode])) {
         $output = $this->arrinfo[$infocode];
     } else {
         $output = $infocode;
     }
     return $output;
 }
Example #16
0
 function render($RecordSet, $titleArray, $fields, $exportFileName)
 {
     /* Data to be inserted into excel in an array of arrays
      * Each array is the avg monthly temp of a different city */
     //$data = $list;
     //$csvTitle = $this->_filetitle;
     /* We know the keys of each sub-array are the same, so
      * extract them from the first sub-array and set them
      * to be our column titles */
     //$titleArray = $this->_headers;
     /* Set your desired delimiter. You can make this a true
      * .csv and set $delimiter = ","; but I find that tabs
      * work better as commas can also be present in your data.
      * Note that you must use the .tsv or .xls file extension for Excel
      * to correctly interpret tabs. Otherwise if you are using commas
      * for your delimiter, use .csv for your file extension. */
     $delimiter = ",";
     //Set target filename - see above comment on file extension.
     //Send headers ..header("Content-Type: text/plain");
     header('Content-type: text/html; charset=utf-8');
     //print the title to the first cell
     //print $csvTitle . "\r\n";
     // $fields = array ();
     //foreach ( $grid->ExtFields as $obt ) {
     //	$titleArray [] = lcfirst ( $obt ['field'] );
     //}
     //Separate each column title name with the delimiter
     $titleString = implode($delimiter, $titleArray);
     $preview = "<table border='1' width='100%'>";
     $preview .= "<tr>";
     foreach ($titleArray as $title) {
         $preview .= "<td>{$title}</td>";
     }
     $preview .= "</tr>";
     ob_start();
     echo $titleString . "\r\n";
     //Loop through each subarray, which are our data sets
     //$RecordSet = $grid->query ();
     $dataRowString = array();
     foreach ($RecordSet as $row) {
         $subArray = array();
         $preview .= "<tr>";
         foreach ($fields as $filed) {
             $text = $row->{$filed};
             $preview .= "<td>{$text}</td>";
             $text = iconv("UTF-8", "TIS-620", $text);
             $subArray[] = "\"{$text}\"";
         }
         $preview .= "</tr>";
         $dataRowString = implode($delimiter, $subArray);
         echo $dataRowString . "\r\n";
     }
     $preview .= "</table>";
     $contents = ob_get_contents();
     ob_clean();
     if ('' == $exportFileName) {
         $exportFileName = uniqid();
     }
     $filePath = App_Env::getPathOfUserTemporaryFolder() . "/" . $exportFileName . '.csv';
     $objFopen = fopen($filePath, 'w');
     fwrite($objFopen, $contents);
     fclose($objFopen);
     echo $preview;
 }
Example #17
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();
        }
    }
Example #18
0
 public function isExists($propName, $val = null)
 {
     if (is_array($propName)) {
         $select = $this->select();
         foreach ($propName as $data) {
             $col = $this->getMapper()->getDbColumn($data['col']);
             $val = $data['val'];
             $operator = trim($data['operator']);
             if ($val == 'ISNULL') {
                 $select->where("{$col} IS NULL");
             } elseif ($operator != '') {
                 $select->where("{$col} {$operator} '{$val}'");
             } else {
                 $select->where("{$col}=?", $val);
             }
         }
         $select->limit(1);
     } elseif ($val != null) {
         $col = $this->getMapper()->getDbColumn($propName);
         $select = $this->select()->where("{$col}=?", $val)->limit(1);
     } else {
         die($this->_modelName . " {$propName} val is null");
     }
     //die("SELECT count(*) AS Counter FROM (". $select .") ddxx");
     $db = App_Env::getDb();
     //if($propName == 'questionId')
     //die ("SELECT count(*) AS Counter FROM (". $select .") ddxx");
     $result = $db->fetchOne(" SELECT count(*) AS Counter FROM (" . $select . ") ddxx");
     return (int) $result > 0 ? true : false;
 }
 function uploadfileAction()
 {
     $this->disableLayout();
     //ini_set("display_errors", 1);
     $arrayErrorCode = array(UPLOAD_ERR_INI_SIZE => "UPLOAD_ERR_INI_SIZE", UPLOAD_ERR_FORM_SIZE => "UPLOAD_ERR_FORM_SIZE", UPLOAD_ERR_PARTIAL => "UPLOAD_ERR_PARTIAL", UPLOAD_ERR_NO_FILE => "UPLOAD_ERR_NO_FILE", UPLOAD_ERR_NO_TMP_DIR => "UPLOAD_ERR_NO_TMP_DIR", UPLOAD_ERR_CANT_WRITE => "UPLOAD_ERR_CANT_WRITE", UPLOAD_ERR_EXTENSION => "UPLOAD_ERR_EXTENSION", UPLOAD_ERR_EXTENSION => "UPLOAD_ERR_EXTENSION");
     sleep(3);
     $folder1 = 'eauditor';
     //strtolower($_SESSION['CollegeShortName']);
     $folder2 = str_replace("-", "", strtolower($this->_request->getParam('systemfolder', '')));
     $folderid = $this->_request->getParam('folder', '');
     // (isset($_REQUEST['folder']))? $_REQUEST['folder'] : '';
     if ($folderid == '') {
         $folderid = $this->_request->getParam('folderid', '1');
         isset($_REQUEST['folderid']) ? $_REQUEST['folder'] : '';
     }
     $file_show = $_FILES['fileupload']['name'];
     // debug($file_show)  ;
     //$fileRealname = $file_show;
     // echo $file_show;
     $file = $file_show;
     //iconv('UTF-8','TIS-620',$file_show);
     $real_name_in_db = $file;
     $url_save_in_db = "/docs/files/" . $folder1 . "/" . $folder2 . "/" . $file;
     $real_url_save_in_db = $url_save_in_db;
     $file_replace = $this->clean_filename($file);
     //$file_replace = iconv("TIS-620","UTF-8", $file_replace) ;
     // debug($file_replace)  ;
     $conn = App_Env::getDb();
     $sql = "SELECT COUNT(*) FROM sys_files WHERE FILE_REAL_NAME LIKE '{$file_show}' ";
     //debug($sql);
     $filecount = (int) $conn->fetchone($sql);
     //debug( "COUNT = ".$filecount);
     if ($filecount > 0) {
         // debug( "line 80 :filename = ".$filename);
         $fileNextIndex = $filecount + 1;
         $fileRename = $this->clean_filename($file_show, $filecount);
         $file_show = $fileRename;
         // debug( "line 90 :fileRename = ".$fileRename);
     } else {
         $fileRename = $this->clean_filename($file_show);
         $file_show = $fileRename;
     }
     $typefile = $_FILES['fileupload']['type'];
     $sizefile = $_FILES['fileupload']['size'];
     //$tempfile = "file/".date("Y-m-d")."-".$file;
     $url = "/docs/files/" . $folder1 . "/" . $folder2 . "/" . $file_show;
     $url_save_in_db = "/docs/files/" . $folder1 . "/" . $folder2 . "/" . $fileRename;
     $structure = str_replace("\\", "/", UPLOAD_PATH . $folder1 . "/" . $folder2);
     //$structure = $_SERVER ['DOCUMENT_ROOT'] . '/file/' . $folderName;
     echo UPLOAD_PATH;
     if (!is_dir($structure)) {
         @mkdir($structure, 0777, true);
     }
     $tempfile_show = $structure . "/" . urlencode($file_show);
     $tempfile = $structure . "/" . $fileRename;
     $errorCode = $_FILES['fileupload']['error'];
     $this->view->errorCode = $errorCode;
     $id = uniqid();
     if ($errorCode === UPLOAD_ERR_OK) {
         try {
             // $newdate =date( 'y-m-d H:i:s' );
             //  $newdatestr = $newdate->format ( 'y-m-d H:i:s' );
             $filedata = array('ID' => $id, 'NAME' => $fileRename, 'TYPE' => $typefile, 'SIZE' => $sizefile, 'PATH' => $tempfile, 'URL' => $url_save_in_db, 'IS_PUBLIC' => 1, 'FILE_REAL_URL' => $real_url_save_in_db, 'FILE_REAL_NAME' => $real_name_in_db, 'folder_id' => $folderid);
             $file = new Sys_Model_File();
             $file->setId($id)->setName($fileRename)->setType($typefile)->setSize($sizefile)->setPath($tempfile)->setUrl($url_save_in_db)->setIsPublic(1)->setIsActive(1)->setFileRealName($real_name_in_db)->setFileRealUrl($real_url_save_in_db)->setFolderId($folderid);
             $this->view->file = $file->save();
         } catch (Exception $e) {
             $error_message = $e->getMessage();
             $this->view->error_message = $error_message;
         }
         move_uploaded_file($_FILES['fileupload']['tmp_name'], $tempfile);
         //copy($_FILES['fileupload']['tmp_name'],$tempfile);
     } else {
         $error_message = $this->file_upload_error_message($errorCode);
         $this->view->errorCode = $arrayErrorCode[$errorCode];
         $this->view->errorCode = errorCode;
     }
 }
Example #20
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());
     }
 }
Example #21
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);
Example #22
0
 function _isMenuLeftPaneStateShow()
 {
     $moduleName = $this->_request->getModuleName();
     $controllerName = $this->_request->getControllerName();
     return App_Env::getSession("LEFT_PLAN_STATE" . $moduleName . $controllerName, 'SHOW') == 'SHOW';
 }
Example #23
0
 public function setModelConfigXml()
 {
     //static $x;
     //echo $x++;
     //echo "[".CONFIG_PATH . "$config","]";
     $model = $this->_modelName;
     $this->_config = App_Env::getConfig($model);
     return $this;
 }
Example #24
0
 protected function _submitForm(App_Form $form, $request, $id = '')
 {
     //print_r($_POST);
     //$form = new App_Form_Table($this->_modelName);
     //$this->_setForm ( $form,$this->_model );
     $id = trim($id);
     if ($request->getPost()) {
         if ($form->isValid($request->getPost())) {
             $isValid = true;
             if ($isValid) {
                 try {
                     if ($id == null) {
                         $info = 7;
                     } else {
                         $info = 8;
                     }
                     $lastId = $form->save($id);
                     $data['id'] = $lastId;
                     if ($form->isInsearted()) {
                         //echo "isInsearted";
                         //$this->_callBackAffterInsert ( $form, $data );
                     } elseif ($form->isUpdated()) {
                         //$this->_callBackAffterUpdate ( $form, $data );
                     }
                     if (trim($id) == '') {
                         $id = $lastId;
                     }
                     return true;
                     //$this->view->alert("กรุณากรอกข้อมูลในแบบฟอร์มให้ถูกต้อง และ บันทึกข้อมูลอีกครั้ง");
                     // $this->view->infocode = $info;
                 } catch (Exception $e) {
                     $this->view->alert("เกิดปัญหาในการบันทึกข้อมูล ลองบันทึกข้อมูลอีกครั้ง");
                     $this->view->infocode = App_Env::sqlerror($e->getMessage());
                     return false;
                 }
             }
         } else {
             $errors = $form->getMessages();
             $messages = array();
             foreach ($errors as $element_name => $error) {
                 $element_messages = array();
                 foreach ($error as $elmessages) {
                     $element_messages[] = "{$elmessages}";
                 }
                 $messages[] = "{$element_name}:" . join(",", $element_messages);
             }
             $form_alert_message = join("<br/>", $messages);
             $this->view->alert("กรุณากรอกข้อมูลในแบบฟอร์มให้ถูกต้อง และ บันทึกข้อมูลอีกครั้ง <br/>" . str_replace("'", "\\'", $form_alert_message));
             return false;
         }
     } else {
         return false;
         // $this->view->infocode = "no post data";
     }
     return false;
 }
Example #25
0
 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;
 }
Example #26
0
    /**
     * @param string $label
     * @param string $onclick
     * @param string $additionalClass
     * @param string $id
     * @param bool $disabled
     * @param string $title
     * @return string
     */
    public function Zbutton($action, $controller = '', $label = '', $id = '', $disabled = false, $title = '', $additionalClass = '', $userParams = null, array $windowOptions = null)
    {
        $module = '';
        if (is_array($action)) {
            $iconclass = isset($action['icon']) ? $action['icon'] : 'ui-icon-bullet';
            $controller = isset($action['controller']) ? $action['controller'] : null;
            $module = isset($action['module']) ? $action['module'] : null;
            $width = isset($action['width']) ? $action['width'] : null;
            $title = isset($action['tooltip']) ? $action['tooltip'] : null;
            $onClickFunction = isset($action['onClickFunction']) ? $action['onClickFunction'] : null;
            $label = isset($action['label']) ? $action['label'] : null;
            $id = isset($action['id']) ? $action['id'] : null;
            $disabled = isset($action['disabled']) ? $action['disabled'] : null;
            $additionalClass = isset($action['class']) ? $action['class'] : null;
            $userParams = isset($action['params']) ? $action['params'] : null;
            $windowOptions = isset($action['windowOptions']) ? $action['windowOptions'] : null;
            $url = isset($action['url']) ? $action['url'] : null;
            $class = isset($action['class']) ? $action['class'] : "{$action}-button";
            $action = isset($action['action']) ? $action['action'] : null;
            //if($label=='')$label=$title;
            //echo $iconclass;
            //return $iconclass;
        }
        //if(strtolower($label) == 'new')$label = ucfirst($action);
        $req = Zend_Controller_Front::getInstance()->getRequest();
        if (trim($controller) == '') {
            $controller = $req->getControllerName();
        }
        if ($module == '') {
            $module = $req->getModuleName();
        }
        //$class = "$action-button";
        $disabledClass = $disabled ? ' button-disabled ' : '';
        $onclick = '';
        if ($label == '') {
            $label = ucfirst($action);
        }
        //if($action =='reload')$label = 'reload';
        if ($title == '') {
            $title = "Click to " . ucfirst($action) . " {$controller}.";
        }
        if ($id == '') {
            $id = 'btn_' . $action;
        }
        //echo $action;
        $resource = strtolower("{$module}:{$controller}");
        $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, $action);
        $resourceName = "{$resource}#{$action}";
        if ($id == "SaveButton") {
            if (in_array(App_Env::getActionName(), array('new', 'new-dialog'))) {
                $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, "new");
            } else {
                $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, "edit");
            }
        } else {
        }
        //	echo (int)$isAllowed,"<br/>";
        $is_refresh = false;
        if ($action == 'reload') {
            $action = null;
            $is_refresh = true;
        }
        if ($isAllowed and $disabled == false) {
            if ($url != '') {
                $link = $url;
                $onclick = " onclick=\"location.href='{$link}'\" ";
            } else {
                if ($onClickFunction != '') {
                    $onclick = $onClickFunction;
                } else {
                    if ($windowOptions != null) {
                        //if(!isset($userParams["print"])){
                        //	$userParams["print"]='html';
                        //}
                        $userParams["mode"] = 'window';
                        if ($url == '') {
                            $link = $this->view->url($action, $controller, $module, $userParams);
                        } else {
                            $link = $url;
                        }
                        $wwidth = isset($windowOptions['width']) ? $windowOptions['width'] : '';
                        $wheight = isset($windowOptions['height']) ? $windowOptions['height'] : '';
                        if ($windowOptions['type'] == 'print') {
                            $id = 'PrintButton';
                            $onclick = "onclick=\"window.print();\"";
                        } else {
                            $onclick = "onclick=\"openWindows('{$link}','{$id}','{$wwidth}','{$wheight}')\"";
                        }
                    } elseif ($id == 'PrintButton') {
                        $userParams["mode"] = 'window';
                        $userParams["print"] = 'html';
                        if ($url == '') {
                            $link = $this->view->url($action, $controller, $module, $userParams);
                        } else {
                            $link = $url;
                        }
                        $onclick = "onclick=\"window.print();\"";
                    } else {
                        if ($is_refresh) {
                            //$link = $this->view->url('SSSSS',$controller,null,$userParams,true);
                            $x = uniqid();
                            $onclick = "onclick=\"location.href='?x={$x}&filter=reset'\"";
                        } elseif ($action != '') {
                            $link = $this->view->url($action, $controller, null, $userParams, true);
                            $onclick = "onclick=\"location.href='{$link}'\"";
                        } else {
                            $onclick = '';
                        }
                    }
                }
            }
        } else {
            $disabled = true;
        }
        if ($disabled == true) {
            $disabledClass = ' button-disabled ';
            $disabled = 'disabled="disabled"';
        }
        if ($action == 'index' or $action == 'back') {
            //$iconclass = "glyphicon glyphicon-refresh";
        }
        if ($action == 'close' or $action == 'back') {
            //$iconclass = "glyphicon glyphicon-refresh";
        }
        if ($is_refresh) {
            $iconclass = "glyphicon glyphicon-refresh";
        } elseif ($id == "SaveButton" or $id == "DownloadButton" or $id == "SaveTransaction") {
            $iconclass = "glyphicon glyphicon-floppy-disk";
        } elseif ($id == "ResetButton" or $class == 'reset' or $Id == "ReStart" or $id == 'forn-search-button-refresh') {
            $iconclass = "glyphicon glyphicon-refresh";
        } elseif ($id == "CancelButton") {
            $iconclass = "glyphicon glyphicon-remove";
        } elseif ($id == "EditButton" or $id == "edit") {
            $iconclass = "glyphicon glyphicon-pencil";
        } elseif ($id == "CloseButton") {
            $iconclass = "glyphicon glyphicon-remove-circle";
        } elseif ($id == "ExportButton") {
            $iconclass = "glyphicon glyphicon-download";
        } elseif ($id == "PrintButton") {
            $iconclass = "glyphicon glyphicon-print";
            $label = 'Print';
        } elseif ($class == 'apply' or $id == 'forn-search-button-submit') {
            $iconclass = "glyphicon glyphicon-search";
            $title = 'search';
            $label = 'search';
        } elseif ($id == 'CloseToIIndexButton' or $id == 'CloseToIndexButton') {
            $iconclass = "glyphicon glyphicon-chevron-left";
            $link = App_View_Helper_Table::getToIndexLink($this->view, null, null, null, array('action' => $action));
            $onclick = "onclick=\"location.href='{$link}'\"";
        } elseif ($id == "DeleteButton") {
            $iconclass = "glyphicon glyphicon-trash";
        } elseif ($id == "NewButton") {
            $iconclass = "glyphicon glyphicon-plus";
        }
        if (trim($iconclass) == '') {
            $iconclass = "glyphicon glyphicon-plus";
        }
        if ($width == '') {
            $width = '300';
        }
        $style = " style='width: {$width} ;' ";
        /*		
        		$output =<<<button
        		<input type='button' value='{$label}'  id='{$id}' name='$id' $onclick $disabled $width title='{$this->view->escape($title)}' class='btn {$class} {$disabledClass} {$additionalClass}' />
        				    
        button;
        					$output2 =<<<buttonImg
        		<img type="button" value="{$label}" 
        		 			id='{$id}'
        		 			name='$id'
        					$onclick
        					$disabled
        					title='{$this->view->escape($title)}'
        					class=' {$class} {$disabledClass} {$additionalClass}' />
        				    
        buttonImg;
        */
        $output3 = <<<buttonImg
\t\t<a resource='{$resourceName}'  id='{$id}' name='{$id}' {$onclick} {$disabled} {$style} title='{$this->view->escape($title)}' class='btn btn-default btn-xs ' >
\t\t<i class="{$iconclass}"></i> {$label}
\t\t</a>
\t\t\t\t    
buttonImg;
        return $output3;
    }
Example #27
0
 function render(App_Grid_Filter $filter, $exportLayout, $page, $fileName)
 {
     $pdf = new mypdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->caption = $this->caption;
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 048');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 048', PDF_HEADER_STRING);
     // set header and footer fonts
     //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     $pdf->SetMargins(2, 0, 5);
     //$pdf->SetHeaderMargin(2);
     //$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set some language-dependent strings
     //$pdf->setLanguageArray($l);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', 'B', 20);
     // add a page
     // -----------------------------------------------------------------------------
     // -----------------------------------------------------------------------------
     $totalpage = $this->filter()->getTotalPage();
     if ($page == 'all') {
         $startPage = 1;
         $endPage = $totalpage;
     } elseif (is_array($page)) {
         $startPage = (int) $page['0'];
         $endPage = (int) $page['1'];
     } elseif (is_numeric($page)) {
         $startPage = $endPage = (int) $page;
     }
     if ($startPage < 0) {
         $startPage = 1;
     }
     if ($endPage == '') {
         $endPage = $startPage;
     }
     if ($endPage > $totalpage) {
         $endPage = $totalpage;
     }
     for ($i = $startPage; $i <= $endPage; $i++) {
         $pdf->AddPage($exportLayout);
         $pdf->SetFont('freeserif', '', 7);
         $pdf->SetX(5);
         $pdf->SetY(10);
         $filter->setPage($i);
         $list = $filter->getList();
         $tbl = $this->renderSimpleTable($filter, $list);
         $pdf->writeHTML($tbl, true, true, false, false, '');
     }
     //Close and output PDF document
     if ('' == $fileName) {
         $fileName = uniqid();
     }
     $filePath = App_Env::getPathOfUserTemporaryFolder() . "/" . $fileName . '.pdf';
     $pdf->Output($filePath, 'F');
     $pdf->Output(null, 'I');
     //============================================================+
     // END OF FILE
     //============================================================+
 }
Example #28
0
 /**
  * Fetch all guestbook entries
  *
  * @return array
  */
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     //$time = microtime_float();
     //exit();
     /*
     if(is_string($where)){
     	$where = explode("WHERE", $where); //Zend_Db_Select::
     }else{
     echo 	$where->getPart( Zend_Db_Select::ORDER );
     }
     if($where ){
     	print_r($where);
     	echo 	$where->getPart( Zend_Db_Select::WHERE );
     }
     */
     $model = $this->getModel();
     //die( "xx".get_class($model) );
     $config = $this->getModelConfig();
     $modelName = get_class($model);
     //$this->getModel()->getModelName();
     // die($modelName);
     if ($model->getBaseSQL() != '') {
         $sql = $model->getBaseSQL();
         $sqlselect = " SELECT * FROM ( {$sql} ) tttt ";
         if ($where instanceof Zend_Db_Select) {
             $dbselect = $where;
             $where = $dbselect->getPart(Zend_Db_Select::WHERE);
             $orders = $dbselect->getPart(Zend_Db_Select::ORDER);
             $count = $dbselect->getPart(Zend_Db_Select::LIMIT_COUNT);
             $offet = $dbselect->getPart(Zend_Db_Select::LIMIT_OFFSET);
             if (count($where) > 0) {
                 $sqlselect .= " WHERE " . join(" ", $where);
             }
             if (count($orders) > 0) {
                 $orderby = array();
                 foreach ($orders as $order) {
                     $orderby[] = $order[0] . ' ' . $order[1];
                 }
                 $sqlselect .= " ORDER BY " . join(",", $orderby);
             }
             if ($count != 0) {
                 $sqlselect .= " LIMIT {$offet},{$count} ";
             }
         } else {
             if ($where != '') {
                 $sqlselect .= " where " . $where;
             }
             if ($order != null) {
                 $sqlselect .= " ORDER BY {$order} ";
             }
             if ($offset != null) {
                 $sqlselect .= " LIMIT {$offset},99999999 ";
             }
             if ($count != null) {
                 if ($offset == null) {
                     $offset = 0;
                 }
                 $sqlselect .= " LIMIT {$offset},{$count} ";
             }
             //	echo $sqlselect;
         }
         $querytype = 'basesql';
         $cacheId = md5($sqlselect);
     } elseif ($where instanceof Zend_Db_Select) {
         $querytype = 'dbselect';
         $cacheId = md5($where);
     } elseif ($model->isIgnoreDbTable()) {
         $querytype = 'db';
         $cacheId = md5($where);
         //	echo "isIgnoreDbTable".$where;
     } else {
         $sqlwhere = $this->_getSQLOfPart($where, $order, $count, $offset);
         $cacheId = md5($modelName . $sqlwhere);
     }
     //die("[".$sqlwhere."]");
     $entries = false;
     if (CACHE_DB_ENABLED) {
         $cache_dir = PRIVATE_PATH . '/data/cache/' . $model->getModelName();
         if (!is_dir($cache_dir)) {
             @mkdir($cache_dir, 0777, true);
         }
         $backendOptions = array('cache_dir' => $cache_dir);
         $frontendOptions = array('lifetime' => 7200, 'automatic_serialization' => true);
         $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
         $entries = $cache->load($cacheId);
     }
     if ($entries === false) {
         switch ($querytype) {
             case 'basesql':
                 //die('basesql');
                 $db = App_Env::getDb();
                 $resultSet = $db->fetchAll($sqlselect);
                 break;
             case 'dbselect':
                 //die('dbselect');
                 $resultSet = $this->getDbTable()->fetchAll($where);
                 break;
             case 'db':
                 //die('db');
                 $db = App_Env::getDb();
                 $db->setFetchMode(Zend_Db::FETCH_BOTH);
                 $resultSet = $db->fetchAll($where);
                 break;
             default:
                 //echo $where ,"<hr/>";
                 //echo $count,"<hr/>";
                 //echo $order,"<hr/>";
                 //echo $offset,"<hr/>";
                 $resultSet = $this->getDbTable()->fetchAll($where, $order, $count, $offset);
                 // die('default');
                 break;
         }
         //  print_r($resultSet);
         $entries = array();
         $configProp = $config->prop;
         foreach ($resultSet as $row) {
             $entries[] = $this->bindEntry($modelName, $row);
         }
         //print_r($entries);
         // echo '<br/>fetchall_time:',round(microtime_float() - $time,3,PHP_ROUND_HALF_UP);
         if (CACHE_DB_ENABLED) {
             $cache->save($entries, $cacheId);
         }
     }
     return $entries;
 }
Example #29
0
 /**
  * 
  * @return Sam_Auth
  */
 static function getInstance()
 {
     $session = new Zend_Session_Namespace('samSession');
     if (isset($session->sesSamXAuth2) and App_Env::getSession("userType") == 'customer') {
         $objSam = $session->sesSamXAuth2;
         // true ; //$_SESSION ['ses_SamX_obj'];
     } else {
         $objSam = new Sam_AuthCustomer();
         $session->sesSamXAuth2 = $objSam;
     }
     App_Env::setSession("userType", 'customer');
     $objSam->setUserType('customer');
     return $objSam;
 }
Example #30
0
 static function getInstance()
 {
     //session_start();
     //if(APPLICATION_ENV == 'development'){
     $session = new Zend_Session_Namespace('sam_session' . uniqid(), true);
     //}
     if (isset($_SESSION['ses_SamX_obj'])) {
         $objSam = $_SESSION['ses_SamX_obj'];
         // true ; //$_SESSION ['ses_SamX_obj'];
         //die("isset");
     } else {
         //die("not isset");
         $objSam = new Sam_Auth();
         $_SESSION['ses_SamX_obj'] = $objSam;
     }
     App_Env::setSession("userType", 'admin');
     $objSam->setUserType('admin');
     return $objSam;
 }