public function update() { if ($_SERVER['REQUEST_METHOD'] === 'GET' and isset($_GET['id']) and is_numeric($_GET['id'])) { $certificate = modelClass::certifyId($_GET['id']); if (is_array($certificate)) { if (count($certificate) > 0) { $data = modelClass::getRow($_GET['id']); if (is_array($data)) { if (count($data) > 0) { $args['cod_centro'] = $data[0]['cod_centro']; $args['desc_centro'] = $data[0]['desc_centro']; $args['cod_ciudad'] = $data[0]['cod_ciudad']; $args['dir'] = $data[0]['dir']; $args['tel'] = $data[0]['tel']; $args['ciudad'] = modelClass::showCity(); } } else { $args['error'] = $data; viewClass::renderHTML('error.php', $args); } } } else { $args['error'] = $certificate; viewClass::renderHTML('error.php', $args); } $args['formAction'] = 'index.php?action=update&id=' . $_GET['id']; viewClass::renderHTML('update.php', $args); } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $data['cod_centro'] = $_POST['txtcod']; $data['desc_centro'] = $_POST['txtDesc']; $data['cod_ciudad'] = $_POST['txtCity']; $data['dir'] = $_POST['txtdir']; $data['tel'] = $_POST['txttel']; $rsp = modelClass::updateCentro($_GET['id'], $data); if ($rsp === true) { $args['success'] = 'Los cambios fueron realizados exitosamente'; } else { $args['error'] = $rsp->getMessage(); } $args['formAction'] = 'index.php?action=update&id=' . $_GET['id']; $args = array_merge($args, $_POST); viewClass::renderHTML('update.php', $args); } else { $this->index(); } }
public function create() { $args['ciudad'] = modelClass::showCity(); $args['ti'] = modelClass::showTypeId(); $args['rh'] = modelClass::getRh(); $template = 'create.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $rsp = modelClass::NewApre($_POST['txtId'], $_POST['txtName'], $_POST['txtLastName'], $_POST['txtPhone'], $_POST['txtCity'], $_POST['txtRh'], $_POST['txtTypeId'], $_POST['txtGender'], $_POST['txtAge']); if ($rsp === true) { $args['success'] = 'El registro fue realizado exitosamente'; $this->index($args); } else { $args['error'] = $rsp->getMessage(); $args['formAction'] = 'index.php=create'; $args = array_merge($args, $_POST); viewClass::renderHTML($template, $args); } } else { $args['formAction'] = 'index.php?action=create'; viewClass::renderHTML($template, $args); } }