Next4Me
 All Classes Files Functions Variables
TplAssetProperty.php
Go to the documentation of this file.
1 <?php
14 class Application_Model_TplAssetProperty extends Zend_Db_Table_Abstract {
15  protected $_name="TplAssetProperty";
16  protected $_primary="IdTplAssetProperty";
17  //==== Start addEditTplAssetProperty =========================================================================
35  function addEditTplAssetProperty($entity) {
36  // function implementation
37  $resultId = 0;
38  $page="TplAssetProperty.php";
39  $method="addEditTplAssetProperty";
40  $result=json_encode($entity);
41  $message="";
42  $type="1";
43  $this->ErrorCode = new Application_Model_ErrorCode;
44  $this->Log = new Application_Model_Log;
45 
46  try{
47  $data=array();
48  if(!isset($entity['IdTplAssetProperty'])){
49  $resultId = 3096;
50  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
51  $resultCode=sprintf($r['Message'], "IdTplAssetProperty");
52  $message=sprintf($r['Message'], "IdTplAssetProperty");
53  $type=3;
54  }else{$data['IdTplAssetProperty']=(int)$entity['IdTplAssetProperty'];}
55 
56  if(!isset($entity['IdTplAsset'])){
57  if($resultId==0 && $data['IdTplAssetProperty']=="0"){
58  $resultId = 3096;
59  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
60  $resultCode=sprintf($r['Message'], "IdTplAsset");
61  $message=sprintf($r['Message'], "IdTplAsset");
62  $type=3;
63  }
64  }else{$data['IdTplAsset']=$entity['IdTplAsset'];}
65 
66  if(!isset($entity['Name'])){
67  if($resultId==0 && $data['IdTplAssetProperty']=="0"){
68  $resultId = 3096;
69  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
70  $resultCode=sprintf($r['Message'], "Name");
71  $message=sprintf($r['Message'], "Name");
72  $type=3;
73  }
74  }else{$data['Name']=$entity['Name'];}
75 
76  if(!isset($entity['PropertyType'])){
77  if($resultId==0 && $data['IdTplAssetProperty']=="0"){
78  $resultId = 3096;
79  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
80  $resultCode=sprintf($r['Message'], "PropertyType");
81  $message=sprintf($r['Message'], "PropertyType");
82  $type=3;
83  }
84  }else{$data['PropertyType']=$entity['PropertyType'];}
85 
86  if(!isset($entity['PropertyString'])){
87  if($resultId==0 && $data['IdTplAssetProperty']=="0"){
88  $resultId = 3096;
89  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
90  $resultCode=sprintf($r['Message'], "PropertyString");
91  $message=sprintf($r['Message'], "PropertyString");
92  $type=3;
93  }
94  }else{$data['PropertyString']=$entity['PropertyString'];}
95 
96  if(!isset($entity['PropertyDate'])){
97  if($resultId==0 && $data['IdTplAssetProperty']=="0"){
98  $resultId = 3096;
99  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
100  $resultCode=sprintf($r['Message'], "PropertyDate");
101  $message=sprintf($r['Message'], "PropertyDate");
102  $type=3;
103  }
104  }else{$data['PropertyDate']=$entity['PropertyDate'];}
105 
106  if(!isset($entity['PropertyValue'])){
107  if($resultId==0 && $data['IdTplAssetProperty']=="0"){
108  $resultId = 3096;
109  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
110  $resultCode=sprintf($r['Message'], "PropertyValue");
111  $message=sprintf($r['Message'], "PropertyValue");
112  $type=3;
113  }
114  }else{$data['PropertyValue']=$entity['PropertyValue'];}
115 
116  if(!isset($data) || $data==null){
117  $resultId = 3096;
118  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
119  $resultCode=sprintf($r['Message'], "IdTplAsset,Name,PropertyType,PropertyImplicitValue");
120  $message=sprintf($r['Message'], "IdTplAsset,Name,PropertyType,PropertyImplicitValue");
121  $type=3;
122  }
123 
124  if($resultId==0 && $data['IdTplAssetProperty']!="0"){
125  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
126  ->from("TplAssetProperty","*")
127  ->where("IdTplAssetProperty=?",$data['IdTplAssetProperty'])
128  );
129  if($rows!=null){
130  $IdTplAsset=$rows->IdTplAsset;
131  if(isset($data['IdTplAsset']) && $IdTplAsset!=$data['IdTplAsset']){
132  $resultId = 5009;
133  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
134  $resultCode=$r['Message'];
135  $message=$r['Message'];
136  $type=3;
137  }
138  }else{
139  $resultId = 3037;
140  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
141  $resultCode=$r['Message'];
142  $message=$r['Message'];
143  $type=3;
144  }
145  }
146  if($resultId==0){
147  if ($data['IdTplAssetProperty']=="0"){
148  $k=$this->insert($data);
149  $k=$this->getAdapter()->lastInsertId();
150  $resultCode=$k;
151  }else{
152  $this->update($data,$this->getAdapter()->quoteInto('IdTplAssetProperty=?',$data['IdTplAssetProperty']));
153  $k=$data['IdTplAssetProperty'];
154  $resultCode=$k;
155  }
156  }
157 
158  }
159  catch(Exception $e){
160  $resultCode=$e->getMessage();
161  $resultId=101;
162  $type=3;
163  }
164  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
165  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
166  return $response;
167 
168  }
169  //============ End addEditTplAssetProperty ==============================================================
170 
171 
172  //==== Start deleteTplAssetProperty =========================================================================
181  function deleteTplAssetProperty($entity) {
182  // function implementation
183  $resultId = 0;
184  $page="TplAssetProperty.php";
185  $method="deleteTplAssetProperty";
186  $result=json_encode($entity);
187  $message="";
188  $type="1";
189  $this->ErrorCode = new Application_Model_ErrorCode;
190  $this->Log = new Application_Model_Log;
191 
192  try{
193  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
194  ->from("TplAssetProperty","*")
195  ->where("IdTplAssetProperty=?",$entity['IdTplAssetProperty'])
196  );
197  if($rows==null){
198  $resultId = 3038;
199  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
200  $resultCode=$r['Message'];
201  $message=$r['Message'];
202  $type=3;
203  }else{
204  $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
205  ->from("TplAssetPropertyMicroflow","*")
206  ->where("IdTplAssetProperty=?",$entity['IdTplAssetProperty'])
207  );
208  if($chld==null){
209  $k=$this->delete($this->getAdapter()->quoteInto("IdTplAssetProperty=?",$entity['IdTplAssetProperty']));
210  $resultCode="Date sterse";
211  }else{
212  $resultId = 4007;
213  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
214  $resultCode=$r['Message'];
215  $message=$r['Message'];
216  $type=3;
217  }
218  }
219  }
220  catch(Exception $e){
221  $resultCode=$e->getMessage();
222  $resultId=101;
223  $type=3;
224  }
225  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
226  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
227  return $response;
228  }
229  //============ End deleteTplAssetProperty ==============================================================
230 
231 
232  //==== Start getTplAssetProperty =========================================================================
246  function getTplAssetProperty($entity) {
247  // function implementation
248  $resultId = 0;
249  $page="TplAssetProperty.php";
250  $method="getTplAssetProperty";
251  $result=json_encode($entity);
252  $message="";
253  $type="1";
254  $this->ErrorCode = new Application_Model_ErrorCode;
255  $this->Log = new Application_Model_Log;
256  $this->Paging=new Application_Model_Paging;
257 
258  try{
259  $pg=$this->Paging->getPageDefault('TplAssetProperty');
260 
261  $data=array();
262  if(!isset($entity['IdTplAssetProperty']))
263  {
264  $resultId = 3148;
265  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
266  $resultCode=sprintf($r['Message'], "IdTplAssetProperty");
267  $message=sprintf($r['Message'], "IdTplAssetProperty");
268  $type=3;
269  }else{$data['IdTplAssetProperty']=$entity['IdTplAssetProperty'];}
270 
271  if(!isset($entity['IdTplAsset']))
272  {
273  $resultId = 3148;
274  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
275  $resultCode=sprintf($r['Message'], "IdTplAsset");
276  $message=sprintf($r['Message'], "IdTplAsset");
277  $type=3;
278  }else{$data['IdTplAsset']=$entity['IdTplAsset'];}
279 
280  if(!isset($entity['IdUserAccount'])){
281  $resultId = 3148;
282  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
283  $resultCode=sprintf($r['Message'], "IdUserAccount");
284  $message=sprintf($r['Message'], "IdUserAccount");
285  $type=3;
286  }else{$data['IdUserAccount']=$entity['IdUserAccount'];}
287 
288  if(!isset($entity['UserAccountType'])){
289  $resultId = 3148;
290  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
291  $resultCode=sprintf($r['Message'], "UserAccountType");
292  $message=sprintf($r['Message'], "UserAccountType");
293  $type=3;
294  }else{$data['UserAccountType']=$entity['UserAccountType'];}
295 
296  if(!isset($entity['pageSize'])){
297  $_pageSize=$pg['pageSize'];
298  }else{
299  $_pageSize=$entity['pageSize'];
300  }
301 
302  if(!isset($entity['pageNo'])){
303  $_pageNo=$pg['pageNo'];
304  }else{$_pageNo=$entity['pageNo'];}
305 
306  if(!isset($entity['orderColumn'])){
307  $_orderColumn=$pg['orderColumn'];
308  }else{$_orderColumn=$entity['orderColumn'];}
309 
310  if(!isset($entity['orderType'])){
311  $_orderType=$pg['orderType'];
312  }else{
313  switch($entity['orderType'])
314  {
315  case 'ASC':
316  $_orderType="ASC";
317  break;
318  case 'DESC':
319  $_orderType="DESC";
320  break;
321  default:
322  $_orderType="DESC";
323  break;
324  }
325  }
326 
327  if(!isset($entity['orderColumn'])){
328  $_orderColumn=$pg['orderColumn'];
329  }else{
330  switch($entity['orderColumn'])
331  {
332  case 'IdTplAssetProperty':
333  $_orderColumn="IdTplAssetProperty";
334  break;
335  case 'IdTplAsset':
336  $_orderColumn="IdTplAsset";
337  break;
338  case 'Name':
339  $_orderColumn="Name";
340  break;
341  case 'PropertyType':
342  $_orderColumn="PropertyType";
343  break;
344  case 'PropertyImplicitValue':
345  $_orderColumn="PropertyImplicitValue";
346  break;
347  case 'PropertyString':
348  $_orderColumn="PropertyString";
349  break;
350  case 'PropertyDate':
351  $_orderColumn="PropertyDate";
352  break;
353  case 'PropertyValue':
354  $_orderColumn="PropertyValue";
355  break;
356  default:
357  $_orderColumn=$orderColumn;
358  break;
359  }
360 
361  }
362  if($resultId==0){
363  $IdTplAssetProperty=(int)$data['IdTplAssetProperty'];
364  $IdTplAsset=(int)$data['IdTplAsset'];
365 
366  $count = $this->fetchRow($this->select()->setIntegrityCheck(false)
367  ->from("TplAssetProperty",array("total"=>"COUNT(IdTplAssetProperty)"))
368  ->where("IdTplAssetProperty=$IdTplAssetProperty OR 0=$IdTplAssetProperty")
369  ->where("IdTplAsset=$IdTplAsset OR 0=$IdTplAsset")
370  );
371 
372  if($count->total==0){
373  $resultId = 3039;
374  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
375  $resultCode=$r['Message'];
376  $message=$r['Message'];
377  $type=3;
378  }else{
379 
380  $offset=$this->Paging->getOffset($count->total, $_pageSize, $_pageNo);
381 
382  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
383  ->from("TplAssetProperty","*")
384  ->where("IdTplAssetProperty=$IdTplAssetProperty OR 0=$IdTplAssetProperty")
385  ->where("IdTplAsset=$IdTplAsset OR 0=$IdTplAsset")
386  ->limit($_pageSize, $offset['start'])
387  ->order($_orderColumn." ".$_orderType)
388  );
389 
390  foreach($rows as $row){
391  $resultEntity[]=array("IdTplAssetProperty" => $row->IdTplAssetProperty,
392  "IdTplAsset" => $row->IdTplAsset,
393  "Name" => $row->Name,
394  "PropertyType" => $row->PropertyType,
395  "PropertyImplicitValue" => $row->PropertyImplicitValue,
396  "PropertyString" => $row->PropertyString,
397  "PropertyDate" => $row->PropertyDate,
398  "PropertyValue" => $row->PropertyValue);
399  }
400 
401  $resultCode=array("pageNo"=>$_pageNo,
402  "pageSize"=>$_pageSize,
403  "pageCount"=>$offset['maxPage'],
404  "orderColumn"=>$_orderColumn,
405  "orderType"=>$_orderType,"entity"=>$resultEntity);
406  }
407  }
408  }
409  catch(Exception $e){
410  $resultCode=$e->getMessage();
411  $resultId=101;
412  $type=3;
413  }
414  $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
415  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
416  return $response;
417  }
418  //============ End getTplAssetProperty ==============================================================
419 
420 }
421 
422 ?>