Next4Me
 All Data Structures Files Functions Variables
application/models/tplContextConditions.php
Go to the documentation of this file.
00001 <?php
00013 class TplContextConditions   extends Zend_Db_Table_Abstract {
00014         protected $_name="tplContextConditions"; 
00015         protected $_primary="IdTplContextCondition"; 
00016         //==== Start AddEditTplContextConditions =========================================================================
00029         function AddEditTplContextConditions($entity) {
00030                         // function implementation
00031             $resultId = 0;
00032             $page="tplContextConditions.php";
00033             $method="AddEditTplContextConditions";
00034             $result=json_encode($entity);
00035             $message="";
00036             $type="1";
00037             $this->ErrorCode = new ErrorCode;
00038             $this->Log = new Log;
00039 
00040             try{
00041                 if ($entity['IdTplContextCondition']=="0"){
00042                     $k=$this->insert($entity);
00043                     $k=$this->getAdapter()->lastInsertId();
00044                     $resultCode=$k;
00045                 }else{
00046                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00047                             ->from("tplContextConditions","*")
00048                             ->where("IdTplContextCondition=?",$entity['IdTplContextCondition'])
00049                     );
00050                 if($rows!=null){
00051                     $IdTplContext=$rows->IdTplContext;
00052                     if($IdTplContext==$entity['IdTplContext']){
00053                     $this->update(array(
00054                         "IdTplContext" => $entity['IdTplContext'], 
00055                         "Name" => $entity['Name'], 
00056                         "Description" => $entity['Description'], 
00057                         "IdContext" => $entity['IdContext'], 
00058                     ),$this->getAdapter()->quoteInto('IdTplContextCondition=?',$entity['IdTplContextCondition']));
00059                     $k=$entity['IdTplContextCondition'];
00060                     $resultCode=$k;
00061                 }else{
00062                     $resultId = 5011;
00063                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00064                     $resultCode=$r['Message'];
00065                     $message=$r['Message'];
00066                     $type=3;    
00067                 }
00068                 }else{
00069                     $resultId = 3046;
00070                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00071                     $resultCode=$r['Message'];
00072                     $message=$r['Message'];
00073                     $type=3;    
00074                 }
00075                 
00076                 }
00077             }
00078             catch(Exception $e){
00079                 $resultCode=$e->getMessage();
00080                 $resultId=101;       
00081                 $type=3;
00082             }
00083                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00084                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00085          return $response;
00086         }
00087         //============ End AddEditTplContextConditions ==============================================================
00088 
00089 
00090         //==== Start DeleteTplContextConditions =========================================================================
00099         function DeleteTplContextConditions($entity) {
00100                         // function implementation
00101             $resultId = 0;
00102             $page="tplContextConditions.php";
00103             $method="DeleteTplContextConditions";
00104             $result=json_encode($entity);
00105             $message="";
00106             $type="1";
00107             $this->ErrorCode = new ErrorCode;
00108             $this->Log = new Log;
00109 
00110             try{
00111                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00112                             ->from("tplContextConditions","*")
00113                             ->where("IdTplContextCondition=?",$entity['IdTplContextCondition'])
00114                     );
00115                 if($rows==null){
00116                     $resultId = 3047;
00117                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00118                     $resultCode=$r['Message'];
00119                     $message=$r['Message'];
00120                     $type=3;    
00121                 }else{
00122                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00123                             ->from("tplContextFactors","*")
00124                             ->where("IdTplContextCondition=?",$entity['IdTplContextCondition'])
00125                     );
00126                     if($chld==null){
00127                         $k=$this->delete($this->getAdapter()->quoteInto("IdTplContextCondition=?",$entity['IdTplContextCondition']));
00128                         $resultCode="Date sterse";
00129                     }else{
00130                         $resultId = 4009;
00131                         $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00132                         $resultCode=$r['Message'];
00133                         $message=$r['Message'];
00134                         $type=3;    
00135                     }
00136                 }
00137             }
00138             catch(Exception $e){
00139                 $resultCode=$e->getMessage();
00140                 $resultId=101;       
00141                 $type=3;
00142             }
00143                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00144                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00145             return $response;
00146         }
00147         //============ End DeleteTplContextConditions ==============================================================
00148 
00149 
00150         //==== Start GetTplContextConditions =========================================================================
00158         function GetTplContextConditions($entity) {
00159                         // function implementation
00160             $resultId = 0;
00161             $page="tplContextConditions.php";
00162             $method="GetTplContextConditions";
00163             $result=json_encode($entity);
00164             $message="";
00165             $type="1";
00166             $this->ErrorCode = new ErrorCode;
00167             $this->Log = new Log;
00168 
00169             try{
00170                  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00171                             ->from("tplContextConditions","*")
00172                             ->where("IdTplContextCondition=?",$entity['IdTplContextCondition'])
00173                             ->orWhere("0=?", $entity['IdTplContextCondition'])
00174                     );
00175             if(count($rows)!=0){
00176                 foreach($rows as $row){
00177                     $resultCode[]=array("IdTplContextCondition" => $row->IdTplContextCondition,
00178                         "IdTplContext" => $row->IdTplContext, 
00179                         "Name" => $row->Name, 
00180                         "Description" => $row->Description, 
00181                         "IdContext" => $row->IdContext, );
00182                 }
00183             }else{
00184                 $resultId = 3048;
00185                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00186                 $resultCode=$r['Message'];
00187                 $message=$r['Message'];
00188                 $type=3;    
00189             }
00190             }
00191             catch(Exception $e){
00192                 $resultCode=$e->getMessage();
00193                 $resultId=101;       
00194                 $type=3;
00195             }
00196                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00197                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00198          return $response;
00199         }
00200         //============ End GetTplContextConditions ==============================================================
00201 
00202 }
00203 
00204 ?>