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