[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9301]
From: |
Torstein |
Subject: |
[Fmsystem-commits] [9301] |
Date: |
Tue, 08 May 2012 06:40:41 +0000 |
Revision: 9301
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9301
Author: vator
Date: 2012-05-08 06:40:38 +0000 (Tue, 08 May 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/controller/inc/class.socheck_list.inc.php
trunk/controller/inc/class.uicalendar.inc.php
trunk/controller/inc/class.uicheck_list.inc.php
Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php 2012-05-07 20:01:28 UTC
(rev 9300)
+++ trunk/controller/inc/class.socheck_list.inc.php 2012-05-08 06:40:38 UTC
(rev 9301)
@@ -162,48 +162,7 @@
return null;
}
}
- /*
- public function get_check_list(){
-
- $current_time = time();
- $buffer_in_days = 3600*24*7*5;
-
- $buffer_time = $current_time - $buffer_in_days;
-
- $sql = "SELECT p.* FROM controller_control p WHERE
$current_time >= p.start_date AND p.start_date > $buffer_time";
- $this->db->query($sql);
-
- while ($this->db->next_record()) {
- $start_date = date("d.m.Y",
$this->db->f('start_date'));
- $end_date = date("d.m.Y", $this->db->f('end_date'));
-
- $control = new
controller_control($this->unmarshal($this->db->f('id', true), 'int'));
-
-
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
-
$control->set_description($this->unmarshal($this->db->f('description', true),
'boolean'));
- $control->set_start_date($start_date);
- $control->set_end_date($end_date);
-
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true),
'int'));
-
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name',
true), 'string'));
-
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id',
true), 'int'));
-
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
true), 'int'));
-
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
-
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
true), 'int'));
-
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
true), 'string'));
-
$control->set_equipment_type_id($this->unmarshal($this->db->f('equipment_type_id',
true), 'int'));
-
$control->set_equipment_id($this->unmarshal($this->db->f('equipment_id', true),
'int'));
-
$control->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'string'));
-
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true),
'int'));
-
$control->set_repeat_type_label($this->unmarshal($this->db->f('repeat_type',
true), 'int'));
-
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval',
true), 'int'));
-
- $results[] = $control->toArray();
- }
-
- return $results;
- }
- */
function get_check_lists_for_control($control_id){
$sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, planned_date, ";
$sql .= "completed_date, component_id, location_code,
num_open_cases, num_pending_cases ";
@@ -318,7 +277,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;
@@ -384,6 +343,7 @@
return $control_array;
}
+ // Fetches all controls as objects with check lists
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, ";
@@ -403,7 +363,7 @@
}
$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;
@@ -463,6 +423,7 @@
return $controls_array;
}
+ // Fetches control id and check lists for period and location
function get_check_lists_for_location_2( $location_code, $from_date_ts,
$to_date_ts, $repeat_type ){
$sql = "SELECT c.id as c_id, ";
$sql .= "cl.id as cl_id, cl.status as cl_status, cl.comment as
cl_comment, deadline, planned_date, completed_date, ";
@@ -520,6 +481,40 @@
return $controls_array;
}
+ // Fetches check lists for location and control id
+ function get_check_lists_for_control_and_location( $control_id,
$location_code, $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.location_code = '{$location_code}' ";
+
+ 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-05-07 20:01:28 UTC
(rev 9300)
+++ trunk/controller/inc/class.uicalendar.inc.php 2012-05-08 06:40:38 UTC
(rev 9301)
@@ -37,6 +37,7 @@
include_class('controller', 'status_agg_month_info', 'inc/helper/');
include_class('controller', 'calendar_builder', 'inc/component/');
include_class('controller', 'location_finder', 'inc/helper/');
+ include_class('controller', 'year_calendar', 'inc/component/');
class controller_uicalendar extends controller_uicommon
{
@@ -114,7 +115,7 @@
$my_locations = $location_finder->get_responsibilities(
$criteria );
if(empty($location_code)){
- $location_code =
$my_locations[0]["location_code"];
+ $location_code =
$my_locations[0]["location_code"];
}
$num_days_in_month = cal_days_in_month(CAL_GREGORIAN,
$month, $year);
@@ -130,27 +131,10 @@
$controls_calendar_array =
$this->calendar_builder->build_calendar_array( $control_with_check_list_array,
$num_days_in_month, "view_days" );
- foreach($controls_calendar_array as &$inst)
- {
- $curr_control = &$inst['control'];
-
- if($curr_control['repeat_type'] == 0)
- $curr_control['repeat_type'] = "Dag";
- else if($curr_control['repeat_type'] == 1)
- $curr_control['repeat_type'] = "Uke";
- else if($curr_control['repeat_type'] == 2)
- $curr_control['repeat_type'] = "Måned";
- else if($curr_control['repeat_type'] == 3)
- $curr_control['repeat_type'] = "År";
- }
-
- //$location_list =
$this->bo->read(array('type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run'
=>$dry_run));
-
$location_array =
execMethod('property.bolocation.read_single', array('location_code' =>
$location_code));
- //lookup=1&type_id=1&lookup_name=0
+
$property_array =
execMethod('property.solocation.read', array('type_id' => 1, 'allrows' =>
true));
- //$property_array =
execMethod('property.bolocation.read', array('type_id' => 1, 'lookup_name' =>
0, 'lookup' => 1));
- //print_r( $property_array );
+
$month_array = array("Januar", "Februar", "Mars",
"April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November",
"Desember");
@@ -176,7 +160,7 @@
self::add_javascript('controller', 'controller',
'jquery.js');
self::add_javascript('controller', 'controller',
'ajax.js');
-
self::render_template_xsl(array('calendar/view_calendar_month',
'calendar/check_list_status_checker'), $data);
+
self::render_template_xsl(array('calendar/view_calendar_month',
'calendar/check_list_status_checker', 'calendar/icon_color_map'), $data);
}
public function view_calendar_for_year()
@@ -196,6 +180,7 @@
$from_date_ts = strtotime("01/01/$year");
$to_year = $year + 1;
$to_date_ts = strtotime("01/01/$to_year");
+
$manage=false;
if($manage)
@@ -215,8 +200,6 @@
$my_locations =
$location_finder->get_responsibilities( $criteria );
}
-
- //print_r($my_locations);
if(empty($location_code)){
$location_code =
$my_locations[0]["location_code"];
}
@@ -227,7 +210,7 @@
// Creates a calendar object for time period
$this->calendar_builder = new
calendar_builder($from_date_ts, $to_date_ts);
- // Loops through controls with repeat type: day or week
in controls_for_location_array
+ // Loops through controls with repeat type day or week
in controls_for_location_array
// and populates array that contains aggregate open
cases pr month.
foreach($controls_for_location_array as $control){
if($control->get_repeat_type() == 0 |
$control->get_repeat_type() == 1){
@@ -271,7 +254,7 @@
'year' =>
$year
);
- self::render_template_xsl(
array('calendar/view_calendar_year', 'calendar/check_list_status_checker'),
$data);
+ self::render_template_xsl(
array('calendar/view_calendar_year', 'calendar/check_list_status_checker',
'calendar/icon_color_map'), $data);
self::add_javascript('controller', 'controller',
'jquery.js');
self::add_javascript('controller', 'controller',
'ajax.js');
}
@@ -280,82 +263,94 @@
{
$control_id = phpgw::get_var('control_id');
$control = $this->so_control->get_single($control_id);
+ $year = phpgw::get_var('year');
if(is_numeric($control_id) & $control_id > 0)
{
$locations_for_control_array =
$this->so_control->get_locations_for_control($control_id);
}
- $year = intval( date("Y") );
-
+ if(empty($year)){
+ $year = intval( date("Y") );
+ }
+
$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_with_check_lists_array = array();
+ //$this->calendar_builder = new
calendar_builder($from_date_ts, $to_date_ts);
- if( $control->get_repeat_type() == 0 |
$control->get_repeat_type() == 1 )
- {
- foreach($locations_for_control_array as
$location)
- {
- $location_code =
$location["location_code"];
+ //$controls_with_check_lists_array = array();
+ $locations_with_calendar_array = array();
+
+ if($control->get_repeat_type() <= 1 ){
+ foreach($locations_for_control_array as
$location){
+ $curr_location_code =
$location['location_code'];
- $agg_open_cases_pr_month_array =
$this->build_agg_open_cases_pr_month_array($control, $location_code, $year);
- $curr_control = clone $control;
-
$curr_control->set_agg_open_cases_pr_month_array(
$agg_open_cases_pr_month_array );
-
$curr_control->set_location_code($location_code);
-
- $controls_with_check_lists_array[] =
$curr_control;
- }
- }
- else if($control->get_repeat_type() == 2 |
$control->get_repeat_type() == 3)
- {
- foreach($locations_for_control_array as
$location)
- {
- $location_code =
$location["location_code"];
- $curr_control = clone $control;
- $control_check_list_array =
$this->so->get_check_lists_for_location( $location_code, $from_date_ts,
$to_date_ts, $control->get_repeat_type(), $control->get_id() );
-
$curr_control->set_location_code($location_code);
+ // 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_location_code,
$year);
- $controls_with_check_lists_array[] =
$curr_control;
+ $year_calendar = new
year_calendar($control, $year);
+ $calendar_array =
$year_calendar->build_agg_calendar($agg_open_cases_pr_month_array);
+ $locations_with_calendar_array[] =
array("location" => $curr_location_code, "calendar_array" => $calendar_array);
}
- }
-
- $controls_calendar_array =
$this->calendar_builder->build_calendar_array($controls_with_check_lists_array,
12, "view_months" );
+ }else if($control->get_repeat_type() == 2){
+ foreach($locations_for_control_array as
$location){
+ $curr_location_code =
$location['location_code'];
+
+ $repeat_type = 2;
+ $location_with_check_lists =
$this->so->get_check_lists_for_control_and_location($control_id,
$curr_location_code, $from_date_ts, $to_date_ts, $repeat_type);
+
+ $check_lists_array =
$location_with_check_lists["check_lists_array"];
+
+ $year_calendar = new
year_calendar($control, $year);
+ $calendar_array =
$year_calendar->build_calendar( $check_lists_array );
- foreach($controls_calendar_array as &$inst)
- {
- $curr_control = &$inst['control'];
- //var_dump($control['location_code']);
- foreach($locations_for_control_array as $loc1)
- {
- if($curr_control["location_code"] ==
$loc1["location_code"])
- $curr_control["location_name"]
= $loc1["loc1_name"];
+ $locations_with_calendar_array[] =
array("location" => $curr_location_code, "calendar_array" => $calendar_array);
}
- }
+ }else if($control->get_repeat_type() == 3){
+ foreach($locations_for_control_array as
$location){
+ $curr_location_code =
$location['location_code'];
+
+ $repeat_type = 3;
+ $location_with_check_lists =
$this->so->get_check_lists_for_control_and_location($control_id,
$curr_location_code, $from_date_ts, $to_date_ts, $repeat_type);
+
+ $year_calendar = new
year_calendar($control, $year);
+
+ $check_lists_array =
$location_with_check_lists["check_lists_array"];
+
+ $calendar_array =
$year_calendar->build_calendar( $check_lists_array );
+
+ $locations_with_calendar_array[] =
array("location" => $curr_location_code, "calendar_array" => $calendar_array);
+ }
+ }
- //_debug_array($controls_calendar_array);
+ $criteria = array
+ (
+ 'user_id' =>
$GLOBALS['phpgw_info']['user']['account_id'], //
+ 'type_id' => 1, // Nivå i bygningsregisteret
1:eiendom
+ 'role_id' => 0, // For å begrense til en
bestemt rolle - ellers listes alle roller for brukeren
+ 'allrows' => false
+ );
+
+ $location_finder = new location_finder();
+ $my_locations = $location_finder->get_responsibilities(
$criteria );
+ //$controls_calendar_array =
$this->calendar_builder->build_calendar_array($controls_with_check_lists_array,
12, "view_months" );
$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',
- 'control_name' =>
$control->get_title()
+ 'my_locations'
=> $my_locations,
+ 'control'
=> $control->toArray(),
+ 'heading_array'
=> $heading_array,
+ 'locations_with_calendar_array' =>
$locations_with_calendar_array,
+ 'date_format'
=> $date_format,
+ 'period'
=> $year,
+ 'year'
=> $year,
);
-
self::render_template_xsl('calendar/view_calendar_year', $data);
-
+ self::render_template_xsl(
array('calendar/view_calendar_year_for_locations',
'calendar/check_list_status_checker', 'calendar/icon_color_map'), $data);
self::add_javascript('controller', 'controller',
'jquery.js');
self::add_javascript('controller', 'controller',
'ajax.js');
}
Modified: trunk/controller/inc/class.uicheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list.inc.php 2012-05-07 20:01:28 UTC
(rev 9300)
+++ trunk/controller/inc/class.uicheck_list.inc.php 2012-05-08 06:40:38 UTC
(rev 9301)
@@ -650,9 +650,6 @@
$closed_check_items_and_cases =
$this->so_check_item->get_check_items_with_cases($check_list_id,
"control_item_type_1", 'closed', null, 'return_array');
$closed_check_items_and_measurements =
$this->so_check_item->get_check_items_with_cases($check_list_id,
"control_item_type_2", 'closed', null, 'return_array');
- //echo "SKRIVER UT LUKKEDE SAKER";
- //print_r($closed_check_items_and_cases);
-
$data = array
(
'closed_check_items_and_cases'
=> $closed_check_items_and_cases,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9301],
Torstein <=