textarea_row(_("Legal Text on Invoice:"), 'legal_text', $_POST['legal_text'], 32, 4);
-gl_all_accounts_list_row(_("Shipping Charged Account:"), 'freight_act', $_POST['freight_act']);
+gl_all_accounts_list_row(_("Shipping Charged Account (default):"), 'freight_act', $_POST['freight_act']);
gl_all_accounts_list_row(_("Deferred Income Account:"), 'deferred_income_act', $_POST['deferred_income_act'], true, false,
_("Not used"), false, false, false);
$this->add_module(_("Maintenance"));
$this->add_lapp_function(2, _("Fixed &Assets"),
- "inventory/manage/items.php?FixedAsset=1", 'SA_ASSET', MENU_ENTRY);
+ "inventory/manage/items.php?type=F", 'SA_ASSET', MENU_ENTRY);
$this->add_rapp_function(2, _("Fixed Assets &Locations"),
"inventory/manage/locations.php?FixedAsset=1", 'SA_INVENTORYLOCATION', MENU_MAINTENANCE);
$this->add_rapp_function(2, _("Fixed Assets &Categories"),
"admin/payment_terms.php?", 'SA_PAYTERMS', MENU_MAINTENANCE);
$this->add_lapp_function(1, _("Shi&pping Company"),
"admin/shipping_companies.php?", 'SA_SHIPPING', MENU_MAINTENANCE);
+ $this->add_lapp_function(1, _("Shipping &Options"),
+ "inventory/manage/items.php?type=T", 'SA_SHIPPING', MENU_ENTRY);
$this->add_rapp_function(1, _("&Points of Sale"),
"sales/manage/sales_points.php?", 'SA_POSSETUP', MENU_MAINTENANCE);
$this->add_rapp_function(1, _("&Printers"),
$stock_types = array(
'M' => _("Manufactured"),
'B' => _("Purchased"),
- 'D' => _("Service")
+ 'D' => _("Service"),
+ 'T' => _("Shipping")
);
//----------------------------------------------------------------------------------
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";
-
- if (isset($opts['fixed_asset']) && $opts['fixed_asset'])
- $sql .= " AND mb_flag='F'";
+ $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['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);
'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;
}
".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
$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");
}
//
//------------------------------------------------------------------------------------
-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 "<td>$label</td>\n";
+ echo "<td>";
+ echo shipping_methods_list($name, $selected_id, $all_option, $submit_on_change);
+ echo "</td>\n";
+}
+
+function shipping_methods_list_row($label, $name, $selected_id=null,
+ $all_option=false, $submit_on_change=false)
+{
+ echo "<tr><td class='label'>$label</td>";
+ shipping_methods_list_cells(null, $name, $selected_id, $all_option, $submit_on_change);
+ echo "</tr>\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 "<tr>";
if ($label != null)
echo "<td class='label'>$label</td>\n";
echo "<td>";
-
- echo array_selector($name, $selected_id, $stock_types,
+
+ echo array_selector($name, $selected_id, $options,
array(
'select_submit'=> true,
- 'disabled' => !$enabled) );
+ 'disabled' => !$enabled)
+ );
echo "</td></tr>\n";
}
//------------------------------------------------------------------------------------
-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 "<td>$label</td>\n";
echo "<td>";
- echo shippers_list($name, $selected_id);
+ echo shippers_list($name, $selected_id, $none_option, $submit_on_change);
echo "</td>\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 "<tr><td class='label'>$label</td>";
- shippers_list_cells(null, $name, $selected_id);
+ shippers_list_cells(null, $name, $selected_id, $none_option, $submit_on_change);
echo "</tr>\n";
}
}
//-----------------------------------------------------------------------------------------------
-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',
));
}
-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 "<td>$label</td>\n";
echo "<td>";
- 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 "</td>\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 "<tr><td class='label'>$label</td>";
- 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 "</tr>\n";
}
$cogs_account, $adjustment_account, $wip_account, $dimension_id,
$dimension2_id, $no_sale, $editable, $no_purchase,
$depreciation_method = 'D', $depreciation_rate=100, $depreciation_factor=1,
- $depreciation_start=null, $fa_class_id=null, $vat_category='')
+ $depreciation_start=null, $fa_class_id=null, $vat_category='', $shipper_id=0)
{
$sql = "UPDATE ".TB_PREF."stock_master SET long_description=".db_escape($long_description).",
description=".db_escape($description).",
depreciation_method=".db_escape($depreciation_method).",
depreciation_rate=".db_escape($depreciation_rate).",
depreciation_factor=".db_escape($depreciation_factor).",
- fa_class_id=".db_escape($fa_class_id);
+ fa_class_id=".db_escape($fa_class_id).",
+ shipper_id=".db_escape($shipper_id);
if ($units != '')
$sql .= ", units=".db_escape($units);
$cogs_account, $adjustment_account, $wip_account, $dimension_id,
$dimension2_id, $no_sale, $editable, $no_purchase,
$depreciation_method='D', $depreciation_rate=100, $depreciation_factor=1, $depreciation_start=null,
- $fa_class_id=null, $vat_category=0)
+ $fa_class_id=null, $vat_category=0, $shipper_id=0)
{
$sql = "INSERT INTO ".TB_PREF."stock_master (stock_id, description, long_description, category_id,
tax_type_id, units, mb_flag, sales_account, inventory_account, cogs_account,
adjustment_account, wip_account, dimension_id, dimension2_id, no_sale, no_purchase, editable, vat_category,
depreciation_method, depreciation_rate, depreciation_factor"
.(isset($depreciation_start) ? ", depreciation_start, depreciation_date, fa_class_id" : "")
- .") VALUES (".db_escape($stock_id).", ".db_escape($description).", ".db_escape($long_description).",
+ .",shipper_id) VALUES (".db_escape($stock_id).", ".db_escape($description).", ".db_escape($long_description).",
".db_escape($category_id).", ".db_escape($tax_type_id).", "
.db_escape($units).", ".db_escape($mb_flag).",
".db_escape($sales_account).", ".db_escape($inventory_account)
.db_escape($editable).",".db_escape($vat_category).","
.db_escape($depreciation_method).",".db_escape($depreciation_rate).",".db_escape($depreciation_factor)
.(isset($depreciation_start) ? ",'".date2sql($depreciation_start)."','".date2sql($depreciation_start)."',".db_escape($fa_class_id) : "")
- .")";
+ .",".db_escape($shipper_id).")";
db_query($sql, "The item could not be added");
_('Cannot delete this item because there are existing sales order items for it.'),
"SELECT COUNT(*) FROM "
.TB_PREF."purch_order_details WHERE item_code=".db_escape($stock_id)=>
- _('Cannot delete this item because there are existing purchase order items for it.')
+ _('Cannot delete this item because there are existing purchase order items for it.'),
+ "SELECT COUNT(*) FROM "
+ .TB_PREF."sales_orders WHERE ship_via=".db_escape($stock_id)=>
+ _('Cannot delete this item because there are existing sales transactions for it.'),
);
$msg = '';
return db_query($sql, "Failed in retreiving item list.");
}
-
if (user_use_date_picker())
$js .= get_js_date_picker();
-if (isset($_GET['FixedAsset'])) {
- $page_security = 'SA_ASSET';
- $_SESSION['page_title'] = _($help_context = "Fixed Assets");
- $_POST['mb_flag'] = 'F';
- $_POST['fixed_asset'] = 1;
+if (isset($_GET['type'])) {
+ if ($_GET['type'] == 'F') {
+
+ $page_security = 'SA_ASSET';
+ $_SESSION['page_title'] = _($help_context = "Fixed Assets");
+ $_POST['mb_flag'] = 'F';
+ } elseif ($_GET['type'] == 'T') {
+
+ $page_security = 'SA_SHIPPING';
+ $_SESSION['page_title'] = _($help_context = "Shipping Options");
+ $_POST['mb_flag'] = 'T';
+ }
}
else {
$_SESSION['page_title'] = _($help_context = "Items");
- if (!get_post('fixed_asset'))
- $_POST['fixed_asset'] = 0;
}
/* EOF Add Image upload for New Item - by Ori */
}
-if (get_post('fixed_asset')) {
+if (get_post('mb_flag') == 'F') {
check_db_has_fixed_asset_categories(_("There are no fixed asset categories defined in the system. At least one fixed asset category is required to add a fixed asset."));
check_db_has_fixed_asset_classes(_("There are no fixed asset classes defined in the system. At least one fixed asset class is required to add a fixed asset."));
} else
unset($_POST['category_id']);
unset($_POST['tax_type_id']);
unset($_POST['units']);
- unset($_POST['mb_flag']);
+ if (!in_array(@$_POST['mb_flag'], array('T', 'F')))
+ unset($_POST['mb_flag']);
unset($_POST['NewStockID']);
unset($_POST['dimension_id']);
unset($_POST['dimension2_id']);
set_focus('NewStockID');
}
- if (get_post('fixed_asset')) {
+ if (get_post('mb_flag') == 'F') {
if ($_POST['depreciation_rate'] > 100) {
$_POST['depreciation_rate'] = 100;
}
{ /*so its an existing one */
update_item($_POST['NewStockID'], $_POST['description'],
$_POST['long_description'], $_POST['category_id'],
- $_POST['tax_type_id'], get_post('units'),
- get_post('fixed_asset') ? 'F' : get_post('mb_flag'), $_POST['sales_account'],
+ $_POST['tax_type_id'], get_post('units'),
+ get_post('mb_flag'), $_POST['sales_account'],
$_POST['inventory_account'], $_POST['cogs_account'],
$_POST['adjustment_account'], $_POST['wip_account'],
$_POST['dimension_id'], $_POST['dimension2_id'],
check_value('no_sale'), check_value('editable'), check_value('no_purchase'),
get_post('depreciation_method'), input_num('depreciation_rate'), input_num('depreciation_factor'), get_post('depreciation_start', null),
- get_post('fa_class_id'), get_post('vat_category'));
+ get_post('fa_class_id'), get_post('vat_category'), get_post('shipper'));
update_record_status($_POST['NewStockID'], $_POST['inactive'],
'stock_master', 'stock_id');
add_item($_POST['NewStockID'], $_POST['description'],
$_POST['long_description'], $_POST['category_id'], $_POST['tax_type_id'],
- $_POST['units'], get_post('fixed_asset') ? 'F' : get_post('mb_flag'), $_POST['sales_account'],
+ $_POST['units'], get_post('mb_flag'), $_POST['sales_account'],
$_POST['inventory_account'], $_POST['cogs_account'],
$_POST['adjustment_account'], $_POST['wip_account'],
$_POST['dimension_id'], $_POST['dimension2_id'],
check_value('no_sale'), check_value('editable'), check_value('no_purchase'),
get_post('depreciation_method'), input_num('depreciation_rate'), input_num('depreciation_factor'), get_post('depreciation_start', null),
- get_post('fa_class_id'), get_post('vat_category'));
+ get_post('fa_class_id'), get_post('vat_category'), get_post('shipper'));
display_notification(_("A new item has been added."));
$_POST['stock_id'] = $_POST['NewStockID'] =
hidden('NewStockID', $_POST['NewStockID']);
set_focus('description');
}
- $fixed_asset = get_post('fixed_asset');
text_row(_("Name:"), 'description', null, 52, 200);
textarea_row(_('Description:'), 'long_description', null, 42, 3);
- stock_categories_list_row(_("Category:"), 'category_id', null, false, $new_item, $fixed_asset);
+ stock_categories_list_row(_("Category:"), 'category_id', null, false, $new_item, get_post('mb_flag'));
if ($new_item && (list_updated('category_id') || !isset($_POST['sales_account']))) { // changed category for new item or first page view
$_POST['tax_type_id'] = $category_record["dflt_tax_type"];
$_POST['units'] = $category_record["dflt_units"];
- $_POST['mb_flag'] = $category_record["dflt_mb_flag"];
+ if (!in_array(get_post('mb_flag'), array('T', 'F')))
+ $_POST['mb_flag'] = $category_record["dflt_mb_flag"];
$_POST['inventory_account'] = $category_record["dflt_inventory_act"];
$_POST['cogs_account'] = $category_record["dflt_cogs_act"];
- $_POST['sales_account'] = $category_record["dflt_sales_act"];
+ if (get_post('mb_flag') == 'T' && !isset($_POST['sales_account']))
+ $_POST['sales_account'] = get_company_pref('freight_act');
+ else
+ $_POST['sales_account'] = $category_record["dflt_sales_act"];
$_POST['adjustment_account'] = $category_record["dflt_adjustment_act"];
$_POST['wip_account'] = $category_record["dflt_wip_act"];
$_POST['dimension_id'] = $category_record["dflt_dim1"];
// show inactive item tax type in selector only if already set.
item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null, !$new_item && item_type_inactive(get_post('tax_type_id')));
- if (!get_post('fixed_asset'))
- stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item);
+ if (!in_array(get_post('mb_flag'), array('T', 'F')))
+ stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item, false);
stock_units_list_row(_('Units of Measure:'), 'units', null, $fresh_item);
vat_category_list_row(_("VAT category:"), 'vat_category', null, $fresh_item, false, !$new_item);
+ if (get_post('mb_flag') != 'T')
check_row(_("Editable description:"), 'editable');
- if (get_post('fixed_asset'))
+ if (get_post('mb_flag') == 'F')
hidden('no_sale', 0);
else
check_row(_("Exclude from sales:"), 'no_sale');
check_row(_("Exclude from purchases:"), 'no_purchase');
- if (get_post('fixed_asset')) {
+ if (get_post('mb_flag') == 'F') {
table_section_title(_("Depreciation"));
fixed_asset_classes_list_row(_("Fixed Asset Class").':', 'fa_class_id', null, false, true);
label_row(_("Last Depreciation").':', $_POST['depreciation_date']==$_POST['depreciation_start'] ? _("None") : $_POST['depreciation_date']);
}
hidden('depreciation_date');
+ } else if (get_post('mb_flag') == 'T') {
+ shippers_list_row(_("Shipping company:"), 'shipper');
}
table_section(2);
gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']);
- if (get_post('fixed_asset')) {
- gl_all_accounts_list_row(_("Asset account:"), 'inventory_account', $_POST['inventory_account']);
- gl_all_accounts_list_row(_("Depreciation cost account:"), 'cogs_account', $_POST['cogs_account']);
- gl_all_accounts_list_row(_("Depreciation/Disposal account:"), 'adjustment_account', $_POST['adjustment_account']);
- }
- elseif (!is_service(get_post('mb_flag')))
- {
- gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
- gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
- gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']);
- }
- else
- {
- gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
- hidden('inventory_account', $_POST['inventory_account']);
- hidden('adjustment_account', $_POST['adjustment_account']);
+ switch(get_post('mb_flag')) {
+ case 'F':
+ gl_all_accounts_list_row(_("Asset account:"), 'inventory_account', $_POST['inventory_account']);
+ gl_all_accounts_list_row(_("Depreciation cost account:"), 'cogs_account', $_POST['cogs_account']);
+ gl_all_accounts_list_row(_("Depreciation/Disposal account:"), 'adjustment_account', $_POST['adjustment_account']);
+ break;
+ case 'T':
+ case 'D':
+ gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
+ hidden('inventory_account', $_POST['inventory_account']);
+ hidden('adjustment_account', $_POST['adjustment_account']);
+ break;
+ default:
+ gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
+ gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
+ gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']);
}
-
if (is_manufactured(get_post('mb_flag')))
gl_all_accounts_list_row(_("WIP Account:"), 'wip_account', $_POST['wip_account']);
else
check_row(_("Delete Image:"), 'del_image');
record_status_list_row(_("Item status:"), 'inactive');
- if (get_post('fixed_asset')) {
+ if (get_post('mb_flag') == 'F') {
table_section_title(_("Values"));
if (!$new_item) {
hidden('material_cost');
{
start_table(TABLESTYLE_NOBORDER);
start_row();
- stock_items_list_cells(_("Select an item:"), 'stock_id', null,
- _('New item'), true, check_value('show_inactive'), false, array('fixed_asset' => get_post('fixed_asset')));
+ if (get_post('mb_flag') == 'T')
+ shipping_methods_list_cells(_("Select method:"), 'stock_id', null, _("New method"), true);
+ else
+ stock_items_list_cells(_("Select an item:"), 'stock_id', null,
+ _('New item'), true, check_value('show_inactive'), false,
+ array('fixed_asset' => get_post('mb_flag') == 'F'));
$new_item = get_post('stock_id')=='';
check_cells(_("Show inactive:"), 'show_inactive', null, true);
end_row();
if (!$stock_id)
unset($_POST['_tabs_sel']); // force settings tab for new customer
-$tabs = (get_post('fixed_asset'))
- ? array(
- 'settings' => array(_('&General settings'), $stock_id),
- 'movement' => array(_('&Transactions'), $stock_id) )
- : array(
- 'settings' => array(_('&General settings'), $stock_id),
- 'sales_pricing' => array(_('S&ales Pricing'), (user_check_access('SA_SALESPRICE') ? $stock_id : null)),
- 'purchase_pricing' => array(_('&Purchasing Pricing'), (user_check_access('SA_PURCHASEPRICING') ? $stock_id : null)),
- 'unit_cost' => array(_('Unit &Cost'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)),
- 'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) &&
- user_check_access('SA_REORDER') ? $stock_id : null)),
- 'movement' => array(_('&Transactions'), (user_check_access('SA_ITEMSTRANSVIEW') && is_inventory_item($stock_id) ?
- $stock_id : null)),
- 'status' => array(_('&Status'), (user_check_access('SA_ITEMSSTATVIEW') ? $stock_id : null)),
- );
-
+switch(get_post('mb_flag')) {
+ case 'F':
+ $tabs = array(
+ 'settings' => array(_('&General settings'), $stock_id),
+ 'movement' => array(_('&Transactions'), $stock_id) );
+ break;
+ case 'T':
+ $tabs = array(
+ 'settings' => array(_('&General settings'), $stock_id),
+ 'sales_pricing' => array(_('S&ales Pricing'), (user_check_access('SA_SALESPRICE') ? $stock_id : null)),
+ 'purchase_pricing' => array(_('&Purchasing Pricing'), (user_check_access('SA_PURCHASEPRICING') ? $stock_id : null)),
+ 'unit_cost' => array(_('Unit &Cost'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)),
+ );
+ break;
+
+ default:
+ $tabs = array(
+ 'settings' => array(_('&General settings'), $stock_id),
+ 'sales_pricing' => array(_('S&ales Pricing'), (user_check_access('SA_SALESPRICE') ? $stock_id : null)),
+ 'purchase_pricing' => array(_('&Purchasing Pricing'), (user_check_access('SA_PURCHASEPRICING') ? $stock_id : null)),
+ 'unit_cost' => array(_('Unit &Cost'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)),
+ 'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) &&
+ user_check_access('SA_REORDER') ? $stock_id : null)),
+ 'movement' => array(_('&Transactions'), (user_check_access('SA_ITEMSTRANSVIEW') && is_inventory_item($stock_id) ?
+ $stock_id : null)),
+ 'status' => array(_('&Status'), (user_check_access('SA_ITEMSSTATVIEW') ? $stock_id : null)), );
+}
tabbed_content_start('tabs', $tabs);
switch (get_post('_tabs_sel')) {
div_end();
hidden('fixed_asset', get_post('fixed_asset'));
-
-if (get_post('fixed_asset'))
- hidden('mb_flag', 'F');
+if (in_array(get_post('mb_flag'), array('F', 'T')))
+ hidden('mb_flag', get_post('mb_flag'));
end_form();
$items[] = $ln_itm->stock_id;
$prices[] = round($ln_itm->price * $ln_itm->quantity, user_price_dec());
}
- $taxes = get_tax_for_items($this->trans_type, $items, $prices, 0,
- $this->tax_group_id, $this->tax_included);
+ $taxes = get_tax_for_items($this->trans_type, $items, $prices, $this->tax_group_id, $this->tax_included);
// Adjustment for swiss franken, we always have 5 rappen = 1/20 franken
if ($this->curr_code == 'CHF') {
}
if (!$this->tax_included ) {
- $taxes = get_tax_for_items($this->trans_type, $items, $prices, 0, $this->tax_group_id,
- $this->tax_included);
+ $taxes = get_tax_for_items($this->trans_type, $items, $prices, $this->tax_group_id, $this->tax_included);
foreach($taxes as $tax)
$total += round($tax['Value'], $dec);
$prices[] = round( $ln_itm->this_quantity_inv * $ln_itm->chg_price, user_price_dec());
}
- $taxes = get_tax_for_items($this->trans_type, $items, $prices, 0, $this->tax_group_id,
+ $taxes = get_tax_for_items($this->trans_type, $items, $prices, $this->tax_group_id,
$this->tax_included);
if (isset($this->tax_overrides))
if ($order->fixed_asset)
stock_purchasable_fa_list_cells(null, 'stock_id', null, false, true, false, true, $order->line_items);
else
- stock_items_list_cells(null, 'stock_id', null, false, true, false, true, array('editable' => 30, 'where'=>array("NOT no_purchase")));
+ stock_purchasable_items_list_cells(null, 'stock_id', null, false, true, false, true, array('editable' => 30, 'where'=>array("NOT no_purchase")));
if (list_updated('stock_id')) {
$Ajax->activate('price');
case 'CATEGORIES':
return stock_categories_list($name, null, _("No Category Filter"));
case 'FCATEGORIES':
- return stock_categories_list($name, null, _("No Category Filter"), false, true);
+ return stock_categories_list($name, null, _("No Category Filter"), false, 'F');
case 'FCLASS':
return fixed_asset_classes_list($name, null, _("No Class Filter"), false);
case 'SALESTYPES':
$result = get_sales_order_details($i, ST_SALESORDER);
$SubTotal = 0;
$items = $prices = array();
+ if ($myrow["ship_via"]) {
+ $items[] = $myrow["ship_via"];
+ $prices[] = $myrow["freight_cost"];
+ }
while ($myrow2=db_fetch($result))
{
$Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight))
$rep->NewPage();
}
+
if ($myrow['comments'] != "")
{
$rep->NewLine();
$rep->TextCol(6, 7, $DisplayTotal, -2);
$rep->NewLine();
}
-
- $tax_items = get_tax_for_items(ST_SALESINVOICE, $items, $prices, $myrow["freight_cost"],
- $myrow['tax_group_id'], $myrow['tax_included']);
+ $tax_items = get_tax_for_items(ST_SALESINVOICE, $items, $prices, $myrow['tax_group_id'], $myrow['tax_included']);
$first = true;
foreach($tax_items as $tax_item)
{
$result = get_sales_order_details($i, ST_SALESQUOTE);
$SubTotal = 0;
$items = $prices = array();
+ if ($myrow["ship_via"]) {
+ $items[] = $myrow["ship_via"];
+ $prices[] = $myrow["freight_cost"];
+ }
while ($myrow2=db_fetch($result))
{
$Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
$rep->NewLine();
}
- $tax_items = get_tax_for_items(ST_SALESORDER, $items, $prices, $myrow["freight_cost"],
- $myrow['tax_group_id'], $myrow['tax_included']);
+ $tax_items = get_tax_for_items(ST_SALESORDER, $items, $prices, $myrow['tax_group_id'], $myrow['tax_included']);
$first = true;
foreach($tax_items as $tax_item)
{
$rep->TextCol(6, 7, $DisplaySubTot, -2);
$rep->NewLine();
- $tax_items = get_tax_for_items(ST_PURCHORDER, $items, $prices, 0,
- $myrow['tax_group_id'], $myrow['tax_included'], TCA_LINES);
+ $tax_items = get_tax_for_items(ST_PURCHORDER, $items, $prices, $myrow['tax_group_id'], $myrow['tax_included'], TCA_LINES);
$first = true;
foreach($tax_items as $tax_item)
{
if (!isset($_POST['ship_via'])) {
$_POST['ship_via'] = $_SESSION['Items']->ship_via;
}
-label_cell(_("Shipping Company"), "class='tableheader2'");
-shippers_list_cells(null, 'ship_via', $_POST['ship_via']);
+label_cell(_("Shipping Method"), "class='tableheader2'");
+shipping_methods_list_cells(null, 'ship_via', $_POST['ship_via']);
// set this up here cuz it's used to calc qoh
if (!isset($_POST['DispatchDate']) || !is_date($_POST['DispatchDate'])) {
if (!isset($_POST['ship_via'])) {
$_POST['ship_via'] = $_SESSION['Items']->ship_via;
}
-label_cell(_("Shipping Company"), "class='tableheader2'");
+label_cell(_("Shipping"), "class='tableheader2'");
if ($prepaid)
{
- $shipper = get_shipper($_SESSION['Items']->ship_via);
- label_cells(null, $shipper['shipper_name']);
+ $shipping = get_item($_SESSION['Items']->ship_via);
+ label_cells(null, $shipping['description']);
} else
- shippers_list_cells(null, 'ship_via', $_POST['ship_via']);
+ shipping_methods_list_cells(null, 'ship_via', $_POST['ship_via']);
if (!isset($_POST['InvoiceDate']) || !is_date($_POST['InvoiceDate'])) {
$_POST['InvoiceDate'] = new_doc_date();
// Makes parent documents for direct delivery/invoice by recurent call.
// $policy - 0 or 1: writeoff/return for IV, back order/cancel for DN
function write($policy=0) {
-
+
global $SysPrefs, $Refs;
begin_transaction(); // prevents partial database changes in case of direct delivery/invoice
{
$items = array();
$prices = array();
- if ($shipping_cost == null)
- $shipping_cost = $this->freight_cost;
+ if ($this->ship_via != '') {
+ if ($shipping_cost == null)
+ $shipping_cost = $this->freight_cost;
+ $items[] = $this->ship_via;
+ $prices[] = $shipping_cost;
+ }
foreach ($this->line_items as $ln_itm) {
$items[] = $ln_itm->stock_id;
$ln_itm->line_price()* (1 - $ln_itm->discount_percent)), user_price_dec());
}
- $taxes = get_tax_for_items($this->trans_type, $items, $prices, $shipping_cost,
- $this->tax_group_id, $this->tax_included);
+ $taxes = get_tax_for_items($this->trans_type, $items, $prices, $this->tax_group_id, $this->tax_included);
// Adjustment for swiss franken, we always have 5 rappen = 1/20 franken
if ($this->customer_currency == 'CHF') {
function get_shipping_tax()
{
- $freight = split_item_price(NULL, $this->freight_cost, $this->tax_group_id, $this->tax_included, $this->trans_type);
+ $freight = split_item_price($this->ship_via, $this->freight_cost, $this->tax_group_id, $this->tax_included, $this->trans_type);
return $freight['Tax'];
}
}
if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) {
- // it's an invoice so also get the shipper and salestype
- $sql .= ", ".TB_PREF."shippers.shipper_name, "
+ // it's an invoice so also get the shipping method and salestype
+ $sql .= ", IFNULL(ship.description, '-') shipping, "
.TB_PREF."sales_types.sales_type, "
.TB_PREF."sales_types.tax_included, "
."branch.*, "
$sql .= " FROM ".TB_PREF."debtor_trans trans
LEFT JOIN ".TB_PREF."comments com ON trans.type=com.type AND trans.trans_no=com.id
- LEFT JOIN ".TB_PREF."shippers ON ".TB_PREF."shippers.shipper_id=trans.ship_via,
+ LEFT JOIN ".TB_PREF."stock_master ship ON ship.stock_id=trans.ship_via,
".TB_PREF."debtors_master cust";
if ($trans_type == ST_CUSTPAYMENT || $trans_type == ST_BANKDEPOSIT) {
}
if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) {
- // it's an invoice so also get the shipper, salestypes
$sql .= ", ".TB_PREF."sales_types, "
.TB_PREF."cust_branch branch, "
.TB_PREF."tax_groups ";
$credit_note->customer_id);
}
+ $freight = get_item($credit_note->ship_via);
+
if ($credit_note->freight_cost != 0) {
- $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $company_data["freight_act"], 0, 0,
+ $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $freight["freight_act"], 0, 0,
$credit_note->get_tax_free_shipping(), $credit_note->customer_id);
}
}
$to_allocate = ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax);
+ $freight = get_item($invoice->ship_via);
+
if ($charge_shipping != 0) {
- $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
+ $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $freight["sales_account"], 0, 0,
-$invoice->get_tax_free_shipping()*$prepaid_factor, $invoice->customer_id);
}
// post all taxes
stype.id AS sales_type_id,
stype.tax_included,
stype.factor,
- ship.shipper_name,
+ ship.description as shipping,
tax_group.name AS tax_group_name,
tax_group.id AS tax_group_id,
cust.tax_id,
LEFT JOIN (SELECT order_, sum(alloc) inv_allocs FROM ".TB_PREF."debtor_trans
WHERE type=".ST_SALESINVOICE." AND order_=".db_escape($order_no)." GROUP BY order_)
inv ON sorder.trans_type=".ST_SALESORDER." AND inv.order_=sorder.order_no
- LEFT JOIN ".TB_PREF."shippers ship ON ship.shipper_id = sorder.ship_via,"
+ LEFT JOIN ".TB_PREF."stock_master ship ON ship.stock_id = sorder.ship_via,"
.TB_PREF."debtors_master cust,"
.TB_PREF."sales_types stype, "
.TB_PREF."tax_groups tax_group, "
$change_prices = 1;
}
- shippers_list_row(_("Shipping Company:"), 'ShipperID', $order->ship_via);
+ shipping_methods_list_row(_("Shipping:"), 'ShipperID', $order->ship_via);
label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%");
if ($order->trans_no!=0)
++$colspan;
start_row();
- label_cell(_("Shipping Charge"), "colspan=$colspan align=right");
- small_amount_cells(null, 'freight_cost', price_format(get_post('freight_cost',0)));
- label_cell('', 'colspan=2');
+
+ label_cell(_("Shipping method:") . shipping_methods_list('ship_via', null, _("None"), true), "colspan=$colspan align=right");
+
+ if (get_post('ship_via') !== ALL_TEXT)
+ {
+ small_amount_cells(null, 'freight_cost', price_format(get_post('freight_cost',0)));
+ label_cell('', 'colspan=2');
+ } else
+ label_cell('', 'colspan=3');
end_row();
$display_sub_total = price_format($total + input_num('freight_cost'));
label_row(_("Sub-total"), $display_sub_total, "colspan=$colspan align=right","align=right", 2);
end_outer_table(1); // outer table
+ if (list_updated('ship_via')) {
+ $_SESSION['Items']->ship_via = get_post('ship_via');
+ $_POST['freight_cost'] = price_format(get_price(get_post('ship_via'), $_SESSION['Items']->customer_currency, get_post('sales_type')));
+ $Ajax->activate('items_table');
+ }
+
+
if ($change_prices != 0) {
foreach ($order->line_items as $line_no=>$item) {
$line = &$order->line_items[$line_no];
$line->price = get_kit_price($line->stock_id, $order->customer_currency,
$order->sales_type, $order->price_factor, get_post('OrderDate'));
}
+ }
+ if ($change_prices != 0 || list_updated('ship_via')) {
+ $_POST['freight_cost'] = price_format(get_price(get_post('ship_via'), $_SESSION['Items']->customer_currency, get_post('sales_type')));
$Ajax->activate('items_table');
}
_('Customer reference number for this order (if any)'));
textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5);
- shippers_list_row(_("Shipping Company:"), 'ship_via', $order->ship_via);
-
end_outer_table(1);
}
div_end();
sales_areas_list_row( _("Sales Area:"), 'area', null);
sales_groups_list_row(_("Sales Group:"), 'group_no', null, true);
locations_list_row(_("Default Inventory Location:"), 'default_location', null);
- shippers_list_row(_("Default Shipping Company:"), 'default_ship_via', null);
+ shipping_methods_list_row(_("Default Shipping:"), 'default_ship_via', null);
tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
table_section_title(_("GL Accounts"));
{
table_section_title(_("Branch"));
locations_list_row(_("Default Inventory Location:"), 'location');
- shippers_list_row(_("Default Shipping Company:"), 'ship_via');
+ shipping_methods_list_row(_("Default Shipping:"), 'ship_via');
sales_areas_list_row( _("Sales Area:"), 'area', null);
tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
}
{
$cart = &$_SESSION['Items'];
+
$cart->reference = $_POST['ref'];
$cart->Comments = $_POST['Comments'];
$cart->document_date = $_POST['OrderDate'];
- $newpayment = false;
+ $newpayment = false;
if (isset($_POST['payment']) && ($cart->payment != $_POST['payment'])) {
$cart->payment = $_POST['payment'];
$cart->payment_terms = get_payment_terms($_POST['payment']);
$newpayment = true;
}
if ($cart->payment_terms['cash_sale']) {
- if ($newpayment) {
+ if ($newpayment)
+ {
$cart->due_date = $cart->document_date;
$cart->phone = $cart->cust_ref = $cart->delivery_address = '';
- $cart->ship_via = 0;
$cart->deliver_to = '';
$cart->prep_amount = 0;
}
$cart->deliver_to = $_POST['deliver_to'];
$cart->delivery_address = $_POST['delivery_address'];
$cart->phone = $_POST['phone'];
- $cart->ship_via = $_POST['ship_via'];
if (!$cart->trans_no || ($cart->trans_type == ST_SALESORDER && !$cart->is_started()))
$cart->prep_amount = input_num('prep_amount', 0);
}
+
+ $cart->ship_via = $_POST['ship_via'];
$cart->Location = $_POST['Location'];
$cart->freight_cost = input_num('freight_cost');
if (isset($_POST['email']))
return false;
}
- if ($_POST['freight_cost'] == "")
- $_POST['freight_cost'] = price_format(0);
-
- if (!check_num('freight_cost',0)) {
+ if (isset($_POST['freight_cost']) && !check_num('freight_cost',0)) {
display_error(_("The shipping cost entered is expected to be numeric."));
set_focus('freight_cost');
return false;
end_row();
start_row();
label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'");
-label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'");
+label_cells(_("Shipping"), $myrow["shipping"], "class='tableheader2'");
end_row();
comments_display_row(ST_CUSTCREDIT, $trans_id);
end_table();
end_row();
start_row();
label_cells(_("Customer Order Ref."), $sales_order["customer_ref"], "class='tableheader2'");
-label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'");
+label_cells(_("Shipping"), $myrow["shipping"], "class='tableheader2'");
label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'");
end_row();
start_row();
end_row();
start_row();
label_cells(_("Customer Order Ref."), $sales_order["customer_ref"], "class='tableheader2'");
-label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'");
+label_cells(_("Shipping"), $myrow["shipping"], "class='tableheader2'");
label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'");
end_row();
start_row();
end_row();
} else
label_row(_("Payment Terms"), $_SESSION['View']->payment_terms['terms'], "class='tableheader2'", "colspan=3");
-
+$shipping = get_item($_SESSION['View']->ship_via);
+label_row(_("Shipping"), $shipping['description'], "class='tableheader2'", "colspan=3");
label_row(_("Delivery Address"), nl2br($_SESSION['View']->delivery_address),
"class='tableheader2'", "colspan=3");
label_row(_("Reference"), $_SESSION['View']->reference, "class='tableheader2'", "colspan=3");
$this->description = _('Upgrade from version 2.4 to 2.5');
}
- //
- // Install procedure. All additional changes
- // not included in sql file should go here.
- //
+ /*
+ Shows parameters to be selected before upgrade (if any)
+ */
+ function show_params($company)
+ {
+
+ display_note(_('Check upgrade parameters below and start upgrade.'));
+ start_table(TABLESTYLE);
+ table_section(1);
+ table_section_title(_("Shipments category default settings"));
+ text_row(_("Category Name:"), 'shipping_cat_description', _('Shippment'), 30, 30);
+ item_tax_types_list_row(_('Item Tax Type:'), 'shipping_tax_type');
+ stock_units_list_row(_('Unit of measure:'), 'shipping_units');
+ gl_all_accounts_list_row(_("Sales Account:"), 'shipping_sales_act', get_company_pref('freight_act'));
+ gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'shipping_cogs_act', get_company_pref('default_cogs_act'));
+ end_table();
+ br();
+
+ }
+
+ /*
+ Fetch & check upgrade parameters, check additional upgrade pre-conditions, set SQL variables.
+ This function is run after successfull switching to target database connection, before sql upgrade script is run.
+ */
+ function prepare()
+ {
+ // set upgrade script parameters
+ foreach( array('shipping_cat_description', 'shipping_tax_type', 'shipping_units', 'shipping_sales_act', 'shipping_cogs_act') as $name)
+ db_query("SET @$name=".db_escape(get_post($name)));
+ return true;
+ }
+
+
+ /*
+ Install procedure. All additional changes
+ not included in sql file should go here.
+ */
function install($company, $force=false)
{
return true;
}
- //
- // optional procedure done after upgrade fail, before backup is restored
- //
+ /*
+ Optional procedure done after upgrade fail, before backup is restored
+ */
function post_fail($company)
{
}
SET tax.tax_group_id = IFNULL(supp.tax_group_id, cust.tax_group_id);
ALTER TABLE `0_tax_groups` ADD COLUMN `tax_area` tinyint(1) NOT NULL DEFAULT '0' AFTER `name`;
+
+# shipment options
+ALTER TABLE `0_stock_master` ADD COLUMN `shipper_id` INT(11) NOT NULL DEFAULT '0' AFTER `vat_category`;
+
+INSERT INTO `0_stock_category` (`description`, `dflt_tax_type`, `dflt_units`, `dflt_mb_flag`, `dflt_sales_act`, `dflt_cogs_act`, `dflt_no_sale`)
+ VALUES (@shipping_cat_description, @shipping_tax_type, @shipping_units, 'T', @shipping_sales_act, @shipping_cogs_act, '1');
+
+SET @shipment_cat=LAST_INSERT_ID();
+
+INSERT INTO `0_stock_master` (`stock_id`, `tax_type_id`, `description`, `units`, `mb_flag`, `sales_account`, `no_sale`, `no_purchase`, `vat_category`, `category_id`, `shipper_id`, `inactive`)
+ SELECT shipper.shipper_name, @shipping_tax_type, shipper.shipper_name, @shipping_units, 'T', @shipping_sales_act, 1, 1, 0, @shipment_cat, shipper.shipper_id, shipper.inactive
+ FROM `0_shippers` shipper;
+
+ALTER TABLE `0_sales_orders` CHANGE COLUMN `ship_via` `ship_via` varchar(20) NOT NULL DEFAULT '';
+
+UPDATE `0_sales_orders` ord
+ LEFT JOIN `0_shippers` ship ON ord.ship_via=ship.shipper_id
+ LEFT JOIN `0_stock_master` stock ON stock.shipper_id=ship.shipper_id
+ SET ord.ship_via=stock.stock_id;
+
+ALTER TABLE `0_debtor_trans` CHANGE COLUMN `ship_via` `ship_via` varchar(20) NOT NULL DEFAULT '';
+
+UPDATE `0_debtor_trans` trans
+ LEFT JOIN `0_shippers` ship ON trans.ship_via=ship.shipper_id
+ LEFT JOIN `0_stock_master` stock ON stock.shipper_id=ship.shipper_id
+ SET trans.ship_via=stock.stock_id;
+
+ALTER TABLE `0_cust_branch` CHANGE COLUMN `default_ship_via` `default_ship_via` varchar(20) NOT NULL DEFAULT '';
+
+UPDATE `0_cust_branch` branch
+ LEFT JOIN `0_shippers` ship ON branch.default_ship_via=ship.shipper_id
+ LEFT JOIN `0_stock_master` stock ON stock.shipper_id=ship.shipper_id
+ SET branch.default_ship_via=stock.stock_id;
+
+ALTER TABLE `0_tax_group_items` DROP COLUMN `tax_shipping`;
`sales_discount_account` varchar(15) NOT NULL DEFAULT '',
`receivables_account` varchar(15) NOT NULL DEFAULT '',
`payment_discount_account` varchar(15) NOT NULL DEFAULT '',
- `default_ship_via` int(11) NOT NULL DEFAULT '1',
+ `default_ship_via` varchar(20) NOT NULL DEFAULT '',
`br_post_address` tinytext NOT NULL,
`group_no` int(11) NOT NULL DEFAULT '0',
`notes` tinytext NOT NULL,
-- Data of table `0_cust_branch` --
INSERT INTO `0_cust_branch` VALUES
-('1', '1', 'Donald Easter LLC', 'Donald Easter', 'N/A', '1', '1', 'DEF', '1', '', '4510', '1200', '4500', '1', 'N/A', '0', '', NULL, '0'),
-('2', '2', 'MoneyMaker Ltd.', 'MoneyMaker', '', '1', '1', 'DEF', '2', '', '4510', '1200', '4500', '1', '', '0', '', NULL, '0');
+('1', '1', 'Donald Easter LLC', 'Donald Easter', 'N/A', '1', '1', 'DEF', '1', '', '4510', '1200', '4500', 'post-std', 'N/A', '0', '', NULL, '0'),
+('2', '2', 'MoneyMaker Ltd.', 'MoneyMaker', '', '1', '1', 'DEF', '2', '', '4510', '1200', '4500', 'post-std', '', '0', '', NULL, '0');
-- Structure of table `0_debtor_trans` --
`alloc` double NOT NULL DEFAULT '0',
`prep_amount` double NOT NULL DEFAULT '0',
`rate` double NOT NULL DEFAULT '1',
- `ship_via` int(11) DEFAULT NULL,
+ `ship_via` varchar(20) NOT NULL DEFAULT '',
`dimension_id` int(11) NOT NULL DEFAULT '0',
`dimension2_id` int(11) NOT NULL DEFAULT '0',
`payment_terms` int(11) DEFAULT NULL,
-- Data of table `0_debtor_trans` --
INSERT INTO `0_debtor_trans` VALUES
-('1', '10', '0', '1', '1', '2018-05-10', '2018-05-05', '001/2018', '1', '1', '6240', '0', '0', '0', '0', '6240', '0', '1', '1', '0', '0', '4', '1'),
-('2', '10', '0', '1', '1', '2018-05-07', '2018-05-07', '002/2018', '1', '2', '300', '0', '0', '0', '0', '300', '0', '1', '1', '0', '0', '4', '1'),
-('3', '10', '0', '2', '2', '2018-05-07', '2018-06-17', '003/2018', '1', '5', '267.14', '0', '0', '0', '0', '0', '0', '1.123', '1', '1', '0', '1', '1'),
-('4', '10', '0', '1', '1', '2018-05-07', '2018-05-07', '004/2018', '1', '7', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1'),
-('5', '10', '0', '1', '1', '2019-01-21', '2019-01-21', '001/2019', '1', '8', '1250', '0', '0', '0', '0', '1250', '0', '1', '1', '0', '0', '4', '1'),
-('1', '12', '0', '1', '1', '2018-05-10', '0000-00-00', '001/2018', '0', '0', '6240', '0', '0', '0', '0', '6240', '0', '1', '0', '0', '0', NULL, '0'),
-('2', '12', '0', '1', '1', '2018-05-07', '0000-00-00', '002/2018', '0', '0', '300', '0', '0', '0', '0', '300', '0', '1', '0', '0', '0', NULL, '0'),
-('3', '12', '0', '1', '1', '2018-05-07', '0000-00-00', '003/2018', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', NULL, '0'),
-('4', '12', '0', '1', '1', '2019-01-21', '0000-00-00', '001/2019', '0', '0', '1250', '0', '0', '0', '0', '1250', '0', '1', '0', '0', '0', NULL, '0'),
-('1', '13', '1', '1', '1', '2018-05-10', '2018-05-05', 'auto', '1', '1', '6240', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1'),
-('2', '13', '1', '1', '1', '2018-05-07', '2018-05-07', 'auto', '1', '2', '300', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1'),
-('3', '13', '1', '2', '2', '2018-05-07', '2018-06-17', 'auto', '1', '5', '267.14', '0', '0', '0', '0', '0', '0', '1.123', '1', '1', '0', '1', '1'),
-('4', '13', '1', '1', '1', '2018-05-07', '2018-05-07', 'auto', '1', '7', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1'),
-('5', '13', '1', '1', '1', '2019-01-21', '2019-01-21', 'auto', '1', '8', '1250', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1');
+('1', '10', '0', '1', '1', '2018-05-10', '2018-05-05', '001/2018', '1', '1', '6240', '0', '0', '0', '0', '6240', '0', '1', 'std-post', '0', '0', '4', '1'),
+('2', '10', '0', '1', '1', '2018-05-07', '2018-05-07', '002/2018', '1', '2', '300', '0', '0', '0', '0', '300', '0', '1', 'std-post', '0', '0', '4', '1'),
+('3', '10', '0', '2', '2', '2018-05-07', '2018-06-17', '003/2018', '1', '5', '267.14', '0', '0', '0', '0', '0', '0', '1.123', 'std-post', '1', '0', '1', '1'),
+('4', '10', '0', '1', '1', '2018-05-07', '2018-05-07', '004/2018', '1', '7', '0', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1'),
+('5', '10', '0', '1', '1', '2019-01-21', '2019-01-21', '001/2019', '1', '8', '1250', '0', '0', '0', '0', '1250', '0', '1', 'std-post', '0', '0', '4', '1'),
+('1', '12', '0', '1', '1', '2018-05-10', '0000-00-00', '001/2018', '0', '0', '6240', '0', '0', '0', '0', '6240', '0', '1', '', '0', '0', NULL, '0'),
+('2', '12', '0', '1', '1', '2018-05-07', '0000-00-00', '002/2018', '0', '0', '300', '0', '0', '0', '0', '300', '0', '1', '', '0', '0', NULL, '0'),
+('3', '12', '0', '1', '1', '2018-05-07', '0000-00-00', '003/2018', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '', '0', '0', NULL, '0'),
+('4', '12', '0', '1', '1', '2019-01-21', '0000-00-00', '001/2019', '0', '0', '1250', '0', '0', '0', '0', '1250', '0', '', '0', '0', '0', NULL, '0'),
+('1', '13', '1', '1', '1', '2018-05-10', '2018-05-05', 'auto', '1', '1', '6240', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1'),
+('2', '13', '1', '1', '1', '2018-05-07', '2018-05-07', 'auto', '1', '2', '300', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1'),
+('3', '13', '1', '2', '2', '2018-05-07', '2018-06-17', 'auto', '1', '5', '267.14', '0', '0', '0', '0', '0', '0', '1.123', 'std-post', '1', '0', '1', '1'),
+('4', '13', '1', '1', '1', '2018-05-07', '2018-05-07', 'auto', '1', '7', '0', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1'),
+('5', '13', '1', '1', '1', '2019-01-21', '2019-01-21', 'auto', '1', '8', '1250', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1');
-- Structure of table `0_debtor_trans_details` --
`comments` tinytext,
`ord_date` date NOT NULL DEFAULT '0000-00-00',
`order_type` int(11) NOT NULL DEFAULT '0',
- `ship_via` int(11) NOT NULL DEFAULT '0',
+ `ship_via` varchar(20) NOT NULL DEFAULT '',
`delivery_address` tinytext NOT NULL,
`contact_phone` varchar(30) DEFAULT NULL,
`contact_email` varchar(100) DEFAULT NULL,
-- Data of table `0_sales_orders` --
INSERT INTO `0_sales_orders` VALUES
-('1', '30', '1', '0', '1', '1', 'auto', '', NULL, '2018-05-10', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-05', '4', '6240', '0', '0'),
-('2', '30', '1', '0', '1', '1', 'auto', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-07', '4', '300', '0', '0'),
-('3', '30', '0', '0', '1', '1', '001/2018', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-08', '4', '300', '0', '0'),
-('4', '30', '0', '0', '2', '2', '002/2018', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'MoneyMaker Ltd.', '0', 'DEF', '2018-05-08', '1', '267.14', '0', '0'),
-('5', '30', '1', '0', '2', '2', 'auto', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'MoneyMaker Ltd.', '0', 'DEF', '2018-06-17', '1', '267.14', '0', '0'),
-('6', '30', '0', '1', '1', '1', '003/2018', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-08', '4', '450', '0', '0'),
-('7', '30', '1', '0', '1', '1', 'auto', '', 'Recurrent Invoice covers period 04/01/2018 - 04/07/2018.', '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-07', '4', '0', '0', '0'),
-('8', '30', '1', '0', '1', '1', 'auto', '', NULL, '2019-01-21', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2019-01-21', '4', '1250', '0', '0');
+('1', '30', '1', '0', '1', '1', 'auto', '', NULL, '2018-05-10', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-05', '4', '6240', '0', '0'),
+('2', '30', '1', '0', '1', '1', 'auto', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-07', '4', '300', '0', '0'),
+('3', '30', '0', '0', '1', '1', '001/2018', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-08', '4', '300', '0', '0'),
+('4', '30', '0', '0', '2', '2', '002/2018', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'MoneyMaker Ltd.', '0', 'DEF', '2018-05-08', '1', '267.14', '0', '0'),
+('5', '30', '1', '0', '2', '2', 'auto', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'MoneyMaker Ltd.', '0', 'DEF', '2018-06-17', '1', '267.14', '0', '0'),
+('6', '30', '0', '1', '1', '1', '003/2018', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-08', '4', '450', '0', '0'),
+('7', '30', '1', '0', '1', '1', 'auto', '', 'Recurrent Invoice covers period 04/01/2018 - 04/07/2018.', '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-07', '4', '0', '0', '0'),
+('8', '30', '1', '0', '1', '1', 'auto', '', NULL, '2019-01-21', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2019-01-21', '4', '1250', '0', '0');
-- Structure of table `0_sales_pos` --
('1', 'Components', '1', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
('2', 'Charges', '1', 'each', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
('3', 'Systems', '1', 'each', 'M', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
-('4', 'Services', '1', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0');
+('4', 'Services', '1', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
+('5', 'Shipping', '1', 'each', 'T', '4430', '5010', '', '', '', '0', '0', '0', '1', '0', '0');
-- Structure of table `0_stock_fa_class` --
`depreciation_date` date NOT NULL DEFAULT '0000-00-00',
`fa_class_id` varchar(20) NOT NULL DEFAULT '',
`vat_category` tinyint(1) NOT NULL DEFAULT '0',
+ `shipper_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`stock_id`)
) ENGINE=InnoDB ;
-- Data of table `0_stock_master` --
INSERT INTO `0_stock_master` VALUES
-('101', '1', '1', 'iPad Air 2 16GB', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '200', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('102', '1', '1', 'iPhone 6 64GB', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '150', '150', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('103', '1', '1', 'iPhone Cover Case', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '10', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('201', '3', '1', 'AP Surf Set', '', 'each', 'M', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '360', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('202', '4', '1', 'Maintenance', '', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('301', '4', '1', 'Support', '', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0');
+('101', '1', '1', 'iPad Air 2 16GB', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '200', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('102', '1', '1', 'iPhone 6 64GB', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '150', '150', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('103', '1', '1', 'iPhone Cover Case', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '10', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('201', '3', '1', 'AP Surf Set', '', 'each', 'M', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '360', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('202', '4', '1', 'Maintenance', '', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('301', '4', '1', 'Support', '', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('post-std', '5', '1', 'Standard post package', '', 'each', 'T', '4430', '5010', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0');
-- Structure of table `0_stock_moves` --
CREATE TABLE `0_tax_group_items` (
`tax_group_id` int(11) NOT NULL DEFAULT '0',
`tax_type_id` int(11) NOT NULL DEFAULT '0',
- `tax_shipping` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`tax_group_id`,`tax_type_id`)
) ENGINE=InnoDB ;
-- Data of table `0_tax_group_items` --
INSERT INTO `0_tax_group_items` VALUES
-('1', '1', '1');
+('1', '1');
-- Structure of table `0_tax_groups` --
`sales_discount_account` varchar(15) NOT NULL DEFAULT '',
`receivables_account` varchar(15) NOT NULL DEFAULT '',
`payment_discount_account` varchar(15) NOT NULL DEFAULT '',
- `default_ship_via` int(11) NOT NULL DEFAULT '1',
+ `default_ship_via` varchar(20) NOT NULL DEFAULT '',
`br_post_address` tinytext NOT NULL,
`group_no` int(11) NOT NULL DEFAULT '0',
`notes` tinytext NOT NULL,
`alloc` double NOT NULL DEFAULT '0',
`prep_amount` double NOT NULL DEFAULT '0',
`rate` double NOT NULL DEFAULT '1',
- `ship_via` int(11) DEFAULT NULL,
+ `ship_via` varchar(20) NOT NULL DEFAULT '',
`dimension_id` int(11) NOT NULL DEFAULT '0',
`dimension2_id` int(11) NOT NULL DEFAULT '0',
`payment_terms` int(11) DEFAULT NULL,
`comments` tinytext,
`ord_date` date NOT NULL DEFAULT '0000-00-00',
`order_type` int(11) NOT NULL DEFAULT '0',
- `ship_via` int(11) NOT NULL DEFAULT '0',
+ `ship_via` varchar(20) NOT NULL DEFAULT '',
`delivery_address` tinytext NOT NULL,
`contact_phone` varchar(30) DEFAULT NULL,
`contact_email` varchar(100) DEFAULT NULL,
('1', 'Components', '1', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
('2', 'Charges', '1', 'each', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
('3', 'Systems', '1', 'each', 'M', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
-('4', 'Services', '1', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0');
+('4', 'Services', '1', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
+('5', 'Shipping', '1', 'each', 'T', '4430', '5010', '', '', '', '0', '0', '0', '1', '0', '0');
-- Structure of table `0_stock_fa_class` --
`depreciation_date` date NOT NULL DEFAULT '0000-00-00',
`fa_class_id` varchar(20) NOT NULL DEFAULT '',
`vat_category` tinyint(1) NOT NULL DEFAULT '0',
+ `shipper_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`stock_id`)
) ENGINE=InnoDB;
-- Data of table `0_stock_master` --
-
+INSERT INTO `0_stock_master` VALUES
+('post-std', '5', '1', 'Standard post package', '', 'each', 'T', '4430', '5010', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0');
-- Structure of table `0_stock_moves` --
DROP TABLE IF EXISTS `0_stock_moves`;
CREATE TABLE `0_tax_group_items` (
`tax_group_id` int(11) NOT NULL DEFAULT '0',
`tax_type_id` int(11) NOT NULL DEFAULT '0',
- `tax_shipping` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`tax_group_id`,`tax_type_id`)
) ENGINE=InnoDB ;
-- Data of table `0_tax_group_items` --
INSERT INTO `0_tax_group_items` VALUES
-('1', '1', '1');
+('1', '1');
-- Structure of table `0_tax_groups` --
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
-function add_tax_group($name, $taxes, $tax_shippings, $tax_area)
+function add_tax_group($name, $taxes, $tax_area)
{
begin_transaction();
$id = db_insert_id();
- add_tax_group_items($id, $taxes, $tax_shippings);
+ add_tax_group_items($id, $taxes);
commit_transaction();
}
-function update_tax_group($id, $name, $taxes, $tax_shippings, $tax_area)
+function update_tax_group($id, $name, $taxes, $tax_area)
{
begin_transaction();
db_query($sql, "could not update tax group");
delete_tax_group_items($id);
- add_tax_group_items($id, $taxes, $tax_shippings);
+ add_tax_group_items($id, $taxes);
- commit_transaction();
+ commit_transaction();
}
function get_all_tax_groups($all=false)
commit_transaction();
}
-function add_tax_group_items($id, $items, $tax_shippings)
+function add_tax_group_items($id, $items)
{
for ($i=0; $i < count($items); $i++)
{
- $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id, tax_shipping)
- VALUES (".db_escape($id).", ".db_escape($items[$i]).", " . $tax_shippings[$i] .")";
- db_query($sql, "could not add item tax group item");
+ $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id)
+ VALUES (".db_escape($id).", ".db_escape($items[$i]).")";
+ db_query($sql, "could not add item tax group item");
}
}
{
$sql = "DELETE FROM ".TB_PREF."tax_group_items WHERE tax_group_id=".db_escape($id);
- db_query($sql, "could not delete item tax group items");
+ db_query($sql, "could not delete item tax group items");
}
//
// Return all tax types with rate value updated according to tax group selected
-// Call the function without arg to find shipment group taxes.
//
-function get_tax_group_rates($group_id=null, $tax_shipping=false)
+function get_tax_group_rates($group_id)
{
global $SysPrefs;
: "CONCAT(t.name, ' (', t.rate, '%)') as tax_type_name,")
."t.sales_gl_code,
t.purchasing_gl_code,
- IF(g.tax_type_id, t.rate, NULL) as rate,
- g.tax_shipping
+ IF(g.tax_type_id, t.rate, NULL) as rate
FROM ".TB_PREF."tax_types t
LEFT JOIN ".TB_PREF."tax_group_items g ON t.id=g.tax_type_id
- AND g.tax_group_id=". ($group_id ? db_escape($group_id) : "(SELECT MIN(id) FROM ".TB_PREF."tax_groups)")
- . " WHERE !t.inactive";
- if ($tax_shipping)
- $sql .= " AND g.tax_shipping=1";
+ AND g.tax_group_id=".db_escape($group_id). " WHERE !t.inactive";
return db_query($sql, "cannot get tax types as array");
}
(SELECT g.id, count(*) cnt
FROM ".TB_PREF."tax_group_items i
LEFT JOIN ".TB_PREF."tax_groups g ON g.id=i.tax_group_id
- WHERE tax_shipping=0 AND tax_area=0 AND !inactive
+ WHERE tax_area=0 AND !inactive
GROUP BY g.id) cnts
ORDER by cnt DESC";
$result = db_query($sql, "cannot get domestic group id");
return $group['id'];
}
-function get_shipping_tax_as_array($id=null)
-{
- $ret_tax_array = array();
-
- $tax_group_items = get_tax_group_rates($id, true);
-
- while ($tax_group_item = db_fetch($tax_group_items))
- {
- $tax_group_item['Value'] = 0;
- $ret_tax_array[$tax_group_item['tax_type_id']] = $tax_group_item;
- }
-
- return $ret_tax_array;
-}
$taxdata = array('tax_area' => $group_data['tax_area'], 'taxes' => null);
- if ($stock_id===null) // shipping special case
- {
- $taxdata['vat_category'] = VC_SERVICES;
- $taxdata['taxes'] = get_tax_group_items_as_array(null);
- return $taxdata;
- }
-
$item_tax_type = get_item_tax_type_for_item($stock_id); // get item tax data
$taxdata['vat_category'] = $item_tax_type['vat_category'];
/*
Main tax procedure splitting transaction item value according to item tax rules applicable:
- $stock_id - stock item code; NULL for shipping
$amount - price/value to be splitted
$tax_group - entity tax group
$tax_included - whether value includes all taxes
//
// $vat_factors - effective part of vat values included in tax; calculated but not included vat is added to net value
//
-function get_tax_for_items($trans_type, $items, $prices, $shipping_cost, $tax_group, $tax_included=null,
+function get_tax_for_items($trans_type, $items, $prices, $tax_group, $tax_included=null,
$tax_algorithm = null, $vat_factors = null, $allow_reverse = true)
{
- // if shipping cost is passed, just add to the prices/items tables
- if ($shipping_cost != 0)
- {
- $items[] = NULL;
- $prices[] = $shipping_cost;
- if ($vat_factors)
- $vat_factors[] = 1;
- }
-
// calculate tax sums
$ret_tax_array = array();
foreach($items as $i => $stock_id)
// create an array of the taxes and array of rates
$taxes = array();
- $tax_shippings = array();
while (($id = find_submit('tax_type_id'))!=-1)
{
if (check_value('tax_type_id'.$id) != 0)
{
$taxes[] = $id;
- $tax_shippings[] = check_value('tax_shipping'.$id);
}
unset($_POST['tax_type_id' . $id]);
- unset($_POST['tax_shipping' . $id]);
}
if ($selected_id != -1)
{
- update_tax_group($selected_id, $_POST['name'], $taxes, $tax_shippings, get_post('tax_area'));
+ update_tax_group($selected_id, $_POST['name'], $taxes, get_post('tax_area'));
display_notification(_('Selected tax group has been updated'));
}
else
{
- add_tax_group($_POST['name'], $taxes, $tax_shippings, get_post('tax_area'));
+ add_tax_group($_POST['name'], $taxes, get_post('tax_area'));
display_notification(_('New tax group has been added'));
}
$items = get_tax_group_rates($selected_id!=-1 ? $selected_id : null);
start_table(TABLESTYLE2);
-$th = array(_("Tax"), "", _("Shipping Tax"));
+$th = array(_("Tax"), "");
table_header($th);
while($item = db_fetch($items))
{
check_cells($item['tax_type_name'], 'tax_type_id' . $item['tax_type_id'],
isset($item['rate']), true, false, "align='center'");
- if (isset($item['rate']))
- check_cells(null, 'tax_shipping' . $item['tax_type_id'], $item['tax_shipping']);
}
else
{
//$_POST['_tax_type_id' . $item['tax_type_id'].'_update'] = 0;
$Ajax->activate('_page_body');
}
- if (check_value('tax_type_id' . $item['tax_type_id'])==1)
- check_cells(null, 'tax_shipping' . $item['tax_type_id'], null);
}
end_row();