[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [12494] start converting the controller module
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [12494] start converting the controller module |
Date: |
Tue, 23 Dec 2014 11:34:44 +0000 |
Revision: 12494
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12494
Author: sigurdne
Date: 2014-12-23 11:34:44 +0000 (Tue, 23 Dec 2014)
Log Message:
-----------
start converting the controller module
Modified Paths:
--------------
branches/dev-syncromind/controller/inc/class.sodocument.inc.php
branches/dev-syncromind/controller/inc/class.uicontrol.inc.php
branches/dev-syncromind/controller/inc/class.uicontrol_group.inc.php
branches/dev-syncromind/controller/inc/class.uicontrol_item.inc.php
branches/dev-syncromind/controller/inc/class.uidocument.inc.php
branches/dev-syncromind/controller/inc/class.uiprocedure.inc.php
branches/dev-syncromind/controller/templates/base/control/control.xsl
branches/dev-syncromind/controller/templates/base/control/control_tabs.xsl
branches/dev-syncromind/controller/templates/base/control_group/control_group.xsl
branches/dev-syncromind/controller/templates/base/control_group/control_group_items.xsl
branches/dev-syncromind/controller/templates/base/control_group/control_group_tabs.xsl
branches/dev-syncromind/controller/templates/base/control_group/control_groups.xsl
branches/dev-syncromind/controller/templates/base/control_item/choose_control_items.xsl
branches/dev-syncromind/controller/templates/base/control_item/control_item.xsl
branches/dev-syncromind/controller/templates/base/control_item/sort_check_list.xsl
branches/dev-syncromind/controller/templates/base/procedure/procedure_item.xsl
branches/dev-syncromind/controller/templates/base/procedure/procedure_tabs.xsl
Modified: branches/dev-syncromind/controller/inc/class.sodocument.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.sodocument.inc.php
2014-12-23 11:33:40 UTC (rev 12493)
+++ branches/dev-syncromind/controller/inc/class.sodocument.inc.php
2014-12-23 11:34:44 UTC (rev 12494)
@@ -241,11 +241,12 @@
$results = array();
while($this->db->next_record())
{
- $result[] = $this->db->f('id');
- $result[] = $this->db->f('title', true);
- $results[] = $result;
+ $results[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'title' => $this->db->f('title', true)
+ );
}
- //$document_type_list = $results;
return $results;
}
Modified: branches/dev-syncromind/controller/inc/class.uicontrol.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.uicontrol.inc.php
2014-12-23 11:33:40 UTC (rev 12493)
+++ branches/dev-syncromind/controller/inc/class.uicontrol.inc.php
2014-12-23 11:34:44 UTC (rev 12494)
@@ -1,123 +1,118 @@
<?php
/**
- * phpGroupWare - controller: a part of a Facilities Management System.
- *
- * @author Erink Holm-Larsen <address@hidden>
- * @author Torstein Vadla <address@hidden>
- * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/
- * @package property
- * @subpackage controller
- * @version $Id$
- */
-
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erink Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id$
+ */
/**
- * Import the jQuery class
- */
+ * Import the jQuery class
+ */
phpgw::import_class('phpgwapi.jquery');
- phpgw::import_class('phpgwapi.uicommon');
- phpgw::import_class('property.boevent');
- phpgw::import_class('controller.socontrol');
- phpgw::import_class('controller.socontrol_group');
- phpgw::import_class('controller.socontrol_item');
- phpgw::import_class('controller.socontrol_item_list');
- phpgw::import_class('controller.soprocedure');
-
- phpgw::import_class('phpgwapi.yui');
-
- include_class('controller', 'control', 'inc/model/');
- include_class('controller', 'control_item_list', 'inc/model/');
- include_class('controller', 'control_group_list', 'inc/model/');
- include_class('controller', 'check_item', 'inc/model/');
-
- class controller_uicontrol extends phpgwapi_uicommon
- {
- private $bo;
- private $so;
- private $so_procedure;
- private $so_control_group;
- private $so_control_item;
- private $so_control_item_list;
- private $so_control_group_list;
- private $so_check_item;
- private $_category_acl;
+ phpgw::import_class('phpgwapi.uicommon_jquery');
+ phpgw::import_class('property.boevent');
+ phpgw::import_class('controller.socontrol');
+ phpgw::import_class('controller.socontrol_group');
+ phpgw::import_class('controller.socontrol_item');
+ phpgw::import_class('controller.socontrol_item_list');
+ phpgw::import_class('controller.soprocedure');
- private $read;
- private $add;
- private $edit;
- private $delete;
+ include_class('controller', 'control', 'inc/model/');
+ include_class('controller', 'control_item_list', 'inc/model/');
+ include_class('controller', 'control_group_list', 'inc/model/');
+ include_class('controller', 'check_item', 'inc/model/');
- public $public_functions = array
- (
- 'index'
=> true,
- 'control_list' =>
true,
- 'view'
=> true,
- 'view_control_details' => true,
- 'save_control_details' => true,
- 'view_control_groups' => true,
- 'save_control_groups' => true,
- 'view_control_items' => true,
- 'save_control_items' => true,
- 'view_check_list' =>
true,
- 'get_controls_by_control_area' => true,
- 'get_control_details' => true
+ class controller_uicontrol extends phpgwapi_uicommon_jquery
+ {
+
+ private $bo;
+ private $so;
+ private $so_procedure;
+ private $so_control_group;
+ private $so_control_item;
+ private $so_control_item_list;
+ private $so_control_group_list;
+ private $so_check_item;
+ private $_category_acl;
+ private $read;
+ private $add;
+ private $edit;
+ private $delete;
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'control_list' => true,
+ 'view' => true,
+ 'view_control_details' => true,
+ 'save_control_details' => true,
+ 'view_control_groups' => true,
+ 'save_control_groups' => true,
+ 'view_control_items' => true,
+ 'save_control_items' => true,
+ 'view_check_list' => true,
+ 'get_controls_by_control_area' => true,
+ 'get_control_details' => true
);
public function __construct()
{
parent::__construct('controller');
- $this->read =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1
- $this->add =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2
- $this->edit =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4
- $this->delete =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
-
- $this->manage =
$GLOBALS['phpgw']->acl->check('.control', 16, 'controller');//16
+ $this->read =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1
+ $this->add =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2
+ $this->edit =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4
+ $this->delete =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
+ $this->manage =
$GLOBALS['phpgw']->acl->check('.control', 16, 'controller');//16
//if(!$manage)
-
- $this->so = CreateObject('controller.socontrol');
- $this->bo = CreateObject('property.boevent',true);
- $this->so_procedure =
CreateObject('controller.soprocedure');
- $this->so_control_group =
CreateObject('controller.socontrol_group');
- $this->so_control_item =
CreateObject('controller.socontrol_item');
- $this->so_control_item_list =
CreateObject('controller.socontrol_item_list');
+
+ $this->so =
CreateObject('controller.socontrol');
+ $this->bo =
CreateObject('property.boevent', true);
+ $this->so_procedure =
CreateObject('controller.soprocedure');
+ $this->so_control_group =
CreateObject('controller.socontrol_group');
+ $this->so_control_item =
CreateObject('controller.socontrol_item');
+ $this->so_control_item_list =
CreateObject('controller.socontrol_item_list');
$this->so_control_group_list =
CreateObject('controller.socontrol_group_list');
- $this->so_check_list =
CreateObject('controller.socheck_list');
- $this->so_check_item =
CreateObject('controller.socheck_item');
-
- $config = CreateObject('phpgwapi.config','controller');
+ $this->so_check_list =
CreateObject('controller.socheck_list');
+ $this->so_check_item =
CreateObject('controller.socheck_item');
+
+ $config =
CreateObject('phpgwapi.config', 'controller');
$config->read();
$this->_category_acl =
isset($config->config_data['acl_at_control_area']) &&
$config->config_data['acl_at_control_area'] == 1 ? true : false;
self::set_active_menu('controller::control');
+
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/base.css');
+
}
-
/**
* Wrapper for control_list
*
* @return void
*/
-
public function index()
{
$this->control_list();
@@ -131,68 +126,66 @@
*/
public function control_list()
{
- if(phpgw::get_var('phpgw_return_as') == 'json') {
+ if(phpgw::get_var('phpgw_return_as') == 'json')
+ {
return $this->query();
}
- self::add_javascript('phpgwapi', 'yahoo',
'datatable.js');
- phpgwapi_yui::load_widget('datatable');
- phpgwapi_yui::load_widget('paginator');
// Sigurd: Start categories
- $cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
- $cats->supress_info = true;
+ $cats =
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+ $cats->supress_info = true;
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
- array_unshift($control_areas['cat_list'],array
('cat_id'=>'','name'=> lang('select value')));
+ $control_areas =
$cats->formatted_xslt_list(array('format' => 'filter', 'selected' =>
$control_area_id,
+ 'globals' => true, 'use_acl' =>
$this->_category_acl));
+ array_unshift($control_areas['cat_list'],
array('cat_id' => '', 'name' => lang('select value')));
$control_areas_array = array();
foreach($control_areas['cat_list'] as $cat_list)
{
$control_areas_array[] = array
- (
- 'id' => $cat_list['cat_id'],
- 'name' => $cat_list['name'],
- );
+ (
+ 'id' => $cat_list['cat_id'],
+ 'name' => $cat_list['name'],
+ );
}
// END categories
-
// start district
- $property_bocommon =
CreateObject('property.bocommon');
- $district_list =
$property_bocommon->select_district_list('dummy',$this->district_id);
- array_unshift ($district_list,array
('id'=>'','name'=>lang('no district')));
+ $property_bocommon =
CreateObject('property.bocommon');
+ $district_list =
$property_bocommon->select_district_list('dummy', $this->district_id);
+ array_unshift($district_list, array('id' => '', 'name'
=> lang('no district')));
// end district
$data = array(
- 'datatable_name' =>
'Kontroller',//lang('controls'),
+ 'datatable_name' => 'Kontroller',
//lang('controls'),
'form' => array(
'toolbar' => array(
'item' => array(
- array('type' =>
'filter',
+ 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')
- )
- )
- ),
+ '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')
+ )
+ )
+ ),
//as categories
array('type' =>
'filter',
'name' =>
'control_areas',
@@ -201,24 +194,15 @@
),
array('type' =>
'filter',
'name' =>
'responsibilities',
- 'text' => lang('Responsibility'),
- 'list' => $this->so->get_roles(),
+ 'text' =>
lang('Responsibility'),
+ 'list' =>
$this->so->get_roles(),
),
array('type' =>
'filter',
'name' =>
'district_id',
- 'text' => lang('district'),
- 'list' => $district_list,
+ 'text' =>
lang('district'),
+ 'list' =>
$district_list,
),
- array('type' => 'text',
- 'text' => lang('searchfield'),
- 'name' =>
'query'
- ),
array(
- 'type' =>
'submit',
- 'name' =>
'search',
- 'value' =>
lang('Search')
- ),
- array(
'type' =>
'link',
'value' =>
lang('New control'),
'href' =>
self::link(array('menuaction' => 'controller.uicontrol.view_control_details')),
@@ -228,34 +212,36 @@
),
),
'datatable' => array(
- 'source' =>
self::link(array('menuaction' => 'controller.uicontrol.control_list',
'phpgw_return_as' => 'json')),
+ 'source' =>
self::link(array('menuaction' => 'controller.uicontrol.control_list',
+ 'phpgw_return_as' => 'json')),
+ 'allrows' => true,
'field' => array(
array(
'key' => 'id',
'label' => lang('ID'),
- 'sortable' => true,
- 'formatter' =>
'YAHOO.portico.formatLink'
+ 'sortable' => true,
+ 'formatter' =>
'JqueryPortico.formatLink'
),
array(
- 'key' => 'title',
- 'label' =>
lang('Control title'),
- 'sortable' =>
true,
- 'formatter' => 'YAHOO.portico.formatLink'
+ 'key' => 'title',
+ 'label' =>
lang('Control title'),
+ 'sortable' => true,
+ 'formatter' =>
'JqueryPortico.formatLink'
),
array(
'key' => 'description',
'label' =>
lang('description'),
- 'sortable' => false
+ 'sortable' => false
),
array(
'key' =>
'control_area_name',
'label' =>
lang('Control area'),
- 'sortable' => false
+ 'sortable' => false
),
array(
'key' =>
'responsibility_name',
'label' =>
lang('Responsibility'),
- 'sortable' => false
+ 'sortable' => false
),
array(
'key' => 'link',
@@ -265,15 +251,15 @@
'key' =>
'show_locations',
'label' => '',
'sortable' => false,
- 'formatter' =>
'YAHOO.portico.formatGenericLink'
+ 'formatter' =>
'JqueryPortico.formatLinkGeneric'
)
)
),
);
- self::render_template_xsl(array( 'datatable_common' ),
$data);
+ self::render_template_xsl(array('datatable_jquery'),
$data);
}
-
+
/**
* Fetches control details from db and returns to view
*
@@ -285,57 +271,58 @@
if($control == null)
{
$control_id = phpgw::get_var('id');
-
+
if(isset($control_id) && $control_id > 0)
{
$control =
$this->so->get_single($control_id);
}
}
-
- $cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
- $cats->supress_info = true;
-
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl'
=> $this->_category_acl));
+
+ $cats =
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+ $cats->supress_info = true;
+
+ $control_areas =
$cats->formatted_xslt_list(array('format' => 'filter', 'globals' => true,
+ 'use_acl' => $this->_category_acl));
$control_areas_array = $control_areas['cat_list'];
-
+
if($control != null)
{
$procedures_array =
$this->so_procedure->get_procedures_by_control_area($control->get_control_area_id());
}
-
+
$role_array = $this->so->get_roles();
-
+
$repeat_type_array = array(
-
array('id' => "0", 'value' => "Dag"),
-
array('id' => "1", 'value' => "Uke"),
-
array('id' => "2", 'value' => "Måned"),
-
array('id' => "3", 'value' => "År")
- );
-
+ array('id' => "0", 'value' => "Dag"),
+ array('id' => "1", 'value' => "Uke"),
+ array('id' => "2", 'value' => "Måned"),
+ array('id' => "3", 'value' => "År")
+ );
+
$tabs = $this->make_tab_menu($control_id);
-
+
$data = array
- (
- 'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 0),
- 'view'
=> "control_details",
- 'editable'
=> true,
- 'control'
=> ($control != null) ? $control : null,
- 'control_areas_array' =>
$control_areas_array,
- 'procedures_array' =>
$procedures_array,
- 'role_array'
=> $role_array,
- 'repeat_type_array' =>
$repeat_type_array
+ (
+ 'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, 'details','control_tabview'),
+ 'view' => "control_details",
+ 'editable' => true,
+ 'control' => ($control != null) ? $control :
null,
+ 'control_areas_array' => $control_areas_array,
+ 'procedures_array' => $procedures_array,
+ 'role_array' => $role_array,
+ 'repeat_type_array' => $repeat_type_array
);
-
+
self::add_javascript('controller', 'yahoo',
'control_tabs.js');
self::add_javascript('controller', 'controller',
'ajax.js');
-
+
$this->use_yui_editor(array('description'));
$GLOBALS['phpgw']->jqcal->add_listener('start_date');
$GLOBALS['phpgw']->jqcal->add_listener('end_date');
self::render_template_xsl(array('control/control_tabs',
'control/control'), $data);
}
-
+
/**
* Public function for saving control details
*
@@ -346,58 +333,59 @@
{
if(!$this->add && !$this->edit)
{
-
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
'controller.uicontrol.index'));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol.index'));
}
$control_id = phpgw::get_var('control_id');
-
+
// Update existing control details
$delete_control_groups = false;
- if(isset($control_id) && $control_id > 0 )
+ if(isset($control_id) && $control_id > 0)
{
- $control = $this->so->get_single($control_id);
- $control_area_id_in_db =
$control->get_control_area_id();
+ $control
= $this->so->get_single($control_id);
+ $control_area_id_in_db =
$control->get_control_area_id();
$control->populate();
- $control_area_id_from_req =
$control->get_control_area_id();
-
+ $control_area_id_from_req =
$control->get_control_area_id();
+
// DELETE EARLIER SAVED CONTROL GROUPS
// If control are is different from a previous
registration - delete related groups
- if( ($control_area_id_in_db > 0) &
($control_area_id_in_db != $control_area_id_from_req) )
- {
+ if(($control_area_id_in_db > 0) &
($control_area_id_in_db != $control_area_id_from_req))
+ {
$delete_control_groups = true;
}
}
// Add control details
- else
+ else
{
$control = new controller_control();
$control->populate();
}
-
+
// SAVE CONTROL DETAILS
- if( $control->validate() )
+ if($control->validate())
{
if($delete_control_groups)
{
// Deleting earlier saved control groups
$this->so_control_group_list->delete_control_groups($control_id);
$saved_control_items =
$this->so_control_item_list->get_control_items_by_control($control_id);
-
+
foreach($saved_control_items as
$control_item)
{
$this->so_control_item_list->delete($control->get_id(),
$control_item->get_id());
}
}
-
+
$control_id = $this->so->store($control);
- $this->redirect(array('menuaction' =>
'controller.uicontrol.view_control_groups', 'control_id' => $control_id));
+ $this->redirect(array('menuaction' =>
'controller.uicontrol.view_control_groups',
+ 'control_id' => $control_id));
}
else
{
- $this->view_control_details($control);
+ $this->view_control_details($control);
}
}
-
+
/**
* Public function for viewing control groups
* Displays control groups by chosen control area
@@ -407,29 +395,29 @@
*/
public function view_control_groups()
{
- $control_id = phpgw::get_var('control_id');
- $control = $this->so->get_single($control_id);
-
+ $control_id = phpgw::get_var('control_id');
+ $control = $this->so->get_single($control_id);
+
// Fetches saved control groups from db
$saved_control_groups =
$this->so_control_group_list->get_control_groups_by_control($control_id);
$saved_control_group_ids = array();
-
+
foreach($saved_control_groups as $control_group)
{
$saved_control_group_ids[] =
$control_group->get_id();
}
-
- // Fetches control groups based on selected control
area
- $control_area =
execMethod('phpgwapi.categories.return_single',
$control->get_control_area_id());
+
+ // Fetches control groups based on selected control area
+ $control_area =
execMethod('phpgwapi.categories.return_single',
$control->get_control_area_id());
$control_groups_as_array =
$this->so_control_group->get_control_groups_as_array($control->get_control_area_id());
-
+
$control_groups = array();
foreach($control_groups_as_array as $control_group)
{
$control_group_id = $control_group['id'];
-
- if( in_array($control_group_id,
$saved_control_group_ids ))
+
+ if(in_array($control_group_id,
$saved_control_group_ids))
{
$control_groups[] = array("checked" =>
1, "control_group" => $control_group);
}
@@ -438,25 +426,25 @@
$control_groups[] = array("checked" =>
0, "control_group" => $control_group);
}
}
-
+
$tabs = $this->make_tab_menu($control_id);
-
+
$data = array
(
- 'tabs' =>
$GLOBALS['phpgw']->common->create_tabs($tabs, 1),
- 'view' =>
"control_groups",
- 'editable' => true,
- 'control' => $control,
- 'control_area' => $control_area,
- 'control_groups' => $control_groups,
+ 'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, 'control_groups','control_tabview'),
+ 'view' => "control_groups",
+ 'editable' => true,
+ 'control' => $control,
+ 'control_area' => $control_area,
+ 'control_groups' => $control_groups,
);
-
+
phpgwapi_jquery::load_widget('core');
self::add_javascript('controller', 'yahoo',
'control_tabs.js');
self::add_javascript('controller', 'controller',
'ajax.js');
self::render_template_xsl(array('control/control_tabs',
'control_group/control_groups'), $data);
}
-
+
/**
* Public function for saving control groups.
*
@@ -467,21 +455,21 @@
{
if(!$this->add && !$this->edit)
{
-
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
'controller.uicontrol.index'));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol.index'));
}
- $control_id = phpgw::get_var('control_id');
- $control_group_ids =
phpgw::get_var('control_group_ids');
+ $control_id =
phpgw::get_var('control_id');
+ $control_group_ids =
phpgw::get_var('control_group_ids');
// Fetches saved control groups
$saved_control_groups =
$this->so_control_group_list->get_control_groups_by_control($control_id);
-
+
// Deletes groups from control that's not among the
chosen groups
foreach($saved_control_groups as $group)
{
// If saved group id not among chosen control
ids, delete the group for the control
- if( !in_array($group->get_id(),
$control_group_ids) )
+ if(!in_array($group->get_id(),
$control_group_ids))
{
$this->so_control_group_list->delete($control_id, $group->get_id());
// Deletes control items for group
@@ -492,142 +480,151 @@
$group_order_nr = 1;
// Saving control groups
- foreach ($control_group_ids as $control_group_id)
+ foreach($control_group_ids as $control_group_id)
{
$control_group =
$this->so_control_group_list->get_group_list_by_control_and_group($control_id,
$control_group_id);
-
+
if($control_group == null)
{
$control_group_list = new
controller_control_group_list();
$control_group_list->set_control_id($control_id);
$control_group_list->set_control_group_id($control_group_id);
$control_group_list->set_order_nr($group_order_nr);
-
+
$this->so_control_group_list->add($control_group_list);
- $group_order_nr++;
+ $group_order_nr++;
}
}
// Redirect: view_control_items
- $this->redirect(array('menuaction' =>
'controller.uicontrol.view_control_items', 'control_id'=>$control_id));
+ $this->redirect(array('menuaction' =>
'controller.uicontrol.view_control_items',
+ 'control_id' => $control_id));
}
-
+
/**
- * Public function for viewing control items
- *
+ * Public function for viewing control items
+ *
* @param HTTP::id the control_id
* @return redirect to function view_control_items
- */
- public function view_control_items(){
- $control_id = phpgw::get_var('control_id', 'int');
- $control = $this->so->get_single($control_id);
-
+ */
+ public function view_control_items()
+ {
+ $control_id = phpgw::get_var('control_id', 'int');
+ $control = $this->so->get_single($control_id);
+
// Array with selected control groups and items
$groups_with_control_items = array();
-
+
$saved_control_groups =
$this->so_control_group_list->get_control_groups_by_control($control_id);
-
+
// Fetches control items for control group and
populates groups_with_control_items with groups and chosen control items
- foreach ($saved_control_groups as $control_group)
- {
+ foreach($saved_control_groups as $control_group)
+ {
// Fetches control items for group
$control_items_for_group =
$this->so_control_item_list->get_control_items($control_group->get_id());
-
+
// Fetches saved, ordered control items for
group
$saved_control_items_for_group =
$this->so_control_item_list->get_control_items_by_control_and_group($control_id,
$control_group->get_id(), "return_object");
-
- // Array that contains saved and unsaved
control items for the group
+
+ // Array that contains saved and unsaved
control items for the group
$control_items_for_group_array = array();
-
- foreach($saved_control_items_for_group as
$saved_control_item){
- $control_items_for_group_array[] =
array("checked" => 1, "control_item" => $saved_control_item->toArray());
+
+ foreach($saved_control_items_for_group as
$saved_control_item)
+ {
+ $control_items_for_group_array[] =
array("checked" => 1, "control_item" => $saved_control_item->toArray());
}
-
- // Loops through all control items for the
group and add those control items that is not saved
- foreach($control_items_for_group as
$control_item){
- $status_control_item_saved = false;
-
- foreach($saved_control_items_for_group
as $saved_control_item){
- if( $control_item->get_id() ==
$saved_control_item->get_id()){
+
+ // Loops through all control items for the
group and add those control items that is not saved
+ foreach($control_items_for_group as
$control_item)
+ {
+ $status_control_item_saved = false;
+
+ foreach($saved_control_items_for_group
as $saved_control_item)
+ {
+ if($control_item->get_id() ==
$saved_control_item->get_id())
+ {
$status_control_item_saved = true;
- }
+ }
}
-
- // Adds control item to saved
- if(!$status_control_item_saved){
+
+ // Adds control item to saved
+ if(!$status_control_item_saved)
+ {
$control_items_for_group_array[] = array("checked" => 0, "control_item" =>
$control_item->toArray());
}
}
-
- $groups_with_control_items[] =
array("control_group" => $control_group->toArray(), "group_control_items" =>
$control_items_for_group_array);
- }
-
+
+ $groups_with_control_items[] =
array("control_group" => $control_group->toArray(),
+ "group_control_items" =>
$control_items_for_group_array);
+ }
+
$tabs = $this->make_tab_menu($control_id);
-
+
$data = array
(
- 'tabs'
=>
$GLOBALS['phpgw']->common->create_tabs($tabs, 2),
- 'view'
=> 'control_items',
- 'control_group_ids'
=> implode($control_group_ids, ","),
- 'control'
=> $control,
- 'groups_with_control_items' =>
$groups_with_control_items
+ 'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, 'control_items','control_tabview'),
+ 'view' => 'control_items',
+ 'control_group_ids' =>
implode($control_group_ids, ","),
+ 'control' => $control,
+ 'groups_with_control_items' =>
$groups_with_control_items
);
-
+
phpgwapi_jquery::load_widget('core');
self::add_javascript('controller', 'yahoo',
'control_tabs.js');
self::add_javascript('controller', 'controller',
'custom_ui.js');
self::add_javascript('controller', 'controller',
'ajax.js');
- self::render_template_xsl(array('control/control_tabs',
'control_item/choose_control_items'), $data);
+ self::render_template_xsl(array('control/control_tabs',
'control_item/choose_control_items'), $data);
}
-
+
/**
* Public function for saving control items
*
* @param HTTP::id the control_id and a comma separated
list of tags (1:2, control_group_id:control_item_id)
* @return redirect to function view_control_items
- */
- public function save_control_items(){
+ */
+ public function save_control_items()
+ {
$control_id = phpgw::get_var('control_id');
// Fetching selected control items. Tags are on the
format 1:2 (group:item).
$control_tag_ids = phpgw::get_var('control_tag_ids');
-
+
$saved_control_items =
$this->so_control_item_list->get_control_items_by_control($control_id,
"return_object");
-
+
// Deleting formerly saved control items
- foreach ($saved_control_items as $saved_control_item)
+ foreach($saved_control_items as $saved_control_item)
{
- $exists = false;
- $saved_control_item_id =
$saved_control_item->get_id();
-
- foreach ($control_tag_ids as $control_item_tag)
+ $exists =
false;
+ $saved_control_item_id =
$saved_control_item->get_id();
+
+ foreach($control_tag_ids as $control_item_tag)
{
- $control_item_id =
substr($control_item_tag, strpos($control_item_tag, ":")+1,
strlen($control_item_tag));
-
+ $control_item_id =
substr($control_item_tag, strpos($control_item_tag, ":") + 1,
strlen($control_item_tag));
+
if($control_item_id ==
$saved_control_item_id)
{
$exists = true;
}
}
-
+
if($exists == false)
{
- $exists = false;
- $status =
$this->so_control_item_list->delete($control_id, $saved_control_item_id);
+ $exists = false;
+ $status =
$this->so_control_item_list->delete($control_id, $saved_control_item_id);
}
}
-
+
$order_nr = 1;
// Saving new control items
- foreach ($control_tag_ids as $control_item_tag)
+ foreach($control_tag_ids as $control_item_tag)
{
// Fetch control_item_id from tag string
- $control_item_id = substr($control_item_tag,
strpos($control_item_tag, ":")+1, strlen($control_item_tag));
-
+ $control_item_id = substr($control_item_tag,
strpos($control_item_tag, ":") + 1, strlen($control_item_tag));
+
$saved_control_list_item =
$this->so_control_item_list->get_single_2($control_id, $control_item_id);
-
- if( $saved_control_list_item == null )
+
+ if($saved_control_list_item == null)
{
// Saves control item
$control_item_list = new
controller_control_item_list();
@@ -635,49 +632,52 @@
$control_item_list->set_control_item_id($control_item_id);
$control_item_list->set_order_nr($order_nr);
$this->so_control_item_list->add($control_item_list);
-
+
$order_nr++;
}
}
-
- $this->redirect(array('menuaction' =>
'controller.uicontrol.view_check_list', 'control_id'=>$control_id ));
+
+ $this->redirect(array('menuaction' =>
'controller.uicontrol.view_check_list',
+ 'control_id' => $control_id));
}
/**
* Public function for viewing chosen control items
- *
+ *
* @param HTTP::id the control_id
- * @return data array
- */
- public function view_check_list(){
- $control_id = phpgw::get_var('control_id');
- $control = $this->so->get_single($control_id);
-
- // Fetches saved control groups from DB for this
control
+ * @return data array
+ */
+ public function view_check_list()
+ {
+ $control_id = phpgw::get_var('control_id');
+ $control = $this->so->get_single($control_id);
+
+ // Fetches saved control groups from DB for this control
$saved_control_groups =
$this->so_control_group_list->get_control_groups_by_control($control_id);
-
+
$saved_groups_with_items_array = array();
-
+
// Populating array with saved control items for each
group
- foreach ($saved_control_groups as $control_group)
- {
+ foreach($saved_control_groups as $control_group)
+ {
// Fetches saved control items for group
$saved_control_items =
$this->so_control_item_list->get_control_items_by_control_and_group($control_id,
$control_group->get_id());
-
- if(count($saved_control_items) > 0)
- $saved_groups_with_items_array[] =
array("control_group" => $control_group->toArray(), "control_items" =>
$saved_control_items);
+
+ if(count($saved_control_items) > 0)
+ $saved_groups_with_items_array[] =
array("control_group" => $control_group->toArray(),
+ "control_items" =>
$saved_control_items);
}
-
+
$tabs = $this->make_tab_menu($control_id);
-
+
$data = array
(
- 'tabs'
=>
$GLOBALS['phpgw']->common->create_tabs($tabs, 3),
- 'view'
=> "sort_check_list",
- 'control'
=> $control,
- 'saved_groups_with_items_array' =>
$saved_groups_with_items_array
+ 'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, 'check_list','control_tabview'),
+ 'view' => "sort_check_list",
+ 'control' => $control,
+ 'saved_groups_with_items_array' =>
$saved_groups_with_items_array
);
-
+
phpgwapi_jquery::load_widget('core');
self::add_javascript('controller', 'yahoo',
'control_tabs.js');
@@ -686,130 +686,143 @@
self::add_javascript('controller', 'controller',
'ajax.js');
self::render_template_xsl(array('control/control_tabs',
'control_item/sort_check_list'), $data);
}
-
+
public function get_control_details()
{
- $control_id = phpgw::get_var('control_id');
- $control = $this->so->get_single($control_id);
+ $control_id = phpgw::get_var('control_id');
+ $control = $this->so->get_single($control_id);
$data = array
(
- 'control' => $control
+ 'control' => $control
);
-
+
self::render_template_xsl('control/control_details',
$data);
}
-
- function make_tab_menu($control_id){
+
+ function make_tab_menu($control_id)
+ {
$tabs = array();
-
- if($control_id > 0){
-
+
+ if($control_id > 0)
+ {
+
$control = $this->so->get_single($control_id);
-
- $tabs[] = array(
- 'label' => "1: " .
lang('Details'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_details',
-
'id' => $control->get_id()))
- );
-
- $saved_control_groups =
$this->so_control_group_list->get_control_groups_by_control( $control->get_id()
);
-
+
+ $tabs['details'] = array(
+ 'label' => "1: " . lang('Details'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_details',
+ 'id' => $control->get_id()))
+ );
+
+ $saved_control_groups =
$this->so_control_group_list->get_control_groups_by_control($control->get_id());
+
if(count($saved_control_groups) > 0)
{
- $tabs[] = array(
- 'label' => "2:
" . lang('Choose_control_groups'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_groups',
-
'control_id' => $control->get_id()))
- );
-
- $saved_control_items =
$this->so_control_item_list->get_control_items_by_control( $control->get_id() );
-
+ $tabs['control_groups'] = array(
+ 'label' => "2: " .
lang('Choose_control_groups'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_groups',
+ 'control_id' =>
$control->get_id()))
+ );
+
+ $saved_control_items =
$this->so_control_item_list->get_control_items_by_control($control->get_id());
+
if(count($saved_control_items) > 0)
{
- $tabs[] = array(
- 'label'
=> "3: " . lang('Choose_control_items'),
- 'link'
=> $GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_items',
-
'control_id' => $control->get_id())));
- $tabs[] = array('label' => "4:
" . lang('Sort_check_list'),
- 'link'
=> $GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_check_list',
-
'control_id' => $control->get_id())));
- }else{
- $tabs[] = array('label' => "3:
" . lang('Choose_control_items'));
- $tabs[] = array('label' => "4:
" . lang('Sort_check_list'));
+ $tabs['control_items'] =
array(
+ 'label' => "3: " .
lang('Choose_control_items'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_items',
+ 'control_id' =>
$control->get_id())));
+ $tabs['check_list'] =
array('label' => "4: " . lang('Sort_check_list'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_check_list',
+ 'control_id' =>
$control->get_id())));
}
- }else{
- $tabs[] = array('label' => "2: " .
lang('Choose_control_groups'));
- $tabs[] = array('label' => "3: " .
lang('Choose_control_items'));
- $tabs[] = array('label' => "4: " .
lang('Sort_check_list'));
+ else
+ {
+ $tabs['control_items'] =
array('label' => "3: " . lang('Choose_control_items'));
+ $tabs['check_list'] =
array('label' => "4: " . lang('Sort_check_list'));
+ }
}
- }else{
- $tabs = array(
- array(
- 'label' => "1: " .
lang('Details')
- ), array(
- 'label' => "2: " .
lang('Choose_control_groups')
- ), array(
- 'label' => "3: " .
lang('Choose_control_items')
- ), array(
- 'label' => "4: " .
lang('Sort_check_list')
- ));
+ else
+ {
+ $tabs['control_groups'] =
array('label' => "2: " . lang('Choose_control_groups'));
+ $tabs['control_items'] =
array('label' => "3: " . lang('Choose_control_items'));
+ $tabs['check_list'] =
array('label' => "4: " . lang('Sort_check_list'));
+ }
}
-
+ else
+ {
+ $tabs = array(
+ 'details' => array(
+ 'label' => "1: " .
lang('Details')
+ ),
+ 'control_groups' => array(
+ 'label' => "2: " .
lang('Choose_control_groups')
+ ),
+ 'control_items' => array(
+ 'label' => "3: " .
lang('Choose_control_items')
+ ),
+ 'check_list' => array(
+ 'label' => "4: " .
lang('Sort_check_list')
+ ));
+ }
+
return $tabs;
- }
+ }
/**
* Public function for retrieving controls that has a certain
control area
*
* @param HTTP:: control area id
* @return array of controls as json
- */
+ */
public function get_controls_by_control_area()
{
$control_area_id = phpgw::get_var('control_area_id');
-
+
$controls_array =
$this->so->get_controls_by_control_area($control_area_id);
-
- if(count($controls_array)>0)
- return json_encode( $controls_array );
+
+ if(count($controls_array) > 0)
+ return json_encode($controls_array);
else
return null;
}
-
+
/**
- * Public function for retrieving locations that is assigned to
a control
- *
+ * Public function for retrieving locations that is assigned to
a control
+ *
* @param HTTP:: control id
- * @return array of locations as json
- */
+ * @return array of locations as json
+ */
public function get_locations_for_control()
{
$control_id = phpgw::get_var('control_id');
-
+
if(is_numeric($control_id) & $control_id > 0)
{
$locations_for_control_array =
$this->so->get_locations_for_control($control_id);
-
+
foreach($locations_for_control_array as
$location)
{
- $results['results'][]= $location;
+ $results['results'][] = $location;
}
-
- $results['total_records'] = count(
$locations_for_control_array );
- $results['start'] = 1;
- $results['sort'] = 'location_code';
-
+
+ $results['total_records'] =
count($locations_for_control_array);
+ $results['start'] = 1;
+ $results['sort'] =
'location_code';
+
array_walk($results['results'], array($this,
'add_actions'), array($type));
}
else
{
$results['total_records'] = 0;
- }
-
- return $this->yui_results($results);
+ }
+
+ $results['draw'] =
phpgw::get_var('draw', 'int');
+
+ return $this->jquery_results($results);
}
-
+
/**
* Add data for context menu
*
@@ -820,82 +833,82 @@
public function add_actions(&$value, $key, $params)
{
unset($value['query_location']);
-
- $value['ajax'] = array();
- $value['actions'] = array();
- $value['labels'] = array();
-
- $value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uicontrol.view_control_details', 'id' => $value['control_id'])));
- $value['labels'][] = lang('View control');
-
- $value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uicontrol.view_locations_for_control', 'id' =>
$value['control_id'])));
- $value['labels'][] = lang('View locations for control');
-
- $value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uicheck_list.add_check_list', 'location_code' =>
$value['location_code'])));
- $value['labels'][] = lang('add_check_list_to_location');
+
+ $value['ajax'] = array();
+ $value['actions'] = array();
+ $value['labels'] = array();
+
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uicontrol.view_control_details',
+ 'id' => $value['control_id'])));
+ $value['labels'][] = lang('View control');
+
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uicontrol.view_locations_for_control',
+ 'id' => $value['control_id'])));
+ $value['labels'][] = lang('View locations for
control');
+
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uicheck_list.add_check_list',
+ 'location_code' => $value['location_code'])));
+ $value['labels'][] =
lang('add_check_list_to_location');
}
-
+
public function register_control_to_location()
{
- $control_id = phpgw::get_var('control_id');
- $location_code = phpgw::get_var('location_code');
-
+ $control_id = phpgw::get_var('control_id');
+ $location_code = phpgw::get_var('location_code');
+
$this->so->register_control_to_location($control_id,
$location_code);
}
-
+
public function query()
{
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+
$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
+ 'start' => phpgw::get_var('start', 'int',
'REQUEST', 0),
+ 'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length', 'int') ==
-1,
);
-
+
+
$ctrl_area = phpgw::get_var('control_areas');
if(isset($ctrl_area) && $ctrl_area > 0)
{
- $filters['control_areas'] = $ctrl_area;
+ $filters['control_areas'] = $ctrl_area;
}
$responsibility = phpgw::get_var('responsibilities');
if(isset($responsibility) && $responsibility > 0)
{
- $filters['responsibilities'] = $responsibility;
+ $filters['responsibilities'] = $responsibility;
}
$filters['district_id'] = phpgw::get_var('district_id',
'int', 'REQUEST', null);
-
- $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;
- }
-
+ $search_for = $params['query'];
+
// 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)
+ $start_index =$params['start'];
+ $num_of_objects = $params['results'] > 0 ?
$params['results'] : null;
+ $sort_field = $params['order'];
+
+ if(!$sort_field)
{
$sort_field = 'controller_control.id';
}
-
- $sort_ascending = phpgw::get_var('dir') == 'desc' ?
false : true;
-
+
+ $sort_ascending =$params['sort'] == '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))
@@ -903,30 +916,35 @@
$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);
-
+ $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);
+
$results = array();
-
+
foreach($result_objects as $control_obj)
{
- $results['results'][] =
$control_obj->serialize();
+ $results['results'][] =
$control_obj->serialize();
}
-
- $results['total_records'] = $object_count;
- $results['start'] = $params['start'];
- $results['sort'] = $params['sort'];
- $results['dir'] = $params['dir'];
+ $results['total_records'] = $object_count;
+ $results['start'] =
$params['start'];
+ $results['sort'] =
$params['sort'];
+ $results['dir'] =
$params['dir'];
+ $results['draw'] = $draw;
+
+
array_walk($results["results"], array($this,
"_add_links"), "controller.uicontrol.view_control_details");
-
- foreach($results["results"] as &$res) {
+ $label = lang('show_controls_for_location');
+
+ foreach($results["results"] as &$res)
+ {
$res['show_locations'] = array(
- 'href' => self::link(array('menuaction'
=> 'controller.uicalendar.view_calendar_year_for_locations', 'control_id' =>
$res['id'])),
- 'label' =>
lang('show_controls_for_location'),
+ 'href' => self::link(array('menuaction'
=> 'controller.uicalendar.view_calendar_year_for_locations',
+ 'control_id' => $res['id'])),
+ 'label' => $label,
);
}
- return $this->yui_results($results);
+ return $this->jquery_results($results);
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/controller/inc/class.uicontrol_group.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.uicontrol_group.inc.php
2014-12-23 11:33:40 UTC (rev 12493)
+++ branches/dev-syncromind/controller/inc/class.uicontrol_group.inc.php
2014-12-23 11:34:44 UTC (rev 12494)
@@ -1,39 +1,38 @@
<?php
/**
- * phpGroupWare - controller: a part of a Facilities Management System.
- *
- * @author Erink Holm-Larsen <address@hidden>
- * @author Torstein Vadla <address@hidden>
- * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/
- * @package property
- * @subpackage controller
- * @version $Id$
- */
-
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erink Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id$
+ */
/**
- * Import the jQuery class
- */
+ * Import the jQuery class
+ */
phpgw::import_class('phpgwapi.jquery');
- phpgw::import_class('phpgwapi.uicommon');
+ phpgw::import_class('phpgwapi.uicommon_jquery');
phpgw::import_class('property.boevent');
phpgw::import_class('controller.socontrol');
phpgw::import_class('controller.socontrol_item');
@@ -42,45 +41,46 @@
include_class('controller', 'control_group', 'inc/model/');
- class controller_uicontrol_group extends phpgwapi_uicommon
+ class controller_uicontrol_group extends phpgwapi_uicommon_jquery
{
+
private $so;
private $so_procedure;
private $so_control_area;
private $so_control_item;
private $so_control_item_list;
private $so_control_group_list;
-
- private $read;
- private $add;
- private $edit;
- private $delete;
-
+ private $read;
+ private $add;
+ private $edit;
+ private $delete;
public $public_functions = array
(
- 'index'
=>
true,
- 'query'
=>
true,
- 'edit'
=>
true,
- 'view'
=>
true,
- 'add'
=> true,
- 'save_group_and_item_order'
=> true,
- 'get_control_groups_by_control_area' => true
+ 'index'
=> true,
+ 'query'
=> true,
+ 'edit'
=> true,
+ 'view'
=> true,
+ 'add'
=> true,
+ 'save_group_and_item_order' =>
true,
+ 'get_control_groups_by_control_area' => true
);
public function __construct()
{
parent::__construct();
- $this->so = CreateObject('controller.socontrol_group');
- $this->so_procedure =
CreateObject('controller.soprocedure');
- $this->so_control_item =
CreateObject('controller.socontrol_item');
- $this->so_control_item_list =
CreateObject('controller.socontrol_item_list');
- $this->so_control_group_list =
CreateObject('controller.socontrol_group_list');
- $GLOBALS['phpgw_info']['flags']['menu_selection'] =
"controller::control_group";
+ $this->so
=
CreateObject('controller.socontrol_group');
+ $this->so_procedure
= CreateObject('controller.soprocedure');
+ $this->so_control_item
= CreateObject('controller.socontrol_item');
+ $this->so_control_item_list
= CreateObject('controller.socontrol_item_list');
+ $this->so_control_group_list
= CreateObject('controller.socontrol_group_list');
+ $GLOBALS['phpgw_info']['flags']['menu_selection']
= "controller::control_group";
- $this->read =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1
- $this->add =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2
- $this->edit =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4
- $this->delete =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
+ $this->read =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1
+ $this->add =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2
+ $this->edit =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4
+ $this->delete =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
+
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/base.css');
+
}
public function index()
@@ -91,89 +91,75 @@
}
// Sigurd: Start categories
- $cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
- $cats->supress_info = true;
+ $cats =
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+ $cats->supress_info = true;
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
- array_unshift($control_areas['cat_list'],array
('cat_id'=>'','name'=> lang('select value')));
- $control_areas_array2 = array();
+ $control_areas =
$cats->formatted_xslt_list(array('format' => 'filter', 'selected'
=> $control_area_id,
+ 'globals' => true, 'use_acl' =>
$this->_category_acl));
+ array_unshift($control_areas['cat_list'],
array('cat_id' => '', 'name' => lang('select value')));
+ $control_areas_array2 = array();
foreach($control_areas['cat_list'] as $cat_list)
{
$control_areas_array2[] = array
(
- 'id' => $cat_list['cat_id'],
- 'name' => $cat_list['name'],
+ 'id' => $cat_list['cat_id'],
+ 'name' => $cat_list['name'],
);
}
// END categories
- self::add_javascript('phpgwapi', 'yahoo',
'datatable.js');
- phpgwapi_yui::load_widget('datatable');
- phpgwapi_yui::load_widget('paginator');
$data = array(
- 'datatable_name' => 'Kontrollgrupper',
//lang('control groups'),
- 'form' => array(
+ 'datatable_name' => 'Kontrollgrupper',
//lang('control groups'),
+ 'form' => array(
'toolbar' => array(
'item' => array(
- array('type' =>
'filter',
- 'name' =>
'control_areas',
- 'text' =>
lang('Control_area'),
- 'list' =>
$control_areas_array2,
+ array('type' =>
'filter',
+ 'name' =>
'control_areas',
+ 'text' =>
lang('Control_area'),
+ 'list' =>
$control_areas_array2,
),
- array('type' => 'text',
- 'text' =>
lang('searchfield'),
- 'name' =>
'query'
- ),
array(
- 'type' =>
'submit',
- 'name' =>
'search',
- 'value' =>
lang('Search')
+ 'type' =>
'link',
+ 'value' =>
lang('New control group'),
+ 'href' =>
self::link(array('menuaction' => 'controller.uicontrol_group.add')),
+ 'class' =>
'new_item'
),
- array(
- 'type' =>
'link',
- 'value' =>
$_SESSION['showall'] ? lang('Show only active') : lang('Show all'),
- 'href' =>
self::link(array('menuaction' => $this->url_prefix.'.toggle_show_inactive'))
- ),
- array(
- 'type' =>
'link',
- 'value' =>
lang('New control group'),
- 'href' =>
self::link(array('menuaction' => 'controller.uicontrol_group.add')),
- 'class' =>
'new_item'
- ),
),
),
),
- 'datatable' => array(
- 'source' =>
self::link(array('menuaction' => 'controller.uicontrol_group.index',
'phpgw_return_as' => 'json')),
- 'field' => array(
+ 'datatable' => array(
+ 'source' =>
self::link(array('menuaction' =>
'controller.uicontrol_group.index',
+ 'phpgw_return_as' =>
'json')),
+ 'allrows' => true,
+ 'field' => array(
array(
- 'key' => 'id',
- 'label' => lang('ID'),
- 'sortable' => true,
- 'formatter' =>
'YAHOO.portico.formatLink'
+ 'key' =>
'id',
+ 'label' =>
lang('ID'),
+ 'sortable' =>
true,
+ 'formatter' =>
'JqueryPortico.formatLink'
),
array(
- 'key' =>
'group_name',
- 'label' =>
lang('Control group title'),
- 'sotrable' =>
false
+ 'key' =>
'group_name',
+ 'label' =>
lang('Control group title'),
+ 'sotrable' =>
false
),
array(
- 'key' => 'procedure',
- 'label' =>
lang('Procedure'),
- 'sortable' => false
+ 'key' =>
'procedure',
+ 'label' =>
lang('Procedure'),
+ 'sortable' =>
false
),
array(
- 'key' =>
'building_part',
- 'label' =>
lang('Building part'),
- 'sortable' => false
+ 'key' =>
'building_part',
+ 'label' =>
lang('Building part'),
+ 'sortable' =>
false
),
array(
- 'key' => 'control_area',
- 'label' =>
lang('Control area'),
- 'sortable' => false
+ 'key' =>
'control_area',
+ 'label' =>
lang('Control area'),
+ 'sortable' =>
false
),
array(
- 'key' => 'link',
+ 'key' => 'link',
'hidden' => true
)
)
@@ -181,36 +167,35 @@
);
//_debug_array($data);
- self::render_template_xsl(array( 'datatable_common' ),
$data);
+ self::render_template_xsl(array('datatable_jquery'),
$data);
}
/**
- * Public method. Forwards the user to edit mode.
- */
+ * Public method. Forwards the user to edit mode.
+ */
public function add()
{
$GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_group.edit'));
}
-
public function edit()
{
- $tabs = array
+ $tabs = array
(
- 'control_group' => array('label' =>
lang('Control_group'), 'link' => '#control_group'),
- 'control_items' => array('label' =>
lang('Control_items'), 'link' => '#control_items')
+ 'control_group' => array('label' =>
lang('Control_group'), 'link' => '#control_group'),
+ 'control_items' => array('label' =>
lang('Control_items'), 'link' => '#control_items')
);
- $tab_to_display = 'control_group';
- $control_group_id = phpgw::get_var('id', 'int');
- $new_control_group = false;
- if( $control_group_id )
+ $tab_to_display = 'control_group';
+ $control_group_id = phpgw::get_var('id', 'int');
+ $new_control_group = false;
+ if($control_group_id)
{
$control_group =
$this->so->get_single($control_group_id);
}
else
{
- $control_group = new controller_control_group();
- $new_control_group = true;
+ $control_group = new
controller_control_group();
+ $new_control_group = true;
}
if(isset($_POST['save_control_group'])) // The user has
pressed the save button
@@ -221,36 +206,35 @@
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uicontrol_group.index'));
}
- $entity_id = phpgw::get_var('entity_id', 'int');
- $category_id = phpgw::get_var('category_id',
'int');
- $component_location_id =
$GLOBALS['phpgw']->locations->get_id('property',".entity.{$entity_id}.{$category_id}");
+ $entity_id =
phpgw::get_var('entity_id', 'int');
+ $category_id =
phpgw::get_var('category_id', 'int');
+ $component_location_id =
$GLOBALS['phpgw']->locations->get_id('property',
".entity.{$entity_id}.{$category_id}");
if(isset($control_group)) // Add new values to
the control item
{
$control_group->set_group_name(phpgw::get_var('group_name'));
- $control_group->set_procedure_id(
phpgw::get_var('procedure') );
- $control_group->set_control_area_id(
phpgw::get_var('control_area') );
- $control_group->set_building_part_id(
phpgw::get_var('building_part') );
+
$control_group->set_procedure_id(phpgw::get_var('procedure'));
+
$control_group->set_control_area_id(phpgw::get_var('control_area'));
+
$control_group->set_building_part_id(phpgw::get_var('building_part'));
$control_group->set_component_location_id($component_location_id);
-
- $attributes =
phpgw::get_var('attributes');
+
+ $attributes =
phpgw::get_var('attributes');
$attributes_operator =
phpgw::get_var('attributes_operator');
-
+
$criteria = array();
if(is_array($attributes))
{
- foreach ($attributes as $_key
=> $_value)
+ foreach($attributes as $_key =>
$_value)
{
if($_value)
{
-
$criteria[$_key]['value'] = $_value;
-
$criteria[$_key]['operator'] = $attributes_operator[$_key];
+
$criteria[$_key]['value'] = $_value;
+
$criteria[$_key]['operator'] = $attributes_operator[$_key];
}
-
}
}
- $control_group->set_component_criteria(
$criteria );
+
$control_group->set_component_criteria($criteria);
if(isset($control_group_id) &&
$control_group_id > 0)
{
@@ -278,11 +262,13 @@
}
if($new_control_group)
{
-
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uicontrol_group.edit', 'id' => $ctrl_group_id));
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uicontrol_group.edit',
+ 'id' =>
$ctrl_group_id));
}
else
{
-
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uicontrol_group.view', 'id' => $ctrl_group_id));
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uicontrol_group.view',
+ 'id' =>
$ctrl_group_id));
}
}
}
@@ -290,7 +276,8 @@
{
if(isset($control_group_id) &&
$control_group_id > 0)
{
-
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uicontrol_group.view', 'id' => $control_group_id));
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uicontrol_group.view',
+ 'id' =>
$control_group_id));
}
else
{
@@ -305,38 +292,40 @@
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uicontrol_group.index'));
}
- $control_item_ids = array();
+ $control_item_ids = array();
// Fetching selected control items
- $control_tag_ids =
phpgw::get_var('item_remove_ids');
+ $control_tag_ids =
phpgw::get_var('item_remove_ids');
- foreach ($control_tag_ids as $control_item_id)
+ foreach($control_tag_ids as $control_item_id)
{
$curr_control_item =
$this->so_control_item->get_single($control_item_id);
$curr_control_item->set_control_group_id(null);
-
+
$this->so_control_item->store($curr_control_item);
}
// Sigurd: START as categories
- $cats = CreateObject('phpgwapi.categories',
-1, 'controller', '.control');
- $cats->supress_info = true;
+ $cats =
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+ $cats->supress_info = true;
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl'
=> $this->_category_acl));
- array_unshift($control_areas['cat_list'],array
('cat_id'=>'','name'=> lang('select value')));
+ $control_areas =
$cats->formatted_xslt_list(array('format' => 'filter', 'globals' => true,
+ 'use_acl' =>
$this->_category_acl));
+ array_unshift($control_areas['cat_list'],
array('cat_id' => '', 'name' => lang('select value')));
$control_area_array = array();
foreach($control_areas['cat_list'] as $cat_list)
{
$control_area_array[] = array
(
- 'id' => $cat_list['cat_id'],
- 'name' => $cat_list['name'],
- 'selected' =>
$control_group->get_control_area_id() == $cat_list['cat_id'] ? 1 : 0
+ 'id' =>
$cat_list['cat_id'],
+ 'name' =>
$cat_list['name'],
+ 'selected' =>
$control_group->get_control_area_id() == $cat_list['cat_id'] ? 1 : 0
);
}
// END as categories
- $procedure_array =
$this->so_procedure->get_procedures(0,0,'title','ASC',null,null,array('control_areas'
=> $control_group->get_control_area_id()));
+ $procedure_array =
$this->so_procedure->get_procedures(0, 0, 'title', 'ASC', null, null, array(
+ 'control_areas' =>
$control_group->get_control_area_id()));
if($this->flash_msgs)
{
@@ -344,36 +333,37 @@
$msgbox_data =
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
}
- foreach ($procedure_array as $procedure)
+ foreach($procedure_array as $procedure)
{
if($control_group->get_procedure_id()
&& $procedure->get_id() == $control_group->get_procedure_id())
{
$procedure_options[] = array
(
- 'id' =>
$procedure->get_id(),
- 'name' =>
$procedure->get_title(),
- 'selected' => 'yes'
+ 'id' =>
$procedure->get_id(),
+ 'name' =>
$procedure->get_title(),
+ 'selected' =>
'yes'
);
}
else
{
$procedure_options[] = array
(
- 'id' =>
$procedure->get_id(),
- 'name' =>
$procedure->get_title()
+ 'id' =>
$procedure->get_id(),
+ 'name' =>
$procedure->get_title()
);
}
}
- array_unshift($procedure_options,array
('id'=>'','name'=> lang('select value')));
+ array_unshift($procedure_options, array('id' =>
'', 'name' => lang('select value')));
$building_part_options =
$this->so->get_building_part_select_array($control_group->get_building_part_id());
$control_group_array =
$control_group->toArray();
- $control_items_array =
$this->so_control_item->get(null,null,'controller_control_item.control_area_id',true,null,null,array('available'
=> 'yes'));
+ $control_items_array =
$this->so_control_item->get(null, null,
'controller_control_item.control_area_id', true, null, null, array(
+ 'available' => 'yes'));
$control_items = array();
- foreach ($control_items_array as $control_item)
+ foreach($control_items_array as $control_item)
{
$control_items[] =
$control_item->serialize();
}
@@ -382,23 +372,22 @@
$selected_control_items = array();
- foreach ($selected_control_items_array as
$ctrl_item)
+ foreach($selected_control_items_array as
$ctrl_item)
{
$selected_control_items[] =
$ctrl_item->serialize();
}
-
phpgwapi_yui::tabview_setup('control_group_tabview');
$data = array
(
- 'tabs'
=> phpgwapi_yui::tabview_generate($tabs, 'control_items'),
- 'value_id'
=> !empty($control_group) ? $control_group->get_id() : 0,
- 'editable'
=> true,
- 'procedure'
=> array('options' => $procedure_options),
- 'control_area'
=> array('options' => $control_area_array),
- 'control_group'
=> $control_group_array,
- 'control_items'
=> $control_items,
- 'selected_control_items' =>
$selected_control_items,
- 'building_part'
=> array('building_part_options' => $building_part_options),
+ 'tabs'
=> phpgwapi_jquery::tabview_generate($tabs,
'control_items','control_group_tabview'),
+ 'value_id'
=> !empty($control_group) ? $control_group->get_id() : 0,
+ 'editable'
=> true,
+ 'procedure'
=> array('options' => $procedure_options),
+ 'control_area' =>
array('options' => $control_area_array),
+ 'control_group' =>
$control_group_array,
+ 'control_items' =>
$control_items,
+ 'selected_control_items' =>
$selected_control_items,
+ 'building_part' =>
array('building_part_options' => $building_part_options),
);
@@ -408,7 +397,8 @@
self::add_javascript('controller', 'yahoo',
'control_tabs.js');
self::add_javascript('controller',
'controller', 'ajax.js');
-
self::render_template_xsl(array('control_group/control_group_tabs','control_group/control_group','control_group/control_group_items'),
$data);
+
self::render_template_xsl(array('control_group/control_group_tabs',
'control_group/control_group',
+ 'control_group/control_group_items'),
$data);
}
else if(isset($_POST['save_control_group_items']))
{
@@ -422,42 +412,45 @@
//update control items with control group id
//$control_group_id =
phpgw::get_var('control_group_id');
- $control_item_ids = array();
+ $control_item_ids = array();
// Fetching selected control items
- $control_tag_ids =
phpgw::get_var('control_tag_ids');
+ $control_tag_ids =
phpgw::get_var('control_tag_ids');
- foreach ($control_tag_ids as $control_item_id)
+ foreach($control_tag_ids as $control_item_id)
{
$curr_control_item =
$this->so_control_item->get_single($control_item_id);
$curr_control_item->set_control_group_id($control_group_id);
-
+
$this->so_control_item->store($curr_control_item);
}
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_group.view', 'id' =>
$control_group_id));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_group.view',
+ 'id' => $control_group_id));
}
else
{
// Sigurd: START as categories
- $cats = CreateObject('phpgwapi.categories',
-1, 'controller', '.control');
- $cats->supress_info = true;
+ $cats =
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+ $cats->supress_info = true;
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl'
=> $this->_category_acl));
- array_unshift($control_areas['cat_list'],array
('cat_id'=>'','name'=> lang('select value')));
+ $control_areas =
$cats->formatted_xslt_list(array('format' => 'filter', 'globals' => true,
+ 'use_acl' =>
$this->_category_acl));
+ array_unshift($control_areas['cat_list'],
array('cat_id' => '', 'name' => lang('select value')));
$control_area_array = array();
foreach($control_areas['cat_list'] as $cat_list)
{
$control_area_array[] = array
(
- 'id' => $cat_list['cat_id'],
- 'name' => $cat_list['name'],
- 'selected' =>
$control_group->get_control_area_id() == $cat_list['cat_id'] ? 1 : 0
+ 'id' =>
$cat_list['cat_id'],
+ 'name' =>
$cat_list['name'],
+ 'selected' =>
$control_group->get_control_area_id() == $cat_list['cat_id'] ? 1 : 0
);
}
// END as categories
- $procedure_array =
$this->so_procedure->get_procedures(0,0,'title','ASC',null,null,array('control_areas'
=> $control_group->get_control_area_id()));
+ $procedure_array =
$this->so_procedure->get_procedures(0, 0, 'title', 'ASC', null, null, array(
+ 'control_areas' =>
$control_group->get_control_area_id()));
if($this->flash_msgs)
{
@@ -466,25 +459,26 @@
}
- foreach ($procedure_array as $procedure)
+ foreach($procedure_array as $procedure)
{
$procedure_options[] = array
(
- 'id' => $procedure->get_id(),
- 'name' =>
$procedure->get_title(),
- 'selected' =>
$procedure->get_id() == $control_group->get_procedure_id() ? 1 : 0
+ 'id' =>
$procedure->get_id(),
+ 'name' =>
$procedure->get_title(),
+ 'selected' =>
$procedure->get_id() == $control_group->get_procedure_id() ? 1 : 0
);
}
- array_unshift($procedure_options,array
('id'=>'','name'=> lang('select value')));
+ array_unshift($procedure_options, array('id' =>
'', 'name' => lang('select value')));
$building_part_options =
$this->so->get_building_part_select_array($control_group->get_building_part_id());
$control_group_array =
$control_group->toArray();
- $control_items_array =
$this->so_control_item->get(null,null,'controller_control_item.control_area_id',true,null,null,array('available'
=> 'yes'));
+ $control_items_array =
$this->so_control_item->get(null, null,
'controller_control_item.control_area_id', true, null, null, array(
+ 'available' => 'yes'));
$control_items = array();
- foreach ($control_items_array as $control_item)
+ foreach($control_items_array as $control_item)
{
$control_items[] =
$control_item->serialize();
}
@@ -493,39 +487,35 @@
$selected_control_items = array();
- foreach ($selected_control_items_array as
$ctrl_item)
+ foreach($selected_control_items_array as
$ctrl_item)
{
$selected_control_items[] =
$ctrl_item->serialize();
}
-
phpgwapi_yui::tabview_setup('control_group_tabview');
-
-
-
//--- sigurd 10.juni 13
- $entity_so =
CreateObject('property.soadmin_entity');
- $custom =
createObject('phpgwapi.custom_fields');
+ $entity_so =
CreateObject('property.soadmin_entity');
+ $custom =
createObject('phpgwapi.custom_fields');
$entity_list = $entity_so->read(array('allrows'
=> true));
- $attributes = array();
- array_unshift($entity_list,array
('id'=>'','name'=> lang('select value')));
+ $attributes = array();
+ array_unshift($entity_list, array('id' => '',
'name' => lang('select value')));
$component_location_id =
$control_group->get_component_location_id();
if($component_location_id)
{
- $loc_arr =
$GLOBALS['phpgw']->locations->get_name($component_location_id);
- $entity_arr =
explode('.',$loc_arr['location']);
+ $loc_arr =
$GLOBALS['phpgw']->locations->get_name($component_location_id);
+ $entity_arr = explode('.',
$loc_arr['location']);
- $entity =
$entity_so->read_single($entity_arr[2]);
- $category =
$entity_so->read_single_category($entity_arr[2],$entity_arr[3]);
- foreach ($entity_list as &$e)
+ $entity =
$entity_so->read_single($entity_arr[2]);
+ $category =
$entity_so->read_single_category($entity_arr[2], $entity_arr[3]);
+ foreach($entity_list as &$e)
{
if($e['id'] == $entity['id'])
{
$e['selected'] = 1;
}
}
- $category_list =
$entity_so->read_category(array('allrows'=>true,'entity_id'=>$entity_arr[2]));
- array_unshift($category_list,array
('id'=>'','name'=> lang('select value')));
- foreach ($category_list as &$c)
+ $category_list =
$entity_so->read_category(array('allrows' => true, 'entity_id' =>
$entity_arr[2]));
+ array_unshift($category_list,
array('id' => '', 'name' => lang('select value')));
+ foreach($category_list as &$c)
{
if($c['id'] == $category['id'])
{
@@ -533,49 +523,49 @@
}
}
- $attributes =
$custom->find('property',".entity.{$entity_arr[2]}.{$entity_arr[3]}", 0,
'','','',true, true);
+ $attributes = $custom->find('property',
".entity.{$entity_arr[2]}.{$entity_arr[3]}", 0, '', '', '', true, true);
$operator1 = array
(
array
(
- 'id' => 'eq',
- 'name' => '='
+ 'id' => 'eq',
+ 'name' => '='
),
);
$operator2 = array
- (
+ (
array
(
- 'id' => 'eq',
- 'name' => '='
+ 'id' => 'eq',
+ 'name' => '='
),
array
(
- 'id' => 'lt',
- 'name' => '<'
+ 'id' => 'lt',
+ 'name' => '<'
),
array
(
- 'id' => 'gt',
- 'name' => '>'
+ 'id' => 'gt',
+ 'name' => '>'
),
);
$component_criteria =
$control_group->get_component_criteria();
- foreach ($attributes as $key => &$a)
+ foreach($attributes as $key => &$a)
{
- switch ($a['datatype'])
+ switch($a['datatype'])
{
case 'LB':
case 'R':
case 'CH':
- $a['operator']
= array('options' => $operator1);
+ $a['operator']
= array('options' => $operator1);
break;
default:
- $a['operator']
= array('options' => $operator2);
+ $a['operator']
= array('options' => $operator2);
}
if(isset($component_criteria[$key]['value']) &&
$component_criteria[$key]['value'])
@@ -602,41 +592,42 @@
}
}
- //---
+ //---
$data = array
(
- 'entities'
=> array('options' => $entity_list),
- 'categories'
=> array('options' => $category_list),
- 'attributes'
=> $attributes,
- 'tabs'
=> phpgwapi_yui::tabview_generate($tabs, $tab_to_display),
- 'value_id'
=> !empty($control_group) ? $control_group->get_id() : 0,
- 'editable'
=> true,
- 'procedure'
=> array('options' => $procedure_options),
- 'control_area'
=> array('options' => $control_area_array),
- 'control_group'
=> $control_group_array,
- 'control_items'
=> $control_items,
- 'selected_control_items' =>
$selected_control_items,
- 'building_part'
=> array('building_part_options' => $building_part_options),
+ 'entities'
=> array('options' => $entity_list),
+ 'categories' =>
array('options' => $category_list),
+ 'attributes' =>
$attributes,
+ 'tabs'
=> phpgwapi_jquery::tabview_generate($tabs,
$tab_to_display,'control_group_tabview'),
+ 'value_id'
=> !empty($control_group) ? $control_group->get_id() : 0,
+ 'editable'
=> true,
+ 'procedure'
=> array('options' => $procedure_options),
+ 'control_area' =>
array('options' => $control_area_array),
+ 'control_group' =>
$control_group_array,
+ 'control_items' =>
$control_items,
+ 'selected_control_items' =>
$selected_control_items,
+ 'building_part' =>
array('building_part_options' => $building_part_options),
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('controller') . '::' . lang('Control_group');
-/*
-
$GLOBALS['phpgw']->richtext->replace_element('what_to_do');
-
$GLOBALS['phpgw']->richtext->replace_element('how_to_do');
- $GLOBALS['phpgw']->richtext->generate_script();
-*/
+ /*
+
$GLOBALS['phpgw']->richtext->replace_element('what_to_do');
+
$GLOBALS['phpgw']->richtext->replace_element('how_to_do');
+
$GLOBALS['phpgw']->richtext->generate_script();
+ */
- // $GLOBALS['phpgw']->js->validate_file( 'yahoo',
'controller.item', 'controller' );
+ //
$GLOBALS['phpgw']->js->validate_file( 'yahoo', 'controller.item', 'controller'
);
phpgwapi_jquery::load_widget('core');
self::add_javascript('controller', 'yahoo',
'control_tabs.js');
self::add_javascript('controller',
'controller', 'ajax.js');
self::add_javascript('controller',
'controller', 'control_group_to_component.js');
-
self::render_template_xsl(array('control_group/control_group_tabs','control_group/control_group','control_group/control_group_items'),
$data);
+
self::render_template_xsl(array('control_group/control_group_tabs',
'control_group/control_group',
+ 'control_group/control_group_items'),
$data);
}
}
@@ -645,26 +636,26 @@
if(!$this->add && !$this->edit)
{
phpgwapi_cache::message_set('No access',
'error');
-
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
'controller.uicontrol_group.index'));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_group.index'));
}
- $control_id = phpgw::get_var('control_id');
- $item_order_str = phpgw::get_var('item_order');
+ $control_id = phpgw::get_var('control_id');
+ $item_order_str = phpgw::get_var('item_order');
$group_order_str = phpgw::get_var('group_order');
$status = 1;
$group_order_arr = explode(",", $group_order_str);
- $item_order_arr = explode(",", $item_order_str);
+ $item_order_arr = explode(",", $item_order_str);
$db_control_group_list =
$this->so_control_group_list->get_db();
// Saves order for control groups
foreach($group_order_arr as $group_id_order)
{
- $group_id_order_arr = explode(":",
$group_id_order);
- $group_id = $group_id_order_arr[0];
- $group_order_nr = $group_id_order_arr[1];
+ $group_id_order_arr = explode(":",
$group_id_order);
+ $group_id =
$group_id_order_arr[0];
+ $group_order_nr =
$group_id_order_arr[1];
// Gets control_group_list object from db if it
exists
$control_group_list =
$this->so_control_group_list->get_group_list_by_control_and_group($control_id,
$group_id);
@@ -672,10 +663,10 @@
$db_control_group_list->transaction_begin();
// Updates group order if control_group_list
object exists
- if( $control_group_list != null )
+ if($control_group_list != null)
{
- $control_group_list->set_order_nr(
$group_order_nr );
- $id =
$this->so_control_group_list->update( $control_group_list );
+
$control_group_list->set_order_nr($group_order_nr);
+ $id =
$this->so_control_group_list->update($control_group_list);
if($id > 0)
{
@@ -684,14 +675,14 @@
else
{
$db_control_group_list->transaction_abort();
- $status = 0;
+ $status = 0;
}
}
// If group is not in db, report error
else
{
echo "Error: group not found";
- $status = 0;
+ $status = 0;
}
}
@@ -700,19 +691,19 @@
// Saves order for control items
foreach($item_order_arr as $item_id_order)
{
- $item_id_order_arr = explode(":",
$item_id_order);
- $control_item_id = $item_id_order_arr[0];
- $item_order_nr = $item_id_order_arr[1];
+ $item_id_order_arr = explode(":",
$item_id_order);
+ $control_item_id =
$item_id_order_arr[0];
+ $item_order_nr =
$item_id_order_arr[1];
$control_item_list =
$this->so_control_item_list->get_single_2($control_id, $control_item_id);
$db_control_item_list->transaction_begin();
// Updates item order if control_item_list
object exists
- if( $control_item_list != null )
+ if($control_item_list != null)
{
- $control_item_list->set_order_nr(
$item_order_nr );
- $id =
$this->so_control_item_list->update( $control_item_list );
+
$control_item_list->set_order_nr($item_order_nr);
+ $id =
$this->so_control_item_list->update($control_item_list);
if($id > 0)
{
@@ -728,7 +719,7 @@
else
{
echo "Error: item not found";
- $status = 0;
+ $status = 0;
}
}
@@ -737,53 +728,43 @@
public function query()
{
+
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+
$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
+ 'start' => phpgw::get_var('start',
'int', 'REQUEST', 0),
+ 'results' => phpgw::get_var('length',
'int', 'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length',
'int') == -1,
);
- $search_for = phpgw::get_var('query');
+ $search_for = $params['query'];
+
+ // YUI variables for paging and sorting
+ $start_index = $params['start'];
+ $num_of_objects = $params['results'] > 0 ?
$params['results'] : null;
+ $sort_field = $params['order'];
+
$ctrl_area = phpgw::get_var('control_areas');
if(isset($ctrl_area) && $ctrl_area > 0)
{
- $filters['control_areas'] = $ctrl_area;
+ $filters['control_areas'] = $ctrl_area;
}
-
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 = 'controller_control_group.id';
}
- $sort_ascending = phpgw::get_var('dir') == 'desc' ?
false : true;
- //Create an empty result set
- $records = array();
+ $sort_ascending = $params['sort'] == 'desc' ? false :
true;
- //Retrieve a contract identifier and load corresponding
contract
- $control_group_id = phpgw::get_var('control_group_id');
- /*if(isset($control_group_id))
- {
- $control_item =
$this->so->get_single($control_group_id);
- }*/
-
//var_dump($start_index.'-'.$num_of_objects.'-'.$sort_field.'-'.$sort_ascending.'-'.$search_for.'-'.$search_type.'-'.$filters);
- $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);
+ $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();
@@ -793,14 +774,15 @@
$results['results'][] =
$control_group_obj->serialize();
}
- $results['total_records'] = $object_count;
- $results['start'] = $params['start'];
- $results['sort'] = $params['sort'];
- $results['dir'] = $params['dir'];
+ $results['total_records'] = $object_count;
+ $results['start'] =
$params['start'];
+ $results['sort'] =
$params['order'];
+ $results['dir'] =
$params['sort'];
+ $results['draw'] = $draw;
array_walk($results["results"], array($this,
"_add_links"), "controller.uicontrol_group.view");
- return $this->yui_results($results);
+ return $this->jquery_results($results);
}
/**
@@ -809,20 +791,21 @@
*/
public function view()
{
- $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('view');
+ $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('view');
- $entity_so =
CreateObject('property.soadmin_entity');
+ $entity_so = CreateObject('property.soadmin_entity');
- $tabs = array
+ $tabs = array
(
- 'control_group' => array('label' =>
lang('Control_group'), 'link' => '#control_group'),
- 'control_items' => array('label' =>
lang('Control_items'), 'link' => '#control_items')
+ 'control_group' => array('label' =>
lang('Control_group'), 'link' => '#control_group'),
+ 'control_items' => array('label' =>
lang('Control_items'), 'link' => '#control_items')
);
//Retrieve the control_group object
- $control_group_id = (int)phpgw::get_var('id');
+ $control_group_id = (int)phpgw::get_var('id');
if(isset($_POST['edit_control_group']))
{
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_group.edit', 'id' =>
$control_group_id));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_group.edit',
+ 'id' => $control_group_id));
}
else
{
@@ -833,7 +816,7 @@
}
else
{
-
$this->render('permission_denied.php',array('error' =>
lang('invalid_request')));
+ $this->render('permission_denied.php',
array('error' => lang('invalid_request')));
return;
}
//var_dump($control_group);
@@ -847,21 +830,21 @@
$control_group_array =
$control_group->toArray();
//var_dump($control_group_array);
- $loc_arr =
$GLOBALS['phpgw']->locations->get_name($control_group->get_component_location_id());
- $entity_arr = explode('.',$loc_arr['location']);
+ $loc_arr =
$GLOBALS['phpgw']->locations->get_name($control_group->get_component_location_id());
+ $entity_arr = explode('.',
$loc_arr['location']);
- $entity =
$entity_so->read_single($entity_arr[2]);
- $category =
$entity_so->read_single_category($entity_arr[2],$entity_arr[3]);
+ $entity =
$entity_so->read_single($entity_arr[2]);
+ $category =
$entity_so->read_single_category($entity_arr[2], $entity_arr[3]);
- $custom =
createObject('phpgwapi.custom_fields');
- $attributes =
$custom->find('property',".entity.{$entity_arr[2]}.{$entity_arr[3]}", 0,
'','','',true, true);
+ $custom =
createObject('phpgwapi.custom_fields');
+ $attributes = $custom->find('property',
".entity.{$entity_arr[2]}.{$entity_arr[3]}", 0, '', '', '', true, true);
$operator1 = array
(
array
(
- 'id' => 'eq',
- 'name' => '='
+ 'id' => 'eq',
+ 'name' => '='
),
);
@@ -869,34 +852,34 @@
(
array
(
- 'id' => 'eq',
- 'name' => '='
+ 'id' => 'eq',
+ 'name' => '='
),
array
(
- 'id' => 'lt',
- 'name' => '<'
+ 'id' => 'lt',
+ 'name' => '<'
),
array
(
- 'id' => 'gt',
- 'name' => '>'
+ 'id' => 'gt',
+ 'name' => '>'
),
);
$component_criteria =
$control_group->get_component_criteria();
- foreach ($attributes as $key => &$a)
+ foreach($attributes as $key => &$a)
{
- switch ($a['datatype'])
+ switch($a['datatype'])
{
case 'LB':
case 'R':
case 'CH':
- $a['operator'] =
array('options' => $operator1);
+ $a['operator'] =
array('options' => $operator1);
break;
default:
- $a['operator'] =
array('options' => $operator2);
+ $a['operator'] =
array('options' => $operator2);
}
if(isset($component_criteria[$key]['value']) &&
$component_criteria[$key]['value'])
@@ -926,29 +909,28 @@
$control_items = array();
- foreach ($control_items_array as $control_item)
+ foreach($control_items_array as $control_item)
{
$control_items[] =
$control_item->serialize();
}
-
phpgwapi_yui::tabview_setup('control_group_tabview');
-
$data = array
(
- 'tabs'
=> phpgwapi_yui::tabview_generate($tabs, 'control_group'),
- 'value_id'
=> !empty($control_group) ? $control_group->get_id() : 0,
- 'control_group'
=> $control_group_array,
- 'entity'
=> $entity,
- 'category'
=> $category,
- 'attributes'
=> $attributes,
- 'selected_control_items' =>
$control_items,
+ 'tabs'
=> phpgwapi_jquery::tabview_generate($tabs,
'control_group','control_group_tabview'),
+ 'value_id'
=> !empty($control_group) ? $control_group->get_id() : 0,
+ 'control_group' =>
$control_group_array,
+ 'entity'
=> $entity,
+ 'category'
=> $category,
+ 'attributes' =>
$attributes,
+ 'selected_control_items' =>
$control_items,
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('controller') . '::' . lang('Control group');
self::add_javascript('controller', 'yahoo',
'control_tabs.js');
-
self::render_template_xsl(array('control_group/control_group_tabs','control_group/control_group','control_group/control_group_items'),
$data);
+
self::render_template_xsl(array('control_group/control_group_tabs',
'control_group/control_group',
+ 'control_group/control_group_items'),
$data);
}
}
@@ -966,9 +948,9 @@
$control_groups_array =
$this->so->get_control_groups_by_control_area($control_area_id);
}
- if(count($control_groups_array)>0)
+ if(count($control_groups_array) > 0)
{
- return json_encode( $control_groups_array );
+ return json_encode($control_groups_array);
}
else
{
@@ -981,15 +963,16 @@
$control_group_id = phpgw::get_var('control_group_id');
if($control_group_id)
{
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl'
=> $this->_category_acl));
+ $control_areas =
$cats->formatted_xslt_list(array('format' => 'filter', 'globals' => true,
+ 'use_acl' =>
$this->_category_acl));
$control_area_array = array();
foreach($control_areas['cat_list'] as $cat_list)
{
$control_area_array[] = array
(
- 'id' => $cat_list['cat_id'],
- 'name' => $cat_list['name'],
+ 'id' => $cat_list['cat_id'],
+ 'name' => $cat_list['name'],
);
}
}
@@ -998,14 +981,13 @@
$control_areas_array =
$this->so->get_control_areas_by_control_group($control_group_id);
}
- if(count($control_areas_array)>0)
+ if(count($control_areas_array) > 0)
{
- return json_encode( $control_areas_array );
+ return json_encode($control_areas_array);
}
else
{
return null;
}
}
-
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/controller/inc/class.uicontrol_item.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.uicontrol_item.inc.php
2014-12-23 11:33:40 UTC (rev 12493)
+++ branches/dev-syncromind/controller/inc/class.uicontrol_item.inc.php
2014-12-23 11:34:44 UTC (rev 12494)
@@ -1,39 +1,38 @@
<?php
/**
- * phpGroupWare - controller: a part of a Facilities Management System.
- *
- * @author Erink Holm-Larsen <address@hidden>
- * @author Torstein Vadla <address@hidden>
- * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/
- * @package property
- * @subpackage controller
- * @version $Id$
- */
-
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erink Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id$
+ */
/**
- * Import the jQuery class
- */
+ * Import the jQuery class
+ */
phpgw::import_class('phpgwapi.jquery');
- phpgw::import_class('phpgwapi.uicommon');
+ phpgw::import_class('phpgwapi.uicommon_jquery');
phpgw::import_class('property.boevent');
phpgw::import_class('controller.socontrol');
phpgw::import_class('controller.socontrol_item');
@@ -42,44 +41,43 @@
include_class('controller', 'control_item', 'inc/model/');
- class controller_uicontrol_item extends phpgwapi_uicommon
+ class controller_uicontrol_item extends phpgwapi_uicommon_jquery
{
+
private $so;
private $so_control_group;
private $so_control_item_option;
-
- private $read;
- private $add;
- private $edit;
- private $delete;
-
+ private $read;
+ private $add;
+ private $edit;
+ private $delete;
public $public_functions = array
- (
- 'index'
=> true,
- 'query'
=> true,
- 'edit'
=> true,
- 'view'
=> true,
- 'add'
=> true,
- 'save'
=> true,
- 'display_control_items' => true,
- 'delete_item_list' => true
+ (
+ 'index' => true,
+ 'query' => true,
+ 'edit' => true,
+ 'view' => true,
+ 'add' => true,
+ 'save' => true,
+ 'display_control_items' => true,
+ 'delete_item_list' => true
);
public function __construct()
{
parent::__construct();
- $this->so = CreateObject('controller.socontrol_item');
- $this->so_control_item_list =
CreateObject('controller.socontrol_item_list');
- $this->so_control_group =
CreateObject('controller.socontrol_group');
- $this->so_control_item_option =
CreateObject('controller.socontrol_item_option');
+ $this->so
= CreateObject('controller.socontrol_item');
+ $this->so_control_item_list =
CreateObject('controller.socontrol_item_list');
+ $this->so_control_group =
CreateObject('controller.socontrol_group');
+ $this->so_control_item_option =
CreateObject('controller.socontrol_item_option');
$GLOBALS['phpgw_info']['flags']['menu_selection'] =
"controller::control_item";
- $this->read =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1
- $this->add =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2
- $this->edit =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4
- $this->delete =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
-
+ $this->read =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1
+ $this->add =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2
+ $this->edit =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4
+ $this->delete =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
+
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/base.css');
}
public function index()
@@ -87,119 +85,111 @@
$dir = phpgw::get_var('dir');
if($dir)
{
- $query_array = array('menuaction' =>
'controller.uicontrol_item.index', 'phpgw_return_as' => 'json', 'sort_dir' =>
'desc');
+ $query_array = array('menuaction' =>
'controller.uicontrol_item.index', 'phpgw_return_as' => 'json',
+ 'sort_dir' => 'desc');
}
else
{
$query_array = array('menuaction' =>
'controller.uicontrol_item.index', 'phpgw_return_as' => 'json');
}
- if(phpgw::get_var('phpgw_return_as') == 'json') {
+ if(phpgw::get_var('phpgw_return_as') == 'json')
+ {
return $this->query();
}
// Sigurd: Start categories
- $cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
- $cats->supress_info = true;
+ $cats =
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+ $cats->supress_info = true;
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
- array_unshift($control_areas['cat_list'],array
('cat_id'=>'','name'=> lang('select value')));
- $control_areas_array2 = array();
+ $control_areas =
$cats->formatted_xslt_list(array('format' => 'filter', 'selected' =>
$control_area_id,
+ 'globals' => true, 'use_acl' =>
$this->_category_acl));
+ array_unshift($control_areas['cat_list'],
array('cat_id' => '', 'name' => lang('select value')));
+ $control_areas_array2 = array();
foreach($control_areas['cat_list'] as $cat_list)
{
$control_areas_array2[] = array
- (
- 'id' => $cat_list['cat_id'],
- 'name' => $cat_list['name'],
+ (
+ 'id' => $cat_list['cat_id'],
+ 'name' => $cat_list['name'],
);
}
// END categories
$data = array(
- 'datatable_name' => 'Kontrollpunkter',
//lang(control items),
- 'form' => array(
+ 'datatable_name' => 'Kontrollpunkter',
//lang(control items),
+ 'form' => array(
'toolbar' => array(
'item' => array(
- array('type' =>
'filter',
- 'name' =>
'control_groups',
- 'text' =>
lang('Control_group').':',
- 'list' =>
$this->so_control_group->get_control_group_select_array(),
+ array('type' =>
'filter',
+ 'name' =>
'control_groups',
+ 'text' =>
lang('Control_group') . ':',
+ 'list' =>
$this->so_control_group->get_control_group_select_array(),
),
- array('type' =>
'filter',
- 'name' =>
'control_areas',
- 'text' =>
lang('Control_area'),
- 'list' =>
$control_areas_array2,
+ array('type' =>
'filter',
+ 'name' =>
'control_areas',
+ 'text' =>
lang('Control_area'),
+ 'list' =>
$control_areas_array2,
),
- array('type' => 'text',
- 'text' =>
lang('searchfield'),
- 'name' =>
'query'
- ),
array(
- 'type' =>
'submit',
- 'name' =>
'search',
- 'value' =>
lang('Search')
+ 'type' =>
'link',
+ 'value' =>
lang('New control item'),
+ 'href' =>
self::link(array('menuaction' => 'controller.uicontrol_item.add')),
+ 'class' =>
'new_item'
),
- array(
- 'type' =>
'link',
- 'value' =>
lang('New control item'),
- 'href' =>
self::link(array('menuaction' => 'controller.uicontrol_item.add')),
- 'class' =>
'new_item'
- ),
),
),
),
- 'datatable' => array(
- 'source' => self::link($query_array),
- 'field' => array(
+ 'datatable' => array(
+ 'source' =>
self::link($query_array),
+ 'allrows' => true,
+ 'field' => array(
array(
- 'key' => 'id',
- 'label' => lang('ID'),
- 'sortable' => true,
- 'formatter' =>
'YAHOO.portico.formatLink'
+ 'key' =>
'id',
+ 'label' =>
lang('ID'),
+ 'sortable' =>
true,
+ 'formatter' =>
'JqueryPortico.formatLink'
),
array(
- 'key' => 'title',
- 'label' =>
lang('Control item title'),
- 'sotrable' =>
false
+ 'key' =>
'title',
+ 'label' =>
lang('Control item title'),
+ 'sotrable' =>
false
),
array(
- 'key' => 'what_to_do',
- 'label' =>
lang('Control item what to do'),
- 'sortable' => false
+ 'key' =>
'what_to_do',
+ 'label' =>
lang('Control item what to do'),
+ 'sortable' =>
false
),
array(
- 'key' =>
'control_group',
- 'label' =>
lang('Control group'),
- 'sortable' => false
+ 'key' =>
'control_group',
+ 'label' =>
lang('Control group'),
+ 'sortable' =>
false
),
array(
- 'key' => 'control_area',
- 'label' =>
lang('Control area'),
- 'sortable' => false
+ 'key' =>
'control_area',
+ 'label' =>
lang('Control area'),
+ 'sortable' =>
false
),
array(
- 'key' => 'link',
+ 'key' => 'link',
'hidden' => true
)
)
),
);
- phpgwapi_yui::load_widget('paginator');
- phpgwapi_yui::load_widget('datatable');
- self::add_javascript('phpgwapi', 'yahoo',
'datatable.js');
-
- self::render_template_xsl( array( 'datatable_common' ),
$data);
+ self::render_template_xsl(array('datatable_jquery'),
$data);
}
/**
- * Public method. Forwards the user to edit mode.
- */
+ * Public method. Forwards the user to edit mode.
+ */
public function add()
{
$GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_item.edit'));
}
- public function delete_item_list(){
- $control_id = phpgw::get_var('control_id');
+ public function delete_item_list()
+ {
+ $control_id = phpgw::get_var('control_id');
$control_item_id = phpgw::get_var('control_item_id');
$status =
$this->so_control_item_list->delete($control_id, $control_item_id);
@@ -207,7 +197,7 @@
return status;
}
- public function edit( $control_item = null )
+ public function edit($control_item = null)
{
// NO REDIRECT
if($control_item == null)
@@ -227,30 +217,31 @@
}
// Sigurd: START as categories
- $cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
- $cats->supress_info = true;
+ $cats =
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+ $cats->supress_info = true;
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl'
=> $this->_category_acl));
+ $control_areas =
$cats->formatted_xslt_list(array('format' => 'filter', 'globals' => true,
+ 'use_acl' => $this->_category_acl));
$control_areas_array = $control_areas['cat_list'];
$control_groups_array =
$this->so_control_group->get_control_group_array();
// Hack to fix display of char
- $what_to_do_fixed = str_replace( " ", "
",$control_item->get_what_to_do() );
- $control_item->set_what_to_do( $what_to_do_fixed );
+ $what_to_do_fixed = str_replace(" ", " ",
$control_item->get_what_to_do());
+ $control_item->set_what_to_do($what_to_do_fixed);
- $how_to_do_fixed = str_replace( " ", "
",$control_item->get_how_to_do() );
- $control_item->set_how_to_do( $how_to_do_fixed );
+ $how_to_do_fixed = str_replace(" ", " ",
$control_item->get_how_to_do());
+ $control_item->set_how_to_do($how_to_do_fixed);
$data = array
- (
- 'editable' => true,
- 'control_item' => $control_item,
- 'control_areas' => $control_areas_array,
- 'control_groups' =>
$control_groups_array,
+ (
+ 'editable' => true,
+ 'control_item' => $control_item,
+ 'control_areas' => $control_areas_array,
+ 'control_groups' => $control_groups_array,
);
- $this->use_yui_editor(array('what_to_do','how_to_do'));
+ $this->use_yui_editor(array('what_to_do', 'how_to_do'));
phpgwapi_jquery::load_widget('core');
self::add_javascript('controller', 'controller',
'ajax.js');
@@ -262,24 +253,24 @@
{
if(!$this->add && !$this->edit)
{
-
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
'controller.uicontrol_item.index'));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_item.index'));
}
- $control_item_id = phpgw::get_var('id');
- $title = phpgw::get_var('title');
- $required = phpgw::get_var('required') == 'on' ? true :
false;
- $type = phpgw::get_var('control_item_type');
- $control_group_id = phpgw::get_var('control_group');
- $control_area_id = phpgw::get_var('control_area');
- $type = phpgw::get_var('control_item_type');
- $what_to_do_txt = phpgw::get_var('what_to_do','html');
- $what_to_do_txt = str_replace(" ", " ",
$what_to_do_txt);
- $how_to_do_txt = phpgw::get_var('how_to_do','html');
- $how_to_do_txt = str_replace(" ", " ",
$how_to_do_txt);
+ $control_item_id = phpgw::get_var('id');
+ $title =
phpgw::get_var('title');
+ $required =
phpgw::get_var('required') == 'on' ? true : false;
+ $type =
phpgw::get_var('control_item_type');
+ $control_group_id =
phpgw::get_var('control_group');
+ $control_area_id =
phpgw::get_var('control_area');
+ $type =
phpgw::get_var('control_item_type');
+ $what_to_do_txt = phpgw::get_var('what_to_do',
'html');
+ $what_to_do_txt = str_replace(" ", " ",
$what_to_do_txt);
+ $how_to_do_txt = phpgw::get_var('how_to_do',
'html');
+ $how_to_do_txt = str_replace(" ", " ",
$how_to_do_txt);
if($control_item_id > 0)
{
- $control_item = $this->so->get_single(
$control_item_id );
+ $control_item =
$this->so->get_single($control_item_id);
}
else
{
@@ -294,7 +285,7 @@
$control_item->set_what_to_do($what_to_do_txt);
$control_item->set_how_to_do($how_to_do_txt);
- if( $control_item->validate() )
+ if($control_item->validate())
{
$transaction_status = true;
@@ -305,18 +296,18 @@
if($saved_control_item_id == 0)
{
- $transaction_status = false;
+ $transaction_status = false;
}
// Delete item option values
- $delete_status =
$this->so->delete_option_values( $saved_control_item_id );
+ $delete_status =
$this->so->delete_option_values($saved_control_item_id);
if($delete_status == 0)
{
$transaction_status = false;
}
- if( $transaction_status == true)
+ if($transaction_status == true)
{
$db_control_item->transaction_commit();
}
@@ -325,30 +316,31 @@
$db_control_item->transaction_abort();
}
- $option_values = array();
- $option_values =
phpgw::get_var('option_values');
+ $option_values = array();
+ $option_values =
phpgw::get_var('option_values');
$option_values_array = array();
foreach($option_values as $option_value)
{
- $control_item_option = new
controller_control_item_option($option_value, $saved_control_item_id);
- $option_values_array[] =
$control_item_option;
+ $control_item_option = new
controller_control_item_option($option_value, $saved_control_item_id);
+ $option_values_array[] =
$control_item_option;
}
$control_item->set_options_array($option_values_array);
// Add new control item option values
- if( ($transaction_status) &
($saved_control_item_id > 0) & ($control_item->get_type() ==
'control_item_type_3' | $control_item->get_type() == 'control_item_type_4'))
+ if(($transaction_status) &
($saved_control_item_id > 0) & ($control_item->get_type() ==
'control_item_type_3' | $control_item->get_type() == 'control_item_type_4'))
{
$control_item_options_array =
$control_item->get_options_array();
foreach($control_item_options_array as
$control_item_option)
{
- $control_item_option_id =
$this->so_control_item_option->store( $control_item_option );
+ $control_item_option_id =
$this->so_control_item_option->store($control_item_option);
}
}
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_item.view', 'id' =>
$saved_control_item_id));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicontrol_item.view',
+ 'id' => $saved_control_item_id));
}
else
{
@@ -371,24 +363,24 @@
}
else
{
-
$this->render('permission_denied.php',array('error' =>
lang('invalid_request')));
+ $this->render('permission_denied.php',
array('error' => lang('invalid_request')));
return;
}
$category =
execMethod('phpgwapi.categories.return_single',
$control_item->get_control_area_id());
- $control_item->set_control_area_name(
$category[0]['name'] );
+
$control_item->set_control_area_name($category[0]['name']);
// Hack to fix display of char
- $what_to_do_fixed = str_replace( " ", "
",$control_item->get_what_to_do() );
- $control_item->set_what_to_do( $what_to_do_fixed );
+ $what_to_do_fixed = str_replace(" ", " ",
$control_item->get_what_to_do());
+ $control_item->set_what_to_do($what_to_do_fixed);
- $how_to_do_fixed = str_replace( " ", "
",$control_item->get_how_to_do() );
- $control_item->set_how_to_do( $how_to_do_fixed );
+ $how_to_do_fixed = str_replace(" ", " ",
$control_item->get_how_to_do());
+ $control_item->set_how_to_do($how_to_do_fixed);
$data = array
- (
- 'control_item' => $control_item,
- 'view' => true
+ (
+ 'control_item' => $control_item,
+ 'view' => true
);
self::render_template_xsl('control_item/control_item',
$data);
@@ -396,23 +388,29 @@
public function query()
{
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+
$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'),
- 'filters' => $filters
+ 'start' => phpgw::get_var('start',
'int', 'REQUEST', 0),
+ 'results' => phpgw::get_var('length',
'int', 'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length',
'int') == -1,
);
- if(phpgw::get_var('sort_dir'))
- {
- $params['dir'] = phpgw::get_var('sort_dir');
- }
- else
- {
- $params['dir'] = phpgw::get_var('dir');
- }
+ $search_for = $params['query'];
+
+ // YUI variables for paging and sorting
+ $start_index = $params['start'];
+ $num_of_objects = $params['results'] > 0 ?
$params['results'] : null;
+ $sort_field = $params['order'];
+
+
$ctrl_area = phpgw::get_var('control_areas');
if(isset($ctrl_area) && $ctrl_area > 0)
{
@@ -425,37 +423,12 @@
$filters['control_groups'] = $ctrl_group;
}
-
- $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 = (int)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 = 'id';
}
- if(phpgw::get_var('sort_dir') == 'desc')
- {
- $sort_ascending = false;
- }
- else
- {
- $sort_ascending = phpgw::get_var('dir') ==
'desc' ? false : true;
- }
- //Create an empty result set
- $records = array();
+ $sort_ascending = $params['sort'] == 'desc' ? false :
true;
//Retrieve a contract identifier and load corresponding
contract
$control_item_id = phpgw::get_var('control_item_id');
@@ -464,9 +437,8 @@
$control_item =
$this->so->get_single($control_item_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);
+ $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);
$results = array();
@@ -475,13 +447,14 @@
$results['results'][] =
$control_item_obj->serialize();
}
- $results['total_records'] = $object_count;
- $results['start'] = $start_index;
- $results['sort'] = $sort_field;
- $results['dir'] = $params['dir'];
+ $results['total_records'] = $object_count;
+ $results['start'] =
$params['start'];
+ $results['sort'] =
$params['order'];
+ $results['dir'] =
$params['sort'];
+ $results['draw'] = $draw;
array_walk($results["results"], array($this,
"_add_links"), "controller.uicontrol_item.view");
- return $this->yui_results($results);
+ return $this->jquery_results($results);
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/controller/inc/class.uidocument.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.uidocument.inc.php
2014-12-23 11:33:40 UTC (rev 12493)
+++ branches/dev-syncromind/controller/inc/class.uidocument.inc.php
2014-12-23 11:34:44 UTC (rev 12494)
@@ -1,546 +1,554 @@
<?php
- /**
- * phpGroupWare - controller: a part of a Facilities Management System.
- *
- * @author Erik Holm-Larsen <address@hidden>
- * @author Torstein Vadla <address@hidden>
- * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/
- * @package property
- * @subpackage controller
- * @version $Id$
- */
+ /**
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erik Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id$
+ */
+ phpgw::import_class('phpgwapi.uicommon_jquery');
+ phpgw::import_class('controller.sodocument');
+ phpgw::import_class('controller.soprocedure');
+ include_class('controller', 'document', 'inc/model/');
- phpgw::import_class('phpgwapi.uicommon');
- phpgw::import_class('controller.sodocument');
- phpgw::import_class('controller.soprocedure');
- include_class('controller', 'document', 'inc/model/');
+ class controller_uidocument extends phpgwapi_uicommon_jquery
+ {
- class controller_uidocument extends phpgwapi_uicommon
- {
- private $so;
- private $so_procedure;
+ private $so;
+ private $so_procedure;
+ private $read;
+ private $add;
+ private $edit;
+ private $delete;
+ public $public_functions = array
+ (
+ 'query' => true,
+ 'add' => true,
+ 'view' => true,
+ 'delete' => true,
+ 'show' => true,
+ 'document_types' => true
+ );
- private $read;
- private $add;
- private $edit;
- private $delete;
+ public function __construct()
+ {
+ parent::__construct();
+ $this->so =
controller_sodocument::get_instance();
+ $this->so_procedure =
controller_soprocedure::get_instance();
+ $this->read =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1
+ $this->add =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2
+ $this->edit =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4
+ $this->delete =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
+
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/base.css');
+ }
+ public function query()
+ {
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
- public $public_functions = array
- (
- 'query'
=> true,
- 'add'
=> true,
- 'view'
=> true,
- 'delete'
=> true,
- 'show'
=> true,
- 'document_types' => true
- );
+ $params = array(
+ 'start' => phpgw::get_var('start',
'int', 'REQUEST', 0),
+ 'results' => phpgw::get_var('length',
'int', 'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length',
'int') == -1,
+ );
- public function __construct()
- {
- parent::__construct();
- $this->so = controller_sodocument::get_instance();
- $this->so_procedure = controller_soprocedure::get_instance();
- $this->read =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1
- $this->add =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2
- $this->edit =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4
- $this->delete =
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
- }
- public function query()
- {
- // YUI variables for paging and sorting
- $start_index = phpgw::get_var('startIndex', 'int');
- $num_of_objects = phpgw::get_var('results', 'int', 'GET', 10);
- $sort_field = phpgw::get_var('sort');
- $sort_ascending = phpgw::get_var('dir') == 'desc' ? false :
true;
- // Form variables
- $search_for = phpgw::get_var('query');
- $search_type = phpgw::get_var('search_option');
- // Create an empty result set
- $result_objects = array();
- $result_count = 0;
+ $search_for = $params['query'];
- //Retrieve a contract identifier and load corresponding contract
- $procedure_id = phpgw::get_var('procedure_id');
- if(isset($procedure_id))
- {
- $procedure = $this->so_procedure->get_single($procedure_id);
- }
+ $start_index = $params['start'];
+ $num_of_objects = $params['results'] > 0 ?
$params['results'] : null;
+ $sort_field = $params['order'];
- $type = phpgw::get_var('type');
- switch($type)
- {
- case 'documents_for_procedure':
- $filters = array('procedure_id' => $procedure_id,
- 'document_type' =>
phpgw::get_var('document_type'));
- break;
- }
+ $ctrl_area = phpgw::get_var('control_areas');
+ if(isset($ctrl_area) && $ctrl_area > 0)
+ {
+ $filters['control_areas'] = $ctrl_area;
+ }
+ $sort_ascending = $params['sort'] == 'desc' ? false :
true;
- $result_objects = $this->so->get($start_index,
- $num_of_objects,
- $sort_field,
- $sort_ascending,
- $search_for,
- $search_type,
- $filters);
- $result_count = $this->so->get_count($search_for, $search_type,
$filters);
-
- //Serialize the documents found
- $rows = array();
- foreach ($result_objects as $result)
- {
- if(isset($result))
- {
- $rows[] = $result->serialize();
- }
- }
-
- $editable = phpgw::get_var('editable') == '1' ? true : false;
-
- //Add context menu columns (actions and labels)
- array_walk($rows, array($this, 'add_actions'), array($type,
-
isset($procedure) ? $procedure->has_permission(PHPGW_ACL_EDIT) : false,
-
$this->type_of_user,
- $editable));
-
- //Build a YUI result from the data
- $result_data = array('results' => $rows, 'total_records' =>
$result_count);
- return $this->yui_results($result_data, 'total_records',
'results');
- }
-
- public function get_document_types()
- {
- $result_objects = $this->so->list_document_types();
-
- $editable = phpgw::get_var('editable') == '1' ? true : false;
- $result_data = array('results' => $result_objects);
-
- //Add context menu columns (actions and labels)
- array_walk(
- $result_data['results'],
- array($this, '_add_links'),
- "controller.uidocument.edit_document_type");
-
-
- //Build a YUI result from the data
- return $this->yui_results($result_data, 'total_records',
'results');
+
+ $search_type = phpgw::get_var('search_option');
+ // Create an empty result set
+ $result_objects = array();
+ $result_count = 0;
+
+ //Retrieve a contract identifier and load corresponding
contract
+ $procedure_id = phpgw::get_var('procedure_id');
+ if(isset($procedure_id))
+ {
+ $procedure =
$this->so_procedure->get_single($procedure_id);
+ }
+
+ $type = phpgw::get_var('type');
+ switch($type)
+ {
+ case 'documents_for_procedure':
+ $filters = array('procedure_id' =>
$procedure_id,
+ 'document_type' =>
phpgw::get_var('document_type'));
+ break;
+ }
+
+ $result_objects = $this->so->get($start_index,
$num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type,
$filters);
+ $result_count = $this->so->get_count($search_for,
$search_type, $filters);
+
+ //Serialize the documents found
+ $rows = array();
+ foreach($result_objects as $result)
+ {
+ if(isset($result))
+ {
+ $rows[] = $result->serialize();
+ }
+ }
+
+ $editable = phpgw::get_var('editable') == '1' ? true :
false;
+
+ //Add context menu columns (actions and labels)
+ array_walk($rows, array($this, 'add_actions'),
array($type,
+ isset($procedure) ?
$procedure->has_permission(PHPGW_ACL_EDIT) : false,
+ $this->type_of_user,
+ $editable));
+
+ $results = array('results' => $rows);
+
+ $results['total_records'] = $object_count;
+ $results['start'] =
$params['start'];
+ $results['sort'] =
$params['order'];
+ $results['dir'] =
$params['sort'];
+ $results['draw'] = $draw;
+
+ //FIXME not used?
+
+ return $this->jquery_results($results);
}
-
- /**
- * Add data for context menu
- *
- * @param $value pointer to
- * @param $key ?
- * @param $params [type of query, editable]
- */
- public function add_actions(&$value, $key, $params)
- {
- $value['ajax'] = array();
- $value['actions'] = array();
- $value['labels'] = array();
-
- //view/download
- $value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uidocument.view',
-
'id' => $value['id'])));
- $value['labels'][] = lang('view');
-
- $type = $params[0];
- $edit_permission = $params[1];
- $user_is = $params[2];
- $editable = $params[3];
-
- switch($type)
- {
- case 'documents_for_procedure':
- if($edit_permission && $editable) {
- $value['ajax'][] = true;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uidocument.delete',
-
'id' => $value['id'])));
- $value['labels'][] = lang('delete');
- }
- break;
- case 'admin':
- $value['ajax'][] = true;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uidocument.edit_document_type',
-
'id' => $value['id'])));
- $value['labels'][] = lang('Edit document type');
- break;
- }
- }
- /**
- * Public function to add a document.
- *
- * @param HTTP::procedure_id the procedure id
- * @return unknown_type
- */
- public function add()
- {
- // Get target ids
- $procedure_id = intval(phpgw::get_var('procedure_id'));
-
- $data = array();
- // Check permissions if procedure id is set
- if(isset($procedure_id) && $procedure_id > 0)
- {
- //Load procedure
- $procedure = $this->so_procedure->get_single($procedure_id);
- }
-
- // If no contract or party is loaded
- if(!isset($procedure))
- {
- $data['error'] = lang('error_no_procedure');
- $this->render('permission_denied.php', $data);
- return;
- }
-
- if($_SERVER['REQUEST_METHOD'] == 'POST')
- {
+ public function get_document_types()
+ {
+ $result_objects = $this->so->list_document_types();
+
+ $editable =
phpgw::get_var('editable') == '1' ? true : false;
+ $results =
array('results' => $result_objects);
+ $results['total_records'] =
count($result_objects);
+ $results['draw'] =
phpgw::get_var('draw', 'int');
+
+ //Add context menu columns (actions and labels)
+ array_walk(
+ $results['results'], array($this, '_add_links'),
"controller.uidocument.edit_document_type");
+
+
+ //Build a YUI result from the data
+ return $this->jquery_results($results);
+ }
+
+ /**
+ * Add data for context menu
+ *
+ * @param $value pointer to
+ * @param $key ?
+ * @param $params [type of query, editable]
+ */
+ public function add_actions(&$value, $key, $params)
+ {
+ $value['ajax'] = array();
+ $value['actions'] = array();
+ $value['labels'] = array();
+
+ //view/download
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uidocument.view',
+ 'id' => $value['id'])));
+ $value['labels'][] = lang('view');
+
+ $type = $params[0];
+ $edit_permission = $params[1];
+ $user_is = $params[2];
+ $editable = $params[3];
+
+ switch($type)
+ {
+ case 'documents_for_procedure':
+ if($edit_permission && $editable)
+ {
+ $value['ajax'][] = true;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uidocument.delete',
+ 'id' =>
$value['id'])));
+ $value['labels'][] =
lang('delete');
+ }
+ break;
+ case 'admin':
+ $value['ajax'][] = true;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uidocument.edit_document_type',
+ 'id' =>
$value['id'])));
+ $value['labels'][] = lang('Edit
document type');
+ break;
+ }
+ }
+
+ /**
+ * Public function to add a document.
+ *
+ * @param HTTP::procedure_id the procedure id
+ * @return unknown_type
+ */
+ public function add()
+ {
+ // Get target ids
+ $procedure_id = intval(phpgw::get_var('procedure_id'));
+
+ $data = array();
+ // Check permissions if procedure id is set
+ if(isset($procedure_id) && $procedure_id > 0)
+ {
+ //Load procedure
+ $procedure =
$this->so_procedure->get_single($procedure_id);
+ }
+
+ // If no contract or party is loaded
+ if(!isset($procedure))
+ {
+ $data['error'] = lang('error_no_procedure');
+ $this->render('permission_denied.php', $data);
+ return;
+ }
+
+ if($_SERVER['REQUEST_METHOD'] == 'POST')
+ {
if(!$this->add && !$this->edit)
{
phpgwapi_cache::message_set('No
access', 'error');
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uidocument.show',
-
'procedure_id' => $procedure->get_id(),
-
'tab' => 'documents'));
-
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uidocument.show',
+ 'procedure_id' =>
$procedure->get_id(),
+ 'tab' =>
'documents'));
}
- //Create a document object
- $document = new controller_document();
- $document->set_title(phpgw::get_var('document_title'));
- $document->set_name($_FILES["file_path"]["name"]);
- $document->set_type_id(phpgw::get_var('document_type'));
- $desc = phpgw::get_var('document_description','html');
- $desc = str_replace(" ", " ", $desc);
- $document->set_description($desc);
- $document->set_procedure_id($procedure_id);
-
- //Retrieve the document properties
- $document_properties = $this->get_type_and_id($document);
-
- // Move file from temporary storage to vfs
- $result = $this->so->write_document_to_vfs
- (
- $document_properties['document_type'],
- $_FILES["file_path"]["tmp_name"],
- $document_properties['id'],
- $_FILES["file_path"]["name"]
- );
-
- if($result)
- {
- if($this->so->store($document))
- {
- if(isset($procedure))
- {
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uidocument.show',
-
'procedure_id' => $procedure->get_id(),
-
'tab' => 'documents'));
- }
- }
- else
- {
- // Handle failure on storing document
- $this->redirect($document, $document_propeties,'','');
- }
- }
- else
- {
- //Handle vfs failure to store document
- $this->redirect($document, $document_propeties,'','');
- }
- }
- }
+ //Create a document object
+ $document = new controller_document();
+
$document->set_title(phpgw::get_var('document_title'));
+
$document->set_name($_FILES["file_path"]["name"]);
+
$document->set_type_id(phpgw::get_var('document_type'));
+ $desc =
phpgw::get_var('document_description', 'html');
+ $desc = str_replace(" ", " ",
$desc);
+ $document->set_description($desc);
+ $document->set_procedure_id($procedure_id);
- /**
- * Public function for viewing/downloading a document.
- *
- * @param HTTP::id the document id
- * @return document on success, error message on failure
- */
- public function view()
- {
- $document_id = intval(phpgw::get_var('id'));
- $document = $this->so->get_single($document_id);
- $document_properties = $this->get_type_and_id($document);
-
- header("Content-Disposition: attachment;
filename={$document->get_name()}");
- header("Content-Type: $file_type");
- header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");
-
- echo $this->so->read_document_from_vfs
- (
- $document_properties['document_type'],
- $document_properties['id'],
- $document->get_name()
- );
- }
+ //Retrieve the document properties
+ $document_properties =
$this->get_type_and_id($document);
- /**
- * Public function for deleting a document. Deletes the document from
- * the database and the virtual file system (vfs).
- *
- * @param HTTP::id the document id
- * @return true if successful, false if error, permission denied
message on
- * not enough privileges
- */
- public function delete()
- {
- $document_id = intval(phpgw::get_var('id'));
- $document = $this->so->get_single($document_id);
-
- $procedure_id = intval(phpgw::get_var('procedure_id'));
-
- if(!$this->delete)
+ // Move file from temporary storage to vfs
+ $result = $this->so->write_document_to_vfs
+ (
+ $document_properties['document_type'],
$_FILES["file_path"]["tmp_name"], $document_properties['id'],
$_FILES["file_path"]["name"]
+ );
+
+ if($result)
+ {
+ if($this->so->store($document))
+ {
+ if(isset($procedure))
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'controller.uidocument.show',
+ 'procedure_id'
=> $procedure->get_id(),
+ 'tab'
=> 'documents'));
+ }
+ }
+ else
+ {
+ // Handle failure on storing
document
+ $this->redirect($document,
$document_propeties, '', '');
+ }
+ }
+ else
+ {
+ //Handle vfs failure to store document
+ $this->redirect($document,
$document_propeties, '', '');
+ }
+ }
+ }
+
+ /**
+ * Public function for viewing/downloading a document.
+ *
+ * @param HTTP::id the document id
+ * @return document on success, error message on failure
+ */
+ public function view()
+ {
+ $document_id = intval(phpgw::get_var('id'));
+ $document =
$this->so->get_single($document_id);
+ $document_properties =
$this->get_type_and_id($document);
+
+ header("Content-Disposition: attachment;
filename={$document->get_name()}");
+ header("Content-Type: $file_type");
+ header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");
+
+ echo $this->so->read_document_from_vfs
+ (
+ $document_properties['document_type'],
$document_properties['id'], $document->get_name()
+ );
+ }
+
+ /**
+ * Public function for deleting a document. Deletes the
document from
+ * the database and the virtual file system (vfs).
+ *
+ * @param HTTP::id the document id
+ * @return true if successful, false if error, permission
denied message on
+ * not enough privileges
+ */
+ public function delete()
+ {
+ $document_id = intval(phpgw::get_var('id'));
+ $document = $this->so->get_single($document_id);
+
+ $procedure_id = intval(phpgw::get_var('procedure_id'));
+
+ if(!$this->delete)
{
phpgwapi_cache::message_set('No access',
'error');
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uidocument.show',
-
'procedure_id' =>
$procedure_id,
-
'tab' => 'documents'));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uidocument.show',
+ 'procedure_id' => $procedure_id,
+ 'tab' =>
'documents'));
}
-
- $procedure = $this->so_procedure->get_single($procedure_id);
- $document_properties = $this->get_type_and_id($document);
-
- /*if(!$this->check_permissions($document,$document_properties))
- {
- $this->render('permission_denied.php');
- return;
- }*/
-
- $result = $this->so->delete_document_from_vfs
- (
- $document_properties['document_type'],
- $document_properties['id'],
- $document->get_name()
- );
-
- if($result)
- {
- $this->so->delete_document($document_id);
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uidocument.show',
-
'procedure_id' => $procedure->get_id(),
-
'tab' => 'documents'));
- }
- // TODO: communicate error/message to user
- return false;
- }
-
- /**
- * Utitity function for redirecting to correct edit mode (procedure)
- *
- * @param $document the target document
- * @param $document_properties the document properies (name/value
array)
- * @param $error an error message
- * @param $message a user message
- */
- public function redirect($document, $document_properties, $error,
$message)
- {
- if($document_properties['document_type'] ==
controller_sodocument::$PROCEDURE_DOCUMENTS)
- {
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uiprocedure.edit',
-
'id' => $document_properties['id'],
-
'error' => $error,
-
'message' => $message));
- }
- }
-
- /**
- * Utiity method for checking the users permission on this document.
If the
- * document is bound to a procedure, then the user must have edit
privileges
- * on the given procedure. If no procedure, the user must be an
executive
- * officer or an administrator.
- *
- * @param $document the document in question
- * @param $document_properties the document type and object id
- * @return true if correct privileges, false otherwise
- */
- private function check_permissions($document, $document_properties)
- {
- if($document_properties ==
controller_sodocument::$PROCEDURE_DOCUMENTS)
- {
- $procedure =
$this->so_procedure->get_single($document_properties['id']);
- if(!$procedure->has_permission(PHPGW_ACL_EDIT))
- {
- return false;
- }
- }
- else
- {
- if(!($this->isExecutiveOfficer() || $this->isAdministrator()))
- {
- return false;
- }
- }
- return true;
- }
+ $procedure =
$this->so_procedure->get_single($procedure_id);
- /**
- * Utility method for finding out whether a document is bound to a
- * procedure.
- *
- * @param $document the given document
- * @return name/value array ('document_type','id')
- */
- private function get_type_and_id($document)
- {
- $document_type;
- $id;
- $procedure_id = $document->get_procedure_id();
- if(isset($procedure_id) && $procedure_id > 0)
- {
- $document_type = controller_sodocument::$PROCEDURE_DOCUMENTS;
- $id = $procedure_id;
- }
- return array
- (
- 'document_type' => $document_type,
- 'id' => $id
- );
- }
-
- public function show()
- {
- $GLOBALS['phpgw_info']['flags']['app_header'] .= '::'.lang('view');
- $procedure_id = (int)phpgw::get_var('procedure_id');
- $document_type = phpgw::get_var('type');
- if(isset($_POST['edit_procedure']))
- {
- $GLOBALS['phpgw']->redirect_link('/index.php', array(
-
'menuaction' => 'controller.uiprocedure.edit',
- 'id' =>
$procedure_id));
- }
- else
- {
- if(isset($procedure_id) && $procedure_id > 0)
- {
- $procedure =
$this->so_procedure->get_single($procedure_id);
- }
- else
- {
- $this->render('permission_denied.php',array('error' =>
lang('invalid_request')));
- return;
- }
-
- if($this->flash_msgs)
- {
- $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
- $msgbox_data =
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
- }
-
- $documents =
$this->so->get(null,null,null,null,null,null,array(
-
'procedure_id' => $procedure_id,
- 'type'
=> $document_type));
-
- $table_header[] = array('header' => lang('Document title'));
- $table_header[] = array('header' => lang('Document name'));
- $table_header[] = array('header' => lang('Document
description'));
-
- foreach($documents as $document)
- {
- /* hack to fix display of char */
- $document->set_description(str_replace(" ", "
",$document->get_description()));
- $doc_array = $document->toArray();
- $doc_array['link'] = self::link(array('menuaction' =>
'controller.uidocument.view',
-
'id' => $doc_array['id']));
- $doc_array['delete_link'] = self::link(array('menuaction'
=> 'controller.uidocument.delete',
-
'id' => $doc_array['id'], 'procedure_id' => $procedure_id));
- $table_values[] = array('document' => $doc_array);
- }
-
- $procedure_array = $procedure->toArray();
-
- $tabs = array( array(
- 'label' => lang('Procedure'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array(
-
'menuaction' => 'controller.uiprocedure.view',
-
'id' => $procedure->get_id()))
-
- ), array(
- 'label' =>
lang('View_documents_for_procedure')
- ));
-
- $data = array
- (
- 'tabs' =>
$GLOBALS['phpgw']->common->create_tabs($tabs, 1),
- 'view' =>
"view_documents_for_procedure",
- 'procedure_id' => !empty($procedure) ?
$procedure->get_id() : 0,
- 'procedure' =>
$procedure_array,
- 'values' =>
$table_values,
- 'table_header' => $table_header,
- );
-
- $this->use_yui_editor(array('document_description'));
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('controller') . '::' . lang('Procedure');
-
- self::render_template_xsl(array('procedure/procedure_tabs',
-
'procedure/procedure_documents'), $data);
- }
- }
-
- public function document_types()
- {
- if(phpgw::get_var('phpgw_return_as') == 'json')
- {
- return $this->get_document_types();
- self::render_template_xsl(array('procedure/procedure_tabs',
-
'common',
-
'procedure/procedure_documents'),
- $data);
- }
- self::add_javascript('phpgwapi', 'yahoo', 'datatable.js');
- phpgwapi_yui::load_widget('datatable');
- phpgwapi_yui::load_widget('paginator');
-
- $data = array(
- 'datatable_name' => 'Dokument typer',
- 'form' => array(
- ),
- 'datatable' => array(
- 'source' => self::link(array('menuaction' =>
'controller.uidocument.document_types',
-
'phpgw_return_as' => 'json')),
- 'field' => array(
- array(
- 'key' => 'id',
- 'label' => lang('ID'),
- 'sortable' => true,
- 'formatter' =>
'YAHOO.portico.formatLink'
- ),
- array(
- 'key' => 'title',
- 'label' => lang('Procedure
title'),
- 'sortable' => false
- ),
- array(
- 'key' => 'link',
- 'hidden' => true
- )
- )
- ),
- );
-
- self::render_template_xsl('datatable_common', $data);
- }
- }
+ $document_properties =
$this->get_type_and_id($document);
+
+ /*
if(!$this->check_permissions($document,$document_properties))
+ {
+ $this->render('permission_denied.php');
+ return;
+ } */
+
+ $result = $this->so->delete_document_from_vfs
+ (
+ $document_properties['document_type'],
$document_properties['id'], $document->get_name()
+ );
+
+ if($result)
+ {
+ $this->so->delete_document($document_id);
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uidocument.show',
+ 'procedure_id' =>
$procedure->get_id(),
+ 'tab' =>
'documents'));
+ }
+ // TODO: communicate error/message to user
+ return false;
+ }
+
+ /**
+ * Utitity function for redirecting to correct edit mode
(procedure)
+ *
+ * @param $document the target document
+ * @param $document_properties the document properies
(name/value array)
+ * @param $error an error message
+ * @param $message a user message
+ */
+ public function redirect($document, $document_properties,
$error, $message)
+ {
+ if($document_properties['document_type'] ==
controller_sodocument::$PROCEDURE_DOCUMENTS)
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uiprocedure.edit',
+ 'id' =>
$document_properties['id'],
+ 'error' => $error,
+ 'message' => $message));
+ }
+ }
+
+ /**
+ * Utiity method for checking the users permission on this
document. If the
+ * document is bound to a procedure, then the user must have
edit privileges
+ * on the given procedure. If no procedure, the user must be an
executive
+ * officer or an administrator.
+ *
+ * @param $document the document in question
+ * @param $document_properties the document type and object id
+ * @return true if correct privileges, false otherwise
+ */
+ private function check_permissions($document,
$document_properties)
+ {
+ if($document_properties ==
controller_sodocument::$PROCEDURE_DOCUMENTS)
+ {
+ $procedure =
$this->so_procedure->get_single($document_properties['id']);
+ if(!$procedure->has_permission(PHPGW_ACL_EDIT))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if(!($this->isExecutiveOfficer() ||
$this->isAdministrator()))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Utility method for finding out whether a document is bound
to a
+ * procedure.
+ *
+ * @param $document the given document
+ * @return name/value array ('document_type','id')
+ */
+ private function get_type_and_id($document)
+ {
+ $document_type;
+ $id;
+ $procedure_id = $document->get_procedure_id();
+ if(isset($procedure_id) && $procedure_id > 0)
+ {
+ $document_type =
controller_sodocument::$PROCEDURE_DOCUMENTS;
+ $id =
$procedure_id;
+ }
+ return array
+ (
+ 'document_type' => $document_type,
+ 'id' => $id
+ );
+ }
+
+ public function show()
+ {
+ $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('view');
+ $procedure_id = (int)phpgw::get_var('procedure_id');
+ $document_type = phpgw::get_var('type');
+ if(isset($_POST['edit_procedure']))
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array(
+ 'menuaction' =>
'controller.uiprocedure.edit',
+ 'id' => $procedure_id));
+ }
+ else
+ {
+ if(isset($procedure_id) && $procedure_id > 0)
+ {
+ $procedure =
$this->so_procedure->get_single($procedure_id);
+ }
+ else
+ {
+ $this->render('permission_denied.php',
array('error' => lang('invalid_request')));
+ return;
+ }
+
+ if($this->flash_msgs)
+ {
+ $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+ $msgbox_data =
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+ }
+
+ $documents = $this->so->get(null, null, null,
null, null, null, array(
+ 'procedure_id' => $procedure_id,
+ 'type' =>
$document_type));
+
+ $table_header[] = array('header' =>
lang('Document title'));
+ $table_header[] = array('header' =>
lang('Document name'));
+ $table_header[] = array('header' =>
lang('Document description'));
+
+ foreach($documents as $document)
+ {
+ /* hack to fix display of char */
+
$document->set_description(str_replace(" ", " ",
$document->get_description()));
+ $doc_array
= $document->toArray();
+ $doc_array['link']
= self::link(array('menuaction' => 'controller.uidocument.view',
@@ Diff output truncated at 153600 characters. @@
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [12494] start converting the controller module,
Sigurd Nes <=