From 9d1c0f50697ae1cd37bb7fd1b6a9a404fa76adb5 Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Thu, 14 Jul 2005 22:33:24 +0000
Subject: [PATCH] Added function_uid and project_uid to stock table.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3455 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../sql/erp5_mysql/z_catalog_stock.zsql       | 10 +++++++
 .../sql/erp5_mysql/z_catalog_stock_list.zsql  | 26 ++++++++++++-------
 .../sql/erp5_mysql/z_create_stock.zsql        |  4 +++
 3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/product/ERP5Catalog/sql/erp5_mysql/z_catalog_stock.zsql b/product/ERP5Catalog/sql/erp5_mysql/z_catalog_stock.zsql
index 9c92ff7bd0..28c3ed45f1 100755
--- a/product/ERP5Catalog/sql/erp5_mysql/z_catalog_stock.zsql
+++ b/product/ERP5Catalog/sql/erp5_mysql/z_catalog_stock.zsql
@@ -17,6 +17,10 @@ getDestinationSectionUid
 isMovement
 getSourcePaymentUid
 getDestinationPaymentUid
+getSourceFunctionUid
+getDestinationFunctionUid
+getSourceProjectUid
+getDestinationProjectUid
 getSimulationState
 getPrice
 getStartDate
@@ -35,6 +39,8 @@ VALUES
   <dtml-sqlvar getDestinationUid type="int">,
   <dtml-if getDestinationSectionUid><dtml-sqlvar getDestinationSectionUid type="int"><dtml-else>NULL</dtml-if>,
   <dtml-if getDestinationPaymentUid><dtml-sqlvar getDestinationPaymentUid type="int"><dtml-else>NULL</dtml-if>,
+  <dtml-if getDestinationFunctionUid><dtml-sqlvar getDestinationFunctionUid type="int"><dtml-else>NULL</dtml-if>,
+  <dtml-if getDestinationProjectUid><dtml-sqlvar getDestinationProjectUid type="int"><dtml-else>NULL</dtml-if>,
   <dtml-if getSourceSectionUid><dtml-sqlvar getSourceSectionUid type="int"><dtml-else>NULL</dtml-if>, 
   <dtml-sqlvar getResourceUid type="int">,
   <dtml-if getInventoriatedQuantity><dtml-sqlvar "getInventoriatedQuantity" type="float"><dtml-else>NULL</dtml-if>,
@@ -52,6 +58,8 @@ VALUES
   <dtml-sqlvar getSourceUid type="int">,  
   <dtml-if getSourceSectionUid><dtml-sqlvar getSourceSectionUid type="int"><dtml-else>NULL</dtml-if>, 
   <dtml-if getSourcePaymentUid><dtml-sqlvar getSourcePaymentUid type="int"><dtml-else>NULL</dtml-if>, 
+  <dtml-if getSourceFunctionUid><dtml-sqlvar getSourceFunctionUid type="int"><dtml-else>NULL</dtml-if>,
+  <dtml-if getSourceProjectUid><dtml-sqlvar getSourceProjectUid type="int"><dtml-else>NULL</dtml-if>,
   <dtml-if getDestinationSectionUid><dtml-sqlvar getDestinationSectionUid type="int"><dtml-else>NULL</dtml-if>,
   <dtml-sqlvar getResourceUid type="int">, 
   <dtml-if getInventoriatedQuantity><dtml-sqlvar "-getInventoriatedQuantity" type="float"><dtml-else>NULL</dtml-if>, 
@@ -73,6 +81,8 @@ VALUES
   <dtml-sqlvar getSourceUid type="int">,  
   <dtml-if getSourceSectionUid><dtml-sqlvar getSourceSectionUid type="int"><dtml-else>NULL</dtml-if>, 
   <dtml-if getSourcePaymentUid><dtml-sqlvar getSourcePaymentUid type="int"><dtml-else>NULL</dtml-if>, 
+  <dtml-if getDestinationFunctionUid><dtml-sqlvar getDestinationFunctionUid type="int"><dtml-else>NULL</dtml-if>,
+  <dtml-if getDestinationProjectUid><dtml-sqlvar getDestinationProjectUid type="int"><dtml-else>NULL</dtml-if>,
   <dtml-if getDestinationSectionUid><dtml-sqlvar getDestinationSectionUid type="int"><dtml-else>NULL</dtml-if>,
   <dtml-sqlvar getResourceUid type="int">, 
   <dtml-if getInventoriatedQuantity><dtml-sqlvar "-getInventoriatedQuantity" type="float"><dtml-else>NULL</dtml-if>, 
diff --git a/product/ERP5Catalog/sql/erp5_mysql/z_catalog_stock_list.zsql b/product/ERP5Catalog/sql/erp5_mysql/z_catalog_stock_list.zsql
index 1159446c55..54ee71df25 100755
--- a/product/ERP5Catalog/sql/erp5_mysql/z_catalog_stock_list.zsql
+++ b/product/ERP5Catalog/sql/erp5_mysql/z_catalog_stock_list.zsql
@@ -17,6 +17,10 @@ getDestinationSectionUid
 isMovement
 getSourcePaymentUid
 getDestinationPaymentUid
+getSourceFunctionUid
+getDestinationFunctionUid
+getSourceProjectUid
+getDestinationProjectUid
 getSimulationState
 getPrice
 getStartDate
@@ -29,10 +33,10 @@ getVariationText</params>
     <dtml-if "isMovement[loop_item]">
       <dtml-if "getResourceUid[loop_item]">
         <dtml-if "getDestinationUid[loop_item]">
