private function edit() { if (empty($_GET['id'])) { $this->show_all(); } else { if (empty($_POST)) { $id_employee = $_GET['id']; $employee = $this->model->get($id_employee); if ($employee) { $section = file_get_contents('Views/Employee/edit.html'); $dicc = array('{id}' => $employee['id_employee'], '{nombre}' => $employee['emp_name'], '{apellido}' => $employee['emp_last_name'], '{RFC}' => $employee['RFC'], '{email}' => $employee['emp_email'], '{telefono}' => $employee['emp_phone'], '{celular}' => $employee['emp_cellpone'], '{direcccion}' => $employee['address'], '{colonia}' => $employee['colony']); $section = strtr($section, $dicc); $this->template($section); } else { echo 'no existe ese empleado para editarlo'; } } else { $id_employee = $_GET['id']; require_once "Controllers/Validaciones.php"; $name = validateName($_POST['name']); $last_name = validateName($_POST['last_name']); $RFC = validateRFC($_POST['RFC']); $email = validateEmail($_POST['email']); $phone = $_POST['phone']; $cellphone = $_POST['cellphone']; $address = $_POST['address']; $colony = validateText($_POST['colony']); $city = $_POST['city']; $employee = new Employee($name, $last_name, $RFC, $email, $phone, $cellphone, $address, $colony, $city); $result = $this->model->edit($employee, $id_employee); if ($result) { $this->show_message("success", "El empleado se edito correctamente"); } else { $this->show_message("danger", "No se edito no puede haber duplicados en el correo o el RFC"); } } } }
private function edit() { if (empty($_GET['id'])) { $this->show_all(); } else { if (empty($_POST)) { $id_client = $_GET['id']; $client = $this->model->get($id_client); if ($client) { $section = file_get_contents('Views/Client/edit.html'); $dicc = array('{id}' => $client['id_client'], '{nombre}' => $client['client_name'], '{RFC}' => $client['client_RFC'], '{email}' => $client['client_emai'], '{telefono}' => $client['client_phone'], '{celular}' => $client['client_cellphone']); $section = strtr($section, $dicc); $this->template($section); } else { echo 'no existe ese empleado para editarlo'; } } else { $id_client = $_GET['id']; require_once "Controllers/Validaciones.php"; $name = validateName($_POST['name']); $RFC = validateRFC($_POST['RFC']); $email = validateEmail($_POST['email']); $phone = $_POST['phone']; $cellphone = $_POST['cellphone']; $client = new Client($name, $RFC, $email, $phone, $cellphone); $result = $this->model->edit($client, $id_client); if ($result) { $this->show_message("success", "El cliente se edito correctamente"); } else { $this->show_message("danger", "No se edito no puede haber duplicados en el nombre o el correo"); } } } }