예제 #1
0
 */
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'config/config.php';
if (isset($_SESSION['authenticated'])) {
    if ($_SESSION['authenticated'] == true) {
        $addResult = null;
        $custCon = new CustomerController();
        $personCon = new PersonController();
        $addressCon = new AddressController();
        if (isset($_POST['hdnAction'])) {
            if ($_POST['hdnAction'] == 'insert') {
                if (!isset($_POST['chkMailingList'])) {
                    $chkMailingList = 0;
                } else {
                    $chkMailingList = $_POST['chkMailingList'];
                }
                $result = $personCon->insertPerson($_POST['txtFirstName'], $_POST['txtSurname'], $_POST['txtPhone'], $_POST['txtMobile'], $_POST['txtEmail'], $chkMailingList);
                $personId = $result['personId'];
                if ($result['stmt']->errorInfo()[2] == null) {
                    $custResult = $custCon->insertCustomer($personId);
                    if ($custResult->errorInfo()[2] == null) {
                        $addressResult = $addressCon->insertAddress($_POST['txtStreetAddress'], $_POST['txtSuburb'], $_POST['txtCity'], $_POST['txtPostcode'], $_POST['txtState'], $personId);
                        if ($addressResult->errorInfo()[2] == null) {
                            $addResult = true;
                        } else {
                            $addResult = $addressResult->errorInfo()[2];
                        }
                    } else {
                        $addResult = $custResult->errorInfo()[2];
                    }
                } else {
                    $addResult = $result['stmt']->errorInfo()[2];