public function checkout($params) { $issue = $params['issue']; $description = $this->request->getParameter('description'); $connection = new Connection(); // get the vehicle form the issue number $SQL = "SELECT idVehicle FROM VehicleReportedIssues WHERE idReportedIssues = :issue"; $statement = new Statement($connection); $statement->setInt('issue', $issue); $vehicle = $statement->select($SQL)->first()['idVehicle']; // insert the vehicle to maintenance $SQL = 'INSERT INTO Maintenance (_idVehicle, BriefDescription, MaintenanceEntryDate) VALUES (:vehicle, :description, CURRENT_TIMESTAMP)'; $statement = new Statement($connection); $statement->setInt('vehicle', $vehicle); $statement->setInt('description', $description); $log = $statement->insert($SQL); // update the reported issues table $SQL = 'UPDATE ReportedIssues SET _MaintenanceLogNumber = :log WHERE idReportedIssues = :issue'; $statement = new Statement($connection); $statement->setInt('log', $log); $statement->setInt('issue', $issue); $statement->update($SQL); header('Location:/mechanic'); }
public function complete($params) { $log = $params['log']; $mechanic = Session::get('id'); $SQL = 'UPDATE Maintenance SET _ReturnedBy = :mechanic, DateReturned = CURRENT_TIMESTAMP WHERE MaintenanceLogNumber = :log'; $statement = new Statement(new Connection()); $statement->setInt('log', $log); $statement->setInt('mechanic', $mechanic); $complete = $statement->update($SQL); if (!is_a($complete, "PDOException")) { header('Location:/mechanic'); } else { $data = ['error' => $complete->errorInfo[2], 'return' => "/maintenance/log/{$log}"]; $html = $this->view->render('Error', $data); $this->response->setContent($html); } }
public function update($params) { $log = $params['log']; $item = $params['item']; $mechanic = Session::get('id'); $description = $this->request->getParameter('description'); $SQL = 'UPDATE MaintenanceItem SET ItemDescription = :description WHERE idMaintenanceItem = :item'; $statement = new Statement(new Connection()); // $statement->setInt('mechanic', $mechanic); $statement->setInt('item', $item); $statement->setInt('description', $description); $statement->update($SQL); header("Location: /maintenance/log/{$log}"); }