Ejemplo n.º 1
0
 public function update(array $data, $id)
 {
     $model_company = new Company_Model_Company();
     if ($model_company->existSupplierCompany($data["fiscal_name"], $id)) {
         //TODO ENVIAR UN MENSAJE
         die("supplier existe");
     }
     //add types of activity for the supplier
     $db = Zend_Registry::get('db');
     $db->delete("suppliers_has_activity_types", "suppliers_id=" . $id);
     $data_activity_type["suppliers_id"] = $data["id"];
     foreach ($data["activity_types_id"] as $value) {
         $data_activity_type["activity_types_id"] = $value;
         $db->insert("suppliers_has_activity_types", $data_activity_type);
         //                 Zend_Debug::dump($data_activity_type);
     }
     //                die();
     $model_company = new Company_Model_Company();
     $data_company = $data;
     $data_company["id"] = $data_company["companies_id"];
     $model_company->update($data_company, 'id = ' . (int) $data["companies_id"]);
     $table = $this->getTable();
     $fields = $table->info(Zend_Db_Table_Abstract::COLS);
     foreach ($data as $field => $value) {
         if (!in_array($field, $fields)) {
             unset($data[$field]);
         }
     }
     return $table->update($data, 'id = ' . (int) $id);
 }
Ejemplo n.º 2
0
 public function save($id)
 {
     $model_company = new Company_Model_Company();
     $data_receipt = $model_company->fetchProductionClientCompany($_SESSION["production"]["id"]);
     $data_receipt["productions_id"] = $_SESSION["production"]["id"];
     $data_receipt["production_name"] = $data_receipt["name"];
     unset($data_receipt["id"]);
     unset($data_receipt["name"]);
     $table = $this->getTable();
     $fields = $table->info(Zend_Db_Table_Abstract::COLS);
     foreach ($data_receipt as $field => $value) {
         if (!in_array($field, $fields)) {
             unset($data_receipt[$field]);
         }
     }
     $table->insert($data_receipt);
     return $table->lastInsertId();
 }
Ejemplo n.º 3
0
 function consultAction()
 {
     $this->_helper->layout->disableLayout();
     //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');
     }
     $model = new Finances_Model_Invoices();
     $this->view->title = "Consult Invoice";
     $invoice_id = $this->_getParam('id', 1);
     if (!$model->fetchInvoiceBelongProduction($invoice_id, $_SESSION["production"]["id"])) {
         return $this->_helper->_redirector->gotoSimple('index');
     }
     $production_model = new Company_Model_Company();
     Zend_Debug::dump($model->fetchInvoice($invoice_id));
     $this->view->company = $production_model->fetchEntry($_SESSION["company"]["id"]);
     $this->view->client = $model->fetchDatasReceiptEntry($invoice_id);
     $this->view->invoices = $model->fetchInvoice($invoice_id);
 }
Ejemplo n.º 4
0
 public function outLitter($where)
 {
     $table = $this->getTable();
     $model = new Company_Model_Company();
     return $model->outLitter($where);
 }
Ejemplo n.º 5
0
 /**
  * AddAction for Suppliers
  *
  * @return void
  */
 public function addAction()
 {
     $this->view->headTitle("Add New Supplier", 'APPEND');
     $request = $this->getRequest();
     $form = new Supplier_Form_Supplier();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $data_company = $form->getValues();
             $data_supplier["description"] = $data_company["observation"];
             $data_activity_types["activity_types_id"] = $data_company["activity_types_id"];
             //add the new company
             $model_company = new Company_Model_Company();
             $data_supplier["companies_id"] = $model_company->saveSupplier($data_company);
             //add this company to supplier table
             $model_supplier = new Supplier_Model_Supplier();
             $data_activity_type["suppliers_id"] = $model_supplier->save($data_supplier);
             $data_companies_supplier["suppliers_id"] = $data_activity_type["suppliers_id"];
             //add this supplier to the company
             $model_companies_supplier = new Supplier_Model_Companiessupplier();
             $data_companies_supplier["companies_id"] = $_SESSION["company"]["id"];
             $model_companies_supplier->save($data_companies_supplier);
             $db = Zend_Registry::get('db');
             //add types of activity for the supplier
             //                 Zend_Debug::dump($data_activity_types,"tipos a insertar");
             foreach ($data_activity_types["activity_types_id"] as $value) {
                 $data_activity_type["activity_types_id"] = $value;
                 //                    Zend_Debug::dump($data_activity_type,"inserta bd");
                 $db->insert("suppliers_has_activity_types", $data_activity_type);
             }
             return $this->_helper->_redirector->gotoSimple('select', 'supplier', 'supplier', array('id' => $data_supplier["companies_id"]));
         }
     } else {
         $form->populate($form->getValues());
     }
     $this->view->form = $form;
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 public function outlitterAction()
 {
     if ($this->getRequest()->isPost()) {
         $del = $this->getRequest()->getPost('del');
         if ($del == 'Yes') {
             $id = $this->getRequest()->getPost('id');
             $model = new Company_Model_Company();
             $model->outLitter('id = ' . (int) $id);
         }
         return $this->_helper->redirector('index');
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $model = new Company_Model_Company();
             $this->view->company = $model->fetchEntry($id);
         }
     }
 }