Next4Me
 All Data Structures Files Functions Variables
application/models/tplActionTypes.php
Go to the documentation of this file.
00001 <?php 
00015 class TplActionTypes extends Zend_Db_Table_Abstract {
00016         protected $_name="tplActionTypes"; 
00017         protected $_primary="IdTplActionType"; 
00018         //==== Start AddEditTplActionTypes =========================================================================
00031         function AddEditTplActionTypes($entity) {
00032                         // function implementation
00033             $resultId = 0;
00034             $page="tplActionTypes.php";
00035             $method="AddEditTplActionTypes";
00036             $result=json_encode($entity);
00037             $message="";
00038             $type="1";
00039             $this->ErrorCode = new ErrorCode;
00040             $this->Log = new Log;
00041 
00042             try{
00043                 if ($entity['IdTplActionType']=="0"){
00044                     $k=$this->insert($entity);
00045                     $k=$this->getAdapter()->lastInsertId();
00046                     $resultCode=$k;
00047                 }else{
00048                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00049                             ->from("tplActionTypes","*")
00050                             ->where("IdTplActionType=?",$entity['IdTplActionType'])
00051                     );
00052                 if($rows==null){
00053                     $resultId = 3052;
00054                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00055                     $resultCode=$r['Message'];
00056                     $message=$r['Message'];
00057                     $type=3;    
00058                 }else{
00059                     $this->update(array(
00060                         "IdTplContext" => $entity['IdTplContext'],
00061                         "Name" => $entity['Name'],
00062                         "Icon" => $entity['Icon'],
00063                         "DurataImplicita" => $entity['DurataImplicita'],
00064                     ),$this->getAdapter()->quoteInto('IdTplActionType=?',$entity['IdTplActionType']));
00065                     $k=$entity['IdTplActionType'];
00066                     $resultCode=$k;
00067                 }
00068                 }
00069                 
00070             }
00071             catch(Exception $e){
00072                 $resultCode=$e->getMessage();
00073                 $resultId=101;       
00074                 $type=3;
00075             }
00076                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00077                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00078             return $response;
00079         
00080         }
00081         //============ End AddEditTplActionTypes ==============================================================
00082 
00083 
00084         //==== Start DeleteTplActionTypes =========================================================================
00094         function DeleteTplActionTypes($entity) {
00095                         // function implementation
00096             $resultId = 0;
00097             $page="tplActionTypes.php";
00098             $method="DeleteTplActionTypes";
00099             $result=json_encode($entity);
00100             $message="";
00101             $type="1";
00102             $this->ErrorCode = new ErrorCode;
00103             $this->Log = new Log;
00104 
00105             try{
00106                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00107                             ->from("tplActionTypes","*")
00108                             ->where("IdTplActionType=?",$entity['IdTplActionType'])
00109                     );
00110                 if($rows==null){
00111                     $resultId = 3053;
00112                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00113                     $resultCode=$r['Message'];
00114                     $message=$r['Message'];
00115                     $type=3;    
00116                 }else{
00117                     $i=0;
00118                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00119                             ->from("tplActionTypeResults","*")
00120                             ->where("IdTplActionType=?",$entity['IdTplActionType'])
00121                     );
00122                     if($chld!=null){
00123                         $i++;
00124                     }
00125                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00126                             ->from("tplActionTypeProperties","*")
00127                             ->where("IdTplActionType=?",$entity['IdTplActionType'])
00128                     );
00129                     if($chld!=null){
00130                         $i++;
00131                     }
00132                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00133                             ->from("tplActionTypeAlerts","*")
00134                             ->where("IdTplActionType=?",$entity['IdTplActionType'])
00135                     );
00136                     if($chld!=null){
00137                         $i++;
00138                     }
00139                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00140                             ->from("tplActionTypeNextActions","*")
00141                             ->where("IdTplActionType=?",$entity['IdTplActionType'])
00142                     );
00143                     if($chld!=null){
00144                         $i++;
00145                     }
00146                 if($i==0){
00147                     $k=$this->delete($this->getAdapter()->quoteInto("IdTplActionType=?",$entity['IdTplActionType']));
00148                     $resultCode="Date sterse";
00149                 }else{
00150                     $resultId = 4010;
00151                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00152                     $resultCode=$r['Message'];
00153                     $message=$r['Message'];
00154                     $type=3;    
00155                     }
00156                 }
00157             }
00158             catch(Exception $e){
00159                 $resultCode=$e->getMessage();
00160                 $resultId=101;       
00161                 $type=3;
00162             }
00163                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00164                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00165             return $response;
00166         }
00167         //============ End DeleteTplActionTypes ==============================================================
00168 
00169 
00170         //==== Start GetTplActionTypes =========================================================================
00179         function GetTplActionTypes($entity) {
00180                         // function implementation
00181             $resultId = 0;
00182             $page="tplActionTypes.php";
00183             $method="GetTplActionTypes";
00184             $result=json_encode($entity);
00185             $message="";
00186             $type="1";
00187             $this->ErrorCode = new ErrorCode;
00188             $this->Log = new Log;
00189 
00190             try{
00191                  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00192                             ->from("tplActionTypes","*")
00193                             ->where("IdTplActionType=?",$entity['IdTplActionType'])
00194                             ->orWhere("0=?", $entity['IdTplActionType'])
00195                     );
00196             if(count($rows)!=0){
00197                 foreach($rows as $row){
00198                     $resultCode[]=array("IdTplActionType"=>$row->IdTplActionType, 
00199                         "IdTplContext" =>$row->IdTplContext, 
00200                         "Name" =>$row->Name, 
00201                         "Icon" => $row->Icon, 
00202                         "DurataImplicita" => $row->DurataImplicita);
00203                 }
00204             }else{
00205                 $resultId = 3054;
00206                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00207                 $resultCode=$r['Message'];
00208                 $message=$r['Message'];
00209                 $type=3;    
00210             }   
00211             }
00212             catch(Exception $e){
00213                 $resultCode=$e->getMessage();
00214                 $resultId=101;       
00215                 $type=3;
00216             }
00217                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00218                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00219             return $response;
00220         }
00221         //============ End GetTplActionTypes ==============================================================
00222 
00223 }
00224 
00225 ?>