X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=b803ac3215b40c4f9231d2ab5742c5e96983b142;hb=5a7ef37131354aabdcf04c639a903e5876b743e4;hp=35fc2b703c985051c983b5d2cbcfdee494bf3f0b;hpb=7e7db9763df89c4010903f960e7ac2f6c22ff654;p=fa-stable.git diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 35fc2b70..b803ac32 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -345,7 +345,9 @@ $opts = array( // default options $img_title = _("Search suppliers"); break; case "account": - $link = $path_to_root . "/gl/inquiry/accounts_list.php?popup=1&client_id=" . $id; + case "account2": + $skip = strtolower($type) == "account" ? false : true; + $link = $path_to_root . "/gl/inquiry/accounts_list.php?popup=1&skip=".$skip."&client_id=" . $id; $img_title = _("Search GL accounts"); break; } @@ -363,7 +365,7 @@ $opts = array( // default options $selector .= ' '.$opts['editlink']; if ($search_box && $opts['cells']) - $str = ($edit_entry!='' ? "$edit_entry" : '')."$selector$img"; + $str = ($edit_entry!='' ? "$edit_entry" : '')."$selector$img"; else $str = $edit_entry.$selector.$img; return $str; @@ -551,10 +553,11 @@ function supplier_list_cells($label, $name, $selected_id=null, $all_option=false $submit_on_change=false, $all=false, $editkey = false) { if ($label != null) - echo "$label\n"; - echo supplier_list($name, $selected_id, $all_option, $submit_on_change, + echo "$label\n"; + echo ""; + echo supplier_list($name, $selected_id, $all_option, $submit_on_change, $all, $editkey); - echo "\n"; + echo "\n"; } function supplier_list_row($label, $name, $selected_id=null, $all_option = false, @@ -758,19 +761,19 @@ function _format_fiscalyears($row) . "  " . ($row[3] ? _('Closed') : _('Active')); } -function fiscalyears_list_cells($label, $name, $selected_id=null) +function fiscalyears_list_cells($label, $name, $selected_id=null, $submit_on_change=false) { if ($label != null) echo "$label\n"; echo ""; - echo fiscalyears_list($name, $selected_id); + echo fiscalyears_list($name, $selected_id, $submit_on_change); echo "\n"; } -function fiscalyears_list_row($label, $name, $selected_id=null) +function fiscalyears_list_row($label, $name, $selected_id=null, $submit_on_change=false) { echo "$label"; - fiscalyears_list_cells(null, $name, $selected_id); + fiscalyears_list_cells(null, $name, $selected_id, $submit_on_change); echo "\n"; } //------------------------------------------------------------------------------------ @@ -820,13 +823,17 @@ function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, function stock_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false, $opts=array(), $editkey = false, $type = "stock") { - $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"; + $sql = "SELECT stock_id, s.description, c.description, shipper.shipper_name, s.inactive, s.editable + FROM ".TB_PREF."stock_master s + LEFT JOIN ".TB_PREF."shippers shipper ON shipper.shipper_id=s.shipper_id + LEFT JOIN ".TB_PREF."stock_category c ON s.category_id=c.category_id"; - if (isset($opts['fixed_asset']) && $opts['fixed_asset']) - $sql .= " AND mb_flag='F'"; + if (isset($opts['shipping']) && $opts['shipping']) + $where[] = "mb_flag='T'"; + elseif (isset($opts['fixed_asset']) && $opts['fixed_asset']) + $where[] = "mb_flag='F'"; else - $sql .= " AND mb_flag!='F'"; + $where[] = "NOT mb_flag IN('F','T')"; if ($editkey) set_editor('item', $name, $editkey); @@ -839,14 +846,15 @@ function stock_items_list($name, $selected_id=null, $all_option=false, 'spec_id' => ALL_TEXT, 'search_box' => true, 'search' => array("stock_id", "c.description","s.description"), - 'search_submit' => get_company_pref('no_item_list')!=0 && (!isset($opts['fixed_asset']) || !$opts['fixed_asset']), + 'search_submit' => get_company_pref('no_item_list') != 0 && (!isset($opts['fixed_asset']) || !$opts['fixed_asset']), 'size'=>10, 'select_submit'=> $submit_on_change, 'category' => 2, - 'order' => array('c.description','stock_id'), + 'order' => (isset($opts['shipping']) && $opts['shipping']) ? array('shipper.shipper_name','stock_id'): array('c.description','stock_id'), 'editlink' => $editkey ? add_edit_combo('item') : false, 'editable' => false, - 'max' => 255 + 'max' => 255, + 'where' => $where ), $opts), $type ); return $ret; } @@ -904,7 +912,7 @@ function sales_items_list($name, $selected_id=null, $all_option=false, ".TB_PREF."stock_category c ON i.category_id=c.category_id WHERE i.stock_id=s.stock_id - AND mb_flag != 'F'"; + AND NOT mb_flag IN('F','T')"; if ($type == 'local') { // exclude foreign codes @@ -941,7 +949,7 @@ function sales_items_list_cells($label, $name, $selected_id=null, $all_option=fa if ($label != null) echo "$label\n"; echo sales_items_list($name, $selected_id, $all_option, $submit_on_change, - '', array('cells'=>true)); + '', array('cells'=>true, 'max'=>50)); // maximum is set to 50 and not default 255. } function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false) @@ -1029,7 +1037,7 @@ function stock_purchasable_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false, $all=false, $editkey=false) { return stock_items_list($name, $selected_id, $all_option, $submit_on_change, - array('where'=>array("NOT no_purchase"), + array('where'=>array("NOT no_purchase", "mb_flag!='F'"), 'show_inactive'=>$all), $editkey, "stock_purchased"); } // @@ -1048,19 +1056,53 @@ function stock_purchasable_items_list_cells($label, $name, $selected_id=null, //------------------------------------------------------------------------------------ -function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true) +function shipping_methods_list($name, $selected_id=null, $all_option=false, $submit_on_change=false) +{ + return stock_items_list($name, $selected_id, $all_option, $submit_on_change, + array('type'=>1, 'shipping'=>true, 'category' => false, 'search_box'=>false, 'search_sumbit' => false), + false, false);//, "shipping_methods"); +} + +function shipping_methods_list_cells($label, $name, $selected_id=null, + $all_option=false, $submit_on_change=false) +{ + if ($label != null) + echo "$label\n"; + echo ""; + echo shipping_methods_list($name, $selected_id, $all_option, $submit_on_change); + echo "\n"; +} + +function shipping_methods_list_row($label, $name, $selected_id=null, + $all_option=false, $submit_on_change=false) +{ + echo "$label"; + shipping_methods_list_cells(null, $name, $selected_id, $all_option, $submit_on_change); + echo "\n"; +} + +//------------------------------------------------------------------------------------ + +function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true, $all=true) { global $stock_types; + $options = $stock_types; + if (!$all) + { + unset($options['T']); + unset($options['F']); + } echo ""; if ($label != null) echo "$label\n"; echo ""; - - echo array_selector($name, $selected_id, $stock_types, + + echo array_selector($name, $selected_id, $options, array( 'select_submit'=> true, - 'disabled' => !$enabled) ); + 'disabled' => !$enabled) + ); echo "\n"; } @@ -1149,11 +1191,12 @@ function stock_depreciable_fa_list_cells($label, $name, $selected_id=null, ( 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'])); + $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 < '".$y."-12-01'"; - $where_opts[] = "depreciation_date >= '".($y-1)."-12-01'"; + $where_opts[] = "depreciation_date <= '".$end."'"; + $where_opts[] = "depreciation_date >= '".$begin."'"; $where_opts[] = "material_cost > 0"; $where_opts[] = "mb_flag='F'"; @@ -1202,7 +1245,7 @@ function tax_types_list_row($label, $name, $selected_id=null, $none_option=false function tax_groups_list($name, $selected_id=null, $none_option=false, $submit_on_change=false) { - $sql = "SELECT id, name FROM ".TB_PREF."tax_groups"; + $sql = "SELECT id, name, inactive FROM ".TB_PREF."tax_groups"; return combo_input($name, $selected_id, $sql, 'id', 'name', array( @@ -1259,26 +1302,31 @@ function item_tax_types_list_row($label, $name, $selected_id=null, $show_inactiv //------------------------------------------------------------------------------------ -function shippers_list($name, $selected_id=null) +function shippers_list($name, $selected_id=null, $none_option=false, $submit_on_change=false) { $sql = "SELECT shipper_id, shipper_name, inactive FROM ".TB_PREF."shippers"; return combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', - array('order'=>array('shipper_name'))); + array('order'=>array('shipper_name'), + 'spec_option' => $none_option, + 'spec_id' => ALL_NUMERIC, + 'select_submit'=> $submit_on_change, + 'async' => false, +)); } -function shippers_list_cells($label, $name, $selected_id=null) +function shippers_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false) { if ($label != null) echo "$label\n"; echo ""; - echo shippers_list($name, $selected_id); + echo shippers_list($name, $selected_id, $none_option, $submit_on_change); echo "\n"; } -function shippers_list_row($label, $name, $selected_id=null) +function shippers_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false) { echo "$label"; - shippers_list_cells(null, $name, $selected_id); + shippers_list_cells(null, $name, $selected_id, $none_option, $submit_on_change); echo "\n"; } @@ -1311,25 +1359,27 @@ function sales_persons_list_row($label, $name, $selected_id=null, $spec_opt=fals //------------------------------------------------------------------------------------ -function sales_areas_list($name, $selected_id=null) +function sales_areas_list($name, $selected_id=null, $special_option=false) { $sql = "SELECT area_code, description, inactive FROM ".TB_PREF."areas"; - return combo_input($name, $selected_id, $sql, 'area_code', 'description', array()); + return combo_input($name, $selected_id, $sql, 'area_code', 'description', + array('spec_option' => $special_option===true ? ' ' : $special_option, + 'order' => 'description', 'spec_id' => 0)); } -function sales_areas_list_cells($label, $name, $selected_id=null) +function sales_areas_list_cells($label, $name, $selected_id=null, $special_option=false) { if ($label != null) echo "$label\n"; echo ""; - echo sales_areas_list($name, $selected_id); + echo sales_areas_list($name, $selected_id, $special_option); echo "\n"; } -function sales_areas_list_row($label, $name, $selected_id=null) +function sales_areas_list_row($label, $name, $selected_id=null, $special_option=false) { echo "$label"; - sales_areas_list_cells(null, $name, $selected_id); + sales_areas_list_cells(null, $name, $selected_id, $special_option); echo "\n"; } @@ -1705,13 +1755,13 @@ 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, $fixed_asset=false) +function stock_categories_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $type=false) { $where_opts = array(); - if ($fixed_asset) - $where_opts[0] = "dflt_mb_flag='F'"; + if (in_array($type, array('F', 'T'))) + $where_opts[] = "dflt_mb_flag=".db_escape($type); else - $where_opts[0] = "dflt_mb_flag!='F'"; + $where_opts[] = "NOT dflt_mb_flag IN('F','T')"; $sql = "SELECT category_id, description, inactive FROM ".TB_PREF."stock_category"; return combo_input($name, $selected_id, $sql, 'category_id', 'description', @@ -1724,19 +1774,19 @@ function stock_categories_list($name, $selected_id=null, $spec_opt=false, $submi )); } -function stock_categories_list_cells($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $fixed_asset=false) +function stock_categories_list_cells($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $type=false) { if ($label != null) echo "$label\n"; echo ""; - echo stock_categories_list($name, $selected_id, $spec_opt, $submit_on_change, $fixed_asset); + echo stock_categories_list($name, $selected_id, $spec_opt, $submit_on_change, $type); echo "\n"; } -function stock_categories_list_row($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $fixed_asset=false) +function stock_categories_list_row($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $type=false) { echo "$label"; - stock_categories_list_cells(null, $name, $selected_id, $spec_opt, $submit_on_change, $fixed_asset); + stock_categories_list_cells(null, $name, $selected_id, $spec_opt, $submit_on_change, $type); echo "\n"; } @@ -1819,7 +1869,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type WHERE chart.account_type=type.id"; if ($type_id ) $sql .= " AND chart.account_type=".db_escape($type_id); - + $account = ($skip_bank_accounts ? "account2" : "account"); return combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name', array( 'format' => '_format_account', @@ -1836,7 +1886,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals 'async' => false, 'category' => 2, 'show_inactive' => $all - ), "account" ); + ), $account ); } function _format_account($row) @@ -1857,11 +1907,11 @@ function gl_all_accounts_list_cells($label, $name, $selected_id=null, } function gl_all_accounts_list_row($label, $name, $selected_id=null, - $skip_bank_accounts=false, $cells=false, $all_option=false, $type_id=false) + $skip_bank_accounts=false, $cells=false, $all_option=false, $submit_on_change=false, $all=false, $type_id=false) { echo "$label"; gl_all_accounts_list_cells(null, $name, $selected_id, - $skip_bank_accounts, $cells, $all_option, $type_id); + $skip_bank_accounts, $cells, $all_option, $submit_on_change, $all, $type_id); echo "\n"; } @@ -2562,6 +2612,26 @@ function payment_services($name) )); } +function vat_category_list_row($label, $name, $selected_id=null, $enabled = true, $submit_on_change=false, $show_obsolete=false) +{ + global $vat_categories; + + echo ""; + if ($label != null) + echo "$label\n"; + echo ""; + + $categories = $vat_categories; + if (!$show_obsolete) + unset($categories[VC_MEDIA]); // obsolete category removed to avoid mistake usage + + echo array_selector($name, $selected_id, $categories, + array( 'select_submit'=> $submit_on_change, + 'disabled' => !$enabled)); + echo "\n"; + +} + function tax_algorithm_list($name, $value=null, $submit_on_change = false) { global $tax_algorithms; @@ -2685,7 +2755,7 @@ function accounts_type_list_row($label, $name, $selected_id=null) 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"; + $sql = " SELECT user_id, IF(real_name = '', user_id, real_name) FROM ".TB_PREF."users"; if ($label != null) echo "$label\n"; @@ -2716,3 +2786,20 @@ function collations_list_row($label, $name, $selected_id=null) array('select_submit'=> false) ); echo "\n"; } + +function vat_areas_list_row($label, $name, $selected_id=null, $enabled=true) +{ + global $tax_area_types; + + echo ""; + if ($label != null) + echo "$label\n"; + echo ""; + + echo array_selector($name, $selected_id, $tax_area_types, + array( + 'select_submit'=> true, + 'disabled' => !$enabled) ); + echo "\n"; +} +