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