Example #1
0
         display_error('State is required.');
     }
     if (strlen($state) > 2) {
         display_error('Use two-letter code for state.');
     }
     if (empty($zip)) {
         display_error('ZIP code is required.');
     }
     if (empty($phone)) {
         display_error('Phone number is required.');
     }
     // If the old address has orders, disable it
     // Otherwise, delete it
     disable_or_delete_address($address_id);
     // Add the new address
     $address_id = add_address($customer_id, $line1, $line2, $city, $state, $zip, $phone);
     // Relate the address to the customer account
     if ($billing) {
         customer_change_billing_id($customer_id, $address_id);
     } else {
         customer_change_shipping_id($customer_id, $address_id);
     }
     // Set the user data in the session
     $_SESSION['user'] = get_customer($customer_id);
     redirect('.');
     break;
 case 'logout':
     unset($_SESSION['user']);
     redirect('..');
     break;
 default:
    if (isset($_POST["addr_amphur"]) && !empty($_POST["addr_amphur"])) {
        $addr_amphur = $_POST["addr_amphur"];
    }
    if (isset($_POST["addr_district"]) && !empty($_POST["addr_district"])) {
        $addr_district = $_POST["addr_district"];
    }
    if (isset($_POST["addr_province"]) && !empty($_POST["addr_province"])) {
        $addr_province = $_POST["addr_province"];
    }
    if (isset($_POST["addr_zipcode"]) && !empty($_POST["addr_zipcode"])) {
        $addr_zipcode = $_POST["addr_zipcode"];
    }
    $new_id = get_address_id($addr_num, $addr_village, $addr_alley, $addr_moo, $addr_road, $addr_district, $addr_amphur, $addr_province, $addr_zipcode);
    if ($addr_id != $new_id) {
        del_address($id, $addr_id, $type);
        add_address($id, $addr_num, $addr_village, $addr_alley, $addr_moo, $addr_road, $addr_district, $addr_amphur, $addr_province, $addr_zipcode, $type);
    }
}
if (isset($_POST["organizationtype"]) && !empty($_POST["organizationtype"]) && $organization_id != 0) {
    $organization_sql = get_organization($id, $organization_id);
    $organization = mysql_fetch_assoc($organization_sql);
    if ($_POST["organizationtype"] != $organization["ORGANIZATION_TYPE_ID"]) {
        $query = "UPDATE `organization` SET `ORGANIZATION_TYPE_ID`='" . $_POST['organizationtype'] . "' WHERE `ID`={$organization_id}";
        mysql_query($query);
    }
}
if (isset($_POST["organization_comment"]) && !empty($_POST["organization_comment"]) && $organization_id != 0) {
    $organization_sql = get_organization($id, $organization_id);
    $organization = mysql_fetch_assoc($organization_sql);
    if ($_POST["organization_comment"] != $organization["ORGANIZATION_COMMENT"]) {
        $query = "UPDATE `organization` SET `ORGANIZATION_COMMENT`='" . $_POST['organization_comment'] . "' WHERE `ID`={$organization_id}";
Example #3
0
    //Validation DOB
    $validation_signup[DOB][VALUE] = filter_input(INPUT_POST, DOB, FILTER_SANITIZE_STRING);
    $date_of_birth = $validation_signup[DOB][VALUE];
    $validation_signup[DOB][IS_VALID] = 1 === preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $date_of_birth);
    $validation_signup[DOB][ERR_MSG] = $validation_signup[DOB][IS_VALID] ? VAL_MSG : ERR_MSG;
    $isFormValid = true;
    foreach ($validation_signup as $field) {
        if (!$field[IS_VALID]) {
            $isFormValid = false;
            break;
        }
    }
    if ($isFormValid) {
        require_once '_addresses.php';
        require_once '_user.php';
        $add_id = add_address($street_num, $street, $city, $province, $postal_code);
        // var_dump($add_id);
        add_user($add_id, $first_name, $last_name, $email, $pass);
        $_SESSION[FIRST_NAME] = $first_name;
        $_SESSION[U_ID] = add_user($add_id, $first_name, $last_name, $email, $pass);
        header('Location: index.php');
    }
}
/*if ($isFormValid) {
    echo 'le formulaire est valide';
} else {
    echo 'FORMULAIRE INCORRECT!!!';
}

var_dump($validation_signup);
echo '******************************';
Example #4
0
function add_address_to_wb_list($user_id, $addr, $wb)
{
    global $dbh;
    $matches = array();
    # look for an email address of the form <user@domain>
    if (preg_match('/<(\\S+\\@\\S+\\.\\S+)>/', $addr, $matches) > 0) {
        $addr = $matches[1];
    } elseif (preg_match("/(\\S+\\@\\S+\\.\\S+)/", $addr, $matches) > 0) {
        $addr = $matches[1];
    }
    $addr = fix_address($addr);
    $addr_id = get_address_id($addr);
    if (substr($addr, 0, 1) == '@') {
        $addr = "*" . $addr;
    }
    if ($addr_id == 0) {
        $addr_id = add_address($addr);
        add_wb_entry($user_id, $addr_id, $wb);
        return 'text_wb_address_added';
    } else {
        $wb_stat = get_wb_status($user_id, $addr_id);
        if ($wb_stat == '') {
            add_wb_entry($user_id, $addr_id, $wb);
            return 'text_wb_address_added';
        } else {
            if ($wb_stat != $wb) {
                set_wb_status($user_id, $addr_id, $wb);
            }
            return 'text_wb_address_changed';
        }
    }
}
// This file will have all the functions to interact with orders (creation, read, etc)
$function = 'unknown';
if (isset($_POST['function'])) {
    $function = $_POST['function'];
    $values = $_POST;
} elseif (isset($_GET['function'])) {
    $function = $_GET['function'];
    $values = $_GET;
} else {
    $values = (array) json_decode(file_get_contents('php://input'));
    $function = $values['function'];
}
switch ($function) {
    case 'add_address':
        include_once __DIR__ . '/customers/add_address.php';
        $responseArray['response'] = add_address($values);
        $responseArray['message'] = 'Address added';
        break;
    case 'get_addresses':
        include_once __DIR__ . '/customers/get_addresses.php';
        $responseArray['response'] = get_addresses($values);
        $responseArray['message'] = 'Addresses got';
        break;
    case 'update_address':
        include_once __DIR__ . '/customers/update_address.php';
        $responseArray['response'] = update_address($values);
        $responseArray['message'] = 'Address updated';
        break;
    case 'add_user':
        include_once __DIR__ . '/customers/add_user.php';
        $responseArray['response'] = add_user($values);
Example #6
0
function add_organization($data_id, $organizationtype, $organizationcomment, $organizationname, $organizationrole, $organization_num, $organization_village, $organization_alley, $organization_moo, $organization_road, $organization_district_id, $organization_amphur_id, $organization_province_id, $organization_zipcode)
{
    $time = date('Y-m-d H:i:s', time());
    $sql_organization = "SELECT * FROM `organization` WHERE `ORGANIZATION_NAME`='{$organizationname}'";
    $res = mysql_query($sql_organization);
    $result_organization = mysql_fetch_assoc($res);
    if (!$result_organization) {
        $sql = "INSERT INTO `organization`(`ORGANIZATION_NAME`, `ORGANIZATION_TYPE_ID`, `ORGANIZATION_COMMENT`) VALUES ('{$organizationname}','{$organizationtype}','{$organizationcomment}')";
        mysql_query($sql);
        $sql = mysql_query("SELECT * FROM `organization` ORDER BY id DESC LIMIT 1");
        while ($row = mysql_fetch_assoc($sql)) {
            $organization_id = $row['ID'];
        }
    } else {
        $res = mysql_query($sql_organization);
        while ($row = mysql_fetch_assoc($res)) {
            print_r($row);
            $organization_id = $row['ID'];
        }
    }
    add_address($organization_id, $organization_num, $organization_village, $organization_alley, $organization_moo, $organization_road, $organization_district_id, $organization_amphur_id, $organization_province_id, $organization_zipcode, 2);
    //-------------organization role-------------------//
    $sql_oraganizationrole = "INSERT INTO `organizationrole`(`PERSON_ID`, `ORGANIZATION_ID`, `ORGANIZATION_ROLE`, `ORGANIZATIONROLE_FROM_DATE`) VALUES ('{$data_id}','{$organization_id}','{$organizationrole}','{$time}')";
    mysql_query($sql_oraganizationrole);
    set_updatetime($data_id);
    return $organization_id;
}