Ejemplo n.º 1
0
/**
 * brandLevelOrders function
 * this funciton is to get order's all details on a brand level distribution, the function is being used while generating the excel repports.
 * the function is also sessible to the dealers, distributors, brand and arvind IT users
 * @param int id - it is brand's id for which detials are required to be generated
 * @param bool confirmed, TRUE or FALSE if required confrimed orders or not, respectively
 * @return array
 * @author Ankit Balyan - sf.ankit@gmail.com
 **/
function brandLevelOrders($id = NULL, $confirmed = FALSE, $user_id = NULL)
{
    global $wpdb;
    $confirmed = $confirmed ? " and orders.order_confirm_ind = {$confirmed} " : ' ';
    if (isDealer()) {
        $user_id = isLogin();
    }
    if (isArvindUser()) {
        $sql = " SELECT \n\t\t\t\t    orders.order_id,users_lvl.lvl_name, users.user_name, brand.brand_name, category.category_name, product.product_code, \n\t\t\t\t\tproduct.product_desc, product.product_color, product.product_price, orders.product_grade,\n\t\t\t\t    orders.order_size1 as 'EXS/26',orders.order_size2 as 'XS/28',orders.order_size3 as 'S/30',\n\t\t\t\t    orders.order_size4 as 'M/32',orders.order_size5 as 'L/34',orders.order_size6 as 'XL/36',\n\t\t\t\t    orders.order_size7 as 'XXL/38',orders.order_size8 as '3XL/40',orders.total_qty, orders.total_price\n\t\t\t\tFROM\n\t\t\t\t    rw_orders AS orders\n\t\t\t\t        LEFT OUTER JOIN\n\t\t\t\t    rw_products AS product ON orders.product_id = product.product_id\n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_brands as brand ON product.brand_id = brand.brand_id \n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_category as category ON product.category_id = category.category_id \n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_users as users ON users.user_id = orders.created_by \n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_user_lvl as users_lvl ON users.user_lvl = users_lvl.lvl_id \n\t\t\t\t    \twhere 1 {$confirmed} ";
    } elseif (isBrandUser() && $id) {
        $sql = " SELECT \n\t\t\t\t    orders.order_id,users_lvl.lvl_name, users.user_name, brand.brand_name, category.category_name, product.product_code, \n\t\t\t\t\tproduct.product_desc, product.product_color, product.product_price, orders.product_grade,\n\t\t\t\t    orders.order_size1 as 'EXS/26',orders.order_size2 as 'XS/28',orders.order_size3 as 'S/30',\n\t\t\t\t    orders.order_size4 as 'M/32',orders.order_size5 as 'L/34',orders.order_size6 as 'XL/36',\n\t\t\t\t    orders.order_size7 as 'XXL/38',orders.order_size8 as '3XL/40',orders.total_qty, orders.total_price\n\t\t\t\tFROM\n\t\t\t\t    rw_orders AS orders\n\t\t\t\t        LEFT OUTER JOIN\n\t\t\t\t    rw_products AS product ON orders.product_id = product.product_id\n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_brands as brand ON product.brand_id = brand.brand_id \n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_category as category ON product.category_id = category.category_id \n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_users as users ON users.user_id = orders.created_by \n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_user_lvl as users_lvl ON users.user_lvl = users_lvl.lvl_id \n\t\t\t\t    \twhere brand.brand_parent_id = {$id} {$confirmed} ";
    } elseif (isDistributor()) {
        $sql = " SELECT \n\t\t\t\t    orders.order_id, users_lvl.lvl_name, users.user_name, brand.brand_name, category.category_name, product.product_code, \n\t\t\t\t\tproduct.product_desc, product.product_color, product.product_price, orders.product_grade,\n\t\t\t\t    orders.order_size1 as 'EXS/26',orders.order_size2 as 'XS/28',orders.order_size3 as 'S/30',\n\t\t\t\t    orders.order_size4 as 'M/32',orders.order_size5 as 'L/34',orders.order_size6 as 'XL/36',\n\t\t\t\t    orders.order_size7 as 'XXL/38',orders.order_size8 as '3XL/40',orders.total_qty, orders.total_price\n\t\t\t\tFROM\n\t\t\t\t    rw_orders AS orders\n\t\t\t\t        LEFT OUTER JOIN\n\t\t\t\t    rw_products AS product ON orders.product_id = product.product_id\n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_brands as brand ON product.brand_id = brand.brand_id \n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_category as category ON product.category_id = category.category_id \n\t\t\t\t    LEFT OUTER JOIN\n\t\t\t\t    rw_users as users ON users.user_id = orders.created_by\n\t\t\t\t    LEFT OUTER JOIN\n\t\t\t\t    rw_user_lvl as users_lvl ON users.user_lvl = users_lvl.lvl_id \n\t\t\t\t    \twhere brand.brand_parent_id = {$id} {$confirmed} ";
    } elseif ($id) {
        $sql = " SELECT \n\t\t\t\t    orders.order_id, brand.brand_name, category.category_name, product.product_code, \n\t\t\t\t\tproduct.product_desc, product.product_color, product.product_price, orders.product_grade,\n\t\t\t\t    orders.order_size1 as 'EXS/26',orders.order_size2 as 'XS/28',orders.order_size3 as 'S/30',\n\t\t\t\t    orders.order_size4 as 'M/32',orders.order_size5 as 'L/34',orders.order_size6 as 'XL/36',\n\t\t\t\t    orders.order_size7 as 'XXL/38',orders.order_size8 as '3XL/40',orders.total_qty, orders.total_price\n\t\t\t\tFROM\n\t\t\t\t    rw_orders AS orders\n\t\t\t\t        LEFT OUTER JOIN\n\t\t\t\t    rw_products AS product ON orders.product_id = product.product_id\n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_brands as brand ON product.brand_id = brand.brand_id \n\t\t\t\t    \tLEFT OUTER JOIN\n\t\t\t\t    rw_category as category ON product.category_id = category.category_id \n\t\t\t\t    \twhere brand.brand_parent_id = {$id} {$confirmed} ";
    }
    if ($user_id) {
        $sql .= " and orders.created_by = " . $user_id;
    }
    $results = $wpdb->get_results($sql);
    $data = array();
    foreach ($results as $key => $value) {
        $data[$key] = (array) $value;
    }
    return $data;
}
Ejemplo n.º 2
0
									<li><a href="#review_order_tab2">All Orders</a></li>
								<?php 
} elseif (isBrandUser() || isArvindUser()) {
    ?>
									<li><a href="#review_order_tab3">Brand Report</a></li>
									<li><a href="#review_order_tab4">Distributor Report</a></li>
								<?php 
} elseif (isArvindUser()) {
    ?>
									<!-- <li><a href="#review_order_tab5">All Orders</a></li> -->
								<?php 
}
?>
								</ul>
								<?php 
if (isDealer()) {
    ?>
								<div id="review_order_tab1">
									<?php 
    $ordered_ids = getOrederedId(null, TRUE);
    ?>
									<?php 
    if (count($ordered_ids)) {
        ?>
									<?php 
        $ordered_ids['brand_id'] = array_values($ordered_ids['brand_id']);
        ?>
									<?php 
        $ordlerLevels = get_nested();
        ?>
									<ul class="accordion">