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