Next4Me
 All Data Structures Files Functions Variables
application/models/tplActionTypeResults.php
Go to the documentation of this file.
00001 <?php
00014 class TplActionTypeResults   extends Zend_Db_Table_Abstract {
00015         protected $_name="tplActionTypeResults"; 
00016         protected $_primary="IdTplActionTypeResult"; 
00017         //==== Start AddTplEditActionTypeResults =========================================================================
00031         function AddEditTplActionTypeResults($entity) {
00032                         // function implementation
00033             $resultId = 0;
00034             $page="tplActionTypeResults.php";
00035             $method="AddEditTplActionTypeResults";
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['IdTplActionTypeResult']=="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("tplActionTypeResults","*")
00050                         ->where("IdTplActionTypeResult=?",$entity['IdTplActionTypeResult'])
00051                 );
00052                 if($rows!=null){
00053                     $IdTplActionType=$rows->IdTplActionType;
00054                     if($IdTplActionType==$entity['IdTplActionType']){
00055                     $this->update(array(
00056                         "IdTplActionType" => $entity['IdTplActionType'], 
00057                         "Name" => $entity['Name'], 
00058                         "Description" => $entity['Description'], 
00059                         "IsSucces" => $entity['IsSucces'], 
00060                         "IdTplActionTypeNextAction" => $entity['IdTplActionTypeNextAction'], 
00061                     ),$this->getAdapter()->quoteInto('IdTplActionTypeResult=?',$entity['IdTplActionTypeResult']));
00062                     $k=$entity['IdTplActionTypeResult'];
00063                     $resultCode=$k;
00064                     }else{
00065                         $resultId = 5014;
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 = 3058;
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             catch(Exception $e){
00083                 $resultCode=$e->getMessage();
00084                 $resultId=101;       
00085                 $type=3;
00086             }
00087                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00088                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00089             return $response;
00090         }
00091         //============ End AddEditTplActionTypeResults ==============================================================
00092 
00093 
00094         //==== Start DeleteTplActionTypeResults =========================================================================
00102         function DeleteTplActionTypeResults($entity) {
00103                         // function implementation
00104             $resultId = 0;
00105             $page="tplActionTypeResults.php";
00106             $method="DeleteTplActionTypeResults";
00107             $result=json_encode($entity);
00108             $message="";
00109             $type="1";
00110             $this->ErrorCode = new ErrorCode;
00111             $this->Log = new Log;
00112 
00113             try{
00114                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00115                             ->from("tplActionTypeResults","*")
00116                             ->where("IdTplActionTypeResult=?",$entity['IdTplActionTypeResult'])
00117                     );
00118                 if($rows==null){
00119                     $resultId = 3059;
00120                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00121                     $resultCode=$r['Message'];
00122                     $message=$r['Message'];
00123                     $type=3;    
00124                 }else{
00125                 $k=$this->delete($this->getAdapter()->quoteInto("IdTplActionTypeResult=?",$entity['IdTplActionTypeResult']));
00126                 $resultCode="Date sterse";
00127                 }
00128             }
00129             catch(Exception $e){
00130                 $resultCode=$e->getMessage();
00131                 $resultId=101;       
00132                 $type=3;
00133             }
00134                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00135                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00136             return $response;
00137         }
00138         //============ End DeleteTplActionTypeResults ==============================================================
00139 
00140 
00141         //==== Start GetActionTypeResults =========================================================================
00149         function GetTplActionTypeResults($entity) {
00150                         // function implementation
00151             $resultId = 0;
00152             $page="tplActionTypeResults.php";
00153             $method="GetTplActionTypeResults";
00154             $result=json_encode($entity);
00155             $message="";
00156             $type="1";
00157             $this->ErrorCode = new ErrorCode;
00158             $this->Log = new Log;
00159 
00160             try{
00161                  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00162                             ->from("tplActionTypeResults","*")
00163                             ->where("IdTplActionTypeResult=?",$entity['IdTplActionTypeResult'])
00164                             ->orWhere("0=?", $entity['IdTplActionTypeResult'])
00165                     );
00166             if(count($rows)!=0){
00167                 foreach($rows as $row){
00168                     $resultCode[]=array("IdTplActionTypeResult" => $row->IdTplActionTypeResult,
00169                         "IdTplActionType" => $row->IdTplActionType, 
00170                         "Name" => $row->Name, 
00171                         "Description" => $row->Description, 
00172                         "IsSucces" => $row->IsSucces, 
00173                         "IdTplActionTypeNextAction" => $row->IdTplActionTypeNextAction, );
00174                 }
00175             }else{
00176                 $resultId = 3060;
00177                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00178                 $resultCode=$r['Message'];
00179                 $message=$r['Message'];
00180                 $type=3;    
00181             }
00182             }
00183             catch(Exception $e){
00184                 $resultCode=$e->getMessage();
00185                 $resultId=101;       
00186                 $type=3;
00187             }
00188                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00189                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00190          return $response;
00191         }
00192         //============ End GetActionTypeResults ==============================================================
00193 
00194 }
00195 
00196 ?>