public function addAction() { $request = $this->getRequest(); $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $form = new Contacts_Form_Contact(); if ($request->isPost()) { $data = $request->getPost(); if ($form->isValid($data) || true) { $addressDb = new Contacts_Model_DbTable_Address(); $latest = end($addressDb->getAddress($data['contactid'])); $addressDb->addAddress($data['contactid'], $data['type'], '', $latest['ordering'] + 1); $address = end($addressDb->getAddress($data['contactid'])); echo $this->view->MultiForm('address', $address); } } }
public function addAction() { $data = array(); $data['created'] = $this->_date; $data['createdby'] = $this->_user['id']; $data['clientid'] = $this->_user['clientid']; $contactDb = new Contacts_Model_DbTable_Contact(); $id = $contactDb->addContact($data); $addressDb = new Contacts_Model_DbTable_Address(); $client = Zend_Registry::get('Client'); //Primary Address $data = array(); $data['contactid'] = $id; $data['type'] = 'primaryAddress'; $data['country'] = $client['country']; $data['clientid'] = $this->_user['clientid']; $data['created'] = $this->_date; $addressDb->addAddress($data); //Shipping Address $data = array(); $data['contactid'] = $id; $data['type'] = 'shippingAddress'; $data['country'] = $client['country']; $data['clientid'] = $this->_user['clientid']; $data['created'] = $this->_date; $addressDb->addAddress($data); //Create contact folder if does not already exists if (!file_exists(BASE_PATH . '/files/contacts/' . $id . '/')) { mkdir(BASE_PATH . '/files/contacts/' . $id . '/'); chmod(BASE_PATH . '/files/contacts/' . $id . '/', 0777); } $this->_helper->redirector->gotoSimple('edit', 'contact', null, array('id' => $id)); }