Пример #1
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
include_once '../../inc/functions.inc';
$return = array();
$method = ifsetor($_POST['method']);
$data = ifsetor($_POST['data']);
if ($method === 'validateSerialNumber') {
    // Clean serial number
    $data['serial_number'] = ltrim($data['serial_number'], '0');
    // Make sure SN doesn't already exist in session array
    if (!snExists($data['serial_number'])) {
        // API call
        $return = validateSn($data['serial_number']);
        if ($return['serial_number']) {
            // Serial number is valid if:
            // 1. Product data is returned 2. No R account exists
            if (!$return['r_account']) {
                if (!isset($_SESSION['registration']['products'])) {
                    $_SESSION['registration']['products'] = array();
                }
                // Run snRules function
                $product = snRules($return);
                // Set product purchase date (based on customer entry)
                $product['date_of_purchase'] = $data['date_of_purchase'];
                $product['uploaded_file'] = '';
                array_push($_SESSION['registration']['products'], $product);
                // Run Vac Warranty Opt In function
                $opt_in = $_SESSION['registration']['opt_in'];
Пример #2
0
 $products = array();
 $today = date_create();
 // POSTed data
 $data = $_POST;
 // Customer properties - key matching from center sale application
 $customer_properties = array('customer_account' => 'r_account', 'first_name' => 'firstname', 'last_name' => 'lastname', 'address_1' => 'street_address', 'address_2' => 'street_address_2', 'address_3' => 'address_3', 'city' => 'city', 'state' => 'state', 'zip' => 'zip', 'zip4' => 'zip4', 'email' => 'email', 'phone_1' => 'phone');
 // Store customer data
 foreach ($customer_properties as $key => $value) {
     $customer[$value] = isset($data[$key]) ? $data[$key] : '';
 }
 // Unset customer account (sundry account passed from Center Sales Application)
 // Perform AMS lookup
 $ams_lookup = __amsCustomerLookup($customer);
 $customer['r_account'] = isset($ams_lookup['r_account']) ? $ams_lookup['r_account'] : '';
 // Validate Serial Number
 $product = validateSn($data['scan_serial_number']);
 if (isset($product['serial_number'])) {
     $product['date_of_purchase'] = date_format($today, 'm/d/Y');
     $product['uploaded_file'] = '';
     $product['order_number'] = $data['order_number'];
     array_push($products, $product);
 } else {
     $error = 'Invalid serial number ' . $data['scan_serial_number'] . '. Please contact Miele IT.';
 }
 if (!isset($error)) {
     // Set registration data
     $registration = array('customer' => $customer, 'products' => $products);
     $_SESSION['registration'] = $registration;
     $return = $registration;
     header('Location: /registration/?step=products');
 } else {