X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=68f67092fc50be9782661dcc99f405e7a1ee95dc;hb=3f3cfa578adbc2b71f4fd9c8d0f5536d26af43d8;hp=129269035ab667e5ee6e785e73fad95bf68a147f;hpb=78fe8cb8f56510ba3f6a1720b207a33b5828e071;p=fa-stable.git diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 12926903..68f67092 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -417,6 +417,21 @@ function _format_add_curr($row) '' : (" - " . $row[2])); } +function add_edit_combo($type) +{ + global $path_to_root, $popup_editors, $use_icon_for_editkey; + + if (!isset($use_icon_for_editkey) || $use_icon_for_editkey==0) + return ""; + // Derive theme path + $theme_path = $path_to_root . '/themes/' . user_theme(); + + $key = $popup_editors[$type][1]; + $onclick = "onclick=\"javascript:callEditor($key); return false;\""; + $img = "Add/Edit"; + return "$img"; +} + function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false, $all=false, $editkey = false) { @@ -428,8 +443,8 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_ if ($editkey) set_editor('supplier', $name, $editkey); - - return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name', + + $ret = combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name', array( 'format' => '_format_add_curr', 'order' => array('supp_ref'), @@ -443,6 +458,9 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_ _('Select supplier'), 'show_inactive'=>$all )); + if ($editkey) + $ret .= add_edit_combo('supplier'); + return $ret; } function supplier_list_cells($label, $name, $selected_id=null, $all_option=false, @@ -477,7 +495,7 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_ if ($editkey) set_editor('customer', $name, $editkey); - return combo_input($name, $selected_id, $sql, 'debtor_no', 'debtor_ref', + $ret = combo_input($name, $selected_id, $sql, 'debtor_no', 'debtor_ref', array( 'format' => '_format_add_curr', 'order' => array('debtor_ref'), @@ -492,6 +510,9 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_ _('Select customer'), 'show_inactive' => $show_inactive ) ); + if ($editkey) + $ret .= add_edit_combo('customer'); + return $ret; } function customer_list_cells($label, $name, $selected_id=null, $all_option=false, @@ -508,6 +529,7 @@ function customer_list_cells($label, $name, $selected_id=null, $all_option=false function customer_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false, $show_inactive=false, $editkey = false) { + echo "$label"; echo customer_list($name, $selected_id, $all_option, $submit_on_change, $show_inactive, $editkey); @@ -528,7 +550,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null, set_editor('branch', $name, $editkey); $where = $enabled ? array("disable_trans = 0") : array(); - return combo_input($name, $selected_id, $sql, 'branch_code', 'branch_ref', + $ret = combo_input($name, $selected_id, $sql, 'branch_code', 'branch_ref', array( 'where' => $where, 'order' => array('branch_ref'), @@ -537,6 +559,11 @@ function customer_branches_list($customer_id, $name, $selected_id=null, 'select_submit'=> $submit_on_change, 'sel_hint' => _('Select customer branch') ) ); + if ($editkey) + { + $ret .= add_edit_combo('branch'); + } + return $ret; } //------------------------------------------------------------------------------------------------ @@ -681,7 +708,7 @@ $options = array( if (!$showclosed) $options['where'][] = "closed=0"; if($showtype) - $options['where'][] = "type_=$showtype"; + $options['where'][] = "type_=".db_escape($showtype); return combo_input($name, $selected_id, $sql, 'id', 'ref', $options); } @@ -718,7 +745,7 @@ function stock_items_list($name, $selected_id=null, $all_option=false, if ($editkey) set_editor('item', $name, $editkey); - return combo_input($name, $selected_id, $sql, 'stock_id', 's.description', + $ret = combo_input($name, $selected_id, $sql, 'stock_id', 's.description', array_merge( array( 'format' => '_format_stock_items', @@ -732,6 +759,9 @@ function stock_items_list($name, $selected_id=null, $all_option=false, 'category' => 2, 'order' => array('c.description','stock_id') ), $opts) ); + if ($editkey) + $ret .= add_edit_combo('item'); + return $ret; } function _format_stock_items($row) @@ -857,7 +887,7 @@ function stock_component_items_list($name, $parent_stock_id, $selected_id=null, $all_option=false, $submit_on_change=false, $editkey = false) { return stock_items_list($name, $selected_id, $all_option, $submit_on_change, - array('where'=>array("stock_id != '$parent_stock_id'")), $editkey); + array('where'=>array("stock_id != ".db_escape($parent_stock_id))), $editkey); } function stock_component_items_list_cells($label, $name, $parent_stock_id, @@ -866,7 +896,7 @@ function stock_component_items_list_cells($label, $name, $parent_stock_id, if ($label != null) echo "$label\n"; echo stock_items_list($name, $selected_id, $all_option, $submit_on_change, - array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true), + array('where'=>array("stock_id != ".db_escape($parent_stock_id)), 'cells'=>true), $editkey); } //------------------------------------------------------------------------------------ @@ -1454,14 +1484,16 @@ function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $sub //----------------------------------------------------------------------------------------------- // Payment type selector for current user. // -function sale_payment_list($name, $category, $selected_id=null, $submit_on_change=true) +function sale_payment_list($name, $category, $selected_id=null, $submit_on_change=true, $prepayments=true) { $sql = "SELECT terms_indicator, terms, inactive FROM ".TB_PREF."payment_terms"; - + if ($category == PM_CASH) // only cash $sql .= " WHERE days_before_due=0 AND day_in_following_month=0"; - if ($category == PM_CREDIT) // only delayed payments - $sql .= " WHERE days_before_due!=0 OR day_in_following_month!=0"; + elseif ($category == PM_CREDIT) // only delayed payments + $sql .= " WHERE days_before_due".($prepayments ? '!=': '>')."0 OR day_in_following_month!=0"; + elseif (!$prepayments) + $sql .= " WHERE days_before_due>=0"; return combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array( @@ -1471,13 +1503,13 @@ function sale_payment_list($name, $category, $selected_id=null, $submit_on_chang } -function sale_payment_list_cells($label, $name, $category, $selected_id=null, $submit_on_change=true) +function sale_payment_list_cells($label, $name, $category, $selected_id=null, $submit_on_change=true, $prepayments=true) { if ($label != null) echo "$label\n"; echo ""; - echo sale_payment_list($name, $category, $selected_id, $submit_on_change); + echo sale_payment_list($name, $category, $selected_id, $submit_on_change, $prepayments); echo "\n"; } @@ -1883,7 +1915,7 @@ function journal_types_list_cells($label, $name, $value=null, $submit_on_change= // exclude quotes, orders and dimensions foreach (array(ST_PURCHORDER, ST_WORKORDER, ST_SALESORDER, ST_DIMENSION, - ST_SALESQUOTE) as $excl) + ST_SALESQUOTE, ST_LOCTRANSFER) as $excl) unset($items[$excl]); echo array_selector($name, $value, $items, @@ -2419,4 +2451,3 @@ function subledger_list_row($label, $name, $selected_id=null, $all_option = fals echo subledger_list($name, $account, $selected_id); echo "\n\n"; } -