Пример #1
0
/**
 * getOrderSum function
 * this funciton is to get total sum or the total quantities of all the orders and also by differenciating by user or confirmed orders.
 * 
 * @todo by providing order id, get the total sums.
 * @param int id, product id not implemented, always null
 * @param  sting qty, get the toal quantities of orders by providing qty = 'qty' string.
 * @param bool confirmed, TRUE or FALSE
 * @return int
 * @author Ankit Balyan - sf.ankit@gmail.com
 **/
function getOrderSum($id = NULL, $qty = NULL, $confirmed = FALSE, $user_id = NULL)
{
    $confirmed = $confirmed ? " and orders.order_confirm_ind = {$confirmed} " : ' ';
    global $wpdb;
    if (isBrandUser()) {
        $user_id = isLogin();
        if ($qty != 'qty') {
            $sql = "SELECT SUM(orders.total_price) as dist_total_price \n\t\t\t\tFROM \n\t\t\t\t\trw_orders AS orders \n\t\t\t\tLEFT OUTER JOIN \n\t\t\t\t\trw_products AS product on orders.product_id = product.product_id\n\t\t\t\tLEFT OUTER JOIN\n                \trw_brand_user_map AS user_brand ON user_brand.user_id = {$user_id}\n                LEFT OUTER JOIN\n                \trw_brands AS brand ON brand.brand_id = user_brand.brand_id\n                OR brand.brand_parent_id = user_brand.brand_id\n\t            where\n\t                product.brand_id = brand.brand_id\n\t            or\n\t                product.brand_id = brand.brand_parent_id\n\t\t\t\t\t\t{$confirmed}";
        } elseif ($qty == 'qty') {
            $sql = "SELECT SUM(orders.total_qty) as dist_total_qty \n\t\t\t\t\tFROM \n\t\t\t\t\t\trw_orders AS orders \n\t\t\t\t\tLEFT OUTER JOIN \n\t\t\t\t\t\trw_products AS product on orders.product_id = product.product_id\n\t\t\t\t    LEFT OUTER JOIN\n                \trw_brand_user_map AS user_brand ON user_brand.user_id = {$user_id}\n\t                LEFT OUTER JOIN\n\t                \trw_brands AS brand ON brand.brand_id = user_brand.brand_id\n\t                OR brand.brand_parent_id = user_brand.brand_id\n\t\t            where\n\t\t                product.brand_id = brand.brand_id\n\t\t            or\n\t\t                product.brand_id = brand.brand_parent_id {$confirmed}";
        }
        $wpdb->get_var($sql);
        $wpdb->last_query;
        return $wpdb->get_var($sql);
    } elseif (isArvindUser()) {
        if ($qty != 'qty') {
            $sql = "SELECT SUM(orders.total_price) as dist_total_price \n\t\t\t\tFROM \n\t\t\t\t\trw_orders AS orders \n\t\t\t    \twhere 1 {$confirmed}";
        } elseif ($qty == 'qty') {
            $sql = "SELECT SUM(orders.total_qty) as dist_total_qty \n\t\t\t\t\tFROM \n\t\t\t\t\t\trw_orders AS orders \n\t\t\t\t    \twhere 1 {$confirmed}";
        }
        if ($user_id) {
            $sql .= " and orders.created_by = " . $user_id;
        }
        $wpdb->get_var($sql);
        $wpdb->last_query;
        return $wpdb->get_var($sql);
    } elseif (count(isDistributor($user_id)) && $user_id && $qty != 'qty') {
        $sql = "SELECT SUM(orders.total_price) as dist_total_price \n\t\t\t\tFROM \n\t\t\t\t\trw_orders AS orders \n\t\t\t\t\tLEFT OUTER JOIN rw_users as users\n\t\t\t    \ton users.user_parent_id = {$user_id} \n\t\t\t    \tor users.user_id = {$user_id}\n\t\t\t    \twhere orders.created_by = users.user_id {$confirmed}";
    } elseif (count(isDistributor($user_id)) && $user_id && $qty == 'qty') {
        $sql = "SELECT SUM(orders.total_qty) as dist_total_qty \n\t\t\t\tFROM \n\t\t\t\t\trw_orders AS orders \n\t\t\t\t\tLEFT OUTER JOIN rw_users as users\n\t\t\t    \ton users.user_parent_id = {$user_id} \n\t\t\t    \tor users.user_id = {$user_id}\n\t\t\t    \twhere orders.created_by = users.user_id {$confirmed}";
    } elseif ($id && $qty != 'qty') {
        $sql = "SELECT \n\t\t\t\t   SUM(orders.total_price) AS user_total_price\n\t\t\t\tFROM\n\t\t\t\t    rw_orders AS orders\n\t\t\t\t    where orders.created_by = {$id} {$confirmed}";
    } elseif ($id && $qty == 'qty') {
        $sql = "SELECT \n\t\t\t\t   SUM(orders.total_qty) AS user_total_qty\n\t\t\t\tFROM\n\t\t\t\t    rw_orders AS orders\n\t\t\t\t    where orders.created_by = {$id} {$confirmed}";
    } elseif (!$id && $qty == 'qty') {
        $sql = "SELECT \n\t\t\t\t   SUM(orders.total_qty) AS user_total_qty\n\t\t\t\tFROM\n\t\t\t\t    rw_orders AS orders\n\t\t\t\t    where orders.created_by = " . isLogin() . " {$confirmed}";
    } else {
        $sql = "SELECT \n\t\t\t\t   SUM(orders.total_price) AS user_total_price\n\t\t\t\tFROM\n\t\t\t\t    rw_orders AS orders\n\t\t\t\t    where orders.created_by = " . isLogin() . " {$confirmed}";
    }
    $wpdb->get_var($sql);
    // /echo $wpdb->last_query;
    return $wpdb->get_var($sql);
}
Пример #2
0
        }
        ?>
									<?php 
    }
    ?>
									</ul>
								<?php 
} else {
    ?>
								<p>Sorry! there are no orders have been made.</p>
								<?php 
}
?>
								</div>
								<?php 
if ($dist = isDistributor()) {
    ?>
								<div id="review_order_tab1">
									<?php 
    $dealers = getDealersByDistributor(isLogin());
    ?>
									<?php 
    $dealers = array_merge($dist, $dealers);
    ?>
									<?php 
    foreach ($dealers as $key => $dealer) {
        ?>
										<?php 
        $ordered_ids = getOrderedIdByUser($dealer->user_id);
        ?>
	
Пример #3
0
			<option value="C">C</option>
			<option value="D">D</option>
		</select>
		</div>
	</div>

	<div class="text-center">
		<a href="#" class="btn btn-default get" onclick="cancelDel()">Cancel</a>
		<input type="submit" name="action" class="btn btn-default get" value="Delete Selected" id="">
	</div>
		
	</form>
</div>
<?php 
    /***************else************************/
} elseif (isDistributor()) {
    ?>
<div class="popupFrom">
	<form action="" class="form-horizontal" role = "form" id="massDelete" class="massDelete">
<?php 
    /*<!-- 	<div class="form-group">
    		<lable class="control-label col-xs-3">User</lable>
    		 <div class="col-xs-9">
    		<select name="massDel[user]" class="" id="">
    		<option value="">Null</option>
    		<?php foreach ($dealers as $key => $dealer): ?>
    			<?php //if ($dealer->user_id == isLogin()): ?>
    				<option value="<?php echo $dealer->user_id ?>"> <?php echo $dealer->user_fullname ?></option>	
    			<?php //endif ?>
    		<?php endforeach; ?>
    		</select>