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