date_ouverture] = array ("ouvert" => $resdate_ouverture->ouvert, "commentaire" => $resdate_ouverture->commentaire) ; } // Default Params $param_d=array(); $param_d['calendar_id'] = 1; // Calendar ID $param_d['calendar_columns']= 5; // Nb of columns $param_d['show_day'] = 1; // Show the day bar $param_d['show_month'] = 1; // Show the month bar $param_d['nav_link'] = 1; // Add a nav bar below $param_d['link_after_date'] = 0; // Enable link on days after the current day $param_d['link_before_date']= 0; // Enable link on days before the current day $param_d['link_on_day'] = $PHP_SELF.'?date='; // Link to put on each day $param_d['font_face'] = 'Verdana, Arial, Helvetica'; // Default font to use $param_d['font_size'] = 10; // Font size in px $param_d['bg_color'] = '#FFFFFF'; $param_d['today_bg_color'] = '#A0C0C0'; $param_d['font_today_color']= '#990000'; $param_d['font_color'] = '#000000'; $param_d['font_nav_bg_color']= '#A9B4B3'; $param_d['font_nav_color'] = '#FFFFFF'; $param_d['font_header_color'] = '#FFFFFF'; $param_d['border_color'] = '#3f6551'; $param_d['use_img'] = 1; // Use gif for nav bar on the bottom // /Params $param = array(); $monthes_name = array('',$msg[1006],$msg[1007],$msg[1008],$msg[1009],$msg[1010],$msg[1011],$msg[1012],$msg[1013],$msg[1014],$msg[1015],$msg[1016],$msg[1017]); $days_name = array('',$msg[1018],$msg[1019],$msg[1020],$msg[1021],$msg[1022],$msg[1023],$msg[1024]); foreach($param_d as $key => $val) { if (isset($params[$key])) $param[$key] = $params[$key]; else $param[$key] = $val; } $param['calendar_columns'] = ($param['show_day']) ? 7 : $param['calendar_columns']; //priv_reg_glob_calendar('date'); if ($date == '') { $date_MySQL = " CURDATE() "; } else { $month = substr($date, 4 ,2); $day = substr($date, 6, 2); $year = substr($date, 0 ,4); $date_MySQL = "'$year-$month-$day'"; } $rqt_date = "select date_format(".$date_MySQL.", '%d') as current_day, date_format(".$date_MySQL.", '%m') as current_month_2, date_format(".$date_MySQL.", '%c') as current_month, date_format(".$date_MySQL.", '%Y') as current_year " ; $resultatdate=pmb_mysql_query($rqt_date); $resdate=pmb_mysql_fetch_object($resultatdate); $current_day = $resdate->current_day; $current_month = $resdate->current_month; $current_month_2 = $resdate->current_month_2; $current_year = $resdate->current_year; $date_MySQL_firstday = "'$year-$current_month_2-01'"; $rqt_date = "select date_format(".$date_MySQL_firstday.", '%w') as first_day_pos, date_format(DATE_SUB(DATE_ADD(".$date_MySQL_firstday.", INTERVAL 1 MONTH),INTERVAL 1 DAY), '%d') as nb_days_month " ; $resultatdate=pmb_mysql_query($rqt_date); $resdate=pmb_mysql_fetch_object($resultatdate); $first_day_pos = $resdate->first_day_pos; $first_day_pos = ($first_day_pos == 0) ? 7 : $first_day_pos; $nb_days_month = $resdate->nb_days_month ; $current_month_name = $monthes_name[$current_month]; /* Ajout ER : détection si date en cours du calendrier correspond ou pas à la date de l'appelant Sans ce test, le lien sur tous les jours identiques d'un autre mois n'étaient pas affichés, exemple : appelant avec date au 04/10/2003 >> lien du 04/11/2003 absent */ $date_MySQL_caller = "'".substr($date_caller, 0 ,4)."-".substr($date_caller, 4 ,2)."-".substr($date_caller, 6 ,2)."'"; $rqt_date = "select date_format(".$date_MySQL_caller.", '%d') as current_day, date_format(".$date_MySQL_caller.", '%c') as current_month, date_format(".$date_MySQL_caller.", '%Y') as current_year "; $resultatdate=pmb_mysql_query($rqt_date); $resdate=pmb_mysql_fetch_object($resultatdate); $caller_day = $resdate->current_day; $caller_month = $resdate->current_month; $caller_year = $resdate->current_year; if (($caller_month==$current_month) && ($caller_year==$current_year) && ($caller_day==$current_day)) $same_date=1; else $same_date=0; if (!$style_calendrier) { $style_calendrier = ''; $output = $style_calendrier ; } else { $output = ''; } if ($form_input_par_jour) $output .= $admin_calendrier_form_mois_start ; $output .= ''; // Displaying the current month/year if ($param['show_month'] == 1) { $output .= ''; $output .= ' "; $output .= ""; } // Building the table row with the days if ($param['show_day'] == 1) { $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; } else { $first_day_pos = 1; } $output .= ''; $int_counter = 0; for ($i = 1; $i < $first_day_pos; $i++) { $output .= ''; $int_counter++; } // Building the table for ($i = 1; $i <= $nb_days_month; $i++) { $i_2 = ($i < 10) ? '0'.$i : $i; if(isset($ouvert[$current_year.'-'.$current_month_2.'-'.$i_2]['commentaire'])) { $commentaire=htmlentities($ouvert[$current_year.'-'.$current_month_2.'-'.$i_2]['commentaire'],ENT_QUOTES, $charset) ; } else { $commentaire=''; } if (isset($ouvert[$current_year.'-'.$current_month_2.'-'.$i_2]['ouvert']) && $ouvert[$current_year.'-'.$current_month_2.'-'.$i_2]['ouvert'] == 1) { $class='lien_date'; $url_maj = $url_maj_base."&action=F&loc=".$loc_id."&date=" ; } else { if (isset($ouvert[$current_year.'-'.$current_month_2.'-'.$i_2]['ouvert']) && $ouvert[$current_year.'-'.$current_month_2.'-'.$i_2]['ouvert'] == 0) { $class = 'lien_date_hs'; } else { $class = ''; } $url_maj = $url_maj_base."&action=O&loc=".$loc_id."&date=" ; } ### Row start if ((($i + $first_day_pos-1) % $param['calendar_columns']) == 1 && $i != 1) { $output .= ""; $int_counter = 0; } if ($form_input_par_jour) { $input_commentaire = " ".str_replace("!!name!!", "comment_".$i_2, $admin_calendrier_form_mois_commentaire) ; $input_commentaire = " ".str_replace("!!commentaire!!", $commentaire, $input_commentaire) ; } else $input_commentaire = "" ; if (($i == $current_day) && ($same_date == 1)) { $output .= ''; } elseif ($param['link_on_day'] != '') { $date_MySQL_loop = "'".$current_year."-".$current_month_2."-".$i_2."'"; $rqt_date = "select case when CURDATE() <= ".$date_MySQL_loop." then 1 ELSE 0 END as test_loop "; $resultatdate=pmb_mysql_query($rqt_date); $resdate=pmb_mysql_fetch_object($resultatdate); $test_loop = $resdate->test_loop; if ($test_loop) { if ($param['link_after_date'] == 0) { $output .= ''; } else { $output .= ''; } } else { if ($param['link_before_date'] == 0) { $output .= ''; } else { $output .= ''; } } } else { $output .= ''; } $int_counter++; // Row end if ( (($i+$first_day_pos-1) % $param['calendar_columns']) == 0 ) { $output .= ''; } } $cell_missing = $param['calendar_columns'] - $int_counter; for ($i = 0; $i < $cell_missing; $i++) { $output .= ''; } $output .= ''; // Display the nav links on the bottom of the table if ($param['nav_link'] == 1) { $date_MySQL = "'$current_year-$current_month-$current_day'"; $rqt_date = "select date_format(DATE_SUB(".$date_MySQL.", INTERVAL 1 YEAR),'%Y%m%d') as previous_month, date_format(DATE_SUB(".$date_MySQL.", INTERVAL 1 MONTH),'%Y%m%d') as previous_day, date_format(DATE_ADD(".$date_MySQL.", INTERVAL 1 YEAR),'%Y%m%d') as next_month, date_format(DATE_ADD(".$date_MySQL.", INTERVAL 1 MONTH),'%Y%m%d') as next_day, case when CURDATE() < date_format(DATE_ADD(".$date_MySQL.", INTERVAL 1 YEAR),'%Y%m%d') then 1 else 0 END as test_next_year, case when CURDATE() < date_format(DATE_ADD(".$date_MySQL.", INTERVAL 1 MONTH),'%Y%m%d') then 1 else 0 END as test_next_month "; $resultatdate=pmb_mysql_query($rqt_date); $resdate=pmb_mysql_fetch_object($resultatdate); $previous_month = $resdate->previous_month; $next_month = $resdate->next_month; $previous_day = $resdate->previous_day; $next_day = $resdate->next_day; $test_next_month = $resdate->test_next_month; $test_next_year = $resdate->test_next_year; if ($param['use_img']) { $g = ''; $gg = ''; $d = ''; $dd = ''; } else { $g = '<'; $gg = '<<'; $d = '>'; $dd = '>>'; } if ( ($param['link_after_date'] == 0) && ($test_next_month) ) { $next_day_link = ' '; } else { $next_day_link = ''.$d.''; } if ( ($param['link_after_date'] == 0) && ($test_next_year) ) { $next_month_link = ' '; } else { $next_month_link = ''.$dd.''; } $output .= ''; $output .= ' '; $output .= ''; } $output .= '
'; $output .= ""; if ($base_url_mois) $output .= ""; if ($param['use_img'] ) $output .= ""; $output .= $current_month_name.' '.$current_year; if ($base_url_mois) $output .= ""; $output .= "
'.$msg[1018].''.$msg[1019].''.$msg[1020].''.$msg[1021].''.$msg[1022].''.$msg[1023].''.$msg[1024].'
 
