fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8800]


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [8800]
Date: Wed, 08 Feb 2012 06:06:46 +0000

Revision: 8800
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8800
Author:   erikhl
Date:     2012-02-08 06:06:45 +0000 (Wed, 08 Feb 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.socheck_list.inc.php
    trunk/controller/inc/class.uicalendar.inc.php
    trunk/controller/inc/class.uicontrol.inc.php
    trunk/controller/js/yahoo/common.js
    trunk/controller/setup/phpgw_no.lang
    trunk/controller/templates/base/calendar/view_calendar_year.xsl
    trunk/controller/templates/base/css/base.css
    trunk/controller/templates/base/view_component_for_control_group.xsl

Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php     2012-02-07 19:04:49 UTC 
(rev 8799)
+++ trunk/controller/inc/class.socheck_list.inc.php     2012-02-08 06:06:45 UTC 
(rev 8800)
@@ -302,11 +302,15 @@
                }
        }
        
-       function get_agg_check_lists_for_location( $location_code, 
$from_date_ts, $to_date_ts ){
-               
+       function get_agg_check_lists_for_location( $location_code, 
$from_date_ts, $to_date_ts, $control_id = 0 ){
+                               
                $sql =  "SELECT c.id as c_id, title, start_date, end_date, 
cl.id as cl_id, c.repeat_type, c.repeat_interval, cl.deadline, count(ci.id) ";
                $sql .= "FROM controller_check_list cl, controller_control c, 
controller_check_item ci ";
                $sql .= "WHERE cl.location_code = '{$location_code}' ";
+               if($control_id > 0)
+               {
+                       $sql .= "AND c.id = {$control_id} ";
+               }
                $sql .= "AND c.repeat_type < 2 ";
                $sql .= "AND cl.control_id = c.id ";
                $sql .= "AND cl.id = ci.check_list_id ";
@@ -314,7 +318,7 @@
                $sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
                $sql .= "GROUP BY c.id, title, start_date, end_date, cl.id, 
cl.deadline, c.repeat_type, c.repeat_interval ";
                $sql .= "ORDER BY c.id";
-
+//var_dump($sql);
                $this->db->query($sql);
                
                $control_id = 0;
@@ -381,17 +385,26 @@
                return $control_array;
        }
        
-       function get_check_lists_for_location( $location_code, $from_date_ts, 
$to_date_ts, $repeat_type ){
+       function get_check_lists_for_location( $location_code, $from_date_ts, 
$to_date_ts, $repeat_type = null, $control_id = 0 ){
+               $use_location_inparam = false;
                $sql =  "SELECT c.id as c_id, title, description, start_date, 
end_date, control_area_id, c.location_code as c_location_code, repeat_type, 
repeat_interval, ";
                $sql .= "cl.id as cl_id, cl.status as cl_status, cl.comment as 
cl_comment, deadline, planned_date, completed_date, ";
                $sql .= "cl.component_id as cl_component_id, cl.location_code 
as cl_location_code, num_open_cases "; 
                $sql .= "FROM controller_control c ";
                $sql .= "LEFT JOIN controller_check_list cl on cl.control_id = 
c.id ";
                $sql .= "WHERE cl.location_code = '{$location_code}' ";
-               $sql .= "AND c.repeat_type = $repeat_type ";
+               if($control_id > 0)
+               {
+                       $sql .= "AND c.id={$control_id} ";
+                       $use_location_inparam = true;
+               }
+               if($repeat_type != null)
+               {
+                       $sql .= "AND c.repeat_type = $repeat_type ";
+               }
                $sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
                $sql .= "ORDER BY c.id;";
-
+//var_dump($sql);
                $this->db->query($sql);
                
                $control_id = 0;
@@ -412,7 +425,14 @@
                                
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
                                
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
                                
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
-                               
$control->set_location_code($this->unmarshal($this->db->f('c_location_code', 
true), 'string'));
+                               if($use_location_inparam)
+                               {
+                                       
$control->set_location_code($location_code);
+                               }
+                               else
+                               {
+                                       
$control->set_location_code($this->unmarshal($this->db->f('c_location_code', 
true), 'string'));
+                               }
                                
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
                                
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
                                                                

Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php       2012-02-07 19:04:49 UTC 
(rev 8799)
+++ trunk/controller/inc/class.uicalendar.inc.php       2012-02-08 06:06:45 UTC 
(rev 8800)
@@ -52,7 +52,8 @@
                (
                        'index' =>      true,
                        'view_calendar_for_month'                       =>      
true,
-                       'view_calendar_for_year'                        =>      
true
+                       'view_calendar_for_year'                        =>      
true,
+                       'view_calendar_for_locations'           =>  true
                );
 
                public function __construct()
@@ -232,5 +233,72 @@
                        self::add_javascript('controller', 'controller', 
'ajax.js');
                }
                
+               public function view_calendar_for_locations()
+               {
+                       $control_id = phpgw::get_var('control_id');
+                       $control = $this->so_control->get_single($control_id);
+                       
+                       if(is_numeric($control_id) & $control_id > 0)
+                       {
+                               $locations_for_control_array = 
$this->so_control->get_locations_for_control($control_id);
+                       }
+                       
+                       $year = date("Y");
+                       
+                       $year = intval($year);
+                                               
+                       $from_date_ts = strtotime("01/01/$year");
+                       $to_year = $year + 1;
+                       $to_date_ts = strtotime("01/01/$to_year");      
+
+                       $this->calendar_builder = new 
calendar_builder($from_date_ts, $to_date_ts);
+               
+                       $controls_calendar_array = array();
+                       foreach($locations_for_control_array as $location)
+                       {
+                               
$control->set_location_code($location["location_code"]);
+                               $controls_calendar_array = 
$this->calendar_builder->build_agg_calendar_array($controls_calendar_array, 
$control, $location["location_code"], $year);
+                               //_debug_array($controls_calendar_array);
+                               $control_check_list_array = 
$this->so->get_check_lists_for_location( $location["location_code"], 
$from_date_ts, $to_date_ts, $control->get_repeat_type(), $control->get_id() );
+                               //_debug_array($controls_check_list_array);
+                       }
+                       
+                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $controls_calendar_array, 
$control_check_list_array, 12, "view_months" );
+                       //_debug_array($controls_calendar_array);
+                       
+                       foreach($controls_calendar_array as &$inst)
+                       {       
+                               $control = &$inst['control'];
+                               //var_dump($control['location_code']);
+                               foreach($locations_for_control_array as $loc1)
+                               {
+                                       if($control["location_code"] == 
$loc1["location_code"])
+                                               $control["location_name"] = 
$loc1["loc1_name"];
+                               }
+                       }
+                       
+                       //_debug_array($controls_calendar_array);
+                       
+                       $heading_array = array("Jan", "Feb", "Mar", "Apr", 
"Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des");
+                       
+                       $data = array
+                       (
+                               'my_locations'                    => 
$locations_for_control_array,
+                               'view_location_code'      => null,
+                               'location_array'                  => 
$locations_for_control_array,
+                               'heading_array'                   => 
$heading_array,
+                               'controls_calendar_array' => 
$controls_calendar_array,
+                               'date_format'                     => 
$date_format,
+                               'period'                                  => 
$year,
+                               'year'                                    => 
$year,
+                               'show_location'                   => 'yes'
+                       );
+                       
+                       
self::render_template_xsl('calendar/view_calendar_year', $data);
+                       
+                       self::add_javascript('controller', 'controller', 
'jquery.js');
+                       self::add_javascript('controller', 'controller', 
'ajax.js');
+               }
+               
                public function query(){}
        }
