Partage
  • Partager sur Facebook
  • Partager sur Twitter

Calendrier de tâches en PHP

    23 mai 2018 à 13:59:04

    Bonjour,

    Je souhaite faire un calendrier de tâches en php. j'en est déjà fait un mais il ne prend pas en compte plusieurs cas particulier et n'est pas du tout du tout optimisé. j'en appel donc à vos connaissances pour me venir en aide. 

    le calendrier ressemble à ça :

    C'est un tableau. Chaque ligne correspond à une tâche. chaque case à la réalisation de la tâche. Une tâche peux se réaliser chaque jours, 1 fois par semaine, 2 fois par semaine, 1 fois toutes les 2 semaines. 

    Aujourd'hui je ne fait une vérification que des taches qui se font chaque jour.

    Voici mon code (très/trop lourd et pas dynamique). Quand je dois rajouter une tache, je dois le faire a la main. il faudrait que ça soit automatique :

    <table class="table table-bordered" width="100%" id="dataTable" cellspacing="0">
                                        <thead>
                                            <tr>
                                                <th width="300px" rowspan="2">
                                                    <center>Activitees </center>
                                                </th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "01")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S01</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "02")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S02</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "03")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S03</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "04")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S04</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "05")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S05</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "06")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S06</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "07")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S07</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "08")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S08</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "09")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S09</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "10")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S10</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "11")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S11</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "12")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S12</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "13")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S13</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "14")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S14</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "15")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S15</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "16")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S16</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "17")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S17</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "18")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S18</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "19")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S19</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "20")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S20</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "21")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S21</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "22")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S22</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "23")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S23</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "24")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S24</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "25")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S25</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "26")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S16</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "27")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S27</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "28")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S28</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "29")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S29</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "30")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S30</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "31")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S31</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "32")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S32</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "33")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S33</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "34")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S34</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "35")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S35</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "36")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S36</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "37")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S37</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "38")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S38</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "39")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S39</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "40")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S40</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "41")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S41</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "42")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S42</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "43")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S43</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "44")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S44</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "45")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S45</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "46")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S46</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "47")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S47</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "48")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S48</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "49")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S49</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "50")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S50</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "51")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S51</th>
                                                <th colspan="7" <?php if(strcmp(gmdate( "W"), "52")==0 ){echo ( 'style="background-color:#EDFA31"'); } ?> >S52</th>
    
                                            </tr>
                                            <tr>
    
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                                <th width="70px">L</th>
                                                <th width="70px">Ma</th>
                                                <th width="70px">Me</th>
                                                <th width="70px">J</th>
                                                <th width="70px">V</th>
                                                <th width="70px">S</th>
                                                <th width="70px">D</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                try {
                                	$PDO = new PDO('mysql:host=localhost;dbname=authentification', 'root', '12c02P73');
                                }
                                catch (Exception $e) {
                                	die("L'accès à  la base de donnée est impossible.");
                                }
                                
                                ?>
    
                                                <tr>
                                                    <td><a href="/pages/FAI/ActivitenumeroXXX/ActivitenumeroXXX.php"><i class="fa fa-fw fa-circle" style="color:blue"></i><span class="number" style="color:blue"><?php echo $number=$PDO->query('SELECT COUNT(*) FROM notif WHERE ouvert = 0 AND titre = "ActivitenumeroXXX";')->fetchColumn();?></span> | Nokia_TD_19</a>                                                    </td>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 1;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Monday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Tuesday FROM ActivitenumeroXXX WHERE numero_semaine = 1;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Tuesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Wednesday FROM ActivitenumeroXXX WHERE numero_semaine = 1;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Wednesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Thursday FROM ActivitenumeroXXX WHERE numero_semaine = 1;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Thursday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Friday FROM ActivitenumeroXXX WHERE numero_semaine = 1;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Friday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <td style="background-color:#EFEEEC;"></td>
                                                    <td style="background-color:#EFEEEC;"></td>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 2;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Monday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Tuesday FROM ActivitenumeroXXX WHERE numero_semaine = 2;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Tuesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Wednesday FROM ActivitenumeroXXX WHERE numero_semaine = 2;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Wednesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Thursday FROM ActivitenumeroXXX WHERE numero_semaine = 2;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Thursday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Friday FROM ActivitenumeroXXX WHERE numero_semaine = 2;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Friday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <td style="background-color:#EFEEEC;"></td>
                                                    <td style="background-color:#EFEEEC;"></td>
    
                                                    <?php                                                                                
                    $r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 3;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Monday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Tuesday FROM ActivitenumeroXXX WHERE numero_semaine = 3;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Tuesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Wednesday FROM ActivitenumeroXXX WHERE numero_semaine = 3;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Wednesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Thursday FROM ActivitenumeroXXX WHERE numero_semaine = 3;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Thursday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Friday FROM ActivitenumeroXXX WHERE numero_semaine = 3;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Friday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <td style="background-color:#EFEEEC;"></td>
                                                    <td style="background-color:#EFEEEC;"></td>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 4;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Monday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Tuesday FROM ActivitenumeroXXX WHERE numero_semaine = 4;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Tuesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Wednesday FROM ActivitenumeroXXX WHERE numero_semaine = 4;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Wednesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Thursday FROM ActivitenumeroXXX WHERE numero_semaine = 4;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Thursday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Friday FROM ActivitenumeroXXX WHERE numero_semaine = 4;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Friday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                    <td style="background-color:#EFEEEC;"></td>
                                                    <td style="background-color:#EFEEEC;"></td>
    
                                                    <?php
                    $r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 5;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Monday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Tuesday FROM ActivitenumeroXXX WHERE numero_semaine = 5;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Tuesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Wednesday FROM ActivitenumeroXXX WHERE numero_semaine = 5;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Wednesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Thursday FROM ActivitenumeroXXX WHERE numero_semaine = 5;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Thursday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Friday FROM ActivitenumeroXXX WHERE numero_semaine = 5;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Friday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <td style="background-color:#EFEEEC;"></td>
                                                        <td style="background-color:#EFEEEC;"></td>
                                                        <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 6;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Monday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Tuesday FROM ActivitenumeroXXX WHERE numero_semaine = 6;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Tuesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Wednesday FROM ActivitenumeroXXX WHERE numero_semaine = 6;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Wednesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Thursday FROM ActivitenumeroXXX WHERE numero_semaine = 6;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Thursday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Friday FROM ActivitenumeroXXX WHERE numero_semaine = 6;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Friday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                        <td style="background-color:#EFEEEC;"></td>
                                                        <td style="background-color:#EFEEEC;"></td>
                                                        <?php
                    $r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 7;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Monday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Tuesday FROM ActivitenumeroXXX WHERE numero_semaine = 7;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Tuesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Wednesday FROM ActivitenumeroXXX WHERE numero_semaine = 7;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Wednesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Thursday FROM ActivitenumeroXXX WHERE numero_semaine = 7;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Thursday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Friday FROM ActivitenumeroXXX WHERE numero_semaine = 7;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Friday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <td style="background-color:#EFEEEC;"></td>
                                                            <td style="background-color:#EFEEEC;"></td>
                                                            <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 8;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Monday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Tuesday FROM ActivitenumeroXXX WHERE numero_semaine = 8;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Tuesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Wednesday FROM ActivitenumeroXXX WHERE numero_semaine =8;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Wednesday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <?php 
    								
    							
    								$r = $PDO->prepare("SELECT Thursday FROM ActivitenumeroXXX WHERE numero_semaine = 8;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Thursday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <?php 
    								
    								
    								$r = $PDO->prepare("SELECT Friday FROM ActivitenumeroXXX WHERE numero_semaine = 8;");
    								$r->execute();
    								$re = $r->fetchAll();
    								if ($re[0]['Friday'] == 1) {echo '<td style="background-color:#6CBB3C;"></td>'; }else {echo '<td style="background-color:#EB1000;"></td>'; } ?>
                                                            <td style="background-color:#EFEEEC;"></td>
                                                            <td style="background-color:#EFEEEC;"></td>
                                                            <?php $r = $PDO->prepare("SELECT Monday FROM ActivitenumeroXXX WHERE numero_semaine = 9;");
    

    (Je suis désolée de l'indentation, problème de copier coller.)

    Chaque tâche est une table de ma base de donnée contenant chaque semaine de S1 à S51 comme suit :

    Comme dit plus tôt cela fonctionne pour les tâches qui se font tout les jours mais ça se complique pour les autres types de tâches. 

    Pouvez vous m'aider ?

    -
    Edité par dikdableu 23 mai 2018 à 14:00:43

    • Partager sur Facebook
    • Partager sur Twitter
      23 mai 2018 à 14:47:43

      en effet, pas dynamique et structure de la base de données très mauvaise.

      Voilà ce que j'avais fait pour un client, qui est sans aucun doute ce que tu recherches  :

      http://antoineoffroy.esy.es/planning/index.php

      Dis moi si cette structure te convient, et on pourra voir ensemble

      • Partager sur Facebook
      • Partager sur Twitter
      Souvent, le problème se trouve devant l'écran :)
        23 mai 2018 à 15:20:52

        michael-62 a écrit:

        en effet, pas dynamique et structure de la base de données très mauvaise.

        Effectivement :)

        michael-62 a écrit:

        Voilà ce que j'avais fait pour un client, qui est sans aucun doute ce que tu recherches  :

        http://antoineoffroy.esy.es/planning/index.php

        Dis moi si cette structure te convient, et on pourra voir ensemble

        Le problème, c'est que c'est divisé par heure et non par jours. J'avais décidé de séparer en semaine S1 à S51 pour éviter les problèmes de jours fériés.

        En fait, j'ai un prestataire à qui je commande des comptes-rendus (les fameuses tâches) qu'il me doit tous les jours, 1 fois par semaine, etc. Je lui ai créé une page de soumissions de comptes-rendus par tâches.

        Quand il me rend un compte-rendu ça incrémente un compteur dans ma base de données (cf dernière image du premier poste). Mon tableau regarde si chaque jour s'il y a un 1 alors il a remis le compte-rendu et la case passe au vert et s'il ne l'a pas fait ça reste rouge.

        Mais j'aimerais simplifier le code et faire en sorte que ça soit dynamique et que ça prenne en compte les différents types de tâche.

        -
        Edité par dikdableu 23 mai 2018 à 15:24:09

        • Partager sur Facebook
        • Partager sur Twitter
          23 mai 2018 à 15:30:36

          Que ça soit heure, ou jour ça revient au même, avec la fonction date tu peux faire des miracles, des tris sur les jours, les semaines, ce que tu veux. Car là avec cette structure tu fais comment quand tu passeras au 1er janvier 2019 ? tu recréais à la main 54 lignes ? tu vas les écraser ? non ce qu'il faut c'est trier et exploiter par rapport au type DATE. J'ai juste qu'à changer quelques lignes dans mon code pour obtenir comme toi.

          Pour tes cases rouges, tu insères dans ta base de données la date avec la condition si la date existe alors c'est rouge sinon c'est vert par exemple. Car au fond les 0 ne servent à rien.

          Après tu peux par exemple afficher le numéro de la semaine, les 14 prochains jours par exemple et j'en passe..

          Le seul truc qu'il ne gère pas directement en effet ce sont les jours fériés, mais après pourquoi ne pas faire une liste de jours fériés pour griser les cases, possible.

          -
          Edité par michael-62 23 mai 2018 à 15:32:28

          • Partager sur Facebook
          • Partager sur Twitter
          Souvent, le problème se trouve devant l'écran :)
            23 mai 2018 à 15:32:23

            michael-62 a écrit:

            Que ça soit heure, ou jour ça revient au même, avec la fonction date tu peux faire des miracles, des tris sur les jours, les semaines, ce que tu veux. Car là avec cette structure tu fais comment quand tu passeras au 1er janvier 2019 ? tu recréais à la main 54 lignes ? tu vas les écraser ? non ce qu'il faut c'est trier et exploiter par rapport au type DATE. J'ai juste qu'à changer quelques lignes dans mon code pour obtenir comme toi.

            Pour tes cases rouges, tu insères dans ta base de données la date avec la condition si la date existe alors c'est rouge sinon c'est vert par exemple. Car au fond les 0 ne servent à rien.

            Après tu peux par exemple afficher le numéro de la semaine, les 14 prochains jours par exemple et j'en passe..

            Je n'avais pas vu les choses comme ça. Effectivement ça serait parfait. mais j'ai du mal à voir à quoi ça ressemblerait 
            • Partager sur Facebook
            • Partager sur Twitter
              23 mai 2018 à 15:46:35

              On voit ça ensemble ce soir. Je t'enverrai un message.
              • Partager sur Facebook
              • Partager sur Twitter
              Souvent, le problème se trouve devant l'écran :)
                24 mai 2018 à 9:00:47

                Salut, 

                Si ça t’intéresse, il y a https://fullcalendar.io/  qui est pas mal je trouve 

                • Partager sur Facebook
                • Partager sur Twitter
                Développeur PHP | Laravel
                  24 mai 2018 à 9:59:08

                  KevinLabre a écrit:

                  Salut, 

                  Si ça t’intéresse, il y a https://fullcalendar.io/  qui est pas mal je trouve 


                  J'avais déjà tenté de le mettre en place mais je n'ai réussi a mettre en place la notion de récurrence (automatiquement, sans avoir a rentrer les événements a la main).

                  • Partager sur Facebook
                  • Partager sur Twitter

                  Calendrier de tâches en PHP

                  × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                  × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                  • Editeur
                  • Markdown