- ".TB_PREF."stock_master.description,
- ".TB_PREF."stock_moves.loc_code,
- SUM(-".TB_PREF."stock_moves.qty*".TB_PREF."stock_moves.price*(1-".TB_PREF."stock_moves.discount_percent)) AS amt,
- SUM(-".TB_PREF."stock_moves.qty) *(".TB_PREF."stock_master.material_cost + ".TB_PREF."stock_master.labour_cost + ".TB_PREF."stock_master.overhead_cost) AS cost
- FROM ".TB_PREF."stock_master,
- ".TB_PREF."stock_category,
- ".TB_PREF."debtor_trans,
- ".TB_PREF."stock_moves
- WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."stock_moves.stock_id
- AND ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id
-
- AND ".TB_PREF."stock_moves.type=".TB_PREF."debtor_trans.type
- AND ".TB_PREF."stock_moves.trans_no=".TB_PREF."debtor_trans.trans_no
- AND ".TB_PREF."stock_moves.tran_date>='$from'
- AND ".TB_PREF."stock_moves.tran_date<='$to'
- AND ((".TB_PREF."debtor_trans.type=13 AND ".TB_PREF."debtor_trans.version=1) OR ".TB_PREF."stock_moves.type=11)
- AND (".TB_PREF."stock_master.mb_flag='B' OR ".TB_PREF."stock_master.mb_flag='M')";
- if ($category != 0)
- $sql .= " AND ".TB_PREF."stock_master.category_id = '$category'";
- if ($location != 'all')
- $sql .= " AND ".TB_PREF."stock_moves.loc_code = '$location'";
- //$sql .= " AND SUM(".TB_PREF."stock_moves.qty) != 0
- $sql .= " GROUP BY ".TB_PREF."stock_master.category_id,
- ".TB_PREF."stock_category.description,
- ".TB_PREF."stock_master.stock_id,
- ".TB_PREF."stock_master.description
- ORDER BY ".TB_PREF."stock_master.category_id,
- ".TB_PREF."stock_master.stock_id";
-*/
- $sql = "SELECT ".TB_PREF."stock_master.category_id,
- ".TB_PREF."stock_category.description AS cat_description,
- ".TB_PREF."stock_master.stock_id,
- ".TB_PREF."stock_master.description,