/** * @return void */ public function addAction() { $request = $this->getRequest(); $phoneNumber = $this->_helper->IdConvert->hexToStr($request->getParam('phone_number')); $form = new Logic_Ws_Sms_Blacklist_Form_Generic(); $form->populate(array('phone_number' => $phoneNumber)); $refferer = $this->getRequestStackPrevious(); if ($this->getRequest()->isPost()) { if ($form->isCancelled($this->getRequest()->getPost())) { $this->_helper->redirector($refferer->action, $refferer->controller); return; } elseif ($form->isValid($this->getRequest()->getPost())) { $db = $this->_model->getDefaultAdapter(); $db->beginTransaction(); try { $values = $form->getValues(); // if (empty($values['ws_client_id'])) { // $dict = new Base_Dictionary(); // $cl = $dict->setSource(new Wsclient(), array('ghost = false'), 'id ASC', 'id', array('client_name'))->getDictionary(); // $values['ws_client_id'] = array_keys($cl); // } $this->_recpient->setClients($values['ws_client_id']); // $this->_recpient->setServices($values['ws_service_id']); $number = $this->_recpient->check($values['phone_number']); if ($number !== NULL) { foreach ($this->_recpient->getClients() as $clients) { // foreach($this->_recpient->getServices() as $service) { // $val['ws_service_id'] = $service; $val['ws_client_id'] = $clients; $val['number_comment'] = $values['number_comment']; $val['sms_recipient_id'] = $number; $row = $this->_model->createRow($val); $row->save(); } $this->_helper->messenger->success(); } else { $this->_helper->messenger->error($this->_recpient->getError()); } $db->commit(); } catch (Logic_Exception $e) { $db->rollBack(); $this->_helper->messenger->error($e->getMessage()); } $this->_helper->redirector($refferer->action, $refferer->controller); return; } } $this->view->form = $form; }