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