Added 'no_purchase' option in stock_master and stock_categories.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Fri, 12 Oct 2012 15:56:25 +0000 (17:56 +0200)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Fri, 12 Oct 2012 15:56:25 +0000 (17:56 +0200)
includes/ui/ui_lists.inc
inventory/includes/db/items_category_db.inc
inventory/includes/db/items_db.inc
inventory/manage/item_categories.php
inventory/manage/items.php
purchasing/includes/ui/po_ui.inc
sql/alter2.4.sql
sql/en_US-demo.sql
sql/en_US-new.sql

index 68f67092fc50be9782661dcc99f405e7a1ee95dc..11ea90c648332ffbd485ce0b444c0caeac40a172 100644 (file)
@@ -922,7 +922,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("mb_flag!= 'M'"), 
+               array('where'=>array("NOT no_purchase"), 
                        'show_inactive'=>$all), $editkey);
 }
 //
@@ -934,7 +934,7 @@ function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
        if ($label != null)
                echo "<td>$label</td>\n";
        echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("mb_flag!= 'M'"), 
+               array('where'=>array("NOT no_purchase"), 
                         'editable' => 30,
                         'cells'=>true), $editkey);
 }
index 27a4ed6bf600da29132de2c44bf21cdf7a2dc566..25368ee75e12c1357e0e002e74ab686b952af1c6 100644 (file)
 ***********************************************************************/
 function add_item_category($description, $tax_type_id, $sales_account, 
        $cogs_account, $inventory_account, $adjustment_account, $assembly_account, 
-       $units, $mb_flag, $dim1, $dim2, $no_sale)
+       $units, $mb_flag, $dim1, $dim2, $no_sale, $no_purchase)
 {
        $sql = "INSERT INTO ".TB_PREF."stock_category (description, dflt_tax_type,
                        dflt_units, dflt_mb_flag, dflt_sales_act, dflt_cogs_act, 
                        dflt_inventory_act, dflt_adjustment_act, dflt_assembly_act, 
-                       dflt_dim1, dflt_dim2, dflt_no_sale)
+                       dflt_dim1, dflt_dim2, dflt_no_sale, dflt_no_purchase)
                VALUES ("
                .db_escape($description).","
                .db_escape($tax_type_id).","
@@ -29,14 +29,15 @@ function add_item_category($description, $tax_type_id, $sales_account,
                .db_escape($assembly_account).","
                .db_escape($dim1).","
                .db_escape($dim2).","
-               .db_escape($no_sale).")";
+               .db_escape($no_sale).","
+               .db_escape($no_purchase).")";
 
        db_query($sql,"an item category could not be added");
 }
 
 function update_item_category($id, $description, $tax_type_id, 
        $sales_account, $cogs_account, $inventory_account, $adjustment_account, 
-       $assembly_account, $units, $mb_flag, $dim1, $dim2, $no_sale)
+       $assembly_account, $units, $mb_flag, $dim1, $dim2, $no_sale, $no_purchase)
 
 {
        $sql = "UPDATE ".TB_PREF."stock_category SET "
@@ -51,7 +52,8 @@ function update_item_category($id, $description, $tax_type_id,
                ."dflt_assembly_act = ".db_escape($assembly_account).","
                ."dflt_dim1 = ".db_escape($dim1).","
                ."dflt_dim2 = ".db_escape($dim2).","
-               ."dflt_no_sale = ".db_escape($no_sale)
+               ."dflt_no_sale = ".db_escape($no_sale).","
+               ."dflt_no_purchase = ".db_escape($no_purchase)
         ."WHERE category_id = ".db_escape($id);
 
        db_query($sql,"an item category could not be updated");
index de6ce056ccd7376d6594a92a74e283f2c459e6fa..60bac30061679dae94b8c90eb2a5b28d263fe265 100644 (file)
@@ -12,7 +12,7 @@
 function update_item($stock_id, $description, $long_description, $category_id, 
        $tax_type_id, $units='', $mb_flag='', $sales_account, $inventory_account, 
        $cogs_account,  $adjustment_account, $assembly_account, $dimension_id, 
-       $dimension2_id, $no_sale, $editable)
+       $dimension2_id, $no_sale, $editable, $no_purchase)
 {
        $sql = "UPDATE ".TB_PREF."stock_master SET long_description=".db_escape($long_description).",
                description=".db_escape($description).",
@@ -26,6 +26,7 @@ function update_item($stock_id, $description, $long_description, $category_id,
                dimension2_id=".db_escape($dimension2_id).",
                tax_type_id=".db_escape($tax_type_id).",
                no_sale=".db_escape($no_sale).",
+               no_purchase=".db_escape($no_purchase).",
                editable=".db_escape($editable);
 
        if ($units != '')
@@ -44,7 +45,7 @@ function update_item($stock_id, $description, $long_description, $category_id,
 function add_item($stock_id, $description, $long_description, $category_id, 
        $tax_type_id, $units, $mb_flag, $sales_account, $inventory_account, 
        $cogs_account, $adjustment_account,     $assembly_account, $dimension_id, 
-       $dimension2_id, $no_sale, $editable)
+       $dimension2_id, $no_sale, $editable, $no_purchase)
 {
        $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,
@@ -57,6 +58,7 @@ function add_item($stock_id, $description, $long_description, $category_id,
                .", ".db_escape($assembly_account).", "
                .db_escape($dimension_id).", ".db_escape($dimension2_id).","
                .db_escape($no_sale).","
+               .db_escape($no_purchase).","
                .db_escape($editable).")";
 
        db_query($sql, "The item could not be added");
index b52d67c812b27497a42eb5f4a54258bd37086148..7ec99d391e2d03de29e6cac12cd59a8631c910b4 100644 (file)
@@ -44,7 +44,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                                $_POST['cogs_account'], $_POST['inventory_account'], 
                                $_POST['adjustment_account'], $_POST['assembly_account'],
                                $_POST['units'], $_POST['mb_flag'],     $_POST['dim1'], $_POST['dim2'],
-                               check_value('no_sale'));
+                               check_value('no_sale'), check_value('no_purchase'));
                        display_notification(_('Selected item category has been updated'));
        } 
        else 
@@ -54,7 +54,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                                $_POST['cogs_account'], $_POST['inventory_account'], 
                                $_POST['adjustment_account'], $_POST['assembly_account'], 
                                $_POST['units'], $_POST['mb_flag'],     $_POST['dim1'], 
-                               $_POST['dim2'], check_value('no_sale'));
+                               $_POST['dim2'], check_value('no_sale'), check_value('no_purchase'));
                        display_notification(_('New item category has been added'));
        }
                $Mode = 'RESET';
