public function indexAction() { $branch_order = 0; $branch = new PAP_Model_Branch(); $form = new PAP_Form_BranchForm(); $this->view->form = $form; //$user = $this->_helper->Session->getUserSession(); $comboProvinces = $form->getElement('province'); $this->loadProvinces($comboProvinces); $comboProvinces->setAttrib('onChange', 'loadCities();'); $comboCities = $form->getElement('city'); $branchMapper = new PAP_Model_BranchMapper(); $branchMapper->findByUserId($this->user, $branch_order, $branch); if ($this->getRequest()->isPost()) { if ($form->isValidPartial($_POST)) { $data = $form->getValues(); $branch = $this->saveBranch($data, 'update'); $this->loadForm($branch, 'update'); $this->loadCities($comboCities, $branch->getProvince(), $branch->getCity()); } } else { if (isset($branch)) { $this->loadProvinces($comboProvinces, $branch->getProvince()); $this->loadCities($comboCities, $branch->getProvince(), $branch->getCity()); $this->loadForm($branch, 'update'); $this->_helper->Session->setBranchSession($branch); } else { $form->name->setValue($this->user->getName()); $form->user->setValue($this->user->getId()); $form->email->setValue($this->user->getEmail()); } } }
public function getBranch($branch_order = 0) { $branch = new PAP_Model_Branch(); $branchMapper = new PAP_Model_BranchMapper(); $branchMapper->findByUserId($this, $branch_order, $branch); return $branch; }