Commit efa3611c authored by Bate's avatar Bate

Planning2

parent 8dfff8cc
......@@ -91,8 +91,8 @@ class planningv extends stdcontents
{
$gap_data = array();
$users = $planning->get_users_for_gap($gap_id,$start);
while( list( $utl, $nom_utl ) = $users->get_row() ){
$gap_data[] = array( 0 => $utl, 1 => $nom_utl);
while( list( $utl, $nom_utl, $user_gap_id ) = $users->get_row() ){
$gap_data[] = array( 0 => $utl, 1 => $nom_utl, 2=> $user_gap_id);
}
$gaps_data[$gap_id] = $gap_data;
}
......@@ -157,7 +157,7 @@ class planningv extends stdcontents
{
$count++;
if($gap_data[0] == $user_id )
$buffer .= ($count==1?"":", ")."<a href=\"./planning2.php?action=remove_from_gap&gap_id=$gap_id&id_planning=$planning->id\">".$gap_data[1]."</a>";
$buffer .= ($count==1?"":", ")."<a href=\"./planning2.php?action=remove_from_gap&user_gap_id=$gap_data[2]&id_planning=$planning->id\">".$gap_data[1]."</a>";
else
$buffer .= ($count==1?"":", ").$gap_data[1];
......
......@@ -418,6 +418,13 @@ class planning2 extends stdentity
WHERE id_gap = $gap_id");
}
function get_user_gap_info( $user_gap_id )
{
return new requete($this->db,
"SELECT id_gap, id_utilisateur, start, end FROM pl2_user_gap
WHERE id_user_gap = $user_gap_id");
}
function get_gaps_from_names( $name )
{
return new requete($this->db,
......@@ -472,7 +479,8 @@ class planning2 extends stdentity
IF(utl_etu_utbm.surnom_utbm!='' AND utl_etu_utbm.surnom_utbm IS NOT NULL,
utl_etu_utbm.surnom_utbm,
CONCAT(`utilisateurs`.`prenom_utl`,' ',`utilisateurs`.`nom_utl`))
as `nom_utilisateur`
as `nom_utilisateur`,
pl2_user_gap.id_user_gap as id_user_gap
FROM pl2_user_gap
JOIN utilisateurs
ON utilisateurs.id_utilisateur = pl2_user_gap.id_utilisateur
......
......@@ -31,6 +31,9 @@ require_once($topdir. "include/entities/planning2.inc.php");
$site = new site ();
$site->add_css($topdir . "css/planning2.css");
if ( !$site->user->is_valid() )
$site->error_forbidden("planning");
$planning = new planning2($site->db, $site->dbrw);
if (isset($_REQUEST["id_planning"]))
......@@ -63,6 +66,32 @@ if($_REQUEST["action"] === "add_to_gap" && isset($_REQUEST["gap_id"]))
}
}
if($_REQUEST["action"] === "remove_from_gap" && isset($_REQUEST["user_gap_id"]))
{
$user_gap_id = $_REQUEST["user_gap_id"];
$user_gap = $planning->get_user_gap_info($user_gap_id);
if( list( $gap_id, $id_utl, $user_gap_start, $user_gap_end ) = $user_gap->get_row())
{
if( $id_utl != $site->user->id )
{
$cts->add_paragraph("Vous n'avez pas le droit de faire cela.");
$site->add_contents($cts);
$site->end_page();
exit();
}
$gap = $planning->get_gap_info( $gap_id );
if( list ( $id_gap, $name_gap, $start, $end ) = $gap->get_row())
{
$frm = new form("remove_from_gap","./planning2.php?id_planning=".$planning->id,true,"POST","Permanence sur le creneau $name_gap de $planning->name");
$frm->add_hidden("action","do_remove_from_gap");
$frm->add_hidden("user_gap_id",$gap_id);
$frm->add_info("Vous desinscrire du ".strftime("%A %H:%M",$week_start+strtotime($start))." au ".strftime("%A %H:%M",$week_start+strtotime($end))."?");
$frm->add_submit("do_add_to_gap","Valider");
$cts->add($frm);
}
}
}
if($_REQUEST["action"] === "do_add_to_gap" && isset($_REQUEST["gap_id"]))
{
if(!$planning->weekly || (isset($_REQUEST["start"]) && isset($_REQUEST["end"])))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment