header("Pragma: no-cache"); // HTTP 1.0. header("Expires: 0"); // Proxies. error_reporting(E_ALL); ini_set("display_errors", 1); require_once 'main.php'; require_once 'Connection.class.php'; require_once 'WorkshopDAO.class.php'; $id = isset($_GET['id']) ? $_GET['id'] : false; if (empty($id)) { die('Id not supplied'); } $c = new Connection(); $conn = $c->getConnection(); $workshopDAO = new WorkshopDAO($conn); $workshop = $workshopDAO->select($id); include 'head.php'; ?> <div class="row"> <div class="col-xs-12 view-page"> <h1>Fitxa de taller</h1> <table class="table"> <tr> <td>Grup</td> <td><?php
if (empty($group_id)) { die('Grup no informat'); } if (empty($workshop_date)) { die('Data no informada'); } if (!empty($favourite) && $favourite !== 'n' && empty($age)) { die("Grup d'edat no informat"); } $activities = isset($_POST['activity']) ? $_POST['activity'] : array(); $workshop = array('id' => $id, 'workshop_date' => $workshop_date, 'group_id' => $group_id, 'observations' => $observations, 'comments' => $comments, 'favourite' => $favourite, 'age' => join(',', $age), 'activities' => $activities); break; } $c = new Connection(); $conn = $c->getConnection(); $workshopDAO = new WorkshopDAO($conn); switch ($action) { case 'new': $insert_id = $workshopDAO->create($workshop); if (count(flatten($activities)) > 0) { $workshopDAO->linkActivities($insert_id, $activities); } break; case 'update': $workshopDAO->update($workshop); $workshopDAO->unlinkActivities($workshop['id']); if (count(flatten($activities)) > 0) { $workshopDAO->linkActivities($workshop['id'], $activities); } break; case 'delete':