[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11079] more on logistic
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11079] more on logistic |
Date: |
Thu, 25 Apr 2013 14:20:54 +0000 |
Revision: 11079
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11079
Author: sigurdne
Date: 2013-04-25 14:20:52 +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.inc.php
trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
trunk/logistic/inc/model/class.requirement_resource_allocation.inc.php
trunk/logistic/setup/tables_current.inc.php
trunk/logistic/setup/tables_update.inc.php
trunk/logistic/templates/base/allocation/book_resources.xsl
trunk/logistic/templates/base/requirement/requirement_overview.xsl
trunk/property/inc/class.boentity.inc.php
trunk/property/inc/class.soentity.inc.php
trunk/property/inc/class.uientity.inc.php
Modified: trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
2013-04-25 08:54:16 UTC (rev 11078)
+++ trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
2013-04-25 14:20:52 UTC (rev 11079)
@@ -49,14 +49,15 @@
$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'),
- 'allocation_id' => 0,//not known yet
- 'create_user' =>
$resource_alloc->get_create_user(),
- 'create_date' => time(),
- 'start_date' =>
$resource_alloc->get_start_date(),
- 'end_date' =>
$resource_alloc->get_end_date(),
+ '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
+ 'create_user' =>
$resource_alloc->get_create_user(),
+ 'create_date' => time(),
+ 'start_date' =>
$resource_alloc->get_start_date(),
+ 'end_date' =>
$resource_alloc->get_end_date(),
);
$sql = 'INSERT INTO lg_calendar (' . implode(',',
array_keys($value_set)) . ') VALUES (' . implode(',', array_values($value_set))
. ')';
@@ -123,6 +124,30 @@
}
}
+
+ public function count_allocated($requirement_id)
+ {
+
+ $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"
+ . " WHERE
lg_requirement_resource_allocation.requirement_id = {$requirement_id}";
+
+ $this->db->query($sql, __LINE__,__FILE__);
+ $sum = 0;
+ while ($this->db->next_record())
+ {
+ if(!$count = $this->db->f('count'))
+ {
+ $count = 1;
+ }
+ $sum += $count;
+ }
+
+ return $sum;
+ }
+
protected function get_id_field_name()
{
if(!$extended_info)
@@ -169,6 +194,7 @@
$tables = "lg_requirement_resource_allocation
allocation";
+ $joins .= " {$this->join } lg_calendar ON allocation.id
= lg_calendar.allocation_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 )";
@@ -179,6 +205,8 @@
else
{
$cols .= "allocation.*, ";
+ $cols .= "lg_calendar.item_inventory_amount as
count,";
+ $cols .= "lg_calendar.item_inventory_id as
inventory_id,";
$cols .= "phpgw_locations.descr AS
resource_type_descr, ";
$cols .= "fm_bim_item.location_code AS
location_code, (xpath('//address/node()',
fm_bim_item.xml_representation))[1]::text AS fm_bim_item_address,
(xpath('//navn[1]/text()', fm_bim_item.xml_representation))[1]::text AS
fm_bim_item_name ";
}
@@ -201,6 +229,8 @@
$allocation->set_resource_type_descr($this->unmarshal($this->db->f('resource_type_descr'),
'string'));
$allocation->set_location_code($this->unmarshal($this->db->f('location_code'),
'string'));
$allocation->set_fm_bim_item_address($this->unmarshal($this->db->f('fm_bim_item_address'),
'string'));
+
$allocation->set_allocated_amount($this->unmarshal($this->db->f('count'),
'int'));
+
$allocation->set_inventory_id($this->unmarshal($this->db->f('inventory_id'),
'int'));
$fm_bim_name = $this->unmarshal(
$this->db->f('fm_bim_item_name'), 'string');
@@ -220,13 +250,14 @@
$location_id = (int)$location_id;
$values = array();
$items = array();
+ $inventory = array();
if (!$ids)
{
return $values;
}
- $sql = "SELECT lg_calendar.item_id,
lg_requirement.activity_id,"
- . " lg_calendar.start_date, lg_calendar.end_date"
+ $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"
. " 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"
@@ -238,16 +269,21 @@
while ($this->db->next_record())
{
$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;
$values[$item_id][] = array
(
- 'start_date' =>
$this->db->f('start_date'),
- 'end_date' =>
$this->db->f('end_date'),
- 'activity_id' =>
$this->db->f('activity_id'),
- 'item_id' => $item_id
+ 'start_date' =>
$this->db->f('start_date'),
+ 'end_date'
=> $this->db->f('end_date'),
+ 'activity_id' =>
$this->db->f('activity_id'),
+ 'item_id'
=> $item_id,
+ 'item_inventory_id' =>
$item_inventory_id,
+ 'item_allocated_amount' =>
$item_inventory_amount
);
}
- return array('calendar' => $values, 'items' => $items);
+ return array('calendar' => $values, 'items' => $items,
'inventory' => $inventory);
}
function delete($resource_allocation_id)
Modified: trunk/logistic/inc/class.uirequirement.inc.php
===================================================================
--- trunk/logistic/inc/class.uirequirement.inc.php 2013-04-25 08:54:16 UTC
(rev 11078)
+++ trunk/logistic/inc/class.uirequirement.inc.php 2013-04-25 14:20:52 UTC
(rev 11079)
@@ -217,8 +217,7 @@
$num_required = $entry['no_of_items'];
- $filters = array('requirement_id' =>
$entry['id']);
- $num_allocated =
$this->so_resource_allocation->get_count($search_for, $search_type, $filters);
+ $num_allocated =
$this->so_resource_allocation->count_allocated($entry['id']);
$entry['allocated'] = $num_allocated;
$entry['select'] = "<input
class=\"select_line\" type =\"radio\" {$_checked} name=\"values[select_line]\"
value=\"{$entry['id']}\">";
Modified: trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
2013-04-25 08:54:16 UTC (rev 11078)
+++ trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
2013-04-25 14:20:52 UTC (rev 11079)
@@ -238,10 +238,41 @@
$requirement['fm_bim_item_name'] = $short_desc;
}
- $delete_href = self::link(
-
array('menuaction' =>
'logistic.uirequirement_resource_allocation.delete',
-
'id' =>
$requirement['id'],
-
'phpgw_return_as' => 'json')
+ if($requirement['inventory_id'])
+ {
+ $inventory =
execMethod('property.soentity.get_inventory',array('inventory_id' =>
$requirement['inventory_id']));
+
+ $system_location =
$GLOBALS['phpgw']->locations->get_name($inventory[0]['p_location_id']);
+
+ $name = 'N∕A';
+ if( preg_match('/.location./i',
$system_location['location']) )
+ {
+ $location_code =
execMethod('property.solocation.get_location_code', $inventory[0]['p_id']);
+ $location =
execMethod('property.solocation.read_single', $location_code);
+ $location_arr =
explode('-', $location_code);
+ $i=1;
+ $name_arr = array();
+ foreach($location_arr
as $_dummy)
+ {
+ $name_arr[] =
$location["loc{$i}_name"];
+ $i++;
+ }
+
+ $name = implode('::',
$name_arr);
+ }
+ else if(
preg_match('/.entity./i', $system_location['location']) )
+ {
+ $name =
execMethod('property.soentity.get_short_description',
+
array('location_id' => $inventory[0]['p_location_id'], 'id' =>
$inventory[0]['p_id']));
+ }
+
+ $requirement['location_code'] =
$location_code;
+
$requirement['fm_bim_item_address'] = $name;
+ }
+
+ $delete_href =
self::link(array('menuaction' =>
'logistic.uirequirement_resource_allocation.delete',
+
'id' =>
$requirement['id'],
+
'phpgw_return_as' =>
'json')
);
$requirement['delete_link'] = "<a
class=\"btn-sm delete\" href=\"{$delete_href}\">Slett</a>";
$rows[] = $requirement;
@@ -416,6 +447,13 @@
$allocation_suggestion['allocated_date'] = implode('; ', $allocated_date);
$allocation_suggestion['allocated_where'] = implode('; ', $allocated_where);
}
+ if(isset($allocation_suggestion['inventory']))
+ {
+ foreach
($allocation_suggestion['inventory'] as & $inventory)
+ {
+ $inventory['allocated_amount']
= $allocated['inventory'][$inventory['inventory_id']];
+ }
+ }
}
$activity = $this->so_activity->get_single(
$requirement->get_activity_id() );
@@ -446,7 +484,10 @@
$chosen_resources = phpgw::get_var('chosen_resources');
$inventory_ids = phpgw::get_var('inventory_ids');
+ $inventory_ids_orig =
phpgw::get_var('inventory_ids_orig');
+ //FIXME: Bruk 'allocation_id' i staden.
+//_debug_array($inventory_ids_orig);die();
$filters = array('requirement_id' =>
$requirement->get_id());
$num_allocated = $this->so->get_count($search_for,
$search_type, $filters);
@@ -456,9 +497,9 @@
if($inventory_ids)
{
- foreach ($inventory_ids as $resource =>
$inventory)
+ foreach ($inventory_ids as $resource =>
$allocated_amount)
{
- if($inventory)
+ if($allocated_amount)
{
$resource_arr = explode('_',
$resource);
$resource_id = $resource_arr[0];
@@ -467,9 +508,9 @@
$resource_alloc = new
logistic_requirement_resource_allocation();
$resource_alloc->set_requirement_id( $requirement->get_id() );
$resource_alloc->set_resource_id( $resource_id );
- //FIXME:
-_debug_array($inventory_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_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/inc/model/class.requirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/model/class.requirement_resource_allocation.inc.php
2013-04-25 08:54:16 UTC (rev 11078)
+++ trunk/logistic/inc/model/class.requirement_resource_allocation.inc.php
2013-04-25 14:20:52 UTC (rev 11079)
@@ -36,7 +36,8 @@
protected $id;
protected $requirement_id;
protected $resource_id;
- protected $inventory;
+ protected $inventory_id;
+ protected $inventory_amount;
protected $location_id;
protected $create_user;
@@ -46,7 +47,8 @@
protected $fm_bim_item_name;
protected $start_date;
protected $end_date;
-
+ protected $allocated_amount;
+ protected $allocated_amount_orig;
/**
* Constructor. Takes an optional ID. If a contract is
created from outside
* the database the ID should be empty so the database can add
one according to its logic.
@@ -99,6 +101,16 @@
return $this->inventory_id;
}
+ public function set_inventory_amount($inventory_amount)
+ {
+ $this->inventory_amount = $inventory_amount;
+ }
+
+ public function get_inventory_amount()
+ {
+ return $this->inventory_amount;
+ }
+
public function set_location_id($location_id)
{
$this->location_id = $location_id;
@@ -180,6 +192,27 @@
return $this->start_date;
}
+ public function set_allocated_amount($allocated_amount)
+ {
+ $this->allocated_amount = $allocated_amount ?
$allocated_amount : 1;
+ }
+
+ public function get_allocated_amount()
+ {
+ return $this->allocated_amount;
+ }
+
+ public function set_allocated_amount_orig($allocated_amount)
+ {
+ $this->allocated_amount_orig = $allocated_amount ?
$allocated_amount : 1;
+ }
+
+ public function get_allocated_amount_orig()
+ {
+ return $this->allocated_amount_orig;
+ }
+
+
/**
* Get a static reference to the storage object associated with
this model object
*
@@ -196,12 +229,16 @@
public function serialize()
{
- return array(
+ $values = array
+ (
'id' =>
$this->get_id(),
'resource_type_descr' =>
$this->get_resource_type_descr(),
'requirement_id' =>
$this->get_requirement_id(),
'resource_id' =>
$this->get_resource_id(),
'inventory_id' =>
$this->get_inventory_id(),
+ //FIXME
+ 'inventory_amount' =>
$this->get_inventory_amount(),
+ 'allocated_amount' =>
$this->get_allocated_amount(),
'location_id' =>
$this->get_location_id(),
'location_code' =>
$this->get_location_code(),
'fm_bim_item_address' =>
$this->get_fm_bim_item_address(),
@@ -209,5 +246,7 @@
'start_date' =>
$this->get_start_date(),
'end_date' =>
$this->get_end_date()
);
+
+ return $values;
}
}
Modified: trunk/logistic/setup/tables_current.inc.php
===================================================================
--- trunk/logistic/setup/tables_current.inc.php 2013-04-25 08:54:16 UTC (rev
11078)
+++ trunk/logistic/setup/tables_current.inc.php 2013-04-25 14:20:52 UTC (rev
11079)
@@ -76,7 +76,8 @@
'id' => array('type' => 'auto',
'precision' => 4, 'nullable' => false),
'location_id' => array('type'
=> 'int', 'precision' => 4, 'nullable' => false),
'item_id' => array('type' =>
'int', 'precision' => 4, 'nullable' => false),
- 'item_inventory_id' =>
array('type' => 'int', 'precision' => 4, 'nullable' => false),
+ 'item_inventory_id' =>
array('type' => 'int', 'precision' => 4, 'nullable' => true),
+ 'item_inventory_amount' =>
array('type' => 'int', 'precision' => 4, 'nullable' => true),
'create_user' => array('type'
=> 'int', 'precision' => 4, 'nullable' => false),
'create_date' => array('type'
=> 'int', 'precision' => 8, 'nullable' => false),
'start_date' => array('type' =>
'int', 'precision' => 8, 'nullable' => false),
Modified: trunk/logistic/setup/tables_update.inc.php
===================================================================
--- trunk/logistic/setup/tables_update.inc.php 2013-04-25 08:54:16 UTC (rev
11078)
+++ trunk/logistic/setup/tables_update.inc.php 2013-04-25 14:20:52 UTC (rev
11079)
@@ -182,6 +182,12 @@
'nullable' => true
));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('lg_calendar','item_inventory_amount',array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => true
+ ));
+
if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
{
$GLOBALS['setup_info']['logistic']['currentver'] =
'0.0.6';
Modified: trunk/logistic/templates/base/allocation/book_resources.xsl
===================================================================
--- trunk/logistic/templates/base/allocation/book_resources.xsl 2013-04-25
08:54:16 UTC (rev 11078)
+++ trunk/logistic/templates/base/allocation/book_resources.xsl 2013-04-25
14:20:52 UTC (rev 11079)
@@ -110,8 +110,10 @@
<div>
<span class="loc_code"></span>
<span class="loc_code">
-
<input type="text" value="{allocated}"
name="inventory_ids[{//allocation_suggestions/id}_{inventory_id}]" size='4'>
+
<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>
</span>
<span class="loc_code"><xsl:value-of disable-output-escaping="yes"
select="where" /></span>
<span class="loc_code"><xsl:value-of select="unit" /></span>
Modified: trunk/logistic/templates/base/requirement/requirement_overview.xsl
===================================================================
--- trunk/logistic/templates/base/requirement/requirement_overview.xsl
2013-04-25 08:54:16 UTC (rev 11078)
+++ trunk/logistic/templates/base/requirement/requirement_overview.xsl
2013-04-25 14:20:52 UTC (rev 11079)
@@ -114,6 +114,7 @@
{key:"id", label:'Id', sortable:true},
{key:"fm_bim_item_name", label:'Navn på
ressurs', sortable:true},
{key:"resource_type_descr",
label:'Ressurstype', sortable:true},
+ {key:"allocated_amount", label:'Antall',
sortable:true},
{key:"location_code", label:'Lokasjonskode',
sortable:true},
{key:"fm_bim_item_address", label:'Adresse',
sortable:true},
{key:"delete_link", label:'Slett bestilling',
sortable:true}
Modified: trunk/property/inc/class.boentity.inc.php
===================================================================
--- trunk/property/inc/class.boentity.inc.php 2013-04-25 08:54:16 UTC (rev
11078)
+++ trunk/property/inc/class.boentity.inc.php 2013-04-25 14:20:52 UTC (rev
11079)
@@ -680,9 +680,13 @@
return $this->so->read_entity_to_link($data);
}
- public function get_inventory($location_id, $id, $inventory_id
= 0)
+ /**
+ * array('id' => $id, 'location_id' => $location_id,
'inventory_id' => $inventory_id)
+ */
+
+ public function get_inventory($data)
{
- $values = $this->so->get_inventory( array('id' => $id,
'location_id' => $location_id, 'inventory_id' => $inventory_id) );
+ $values = $this->so->get_inventory( $data );
$interlink = CreateObject('property.interlink');
Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php 2013-04-25 08:54:16 UTC (rev
11078)
+++ trunk/property/inc/class.soentity.inc.php 2013-04-25 14:20:52 UTC (rev
11079)
@@ -2378,11 +2378,8 @@
$id = (int)$data['id'];
$inventory_id = isset($data['inventory_id']) &&
$data['inventory_id'] ? (int)$data['inventory_id'] : 0;
- if(!$location_id || ! $id)
- {
- return array();
- }
-
+ $filtermethod = '';
+
if($inventory_id)
{
$filtermethod = "WHERE fm_bim_item_inventory.id
= {$inventory_id}";
@@ -2392,6 +2389,11 @@
$filtermethod = "WHERE location_id =
{$location_id} AND fm_bim_item_inventory.item_id = {$id} AND expired_on IS
NULL";
}
+ if(!$filtermethod)
+ {
+ return array();
+ }
+
$sql = "SELECT fm_bim_item_inventory.*,
fm_standard_unit.name AS unit FROM fm_bim_item_inventory"
. " {$this->join} fm_standard_unit ON
fm_bim_item_inventory.unit_id = fm_standard_unit.id"
. " {$filtermethod}"
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2013-04-25 08:54:16 UTC (rev
11078)
+++ trunk/property/inc/class.uientity.inc.php 2013-04-25 14:20:52 UTC (rev
11079)
@@ -2885,7 +2885,7 @@
$location_id =
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
".{$this->type}.{$this->entity_id}.{$this->cat_id}");
}
- $inventory = $this->bo->get_inventory($location_id,
$id);
+ $inventory = $this->bo->get_inventory(array('id' =>
$id, 'location_id' => $location_id));
if( phpgw::get_var('phpgw_return_as') == 'json' )
{
@@ -2919,7 +2919,7 @@
$GLOBALS['phpgw']->common->phpgw_exit();
}
$unit_id = '';
- if( $inventory = $this->bo->get_inventory($location_id,
$id, $inventory_id) )
+ if( $inventory = $this->bo->get_inventory(array('id' =>
$id, 'location_id' => $location_id, 'inventory_id' => $inventory_id)) )
{
$unit_id = $inventory[0]['unit_id'];
}
@@ -3041,7 +3041,7 @@
}
$unit_id = '';
- if( $inventory = $this->bo->get_inventory($location_id,
$id) )
+ if( $inventory = $this->bo->get_inventory(array('id' =>
$id, 'location_id' => $location_id)) )
{
$unit_id = $inventory[0]['unit_id'];
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11079] more on logistic,
Sigurd Nes <=