@@ -150,6 +150,7 @@ if ($selected_id != -1)
                $_POST['dim1']  = $myrow["dflt_dim1"];
                $_POST['dim2']  = $myrow["dflt_dim2"];
                $_POST['no_sale']  = $myrow["dflt_no_sale"];
+               $_POST['no_purchase']  = $myrow["dflt_no_purchase"];
        } 
        hidden('selected_id', $selected_id);
        hidden('category_id');
@@ -157,6 +158,7 @@ if ($selected_id != -1)
                $_POST['long_description'] = '';
                $_POST['description'] = '';
                $_POST['no_sale']  = 0;
+               $_POST['no_purchase']  = 0;
 
                $company_record = get_company_prefs();
 
@@ -189,6 +191,8 @@ stock_units_list_row(_("Units of Measure:"), 'units', null);
 
 check_row(_("Exclude from sales:"), 'no_sale');
 
+check_row(_("Exclude from purchases:"), 'no_purchase');
+
 gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']);
 
 if (is_service($_POST['mb_flag']))
index 70572f59fed52f10d7245ca162d4941a38af1864..9a91acc229e6d199234248f65260c4f185d83cd5 100644 (file)
@@ -126,6 +126,7 @@ function clear_data()
        unset($_POST['dimension_id']);
        unset($_POST['dimension2_id']);
        unset($_POST['no_sale']);
+       unset($_POST['no_purchase']);
 }
 
 //------------------------------------------------------------------------------------
@@ -182,7 +183,7 @@ if (isset($_POST['addupdate']))
                                $_POST['inventory_account'], $_POST['cogs_account'],
                                $_POST['adjustment_account'], $_POST['assembly_account'], 
                                $_POST['dimension_id'], $_POST['dimension2_id'],
-                               check_value('no_sale'), check_value('editable'));
+                               check_value('no_sale'), check_value('editable'), check_value('no_purchase'));
                        update_record_status($_POST['NewStockID'], $_POST['inactive'],
                                'stock_master', 'stock_id');
                        update_record_status($_POST['NewStockID'], $_POST['inactive'],
@@ -200,12 +201,12 @@ if (isset($_POST['addupdate']))
                                $_POST['inventory_account'], $_POST['cogs_account'],
                                $_POST['adjustment_account'], $_POST['assembly_account'], 
                                $_POST['dimension_id'], $_POST['dimension2_id'],
-                               check_value('no_sale'), check_value('editable'));
+                               check_value('no_sale'), check_value('editable'), check_value('no_purchase'));
 
                        display_notification(_("A new item has been added."));
                        $_POST['stock_id'] = $_POST['NewStockID'] = 
                        $_POST['description'] = $_POST['long_description'] = '';
