diff --git a/html/do.php b/html/do.php index b91308fe0..47f180f21 100644 --- a/html/do.php +++ b/html/do.php @@ -56,6 +56,9 @@ $cn = Dossier::connect(); global $g_user, $cn,$g_parameter,$http; $g_user = new User($cn); $http=new HttpInput(); +if ( ! defined("FIRST_WEEK_DAY")) { + define ("FIRST_WEEK_DAY",$g_user->get_first_week_day()); +} /* * check that the database is not empty */ diff --git a/include/ajax/ajax_preference.php b/include/ajax/ajax_preference.php index 3f7448b60..95589e736 100644 --- a/include/ajax/ajax_preference.php +++ b/include/ajax/ajax_preference.php @@ -69,7 +69,7 @@ if ( $action == 'display_form' ) echo HtmlInput::title_box(_('Préférence'), 'preference_div'); echo '
'; echo '

'; - echo _("Après validation, recharger si vous changez la langue"); + echo _("Après validation, recharger pour appliquer les changements"); echo '

'; //---------------------------------------------------------------------- // @@ -145,6 +145,29 @@ if ( $action == 'display_form' ) select("exercice_setting",$selected_exercice,$js)->input();?> + + + + + + _("Lundi"),"value"=>1], + ["label"=>_("Mardi"),"value"=>2], + ["label"=>_("Mercredi"),"value"=>3], + ["label"=>_("Jeudi"),"value"=>4], + ["label"=>_("Vendredi"),"value"=>5], + ["label"=>_("Samedi"),"value"=>6], + ["label"=>_("Dimanche"),"value"=>0], + ); + $selFirstDay=new ISelect("selFirstDay"); + $selFirstDay->value=$aFirstDay; + $selFirstDay->selected=$g_user->get_first_week_day(); + echo $selFirstDay->input(); + ?> + + + @@ -303,6 +326,7 @@ if ($action == 'save') $csv_fieldsep=$http->post("csv_fieldsep","number"); $csv_decimal=$http->post("csv_decimal","number"); $csv_encoding=$http->post("csv_encoding"); + $firstday=$http->post("selFirstDay","number"); if (strlen(trim($pass_1)) != 0 && strlen(trim($pass_2)) != 0) { @@ -322,8 +346,9 @@ if ($action == 'save') $g_user->save_global_preference('csv_fieldsep', $csv_fieldsep); $g_user->save_global_preference('csv_decimal', $csv_decimal); $g_user->save_global_preference('csv_encoding', $csv_encoding); + $g_user->save_global_preference('first_week_day', $firstday); $g_user->save_email($p_email); - + $_SESSION[SESSION_KEY.'g_theme']=$style_user; $_SESSION[SESSION_KEY.'g_pagesize']=$p_size; $_SESSION[SESSION_KEY.'g_lang']=$lang; diff --git a/include/class/user.class.php b/include/class/user.class.php index 3ad5bfefb..0493b7345 100644 --- a/include/class/user.class.php +++ b/include/class/user.class.php @@ -127,7 +127,7 @@ class User $this->login =strtolower($row['use_login']); $this->admin = $row['use_admin']; $this->password = $row['use_pass']; - $this->email=$row['use_email']; + $this->email=$row['use_email']; } function save() @@ -555,16 +555,16 @@ class User $type = $row['parameter_type']; $l_array[$type] = $row['parameter_value']; } - $repo=new Database(); - $a_global_pref=$repo->get_array("select parameter_type,parameter_value from user_global_pref - where - upper(user_id) = upper($1)",[$this->login]); - $nb_global=count($a_global_pref); - for ( $i = 0 ;$i< $nb_global ; $i++) { - $idx=$a_global_pref[$i]['parameter_type']; - $value=$a_global_pref[$i]['parameter_value']; - $l_array[$idx]=$value; - } + $repo=new Database(); + $a_global_pref=$repo->get_array("select parameter_type,parameter_value from user_global_pref + where + upper(user_id) = upper($1)",[$this->login]); + $nb_global=count($a_global_pref); + for ( $i = 0 ;$i< $nb_global ; $i++) { + $idx=$a_global_pref[$i]['parameter_type']; + $value=$a_global_pref[$i]['parameter_value']; + $l_array[$idx]=$value; + } return $l_array; } @@ -663,7 +663,8 @@ class User 'g_lang' => 'LANG', 'csv_fieldsep'=>'csv_fieldsep', 'csv_decimal'=>'csv_decimal' , - 'csv_encoding'=>'csv_encoding'); + 'csv_encoding'=>'csv_encoding', + 'first_week_day'=>'first_week_day'); foreach ($array_pref as $name => $parameter) { @@ -690,29 +691,28 @@ class User { $default_parameter = array("THEME" => "classic", - "PAGESIZE" => "50", - 'TOPMENU' => 'TEXT', - 'LANG' => 'fr_FR.utf8', + "PAGESIZE" => "50", + 'TOPMENU' => 'TEXT', + 'LANG' => 'fr_FR.utf8', 'csv_fieldsep'=>'0', 'csv_decimal'=>'0', - 'csv_encoding'=>'utf8' + 'csv_encoding'=>'utf8', + 'first_week_day'=>1 ); $cn = new Database(); - $Sql = "insert into user_global_pref(user_id,parameter_type,parameter_value) - values ('%s','%s','%s')"; + $sql = "insert into user_global_pref(user_id,parameter_type,parameter_value) + values ($1,$2,$3)"; if ($p_type == "") { foreach ($default_parameter as $name => $value) { - $Insert = sprintf($Sql, $this->login, $name, $value); - $cn->exec_sql($Insert); + $cn->exec_sql($sql,array($this->login,$name,$value)); } } else { $value = ($p_value == "") ? $default_parameter[$p_type] : $p_value; - $Insert = sprintf($Sql, $this->login, $p_type, $value); - $cn->exec_sql($Insert); + $cn->exec_sql($sql,array($this->login,$p_type,$value)); } } @@ -727,12 +727,13 @@ class User function update_global_pref($p_type, $p_value = "") { $default_parameter = array("THEME" => "classic", - "PAGESIZE" => "50", - "LANG" => 'fr_FR.utf8', - 'TOPMENU' => 'SELECT', + "PAGESIZE" => "50", + "LANG" => 'fr_FR.utf8', + 'TOPMENU' => 'SELECT', 'csv_fieldsep'=>'0', 'csv_decimal'=>'0', - 'csv_encoding'=>'utf8' + 'csv_encoding'=>'utf8', + 'first_week_day'=>1 ); $cn = new Database(); $Sql = "update user_global_pref set parameter_value=$1 @@ -1479,6 +1480,21 @@ class User $this->db->exec_sql("update user_active_security set us_action=$1 where us_login = $2",[$flag,$this->login]); } } + + /** + * + */ + function get_first_week_day() + { + $repocn=new Database(); + $result=$repocn->get_value("select parameter_value from user_global_pref where parameter_type=$1 and user_id=$2 ", + array("first_week_day",$this->login)); + if ($repocn->count() == 0 ) { + $this->save_global_preference("first_week_day",1); + return 1; + } + return $result; + } } -?> +?> \ No newline at end of file diff --git a/include/lib/idate.class.php b/include/lib/idate.class.php index 3deb069a9..805041b0f 100644 --- a/include/lib/idate.class.php +++ b/include/lib/idate.class.php @@ -37,6 +37,7 @@ class IDate extends HtmlInput var $placeholder; var $title; var $autofocus; + var $firstDate; //extra=""; $this->style=' class="input_text" '; $this->autofocus=false; + $this->firstDate=(defined("FIRST_WEEK_DAY"))?FIRST_WEEK_DAY:0; } + /** + * @return string + */ + public function get_placeholder() + { + return $this->placeholder; + return $this; + } + + /** + * @param string $placeholder + */ + public function set_placeholder($placeholder) + { + $this->placeholder = $placeholder; + return $this; + } + + /** + * @return string + */ + public function get_title() + { + return $this->title; + return $this; + } + + /** + * @param string $title + */ + public function set_title($title) + { + $this->title = $title; + return $this; + } + + /** + * @return false + */ + public function get_autofocus() + { + return $this->autofocus; + return $this; + } + + /** + * @param false $autofocus + */ + public function set_autofocus($autofocus) + { + $this->autofocus = $autofocus; + return $this; + } + + /** + * @return mixed + */ + public function get_firstDate() + { + return $this->firstDate; + return $this; + } + + /** + * @param mixed $firstDate + */ + public function set_firstDate($firstDate) + { + if (isNumber($firstDate)==0){ + throw new Exception("IDATE1: invalide data"); + } + $this->firstDate = $firstDate; + return $this; + } + /*!\brief show the html input of the widget */ @@ -83,10 +160,12 @@ class IDate extends HtmlInput button : "%s_trigger", align : "Bl", singleClick : true, - firstDay:0 + firstDay:%s }); ' - ,$this->id,$this->id); + ,$this->id, + $this->id, + $this->firstDate); return $r; } diff --git a/include/template/calendar.php b/include/template/calendar.php index 7b921e6f5..88effb67f 100644 --- a/include/template/calendar.php +++ b/include/template/calendar.php @@ -18,41 +18,47 @@ get_first_week_day(); +$nDay=$nFirstDay; for ($i=0;$i<=6;$i++){ echo ""; - echo $week[$i]; + $nDay=($nDay>6)?0:$nDay; + echo $week[$nDay]; + $nDay++; echo ""; } ?> day) { -if ( $week == 0 ) echo ""; -$class="workday"; -if ( $week == 0 || $week == 6) $class="weekend"; -// compute the date -$timestamp_date=mktime(0,0,0,$this->month,$ind,$this->year); -$date_calendar=date('w',$timestamp_date); -$st=""; -if ( $today_month==$this->month && $today_day==$ind) - $st=' style="border:1px solid red" '; -if ( $date_calendar == $week ) { - echo ''.''.$ind.""; - echo $cell[$ind]; - echo ''; - $ind++;$week++; -} else { - echo ""; - $week++; + if ( $nCol == 0 ) echo ""; + $class="workday"; + if ( $week == 0 || $week == 6) $class="weekend"; + // compute the date + $timestamp_date=mktime(0,0,0,$this->month,$ind,$this->year); + $date_calendar=date('w',$timestamp_date); + $st=""; + if ( $today_month==$this->month && $today_day==$ind) + $st=' style="border:1px solid red" '; + if ( $date_calendar == $week ) { + echo ''.''.$ind.""; + echo $cell[$ind]; + echo ''; + $ind++;$week++;$nCol++; + } else { + echo ""; + $week++;$nCol++; + } + //if ( $ind > $this->day ) exit(); + if ( $nCol == 7 ) { echo "";$nCol=0;} + if ( $week == 7 ) { $week=0;} } -//if ( $ind > $this->day ) exit(); -if ( $week == 7 ) { echo "";$week=0;} -} -if ( $week != 0 ) { echo "";} +if ( $nCol != 0 ) { echo "";} ?>