';
while($set_ord = mysqli_fetch_assoc($get_ord)){
// Yoga Videos
$get_yoga = mysqli_query($conn,"select td.orderid, sp.name, sp.vstatus, tc.name, tc.gst_percent, tc.hsn, td.price, td.qty from tbl_order td inner join shop_product sp on sp.product_id=td.productid inner join tbl_company tc on tc.id=sp.vstatus where sp.v_s=1 and td.orderid='".$set_ord['orderid']."'");
$get_status = mysqli_query($conn, "SELECT new_status from shop_user where user_id = '".$set_ord['userid']."' and new_status=1");
$stat_rows = mysqli_num_rows($get_status);
if($stat_rows > 0){
$bg_color='yellow';
}else{
$bg_color='';
}
$yoga_rows = mysqli_num_rows($get_yoga);
if($yoga_rows > 0){
$cgst='';
$sgst = '';
$igst='';
$gst = '';
$tax_amount='';
$my_tax='';
$gst_percent = '';
$get_calc = mysqli_query($conn,"select SUM(td.price * td.qty) as total_amount from tbl_order td inner join shop_product sp on sp.product_id=td.productid inner join tbl_company tc on tc.id=sp.vstatus where sp.v_s=1 and td.orderid='".$set_ord['orderid']."'");
$set_calc = mysqli_fetch_assoc($get_calc);
if($set_ord['offer'] ==''){
$ord_offer = 0;
}else{
$ord_offer = $set_ord['offer'];
}
$calc_offer = $set_calc['total_amount'] * ($ord_offer/100);
$total_amount = $set_calc['total_amount'] - $calc_offer;
$gst_rate = 18; // GST percentage
if($set_ord['contry'] == 'India'){
$base_price = $total_amount / (1 + $gst_rate / 100);
$my_tax = $total_amount - $base_price;
$temp_tax_amount = $total_amount - $my_tax;
$cgst = $my_tax / 2;
$sgst = $my_tax / 2;
$tax_amount = number_format((float)$temp_tax_amount, 2, '.', '');
}
$get_user = mysqli_query($conn, "SELECT `name`,gst_no from shop_user where user_id='".$set_ord['userid']."'");
$user_row = mysqli_num_rows($get_user);
if($user_row > 0){
$set_user = mysqli_fetch_assoc($get_user);
$name = $set_user['name'];
if($set_user['gst_no'] ==''){
$gst_no ='NOT APPLICABLE';
}else{
$gst_no = $set_user['gst_no'];
}
}else{
$name=$set_ord['dif_name'];
}
if($set_ord['contry'] == 'India'){
$state = $set_ord['state'];
$country = $set_ord['contry'];
$gst_percent = '18';
if($set_ord['state'] != 'Tamilnadu'){
$cgst='';
$sgst = '';
$igst = $total_amount - $base_price;
}else{
$igst = "0.00";
}
}else{
$state = $set_ord['contry'];
$country = $set_ord['contry'];
$gst_percent = '';
}
if($set_ord['orderstatus']==90){
$color="red";
$gst_no ='DELETED';
}else{
$color='';
}
if($set_ord['orderstatus']==90){
$total_amount =0;
$cgst='';
$sgst = '';
$igst='';
$gst = '';
$tax_amount='';
$my_tax='';
$gst_percent = '';
}
$grand_total+=$total_amount;
$htmlTable.= '
'.($incr=$incr+1).' |
'.$set_ord['refid'].' |
'.date('d-m-Y', strtotime($set_ord['ordtime'])).' |
'.strtoupper($name).' |
'.$gst_no.' |
'.$state.' |
'.$country.' |
'.$stat_rows.' |
'.$tax_amount.' |
999723 |
'.$gst_percent.' |
'.number_format((float)$cgst, 2, '.', '').' |
'.number_format((float)$sgst, 2, '.', '').' |
'.number_format((float)$igst, 2, '.', '').' |
'.number_format((float)$my_tax, 2, '.', '').' |
'.$total_amount.' |
';
}
// Book
$get_book = mysqli_query($conn,"select td.orderid, sp.name, sp.vstatus, tc.name, tc.gst_percent, tc.hsn, td.price, td.qty from tbl_order td inner join shop_product sp on sp.product_id=td.productid inner join tbl_company tc on tc.id=sp.vstatus where sp.name='T.I. Book - New' and td.orderid='".$set_ord['orderid']."'");
$book_rows = mysqli_num_rows($get_book);
if($book_rows > 0){
$cgst='';
$sgst = '';
$gst = '';
$igst='';
$tax_amount='';
$my_tax='';
$gst_percent='';
$get_calc = mysqli_query($conn,"select SUM(td.price * td.qty) as total_amount from tbl_order td inner join shop_product sp on sp.product_id=td.productid inner join tbl_company tc on tc.id=sp.vstatus where sp.name='T.I. Book - New' and td.orderid='".$set_ord['orderid']."'");
$set_calc = mysqli_fetch_assoc($get_calc);
if($set_ord['offer'] ==''){
$ord_offer = 0;
}else{
$ord_offer = $set_ord['offer'];
}
$calc_offer = $set_calc['total_amount'] * ($ord_offer/100);
$total_amount = $set_calc['total_amount'] - $calc_offer;
$gst_rate = 5;
if($set_ord['contry'] == 'India'){
$base_price = $total_amount / (1 + $gst_rate / 100);
$my_tax = $total_amount - $base_price;
$temp_tax_amount = $total_amount - $my_tax;
$cgst = $my_tax / 2;
$sgst = $my_tax / 2;
$tax_amount = number_format((float)$temp_tax_amount, 2, '.', '');
}
$get_user = mysqli_query($conn, "SELECT `name`,gst_no from shop_user where user_id='".$set_ord['userid']."'");
$user_row = mysqli_num_rows($get_user);
if($user_row > 0){
$set_user = mysqli_fetch_assoc($get_user);
$name = $set_user['name'];
if($set_user['gst_no'] ==''){
$gst_no ='NOT APPLICABLE';
}else{
$gst_no = $set_user['gst_no'];
}
}else{
$name=$set_ord['dif_name'];
}
if($set_ord['contry'] == 'India'){
$state = $set_ord['state'];
$country = $set_ord['contry'];
$gst_percent = '5';
if($set_ord['state'] != 'Tamilnadu'){
$cgst='';
$sgst = '';
$igst = $total_amount - $base_price;
}else{
$igst = "0.00";
}
}else{
$state = $set_ord['contry'];
$country = $set_ord['contry'];
$gst_percent = '';
}
if($set_ord['orderstatus']==90){
$color="red";
$gst_no ='DELETED';
}else{
$color='';
}
if($set_ord['orderstatus']==90){
$total_amount =0;
$cgst='';
$sgst = '';
$gst = '';
$igst='';
$tax_amount='';
$my_tax='';
$gst_percent = '';
}
$grand_total+=$total_amount;
$htmlTable.= '
'.($incr=$incr+1).' |
'.$set_ord['refid'].' |
'.date('d-m-Y', strtotime($set_ord['ordtime'])).' |
'.strtoupper($name).' |
'.$gst_no.' |
'.$state.' |
'.$country.' |
'.$book_rows.' |
'.$tax_amount.' |
49011010 |
'.$gst_percent.' |
'.number_format((float)$cgst, 2, '.', '').' |
'.number_format((float)$sgst, 2, '.', '').' |
'.number_format((float)$igst, 2, '.', '').' |
'.number_format((float)$my_tax, 2, '.', '').' |
'.$total_amount.' |
';
}
// remaining products
foreach($hsn_array as $key=>$value){
$exp = explode('_',$key);
$get_other = mysqli_query($conn,"select td.orderid, sp.name, sp.vstatus, tc.name, tc.gst_percent, tc.hsn, td.price, td.qty from tbl_order td inner join shop_product sp on sp.product_id=td.productid inner join tbl_company tc on tc.id=sp.vstatus where sp.name!='T.I. Book - New' and sp.v_s not in (1,4) and tc.hsn='$exp[0]' and tc.gst_percent='$value' and td.orderid='".$set_ord['orderid']."'");
$other_rows = mysqli_num_rows($get_other);
if($other_rows > 0){
$cgst='';
$sgst = '';
$gst = '';
$igst='';
$tax_amount='';
$my_tax='';
$gst_percent='';
$get_calc = mysqli_query($conn,"select SUM(td.price * td.qty) as total_amount, SUM(td.qty) as sum_qty from tbl_order td inner join shop_product sp on sp.product_id=td.productid inner join tbl_company tc on tc.id=sp.vstatus where sp.v_s not in (1,4) and tc.hsn='$exp[0]' and tc.gst_percent='$value' and td.orderid='".$set_ord['orderid']."'");
$set_calc = mysqli_fetch_assoc($get_calc);
if($set_ord['offer'] ==''){
$ord_offer = 0;
}else{
$ord_offer = $set_ord['offer'];
}
$calc_offer = $set_calc['total_amount'] * ($ord_offer/100);
$total_amount = $set_calc['total_amount'] - $calc_offer;
if($set_ord['contry'] == 'India'){
$base_price = $total_amount / (1 + $value / 100);
$my_tax = $total_amount - $base_price;
$temp_tax_amount = $total_amount - $my_tax;
$cgst = $my_tax / 2;
$sgst = $my_tax / 2;
$tax_amount = number_format((float)$temp_tax_amount, 2, '.', '');
}
$get_user = mysqli_query($conn, "SELECT `name`,gst_no from shop_user where user_id='".$set_ord['userid']."'");
$user_row = mysqli_num_rows($get_user);
if($user_row > 0){
$set_user = mysqli_fetch_assoc($get_user);
$name = $set_user['name'];
if($set_user['gst_no'] ==''){
$gst_no ='NOT APPLICABLE';
}else{
$gst_no = $set_user['gst_no'];
}
}else{
$name=$set_ord['dif_name'];
}
if($set_ord['contry'] == 'India'){
$state = $set_ord['state'];
$country = $set_ord['contry'];
$gst_percent = $value;
if($set_ord['state'] != 'Tamilnadu'){
$cgst='';
$sgst = '';
$igst = $total_amount - $base_price;
}else{
$igst = "0.00";
}
}else{
$state = $set_ord['contry'];
$country = $set_ord['contry'];
$gst_percent = '';
}
if($set_ord['orderstatus']==90){
$color="red";
$gst_no ='DELETED';
}else{
$color='';
}
if($set_ord['orderstatus']==90){
$total_amount =0;
$cgst='';
$sgst = '';
$igst='';
$gst = '';
$my_tax='';
$tax_amount='';
$gst_percent = '';
}
$grand_total+=$total_amount;
$htmlTable.= '
'.($incr=$incr+1).' |
'.$set_ord['refid'].' |
'.date('d-m-Y', strtotime($set_ord['ordtime'])).' |
'.strtoupper($name).' |
'.$gst_no.' |
'.$state.' |
'.$country.' |
'.$set_calc['sum_qty'].' |
'.$tax_amount.' |
'.$exp[0].' |
'.$gst_percent.' |
'.number_format((float)$cgst, 2, '.', '').' |
'.number_format((float)$sgst, 2, '.', '').' |
'.number_format((float)$igst, 2, '.', '').' |
'.number_format((float)$my_tax, 2, '.', '').' |
'.$total_amount.' |
';
}
}
}
$htmlTable.= '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Total |
'.$grand_total.' |
';
$htmlTable.= '