fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10756] Changed planned controls


From: Torstein
Subject: [Fmsystem-commits] [10756] Changed planned controls
Date: Wed, 06 Feb 2013 06:56:25 +0000

Revision: 10756
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10756
Author:   vator
Date:     2013-02-06 06:56:25 +0000 (Wed, 06 Feb 2013)
Log Message:
-----------
Changed planned controls

Modified Paths:
--------------
    trunk/controller/inc/hook_home.inc.php

Modified: trunk/controller/inc/hook_home.inc.php
===================================================================
--- trunk/controller/inc/hook_home.inc.php      2013-02-06 06:54:05 UTC (rev 
10755)
+++ trunk/controller/inc/hook_home.inc.php      2013-02-06 06:56:25 UTC (rev 
10756)
@@ -50,11 +50,10 @@
        $styling  = "\n".'<!-- BEGIN checklist info -->'."\n ";
        $styling .= "<style>";
        $styling .= " .home-box { background: none repeat scroll 0 0 #EDF5FF; 
border-color: #DBE5EF; border-radius: 4px; margin: 5px 20px 20px;}";
-       $styling .= " .home-box .home_portal { margin: 0;border: 1px solid 
#DEEAF8;}";
-
+       $styling .= " .home-box .home_portal { margin: 0;border: 1px solid 
#EBF3FC;}";
        $styling .= " .home_portal { margin:20px 20px 0 10px; }"; 
        $styling .= " .home_portal a { color:#0066CC;text-decoration: 
none;text-transform: uppercase;}"; 
-       $styling .= " .home_portal h2 { overflow:hidden;clear:left;font-size: 
13px;font-weight: bold;text-transform:uppercase; background: #DEEAF8; margin: 
0; padding: 2px 10px; color: #1C3C6F;}";
+       $styling .= " .home_portal h2 { overflow:hidden;clear:left;font-size: 
13px;font-weight: bold;text-transform:uppercase; background: #D0DEF4; margin: 
0; padding: 2px 10px; color: #1C3C6F;}";
        $styling .= " .home_portal h2 div{ display:block;float:left;cursor: 
pointer;vertical-align: middle;}";
        $styling .= " .home_portal .title { width:300px;margin:0 20px 0 0;}"; 
        $styling .= " .home_portal .control-area { width:200px;}";
@@ -69,7 +68,7 @@
        
        $styling .= " h2.heading { font-size: 22px; font-weight: normal;margin: 
0 0 0 20px;}";
        
-       $styling .= " h4.expand_trigger { clear:both;overflow:hidden;font-size: 
12px;color:#031647;background: #D0DEF4;padding:2px 4px;margin:0; }";
+       $styling .= " h4.expand_trigger { clear:both;overflow:hidden;font-size: 
12px;color:#031647;background: #DEEAF8;padding:2px 4px;margin:0; }";
        $styling .= " h4.expand_trigger img { 
float:left;vertical-align:middle;margin-right:3px; }";
        $styling .= " h4.expand_trigger span { 
float:left;display:block;vertical-align:middle; }";
        $styling .= " h4.expand_trigger span.deadline { width:805px; }";
@@ -125,55 +124,145 @@
        
        $my_locations = array_merge($my_properties, $my_buildings);
        
+  
+  /* =======================================  PLANNED CONTROLS FOR CURRENT 
USER  ================================= */
        
+       $my_planned_controls_HTML = "<div class='home_portal'><h2><div 
class='date heading'>Fristdato</div><div class='control heading'>Tittel på 
kontroll</div><div class='title heading'>Lokasjonsnavn</div><div 
class='control-area heading'>Kontrollområde</div></h2>";
        
-       /* =======================================  UNDONE ASSIGNED CONTROLS 
FOR CURRENT USER  ================================= */
-       
-       $my_controls = array();
+       // Todays date
+       $from_date_ts =  mktime(0, 0, 0, date("n"), date("j"), date("Y") );
+       // One month ahead in time
+  $to_date_ts = mktime(0, 0, 0, date("n")+1, date("j"), date("Y") );
+         
+  // fetch all repeat types
        $repeat_type = null;