\ No newline at end of file

Modified: trunk/controller/inc/class.uicontrol.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol.inc.php        2012-02-07 19:04:49 UTC 
(rev 8799)
+++ trunk/controller/inc/class.uicontrol.inc.php        2012-02-08 06:06:45 UTC 
(rev 8800)
@@ -218,11 +218,55 @@
                                                array(
                                                        'key' => 'link',
                                                        'hidden' => true
+                                               ),
+                                               array(
+                                                       'key' => 
'show_locations',
+                                                       'label' => '',
+                                                       'sortable' => false,
+                                                       'formatter' => 
'YAHOO.portico.formatGenericLink'
                                                )
                                        )
                                ),
                        );
-//_debug_array($data);
+/*     
+ *                                             ,
+                                               array(
+                                                       'key' => 'actions',
+                                                       'hidden' => true
+                                               ),
+                                               array(
+                                                       'key' => 'labels',
+                                                       'hidden' => true
+                                               ),
+                                               array(
+                                                       'key' => 'ajax',
+                                                       'hidden' => true
+                                               )               
+ * 
+ * $parameters3 = array
+                                       (
+                                               'parameter' => array
+                                               (
+                                                       array
+                                                       (
+                                                               'name'          
=> 'search_for',
+                                                               'source'        
=> 'location_code'
+                                                       ),
+                                               )
+                                       );
+                       $data['rowactions']['action'][] = array
+                                               (
+                                                       'my_name'               
        => 'view',
+                                                       'text'                  
=> lang('composites'),
+                                                       'action'                
=> $GLOBALS['phpgw']->link('/index.php',array
+                                                       (
+                                                               'menuaction'    
  => 'rental.uicomposite.index',
+                                                               'search_type'   
  => 'location_id',
+                                                               'populate_form' 
  => 'yes'
+                                                       )),
+                                                       'parameters'    => 
$parameters3
+                                               );*/
+//_debug_array($data); 
 
                        self::render_template_xsl('datatable', $data);
                }
