Esempio n. 1
0
 /**
  * Delete entries
  * 
  * @param  array|string $where SQL WHERE clause(s)
  * @return int|string
  */
 public function delete($user_id, $company_id)
 {
     $model_contact = new Company_Model_Contact();
     $data["acl_users_id"] = 0;
     $model_contact->update($data, 'acl_users_id = ' . (int) $user_id . ' and company_id =' . $company_id);
     //delete resource
     $table = $this->getTable();
     $table->delete('acl_users_id = ' . (int) $user_id . ' and companies_id =' . $company_id);
 }
Esempio n. 2
0
 public function update(array $data, $where)
 {
     $table = $this->getTable();
     $fields = $table->info(Zend_Db_Table_Abstract::COLS);
     //check if the user want have contat
     $data_contact = $data;
     $data_contact['acl_users_id'] = $data["id"];
     unset($data_contact["id"]);
     if ($data_contact["add_contact"]) {
         $model = new Company_Model_Contact();
         $model->save($data_contact);
     }
     foreach ($data as $field => $value) {
         if (!in_array($field, $fields)) {
             unset($data[$field]);
         }
     }
     if ($data['password'] != "") {
         $data['password'] = hash('SHA256', $data['password']);
     } else {
         unset($data['password']);
     }
     return $table->update($data, $where);
 }
Esempio n. 3
0
 function consultAction()
 {
     //get the page of the table
     $this->gpms = new Zend_Session_Namespace('gpms');
     if ($this->gpms->storage->out_production == 0) {
         return $this->_helper->_redirector->gotoSimple('index', 'company', 'company');
     }
     //         die();
     $this->company = new Zend_Session_Namespace('company');
     $page = $this->_getParam('page', 1);
     $models = new Company_Model_Contact();
     $paginator = Zend_Paginator::factory($models->fetchCompany($this->company->id));
     $contact = Zend_Registry::get('company');
     $paginator->setItemCountPerPage($contact->paginator);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange($contact->paginator);
     $this->view->paginator = $paginator;
     //get the dates for the table
     $model = new Company_Model_Company();
     $select_company = $model->fetchEntry($_SESSION["company"]["id"]);
     $this->view->select_company = $select_company;
     //send information to the view
     $this->view->title = "Production Consult";
 }
Esempio n. 4
0
 public function inlitterAction()
 {
     if ($this->getRequest()->isPost()) {
         $del = $this->getRequest()->getPost('del');
         if ($del == 'Yes') {
             $id = $this->getRequest()->getPost('id');
             $model = new Company_Model_Contact();
             $model->inLitter('id = ' . (int) $id);
         }
         $company_id = $this->getRequest()->getPost('company_id');
         //check if its ownCompany
         return $this->_helper->_redirector->gotoSimple('index', 'company', 'company', array('company_id' => $company_id));
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $model = new Company_Model_Contact();
             $this->view->contact = $model->fetchEntry($id);
         }
     }
 }
Esempio n. 5
0
 /**
  * Delete entries
  * 
  * @param  array|string $where SQL WHERE clause(s)
  * @return int|string
  */
 public function delete($id)
 {
     //check the integration TODO the views and resource check
     $model_production = new Production_Model_Production();
     if ($model_production->fetchHaveCompanyClient($id) != null) {
         die("esta compañia esta trabajando como cliente de una produccion");
     }
     $model_contact = new Company_Model_Contact();
     if ($model_contact->fetchHaveCompanyContact($id)) {
         die("esta compañia tiene contactos asociaodos");
     }
     //delete resource
     $table = $this->getTable();
     $table->delete('id = ' . (int) $id);
 }