+function stock_purchasable_fa_list_cells($label, $name, $selected_id=null, $all_option=false,
+ $submit_on_change=false, $all=false, $editkey = false, $exclude_items = array())
+{
+ // Check if a fixed asset has been bought.
+ $where_opts[] = "stock_id NOT IN
+ ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE type=".ST_SUPPRECEIVE." AND qty!=0 )";
+
+ // exclude items currently on the order.
+ foreach($exclude_items as $item) {
+ $where_opts[] = "stock_id != ".db_escape($item->stock_id);
+ }
+ $where_opts[] = "mb_flag='F'";
+
+ echo stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change, $all, $editkey,
+ array('fixed_asset' => true, 'where' => $where_opts));
+}
+
+function stock_disposable_fa_list($name, $selected_id=null,
+ $all_option=false, $submit_on_change=false)
+{
+ // Check if a fixed asset has been bought....
+ $where_opts[] = "stock_id IN
+ ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE type=".ST_SUPPRECEIVE." AND qty!=0 )";
+ // ...but has not been disposed or sold already.
+ $where_opts[] = "stock_id NOT IN
+ ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE (type=".ST_CUSTDELIVERY." OR type=".ST_INVADJUST.") AND qty!=0 )";
+
+ $where_opts[] = "mb_flag='F'";
+
+ echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
+ array('fixed_asset' => true, 'where' => $where_opts));
+}
+
+function stock_disposable_fa_list_cells($label, $name, $selected_id=null,
+ $all_option=false, $submit_on_change=false, $exclude_items = array())
+{
+ // Check if a fixed asset has been bought....
+ $where_opts[] = "stock_id IN
+ ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE type=".ST_SUPPRECEIVE." AND qty!=0 )";
+ // ...but has not been disposed or sold already.
+ $where_opts[] = "stock_id NOT IN
+ ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE (type=".ST_CUSTDELIVERY." OR type=".ST_INVADJUST.") AND qty!=0 )";
+
+ $where_opts[] = "mb_flag='F'";
+
+ foreach($exclude_items as $item) {
+ $where_opts[] = "stock_id != ".db_escape($item->stock_id);
+ }
+
+ if ($label != null)
+ echo "<td>$label</td>\n";
+ echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
+ array('fixed_asset' => true, 'cells'=>true, 'where' => $where_opts));
+}
+
+function stock_depreciable_fa_list_cells($label, $name, $selected_id=null,
+ $all_option=false, $submit_on_change=false)
+{
+
+ // Check if a fixed asset has been bought....
+ $where_opts[] = "stock_id IN
+ ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE type=".ST_SUPPRECEIVE." AND qty!=0 )";
+ // ...but has not been disposed or sold already.
+ $where_opts[] = "stock_id NOT IN
+ ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE (type=".ST_CUSTDELIVERY." OR type=".ST_INVADJUST.") AND qty!=0 )";
+
+ $year = get_current_fiscalyear();
+ $begin = date2sql(add_months(sql2date($year['begin']), -1));
+ $end = date2sql(add_months(sql2date($year['end']), -1));
+
+ // check if current fiscal year
+ $where_opts[] = "depreciation_date <= '".$end."'";
+ $where_opts[] = "depreciation_date >= '".$begin."'";
+
+ $where_opts[] = "material_cost > 0";
+ $where_opts[] = "mb_flag='F'";
+
+ if ($label != null)
+ echo "<td>$label</td>\n";
+ echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
+ array('fixed_asset' => true, 'where' => $where_opts, 'cells'=>true));
+}
+
+//------------------------------------------------------------------------------------
+