+  
+  // Fetches controls current user is responsible for 1 month ahead
+  $my_controls = array();
+  $my_controls = get_my_controls($my_locations, $from_date_ts, $to_date_ts, 
$repeat_type);
        
-       // from date is set to 3 months back in time
-       $from_date_ts =  mktime(0, 0, 0, date("n")-3, date("j"), date("Y") );
-       $to_date_ts =  mktime(0, 0, 0, date("n"), date("j"), date("Y") );
-       
-       // Fetches controls current user is responsible for 3 months back in 
time
-       foreach($my_locations as $location)
-       {
-               $controls = array();
-               $components_with_controls_array = array();
-               $location_code = $location["location_code"];
+  $my_planned_controls = array();
+  
+       // Generates an array with planned controls
+       foreach($my_controls as $container_arr)
+       {       
+               $location_code = $container_arr[0];
+               $control_type = $container_arr[1];
+               $controls = $container_arr[2];
+                               
+               foreach($controls as $my_control)
+               {
+                       if($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_DAY)
+                       {
+                               // Daily control: To_date assigned to one week 
ahead in time if repeat type is daily
+                               $to_date_ts =  mktime(0, 0, 0, date("n"), 
date("j")+7, date("Y") );
+                       }
+                       else if(($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_WEEK) 
+                                               | ($my_control["repeat_type"] 
== controller_control::REPEAT_TYPE_MONTH) 
+                                               | ($my_control["repeat_type"] 
== controller_control::REPEAT_TYPE_YEAR))
+                       {
+                               // Daily, monthly yearly control: to_date in 
one month
+                               $to_date_ts =  mktime(0, 0, 0, date("n")+1, 
date("j"), date("Y") ); 
+                       }
+               
+                       if($control_type == "location")
+                       {
+        $check_list_array = 
$so_check_list->get_check_lists_for_control_and_location( $my_control['id'], 
$location_code, $from_date_ts, $to_date_ts, $repeat_type = null);
+        
+        foreach($check_list_array as $check_list)
+        {
+          $planned_date_for_check_list = $check_list->get_planned_date();
 
-               $controls_at_location = $so_control->get_controls_by_location( 
$location_code, $from_date_ts, $to_date_ts, $repeat_type, "return_array", 
$location["role_id"] );
-                                   
-               $level = count(explode('-', $location_code));
+          if($planned_date_for_check_list > 0)
+          {
+            $my_planned_controls[$planned_date_for_check_list][] = array( 
$check_list->get_deadline(), $my_control, "location", $location_code );
+          }
+        }
+                       }
+                       else if($control_type == "component")
+                       {
+                               $component = $container_arr[3];
+                               $check_list_array = 
$so_check_list->get_check_lists_for_control_and_component( $my_control['id'], 
$component['location_id'], $component['id'], $from_date_ts, $to_date_ts, 
$repeat_type = null );
+        
+        foreach($check_list_array as $check_list)
+        {
+          $planned_date_for_check_list = $check_list->get_planned_date();
 
-               if($level == 1){
-                       // Fetches all controls for the components for a 
location within time period
-                       $filter = "bim_item.location_code = '$location_code' ";
-                       $components_with_controls_array = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);      
-               }else
-               {
-                       // Fetches all controls for the components for a 
location within time period
-                       $filter = "bim_item.location_code LIKE 
'$location_code%' ";
-                       $components_with_controls_array = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);      
-               }
+          if($planned_date_for_check_list > 0)
+          {
+            $my_planned_controls[$planned_date_for_check_list][] = 
array($check_list->get_deadline(), $my_control, "component", 
$component['location_id'], $component['id'] );
+          }
+        }
+                       }
+         }
+  }
 
