Project

General

Profile

groupe_interclasses_modif.php

Cédric Frayssinet, 10/05/2015 04:01 PM

Download (16.5 KB)

 
1
<?php 
2

    
3
include "../authentification/authcheck.php" ;
4
if (($_SESSION['droits']<>1)&&($_SESSION['droits']<>2)&&($_SESSION['droits']<>3)&&($_SESSION['droits']<>8)) { header("Location: ../index.php");};
5

    
6
require_once('../Connections/conn_cahier_de_texte.php');
7
require_once('../inc/functions_inc.php');
8

    
9

    
10
$editFormAction = '#';
11
if (isset($_SERVER['QUERY_STRING'])) {
12
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
13
}
14
$datetoday=date('y-m-d');
15

    
16
mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
17
$query_RsClasse = "SELECT * FROM cdt_classe ORDER BY nom_classe ASC";
18
$RsClasse = mysql_query($query_RsClasse, $conn_cahier_de_texte) or die(mysql_error());
19
$row_RsClasse = mysql_fetch_assoc($RsClasse);
20
$totalRows_RsClasse = mysql_num_rows($RsClasse);
21

    
22
$i=1;
23
do
24
{
25
$indcl_id[$i]=$row_RsClasse['ID_classe'];
26
$i=$i+1;
27
}while ($row_RsClasse = mysql_fetch_assoc($RsClasse)) ;
28

    
29
mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
30
$query_Rsgroupe = "SELECT * FROM cdt_groupe ORDER BY ID_groupe ASC";
31
$Rsgroupe = mysql_query($query_Rsgroupe, $conn_cahier_de_texte) or die(mysql_error());
32
$row_Rsgroupe = mysql_fetch_assoc($Rsgroupe);
33
$totalRows_Rsgroupe = mysql_num_rows($Rsgroupe);
34

    
35

    
36
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1") && (isset($_GET['ID_gic']))) {
37
  
38
  if ($_SESSION['droits']==1){$num_prof=$_POST['num_prof'];} else {$num_prof=$_SESSION['ID_prof'];};
39
  
40
  $nom_gic= str_replace(array("/", "&", "\'"), "-",$_POST['nom_gic']);
41
  $nom_gic= trim(str_replace('"',' ',$nom_gic));
42
  $nom_gic= trim(str_replace("'","-",$nom_gic));
43
  $updateSQL = sprintf(" UPDATE `cdt_groupe_interclasses` SET prof_ID=%u , nom_gic=%s , commentaire_gic =%s WHERE ID_gic=%u ",
44
  
45
  GetSQLValueString($num_prof, "int"),
46
  GetSQLValueString($nom_gic, "text"),
47
  GetSQLValueString($_POST['commentaire_gic'],"text"),
48
  GetSQLValueString($_GET['ID_gic'],"int")
49
  
50
  );
51
  mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
52
  $Result1 = mysql_query($updateSQL, $conn_cahier_de_texte) or die(mysql_error());
53

    
54
 
55
  //on efface
56
  if ((isset($_GET['ID_gic'])) && ($_GET['ID_gic'] != "")) {
57
    $deleteSQL = sprintf("DELETE FROM cdt_groupe_interclasses_classe WHERE gic_ID=%u",
58
                         GetSQLValueString($_GET['ID_gic'], "int"));
59
  
60
    mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
61
    $Result1 = mysql_query($deleteSQL, $conn_cahier_de_texte) or die(mysql_error());
62
  
63
  }
64

    
65

    
66
$UID=mysql_insert_id(); 
67
        
68
$nblign=$_POST['nb_classes'];
69
        
70
for ($i=1; $i<=$totalRows_RsClasse; $i++) { 
71

    
72
    $refclasse='classe'.$i;
73
    $refgroupe='groupe'.$i;
74
    if (isset($_POST[$refclasse])&&(isset($_POST[$refgroupe])) &&($_POST[$refclasse]=='on')){
75
        
76
    $insertSQL2= sprintf("INSERT INTO `cdt_groupe_interclasses_classe` ( `gic_ID` , `classe_ID`, `groupe_ID`)  VALUES ('%s', '%s', '%s');",$_GET['ID_gic'],$indcl_id[$i], $_POST[$refgroupe]);
77
   
78
    $Result2 = mysql_query($insertSQL2, $conn_cahier_de_texte) or die(mysql_error());
79
    }//du if
80
  }//du for
