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