Next4Me
 All Classes Files Functions Variables
TplActionTypeNextAction.php
Go to the documentation of this file.
1 <?php
16 class Application_Model_TplActionTypeNextAction extends Zend_Db_Table_Abstract {
17  protected $_name="TplActionTypeNextAction";
18  protected $_primary="IdTplActionTypeNextAction";
19 
20  //==== Start addEditTplActionTypeNextAction =========================================================================
35  function addEditTplActionTypeNextAction($entity) {
36  // function implementation
37  $resultId = 0;
38  $page="TplActionTypeNextAction.php";
39  $method="addEditTplActionTypeNextAction";
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['IdTplActionTypeNextAction'])){
49  $resultId = 3092;
50  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
51  $resultCode=sprintf($r['Message'], "IdTplActionTypeNextAction");
52  $message=sprintf($r['Message'], "IdTplActionTypeNextAction");
53  $type=3;
54  }else{$data['IdTplActionTypeNextAction']=(int)$entity['IdTplActionTypeNextAction'];}
55 
56  if(!isset($entity['IdTplActionType'])){
57  if($resultId==0 && $entity['IdTplActionTypeNextAction']=="0"){
58  $resultId = 3092;
59  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
60  $resultCode=sprintf($r['Message'], "IdTplActionType");
61  $message=sprintf($r['Message'], "IdTplActionType");
62  $type=3;
63  }
64  }else{$data['IdTplActionType']=$entity['IdTplActionType'];}
65  if(!isset($entity['Name'])){
66  if($resultId==0 && $entity['IdTplActionTypeNextAction']=="0"){
67  $resultId = 3092;
68  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
69  $resultCode=sprintf($r['Message'], "Name");
70  $message=sprintf($r['Message'], "Name");
71  $type=3;
72  }
73  }else{$data['Name']=$entity['Name'];}
74  if(!isset($entity['Description'])){
75  if($resultId==0 && $entity['IdTplActionTypeNextAction']=="0"){
76  $resultId = 3092;
77  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
78  $resultCode=sprintf($r['Message'], "Description");
79  $message=sprintf($r['Message'], "Description");
80  $type=3;
81  }
82  }else{$data['Description']=$entity['Description'];}
83  if(!isset($entity['IsRecursive'])){
84  if($resultId==0 && $entity['IdTplActionTypeNextAction']=="0"){
85  $resultId = 3092;
86  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
87  $resultCode=sprintf($r['Message'], "IsRecursive");
88  $message=sprintf($r['Message'], "IsRecursive");
89  $type=3;
90  }
91  }else{$data['IsRecursive']=$entity['IsRecursive'];}
92  if(!isset($data) || $data==null){
93  $resultId = 3092;
94  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
95  $resultCode=sprintf($r['Message'], "IdTplActionType,Name,Description,IsRecursive");
96  $message=sprintf($r['Message'], "IdTplActionType,Name,Description,IsRecursive");
97  $type=3;
98  }
99  if($resultId==0 && $data['IdTplActionTypeNextAction']!="0"){
100  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
101  ->from("TplActionTypeNextAction","*")
102  ->where("IdTplActionTypeNextAction=?",$data['IdTplActionTypeNextAction'])
103  );
104  if($rows!=null){
105  $IdTplActionType=$rows->IdTplActionType;
106  if(isset($data['IdTplActionType']) && $IdTplActionType!=$data['IdTplActionType']){
107  $resultId = 5016;
108  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
109  $resultCode=$r['Message'];
110  $message=$r['Message'];
111  $type=3;
112  }
113  }else{
114  $resultId = 3064;
115  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
116  $resultCode=$r['Message'];
117  $message=$r['Message'];
118  $type=3;
119  }
120  }
121  if($resultId==0){
122  if ($data['IdTplActionTypeNextAction']=="0"){
123  $k=$this->insert($data);
124  $k=$this->getAdapter()->lastInsertId();
125  $resultCode=$k;
126  }else{
127  $this->update($data,$this->getAdapter()->quoteInto('IdTplActionTypeNextAction=?',$data['IdTplActionTypeNextAction']));
128  $k=$data['IdTplActionTypeNextAction'];
129  $resultCode=$k;
130  }
131  }
132  }
133  catch(Exception $e){
134  $resultCode=$e->getMessage();
135  $resultId=101;
136  $type=3;
137  }
138  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
139  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
140  return $response;
141  }
142  //============ End addEditTplActionTypeNextAction ==============================================================
143 
144 
145  //==== Start deleteTplActionTypeNextAction =========================================================================
153  function deleteTplActionTypeNextAction($entity) {
154  // function implementation
155  $resultId = 0;
156  $page="TplActionTypeNextAction.php";
157  $method="deleteTplActionTypeNextAction";
158  $result=json_encode($entity);
159  $message="";
160  $type="1";
161  $this->ErrorCode = new Application_Model_ErrorCode;
162  $this->Log = new Application_Model_Log;
163 
164  try{
165  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
166  ->from("TplActionTypeNextAction","*")
167  ->where("IdTplActionTypeNextAction=?",$entity['IdTplActionTypeNextAction'])
168  );
169  if($rows==null){
170  $resultId = 3065;
171  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
172  $resultCode=$r['Message'];
173  $message=$r['Message'];
174  $type=3;
175  }else{
176  $k=$this->delete($this->getAdapter()->quoteInto("IdTplActionTypeNextAction=?",$entity['IdTplActionTypeNextAction']));
177  $resultCode="Date sterse";
178  }
179  }
180  catch(Exception $e){
181  $resultCode=$e->getMessage();
182  $resultId=101;
183  $type=3;
184  }
185  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
186  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
187  return $response;
188  }
189  //============ End deleteTplActionTypeNextAction ==============================================================
190 
191 
192  //==== Start getTplActionTypeNextAction =========================================================================
206  function getTplActionTypeNextAction($entity) {
207  // function implementation
208  $resultId = 0;
209  $page="TplActionTypeNextAction.php";
210  $method="getTplActionTypeNextAction";
211  $result=json_encode($entity);
212  $message="";
213  $type="1";
214  $this->ErrorCode = new Application_Model_ErrorCode;
215  $this->Log = new Application_Model_Log;
216  $this->Paging = new Application_Model_Paging;
217 
218  try{
219  $pg=$this->Paging->getPageDefault('TplActionTypeNextAction');
220 
221  $data=array();
222  if(!isset($entity['IdTplActionTypeNextAction']))
223  {
224  $resultId = 3144;
225  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
226  $resultCode=sprintf($r['Message'], "IdTplActionTypeNextAction");
227  $message=sprintf($r['Message'], "IdTplActionTypeNextAction");
228  $type=3;
229  }else{$data['IdTplActionTypeNextAction']=$entity['IdTplActionTypeNextAction'];}
230 
231  if(!isset($entity['IdTplActionType']))
232  {
233  $resultId = 3144;
234  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
235  $resultCode=sprintf($r['Message'], "IdTplActionType");
236  $message=sprintf($r['Message'], "IdTplActionType");
237  $type=3;
238  }else{$data['IdTplActionType']=$entity['IdTplActionType'];}
239 
240  if(!isset($entity['IdUserAccount'])){
241  $resultId = 3144;
242  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
243  $resultCode=sprintf($r['Message'], "IdUserAccount");
244  $message=sprintf($r['Message'], "IdUserAccount");
245  $type=3;
246  }else{$data['IdUserAccount']=$entity['IdUserAccount'];}
247 
248  if(!isset($entity['UserAccountType'])){
249  $resultId = 3144;
250  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
251  $resultCode=sprintf($r['Message'], "UserAccountType");
252  $message=sprintf($r['Message'], "UserAccountType");
253  $type=3;
254  }else{$data['UserAccountType']=$entity['UserAccountType'];}
255 
256  if(!isset($entity['pageSize'])){
257  $_pageSize=$pg['pageSize'];
258  }else{
259  $_pageSize=$entity['pageSize'];
260  }
261 
262  if(!isset($entity['pageNo'])){
263  $_pageNo=$pg['pageNo'];
264  }else{$_pageNo=$entity['pageNo'];}
265 
266  if(!isset($entity['orderColumn'])){
267  $_orderColumn=$pg['orderColumn'];
268  }else{$_orderColumn=$entity['orderColumn'];}
269 
270  if(!isset($entity['orderType'])){
271  $_orderType=$pg['orderType'];
272  }else{
273  switch($entity['orderType'])
274  {
275  case 'ASC':
276  $_orderType="ASC";
277  break;
278  case 'DESC':
279  $_orderType="DESC";
280  break;
281  default:
282  $_orderType="DESC";
283  break;
284  }
285  }
286 
287  if(!isset($entity['orderColumn'])){
288  $_orderColumn=$pg['orderColumn'];
289  }else{
290  switch($entity['orderColumn'])
291  {
292  case 'IdTplActionTypeNextAction':
293  $_orderColumn="IdTplActionTypeNextAction";
294  break;
295  case 'IdTplActionType':
296  $_orderColumn="IdTplActionType";
297  break;
298  case 'Name':
299  $_orderColumn="Name";
300  break;
301  case 'Description':
302  $_orderColumn="Description";
303  break;
304  case 'IsRecursive':
305  $_orderColumn="IsRecursive";
306  break;
307  default:
308  $_orderColumn=$orderColumn;
309  break;
310  }
311 
312  }
313 
314  if($resultId==0){
315  $IdTplActionType=(int)$data['IdTplActionType'];
316  $IdTplActionTypeNextAction=(int)$data['IdTplActionTypeNextAction'];
317 
318  $count = $this->fetchRow($this->select()->setIntegrityCheck(false)
319  ->from("TplActionTypeNextAction",array("total"=>"COUNT(IdTplActionTypeNextAction)"))
320  ->where("IdTplActionType=$IdTplActionType OR 0=$IdTplActionType")
321  ->where("IdTplActionTypeNextAction=$IdTplActionTypeNextAction OR 0=$IdTplActionTypeNextAction")
322  );
323 
324  if($count->total==0){
325  $resultId = 3066;
326  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
327  $resultCode=$r['Message'];
328  $message=$r['Message'];
329  $type=3;
330  }else{
331 
332  $offset=$this->Paging->getOffset($count->total, $_pageSize, $_pageNo);
333 
334  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
335  ->from("TplActionTypeNextAction","*")
336  ->where("IdTplActionType=$IdTplActionType OR 0=$IdTplActionType")
337  ->where("IdTplActionTypeNextAction=$IdTplActionTypeNextAction OR 0=$IdTplActionTypeNextAction")
338  ->limit($_pageSize, $offset['start'])
339  ->order($_orderColumn." ".$_orderType)
340  );
341 
342  foreach($rows as $row){
343  $resultEntity[]=array("IdTplActionTypeNextAction" => $row->IdTplActionTypeNextAction,
344  "IdTplActionType" => $row->IdTplActionType,
345  "Name" => $row->Name,
346  "Description" => $row->Description,
347  "IsRecursive" => $row->IsRecursive,
348  );
349  }
350 
351  $resultCode=array("pageNo"=>$_pageNo,
352  "pageSize"=>$_pageSize,
353  "pageCount"=>$offset['maxPage'],
354  "orderColumn"=>$_orderColumn,
355  "orderType"=>$_orderType,"entity"=>$resultEntity);
356  }
357  }
358  }
359  catch(Exception $e){
360  $resultCode=$e->getMessage();
361  $resultId=101;
362  $type=3;
363  }
364  $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
365  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
366  return $response;
367  }
368  //============ End getTplActionTypeNextAction ==============================================================
369 
370 }
371 
372 ?>