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