[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10653] property: condition survey
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10653] property: condition survey |
Date: |
Tue, 08 Jan 2013 14:56:36 +0000 |
Revision: 10653
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10653
Author: sigurdne
Date: 2013-01-08 14:56:32 +0000 (Tue, 08 Jan 2013)
Log Message:
-----------
property: condition survey
Modified Paths:
--------------
trunk/property/inc/class.borequest.inc.php
trunk/property/inc/class.sorequest.inc.php
trunk/property/inc/class.uicondition_survey.inc.php
trunk/property/templates/base/condition_survey.xsl
Modified: trunk/property/inc/class.borequest.inc.php
===================================================================
--- trunk/property/inc/class.borequest.inc.php 2013-01-08 08:07:29 UTC (rev
10652)
+++ trunk/property/inc/class.borequest.inc.php 2013-01-08 14:56:32 UTC (rev
10653)
@@ -413,6 +413,13 @@
return $this->so->update_priority_key($values);
}
+ public function read_survey_data($data)
+ {
+ $values = $this->so->read_survey_data($data);
+ $this->total_records = $this->so->total_records;
+ return $values;
+ }
+
function read($data)
{
$custom = createObject('phpgwapi.custom_fields');
@@ -460,6 +467,7 @@
$request[$i]['coordinator'] =
$GLOBALS['phpgw']->accounts->id2name($request[$i]['coordinator']);
$request[$i]['start_date'] =
$GLOBALS['phpgw']->common->show_date($request[$i]['start_date'],$dateformat);
$request[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($request[$i]['entry_date'],$dateformat);
+ $request[$i]['planned_year'] =
$request[$i]['planned_year'] ? date('Y',$request[$i]['planned_year']) : '';
$request[$i]['closed_date'] =
$GLOBALS['phpgw']->common->show_date($request[$i]['closed_date'],$dateformat);
$request[$i]['in_progress_date'] =
$GLOBALS['phpgw']->common->show_date($request[$i]['in_progress_date'],$dateformat);
$request[$i]['delivered_date'] =
$GLOBALS['phpgw']->common->show_date($request[$i]['delivered_date'],$dateformat);
Modified: trunk/property/inc/class.sorequest.inc.php
===================================================================
--- trunk/property/inc/class.sorequest.inc.php 2013-01-08 08:07:29 UTC (rev
10652)
+++ trunk/property/inc/class.sorequest.inc.php 2013-01-08 14:56:32 UTC (rev
10653)
@@ -193,6 +193,98 @@
}
+ function read_survey_data($data)
+ {
+ $start =
isset($data['start']) && $data['start'] ? (int)$data['start'] : 0;
+ $condition_survey_id = $data['condition_survey_id']
? (int) $data['condition_survey_id'] : 0;
+ $sort =
isset($data['sort']) && $data['sort'] ? $data['sort'] : 'DESC';
+ $order =
isset($data['order'])?$data['order']:'';
+
+
+ if ($order)
+ {
+ switch($order)
+ {
+ case 'planned_year':
+ $ordermethod = " ORDER BY
planned_year $sort";
+ break;
+ case 'url':
+ $ordermethod = " ORDER BY
fm_request.id $sort";
+ break;
+ default:
+ $ordermethod = " ORDER BY
$order $sort";
+ }
+ }
+ else
+ {
+ $ordermethod = ' ORDER BY fm_request.id DESC';
+ }
+
+ $filtermethod = " WHERE fm_request.condition_survey_id
= '{$condition_survey_id}'";
+
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " AND
fm_request.category='{$cat_id}'";
+ }
+
+ $sql = "SELECT DISTINCT fm_request.id as
request_id,fm_request_status.descr as status,fm_request.building_part,"
+ . "
fm_request.start_date,fm_request.closed_date,fm_request.in_progress_date,"
+ . " fm_request.delivered_date,fm_request.title as
title,max(fm_request_condition.degree) as condition_degree,"
+ . " sum(fm_request_planning.amount) as planned_budget,
fm_request.budget,fm_request.score,min(fm_request_planning.date) as
planned_year"
+ . " FROM (((( fm_request LEFT JOIN fm_request_status
ON fm_request.status = fm_request_status.id)"
+ . " LEFT JOIN fm_request_planning ON fm_request.id =
fm_request_planning.request_id)"
+ . " LEFT JOIN fm_request_consume ON fm_request.id =
fm_request_consume.request_id)"
+ . " LEFT JOIN fm_request_condition ON fm_request.id =
fm_request_condition.request_id)"
+ . " {$filtermethod}"
+ . " GROUP BY fm_request_status.descr,fm_request.budget,"
+ . "
building_part,fm_request.start_date,fm_request.entry_date,fm_request.closed_date,"
+ . "
fm_request.in_progress_date,fm_request.delivered_date,title,budget,score,fm_request.id,fm_request_status.descr";
+
+ $sql2 = "SELECT count(*) as cnt, sum(budget) as
sum_budget FROM ({$sql}) as t";
+
+ $this->_db->query($sql2,__LINE__,__FILE__);
+ $this->_db->next_record();
+ $this->_total_records = $this->_db->f('cnt');
+ $this->sum_budget = $this->_db->f('sum_budget');
+//_debug_array($sql);
+
+/*
+ $sql3 = "SELECT sum(fm_request_consume.amount) as
sum_consume FROM {$sql_arr[1]}";
+ $this->_db->query($sql3,__LINE__,__FILE__);
+ $this->_db->next_record();
+ $this->sum_consume = $this->_db->f('sum_consume');
+*/
+
+ if(!$allrows)
+ {
+ $this->_db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->_db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $values = array();
+
+ while ($this->_db->next_record())
+ {
+ $values[] = array
+ (
+ 'id' =>
$this->_db->f('request_id'),
+ 'status' =>
$this->_db->f('status',true),
+ 'building_part' =>
$this->_db->f('building_part'),
+ 'title' =>
$this->_db->f('title',true),
+ 'condition_degree' =>
$this->_db->f('condition_degree'),
+ 'budget' =>
$this->_db->f('budget'),
+ 'planned_budget' =>
$this->_db->f('planned_budget'),
+ 'score' =>
$this->_db->f('score'),
+ 'planned_year' =>
$this->_db->f('planned_year') ? date('Y', $this->_db->f('planned_year')) : '',
+ );
+ }
+ return $values;
+ }
+
function read($data)
{
$start = isset($data['start']) &&
$data['start'] ? (int)$data['start'] : 0;
@@ -374,6 +466,22 @@
$uicols['classname'][] = '';
$uicols['sortable'][] = true;
+
+ $cols.= ",min(fm_request_planning.date) as
planned_year";
+ $cols_return[] =
'planned_year';
+// $cols_group[] =
'planned_year';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'planned_year';
+ $uicols['descr'][] = lang('planned
year');
+ $uicols['statustext'][] = lang('planned year');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = true;
+
+
$this->_db->query("SELECT * FROM $attribute_table WHERE
list=1 AND $attribute_filter");
$_attrib = array();
while ($this->_db->next_record())
@@ -414,7 +522,11 @@
$paranthesis = '(';
$joinmethod = "{$this->_left_join} fm_request_status ON
{$entity_table}.status = fm_request_status.id)";
+
$paranthesis .= '(';
+ $joinmethod .= "{$this->_left_join} fm_request_planning
ON {$entity_table}.id = fm_request_planning.request_id)";
+
+ $paranthesis .= '(';
$joinmethod .= "{$this->_left_join} fm_request_consume
ON {$entity_table}.id = fm_request_consume.request_id)";
$paranthesis .= '(';
$joinmethod .= "{$this->_left_join}
fm_request_condition ON {$entity_table}.id = fm_request_condition.request_id)";
@@ -433,7 +545,14 @@
if ($order)
{
- $ordermethod = " order by $order $sort";
+ switch($order)
+ {
+ case 'planned_year':
+ $ordermethod = " ORDER BY
planned_year $sort";
+ break;
+ default:
+ $ordermethod = " order by
$order $sort";
+ }
}
else
{
Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2013-01-08 08:07:29 UTC
(rev 10652)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2013-01-08 14:56:32 UTC
(rev 10653)
@@ -47,7 +47,7 @@
'get_users' => true,
'edit_survey_title' => true,
'get_files' => true,
- 'get_related' => true,
+ 'get_request' => true,
'get_summation' => true,
'view_file' => true,
'import' => true,
@@ -330,7 +330,7 @@
$tabs['generic'] = array('label' =>
lang('generic'), 'link' => '#generic');
$active_tab = 'generic';
$tabs['documents'] = array('label' =>
lang('documents'), 'link' => null);
- $tabs['related'] = array('label' =>
lang('related'), 'link' => null);
+ $tabs['request'] = array('label' =>
lang('request'), 'link' => null);
$tabs['summation'] = array('label' =>
lang('summation'), 'link' => null);
$tabs['import'] = array('label' =>
lang('import'), 'link' => null);
@@ -341,7 +341,7 @@
$tabs['import']['link'] = '#import';
}
$tabs['documents']['link'] = '#documents';
- $tabs['related']['link'] = '#related';
+ $tabs['request']['link'] = '#request';
$tabs['summation']['link'] = '#summation';
if (!$values)
@@ -385,23 +385,24 @@
'container' =>
'datatable-container_0',
'requestUrl' =>
json_encode(self::link(array('menuaction' =>
'property.uicondition_survey.get_files', 'id' =>
$id,'phpgw_return_as'=>'json'))),
'ColumnDefs' => $file_def,
-
+
);
$related_def = array
(
array('key' =>
'url','label'=>lang('id'),'sortable'=>false,'resizeable'=>true),
- array('key' =>
'type','label'=>lang('type'),'sortable'=>true,'resizeable'=>true),
array('key' =>
'title','label'=>lang('title'),'sortable'=>false,'resizeable'=>true),
- array('key' =>
'status','label'=>lang('status'),'sortable'=>false,'resizeable'=>true),
- array('key' =>
'user','label'=>lang('user'),'sortable'=>true,'resizeable'=>true),
- array('key' =>
'entry_date','label'=>lang('entry date'),'sortable'=>false,'resizeable'=>true),
+ array('key' =>
'status','label'=>lang('status'),'sortable'=>true,'resizeable'=>true),
+ array('key' =>
'budget','label'=>lang('budget'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
+// array('key' =>
'planned_budget','label'=>lang('planned
budget'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
+ array('key' =>
'planned_year','label'=>lang('year'),'sortable'=>true,'resizeable'=>true),
);
+
$datatable_def[] = array
(
'container' =>
'datatable-container_1',
- 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
'property.uicondition_survey.get_related', 'id' =>
$id,'phpgw_return_as'=>'json'))),
+ 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
'property.uicondition_survey.get_request', 'id' =>
$id,'phpgw_return_as'=>'json'))),
'ColumnDefs' => $related_def
);
@@ -563,7 +564,7 @@
$start = phpgw::get_var('startIndex', 'int', 'REQUEST',
0);
$total_records = count($files);
- $num_rows =
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) &&
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int)
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
+ $num_rows =
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) &&
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int)
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
if($allrows)
{
@@ -591,7 +592,7 @@
'file_name' => "<a
href='{$link_view_file}&file_name={$_entry['name']}' target='_blank'
title='{$lang_view}'>{$_entry['name']}</a>",
'delete_file' => "<input
type='checkbox' name='file_action[]' value='{$_entry['name']}'
title='$lang_delete'>",
);
- }
+ }
$data = array(
'ResultSet' => array(
@@ -618,10 +619,10 @@
}
$values = $this->bo->get_summation($id);
-
+
$total_records = count($values);
- $num_rows =
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) &&
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int)
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
+ $num_rows =
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) &&
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int)
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
$start = phpgw::get_var('startIndex', 'int', 'REQUEST',
0);
if($allrows)
@@ -651,7 +652,7 @@
}
- function get_related()
+ function get_request()
{
$id = phpgw::get_var('id', 'int', 'REQUEST');
@@ -659,60 +660,37 @@
{
return;
}
-
- $interlink = CreateObject('property.interlink');
- $target = $interlink->get_relation('property',
$this->acl_location, $id, 'target');
-
- $values = array();
- if($target)
- {
- foreach($target as $_target_section)
- {
- foreach ($_target_section['data'] as
$_target_entry)
- {
- $values[] = array
- (
- 'url' => "<a
href=\"{$_target_entry['link']}\" > {$_target_entry['id']}</a>",
- 'type' =>
$_target_section['descr'],
- 'title' =>
$_target_entry['title'],
- 'status' =>
$_target_entry['statustext'],
- 'user' =>
$GLOBALS['phpgw']->accounts->get($_target_entry['account_id'])->__toString(),
- 'entry_date'=>
$GLOBALS['phpgw']->common->show_date($_target_entry['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
- );
- }
- }
- }
-
-//------ Start pagination
-
+ $borequest = CreateObject('property.borequest');
$start = phpgw::get_var('startIndex', 'int', 'REQUEST',
0);
+ $sortKey = phpgw::get_var('sort', 'string', 'REQUEST',
'request_id');
+ $sortDir = phpgw::get_var('dir', 'string', 'REQUEST',
'ASC');
- $total_records = count($values);
+ $criteria = array
+ (
+ 'condition_survey_id' => $id,
+ 'start' =>
$start,
+ 'order' =>
$sortKey,
+ 'sort' =>
$sortDir
+ );
- $num_rows =
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) &&
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int)
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
+ $values = $borequest->read_survey_data($criteria);
+ $total_records = $borequest->total_records;
- if($allrows)
+ $base_url = self::link(array('menuaction' =>
'property.uirequest.edit'));
+ foreach ($values as &$_entry)
{
- $out = $values;
+ $_entry['url'] = "<a
href=\"{$base_url}&id={$_entry['id']}\" >{$_entry['id']}</a>";
}
- else
- {
- $page = ceil( ( $start / $total_records ) *
($total_records/ $num_rows) );
- $values_part = array_chunk($values, $num_rows);
- $out = $values_part[$page];
- }
-//------ End pagination
-
-
+ $num_rows =
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) &&
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int)
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
$data = array(
'ResultSet' => array(
'totalResultsAvailable' =>
$total_records,
'startIndex' => $start,
- 'sortKey' => 'type',
- 'sortDir' => "ASC",
- 'Result' => $out,
+ 'sortKey' => $sortKey,
+ 'sortDir' => $sortDir,
+ 'Result' => $values,
'pageSize' => $num_rows,
'activePage' => floor($start /
$num_rows) + 1
)
@@ -721,8 +699,6 @@
}
-
-
/**
* Dowloads a single file to the browser
*
@@ -823,7 +799,7 @@
$step = phpgw::get_var('step', 'int',
'REQUEST');
$sheet_id = phpgw::get_var('sheet_id',
'int', 'REQUEST');
-
+
$sheet_id = $sheet_id ? $sheet_id :
phpgw::get_var('selected_sheet_id', 'int', 'REQUEST');
if(!$step )
@@ -874,7 +850,7 @@
}
$tabs = array();
-
+
switch ($step)
{
case 0:
@@ -917,7 +893,7 @@
break;
*/
}
-
+
//-----------
$data = array();
@@ -934,7 +910,7 @@
{
$objPHPExcel =
PHPExcel_IOFactory::load($cached_file);
$AllSheets =
$objPHPExcel->getSheetNames();
-
+
$sheets = array();
if($AllSheets)
{
@@ -986,7 +962,7 @@
$html_table .=
"<tr><td><pre>{$_radio}</pre></td><td>" . implode('</td><td>',
array_values($row)) . '</td></tr>';
$i++;
}
- }
+ }
else if($data && $step == 3)
{
$_options = array
@@ -1011,7 +987,7 @@
foreach($data[$start_line] as $_column =>
$_value)
{
$selected = isset($columns[$_column])
&& $columns[$_column] ? $columns[$_column] : '';
-
+
$_listbox =
phpgwapi_sbox::getArrayItem("columns[{$_column}]", $selected, $_options, true );
$html_table .= "<tr><td>[{$_column}]
{$_value}</td><td>{$_listbox}</td><tr>";
}
@@ -1034,7 +1010,7 @@
{
$_result[$_value_key]
=trim($data[$i][$_row_key]);
}
-
+
}
$import_data[] = $_result;
}
@@ -1180,7 +1156,7 @@
{
return lang('no access');
}
-
+
if ($id )
{
$values = $this->bo->read_single( array('id' =>
$id, 'view' => true) );
Modified: trunk/property/templates/base/condition_survey.xsl
===================================================================
--- trunk/property/templates/base/condition_survey.xsl 2013-01-08 08:07:29 UTC
(rev 10652)
+++ trunk/property/templates/base/condition_survey.xsl 2013-01-08 14:56:32 UTC
(rev 10653)
@@ -252,7 +252,7 @@
</xsl:choose>
</dl>
</div>
- <div id="related">
+ <div id="request">
<dl class="proplist-col">
<dt>
<label>
@@ -266,7 +266,7 @@
</dt>
<dt>
- <label><xsl:value-of
select="php:function('lang', 'related')"/></label>
+ <label><xsl:value-of
select="php:function('lang', 'request')"/></label>
</dt>
<dd>
<div style="clear:both;"
id="datatable-container_1"></div>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10653] property: condition survey,
Sigurd Nes <=