fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9568] Added display of components for control


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [9568] Added display of components for control
Date: Wed, 13 Jun 2012 08:10:41 +0000

Revision: 9568
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9568
Author:   erikhl
Date:     2012-06-13 08:10:41 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
Added display of components for control

Modified Paths:
--------------
    trunk/controller/inc/class.menu.inc.php
    trunk/controller/inc/class.socheck_list.inc.php
    trunk/controller/inc/class.uicalendar.inc.php
    trunk/controller/inc/class.uicontrol_location.inc.php
    
trunk/controller/templates/base/calendar/view_calendar_year_for_locations.xsl

Modified: trunk/controller/inc/class.menu.inc.php
===================================================================
--- trunk/controller/inc/class.menu.inc.php     2012-06-13 06:39:44 UTC (rev 
9567)
+++ trunk/controller/inc/class.menu.inc.php     2012-06-13 08:10:41 UTC (rev 
9568)
@@ -64,12 +64,12 @@
                                                                                
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'controller.uicontrol_location.index') ),
                                                                                
                'image' => array('property', 'location_1')
                                                                                
        ),
-/*                                                                             
        'component_for_check_list' => array
+                                                                               
        'component_for_check_list' => array
                                                                                
        (
                                                                                
                'text'  => lang('component'),
-                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'controller.uicheck_list_for_component.index') ),
+                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 
'controller.uicontrol_location.register_control_to_component') ),
                                                                                
                'image' => array('property', 'entity_1')
-                                                                               
        )*/
