Next4Me
 All Data Structures Files Functions Variables
application/models/tplMicroflows.php
Go to the documentation of this file.
00001 <?php 
00016 class TplMicroflows  extends Zend_Db_Table_Abstract {
00017         protected $_name="tplMicroflows"; 
00018         protected $_primary="IdTplMf"; 
00019         //==== Start AddEditTplMicroflows =========================================================================
00030         function AddEditTplMicroflows($entity) {
00031             $resultId = 0;
00032             $page="tplMicroflows.php";
00033             $method="AddEditTplMicroflows";
00034             $result=json_encode($entity);
00035             $message="";
00036             $type="1";
00037             $this->ErrorCode = new ErrorCode;
00038             $this->Log = new Log;
00039 
00040             try{
00041                 if ($entity['IdTplMf']=="0"){
00042                     $k=$this->insert($entity);
00043                     $k=$this->getAdapter()->lastInsertId();
00044                     $resultCode=$k;
00045                 }else{
00046                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00047                             ->from("tplMicroflows","*")
00048                             ->where("IdTplMf=?",$entity['IdTplMf'])
00049                     );
00050                 if($rows!=null){
00051                     $this->update(array(
00052                         "IdTplAssetTypeProperty" => $entity['IdTplAssetTypeProperty'],
00053                         "Name" => $entity['Name'], 
00054                     ),$this->getAdapter()->quoteInto('IdTplMf=?',$entity['IdTplMf']));
00055                     $k=$entity['IdTplMf'];
00056                      $resultCode=$k;    
00057                 }else{
00058                     $resultId = 3067;
00059                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00060                     $resultCode=$r['Message'];
00061                     $message=$r['Message'];
00062                     $type=3;    
00063                 }
00064                 }
00065             }
00066             catch(Exception $e){
00067                 $resultCode=$e->getMessage();
00068                 $resultId=101;       
00069                 $type=3;
00070             }
00071                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00072                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00073          return $response;
00074         }
00075         //============ End AddEditTplMicroflows ==============================================================
00076 
00077 
00078         //==== Start DeleteTplMicroflows =========================================================================
00088         function DeleteTplMicroflows($entity) {
00089                         // function implementation
00090             $resultId = 0;
00091             $page="tplMicroflows.php";
00092             $method="DeleteTplMicroflows";
00093             $result=json_encode($entity);
00094             $message="";
00095             $type="1";
00096             $this->ErrorCode = new ErrorCode;
00097             $this->Log = new Log;
00098 
00099             try{
00100                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00101                             ->from("tplMicroflows","*")
00102                             ->where("IdTplMf=?",$entity['IdTplMf'])
00103                     );
00104                 if($rows==null){
00105                     $resultId = 3068;
00106                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00107                     $resultCode=$r['Message'];
00108                     $message=$r['Message'];
00109                     $type=3;    
00110                 }else{
00111                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00112                             ->from("tplMicroflowActions","*")
00113                             ->where("IdTplMicroflow=?",$entity['IdTplMf'])
00114                     );
00115                 if($chld==null){
00116                     $k=$this->delete($this->getAdapter()->quoteInto("IdTplMf=?",$entity['IdTplMf']));
00117                     $resultCode="Date sterse";
00118                 }else{
00119                     $resultId = 4011;
00120                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00121                     $resultCode=$r['Message'];
00122                     $message=$r['Message'];
00123                     $type=3;    
00124                     }
00125                 }
00126             }
00127             catch(Exception $e){
00128                 $resultCode=$e->getMessage();
00129                 $resultId=101;       
00130                 $type=3;
00131             }
00132                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00133                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00134          return $response;
00135         }
00136         //============ End DeleteMicroflows ==============================================================
00137 
00138 
00139         //==== Start GetTplMicroflows =========================================================================
00148         function GetTplMicroflows($entity) {
00149                         // function implementation
00150             $resultId = 0;
00151             $page="tplMicroflows.php";
00152             $method="GetTplMicroflows";
00153             $result=json_encode($entity);
00154             $message="";
00155             $type="1";
00156             $this->ErrorCode = new ErrorCode;
00157             $this->Log = new Log;
00158 
00159             try{
00160                 $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00161                             ->from("tplMicroflows","*")
00162                             ->where("IdTplMf=?",$entity['IdTplMf'])
00163                             ->orWhere("0=?", $entity['IdTplMf'])
00164                     );
00165             if(count($rows)!=0){
00166                 foreach($rows as $row){
00167                     $resultCode[]=array("IdTplMf"=>$row->IdTplMf, 
00168                         "IdTplAssetTypeProperty"=>$row->IdTplAssetTypeProperty, 
00169                         "Name"=>$row->Name);
00170                 }
00171             }else{
00172                 $resultId = 3069;
00173                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00174                 $resultCode=$r['Message'];
00175                 $message=$r['Message'];
00176                 $type=3;    
00177             }
00178             }
00179             catch(Exception $e){
00180                 $resultCode=$e->getMessage();
00181                 $resultId=101;       
00182                 $type=3;
00183             }
00184                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00185                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00186          return $response;
00187         }
00188         //============ End GetTplMicroflows ==============================================================
00189 
00190 }
00191 
00192 ?>