X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=0149442508ed5d95404f9af2b151170373f3abdb;hb=f9ad5818b3b263cf9ecb9d3d08d833ed79d97fe6;hp=f604f69a6a190ad25f213a01d14a2bcd8666c8c9;hpb=5e63c6ace55729bbb5ee3b060035a25a4426eb0a;p=fa-stable.git
diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc
index f604f69a..01494425 100644
--- a/includes/ui/ui_lists.inc
+++ b/includes/ui/ui_lists.inc
@@ -60,7 +60,8 @@ $opts = array( // default options
'box_hint' => null, // box/selectors hints; null = std see below
'category' => false, // category column name or false
'show_inactive' => false, // show inactive records.
- 'editable' => false // false, or length of editable entry field
+ 'editable' => false, // false, or length of editable entry field
+ 'editlink' => false // link to entity entry/edit page (optional)
);
// ------ merge options with defaults ----------
if($options != null)
@@ -179,8 +180,6 @@ $opts = array( // default options
$found = false;
$lastcat = null;
$edit = false;
-//if($name=='stock_id') display_notification('
'.print_r($_POST, true).'
');
-//if($name=='curr_default') display_notification($opts['search_submit']);
if($result = db_query($sql)) {
while ($contact_row = db_fetch($result)) {
$value = $contact_row[0];
@@ -212,11 +211,15 @@ $opts = array( // default options
}
$cat = $contact_row[$opts['category']];
if ($opts['category'] !== false && $cat != $lastcat){
+ if ($lastcat!==null)
+ $selector .= "";
$selector .= "";
db_free_result($result);
}
@@ -224,8 +227,6 @@ $opts = array( // default options
if ($spec_option !== false) { // if special option used - add it
$first_id = $spec_id;
$first_opt = $spec_option;
-// }
-// if($first_id !== false) {
$sel = $found===false ? 'selected' : '';
$optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
$selector = "\n"
@@ -286,6 +287,9 @@ $opts = array( // default options
}
default_focus(($search_box && $by_id) ? $search_box : $name);
+ if ($opts['editlink'])
+ $selector .= ' '.$opts['editlink'];
+
if ($search_box && $opts['cells'])
$str = ($edit_entry!='' ? "$edit_entry | " : '')."$selector | ";
else
@@ -348,23 +352,21 @@ $opts = array( // default options
$selector = $first_opt = '';
$first_id = false;
$found = false;
-//if($name=='SelectStockFromList') display_error($sql);
- foreach($items as $value=>$descr) {
- $sel = '';
- if (in_array((string)$value, $selected_id, true)) {
- $sel = 'selected';
- $found = $value;
- }
- if ($first_id === false) {
- $first_id = $value;
- $first_opt = $descr;
- }
- $selector .= "\n";
+ foreach($items as $value=>$descr) {
+ $sel = '';
+ if (in_array((string)$value, $selected_id, true)) {
+ $sel = 'selected';
+ $found = $value;
}
+ if ($first_id === false) {
+ $first_id = $value;
+ $first_opt = $descr;
+ }
+ $selector .= "\n";
+ }
if ($first_id!==false) {
$sel = ($found===$first_id) || ($found===false && ($spec_option===false)) ? "selected='selected'" : '';
- $selector = sprintf($first_opt, $sel).$selector;
}
// Prepend special option.
if ($spec_option !== false) { // if special option used - add it
@@ -399,7 +401,14 @@ $opts = array( // default options
return $selector;
}
//----------------------------------------------------------------------------------------------
+function array_selector_row($label, $name, $selected_id, $items, $options=null)
+{
+ echo "$label | \n";
+ echo array_selector($name, $selected_id, $items, $options);
+ echo " |
\n";
+}
+//----------------------------------------------------------------------------------------------
function _format_add_curr($row)
{
static $company_currency;
@@ -451,10 +460,9 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_
'async' => false,
'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
_('Select supplier'),
- 'show_inactive'=>$all
+ 'show_inactive'=>$all,
+ 'editlink' => $editkey ? add_edit_combo('supplier') : false
));
- if ($editkey)
- $ret .= add_edit_combo('supplier');
return $ret;
}
@@ -503,10 +511,9 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_
'async' => false,
'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F2 - entry new customer') :
_('Select customer'),
- 'show_inactive' => $show_inactive
+ 'show_inactive' => $show_inactive,
+ 'editlink' => $editkey ? add_edit_combo('customer') : false
) );
- if ($editkey)
- $ret .= add_edit_combo('customer');
return $ret;
}
@@ -551,12 +558,9 @@ function customer_branches_list($customer_id, $name, $selected_id=null,
'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
'spec_id' => ALL_TEXT,
'select_submit'=> $submit_on_change,
- 'sel_hint' => _('Select customer branch')
+ 'sel_hint' => _('Select customer branch'),
+ 'editlink' => $editkey ? add_edit_combo('branch') : false
) );
- if ($editkey)
- {
- $ret .= add_edit_combo('branch');
- }
return $ret;
}
//------------------------------------------------------------------------------------------------
@@ -583,32 +587,32 @@ function customer_branches_list_row($label, $customer_id, $name, $selected_id=nu
//------------------------------------------------------------------------------------------------
-function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
+function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false, $fixed_asset=false)
{
- $sql = "SELECT loc_code, location_name, inactive FROM ".TB_PREF."locations";
+ $sql = "SELECT loc_code, location_name, inactive FROM ".TB_PREF."locations WHERE fixed_asset=".(int)$fixed_asset;
-return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
- array(
- 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
- 'spec_id' => ALL_TEXT,
- 'select_submit'=> $submit_on_change
- ) );
+ return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
+ array(
+ 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
+ 'spec_id' => ALL_TEXT,
+ 'select_submit'=> $submit_on_change
+ ) );
}
-function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
+function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false, $fixed_asset=false)
{
if ($label != null)
echo "$label | \n";
echo "";
- echo locations_list($name, $selected_id, $all_option, $submit_on_change);
+ echo locations_list($name, $selected_id, $all_option, $submit_on_change, $fixed_asset);
echo " | \n";
}
-function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
+function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false, $fixed_asset=false)
{
echo "$label | ";
- locations_list_cells(null, $name, $selected_id, $all_option, $submit_on_change);
+ locations_list_cells(null, $name, $selected_id, $all_option, $submit_on_change, $fixed_asset);
echo "
\n";
}
@@ -618,13 +622,13 @@ function currencies_list($name, $selected_id=null, $submit_on_change=false)
{
$sql = "SELECT curr_abrev, currency, inactive FROM ".TB_PREF."currencies";
-// default to the company currency
-return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
- array(
- 'select_submit'=> $submit_on_change,
- 'default' => get_company_currency(),
- 'async' => false
- ) );
+ // default to the company currency
+ return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
+ array(
+ 'select_submit'=> $submit_on_change,
+ 'default' => get_company_currency(),
+ 'async' => false
+ ) );
}
function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
@@ -650,22 +654,22 @@ function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
$sql = "SELECT * FROM ".TB_PREF."fiscal_year";
-// default to the company current fiscal year
+ // default to the company current fiscal year
-return combo_input($name, $selected_id, $sql, 'id', '',
- array(
- 'order' => 'begin',
- 'default' => get_company_pref('f_year'),
- 'format' => '_format_fiscalyears',
- 'select_submit'=> $submit_on_change,
- 'async' => false
- ) );
+ return combo_input($name, $selected_id, $sql, 'id', '',
+ array(
+ 'order' => 'begin',
+ 'default' => get_company_pref('f_year'),
+ 'format' => '_format_fiscalyears',
+ 'select_submit'=> $submit_on_change,
+ 'async' => false
+ ) );
}
function _format_fiscalyears($row)
{
return sql2date($row[1]) . " - " . sql2date($row[2])
- . " " . ($row[3] ? _('Closed') : _('Active')) . "\n";
+ . " " . ($row[3] ? _('Closed') : _('Active'));
}
function fiscalyears_list_cells($label, $name, $selected_id=null)
@@ -688,14 +692,14 @@ function fiscalyears_list_row($label, $name, $selected_id=null)
function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
$submit_on_change=false, $showclosed=false, $showtype=1)
{
-$sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
+ $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
-$options = array(
- 'order' => 'reference',
- 'spec_option'=>$no_option ? $showname : false,
- 'spec_id' => 0,
- 'select_submit'=> $submit_on_change,
- 'async' => false,
+ $options = array(
+ 'order' => 'reference',
+ 'spec_option'=>$no_option ? $showname : false,
+ 'spec_id' => 0,
+ 'select_submit'=> $submit_on_change,
+ 'async' => false,
);
if (!$showclosed)
@@ -734,25 +738,31 @@ function stock_items_list($name, $selected_id=null, $all_option=false,
$sql = "SELECT stock_id, s.description, c.description, s.inactive, s.editable
FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
+ if (isset($opts['fixed_asset']) && $opts['fixed_asset'])
+ $sql .= " AND mb_flag='F'";
+ else
+ $sql .= " AND mb_flag!='F'";
+
if ($editkey)
set_editor('item', $name, $editkey);
$ret = combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
- array_merge(
- array(
- 'format' => '_format_stock_items',
- 'spec_option' => $all_option===true ? _("All Items") : $all_option,
- 'spec_id' => ALL_TEXT,
- 'search_box' => true,
- 'search' => array("stock_id", "c.description","s.description"),
- 'search_submit' => get_company_pref('no_item_list')!=0,
- 'size'=>10,
- 'select_submit'=> $submit_on_change,
- 'category' => 2,
- 'order' => array('c.description','stock_id')
- ), $opts) );
- if ($editkey)
- $ret .= add_edit_combo('item');
+ array_merge(
+ array(
+ 'format' => '_format_stock_items',
+ 'spec_option' => $all_option===true ? _("All Items") : $all_option,
+ 'spec_id' => ALL_TEXT,
+ 'search_box' => true,
+ 'search' => array("stock_id", "c.description","s.description"),
+ 'search_submit' => get_company_pref('no_item_list')!=0,
+ 'size'=>10,
+ 'select_submit'=> $submit_on_change,
+ 'category' => 2,
+ 'order' => array('c.description','stock_id'),
+ 'editlink' => $editkey ? add_edit_combo('item') : false,
+ 'editable' => false,
+ 'max' => 255
+ ), $opts) );
return $ret;
}
@@ -762,12 +772,27 @@ function _format_stock_items($row)
}
function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false,
- $submit_on_change=false, $all=false, $editkey = false)
+ $submit_on_change=false, $all=false, $editkey = false, $opts= array())
{
+ if (isset($opts['fixed_asset']) && $opts['fixed_asset'])
+ $editor_item = 'fa_item';
+ else
+ $editor_item = 'item';
+
+// if ($editkey) ??
+// set_editor($editor_item, $name, $editkey);
+
if ($label != null)
echo "$label | \n";
+
+// ??
+// $opts = array_merge($options, array('cells'=>true, 'show_inactive'=>$all, 'new_icon' => $editkey ? 'item' : false));
+//
+// echo stock_items_list($name, $selected_id, $all_option, $submit_on_change, $opts);
+
echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
- array('cells'=>true, 'show_inactive'=>$all), $editkey);
+ array_merge(array('cells'=>true, 'show_inactive'=>$all), $opts), $editkey);
+
}
/*
function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
@@ -793,7 +818,8 @@ function sales_items_list($name, $selected_id=null, $all_option=false,
LEFT JOIN
".TB_PREF."stock_category c
ON i.category_id=c.category_id
- WHERE i.stock_id=s.stock_id";
+ WHERE i.stock_id=s.stock_id
+ AND mb_flag != 'F'";
if ($type == 'local') { // exclude foreign codes
@@ -805,21 +831,21 @@ function sales_items_list($name, $selected_id=null, $all_option=false,
$sql .= " GROUP BY i.item_code";
return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
- array_merge(
- array(
- 'format' => '_format_stock_items',
- 'spec_option' => $all_option===true ? _("All Items") : $all_option,
- 'spec_id' => ALL_TEXT,
- 'search_box' => true,
- 'search' => array("i.item_code", "c.description", "i.description"),
- 'search_submit' => get_company_pref('no_item_list')!=0,
- 'size'=>15,
- 'select_submit'=> $submit_on_change,
- 'category' => 2,
- 'order' => array('c.description','i.item_code'),
- 'editable' => 30,
- 'max' => 255
- ), $opts) );
+ array_merge(
+ array(
+ 'format' => '_format_stock_items',
+ 'spec_option' => $all_option===true ? _("All Items") : $all_option,
+ 'spec_id' => ALL_TEXT,
+ 'search_box' => true,
+ 'search' => array("i.item_code", "c.description", "i.description"),
+ 'search_submit' => get_company_pref('no_item_list')!=0,
+ 'size'=>15,
+ 'select_submit'=> $submit_on_change,
+ 'category' => 2,
+ 'order' => array('c.description','i.item_code'),
+ 'editable' => 30,
+ 'max' => 255
+ ), $opts) );
}
function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false, $editkey=false)
@@ -932,16 +958,7 @@ function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
'editable' => 30,
'cells'=>true), $editkey);
}
-/*
-function stock_purchasable_items_list_row($label, $name, $selected_id=null,
- $all_option=false, $submit_on_change=false, $editkey=false)
-{
- echo "$label | ";
- stock_purchasable_items_list_cells(null, $name, $selected_id=null,
- $all_option, $submit_on_change, $editkey);
- echo "
\n";
-}
-*/
+
//------------------------------------------------------------------------------------
function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
@@ -978,17 +995,101 @@ function stock_units_list_row($label, $name, $value=null, $enabled=true)
//------------------------------------------------------------------------------------
+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 "$label | \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();
+ $y = date('Y', strtotime($year['end']));
+
+ // check if current fiscal year
+ $where_opts[] = "depreciation_date < '".$y."-12-01'";
+ $where_opts[] = "depreciation_date >= '".($y-1)."-12-01'";
+
+ $where_opts[] = "material_cost > 0";
+ $where_opts[] = "mb_flag='F'";
+
+ if ($label != null)
+ echo "$label | \n";
+ echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
+ array('fixed_asset' => true, 'where' => $where_opts, 'cells'=>true));
+}
+
+//------------------------------------------------------------------------------------
+
function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
{
$sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
return combo_input($name, $selected_id, $sql, 'id', 'name',
- array(
- 'spec_option' => $none_option,
- 'spec_id' => ALL_NUMERIC,
- 'select_submit'=> $submit_on_change,
- 'async' => false,
- ) );
+ array(
+ 'spec_option' => $none_option,
+ 'spec_id' => ALL_NUMERIC,
+ 'select_submit'=> $submit_on_change,
+ 'async' => false,
+ ) );
}
function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
@@ -1017,13 +1118,13 @@ function tax_groups_list($name, $selected_id=null,
$sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
return combo_input($name, $selected_id, $sql, 'id', 'name',
- array(
- 'order' => 'id',
- 'spec_option' => $none_option,
- 'spec_id' => ALL_NUMERIC,
- 'select_submit'=> $submit_on_change,
- 'async' => false,
- ) );
+ array(
+ 'order' => 'id',
+ 'spec_option' => $none_option,
+ 'spec_id' => ALL_NUMERIC,
+ 'select_submit'=> $submit_on_change,
+ 'async' => false,
+ ) );
}
function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
@@ -1287,7 +1388,6 @@ function sales_types_list($name, $selected_id=null, $submit_on_change=false, $sp
'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
'spec_id' => 0,
'select_submit'=> $submit_on_change,
- // 'async' => false,
) );
}
@@ -1309,29 +1409,6 @@ function sales_types_list_row($label, $name, $selected_id=null, $submit_on_chang
//-----------------------------------------------------------------------------------------------
-function movement_types_list($name, $selected_id=null)
-{
- $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
- return combo_input($name, $selected_id, $sql, 'id', 'name', array());
-}
-
-function movement_types_list_cells($label, $name, $selected_id=null)
-{
- if ($label != null)
- echo "$label | \n";
- echo "";
- echo movement_types_list($name, $selected_id);
- echo " | \n";
-}
-
-function movement_types_list_row($label, $name, $selected_id=null)
-{
- echo "$label | ";
- movement_types_list_cells(null, $name, $selected_id);
- echo "
\n";
-}
-
-//-----------------------------------------------------------------------------------------------
function _format_date($row)
{
return sql2date($row['reconciled']);
@@ -1343,12 +1420,12 @@ function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on
WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
GROUP BY reconciled";
return combo_input($name, $selected_id, $sql, 'id', 'reconciled',
- array(
- 'spec_option' => $special_option,
- 'format' => '_format_date',
- 'spec_id' => '',
- 'select_submit'=> $submit_on_change
- ) );
+ array(
+ 'spec_option' => $special_option,
+ 'format' => '_format_date',
+ 'spec_id' => '',
+ 'select_submit'=> $submit_on_change
+ ) );
}
function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
@@ -1375,10 +1452,10 @@ function workcenter_list($name, $selected_id=null, $all_option=false)
$sql = "SELECT id, name, inactive FROM ".TB_PREF."workcentres";
return combo_input($name, $selected_id, $sql, 'id', 'name',
- array(
- 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
- 'spec_id' => ALL_TEXT,
- ) );
+ array(
+ 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
+ 'spec_id' => ALL_TEXT,
+ ) );
}
function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
@@ -1402,17 +1479,17 @@ function workcenter_list_row($label, $name, $selected_id=null, $all_option=false
function bank_accounts_list($name, $selected_id=null, $submit_on_change=false, $spec_option=false)
{
- $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
+ $sql = "SELECT id, bank_account_name, bank_curr_code, inactive
FROM ".TB_PREF."bank_accounts";
return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
- array(
- 'format' => '_format_add_curr',
- 'select_submit'=> $submit_on_change,
- 'spec_option' => $spec_option,
- 'spec_id' => '',
- 'async' => false
- ) );
+ array(
+ 'format' => '_format_add_curr',
+ 'select_submit'=> $submit_on_change,
+ 'spec_option' => $spec_option,
+ 'spec_id' => '',
+ 'async' => false
+ ) );
}
function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
@@ -1435,21 +1512,21 @@ function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_cha
function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false, $all_option=false)
{
- $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
+ $sql = "SELECT id, bank_account_name, bank_curr_code, inactive
FROM ".TB_PREF."bank_accounts
- WHERE ".TB_PREF."bank_accounts.account_type=".BT_CASH;
+ WHERE account_type=".BT_CASH;
if ($label != null)
echo "$label | \n";
echo "";
echo combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
- array(
- 'spec_option' => $all_option,
- 'spec_id' => ALL_TEXT,
- 'format' => '_format_add_curr',
- 'select_submit'=> $submit_on_change,
- 'async' => true
- ) );
+ array(
+ 'spec_option' => $all_option,
+ 'spec_id' => ALL_TEXT,
+ 'format' => '_format_add_curr',
+ 'select_submit'=> $submit_on_change,
+ 'async' => true
+ ) );
echo " |
\n";
}
//-----------------------------------------------------------------------------------------------
@@ -1465,13 +1542,13 @@ function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $sub
echo "";
echo combo_input($name, $selected_id, $sql, 'id', 'pos_name',
- array(
- 'select_submit'=> $submit_on_change,
- 'async' => true,
- 'spec_option' =>$spec_option,
- 'spec_id' => -1,
- 'order'=> array('pos_name')
- ) );
+ array(
+ 'select_submit'=> $submit_on_change,
+ 'async' => true,
+ 'spec_option' =>$spec_option,
+ 'spec_id' => -1,
+ 'order'=> array('pos_name')
+ ) );
echo " | \n";
}
@@ -1490,10 +1567,10 @@ function sale_payment_list($name, $category, $selected_id=null, $submit_on_chang
$sql .= " WHERE days_before_due>=0";
return combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms',
- array(
- 'select_submit'=> $submit_on_change,
- 'async' => true
- ) );
+ array(
+ 'select_submit'=> $submit_on_change,
+ 'async' => true
+ ) );
}
@@ -1514,10 +1591,10 @@ function class_list($name, $selected_id=null, $submit_on_change=false)
$sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
- array(
- 'select_submit'=> $submit_on_change,
- 'async' => false
- ) );
+ array(
+ 'select_submit'=> $submit_on_change,
+ 'async' => false
+ ) );
}
@@ -1538,34 +1615,71 @@ function class_list_row($label, $name, $selected_id=null, $submit_on_change=fals
}
//-----------------------------------------------------------------------------------------------
-function stock_categories_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
+function stock_categories_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $fixed_asset=false)
{
+ $where_opts = array();
+ if ($fixed_asset)
+ $where_opts[0] = "dflt_mb_flag='F'";
+ else
+ $where_opts[0] = "dflt_mb_flag!='F'";
+
$sql = "SELECT category_id, description, inactive FROM ".TB_PREF."stock_category";
return combo_input($name, $selected_id, $sql, 'category_id', 'description',
- array('order'=>'category_id',
- 'spec_option' => $spec_opt,
- 'spec_id' => -1,
- 'select_submit'=> $submit_on_change,
- 'async' => true
- ));
+ array('order'=>'category_id',
+ 'spec_option' => $spec_opt,
+ 'spec_id' => -1,
+ 'select_submit'=> $submit_on_change,
+ 'async' => true,
+ 'where' => $where_opts,
+ ));
}
-function stock_categories_list_cells($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
+function stock_categories_list_cells($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $fixed_asset=false)
{
if ($label != null)
echo "$label | \n";
echo "";
- echo stock_categories_list($name, $selected_id, $spec_opt, $submit_on_change);
+ echo stock_categories_list($name, $selected_id, $spec_opt, $submit_on_change, $fixed_asset);
echo " | \n";
}
-function stock_categories_list_row($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
+function stock_categories_list_row($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $fixed_asset=false)
{
echo "$label | ";
- stock_categories_list_cells(null, $name, $selected_id, $spec_opt, $submit_on_change);
+ stock_categories_list_cells(null, $name, $selected_id, $spec_opt, $submit_on_change, $fixed_asset);
echo "
\n";
}
+//-----------------------------------------------------------------------------------------------
+function fixed_asset_classes_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
+{
+ $sql = "SELECT c.fa_class_id, CONCAT(c.fa_class_id,' - ',c.description) `desc`, CONCAT(p.fa_class_id,' - ',p.description) `class`, c.inactive FROM "
+ .TB_PREF."stock_fa_class c LEFT JOIN ".TB_PREF."stock_fa_class p ON c.parent_id=p.fa_class_id";
+
+ return combo_input($name, $selected_id, $sql, 'c.fa_class_id', 'desc',
+ array('order'=>'c.fa_class_id',
+ 'spec_option' => $spec_opt,
+ 'spec_id' => '-1',
+ 'select_submit'=> $submit_on_change,
+ 'async' => true,
+ 'search_box' => true,
+ 'search' => array("c.fa_class_id"),
+ 'search_submit' => false,
+ 'spec_id' => '',
+ 'size' => 3,
+ 'max' => 3,
+ 'category' => 'class',
+ ));
+}
+
+function fixed_asset_classes_list_row($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
+{
+ echo "$label | ";
+ echo "";
+ echo fixed_asset_classes_list($name, $selected_id, $spec_opt, $submit_on_change);
+ echo " |
\n";
+}
+
//-----------------------------------------------------------------------------------------------
function gl_account_types_list($name, $selected_id=null, $all_option=false, $all=true)
@@ -1574,12 +1688,12 @@ function gl_account_types_list($name, $selected_id=null, $all_option=false, $all
$sql = "SELECT id, name FROM ".TB_PREF."chart_types";
return combo_input($name, $selected_id, $sql, 'id', 'name',
- array(
- 'format' => '_format_account',
- 'order' => array('class_id', 'id', 'parent'),
- 'spec_option' =>$all_option,
- 'spec_id' => ALL_TEXT
- ) );
+ array(
+ 'format' => '_format_account',
+ 'order' => array('class_id', 'id', 'parent'),
+ 'spec_option' =>$all_option,
+ 'spec_id' => ALL_TEXT
+ ) );
}
function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false, $all=false)
@@ -1616,28 +1730,27 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals
WHERE chart.account_type=type.id";
return combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
- array(
- 'format' => '_format_account',
- 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
- 'spec_id' => '',
- 'type' => 2,
- 'order' => array('type.class_id','type.id','account_code'),
- 'search_box' => $cells,
+ array(
+ 'format' => '_format_account',
+ 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
+ 'spec_id' => '',
+ 'type' => 2,
+ 'order' => array('type.class_id','type.id','account_code'),
+ 'search_box' => $cells,
'search_submit' => false,
'size' => 12,
'max' => 10,
'cells' => true,
- 'select_submit'=> $submit_on_change,
- 'async' => false,
- 'category' => 2,
- 'show_inactive' => $all
- ) );
-
+ 'select_submit'=> $submit_on_change,
+ 'async' => false,
+ 'category' => 2,
+ 'show_inactive' => $all
+ ) );
}
function _format_account($row)
{
- return $row[0] . " " . $row[1];
+ return $row[0] . " " . $row[1];
}
function gl_all_accounts_list_cells($label, $name, $selected_id=null,
@@ -1997,9 +2110,9 @@ function credit_type_list_cells($label, $name, $selected=null, $submit_on_change
label_cell($label);
echo "\n";
echo array_selector($name, $selected,
- array( 'Return' => _("Items Returned to Inventory Location"),
- 'WriteOff' => _("Items Written Off")),
- array( 'select_submit'=> $submit_on_change ) );
+ array( 'Return' => _("Items Returned to Inventory Location"),
+ 'WriteOff' => _("Items Written Off")),
+ array( 'select_submit'=> $submit_on_change ) );
echo " | \n";
}
@@ -2017,8 +2130,8 @@ function number_list($name, $selected, $from, $to, $no_option=false)
$items[$i] = "$i";
return array_selector($name, $selected, $items,
- array( 'spec_option' => $no_option,
- 'spec_id' => ALL_NUMERIC) );
+ array( 'spec_option' => $no_option,
+ 'spec_id' => ALL_NUMERIC) );
}
function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
@@ -2165,13 +2278,13 @@ function security_roles_list($name, $selected_id=null, $new_item=false, $submit_
$sql = "SELECT id, role, inactive FROM ".TB_PREF."security_roles";
-return combo_input($name, $selected_id, $sql, 'id', 'description',
- array(
- 'spec_option'=>$new_item ? _("New role") : false,
- 'spec_id' => '',
- 'select_submit'=> $submit_on_change,
- 'show_inactive' => $show_inactive
- ) );
+ return combo_input($name, $selected_id, $sql, 'id', 'description',
+ array(
+ 'spec_option'=>$new_item ? _("New role") : false,
+ 'spec_id' => '',
+ 'select_submit'=> $submit_on_change,
+ 'show_inactive' => $show_inactive
+ ) );
}
function security_roles_list_cells($label, $name, $selected_id=null, $new_item=false, $submit_on_change=false,
@@ -2385,6 +2498,40 @@ function tax_algorithm_list_row($label, $name, $value=null, $submit_on_change=fa
tax_algorithm_list_cells(null, $name, $value, $submit_on_change);
echo "\n";
}
+
+function refline_list($name, $type, $value=null, $spec_option=false)
+{
+ $sql = "SELECT id, prefix, inactive FROM ".TB_PREF."reflines";
+
+ $where = array();
+
+ if (isset($type))
+ $where = array('`trans_type`='.db_escape($type));
+
+ return combo_input($name, $value, $sql, 'id', 'prefix',
+ array(
+ 'order'=>array('prefix'),
+ 'spec_option' => $spec_option,
+ 'spec_id' => '',
+ 'type' => 2,
+ 'where' => $where,
+ 'select_submit' => true,
+ )
+ );
+}
+
+function refline_list_row($label, $name, $type, $selected_id=null, $spec_option=false)
+{
+ echo "";
+ if ($label != null)
+ echo "$label | \n";
+ echo "";
+
+ echo refline_list($name, $type, $selected_id, $spec_option);
+ echo " |
\n";
+}
+
+
//----------------------------------------------------------------------------------------------
function subledger_list($name, $account, $selected_id=null)
@@ -2444,3 +2591,37 @@ function accounts_type_list_row($label, $name, $selected_id=null)
echo "\n";
}
+function users_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $spec_opt=true)
+{
+ $where = false;
+ $sql = " SELECT user_id, real_name FROM ".TB_PREF."users";
+
+ if ($label != null)
+ echo "$label | \n";
+ echo "";
+
+ echo combo_input($name, $selected_id, $sql, 'user_id', 'real_name',
+ array(
+ 'spec_option' => $spec_opt===true ?_("All users") : $spec_opt,
+ 'spec_id' => '',
+ 'order' => 'real_name',
+ 'select_submit'=> $submit_on_change,
+ 'async' => false
+ ) );
+ echo " | ";
+
+}
+
+function collations_list_row($label, $name, $selected_id=null)
+{
+ global $supported_collations;
+
+ echo "";
+ if ($label != null)
+ echo "$label | \n";
+ echo "";
+
+ echo array_selector($name, $selected_id, $supported_collations,
+ array('select_submit'=> false) );
+ echo " |
\n";
+}