modify("-$i month"); // Subtract months iteratively $lastThreeMonths[] = $date->format('Y-m'); } // Output the last 3 months foreach ($lastThreeMonths as $month) { // $get_sales = mysqli_query($conn, "select sum(tot_price) as price from tbl_dealer_ef_sub where dealer_id='".$set_deal['user_id']."' and ref_order_id is not null and stock_status!='no stock' and date(order_date_time) like '%$month%'"); $get_sales = mysqli_query($conn, "SELECT * from tbl_confirmorder where userid='".$set_deal['user_id']."' and orderstatus in (0,1,5,15,2,3,24,25) and orderid IN(SELECT orderid from tbl_order where totprice!=0) and date(order_date_time) like '%$month%' order by orid asc"); while($set_sales = mysqli_fetch_assoc($get_sales)) { $get_ord = mysqli_query($conn, "SELECT sum(totprice) as prices FROM tbl_order where orderid='".$set_sales['orderid']."'"); $set_ord=mysqli_fetch_assoc($get_ord); $tot_sales +=$set_ord['prices']; } } if($tot_sales !='' && $tot_sales !=0 && $tot_sales > 0){ $total_amount=0; ?> 0){ while($set_sales = mysqli_fetch_assoc($get_sales)) { $get_ord = mysqli_query($conn, "SELECT sum(totprice) as prices FROM tbl_order where orderid='".$set_sales['orderid']."'"); $set_ord=mysqli_fetch_assoc($get_ord); $gst_total_sales +=$set_ord['prices']; } $total_gst_sales +=$gst_total_sales; } $get_sales = mysqli_query($conn, "SELECT * from tbl_confirmorder where userid='".$set_deal['user_id']."' and orderstatus in (0,1,5,15,2,3) and refid like '%CO%' and orderid IN(SELECT orderid from tbl_order where totprice!=0) and date(order_date_time) like '%$both%' order by orid asc"); $check_cash_rows = mysqli_num_rows($get_sales); if($check_cash_rows > 0){ while($set_sales = mysqli_fetch_assoc($get_sales)) { $get_ord = mysqli_query($conn, "SELECT sum(totprice) as prices FROM tbl_order where orderid='".$set_sales['orderid']."'"); $set_ord=mysqli_fetch_assoc($get_ord); $cash_total_sales +=$set_ord['prices']; } echo $total_cash_sales +=$cash_total_sales; } } if(date('Y-m', strtotime($set_deal['date'])) == $both){ $style='style="text-align:right; padding-right:0px; background-color:#DAF7A6"'; }else{ $style='style="text-align:right;padding-right:0px;"'; } ?>
S. NO. Dealer City Total
>GST:
CASH:
> GST:
CASH:

format('Y-m'); } // Output the last 3 months foreach ($lastThreeMonths as $month) { // $get_sales = mysqli_query($conn, "select sum(tot_price) as price from tbl_dealer_ef_sub where dealer_id='".$set_deal['user_id']."' and ref_order_id is not null and stock_status!='no stock' and date(order_date_time) like '%$month%'"); $get_sales = mysqli_query($conn, "SELECT * from tbl_confirmorder where userid='".$set_deal['user_id']."' and orderstatus in (0,1,5,15,2,3,24,25) and orderid IN(SELECT orderid from tbl_order where totprice!=0) and date(order_date_time) like '%$month%' order by orid asc"); while($set_sales = mysqli_fetch_assoc($get_sales)) { $get_ord = mysqli_query($conn, "SELECT sum(totprice) as prices FROM tbl_order where orderid='".$set_sales['orderid']."'"); $set_ord=mysqli_fetch_assoc($get_ord); $tot_sales +=$set_ord['prices']; } } if($tot_sales !='' && $tot_sales !=0 && $tot_sales > 0){ $total_amount=0; ?> 0){ while($set_sales = mysqli_fetch_assoc($get_sales)) { $get_ord = mysqli_query($conn, "SELECT sum(totprice) as prices FROM tbl_order where orderid='".$set_sales['orderid']."'"); $set_ord=mysqli_fetch_assoc($get_ord); $gst_total_sales +=$set_ord['prices']; } $total_gst_sales +=$gst_total_sales; } $get_sales1 = mysqli_query($conn, "SELECT * from tbl_confirmorder where userid='".$set_deal['user_id']."' and orderstatus in (0,1,5,15,2,3) and refid like '%CO%' and orderid IN(SELECT orderid from tbl_order where totprice!=0) and date(order_date_time) like '%$both%' order by orid asc"); $check_cash_rows = mysqli_num_rows($get_sales1); if($check_cash_rows > 0){ while($set_sales1 = mysqli_fetch_assoc($get_sales1)) { $get_ord1 = mysqli_query($conn, "SELECT sum(totprice) as prices FROM tbl_order where orderid='".$set_sales1['orderid']."'"); $set_ord1=mysqli_fetch_assoc($get_ord1); $cash_total_sales +=$set_ord1['prices']; } } $total_cash_sales +=$cash_total_sales; } if(date('Y-m', strtotime($set_deal['date'])) == $both){ $style='style="text-align:right; padding-right:0px; background-color:#DAF7A6"'; }else{ $style='style="text-align:right; padding-right:0px;"'; } ?>
S. NO. Dealer City Total
>GST:
CASH:
> GST:
CASH: