public function findByUserPerPage($A_limit) { $I_firstOfPage = $A_limit['firstOfPage']; $I_perPage = $A_limit['perPage']; $S_sql = 'SELECT c.id, c.control_date, c.conform, c.comment, c.epi_id, c.inspector_id FROM check_epi AS c INNER JOIN epi AS e ON e.id = c.epi_id INNER JOIN operator AS o ON o.id = e.operator_id WHERE o.id = ? LIMIT ' . $I_firstOfPage . ', ' . $I_perPage; $A_params = array(Session::getSession('user')->getOperatorId()); $O_connection = new Connection(); if ($A_data = $O_connection->requestDb($S_sql, $A_params, self::CLASS_NAME)) { $A_checks = null; foreach ($A_data as $O_check) { $O_check->initControlDate(); if (!is_null($O_check->getEpiId())) { try { $O_epiMapper = new EpiMapper(); $O_epi = $O_epiMapper->findById($O_check->getEpiId()); $O_check->setEpi($O_epi); $O_operatorMapper = new OperatorMapper(); $O_operator = $O_operatorMapper->findByEpi($O_check->getEpiId()); } 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_check->getInspectorId())) { try { $O_inspectorMapper = new InspectorMapper(); $O_inspector = $O_inspectorMapper->findById($O_check->getInspectorId()); $O_check->setInspector($O_inspector); } catch (Exception $e) { //On récupère le message de l'exception echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage(); } } $A_checks[] = ['check' => $O_check, 'operator' => $O_operator]; // $A_checks[] = $O_check; } return $A_checks; } else { throw new Exception("Une erreur s'est produite"); } }
public function modifyAction($I_id) { $this->haveAccess(2); $O_epiMapper = new EpiMapper(); $O_epi = $O_epiMapper->findById($I_id); $O_epi->setDealer($_POST['dealer']); $O_epi->setOrderNumber($_POST['order_number']); $O_date = new DateTime($_POST['manufacture_date']); $O_epi->setManufactureDate($O_date); $O_date = new DateTime($_POST['purchase_date']); $O_epi->setPurchaseDate($O_date); $O_epi->setProfile($_POST['profile']); $O_epi->setInternalReference($_POST['internal_reference']); $O_date = new DateTime($_POST['commissioning_date']); $O_epi->setCommissioningDate($O_date); $O_date = new DateTime($_POST['last_check_date']); $O_epi->setLastCheckDate($O_date); $O_date = new DateTime($_POST['next_check_date']); $O_epi->setNextCheckDate($O_date); $O_date = new DateTime($_POST['end_of_life_date']); $O_epi->setEndOfLifeDate($O_date); $O_epi->setOperatorId($_POST['operator_id']); try { // on donne l'objet epi pour la mise à jour $O_epiMapper->update($O_epi); die(header('Location:/epi/paginate/1')); } catch (Exception $e) { Session::setSession('error', $e->getMessage()); } }