fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12784] controller: integrate from property::entity


From: Sigurd Nes
Subject: [Fmsystem-commits] [12784] controller: integrate from property::entity
Date: Tue, 24 Feb 2015 11:11:58 +0000

Revision: 12784
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12784
Author:   sigurdne
Date:     2015-02-24 11:11:57 +0000 (Tue, 24 Feb 2015)
Log Message:
-----------
controller: integrate from property::entity

Modified Paths:
--------------
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.uicalendar.inc.php
    trunk/controller/setup/setup.inc.php
    trunk/controller/setup/tables_current.inc.php
    trunk/controller/setup/tables_update.inc.php

Added Paths:
-----------
    trunk/controller/inc/class.uilookup.inc.php

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2015-02-24 11:07:41 UTC 
(rev 12783)
+++ trunk/controller/inc/class.socontrol.inc.php        2015-02-24 11:11:57 UTC 
(rev 12784)
@@ -132,7 +132,7 @@
                        $check_list_array = array();
                        
                        $sql  = "SELECT DISTINCT 
controller_check_list.location_code, controller_check_list.control_id, 
controller_check_list.id AS check_list_id,"
-                               . " 
procedure_id,requirement_id,costresponsibility_id,description, start_date, 
end_date,deadline,planned_date, completed_date,"
+                               . " 
procedure_id,requirement_id,costresponsibility_id,description, 
controller_control.start_date, end_date,deadline,planned_date, completed_date,"
                                . " control_area_id, 
repeat_type,repeat_interval, title"
                                . " FROM controller_check_list"
                                . " {$this->join} controller_control ON 
controller_check_list.control_id = controller_control.id"
@@ -211,7 +211,7 @@
 
                
                        $sql  = "SELECT DISTINCT 
controller_check_list.location_code, controller_check_list.control_id, 
controller_check_list.id AS check_list_id,"
-                               . " controller_control.description, start_date, 
end_date, deadline,planned_date, completed_date,"
+                               . " controller_control.description, 
controller_control.start_date, end_date, deadline,planned_date, completed_date,"
                                . " 
control_area_id,controller_check_list.location_id,title,controller_check_list.component_id"
                                . " FROM controller_check_list"
                                . " {$this->join} controller_control ON 
controller_check_list.control_id = controller_control.id"
@@ -827,6 +827,8 @@
                */
                function register_control_to_component($data)
                {
+                       $assigned_to    = isset($data['assigned_to']) && 
$data['assigned_to'] ? $data['assigned_to'] : null;
+                       $start_date                     = 
isset($data['start_date']) && $data['start_date'] ? $data['start_date'] : null;
 
                        $delete_component = array();
                        $add_component = array();
@@ -861,10 +863,17 @@
                        
                                        if(!$this->db->next_record())
                                        {
-                                               $sql =  "INSERT INTO 
controller_control_component_list (control_id, location_id, component_id) ";
-                                               $sql .= "VALUES ( 
{$control_id}, {$location_id}, {$component_id})";
-                                               
-                                               $this->db->query($sql);
+                                               $values_insert = array
+                                               (
+                                                       'control_id'            
=> $control_id,
+                                                       'location_id'           
=> $location_id,
+                                                       'component_id'          
=> $component_id,
+                                                       'assigned_to'           
=> $assigned_to,
+                                                       'start_date'            
=> $start_date
+                                               );
+
+                                               $this->db->query("INSERT INTO 
controller_control_component_list (" . implode(',',array_keys($values_insert)) 
. ') VALUES ('
+                                                . 
$this->db->validate_insert(array_values($values_insert)) . 
')',__LINE__,__FILE__);
                                        }
                                }
                        }
@@ -904,6 +913,64 @@
                        $this->db->query($sql);
                }
 
