Next4Me
 All Classes Files Functions Variables
MicroflowNextAction.php
Go to the documentation of this file.
1 <?php
20 class Application_Model_MicroflowNextAction extends Zend_Db_Table_Abstract {
21  //put your code here
22  protected $_name="MicroflowNextAction";
23  protected $_primary="IdMicroflowNextAction";
24  protected $_referenceMap=array(
25  'MicroflowNextAction'=>array(
26  'columns'=>array('IdNextActionMf'),
27  'refTableClass'=>'MicroflowAction',
28  'refColumns'=>array('IdMicroflowAction'),
29  'onDelete' => self::CASCADE,
30  'onUpdate' => self::RESTRICT
31  )
32  );
33 
34  //==== Start addEditMicroflowNextAction =========================================================================
52  function addEditMicroflowNextAction($entity) {
53  // function implementation
54  $resultId = 0;
55  $page="MicroflowNextAction.php";
56  $method="addEditMicroflowNextAction";
57  $result=json_encode($entity);
58  $message="";
59  $type="1";
60  $this->ErrorCode = new Application_Model_ErrorCode;
61  $this->Log = new Application_Model_Log;
62 
63  try{
64  $data=array();
65  if(!isset($entity['IdMicroflowNextAction'])){
66  $resultId = 3084;
67  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
68  $resultCode=sprintf($r['Message'], "IdMicroflowNextAction");
69  $message=sprintf($r['Message'], "IdMicroflowNextAction");
70  $type=3;
71  }else{$data['IdMicroflowNextAction']=$entity['IdMicroflowNextAction'];}
72 
73  if(!isset($entity['IdNextActionMf'])){
74  if($resultId==0 && $entity['IdMicroflowNextAction']=="0"){
75  $resultId = 3084;
76  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
77  $resultCode=sprintf($r['Message'], "IdNextActionMf");
78  $message=sprintf($r['Message'], "IdNextActionMf");
79  $type=3;
80  }
81  }else{$data['IdNextActionMf']=$entity['IdNextActionMf'];}
82 
83  if(!isset($entity['Name'])){
84  if($resultId==0 && $entity['IdMicroflowNextAction']=="0"){
85  $resultId = 3084;
86  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
87  $resultCode=sprintf($r['Message'], "Name");
88  $message=sprintf($r['Message'], "Name");
89  $type=3;
90  }
91  }else{$data['Name']=$entity['Name'];}
92 
93  if(!isset($entity['Description'])){
94  if($resultId==0 && $entity['IdMicroflowNextAction']=="0"){
95  $resultId = 3084;
96  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
97  $resultCode=sprintf($r['Message'], "Description");
98  $message=sprintf($r['Message'], "Description");
99  $type=3;
100  }
101  }else{$data['Description']=$entity['Description'];}
102 
103  if(!isset($entity['IsRecursive'])){
104  if($resultId==0 && $entity['IdMicroflowNextAction']=="0"){
105  $resultId = 3084;
106  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
107  $resultCode=sprintf($r['Message'], "IsRecursive");
108  $message=sprintf($r['Message'], "IsRecursive");
109  $type=3;
110  }
111  }else{$data['IsRecursive']=$entity['IsRecursive'];}
112 
113  if(!isset($entity['IdTplMicroflowNextAction'])){
114  if($resultId==0 && $entity['IdMicroflowNextAction']=="0"){
115  $resultId = 3084;
116  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
117  $resultCode=sprintf($r['Message'], "IdTplMicroflowNextAction");
118  $message=sprintf($r['Message'], "IdTplMicroflowNextAction");
119  $type=3;
120  }
121  }else{$data['IdTplMicroflowNextAction']=$entity['IdTplMicroflowNextAction'];}
122 
123  if(!isset($entity['IdUserAccount'])){
124  $resultId = 3084;
125  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
126  $resultCode=sprintf($r['Message'], "IdUserAccount");
127  $message=sprintf($r['Message'], "IdUserAccount");
128  $type=3;
129  }else{$data['IdUserAccount']=$entity['IdUserAccount'];}
130 
131  if(!isset($entity['UserAccountType'])){
132  $resultId = 3084;
133  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
134  $resultCode=sprintf($r['Message'], "UserAccountType");
135  $message=sprintf($r['Message'], "UserAccountType");
136  $type=3;
137  }else{$data['UserAccountType']=$entity['UserAccountType'];}
138 
139  if(!isset($data) && $data==null){
140  $resultId = 3084;
141  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
142  $resultCode=sprintf($r['Message'], "IdNextActionMf,Name,Description,IsRecursive,IdTplMicroflowNextAction");
143  $message=sprintf($r['Message'], "IdNextActionMf,Name,Description,IsRecursive,IdTplMicroflowNextAction");
144  $type=3;
145  }
146 
147  if($resultId==0){
148  if($data['UserAccountType']=="0"){
149  $IdUserAccount=0;
150  }else{
151  $IdUserAccount=(int)$data['IdUserAccount'];
152  }
153  $IdMicroflowNextAction=(int)$data['IdMicroflowNextAction'];
154  unset($data['UserAccountType']);
155 
156  if ($IdMicroflowNextAction=="0"){
157  $k=$this->insert($data);
158  $k=$this->getAdapter()->lastInsertId();
159  $resultCode=$k;
160  }else{
161 
162  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
163  ->from("MicroflowNextAction","*")
164  ->where("IdMicroflowNextAction=$IdMicroflowNextAction")
165  ->where("IdUserAccount=$IdUserAccount OR 0=$IdUserAccount")
166  );
167  if($rows!=null){
168  if(isset($data['IdNextActionMf'])){
169  $IdNextActionMf=$rows->IdNextActionMf;
170  if($IdNextActionMf!=$entity['IdNextActionMf']){
171  $resultId = 5008;
172  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
173  $resultCode=$r['Message'];
174  $message=$r['Message'];
175  $type=3;
176  }
177  }
178  }else{
179  $resultId = 3031;
180  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
181  $resultCode=$r['Message'];
182  $message=$r['Message'];
183  $type=3;
184  }
185  if($resultId==0){
186  unset($data['IdUserAccount']);
187  $this->update($data,$this->getAdapter()->quoteInto('IdMicroflowNextAction=?',$IdMicroflowNextAction));
188  $k=$entity['IdMicroflowNextAction'];
189  $resultCode=$k;
190  }
191  }
192 
193  }
194 
195 
196  }
197  catch(Exception $e){
198  $resultCode=$e->getMessage();
199  $resultId=101;
200  $type=3;
201  }
202  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
203  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
204  return $response;
205  }
206  //============ End addEditMicroflowNextAction ==============================================================
207 
208 
209  //==== Start deleteMicroflowNextAction =========================================================================
220  function deleteMicroflowNextAction($entity) {
221  // function implementation
222  $resultId = 0;
223  $page="MicroflowNextAction.php";
224  $method="deleteMicroflowNextAction";
225  $result=json_encode($entity);
226  $message="";
227  $type="1";
228  $this->ErrorCode = new Application_Model_ErrorCode;
229  $this->Log = new Application_Model_Log;
230 
231  try{
232  $data=array();
233  if(!isset($entity['IdMicroflowNextAction'])){
234  $resultId = 3167;
235  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
236  $resultCode=sprintf($r['Message'], "IdMicroflowNextAction");
237  $message=sprintf($r['Message'], "IdMicroflowNextAction");
238  $type=3;
239  }else{$data['IdMicroflowNextAction']=$entity['IdMicroflowNextAction'];}
240 
241  if(!isset($entity['IdNextActionMf'])){
242  $resultId = 3167;
243  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
244  $resultCode=sprintf($r['Message'], "IdNextActionMf");
245  $message=sprintf($r['Message'], "IdNextActionMf");
246  $type=3;
247  }else{$data['IdNextActionMf']=$entity['IdNextActionMf'];}
248 
249  if(!isset($entity['IdUserAccount'])){
250  $resultId = 3167;
251  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
252  $resultCode=sprintf($r['Message'], "IdUserAccount");
253  $message=sprintf($r['Message'], "IdUserAccount");
254  $type=3;
255  }else{$data['IdUserAccount']=$entity['IdUserAccount'];}
256 
257  if(!isset($entity['UserAccountType'])){
258  $resultId = 3167;
259  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
260  $resultCode=sprintf($r['Message'], "UserAccountType");
261  $message=sprintf($r['Message'], "UserAccountType");
262  $type=3;
263  }else{$data['UserAccountType']=$entity['UserAccountType'];}
264 
265  if(!isset($data)|| $data==null){
266  $resultId = 3167;
267  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
268  $resultCode=sprintf($r['Message'], "IdAssetProperty,IdTplMicroflow,Name");
269  $message=sprintf($r['Message'], "IdAssetProperty,IdTplMicroflow,Name");
270  $type=3;
271  }
272  if($resultId==0){
273  $IdUserAccount=(int)$data['IdUserAccount'];
274  $IdMicroflowNextAction=(int)$data['IdMicroflowNextAction'];
275  $IdNextActionMf=(int)$data['IdNextActionMf'];
276  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
277  ->from("MicroflowNextAction","*")
278  ->where("IdMicroflowNextAction=$IdMicroflowNextAction OR 0=$IdMicroflowNextAction")
279  ->where("IdNextActionMf=$IdNextActionMf OR 0=$IdNextActionMf")
280  ->where("IdUserAccount=$IdUserAccount")
281  );
282 
283  if($rows==null){
284  $resultId = 3032;
285  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
286  $resultCode=$r['Message'];
287  $message=$r['Message'];
288  $type=3;
289  }else{
290  $k=$this->delete(array("IdMicroflowNextAction=$IdMicroflowNextAction OR 0=$IdMicroflowNextAction",
291  "IdNextActionMf=$IdNextActionMf OR 0=$IdNextActionMf",
292  "IdUserAccount=$IdUserAccount"));
293  $resultCode="Date sterse";
294  }
295  }
296  }
297  catch(Exception $e){
298  $resultCode=$e->getMessage();
299  $resultId=101;
300  $type=3;
301  }
302  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
303  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
304  return $response;
305  }
306  //============ End deleteMicroflowNextAction ==============================================================
307 
308 
309  //==== Start getMicroflowNextAction =========================================================================
329  function getMicroflowNextAction($entity) {
330  // function implementation
331  $resultId = 0;
332  $page="MicroflowNextAction.php";
333  $method="getMicroflowNextAction";
334  $result=json_encode($entity);
335  $message="";
336  $type="1";
337  $this->ErrorCode = new Application_Model_ErrorCode;
338  $this->Log = new Application_Model_Log;
339  $this->Paging = new Application_Model_Paging;
340 
341  try{
342  $pg=$this->Paging->getPageDefault('MicroflowNextAction');
343 
344  $data=array();
345  if(!isset($entity['IdMicroflowNextAction']))
346  {
347  $resultId = 3140;
348  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
349  $resultCode=sprintf($r['Message'], "IdMicroflowNextAction");
350  $message=sprintf($r['Message'], "IdMicroflowNextAction");
351  $type=3;
352  }else{$data['IdMicroflowNextAction']=$entity['IdMicroflowNextAction'];}
353 
354  if(!isset($entity['IdNextActionMf']))
355  {
356  $resultId = 3140;
357  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
358  $resultCode=sprintf($r['Message'], "IdNextActionMf");
359  $message=sprintf($r['Message'], "IdNextActionMf");
360  $type=3;
361  }else{$data['IdNextActionMf']=$entity['IdNextActionMf'];}
362 
363  if(!isset($entity['IdUserAccount'])){
364  $resultId = 3140;
365  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
366  $resultCode=sprintf($r['Message'], "IdUserAccount");
367  $message=sprintf($r['Message'], "IdUserAccount");
368  $type=3;
369  }else{$data['IdUserAccount']=$entity['IdUserAccount'];}
370 
371  if(!isset($entity['UserAccountType'])){
372  $resultId = 3140;
373  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
374  $resultCode=sprintf($r['Message'], "UserAccountType");
375  $message=sprintf($r['Message'], "UserAccountType");
376  $type=3;
377  }else{$data['UserAccountType']=$entity['UserAccountType'];}
378 
379  if(!isset($entity['pageSize'])){
380  $_pageSize=$pg['pageSize'];
381  }else{
382  $_pageSize=$entity['pageSize'];
383  }
384 
385  if(!isset($entity['pageNo'])){
386  $_pageNo=$pg['pageNo'];
387  }else{$_pageNo=$entity['pageNo'];}
388 
389  if(!isset($entity['orderColumn'])){
390  $_orderColumn=$pg['orderColumn'];
391  }else{$_orderColumn=$entity['orderColumn'];}
392 
393  if(!isset($entity['orderType'])){
394  $_orderType=$pg['orderType'];
395  }else{
396  switch($entity['orderType'])
397  {
398  case 'ASC':
399  $_orderType="ASC";
400  break;
401  case 'DESC':
402  $_orderType="DESC";
403  break;
404  default:
405  $_orderType="DESC";
406  break;
407  }
408  }
409 
410  if(!isset($entity['orderColumn'])){
411  $_orderColumn=$pg['orderColumn'];
412  }else{
413  switch($entity['orderColumn'])
414  {
415  case 'IdMicroflowNextAction':
416  $_orderColumn="IdMicroflowNextAction";
417  break;
418  case 'IdNextActionMf':
419  $_orderColumn="IdNextActionMf";
420  break;
421  case 'Name':
422  $_orderColumn="Name";
423  break;
424  case 'Description':
425  $_orderColumn="Description";
426  break;
427  case 'IsRecursive':
428  $_orderColumn="IsRecursive";
429  break;
430  case 'IdTplMicroflowNextAction':
431  $_orderColumn="IdTplMicroflowNextAction";
432  break;
433  case 'IdUserAccount':
434  $_orderColumn="IdUserAccount";
435  break;
436  default:
437  $_orderColumn=$orderColumn;
438  break;
439  }
440 
441  }
442 
443  if($resultId==0){
444  if($data['UserAccountType']=="0"){
445  $IdUserAccount=0;
446  }else{
447  $IdUserAccount=(int)$data['IdUserAccount'];
448  }
449  $IdMicroflowNextAction=(int)$data['IdMicroflowNextAction'];
450  $IdNextActionMf=(int)$data['IdNextActionMf'];
451 
452  $count = $this->fetchRow($this->select()->setIntegrityCheck(false)
453  ->from("MicroflowNextAction",array("total"=>"COUNT(IdMicroflowNextAction)"))
454  ->where("IdUserAccount=$IdUserAccount OR 0=$IdUserAccount")
455  ->where("IdMicroflowNextAction=$IdMicroflowNextAction OR 0=$IdMicroflowNextAction")
456  ->where("IdNextActionMf=$IdNextActionMf OR 0=$IdNextActionMf")
457  );
458 
459  if($count->total==0){
460  $resultId = 3033;
461  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
462  $resultCode=$r['Message'];
463  $message=$r['Message'];
464  $type=3;
465  }else{
466 
467  $offset=$this->Paging->getOffset($count->total, $_pageSize, $_pageNo);
468 
469  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
470  ->from("MicroflowNextAction","*")
471  ->where("IdUserAccount=$IdUserAccount OR 0=$IdUserAccount")
472  ->where("IdMicroflowNextAction=$IdMicroflowNextAction OR 0=$IdMicroflowNextAction")
473  ->where("IdNextActionMf=$IdNextActionMf OR 0=$IdNextActionMf")
474  ->limit($_pageSize, $offset['start'])
475  ->order($_orderColumn." ".$_orderType)
476  );
477  foreach($rows as $row){
478  $resultEntity[]=array("IdMicroflowNextAction"=>$row->IdMicroflowNextAction,
479  "IdNextActionMf"=>$row->IdNextActionMf,
480  "Name"=>$row->Name,
481  "Description"=>$row->Description,
482  "IsRecursive"=>$row->IsRecursive,
483  "IdTplMicroflowNextAction"=>$row->IdTplMicroflowNextAction);
484  }
485  $resultCode=array("pageNo"=>$_pageNo,
486  "pageSize"=>$_pageSize,
487  "pageCount"=>$offset['maxPage'],
488  "orderColumn"=>$_orderColumn,
489  "orderType"=>$_orderType,"entity"=>$resultEntity);
490  }
491 
492  }
493  }
494  catch(Exception $e){
495  $resultCode=$e->getMessage();
496  $resultId=101;
497  $type=3;
498  }
499  $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
500  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
501  return $response;
502  }
503  //============ End getMicroflowNextAction ==============================================================
504 
505 }
506 
507 ?>