valneyf

functions.php

Feb 22nd, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2.  
  3. require_once('../config.php');
  4. require_once(DBAPI);
  5.  
  6. $customers = null;
  7. $customer = null;
  8.  
  9. /**
  10.  *  Listagem de Clientes
  11.  */
  12. function index() {
  13.     global $customers;
  14.     $customers = find_all('customers');
  15. }
  16.  
  17. /**
  18.  *  Cadastro de Clientes
  19.  */
  20. function add() {
  21.   if (!empty($_POST['customer'])) {
  22.    
  23.     $today =
  24.       date_create('now', new DateTimeZone('America/Sao_Paulo'));
  25.     $customer = $_POST['customer'];
  26.     $customer['modified'] = $customer['created'] = $today->format("Y-m-d H:i:s");
  27.    
  28.     save('customers', $customer);
  29.     header('location: index.php');
  30.   }
  31. }
  32.  
  33. /**
  34.  *  Visualização de um Cliente
  35.  */
  36. function view($id = null) {
  37.   global $customer;
  38.   $customer = find('customers', $id);
  39. }
  40.  
  41. /**
  42.  *  Exclusão de um Cliente
  43.  */
  44. function delete($id = null) {
  45.   global $customer;
  46.   $customer = remove('customers', $id);
  47.   header('location: index.php');
  48. }
Add Comment
Please, Sign In to add comment