Next4Me
 All Data Structures Files Functions Variables
application/models/tplActionTypeAlerts.php
Go to the documentation of this file.
00001 <?php
00014 class TplActionTypeAlerts   extends Zend_Db_Table_Abstract {
00015         protected $_name="tplActionTypeAlerts"; 
00016         protected $_primary="IdTplActionTypeAlert"; 
00017         //==== Start AddEditTplActionTypeAlerts =========================================================================
00031         function AddEditTplActionTypeAlerts($entity) {
00032                         // function implementation
00033             $resultId = 0;
00034             $page="tplActionTypeAlerts.php";
00035             $method="AddEditTplActionTypeAlerts";
00036             $result=json_encode($entity);
00037             $message="";
00038             $type="1";
00039             $this->ErrorCode = new ErrorCode;
00040             $this->Log = new Log;
00041 
00042             try{
00043                 if ($entity['IdTplActionTypeAlert']=="0"){
00044                     $k=$this->insert($entity);
00045                     $k=$this->getAdapter()->lastInsertId();
00046                     $resultCode=$k;
00047                 }else{
00048                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00049                     ->from("tplActionTypeAlerts","*")
00050                     ->where("IdTplActionTypeAlert=?",$entity['IdTplActionTypeAlert'])
00051                     );
00052                 if($rows!=null){
00053                     $IdTplActionType=$rows->IdTplActionType;
00054                     if($IdTplActionType==$entity['IdTplActionType']){
00055                     $this->update(array(
00056                         "IdTplActionType" => $entity['IdTplActionType'], 
00057                         "AlertName" => $entity['AlertName'], 
00058                         "AlertChanel" => $entity['AlertChanel'], 
00059                         "AlertTargetType" => $entity['AlertTargetType'], 
00060                         "TimeBefore" => $entity['TimeBefore'], 
00061                     ),$this->getAdapter()->quoteInto('IdTplActionTypeAlert=?',$entity['IdTplActionTypeAlert']));
00062                     $k=$entity['IdTplActionTypeAlert'];
00063                     $resultCode=$k;
00064                 }else{
00065                     $resultId = 5015;
00066                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00067                     $resultCode=$r['Message'];
00068                     $message=$r['Message'];
00069                     $type=3;    
00070                 }
00071                 }else{
00072                     $resultId = 3061;
00073                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00074                     $resultCode=$r['Message'];
00075                     $message=$r['Message'];
00076                     $type=3;    
00077                 }
00078                 
00079                 }
00080                 
00081                 
00082             }
00083             catch(Exception $e){
00084                 $resultCode=$e->getMessage();
00085                 $resultId=101;       
00086                 $type=3;
00087             }
00088                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00089                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00090          return $response;
00091         }
00092         //============ End AddEditTplActionTypeAlerts ==============================================================
00093 
00094 
00095         //==== Start DeleteTplActionTypeAlerts =========================================================================
00103         function DeleteTplActionTypeAlerts($entity) {
00104                         // function implementation
00105             $resultId = 0;
00106             $page="tplActionTypeAlerts.php";
00107             $method="DeleteTplActionTypeAlerts";
00108             $result=json_encode($entity);
00109             $message="";
00110             $type="1";
00111             $this->ErrorCode = new ErrorCode;
00112             $this->Log = new Log;
00113 
00114             try{
00115                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00116                             ->from("tplActionTypeAlerts","*")
00117                             ->where("IdTplActionTypeAlert=?",$entity['IdTplActionTypeAlert'])
00118                     );
00119                 if($rows==null){
00120                     $resultId = 3062;
00121                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00122                     $resultCode=$r['Message'];
00123                     $message=$r['Message'];
00124                     $type=3;    
00125                 }else{
00126                 $k=$this->delete($this->getAdapter()->quoteInto("IdTplActionTypeAlert=?",$entity['IdTplActionTypeAlert']));
00127                 $resultCode="Date sterse";
00128                 }
00129             }
00130             catch(Exception $e){
00131                 $resultCode=$e->getMessage();
00132                 $resultId=101;       
00133                 $type=3;
00134             }
00135                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00136                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00137             return $response;
00138         }
00139         //============ End DeleteTplActionTypeAlerts ==============================================================
00140 
00141 
00142         //==== Start GetTplActionTypeAlerts =========================================================================
00150         function GetTplActionTypeAlerts($entity) {
00151                         // function implementation
00152             $resultId = 0;
00153             $page="tplActionTypeAlerts.php";
00154             $method="GetTplActionTypeAlerts";
00155             $result=json_encode($entity);
00156             $message="";
00157             $type="1";
00158             $this->ErrorCode = new ErrorCode;
00159             $this->Log = new Log;
00160 
00161             try{
00162                  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00163                             ->from("tplActionTypeAlerts","*")
00164                             ->where("IdTplActionTypeAlert=?",$entity['IdTplActionTypeAlert'])
00165                             ->orWhere("0=?", $entity['IdTplActionTypeAlert'])
00166                     );
00167             if(count($rows)!=0){
00168                 foreach($rows as $row){
00169                  $resultCode[]=array("IdTplActionTypeAlert" => $row->IdTplActionTypeAlert,
00170                         "IdTplActionType" => $row->IdTplActionType, 
00171                         "AlertName" => $row->AlertName, 
00172                         "AlertChanel" => $row->AlertChanel, 
00173                         "AlertTargetType" => $row->AlertTargetType, 
00174                         "TimeBefore" => $row->TimeBefore, );
00175                 }
00176             }else{
00177                 $resultId = 3063;
00178                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00179                 $resultCode=$r['Message'];
00180                 $message=$r['Message'];
00181                 $type=3;    
00182             }
00183             }
00184             catch(Exception $e){
00185                 $resultCode=$e->getMessage();
00186                 $resultId=101;       
00187                 $type=3;
00188             }
00189                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00190                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00191          return $response;
00192         }
00193         //============ End GetTplActionTypeAlerts ==============================================================
00194 
00195 }
00196 
00197 ?>