fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11081] more on logistic


From: Sigurd Nes
Subject: [Fmsystem-commits] [11081] more on logistic
Date: Fri, 26 Apr 2013 11:36:01 +0000

Revision: 11081
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11081
Author:   sigurdne
Date:     2013-04-26 11:36:01 +0000 (Fri, 26 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/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.interlink.inc.php
    trunk/property/setup/phpgw_no.lang
    trunk/property/templates/base/request.xsl

Modified: trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php  
2013-04-25 19:51:21 UTC (rev 11080)
+++ trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php  
2013-04-26 11:36:01 UTC (rev 11081)
@@ -260,9 +260,13 @@
                * Finds allocated items within timespan
                *
                */
-               public function check_calendar($location_id = 0, $ids = 
array(), $start_date, $end_date)
+               public function check_calendar($requirement, $ids = array())
                {
-                       $location_id = (int)$location_id;
+                       $start_date                     = 
$requirement->get_start_date();
+                       $end_date                       = 
$requirement->get_end_date();
+                       $location_id            = 
$requirement->get_location_id();
+                       $requirement_id         = (int)$requirement->get_id();
+
                        $values = array();
                        $items = array();
                        $inventory = array();
@@ -272,15 +276,19 @@
                        {
                                return $values;
                        }
+
+                       // for this requirement
                        $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.id AS 
requirement_id,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"
                        . " WHERE lg_calendar.location_id = {$location_id}"
                        . " AND lg_calendar.item_id IN (" . implode(',', $ids) 
. ')'
-                       . " AND lg_calendar.end_date >= {$start_date} AND 
lg_calendar.start_date <= {$end_date}";
+                       . " AND lg_calendar.end_date >= {$start_date} AND 
lg_calendar.start_date <= {$end_date}"
+                       . " AND lg_requirement.id = {$requirement_id}";
+
                        $this->db->query($sql,__LINE__,__FILE__);
 
                        while ($this->db->next_record())
@@ -289,19 +297,52 @@
                                $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');
+                               $start_date             = 
$this->db->f('start_date');
+                               $end_date               = 
$this->db->f('end_date');
+
+
                                $items[$item_id] = true;
                                $inventory[$item_inventory_id] = 
$item_allocated_amount;
-                               $allocations[$item_inventory_id] = 
$allocation_id;
+                               $allocations[$item_inventory_id] = array
+                               (
+                                       'requirement_id'                => 
$this->db->f('requirement_id'),
+                                       'allocation_id'                 => 
$allocation_id,
+                                       'start_date'                    => 
$start_date,
+                                       'end_date'                              
=> $end_date
+                               );
+                                       
                                $values[$item_id][] = array
                                (
-                                       'start_date'                    => 
$this->db->f('start_date'),
-                                       'end_date'                              
=> $this->db->f('end_date'),
+                                       'start_date'                    => 
$start_date,
+                                       'end_date'                              
=> $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
                                );
                        }
+
+
+                       //total
+                       $sql = "SELECT 
lg_calendar.item_id,lg_calendar.item_inventory_id,lg_calendar.item_inventory_amount,"
+                       . " lg_requirement.id AS 
requirement_id,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"
+                       . " WHERE lg_calendar.location_id = {$location_id}"
+                       . " AND lg_calendar.item_id IN (" . implode(',', $ids) 
. ')'
+                       . " AND lg_calendar.end_date >= {$start_date} AND 
lg_calendar.start_date <= {$end_date}";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       while ($this->db->next_record())
+                       {
+                               $allocation_id = $this->db->f('allocation_id');
+                               $item_inventory_id = 
$this->db->f('item_inventory_id');
+                               
$allocations[$item_inventory_id]['total_allocated'] += 
$this->db->f('item_inventory_amount');
+                       }
+
                        return array('calendar' => $values, 'items' => $items, 
'inventory' => $inventory, 'allocations' => $allocations);
                }
 

Modified: trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php  
2013-04-25 19:51:21 UTC (rev 11080)
+++ trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php  
2013-04-26 11:36:01 UTC (rev 11081)
@@ -411,7 +411,7 @@
 
                        reset($allocation_suggestions);
 
-                       $allocated = $this->so->check_calendar($location_id, 
$suggestion_ids, $requirement->get_start_date(), $requirement->get_end_date() );
+                       $allocated = $this->so->check_calendar($requirement, 
$suggestion_ids);
 //_debug_array($allocated);die();
 //end fuzzy
                        $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
