$stmt = $pdo->query("SELECT Bcsaleorder.DocNo as Docno,BCSale.Name as Name,BCar.Name1 as Bcarname1 ,Bcitem.Code as Code,BCitem.Name1 as Name1,stockqty as Stockqty FROM BCSaleOrderSub
LEFT JOIN bcitem on bcitem.code = BCSaleOrderSub.ItemCode
LEFT JOIN BCSaleOrder on BCSaleOrder.docno = BCSaleOrderSub.DocNo
LEFT JOIN BCSale on BCSale.Code = BCSaleOrderSub.SaleCode
LEFT JOIN BCAR on Bcar.Code = BCSaleOrderSub.ArCode
WHERE BCsaleordersub.Qty <= Bcitem.StockQty
And BCSaleOrder.IsCancel = 0
And BCsaleorder.IsCompleteSave = 1
AND BCsaleorder.IsConfirm = 0
And BCSaleOrder.BillStatus = 0
And BCSaleOrderSub.DocDate BETWEEN '2022/01/01' and '2022/07/31'");