/** * Funcion de clienteEditar a nivel comercio * * La funcion clienteEditar se implementa a nivel Comercio, la cual * actualiza un cliente registrado previamente, utiliza la clase Cliente. * * @author Christian Hernandez <*****@*****.**> * @version 1.0 * @copyright MásNegocio * * @param $idCustomer es el Id del cliente que se actualizara * */ function clienteEditar($idCustomer = "") { $app = Slim::getInstance(); try { $app->log->info("Servicio cliente - Editar - Inicializando"); $cliente = new Cliente(); $cliente->actualizar($idCustomer, $app->request()->params()); $response = $cliente->__get("response"); $app->log->info("Servicio cliente - Editar - Proceso Completo "); $app->response->setStatus(204); } catch (Exception $e) { $app->log->info("Servicio cliente - Editar - Proceso Incompleto "); $app->log->info("Servicio cliente - Editar - " . $e->getMessage()); $response = $cliente->__response(); if ($e->getCode() == 3000) { $response['message'] = $e->getMessage(); } $app->log->info(print_r($response, true)); //$app->response->setStatus(400); } $jsonStr = json_encode($response); $app->log->info("Servicio cliente - Editar - Response \n->{$jsonStr}<-"); $app->response->headers->set('Content-Type', 'application/json'); $app->response->body($jsonStr); $app->stop(); }
<th>Telefone</th> <th>Data Nascimento</th> <th colspan="2">Ações <a href="cliente.php?op=I" class="btn btn-success">Novo</a></th> </tr> </thead> <tbody> <?php $dao = new ClienteDAO(new Cliente()); $tabela = $dao->listar(); foreach ($tabela as $row) { $cli = new Cliente($row); ?> <tr> <td><?php echo $cli->__get('id'); ?> </td> <td><a href="../controller/clienteController.php?op=U&id=<?php echo $cli->__get('id'); ?> "><?php echo $cli->__get('nome'); ?> </a></td> <td><?php echo $cli->__get('telefone'); ?> </td> <td><?php echo $cli->__get('dataNasc');
<?php function __autoload($classe) { @(include "../model/{$classe}.php"); @(include "../model/helpers/{$classe}.php"); } session_start(); $cli = new Cliente($_REQUEST); $dao = new ClienteDAO($cli); $validado = true; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Aplicar validator CPF if (!empty($cli->__get('cpf'))) { $validado = Validator::validaCPF($cli->__get('cpf')); } if ($validado) { $dao->salvar(); header('Location:../view/cliente.php?op=L'); } else { $_SESSION['msg'] = 'Cpf inválido!'; header('Location:../view/cliente.php?op=F'); } } else { if ($_GET['op'] == 'D') { // "Excluir" $dao->excluir(); header('Location:../view/cliente.php?op=L'); } else { if ($_GET['op'] == 'U') { $cli = $dao->buscar();
<?php if ($_GET['op'] == 'I') { $id = ''; $nome = ''; $cpf = ''; $sexo = ''; $dataNasc = ''; $telefone = ''; $endereco = ''; $op = 'I'; } else { $cli = new Cliente($_SESSION['obj']); $id = $cli->__get('id'); $nome = $cli->__get('nome'); $cpf = $cli->__get('cpf'); $sexo = $cli->__get('sexo'); $dataNasc = $cli->__get('dataNasc'); $telefone = $cli->__get('telefone'); $endereco = $cli->__get('endereco'); $op = 'U'; } ?> <form class="form-horizontal" action="../controller/clienteController.php" method="post"> <fieldset> <div id="legend" class=""> <legend class="">Cadastro do Cliente</legend> </div> <div class="control-group">