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