public function createAction()
 {
     $this->haveAccess();
     $O_label = new Label();
     $O_label->setLabel($_POST['label']);
     $O_label->setModel($_POST['model']);
     $O_label->setReference($_POST['reference']);
     $O_label->setDescription($_POST['description']);
     $O_label->setLifetime($_POST['lifetime']);
     $O_label->setControlCycle($_POST['control_cycle']);
     $O_label->setNotice($_POST['notice']);
     $O_label->setProcedure($_POST['procedure']);
     $O_label->setImage($_POST['image']);
     $O_label->setSize($_POST['size']);
     $O_label->setColor($_POST['color']);
     $O_label->setCategoryEpiId($_POST['category_epi_id']);
     $O_labelMapper = new LabelMapper();
     $I_labelId = $O_labelMapper->insert($O_label);
     die(header('Location:/label/paginate/1'));
 }
Beispiel #2
0
 public function findToNextCheckBysubgroupId($I_subgroup_id)
 {
     // je crée la date à l'instant t et je rajoute 1 mois
     $O_date = new DateTime();
     // 60 x 60 x 24 x 30 = 2592000 secondes
     $I_date = $O_date->format('U') + 2592000;
     $O_date = DateTime::createFromFormat('U', $I_date);
     $S_sql = "SELECT e.id , e.dealer, e.order_number, e.manufacture_date, e.purchase_date, e.profile, e.internal_reference, e.commissioning_date,\n              e.last_check_date, e.next_check_date, e.end_of_life_date, e.operator_id, e.safety_line_id, e.team_id, e.label_epi_id\n              FROM epi as e\n              INNER JOIN team as t ON t.id = e.team_id\n              INNER JOIN subgroup as s ON s.id = t.subgroup_id\n              WHERE subgroup_id = ? AND profile ='en service' AND next_check_date > '2000-01-01' AND next_check_date < '" . $O_date->format('Y-m-d H:i:s') . "'";
     $A_params = array($I_subgroup_id);
     $O_connection = new Connection();
     if ($A_data = $O_connection->requestDb($S_sql, $A_params, self::CLASS_NAME)) {
         $A_epis = null;
         foreach ($A_data as $key => $value) {
             $O_epi = $A_data[$key];
             // on récupère l'objet epi
             $O_epi->initManufactureDate();
             $O_epi->initPurchaseDate();
             $O_epi->initCommissioningDate();
             $O_epi->initLastCheckDate();
             $O_epi->initNextCheckDate();
             $O_epi->initEndOfLifeDate();
             if (!is_null($O_epi->getLabelEpiId())) {
                 try {
                     $O_labelMapper = new LabelMapper();
                     $O_label = $O_labelMapper->findById($O_epi->getLabelEpiId());
                     $O_epi->setLabelEpi($O_label);
                 } catch (Exception $e) {
                     //On récupère le message de l'exception
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             if (!is_null($O_epi->getTeamId())) {
                 try {
                     $O_teamMapper = new TeamMapper();
                     $O_team = $O_teamMapper->findById($O_epi->getTeamId());
                     $O_epi->setTeam($O_team);
                 } catch (Exception $e) {
                     //On récupère le message de l'exception
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             $A_epis[] = $O_epi;
         }
         return $A_epis;
     } else {
         throw new Exception("Pas d'EPI à controler.");
     }
 }
 public function newAction()
 {
     $this->haveAccess(1);
     $O_labelMapper = new LabelMapper();
     $O_label = $O_labelMapper->findAll();
     $O_operatorMapper = new OperatorMapper();
     $O_operator = $O_operatorMapper->findAll();
     Buffer::flushBuffer('epi/new', array('label' => $O_label, 'operator' => $O_operator));
 }