/**
  * AddAction for Productions
  *
  * @return void
  */
 public function addAction()
 {
     $this->view->headTitle("Add New Production", 'APPEND');
     $request = $this->getRequest();
     //form for a new production
     $production_form = new Production_Form_Production();
     //form for a new client
     $company_form = new Company_Form_Company();
     // check if there is a selection client
     $data_clients['client_companies_id'] = $this->_getParam('client_companies_id');
     $production_form->populate($data_clients);
     if ($this->getRequest()->isPost()) {
         $data_post = $request->getPost();
         if (isset($data_post["status_id"])) {
             if ($production_form->isValid($request->getPost())) {
                 $data_production = $production_form->getValues();
                 $model_production = new Production_Model_Production();
                 $id_production = $model_production->save($data_production);
                 return $this->_helper->_redirector->gotoSimple('select', 'production', 'production', array('id' => $id_production));
             } else {
                 $production_form->populate($production_form->getValues());
             }
         } elseif ($company_form->isValid($request->getPost())) {
             $data_clients = $company_form->getValues();
             $model_company = new Company_Model_Company();
             $client_companies_id = $model_company->saveClient($data_clients);
             return $this->_helper->_redirector->gotoSimple('add', 'production', 'production', array('client_companies_id' => $client_companies_id));
         } else {
             $company_form->populate($company_form->getValues());
         }
     }
     $this->view->production_form = $production_form;
     $this->view->company_form = $company_form;
 }
 /**
  * EditAction for Companys
  *
  * @return void
  */
 public function editAction()
 {
     $this->gpms = new Zend_Session_Namespace('gpms');
     if ($this->gpms->storage->out_production == 0) {
         return $this->_helper->_redirector->gotoSimple('index', 'company', 'company');
     }
     $this->view->title = "Edit Company";
     $form = new Company_Form_Company();
     //get the dates for the table
     $model = new Company_Model_Company();
     $select_company = $model->fetchEntry($_SESSION["company"]["id"]);
     $this->view->select_company = $select_company;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $model = new Company_Model_Company();
             $id = $this->getRequest()->getPost('id');
             $model->update($form->getValues(), 'id = ' . (int) $id);
             return $this->_helper->redirector('index');
         } else {
             $form->populate($this->getRequest()->getPost());
         }
     } else {
         $id = $_SESSION["company"]["id"];
         if ($id > 0) {
             $model = new Company_Model_Company();
             $form->populate($model->fetchEntry($id));
         }
     }
     $this->view->form = $form;
 }