<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_WORKING_WEEK';
$path_to_root = "../..";

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/payroll/includes/payroll_db.inc");

page(_($help_context = "Working Week"));

//------------------------------------------------------------------------------------

start_form();

div_start('reorders');
start_table(TABLESTYLE, "width=30%");

$th = array(_("Day"), _("Working Time"));
table_header($th);

$j = 1;
$k=0; //row colour counter

$result = get_weking_week();

if (@$_GET['popup'])
{
	hidden('_tabs_sel', get_post('_tabs_sel'));
	hidden('popup', @$_GET['popup']);
}

while ($myrow = db_fetch($result))
{

    if (isset($_POST['UpdateData']))
    {
        update_working_week($_POST['monday'],$_POST['tuesday'],
                            $_POST['wednesday'],$_POST['thursday'],
                            $_POST['friday'],$_POST['saturday'],
                            $_POST['sunday']);
        
        display_notification(_("Working wekk has been updated."));
    }
    
    $_POST['monday'] = $myrow["monday"];
    $_POST['tuesday'] = $myrow["tuesday"];
    $_POST['wednesday'] = $myrow["wednesday"];
    $_POST['thursday'] = $myrow["thursday"];
    $_POST['friday'] = $myrow["friday"];
    $_POST['saturday'] = $myrow["saturday"];
    $_POST['sunday'] = $myrow["sunday"];
    

    value_list_code_row("Monday", 'monday', 'WORKING_TIME', $_POST['monday'] );
    value_list_code_row("tuesday", 'tuesday', 'WORKING_TIME', $_POST['tuesday'] );
    value_list_code_row("wednesday", 'wednesday', 'WORKING_TIME', $_POST['wednesday'] );
    value_list_code_row("thursday", 'thursday', 'WORKING_TIME', $_POST['thursday'] );
    value_list_code_row("friday", 'friday', 'WORKING_TIME', $_POST['friday'] );
    value_list_code_row("saturday", 'saturday', 'WORKING_TIME', $_POST['saturday'] );
    value_list_code_row("sunday", 'sunday', 'WORKING_TIME', $_POST['sunday'] );

    end_row();

}

end_table(1);
div_end();
submit_center('UpdateData', _("Update"), true, false, 'default');

if (!@$_GET['popup'])
{
	end_form();
	end_page(@$_GET['popup'], false, false);
}
?>