-                       $_POST['no_sale'] = $_POST['editable'] = 0;
+                       $_POST['no_sale'] = $_POST['editable'] = $_POST['no_purchase'] =0;
                        set_focus('NewStockID');
                }
                $Ajax->activate('_page_body');
@@ -294,7 +295,8 @@ function item_settings(&$stock_id)
                        $_POST['dimension_id']  = $myrow['dimension_id'];
                        $_POST['dimension2_id'] = $myrow['dimension2_id'];
                        $_POST['no_sale']       = $myrow['no_sale'];
-                       $_POST['del_image'] = 0;        
+                       $_POST['no_purchase']   = $myrow['no_purchase'];
+                       $_POST['del_image'] = 0;
                        $_POST['inactive'] = $myrow["inactive"];
                        $_POST['editable'] = $myrow["editable"];
                }
@@ -324,6 +326,7 @@ function item_settings(&$stock_id)
                $_POST['dimension_id'] = $category_record["dflt_dim1"];
                $_POST['dimension2_id'] = $category_record["dflt_dim2"];
                $_POST['no_sale'] = $category_record["dflt_no_sale"];
+               $_POST['no_purchase'] = $category_record["dflt_no_purchase"];
                $_POST['editable'] = 0;
 
        }
@@ -340,6 +343,8 @@ function item_settings(&$stock_id)
 
        check_row(_("Exclude from sales:"), 'no_sale');
 
+       check_row(_("Exclude from purchases:"), 'no_purchase');
+
        table_section(2);
 
        $dim = get_company_pref('use_dimension');
