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 findByName($S_name) { $S_sql = 'SELECT id, name, first_name, size_harness, email, inception_date, team_id FROM operator WHERE name = ?'; $A_params = array($S_name); $O_connection = new Connection(); if ($O_operator = $O_connection->requestDb($S_sql, $A_params, self::CLASS_NAME, $onlyOneObject = true)) { $O_operator->initInceptionDate(); $O_teamMapper = new TeamMapper(); $O_team = $O_teamMapper->findById($O_operator->getTeamId()); $O_operator->setTeam($O_team); return $O_operator; } else { throw new Exception("une erreur c'est produite lors de la requête"); } }