'.$input_commentaire.''.$i.''.$i.''.$input_commentaire.''.$i.''.$i.''.$input_commentaire.''.$i.''.$input_commentaire.$i.'
 
'; $output .= " ".$gg."   ".$g."   $next_day_link   $next_month_link "; $output .= '
'; if ($form_input_par_jour) { $admin_calendrier_form_mois_end = str_replace ("!!annee_mois!!", $current_year.'-'.$current_month_2, $admin_calendrier_form_mois_end) ; $admin_calendrier_form_mois_end = str_replace ("!!book_location_id!!", $loc_id, $admin_calendrier_form_mois_end) ; $output .= $admin_calendrier_form_mois_end ; } return $output; } function calendar_open_or_close_date($date, $ouverture, $commentaire) { global $faire; global $duplicate_locs, $loc; if($faire=="initialization") { $rqt_date = "delete from ouvertures where date_ouverture='".$date."' and num_location=$loc "; pmb_mysql_query($rqt_date); } else { $rqt_date = "update ouvertures set ouvert=$ouverture, commentaire='$commentaire' where date_ouverture='".$date."' and num_location=$loc "; pmb_mysql_query($rqt_date); if (!pmb_mysql_affected_rows()) { $rqt_date = "insert into ouvertures set ouvert=$ouverture, date_ouverture='".$date."', commentaire='$commentaire', num_location=$loc "; pmb_mysql_query($rqt_date); if (!pmb_mysql_affected_rows()) die ("insert into ouvertures failes") ; } } if (isset($duplicate_locs) && is_array($duplicate_locs)) { foreach ($duplicate_locs as $duplicate_loc) { if($faire=="initialization") { $rqt_date = "delete from ouvertures where date_ouverture='".$date."' and num_location=$duplicate_loc "; pmb_mysql_query($rqt_date); } else { $rqt_date = "update ouvertures set ouvert=$ouverture, commentaire='$commentaire' where date_ouverture='".$date."' and num_location=$duplicate_loc "; pmb_mysql_query($rqt_date); if (!pmb_mysql_affected_rows()) { $rqt_date = "insert into ouvertures set ouvert=$ouverture, date_ouverture='".$date."', commentaire='$commentaire', num_location=$duplicate_loc "; pmb_mysql_query($rqt_date); if (!pmb_mysql_affected_rows()) die ("insert into ouvertures failes") ; } } } } }