+                                                                               
        )
                                                                                
)
                                        ),
 /*                                     'location_for_check_list' => array

Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php     2012-06-13 06:39:44 UTC 
(rev 9567)
+++ trunk/controller/inc/class.socheck_list.inc.php     2012-06-13 08:10:41 UTC 
(rev 9568)
@@ -319,11 +319,18 @@
                }       
        }
        
-       function get_num_open_cases_for_control( $control_id, $location_code, 
$from_date_ts, $to_date_ts ){
+       function get_num_open_cases_for_control( $control_id, $location_code, 
$from_date_ts, $to_date_ts, $component ){
                
                $sql =  "SELECT c.id as c_id, sum(cl.num_open_cases) as count ";
                $sql .= "FROM controller_check_list cl, controller_control c ";
-               $sql .= "WHERE cl.location_code = '{$location_code}' ";
+               if($component)
+               {
+                   $sql .= "WHERE cl.component_id = {$location_code} ";
+               }
+               else
+               {
+                   $sql .= "WHERE cl.location_code = '{$location_code}' ";
+               }
                $sql .= "AND c.id = $control_id ";
                $sql .= "AND cl.control_id = c.id ";
                $sql .= "AND cl.deadline >= $from_date_ts AND $to_date_ts > 
cl.deadline ";
@@ -506,6 +513,40 @@
                return array( "location_code" => $location_code, 
"check_lists_array" => $check_lists_array);
        }
        
+// Fetches check lists for component and control id
+       function get_check_lists_for_control_and_component( $control_id, 
$component_id, $from_date_ts, $to_date_ts, $repeat_type = null ){
+               $sql =  "SELECT 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, num_pending_cases "; 
+               $sql .= "FROM controller_check_list cl ";
+               $sql .= "LEFT JOIN controller_control c on cl.control_id = c.id 
";
+               $sql .= "WHERE cl.control_id = {$control_id} ";
+               $sql .= "AND cl.component_id = {$component_id} ";
+               
+               if( $repeat_type != null )
+                       $sql .= "AND c.repeat_type = $repeat_type ";
+               
+               $sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
+               
+               $this->db->query($sql);
+               
+               while ($this->db->next_record()) {
+                       $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
+                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true), 
'int'));
+                       
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
+                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));
+                       
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date', 
true), 'int'));
+                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date', 
true), 'int')); 
+                       
$check_list->set_component_id($this->unmarshal($this->db->f('cl_component_id', 
true), 'int'));
+                       
$check_list->set_location_code($this->unmarshal($this->db->f('cl_location_code',
 true), 'string'));
+                       
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases', 
true), 'int'));
+                       
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases',
 true), 'int'));
+                       
+                       $check_lists_array[] = $check_list;
+               }
+               
+               return array( "location_code" => $location_code, 
"check_lists_array" => $check_lists_array);
+       }
+       
        function get_check_list_for_date($control_id, $current_date){
                $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, ";

Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php       2012-06-13 06:39:44 UTC 
(rev 9567)
+++ trunk/controller/inc/class.uicalendar.inc.php       2012-06-13 08:10:41 UTC 
(rev 9568)
@@ -309,6 +309,7 @@
                        if(is_numeric($control_id) & $control_id > 0)
                        {
                                $locations_for_control_array = 
$this->so_control->get_locations_for_control($control_id);
+                               $components_for_control_array = 
$this->so_control->get_components_for_control($control_id);
                        }
                        
                        if(empty($year)){
@@ -332,6 +333,17 @@
                                        $calendar_array = 
$year_calendar->build_agg_calendar($agg_open_cases_pr_month_array);
                                        $locations_with_calendar_array[] = 
array("location" => $location, "calendar_array" => $calendar_array);
                                }
+                               
+                           foreach($components_for_control_array as 
$component){
+                                       $curr_component_id = 
$component['component_id'];
+                                       
+                                       // Loops through controls in 
controls_for_location_array and populates aggregate open cases pr month array.
+                                       $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($control, $curr_component_id, $year, 
true);
+                                       
+                                       $year_calendar = new 
year_calendar($control, $year);
+                                       $calendar_array = 
$year_calendar->build_agg_calendar($agg_open_cases_pr_month_array);
+                                       $components_with_calendar_array[] = 
array("component" => $component, "calendar_array" => $calendar_array);
+                               }
                        }else if($control->get_repeat_type() > 1){
                                foreach($locations_for_control_array as 
$location){
                                        $curr_location_code = 
$location['location_code'];
@@ -346,6 +358,20 @@
 
                                        $locations_with_calendar_array[] = 
array("location" => $location, "calendar_array" => $calendar_array);
                                }
+                               
+                           foreach($components_for_control_array as 
$component){
+                                       $curr_component_id = 
$component['component_id'];
+                                       
+                                       $repeat_type = 
$control->get_repeat_type();
+                                       $component_with_check_lists = 
$this->so->get_check_lists_for_control_and_component($control_id, 
$curr_component_id, $from_date_ts, $to_date_ts, $repeat_type);  
+                                       
+                                       $check_lists_array = 
$component_with_check_lists["check_lists_array"];
+                                       
+                                       $year_calendar = new 
year_calendar($control, $year);
+                                       $calendar_array = 
$year_calendar->build_calendar( $check_lists_array );
+
+                                       $components_with_calendar_array[] = 
array("component" => $component, "calendar_array" => $calendar_array);
+                               }
                        }
                        
                        $criteria = array
@@ -365,6 +391,7 @@
                                'control'                                       
                                        => $control->toArray(),
                                'heading_array'                                 
                => year_calendar::get_heading_array(),
                                'locations_with_calendar_array' => 
$locations_with_calendar_array,
+                           'components_with_calendar_array' => 
$components_with_calendar_array,
                                'date_format'                                   
                        => $date_format,
                                'current_year'                                  
        => $year,
                        );
@@ -386,6 +413,7 @@
                        if(is_numeric($control_id) & $control_id > 0)
                        {
                                $locations_for_control_array = 
$this->so_control->get_locations_for_control($control_id);
+                               $components_for_control_array = 
$this->so_control->get_components_for_control($control_id);
                        }
 
                        if(empty($year)){
@@ -462,7 +490,7 @@
                }
                
                // Generates array of aggregated number of open cases for each 
month in time period 
-               function build_agg_open_cases_pr_month_array($control, 
$location_code, $year){
+               function build_agg_open_cases_pr_month_array($control, 
$location_code, $year, $component=false ){
                                
                        // Checks if control starts in the year that is 
displayed 
                        if( date("Y", $control->get_start_date()) == $year ){
@@ -496,7 +524,7 @@
                                $num_open_cases_for_control_array = array();
                                
                                // Fetches aggregate value for open cases in a 
month from db    
-                               $num_open_cases_for_control_array = 
$this->so_check_list->get_num_open_cases_for_control( $control->get_id(), 
$location_code, $month_start_ts, $month_end_ts ); 
+                               $num_open_cases_for_control_array = 
$this->so_check_list->get_num_open_cases_for_control( $control->get_id(), 
$location_code, $month_start_ts, $month_end_ts, $component );     
                                
                                // If there is a aggregated value for the 
month, add aggregated status object to agg_open_cases_pr_month_array
                                if( !empty($num_open_cases_for_control_array) ){

Modified: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php       2012-06-13 
06:39:44 UTC (rev 9567)
+++ trunk/controller/inc/class.uicontrol_location.inc.php       2012-06-13 
08:10:41 UTC (rev 9568)
@@ -563,6 +563,7 @@
 
                function register_control_to_component()
                {
+                   
self::set_active_menu('controller::control::component_for_check_list');
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
                        $receipt = array();
 
@@ -634,7 +635,7 @@
 
                        $tabs = array
                        ( 
-                               array
+/*                             array
                                (
                                        'label' => 
lang('View_locations_for_control'),
                                        'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.index'))
@@ -643,7 +644,7 @@
                                (
                                        'label' => 
lang('Add_locations_for_control'),
                                        'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.register_control_to_location'))
-                               ),
+                               ),*/
                                array
                                (
                                        'label' => lang('add components for 
control')

Modified: 
trunk/controller/templates/base/calendar/view_calendar_year_for_locations.xsl
===================================================================
--- 
trunk/controller/templates/base/calendar/view_calendar_year_for_locations.xsl   
    2012-06-13 06:39:44 UTC (rev 9567)
+++ 
trunk/controller/templates/base/calendar/view_calendar_year_for_locations.xsl   
    2012-06-13 08:10:41 UTC (rev 9568)
@@ -83,6 +83,70 @@
                </xsl:choose>
        </table>
        </div>
+               <div id="cal_wrp">
+                       <table id="calendar" class="year">
+                               <tr>
+                                       <th>
+                                               <span 
class="location_code">Lokasjon</span>
+                                       </th>
+                                       <th>
+                                               <span 
class="location_name">Komponenttype</span>
+                                       </th>
+                                       <xsl:for-each select="heading_array">
+                                               <th>
+                                                       <a>
+                                                               <xsl:attribute 
name="href">
+                                                                       
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_month_for_locations</xsl:text>
+                                                                       
<xsl:text>&amp;year=</xsl:text>
+                                                                       
<xsl:value-of select="current_year"/>
+                                                                       
<xsl:text>&amp;month=</xsl:text>
+                                                                       
<xsl:number/>
+                                                                       
<xsl:text>&amp;control_id=</xsl:text>
+                                                                       
<xsl:value-of select="//control/id"/>
+                                                               </xsl:attribute>
+                                                               
+                                                               <xsl:variable 
name="month_str">short_month <xsl:value-of select="."/> 
capitalized</xsl:variable>
+                                                               <xsl:value-of 
select="php:function('lang', $month_str)" />
+                                                       </a>                    
        
+                                               </th>
+                                       </xsl:for-each>
+                               </tr>
+                       
+                       <xsl:choose>
+                               <xsl:when 
test="components_with_calendar_array/child::node()">
+                               
+                               <xsl:for-each 
select="components_with_calendar_array">
+                                       <tr>                            
+                                               <xsl:choose>
+                                               <xsl:when test="(position() mod 
2) != 1">
+                                                   <xsl:attribute 
name="class">odd</xsl:attribute>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                   <xsl:attribute 
name="class">even</xsl:attribute>
+                                               </xsl:otherwise>
+                                           </xsl:choose>
+                                   
+                                               <td>
+                                                       <xsl:value-of 
select="component/component_location"/>
+                                               </td>
+                                               <td class="location_name">
+                                                       <xsl:value-of 
select="component/component_description"/>
+                                               </td>
+                                                       
+                                               <xsl:for-each 
select="calendar_array">
+                                                       <xsl:call-template 
name="check_list_status_checker" >
+                                                               <xsl:with-param 
name="location_code"><xsl:value-of select="//location"/></xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:for-each>
+                                       </tr>   
+                               </xsl:for-each> 
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <tr class="cal_info_msg"><td colspan="3">Ingen 
sjekklister for komponent i angitt periode</td></tr>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </table>
+       </div>
 </div>
 </div>
 </xsl:template>




reply via email to

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