81

    
82
   if (isset($_POST['gic_eleves']) ){
83
    //on efface les references ele_gic
84
     $deleteSQL_ele_gic = sprintf("DELETE FROM `ele_gic` WHERE ID_gic=%u",
85
                            GetSQLValueString($_GET['ID_gic'], "int"));
86
     
87
       mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
88
       $Result_del_ele_gic = mysql_query($deleteSQL_ele_gic, $conn_cahier_de_texte) or die(mysql_error());
89
     
90
            foreach( $_POST['gic_eleves'] as $gic_eleve ) {
91
                mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
92
                $insertSQL_ele_gic = sprintf("INSERT INTO `ele_gic` (  `ID_ele`, `ID_gic`)  VALUES ( '%s', '%s');", GetSQLValueString($gic_eleve, "int") , GetSQLValueString($_GET['ID_gic'], "int")  );
93
                //print $insertSQL_ele_gic  ."<br />";
94
                $Result_ele_gic = mysql_query($insertSQL_ele_gic, $conn_cahier_de_texte) or die(mysql_error());
95
          }
96
      
97
   }
98
 
99
        if (($_SESSION['droits']==1)||($_SESSION['droits']==3)){
100
        $insertGoTo="../inc/regroupement_liste.php";} 
101
        else {
102
        $insertGoTo = "groupe_interclasses_ajout.php";
103
        };
104
header(sprintf("Location: %s", $insertGoTo));
105
}
106

    
107
mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
108
$query_RsModifgic =sprintf("SELECT * FROM cdt_groupe_interclasses,cdt_prof WHERE ID_gic=%u AND cdt_groupe_interclasses.prof_ID = cdt_prof.ID_prof ",GetSQLValueString($_GET['ID_gic'], "int") );
109
$RsModifgic = mysql_query($query_RsModifgic, $conn_cahier_de_texte) or die(mysql_error());
110
$row_RsModifgic = mysql_fetch_assoc($RsModifgic);
111
$totalRows_RsModifgic = mysql_num_rows($RsModifgic);
112

    
113
mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
114
$query_Rsgic =sprintf("SELECT * FROM cdt_groupe_interclasses WHERE prof_ID=%u ",$row_RsModifgic['ID_prof']);
115
$Rsgic = mysql_query($query_Rsgic, $conn_cahier_de_texte) or die(mysql_error());
116
$row_Rsgic = mysql_fetch_assoc($Rsgic);
117
$totalRows_Rsgic = mysql_num_rows($Rsgic);
118

    
119
mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
120
$query_Rsdest =sprintf("SELECT * FROM cdt_groupe_interclasses_classe WHERE gic_ID=%u ",$_GET['ID_gic'] );
121
//print $query_Rsdest ;
122
$Rsdest = mysql_query($query_Rsdest, $conn_cahier_de_texte) or die(mysql_error());
123
$row_Rsdest = mysql_fetch_assoc($Rsdest);
124
$totalRows_Rsdest = mysql_num_rows($Rsdest);
125
//print $totalRows_Rsdest . "<br />";
126

    
127

    
128

    
129
// Gestion des gic avec le module d'absence
130
if ( (isset($_SESSION['module_absence'])) && ($_SESSION['module_absence']=='Oui')) {
131
  // On recupere les eleves selectionnes
132
  $selected_eles = array();
133
  mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
134
  $query_Rsele_select_classe = sprintf("SELECT gic.ID_ele FROM `ele_gic` as gic, `ele_liste` as ele WHERE gic.ID_ele = ele.ID_ele AND ID_gic='%s'", GetSQLValueString($_GET['ID_gic'], "int")   );
135
  $Rsele_select_classe = mysql_query($query_Rsele_select_classe, $conn_cahier_de_texte) or die(mysql_error());
136
  //$row_Rsele_select_classe = mysql_fetch_assoc($Rsele_select_classe);
137
  //$totalRows_Rsele_select_classe = mysql_num_rows($Rsele_select_classe);
138
  while (($row_rq = mysql_fetch_array($Rsele_select_classe , MYSQL_ASSOC) )) {    
139
    array_push(  $selected_eles , $row_rq['ID_ele'] );
140
  }
141
  
142
  $classes = array();
143
  mysql_data_seek($Rsdest,0) ;
144
  while (($row_rq = mysql_fetch_array($Rsdest , MYSQL_ASSOC) )) {    
145
    array_push( $classes , $row_rq['classe_ID'] );
146
  }
147
 // print_r($classes );
148
   $in_classes = join(" ,", $classes) ;
149
   mysql_data_seek($Rsdest, 0);
150
//  echo $in_classes ;
151
}
152

    
153

    
154
?>
155
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
156
<html>
157
<head>
158
<title>Cahier de textes - <?php echo $_SESSION['identite']?></title>
159
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
160
<link href="../styles/style_default.css" rel="stylesheet" type="text/css">
161
<style>
162
form{
163
   margin:5;
164
   padding:0;
165
}
166
.bordure_grise {
167
        border: 1px solid #CCCCCC;
168
}
169
.Style70 {font-size: 16px}
170
</style>
171
<script type="text/javascript" src="../jscripts/jquery-1.6.2.js"> </script>
172
<script type="text/javascript" src="../jscripts/utils.js"></script>
173
<script type="text/JavaScript">
174
function verifier() {
175
  var cases = document.getElementsByTagName('input');   // on recupere tous les INPUT
176
   for (var i=0; i<cases.length; i++)  {     // on les parcourt
177
       if (cases[i].type == 'checkbox')    // si on a une checkbox...
178
             { //alert(cases[i].checked);
179
                 if (cases[i].checked==true) {          //si la case est cochee, envoi du formulaire                
180
                        if(cases[i].name != 'online') {return true}
181
                                }; 
182
                 }
183
                 
184
   };
185
   alert("Il faut indiquer un destinataire. Cocher au moins une classe");
186
   return false;
187
   }
