Included Sales Pricing, Purchasing Prising, Cost update and Reorder Levels in tabs...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 26 Jan 2013 14:29:51 +0000 (15:29 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 26 Jan 2013 14:29:51 +0000 (15:29 +0100)
inventory/cost_update.php
inventory/includes/db/items_prices_db.inc
inventory/includes/db/items_trans_db.inc
inventory/manage/items.php
inventory/prices.php
inventory/purchasing_data.php
inventory/reorder_level.php

index b5ee125dd966fab6f3094b8360c60692e950d428..e16594b383d75df3d7a1e895210e0113befb6b0e 100644 (file)
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 $page_security = 'SA_STANDARDCOST';
-$path_to_root = "..";
-include_once($path_to_root . "/includes/session.inc");
+if (!@$_GET['popup'])
+       $path_to_root = "..";
+else   
+       $path_to_root = "../..";
 
+include_once($path_to_root . "/includes/session.inc");
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/banking.inc");
 include_once($path_to_root . "/includes/manufacturing.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
-
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
-$js = "";
-if ($use_popup_windows)
-       $js .= get_js_open_window(900, 500);
-page(_($help_context = "Inventory Item Cost Update"), false, false, "", $js);
+
+if (!@$_GET['popup'])
+{
+       $js = "";
+       if ($use_popup_windows)
+               $js .= get_js_open_window(900, 500);
+       page(_($help_context = "Inventory Item Cost Update"), false, false, "", $js);
+}
 
 //--------------------------------------------------------------------------------------
 
@@ -68,8 +74,9 @@ if (isset($_POST['UpdateData']))
 
         if ($update_no > 0)
         {
-               display_note(get_gl_view_str(ST_COSTUPDATE, $update_no, _("View the GL Journal Entries for this Cost Update")), 0, 1);
+               display_notification(get_gl_view_str(ST_COSTUPDATE, $update_no, _("View the GL Journal Entries for this Cost Update")), 0, 1);
         }
+
        }
 }
 
@@ -77,16 +84,25 @@ if (list_updated('stock_id'))
        $Ajax->activate('cost_table');
 //-----------------------------------------------------------------------------------------
 
-start_form();
+$action = $_SERVER['PHP_SELF'];
+if (@$_GET['popup'])
+       $action .= "?stock_id=".get_post('stock_id');
+start_form(false, false, $action);
 
 if (!isset($_POST['stock_id']))
        $_POST['stock_id'] = get_global_stock_item();
 
-echo "<center>" . _("Item:"). "&nbsp;";
-//echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
-echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
+if (!@$_GET['popup'])
+{
+       echo "<center>" . _("Item:"). "&nbsp;";
+       //echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
+       echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
+
+       echo "</center><hr>";
+}
+else
+       br(2);
 
-echo "</center><hr>";
 set_global_stock_item($_POST['stock_id']);
 
 $myrow = get_item($_POST['stock_id']);
@@ -100,6 +116,9 @@ $_POST['labour_cost'] = price_decimal_format($myrow["labour_cost"], $dec2);
 $_POST['overhead_cost'] = price_decimal_format($myrow["overhead_cost"], $dec3);
 
 amount_row(_("Standard Material Cost Per Unit"), "material_cost", null, "class='tableheader2'", null, $dec1);
+
+if (@$_GET['popup'])
+       hidden('_tabs_sel', get_post('_tabs_sel'));
 if ($myrow["mb_flag"]=='M')
 {
        amount_row(_("Standard Labour Cost Per Unit"), "labour_cost", null, "class='tableheader2'", null, $dec2);
@@ -116,6 +135,7 @@ div_end();
 submit_center('UpdateData', _("Update"), true, false, 'default');
 
 end_form();
-end_page();
+if (!@$_GET['popup'])
+       end_page(@$_GET['popup'], false, false);
 
 ?>
index 9b670d2499fb55dbf7ed68ceb5df4a6515bcb48c..bcf734b8baa1342632bcfc826ab3f653eecc3c08 100644 (file)
@@ -53,4 +53,14 @@ function get_stock_price($price_id)
        return db_fetch($result);
 }
 
