0){ $set_sto = mysqli_fetch_array($get_sto); $new_stock = $set_sto['new_stock']; }else{ $new_stock = 0; } $get_prod = mysqli_query($conn, "SELECT * from shop_product where product_id='$row1[product_id]'"); $get_product = mysqli_fetch_array($get_prod, MYSQLI_ASSOC); //opening balance $open_bal = mysqli_query($conn, "select * from stock_log_entry where product_id = '".$row1['product_id']."' and DATE(created_at)='$prev_date'"); $check_rows = mysqli_num_rows($open_bal); if($check_rows > 0){ $sql = mysqli_query($conn, "select * from stock_log_entry where product_id = '".$row1['product_id']."' and DATE(created_at)='$prev_date' order by id desc limit 1"); $open_balance = mysqli_fetch_array($sql, MYSQLI_ASSOC); $opening_balance = $open_balance['current_stock']; }else{ $open_bal_1 = mysqli_query($conn, "select * from stock_log_entry where product_id = '".$row1['product_id']."' order by id desc limit 1"); $check_rows_1 = mysqli_num_rows($open_bal_1); if($check_rows_1 > 0){ $open_balance_1 = mysqli_fetch_array($open_bal_1, MYSQLI_ASSOC); $opening_balance = $open_balance_1['current_stock']; }else{ $opening_balance = 0; } } $open_balance = mysqli_fetch_array($open_bal, MYSQLI_ASSOC); ?> 0){ $get_sales = mysqli_fetch_array($get_sale, MYSQLI_ASSOC); ?> 0){ $get_refund = mysqli_fetch_array($get_refu, MYSQLI_ASSOC); $get_refund_count = $get_refund_count + $get_refund['qtys']; } } $balance = $opening_balance - $sale_qty + $new_stock; $get_packing = mysqli_query($conn, "SELECT sum(tb.qty + tb.freeqty) AS fqty FROM tbl_confirmorder tc INNER JOIN tbl_order tb ON tc.orderid = tb.orderid WHERE tc.orderstatus = 5 AND tc.varstatus!='Cash' and tc.company_name='Energy Foods' and tb.productid='".$row1['product_id']."'"); $pack_rows = mysqli_num_rows($get_packing); if($pack_rows > 0){ $set_packing = mysqli_fetch_array($get_packing, MYSQLI_ASSOC); $packing = $set_packing['fqty']; }else{ $packing = 0; } $get_new = mysqli_query($conn, "SELECT sum(tb.qty + tb.freeqty) AS fqty FROM tbl_confirmorder tc INNER JOIN tbl_order tb ON tc.orderid = tb.orderid WHERE tc.orderstatus = 0 AND tc.varstatus!='Cash' and tc.company_name='Energy Foods' and tb.productid='".$row1['product_id']."'"); $new_rows = mysqli_num_rows($get_new); if($new_rows > 0){ $set_new = mysqli_fetch_array($get_new, MYSQLI_ASSOC); $new = $set_new['fqty']; }else{ $new = 0; } $pending = $packing + $new; if(!isset($pending)){ $pending = 0; } $instock = $balance + $pending; ?>
Product Name Opening Sales New Stock Returned ID Balance Unpacked In Stock
0