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