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