Next4Me
 All Data Structures Files Functions Variables
application/models/tplAssetTypeProperties.php
Go to the documentation of this file.
00001 <?php
00013 class TplAssetTypeProperties   extends Zend_Db_Table_Abstract {
00014         protected $_name="tplAssetTypeProperties"; 
00015         protected $_primary="IdTplAssetTypeProperty"; 
00016         //==== Start AddEditTplAssetTypeProperties =========================================================================
00029         function AddEditTplAssetTypeProperties($entity) {
00030                         // function implementation
00031             $resultId = 0;
00032             $page="tplAssetTypeProperties.php";
00033             $method="AddEditTplAssetTypeProperties";
00034             $result=json_encode($entity);
00035             $message="";
00036             $type="1";
00037             $this->ErrorCode = new ErrorCode;
00038             $this->Log = new Log;
00039 
00040             try{
00041                 if ($entity['IdTplAssetTypeProperty']=="0"){
00042                     $k=$this->insert($entity);
00043                     $k=$this->getAdapter()->lastInsertId();
00044                     $resultCode=$k;
00045                 }else{
00046                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00047                             ->from("tplAssetTypeProperties","*")
00048                             ->where("IdTplAssetTypeProperty=?",$entity['IdTplAssetTypeProperty'])
00049                     );
00050                 if($rows!=null){
00051                     $IdTplAssetType=$rows->IdTplAssetType;
00052                     if($IdTplAssetType==$entity['IdTplAssetType']){
00053                     $this->update(array(
00054                         "IdTplAssetType" => $entity['IdTplAssetType'],
00055                         "Name" => $entity['Name'],
00056                         "PropertyType" => $entity['PropertyType'],
00057                         "PropertyImplicitValue" => $entity['PropertyImplicitValue'],
00058                     ),$this->getAdapter()->quoteInto('IdTplAssetTypeProperty=?',$entity['IdTplAssetTypeProperty']));
00059                     $k=$entity['IdTplAssetTypeProperty'];
00060                     $resultCode=$k;
00061                 }else{
00062                     $resultId = 5009;
00063                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00064                     $resultCode=$r['Message'];
00065                     $message=$r['Message'];
00066                     $type=3;    
00067                 }
00068                 }else{
00069                     $resultId = 3037;
00070                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00071                     $resultCode=$r['Message'];
00072                     $message=$r['Message'];
00073                     $type=3;    
00074                 }
00075                 
00076                 }
00077                 
00078             }
00079             catch(Exception $e){
00080                 $resultCode=$e->getMessage();
00081                 $resultId=101;       
00082                 $type=3;
00083             }
00084                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00085                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00086          return $response;
00087         
00088         }
00089         //============ End AddEditTplAssetTypeProperties ==============================================================
00090 
00091 
00092         //==== Start DeleteTplAssetTypeProperties =========================================================================
00101         function DeleteTplAssetTypeProperties($entity) {
00102                         // function implementation
00103             $resultId = 0;
00104             $page="tplAssetTypeProperties.php";
00105             $method="DeleteTplAssetTypeProperties";
00106             $result=json_encode($entity);
00107             $message="";
00108             $type="1";
00109             $this->ErrorCode = new ErrorCode;
00110             $this->Log = new Log;
00111 
00112             try{
00113                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00114                             ->from("tplAssetTypeProperties","*")
00115                             ->where("IdTplAssetTypeProperty=?",$entity['IdTplAssetTypeProperty'])
00116                     );
00117                 if($rows==null){
00118                     $resultId = 3038;
00119                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00120                     $resultCode=$r['Message'];
00121                     $message=$r['Message'];
00122                     $type=3;    
00123                 }else{
00124                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00125                             ->from("tplAssetPropertiesMicroflow","*")
00126                             ->where("IdTplAssetTypeProperty=?",$entity['IdTplAssetTypeProperty'])
00127                     );
00128                 if($chld==null){
00129                     $k=$this->delete($this->getAdapter()->quoteInto("IdTplAssetTypeProperty=?",$entity['IdTplAssetTypeProperty']));
00130                     $resultCode="Date sterse";
00131                 }else{
00132                     $resultId = 4007;
00133                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00134                     $resultCode=$r['Message'];
00135                     $message=$r['Message'];
00136                     $type=3;    
00137                     }
00138                 }
00139             }
00140             catch(Exception $e){
00141                 $resultCode=$e->getMessage();
00142                 $resultId=101;       
00143                 $type=3;
00144             }
00145                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00146                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00147          return $response;
00148         }
00149         //============ End DeleteTplAssetTypeProperties ==============================================================
00150 
00151 
00152         //==== Start GetTplAssetTypeProperties =========================================================================
00160         function GetTplAssetTypeProperties($entity) {
00161                         // function implementation
00162             $resultId = 0;
00163             $page="tplAssetTypeProperties.php";
00164             $method="GetTplAssetTypeProperties";
00165             $result=json_encode($entity);
00166             $message="";
00167             $type="1";
00168             $this->ErrorCode = new ErrorCode;
00169             $this->Log = new Log;
00170 
00171             try{
00172                  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00173                             ->from("tplAssetTypeProperties","*")
00174                             ->where("IdTplAssetTypeProperty=?",$entity['IdTplAssetTypeProperty'])
00175                             ->orWhere("0=?", $entity['IdTplAssetTypeProperty'])
00176                     );
00177                  if(count($rows)!=0){
00178                 foreach($rows as $row){
00179                     $resultCode[]=array("IdTplAssetTypeProperty" => $row->IdTplAssetTypeProperty, 
00180                         "IdTplAssetType" => $row->IdTplAssetType, 
00181                         "Name" => $row->Name, 
00182                         "PropertyType" => $row->PropertyType, 
00183                         "PropertyImplicitValue" => $row->PropertyImplicitValue);
00184                 }
00185                 }else{
00186                     $resultId = 3039;
00187                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00188                     $resultCode=$r['Message'];
00189                     $message=$r['Message'];
00190                     $type=3;    
00191                  }
00192             }
00193             catch(Exception $e){
00194                 $resultCode=$e->getMessage();
00195                 $resultId=101;       
00196                 $type=3;
00197             }
00198                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00199                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00200          return $response;
00201         }
00202         //============ End GetTplAssetTypeProperties ==============================================================
00203 
00204 }
00205 
00206 ?>