Next4Me
 All Data Structures Files Functions Variables
application/models/tplMicroflowActions.php
Go to the documentation of this file.
00001 <?php 
00014 class TplMicroflowActions   extends Zend_Db_Table_Abstract {
00015         protected $_name="tplMicroflowActions"; 
00016         protected $_primary="IdTplMicroflowAction"; 
00017         //==== Start AddEditTplMicroflowActions =========================================================================
00031         function AddEditTplMicroflowActions($entity) {
00032                         // function implementation
00033             $resultId = 0;
00034             $page="tplMicroflowActions.php";
00035             $method="AddEditTplMicroflowActions";
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['IdTplMicroflowAction']=="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("tplMicroflowActions","*")
00050                             ->where("IdTplMicroflowAction=?",$entity['IdTplMicroflowAction'])
00051                     );
00052                 if($rows!=null){
00053                     $IdTplMicroflow=$rows->IdTplMicroflow;
00054                     if($IdTplMicroflow==$entity['IdTplMicroflow']){
00055                     $this->update(array(
00056                         "IdTplMicroflow" => $entity['IdTplMicroflow'], 
00057                         "IdTplActionType" => $entity['IdTplActionType'], 
00058                         "Name" => $entity['Name'], 
00059                         "Description" => $entity['Description'], 
00060                         "IdTplContext" => $entity['IdTplContext'], 
00061                     ),$this->getAdapter()->quoteInto('IdTplMicroflowAction=?',$entity['IdTplMicroflowAction']));
00062                     $k=$entity['IdTplMicroflowAction'];
00063                     $resultCode=$k;
00064                 }else{
00065                     $resultId = 5017;
00066                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00067                     $resultCode=$r['Message'];
00068                     $message=$r['Message'];
00069                     $type=3;    
00070                 }
00071                 }else{
00072                     $resultId = 3070;
00073                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00074                     $resultCode=$r['Message'];
00075                     $message=$r['Message'];
00076                     $type=3;    
00077                 }                                    
00078              }
00079                 
00080             }
00081             catch(Exception $e){
00082                 $resultCode=$e->getMessage();
00083                 $resultId=101;       
00084                 $type=3;
00085             }
00086                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00087                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00088          return $response;
00089         }
00090         //============ End AddEditTplMicroflowActions ==============================================================
00091 
00092 
00093         //==== Start DeleteTplMicroflowActions =========================================================================
00102         function DeleteTplMicroflowActions($entity) {
00103                         // function implementation
00104             $resultId = 0;
00105             $page="tplMicroflowActions.php";
00106             $method="DeleteTplMicroflowActions";
00107             $result=json_encode($entity);
00108             $message="";
00109             $type="1";
00110             $this->ErrorCode = new ErrorCode;
00111             $this->Log = new Log;
00112 
00113             try{
00114                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00115                             ->from("tplMicroflowActions","*")
00116                             ->where("IdTplMicroflowAction=?",$entity['IdTplMicroflowAction'])
00117                     );
00118                 if($rows==null){
00119                     $resultId = 3071;
00120                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00121                     $resultCode=$r['Message'];
00122                     $message=$r['Message'];
00123                     $type=3;    
00124                 }else{
00125                     $i=0;
00126                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00127                             ->from("tplMicroflowActionResults","*")
00128                             ->where("IdTplMicroflowAction=?",$entity['IdTplMicroflowAction'])
00129                     );
00130                     if($chld!=null){
00131                         $i++;
00132                     }
00133                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00134                             ->from("tplMicroflowNextActions","*")
00135                             ->where("IdTplMicroflowAction=?",$entity['IdTplMicroflowAction'])
00136                     );
00137                     if($chld!=null){
00138                         $i++;
00139                     }
00140                 if($i==0){
00141                     $k=$this->delete($this->getAdapter()->quoteInto("IdTplMicroflowAction=?",$entity['IdTplMicroflowAction']));
00142                     $resultCode="Date sterse";
00143                 }else{
00144                     $resultId = 4012;
00145                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00146                     $resultCode=$r['Message'];
00147                     $message=$r['Message'];
00148                     $type=3;    
00149                     }
00150                 }
00151             }
00152             catch(Exception $e){
00153                 $resultCode=$e->getMessage();
00154                 $resultId=101;       
00155                 $type=3;
00156             }
00157                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00158                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00159             return $response;
00160         }
00161         //============ End DeleteTplMicroflowActions ==============================================================
00162 
00163 
00164         //==== Start GetTplMicroflowActions =========================================================================
00172         function GetTplMicroflowActions($entity) {
00173                         // function implementation
00174             $resultId = 0;
00175             $page="tplMicroflowActions.php";
00176             $method="GetTplMicroflowActions";
00177             $result=json_encode($entity);
00178             $message="";
00179             $type="1";
00180             $this->ErrorCode = new ErrorCode;
00181             $this->Log = new Log;
00182 
00183             try{
00184                  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00185                             ->from("tplMicroflowActions","*")
00186                             ->where("IdTplMicroflowAction=?",$entity['IdTplMicroflowAction'])
00187                             ->orWhere("0=?", $entity['IdTplMicroflowAction'])
00188                     );
00189             if(count($rows)!=0){
00190                 foreach($rows as $row){
00191                     $resultCode[]=array("IdTplMicroflowAction" => $row->IdTplMicroflowAction,
00192                         "IdTplMicroflow" => $row->IdTplMicroflow, 
00193                         "IdTplActionType" => $row->IdTplActionType, 
00194                         "Name" => $row->Name, 
00195                         "Description" => $row->Description, 
00196                         "IdTplContext" => $row->IdTplContext, );
00197                 }
00198             }else{
00199                 $resultId = 3072;
00200                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00201                 $resultCode=$r['Message'];
00202                 $message=$r['Message'];
00203                 $type=3;    
00204             }
00205             }
00206             catch(Exception $e){
00207                 $resultCode=$e->getMessage();
00208                 $resultId=101;       
00209                 $type=3;
00210             }
00211                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00212                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00213          return $response;
00214         }
00215         //============ End GetTplMicroflowActions ==============================================================
00216 
00217 }
00218 
00219 ?>