<?php
function dateFR( $time )
{
}
function shortDateFR( $time )
{
}
function birthDateFR( $time )
{
return ( $time ===
'0000-00-00' ) ?
'-' :
strftime( "%d/%m/%Y" ,
strtotime( $time ) );
}
function dateSQL( $time )
{
$regex = '`^(0[1-9]|1\d|2\d|3[0-1])\/(0[1-9]|1[0-2])\/(\d{4})$`';
$replace = '$3-$2-$1';
}
class Membres
{
static function displayList
( $status ) {
if( $status === 'administrateur' )
{
if( isset( $_GET['view'] ) ) {
$view = $_GET['view'];
{
$view = 'all';
}
elseif( $view ===
'detail' &&
isset( $_GET['id'] ) ) {
$id = (int) $_GET['id'];
}
}
else
{
$view = 'all';
}
if( isset( $_GET['sort'] ) && !
empty( $_GET['sort'] ) ) {
$sort = $_GET['sort'];
{
$sort = 'user_name';
}
}
else
{
$sort = 'user_name';
}
if( isset( $_GET['order'] ) && !
empty( $_GET['order'] ) ) {
$order = $_GET['order'];
{
$order = 'asc';
}
}
else
{
$order = 'asc';
}
if( isset( $_GET['start'] ) && !
empty( $_GET['start'] ) ) {
$start = (int) $_GET['start'];
}
else
{
$start = 1;
}
if( $view === 'detail' )
{
$sql = "SELECT `users`.`user_name`, `users`.`user_adress`, `users`.`user_tel1`, `users`.`user_tel2`, `users`.`user_mail`, `users`.`user_pupitres`, `users`.`user_membres` , `users`.`user_admission` , `users`.`user_demission`, `users`.`user_naissance`, `users`.`user_bureau`, `users`.`user_responsable` , `temp_reply`.`reply_count` FROM `users` LEFT JOIN ( SELECT `reply`.`user_id` , COUNT( `reply`.`user_id` ) AS `reply_count` FROM `reply` GROUP BY `reply`.`user_id` ) AS `temp_reply` ON `users`.`user_id` = `temp_reply`.`user_id` WHERE `users`.`user_id` = '$id' LIMIT 1;";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
$content = TXT_INDENT.TXT_INDENT.'<h3>Fiche de '.$row->user_name.'</h3>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.
'<p><strong>Adresse : </strong>'.
stripslashes( $row->user_adress
).
'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Téléphone 1 : </strong>'.$row->user_tel1.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Téléphone 2 : </strong>'.$row->user_tel2.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Courriel : </strong>'.$row->user_mail.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Pupitre : </strong>'.$row->user_pupitres.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Membre : </strong>'.$row->user_membres.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Admission : </strong>'.birthDateFR( $row->user_admission ).'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Démission : </strong>'.birthDateFR( $row->user_demission ).'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Né(e) le : </strong>'.birthDateFR( $row->user_naissance ).'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Bureau : </strong>'.$row->user_bureau.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<p><strong>Responsable : </strong>'.$row->user_responsable.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.
'<p class="button">[ <a onclick="displayBox(\'requests/membres.php5?do=edit&user_id='.
$id.
'\', \'box\'); return false">Modifier</a> ] [ <a onclick="displayBox(\'requests/membres.php5?do=delete&user_id='.
$id.
'&user_name='.
urlencode( $row->user_name
).
'\', \'box\'); return false">Supprimer</a> ]</p>'.TXT_CRLF;
}
}
else
{
$totalCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `users`.`user_membres` <> \'Sortants\' ;' , true );
$length = 20;
$pagesNum =
ceil( $totalCount /
$length );
if( $start < 1 )
{
$start = 1;
}
if( $start > $pagesNum )
{
$start = $pagesNum;
}
$sqlStart = ( $start - 1 ) * $length;
$sql = "SELECT `users`.`user_id`, `users`.`user_adress`, `users`.`user_tel1`, `users`.`user_tel2`, `users`.`user_mail`, `users`.`user_naissance`, `users`.`user_name` , `temp_reply`.`reply_count`
FROM `users`
LEFT JOIN ( SELECT `reply`.`user_id` , COUNT( `reply`.`user_id` ) AS `reply_count`
FROM `reply` GROUP BY `reply`.`user_id` ) AS `temp_reply` ON `users`.`user_id` = `temp_reply`.`user_id`
WHERE `users`.`user_id` <> 0 AND `users`.`user_membres` <> 'Sortants'
LIMIT $sqlStart , $length;";
$userCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 ;' , true );
$executantsCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `user_membres` = \'Exécutants\';' , true );
$debutantsCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `user_membres` = \'Débutants\';' , true );
$eveilCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `user_membres` = \'Eveil-musical\';' , true );
$nonCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `user_membres` = \'Non-musiciens\';' , true );
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
$content = TXT_INDENT.TXT_INDENT.'<p class="print"><a href="print/membres.php5">Imprimer la liste des membres</a> | <a href="print/membres_birthday.php5">Imprimer les dates de naissance</a></p>';
$content .= TXT_INDENT.TXT_INDENT.'<p id="pagination">Page : ';
for( $i = 1 ; $i <= $pagesNum ; $i++)
{
if( $i == $start )
{
$content .= ' [ '.$i.' ] ';
}
else
{
$content .= " <a href=\"index.php5?cat=sorties&page=membres&view=$view&sort=$sort&order=$order&start=$i\">".$i.'</a> ';
}
}
$content .= '</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'<table id="liste-admin">'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<thead>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tr>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Nom</th>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Adresse</th>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Téléphone 1</th>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Téléphone 2</th>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Courriel</th>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Né(e) le</th>'.TXT_CRLF;
/*$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th><a'.self::getFieldLinkAttributes( 'reply_count' , $sort , $order ).'>réponses</a></th>'.TXT_CRLF;*/
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tr>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</thead>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tfoot>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tr>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th colspan="6">'.$totalCount.' Membres | '.$executantsCount.' Exécutants | '.$debutantsCount.' Débutants | '.$eveilCount.' Eveil musical | '.$nonCount.' Non musiciens</th>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tr>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tfoot>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tbody>'.TXT_CRLF;
{
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tr>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td><a href="index.php5?cat=sorties&page=membres&view=detail&id='.$row->user_id.'">'.$row->user_name.'</a></td>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.
'<td>'.
nl2br( $row->user_adress
).
'</td>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.$row->user_tel1.'</td>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.$row->user_tel2.'</td>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.$row->user_mail.'</td>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.birthDateFR( $row->user_naissance ).'</td>'.TXT_CRLF;
/*$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td><a href="index.php5?cat=sorties&page=reponses&view=user&id='.$row->user_id.'">'.$row->reply_count.'</a></td>'.TXT_CRLF;*/
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tr>'.TXT_CRLF;
}
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tbody>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.'</table>'.TXT_CRLF;
}
else
{
$content = '<p>Aucun membre à afficher</p>';
}
}
$content .= self::displayAddingBox();
}
elseif( $status === 'membre' )
{
$sql = "SELECT `questions`.`question_id` AS `id`, `questions`.`question_date`, DATE_FORMAT( `questions`.`question_date` , '%Hh%i' ) as `formated_time`, DATE_FORMAT( `questions`.`question_reply` , '%d/%m/%Y') as `formated_reply`, `questions`.`question_place`, `questions`.`question_object`, `questions`.`question_comment`, `reply`.`user_id`, `reply`.`question_id`, `reply`.`reply_value` FROM `questions` LEFT JOIN ( SELECT `reply`.`user_id`, `reply`.`question_id`, `reply`.`reply_value` FROM `reply` WHERE `reply`.`user_id` = '".$_SESSION['user_id']."' ) AS `reply` ON `questions`.`question_id` = `reply`.`question_id` WHERE `questions`.`question_reply` >= NOW() GROUP BY `questions`.`question_id`";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
$content = TXT_INDENT.TXT_INDENT.'<dl>'.TXT_CRLF;
{
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.$row->question_place.' le '.dateFR( $row->question_date ).' RDV Salle de musique '.$row->formated_time.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>'.$row->question_object.'</p>'.TXT_CRLF;
if( !
empty( $row->question_comment
) ) {
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p><em>'.$row->question_comment.'</em></p>'.TXT_CRLF;
}
if( $row->reply_value === null )
{
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<form method="post" action="index.php5?page=reply">'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>réponse avant le '.$row->formated_reply.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<select name="reply-value">'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="oui">Oui</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="non">Non</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="nsp">Ne sais pas</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</select>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p><input type="hidden" name="do" value="insert" /><input type="hidden" name="id" value="'.$row->id.'" /><input type="submit" value="Répondre" /></p>'.TXT_CRLF;
}
else
{
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<form method="post" action="index.php5?page=reply">'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>réponse avant le '.$row->formated_reply.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<select id="reply-value-'.$row->id.'" name="reply-value" disabled="disabled">'.TXT_CRLF;
switch( true )
{
case( $row->reply_value === 'oui' ):
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="oui" selected="selected">Oui</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="non">Non</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="nsp">Ne sais pas</option>'.TXT_CRLF;
break;
case( $row->reply_value === 'non' ):
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="oui">Oui</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="non" selected="selected">Non</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="nsp">Ne sais pas</option>'.TXT_CRLF;
break;
case( $row->reply_value === 'nsp' ):
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="oui">Oui</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="non">Non</option>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="nsp" selected="selected">Ne sais pas</option>'.TXT_CRLF;
break;
}
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</select>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p><input type="hidden" name="do" value="update" /><input type="hidden" name="id" "value="'.$row->id.'" /><input type="submit" id="reply-submit-'.$row->id.'" value="Répondre" disabled="disabled" /></p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p id="reply-modify-'.$row->id.'"><input type="button" onclick="enableReplyButtons('.$row->id.');" value="modifier" /></p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p id="reply-cancel-'.$row->id.'" class="reply-cancel"><input type="button" onclick="disableReplyButtons('.$row->id.');" value="annuler" /></p>'.TXT_CRLF;
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<script type="text/javascript" src="../resources/js/toggleReplyButtons.js"></script>'.TXT_CRLF;
}
$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</form>'.TXT_CRLF;
}
$content .= TXT_INDENT.TXT_INDENT.'</dl>'.TXT_CRLF;
}
else
{
$content = TXT_INDENT.TXT_INDENT.'<p>Il n\'y a pas de sortie à afficher.</p>'.TXT_CRLF;
}
}
else
{
$sql = "SELECT `questions`.`question_date`, DATE_FORMAT( `questions`.`question_date` , '%Hh%i' ) as `formated_time`, `question_place`, `question_object`, `question_comment` FROM `questions` WHERE `question_date` > NOW()";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() === true )
{
$error = DbConnection::getError();
}
if( $result )
{
$content = TXT_INDENT.TXT_INDENT.'<ul id="questions">'.TXT_CRLF;
{
$content .= TXT_INDENT.TXT_INDENT.'<li><span class="questions-date">'.dateFR( $row->question_date ).'</span><span class="questions-time">RDV Salle de musique '.$row->formated_time.'</span><span class="questions-place">'.$row->question_place.'</span><span class="questions-object">'.$row->question_object.'</span>';
if( empty( $row->question_comment
) ) {
$content .= '</li>'.TXT_CRLF;
}
else
{
$content .= '<span class="questions-comment">'.$row->question_comment.'</span></li>'.TXT_CRLF;
}
}
$content .= TXT_INDENT.TXT_INDENT.'</ul>'.TXT_CRLF;
}
else
{
$content = TXT_INDENT.TXT_INDENT.'<p>Il n\'y a pas de sortie à afficher.</p>'.TXT_CRLF;
}
}
return $content;
}
static function displayBureau
() {
$sql = "SELECT `users`.`user_name`, `users`.`user_bureau`
FROM `users`
WHERE `user_bureau` <> ''
ORDER BY `users`.`user_bureau`";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
echo TXT_INDENT.TXT_INDENT ,
'<dl id="bureau">' , TXT_CRLF;
{
echo TXT_INDENT.TXT_INDENT ,
'<dt>' ,
$row->user_bureau ,
' </dt>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT ,
'<dd>' ,
$row->user_name ,
' </dd>' , TXT_CRLF;
}
echo TXT_INDENT.TXT_INDENT ,
'</dl>' , TXT_CRLF;
}
}
static function displayComite
() {
$sql = "SELECT `users`.`user_name`, `users`.`user_responsable`
FROM `users`
WHERE `user_responsable` <> ''
ORDER BY `users`.`user_responsable`";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
echo TXT_INDENT.TXT_INDENT ,
'<dl id="comite">' , TXT_CRLF;
{
echo TXT_INDENT.TXT_INDENT ,
'<dt>' ,
$row->user_responsable ,
' </dt>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT ,
'<dd>' ,
$row->user_name ,
' </dd>' , TXT_CRLF;
}
echo TXT_INDENT.TXT_INDENT ,
'</dl>' , TXT_CRLF;
}
}
static function displayExecutants
() {
if( isset( $_GET['sort'] ) && !
empty( $_GET['sort'] ) ) {
$sort = $_GET['sort'];
if( !
in_array( $sort ,
array ( 'user_name' ,
'user_admission' ,
'user_demission' ) ) ) {
$sort = 'user_name';
}
}
else
{
$sort = 'user_name';
}
if( isset( $_GET['order'] ) && !
empty( $_GET['order'] ) ) {
$order = $_GET['order'];
{
$order = 'asc';
}
}
else
{
$order = 'asc';
}
$sql = "SELECT `users`.`user_name`, `users`.`user_membres`, `users`.`user_admission`, `users`.`user_demission`
FROM `users`
WHERE `users`.`user_id` <> 0 AND (`users`.`user_membres` = 'Exécutants' OR `users`.`user_membres` = 'Sortants')
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
echo TXT_INDENT.TXT_INDENT ,
'<table id="executants">' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT.TXT_INDENT ,
'<thead>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT ,
'<tr>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT ,
'<th><a'.self::
getFieldLinkAttributes( 'user_name' ,
$sort ,
$order ,
'index.php5?cat=musiciens&page=bureau' ).
'>Nom</a></th>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT ,
'<th><a'.self::
getFieldLinkAttributes( 'user_admission' ,
$sort ,
$order ,
'index.php5?cat=musiciens&page=bureau' ).
'>Admission</a></th>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT ,
'<th><a'.self::
getFieldLinkAttributes( 'user_demission' ,
$sort ,
$order ,
'index.php5?cat=musiciens&page=bureau' ).
'>Démission</a></th>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT ,
'</tr>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT ,
'</thead>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT ,
'</body>' , TXT_CRLF;
{
$entree = ( $row->user_admission === '0000-00-00' ) ? '' : shortDateFR( $row->user_admission );
$sortie = ( $row->user_demission === '0000-00-00' ) ? '' : shortDateFR( $row->user_demission );
echo TXT_INDENT.TXT_INDENT ,
'<tr><td>' ,
$row->user_name ,
'</td><td>' ,
$entree ,
'</td><td>',
$sortie ,
'</td></tr>' , TXT_CRLF;
}
echo TXT_INDENT.TXT_INDENT ,
'</tbody>' , TXT_CRLF;
echo TXT_INDENT.TXT_INDENT ,
'</table>' , TXT_CRLF;
}
}
static function displayAddingBox
() {
?>
<div id="box">
<form action="index.php5?cat=sorties&page=membres" method="post" >
<fieldset>
<legend>Ajouter un membre</legend>
<p>
<label for="add-nom">Nom :</label>
<input type="text" name="nom" id="add-nom" />
</p>
<p>
<label for="add-adress">Adresse :</label>
<textarea id="add-adress" name="adress"></textarea>
</p>
<p>
<label for="add-tel1">Téléphone 1 :</label>
<input type="text" name="tel1" id="add-tel1" />
</p>
<p>
<label for="add-tel2">Téléphone 2 :</label>
<input type="text" name="tel2" id="add-tel2" />
</p>
<p>
<label for="add-mail">Courriel :</label>
<input type="text" name="mail" id="add-mail" />
</p>
<p>
<label for="add-pupitres">Pupitre :</label>
<?php
//menu déroulant pour le type de pupitres
//requête
$sql="show columns from users like 'user_pupitres'";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
//on récupère la colonne 'Type' dans le résultat $result de la requete $sql
//ce qui donne un string du type : set('blabla','blabla',...)
//il faut donc enlever le début et la fin puis utiliser split pour récupérer chaque champ
$resp=
split("','",
$type);
//creation du select avec toutes les options correspondant à chaque champ du tableau $resp
echo "<select multiple name='pupitres' id='add-pupitres'>";
echo "<option selected value='-1'>--liste pupitres--</option>";
foreach( $resp as $row )
{
echo "<option value=$row>$row</option>";
}
}
?>
</p>
<p>
<label for="add-membres">Membre :</label>
<?php
//menu déroulant pour le type de membres
$sql="show columns from users like 'user_membres'";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
$resp=
split("','",
$type);
echo "<select multiple name='membres' id='add-membres'>";
echo "<option selected value='-1'>--liste membres--</option>";
foreach( $resp as $row )
{
echo "<option value=$row>$row</option>";
}
}
?>
</p>
<p>
<label for="add-admission">Admission :</label>
<input onclick="ds_sh(this);" type="text" name="admission" id="add-admission" />
</p>
<p>
<label for="add-demission">Démission :</label>
<input onclick="ds_sh(this);" type="text" name="demission" id="add-demission" />
</p>
<p>
<label for="add-naissance">Né(e) le :</label>
<input onclick="ds_sh(this);" type="text" name="naissance" id="add-naissance" />
</p>
<p>
<label for="add-bureau">Bureau :</label>
<?php
$sql="show columns from users like 'user_bureau'";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
$resp=
split("','",
$type);
echo "<select multiple name='bureau' id='add-bureau'>";
echo "<option selected value='-1'>--liste du bureau--</option>";
foreach( $resp as $row )
{
echo "<option value=$row>$row</option>";
}
}
?>
</p>
<p>
<label for="add-responsable">Responsable :</label>
<?php
//Menu déroulant pour la liste des responsabilités
$sql="show columns from users like 'user_responsable'";
$result = DbConnection::select( $sql );
if( DbConnection::hasError() )
{
$error = DbConnection::getError();
}
if( $result )
{
$resp=
split("','",
$type);
//TODO multiple
echo "<select multiple name='responsable'id='add-responsable'>";
echo "<option selected value='-1'>--liste des responsabilites--</option>";
/*echo "<option value = $resp[0]> $resp[0] </option>";
echo "<option value = $resp[1]> $resp[1] </option>";
echo "<option value = $resp[count($resp)-1]> $resp[count($resp)-1] </option>";*/
foreach( $resp as $row )
{
echo "<option value=$row>$row</option>";
}
/*for ($i=0; $i<count($resp); $i++) {
echo "<option value = $resp[i]> '$resp[i]' </option>";
}*/
/*while($row = mysql_fetch_array($resp))
{
echo "<option value=$data[0]>$data[0]</option>";
}
}
?>
</p>
<p>
<input type="hidden" name="do" value="add" />
<input type="reset" value="Effacer" />
<input type="submit" value="Soumettre" />
</p>
</fieldset>
</form>
</div>
<?php //return $box;
}
{
if( isset( $_POST['nom'] ) ) {
$input['nom'] = $_POST['nom'];
}
else
{
$errors[] = 'Il faut saisir une valeur pour le nom.';
}
if( isset( $_POST['mail'] ) ) {
$input['mail'] = $_POST['mail'];
}
else
{
$input['mail'] = '';
}
if( isset( $_POST['adress'] ) ) {
$input['adress'] = $_POST['adress'];
}
else
{
$input['adress'] = '';
}
if( isset( $_POST['tel1'] ) ) {
$input['tel1'] = $_POST['tel1'];
}
else
{
$input['tel1'] = '';
}
if( isset( $_POST['tel2'] ) ) {
$input['tel2'] = $_POST['tel2'];
}
else
{
$input['tel2'] = '';
}
if( isset( $_POST['pupitres'] ) ) {
$input['pupitres'] = $_POST['pupitres'];
}
else
{
$input['pupitres'] = '';
}
if( isset( $_POST['membres'] ) ) {
$input['membres'] = $_POST['membres'];
}
else
{
$input['membres'] = '';
}
if( isset( $_POST['admission'] ) ) {
$input['admission'] = $_POST['admission'];
}
else
{
$input['admission'] = '';
}
if( isset( $_POST['demission'] ) ) {
$input['demission'] = $_POST['demission'];
}
else
{
$input['demission'] = '';
}
if( isset( $_POST['naissance'] ) ) {
$input['naissance'] = $_POST['naissance'];
}
else
{
$input['naissance'] = '';
}
if( isset( $_POST['bureau'] ) ) {
$input['bureau'] = $_POST['bureau'];
}
else
{
$input['bureau'] = '';
}
if( isset( $_POST['responsable'] ) ) {
$input['responsable'] = $_POST['responsable'];
}
else
{
$input['responsable'] = '';
}
if( count( $errors ) >
0 ) {
return implode( '<br />' ,
$errors );
}
$input['pswd'] = self::buildPassword();
$result = dbConnection::insert("INSERT INTO `users` ( `user_id` , `user_name` , `user_adress` , `user_tel1` , `user_tel2` , `user_mail` , `user_pupitres` , `user_membres` , `user_password` , `user_admission` , `user_demission` , `user_naissance` , `user_bureau` , `user_responsable` ) VALUES ( NULL , '".$input['nom']."', '".$input['adress']."', '".$input['tel1']."', '".$input['tel2']."', '".$input['mail']."', '".$input['pupitres']."', '".$input['membres']."', PASSWORD( '".$input['pswd']."' ), '".dateSQL( $input['admission'] )."', '".dateSQL( $input['demission'] )."', '".dateSQL( $input['naissance'] )."', '".$input['bureau']."', '".$input['responsable']."' );" );
return $result;
}
static function updateMembre
( $id ) {
if( isset( $_POST['nom'] ) ) {
$input['nom'] = $_POST['nom'];
}
else
{
$errors[] = 'Il faut saisir une valeur pour le nom.';
}
if( isset( $_POST['mail'] ) ) {
$input['mail'] = $_POST['mail'];
}
else
{
$input['mail'] = '';
}
if( isset( $_POST['adress'] ) ) {
$input['adress'] = $_POST['adress'];
}
else
{
$input['adress'] = '';
}
if( isset( $_POST['tel1'] ) ) {
$input['tel1'] = $_POST['tel1'];
}
else
{
$input['tel1'] = '';
}
if( isset( $_POST['tel2'] ) ) {
$input['tel2'] = $_POST['tel2'];
}
else
{
$input['tel2'] = '';
}
if( isset( $_POST['pupitres'] ) ) {
$input['pupitres'] = $_POST['pupitres'];
}
else
{
$input['pupitres'] = '';
}
if( isset( $_POST['membres'] ) ) {
$input['membres'] = $_POST['membres'];
}
else
{
$input['membres'] = '';
}
if( isset( $_POST['admission'] ) ) {
$input['admission'] = $_POST['admission'];
}
else
{
$input['admission'] = '';
}
if( isset( $_POST['demission'] ) ) {
$input['demission'] = $_POST['demission'];
}
else
{
$input['demission'] = '';
}
if( isset( $_POST['naissance'] ) ) {
$input['naissance'] = $_POST['naissance'];
}
else
{
$input['naissance'] = '';
}
if( isset( $_POST['bureau'] ) ) {
$input['bureau'] = $_POST['bureau'];
}
else
{
$input['bureau'] = '';
}
if( isset( $_POST['responsable'] ) ) {
$input['responsable'] = $_POST['responsable'];
}
else
{
$input['responsable'] = '';
}
if( count( $errors ) >
0 ) {
return implode( '<br />' ,
$errors );
}
$input['pswd'] = self::buildPassword();
//UPDATE `users` SET `user_tel1` = '9876543210' WHERE `user_id` =64 LIMIT 1 ;
$result = dbConnection::query( "UPDATE `users` SET `user_name` = '".$input['nom']."' , `user_adress` = '".$input['adress']."' , `user_tel1` = '".$input['tel1']."' , `user_tel2` = '".$input['tel2']."' , `user_mail` = '".$input['mail']."' , `user_pupitres` = '".$input['pupitres']."' , `user_membres` = '".$input['membres']."' , `user_admission` = '".dateSQL( $input['admission'] )."' , `user_demission` = '".dateSQL( $input['demission'] )."' , `user_naissance` = '".dateSQL( $input['naissance'] )."' , `user_bureau` = '".$input['bureau']."' , `user_responsable` = '".$input['responsable']."'WHERE `user_id` = ".$id.' LIMIT 1' );
return $result;
}
static function deleteMembre
( $id ) {
$sql = "DELETE FROM `users` WHERE `users`.`user_id` = $id LIMIT 1;";
return dbConnection::query( $sql );
}
static function buildPassword
() {
for( $i = 0 ; $i < 6 ; $i++ )
{
$letters[] =
chr( rand( 97 ,
122 ) );
}
}
static function deleteQuestion
( $id ) {
$sql = "DELETE FROM `questions` WHERE `questions`.`question_id` = $id LIMIT 1;";
return dbConnection::query( $sql );
}
static function updateQuestion
( $id ) {
if( isset( $_POST['date'] ) && !
empty( $_POST['date'] ) ) {
$input['date'] = $_POST['date'];
if( !
preg_match( '`(\d{1,2})/(\d{1,2})/(\d{4})`' ,
$input['date'] ) ) {
$errors[] = 'La date saisie pour la sortie est incorrecte.';
}
elseif( isset( $_POST['heure'] ) && !
empty( $_POST['heure'] ) &&
isset( $_POST['minute'] ) && !
empty( $_POST['minute'] ) ) {
list( $day ,
$month ,
$year ) =
explode( '/' ,
$input['date'] );
$hour = (int) $_POST['heure'];
$minut = (int) $_POST['minute'];
$month = (int) $month;
$day = (int) $day;
$year = (int) $year;
if( !
mktime( $hour ,
$minut ,
00 ,
$month ,
$day ,
$year ) ) {
$errors[] = 'L\'heure saisie pour la sortie est incorrecte.';
}
else
{
$hour =
str_pad( $hour ,
2,
'0' , STR_PAD_LEFT
);
$minut =
str_pad( $minut ,
2,
'0' , STR_PAD_LEFT
);
$month =
str_pad( $month ,
2,
'0' , STR_PAD_LEFT
);
$day =
str_pad( $day ,
2,
'0' , STR_PAD_LEFT
);
$input['date'] = $year.$month.$day.$hour.$minut.'00';
}
}
else
{
$errors[] = 'Il faut saisir une valeur pour l\'heure de la sortie.';
}
}
else
{
$errors[] = 'Il faut saisir une valeur pour la date de la sortie.';
}
if( isset( $_POST['reponse'] ) && !
empty( $_POST['reponse'] ) ) {
$input['reponse'] = $_POST['reponse'];
if( !
preg_match( '`(\d{1,2})/(\d{1,2})/(\d{4})`' ,
$input['reponse'] ) ) {
$errors[] = 'La date saisie pour la réponse est incorrecte.';
}
else
{
list( $day ,
$month ,
$year ) =
explode( '/' ,
$input['reponse'] );
$month =
str_pad( $month ,
2,
'0' , STR_PAD_LEFT
);
$day =
str_pad( $day ,
2,
'0' , STR_PAD_LEFT
);
$input['reponse'] = $year.$month.$day.'235959';
}
}
else
{
$errors[] = 'Il faut saisir une valeur pour la date de réponse.';
}
if( isset( $_POST['lieu'] ) && !
empty( $_POST['lieu'] ) ) {
}
else
{
$errors[] = 'Il faut saisir une valeur pour le lieu de la sortie.';
}
if( isset( $_POST['objet'] ) && !
empty( $_POST['objet'] ) ) {
}
else
{
$errors[] = 'Il faut saisir une valeur pour l\'objet de la sortie.';
}
if( isset( $_POST['commentaire'] ) ) {
}
else
{
$input['commentaire'] = '';
}
if( count( $errors ) >
0 ) {
return implode( '<br />' ,
$errors );
}
return dbConnection::query("UPDATE `questions` SET `question_date` = '{$input['date']}', `question_reply` = '{$input['reponse']}', `question_place` = '{$input['lieu']}', `question_object` = '{$input['objet']}', `question_comment` = '{$input['commentaire']}' WHERE `questions`.`question_id` = $id LIMIT 1 ;" );
}
static function getOne
( $id ,
$withDetails =
false ) {
if( $withDetails )
{
$sql = "SELECT `user_id`, `user_mail`, `user_name`, `user_adress`, `user_tel1`, `user_tel2`, `user_password`, `user_pupitres`, `user_membres`, `user_admission`, `user_demission`, `user_naissance`, `user_bureau`, `user_responsable` FROM `users` WHERE `user_id` ='$id' LIMIT 1";
}
else
{
$sql = "SELECT `user_id`, `user_mail`, `user_name`, `user_adress`, `user_tel1`, `user_tel2`, `user_password`, `user_pupitres`, `user_membres`, `user_admission`, `user_demission`, `user_naissance`, `user_bureau`, `user_responsable` FROM `users` WHERE `user_id` ='$id' LIMIT 1";
}
$result = DbConnection::select( $sql );
if( $result )
{
}
else
{
return false;
}
}
private static function getFieldLinkAttributes
( $field ,
$sort ,
$order ,
$page =
'index.php5?cat=sorties&page=membres' ) {
if( $field === $sort )
{
if( $order === 'asc' )
{
$invertOrder = 'desc';
}
else
{
$invertOrder = 'asc';
}
$attributes = " href=\"$page&sort=$field&order=$invertOrder\" class=\"sort-$order\"";
}
else
{
$attributes = " href=\"$page&sort=$field&order=$order\"";
}
return $attributes;
}
}
?>