@@ -451,8 +451,26 @@
                                {
                                        foreach 
($allocation_suggestion['inventory'] as & $inventory)
                                        {
+                                               
+                                               //Allocated to another 
requirement:
+                                               
if(isset($allocated['allocations'][$inventory['inventory_id']]['requirement_id'])
 && $requirement->get_id() != 
$allocated['allocations'][$inventory['inventory_id']]['requirement_id'])
+                                               {
+                                                       $inventory['disabled'] 
= true;
+                                               }
+                                               
                                                $inventory['allocated_amount'] 
= $allocated['inventory'][$inventory['inventory_id']];
-                                               $inventory['allocation_id'] = 
$allocated['allocations'][$inventory['inventory_id']];
+
+                                               $inventory['bookable_amount'] = 
(int)$inventory['inventory'] - 
(int)$allocated['allocations'][$inventory['inventory_id']]['total_allocated'];
+
+                                               $inventory['allocation_id'] = 
$allocated['allocations'][$inventory['inventory_id']]['allocation_id'];
+                                               
+                                               
if($allocated['allocations'][$inventory['inventory_id']]['start_date'])
+                                               {
+                                                       
$inventory['allocated_date'] = 
$GLOBALS['phpgw']->common->show_date($allocated['allocations'][$inventory['inventory_id']]['start_date']
 ,$dateformat)
+                                                                               
        . ' - ' . 
$GLOBALS['phpgw']->common->show_date($allocated['allocations'][$inventory['inventory_id']]['end_date']
 ,$dateformat);
+                                               }
+
+
                                        }
                                }
                        }

Modified: trunk/logistic/templates/base/allocation/book_resources.xsl
===================================================================
--- trunk/logistic/templates/base/allocation/book_resources.xsl 2013-04-25 
19:51:21 UTC (rev 11080)
+++ trunk/logistic/templates/base/allocation/book_resources.xsl 2013-04-26 
11:36:01 UTC (rev 11081)
@@ -108,27 +108,45 @@
                                                                <xsl:when 
test="inventory != ''">
                                                                        
<xsl:for-each select="inventory">
                                                                                
<div>
-                                                                               
        <span class="loc_code"></span>
+                                                                               
        <span class="loc_code"><xsl:value-of select="unit" /></span>
                                                                                
        <span class="loc_code">
                                                                                
                <input type="text" value="{allocated_amount}" 
name="inventory_ids[{//allocation_suggestions/id}_{inventory_id}]" size='4'>
+                                                                               
                        <xsl:if test="disabled = '1'">
+                                                                               
                                <xsl:attribute name="disabled">
+                                                                               
                                        <xsl:text>disabled</xsl:text>
+                                                                               
                                </xsl:attribute>
+                                                                               
                        </xsl:if>
                                                                                
                </input>
                                                                                
                <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>
-                                                                               
        <span class="loc_code"><xsl:value-of select="unit" /></span>
-                                                                               
        <span class="loc_code"><xsl:value-of select="inventory" /></span>
-                                                                               
        
+                                                                               
        <span class="loc_code">
+                                                                               
                <xsl:value-of select="bookable_amount" />
+                                                                               
                <xsl:text> ( </xsl:text>
+                                                                               
                <xsl:value-of select="inventory" />
+                                                                               
                <xsl:text> )</xsl:text>
+                                                                               
        </span>
+                                                                               
        <span class="loc_code"><xsl:value-of disable-output-escaping="yes" 
select="where_name" /></span>
+
+                                                                               
        <xsl:choose>
+                                                                               
                <xsl:when test="allocated_amount != ''">
+                                                                               
                        <span class="loc_code">
+                                                                               
                                <xsl:value-of select="allocated_amount" />
+                                                                               
                                <xsl:text> ( </xsl:text>
+                                                                               
                                <xsl:value-of select="allocated_date" />
+                                                                               
                                <xsl:text> )</xsl:text>
+                                                                               
                        </span>                                                 
                                
+                                                                               
            </xsl:when>
+                                                                               
        </xsl:choose>
                                                                                
</div>
                                                                        
</xsl:for-each>
                                                            </xsl:when>
                                                            <xsl:otherwise>