-               if( count($controls_at_location) > 0 )
+       $my_planned_controls_HTML .= "<ul style='overflow:hidden;'>";
+       
+       foreach($my_planned_controls as $planned_date_ts => 
$planned_controls_on_date)
+       {  
+               if(count( $planned_controls_on_date) > 1 )
                {
-                       // Saves location code, location type and an array 
containing controls at locations
-                       $my_controls[] = array( $location_code, 'location', 
$controls_at_location );
-               }
+                       $my_planned_controls_HTML .= "<li>";
+                       $my_planned_controls_HTML .= "<a href='#'><h4 
class='expand_trigger'><img height='12' src='controller/images/arrow_right.png' 
/><span class='deadline'>Frist: "  . date($dateformat, $date_ts) .  
"</span><span class='num_controls'>Antall kontroller: " .  
count($planned_controls_on_date) . "</span></h4></a>";
+      $my_planned_controls_HTML .= "</li><ul class='expand_list'>";
+    }
+                       
+               foreach($planned_controls_on_date as $my_planned_control)
+               {
+                       $deadline_ts = $my_planned_control[0];
+                       $my_control = $my_planned_control[1];
+                       
+      $control_area_name = get_control_area_name( 
$my_control["control_area_id"] );
+                       
+                       $date_str = date($dateformat, $deadline_ts);
+                       
+      $check_list_id = $my_planned_control[2];
+      $location_code = $my_planned_control[3];
 
-               if( count($components_with_controls_array) > 0 )
-               {
-                       foreach($components_with_controls_array as $component)
-                       {
-                               // Saves location code, location type, an array 
containing controls at locations and component object 
-                               $my_controls[] = array( $location_code, 
'component', $component['controls_array'], $component );
-                       }
-               }
+      if(!isset($location_array[$location_code]) || 
!$location_array[$location_code])
+      {
+        $location_array[$location_code] = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
+      }
+      $location_name = $location_array[$location_code]["loc1_name"];
+
+      if(count( $planned_controls_on_date ) > 1 )
+      {
+        $link = "";
+        $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
+
+        $my_planned_controls_HTML .= "<li><a href='$link'><div 
class='date'>Fristdato {$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+      }
+      else
+      {
+        $link = "";
+        $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
+
+        $my_planned_controls_HTML .= "<li><a href='$link'><div 
class='date'>Fristdato {$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+      }
+    }
        }
+               
+       if(count( $planned_controls_on_date ) > 1 )
+       {
+               $my_planned_controls_HTML .= "</li></ul>";
+       }
        
+       echo "\n".'<!-- BEGIN checklist info -->'."\n <h2 class='heading'>Mine 
planlagte kontroller</h2><div class='home-box'>" . $my_planned_controls_HTML . 
"</div></div>\n".'<!-- END checklist info -->'."\n";
+
+       
+       /* =======================================  UNDONE ASSIGNED CONTROLS 
FOR CURRENT USER  ================================= */
+       
+  // from date is set to 3 months back in time
+       $from_date_ts =  mktime(0, 0, 0, date("n")-3, date("j"), date("Y") );
+       $to_date_ts =  mktime(0, 0, 0, date("n"), date("j"), date("Y") );
+  
+  // fetch all repeat types
+       $repeat_type = null;
+  
+  // Fetches controls current user is responsible for 3 months back in time
+  $my_controls = get_my_controls($my_locations, $from_date_ts, $to_date_ts, 
$repeat_type);
+  
        $my_undone_controls = array();
 
        // Generates an array containing undone controls
@@ -224,7 +313,6 @@
                                        
                                        $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, null, $component['location_id'], $component['id'], 
"component"  );
                                }
-
                                $control_id = $my_control['id'];
                                
                                if($check_list == null & $control_type == 
"location")
@@ -236,7 +324,7 @@
                                        $component = $container_arr[3];
                                        $my_undone_controls[$deadline_ts][]= 
array("add", $deadline_ts, $my_control, "component", $component['location_id'], 
$component['id'] );
                                }
-                               else if($check_list->get_status() == 
controller_check_list::STATUS_NOT_DONE)
+                               else if( ($check_list->get_status() == 
controller_check_list::STATUS_NOT_DONE) || ($check_list->get_status() == 
controller_check_list::STATUS_CANCELED) ) 
                                {
                                        $my_undone_controls[$deadline_ts][] = 
array("edit", $deadline_ts, $my_control, $check_list->get_id(), $location_code 
);
                                }
@@ -267,18 +355,8 @@
                        $deadline_ts = $my_undone_control[1];
                        $my_control = $my_undone_control[2];
                        
-                       $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
-                       $cats->supress_info     = true;
-                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => '','globals' 
=> true,'use_acl' => $this->_category_acl));
-                       
-                       foreach($control_areas['cat_list'] as $area)
-                       {
-                               if($area['cat_id'] == 
$my_control["control_area_id"])
-                               {
-                                       $control_area_name = $area['name'];
-                               }
-                       }
-                       
+      $control_area_name = get_control_area_name( 
$my_control["control_area_id"] );
+                       
                        $date_str = date($dateformat, $deadline_ts);
                        
                        if($check_list_status == "add")
@@ -377,173 +455,24 @@
        
        $my_undone_controls_HTML .= "</div>"; // home_portal
        
