Example #1
0
 public function save(PAP_Model_Branch $branch)
 {
     $data = array('user_id' => $branch->getUser(), 'branch_order' => $branch->getBranchorder(), 'branch_email' => $branch->getEmail(), 'branch_website' => $branch->getWebsite(), 'latitude' => $branch->getLatitude(), 'longitude' => $branch->getLongitude(), 'name' => $branch->getName(), 'street' => $branch->getStreet(), 'number' => $branch->getNumber(), 'phone' => $branch->getPhone(), 'local' => $branch->getLocal(), 'logo' => $branch->getLogo(), 'province_id' => $branch->getProvince(), 'city_id' => $branch->getCity(), 'zip_code' => $branch->getZipcode(), 'created' => date('Y-m-d H:i:s'), 'updated' => date('Y-m-d H:i:s'));
     if (null === ($id = $branch->getId())) {
         unset($data['branch_id']);
         $this->getDbTable()->insert($data);
         $last_id = $this->getDbTable()->getAdapter()->lastInsertId();
         $branch->setId($last_id);
     } else {
         $this->getDbTable()->update($data, array('branch_id = ?' => $id));
     }
 }
 private function loadForm(PAP_Model_Branch $branch, $formName)
 {
     $form = $this->view->form;
     $form->name->setValue($branch->getName());
     $form->street->setValue($branch->getStreet());
     $form->number->setValue($branch->getNumber());
     $form->local->setValue($branch->getLocal());
     $form->phone->setValue($branch->getPhone());
     $form->email->setValue($branch->getEmail());
     $form->website->setValue($branch->getWebsite());
     $form->zipcode->setValue($branch->getZipcode());
     $form->lat->setValue($branch->getLatitude())->setAttrib('readonly', 'true')->setAttrib('class', 'readonly');
     $form->latitude->setValue($branch->getLatitude());
     $form->lng->setValue($branch->getLongitude())->setAttrib('readonly', 'true')->setAttrib('class', 'readonly');
     $form->longitude->setValue($branch->getLongitude());
     $form->user->setValue($branch->getUser());
     $form->branch_id->setValue($branch->getId());
     $form->branch_order->setValue($branch->getBranchorder());
     $form->logo->setOptions(array('src' => '/images' . $branch->getLogo()));
     $form->setDefault('province', $branch->getProvince());
     //$combo->setAttrib('onChange', 'loadCities();');
     //$combo = $form->getElement("city");
     //$this->loadCities($combo, $branch->getProvince());
     $form->setDefault('city', $branch->getCity());
     if ($formName = 'update') {
         $form->filebranch->setRequired(false)->setLabel('Imagen del Comercio');
     }
 }