Esempio n. 1
0
<?php

$addressManager = new AddressManager($db);
try {
    $address = $addressManager->findByIdUser($currentUser->getId());
} catch (Exception $e) {
    $address = $e->getMessage();
}
$ship_address = $ship_postal_code = $ship_city = $ship_region = $ship_country = $bill_address = $bill_postal_code = $bill_city = $bill_region = $bill_country = "";
if (is_object($address)) {
    $ship_address = $address->getShipAddress();
    $ship_postal_code = $address->getShipPostalCode();
    $ship_city = $address->getShipCity();
    $ship_region = $address->getShipRegion();
    $ship_country = $address->getShipCountry();
    $bill_address = $address->getBillAddress();
    $bill_postal_code = $address->getBillPostalCode();
    $bill_city = $address->getBillCity();
    $bill_region = $address->getBillRegion();
    $bill_country = $address->getBillCountry();
}
require 'views/edit_address.phtml';
Esempio n. 2
0
 try {
     $retour = $addressManager->findByIdUser($currentUser->getId());
 } catch (Exception $e) {
     $retour = $e->getMessage();
 }
 if (is_string($retour)) {
     $retour = $addressManager->create($currentUser, $_POST['ship_address'], $_POST['ship_city'], $_POST['ship_postal_code'], $_POST['ship_region'], $_POST['ship_country'], $_POST['bill_address'], $_POST['bill_city'], $_POST['bill_postal_code'], $_POST['bill_region'], $_POST['bill_country']);
     if (is_string($retour)) {
         $errors = array_merge($errors, $retour);
     } else {
         header('Location: index.php?page=profil');
         exit;
     }
 } else {
     $addressManager = new AddressManager($db);
     $address = $addressManager->findByIdUser($_SESSION['id']);
     $address->setShipAddress($_POST['ship_address']);
     $address->setShipCity($_POST['ship_city']);
     $address->setShipPostalCode($_POST['ship_postal_code']);
     $address->setShipRegion($_POST['ship_region']);
     $address->setShipCountry($_POST['ship_country']);
     $address->setBillAddress($_POST['bill_address']);
     $address->setBillCity($_POST['bill_city']);
     $address->setBillPostalCode($_POST['bill_postal_code']);
     $address->setBillRegion($_POST['bill_region']);
     $address->setBillCountry($_POST['bill_country']);
     $retour = $addressManager->update($address);
     if (is_array($retour)) {
         $errors = array_merge($errors, $retour);
     } else {
         $_SESSION['success'] = 'Your informations has been updated';