188

189
function MM_goToURL() { //v3.0
190
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
191
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
192
}
193

194
function confirmation(sup_nom_gic,ref)
195
{
196
  if (confirm("Voulez-vous supprimer r\351ellement ce groupe-classe "+" N\260"+ref+" nomm\351"+sup_nom_gic)) { // Clic sur OK
197
    MM_goToURL('window','groupe_interclasses_supprime.php?ID_gic='+ref);
198
       }
199
}
200

    
201

    
202

    
203
</script>
204
</head>
205
<body >
206
<div id="">
207
<!--<div id="container3"> en remplacement du div ci-dessus pour un tableau moins large -->
208
<p><table class="lire_bordure" width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
209

    
210
  <tr class="lire_cellule_4">
211
    <td ><?php echo $_SESSION['identite']; ?> - Gestion des regroupements d'&eacute;l&egrave;ves issus de plusieurs classes <?php if ($_SESSION['droits']==1){echo ' pour l\'enseignant '.$row_RsModifgic['identite'];};?> </td>
212
    <td ><div align="right"><a href="<?php if (($_SESSION['droits']==2)||($_SESSION['droits']==8))  {echo 'enseignant.php';};
213
        if (($_SESSION['droits']==1)||($_SESSION['droits']==3)){echo '../inc/regroupement_liste.php';};?>">
214
        <img src="../images/home-menu.gif" alt="Accueil" width="26" height="20" border="0" /></a></div></td>
215
  </tr>  <tr>
216
    <td colspan="2" valign="top" class="lire_cellule_2" ><br /><br />
217
<form onLoad= "formfocus()" method="post"  name="form1" enctype="multipart/form-data" action="<?php echo $editFormAction; ?>" onsubmit="return verifier()">
218

    
219
             
220

    
221
      <table width="100%" border="0" cellspacing="5" cellpadding="0">
222
        <tr>
223
          <td valign="top"><table border="0" align="center" class="bordure">
224
            <tr>
225
              <td class="Style6"><div align="center">El&egrave;ves venant de</div></td>
226
              <td class="Style6">