index 18093ceff59b4a351259f2c2750ec036b21771f0..8adca98b97edbaf258c81c9497f576be21e3764a 100644 (file)
@@ -412,9 +412,7 @@ function po_item_controls(&$order, &$rowcounter, $line_no=-1)
        {
 //             hidden('line_no', ($_SESSION['PO']->lines_on_order + 1));
 
-               //Chaitanya : Manufcatured item can be purchased
-               stock_items_list_cells(null, 'stock_id', null, false, true, true);
-               //stock_purchasable_items_list_cells(null, 'stock_id', null, false, true, true);
+               stock_purchasable_items_list_cells(null, 'stock_id', null, false, true, true);
                if (list_updated('stock_id')) {
                            $Ajax->activate('price');
                            $Ajax->activate('units');
index 4d86ae3bee37b67e6c617ce1704c71614a3eeff2..727621cd551c4cd9fcb4648bf856318cec75438e 100644 (file)
@@ -76,3 +76,6 @@ UPDATE `0_security_roles` SET `sections`=CONCAT_WS(';', `sections`, '768'), `are
 
 UPDATE `0_security_roles` SET `areas`=CONCAT_WS(';', `areas`, '775')
        WHERE NOT `areas` REGEXP '[^0-9]?775[^0-9]?';
+
+ALTER TABLE `0_stock_master` ADD COLUMN `no_purchase` tinyint(1) NOT NULL default '0' AFTER `no_sale`;
+ALTER TABLE `0_stock_category` ADD COLUMN `dflt_no_purchase` tinyint(1) NOT NULL default '0' AFTER `dflt_no_sale`;
index 91ced85f6dc3104f36581d294a37392528c1abe9..4043aa5b4ea186a4f16b23f0f8a6b8d684b146de 100644 (file)
@@ -1746,6 +1746,7 @@ CREATE TABLE IF NOT EXISTS `0_stock_category` (
   `dflt_dim2` int(11) default NULL,
   `inactive` tinyint(1) NOT NULL default '0',
   `dflt_no_sale` tinyint(1) NOT NULL default '0',
+  `dflt_no_purchase` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`category_id`),
   UNIQUE KEY `description` (`description`)
 ) ENGINE=MyISAM  AUTO_INCREMENT=5 ;
@@ -1754,10 +1755,10 @@ CREATE TABLE IF NOT EXISTS `0_stock_category` (
 -- Dumping data for table `0_stock_category`
 --
 
-INSERT INTO `0_stock_category` VALUES(1, 'Components', 1, 'each', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0);
-INSERT INTO `0_stock_category` VALUES(2, 'Charges', 1, 'each', 'D', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0);
-INSERT INTO `0_stock_category` VALUES(3, 'Systems', 1, 'each', 'M', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0);
-INSERT INTO `0_stock_category` VALUES(4, 'Services', 1, 'hrs', 'D', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0);
+INSERT INTO `0_stock_category` VALUES(1, 'Components', 1, 'each', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_category` VALUES(2, 'Charges', 1, 'each', 'D', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_category` VALUES(3, 'Systems', 1, 'each', 'M', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_category` VALUES(4, 'Services', 1, 'hrs', 'D', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 0);
 
 -- --------------------------------------------------------
 
@@ -1788,6 +1789,7 @@ CREATE TABLE IF NOT EXISTS `0_stock_master` (
   `overhead_cost` double NOT NULL default '0',
   `inactive` tinyint(1) NOT NULL default '0',
   `no_sale` tinyint(1) NOT NULL default '0',
+  `no_purchase` tinyint(1) NOT NULL default '0',
   `editable` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`stock_id`)
 ) ENGINE=InnoDB;
@@ -1796,11 +1798,11 @@ CREATE TABLE IF NOT EXISTS `0_stock_master` (
 -- Dumping data for table `0_stock_master`
 --
 
-INSERT INTO `0_stock_master` VALUES('102', 1, 1, '17inch VGA Monitor', '', 'ea.', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 10, 0, 0, 0, 0, 0);
-INSERT INTO `0_stock_master` VALUES('103', 1, 1, '32MB VGA Card', '', 'ea.', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 11, 0, 0, 0, 0, 0);
-INSERT INTO `0_stock_master` VALUES('104', 1, 1, '52x CD Drive', '', 'ea.', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 12, 0, 0, 0, 0, 0);
-INSERT INTO `0_stock_master` VALUES('201', 4, 1, 'Assembly Labour', '', 'hrs', 'D', '4010', '5010', '5010', '5040', '1530', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-INSERT INTO `0_stock_master` VALUES('3400', 3, 1, 'P4 Business System', '', 'ea.', 'M', '4010', '5010', '1540', '5040', '1530', 0, 0, 0, 0, 33, 3.9999999999999, 2, 0, 0, 0);
+INSERT INTO `0_stock_master` VALUES('102', 1, 1, '17inch VGA Monitor', '', 'ea.', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_master` VALUES('103', 1, 1, '32MB VGA Card', '', 'ea.', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_master` VALUES('104', 1, 1, '52x CD Drive', '', 'ea.', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_master` VALUES('201', 4, 1, 'Assembly Labour', '', 'hrs', 'D', '4010', '5010', '5010', '5040', '1530', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_master` VALUES('3400', 3, 1, 'P4 Business System', '', 'ea.', 'M', '4010', '5010', '1540', '5040', '1530', 0, 0, 0, 0, 33, 3.9999999999999, 2, 0, 0, 0, 0);
 
 -- --------------------------------------------------------
 
index 240f85d62a53cc88294335c7ca73c2cd5dde5f98..7f61422be31a8cade1acb79fd0582134c409a51e 100644 (file)
@@ -1558,6 +1558,7 @@ CREATE TABLE IF NOT EXISTS `0_stock_category` (
   `dflt_dim2` int(11) default NULL,
   `inactive` tinyint(1) NOT NULL default '0',
   `dflt_no_sale` tinyint(1) NOT NULL default '0',
+  `dflt_no_sale` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`category_id`),
   UNIQUE KEY `description` (`description`)
 ) ENGINE=MyISAM  AUTO_INCREMENT=5 ;
@@ -1566,10 +1567,10 @@ CREATE TABLE IF NOT EXISTS `0_stock_category` (
 -- Dumping data for table `0_stock_category`
 --
 
-INSERT INTO `0_stock_category` VALUES(1, 'Components', 1, 'each', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0);
-INSERT INTO `0_stock_category` VALUES(2, 'Charges', 1, 'each', 'D', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0);
-INSERT INTO `0_stock_category` VALUES(3, 'Systems', 1, 'each', 'M', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0);
-INSERT INTO `0_stock_category` VALUES(4, 'Services', 1, 'hrs', 'D', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0);
+INSERT INTO `0_stock_category` VALUES(1, 'Components', 1, 'each', 'B', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_category` VALUES(2, 'Charges', 1, 'each', 'D', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_category` VALUES(3, 'Systems', 1, 'each', 'M', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 0);
+INSERT INTO `0_stock_category` VALUES(4, 'Services', 1, 'hrs', 'D', '4010', '5010', '1510', '5040', '1530', 0, 0, 0, 0, 0);
 
 -- --------------------------------------------------------
 
@@ -1600,6 +1601,7 @@ CREATE TABLE IF NOT EXISTS `0_stock_master` (
   `overhead_cost` double NOT NULL default '0',
   `inactive` tinyint(1) NOT NULL default '0',
   `no_sale` tinyint(1) NOT NULL default '0',
+  `no_purchase` tinyint(1) NOT NULL default '0',
   `editable` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`stock_id`)
 ) ENGINE=InnoDB;