See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
function update_item($stock_id, $description, $long_description, $category_id,
- $tax_type_id, $units='', $mb_flag='', $sales_account, $inventory_account,
+ $tax_type_id, $units, $mb_flag, $sales_account, $inventory_account,
$cogs_account, $adjustment_account, $wip_account, $dimension_id,
$dimension2_id, $no_sale, $editable, $no_purchase,
$depreciation_method = 'D', $depreciation_rate=100, $depreciation_factor=1,
if ($mb_flag != '')
$sql .= ", mb_flag=".db_escape($mb_flag);
- if ($depreciation_start != '') {
+ if (isset($depreciation_start)) {
$sql .= ", depreciation_start='".date2sql($depreciation_start)."'"
.", depreciation_date='".date2sql($depreciation_start)."'";
}
$sql = "INSERT INTO ".TB_PREF."stock_master (stock_id, description, long_description, category_id,
tax_type_id, units, mb_flag, sales_account, inventory_account, cogs_account,
adjustment_account, wip_account, dimension_id, dimension2_id, no_sale, no_purchase, editable,
- depreciation_method, depreciation_rate, depreciation_factor, depreciation_start, depreciation_date, fa_class_id)
- VALUES (".db_escape($stock_id).", ".db_escape($description).", ".db_escape($long_description).",
+ depreciation_method, depreciation_rate, depreciation_factor"
+ .(isset($depreciation_start) ? ", depreciation_start, depreciation_date, fa_class_id" : "")
+ .") VALUES (".db_escape($stock_id).", ".db_escape($description).", ".db_escape($long_description).",
".db_escape($category_id).", ".db_escape($tax_type_id).", "
.db_escape($units).", ".db_escape($mb_flag).",
".db_escape($sales_account).", ".db_escape($inventory_account)
.db_escape($no_sale).","
.db_escape($no_purchase).","
.db_escape($editable).","
- .db_escape($depreciation_method).",".db_escape($depreciation_rate).",".db_escape($depreciation_factor).",'"
- .date2sql($depreciation_start)."','".date2sql($depreciation_start)."',"
- .db_escape($fa_class_id).")";
+ .db_escape($depreciation_method).",".db_escape($depreciation_rate).",".db_escape($depreciation_factor)
+ .(isset($depreciation_start) ? ",'".date2sql($depreciation_start)."','".date2sql($depreciation_start)."',".db_escape($fa_class_id) : "")
+ .")";
db_query($sql, "The item could not be added");
AND stock_id=".db_escape($stock_id);
$result = db_query($sql,"an item could not be retreived");
- return db_fetch($result);
+ return db_fetch_assoc($result);
}
function get_items($fixed_asset = 0)