X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=0fde17de1c1a5ec20e6bdbc4bb3c43dce8890254;hb=175a48c5bd73abe16e77fa2cb48ba522f00d1501;hp=d6e77f17bd31e7a1f8f7579ef175a70454af868b;hpb=68d5eafc4d93d1305ee43ae8990b4485f1695b10;p=fa-stable.git diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index d6e77f17..0fde17de 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -46,9 +46,10 @@ $opts = array( // default options 'sel_hint' => null, 'search_box' => false, // name or true/false 'type' => 0, // type of extended selector: - // 0 - with (optional) visible search box, search by id + // 0 - with (optional) visible search box, search by fragment inside id // 1 - with hidden search box, search by option text - // 2 - TODO reverse: box with hidden selector available via enter; this + // 2 - with (optional) visible search box, search by fragment at the start of id + // 3 - TODO reverse: box with hidden selector available via enter; this // would be convenient for optional ad hoc adding of new item 'search_submit' => true, //search submit button: true/false 'size' => 8, // size and max of box tag @@ -77,8 +78,17 @@ $opts = array( // default options $select_submit = $opts['select_submit']; $spec_id = $opts['spec_id']; $spec_option = $opts['spec_option']; - $by_id = ($opts['type'] == 0); - $class = $by_id ? 'combo':'combo2'; + if ($opts['type'] == 0) { + $by_id = true; + $class = 'combo'; + } elseif($opts['type'] == 1) { + $by_id = false; + $class = 'combo2'; + } else { + $by_id = true; + $class = 'combo3'; + } + $disabled = $opts['disabled'] ? "disabled" : ''; $multi = $opts['multi']; @@ -133,13 +143,14 @@ $opts = array( // default options if ($spec_option === false && $selected_id == array()) $limit = ' LIMIT 1'; else - $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'"; + $opts['where'][] = $valfield . "=". db_escape(get_post($name, $spec_id)); } else if ($txt != '*') { foreach($opts['search'] as $i=> $s) - $opts['search'][$i] = $s . " LIKE '%{$txt}%'"; + $opts['search'][$i] = $s . " LIKE " + .db_escape(($class=='combo3' ? '' : '%').$txt.'%'); $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')'; } } @@ -511,7 +522,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null, global $all_items; $sql = "SELECT branch_code, branch_ref FROM ".TB_PREF."cust_branch - WHERE debtor_no='" . $customer_id . "' "; + WHERE debtor_no=" . db_escape($customer_id)." "; if ($editkey) set_editor('branch', $name, $editkey); @@ -1396,17 +1407,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) +function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false, $all_option=false) { + global $all_items; + $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive FROM ".TB_PREF."bank_accounts - WHERE ".TB_PREF."bank_accounts.account_type=3"; + WHERE ".TB_PREF."bank_accounts.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_items, 'format' => '_format_add_curr', 'select_submit'=> $submit_on_change, 'async' => true @@ -1439,17 +1454,14 @@ function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $sub //----------------------------------------------------------------------------------------------- // Payment type selector for current user. // -function sale_payment_list($name, $selected_id=null, $submit_on_change=true) +function sale_payment_list($name, $category, $selected_id=null, $submit_on_change=true) { $sql = "SELECT terms_indicator, terms, inactive FROM ".TB_PREF."payment_terms"; - $paym = get_sales_point(user_pos()); - - if (!$paym['cash_sale'] || !$paym['credit_sale']) { - if ($paym['cash_sale']) // only cash + + if ($category == PM_CASH) // only cash $sql .= " WHERE days_before_due=0 AND day_in_following_month=0"; - else + if ($category == PM_CREDIT) // only delayed payments $sql .= " WHERE days_before_due!=0 OR day_in_following_month!=0"; - } return combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array( @@ -1459,13 +1471,13 @@ function sale_payment_list($name, $selected_id=null, $submit_on_change=true) } -function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=true) +function sale_payment_list_cells($label, $name, $category, $selected_id=null, $submit_on_change=true) { if ($label != null) echo "$label\n"; echo ""; - echo sale_payment_list($name, $selected_id, $submit_on_change); + echo sale_payment_list($name, $category, $selected_id, $submit_on_change); echo "\n"; } @@ -1538,6 +1550,7 @@ function gl_account_types_list($name, $selected_id=null, $all_option=false, $all 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_items @@ -1582,6 +1595,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals '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, @@ -1825,11 +1839,13 @@ function pagesizes_list_row($label, $name, $value=null) echo "\n"; } -function systypes_list($name, $value=null, $spec_opt=false, $submit_on_change=false) +function systypes_list($name, $value=null, $spec_opt=false, $submit_on_change=false, $exclude=array()) { global $systypes_array; - return array_selector($name, $value, $systypes_array, + // emove non-voidable transactions if needed + $systypes = array_diff_key($systypes_array, array_flip($exclude)); + return array_selector($name, $value, $systypes, array( 'spec_option'=> $spec_opt, 'spec_id' => ALL_NUMERIC, @@ -1839,19 +1855,19 @@ function systypes_list($name, $value=null, $spec_opt=false, $submit_on_change=fa ); } -function systypes_list_cells($label, $name, $value=null, $submit_on_change=false) +function systypes_list_cells($label, $name, $value=null, $submit_on_change=false, $exclude=array()) { if ($label != null) echo "$label\n"; echo ""; - echo systypes_list($name, $value, false, $submit_on_change); + echo systypes_list($name, $value, false, $submit_on_change, $exclude); echo "\n"; } -function systypes_list_row($label, $name, $value=null, $submit_on_change=false) +function systypes_list_row($label, $name, $value=null, $submit_on_change=false, $exclude=array()) { echo "$label"; - systypes_list_cells(null, $name, $value, $submit_on_change); + systypes_list_cells(null, $name, $value, $submit_on_change, $exclude); echo "\n"; } @@ -2294,7 +2310,7 @@ function coa_list_row($label, $name, $value=null) $sqldir = opendir($path); while (false !== ($fname = readdir($sqldir))) { - if (is_file($path.$fname) && substr($fname,-4)=='.sql' && substr($fname,0,5)!='alter') + if (is_file($path.$fname) && substr($fname,-4)=='.sql' && @($fname[2] == '_')) { $ext = array_search_value($fname, $installed_extensions, 'sql'); if ($ext!=null) { @@ -2315,4 +2331,32 @@ function coa_list_row($label, $name, $value=null) echo array_selector( $name, $value, $coas ); echo "\n"; } + +function tax_algorithm_list($name, $value=null, $submit_on_change = false) +{ + global $tax_algorithms; + + return array_selector($name, $value, $tax_algorithms, + array( + 'select_submit'=> $submit_on_change, + 'async' => true, + ) + ); +} + +function tax_algorithm_list_cells($label, $name, $value=null, $submit_on_change=false) +{ + if ($label != null) + echo "$label\n"; + echo ""; + echo tax_algorithm_list($name, $value, $submit_on_change); + echo "\n"; +} + +function tax_algorithm_list_row($label, $name, $value=null, $submit_on_change=false) +{ + echo "$label"; + tax_algorithm_list_cells(null, $name, $value, $submit_on_change); + echo "\n"; +} ?> \ No newline at end of file