227
<SCRIPT>
228
function cocherTout(etat)
229
{
230
   var cases = document.getElementsByTagName('input');   // on recupere tous les INPUT
231
   for(var i=0; i<cases.length; i++)     // on les parcourt
232
      if(cases[i].type == 'checkbox')     // si on a une checkbox...
233
         cases[i].checked = etat;     // ... on la coche ou non
234
}
235

    
236
function decocherTout()
237
{
238
   var cases = document.getElementsByTagName('input');   // on recupere tous les INPUT
239
   cases[0].checked = false;     // ... on decoche la premiere, le TOUS
240
}
241
</SCRIPT>              
242
Tout<input type="checkbox" name="checkbox" id="tousaucun" onclick=cocherTout(this.checked) value="ok" ></td>
243

    
244
              <td class="Style6">Groupes</td>
245
            </tr>
246
            <?php 
247
mysql_data_seek($RsClasse, 0);
248

    
249
$i=1;
250

    
251
while ($row_RsClasse = mysql_fetch_assoc($RsClasse)){  ?>
252
            <tr>
253
              <td class="tab_detail"><div align="left"><?php echo $row_RsClasse['nom_classe']; ?></div></td>
254
              <td class="tab_detail"><div align="center">
255
                                  
256
<input type="checkbox" name="<?php echo 'classe'.$i; ?>"   id="<?php echo 'classe'.$row_RsClasse['ID_classe']; ?>"  
257
                                  <?php
258
            if ( (isset($_SESSION['module_absence'])) && ($_SESSION['module_absence']=='Oui'))  {
259
                                        echo 'onclick="majElevesListe();"';
260
                        }
261
                $groupe_sel='';  
262
             do {
263
                          if ($row_RsClasse['ID_classe']==$row_Rsdest['classe_ID']){echo 'checked';$groupe_sel=$row_Rsdest['groupe_ID'];};
264
                             } while ($row_Rsdest = mysql_fetch_assoc($Rsdest));
265
                                 mysql_data_seek($Rsdest, 0);                
266
  ?>>
267
                                  
268
                                  
269
              </div></td>
270
              <td class="tab_detail"><select name="<?php echo 'groupe'.$i; ?>" size="1" class="menu_deroulant" id="<?php echo 'groupe'.$row_RsClasse['ID_classe']; ?>">
271
                  <?php do {  ?>
272
                  <option value="<?php echo $row_Rsgroupe['ID_groupe']?>"
273
                                  
274
                                  
275
                                  <?php if ((isset($groupe_sel))&&($groupe_sel==$row_Rsgroupe['ID_groupe'] )) {echo ' selected';};?>
276
                                  
277
                                  
278
                                  ><?php echo $row_Rsgroupe['groupe']?></option>
279
                  <?php
280
                } while ($row_Rsgroupe = mysql_fetch_assoc($Rsgroupe));
281
            $rows = mysql_num_rows($Rsgroupe);
282
            if($rows > 0) {
283
            mysql_data_seek($Rsgroupe, 0);
284
                $row_Rsgroupe = mysql_fetch_assoc($Rsgroupe);
285
            }?>
286
              </select></td>
287
            </tr>
288
            <?php 
289
                        $i=$i+1;
290
                        } ; ?>
291
          </table>          </td>
292
          <td valign="top">
293
                  <?php if($totalRows_Rsgic<>0){ ?>
294
                  <table width="700" border="1" align="center" cellpadding="0" cellspacing="0" class="bordure">
295
            <tr>
296
              <td class="Style6">Ref</td>
297
              <td class="Style6"><div align="center">Nom du groupe classe</div></td>
298
              <td class="Style6">Commentaire</td>
299
                          </tr>
300
            <?php 
301
                        do { ?>
302
            <tr>
303
              <td class="tab_detail"><?php echo $row_Rsgic['ID_gic']; ?></td>
304
                          <td class="tab_detail"><?php echo $row_Rsgic['nom_gic']; ?></td>
305
              <td class="tab_detail"><?php echo $row_Rsgic['commentaire_gic']; ?></td>
306
              </tr>
307
            <?php } while ($row_Rsgic = mysql_fetch_assoc($Rsgic)); ?>
308
          </table>
309
        <?php ;};?>
310
            <p>&nbsp;</p>
311
            <p>&nbsp;</p>
312
                                <div align="center">
313
                <fieldset style="width : 90%">
