Next4Me
 All Data Structures Files Functions Variables
application/models/MicroflowActions.php
Go to the documentation of this file.
00001 <?php 
00017 class MicroflowActions  extends Zend_Db_Table_Abstract {
00018     //put your code here
00019     protected $_name="MicroflowActions"; 
00020     protected $_primary="IdMicroflowAction"; 
00021     
00022 
00023         //==== Start AddEditMicroflowActions =========================================================================
00040         function AddEditMicroflowActions($entity) {
00041                         // function implementation
00042             $resultId = 0;
00043             $page="MicroflowActions.php";
00044             $method="AddEditMicroflowActions";
00045             $result=json_encode($entity);
00046             $message="";
00047             $type="1";
00048             $this->ErrorCode = new ErrorCode;
00049             $this->Log = new Log;
00050 
00051             try{
00052                 if ($entity['IdMicroflowAction']=="0"){
00053                     $k=$this->insert(array(
00054                         "IdMicroflowAction" => $entity['IdMicroflowAction'],
00055                         "IdMicroflow" => $entity['IdMicroflow'],
00056                         "Name" => $entity['Name'], 
00057                         "Description"=>$entity['Description'],
00058                         "TimeActivation"=>$entity['TimeActivation'],
00059                         "TimeClosed"=>$entity['TimeClosed'],
00060                         "IdContext"=>$entity['IdContext'],
00061                         "IdTplMicroflowAction"=>$entity['IdTplMicroflowAction']));
00062                     $k=$this->getAdapter()->lastInsertId();
00063                     $resultCode=$k;
00064                 }else{
00065                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00066                     ->from("MicroflowActions","*")
00067                     ->where("IdMicroflowAction=?",$entity['IdMicroflowAction'])
00068                     );
00069                 if($rows!=null){
00070                     $IdMicroflow=$rows->IdMicroflow;
00071                 if($IdMicroflow==$entity['IdMicroflow']){
00072                     $this->update(array(
00073                         "IdMicroflow" => $entity['IdMicroflow'],
00074                         "Name" => $entity['Name'], 
00075                         "Description"=>$entity['Description'],
00076                         "TimeActivation"=>$entity['TimeActivation'],
00077                         "TimeClosed"=>$entity['TimeClosed'],
00078                         "IdContext"=>$entity['IdContext'],
00079                         "IdTplMicroflowAction"=>$entity['IdTplMicroflowAction'],
00080                     ),$this->getAdapter()->quoteInto('IdMicroflowAction=?',$entity['IdMicroflowAction']));
00081                     $k=$entity['IdMicroflowAction'];
00082                     $resultCode=$k;    
00083                 }else{
00084                     $resultId = 5004;
00085                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00086                     $resultCode=$r['Message'];
00087                     $message=$r['Message'];
00088                     $type=3;
00089                 }
00090                 }else{
00091                     $resultId = 3019;
00092                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00093                     $resultCode=$r['Message'];
00094                     $message=$r['Message'];
00095                     $type=3;
00096                 }
00097                 
00098             }
00099             }
00100             catch(Exception $e){
00101                 $resultCode=$e->getMessage();
00102                 $resultId=101;       
00103                 $type=3;
00104             }
00105                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00106                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00107          return $response;
00108         }
00109         //============ End AddEditMicroflowActions ==============================================================
00110 
00111 
00112         //==== Start DeleteMicroflowActions =========================================================================
00122         function DeleteMicroflowActions($entity) {
00123                         // function implementation
00124             $resultId = 0;
00125             $page="MicroflowActions.php";
00126             $method="DeleteMicroflowActions";
00127             $result=json_encode($entity);
00128             $message="";
00129             $type="1";
00130             $this->ErrorCode = new ErrorCode;
00131             $this->Log = new Log;
00132 
00133             try{
00134                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00135                             ->from("MicroflowActions","*")
00136                             ->where("IdMicroflowAction=?",$entity['IdMicroflowAction'])
00137                     );
00138                 if($rows==null){
00139                     $resultId = 3020;
00140                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00141                     $resultCode=$r['Message'];
00142                     $message=$r['Message'];
00143                     $type=3;
00144                 }else{
00145                     $i=0;
00146                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00147                             ->from("MicroflowActionResults","*")
00148                             ->where("IdMicroflowAction=?",$entity['IdMicroflowAction'])
00149                     );
00150                     if($chld!=null){
00151                         $i++;
00152                     }
00153                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00154                             ->from("MicroflowActionProperties","*")
00155                             ->where("IdMicroflowAction=?",$entity['IdMicroflowAction'])
00156                     );
00157                     if($chld!=null){
00158                         $i++;
00159                     }
00160                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00161                             ->from("MicroflowActionAlerts","*")
00162                             ->where("IdMicroflowAction=?",$entity['IdMicroflowAction'])
00163                     );
00164                     if($chld!=null){
00165                         $i++;
00166                     }
00167                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00168                             ->from("MicroflowNextActions","*")
00169                             ->where("IdNextActionMf=?",$entity['IdMicroflowAction'])
00170                     );
00171                     if($chld!=null){
00172                         $i++;
00173                     }
00174                  if($i==0){
00175                     $k=$this->delete($this->getAdapter()->quoteInto("IdMicroflowAction=?",$entity['IdMicroflowAction']));
00176                     $resultCode="Date sterse";    
00177                 }else{
00178                     $resultId = 4005;
00179                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00180                     $resultCode=$r['Message'];
00181                     $message=$r['Message'];
00182                     $type=3;
00183                     }
00184                 }
00185             }
00186             catch(Exception $e){
00187                 $resultCode=$e->getMessage();
00188                 $resultId=101;       
00189                 $type=3;
00190             }
00191                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00192                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00193             return $response;
00194         }
00195         //============ End DeleteMicroflowActions ==============================================================
00196 
00197 
00198         //==== Start GetMicroflowActions =========================================================================
00212         function GetMicroflowActions($entity) {
00213                         // function implementation
00214             $resultId = 0;
00215             $page="MicroflowActions.php";
00216             $method="GetMicroflowActions";
00217             $result=json_encode($entity);
00218             $message="";
00219             $type="1";
00220             $this->ErrorCode = new ErrorCode;
00221             $this->Log = new Log;
00222 
00223             try{
00224                 if(isset($entity['IdMicroflowAction'])&&$entity['IdMicroflowAction']!=null){
00225                     $IdMicroflowAction=$entity['IdMicroflowAction'];
00226                 }else{
00227                     $IdMicroflowAction=0;
00228                 }
00229                 if(isset($entity['IdMicroflow'])&&$entity['IdMicroflow']!=null){
00230                     $IdMicroflow=$entity['IdMicroflow'];
00231                 }else{
00232                     $IdMicroflow=0;
00233                 }
00234                 $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00235                             ->from("MicroflowActions","*")
00236                             ->where("IdMicroflowAction=$IdMicroflowAction OR 0=$IdMicroflowAction")
00237                             ->where("IdMicroflow=$IdMicroflow OR 0=$IdMicroflow")
00238                     );
00239                 if(count($rows)!=0){
00240                     foreach($rows as $row){
00241                         $resultCode[]=array("IdMicroflowAction"=>$row->IdMicroflowAction,
00242                             "IdMicroflow"=>$row->IdMicroflow, 
00243                             "Name"=>$row->Name,
00244                             "Description"=>$row->Description,
00245                             "TimeActivation"=>$row->TimeActivation,
00246                             "TimeClosed"=>$row->TimeClosed,
00247                             "IdContext"=>$row->IdContext,
00248                             "IdTplMicroflowAction"=>$row->IdTplMicroflowAction);
00249                 }
00250                 }else{
00251                     $resultId = 3021;
00252                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00253                     $resultCode=$r['Message'];
00254                     $message=$r['Message'];
00255                     $type=3;
00256                 }
00257             }
00258             catch(Exception $e){
00259                 $resultCode=$e->getMessage();
00260                 $resultId=101;       
00261                 $type=3;
00262             }
00263                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00264                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00265          return $response;
00266         }
00267         //============ End GetMicroflowActions ==============================================================
00268 
00269 }
00270 
00271 ?>