+               /**
+                * Get all controls assosiated with a component
+                * 
+                * @param array $data location_id and component_id
+                * @return array controls assosiated with a component
+                * @throws Exception if missing valid input
+                */
+               function get_controls_at_component($data)
+               {
+                       if(!isset($data['location_id']) || 
!$data['location_id'])
+                       {
+                               throw new 
Exception("controller_socontrol::get_controls_at_component - Missing 
location_id in input");
+                       }
+                       if(!isset($data['component_id']) || 
!$data['component_id'])
+                       {
+                               throw new 
Exception("controller_socontrol::get_controls_at_component - Missing 
component_id in input");
+                       }
+
+                       static $users = array(); // cache result
+
+                       $location_id = (int)$data['location_id'];
+                       $component_id = (int)$data['component_id'];
+
+                       $sql = "SELECT controller_control_component_list.* , 
controller_control.title, repeat_type, repeat_interval, enabled"
+                       . "  FROM controller_control_component_list"
+                       . " {$this->db->join} controller_control ON 
controller_control.id = controller_control_component_list.control_id WHERE 
location_id = {$location_id} AND component_id = {$component_id}";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $controls = array();
+
+                       while ($this->db->next_record())
+                       {
+                               $controls[] = array
+                               (
+                                       'id'                    => 
$this->db->f('id'),
+                                       'control_id'    => 
$this->db->f('control_id'),
+                                       'title'                 => 
$this->db->f('title',true),
+                                       'location_id'   => 
$this->db->f('location_id'),
+                                       'component_id'  => 
$this->db->f('component_id'),
+                                       'assigned_to'   => 
$this->db->f('assigned_to'),
+                                       'start_date'    => 
$this->db->f('start_date'),
+                                       'repeat_type'   => 
$this->db->f('repeat_type'),
+                                       'repeat_interval'       => 
$this->db->f('repeat_interval'),
+                                       'enabled'       => 
$this->db->f('enabled'),
+                               );
+                       }
+
+                       foreach($controls as &$entry)
+                       {
+                               if(!isset($users[$entry['assigned_to']]))
+                               {
+                                       $users[$entry['assigned_to']] = 
$GLOBALS['phpgw']->accounts->get($entry['assigned_to'])->__toString();
+                               }
+                               $entry['assigned_to_name'] = 
$users[$entry['assigned_to']];
+                       }
+                       return $controls;
+
+               }
+
                function get_id_field_name($extended_info = false)
                {
                        if(!$extended_info)

Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php       2015-02-24 11:07:41 UTC 
(rev 12783)
+++ trunk/controller/inc/class.uicalendar.inc.php       2015-02-24 11:11:57 UTC 
(rev 12784)
@@ -680,8 +680,14 @@
                        static $_location_name = array();
                        $control_id = phpgw::get_var('control_id');
                        $control = $this->so_control->get_single($control_id);
-                       $year = intval(phpgw::get_var('year'));
-                       $month = intval(phpgw::get_var('month'));
+                       if(!$year = intval(phpgw::get_var('year')))
+                       {
+                               $year = date('Y');
+                       }
+                       if(!$month = intval(phpgw::get_var('month')))
+                       {
+                               $month = date('m');
+                       }
 
                        $user_id = $GLOBALS['phpgw_info']['user']['account_id'];
 

Added: trunk/controller/inc/class.uilookup.inc.php
===================================================================
--- trunk/controller/inc/class.uilookup.inc.php                         (rev 0)
+++ trunk/controller/inc/class.uilookup.inc.php 2015-02-24 11:11:57 UTC (rev 
12784)
@@ -0,0 +1,301 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
+       * @package property
+       * @subpackage core
+       * @version $Id: class.uilookup.inc.php 11909 2014-04-13 16:49:53Z 
sigurdne $
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+       phpgw::import_class('phpgwapi.yui');
+
+       class controller_uilookup
+       {
+               var $cat_id;
+               var $start;
+               var $query;
+               var $sort;
+               var $order;
+               var $filter;
+
+               var $public_functions = array
+                       (
+                               'control'               => true
+                       );
+
+               function __construct()
+               {
+                       $GLOBALS['phpgw_info']['flags']['noframework'] = true;
+                       $GLOBALS['phpgw_info']['flags']['headonly']=true;
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+
+                       $this->start                            = 
$this->bo->start;
+                       $this->query                            = 
$this->bo->query;
+                       $this->sort                                     = 
$this->bo->sort;
+                       $this->order                            = 
$this->bo->order;
+                       $this->filter                           = 
$this->bo->filter;
+                       $this->cat_id                           = 
$this->bo->cat_id;
+                       phpgwapi_yui::load_widget('tabview');
+                       phpgwapi_yui::load_widget('dragdrop');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('menu');
+                       phpgwapi_yui::load_widget('connection');
+                       phpgwapi_yui::load_widget('loader');
+                       phpgwapi_yui::load_widget('tabview');
+                       phpgwapi_yui::load_widget('paginator');
+                       phpgwapi_yui::load_widget('animation');
+
+                       if ( !isset($GLOBALS['phpgw']->css) || 
!is_object($GLOBALS['phpgw']->css) )
+                       {
+                               $GLOBALS['phpgw']->css = 
createObject('phpgwapi.css');
+                       }
+                       // Prepare CSS Style
+                       $GLOBALS['phpgw']->css->validate_file('datatable');
+                       $GLOBALS['phpgw']->css->validate_file('property');
+                       
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+
+               }
+
+               function control()
+               {
+                       if( phpgw::get_var('phpgw_return_as') != 'json' )
+                       {
+
+                               $datatable['config']['base_url']        = 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                               'menuaction'                    
=> 'controller.uilookup.control',
+                                               'second_display'        => true,
+                                               'cat_id'                        
=> $this->cat_id,
+                                               'query'                         
=> $this->query,
+                                               'filter'                        
=> $this->filter,
+                                       ));
+
+                               $datatable['config']['allow_allrows'] = true;
+
+                               $datatable['config']['base_java_url'] = 
"menuaction:'controller.uilookup.control',"
+                                       ."second_display:true,"
+                                       ."cat_id:'{$this->cat_id}',"
+                                       ."query:'{$this->query}',"
+                                       ."filter:'{$this->filter}'";
+
+                               $datatable['actions']['form'] = array
+                                       (
+                                               array
+                                               (
+                                                       'action'        => 
$GLOBALS['phpgw']->link('/index.php',
+                                                       array
+                                                       (
+                                                               'menuaction'    
        => 'controller.uilookup.control',
+                                                               
'second_display'        => true,
+                                                               'cat_id'        
                => $this->cat_id,
+                                                               'query'         
                => $this->query,
+                                                               'filter'        
                => $this->filter
+                                                       )
+                                               ),
+                                               'fields'        => array
+                                               (
+                                                       'field' => array
+                                                       (
+                                                               array
+                                                               ( //boton  
SEARCH
+                                                                       'id' => 
'btn_search',
+                                                                       'name' 
=> 'search',
+                                                                       'value' 
   => lang('search'),
+                                                                       'type' 
=> 'button',
+                                                                       
'tab_index' => 2
+                                                               ),
+                                                               array
+                                                               ( // TEXT IMPUT
+                                                                       'name'  
   => 'query',
+                                                                       'id'    
 => 'txt_query',
+                                                                       'value' 
   => '',//'',//$query,
+                                                                       'type' 
=> 'text',
+                                                                       'size'  
  => 28,
+                                                                       
'onkeypress' => 'return pulsar(event)',
+                                                                       
'tab_index' => 1
+                                                               )
+                                                       ),
+                                                       'hidden_value' => array
+                                                       (
+                                                               )
+                                                       )
+                                               )
+                                       );
+                       }
+
+                       $uicols = array (
+                               'input_type'    =>      array('text','text',),
+                               'name'                  =>      
array('id','title'),
+                               'sort_field'    =>      array('id','title'),
+                               'formatter'             =>      array('',''),
+                               'descr'                 =>      
array(lang('ID'),lang('title'))
+                       );
+
+                       $values = array();
+                       $uicontrol      = CreateObject('controller.uicontrol');
+
+                       $_GET['startIndex'] = phpgw::get_var('start');
+                       $_REQUEST['startIndex'] = phpgw::get_var('start');
+                       $_GET['dir'] = phpgw::get_var('sort', 'string', 'GET', 
'ASC');
+                       $_REQUEST['dir'] = phpgw::get_var('sort', 'string', 
'GET', 'ASC');
+                       $_GET['sort'] = phpgw::get_var('order', 'string', 
'GET', 'id');
+                       $_REQUEST['sort'] = phpgw::get_var('order', 'string', 
'GET', 'id');
+
+
+                       $values = $uicontrol->query();
+
+                       $json = array
+                               (
+                                       'recordsReturned'       => 
$values['ResultSet']['recordsReturned'],
+                                       'totalRecords'          => 
$values['ResultSet']['totalRecords'],
+                                       'startIndex'            => 
$values['ResultSet']['startIndex'],
+                               //      'pageSize'              => 
$values['ResultSet']['pageSize'],
+                                       'sort'                          => 
$values['ResultSet']['sortKey'],
+                                       'dir'                           => 
$values['ResultSet']['sortDir'],
+                                       'records'                       => 
$values['ResultSet']['Result'],
+                               );
+
+                       if( phpgw::get_var('phpgw_return_as') == 'json' )
+                       {
+                               return $json;
+                       }
+
+
+                       $uicols_count   = count($uicols['descr']);
+                       $datatable['rowactions']['action'] = array();
+                       for ($i=0;$i<$uicols_count;$i++)
+                       {
+                               //all colums should be have formatter
+                               
$datatable['headers']['header'][$i]['formatter'] = 
($uicols['formatter'][$i]==''?  '""' : $uicols['formatter'][$i]);
+                               if($uicols['input_type'][$i]!='hidden')
+                               {
+                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
+                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
+                                       
$datatable['headers']['header'][$i]['visible']                  = true;
+                                       
$datatable['headers']['header'][$i]['sortable']                 = true;
+                                       
$datatable['headers']['header'][$i]['sort_field']       = 
$uicols['sort_field'][$i];
+                               }
+                               else
+                               {
+                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
+                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
+                                       
$datatable['headers']['header'][$i]['visible']                  = false;
+                                       
$datatable['headers']['header'][$i]['sortable']                 = false;
+                                       
$datatable['headers']['header'][$i]['format']                   = 'hidden';
+                               }
+                       }
+
+                       $function_exchange_values = '';
+
+                       $function_exchange_values .= 
'opener.document.getElementById("control_id").value = "";' ."\r\n";
+                       $function_exchange_values .= 
'opener.document.getElementById("control_name").value = "";' ."\r\n";
+
+                       $function_exchange_values .= 
'opener.document.getElementById("control_id").value = data.getData("id");' 
."\r\n";
+                       $function_exchange_values .= 
'opener.document.getElementById("control_name").value = data.getData("title");' 
 ."\r\n";
+
+                       $function_exchange_values .= 'window.close()';
+
+                       $datatable['exchange_values'] = 
$function_exchange_values;
+                       $datatable['valida'] = '';
+
+                       // path for property.js
+                       $property_js = "/property/js/yahoo/property.js";
+
+                       if 
(!isset($GLOBALS['phpgw_info']['server']['no_jscombine']) || 
!$GLOBALS['phpgw_info']['server']['no_jscombine'])
+                       {
+                               $cachedir = 
urlencode($GLOBALS['phpgw_info']['server']['temp_dir']);
+                               $property_js = 
"/phpgwapi/inc/combine.php?cachedir={$cachedir}&type=javascript&files=" . 
str_replace('/', '--', ltrim($property_js,'/'));
+                       }
+
+                       $datatable['property_js'] = 
$GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js;
+
+                       // Pagination and sort values
+                       $datatable['pagination']['records_start']       = 
(int)phpgw::get_var('start');
+                       $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       $datatable['pagination']['records_returned']= 
$values['ResultSet']['recordsReturned'];
+                       $datatable['pagination']['records_total']       = 
$values['ResultSet']['totalRecords'];
+
+                       if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
+                       {
+                               $datatable['sorting']['order']                  
= 'id'; // name key Column in myColumnDef
+                               $datatable['sorting']['sort']                   
= 'asc'; // ASC / DESC
+                       }
+                       else
+                       {
+                               $datatable['sorting']['order']                  
= phpgw::get_var('sort', 'string'); // name of column of Database
+                               $datatable['sorting']['sort']                   
= phpgw::get_var('dir', 'string'); // ASC / DESC
+                       }
+
+                       $appname                                                
= lang('controller');
+                       $function_msg                                   = '';
+
+
+                       //-- BEGIN----------------------------- JSON CODE 
------------------------------
+
+                       //values for Pagination
+                       $json = array
+                               (
+                                       'recordsReturned'       => 
$datatable['pagination']['records_returned'],
+                                       'totalRecords'          => 
(int)$datatable['pagination']['records_total'],
+                                       'startIndex'            => 
$datatable['pagination']['records_start'],
+                                       'sort'                          => 
$datatable['sorting']['order'],
+                                       'dir'                           => 
$datatable['sorting']['sort'],
+                                       'records'                       => 
array()
+                               );
+
+
+                       // right in datatable
+                       if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
+                       {
+                               $json ['rights'] = 
$datatable['rowactions']['action'];
+                       }
+
+                       if( phpgw::get_var('phpgw_return_as') == 'json' )
+                       {
+                               return $json;
+                       }
+
+
+                       $datatable['json_data'] = json_encode($json);
+                       //-------------------- JSON CODE ----------------------
+
+                       // Prepare template variables and process XSLT
+                       $template_vars = array();
+                       $template_vars['datatable'] = $datatable;
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
$template_vars);
+
+                       //Title of Page
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . ' - ' . $appname . ': ' . $function_msg;
+
+                       // Prepare generic YUI Library for old style lookup
+                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'lookup.tenant.index', 'property' );
+               }
+       }