314
                  <legend align="top"><strong>Modification d'un regroupement d'&eacute;l&egrave;ves issus de diff&eacute;rentes classes</strong></legend>
315
                  <table align="center" cellspacing="5">
316
                    <tr valign="baseline">
317
                      <td valign="top"><p>Libell&eacute; du regroupement <br>
318
                          <input name="nom_gic" type="text" size="50" value="<?php echo $row_RsModifgic['nom_gic']; ?>">
319
                  </p>
320
                        <p>Commentaire (facultatif) <br />
321
                          <textarea name="commentaire_gic" cols="70" rows="2" id="message" width="200" height= "80" ><?php echo $row_RsModifgic['commentaire_gic']; ?></textarea>
322
                  </p>
323
                   <?php
324
                                if ( (isset($_SESSION['module_absence'])) && ($_SESSION['module_absence']=='Oui')) {
325
                                  ?>
326
                                 <p>S&eacute;lection des &eacute;l&egrave;ves <br />
327
                                        <select id="gic_eleves" name="gic_eleves[]" multiple size="10">
328
                                        
329
                   <?php
330
                    mysql_select_db($database_conn_cahier_de_texte, $conn_cahier_de_texte);
331
                        $rq=mysql_query("SELECT nom_classe,code_classe FROM `cdt_classe` where `ID_classe` IN (". $in_classes  .");");
332
                        if  ($rq!=NULL){
333
                          
334
                          while (($row_rq = mysql_fetch_array($rq, MYSQL_ASSOC) )) {
335
                            
336
                            //print_r($row_rq );
337
                            //echo $row_rq['code_classe'] . "<br />";
338
                            
339
                             $rq_eleves=mysql_query("SELECT * FROM `ele_liste` where `classe_ele` = '". $row_rq['code_classe']."';");
340
                             //print "SELECT * FROM `ele_liste` where `classe_ele` = '". $row_rq['code_classe']."';" ;
341
                              if  ($rq_eleves!=NULL){
342
                              print  "<optgroup label='" . $row_rq['nom_classe'] . "' >";
343
                              while (($row_rq_eleve = mysql_fetch_array($rq_eleves, MYSQL_ASSOC) )) {
344
                                echo "<option name='".$row_rq_eleve['ID_ele']."'  value='".$row_rq_eleve['ID_ele'] ."'" ;
345
                                if (in_array($row_rq_eleve['ID_ele'], $selected_eles ) ) {
346
                                  echo " selected ";
347
                                }
348
                                echo ">".$row_rq_eleve['nom_ele'] . "&nbsp;" . $row_rq_eleve['prenom_ele']."</option>";
349
                              };
350
                              print  "</optgroup  >";
351
                              
352
                              }
353
                          };
354
                          
355
                        }
356
                    
357
                   ?> 
358
                    
359
                                        </select>  
360
               </p> 
361
                                  
362
                                 <?php
363
                 mysql_free_result($rq);
364
                 
365
                                }
366
                                
367
                                ?>   
368
                                
369
                                
370
 
371
                        <p align="center"> <br />
372
                          <input name="submit" type="submit" value="Enregistrer les modifications">
373
                  </p>
374
                  <p align="center"><a href="<?php        if (($_SESSION['droits']==1)||($_SESSION['droits']==3)){echo '../inc/regroupement_liste.php';} else { echo 'groupe_interclasses_ajout.php';};?>">Annuler</a></p></td>
375
                  </tr>
376
                  </table>
377
                                      
378
            </fieldset></div>
379
            <p>
380
              <input type="hidden" name="nb_classes" value="<?php echo $totalRows_RsClasse;?>">
381
              <input type="hidden" name="num_prof" value="<?php echo $row_RsModifgic['prof_ID'];?>">                          
382
              <input type="hidden" name="MM_update" value="form1">
383
             </p>
384
                         
385
          </form></td>
386
    </tr>
387

    
388
</table>
389
</p>
390
</div>
391

    
392

    
393

    
394

    
395
</DIV>
396
</body>
397
</html>
398
<?php
399

    
400
mysql_free_result($RsClasse);
401
mysql_free_result($Rsgroupe);
402
mysql_free_result($Rsdest);
403
?>