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