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