function handler() { $event = VIEW_LIST; $uri = $_SERVER['REQUEST_URI']; $peticiones = array(SELECT_CASE, INSERT_CASE, UPDATE_CASE, DELETE_CASE, UPLOAD_CASE, INSERT_IMG_CASE, DELETE_IMG_CASE, VIEW_INSERT, VIEW_UPDATE, VIEW_UPLOAD, VIEW_LIST); foreach ($peticiones as $peticion) { $uri_peticion = MODULO . $peticion . '/'; if (strpos($uri, $uri_peticion) == true) { $event = $peticion; } } $data = helper_data(); $data_2 = helper_data_2(); $obj = set_obj(); switch ($event) { case SELECT_CASE: $obj->select($data); $dataArray = array('name' => $obj->name, 'id' => $obj->id); retornar_vista(VIEW_UPDATE, $dataArray); break; case INSERT_CASE: $obj->insert($data); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_INSERT, $dataArray); break; case UPDATE_CASE: $obj->update($data); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; case DELETE_CASE: $obj->delete($data['id']); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; case UPLOAD_CASE: $obj->select($data); $dataArray = array('name' => $obj->name, 'id' => $obj->id); retornar_vista(VIEW_UPLOAD, $dataArray); break; case INSERT_IMG_CASE: $obj->insert_img($data_2); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; case DELETE_IMG_CASE: $obj->delete_img($data_2['id']); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; default: retornar_vista($event); } }
function handler() { $event = VIEW_LIST; $uri = $_SERVER['REQUEST_URI']; $peticiones = array(SELECT_CASE, INSERT_CASE, UPDATE_CASE, DELETE_CASE, VIEW_INSERT, VIEW_UPDATE, VIEW_LIST); foreach ($peticiones as $peticion) { $uri_peticion = MODULO . $peticion . '/'; if (strpos($uri, $uri_peticion) == true) { $event = $peticion; } } $data = helper_data(); $obj = set_obj(); switch ($event) { case SELECT_CASE: $obj->select($data); $dataArray = array('holder_name' => $obj->holder_name, 'holder_email' => $obj->holder_email, 'holder_phone' => $obj->holder_phone, 'city' => $obj->city, 'date_reservation' => $obj->date_reservation, 'num_children' => $obj->num_children, 'num_adults' => $obj->num_adults, 'id_excursion' => $obj->id_excursion, 'observations' => $obj->observations, 'id' => $obj->id); retornar_vista(VIEW_UPDATE, $dataArray); break; case INSERT_CASE: $obj->insert($data); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_INSERT, $dataArray); break; case UPDATE_CASE: $obj->update($data); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; case DELETE_CASE: $obj->delete($data['id']); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; default: retornar_vista($event); } }
function handler() { $event = VIEW_LIST; $uri = $_SERVER['REQUEST_URI']; $peticiones = array(SELECT_CASE, INSERT_CASE, UPDATE_CASE, DELETE_CASE, VIEW_INSERT, VIEW_UPDATE, VIEW_LIST); foreach ($peticiones as $peticion) { $uri_peticion = MODULO . $peticion . '/'; if (strpos($uri, $uri_peticion) == true) { $event = $peticion; } } $data = helper_data(); $obj = set_obj(); switch ($event) { case SELECT_CASE: $obj->select($data); $dataArray = array('name' => $obj->name, 'description' => $obj->description, 'price_child' => $obj->price_child, 'price_adult' => $obj->price_adult, 'date_departure' => $obj->date_departure, 'date_return' => $obj->date_return, 'id_category' => $obj->id_category, 'id' => $obj->id); retornar_vista(VIEW_UPDATE, $dataArray); break; case INSERT_CASE: $obj->insert($data); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_INSERT, $dataArray); break; case UPDATE_CASE: $obj->update($data); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; case DELETE_CASE: $obj->delete($data['id']); $dataArray = array('mensaje' => $obj->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; default: retornar_vista($event); } }
function handler() { $event = VIEW_LIST; $uri = $_SERVER['REQUEST_URI']; $peticiones = array(RESERVATION_CASE, QUOTE_CASE, INSERT_CASE, OP_CASE, VIEW_RESERVATION, VIEW_QUOTE, VIEW_LIST); foreach ($peticiones as $peticion) { $uri_peticion = MODULO . $peticion . '/'; if (strpos($uri, $uri_peticion) == true) { $event = $peticion; } } $data = helper_data(); $obj = set_obj(); $obj_2 = set_obj_2(); switch ($event) { case RESERVATION_CASE: $obj->select($data); $dataArray = array('name' => $obj->name, 'id' => $obj->id); retornar_vista(VIEW_RESERVATION, $dataArray); break; case QUOTE_CASE: $obj->select($data); $dataArray = array('name' => $obj->name, 'price_child' => $obj->price_child, 'price_adult' => $obj->price_adult, 'id' => $obj->id); retornar_vista(VIEW_QUOTE, $dataArray); break; case INSERT_CASE: $obj_2->insert($data); $dataArray = array('mensaje' => $obj_2->mensaje); retornar_vista(VIEW_LIST, $dataArray); break; case OP_CASE: retornar_vista(VIEW_QUOTE, $dataArray); break; default: retornar_vista($event); } }