-       echo "\n".'<!-- BEGIN checklist info -->'."\n <h2 class='heading'>Mine 
glemte kontroller</h2><div 
class='home-box'>".$my_undone_controls_HTML."</div>\n".'<!-- END checklist info 
-->'."\n";
+       echo "\n".'<!-- BEGIN checklist info -->'."\n <h2 class='heading'>Mine 
ugjorte kontroller</h2><div 
class='home-box'>".$my_undone_controls_HTML."</div>\n".'<!-- END checklist info 
-->'."\n";
 
        
-       /* =======================================  PLANNED CONTROLS FOR 
CURRENT USER  ================================= */
-
-       $repeat_type = null;
-       $controls_for_location_array = array();
-       foreach($my_locations as $location)
-       {
-
-               $controls = array();
-               $controls_loc = 
$so_control->get_controls_by_location($location["location_code"], 
$from_date_ts, $to_date_ts, $repeat_type, "return_array", $location["role_id"] 
);
-               $controls_comp = 
$so_control->get_controls_for_components_by_location($location["location_code"],
 $from_date_ts, $to_date_ts, $repeat_type, $location["role_id"] );
-           
-               foreach($controls_loc as $cl)
-               {
-                       $controls[] = $cl;
-               }
-           
-               foreach($controls_comp as $cc)
-         {
-                       $controls[] = $cc;
-               }
-           
-               $controls_for_location_array[] = 
array($location["location_code"], $controls);
-       }
-
-       $controls_array = array();
-       $control_dates = array();
-       foreach($controls_for_location_array as $control_arr)
-       {
-               $current_location = $control_arr[0];
-               $controls_for_loc_array = $control_arr[1];
-               foreach($controls_for_loc_array as $control)
-               {
-                       $date_generator = new 
date_generator($control["start_date"], $control["end_date"], $from_date_ts, 
$to_date_ts, $control["repeat_type"], $control["repeat_interval"]);
-                       $controls_array[] = array($current_location, $control, 
$date_generator->get_dates());
-               }
-       }
-
-       $portalbox1 = CreateObject('phpgwapi.listbox', array
-       (
-               'title'         => "<div class='date 
heading'>Fristdato</div><div class='control heading'>Tittel på 
kontroll</div><div class='title heading'>Lokasjonsnavn</div><div 
class='control-area heading'>Kontrollområde</div>",
-               'primary'       => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
-               'secondary'     => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
-               'tertiary'      => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
-               'width' => '100%',
-               'outerborderwidth'      => '0',
-               'header_background_image'       => 
$GLOBALS['phpgw']->common->image('phpgwapi','bg_filler', '.png', False)
-       ));
-
-       $category_name = array(); // caching
-       
-       $cats   = CreateObject('phpgwapi.categories', -1, 'controller', 
'.control');
-       $cats->supress_info     = true;
-       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => '','globals' 
=> true,'use_acl' => $this->_category_acl));
-
-       $portalbox1->data = array();
-       $portalbox1_data = array();
-       foreach ($controls_array as $control_instance)
-       {
-               $curr_location = $control_instance[0];
-               $current_control = $control_instance[1];
-               $check_lists = 
$so_check_list->get_planned_check_lists_for_control($current_control["id"], 
$curr_location, $current_control['location_id'], 
$current_control['component_id']);
-
-               if(!isset($location_array[$curr_location]) || 
!$location_array[$curr_location])
-               {
-                       $location_array[$curr_location] = 
execMethod('property.bolocation.read_single', array('location_code' => 
$curr_location));
-               }
-               $location_name = $location_array[$curr_location]["loc1_name"];
-
-               if(isset($current_control['component_id']) && 
$current_control['component_id'])
-               {
-//_debug_array($current_control);
-                       
if(!isset($component_short_desc[$current_control['location_id']][$current_control['component_id']]))
-                       {
-                               
$component_short_desc[$current_control['location_id']][$current_control['component_id']]
 = execMethod('property.soentity.get_short_description', array('location_id' => 
$current_control['location_id'], 'id' => $current_control['component_id']));
-                       }
-                       
-                       
if($component_short_desc[$current_control['location_id']][$current_control['component_id']])
-                       {
-                               $location_name .= 
"::{$component_short_desc[$current_control['location_id']][$current_control['component_id']]}";
-                       }
-               }
-
-               foreach($control_areas['cat_list'] as $area)
-               {
-                       if($area['cat_id'] == 
$current_control["control_area_id"])
-                       {
-                               $control_area_name = $area['name'];
-                       }
-               }
-               foreach($check_lists as $check_list)
-               {
-                       $next_date = "Planlagt: " . date($dateformat, 
$check_list->get_planned_date());
-                       $portalbox1_data[] = array(
-                               $check_list->get_planned_date(), array(
-                                       'text' => "<div 
class='date'>{$next_date}</div><div 
class='control'>{$current_control["title"]}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div>",
-                                       'link' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => 
$check_list->get_id()))
-                       ));
-               }
-       }
-       //sort data by planned date for check list
-       sort($portalbox1_data);
-       //$limit = 5;
-       $tmp = 0;
-       foreach($portalbox1_data as $check_list_dates)
-       {
-               if($tmp < $limit_no_of_planned)
-               {
-                       $portalbox1->data[] = $check_list_dates[1];
-               }
-               $tmp++;
-       }
-       echo "\n".'<!-- BEGIN checklist info -->'."\n<h2 class='heading'>Mine 
planlagte kontroller</h2><div 
class='home-box'>".$portalbox1->draw()."</div>\n".'<!-- END checklist info 
-->'."\n";
-
-       
-       
        /* ================================  CONTROLS ASSIGNED TO CURRENT USER  
================================= */
        
        $my_assigned_controls_HTML = "<div class='home_portal'><h2><div 
class='date heading'>Fristdato</div><div class='control heading'>Tittel på 
kontroll</div><div class='title heading'>Lokasjonsnavn</div><div 
class='control-area heading'>Kontrollområde</div></h2>";
        
-       $my_controls = array();
-       $repeat_type = null;
        
        $from_date_ts =  strtotime("now");
        $to_date_ts = mktime(0, 0, 0, date("n")+1, date("j"), date("Y") );
