Next4Me
 All Classes Files Functions Variables
TplMicroflow.php
Go to the documentation of this file.
1 <?php
15 class Application_Model_TplMicroflow extends Zend_Db_Table_Abstract {
16  protected $_name="TplMicroflow";
17  protected $_primary="IdTplMicroflow";
18 
19  //==== Start addEditTplMicroflow =========================================================================
31  function addEditTplMicroflow($entity) {
32  $resultId = 0;
33  $page="TplMicroflow.php";
34  $method="addEditTplMicroflow";
35  $result=json_encode($entity);
36  $message="";
37  $type="1";
38  $this->ErrorCode = new Application_Model_ErrorCode;
39  $this->Log = new Application_Model_Log;
40 
41  try{
42  $data=array();
43  if(!isset($entity['IdTplMicroflow'])){
44  $resultId = 3101;
45  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
46  $resultCode=sprintf($r['Message'], "IdTplMicroflow");
47  $message=sprintf($r['Message'], "IdTplMicroflow");
48  $type=3;
49  }else{$data['IdTplMicroflow']=(int)$entity['IdTplMicroflow'];}
50 
51  if(!isset($entity['IdTplAssetProperty'])){
52  if($resultId==0 && $data['IdTplMicroflow']=="0"){
53  $resultId = 3101;
54  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
55  $resultCode=sprintf($r['Message'], "IdTplAssetProperty");
56  $message=sprintf($r['Message'], "IdTplAssetProperty");
57  $type=3;
58  }
59  }else{$data['IdTplAssetProperty']=$entity['IdTplAssetProperty'];}
60 
61  if(!isset($entity['Name'])){
62  if($resultId==0 && $data['IdTplMicroflow']=="0"){
63  $resultId = 3101;
64  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
65  $resultCode=sprintf($r['Message'], "Name");
66  $message=sprintf($r['Message'], "Name");
67  $type=3;
68  }
69  }else{$data['Name']=$entity['Name'];}
70 
71  if(!isset($data) || $data==null){
72  $resultId = 3101;
73  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
74  $resultCode=sprintf($r['Message'], "IdTplAssetTypeProperty,Name");
75  $message=sprintf($r['Message'], "IdTplAssetTypeProperty,Name");
76  $type=3;
77  }
78  if($resultId==0 && $entity['IdTplMicroflow']!="0"){
79  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
80  ->from("TplMicroflow","*")
81  ->where("IdTplMicroflow=?",$entity['IdTplMicroflow'])
82  );
83  if($rows==null){
84  $resultId = 3067;
85  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
86  $resultCode=$r['Message'];
87  $message=$r['Message'];
88  $type=3;
89  }
90  }
91  unset($data['IdUserAccount']);
92  unset($data['UserAccountType']);
93  if($resultId==0){
94  if ($data['IdTplMicroflow']=="0"){
95  $k=$this->insert($data);
96  $k=$this->getAdapter()->lastInsertId();
97  $resultCode=$k;
98  }else{
99  $this->update($data,$this->getAdapter()->quoteInto('IdTplMicroflow=?',$data['IdTplMicroflow']));
100  $k=$data['IdTplMicroflow'];
101  $resultCode=$k;
102  }
103  }
104  }
105  catch(Exception $e){
106  $resultCode=$e->getMessage();
107  $resultId=101;
108  $type=3;
109  }
110  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
111  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
112  return $response;
113  }
114  //============ End addEditTplMicroflow ==============================================================
115 
116 
117  //==== Start deleteTplMicroflow =========================================================================
127  function deleteTplMicroflow($entity) {
128  // function implementation
129  $resultId = 0;
130  $page="TplMicroflow.php";
131  $method="deleteTplMicroflow";
132  $result=json_encode($entity);
133  $message="";
134  $type="1";
135  $this->ErrorCode = new Application_Model_ErrorCode;
136  $this->Log = new Application_Model_Log;
137 
138  try{
139  $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
140  ->from("TplMicroflow","*")
141  ->where("IdTplMicroflow=?",$entity['IdTplMicroflow'])
142  );
143  if($rows==null){
144  $resultId = 3068;
145  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
146  $resultCode=$r['Message'];
147  $message=$r['Message'];
148  $type=3;
149  }else{
150  $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
151  ->from("TplMicroflowAction","*")
152  ->where("IdTplMicroflow=?",$entity['IdTplMicroflow'])
153  );
154  if($chld==null){
155  $k=$this->delete($this->getAdapter()->quoteInto("IdTplMicroflow=?",$entity['IdTplMicroflow']));
156  $resultCode="Date sterse";
157  }else{
158  $resultId = 4011;
159  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
160  $resultCode=$r['Message'];
161  $message=$r['Message'];
162  $type=3;
163  }
164  }
165  }
166  catch(Exception $e){
167  $resultCode=$e->getMessage();
168  $resultId=101;
169  $type=3;
170  }
171  $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
172  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
173  return $response;
174  }
175  //============ End deleteTplMicroflow ==============================================================
176 
177 
178  //==== Start getTplMicroflow =========================================================================
192  function getTplMicroflow($entity) {
193  // function implementation
194  $resultId = 0;
195  $page="TplMicroflow.php";
196  $method="getTplMicroflow";
197  $result=json_encode($entity);
198  $message="";
199  $type="1";
200  $this->ErrorCode = new Application_Model_ErrorCode;
201  $this->Log = new Application_Model_Log;
202  $this->Paging=new Application_Model_Paging;
203 
204  try{
205  $pg=$this->Paging->getPageDefault('TplMicroflow');
206 
207  $data=array();
208  if(!isset($entity['IdTplMicroflow']))
209  {
210  $resultId = 3153;
211  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
212  $resultCode=sprintf($r['Message'], "IdTplMicroflow");
213  $message=sprintf($r['Message'], "IdTplMicroflow");
214  $type=3;
215  }else{$data['IdTplMicroflow']=$entity['IdTplMicroflow'];}
216 
217  if(!isset($entity['IdUserAccount'])){
218  $resultId = 3153;
219  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
220  $resultCode=sprintf($r['Message'], "IdUserAccount");
221  $message=sprintf($r['Message'], "IdUserAccount");
222  $type=3;
223  }else{$data['IdUserAccount']=$entity['IdUserAccount'];}
224 
225  if(!isset($entity['UserAccountType'])){
226  $resultId = 3153;
227  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
228  $resultCode=sprintf($r['Message'], "UserAccountType");
229  $message=sprintf($r['Message'], "UserAccountType");
230  $type=3;
231  }else{$data['UserAccountType']=$entity['UserAccountType'];}
232 
233  if(!isset($entity['pageSize'])){
234  $_pageSize=$pg['pageSize'];
235  }else{
236  $_pageSize=$entity['pageSize'];
237  }
238 
239  if(!isset($entity['pageNo'])){
240  $_pageNo=$pg['pageNo'];
241  }else{$_pageNo=$entity['pageNo'];}
242 
243  if(!isset($entity['orderColumn'])){
244  $_orderColumn=$pg['orderColumn'];
245  }else{$_orderColumn=$entity['orderColumn'];}
246 
247  if(!isset($entity['orderType'])){
248  $_orderType=$pg['orderType'];
249  }else{
250  switch($entity['orderType'])
251  {
252  case 'ASC':
253  $_orderType="ASC";
254  break;
255  case 'DESC':
256  $_orderType="DESC";
257  break;
258  default:
259  $_orderType="DESC";
260  break;
261  }
262  }
263 
264  if(!isset($entity['orderColumn'])){
265  $_orderColumn=$pg['orderColumn'];
266  }else{
267  switch($entity['orderColumn'])
268  {
269  case 'IdTplMicroflow':
270  $_orderColumn="IdTplMicroflow";
271  break;
272  case 'IdTplAssetProperty':
273  $_orderColumn="IdTplAssetProperty";
274  break;
275  case 'Name':
276  $_orderColumn="Name";
277  break;
278  default:
279  $_orderColumn=$orderColumn;
280  break;
281  }
282 
283  }
284 
285  if($resultId==0){
286  $IdTplMicroflow=(int)$data['IdTplMicroflow'];
287 
288  $count = $this->fetchRow($this->select()->setIntegrityCheck(false)
289  ->from("TplMicroflow",array("total"=>"COUNT(IdTplMicroflow)"))
290  ->where("IdTplMicroflow=$IdTplMicroflow OR 0=$IdTplMicroflow")
291  );
292 
293  if($count->total==0){
294  $resultId = 3069;
295  $r=$this->ErrorCode->getErrorCode($resultId,Zend_Registry::get('language'));
296  $resultCode=$r['Message'];
297  $message=$r['Message'];
298  $type=3;
299  }else{
300 
301  $offset=$this->Paging->getOffset($count->total, $_pageSize, $_pageNo);
302 
303  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
304  ->from("TplMicroflow","*")
305  ->where("IdTplMicroflow=$IdTplMicroflow OR 0=$IdTplMicroflow")
306  ->limit($_pageSize, $offset['start'])
307  ->order($_orderColumn." ".$_orderType)
308  );
309 
310  foreach($rows as $row){
311  $resultEntity[]=array("IdTplMicroflow"=>$row->IdTplMicroflow,
312  "IdTplAssetProperty"=>$row->IdTplAssetProperty,
313  "Name"=>$row->Name);
314  }
315 
316  $resultCode=array("pageNo"=>$_pageNo,
317  "pageSize"=>$_pageSize,
318  "pageCount"=>$offset['maxPage'],
319  "orderColumn"=>$_orderColumn,
320  "orderType"=>$_orderType,"entity"=>$resultEntity);
321  }
322  }
323  }
324  catch(Exception $e){
325  $resultCode=$e->getMessage();
326  $resultId=101;
327  $type=3;
328  }
329  $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
330  $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
331  return $response;
332  }
333  //============ End getTplMicroflow ==============================================================
334 
335 }
336 
337 ?>