Next4Me
 All Data Structures Files Functions Variables
application/models/MicroflowNextActions.php
Go to the documentation of this file.
00001 <?php 
00021 class MicroflowNextActions  extends Zend_Db_Table_Abstract {
00022     //put your code here
00023     protected $_name="MicroflowNextActions"; 
00024     protected $_primary="IdMicroflowNextAction"; 
00025     
00026 
00027         //==== Start AddEditMicroflowNextActions =========================================================================
00042         function AddEditMicroflowNextActions($entity) {
00043                         // function implementation
00044             $resultId = 0;
00045             $page="MicroflowNextActions.php";
00046             $method="AddEditMicroflowNextActions";
00047             $result=json_encode($entity);
00048             $message="";
00049             $type="1";
00050             $this->ErrorCode = new ErrorCode;
00051             $this->Log = new Log;
00052 
00053             try{
00054                 if ($entity['IdMicroflowNextAction']=="0"){
00055                     $k=$this->insert($entity);
00056                     $k=$this->getAdapter()->lastInsertId();
00057                     $resultCode=$k;
00058                 }else{
00059                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00060                     ->from("MicroflowNextActions","*")
00061                     ->where("IdMicroflowNextAction=?",$entity['IdMicroflowNextAction'])
00062                     );
00063                 if($rows!=null){
00064                     $IdNextActionMf=$rows->IdNextActionMf;
00065                 if($IdNextActionMf==$entity['IdNextActionMf']){
00066                     $this->update(array(
00067                         "IdNextActionMf" => $entity['IdNextActionMf'],
00068                         "Name" => $entity['Name'], 
00069                         "Description"=>$entity['Description'],
00070                         "IsRecursive"=>$entity['IsRecursive'],
00071                         "IdTplMicroflowNextAction"=>$entity['IdTplMicroflowNextAction']
00072                     ),$this->getAdapter()->quoteInto('IdMicroflowNextAction=?',$entity['IdMicroflowNextAction']));
00073                     $k=$entity['IdMicroflowNextAction'];
00074                     $resultCode=$k;
00075                 }else{
00076                     $resultId = 5008;
00077                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00078                     $resultCode=$r['Message'];
00079                     $message=$r['Message'];
00080                     $type=3;
00081                 }
00082                 }else{
00083                     $resultId = 3031;
00084                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00085                     $resultCode=$r['Message'];
00086                     $message=$r['Message'];
00087                     $type=3;
00088                 }
00089                 
00090                 }
00091                 
00092                     
00093                 
00094             }
00095             catch(Exception $e){
00096                 $resultCode=$e->getMessage();
00097                 $resultId=101;       
00098                 $type=3;
00099             }
00100                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00101                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00102          return $response;
00103         }
00104         //============ End AddEditMicroflowNextActions ==============================================================
00105 
00106 
00107         //==== Start DeleteMicroflowNextActions =========================================================================
00117         function DeleteMicroflowNextActions($entity) {
00118                         // function implementation
00119             $resultId = 0;
00120             $page="MicroflowNextActions.php";
00121             $method="DeleteMicroflowNextActions";
00122             $result=json_encode($entity);
00123             $message="";
00124             $type="1";
00125             $this->ErrorCode = new ErrorCode;
00126             $this->Log = new Log;
00127 
00128             try{
00129                 if(isset($entity['IdMicroflowNextAction'])&&$entity['IdMicroflowNextAction']!=null)
00130                 {
00131                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00132                                 ->from("MicroflowNextActions","*")
00133                                 ->where("IdMicroflowNextAction=?",$entity['IdMicroflowNextAction'])
00134                         );
00135                     if($rows==null){
00136                         $resultId = 3032;
00137                         $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00138                         $resultCode=$r['Message'];
00139                         $message=$r['Message'];
00140                         $type=3;                    
00141                     }else{
00142                     $k=$this->delete($this->getAdapter()->quoteInto("IdMicroflowNextAction=?",$entity['IdMicroflowNextAction']));
00143                     $resultCode="Date sterse";
00144                     }
00145                 }
00146                 if(isset($entity['IdMicroflowAction'])&&$entity['IdMicroflowAction']!=null)
00147                 {
00148                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00149                                 ->from("MicroflowNextActions","*")
00150                                 ->where("IdNextActionMf=?",$entity['IdMicroflowAction'])
00151                         );
00152                     if($rows==null){
00153                         $resultId = 3032;
00154                         $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00155                         $resultCode=$r['Message'];
00156                         $message=$r['Message'];
00157                         $type=3;                    
00158                     }else{
00159                     $k=$this->delete($this->getAdapter()->quoteInto("IdNextActionMf=?",$entity['IdMicroflowAction']));
00160                     $resultCode="Date sterse";
00161                     }
00162                 }
00163             }
00164             catch(Exception $e){
00165                 $resultCode=$e->getMessage();
00166                 $resultId=101;       
00167                 $type=3;
00168             }
00169                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00170                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00171             return $response;
00172         }
00173         //============ End DeleteMicroflowNextActions ==============================================================
00174 
00175 
00176         //==== Start GetMicroflowNextActions =========================================================================
00189         function GetMicroflowNextActions($entity) {
00190                         // function implementation
00191             $resultId = 0;
00192             $page="MicroflowNextActions.php";
00193             $method="GetMicroflowNextActions";
00194             $result=json_encode($entity);
00195             $message="";
00196             $type="1";
00197             $this->ErrorCode = new ErrorCode;
00198             $this->Log = new Log;
00199 
00200             try{
00201                 if(isset($entity['IdMicroflowAction'])&&$entity['IdMicroflowAction']!=null){
00202                     $IdMicroflowAction=$entity['IdMicroflowAction'];
00203                 }else{
00204                     $IdMicroflowAction=0;
00205                 }
00206                 if(isset($entity['IdMicroflowNextAction'])&&$entity['IdMicroflowNextAction']!=null){
00207                     $IdMicroflowNextAction=$entity['IdMicroflowNextAction'];
00208                 }else{
00209                     $IdMicroflowNextAction=0;
00210                 }
00211                 $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00212                             ->from("MicroflowNextActions","*")
00213                             ->where("IdMicroflowNextAction=$IdMicroflowNextAction OR 0=$IdMicroflowNextAction")
00214                             ->where("IdNextActionMf=$IdMicroflowAction OR 0=$IdMicroflowAction")
00215                     );
00216             if(count($rows)!=0){
00217                 foreach($rows as $row){
00218                     $resultCode[]=array("IdMicroflowNextAction"=>$row->IdMicroflowNextAction,
00219                         "IdNextActionMf"=>$row->IdNextActionMf, 
00220                         "Name"=>$row->Name,
00221                         "Description"=>$row->Description,
00222                         "IsRecursive"=>$row->IsRecursive,
00223                         "IdTplMicroflowNextAction"=>$row->IdTplMicroflowNextAction);
00224                 }                
00225             }else{
00226                 $resultId = 3033;
00227                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00228                 $resultCode=$r['Message'];
00229                 $message=$r['Message'];
00230                 $type=3;
00231             }
00232             }
00233             catch(Exception $e){
00234                 $resultCode=$e->getMessage();
00235                 $resultId=101;       
00236                 $type=3;
00237             }
00238                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00239                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00240          return $response;
00241         }
00242         //============ End GetMicroflowNextActions ==============================================================
00243 
00244 }
00245 
00246 ?>