[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9154]
From: |
Torstein |
Subject: |
[Fmsystem-commits] [9154] |
Date: |
Mon, 16 Apr 2012 12:17:22 +0000 |
Revision: 9154
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9154
Author: vator
Date: 2012-04-16 12:17:22 +0000 (Mon, 16 Apr 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/controller/inc/class.uicalendar.inc.php
trunk/controller/inc/component/class.calendar_builder.inc.php
trunk/controller/inc/helper/class.check_list_status_manager.inc.php
trunk/controller/inc/helper/class.status_checker.inc.php
trunk/controller/js/controller/ajax.js
Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php 2012-04-16 12:17:10 UTC
(rev 9153)
+++ trunk/controller/inc/class.uicalendar.inc.php 2012-04-16 12:17:22 UTC
(rev 9154)
@@ -122,6 +122,9 @@
$controls_calendar_array =
$this->calendar_builder->build_calendar_array( $control_with_check_list_array,
$num_days_in_month, "view_days" );
+ //print_r($controls_calendar_array);
+
+
foreach($controls_calendar_array as &$inst)
{
$curr_control = &$inst['control'];
@@ -202,7 +205,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){
@@ -353,14 +356,14 @@
// 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){
- // Checks if control starts in the year that will be
shown
+ // Checks if control starts in the year that is
displayed
if( date("Y", $control->get_start_date()) == $year ){
$from_month = date("n",
$control->get_start_date());
}else{
$from_month = 1;
}
- // Checks if control ends in the year that will be shown
+ // Checks if control ends in the year that is displayed
if( date("Y", $control->get_end_date()) == $year ){
$to_month = date("n", $control->get_end_date());
}else{
@@ -371,24 +374,31 @@
// Fetches aggregate value for open cases in each month
in time period
for($from_month;$from_month<=$to_month;$from_month++){
-
- $trail_from_date_ts =
strtotime("$from_month/01/$year");
- $trail_to_date_ts =
strtotime("$to_month/01/$year");
-
+
+ $month_start_ts =
strtotime("$from_month/01/$year");
+ $end_month = $from_month + 1;
+
+ if($end_month > 12){
+ $year = $year + 1;
+ $end_month = 1;
+ }
+
+ $month_end_ts =
strtotime("$end_month/01/$year");
+
$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, $trail_from_date_ts, $trail_to_date_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 );
+
// 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) ){
$status_agg_month_info = new
status_agg_month_info();
-
$status_agg_month_info->set_month_nr(date("n", $from_month));
+
$status_agg_month_info->set_month_nr($from_month);
$status_agg_month_info->set_agg_open_cases(
$num_open_cases_for_control_array["count"] );
$agg_open_cases_pr_month_array[] =
$status_agg_month_info;
}
}
-
+
return $agg_open_cases_pr_month_array;
}
Modified: trunk/controller/inc/component/class.calendar_builder.inc.php
===================================================================
--- trunk/controller/inc/component/class.calendar_builder.inc.php
2012-04-16 12:17:10 UTC (rev 9153)
+++ trunk/controller/inc/component/class.calendar_builder.inc.php
2012-04-16 12:17:22 UTC (rev 9154)
@@ -37,7 +37,7 @@
if($date < $todays_date){
$status = "control_not_accomplished";
}else{
- $status = "control_registered";
+ $status = "CONTROL_REGISTERED";
}
if( $period_type == "view_months" )
@@ -55,13 +55,16 @@
return $calendar_array;
}
+ // Function that puts checklists into a twelve months array for
displaying a year or a days array for displaying a month
public function build_calendar_array( $controls_with_check_lists_array,
$num, $period_type ){
foreach($controls_with_check_lists_array as $control){
+
+ // ======================== DISPLAY STATUS FOR A MONTH
OR DAYS IN A MONTH ==========================
if($period_type == "view_days" | ($period_type ==
"view_months" & $control->get_repeat_type() == 2 | $control->get_repeat_type()
== 3))
{
$calendar_array = $this->init_calendar(
$control, $num, $period_type );
-
+
foreach($control->get_check_lists_array() as
$check_list)
{
$check_list_status_manager = new
check_list_status_manager( $check_list );
@@ -82,10 +85,14 @@
$controls_calendar_array[] = array("control" =>
$control->toArray(), "calendar_array" => $calendar_array);
}
+ // ======================== DISPLAY AGGREGATE STATUS
FOR A MONTH ==========================
else if($period_type == "view_months" &
($control->get_repeat_type() == 0 | $control->get_repeat_type() == 1))
{
$calendar_array = array();
+ for($i=1;$i<=12;$i++)
+ $calendar_array[$i] = "";
+
foreach($control->get_agg_open_cases_pr_month_array() as $status_agg_month_info)
{
$status =
"controls_accomplished_with_errors";
Modified: trunk/controller/inc/helper/class.check_list_status_manager.inc.php
===================================================================
--- trunk/controller/inc/helper/class.check_list_status_manager.inc.php
2012-04-16 12:17:10 UTC (rev 9153)
+++ trunk/controller/inc/helper/class.check_list_status_manager.inc.php
2012-04-16 12:17:22 UTC (rev 9154)
@@ -44,14 +44,15 @@
$check_list_status_info->set_check_list_id(
$this->check_list->get_id() );
$todays_date_ts = mktime(0,0,0,date("m"), date("d"),
date("Y"));
-
- if( $this->check_list->get_status() ==
controller_check_list::STATUS_NOT_DONE & $this->check_list->get_planned_date()
> 0 & $this->check_list->get_deadline() > $todays_date_ts)
+
+ // Control PLANNED - the checklist has a planned date
+ if( $this->check_list->get_status() ==
controller_check_list::STATUS_NOT_DONE & $this->check_list->get_planned_date()
> 0 & $this->check_list->get_deadline() >= $todays_date_ts)
{
- $status = "control_planned";
+ $status = "CONTROL_PLANNED";
}
else if( $this->check_list->get_status() ==
controller_check_list::STATUS_NOT_DONE & $this->check_list->get_planned_date()
> 0 & $this->check_list->get_deadline() < $todays_date_ts )
{
- $status = "control_not_accomplished_with_info";
+ $status = "CONTROL_NOT_DONE_WITH_PLANNED_DATE";
}
else if( $this->check_list->get_status() ==
controller_check_list::STATUS_NOT_DONE & $this->check_list->get_deadline() <
$todays_date_ts )
{
@@ -59,11 +60,11 @@
}
else if( $this->check_list->get_status() ==
controller_check_list::STATUS_DONE & $this->check_list->get_completed_date() >
$this->check_list->get_deadline() & $this->check_list->get_num_open_cases() ==
0)
{
- $status =
"control_accomplished_over_time_without_errors";
+ $status =
"CONTROL_DONE_OVER_TIME_WITHOUT_ERRORS";
}
else if( $this->check_list->get_status() ==
controller_check_list::STATUS_DONE & $this->check_list->get_completed_date() <
$this->check_list->get_deadline() & $this->check_list->get_num_open_cases() ==
0)
{
- $status =
"control_accomplished_in_time_without_errors";
+ $status = "CONTROL_DONE_IN_TIME_WITHOUT_ERRORS";
}
else if( $this->check_list->get_status() ==
controller_check_list::STATUS_DONE & $this->check_list->get_num_open_cases() >
0){
$status = "control_accomplished_with_errors";
Modified: trunk/controller/inc/helper/class.status_checker.inc.php
===================================================================
--- trunk/controller/inc/helper/class.status_checker.inc.php 2012-04-16
12:17:10 UTC (rev 9153)
+++ trunk/controller/inc/helper/class.status_checker.inc.php 2012-04-16
12:17:22 UTC (rev 9154)
@@ -36,6 +36,9 @@
}
}
+ if($num_open_cases > 0)
+
$check_list->set_status(controller_check_list::STATUS_DONE);
+
$check_list->set_num_open_cases($num_open_cases);
$check_list->set_num_pending_cases($num_pending_cases);
Modified: trunk/controller/js/controller/ajax.js
===================================================================
--- trunk/controller/js/controller/ajax.js 2012-04-16 12:17:10 UTC (rev
9153)
+++ trunk/controller/js/controller/ajax.js 2012-04-16 12:17:22 UTC (rev
9154)
@@ -327,6 +327,7 @@
$(this).addClass("focus");
});
+ // ================= SAVE CONTROL DETAILS - FORM SUBMIT
==================
$("#frm_save_control_details").submit(function(e){
var thisForm = $(this);
@@ -369,7 +370,6 @@
});
- // file: view_check_lists_for_location.xsl
// Fetches info about a check list on hover status image icon
$('a.view_check_list').bind('contextmenu', function(){
var thisA = $(this);
@@ -475,6 +475,9 @@
});
});
+ //=========================== CHECKLIST
================================
+
+ // UPDATE CHECKLIST DETAILS
$("#frm_update_check_list").live("submit", function(e){
e.preventDefault();
@@ -482,28 +485,73 @@
var submitBnt = $(thisForm).find("input[type='submit']");
var requestUrl = $(thisForm).attr("action");
- $.ajax({
- type: 'POST',
- url: requestUrl + "&phpgw_return_as=json&" +
$(thisForm).serialize(),
- success: function(data) {
- if(data){
- var obj = jQuery.parseJSON(data);
-
- if(obj.status == "updated"){
- var submitBnt =
$(thisForm).find("input[type='submit']");
- $(submitBnt).val("Lagret");
-
- // Changes text on save button back
to original
- window.setTimeout(function() {
- $(submitBnt).val('Lagre
sjekkpunkt');
-
$(submitBnt).addClass("not_active");
- }, 1000);
+ var statusFieldVal = $("#status").val();
+ var completedDateVal = $("#completed_date").val();
+ var completedDateRow = $("#completed_date").closest(".row");
+
+ // Checks that COMPLETE DATE is set if status is set to DONE
+ if(statusFieldVal == 1 & completedDateVal == ''){
+ // Displays error message above completed date
+ $(completedDateRow).before("<div
class='input_error_msg'>Vennligst angi når kontrollen ble utført</div>");
+ }else{
+
+ $(".input_error_msg").hide();
+
+ $.ajax({
+ type: 'POST',
+ url: requestUrl + "&phpgw_return_as=json&" +
$(thisForm).serialize(),
+ success: function(data) {
+ if(data){
+ var obj = jQuery.parseJSON(data);
+
+ if(obj.status == "updated"){
+ var submitBnt =
$(thisForm).find("input[type='submit']");
+ $(submitBnt).val("Lagret");
+
+ // Changes text on save
button back to original
+ window.setTimeout(function() {
+
$(submitBnt).val('Lagre sjekkpunkt');
+
$(submitBnt).addClass("not_active");
+ }, 1000);
+ }
}
- }
- }
- });
+ }
+ });
+ }
});
+ // Display submit button on click
+ $("#frm_update_check_list").live("click", function(e){
+ var thisForm = $(this);
+ var submitBnt = $(thisForm).find("input[type='submit']");
+ $(submitBnt).removeClass("not_active");
+ });
+
+ //============================= ADD CHECKLIST
===========================
+
+ // ADD CHECKLIST
+ $("#frm_add_check_list").live("submit", function(e){
+
+ var thisForm = $(this);
+ var statusFieldVal = $("#status").val();
+ var completedDateVal = $("#completed_date").val();
+ var completedDateRow = $("#completed_date").closest(".row");
+
+ // Checks that COMPLETE DATE is set if status is set to DONE
+ if(statusFieldVal == 1 & completedDateVal == ''){
+ e.preventDefault();
+ // Displays error message above completed date
+ $(completedDateRow).before("<div
class='input_error_msg'>Vennligst angi når kontrollen ble utført</div>");
+ }
+ });
+
+ // Display submit button on click
+ $("#frm_add_check_list").live("click", function(e){
+ var thisForm = $(this);
+ var submitBnt = $(thisForm).find("input[type='submit']");
+ $(submitBnt).removeClass("not_active");
+ });
+
$(".frm_register_case").live("submit", function(e){
e.preventDefault();
@@ -717,18 +765,6 @@
return false;
});
- $("#frm_update_check_list").live("click", function(e){
- var thisForm = $(this);
- var submitBnt = $(thisForm).find("input[type='submit']");
- $(submitBnt).removeClass("not_active");
- });
-
- $("#frm_add_check_list").live("click", function(e){
- var thisForm = $(this);
- var submitBnt = $(thisForm).find("input[type='submit']");
- $(submitBnt).removeClass("not_active");
- });
-
$(".frm_save_check_item").live("click", function(e){
var thisForm = $(this);
var submitBnt = $(thisForm).find("input[type='submit']");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9154],
Torstein <=