+         
+  // fetch all repeat types
+       $repeat_type = null;
+  
+  // Fetches controls current user is responsible for 1 month ahead in time
+  $my_controls = array();
+  $my_controls = get_my_controls($my_locations, $from_date_ts, $to_date_ts, 
$repeat_type);
        
-       // Fetches controls current user is responsible for
-       $my_controls = array();
-       foreach($my_locations as $location)
-       {
-               $controls = array();
-               $components_with_controls_array = array();
-               $location_code = $location["location_code"];
-                                               
-               $controls_loc = $so_control->get_controls_by_location( 
$location_code, $from_date_ts, $to_date_ts, $repeat_type, "return_array", 
$location["role_id"] );
-                                   
-               $level = count(explode('-', $location_code));
-
-               if($level == 1)
-               {
-                       // Fetches all controls for the components for a 
location within time period
-                       $filter = "bim_item.location_code = '$location_code' ";
-                       $components_with_controls_array = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);      
-               }
-               else
-               {
-                       // Fetches all controls for the components for a 
location within time period
-                       $filter = "bim_item.location_code LIKE 
'$location_code%' ";
-                       $components_with_controls_array = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);      
-               }
-
-               if( count($controls_loc) > 0 )
-               {
-                       $my_controls[] = array( $location_code, 'location', 
$controls_loc );
-               }
-
-               if( count($components_with_controls_array) > 0 )
-               {
-                       foreach($components_with_controls_array as $component)
-                       {
-                   $my_controls[] = array( $location_code, 'component', 
$component['controls_array'], $component );
-                       }
-               }
-       }
-       
        $my_assigned_controls = array();
 
        $from_date_ts =  mktime(0, 0, 0, date("n"), date("j"), date("Y") );
@@ -566,10 +495,10 @@
                                                | ($my_control["repeat_type"] 
== controller_control::REPEAT_TYPE_MONTH) 
                                                | ($my_control["repeat_type"] 
== controller_control::REPEAT_TYPE_YEAR))
                        {
-                               // Daily, monthly yearly control: Todate in one 
month
+                               // Daily, monthly yearly control: to_date in 
one month
                                $to_date_ts =  mktime(0, 0, 0, date("n")+1, 
date("j"), date("Y") ); 
                        }
-
+      
                        $date_generator = new 
date_generator($my_control["start_date"], $my_control["end_date"], 
$from_date_ts, $to_date_ts, $my_control["repeat_type"], 
$my_control["repeat_interval"]);
                        $deadline_dates_for_control = 
$date_generator->get_dates();
 
@@ -580,14 +509,18 @@
                                
                                if($control_type == "location")
                                {
+          // Gets checklist for control with current date as deadline if there 
exists one
                                        $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, $location_code, null, null, "location"  );
                                }
                                else if($control_type == "component")
                                {
                                        $component = $container_arr[3];
+          
+          // Gets checklist for control with current date as deadline if there 
exists one
                                        $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, null, $component['location_id'], $component['id'], 
"component"  );
                                }
-                               
+        
+        // Check if there is a checklist on the deadline
                                if($check_list == null)
                                {      
                                        if($control_type == "location")
@@ -600,9 +533,10 @@
                                                
$my_assigned_controls[$deadline_ts][] =  array("add", $deadline_ts, 
$my_control, "component", $component['location_id'], $component['id'] );
                      }
                                }
-                               else if($check_list->get_status() == 
controller_check_list::STATUS_NOT_DONE)
+        // Do not put checklist with status planned in list
+                               else if( ($check_list->get_planned_date() == '' 
|| $check_list->get_planned_date() == 0 ) && ( $check_list->get_status() == 
controller_check_list::STATUS_NOT_DONE || ($check_list->get_status() == 
controller_check_list::STATUS_CANCELED)) )
                                {
-                                       $my_assigned_controls[$deadline_ts][] = 
array("edit", $deadline_ts, $my_control, $check_list->get_id(), $location_code 
);
+                       $my_assigned_controls[$deadline_ts][] = array("edit", 
$deadline_ts, $my_control, $check_list->get_id(), $location_code );
                                }
                        }
                }
