Next4Me
 All Classes Files Functions Variables
MicroflowActionProperty.php
Go to the documentation of this file.
1 <?php
18 class Application_Model_MicroflowActionProperty extends Zend_Db_Table_Abstract {
19  //put your code here
20  protected $_name="MicroflowActionProperty";
21  protected $_primary="IdMicroflowActionProperty";
22  protected $_referenceMap=array(
23  'MicroflowActionProperty'=>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 addEditMicroflowActionProperty =========================================================================
49  function addEditMicroflowActionProperty($entity) {
50  // function implementation
51  $resultId = 0;
52  $page="MicroflowActionProperty.php";
53  $method="addEditMicroflowActionProperty";
54  $result=json_encode($entity);
55  $message="";
56  $type="1";
57  $this->ErrorCode = new Application_Model_ErrorCode;
58  $this->Log = new Application_Model_Log;
59 
60  try{
61  $data=array();
62  if(!isset($entity['IdMicroflowActionProperty'])){
63  $resultId = 3082;
64  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
65  $resultCode=sprintf($r['Message'], "IdMicroflowActionProperty");
66  $message=sprintf($r['Message'], "IdMicroflowActionProperty");
67  $type=3;
68  }else{$data['IdMicroflowActionProperty']=$entity['IdMicroflowActionProperty'];}
69 
70  if(!isset($entity['IdMicroflowAction'])){
71  if($resultId==0 && (int)$entity['IdMicroflowActionProperty']==0){
72  $resultId = 3082;
73  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
74  $resultCode=sprintf($r['Message'], "IdMicroflowAction");
75  $message=sprintf($r['Message'], "IdMicroflowAction");
76  $type=3;
77  }
78  }else{$data['IdMicroflowAction']=$entity['IdMicroflowAction'];}
79 
80  if(!isset($entity['IdTplActionTypeProperty'])){
81  if($resultId==0 && (int)$entity['IdMicroflowActionProperty']==0){
82  $resultId = 3082;
83  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
84  $resultCode=sprintf($r['Message'], "IdTplActionTypeProperty");
85  $message=sprintf($r['Message'], "IdTplActionTypeProperty");
86  $type=3;
87  }
88  }else{$data['IdTplActionTypeProperty']=$entity['IdTplActionTypeProperty'];}
89 
90  if(!isset($entity['PropertyString'])){
91  if($resultId==0 && (int)$entity['IdMicroflowActionProperty']==0){
92  $resultId = 3082;
93  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
94  $resultCode=sprintf($r['Message'], "PropertyString");
95  $message=sprintf($r['Message'], "PropertyString");
96  $type=3;
97  }
98  }else{$data['PropertyString']=$entity['PropertyString'];}
99 
100  if(!isset($entity['PropertyValue'])){
101  if($resultId==0 && (int)$entity['IdMicroflowActionProperty']==0){
102  $resultId = 3082;
103  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
104  $resultCode=sprintf($r['Message'], "PropertyValue");
105  $message=sprintf($r['Message'], "PropertyValue");
106  $type=3;
107  }
108  }else{$data['PropertyValue']=$entity['PropertyValue'];}
109 
110  if(!isset($entity['PropertyDate'])){
111  if($resultId==0 && (int)$entity['IdMicroflowActionProperty']==0){
112  $resultId = 3082;
113  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
114  $resultCode=sprintf($r['Message'], "PropertyDate");
115  $message=sprintf($r['Message'], "PropertyDate");
116  $type=3;
117  }
118  }else{$data['PropertyDate']=$entity['PropertyDate'];}
119 
120  if(!isset($entity['PropertyType'])){
121  if($resultId==0 && (int)$entity['IdMicroflowActionProperty']==0){
122  $resultId = 3082;
123  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
124  $resultCode=sprintf($r['Message'], "PropertyType");
125  $message=sprintf($r['Message'], "PropertyType");
126  $type=3;
127  }
128  }else{$data['PropertyType']=$entity['PropertyType'];}
129 
130  if(!isset($entity['PropertyName'])){
131  if($resultId==0 && (int)$entity['IdMicroflowActionProperty']==0){
132  $resultId = 3082;
133  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
134  $resultCode=sprintf($r['Message'], "PropertyName");
135  $message=sprintf($r['Message'], "PropertyName");
136  $type=3;
137  }
138  }else{$data['PropertyName']=$entity['PropertyName'];}
139 
140  if(!isset($entity['IdUserAccount'])){
141  $resultId = 3082;
142  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
143  $resultCode=sprintf($r['Message'], "IdUserAccount");
144  $message=sprintf($r['Message'], "IdUserAccount");
145  $type=3;
146  }else{$data['IdUserAccount']=$entity['IdUserAccount'];}
147 
148  if(!isset($entity['UserAccountType'])){
149  $resultId = 3082;
150  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
151  $resultCode=sprintf($r['Message'], "UserAccountType");
152  $message=sprintf($r['Message'], "UserAccountType");
153  $type=3;
154  }else{$data['UserAccountType']=$entity['UserAccountType'];}
155 
156  if(!isset($data) || $data==null){
157  $resultId = 3082;
158  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
159  $resultCode=sprintf($r['Message'], "IdTplActionTypeProperty,IdMicroflowAction,PropertyString,PropertyValue,PropertyDate,PropertyType,PropertyName");
160  $message=sprintf($r['Message'], "IdTplActionTypeProperty,IdMicroflowAction,PropertyString,PropertyValue,PropertyDate,PropertyType,PropertyName");
161  $type=3;
162  }
163  if($resultId==0){
164  if($data['UserAccountType']=="0"){
165  $IdUserAccount=0;
166  }else{
167  $IdUserAccount=(int)$data['IdUserAccount'];
168  }
169  $IdMicroflowActionProperty=(int)$data['IdMicroflowActionProperty'];
170  unset($data['UserAccountType']);
171 
172  if ($IdMicroflowActionProperty=="0"){
173  $k=$this->insert($data);
174  $k=$this->getAdapter()->lastInsertId();
175  $resultCode=$k;
176  }else{
177  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
178  ->from("MicroflowActionProperty","*")
179  ->where("IdMicroflowActionProperty=?",$IdMicroflowActionProperty)
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 = 5005;
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 = 3022;
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('IdMicroflowActionProperty=?',$IdMicroflowActionProperty));
203  $k=$IdMicroflowActionProperty;
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 addEditMicroflowActionProperty ==============================================================
220 
221 
222  //==== Start deleteMicroflowActionProperty =========================================================================
233  function deleteMicroflowActionProperty($entity) {
234  // function implementation
235  $resultId = 0;
236  $page="MicroflowActionProperty.php";
237  $method="deleteMicroflowActionProperty";
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['IdMicroflowActionProperty'])){
247  $resultId = 3165;
248  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
249  $resultCode=sprintf($r['Message'], "IdMicroflowActionProperty");
250  $message=sprintf($r['Message'], "IdMicroflowActionProperty");
251  $type=3;
252  }else{$data['IdMicroflowActionProperty']=$entity['IdMicroflowActionProperty'];}
253 
254  if(!isset($entity['IdMicroflowAction'])){
255  $resultId = 3165;
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 = 3165;
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 = 3165;
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 = 3165;
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 
286  if($resultId==0){
287 
288  $IdUserAccount=(int)$data['IdUserAccount'];
289  $IdMicroflowActionProperty=(int)$data['IdMicroflowActionProperty'];
290  $IdMicroflowAction=(int)$data['IdMicroflowAction'];
291 
292  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
293  ->from("MicroflowActionProperty","*")
294  ->where("IdMicroflowActionProperty=$IdMicroflowActionProperty OR 0=$IdMicroflowActionProperty")
295  ->where("IdMicroflowAction=$IdMicroflowAction OR 0=$IdMicroflowAction")
296  ->where("IdUserAccount=$IdUserAccount")
297  );
298  if($rows==null){
299  $resultId = 3023;
300  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
301  $resultCode=$r['Message'];
302  $message=$r['Message'];
303  $type=3;
304  }else{
305  $k=$this->delete(array("IdMicroflowActionProperty=$IdMicroflowActionProperty OR 0=$IdMicroflowActionProperty",
306  "IdMicroflowAction=$IdMicroflowAction OR 0=$IdMicroflowAction",
307  "IdUserAccount=$IdUserAccount"));
308  $resultCode="Date sterse";
309  }
310  }
311 
312  }
313  catch(Exception $e){
314  $resultCode=$e->getMessage();
315  $resultId=101;
316  $type=3;
317  }
318  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
319  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
320  return $response;
321  }
322  //============ End deleteMicroflowActionProperty ==============================================================
323 
324 
325  //==== Start getMicroflowActionProperty =========================================================================
345  function getMicroflowActionProperty($entity) {
346  // function implementation
347  $resultId = 0;
348  $page="MicroflowActionProperty.php";
349  $method="getMicroflowActionProperty";
350  $result=json_encode($entity);
351  $message="";
352  $type="1";
353  $this->ErrorCode = new Application_Model_ErrorCode;
354  $this->Log = new Application_Model_Log;
355  $this->Paging = new Application_Model_Paging;
356 
357  try{
358  $pg=$this->Paging->getPageDefault('MicroflowActionProperty');
359 
360  $data=array();
361  if(!isset($entity['IdMicroflowActionProperty']))
362  {
363  $resultId = 3138;
364  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
365  $resultCode=sprintf($r['Message'], "IdMicroflowActionProperty");
366  $message=sprintf($r['Message'], "IdMicroflowActionProperty");
367  $type=3;
368  }else{$data['IdMicroflowActionProperty']=$entity['IdMicroflowActionProperty'];}
369 
370  if(!isset($entity['IdMicroflowAction']))
371  {
372  $resultId = 3138;
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 = 3138;
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 = 3138;
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 'IdMicroflowActionProperty':
432  $_orderColumn="IdMicroflowActionProperty";
433  break;
434  case 'IdMicroflowAction':
435  $_orderColumn="IdMicroflowAction";
436  break;
437  case 'IdTplActionTypeProperty':
438  $_orderColumn="IdTplActionTypeProperty";
439  break;
440  case 'PropertyString':
441  $_orderColumn="PropertyString";
442  break;
443  case 'PropertyValue':
444  $_orderColumn="PropertyValue";
445  break;
446  case 'PropertyDate':
447  $_orderColumn="PropertyDate";
448  break;
449  case 'PropertyType':
450  $_orderColumn="PropertyType";
451  break;
452  case 'PropertyName':
453  $_orderColumn="PropertyName";
454  break;
455 
456  case 'IdUserAccount':
457  $_orderColumn="IdUserAccount";
458  break;
459  default:
460  $_orderColumn=$orderColumn;
461  break;
462  }
463 
464  }
465 
466  if($resultId==0){
467  if($data['UserAccountType']=="0"){
468  $IdUserAccount=0;
469  }else{
470  $IdUserAccount=(int)$data['IdUserAccount'];
471  }
472  $IdMicroflowActionProperty=(int)$data['IdMicroflowActionProperty'];
473  $IdMicroflowAction=(int)$data['IdMicroflowAction'];
474 
475  $count = $this->fetchRow($this->select()->setIntegrityCheck(false)
476  ->from("MicroflowActionProperty",array("total"=>"COUNT(IdMicroflowActionProperty)"))
477  ->where("IdUserAccount=$IdUserAccount OR 0=$IdUserAccount")
478  ->where("IdMicroflowAction=$IdMicroflowAction OR 0=$IdMicroflowAction")
479  ->where("IdMicroflowActionProperty=$IdMicroflowActionProperty OR 0=$IdMicroflowActionProperty")
480  );
481 
482  if($count->total==0){
483 
484  $resultId = 3024;
485  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
486  $resultCode=$r['Message'];
487  $message=$r['Message'];
488  $type=3;
489 
490  }else{
491 
492  $offset=$this->Paging->getOffset($count->total, $_pageSize, $_pageNo);
493 
494  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
495  ->from("MicroflowActionProperty","*")
496  ->where("IdMicroflowActionProperty=$IdMicroflowActionProperty OR 0=$IdMicroflowActionProperty")
497  ->where("IdMicroflowAction=$IdMicroflowAction OR 0=$IdMicroflowAction")
498  ->limit($_pageSize, $offset['start'])
499  ->order($_orderColumn." ".$_orderType)
500  );
501 
502  foreach($rows as $row){
503  $resultEntity[]=array("IdMicroflowActionProperty"=>$row->IdMicroflowActionProperty,
504  "IdMicroflowAction"=>$row->IdMicroflowAction,
505  "IdTplActionTypeProperty"=>$row->IdTplActionTypeProperty,
506  "PropertyString" => $row->PropertyString,
507  "PropertyValue" => $row->PropertyValue,
508  "PropertyDate" => $row->PropertyDate,
509  "PropertyType" => $row->PropertyType,
510  "PropertyName"=>$row->PropertyName);
511  }
512 
513  $resultCode=array("pageNo"=>$_pageNo,
514  "pageSize"=>$_pageSize,
515  "pageCount"=>$offset['maxPage'],
516  "orderColumn"=>$_orderColumn,
517  "orderType"=>$_orderType,"entity"=>$resultEntity);
518  }
519  }
520  }
521  catch(Exception $e){
522  $resultCode=$e->getMessage();
523  $resultId=101;
524  $type=3;
525  }
526  $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
527  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
528  return $response;
529  }
530  //============ End getMicroflowActionProperty ==============================================================
531 
532 }
533 
534 
535 ?>