MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
-$page_security = 'SA_SALESANALYTIC';
+$page_security = 'SA_SUPPLIERANALYTIC';
// ----------------------------------------------------------------
// $ Revision: 2.0 $
// Creator: Joe Hunt
item.stock_id,
item.description, item.inactive,
move.loc_code,
- supplier.supplier_id,
+ supplier.supplier_id , IF(ISNULL(grn.rate), credit.rate, grn.rate) ex_rate,
supplier.supp_name AS supplier_name,
move.tran_date,
move.qty AS qty,
move.price
- FROM ".TB_PREF."stock_master item,
- ".TB_PREF."stock_category category,
- ".TB_PREF."suppliers supplier,
- ".TB_PREF."stock_moves move
+ FROM ".TB_PREF."stock_moves move
+ LEFT JOIN ".TB_PREF."supp_trans credit ON credit.trans_no=move.trans_no AND credit.type=move.type
+ LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=move.trans_no AND 25=move.type
+ LEFT JOIN ".TB_PREF."suppliers supplier ON IFNULL(grn.supplier_id, credit.supplier_id)=supplier.supplier_id,
+ ".TB_PREF."stock_master item,
+ ".TB_PREF."stock_category category
WHERE item.stock_id=move.stock_id
AND item.category_id=category.category_id
- AND move.person_id=supplier.supplier_id
AND move.tran_date>='$from'
AND move.tran_date<='$to'
AND (move.type=".ST_SUPPRECEIVE." OR move.type=".ST_SUPPCREDIT.")
AND trans.tran_date=".db_escape($date);
$result = db_query($sql,"No transactions were returned");
$row = db_fetch_row($result);
- if (isset($row[0]))
- return $row[0];
- else
- return '';
-}
-
-
+ return is_array($row) ? $row[0] : '';
+}
+
//----------------------------------------------------------------------------------------------------
function print_inventory_purchase()
}
$curr = get_supplier_currency($trans['supplier_id']);
- $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['tran_date']));
- $trans['price'] *= $rate;
+ $trans['price'] *= $trans['ex_rate'];
$rep->NewLine();
$trans['supp_reference'] = get_supp_inv_reference($trans['supplier_id'], $trans['stock_id'], $trans['tran_date']);
$rep->fontSize -= 2;
$rep->NewLine();
$rep->NewLine();
$total_supp = $total_qty = 0.0;
- $supplier_name = $trans['supplier_name'];
+ $supplier_name = isset($trans['supplier_name']) ? $trans['supplier_name'] : "";
}
}
if ($supplier_name != '')