Exemplo 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);
 }
Exemplo n.º 2
0
 /**
  * EditAction for Contacts
  *
  * @return void
  */
 public function editAction()
 {
     $form = new Company_Form_Contact();
     // if isPost try to update the information of the form
     if ($this->getRequest()->isPost()) {
         //Check the validation of the form
         if ($form->isValid($this->getRequest()->getPost())) {
             //update  the datas of form
             $model = new Company_Model_Contact();
             $id = $this->getRequest()->getPost('id');
             $model->update($form->getValues(), 'id = ' . (int) $id);
             //check Ajax
             if ($this->_request->isXmlHttpRequest()) {
                 $this->_helper->layout->disableLayout();
                 $data = $model->fetchEntry($id);
                 $this->_helper->viewRenderer('reloadrow');
                 $this->view->contact = $data;
                 return $data;
             } else {
                 //check if its ownCompany
                 $id = $this->_getParam('company_id', 0);
                 return $this->_helper->_redirector->gotoSimple('index', 'company', 'company');
             }
         } else {
             //check if dont pass the validation of the form and its Ajax
             if ($this->_request->isXmlHttpRequest()) {
                 $this->_helper->layout->disableLayout();
                 $form->populate($this->getRequest()->getPost());
                 $form->submit->setOptions(array('onChange' => "javascript:getAjaxResponsePost('contact','http://globalpms.es/company/contact/edit/company_id/{$company_id}','iDformcontact'); return false;"));
             }
             $form->populate($this->getRequest()->getPost());
         }
     } else {
         $id = $this->_getParam('id', 0);
         $model = new Company_Model_Contact();
         //comprobar si tiene permiso para editar el contacto solo los de su empresa
         if (!$model->isOwnContact($id)) {
             return $this->_helper->_redirector->gotoSimple('index', 'company', 'company');
         }
         $company_id = $this->_getParam('company_id', 0);
         if ($id > 0) {
             //check si es una peticion ajax
             if ($this->_request->isXmlHttpRequest()) {
                 $this->_helper->layout->disableLayout();
                 $form->submit->setOptions(array('onClick' => "javascript:getAjaxResponsePost('contact','http://globalpms.es/company/contact/edit/company_id/{$company_id}','iDformcontact'); return false;"));
                 // $this->_helper->viewRenderer->setNoRender(true);
             }
             $form->populate($model->fetchEntry($id));
         }
     }
     //$this->view->title = "Edit Contacts";
     $this->view->form = $form;
 }