<?php
-
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU General Public License, GPL,
+ as published by the Free Software Foundation, either version 3
+ of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
function write_item_unit($selected, $abbr, $description, $decimals)
{
if($selected!='')
return ($myrow[0] > 0);
}
-function get_all_item_units() {
- $sql = "SELECT * FROM ".TB_PREF."item_units ORDER BY name";
+function get_all_item_units($all=false) {
+ $sql = "SELECT * FROM ".TB_PREF."item_units";
+ if (!$all) $sql .= " WHERE !inactive";
+ $sql .= " ORDER BY name";
return db_query($sql, "could not get stock categories");
}
+// 2008-06-15. Added Joe Hunt to get a measure of unit by given stock_id
+function get_unit_dec($stock_id)
+{
+ $sql = "SELECT decimals FROM ".TB_PREF."item_units, ".TB_PREF."stock_master
+ WHERE abbr=units AND stock_id='$stock_id' LIMIT 1";
+ $result = db_query($sql, "could not get unit decimals");
+
+ $row = db_fetch_row($result);
+ return $row[0];
+}
+
?>
\ No newline at end of file