fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10097] initial add of file


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [10097] initial add of file
Date: Wed, 03 Oct 2012 07:11:44 +0000

Revision: 10097
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10097
Author:   erikhl
Date:     2012-10-03 07:11:43 +0000 (Wed, 03 Oct 2012)
Log Message:
-----------
initial add of file

Added Paths:
-----------
    trunk/logistic/inc/class.uirequirement.inc.php

Added: trunk/logistic/inc/class.uirequirement.inc.php
===================================================================
--- trunk/logistic/inc/class.uirequirement.inc.php                              
(rev 0)
+++ trunk/logistic/inc/class.uirequirement.inc.php      2012-10-03 07:11:43 UTC 
(rev 10097)
@@ -0,0 +1,218 @@
+<?php
+
+       /**
+        * phpGroupWare - logistic: a part of a Facilities Management System.
+        *
+        * @author Erik Holm-Larsen <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 logistic
+        * @version $Id $
+        */
+
+       phpgw::import_class('phpgwapi.uicommon');
+       phpgw::import_class('logistic.sorequirement');
+
+       include_class('logistic', 'requirement');
+
+
+       class uirequirement extends phpgwapi_uicommon
+       {
+               private $so;
+
+               public $public_functions = array(
+                       'query' => true,
+                       'index' => true,
+                       'add' => true,
+                       'edit' => true,
+                       'view' => true
+               );
+
+               public function __construct()
+               {
+                       parent::__construct();
+
+                       $this->so = CreateObject('logistic.sorequirement');
+
+                       $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"logistic::project::requirement";
+               }
+
+
+               public function query()
+               {
+                       $params = array(
+                               'start' => phpgw::get_var('startIndex', 'int', 
'REQUEST', 0),
+                               'results' => phpgw::get_var('results', 'int', 
'REQUEST', null),
+                               'query' => phpgw::get_var('query'),
+                               'sort' => phpgw::get_var('sort'),
+                               'dir' => phpgw::get_var('dir'),
+                               'filters' => $filters
+                       );
+
+                       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');
+                       $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;
+
+                       //Retrieve a contract identifier and load corresponding 
contract
+                       $project_id = phpgw::get_var('project_id');
+
+                       $exp_param = phpgw::get_var('export');
+                       $export = false;
+                       if (isset($exp_param))
+                       {
+                               $export = true;
+                               $num_of_objects = null;
+                       }
+
+                       //Retrieve the type of query and perform type specific 
logic
+                       $query_type = phpgw::get_var('type');
+                       //var_dump($query_type);
+                       switch ($query_type)
+                       {
+                               default: // ... all composites, filters (active 
and vacant)
+                                       phpgwapi_cache::session_set('logistic', 
'requirement_query', $search_for);
+                                       //$filters = array('project_type' => 
phpgw::get_var('project_type'));
+                                       $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);
+                                       break;
+                       }
+
+                       //Create an empty row set
+                       $rows = array();
+                       foreach ($result_objects as $result)
+                       {
+                               if (isset($result))
+                               {
+                                       $rows[] = $result->serialize();
+                               }
+                       }
+
+                       // ... add result data
+                       $result_data = array('results' => $rows);
+
+                       $result_data['total_records'] = $object_count;
+                       $result_data['start'] = $params['start'];
+                       $result_data['sort'] = $params['sort'];
+                       $result_data['dir'] = $params['dir'];
+
+                       $editable = phpgw::get_var('editable') == 'true' ? true 
: false;
+
+                       if (!$export)
+                       {
+                               //Add action column to each row in result table
+                               array_walk(
+                                                               
$result_data['results'], array($this, '_add_links'), "logistic.uiproject.view");
+                       }
+                       return $this->yui_results($result_data);
+               }
+
+               public function index()
+               {
+                       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');
+
+                       $data = array(
+                               'datatable_name'        => lang('requirement'),
+                               'form' => array(
+                                       'toolbar' => array(
+                                               'item' => array(
+                                                       array('type' => 'text',
+                                                               'text' => 
lang('search'),
+                                                               'name' => 
'query'
+                                                       ),
+                                                       array(
+                                                               'type' => 
'submit',
+                                                               'name' => 
'search',
+                                                               'value' => 
lang('Search')
+                                                       ),
+                                               ),
+                                       ),
+                               ),
+                               'datatable' => array(
+                                       'source' => 
self::link(array('menuaction' => 'logistic.uirequirement.index', 
'phpgw_return_as' => 'json')),
+                                       'field' => array(
+                                               array(
+                                                       'key' => 'name',
+                                                       'label' => 
lang('Project name'),
+                                                       'sortable' => true
+                                               ),
+                                               array(
+                                                       'key' => 'id',
+                                                       'label' => lang('ID'),
+                                                       'sortable' => true,
+                                                       'formatter' => 
'YAHOO.portico.formatLink'
+                                               ),
+                                               array(
+                                                       'key' => 'link',
+                                                       'hidden' => true
+                                               )
+                                       )
+                               ),
+                       );
+
+                       $parameters = array
+                               (
+                                       'parameter' => array
+                                       (
+                                               array
+                                               (
+                                                       'name'          => 
'requirement_id',
+                                                       'source'        => 'id'
+                                               ),
+                                       )
+                               );
+
+                       $data['datatable']['actions'][] = array
+                                       (
+                                               'my_name'               => 
'book_requirement',
+                                               'text'                  => 
lang('t_book_requirement'),
+                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
+                                               (
+                                                       'menuaction'    => 
'logistic.uiactivity.edit'
+                                               )),
+                                               'parameters'    => 
json_encode($parameters)
+                                       );
+
+                       self::render_template_xsl('datatable_common', $data);
+               }
+       }
\ No newline at end of file




reply via email to

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