@@ -627,14 +561,14 @@
                {
                        $my_assigned_controls_HTML .= "<ul 
class='expand_list'>";
                } 
-                       
+               
                foreach($assigned_controls_on_date as $my_assigned_control)
                {
                        $check_list_status = $my_assigned_control[0];
                        $deadline_ts = $my_assigned_control[1];
                        $my_control = $my_assigned_control[2];
                        
-                   reset($control_areas['cat_list']);    
+                 reset($control_areas['cat_list']);    
                        
                        foreach($control_areas['cat_list'] as $area)
                        {
@@ -660,8 +594,7 @@
                                        }
                                        $location_name = 
$location_array[$location_code]["loc1_name"];
                        
-                                       
-                               if(count( $assigned_controls_on_date) > 1 )
+          if(count( $assigned_controls_on_date) > 1 )
                                        {
                                                $link = "";
                                                $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list', 'type' => "location", 'control_id' => 
$my_control['id'], 'location_code' => $location_code, 'deadline_ts' => 
$deadline_ts));
@@ -743,8 +676,77 @@
                if(count( $assigned_controls_on_date ) > 1 )
                {
                        $my_assigned_controls_HTML .= "</ul>";
-                }
-                 
+    }
        }
 
        echo "\n".'<!-- BEGIN checklist info -->'."\n <h2 class='heading'>Mine 
tildelte kontroller</h2><div class='home-box'>" . $my_assigned_controls_HTML . 
"</div></div>\n".'<!-- END checklist info -->'."\n";
+
+  
+  
+  /* ================================  FUNCTIONS  
======================================== */
+  
+  
+  function get_my_controls($my_locations, $from_date_ts, $to_date_ts, 
$repeat_type)
+  {
+    $so_control = CreateObject('controller.socontrol');
+    
+    foreach($my_locations as $location)
+    {
+      
+      $controls = array();
+      $components_with_controls_array = array();
+      $location_code = $location["location_code"];
+      
+      $controls_at_location = $so_control->get_controls_by_location( 
$location_code, $from_date_ts, $to_date_ts, $repeat_type, "return_array", 
$location["role_id"] );
+
+      $level = count(explode('-', $location_code));
+
+      if($level == 1)
+      {
+        // Fetches all controls for the components for a location within time 
period
+        $filter = "bim_item.location_code = '$location_code' ";
+        $components_with_controls_array = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);     
+      }
+      else
+      {
+        // Fetches all controls for the components for a location within time 
period
+        $filter = "bim_item.location_code LIKE '$location_code%' ";
+        $components_with_controls_array = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);     
+      }
+
+      if( count($controls_at_location) > 0 )
+      {
+        // Saves location code, location type and an array containing controls 
at locations
+        $my_controls[] = array( $location_code, 'location', 
$controls_at_location );
+      }
+
+      if( count($components_with_controls_array) > 0 )
+      {
+        foreach($components_with_controls_array as $component)
+        {
+          // Saves location code, location type, an array containing controls 
at locations and component object 
+          $my_controls[] = array( $location_code, 'component', 
$component['controls_array'], $component );
+        }
+      }
+    }
+    
+    return $my_controls;
+  }
+  
+  function get_control_area_name( $control_area_id ) 
+  {
+    $cats      = CreateObject('phpgwapi.categories', -1, 'controller', 
'.control');
+    $cats->supress_info        = true;
+    
+    $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => '','globals' 
=> true,'use_acl' => 0));
+   
+    foreach($control_areas['cat_list'] as $area)
+               {
+      if( $area['cat_id'] == $control_area_id )
+                       {
+                               $control_area_name = $area['name'];
+                       }
+               }
+   
+    return $control_area_name;
+  }
\ No newline at end of file




reply via email to

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