fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [11080] more on logistic


From: Sigurd Nes
Subject: [Fmsystem-commits] [11080] more on logistic
Date: Thu, 25 Apr 2013 19:51:22 +0000

Revision: 11080
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11080
Author:   sigurdne
Date:     2013-04-25 19:51:21 +0000 (Thu, 25 Apr 2013)
Log Message:
-----------
more on logistic

Modified Paths:
--------------
    trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
    trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
    trunk/logistic/setup/setup.inc.php
    trunk/logistic/setup/tables_update.inc.php
    trunk/logistic/templates/base/allocation/book_resources.xsl

Modified: trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php  
2013-04-25 14:20:52 UTC (rev 11079)
+++ trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php  
2013-04-25 19:51:21 UTC (rev 11080)
@@ -47,13 +47,20 @@
                {
                        $this->db->transaction_begin();
 
+                       $allocation_id = $resource_alloc->get_id();
+
+                       if($allocation_id)
+                       {
+                               throw new exception("FIXME: oppdater allokering 
{$allocation_id}");
+                       }
+
                        $value_set = array
                        (
                                'location_id'                   => 
$resource_alloc->get_location_id(),
                                'item_id'                               => 
$this->marshal($resource_alloc->get_resource_id(), 'int'),
                                'item_inventory_id'             => 
$this->marshal($resource_alloc->get_inventory_id(), 'int'),
                                'item_inventory_amount' => 
$this->marshal($resource_alloc->get_allocated_amount(), 'int'),
-                               'allocation_id'                 => 0,//not 
known yet
+       //                      'allocation_id'                 => 0,//not 
known yet
                                'create_user'                   => 
$resource_alloc->get_create_user(),
                                'create_date'                   => time(),
                                'start_date'                    => 
$resource_alloc->get_start_date(),
@@ -90,7 +97,7 @@
                        if($result)
                        {
                                $allocation_id =  
$this->db->get_last_insert_id('lg_requirement_resource_allocation', 'id');
-                               $this->db->query("UPDATE lg_calendar SET 
allocation_id = {$allocation_id} WHERE id = {$calendar_id}", __LINE__,__FILE__);
+//                             $this->db->query("UPDATE lg_calendar SET 
allocation_id = {$allocation_id} WHERE id = {$calendar_id}", __LINE__,__FILE__);
                        }
                        else
                        {
@@ -114,6 +121,14 @@
 
                        $result = $this->db->query('UPDATE 
lg_requirement_resource_allocation SET ' . join(',', $values) . " WHERE 
id=$id", __LINE__,__FILE__);
 
+                       $item_inventory_amount = 
(int)$resource_alloc->get_allocated_amount();
+
+                       $this->db->query("SELECT calendar_id FROM 
lg_requirement_resource_allocation WHERE id = {$id}",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $calendar_id = (int)$this->db->f('calendar_id');
+
+                       $this->db->query("UPDATE lg_calendar SET 
item_inventory_amount = {$item_inventory_amount} WHERE id = 
{$calendar_id}",__LINE__,__FILE__);
+
                        if($result)
                        {
                                return $id;
@@ -131,7 +146,7 @@
                        $requirement_id = (int) $requirement_id;
 
                        $sql = "SELECT item_inventory_amount as count FROM 
lg_requirement_resource_allocation"
-                       . " {$this->join } lg_calendar ON 
lg_requirement_resource_allocation.id = lg_calendar.allocation_id"
+                       . " {$this->join } lg_calendar ON 
lg_requirement_resource_allocation.calendar_id = lg_calendar.id"
                        . " WHERE 
lg_requirement_resource_allocation.requirement_id = {$requirement_id}";
 
                        $this->db->query($sql, __LINE__,__FILE__);
@@ -194,7 +209,7 @@
 
 
                        $tables = "lg_requirement_resource_allocation 
allocation";
-                       $joins .= " {$this->join } lg_calendar ON allocation.id 
= lg_calendar.allocation_id";
+                       $joins .= " {$this->join } lg_calendar ON 
allocation.calendar_id = lg_calendar.id";
                        $joins .= "     {$this->left_join} phpgw_locations ON 
(phpgw_locations.location_id = allocation.location_id)";
                        $joins .= "     {$this->left_join} fm_bim_item ON 
(fm_bim_item.location_id = allocation.location_id and fm_bim_item.id = 
allocation.resource_id )";
                         
@@ -251,13 +266,15 @@
                        $values = array();
                        $items = array();
                        $inventory = array();
+                       $allocations = array();
                        
                        if (!$ids)
                        {
                                return $values;
                        }
                        $sql = "SELECT 
lg_calendar.item_id,lg_calendar.item_inventory_id,lg_calendar.item_inventory_amount,"
-                       . " lg_requirement.activity_id, lg_calendar.start_date, 
lg_calendar.end_date"
+                       . " lg_requirement.activity_id, lg_calendar.start_date, 
lg_calendar.end_date,"
+                       . " lg_requirement_resource_allocation.id AS 
allocation_id"
                        . " FROM lg_requirement_resource_allocation"
                        . " {$this->join} lg_calendar ON 
lg_requirement_resource_allocation.calendar_id = lg_calendar.id"
                        . " {$this->join} lg_requirement ON 
lg_requirement_resource_allocation.requirement_id = lg_requirement.id"
@@ -268,11 +285,13 @@
 
                        while ($this->db->next_record())
                        {
+                               $allocation_id = $this->db->f('allocation_id');
                                $item_id = $this->db->f('item_id');
                                $item_inventory_id = 
$this->db->f('item_inventory_id');
                                $item_allocated_amount = 
$this->db->f('item_inventory_amount');
                                $items[$item_id] = true;
                                $inventory[$item_inventory_id] = 
$item_allocated_amount;
+                               $allocations[$item_inventory_id] = 
$allocation_id;
                                $values[$item_id][] = array
                                (
                                        'start_date'                    => 
$this->db->f('start_date'),
@@ -283,7 +302,7 @@
                                        'item_allocated_amount' => 
$item_inventory_amount
                                );
                        }
-                       return array('calendar' => $values, 'items' => $items, 
'inventory' => $inventory);
+                       return array('calendar' => $values, 'items' => $items, 
'inventory' => $inventory, 'allocations' => $allocations);
                }
 
                function delete($resource_allocation_id)
@@ -291,9 +310,13 @@
                        $this->db->transaction_begin();
 
                        $resource_allocation_id = (int) $resource_allocation_id;
-                       $this->db->query("DELETE FROM 
lg_requirement_resource_allocation WHERE id = $resource_allocation_id");
-                       $this->db->query("DELETE FROM lg_calendar WHERE 
allocation_id = $resource_allocation_id");
+                       $this->db->query("SELECT calendar_id FROM 
lg_requirement_resource_allocation WHERE id = 
{$resource_allocation_id}",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $calendar_id = (int)$this->db->f('calendar_id');
 
+                       $this->db->query("DELETE FROM 
lg_requirement_resource_allocation WHERE id = {$resource_allocation_id}");
+                       $this->db->query("DELETE FROM lg_calendar WHERE id = 
{$calendar_id}");
+
                        return !!$this->db->transaction_commit();
                }
                

Modified: trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php  
2013-04-25 14:20:52 UTC (rev 11079)
+++ trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php  
2013-04-25 19:51:21 UTC (rev 11080)
@@ -452,6 +452,7 @@
                                        foreach 
($allocation_suggestion['inventory'] as & $inventory)
                                        {
                                                $inventory['allocated_amount'] 
= $allocated['inventory'][$inventory['inventory_id']];
+                                               $inventory['allocation_id'] = 
$allocated['allocations'][$inventory['inventory_id']];
                                        }
                                }
                        }
@@ -484,7 +485,7 @@
                        $chosen_resources = phpgw::get_var('chosen_resources');
                        
                        $inventory_ids = phpgw::get_var('inventory_ids');
-                       $inventory_ids_orig = 
phpgw::get_var('inventory_ids_orig');
+                       $allocations = phpgw::get_var('allocations');
                        //FIXME: Bruk 'allocation_id' i staden.
 
 //_debug_array($inventory_ids_orig);die();
@@ -510,7 +511,7 @@
                                                
$resource_alloc->set_resource_id( $resource_id );
                                                
$resource_alloc->set_inventory_id( $inventory_id );
                                                
$resource_alloc->set_allocated_amount( $allocated_amount );
-                                               
$resource_alloc->set_allocated_amount_orig( $inventory_ids_orig[$resource] );
+                                               $resource_alloc->set_id( 
$allocations[$resource] );
                                                
$resource_alloc->set_location_id( $requirement->get_location_id() );
                                                
$resource_alloc->set_create_user( $user_id );
                                                
$resource_alloc->set_start_date( $requirement->get_start_date() );

Modified: trunk/logistic/setup/setup.inc.php
===================================================================
--- trunk/logistic/setup/setup.inc.php  2013-04-25 14:20:52 UTC (rev 11079)
+++ trunk/logistic/setup/setup.inc.php  2013-04-25 19:51:21 UTC (rev 11080)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['logistic']['name'] = 'logistic';
-       $setup_info['logistic']['version'] = '0.0.5';
+       $setup_info['logistic']['version'] = '0.0.6';
        $setup_info['logistic']['app_order'] = 70;
        $setup_info['logistic']['enable'] = 1;
        $setup_info['logistic']['app_group']    = 'office';

Modified: trunk/logistic/setup/tables_update.inc.php
===================================================================
--- trunk/logistic/setup/tables_update.inc.php  2013-04-25 14:20:52 UTC (rev 
11079)
+++ trunk/logistic/setup/tables_update.inc.php  2013-04-25 19:51:21 UTC (rev 
11080)
@@ -173,9 +173,8 @@
        {
                $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
 
+//             $GLOBALS['phpgw_setup']->oProc->DropColumn('lg_calendar', 
array(), 'allocation_id');
 
-               $GLOBALS['phpgw_setup']->oProc->DropColumn('lg_calendar', 
array(), 'allocation_id');
-
                
$GLOBALS['phpgw_setup']->oProc->AddColumn('lg_calendar','item_inventory_id',array(
                        'type' => 'int',
                        'precision' => 4,

Modified: trunk/logistic/templates/base/allocation/book_resources.xsl
===================================================================
--- trunk/logistic/templates/base/allocation/book_resources.xsl 2013-04-25 
14:20:52 UTC (rev 11079)
+++ trunk/logistic/templates/base/allocation/book_resources.xsl 2013-04-25 
19:51:21 UTC (rev 11080)
@@ -112,7 +112,7 @@
                                                                                
        <span class="loc_code">
                                                                                
                <input type="text" value="{allocated_amount}" 
name="inventory_ids[{//allocation_suggestions/id}_{inventory_id}]" size='4'>
                                                                                
                </input>
-                                                                               
                <input type="hidden" value="{allocated_amount}" 
name="inventory_ids_orig[{//allocation_suggestions/id}_{inventory_id}]">
+                                                                               
                <input type="hidden" value="{allocation_id}" 
name="allocations[{//allocation_suggestions/id}_{inventory_id}]">
                                                                                
                </input>
                                                                                
        </span>
                                                                                
        <span class="loc_code"><xsl:value-of disable-output-escaping="yes" 
select="where" /></span>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]