Modified: trunk/controller/setup/setup.inc.php
===================================================================
--- trunk/controller/setup/setup.inc.php        2015-02-24 11:07:41 UTC (rev 
12783)
+++ trunk/controller/setup/setup.inc.php        2015-02-24 11:11:57 UTC (rev 
12784)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['controller']['name'] = 'controller';
-       $setup_info['controller']['version'] = '0.1.48';
+       $setup_info['controller']['version'] = '0.1.49';
        $setup_info['controller']['app_order'] = 100;
        $setup_info['controller']['enable'] = 1;
        $setup_info['controller']['app_group']  = 'office';

Modified: trunk/controller/setup/tables_current.inc.php
===================================================================
--- trunk/controller/setup/tables_current.inc.php       2015-02-24 11:07:41 UTC 
(rev 12783)
+++ trunk/controller/setup/tables_current.inc.php       2015-02-24 11:11:57 UTC 
(rev 12784)
@@ -143,10 +143,12 @@
                ),
                'controller_control_component_list' => array(
                                'fd' => array(
-                                       'id'                                    
        => array('type' => 'auto', 'nullable' => false),
+                                       'id'                            => 
array('type' => 'auto', 'nullable' => false),
                                        'control_id'            => array('type' 
=> 'int', 'precision' => '4', 'nullable' => false),
-                                       'location_id'   => array('type' => 
'int', 'precision' => '4', 'nullable' => false),
-                                       'component_id'  => array('type' => 
'int', 'precision' => '4', 'nullable' => false)
+                                       'location_id'           => array('type' 
=> 'int', 'precision' => '4', 'nullable' => false),
+                                       'component_id'          => array('type' 
=> 'int', 'precision' => '4', 'nullable' => false),
+                                       'assigned_to'           => array('type' 
=> 'int', 'precision' => '4', 'nullable' => true),
+                                       'start_date'            => array('type' 
=> 'int', 'precision' => '4', 'nullable' => true),
                                ),
                        'pk' => array('id'),
                        'fk' => array(),

Modified: trunk/controller/setup/tables_update.inc.php
===================================================================
--- trunk/controller/setup/tables_update.inc.php        2015-02-24 11:07:41 UTC 
(rev 12783)
+++ trunk/controller/setup/tables_update.inc.php        2015-02-24 11:11:57 UTC 
(rev 12784)
@@ -965,3 +965,29 @@
                }
        }
 
+       /**
+       * Assign responsible user to control at componant from date.
+       **/
+       $test[] = '0.1.48';
+       function controller_upgrade0_1_48()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_control_component_list','assigned_to',array(
+                       'type' => 'int',
+                       'precision' => '4',
+                       'nullable' => true
+               ));
+
+                       
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_control_component_list','start_date',array(
+                       'type' => 'int',
+                       'precision' => '8',
+                       'nullable' => true
+               ));
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['controller']['currentver'] = 
'0.1.49';
+                       return 
$GLOBALS['setup_info']['controller']['currentver'];
+               }
+       }




reply via email to

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