• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List

E:/E/GEAMP/www/openbiz/openbiz/bin/easy/EasyViewWizard.php

00001 <?PHP
00025 class EasyViewWizard extends EasyView
00026 {
00027     protected $m_CurrentStep;
00028     protected $m_FormStates;    // (formname, visited, committed)
00029     protected $m_DropSession = false;
00030     protected $m_NaviMethod = 'SwitchPage';
00031 
00032     protected function readMetadata(&$xmlArr)
00033     {
00034         parent::readMetaData($xmlArr);
00035         $this->m_NaviMethod = isset($xmlArr["EASYVIEW"]["ATTRIBUTES"]["NAVIMETHOD"]) ? $xmlArr["EASYVIEW"]["ATTRIBUTES"]["NAVIMETHOD"] :'SwitchPage';
00036     }
00043     public function getSessionVars($sessionContext)
00044     {
00045         $sessionContext->getObjVar($this->m_Name, "FormStates", $this->m_FormStates, true);
00046         $sessionContext->getObjVar($this->m_Name, "CurrentStep", $this->m_CurrentStep, true);
00047     }
00048 
00055     public function setSessionVars($sessionContext)
00056     {
00057         if ($this->m_DropSession){
00058             $sessionContext->cleanObj($this->m_Name, true);
00059         }else{
00060             $sessionContext->setObjVar($this->m_Name, "FormStates", $this->m_FormStates, true);
00061             $sessionContext->setObjVar($this->m_Name, "CurrentStep", $this->m_CurrentStep, true);
00062         }
00063         
00064     }
00065 
00072     protected function initAllForms()
00073     {
00074     }
00075 
00081     protected function processRequest()
00082     {
00083         parent::processRequest();
00084 
00085         $step = $this->getCurrentStep();
00086 
00087         // only display given step form
00088         $i = 1;
00089         foreach ($this->m_FormRefs as $formRef)
00090         {
00091             if ($i == $step)
00092                 $formRef->m_Display = true;
00093             else
00094                 $formRef->m_Display = false;
00095             $i++;
00096         }
00097     }
00098         
00099     protected function getStepName($step)
00100     {
00101               $i = 1;
00102         foreach ($this->m_FormRefs as $formRef){
00103             if($i == $step){              
00104               return $formRef->m_Name;
00105             }               
00106             $i++;
00107         }
00108         return "";
00109     }
00110         
00116     public function getCurrentStep()
00117     {
00118        if($this->m_CurrentStep){
00119               return $this->m_CurrentStep;
00120        }else{
00121                $step = isset($_GET['step']) ? $_GET['step'] : 1;
00122        
00123                $numForms = 0;
00124                foreach ($this->m_FormRefs as $formRef)
00125                    $numForms++;
00126        
00127                if ($step < 1)
00128                    $step = 1;
00129                if ($step > $numForms)
00130                    $step = $numForms;
00131                $this->m_CurrentStep = $step;
00132                return $step;
00133        }
00134     }
00135 
00142     public function renderStep($step)
00143     {
00144        if($this->m_CurrentStep){
00145               $currentStep = $this->m_CurrentStep;
00146        }else{
00147               $currentStep = $this->getCurrentStep();
00148        }
00149         if ($currentStep == $step)
00150             return;
00151               switch(strtoupper($this->m_NaviMethod)){
00152                      case "SWITCHFORM":
00153                             $targetForm = $this->getStepName($step);
00154                             $currentForm = $this->getStepName($currentStep);
00155                             $this->m_CurrentStep = $step;             
00156                             $formObj = BizSystem::objectFactory()->getObject($currentForm);
00157                             $formObj->switchForm($targetForm);
00158                             break;
00159                             
00160                      case "SWITCHPAGE":
00161                      default:
00162                             $url = "controller.php?view=".$this->m_Name."&step=".$step;
00163                       BizSystem::clientProxy()->ReDirectPage($url);
00164                             break;
00165                      
00166               }
00167     }
00168 
00175     public function getFormInputs($formName)
00176     {
00177         $formObj = BizSystem::objectFactory()->getObject($formName);
00178         $rec = $formObj->getActiveRecord();
00179         return $rec;
00180     }
00181 
00190     public function setFormState($formName, $state, $value)
00191     {
00192         $this->m_FormStates[$formName][$state] = $value;
00193     }
00194 
00200     public function commit()
00201     {
00202         // call all step forms Commit method
00203         foreach ($this->m_FormStates as $formName=>$state)
00204         {
00205             if ($state['visited'])
00206             {
00207                 $r = BizSystem::objectFactory()->getObject($formName)->commit();
00208                 if (!$r)
00209                     return false;
00210             }
00211         }              
00212         foreach ($this->m_FormStates as $formName=>$state)
00213         {
00214             if ($state['visited'])
00215             {
00216                 $r = BizSystem::objectFactory()->getObject($formName)->dropSession();
00217                 if (!$r)
00218                     return false;
00219             }
00220         } 
00221                 
00222         $this->m_DropSession = true;
00223         return true;
00224     }
00225    
00231     public function cancel()
00232     {
00233         // call all step forms Cancel method
00234         foreach ($this->m_FormStates as $formName=>$state)
00235         {
00236             if ($state['visited'])
00237                 BizSystem::objectFactory()->getObject($formName)->cancel();
00238         }
00239         $this->m_DropSession = true;
00240     }
00241 
00248     public function outputAttrs()
00249     {
00250         $out = parent::outputAttrs();
00251         $out['step'] = $this->m_CurrentStep;
00252         $out['forms'] = $this->m_FormRefs;
00253 
00254         return $out;
00255     }
00256 
00257 }
00258 
00259 ?>

Generated on Thu Apr 19 2012 17:09:13 for openbiz by  doxygen 1.7.2