IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

[Dates] calendrier interactif : afficher une date


Sujet :

Langage PHP

  1. #1
    Membre averti
    Inscrit en
    Mars 2004
    Messages
    1 911
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 1 911
    Points : 420
    Points
    420
    Par défaut [Dates] calendrier interactif : afficher une date
    Bonjour,

    est il possible en php de faire apparaitre un calendrier et de choisir une date comme sur ce site :http://www.echangersamaison.com/

    ce n est pas de la pub...

    on peut faire apparaitre le calendrier dans l etape 3 de la connexion.

    il faut donc creer un compte bidon...

    merci d avance pour votre aide.

    desole pour les accents, je suis en qwerty ...

  2. #2
    Membre expérimenté
    Avatar de Jumano
    Profil pro
    Inscrit en
    Février 2007
    Messages
    1 163
    Détails du profil
    Informations personnelles :
    Âge : 56
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Février 2007
    Messages : 1 163
    Points : 1 595
    Points
    1 595
    Par défaut
    Bonsoir,
    Ce calendrier sert à quoi, à alimenter un champs date dans un formulaire ?

  3. #3
    Membre à l'essai
    Inscrit en
    Avril 2008
    Messages
    22
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 22
    Points : 24
    Points
    24
    Par défaut
    Oui, il existe de tels calendriers...
    En voici un, de phptools4u, modifié par mes soins :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    <?php
    /**************************************************************************
                 ____  _   _ ____  _              _     _  _   _   _
                |  _ \| | | |  _ \| |_ ___   ___ | |___| || | | | | |
                | |_) | |_| | |_) | __/ _ \ / _ \| / __| || |_| | | |
                |  __/|  _  |  __/| || (_) | (_) | \__ \__   _| |_| |
                |_|   |_| |_|_|    \__\___/ \___/|_|___/  |_|  \___/
                
                           calendrier.php  -  A calendar
                                 -------------------
        begin                : June 2002
        Version	        : 2.1 (Jan 04)
        copyleft           : (C) 2002-2003 PHPtools4U.com - Mathieu LESNIAK
    	email          : support@phptools4u.com
    
     *   This program is free software; you can redistribute it and/or modify
     *   it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation; either version 2 of the License, or
     *   (at your option) any later version.
    **************************************************************************/
     
    /**
    *Ce script à été réutilisé et modifié par Flavien Maheo
    * 1ère fonction calendar : Fonction principale permettant d'afficher un calendrier.
    * 2ème fonction numero_semaine: Fonction permettant de calculer le numéro de la  semaine en fonction du jour sélectionné dans le calendrier.
    * 3ème fonction week_dates: Fonction permettant de récupérer la date des différents jours de la semaine  sous la forme Year-Month-Day afin d'effectuer des requêtes dans la bdd
    * 4ème fonction week_dates2 : Fonction identique à la précedente permettant de récupérer le 1er jour(lundi) et le dernier jour de la semaine (vendredi)  mais sous la forme Day-Month afin d'effectuer un simple affichage de la semaine pour l'utilisateur
     **/
     
     
    ### French Version
    $calendar_txt['french']['monthes'] 	    = array('', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet',
    											'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre');
    $calendar_txt['french']['days']		    = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi',	'Dimanche');
    $calendar_txt['french']['first_day']    = 0;
    $calendar_txt['french']['misc'] 	    = array('Mois précédent', 'Mois suivant','Jour précédent', 'Jour suivant');
     
     
     
    /**
    * Fonction calendar : Fonction principale permettant d'afficher  un calendrier.
    * Elle récupère également les éléments retournés par les fonctions de traitement de date afin de les distribuer aux autres classes et scripts.
    * Elle retourne alors tous les éléments utiles sous la forme d'un tableau ou sont stocké le calendrier à afficher, le numéro de la semaine, ainsi que les différents types de date retournées.
     **/
    function calendar($date = '') {
    	Global $link_on_day, $PHP_SELF, $params;
    	Global $_POST, $_GET;
    	Global $calendar_txt;
    	Global $jour_pointe;
    	Global $current_day_name;
    	Global $current_day;
    	Global $current_month;
    	Global $current_year;
    	Global $current_month_2;
    	Global $tab_debut;
    	Global $tab_fin;
    	Global $totalRows_Recordset1; //nb de periodes de vacances
     
     
    	### Default Params
     
    	$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']		= 1; // Enable link on days after the current day
    	$param_d['link_before_date']	= 1; // Enable link on days before the current day
     
     
    	$param_d['aaaa'] = $_GET['a'];
    	$param_d['clcl'] = $_GET['cl'];
    	$param_d['matmat'] = $_GET['mat'];
    	$param_d['link_on_day']	= 'ctv.php?a=aaaa&date=%%dd%%'.'&cl=clcl&mat=matmat'; // 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']		= '#BBCEDE';
    	$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['use_img']				= 0; // Use gif for nav bar on the bottom
     
     
    	### Spcifique au cahier de texte
    	$param_d['border_color']		= '#0F5080';
    	$param_d['bg_listejour']		= '#BBCEDE';
    	$param_d['bg_top']		        = 'url(./calendrier/bande_bleue.jpg)';
     
     
    	### New params V2
    	$param_d['lang']				= 'french';
    	$param_d['font_highlight_color']= '#FF0000';
    	$param_d['bg_highlight_color']  = '#00FF00';
    	$param_d['day_mode']			= 0;
    	$param_d['time_step']			= 60;
    	$param_d['time_start']			= '8:00';
    	$param_d['time_stop']			= '18:00';
    	$param_d['highlight']			= array();
        // Can be 'hightlight' or 'text'
        $param_d['highlight_type']      = 'highlight';
        $param_d['cell_width']          = 20;
        $param_d['cell_height']         = 20;
        $param_d['short_day_name']      = 1;
        $param_d['link_on_hour']        = $PHP_SELF.'?hour=%%hh%%';
     
    	### /Params
     
     
    	### Getting all params
    	while (list($key, $val) = each($param_d)) {
    		if (isset($params[$key])) {
    			$param[$key] = $params[$key];
    		}
    		else {
    			$param[$key] = $param_d[$key];
    		}
    	}
     
    	$monthes_name = $calendar_txt[$param['lang']]['monthes'];
    	$param['calendar_columns'] = ($param['show_day']) ? 7 : $param['calendar_columns'];
     
        $date = priv_reg_glob_calendar('date');
    	if ($date == '') {
    		$timestamp = time();
    	}
    	else {
    		$month 		= substr($date, 4 ,2);
    		$day 		= substr($date, 6, 2);
    		$year		= substr($date, 0 ,4);
    		$timestamp 	= mktime(0, 0, 0, $month, $day, $year);
    	}
     
     
    	$current_day 		= date("d", $timestamp);
    	$current_month 		= date('n', $timestamp);
    	$current_month_2	= date('m', $timestamp);
    	$current_year 		= date('Y', $timestamp);
        $first_decalage 	= date("w", mktime(0, 0, 0, $current_month, 1, $current_year));
    	### Sunday is the _LAST_ day
    	$first_decalage		= ( $first_decalage == 0 ) ? 7 : $first_decalage;
     
     
    	$current_day_index	= date('w', $timestamp) + $calendar_txt[$param['lang']]['first_day'] - 1;
    	$current_day_index	= ($current_day_index == -1) ? 7 : $current_day_index;
    	$current_day_index	= ($current_day_index == 7) ? 6 : $current_day_index;
    	$current_day_name	= $calendar_txt[$param['lang']]['days'][$current_day_index];
    	$current_month_name = $monthes_name[$current_month];
    	$nb_days_month 		= date("t", $timestamp);
     
    	$current_timestamp 	= mktime(23,59,59,date("m"), date("d"), date("Y"));
     
     
     
     
    	### CSS
    	$output  = '<style type="text/css">'."\n";
    	$output .= '<!--'."\n";
    	$output .= '	.calendarNav'.$param['calendar_id'].' 	{  font-family: '.$param['font_face'].'; font-size: '.($param['font_size']-1).'px; font-style: normal; background-color: '.$param['border_color'].'}'."\n";
    	$output .= '	.calendarTop'.$param['calendar_id'].' 	{  font-family: '.$param['font_face'].'; font-size: '.($param['font_size']+1).'px; font-style: normal; color: '.$param['font_header_color'].'; font-weight: bold;  background-color: '.$param['border_color'].'}'."\n";
    	$output .= '	.calendarToday'.$param['calendar_id'].' {  font-family: '.$param['font_face'].'; font-size: '.$param['font_size'].'px; font-weight: bold; color: '.$param['font_today_color'].'; background-color: '.$param['today_bg_color'].';}'."\n";
    	$output .= '	.calendarDays'.$param['calendar_id'].' 	{  width:'.$param['cell_width'].'; height:'.$param['cell_height'].'; font-family: '.$param['font_face'].'; font-size: '.$param['font_size'].'px; font-style: normal; color: '.$param['font_color'].'; background-color: '.$param['bg_color'].'; text-align: center}'."\n";
    	$output .= '	.calendarHL'.$param['calendar_id'].' 	{  width:'.$param['cell_width'].'; height:'.$param['cell_height'].';font-family: '.$param['font_face'].'; font-size: '.$param['font_size'].'px; font-style: normal; color: '.$param['font_highlight_color'].'; background-color: '.$param['bg_highlight_color'].'; text-align: center}'."\n";
    	$output .= '	.calendarHeader'.$param['calendar_id'].'{  font-family: '.$param['font_face'].'; font-size: '.($param['font_size']-1).'px; background-color: '.$param['font_nav_bg_color'].'; color: '.$param['font_nav_color'].';}'."\n";
    	$output .= '	.calendarTable'.$param['calendar_id'].' {  background-color: '.$param['border_color'].'; border: 0px '.$param['border_color'].' solid}'."\n";
    	$output .= 'a { text-decoration:none; color:black}'."\n";
    	$output .= '-->'."\n";
    	$output .= '</style>'."\n";
    	$output .= '<table border="0" class="calendarTable'.$param['calendar_id'].'"cellpadding="2" cellspacing="1">'."\n";
     
    	### Displaying the current month/year
    	if ($param['show_month'] == 1) {
    		$output .= '<tr>'."\n";
    		$output .= '	<td colspan="'.$param['calendar_columns'].'" align="center" class="calendarTop'.$param['calendar_id'].' " style="background:'.$param['bg_top'].'">'."\n";
    		### Insert an img at will
    		/*if ($param['use_img'] ) {
    			$output .= '<a href="../archive/archive_menu.php" target="_blank"><img src="./calendrier/mois.gif" title="Consulter les archives" alt="Consulter les archives" border="0"></a> ';
    		}*/
    		if ( $param['day_mode'] == 1 ) {
    			$output .= '		'.$current_day_name.' '.$current_day.' '.$current_month_name.' '.$current_year."\n";
    		}
    		else {
    			$output .= '		'.$current_month_name.' '.$current_year."\n";
    		}
    		$output .= '	</td>'."\n";
    		$output .= '</tr>'."\n";
    	}
     
    	### Building the table row with the days
    	if ($param['show_day'] == 1 && $param['day_mode'] == 0) {
    		$output .= '<tr align="center">'."\n";
    		$first_day = $calendar_txt[$param['lang']]['first_day'];
    		for ($i = $first_day; $i < 7 + $first_day; $i++) {
     
    			$index = ( $i >= 7) ? (7 + $i): $i;
    			$index = ($i < 0) ? (7 + $i) : $i;
     
                $day_name = ( $param['short_day_name'] == 1 ) ? substr($calendar_txt[$param['lang']]['days'][$index], 0, 1) : $calendar_txt[$param['lang']]['days'][$index];
    			$output .= '	<td class="calendarHeader'.$param['calendar_id'].'" style="background:'.$param['bg_listejour'].'"><b>'.$day_name.'</b></td>'."\n";
    		}
     
    		$output .= '</tr>'."\n";	
    		$first_decalage = $first_decalage - $calendar_txt[$param['lang']]['first_day'];
    		$first_decalage = ( $first_decalage > 7 ) ? $first_decalage - 7 : $first_decalage;
    	}
    	else {
    		$first_decalage = 0;	
    	}
     
    	$output .= '<tr align="center">';
    	$int_counter = 0;
     
     
    	if ( $param['day_mode'] == 1 ) {
    		list($hour_start, $min_start) 	= explode(':', $param['time_start']);
    		list($hour_end, $min_end)		= explode(':', $param['time_stop']);
    		$ts_start 	= ( $hour_start * 60 ) + $min_start;
    		$ts_end		= ( $hour_end * 60 ) + $min_end;
    		$nb_steps	= ceil( ($ts_end - $ts_start) / $param['time_step'] );
     
    		for ( $i = 0; $i <= $nb_steps; $i++ ) {
                $current_ts		= ($ts_start) + $i * $param['time_step'];
    			$current_hour 	= floor($current_ts / 60);
    			$current_min 	= $current_ts % 60;
    			$current_hour 	= (strlen($current_hour) < 2) ? '0'.$current_hour : $current_hour;
    			$current_min 	= (strlen($current_min) < 2) ? '0'.$current_min : $current_min;
     
       			$highlight_current  = ( isset($param['highlight'][date('Ymd', $timestamp).$current_hour.$current_min]) );
                $css_2_use          = ( $highlight_current ) ? 'HL' : 'Days';
                $txt_2_use          = ( $highlight_current && $param['highlight_type'] == 'text') ? $param['highlight'][date('Ymd', $timestamp).$current_hour.$current_min] : '';
     
    			$output .= '<tr>'."\n";
                if ( $param['link_on_hour'] != '') {
                    $output .= '	<td class="calendar'.$css_2_use.$param['calendar_id'].'" width="10%"><a href="'.str_replace('%%hh%%', date('Ymd', $timestamp).$current_hour.$current_min, $param['link_on_hour']).'">'.$current_hour.':'.$current_min.'</a></td>'."\n";
                }
                else {
                    $output .= '	<td class="calendar'.$css_2_use.$param['calendar_id'].'" width="10%">'.$current_hour.':'.$current_min.'</td>'."\n";
                }
    			$output .= '    <td class="calendar'.$css_2_use.$param['calendar_id'].'">'.$txt_2_use.'</td>	'."\n";
    			$output .= '</tr>'."\n";	
    		}
     
    	}
    	else {
    		# Filling with empty cells at the begining
    		for ($i = 1; $i < $first_decalage; $i++) {
    			$output .= '<td class="calendarDays'.$param['calendar_id'].'">&nbsp;</td>'."\n";
    			$int_counter++;
    		}
    		### Building the table
    		for ($i = 1; $i <= $nb_days_month; $i++) {
    			### Do we highlight the current day ?
    			$i_2 = ($i < 10) ? '0'.$i : $i;		
    		    $highlight_current = ( isset($param['highlight'][date('Ym', $timestamp).$i_2]) );	
    			### Row start
    			if ( ($i + $first_decalage) % $param['calendar_columns'] == 2 && $i != 1) {
    				$output .= '<tr align="center">'."\n";
    				$int_counter = 0;
    			}
     
    			$css_2_use = ( $highlight_current ) ? 'HL' : 'Days';
                $txt_2_use = ( $highlight_current && $param['highlight_type'] == 'text') ? '<br>'.$param['highlight'][date('Ym', $timestamp).$i_2] : '';
     
    //################# VACANCES #################		
     
     
     	$nv=0;$pv=0;
       	$code_d=$current_year.$current_month_2.$i_2;
     do { 
    	$nv=$nv+1;	
     
    	if (($code_d>=$tab_debut[$nv])&&($code_d<=$tab_fin[$nv])) { $pv=1;} 
     
    	}	  
    	while ($nv<$totalRows_Recordset1); 
     
     //##############################################
     
                if ($i == $current_day) { 
    	$output .= '<td ';
    //	if ($pv==1){ $output .=' bgcolor="#CCCCCC"> <span style="font-size: 10px ; font-weight: bold ; color: #990000; background-color: #A0C0C0;">'.$i.'</span>';} 
    if ($pv==1){ $output .=' class="calendarToday1"> '.$i;} 
    	else {
    	$numSemaine = numero_semaine($current_day,$current_month,$current_year);
     
    	$numjour = week_dates($numSemaine,$current_year);
     
    	$param['link_on_day']= 'ctv.php?a='.$param['aaaa'].'&date=%%dd%%'.'&cl='.$param['clcl'].'&mat='.$param['matmat']; // Link to put on each day
     
     
     
    	$output .= 'class="calendarToday'.$param['calendar_id'].'" align="center"><a href="'.str_replace('%%dd%%', $current_year.$current_month_2.$i_2,$param['link_on_day']).'">'.$i.$txt_2_use.'</A></td>'."\n";
    	}
    $jour_pointe= $current_day_name. '    '.$i. '    '.$current_month_name. '    '.$current_year; 
    				$jj=$i;
    			}
    			elseif ($param['link_on_day'] != '') {
    				$loop_timestamp = mktime(0,0,0, $current_month, $i, $current_year);
     
    				if (( ($param['link_after_date'] == 0) && ($current_timestamp < $loop_timestamp)) || (($param['link_before_date'] == 0) && ($current_timestamp >= $loop_timestamp)) ){
    					$output .= '<td class="calendar'.$css_2_use.$param['calendar_id'].'">'.$i.$txt_2_use.'</td>'."\n";
    				}
    				else {
     
    					$output .= '<td ';
     
    	//coloration vacances				
     
    	if ($pv==1){ $output .=' bgcolor="#CCCCFF"> <span style="font-size: 10px">'.$i.'</span>';} 
    	else {
     
    		//on recupère le numéro de la semaine en fonction du jour sélectionné dans le calendrier ($i_2)
    		$numSemaine = numero_semaine($i_2,$current_month,$current_year);
    		//puis avec ce numéro de semaine, on calcul la date du lundi et du vendredi de celle-ci
    		$numjour = week_dates($numSemaine,$current_year);
    		//lien à mettre dans l'url de la page pour chaque jour sélectionné
    		$param['link_on_day']= 'ctv.php?a='.$param['aaaa'].'&date=%%dd%%'.'&cl='.$param['clcl'].'&mat='.$param['matmat'];
     
     
    		$output .='class="calendarDays1"'.'"><a href="'.str_replace('%%dd%%', $current_year.$current_month_2.$i_2,$param['link_on_day']).'">'.$i.'</a>';}
     
    			$output .=$txt_2_use;
    			$output .='</td>'."\n";
    				}
    			}
    			else {
    				$output .= '<td class="calendar'.$css_2_use.$param['calendar_id'].'">'.$i.'</td>'."\n";
    			}	
    			$int_counter++;
     
    			### Row end
    			if (  ($i + $first_decalage) % ($param['calendar_columns'] ) == 1 ) {
    				$output .= '</tr>'."\n";	
    			}
    		}
    		$cell_missing = $param['calendar_columns'] - $int_counter;
     
    		for ($i = 0; $i < $cell_missing; $i++) {
    			$output .= '<td class="calendarDays'.$param['calendar_id'].'">&nbsp;</td>'."\n";
    		}
    		$output .= '</tr>'."\n";
    	}
    	### Display the nav links on the bottom of the table
    	if ($param['nav_link'] == 1) {
    		$previous_month = date("Ymd", 	
    								mktime( 12, 
    										0, 
    										0, 
    										($current_month - 1),
    										$current_day,
    										$current_year
    									   )
    								);
     
    		$previous_day 	= date("Ymd", 	
    								mktime( 12, 
    										0, 
    										0, 
    										$current_month,
    										$current_day - 1,
    										$current_year
    									   )
    								);
    		$next_day 		= date("Ymd", 	
    								mktime( 1, 
    										12, 
    										0, 
    										$current_month,
    										$current_day + 1,
    										$current_year
    									   )
    								);
    		$next_month		= date("Ymd", 	
    								mktime( 1, 
    										12, 
    										0, 
    										$current_month + 1,
    										$current_day,
    										$current_year
    									   )
    								);
     
     
    		if ($param['use_img']) {
    			$g 	= '<img src="./calendrier/g.gif" border="0">';//"jour précèdant"
    			$gg = '<img src="./calendrier/gg.gif" border="0">';//"mois précèdant"
    			$d 	= '<img src="./calendrier/d.gif" border="0">';//"prochain jour"
    			$dd = '<img src="./calendrier/dd.gif" border="0">';//"prochain mois"
    		}
    		else {
    			$g 	= '&lt;';
    			$gg = '&lt;&lt;';
    			$d = '&gt;';
    			$dd = '&gt;&gt;';
    		}
     
    		if ( ($param['link_after_date'] == 0) 
    				&& ($current_timestamp < mktime(0,0,0, $current_month, $current_day+1, $current_year))
    			) {
    			$next_day_link = '&nbsp;';
    		}
    		else {
     
    			//on recupère le numéro de la semaine lorsque l'utilisateur à selectionner l'icone "prochain jour" dans le calendrier
    			$numSemaine = numero_semaine($current_day+1,$current_month,$current_year);
     
    			//puis avec ce numéro de semaine, on calcul la date du lundi et du vendredi de celle-ci
    			$numjour = week_dates($numSemaine,$current_year);
     
    			//lien à mettre dans l'url de la page pour "prochain jour" sélectionné
    			$next_day_link ='<a href="ctv.php?a='.$param['aaaa'].'&date='.$next_day.'&cl='.$param['clcl'].'&mat='.$param['matmat'].'" title="'.$calendar_txt[$param['lang']]['misc'][3].'">'.$d.'</a>'."\n";
    		}
     
    		if ( ($param['link_before_date'] == 0) 
    				&& ($current_timestamp > mktime(0,0,0, $current_month, $current_day-1, $current_year))
    			){
    			$previous_day_link = '&nbsp;';
    		}
    		else {
     
    			//on recupère le numéro de la semaine lorsque l'utilisateur à selectionner l'icone "jour précèdant" dans le calendrier
    			$numSemaine = numero_semaine($current_day,$current_month,$current_year);
     
    			//puis avec ce numéro de semaine, on calcul la date du lundi et du vendredi de celle-ci
    			$numjour = week_dates($numSemaine,$current_year);
     
    			//lien à mettre dans l'url de la page pour "jour précèdant" sélectionné
    			$previous_day_link 		= '<a href="ctv.php?a='.$param['aaaa'].'&date='.$previous_day.'&cl='.$param['clcl'].'&mat='.$param['matmat'].'" title="'.$calendar_txt[$param['lang']]['misc'][2].'">'.$g.'</a>'."\n";
    		}
     
    		if ( ($param['link_after_date'] == 0) 
    				&& ($current_timestamp < mktime(0,0,0, $current_month+1, $current_day, $current_year))
    			) {
    			$next_month_link = '&nbsp;';		
    		}
    		else {
     
    		    //on recupère le numéro de la semaine lorsque l'utilisateur à selectionner l'icone "prochain mois" dans le calendrier
    			$numSemaine = numero_semaine($current_day,$current_month+1,$current_year);
     
    			//puis avec ce numéro de semaine, on calcul la date du lundi et du vendredi de celle-ci
    			$numjour = week_dates($numSemaine,$current_year);
     
    			//lien à mettre dans l'url de la page pour "prochain mois" sélectionné
    			$next_month_link 	= '<a href="ctv.php?a='.$param['aaaa'].'&date='.$next_month.'&cl='.$param['clcl'].'&mat='.$param['matmat'].'" title="'.$calendar_txt[$param['lang']]['misc'][1].'">'.$dd.'</a>'."\n";
    		}
     
    		if  ( ($param['link_before_date'] == 0) 
    				&& ($current_timestamp >= mktime(0,0,0, $current_month-1, $current_day, $current_year))
    			){
    			$previous_month_link = '&nbsp;';		
    		}
    		else {
     
    			 //on recupère le numéro de la semaine lorsque l'utilisateur à selectionner l'icone "mois précèdant" dans le calendrier
    			$numSemaine = numero_semaine($current_day,$current_month-1,$current_year);
     
    			//puis avec ce numéro de semaine, on calcul la date du lundi et du vendredi de celle-ci
    			$numjour = week_dates($numSemaine,$current_year);
     
    			//lien à mettre dans l'url de la page pour "mois précèdant" sélectionné
    			$previous_month_link 	= '<a href="ctv.php?a='.$param['aaaa'].'&date='.$previous_month.'&cl='.$param['clcl'].'&mat='.$param['matmat'].'" title="'.$calendar_txt[$param['lang']]['misc'][0].'">'.$gg.'</a>'."\n";
    		}
     
    		//variable d'affichage du calendrier
    		$output .= '<tr>'."\n";
    		$output .= '	<td colspan="'.$param['calendar_columns'].'" class="calendarDays'.$param['calendar_id'].'">'."\n";
    		$output .= '		<table width="100%" border="0" >';
    		$output .= '		<tr>'."\n";
    		$output .= '			<td width="25%" align="left" class="calendarDays'.$param['calendar_id'].'">'."\n";
    		$output .= 					$previous_month_link;
    		$output .= '			</td>'."\n";
    		$output .= '			<td width="25%" align="center" class="calendarDays'.$param['calendar_id'].'">'."\n";
    		$output .= 					$previous_day_link;
    		$output .= '			</td>'."\n";
    		$output .= '			<td width="25%" align="center" class="calendarDays'.$param['calendar_id'].'">'."\n";
    		$output .= 					$next_day_link;
    		$output .= '			</td>'."\n";
    		$output .= '			<td width="25%" align="right" class="calendarDays'.$param['calendar_id'].'">'."\n";
    		$output .= 					$next_month_link;
    		$output .= '			</td>'."\n";
    		$output .= '		</tr>';
    		$output .= '		</table>';
    		$output .= '	</td>'."\n";
    		$output .= '</tr>'."\n";
    		$output .= '</table>'."\n";
     
    	}
     
    	//le calendrier est stocké dans la 1ère case du tableau
    	$tab[0]=$output;
     
    	//on récupère le numéro de semaine correspondant au jour sélectionné dans le calendrier
    	$numSemaine = numero_semaine($current_day,$current_month,$current_year);
    	//puis on le stocke dans la 2ème case du tableau
    	$tab[1]=$numSemaine;
     
    	//on récupère sous la forme d'un  tableau les dates correspondant aux jours de la semaine sous la forme Year-Month-Day (requètes mySQL)
    	$numjour = week_dates($numSemaine,$current_year);
    	//puis on stocke dans les cases réspéctives du tableau les dates de la semaine
    	$tab[2] = $numjour[1];//lundi
    	$tab[12] = $numjour[2]; //mardi
    	$tab[13] = $numjour[3]; //mercredi
    	$tab[14] = $numjour[4]; //jeudi
    	$tab[3] = $numjour[5];//vendredi
     
    	//on récupère sous la forme d'un tableau les dates correspondant correspondant aux jours de la semaine sous la forme Day-Month (affichage)
    	$numjouraffiche = week_dates2($numSemaine,$current_year);
    	//puis on stocke dans les cases réspéctives du tableau les dates de la semaine
    	$tab[4] = $numjouraffiche[1];//lundi
    	$tab[5] = $numjouraffiche[2];//vendredi
     
    	//On stocke dans la 16ème case du tableau la date sous la forme YearMonthDay
    	$tab[15] = $current_year.$current_month_2.$current_day;  
     
    	//puis on retourne le tableau
    	return $tab;
     
    }
     
    function priv_reg_glob_calendar($var) {
    	Global $_GET, $_POST;
     
    	if (isset($_GET[$var])) {
    		return $_GET[$var];
    	}
    	elseif (isset($_POST[$var])) {
    		return $_POST[$var];
    	}
    	else {
    		return '';
    	}	
    }
     
     
    /**
     * Fonction permettant de calculer le numéro de la  semaine en fonction du jour sélectionné dans le calendrier.
     * Retourne le numéro de la semaine
     * paramètres : le jour, le mois, l'année 
     **/ 
    function numero_semaine($jour,$mois,$annee)
    {
        /*
         * Norme ISO-8601:
         * - La semaine 1 de toute année est celle qui contient le 4 janvier ou que la semaine 1 de toute année est celle qui contient le 1er jeudi de janvier.
         * - La majorité des années ont 52 semaines mais les années qui commence un jeudi et les années bissextiles commençant un mercredi en possède 53.
         * - Le 1er jour de la semaine est le Lundi
         */ 
     
        // Définition du Jeudi de la semaine
        if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche
            $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60;
        else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) // du Lundi au Mercredi
            $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60;
        else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) // du Vendredi au Samedi
            $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60;
        else // Jeudi
            $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee);
     
        // Définition du premier Jeudi de l'année
        if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche
        {
            $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60;
        }
        else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) // du Lundi au Mercredi
        {
            $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60;
        }
        else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) // du Vendredi au Samedi
        {
            $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60;
        }
        else // Jeudi
        {
            $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine));
        }
     
        // Définition du numéro de semaine: nb de jours entre "premier Jeudi de l'année" et "Jeudi de la semaine";
        $numeroSemaine =     ( 
                        ( 
                            date("z",mktime(12,0,0,date("m",$jeudiSemaine),date("d",$jeudiSemaine),date("Y",$jeudiSemaine))) 
                            -
                            date("z",mktime(12,0,0,date("m",$premierJeudiAnnee),date("d",$premierJeudiAnnee),date("Y",$premierJeudiAnnee))) 
                        ) / 7 
                    ) + 1;
     
        // Cas particulier de la semaine 53
        if ($numeroSemaine==53)
        {
            // Les années qui commence un Jeudi et les années bissextiles commençant un Mercredi en possède 53
            if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==4 || (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==3 && date("z",mktime(12,0,0,12,31,date("Y",$jeudiSemaine)))==365))
            {
                $numeroSemaine = 53;
            }
            else
            {
                $numeroSemaine = 1;
            }
        }
     
        return sprintf("%02d",$numeroSemaine);
    }
     
     
     
    /**
    * Fonction permettant de récupérer la date des différents jours de la semaine  sous la forme Year-Month-Day afin d'effectuer des requêtes dans la bdd
    * Retourne un tableau comprenant les dates des différents jours de la semaine en particulier la date de début de semaine (lundi) et de fin de semaine(vendredi)
    * paramètres : le numéro de la semaine, l'année.	 
    **/ 
    function week_dates($week,$year) {
    $week_dates = array();
    // Get timestamp of first week of the year
    $first_day = mktime(12,0,0,1,1,$year);
    $first_week = date("W",$first_day);
    if ($first_week > 1) {
    $first_day = strtotime("+1 week",$first_day); // skip to next if year does not begin with week 1
    }
    // Get timestamp of the week
    $timestamp = strtotime("+$week week",$first_day);
     
    // Adjust to Monday of that week
     $what_day = date("w",$timestamp);
        if ($what_day==0) {
          // actually Sunday, last day of the week. FIX;
            $timestamp = strtotime("-6 days",$timestamp);
        } elseif ($what_day > 1) {
           $what_day--;
           $timestamp = strtotime("-$what_day days",$timestamp);
       }
        $week_dates[1] = date("Y-m-d",strtotime("-7 day",$timestamp));//lundi
        $week_dates[2] = date("Y-m-d",strtotime("-6 day",$timestamp));//mardi
    	$week_dates[3] = date("Y-m-d",strtotime("-5 day",$timestamp));//mercredi
    	$week_dates[4] = date("Y-m-d",strtotime("-4 day",$timestamp));//jeudi
    	$week_dates[5] = date("Y-m-d",strtotime("-3 day",$timestamp));//vendredi 
     
       return($week_dates);
     }
     
     
    /**
    * Fonction identique à la précédente permettant de récupérer le 1er jour(lundi) et le dernier jour de la semaine (vendredi)  mais sous la forme Day-Month afin d'effectuer un simple affichage de la semaine pour l'utilisateur
    * Retourne un tableau comprenant les dates du lundi et du vendredi de la semaine.
    * paramètres : le numéro de la semaine, l'année.	 
    **/ 
    function week_dates2($week,$year) {
    $week_dates2 = array();
    // Get timestamp of first week of the year
    $first_day = mktime(12,0,0,1,1,$year);
    $first_week = date("W",$first_day);
    if ($first_week > 1) {
    $first_day = strtotime("+1 week",$first_day); // skip to next if year does not begin with week 1
    }
    // Get timestamp of the week
    $timestamp = strtotime("+$week week",$first_day);
     
    // Adjust to Monday of that week
     $what_day = date("w",$timestamp); // I wanted to do "N" but only version 4.3.9 is installed :-(
        if ($what_day==0) {
          // actually Sunday, last day of the week. FIX;
            $timestamp = strtotime("-6 days",$timestamp);
        } elseif ($what_day > 1) {
           $what_day--;
           $timestamp = strtotime("-$what_day days",$timestamp);
       }
        $week_dates2[1] = date("d-m",strtotime("-7 day",$timestamp)); // lundi
        $week_dates2[2] = date("d-m",strtotime("-3 day",$timestamp)); // vendredi
     
       return($week_dates2);
     }
    ?>
    Voila, désolé le code est long...

  4. #4
    Membre à l'essai
    Inscrit en
    Avril 2008
    Messages
    22
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 22
    Points : 24
    Points
    24
    Par défaut
    Désolé pour le double post, mais le code est vraiment très très long :

    Ensuite tu appelles le calendrier de cette façon (dans ta page qui l'affiche) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
     <?php
    				include_once ("./calendrier/calendrier.php");
    				$tablo= calendar();
     
     
    				echo $tablo[0];
     
    				$lundi = $tablo[2];
    				$vendredi = $tablo[3];
    				$current_day = $tablo[15];
     
    				$affich_lundi = $tablo[4];
    				$affich_vendredi = $tablo[5];
     
    				$numeroSemaine= $tablo[1];
    				echo "<br /><strong>Semaine $numeroSemaine </strong>";
     
    				?>

  5. #5
    Membre averti
    Inscrit en
    Mars 2004
    Messages
    1 911
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 1 911
    Points : 420
    Points
    420
    Par défaut
    merci pour le code, je vais le tester.
    par contre ce au je trouve original dans le site que j ai donne en exemple plus haut c est au moment ou je clique sur le bouton du formulaire,
    je ne change pas de page mais il y a un petit calendrier qui s affiche.
    ensuite je choisi ma date et la date que j ai selectionnee s affcihe sur le formulaire. Apparemment dans ton exemple on change de page...

  6. #6
    Membre averti
    Profil pro
    Développeur Web
    Inscrit en
    Septembre 2004
    Messages
    352
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Septembre 2004
    Messages : 352
    Points : 434
    Points
    434
    Par défaut
    Dans ce cas, c'est un calendrier en Javascript qu'il te faut comme calendarPopUp.

  7. #7
    Membre expérimenté
    Avatar de Jumano
    Profil pro
    Inscrit en
    Février 2007
    Messages
    1 163
    Détails du profil
    Informations personnelles :
    Âge : 56
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Février 2007
    Messages : 1 163
    Points : 1 595
    Points
    1 595
    Par défaut
    Regarde ici ou alors ici

Discussions similaires

  1. [Calendrier] afficher une date textuel à partir d'une entrée "date"
    Par Djsarkndp dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 2
    Dernier message: 26/03/2009, 12h22
  2. Réponses: 4
    Dernier message: 26/08/2008, 17h11
  3. Gérer l'ensemble des dates entre une date de début et une date de fin
    Par shaun_the_sheep dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 25/04/2008, 11h13
  4. Réponses: 7
    Dernier message: 22/11/2006, 09h14
  5. Réponses: 1
    Dernier message: 18/08/2006, 10h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo