function cw_fbauth_user_login($user)
{
    global $tables, $current_area;
    cw_load('crypt', 'user', 'mail');
    $user_data = cw_query_first("SELECT customer_id, email, password\n\t\t\t\t\t\t\t\t\tFROM {$tables['customers']} \n\t\t\t\t\t\t\t\t\tWHERE oauth_uid='" . $user['id'] . "' AND oauth_type='F'  \n\t\t\t\t\t\t\t\t\t\tAND usertype='" . $current_area . "' \n\t\t\t\t\t\t\t\t\t\tAND status='Y'");
    if (!empty($user_data)) {
        // login user
        global $email, $password, $action;
        $email = $user_data['email'];
        $password = text_decrypt($user_data['password']);
        $action = 'login';
        cw_include('include/login.php');
    } else {
        // create user
        $register = array();
        $register['email'] = $user['email'];
        if (strpos($user['email'], "proxymail.facebook.com") !== FALSE) {
            cw_header_location("index.php?target=fb_auth_get_email", TRUE);
        }
        $register['password'] = $register['password2'] = md5(uniqid('cw_', TRUE), TRUE);
        $register['usertype'] = $current_area;
        $partner_membership =& cw_session_register('partner_membership');
        $register['membership_id'] = $partner_membership;
        $customer_id = cw_user_create_profile($register);
        $identifiers =& cw_session_register('identifiers', array());
        $identifiers[$current_area] = array('customer_id' => $customer_id);
        $customer = array('oauth_uid' => $user['id']);
        cw_array2update('customers', $customer, "customer_id='{$customer_id}'");
        $address = array('main' => 1, 'firstname' => $user['first_name'], 'lastname' => $user['last_name']);
        $additional_info = array('sex' => $user['gender'] == 'male' ? 1 : 0);
        $userinfo = array('addresses' => $address, 'additional_info' => $additional_info);
        cw_user_update($userinfo, $customer_id, $customer_id);
        cw_user_send_modification_mail($customer_id, TRUE);
    }
}
function cw_import_users($xcart_conf)
{
    cw_load('crypt', 'user');
    extract($xcart_conf);
    extract(cw_vers_diff_attr($conn));
    fout("<br /><br />Import of Users...<br />");
    if ($clean_users) {
        $cw_admins = cw_query("select * from cw_customers u left join cw_customers_addresses a\n\t\t\ton u.customer_id=a.customer_id and a.main=1 where u.usertype='A'");
        db_query("TRUNCATE TABLE cw_customers");
        db_query("TRUNCATE TABLE cw_customers_system_info");
        db_query("TRUNCATE TABLE cw_customers_customer_info");
    }
    $users_per_run = 500;
    global $page;
    if (!isset($page)) {
        $page = 1;
    }
    $users_offset = $users_per_run * ($page - 1);
    $users_count = $users_per_run;
    $where_ids_range = "WHERE id > 58965";
    $users = cw_query("select * from xcart_customers {$where_ids_range} order by usertype in ('P','A') desc, login=email desc limit {$users_offset}, {$users_count}", $conn);
    $users_count = count($users);
    $processed_customers = array();
    $i = 1;
    $em = array();
    $user_ind = array();
    foreach ($users as $k => $v) {
        $v['password'] = cw_user_get_hashed_password(text_decrypt($v['password'], $blowfish_key));
        extract($v);
        $membership_id = $membershipid;
        //$email=$login;
        if ($uwithid) {
            $customer_id = $id;
        } else {
            $customer_id = $i++;
        }
        $processed_customers[] = $id;
        $language = strtoupper($language);
        if (in_array($email, $em)) {
            $log = str_replace(" ", "-", $login);
            $email = "{$log}-{$email}";
            $users[$k]['email'] = "{$log}-{$email}";
        }
        $em[] = $email;
        if ($usertype == 'A' || $usertype == 'P') {
            $usertype = 'A';
        } else {
            $usertype = 'C';
        }
        $arr = compact('customer_id', 'usertype', 'password', 'email', 'status', 'membership_id', 'language');
        $usrs[$customer_id] = $arr;
        cw_array2insert_esc('cw_customers', $arr);
        $creation_customer_id = $customer_id;
        $creation_date = $first_login;
        //time();
        $modification_customer_id = $customer_id;
        $modification_date = time();
        //$last_login=time(); - already extracted
        $arr = compact('customer_id', 'creation_customer_id', 'creation_date', 'modification_customer_id', 'modification_date', 'last_login');
        cw_array2insert_esc('cw_customers_system_info', $arr);
        $web_user = 1;
        cw_array2insert_esc('cw_customers_customer_info', compact('customer_id', 'web_user'));
        $ul[] = $email;
        $companies[$customer_id] = $company;
        $user_ind[$login] = $customer_id;
        $users[$k]['userid'] = $customer_id;
        fout();
    }
    fout("<br /><br />Import of an Address Book...<br />");
    if ($clean_users) {
        db_query("TRUNCATE TABLE cw_customers_addresses");
    }
    //$i=10000; //address book id start
    if ($withab) {
        $addresses = cw_query("select * from xcart_address_book where userid in ('" . implode("','", $processed_customers) . "')", $conn);
    } else {
        foreach ($users as $v) {
            extract($v);
            if ($b_firstname != '' || 1) {
                //$id=$i++;
                $firstname = $b_firstname;
                $lastname = $b_lastname;
                $address = $b_address;
                $city = $b_city;
                $county = $b_county;
                $state = $b_state;
                $country = $b_country;
                $zipcode = $b_zipcode;
                $default_b = 'Y';
                $default_s = 'N';
                $addresses[] = compact('id', 'userid', 'firstname', 'lastname', 'address', 'city', 'county', 'state', 'country', 'zipcode', 'default_b', 'default_s', 'phone', 'fax');
            }
            if ($s_firstname != '' || 1) {
                //$id=$i++;
                $firstname = $s_firstname;
                $lastname = $s_lastname;
                $address = $s_address;
                $city = $s_city;
                $county = $s_county;
                $state = $s_state;
                $country = $s_country;
                $zipcode = $s_zipcode;
                $default_b = 'N';
                $default_s = 'Y';
                $addresses[] = compact('id', 'userid', 'firstname', 'lastname', 'address', 'city', 'county', 'state', 'country', 'zipcode', 'default_b', 'default_s', 'phone', 'fax');
            }
        }
    }
    unset($users);
    $cust_addr_ids = array();
    foreach ($addresses as $v) {
        extract($v);
        $address_id = $id;
        $customer_id = $userid;
        $region = $county;
        $main = $default_b == 'Y' ? 1 : 0;
        $current = $default_s == 'Y' ? 1 : 0;
        if (isset($companies[$customer_id])) {
            $company = $companies[$customer_id];
        } else {
            $company = '';
        }
        $arr = compact('address_id', 'customer_id', 'main', 'current', 'firstname', 'lastname', 'address', 'city', 'state', 'country', 'region', 'zipcode', 'phone', 'fax', 'company');
        cw_array2insert_esc('cw_customers_addresses', $arr);
        $cust_addr_ids[$customer_id] = array();
        if ($main) {
            $cust_addr_ids[$customer_id]['main'] = $address_id;
        }
        if ($current) {
            $cust_addr_ids[$customer_id]['current'] = $address_id;
        }
        fout();
    }
    unset($addresses);
    if (isset($cw_admins) && is_array($cw_admins) && !empty($cw_admins)) {
        $uid = intval(cw_query_first_cell("select customer_id from cw_customers order by customer_id desc limit 1")) + 1;
        foreach ($cw_admins as $v) {
            if (!in_array($v['email'], $ul)) {
                $v['customer_id'] = $uid;
                extract($v);
                compact('customer_id', 'usertype', 'password', 'email', 'status', 'membership_id', 'language');
                cw_array2insert_esc('cw_customers', $v);
                $ul[] = $v['email'];
                $creation_date = time();
                $creation_customer_id = $customer_id;
                $modification_customer_id = $customer_id;
                $modification_date = time();
                $last_login = time();
                $arr = compact('customer_id', 'creation_customer_id', 'creation_date', 'modification_customer_id', 'modification_date', 'last_login');
                cw_array2insert_esc('cw_customers_system_info', $arr);
                $web_user = 1;
                cw_array2insert_esc('cw_customers_customer_info', compact('customer_id', 'web_user'));
                if (!isset($firstname) || ($firstname = '')) {
                    $firstname = 'Admin';
                }
                if (!isset($lastname) || ($lastname = '')) {
                    $lastname = 'Admin';
                }
                $main = 1;
                $arr = compact('customer_id', 'main', 'current', 'firstname', 'lastname', 'address', 'state', 'country', 'region', 'zipcode', 'phone', 'fax', 'company');
                cw_array2insert_esc('cw_customers_addresses', $arr);
                $uid++;
            }
        }
    }
    // wishlists
    /*
    	$wishlist=cw_query("select * from xcart_wishlist",$conn);
    	db_query ("TRUNCATE TABLE cw_wishlist");
    	foreach ($wishlist as $v) {
    		extract($v);
    		if ($uwithid) $customer_id=$userid; else $customer_id=$user_ind[$login];
    		$wishlist_id=$wishlistid; $product_id=$productid;
    		$arr=compact('wishlist_id','customer_id','product_id','amount','amount_purchased','options','event_id','object');
    		cw_array2insert_esc ('cw_wishlist',$arr);
    		fout();
    	}
    */
    fout("<br /><br />Import of Orders & Invoices...<br />");
    //print_r($cust_addr_ids);
    // orders, invoices
    if ($clean_docs) {
        db_query("TRUNCATE TABLE cw_docs");
        db_query("TRUNCATE TABLE cw_docs_info");
        db_query("TRUNCATE TABLE cw_docs_settings");
        db_query("TRUNCATE TABLE cw_docs_user_info");
    }
    $orders_per_run = 250;
    $orders_offset = $orders_per_run * ($page - 1);
    $orders_count = $orders_per_run;
    $where_orderids_range = "WHERE orderid > 63375";
    $orders = cw_query("select * from xcart_orders {$where_orderids_range} limit {$orders_offset}, {$orders_count}", $conn);
    $orders_count = count($orders);
    $doc_ids = array();
    $processed_orders = array();
    //$doc_id=$doc_info_id=1;
    $type = "O";
    //$_display_id=$_display_doc_id=1;
    foreach ($orders as $v) {
        extract($v);
        //$doc_ids[$orderid]=$doc_id;
        $doc_id = $orderid;
        $processed_orders[] = $orderid;
        $doc_info_id = $doc_id;
        $doc_ids[$orderid] = $orderid;
        $year = date("Y", $date);
        $display_id = "SW " . $doc_id;
        $display_doc_id = $doc_id;
        $arr = compact('doc_id', 'doc_info_id', 'type', 'display_id', 'display_doc_id', 'year', 'date', 'status');
        cw_array2insert_esc('cw_docs', $arr);
        $payment_id = $paymentid;
        $display_total = $total;
        $display_subtotal = $subtotal;
        $shipping_id = $shippingid;
        $details = cw_crypt_text(text_decrypt($details, $blowfish_key));
        $applied_taxes = $taxes_applied;
        $shipping_id = $shippingid;
        $display_shipping_cost = $shipping_cost;
        $shipping_label = isset($shipping) ? $shipping : '';
        $payment_label = $payment_method;
        $discount_value = $discount;
        $arr = compact('doc_info_id', 'total', 'display_total', 'subtotal', 'display_subtotal', 'extra', 'details', 'payment_id', 'shipping_id', 'shipping_cost', 'notes', 'tax', 'applied_taxes', 'customer_notes', 'payment_label', 'payment_surcharge', 'shipping_id', 'shipping_cost', 'display_shipping_cost', 'shipping_label', 'giftcert_discount', 'coupon', 'coupon_discount', 'discount', 'discount_value');
        cw_array2insert_esc('cw_docs_info', $arr);
        $show_price = 0;
        $arr = compact('doc_info_id', 'show_price');
        cw_array2insert_esc('cw_docs_settings', $arr);
        if ($uwithid) {
            $customer_id = $userid;
        } else {
            $customer_id = $user_ind[$login];
        }
        $cust_inf = cw_query_first("select c.usertype, c.email from cw_customers where customer_id='{$customer_id}'");
        $usertype = $cust_inf['usertype'];
        $email = $cust_inf['email'];
        $main_address_id = cw_query_first_cell("select address_id from cw_customers_addresses where customer_id='{$customer_id}' and main=1");
        $current_address_id = cw_query_first_cell("select address_id from cw_customers_addresses where customer_id='{$customer_id}' and current=1");
        /*
        		$usertype=$usrs[$customer_id]['usertype'];
        		if (isset($cust_addr_ids[$customer_id]['main']))
        			$main_address_id=$cust_addr_ids[$customer_id]['main']; else $main_address_id=0;
        		if (isset($cust_addr_ids[$customer_id]['current']))
        			$current_address_id=$cust_addr_ids[$customer_id]['current']; else $current_address_id=0;
        		$email=$usrs[$customer_id]['email'];
        */
        $arr = compact('doc_info_id', 'customer_id', 'usertype', 'main_address_id', 'current_address_id', 'email', 'tax_number', 'tax_exempt');
        cw_array2insert_esc('cw_docs_user_info', $arr);
        $display_id++;
        $display_doc_id++;
        $doc_id++;
        $doc_info_id++;
        fout();
    }
    unset($orders);
    unset($usrs);
    if ($clean_docs) {
        db_query("TRUNCATE TABLE cw_docs_items");
    }
    $details = cw_query("select * from xcart_order_details where orderid in ('" . implode("','", $processed_orders) . "')", $conn);
    foreach ($details as $v) {
        extract($v);
        $item_id = $itemid;
        $doc_id = $doc_ids[$orderid];
        $product_id = $productid;
        if ($uwithid) {
            $warehouse_customer_id = $provider;
        } else {
            $warehouse_customer_id = $user_ind[$provider];
        }
        $arr = compact('item_id', 'doc_id', 'product_id', 'productcode', 'product', 'product_options', 'price', 'amount', 'extra_data', 'warehouse_customer_id');
        cw_array2insert_esc('cw_docs_items', $arr);
    }
    if ($users_count || $orders_count) {
        return $page + 1;
    } else {
        return 0;
    }
}
function cw_user_get_current_ccinfo($customer_id)
{
    global $tables;
    $cc_info = cw_query_first("select * from {$tables['customers_ccinfo']} where customer_id='{$customer_id}'");
    if ($cc_info) {
        $cc_info['card_number'] = text_decrypt($cc_info['card_number']);
        if (is_null($cc_info['card_number'])) {
            cw_log_flag("log_decrypt_errors", "DECRYPT", " Could not decrypt the field 'Card number' for the user " . $userinfo['customer_id'], true);
        }
        $cc_info['card_cvv2'] = text_decrypt($cc_info['card_cvv2']);
        if (is_null($cc_info['card_cvv2'])) {
            cw_log_flag("log_decrypt_errors", "DECRYPT", " Could not decrypt the field 'Card CVV2' for the user " . $userinfo['customer_id'], true);
        }
    }
    return $cc_info;
}
Esempio n. 4
0
function sendUserInformation($params)
{
    if (isset($params["email"])) {
        $sendParams;
        $sql = "SELECT * from user";
        $sql .= " WHERE email=:email ";
        $sendParams['email'] = $params['email'];
        $result = queryDatabase($sql, $sendParams);
        $count = 0;
        while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
            $count++;
            $body = "Here is your requested user information.\r\n";
            $body .= "username: "******"username"] . "\r\n";
            $body .= "password: "******"password"]) . "\r\n \r\n";
            $email = $row["email"];
        }
        if ($count == 1) {
            $headers = "From: mig@themapoffice.com \r\n";
            $headers .= "Content-Type: text/plain; charset=UTF-8";
            $headers .= "MIME-Version: 1.0 ";
            mail($email, "Your MiG account information", $body, $headers);
            sendSuccess();
        } else {
            if ($count == 0) {
                die("No such email");
            } else {
                die("Contact System administrator");
            }
        }
    } else {
        die("No email was provided");
    }
}
function cw_doc_get($doc_id, $info_type = 0)
{
    global $tables;
    global $config, $addons;
    global $app_main_dir;
    global $smarty;
    cw_load('warehouse', 'profile_fields');
    $doc = cw_query_first("select * from {$tables['docs']} where doc_id='{$doc_id}'");
    $doc['info'] = cw_query_first("select * from {$tables['docs_info']} where doc_info_id='{$doc['doc_info_id']}'");
    $doc['info']['carrier'] = cw_call('cw_shipping_get_carrier', array($doc['info']['shipping_id']));
    $doc['info']['applied_taxes'] = unserialize($doc['info']['applied_taxes']);
    $doc['info']['extra'] = unserialize($doc['info']['extra']);
    $doc['info']['extras'] = cw_call('cw_doc_get_extras_data', array($doc_id));
    $doc['userinfo'] = cw_query_first("select * from {$tables['docs_user_info']} where doc_info_id='{$doc['doc_info_id']}'");
    $doc['userinfo']['main_address'] = cw_user_get_address(null, $doc['userinfo']['main_address_id']);
    $doc['userinfo']['current_address'] = cw_user_get_address(null, $doc['userinfo']['current_address_id']);
    $fields_area = cw_profile_fields_get_area($doc['userinfo']['customer_id'], $doc['userinfo']['membership_id']);
    list($profile_sections, $profile_fields, $additional_fields) = cw_profile_fields_get_sections('U', true, $fields_area);
    $doc['userinfo']['profile_sections'] = $profile_sections;
    $doc['userinfo']['profile_fields'] = $profile_fields;
    $doc['related_docs'] = cw_doc_get_related($doc_id);
    $doc['settings'] = cw_doc_get_settings($doc['doc_info_id']);
    if ($addons['egoods']) {
        $join .= " left join {$tables['download_keys']} ON {$tables['docs_items']}.item_id={$tables['download_keys']}.item_id AND {$tables['download_keys']}.product_id={$tables['docs_items']}.product_id";
        $fields .= ", {$tables['download_keys']}.download_key, {$tables['download_keys']}.expires";
    }
    $join .= " left join {$tables['products_system_info']} on {$tables['products_system_info']}.product_id={$tables['docs_items']}.product_id";
    $fields .= ", {$tables['products_system_info']}.supplier_customer_id";
    $products = cw_query("select {$tables['products']}.*, {$tables['products']}.productcode as sku, {$tables['docs_items']}.*, IF({$tables['products']}.product_id IS NULL, 'Y', '') as is_deleted, IF({$tables['docs_items']}.product = '', {$tables['products']}.product, {$tables['docs_items']}.product) as product {$fields} FROM {$tables['docs_items']} LEFT JOIN {$tables['products']} ON {$tables['docs_items']}.product_id = {$tables['products']}.product_id {$join} WHERE {$tables['docs_items']}.doc_id='{$doc_id}'");
    $products = cw_doc_translate_products($products, $doc['info']['language']);
    $is_returns = false;
    cw_load('warehouse');
    $gift_doc_ids = cw_doc_get_related_docs($doc_id);
    $gift_doc_ids = array_unique(array_merge($gift_doc_ids, array($doc_id)));
    $giftcerts = cw_query("SELECT * {$gc_add_date} FROM {$tables['giftcerts']} WHERE doc_id in ('" . implode(',', $gift_doc_ids) . "')");
    if (!empty($giftcerts) && $config['General']['use_counties'] == "Y") {
        foreach ($giftcerts as $k => $v) {
            if (!empty($v['recipient_county'])) {
                $giftcerts[$k]['recipient_countyname'] = cw_get_county($v['recipient_county']);
            }
        }
    }
    $doc['giftcerts'] = $giftcerts;
    if ($doc['info']['giftcert_ids']) {
        $doc['info']['applied_giftcerts'] = explode('*', $doc['info']['giftcert_ids']);
        if ($doc['info']['applied_giftcerts']) {
            $tmp = array();
            foreach ($doc['info']['applied_giftcerts'] as $k => $v) {
                if (empty($v)) {
                    continue;
                }
                list($arr['giftcert_id'], $arr['giftcert_cost']) = explode(':', $v);
                $tmp[] = $arr;
            }
            $doc['info']['applied_giftcerts'] = $tmp;
        }
    }
    $doc['is_returns'] = $is_returns;
    if (cw_query_first_cell("select count(*) from {$tables['docs_items']}, {$tables['download_keys']} WHERE {$tables['docs_items']}.doc_id = '{$doc_id}' and {$tables['download_keys']}.item_id = {$tables['docs_items']}.item_id ")) {
        $doc['is_egood'] = 'Y';
    } elseif (cw_query_first_cell("select count(*) from {$tables['docs_items']}, {$tables['products']} WHERE {$tables['docs_items']}.doc_id = '{$doc_id}' and {$tables['docs_items']}.product_id={$tables['products']}.product_id AND {$tables['products']}.distribution != ''")) {
        $doc['is_egood'] = 'E';
    }
    if (preg_match("/(free_ship|percent|absolute)(?:``)(.+)/S", $doc['coupon'], $found)) {
        $doc['coupon'] = $found[2];
        $doc['coupon_type'] = $found[1];
    }
    $order['info']['extra']['tax_info']['product_tax_name'] = '';
    $_products_taxes = array();
    if ($products) {
        foreach ($products as $k => $v) {
            if ($addons['sn']) {
                $v['serial_numbers'] = cw_query("select * from {$tables['docs_items_serials']} where item_id='{$v['item_id']}'");
            }
            $v['product_options_txt'] = $v['product_options'];
            if ($v['extra_data']) {
                $v['extra_data'] = unserialize($v['extra_data']);
                if (is_array(@$v['extra_data']['display'])) {
                    foreach ($v['extra_data']['display'] as $i => $j) {
                        $v["display_" . $i] = $j;
                    }
                }
                if (is_array($v['extra_data']['taxes'])) {
                    foreach ($v['extra_data']['taxes'] as $i => $j) {
                        if ($j['tax_value'] > 0) {
                            $_products_taxes[$i] = $j['tax_display_name'];
                        }
                    }
                }
            }
            $v['original_price'] = $v['ordered_price'] = $v['price'];
            $v['price_deducted_tax'] = "Y";
            if ($v['is_deleted'] != 'Y') {
                $v['original_price'] = cw_query_first_cell("SELECT {$tables['products_prices']}.price FROM {$tables['products_prices']} WHERE {$tables['products_prices']}.product_id = '{$v['product_id']}' AND {$tables['products_prices']}.membership_id IN (0, '{$userinfo['membership_id']}') AND {$tables['products_prices']}.quantity <= '{$v['amount']}' AND {$tables['products_prices']}.variant_id = 0");
                # kornev, TOFIX
                if ($addons['product_options'] && $v['extra_data']['product_options']) {
                    list($variant, $product_options) = cw_get_product_options_data($v['product_id'], $v['extra_data']['product_options'], $userinfo['membership_id']);
                    if ($product_options === false) {
                        unset($product_options);
                    } else {
                        if (empty($variant['price'])) {
                            $variant['price'] = $v['original_price'];
                        }
                        $v['original_price'] = $variant['price'];
                        unset($variant['price']);
                        if ($product_options) {
                            foreach ($product_options as $o) {
                                if ($o['modifier_type'] == '%') {
                                    $v['original_price'] += $v['original_price'] * $o['price_modifier'] / 100;
                                } else {
                                    $v['original_price'] += $o['price_modifier'];
                                }
                            }
                        }
                        $v['product_options'] = $product_options;
                        # Check current and saved product options set
                        if (!empty($v['product_options_txt'])) {
                            $flag_txt = true;
                            # Check saved product options
                            $count = 0;
                            foreach ($v['product_options'] as $opt) {
                                if (preg_match("/" . preg_quote($opt['class'], "/") . ": " . preg_quote($opt['option_name'], "/") . "/Sm", $v['product_options_txt'])) {
                                    $count++;
                                }
                            }
                            if ($count != count($v['product_options'])) {
                                $flag_txt = false;
                            }
                            # Check current product options set
                            if ($flag_txt) {
                                $count = 0;
                                $tmp = explode("\n", $v['product_options_txt']);
                                foreach ($tmp as $txt_row) {
                                    if (!preg_match("/^([^:]+): (.*)\$/S", trim($txt_row), $match)) {
                                        continue;
                                    }
                                    foreach ($v['product_options'] as $opt) {
                                        if ($match[1] == $opt['option_name'] && $match[2] == trim($opt['name'])) {
                                            $count++;
                                            break;
                                        }
                                    }
                                }
                                if ($count != count($tmp)) {
                                    $flag_txt = false;
                                }
                            }
                            # Force display saved product options set
                            # if saved and current product options sets wasn't equal
                            if (!$flag_txt) {
                                $v['force_product_options_txt'] = true;
                            }
                        }
                        if (!empty($variant)) {
                            $v = cw_array_merge($v, $variant);
                        }
                    }
                }
            }
            $products[$k] = $v;
        }
    }
    $doc['products'] = $products;
    if (count($_products_taxes) == 1) {
        $order['info']['extra']['tax_info']['product_tax_name'] = array_pop($_products_taxes);
    }
    if ($order['coupon_type'] == "free_ship") {
        $order['shipping_cost'] = $order['coupon_discount'];
        $order['discounted_subtotal'] += $order['coupon_discount'];
    }
    $order['discounted_subtotal'] = price_format($order['discounted_subtotal']);
    # kornev, 512 is free for now (something was removed)
    if ($info_type & 1024 && $addons['pos']) {
        cw_load('pos');
        $doc['pos'] = cw_pos_get_doc_info($doc['doc_info_id']);
    }
    if ($info_type & 2048) {
        $doc['warehouse'] = cw_warehouse_get_like_user($doc['info']['warehouse_customer_id'], $doc['info']['warehouse_customer_id']);
    }
    if ($info_type & 4096) {
        $doc['quotes'] = cw_doc_get_quotes($doc_id);
    }
    if ($info_type & 8192) {
        $doc['info']['details'] = text_decrypt($doc['info']['details']);
    }
    if ($info_type & 1) {
        $doc['attributes'] = cw_func_call('cw_attributes_get', array('item_id' => $doc_id, 'item_type' => 'O'));
    }
    return $doc;
}
Esempio n. 6
0
function ouputMySQLResults($result)
{
    if (is_null($result)) {
        return false;
    }
    // create an array to hold the query result
    $resultList = array();
    if ($result) {
        while ($row = $result->fetch(PDO::FETCH_OBJ)) {
            if (isset($row->password)) {
                $row->password = text_decrypt($row->password);
            }
            foreach ($row as $key => $value) {
                $row->{$key} = stripslashes($value);
            }
            array_push($resultList, $row);
        }
    }
    header("Content-type: application/json; charset=UTF-8");
    echo json_encode($resultList);
    //serializeArray($resultList);
}