Esempio n. 1
0
 /**
  * Delete entries
  * 
  * @param  array|string $where SQL WHERE clause(s)
  * @return int|string
  */
 public function delete($id)
 {
     $model_activities = new Production_Model_Activity();
     if ($model_activities->fetchHaveActivities($id)) {
         die("esta compañia tiene actividades relacionanadas");
     }
     $model_permission_production = new Production_Model_Permissionproduction();
     $model_permission_production->delete_production($id);
     //delete resource
     $table = $this->getTable();
     $table->delete('id = ' . (int) $id);
 }
 public function _selectOptions_Users()
 {
     $sql = "SELECT  acl_users.id,acl_users.name\n                  FROM acl_users,acl_users_has_companies \n                  WHERE acl_users_has_companies.acl_users_id=acl_users.id \n                       AND (acl_users_has_companies.companies_id=" . $_SESSION['company']['id'] . " OR acl_users_has_companies.companies_id=" . $_SESSION['production']['client_company'] . ")";
     $db = Zend_Registry::get('db');
     $result = $db->fetchPairs($sql);
     $model = new Production_Model_Permissionproduction();
     foreach ($result as $key => $value) {
         if ($model->fetchisEntry($key, $_SESSION['production']['id'])) {
             unset($result[$key]);
         }
     }
     if ($result == null) {
         echo "no quedan usuarios para añadir";
         //$this->url(array('controller' => 'permissionproduction', 'action' => 'index' ));
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * deleteAction for Productions
  *
  * @return void
  */
 public function selectAction()
 {
     $id = $this->_getParam('id', 0);
     //      //se comprueba que el usuario tiene permiso para esa produccion
     //se comprueba que el usuario tiene permiso para esa accion hecho
     $model_permission_production = new Production_Model_Permissionproduction();
     if (!$model_permission_production->isUserAllowedProduccition($id)) {
         echo "no tiene acceso a la produccion " . $production["name"];
         return $this->_helper->_redirector->gotoSimple('index', 'production', 'production');
     }
     $model = new Production_Model_Production();
     $production = $model->fetchEntry($id);
     $this->production = new Zend_Session_Namespace('production');
     $this->production->id = $id;
     $this->production->name = $production["name"];
     $this->production->activity_users = null;
     $this->production->activity = null;
     return $this->_helper->_redirector->gotoSimple('consult', 'finances', 'finances');
 }
 function consultAction()
 {
     //get the page of the table
     $this->production = new Zend_Session_Namespace('production');
     if ($this->production->id == null) {
         return $this->_helper->_redirector->gotoSimple('index', 'production', 'production');
     }
     $page = $this->_getParam('page', 1);
     //get the dates for the table
     $model = new Production_Model_Production();
     $data = $model->fetchEntryProduction();
     $this->production->client_company = $data["client_companies_id"];
     $this->production->own_company = $data["companies_id"];
     $this->production->own_company_name = $data["own_company_name"];
     $this->production->client_company_name = $data["client_company_name"];
     $this->view->production = $data;
     //send information to the view
     $this->view->title = "Production Consult";
     //get the dates for the table Activity
     $model = new Production_Model_Activity();
     //        Zend_Debug::dump($_SESSION);
     //               die();
     //TODO cambiar hardcode por roles que pueden verse
     if ($_SESSION['gpms']['role'] == "Encargado Actividad" or $_SESSION['gpms']['role'] == "public") {
         $data_activities = $model->fetchOwnActivities();
     } else {
         $data_activities = $model->fetchActivities();
     }
     if ($data_activities) {
         $paginator = Zend_Paginator::factory($data_activities);
         $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;
     }
     //get the dates for permission
     $page = $this->_getParam('page', 1);
     //get the dates for the table
     $model_permission = new Production_Model_Permissionproduction();
     $data_permission = $model_permission->fetchUserPermissionproductions();
     //paginator
     if ($data) {
         $paginator2 = Zend_Paginator::factory($data_permission);
         $production = Zend_Registry::get('production');
         $paginator2->setItemCountPerPage($production->paginator);
         $paginator2->setCurrentPageNumber($page);
         $paginator2->setPageRange($production->paginator);
         $this->view->paginator2 = $paginator2;
     } else {
         $this->view->paginator = null;
     }
     //send information to the view
 }
 /**
  * inlitterAction for Permissionproductions
  *
  * @return void
  */
 public function inlitterAction()
 {
     //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->getRequest()->isPost()) {
         $del = $this->getRequest()->getPost('del');
         if ($del == 'Yes') {
             $id = $this->getRequest()->getPost('id');
             $model = new Production_Model_Permissionproduction();
             $model->inLitter('id = ' . (int) $id);
         }
         return $this->_helper->redirector('index');
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $model = new Production_Model_Permissionproduction();
             $this->view->permissionproduction = $model->fetchEntry($id);
         }
     }
 }