-          <dtml-call expr="row_list.append([uid[loop_item], getDestinationUid[loop_item], getDestinationSectionUid[loop_item], getDestinationPaymentUid[loop_item], getSourceSectionUid[loop_item], getResourceUid[loop_item], getInventoriatedQuantity[loop_item], getStopDate[loop_item], getPrice[loop_item], isAccountable[loop_item], getPortalType[loop_item], getSimulationState[loop_item], getVariationText[loop_item]])">
+          <dtml-call expr="row_list.append([uid[loop_item], getDestinationUid[loop_item], getDestinationSectionUid[loop_item], getDestinationPaymentUid[loop_item], getDestinationFunctionUid[loop_item], getDestinationProjectUid[loop_item], getSourceSectionUid[loop_item], getResourceUid[loop_item], getInventoriatedQuantity[loop_item], getStopDate[loop_item], getPrice[loop_item], isAccountable[loop_item], getPortalType[loop_item], getSimulationState[loop_item], getVariationText[loop_item]])">
         </dtml-if>
         <dtml-if "getSourceUid[loop_item]">
-          <dtml-call expr="row_list.append([uid[loop_item], getSourceUid[loop_item], getSourceSectionUid[loop_item], getSourcePaymentUidList[loop_item], getDestinationSectionUid[loop_item], getResourceUid[loop_item], -getInventoriatedQuantity[loop_item], getStartDate[loop_item], getPrice[loop_item], isAccountable[loop_item], getPortalType[loop_item], getSimulationState[loop_item], getVariationText[loop_item]])">
+          <dtml-call expr="row_list.append([uid[loop_item], getSourceUid[loop_item], getSourceSectionUid[loop_item], getSourcePaymentUid[loop_item], getSourceFunctionUid[loop_item], getSourceProjectUid[loop_item], getDestinationSectionUid[loop_item], getResourceUid[loop_item], -getInventoriatedQuantity[loop_item], getStartDate[loop_item], getPrice[loop_item], isAccountable[loop_item], getPortalType[loop_item], getSimulationState[loop_item], getVariationText[loop_item]])">
         </dtml-if>
       </dtml-if>
     </dtml-if>
@@ -48,15 +52,17 @@ VALUES
   <dtml-sqlvar expr="row_item[1]" type="int">,  
   <dtml-sqlvar expr="row_item[2]" type="int" optional>, 
   <dtml-sqlvar expr="row_item[3]" type="int" optional>, 
-  <dtml-sqlvar expr="row_item[4]" type="int" optional>,
-  <dtml-sqlvar expr="row_item[5]" type="int">, 
-  <dtml-sqlvar expr="row_item[6]" type="float" optional>,
-  <dtml-sqlvar expr="row_item[7]" type="datetime" optional>
-  <dtml-sqlvar expr="row_item[8]" type="float" optional>
-  <dtml-sqlvar expr="row_item[9]" type="int" optional>
-  <dtml-sqlvar expr="row_item[10]" type="string" optional>
-  <dtml-sqlvar expr="row_item[11]" type="string" optional>
+  <dtml-sqlvar expr="row_item[4]" type="int" optional>, 
+  <dtml-sqlvar expr="row_item[5]" type="int" optional>, 
+  <dtml-sqlvar expr="row_item[6]" type="int" optional>,
+  <dtml-sqlvar expr="row_item[7]" type="int">, 
+  <dtml-sqlvar expr="row_item[8]" type="float" optional>,
+  <dtml-sqlvar expr="row_item[9]" type="datetime" optional>
+  <dtml-sqlvar expr="row_item[10]" type="float" optional>
+  <dtml-sqlvar expr="row_item[11]" type="int" optional>
   <dtml-sqlvar expr="row_item[12]" type="string" optional>
+  <dtml-sqlvar expr="row_item[13]" type="string" optional>
+  <dtml-sqlvar expr="row_item[14]" type="string" optional>
 )
 <dtml-if sequence-end><dtml-else>,</dtml-if>
     </dtml-in>
diff --git a/product/ERP5Catalog/sql/erp5_mysql/z_create_stock.zsql b/product/ERP5Catalog/sql/erp5_mysql/z_create_stock.zsql
index 0abfca9ebc..6032d4a606 100755
--- a/product/ERP5Catalog/sql/erp5_mysql/z_create_stock.zsql
+++ b/product/ERP5Catalog/sql/erp5_mysql/z_create_stock.zsql
@@ -17,6 +17,8 @@ CREATE TABLE `stock` (
   `node_uid` BIGINT UNSIGNED,
   `section_uid` BIGINT UNSIGNED,
   `payment_uid` BIGINT UNSIGNED,
+  `function_uid` BIGINT UNSIGNED,
+  `project_uid` BIGINT UNSIGNED,
   `mirror_section_uid` BIGINT UNSIGNED,
   `resource_uid` BIGINT UNSIGNED,
   `quantity` real ,
@@ -32,6 +34,8 @@ CREATE TABLE `stock` (
   KEY `mirror_section_uid` (`mirror_section_uid`),
   KEY `node_uid` (`node_uid`),
   KEY `payment_uid` (`payment_uid`),
+  KEY `function_uid` (`function_uid`),
+  KEY `project_uid` (`project_uid`),
   KEY `resource_uid` (`resource_uid`),
   KEY `simulation_state` (`simulation_state`),
   KEY `resource_node_uid` (`resource_uid`, `node_uid`),
-- 
2.30.9