@@ -635,12 +679,22 @@
                        $value['ajax'] = array();
                        $value['actions'] = array();
                        $value['labels'] = array();
-                       $value['parameters'] = array();
+                       //$value['parameters'] = 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['parameters'][] = "control_id";
+                       
+                       $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['parameters'][] = "control_id";
+                       
+                       $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['parameters'][] = "control_id";
+                       //$value['parameters'][] = "control_id";
                }
                
                public function register_control_to_location()
@@ -710,6 +764,12 @@
                        
                        foreach($result_objects as $control_obj)
                        {
+/*                             $obj_serialized = $control_obj->serialize();
+                               $obj_serialized['show_locations'] = array(
+                                       'href' => 
html_entity_decode(self::link(array('menuaction' => 
'controller.uicontrol.view_locations_for_control', 'id' => 
$result['location_id']))),
+                                       'label' => 
lang('show_controls_for_location')
+                               );
+                               $results['results'][] = $obj_serialized;*/
                                $results['results'][] = 
$control_obj->serialize();      
                        }
                        
@@ -718,9 +778,16 @@
                        $results['sort'] = $params['sort'];
                        $results['dir'] = $params['dir'];
 
+                       //array_walk($results["results"], array($this, 
"add_actions"), array($type));
                        array_walk($results["results"], array($this, 
"_add_links"), "controller.uicontrol.view_control_details");
+                       
+                       foreach($results["results"] as &$res) {
+                               $res['show_locations'] = array(
+                                       'href' => self::link(array('menuaction' 
=> 'controller.uicalendar.view_calendar_for_locations', 'control_id' => 
$res['id'])),
+                                       'label' => 
lang('show_controls_for_location'),
+                               );
+                       }
 
                        return $this->yui_results($results);
                }
-
        }

Modified: trunk/controller/js/yahoo/common.js
===================================================================
--- trunk/controller/js/yahoo/common.js 2012-02-07 19:04:49 UTC (rev 8799)
+++ trunk/controller/js/yahoo/common.js 2012-02-08 06:06:45 UTC (rev 8800)
@@ -118,10 +118,21 @@
        elCell.innerHTML = '<a href="' + link + '">' + name + '</a>'; 
 };
 
