Next4Me
 All Data Structures Files Functions Variables
application/models/CmplxMicroflows.php
Go to the documentation of this file.
00001 <?php
00002 
00021 class CmplxMicroflowsAndDetails  {
00022     //put your code here
00023     
00024         //==== GetMicroflowsAndDetails =========================================================================
00032         function GetMicroflowsAndDetails($entity) {
00033             $this->Microflows=new Microflows();
00034             $this->MicroflowActions= new MicroflowActions();
00035             $this->MicroflowActionResults= new MicroflowActionResults();
00036             $this->MicroflowActionProperties= new MicroflowActionProperties();
00037             $this->MicroflowActionAlerts= new MicroflowActionAlerts();
00038             $this->MicroflowNextActions= new MicroflowNextActions();
00039             $Microflows=$this->Microflows->GetMicroflows($entity);
00040             //echo "<pre>"; print_r($Microflows); echo "</pre>";
00041             if($Microflows['resultId']=="0"){
00042                 foreach($Microflows['resultCode'] as $a)
00043                 {
00044                     $entity=array("IdMicroflow"=>$a['IdMicroflow']);
00045                     $MicroflowActions=$this->MicroflowActions->GetMicroflowActions($entity);
00046                     if($MicroflowActions['resultId']=="0"){
00047                         foreach($MicroflowActions['resultCode'] as $m)
00048                         {
00049                             $entity=array("IdMicroflowAction"=>$m['IdMicroflowAction']);
00050                             $MicroflowActionResults=$this->MicroflowActionResults->GetMicroflowActionResults($entity);
00051                             if($MicroflowActionResults['resultId']=="0"){
00052                                 $resultMicroflowActionResult=$MicroflowActionResults['resultCode'];
00053                             }else{
00054                                 $resultMicroflowActionResult=null;
00055                             }
00056                             $MicroflowActionProperties=$this->MicroflowActionProperties->GetMicroflowActionProperties($entity);
00057                             if($MicroflowActionProperties['resultId']=="0"){
00058                                 $resultMicroflowActionProperties=$MicroflowActionProperties['resultCode'];
00059                             }else{
00060                                 $resultMicroflowActionProperties=null;
00061                             }
00062                             $MicroflowActionAlerts=$this->MicroflowActionAlerts->GetMicroflowActionAlerts($entity);
00063                             if($MicroflowActionAlerts['resultId']=="0"){
00064                                 $resultMicroflowActionAlerts=$MicroflowActionAlerts['resultCode'];
00065                             }else{
00066                                 $resultMicroflowActionAlerts=null;
00067                             }
00068                             $MicroflowNextActions=$this->MicroflowNextActions->GetMicroflowNextActions($entity);
00069                             if($MicroflowNextActions['resultId']=="0"){
00070                                 $resultMicroflowNextActions=$MicroflowNextActions['resultCode'];
00071                             }else{
00072                                 $resultMicroflowNextActions=null;
00073                             }
00074                            $resultMicroflowActions[]=array($m,"MicroflowActionResults"=>$resultMicroflowActionResult, "MicroflowActionProperties"=>$resultMicroflowActionProperties,  "MicroflowActionAlerts"=>$resultMicroflowActionAlerts, "MicroflowNextActions"=>$resultMicroflowNextActions, "MicroflowActionAlerts"=>$resultMicroflowActionAlerts); 
00075                         }
00076                     }
00077                     
00078                     $resultCode[]=array($a,"MicroflowActions"=>$resultMicroflowActions);
00079                 }
00080             }else{
00081                 $resultCode=$Microflows;
00082             }
00083             
00084             return $resultCode;
00085             
00086         }
00087         //============ End GetMicroflowsAndDetails ==============================================================
00088 
00089         //==== AddEditMicroflowsAndDetails =========================================================================
00140         function AddEditMicroflowsAndDetails($entity) {
00141             $this->Microflows=new Microflows();
00142             $this->MicroflowActions= new MicroflowActions();
00143             $this->MicroflowActionResults= new MicroflowActionResults();
00144             $this->MicroflowActionProperties= new MicroflowActionProperties();
00145             $this->MicroflowActionAlerts= new MicroflowActionAlerts();
00146             $this->MicroflowNextActions= new MicroflowNextActions();
00147             //echo "<pre>"; print_r($entity); echo "</pre>";
00148            
00149             if($entity['IdMicroflow']=="0"){
00150                 $microflow=array("IdMicroflow" => $entity['IdMicroflow'],
00151                     "IdAssetProperty" => $entity['IdAssetProperty'],
00152                     "IdTplMicroflow" => $entity['IdTplMicroflow'],
00153                     "Name" => $entity['Name']);
00154                 $r=$this->Microflows->AddEditMicroflows($microflow);
00155                 if($r['resultId']=="0"){
00156                     $lastId= $r['resultCode'];
00157                     foreach($entity['MicroflowActions'] as $microflowAction)
00158                     {
00159                         $microflowAction['IdMicroflowAction']="0";
00160                         $microflowAction['IdMicroflow']=$lastId;
00161                         $r=$this->MicroflowActions->AddEditMicroflowActions($microflowAction);
00162                         if($r['resultId']=="0"){
00163                             $lastActionId=$r['resultCode'];
00164                             if($microflowAction['MicroflowActionProperties']!=null)
00165                             {
00166                                 foreach($microflowAction['MicroflowActionProperties'] as $microflowActionProperty)
00167                                 {
00168                                     $microflowActionProperty['IdMicroflowActionProperty']="0";
00169                                     $microflowActionProperty['IdMicroflowAction']=$lastActionId;
00170                                     $r=$this->MicroflowActionProperties->AddEditMicroflowActionProperties($microflowActionProperty);
00171                                     
00172                                 }
00173                             }
00174                             if($microflowAction['MicroflowActionAlerts']!=null)
00175                             {
00176                                 
00177                             foreach($microflowAction['MicroflowActionAlerts'] as $microflowActionAlert)
00178                             {
00179                                 $microflowActionAlert['IdMicroflowActionAlert']="0";
00180                                 $microflowActionAlert['IdMicroflowAction']=$lastActionId;
00181                                 
00182                                 $r=$this->MicroflowActionAlerts->AddEditMicroflowActionAlerts($microflowActionAlert);
00183                                 
00184                             }
00185                             }
00186                             if($microflowAction['MicroflowActionResults']!=null)
00187                             {
00188                             foreach($microflowAction['MicroflowActionResults'] as $microflowActionResult)
00189                             {
00190                                 $microflowActionResult['IdMicroflowActionResult']="0";
00191                                 $microflowActionResult['IdMicroflowAction']=$lastActionId;
00192                                 $r=$this->MicroflowActionResults->AddEditMicroflowActionResults($microflowActionResult);
00193                                 
00194                             }
00195                             }
00196                             if($microflowAction['MicroflowNextActions']!=null)
00197                             {
00198                                 foreach($microflowAction['MicroflowNextActions'] as $microflowNextAction)
00199                                 {
00200                                     $microflowNextAction['IdMicroflowNextAction']="0";
00201                                     $microflowNextAction['IdNextActionMf']=$lastActionId;
00202                                     $r=$this->MicroflowNextActions->AddEditMicroflowNextActions($microflowNextAction);
00203                                     
00204                                 }
00205                             }
00206                         }
00207                     }
00208                 }
00209             }else{
00210                  $microflow=array("IdMicroflow" => $entity['IdMicroflow'],
00211                     "IdAssetProperty" => $entity['IdAssetProperty'],
00212                     "IdTplMicroflow" => $entity['IdTplMicroflow'],
00213                     "Name" => $entity['Name']);
00214                 $r=$this->Microflows->AddEditMicroflows($microflow);
00215                 if($r['resultId']=="0"){
00216                     $lastId= $r['resultCode'];
00217                     foreach($entity['MicroflowActions'] as $microflowAction)
00218                     {
00219                         $microflowAction['IdMicroflowAction']="0";
00220                         $microflowAction['IdMicroflow']=$lastId;
00221                         $r=$this->MicroflowActions->AddEditMicroflowActions($microflowAction);
00222                         if($r['resultId']=="0"){
00223                             $lastActionId=$r['resultCode'];
00224                             if($microflowAction['MicroflowActionProperties']!=null)
00225                             {
00226                                 foreach($microflowAction['MicroflowActionProperties'] as $microflowActionProperty)
00227                                 {
00228                                     $microflowActionProperty['IdMicroflowActionProperty']="0";
00229                                     $microflowActionProperty['IdMicroflowAction']=$lastActionId;
00230                                     $r=$this->MicroflowActionProperties->AddEditMicroflowActionProperties($microflowActionProperty);
00231                                     
00232                                 }
00233                             }
00234                             if($microflowAction['MicroflowActionAlerts']!=null)
00235                             {
00236                                 
00237                             foreach($microflowAction['MicroflowActionAlerts'] as $microflowActionAlert)
00238                             {
00239                                 $microflowActionAlert['IdMicroflowActionAlert']="0";
00240                                 $microflowActionAlert['IdMicroflowAction']=$lastActionId;
00241                                 
00242                                 $r=$this->MicroflowActionAlerts->AddEditMicroflowActionAlerts($microflowActionAlert);
00243                                 
00244                             }
00245                             }
00246                             if($microflowAction['MicroflowActionResults']!=null)
00247                             {
00248                             foreach($microflowAction['MicroflowActionResults'] as $microflowActionResult)
00249                             {
00250                                 $microflowActionResult['IdMicroflowActionResult']="0";
00251                                 $microflowActionResult['IdMicroflowAction']=$lastActionId;
00252                                 $r=$this->MicroflowActionResults->AddEditMicroflowActionResults($microflowActionResult);
00253                                 
00254                             }
00255                             }
00256                             if($microflowAction['MicroflowNextActions']!=null)
00257                             {
00258                                 foreach($microflowAction['MicroflowNextActions'] as $microflowNextAction)
00259                                 {
00260                                     $microflowNextAction['IdMicroflowNextAction']="0";
00261                                     $microflowNextAction['IdNextActionMf']=$lastActionId;
00262                                     $r=$this->MicroflowNextActions->AddEditMicroflowNextActions($microflowNextAction);
00263                                     
00264                                 }
00265                             }
00266                         }
00267                     }
00268                 }   
00269             }
00270                 
00271             return array("resultId"=>"0", "resultCode"=>"Update ok");
00272         }
00273         //============ End AddEditMicroflowsAndDetails ==============================================================
00274 
00275         //==== DeleteMicroflowsAndDetails =========================================================================
00283         function DeleteMicroflowsAndDetails($entity) {
00284             
00285             $this->Microflows=new Microflows();
00286             $this->MicroflowActions= new MicroflowActions();
00287             $this->MicroflowActionResults= new MicroflowActionResults();
00288             $this->MicroflowActionProperties= new MicroflowActionProperties();
00289             $this->MicroflowActionAlerts= new MicroflowActionAlerts();
00290             $this->MicroflowNextActions= new MicroflowNextActions();
00291             
00292             $r=$this->MicroflowActions->GetMicroflowActions($entity);
00293             if($r['resultId']=="0"){
00294                 $MicroflowActions=$r['resultCode'];
00295                 foreach($MicroflowActions as $m)
00296                 {
00297                     $this->MicroflowActionResults->DeleteMicroflowActionResults($m);
00298                     $this->MicroflowActionProperties->DeleteMicroflowActionProperties($m);
00299                     $this->MicroflowActionAlerts->DeleteMicroflowActionAlerts($m);
00300                     $this->MicroflowNextActions->DeleteMicroflowNextActions($m);
00301                     $this->MicroflowActions->DeleteMicroflowActions($m);
00302                 }
00303             }
00304             $this->Microflows->DeleteMicroflows($entity);
00305                 
00306             return array("resultId"=>"0", "resultCode"=>"Date Sterse");
00307         }
00308         //============ End DeleteMicroflowsAndDetails ==============================================================
00309 }
00310 ?>
00311