+function get_stock_price_type_currency($stock_id, $type, $currency)
+{
+       $sql = "SELECT * FROM ".TB_PREF."prices WHERE stock_id=".db_escape($stock_id)."
+               AND sales_type_id=".db_escape($type)."
+               AND curr_abrev=".db_escape($currency);
+       
+       $result = db_query($sql,"price could not be retreived");
+       
+       return db_fetch($result);
+}
 ?>
\ No newline at end of file
index 3b71bf56d6af14d4fc176887ba343de1698ba2ff..0a17b66eeec9b1aaed12ed89c1cea03bfbee68fc 100644 (file)
@@ -58,7 +58,7 @@ function stock_cost_update($stock_id, $material_cost, $labour_cost, $overhead_co
                        $stock_gl_code = get_stock_gl_code($stock_id);
                        $update_no = get_next_trans_no(ST_COSTUPDATE);
                        $memo_ = sprintf(_("Cost was %s changed to %s x quantity on hand for item '%s'"),
-                               number_format2($last_cost, 2), number_format2($new_cost, 2), $$stock_id);
+                               number_format2($last_cost, 2), number_format2($new_cost, 2), $stock_id);
                        add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $date_, $stock_gl_code["adjustment_account"], 
                                $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], $memo_, (-$value_of_change));     
 
index 666486f08b94ddd1295210e20c122d80e8547feb..7e5bb7aeea6b2dd8c5de058f34b9d5afefca7350 100644 (file)
@@ -452,6 +452,10 @@ if (!$stock_id)
 
 tabbed_content_start('tabs', array(
                'settings' => array(_('&General settings'), $stock_id),
+               'sales_pricing' => array(_('S&ales Pricing'), $stock_id),
+               'purchase_pricing' => array(_('&Purchasing Pricing'), $stock_id),
+               'standard_cost' => array(_('Standard &Costs'), $stock_id),
+               'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) ? $stock_id : null)),
                'movement' => array(_('&Transactions'), $stock_id),
                'status' => array(_('&Status'), $stock_id),
        ));
