forgotten
[fa-stable.git] / sales / manage / sales_types.php
index bad18a693cd4e623082b2f422f5f57462785930f..195a1a5bc24c7b7c422c61f041b8d3e094417436 100644 (file)
@@ -36,7 +36,8 @@ function can_process()
 
 if (isset($_POST['ADD_ITEM']) && can_process()) 
 {
-       add_sales_type($_POST['sales_type'], isset($_POST['tax_included']));
+       add_sales_type($_POST['sales_type'], isset($_POST['tax_included']) ? 1:0, 
+           $_POST['factor']);
        meta_forward($_SERVER['PHP_SELF']);     
 }
 
@@ -45,7 +46,8 @@ if (isset($_POST['ADD_ITEM']) && can_process())
 if (isset($_POST['UPDATE_ITEM']) && can_process()) 
 {
 
-       update_sales_type($selected_id, $_POST['sales_type'], isset($_POST['tax_included']) ? 1:0);
+       update_sales_type($selected_id, $_POST['sales_type'], isset($_POST['tax_included']) ? 1:0,
+            $_POST['factor']);
        meta_forward($_SERVER['PHP_SELF']);     
 } 
 
@@ -91,21 +93,29 @@ $result = get_all_sales_types();
 
 start_table("$table_style width=30%");
 
-$th = array (_("Type Name"), 'Tax Incl', '','');
+$th = array (_('Type Name'), _('Factor'), _('Tax Incl'), '','');
 table_header($th);
 $k = 0;
+$base_sales = get_base_sales_type();
 
 while ($myrow = db_fetch($result)) 
 {
-       alt_table_row_color($k);
-       label_cell($myrow["sales_type"]);       
+       if ($myrow["id"] == $base_sales)
+           start_row("class='overduebg'");
+       else
+           alt_table_row_color($k);
+       label_cell($myrow["sales_type"]);
+       $f = number_format2($myrow["factor"],4);
+       if($myrow["id"] == $base_sales) $f = "<I>"._('Base')."</I>";
+       label_cell($f); 
        label_cell($myrow["tax_included"] ? _('Yes'):_('No'), 'align=center');  
-    edit_link_cell("selected_id=".$myrow["id"]);
-    delete_link_cell("selected_id=".$myrow["id"]."&delete=1");
+       edit_link_cell("selected_id=".$myrow["id"]);
+       delete_link_cell("selected_id=".$myrow["id"]."&delete=1");
        end_row();
 }
 
 end_table();
+display_note(_("Marked sales type is the company base pricelist for prices calculations."), 0, 0, "class='overduefg'");
 
 //----------------------------------------------------------------------------------------------------
 
@@ -114,6 +124,8 @@ hyperlink_no_params($_SERVER['PHP_SELF'], _("New Sales type"));
 start_form();
  if (!isset($_POST['tax_included']))
        $_POST['tax_included'] = 0;
+ if (!isset($_POST['base']))
+       $_POST['base'] = 0;
 
 start_table("$table_style2 width=30%");
 
@@ -124,12 +136,14 @@ if ($selected_id != -1)
        
        $_POST['sales_type']  = $myrow["sales_type"];
        $_POST['tax_included']  = $myrow["tax_included"];
+       $_POST['factor']  = number_format2($myrow["factor"],4);
        
        hidden('selected_id', $selected_id);
 } 
 
-text_row_ex(_("Sales Type Name:"), 'sales_type', 20);
-check_cells("Tax  included", 'tax_included', $_POST['tax_included']);
+text_row_ex(_("Sales Type Name").':', 'sales_type', 20);
+amount_row(_("Calculation factor").':', 'factor');
+check_row(_("Tax included").':', 'tax_included', $_POST['tax_included']);
 
 end_table(1);