public function consultAction()
 {
     $this->supplier = new Zend_Session_Namespace('supplier');
     if ($this->supplier->id == null) {
         return $this->_helper->_redirector->gotoSimple('consult', 'production', 'production');
     }
     //get the contacs of the supplier
     $page = $this->_getParam('page', 1);
     $models = new Production_Model_Contactresource();
     $paginator = Zend_Paginator::factory($models->fetchSupplier($this->supplier->id));
     $contact = Zend_Registry::get('supplier');
     $paginator->setItemCountPerPage($contact->paginator);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange($contact->paginator);
     $this->view->paginator = $paginator;
     $model = new Production_Model_Resource();
     $data_resource = $model->fetchEntriesSupplier();
     //data resource of supplier
     if ($data_resource) {
         $paginator_resource = Zend_Paginator::factory($data_resource);
         $supplier = Zend_Registry::get('supplier');
         $paginator_resource->setItemCountPerPage($supplier->paginator);
         $paginator_resource->setCurrentPageNumber($page);
         $paginator_resource->setPageRange($supplier->paginator);
         $this->view->paginator_resource = $paginator_resource;
     } else {
         $this->view->paginator_resource = null;
     }
     //send information to the view
     $this->view->title = "Resources list";
     //get the dates for the table
     $model = new Production_Model_Productionsuppliers();
     $select_supplier = $model->fetchEntry($_SESSION["supplier"]["id"]);
     //Zend_Debug::dump($select_supplier);
     $this->view->select_supplier = $select_supplier;
     //send information to the view
     $this->view->title = "Supplier Consult";
 }
 function consultAction()
 {
     //check if the user select a production
     $this->production = new Zend_Session_Namespace('production');
     if ($this->production->id == null) {
         return $this->_helper->_redirector->gotoSimple('index', 'production', 'production');
     }
     if ($this->production->activity_id == null) {
         return $this->_helper->_redirector->gotoSimple('consult', 'production', 'production');
     }
     $page = $this->_getParam('page', 1);
     //get the dates for the table
     $model = new Production_Model_Resource();
     $data_resource = $model->fetchEntriesActivity();
     //paginator
     if ($data_resource) {
         $paginator = Zend_Paginator::factory($data_resource);
         $production = Zend_Registry::get('production');
         $paginator->setItemCountPerPage($production->paginator);
         $paginator->setCurrentPageNumber($page);
         $paginator->setPageRange($production->paginator);
         $this->view->paginator = $paginator;
     } else {
         $this->view->paginator = null;
     }
     //send information to the view
     $this->view->title = "Resources list";
     //get the dates for the table
     $model = new Production_Model_Activity();
     $data = $model->fetchEntryActivity();
     //        $this->production = new Zend_Session_Namespace('production');
     //        $this->production->activity_users=$data["users_activity_id"];
     $this->view->activity = $data;
     //send information to the view
     $this->view->title = "Production Consult";
 }
 /**
  * deleteAction for Resources
  *
  * @return void
  */
 public function deleteAction()
 {
     if ($this->getRequest()->isPost()) {
         $del = $this->getRequest()->getPost('del');
         if ($del == 'Yes') {
             $id = $this->getRequest()->getPost('id');
             $model = new Production_Model_Resource();
             $model->delete('id = ' . (int) $id);
         }
         return $this->_helper->_redirector->gotoSimple('consult', 'activity', 'production');
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $model = new Production_Model_Resource();
             $this->view->resource = $model->fetchEntry($id);
         }
     }
 }
 /**
  * AddAction for Receipt
  *
  * @return void
  */
 public function addreceiptAction()
 {
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->viewRenderer->setNoRender(true);
         $this->_helper->layout->disableLayout();
     }
     $id = $this->_getParam('id', 10);
     $price = $this->_getParam('price', 0);
     $facturation_type = $this->_getParam('facturation_type', 32);
     //        Zend_Debug::dump($price,"facturation_type");
     //        Zend_Debug::dump($facturation_type,"facturation_type");
     //        die();
     if ($id == 0) {
         return $this->_helper->_redirector->gotoSimple('consult', 'finances', 'finances');
     }
     $model_resource_activity_has_receipt = new Finances_Model_Resourceactivityhasreceipt();
     // Comprobar que no esta añadido en el recibo
     $receipt_id = $model_resource_activity_has_receipt->fetchEntryActivityResource($id);
     if ($receipt_id != null) {
         return $this->_helper->_redirector->gotoSimple('consult', 'finances', 'finances');
     }
     // Comprobar que los campos de : tipo de facturación, precio estan rellenados
     $model_receipt = new Finances_Model_Receipts();
     $data_receipt = $model_receipt->fetchProductionHasOpenReceipt($_SESSION["production"]["id"]);
     $receipt_id = $data_receipt["id"];
     // Comprobar que no hay ningun recibo abierto en la produccion
     if (!$receipt_id) {
         // Si no lo hay introducir crear un recibo
         $receipt_id = $model_receipt->save($id);
     }
     $model_activity_resource = new Production_Model_Resource();
     $data_activity_resource["iva_type"] = $model_activity_resource->fetchIvaType($id);
     $data_activity_resource["receipts_id"] = $receipt_id;
     $data_activity_resource["resources_activities_id"] = $id;
     $data_activity_resource["price"] = (int) $price;
     $data_activity_resource["facturation_types_id"] = (int) $facturation_type;
     $data_activity_resource["quantity"] = $model_activity_resource->fetchQuantity($id);
     $data_activity_resource["final_price"] = $model_resource_activity_has_receipt->calculateFinalPrice($data_activity_resource["resources_activities_id"], $data_activity_resource["price"], $data_activity_resource["facturation_types_id"], $data_activity_resource["quantity"]);
     $data_actitity_resource["id"] = $model_resource_activity_has_receipt->save($data_activity_resource);
     $json = Zend_Json::encode($model_resource_activity_has_receipt->fetchEntry($data_actitity_resource["id"]));
     echo $json;
     //        return $this->_helper->_redirector->gotoSimple('consult', 'finances', 'finances');
 }