@@ -461,6 +465,30 @@ tabbed_content_start('tabs', array(
                case 'settings':
                        item_settings($stock_id); 
                        break;
+               case 'sales_pricing':
+                       $_GET['stock_id'] = $stock_id;
+                       $_GET['popup'] = 1;
+                       include_once($path_to_root."/inventory/prices.php");
+                       break;
+               case 'purchase_pricing':
+                       $_GET['stock_id'] = $stock_id;
+                       $_GET['popup'] = 1;
+                       include_once($path_to_root."/inventory/purchasing_data.php");
+                       break;
+               case 'standard_cost':
+                       $_GET['stock_id'] = $stock_id;
+                       $_GET['popup'] = 1;
+                       include_once($path_to_root."/inventory/cost_update.php");
+                       break;
+               case 'reorder_level':
+                       if (!is_inventory_item($stock_id))
+                       {
+                               break;
+                       }       
+                       $_GET['stock_id'] = $stock_id;
+                       $_GET['popup'] = 1;
+                       include_once($path_to_root."/inventory/reorder_level.php");
+                       break;
                case 'movement':
                        $_GET['stock_id'] = $stock_id;
                        $_GET['popup'] = 1;
index dfac2aa5a4c6b01c27da23ba0ab1cdca1f7948b7..123c4bd0b0789613bf4faf5f276e119e214bd144 100644 (file)
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 $page_security = 'SA_SALESPRICE';
-$path_to_root = "..";
-include_once($path_to_root . "/includes/session.inc");
-
-page(_($help_context = "Inventory Item Sales prices"));
+if (!@$_GET['popup'])
+       $path_to_root = "..";
+else   
+       $path_to_root = "../..";
 
+include_once($path_to_root . "/includes/session.inc");
 include_once($path_to_root . "/sales/includes/sales_db.inc");
 include_once($path_to_root . "/sales/includes/db/sales_types_db.inc");
 include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
-
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 
+if (!@$_GET['popup'])
+       page(_($help_context = "Inventory Item Sales prices"));
+
 //---------------------------------------------------------------------------------------------------
 
 check_db_has_stock_items(_("There are no items defined in the system."));
@@ -48,15 +51,22 @@ if (!isset($_POST['curr_abrev']))
 
 //---------------------------------------------------------------------------------------------------
 
-start_form();
+$action = $_SERVER['PHP_SELF'];
+if (@$_GET['popup'])
+       $action .= "?stock_id=".get_post('stock_id');
+start_form(false, false, $action);
 
 if (!isset($_POST['stock_id']))
        $_POST['stock_id'] = get_global_stock_item();
 
-echo "<center>" . _("Item:"). "&nbsp;";
-echo sales_items_list('stock_id', $_POST['stock_id'], false, true, '', array('editable' => false));
-echo "<hr></center>";
-
+if (!@$_GET['popup'])
+{
+       echo "<center>" . _("Item:"). "&nbsp;";
+       echo sales_items_list('stock_id', $_POST['stock_id'], false, true, '', array('editable' => false));
+       echo "<hr></center>";
+}
+else
+       br(2);
 set_global_stock_item($_POST['stock_id']);
 
 //----------------------------------------------------------------------------------------------------
@@ -70,6 +80,12 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                display_error( _("The price entered must be numeric."));
                set_focus('price');
        }
+       elseif ($Mode == 'ADD_ITEM' && get_stock_price_type_currency($_POST['stock_id'], $_POST['sales_type_id'], $_POST['curr_abrev']))
+       {
+       $input_error = 1;
+       display_error( _("The sales pricing for this item, sales type and currency has already been added."));
+               set_focus('supplier_id');
+       }
 
        if ($input_error != 1)
        {
@@ -168,6 +184,9 @@ if ($Mode == 'Edit')
 }
 
 hidden('selected_id', $selected_id);
+if (@$_GET['popup'])
+       hidden('_tabs_sel', get_post('_tabs_sel'));
+
 div_start('price_details');
 start_table(TABLESTYLE2);
 
@@ -191,5 +210,6 @@ submit_add_or_update_center($selected_id == -1, '', 'both');
 div_end();
 
 end_form();
-end_page();
+if (!@$_GET['popup'])
+       end_page(@$_GET['popup'], false, false);
 ?>
index 0a7a01c3d02be91c6cae1fe1610af77d2ae9b32e..3f85c0376f522bec9e744933eced092c58ed81c0 100644 (file)
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 $page_security = 'SA_PURCHASEPRICING';
-$path_to_root = "..";
-include_once($path_to_root . "/includes/session.inc");
-
-page(_($help_context = "Supplier Purchasing Data"));
+if (!@$_GET['popup'])
+       $path_to_root = "..";
+else   
+       $path_to_root = "../..";
 
+include_once($path_to_root . "/includes/session.inc");
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/manufacturing.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
 
+if (!@$_GET['popup'])
+       page(_($help_context = "Supplier Purchasing Data"));
+
 check_db_has_purchasable_items(_("There are no purchasable inventory items defined in the system."));
 check_db_has_suppliers(_("There are no suppliers defined in the system."));
 
 //----------------------------------------------------------------------------------------
 simple_page_mode(true);
+if (isset($_GET['stock_id']))
+{
+       $_POST['stock_id'] = $_GET['stock_id'];
+}
 
 //--------------------------------------------------------------------------------------------------
 
@@ -36,7 +44,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        {
        $input_error = 1;
        display_error( _("There is no item selected."));
-       set_focus('stock_id');
+               set_focus('stock_id');
        }
        elseif (!check_num('price', 0))
        {
@@ -50,7 +58,12 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        display_error( _("The conversion factor entered was not numeric. The conversion factor is the number by which the price must be divided by to get the unit price in our unit of measure."));
                set_focus('conversion_factor');
        }
-
+       elseif ($Mode == 'ADD_ITEM' && get_item_purchasing_data($_POST['supplier_id'], $_POST['stock_id']))
+       {
+       $input_error = 1;
+       display_error( _("The purchasing data for this supplier has already been added."));
+               set_focus('supplier_id');
+       }
        if ($input_error == 0)
        {
        if ($Mode == 'ADD_ITEM') 
@@ -93,17 +106,24 @@ if (list_updated('stock_id'))
        $Ajax->activate('price_table');
 //--------------------------------------------------------------------------------------------------
 
-start_form();
+$action = $_SERVER['PHP_SELF'];
+if (@$_GET['popup'])
+       $action .= "?stock_id=".get_post('stock_id');
+start_form(false, false, $action);
 
 if (!isset($_POST['stock_id']))
        $_POST['stock_id'] = get_global_stock_item();
 
-echo "<center>" . _("Item:"). "&nbsp;";
-//Chaitanya : All items can be purchased
-echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
-//echo stock_purchasable_items_list('stock_id', $_POST['stock_id'], false, true);
-
-echo "<hr></center>";
+if (!@$_GET['popup'])
+{
+       echo "<center>" . _("Item:"). "&nbsp;";
+       //Chaitanya : All items can be purchased
+       echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
+       //echo stock_purchasable_items_list('stock_id', $_POST['stock_id'], false, true);
+       echo "<hr></center>";
+}
+else
+       br(2);
 
 set_global_stock_item($_POST['stock_id']);
 
@@ -176,6 +196,9 @@ if ($Mode =='Edit')
 
 br();
 hidden('selected_id', $selected_id);
+if (@$_GET['popup'])
+       hidden('_tabs_sel', get_post('_tabs_sel'));
+
 start_table(TABLESTYLE2);
 
 if ($Mode == 'Edit')
@@ -204,6 +227,7 @@ end_table(1);
 submit_add_or_update_center($selected_id == -1, '', 'both');
 
 end_form();
-end_page();
+if (!@$_GET['popup'])
+       end_page(@$_GET['popup'], false, false);
 
 ?>
index 4e8f02c4fa7ee07e5694c0834b441ce65fa43d77..e2ace58ab33402975313a827e146e14092ca6544 100644 (file)
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 $page_security = 'SA_REORDER';
-$path_to_root = "..";
-include_once($path_to_root . "/includes/session.inc");
-
-page(_($help_context = "Reorder Levels"));
+if (!@$_GET['popup'])
+       $path_to_root = "..";
+else   
+       $path_to_root = "../..";
 
+include_once($path_to_root . "/includes/session.inc");
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
-
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 
+if (!@$_GET['popup'])
+       page(_($help_context = "Reorder Levels"));
+
 check_db_has_costable_items(_("There are no inventory items defined in the system (Purchased or manufactured items)."));
 
 //------------------------------------------------------------------------------------
@@ -35,20 +38,28 @@ if (list_updated('stock_id'))
 }
 //------------------------------------------------------------------------------------
 
-start_form();
+$action = $_SERVER['PHP_SELF'];
+if (@$_GET['popup'])
+       $action .= "?stock_id=".get_post('stock_id');
+start_form(false, false, $action);
 
 if (!isset($_POST['stock_id']))
        $_POST['stock_id'] = get_global_stock_item();
 
-echo "<center>" . _("Item:"). "&nbsp;";
-echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
-
-echo "<hr></center>";
+if (!@$_GET['popup'])
+{
+       echo "<center>" . _("Item:"). "&nbsp;";
+       echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
 
+       echo "<hr></center>";
+}
+else
+       br(2);
 div_start('show_heading');
 stock_item_heading($_POST['stock_id']);
 br();
 div_end();
+
 set_global_stock_item($_POST['stock_id']);
 
 div_start('reorders');
@@ -62,6 +73,9 @@ $k=0; //row colour counter
 
 $result = get_loc_details($_POST['stock_id']);
 
+if (@$_GET['popup'])
+       hidden('_tabs_sel', get_post('_tabs_sel'));
+
 while ($myrow = db_fetch($result))
 {
 
@@ -97,6 +111,7 @@ div_end();
 submit_center('UpdateData', _("Update"), true, false, 'default');
 
 end_form();
-end_page();
+if (!@$_GET['popup'])
+       end_page(@$_GET['popup'], false, false);
 
 ?>