Next4Me
 All Classes Files Functions Variables
CmplxMicroflowAndDetail.php
Go to the documentation of this file.
1 <?php
26 class Application_Model_CmplxMicroflowAndDetail extends Zend_Db_Table
27 {
28  //==== Start addEditMicroflowAndDetail =========================================================================
82  function addEditMicroflowAndDetail($entity){
83  $this->Microflow = new Application_Model_Microflow();
84  $this->MicroflowAction = new Application_Model_MicroflowAction();
85  $this->MicroflowActionAlert = new Application_Model_MicroflowActionAlert();
86  $this->MicroflowActionResult = new Application_Model_MicroflowActionResult();
87  $this->MicroflowActionProperty = new Application_Model_MicroflowActionProperty();
88  $this->MicroflowNextAction = new Application_Model_MicroflowNextAction();
89 
90  $commit=1;
91 
92  $microflowResult=$this->Microflow->addEditMicroflow($entity);
93  if($microflowResult['resultId']=="0")
94  {
95  $lastId=$microflowResult['resultCode'];
96  if(isset($entity['MicroflowAction'])&&($entity['MicroflowAction']!=""))
97  {
98  foreach($entity['MicroflowAction'] as $mAction)
99  {
100  if($commit==1)
101  {
102  $mAction['IdUserAccount']=$entity['IdUserAccount'];
103  $mAction['UserAccountType']=$entity['UserAccountType'];
104 
105  if((int)$mAction['IdMicroflowAction']<0)
106  {
107  $mADel['IdMicroflowAction']=(int)$mAction['IdMicroflowAction']*(-1);
108  $mADel['IdUserAccount']=$entity['IdUserAccount'];
109  $mADel['UserAccountType']=$entity['UserAccountType'];
110  $mADel['IdMicroflow']="0";
111  $mADel['IdMicroflowActionAlert']="0";
112  $mADel['IdMicroflowActionProperty']="0";
113  $mADel['IdMicroflowActionResult']="0";
114  $mADel['IdMicroflowNextAction']="0";
115  $mActionAlertDelete=$this->MicroflowActionAlert->deleteMicroflowActionAlert($mADel);
116  $mActionPropertyDelete=$this->MicroflowActionProperty->deleteMicroflowActionProperty($mADel);
117  $mActionResultDelete=$this->MicroflowActionResult->deleteMicroflowActionResult($mADel);
118  $mNextActionDelete=$this->MicroflowNextAction->deleteMicroflowNextAction($mADel);
119  $mActionDelete=$this->MicroflowAction->deleteMicroflowAction($mADel);
120  if($mActionDelete['resultId']!="0"){
121  $response=$mActionDelete['resultCode'];
122  $commit=0;
123  }
124  }else
125  {
126  $mAction['IdMicroflow']=$lastId;
127  $mActionAddEdit=$this->MicroflowAction->addEditMicroflowAction($mAction);
128  if($mActionAddEdit['resultId']=="0")
129  {
130  $lastIdAction=$mActionAddEdit['resultCode'];
131  if(isset($mAction['MicroflowActionAlert'])&&($mAction['MicroflowActionAlert']!=""))
132  {
133  foreach($mAction['MicroflowActionAlert'] as $mActionAlert)
134  {
135  $mActionAlert['IdUserAccount']=$entity['IdUserAccount'];
136  $mActionAlert['UserAccountType']=$entity['UserAccountType'];
137  if($commit==1)
138  {
139  if((int)$mActionAlert['IdMicroflowActionAlert']<0)
140  {
141  $mActionAlertDel['IdMicroflowActionAlert']=(int)$mActionAlert['IdMicroflowActionAlert']*(-1);
142  $mActionAlertDel['IdUserAccount']=$entity['IdUserAccount'];
143  $mActionAlertDel['UserAccountType']=$entity['UserAccountType'];
144  $mActionAlertDel['IdMicroflowAction']="0";
145  $mActionAlertDelete=$this->MicroflowActionAlert->deleteMicroflowActionAlert($mActionAlertDel);
146  if($mActionAlertDelete['resultId']!="0")
147  {
148  $response=$mActionAlertDelete['resultCode'];
149  $commit=0;
150  }
151  }else
152  {
153  $mActionAlert['IdMicroflowAction']=$lastIdAction;
154  $mActionAlertAddEdit=$this->MicroflowActionAlert->addEditMicroflowActionAlert($mActionAlert);
155  if($mActionAlertAddEdit['resultId']!="0")
156  {
157  $response=$mActionAlertAddEdit['resultCode'];
158  $commit=0;
159  }
160  }
161  }
162  }
163  }
164 
165  if(isset($mAction['MicroflowActionProperty'])&&($mAction['MicroflowActionProperty']!=""))
166  {
167  foreach($mAction['MicroflowActionProperty'] as $mActionProperty)
168  {
169  if($commit==1)
170  {
171  if((int)$mActionProperty['IdMicroflowActionProperty']<0)
172  {
173  $mActionPropertyDel['IdMicroflowActionProperty']=(int)$mActionProperty['IdMicroflowActionProperty']*(-1);
174  $mActionPropertyDel['IdUserAccount']=$entity['IdUserAccount'];
175  $mActionPropertyDel['UserAccountType']=$entity['UserAccountType'];
176  $mActionPropertyDel['IdMicroflowAction']="0";
177  $mActionPropertyDelete=$this->MicroflowActionProperty->deleteMicroflowActionProperty($mActionPropertyDel);
178  if($mActionPropertyDelete['resultId']!="0")
179  {
180  $response=$mActionPropertyDelete['resultCode'];
181  $commit=0;
182  }
183  }else{
184  $mActionProperty['IdMicroflowAction']=$lastIdAction;
185  $mActionProperty['IdUserAccount']=$entity['IdUserAccount'];
186  $mActionProperty['UserAccountType']=$entity['UserAccountType'];
187  $mActionPropertyAddEdit=$this->MicroflowActionProperty->addEditMicroflowActionProperty($mActionProperty);
188  if($mActionPropertyAddEdit['resultId']!="0")
189  {
190  $response=$mActionPropertyAddEdit['resultCode'];
191  $commit=0;
192  }
193  }
194  }
195  }
196  }
197 
198  if(isset($mAction['MicroflowActionResult'])&&($mAction['MicroflowActionResult']!=""))
199  {
200  foreach($mAction['MicroflowActionResult'] as $mActionResult)
201  {
202  if($commit==1)
203  {
204  if((int)$mActionResult['IdMicroflowActionResult']<0)
205  {
206  echo "mActRes<br>2";
207  $mActionResultDel['IdMicroflowActionResult']=(int)$mActionResult['IdMicroflowActionResult']*(-1);
208  $mActionResultDel['IdUserAccount']=$entity['IdUserAccount'];
209  $mActionResultDel['UserAccountType']=$entity['UserAccountType'];
210  $mActionResultDel['IdMicroflowAction']="0";
211  $mActionResultDelete=$this->MicroflowActionResult->deleteMicroflowActionResult($mActionResultDel);
212  if($mActionResultDelete['resultId']!="0")
213  {
214  $response=$mActionPropertyAddEdit['resultCode'];
215  $commit=0;
216  }
217  }else{
218  $mActionResult['IdMicroflowAction']=$lastIdAction;
219  $mActionResult['IdUserAccount']=$entity['IdUserAccount'];
220  $mActionResult['UserAccountType']=$entity['UserAccountType'];
221  $mActionResultAddEdit=$this->MicroflowActionResult->addEditMicroflowActionResult($mActionResult);
222  if($mActionResultAddEdit['resultId']!="0")
223  {
224  $response=$mActionResultAddEdit['resultCode'];
225  $commit=0;
226  }
227  }
228  }
229  }
230  }
231 
232  if(isset($mAction['MicroflowNextAction'])&&($mAction['MicroflowNextAction']!=""))
233  {
234  foreach($mAction['MicroflowNextAction'] as $mNextAction)
235  {
236  if($commit==1)
237  {
238  if((int)$mNextAction['IdMicroflowNextAction']<0)
239  {
240  $mNextActionDel['IdMicroflowNextAction']=(int)$mNextAction['IdMicroflowNextAction']*(-1);
241  $mNextActionDel['IdUserAccount']=$entity['IdUserAccount'];
242  $mNextActionDel['UserAccountType']=$entity['UserAccountType'];
243  $mNextActionDel['IdMicroflowAction']="0";
244  $mNextActionDelete=$this->MicroflowNextAction->deleteMicroflowNextAction($mNextActionDel);
245  if($mNextActionDelete['resultId']!="0")
246  {
247  $response=$mNextActionDelete['responseCode'];
248  $commit=0;
249  }
250  }
251  }else{
252  $mNextAction['IdMicroflowAction']=$lastIdAction;
253  $mNextAction['IdUserAccount']=$entity['IdUserAccount'];
254  $mNextAction['UserAccountType']=$entity['UserAccountType'];
255  $mNextActionAddEdit=$this->MicroflowNextAction->addEditMicroflowNextAction($mNextAction);
256  if($mNextActionAddEdit['resultId']!="0")
257  {
258  $response=$mNextActionAddEdit['resultCode'];
259  $commit=0;
260  }
261  }
262  }
263  }
264 
265  }else
266  {
267  $response=$mActionAddEdit['resultCode'];
268  $commit=0;
269  }
270  }
271  }
272  }
273  }
274  if($commit==1){
275  $response=$microflowResult;
276  }
277  }else{
278  $commit=0;
279  $response=$microflowResult;
280  }
281  return array("commit"=>$commit,"entity"=>$response);
282  }
283  //============ End addEditMicroflowAndDetail ==============================================================
284 
285  //==== Start deleteMicroflowAndDetail =========================================================================
293  function deleteMicroflowAndDetail($entity){
294  $this->Microflow = new Application_Model_Microflow();
295  $this->MicroflowAction = new Application_Model_MicroflowAction();
296  $this->MicroflowActionAlert = new Application_Model_MicroflowActionAlert();
297  $this->MicroflowActionResult = new Application_Model_MicroflowActionResult();
298  $this->MicroflowActionProperty = new Application_Model_MicroflowActionProperty();
299  $this->MicroflowNextAction = new Application_Model_MicroflowNextAction();
300  $microflowRowset=$this->Microflow->getMicroflow($entity);
301  if($microflowRowset['resultId']=="0"){
302  foreach($microflowRowset['resultCode']['entity'] as $microflowRow)
303  {
304  $data1=array("IdMicroflow"=>$microflowRow['IdMicroflow'], "IdMicroflowAction"=>"0", "IdUserAccount"=>$entity['IdUserAccount'],"UserAccountType"=>$entity['UserAccountType']);
305  $contextCondition=array();
306  $microflowActionRowset=$this->MicroflowAction->getMicroflowAction($data1);
307  if($microflowActionRowset['resultId']=="0"){
308  foreach($microflowActionRowset['resultCode']['entity'] as $microflowActionRow)
309  {
310  $data=array("IdMicroflowAction"=>$microflowActionRow['IdMicroflowAction'],
311  "IdMicroflowActionAlert"=>"0", "IdMicroflowActionProperty"=>"0",
312  "IdMicroflowActionResult"=>"0", "IdMicroflowNextAction"=>"0",
313  "IdUserAccount"=>$entity['IdUserAccount'],"UserAccountType"=>$entity['UserAccountType']);
314  $delMicroflowActionAlert=$this->MicroflowActionAlert->deleteMicroflowActionAlert($data);
315  $delMicroflowActionProperty=$this->MicroflowActionProperty->deleteMicroflowActionProperty($data);
316  $delMicroflowActionResult=$this->MicroflowActionResult->deleteMicroflowActionResult($data);
317  $delMicroflowNextAction=$this->MicroflowNextAction->deleteMicroflowNextAction($data);
318  }
319  $delMicroflowAction=$this->MicroflowAction->deleteMicroflowAction($data1);
320  }
321  }
322  $delMicroflow=$this->Microflow->deleteMicroflow($entity);
323  $result=array("resultId"=>$delMicroflow['resultId'], "resultCode"=>$delMicroflow['resultCode']);
324  }else{
325  $result=array("resultId"=>$microflowRowset['resultId'], "resultCode"=>$microflowRowset['resultCode']);
326  }
327  return array("commit"=>"1","entity"=>$result);
328  }
329  //============ End deleteMicroflowAndDetail ==============================================================
330 
331  //==== Start getMicroflowAndDetail =========================================================================
340  function getMicroflowAndDetail($entity){
341 
342  $this->Microflow = new Application_Model_Microflow();
343  $this->MicroflowAction = new Application_Model_MicroflowAction();
344  $this->MicroflowActionAlert = new Application_Model_MicroflowActionAlert();
345  $this->MicroflowActionResult = new Application_Model_MicroflowActionResult();
346  $this->MicroflowActionProperty = new Application_Model_MicroflowActionProperty();
347  $this->MicroflowNextAction = new Application_Model_MicroflowNextAction();
348 
349  $microflowsRowset=$this->Microflow->getMicroflow($entity);
350  if($microflowsRowset['resultId']=="0"){
351 
352  foreach($microflowsRowset['resultCode']['entity'] as $microflowRow)
353  {
354  $microflowAction=array();
355  $data=array("IdMicroflow"=>$microflowRow['IdMicroflow'], "IdMicroflowAction"=>'0', "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
356  $microflowActionsRowset=$this->MicroflowAction->getMicroflowAction($data);
357  if($microflowActionsRowset['resultId']=="0"){
358  foreach($microflowActionsRowset['resultCode']['entity'] as $microflowActionRow)
359  {
360  $microflowActionAlert=array();
361  $microflowActionProperty=array();
362  $microflowActionResult=array();
363  $microflowNextAction=array();
364  $data=array("IdMicroflowAction"=>$microflowActionRow['IdMicroflowAction'], "IdMicroflowNextAction"=>'0', "IdMicroflowActionResult"=>'0', "IdMicroflowActionProperty"=>'0', "IdMicroflowActionAlert"=>'0', "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
365  $microflowActionAlertRowset=$this->MicroflowActionAlert->getMicroflowActionAlert($data);
366  if($microflowActionAlertRowset['resultId']=="0"){
367  foreach($microflowActionAlertRowset['resultCode']['entity'] as $microflowActionAlertRow){
368  $microflowActionAlert[]=array("IdMicroflowActionAlert"=>$microflowActionAlertRow['IdMicroflowActionAlert'],
369  "IdMicroflowAction"=>$microflowActionAlertRow['IdMicroflowAction'],
370  "IdTplActionTypeAlert"=>$microflowActionAlertRow['IdTplActionTypeAlert'],
371  "AlertName"=>$microflowActionAlertRow['AlertName'],
372  "AlertChannel"=>$microflowActionAlertRow['AlertChannel'],
373  "AlertTarget"=>$microflowActionAlertRow['AlertTarget'],
374  "WhenTime"=>$microflowActionAlertRow['WhenTime'],
375  "IdChannel"=>$microflowActionAlertRow['IdChannel']);
376  }
377  }
378  $microflowActionPropertyRowset=$this->MicroflowActionProperty->getMicroflowActionProperty($data);
379  if($microflowActionPropertyRowset['resultId']=="0"){
380  foreach($microflowActionPropertyRowset['resultCode']['entity'] as $microflowActionPropertyRow){
381  $microflowActionProperty[]=array("IdMicroflowActionProperty"=>$microflowActionPropertyRow['IdMicroflowActionProperty'],
382  "IdMicroflowAction"=>$microflowActionPropertyRow['IdMicroflowAction'],
383  "IdTplActionTypeProperty"=>$microflowActionPropertyRow['IdTplActionTypeProperty'],
384  "PropertyString"=>$microflowActionPropertyRow['PropertyString'],
385  "PropertyValue"=>$microflowActionPropertyRow['PropertyValue'],
386  "PropertyDate"=>$microflowActionPropertyRow['PropertyDate']);
387  }
388  }
389  $microflowActionResultRowset=$this->MicroflowActionResult->getMicroflowActionResult($data);
390  if($microflowActionResultRowset['resultId']=="0"){
391  foreach($microflowActionResultRowset['resultCode']['entity'] as $microflowActionResultRow){
392  $microflowActionResult[]=array("IdMicroflowActionResult"=>$microflowActionResultRow['IdMicroflowActionResult'],
393  "IdMicroflowAction"=>$microflowActionResultRow['IdMicroflowAction'],
394  "ResultName"=>$microflowActionResultRow['ResultName'],
395  "Description"=>$microflowActionResultRow['Description'],
396  "IsSucces"=>$microflowActionResultRow['IsSuccess'],
397  "IdTplMicroflowActionResult"=>$microflowActionResultRow['IdTplMicroflowActionResult'],
398  "IdMicroflowNextAction"=>$microflowActionResultRow['IdMicroflowNextAction']);
399  }
400  }
401  $microflowNextActionRowset=$this->MicroflowNextAction->getMicroflowNextAction($data);
402  if($microflowNextActionRowset['resultId']=="0"){
403  foreach($microflowNextActionRowset['resultCode']['entity'] as $microflowNextActionRow){
404  $microflowNextAction[]=array("IdMicroflowNextAction"=>$microflowNextActionRow['IdMicroflowNextAction'],
405  "IdNextActionMf"=>$microflowNextActionRow['IdNextActionMf'],
406  "Name"=>$microflowNextActionRow['Name'],
407  "Description"=>$microflowNextActionRow['Description'],
408  "IsRecursive"=>$microflowNextActionRow['IsRecursive'],
409  "IdTplMicroflowNextAction"=>$microflowNextActionRow['IdTplMicroflowNextAction']);
410  }
411  }
412  $microflowAction[]=array("IdMicroflowAction"=>$microflowActionRow['IdMicroflowAction'],
413  "IdMicroflow"=>$microflowActionRow['IdMicroflow'],
414  "Name"=>$microflowActionRow['Name'],
415  "Description"=>$microflowActionRow['Description'],
416  "TimeActivation"=>$microflowActionRow['TimeActivation'],
417  "TimeClosed"=>$microflowActionRow['TimeClosed'],
418  "IdContext"=>$microflowActionRow['IdContext'],
419  "IdTplMicroflowAction"=>$microflowActionRow['IdTplMicroflowAction'],
420  "Status"=>$microflowActionRow['Status'],
421  "MicroflowActionAlert"=>$microflowActionAlert,
422  "MicroflowActionProperty"=>$microflowActionProperty,
423  "MicroflowActionResult"=>$microflowActionResult,
424  "MicroflowNextAction"=>$microflowNextAction);
425  }
426  }
427  $_CmplxMicroflow[]=array("IdMicroflow"=>$microflowRow['IdMicroflow'],
428  "IdAssetProperty"=> $microflowRow['IdAssetProperty'],
429  "IdTplMicroflow"=> $microflowRow['IdTplMicroflow'],
430  "Name"=> $microflowRow['Name'],"MicroflowAction"=>$microflowAction);
431  }
432  $result=array("resultId"=>$microflowsRowset['resultId'], "resultCode"=>$_CmplxMicroflow);
433  }else{
434  $result=array("resultId"=>$microflowsRowset['resultId'], "resultCode"=>$microflowsRowset['resultCode']);
435  }
436  return array("commit"=>"1","entity"=>$result);
437  }
438  //============ End getMicroflowAndDetail ==============================================================
439 
440  //==== Start getActionAndDetail =========================================================================
449  function getActionAndDetail($entity){
450 
451  $this->MicroflowAction = new Application_Model_MicroflowAction();
452  $this->MicroflowActionAlert = new Application_Model_MicroflowActionAlert();
453  $this->MicroflowActionResult = new Application_Model_MicroflowActionResult();
454  $this->MicroflowActionProperty = new Application_Model_MicroflowActionProperty();
455  $this->MicroflowNextAction = new Application_Model_MicroflowNextAction();
456 
457 
458  $microflowAction=array();
459  $microflowActionsRowset=$this->MicroflowAction->getMicroflowAction($entity);
460  if($microflowActionsRowset['resultId']=="0"){
461  foreach($microflowActionsRowset['resultCode']['entity'] as $microflowActionRow)
462  {
463  $microflowActionAlert=array();
464  $microflowActionProperty=array();
465  $microflowActionResult=array();
466  $microflowNextAction=array();
467  $data=array("IdMicroflowAction"=>$microflowActionRow['IdMicroflowAction'], "IdMicroflowNextAction"=>'0', "IdMicroflowActionResult"=>'0', "IdMicroflowActionProperty"=>'0', "IdMicroflowActionAlert"=>'0', "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
468  $microflowActionAlertRowset=$this->MicroflowActionAlert->getMicroflowActionAlert($data);
469  if($microflowActionAlertRowset['resultId']=="0"){
470  foreach($microflowActionAlertRowset['resultCode']['entity'] as $microflowActionAlertRow){
471  $microflowActionAlert[]=array("IdMicroflowActionAlert"=>$microflowActionAlertRow['IdMicroflowActionAlert'],
472  "IdMicroflowAction"=>$microflowActionAlertRow['IdMicroflowAction'],
473  "IdTplActionTypeAlert"=>$microflowActionAlertRow['IdTplActionTypeAlert'],
474  "AlertName"=>$microflowActionAlertRow['AlertName'],
475  "AlertChanel"=>$microflowActionAlertRow['AlertChanel'],
476  "AlertTarget"=>$microflowActionAlertRow['AlertTarget'],
477  "WhenTime"=>$microflowActionAlertRow['WhenTime'],
478  "IdChannel"=>$microflowActionAlertRow['IdChannel']);
479  }
480  }
481  $microflowActionPropertyRowset=$this->MicroflowActionProperty->getMicroflowActionProperty($data);
482  if($microflowActionPropertyRowset['resultId']=="0"){
483  foreach($microflowActionPropertyRowset['resultCode']['entity'] as $microflowActionPropertyRow){
484  $microflowActionProperty[]=array("IdMicroflowActionProperty"=>$microflowActionPropertyRow['IdMicroflowActionProperty'],
485  "IdMicroflowAction"=>$microflowActionPropertyRow['IdMicroflowAction'],
486  "IdTplActionTypeProperty"=>$microflowActionPropertyRow['IdTplActionTypeProperty'],
487  "PropertyString"=>$microflowActionPropertyRow['PropertyString'],
488  "PropertyValue"=>$microflowActionPropertyRow['PropertyValue'],
489  "PropertyDate"=>$microflowActionPropertyRow['PropertyDate']);
490  }
491  }
492  $microflowActionResultRowset=$this->MicroflowActionResult->getMicroflowActionResult($data);
493  if($microflowActionResultRowset['resultId']=="0"){
494  foreach($microflowActionResultRowset['resultCode']['entity'] as $microflowActionResultRow){
495  $microflowActionResult[]=array("IdMicroflowActionResult"=>$microflowActionResultRow['IdMicroflowActionResult'],
496  "IdMicroflowAction"=>$microflowActionResultRow['IdMicroflowAction'],
497  "ResultName"=>$microflowActionResultRow['ResultName'],
498  "Description"=>$microflowActionResultRow['Description'],
499  "IsSucces"=>$microflowActionResultRow['IsSuccess'],
500  "IdTplMicroflowActionResult"=>$microflowActionResultRow['IdTplMicroflowActionResult'],
501  "IdMicroflowNextAction"=>$microflowActionResultRow['IdMicroflowNextAction']);
502  }
503  }
504  $microflowNextActionRowset=$this->MicroflowNextAction->getMicroflowNextAction($data);
505  if($microflowNextActionRowset['resultId']=="0"){
506  foreach($microflowNextActionRowset['resultCode']['entity'] as $microflowNextActionRow){
507  $microflowNextAction[]=array("IdMicroflowNextAction"=>$microflowNextActionRow['IdMicroflowNextAction'],
508  "IdNextActionMf"=>$microflowNextActionRow['IdNextActionMf'],
509  "Name"=>$microflowNextActionRow['Name'],
510  "Description"=>$microflowNextActionRow['Description'],
511  "IsRecursive"=>$microflowNextActionRow['IsRecursive'],
512  "IdTplMicroflowNextAction"=>$microflowNextActionRow['IdTplMicroflowNextAction']);
513  }
514  }
515  $microflowAction[]=array("IdMicroflowAction"=>$microflowActionRow['IdMicroflowAction'],
516  "IdMicroflow"=>$microflowActionRow['IdMicroflow'],
517  "Name"=>$microflowActionRow['Name'],
518  "Description"=>$microflowActionRow['Description'],
519  "TimeActivation"=>$microflowActionRow['TimeActivation'],
520  "TimeClosed"=>$microflowActionRow['TimeClosed'],
521  "IdContext"=>$microflowActionRow['IdContext'],
522  "IdTplMicroflowAction"=>$microflowActionRow['IdTplMicroflowAction'],
523  "Status"=>$microflowActionRow['Status'],
524  "MicroflowActionAlert"=>$microflowActionAlert,
525  "MicroflowActionProperty"=>$microflowActionProperty,
526  "MicroflowActionResult"=>$microflowActionResult,
527  "MicroflowNextAction"=>$microflowNextAction);
528  }
529 
530  $result=array("resultId"=>$microflowActionsRowset['resultId'], "resultCode"=>$microflowAction);
531  }else{
532  $result=array("resultId"=>$microflowActionsRowset['resultId'], "resultCode"=>$microflowActionsRowset['resultCode']);
533  }
534  return array("commit"=>"1","entity"=>$result);
535  }
536  //============ End getActionAndDetail ==============================================================
537 
538  //============ Start getMicroflowAndDetailByAssetProperty ===========================================
547  $this->AssetProperty = new Application_Model_AssetProperty();
548  $assetPropertyRowset=$this->AssetProperty->getAssetProperty($entity);
549  if($assetPropertyRowset['resultId']=="0"){
550  foreach($assetPropertyRowset['resultCode']['entity'] as $assetPropertyRow)
551  {
552  $data=array("IdAssetProperty"=>$assetPropertyRow['IdAssetProperty'], "IdMicroflow"=>"0", "IdUserAccount"=>$entity['IdUserAccount'],"UserAccountType"=>$entity['UserAccountType']);
553  $microflow=$this->getMicroflowAndDetail($data);
554  $mResult=array();
555  //print_r($microflow);
556  if($microflow['entity']['resultId']=="0"){
557  $mResult=$microflow['entity']['resultCode'];
558  }
559  $assetProperty[]=array("IdAssetPoperty"=>$assetPropertyRow['IdAssetProperty'],
560  "IdAsset"=>$assetPropertyRow['IdAsset'],
561  "Name"=>$assetPropertyRow['Name'],
562  "PropertyValue"=>$assetPropertyRow['PropertyValue'],
563  "PropertyString"=>$assetPropertyRow['PropertyString'],
564  "PropertyDate"=>$assetPropertyRow['PropertyDate'],
565  "PropertyType"=>$assetPropertyRow['PropertyType'],"Microflow"=>$mResult);
566  }
567  $result=array("resultId"=>$assetPropertyRowset['resultId'], "resultCode"=>$assetProperty);
568  }else{
569  $result=array("resultId"=>$assetPropertyRowset['resultId'], "resultCode"=>$assetPropertyRowset['resultCode']);
570  }
571  return array("commit"=>"1","entity"=>$result);
572  }
573 
574 
575  //============ End getMicroflowAndDetailByAssetProperty ===========================================
576 
577  //============ Start getMicroflowAndDetailByAsset =================================================
584  function getMicroflowAndDetailByAsset($entity){
585  $this->CmplxAssetAndProperty = new Application_Model_CmplxAssetAndProperty();
586  $assetPropertyRowset=$this->CmplxAssetAndProperty->getAssetAndProperty($entity);
587  if($assetPropertyRowset['entity']['resultId']=="0"){
588  foreach ($assetPropertyRowset['entity']['resultCode'] as $asset){
589  $propertyData=array();
590  foreach ($asset['AssetProperty'] as $property){
591  $data=array("IdAssetProperty"=>$property['IdAssetProperty'], "IdMicroflow"=>"0", "IdUserAccount"=>$entity['IdUserAccount'],"UserAccountType"=>$entity['UserAccountType']);
592  $microflow=$this->getMicroflowAndDetail($data);
593  $mResult=array();
594  //print_r($microflow);
595  if($microflow['entity']['resultId']=="0"){
596  $mResult=$microflow['entity']['resultCode'];
597  }
598  $propertyData[]=array("IdAssetProperty"=>$property['IdAssetProperty'],
599  "IdAsset"=>$property['IdAsset'],
600  "Name"=>$property['Name'],
601  "PropertyValue"=>$property['PropertyValue'],
602  "PropertyString"=>$property['PropertyString'],
603  "PropertyDate"=>$property['PropertyDate'],
604  "PropertyType"=>$property['PropertyType'],
605  "Microflow"=>$mResult);
606  }
607 
608  $assetData[]=array("IdAsset"=>$asset['IdAsset'],
609  "IdTplAsset"=>$asset['IdTplAsset'],
610  "Name"=>$asset['Name'],
611  "IdUserAccount"=>$asset['IdUserAccount'],
612  "AssetProperty"=>$propertyData);
613 
614  }
615  $result=array("resultId"=>$assetPropertyRowset['entity']['resultId'], "resultCode"=>$assetData);
616  }else{
617  $result=array("resultId"=>$assetPropertyRowset['entity']['resultId'], "resultCode"=>$assetPropertyRowset['entity']['resultCode']);
618  }
619  return array("commit"=>"1", "entity"=>$result);
620  }
621 
622  //============ End getMicroflowAndDetailByAsset ===================================================
623 }