public function addAction()
 {
     $access_rights = $this->getSubModuleAccessRights(27);
     extract($access_rights);
     if (isset($add_action)) {
         $form = new CompanyForm($this->serviceLocator());
         $request = $this->getRequest();
         if ($request->isPost()) {
             $company = new Company();
             $form->setInputFilter($company->getInputFilter());
             $form->setData($request->getPost());
             if ($form->isValid()) {
                 $company->exchangeArray($form->getData());
                 if ($this->noRecordExists('companies', 'company_name')) {
                     $id = $this->getCompanyTable()->saveCompany($company);
                     $from = $this->getRequest()->getPost()->toArray();
                     $industry = (array) $this->getIndustryTable()->getIndustry($from['industry_id']);
                     unset($from['submit'], $from['companies_id'], $from['industry_id']);
                     $added = $this->prepare_added_data($from);
                     $this->save_to_audit_trail($from['company_name'], $added . 'industry=' . $industry['industry_name'], '--', 'add', 27);
                     $this->flashMessenger()->addMessage(['content' => $request->getPost('company_name') . ' has been successfully saved', 'type' => 'success']);
                 } else {
                     $this->flashMessenger()->addMessage(['content' => $request->getPost('company_name') . ' already exists!', 'type' => 'danger']);
                 }
             }
         }
     } else {
         $this->flashMessenger()->addMessage(['content' => 'You do not have permission to add', 'type' => 'danger']);
     }
     $this->redirect()->toRoute('company_industry');
 }
 public function indexAction()
 {
     $dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $form = new CompanyForm($dbAdapter);
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $company = new Company();
         $form->setInputFilter($company->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $company->exchangeArray($form->getData());
             $this->getCompanyList()->saveCompany($company);
             // Redirect to list of companys
             return $this->redirect()->toRoute('company');
         }
     }
     return array('form' => $form);
 }