[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [13209] property: add column for vendors at project
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [13209] property: add column for vendors at project |
Date: |
Fri, 15 May 2015 13:16:04 +0000 |
Revision: 13209
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13209
Author: sigurdne
Date: 2015-05-15 13:16:03 +0000 (Fri, 15 May 2015)
Log Message:
-----------
property: add column for vendors at project
Modified Paths:
--------------
trunk/property/inc/class.boproject.inc.php
trunk/property/inc/class.soproject.inc.php
Modified: trunk/property/inc/class.boproject.inc.php
===================================================================
--- trunk/property/inc/class.boproject.inc.php 2015-05-14 22:04:32 UTC (rev
13208)
+++ trunk/property/inc/class.boproject.inc.php 2015-05-15 13:16:03 UTC (rev
13209)
@@ -236,6 +236,12 @@
'name' => lang('billable
hours'),
'sortable' => true
);
+ $columns['vendor_names'] = array
+ (
+ 'id' => 'vendor_names',
+ 'name' => lang('vendor'),
+ 'sortable' => false
+ );
return $columns;
}
@@ -486,6 +492,7 @@
$custom_cols =
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['project_columns'])
&&
$GLOBALS['phpgw_info']['user']['preferences']['property']['project_columns'] ?
$GLOBALS['phpgw_info']['user']['preferences']['property']['project_columns'] :
array();
$column_list = $this->get_column_list();
+ $get_vendor_names = false;
foreach ($custom_cols as $col_id)
{
@@ -501,6 +508,10 @@
$this->uicols['sortable'][]
= $column_list[$col_id]['sortable'];
$this->uicols['formatter'][] =
$column_list[$col_id]['formatter'];
$this->uicols['classname'][] =
$column_list[$col_id]['classname'];
+ if($col_id == 'vendor_names')
+ {
+ $get_vendor_names = true;
+ }
}
}
@@ -525,6 +536,18 @@
$entry['entry_date'] =
$GLOBALS['phpgw']->common->show_date($entry['entry_date'],$dateformat);
$entry['start_date'] =
$GLOBALS['phpgw']->common->show_date($entry['start_date'],$dateformat);
$entry['end_date'] =
$GLOBALS['phpgw']->common->show_date($entry['end_date'],$dateformat);
+ if($get_vendor_names &&
isset($entry['vendor_list']) && $entry['vendor_list'])
+ {
+ $vendor_names = array();
+ foreach($entry['vendor_list'] as
$vendor_id)
+ {
+ $vendor_names[] =
$this->get_vendor_name($vendor_id);
+ }
+ if($vendor_names)
+ {
+ $entry['vendor_names'] =
implode(', ', $vendor_names);
+ }
+ }
if(!isset($data['skip_origin']) ||
!$data['skip_origin'])
{
$origin =
$this->interlink->get_relation('property', '.project', $entry['project_id'],
'origin');
@@ -605,12 +628,41 @@
return $values;
}
+ private function get_vendor_name($vendor_id = 0)
+ {
+ static $vendor_name = array();
+ static $attributes = array();
+ static $contacts = null;
+
+ if(isset($vendor_name[$vendor_id]) &&
$vendor_name[$vendor_id])
+ {
+ return $vendor_name[$vendor_id];
+ }
+ else
+ {
+ if(!$contacts)
+ {
+ $contacts =
CreateObject('property.sogeneric');
+
$contacts->get_location_info('vendor',false);
+ }
+ if(!$attributes)
+ {
+ $attributes =
$this->custom->find('property','.vendor', 0, '', 'ASC', 'attrib_sort', true,
true);
+ }
+ $vendor = $contacts->read_single(array('id' =>
$vendor_id), array('id' => $vendor_id, 'attributes' => $attributes));
+ foreach($vendor['attributes'] as $attribute)
+ {
+ if($attribute['name']=='org_name')
+ {
+ $vendor_name[$vendor_id] =
$attribute['value'];
+ return $attribute['value'];
+ }
+ }
+ }
+ }
+
public function get_orders($data)
{
- $contacts = CreateObject('property.sogeneric');
- $contacts->get_location_info('vendor',false);
-
- static $vendor_name = array();
$values = $this->so->project_workorder_data($data);
$sum_deviation = 0;
@@ -619,29 +671,10 @@
$sum_deviation+= $entry['deviation'];
$entry['cost'] = $entry['combined_cost'];
- //
$entry['title']=htmlspecialchars_decode($entry['title']);
if(isset($entry['vendor_id']) &&
$entry['vendor_id'])
{
-
if(isset($vendor_name[$entry['vendor_id']]) &&
$vendor_name[$entry['vendor_id']])
- {
- $entry['vendor_name'] =
$vendor_name[$entry['vendor_id']];
- }
- else
- {
- $vendor['attributes'] =
$this->custom->find('property','.vendor', 0, '', 'ASC', 'attrib_sort', true,
true);
-
- $vendor =
$contacts->read_single(array('id' => $entry['vendor_id']), $vendor);
- foreach($vendor['attributes']
as $attribute)
- {
-
if($attribute['name']=='org_name')
- {
-
$entry['vendor_name'] = $attribute['value'];
-
$vendor_name[$entry['vendor_id']] = $attribute['value'];
- break;
- }
- }
- }
+ $entry['vendor_name'] =
$this->get_vendor_name((int)$entry['vendor_id']);
}
}
return $values;
Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php 2015-05-14 22:04:32 UTC (rev
13208)
+++ trunk/property/inc/class.soproject.inc.php 2015-05-15 13:16:03 UTC (rev
13209)
@@ -37,6 +37,7 @@
var $total_records = 0;
private $global_lock = false;
+ private $vendor_list = array();
function __construct()
{
@@ -755,6 +756,7 @@
$year =
(int) $filter_year;
$project_budget =
$this->get_budget($project['project_id']);
+ $project['vendor_list'] =
$this->vendor_list;
foreach($project_budget as
$entry)
{
if($year &&
$entry['year'] == $year)
@@ -2118,16 +2120,23 @@
$project_total_budget = array_sum($project_budget);
- $sql = "SELECT fm_workorder.id AS order_id "
+ $sql = "SELECT fm_workorder.id AS order_id, vendor_id"
. " FROM fm_workorder"
. " WHERE project_id = {$project_id}";
$this->db->query($sql, __LINE__, __FILE__);
$_order_list = array();
+ $_vendor_list = array();
while($this->db->next_record())
{
$_order_list[] = $this->db->f('order_id');
+
+ if($_vendor_id = $this->db->f('vendor_id'))
+ {
+ $_vendor_list[] = $_vendor_id;
+ }
}
+ $this->vendor_list = $_vendor_list;
$soworkorder = CreateObject('property.soworkorder');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [13209] property: add column for vendors at project,
Sigurd Nes <=