[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8061]
From: |
Erik Holm-Larsen |
Subject: |
[Fmsystem-commits] [8061] |
Date: |
Wed, 09 Nov 2011 07:41:06 +0000 |
Revision: 8061
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8061
Author: erikhl
Date: 2011-11-09 07:41:05 +0000 (Wed, 09 Nov 2011)
Log Message:
-----------
Modified Paths:
--------------
trunk/controller/inc/class.socheck_list.inc.php
trunk/controller/inc/class.uicheck_list.inc.php
trunk/controller/templates/base/control.xsl
Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php 2011-11-09 07:11:58 UTC
(rev 8060)
+++ trunk/controller/inc/class.socheck_list.inc.php 2011-11-09 07:41:05 UTC
(rev 8061)
@@ -199,9 +199,100 @@
}
- function get_query(string $sort_field, boolean $ascending, string
$search_for, string $search_type, array $filters, boolean $return_count){}
+ function get_query(string $sort_field, boolean $ascending, string
$search_for, string $search_type, array $filters, boolean $return_count)
+ {
+ $current_time = time();
+ $buffer_in_days = 3600*24*7*5;
+ $buffer_time = $current_time - $buffer_in_days;
- function populate(int $object_id, &$object){}
+ $clauses = array('1=1');
+ $clauses[] = "{$current_time} >= p.start_date AND p.start_date
> {$buffer_time}";
+
+ $filter_clauses = array();
+
+ // Search for based on search type
+ if($search_for)
+ {
+ $search_for = $this->marshal($search_for,'field');
+ $like_pattern = "'%".$search_for."%'";
+ $like_clauses = array();
+ switch($search_type){
+ default:
+ $like_clauses[] = "p.title $this->like
$like_pattern";
+ break;
+ }
+
+ if(count($like_clauses))
+ {
+ $clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
+ }
+ }
+ //var_dump($filters);
+ if(isset($filters[$this->get_id_field_name()]))
+ {
+ $filter_clauses[] = "p.id =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+ }
+
+ if(count($filter_clauses))
+ {
+ $clauses[] = join(' AND ', $filter_clauses);
+ }
+
+ $condition = join(' AND ', $clauses);
+
+ $tables = "controller_control p";
+ //$joins = " {$this->left_join} rental_document_types ON
(rental_document.type_id = rental_document_types.id)";
+ //$joins = " {$this->left_join} controller_control_area ON
(controller_control.control_area_id = controller_control_area.id)";
+ //$joins .= " {$this->left_join} controller_procedure ON
(controller_control.procedure_id = controller_procedure.id)";
+
+ if($return_count)
+ {
+ $cols = 'COUNT(DISTINCT(p.id)) AS count';
+ }
+ else
+ {
+ $cols = 'p.* ';
+ }
+
+ $dir = $ascending ? 'ASC' : 'DESC';
+ if($sort_field == 'id')
+ {
+ $sort_field = 'p.id';
+ }
+ $order = $sort_field ? "ORDER BY {$this->marshal($sort_field,
'field')} $dir ": '';
+
+ return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
+ }
+
+ function populate(int $control_id, &$control)
+ {
+ $start_date = date("d.m.Y", $this->db->f('start_date'));
+ $end_date = date("d.m.Y", $this->db->f('end_date'));
+
+ if($control == null) {
+ $control = new controller_control((int) $control_id);
+
+
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
+
$control->set_description($this->unmarshal($this->db->f('description', true),
'boolean'));
+ $control->set_start_date($start_date);
+ $control->set_end_date($end_date);
+
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true),
'int'));
+
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name',
true), 'string'));
+
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id',
true), 'int'));
+
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
true), 'int'));
+
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
+
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
true), 'int'));
+
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
true), 'string'));
+//
$control->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
true), 'int'));
+
$control->set_equipment_type_id($this->unmarshal($this->db->f('equipment_type_id',
true), 'int'));
+
$control->set_equipment_id($this->unmarshal($this->db->f('equipment_id', true),
'int'));
+
$control->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'int'));
+
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true),
'int'));
+
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval',
true), 'int'));
+ }
+
+ return $control;
+ }
function add(&$check_list)
{
Modified: trunk/controller/inc/class.uicheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list.inc.php 2011-11-09 07:11:58 UTC
(rev 8060)
+++ trunk/controller/inc/class.uicheck_list.inc.php 2011-11-09 07:41:05 UTC
(rev 8061)
@@ -42,7 +42,7 @@
public function index()
{
- $check_list_array = $this->so->get_check_list();
+/* $check_list_array = $this->so->get_check_list();
$data = array
(
@@ -50,6 +50,95 @@
);
self::render_template_xsl('control_check_lists', $data);
+ */
+ if(phpgw::get_var('phpgw_return_as') == 'json') {
+ return $this->query();
+ }
+ self::add_javascript('controller', 'yahoo',
'datatable.js');
+ phpgwapi_yui::load_widget('datatable');
+ phpgwapi_yui::load_widget('paginator');
+
+ $data = array(
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array(
+ array('type' =>
'filter',
+ 'name' =>
'status',
+ 'text' => lang('Status'),
+ 'list' => array(
+ array(
+ 'id' => 'none',
+ 'name' => lang('Not selected')
+ ),
+ array(
+ 'id' => 'NEW',
+ 'name' => lang('NEW')
+ ),
+ array(
+ 'id' => 'PENDING',
+ 'name' => lang('PENDING')
+ ),
+ array(
+ 'id' => 'REJECTED',
+ 'name' => lang('REJECTED')
+ ),
+ array(
+ 'id' => 'ACCEPTED',
+ 'name' => lang('ACCEPTED')
+ )
+ )
+ ),
+ array('type' => 'text',
+ 'text' => lang('searchfield'),
+ 'name' =>
'query'
+ ),
+ array(
+ 'type' =>
'submit',
+ 'name' =>
'search',
+ 'value' =>
lang('Search')
+ ),
+ ),
+ ),
+ ),
+ 'datatable' => array(
+ 'source' =>
self::link(array('menuaction' => 'controller.uicheck_list.index',
'phpgw_return_as' => 'json')),
+ 'field' => array(
+ array(
+ 'key' => 'id',
+ 'label' => lang('ID'),
+ 'sortable' => true,
+ 'formatter' =>
'YAHOO.portico.formatLink'
+ ),
+ array(
+ 'key' => 'title',
+ 'label' =>
lang('Control title'),
+ 'sortable' =>
false
+ ),
+ array(
+ 'key' => 'start_date',
+ 'label' =>
lang('start_date'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'planned_date',
+ 'label' =>
lang('planned_date'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'end_date',
+ 'label' =>
lang('end_date'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'link',
+ 'hidden' => true
+ )
+ )
+ ),
+ );
+//_debug_array($data);
+
+ self::render_template_xsl('datatable', $data);
}
public function view_check_list()
@@ -234,5 +323,64 @@
$this->redirect(array('menuaction' =>
'controller.uicheck_list.view_check_list_for_control',
'control_id'=>$control_id));
}
- public function query(){}
+ public function query()
+ {
+ $params = array(
+ 'start' => phpgw::get_var('startIndex', 'int',
'REQUEST', 0),
+ 'results' => phpgw::get_var('results', 'int',
'REQUEST', null),
+ 'query' => phpgw::get_var('query'),
+ 'sort' => phpgw::get_var('sort'),
+ 'dir' => phpgw::get_var('dir'),
+ 'filters' => $filters
+ );
+
+ $search_for = phpgw::get_var('query');
+
+
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
+ {
+ $user_rows_per_page =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else {
+ $user_rows_per_page = 10;
+ }
+
+ // YUI variables for paging and sorting
+ $start_index = phpgw::get_var('startIndex', 'int');
+ $num_of_objects = phpgw::get_var('results', 'int',
'GET', $user_rows_per_page);
+ $sort_field = phpgw::get_var('sort');
+ if($sort_field == null)
+ {
+ $sort_field = 'control_id';
+ }
+ $sort_ascending = phpgw::get_var('dir') == 'desc' ?
false : true;
+ //Create an empty result set
+ $records = array();
+
+ //Retrieve a contract identifier and load corresponding
contract
+/* $control_id = phpgw::get_var('control_id');
+ if(isset($control_id))
+ {
+ $control = $this->so->get_single($control_id);
+ }
+*/
+ $result_objects = $this->so->get($start_index,
$num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type,
$filters);
+ $object_count = $this->so->get_count($search_for,
$search_type, $filters);
+ //var_dump($result_objects);
+
+ $results = array();
+
+ foreach($result_objects as $check_list_obj)
+ {
+ $results['results'][] =
$check_list_obj->serialize();
+ }
+
+ $results['total_records'] = $object_count;
+ $results['start'] = $params['start'];
+ $results['sort'] = $params['sort'];
+ $results['dir'] = $params['dir'];
+
+ array_walk($results["results"], array($this,
"_add_links"), "controller.uicheck_list.view_check_lists_for_control");
+
+ return $this->yui_results($results);
+ }
}
Modified: trunk/controller/templates/base/control.xsl
===================================================================
--- trunk/controller/templates/base/control.xsl 2011-11-09 07:11:58 UTC (rev
8060)
+++ trunk/controller/templates/base/control.xsl 2011-11-09 07:41:05 UTC (rev
8061)
@@ -72,27 +72,14 @@
<dd>
<xsl:choose>
<xsl:when test="editable">
- <input type="text" name="title"
id="title" value="{control/title}" />
+ <input type="text" name="title"
id="title" value="{control/title}" size="80"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="control/title" />
</xsl:otherwise>
</xsl:choose>
</dd>
- <dt>
- <label
for="description">Beskrivelse</label>
- </dt>
- <dd>
- <xsl:choose>
- <xsl:when test="editable">
- <textarea cols="70" rows="5"
name="description" id="description"><xsl:value-of select="control/description"
/></textarea>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of
select="control/description" disable-output-escaping="yes"/>
- </xsl:otherwise>
- </xsl:choose>
- </dd>
- <dt>
+<dt>
<label
for="start_date">Startdato</label>
</dt>
<dd>
@@ -129,6 +116,19 @@
</xsl:otherwise>
</xsl:choose>
</dd>
+ <dt>
+ <label
for="description">Beskrivelse</label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <textarea cols="70" rows="5"
name="description" id="description"><xsl:value-of select="control/description"
/></textarea>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="control/description" disable-output-escaping="yes"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
</dl>
<div class="form-buttons">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8061],
Erik Holm-Larsen <=