+YAHOO.portico.formatGenericLink = function(elCell, oRecord, oColumn, oData)
+{
+       var data = oRecord.getData(oColumn.key);
+       //console.log(data['href']);
+       var link = data['href'];
+       var name = data['label'];
+       
+       elCell.innerHTML = '<a href="' + link + '">' + name + '</a>';
+};
+
+/*
 YAHOO.portico.formatGenericLink = function() {
        var links = [];
        var nOfLinks = arguments.length;
-       
+
        for (var i=0; i < nOfLinks; i++) { links[i] = arguments[i]; }
        
        return function(elCell, oRecord, oColumn, oData)
@@ -150,7 +161,7 @@
                elCell.innerHTML = linksHtml;
        };
 };
-
+*/
 YAHOO.portico.autocompleteHelper = function(url, field, hidden, container, 
label_attr) {
        label_attr = label_attr || 'name';
        var myDataSource = new YAHOO.util.DataSource(url);

Modified: trunk/controller/setup/phpgw_no.lang
===================================================================
--- trunk/controller/setup/phpgw_no.lang        2012-02-07 19:04:49 UTC (rev 
8799)
+++ trunk/controller/setup/phpgw_no.lang        2012-02-08 06:06:45 UTC (rev 
8800)
@@ -314,4 +314,5 @@
 select value   controller      no      Velg
 component_for_control_group    controller      no      Utstyr tilknyttet 
kontrollgrupper
 View_component_for_control_group       controller      no      Vis knytning 
mot utstyr
-Add_component_for_control_group        controller      no      Legg til 
knytning mot utstyr
\ No newline at end of file
+Add_component_for_control_group        controller      no      Legg til 
knytning mot utstyr
+show_controls_for_location     controller      no      Vis lokasjoner
\ No newline at end of file

Modified: trunk/controller/templates/base/calendar/view_calendar_year.xsl
===================================================================
--- trunk/controller/templates/base/calendar/view_calendar_year.xsl     
2012-02-07 19:04:49 UTC (rev 8799)
+++ trunk/controller/templates/base/calendar/view_calendar_year.xsl     
2012-02-08 06:06:45 UTC (rev 8800)
@@ -49,12 +49,13 @@
                
                <ul class="calendar">
                                <li class="heading">
-                                       <div class="id">ID</div>
+                                       <xsl:if test="show_location">
+                                       <div class="title">Lokasjon</div>
+                                       </xsl:if>
                                        <div class="title">Tittel</div>
                                        <div class="date">Start dato</div>
                                        <div class="date">Slutt dato</div>
                                        <div 
class="frequency">Frekvenstype</div>
-                                       <div 
class="frequency">Frekvensintervall</div>
                                        <div class="months">
                                        <xsl:for-each select="heading_array">
                                                <div>
@@ -81,9 +82,11 @@
                                <xsl:for-each select="controls_calendar_array">
                                        <xsl:variable 
name="control_id"><xsl:value-of select="control/id"/></xsl:variable>
                                        <li>
-                                       <div class="id">
-                                               <xsl:value-of 
select="control/id"/>
-                                               </div>
+                                               <xsl:if test="//show_location">
+                                                       <div class="title">
+                                                               <xsl:value-of 
select="control/location_name"/>
+                                                       </div>
+                                               </xsl:if>
                                                <div class="title">
                                                <xsl:value-of 
select="control/title"/>
                                                </div>
@@ -102,9 +105,6 @@
                                                </div>
                                                <div class="frequency">
                                                <xsl:value-of 
select="control/repeat_type"/>
-                                               </div>
-                                               <div class="frequency">
-                                               <xsl:value-of 
select="control/repeat_interval"/>
                                                </div>                          
                        
                                                <div class="months">
                                                <xsl:for-each 
select="calendar_array">

Modified: trunk/controller/templates/base/css/base.css
===================================================================
--- trunk/controller/templates/base/css/base.css        2012-02-07 19:04:49 UTC 
(rev 8799)
+++ trunk/controller/templates/base/css/base.css        2012-02-08 06:06:45 UTC 
(rev 8800)
@@ -851,6 +851,9 @@
 ul.calendar div.title, ul.calendar.info div.title {
        width: 200px;
 }
+ul.calendar div.title {
+       width: 150px;
+}
 ul.calendar div.id, ul.calendar.info div.id {
        width: 50px;
 }

Modified: trunk/controller/templates/base/view_component_for_control_group.xsl
===================================================================
--- trunk/controller/templates/base/view_component_for_control_group.xsl        
2012-02-07 19:04:49 UTC (rev 8799)
+++ trunk/controller/templates/base/view_component_for_control_group.xsl        
2012-02-08 06:06:45 UTC (rev 8800)
@@ -39,7 +39,7 @@
                                 
                                 <form id="loc_form" action="" method="GET">
                        
-                                       <select id="control_group_id" 
name="control_group_id">
+                                       <select id="control_group_id" 
name="control_group_id" style="width: 250px;">
                                        <xsl:choose>
                                                <xsl:when 
test="control_group_array/child::node()">
                                                        <xsl:for-each 
select="control_group_array">




reply via email to

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