fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8299]


From: Torstein
Subject: [Fmsystem-commits] [8299]
Date: Thu, 15 Dec 2011 08:33:57 +0000

Revision: 8299
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8299
Author:   vator
Date:     2011-12-15 08:33:57 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.uilocation_check_list.inc.php

Modified: trunk/controller/inc/class.uilocation_check_list.inc.php
===================================================================
--- trunk/controller/inc/class.uilocation_check_list.inc.php    2011-12-15 
08:25:55 UTC (rev 8298)
+++ trunk/controller/inc/class.uilocation_check_list.inc.php    2011-12-15 
08:33:57 UTC (rev 8299)
@@ -1,8 +1,8 @@
 <?php
-       /**
+/**
        * phpGroupWare - controller: a part of a Facilities Management System.
        *
-       * @author Erink Holm-Larsen <address@hidden>
+       * @author Erik Holm-Larsen <address@hidden>
        * @author Torstein Vadla <address@hidden>
        * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
        * This file is part of phpGroupWare.
@@ -30,11 +30,12 @@
 
        phpgw::import_class('controller.uicommon');
        phpgw::import_class('controller.socheck_list');
-
+       
        include_class('controller', 'check_list', 'inc/model/');
        include_class('controller', 'check_item', 'inc/model/');
        include_class('controller', 'check_list_status_info', 'inc/helper/');
-
+       include_class('controller', 'calendar_builder', 'inc/components/');
+               
        class controller_uilocation_check_list extends controller_uicommon
        {
                private $so;
@@ -44,7 +45,8 @@
                private $so_control_item;
                private $so_check_list;
                private $so_check_item;
-
+               private $calendar_builder;
+                               
                public $public_functions = array
                (
                        'index' =>      true,
@@ -54,13 +56,13 @@
                        'edit_check_list'                                       
=>      true,
                        'save_check_items'                                      
=>      true,
                        'view_check_lists_for_location'         =>      true,
-                       'view_agg_check_lists_for_location'     =>      true
+                       'view_calendar'                                         
=>      true
                );
 
                public function __construct()
                {
                        parent::__construct();
-
+                       
                        $this->so = CreateObject('controller.socheck_list');
                        $this->so_control = 
CreateObject('controller.socontrol');
                        $this->so_control_group = 
CreateObject('controller.socontrol_group');
@@ -68,53 +70,56 @@
                        $this->so_control_item = 
CreateObject('controller.socontrol_item');
                        $this->so_check_list = 
CreateObject('controller.socheck_list');
                        $this->so_check_item = 
CreateObject('controller.socheck_item');
-
+                       
                        
self::set_active_menu('controller::location_check_list');
                }
-
-               public function view_agg_check_lists_for_location()
+               
+               public function view_calendar()
                {
                        $control_id = phpgw::get_var('control_id');
                        $location_code = phpgw::get_var('location_code');
                        $year = phpgw::get_var('year');
                        $month = phpgw::get_var('month');
-
+                       
                        if( empty($month) ){
                                $year = intval($year);
-
+                       
                                $from_date = strtotime("01/01/$year");
                                $to_year = $year + 1;
-                               $to_date = strtotime("01/01/$to_year");
+                               $to_date = strtotime("01/01/$to_year"); 
                        }
                        else{
                                $year = intval($year);
                                $from_month = intval($month);
-
+                               
                                $from_date = strtotime("$from_month/01/$year");
                                $to_month = $from_month + 1;
                                $to_date = strtotime("$to_month/01/$year+1");
                        }
-
+                       
                        $control = $this->so_control->get_single($control_id);
-
+                       
                        if(empty($location_code)){
-                               $location_code = "1101";
+                               $location_code = "1101";        
                        }
-
+                       
+                       // Get check lists for a YEAR
                        if( empty($month) )
                        {
+                               $this->calendar_builder = new 
calendar_builder($from_date, $to_date);
+                               
                                // Gets an array of controls that contains 
check_lists for the specified location
-                               $controls_array = 
$this->so->get_agg_check_lists_for_location( $location_code, $from_date, 
$to_date );
-                               $controls_calendar_array = 
$this->build_agg_calendar_array( $controls_array );
-
+                               $agg_check_list_array = 
$this->so->get_agg_check_lists_for_location( $location_code, $from_date, 
$to_date );
+                               $controls_calendar_array = 
$this->calendar_builder->build_agg_calendar_array( $agg_check_list_array );
+                       
                                $repeat_type = 2;
-                               $control_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date, $to_date, 
$repeat_type );
-                               $controls_calendar_array = 
$this->build_calendar_array( $control_array, $controls_calendar_array, 12, 
"view_months" );
-
+                               $check_list_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date, $to_date, 
$repeat_type );
+                               $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $check_list_array, 
$controls_calendar_array, 12, "view_months" );
+                               
                                $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
-
+                               
                                $heading_array = array("Jan", "Feb", "Mar", 
"Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des");
-
+                                                               
                                $data = array
                                (
                                        'location_array'                  => 
$location_array,
@@ -124,23 +129,26 @@
                                        'period'                                
  => $year,
                                        'year'                                  
  => $year
                                );
-                               
self::render_template_xsl('view_agg_check_lists_for_location_year', $data);
+                               self::render_template_xsl('view_calendar_year', 
$data);
                        }
+                       // Get check lists for a MONTH
                        else
                        {
+                               $this->calendar_builder = new 
calendar_builder($from_date, $to_date);
+                               
                                $repeat_type = 0;
-                               $control_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date, $to_date, 
$repeat_type);
-                               $controls_calendar_array = 
$this->build_calendar_array( $control_array, null, 31, "view_days" );
-
+                               $check_list_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date, $to_date, 
$repeat_type);
+                               $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $check_list_array, null, 31, 
"view_days" );
+                                                               
                                $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
-
+                               
                                for($i=1;$i<=31;$i++){
-                                       $heading_array[$i] = "$i";
+                                       $heading_array[$i] = "$i";      
                                }
-
+                                                               
                                $data = array
                                (
-
+                                       
                                        'location_array'                  => 
$location_array,
                                        'heading_array'                   => 
$heading_array,
                                        'controls_calendar_array' => 
$controls_calendar_array,
@@ -148,96 +156,32 @@
                                        'period'                                
  => $month,
                                        'year'                                  
  => $year
                                );
-                               
self::render_template_xsl('view_agg_check_lists_for_location_month', $data);
+                               
self::render_template_xsl('view_calendar_month', $data);        
                        }
-
+                       
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
                }
-
-               public function build_calendar_array( $control_array, 
$controls_calendar_array, $num, $period_type ){
-
-                       foreach($control_array as $control){
-
-                               // Initialises twelve_months_array
-                               for($i=1;$i<=$num;$i++){
-                                       $calendar_array[$i] = null;
-                               }
-
-                               // Inserts check_list object on deadline month 
in twelve_months_array
-                               foreach($control->get_check_lists_array() as 
$check_list){
-
-                                       $check_list_status_info = new 
check_list_status_info();
-                                       
$check_list_status_info->set_id($check_list->get_id());
-                                       
$check_list_status_info->set_status_text($check_list->get_status());
-
-                                       if($check_list->get_status() == 'Ikke 
utført'){
-                                               
$check_list_status_info->set_status(0);
-                                       }
-
-                                       $check_list_status_info->set_deadline( 
date("d/m-Y", $check_list->get_deadline()) );
-
-                                       if($period_type == "view_months")
-                                       {
-                                               $calendar_array[ date("n", 
$check_list->get_deadline()) ] = $check_list_status_info->serialize();
-                                       }
-                                       else{
-                                               $calendar_array[ date("j", 
$check_list->get_deadline()) ] = $check_list_status_info->serialize();
-                                       }
-                               }
-
-                               $controls_calendar_array[] = array("control" => 
$control->toArray(), "calendar_array" => $calendar_array);
-                       }
-
-                       return $controls_calendar_array;
-               }
-
-               // Function receives array with control objects that each 
contain check_lists for a certain period
-               public function build_agg_calendar_array( $controls_array ){
-
-                       $calendar_array = array();
-
-                       foreach($controls_array as $control_array){
-
-                               $control_info = $control_array['control'];
-                               $check_list_array = 
$control_array['check_list'];
-
-                               $control_id = $control_info['id'];
-                                
-                               // Initialises twelve_months_array
-                               for($i=0;$i<12;$i++){
-                                       $calendar_array[$i] = null;
-                               }
-
-                               // Inserts check_list object on deadline month 
in twelve_months_array
-                               foreach($check_list_array as $check_list){
-                                       $calendar_array[ date("m", 
$check_list['deadline']) - 1 ] += $check_list['count'];
-                               }
-
-                               $control_calendar_array[] = array("control" => 
$control_info, "calendar_array" => $calendar_array);
-                       }
-
-                       return $control_calendar_array;
-               }
-
+               
+               
                public function view_check_lists_for_location()
                {
                        $control_id = phpgw::get_var('control_id');
                        $control = $this->so_control->get_single($control_id);
-
+                       
                        $location_code = "1101";
-
+                                               
                        $from_date = strtotime("01/01/2011");
                        $num_days_in_dec = cal_days_in_month(CAL_GREGORIAN, 12, 
2011);
                        $to_date =  strtotime("12/$num_days_in_dec/2011");
-
+                       
                        // Gets an array of controls that contains check_lists 
for the specified location 
                        $control_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date, $to_date );
-
-                       $controls_calendar_array = $this->build_calendar_array( 
$control_array, $from_date, $to_date );
-
+                       
+                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $control_array, $from_date, 
$to_date );
+                       
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
-
+                       
                        $data = array
                        (
                                'location_array'                  => 
$location_array,
@@ -246,76 +190,76 @@
                                'from_date'                       => $from_date,
                                'to_date'                                 => 
$to_date
                        );
-
+                       
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
                        
self::render_template_xsl('view_check_lists_for_location', $data);
                }
-
+                               
                public function view_check_lists_for_control()
                {
                        $control_id = phpgw::get_var('id');
                        $control = $this->so_control->get_single($control_id);
-
+                       
                        $date_format = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
-                       $check_list_array = 
$this->so->get_check_lists_for_control( $control_id );
-
+               
+                       $check_list_array = 
$this->so->get_check_lists_for_control( $control_id );      
+                       
                        $data = array
                        (
                                'control_as_array'      => $control->toArray(),
                                'check_list_array'      => $check_list_array,
                                'date_format'           => $date_format
                        );
-
+                       
                        self::render_template_xsl('view_check_lists', $data);
                }
-
+               
                public function view_control_items_for_control()
                {
                        $control_id = phpgw::get_var('control_id');
                        $control = $this->so_control->get_single($control_id);
-
+                                               
                        $control_groups_array = 
$this->so_control_group_list->get_control_groups_by_control_id( $control_id );
 
                        $saved_groups_with_items_array = array();
-
+                       
                        foreach ($control_groups_array as $control_group)
-                       {
+                       {       
                                $control_group_id = $control_group->get_id();
                                $saved_control_items = 
$this->so_control_item->get_control_items_by_control_id_and_group($control_id, 
$control_group_id);
-
+                               
                                $saved_groups_with_items_array[] = 
array("control_group" => $control_group->toArray(), "control_items" => 
$saved_control_items);
-                       }
-
+                       }       
+               
                        $data = array
                        (
                                'control_as_array'                              
=> $control->toArray(),
                                'saved_groups_with_items_array' => 
$saved_groups_with_items_array
                        );
-
+                                                               
                        self::render_template_xsl('view_check_list', $data);
                }
-
+               
                public function save_check_items(){
                        $check_item_ids = phpgw::get_var('check_item_ids');
                        $check_list_id = phpgw::get_var('check_list_id');
-
+                       
                        foreach($check_item_ids as $check_item_id){
                                $status = phpgw::get_var('status_' . 
$check_item_id);
                                $comment = phpgw::get_var('comment_' . 
$check_item_id);
-
+                               
                                $check_item = 
$this->so_check_item->get_single($check_item_id);
-
+                               
                                $check_item->set_status( $status );
                                $check_item->set_comment( $comment );
-
+                               
                                $this->so_check_item->store( $check_item );
                        }
-
-                       $this->redirect(array('menuaction' => 
'controller.uicheck_list.view_check_list', 'check_list_id'=>$check_list_id));
+                       
+                       $this->redirect(array('menuaction' => 
'controller.uicheck_list.view_check_list', 'check_list_id'=>$check_list_id));   
  
                }
-
+               
                public function save_check_list(){
                        $control_id = phpgw::get_var('control_id');
                        $control = $this->so_control->get_single($control_id);
@@ -324,41 +268,41 @@
                        $end_date = $control->get_end_date();
                        $repeat_type = $control->get_repeat_type();
                        $repeat_interval = $control->get_repeat_interval();
-
+                       
                        $status = true;
                        $comment = "Kommentar for sjekkliste";
                        $deadline = $start_date;
-
+                       
                        // Saving check_list
                        $new_check_list = new controller_check_list();
                        $new_check_list->set_control_id( $control_id );
                        $new_check_list->set_status( $status );
                        $new_check_list->set_comment( $comment );
                        $new_check_list->set_deadline( $deadline );
-
+                       
                        $check_list_id = $this->so_check_list->store( 
$new_check_list );
-
+                       
                        $control_items_list = 
$this->so_control_item->get_control_items_by_control_id($control_id);
-
+                       
                        foreach($control_items_list as $control_item){
-
+                               
                                $status = true;
                                $comment = "Kommentar for sjekk item";
-
+                               
                                // Saving check_items for a list
                                $new_check_item = new controller_check_item();
                                $new_check_item->set_check_list_id( 
$check_list_id );
-
+                               
                                $new_check_item->set_control_item_id( 
$control_item->get_id() );
                                $new_check_item->set_status( $status );
                                $new_check_item->set_comment( $comment );
 
                                $saved_check_item = 
$this->so_check_item->store( $new_check_item );
                        }
-
-                       $this->redirect(array('menuaction' => 
'controller.uicheck_list.view_check_list_for_control', 
'control_id'=>$control_id));
+                       
+                       $this->redirect(array('menuaction' => 
'controller.uicheck_list.view_check_list_for_control', 
'control_id'=>$control_id));       
                }
-
+               
                public function make_check_list_for_control(){
                        $control_id = phpgw::get_var('control_id');
                        $control = $this->so_control->get_single($control_id);
@@ -367,41 +311,41 @@
                        $end_date = $control->get_end_date();
                        $repeat_type = $control->get_repeat_type();
                        $repeat_interval = $control->get_repeat_interval();
-
+                       
                        $status = true;
                        $comment = "Kommentar for sjekkliste";
                        $deadline = $start_date;
-
+                       
                        // Saving check_list
                        $new_check_list = new controller_check_list();
                        $new_check_list->set_control_id( $control_id );
                        $new_check_list->set_status( $status );
                        $new_check_list->set_comment( $comment );
                        $new_check_list->set_deadline( $deadline );
-
+                       
                        $check_list_id = $this->so_check_list->store( 
$new_check_list );
-
+                       
                        $control_items_list = 
$this->so_control_item->get_control_items_by_control_id($control_id);
-
+                       
                        foreach($control_items_list as $control_item){
-
+                               
                                $status = true;
                                $comment = "Kommentar for sjekk item";
-
+                               
                                // Saving check_items for a list
                                $new_check_item = new controller_check_item();
                                $new_check_item->set_check_list_id( 
$check_list_id );
-
+                               
                                $new_check_item->set_control_item_id( 
$control_item->get_id() );
                                $new_check_item->set_status( $status );
                                $new_check_item->set_comment( $comment );
 
                                $saved_check_item = 
$this->so_check_item->store( $new_check_item );
                        }
-
-                       $this->redirect(array('menuaction' => 
'controller.uicheck_list.view_check_list_for_control', 
'control_id'=>$control_id));
+                       
+                       $this->redirect(array('menuaction' => 
'controller.uicheck_list.view_check_list_for_control', 
'control_id'=>$control_id));       
                }
-
+               
                public function query()
                {
                        $params = array(
@@ -412,7 +356,7 @@
                                'dir'   => phpgw::get_var('dir'),
                                'filters' => $filters
                        );
-
+                       
                        $search_for = phpgw::get_var('query');
 
                        
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
@@ -422,7 +366,7 @@
                        else {
                                $user_rows_per_page = 10;
                        }
-
+                       
                        // YUI variables for paging and sorting
                        $start_index    = phpgw::get_var('startIndex', 'int');
                        $num_of_objects = phpgw::get_var('results', 'int', 
'GET', $user_rows_per_page);
@@ -434,7 +378,7 @@
                        $sort_ascending = phpgw::get_var('dir') == 'desc' ? 
false : true;
                        //Create an empty result set
                        $records = array();
-
+                       
                        //Retrieve a contract identifier and load corresponding 
contract
 /*                     $control_id = phpgw::get_var('control_id');
                        if(isset($control_id))
@@ -445,14 +389,14 @@
                        $result_objects = $this->so->get($start_index, 
$num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, 
$filters);
                        $object_count = $this->so->get_count($search_for, 
$search_type, $filters);
                        //var_dump($result_objects);
-
+                                                               
                        $results = array();
-
+                       
                        foreach($result_objects as $check_list_obj)
                        {
-                               $results['results'][] = 
$check_list_obj->serialize();
+                               $results['results'][] = 
$check_list_obj->serialize();   
                        }
-
+                       
                        $results['total_records'] = $object_count;
                        $results['start'] = $params['start'];
                        $results['sort'] = $params['sort'];
@@ -462,4 +406,4 @@
 
                        return $this->yui_results($results);
                }
-       }
+       }
\ No newline at end of file




reply via email to

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