-                                                       <span 
class="loc_id"><xsl:value-of select="location_id" /></span>
-                                               <!--    <span 
class="type"><xsl:value-of select="type_lokale" /></span> -->
-                                                       <span 
class="loc_code"><xsl:value-of select="location_code" /></span>
-                                                       <span 
class="loc_code"><xsl:value-of select="allocated_date" /></span>
-                                                       <span 
class="loc_code"><xsl:value-of select="allocated_where" /></span>
-
+                                                                       <span 
class="loc_id"><xsl:value-of select="location_id" /></span>
+                                                       <!--    <span 
class="type"><xsl:value-of select="type_lokale" /></span> -->
+                                                                       <span 
class="loc_code"><xsl:value-of select="location_code" /></span>
+                                                                       <span 
class="loc_code"><xsl:value-of select="allocated_date" /></span>
+                                                                       <span 
class="loc_code"><xsl:value-of select="allocated_where" /></span>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
 

Modified: trunk/logistic/templates/base/requirement/requirement_overview.xsl
===================================================================
--- trunk/logistic/templates/base/requirement/requirement_overview.xsl  
2013-04-25 19:51:21 UTC (rev 11080)
+++ trunk/logistic/templates/base/requirement/requirement_overview.xsl  
2013-04-26 11:36:01 UTC (rev 11081)
@@ -114,7 +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:"allocated_amount", label:'Antall', 
sortable:false},
                                {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 19:51:21 UTC (rev 
11080)
+++ trunk/property/inc/class.boentity.inc.php   2013-04-26 11:36:01 UTC (rev 
11081)
@@ -694,8 +694,9 @@
                        {
                                $link_info = 
$interlink->get_location_link($entry['p_location_id'], $entry['p_id'],'view');
                                $entry['where'] = "<a 
href='{$link_info['link']}'>{$link_info['name']}</a>";
-                               $entry['location_id'] = $location_id;
-                               $entry['id'] = $id;
+                               $entry['where_name'] = $link_info['name'];
+                               $entry['location_id'] = $data['location_id'];
+                               $entry['id'] = $data['id'];
                        }
 
                        return $values;

Modified: trunk/property/inc/class.interlink.inc.php
===================================================================
--- trunk/property/inc/class.interlink.inc.php  2013-04-25 19:51:21 UTC (rev 
11080)
+++ trunk/property/inc/class.interlink.inc.php  2013-04-26 11:36:01 UTC (rev 
11081)
@@ -204,8 +204,19 @@
                        $name = 'N∕A';
                        if( preg_match('/.location./i', 
$system_location['location']) )
                        {
-                               $id = 
execMethod('property.solocation.get_location_code',$id);
-                               $name = $id;
+                               $location_code = 
execMethod('property.solocation.get_location_code',$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']) )
                        {

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2013-04-25 19:51:21 UTC (rev 11080)
+++ trunk/property/setup/phpgw_no.lang  2013-04-26 11:36:01 UTC (rev 11081)
@@ -338,7 +338,8 @@
 click this link to view the remark     property        no      klikk her for å 
vise merknad
 click this to add an order to an existing project      property        no      
klikk her for å legge til en ny bestilling til et eksisterende prosjekt
 click this to generate a request with this information property        no      
klikk her for å generere et behov med basis i denne informasjonen
-click this to generate a project with this information property        no      
klikk her for å lage ett nytt prosjekt med informasjon fra denne saken
+click this to generate a project with this information property        no      
klikk her for å lage et nytt prosjekt med informasjon fra denne saken
+click this to link this request to an existing project property        no      
klikk her for å lenke dette behovet til et eksisterende prosjekt
 click to view file     property        no      Klikk for vise fil
 close  property        no      Avslutt
 closed property        no      Avsluttet

Modified: trunk/property/templates/base/request.xsl
===================================================================
--- trunk/property/templates/base/request.xsl   2013-04-25 19:51:21 UTC (rev 
11080)
+++ trunk/property/templates/base/request.xsl   2013-04-26 11:36:01 UTC (rev 
11081)
@@ -162,7 +162,7 @@
                                                                <input 
type="hidden" name="query" value="{loc1}"/>
                                                                <input 
type="submit" name="location" value="{php:function('lang', 'add to project as 
relation')}">
                                                                        
<xsl:attribute name="title">
-                                                                               
<xsl:value-of select="php:function('lang', 'click this to add an order to an 
existing project')"/>
+                                                                               
<xsl:value-of select="php:function('lang', 'click this to link this request to 
an existing project')"/>
                                                                        
</xsl:attribute>
                                                                </input>
                                                        </form>




reply via email to

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