Commit b10d230e authored by Bate's avatar Bate

Test planning

parent 23f727e8
......@@ -335,22 +335,79 @@ class planning2 extends stdentity
WHERE id_utilisateur = $user_id");
}
function get_gaps()
function get_gaps( $start, $end )
{
return new requete($this->db,
"SELECT id_gap FROM pl2_gap WHERE id_planning = $this->id");
if($this->week)
return new requete($this->db,
"SELECT id_gap, start, end, gap_name FROM pl2_gap
WHERE id_planning = $this->id
ORDER BY start ASC");
else
return new requete($this->db,
"SELECT id_gap, start, end, gap_name FROM pl2_gap
WHERE id_planning = $this->id
AND end > '".date("Y-m-d H:i:s",$start)."'
AND start < '".date("Y-m-d H:i:s",$end)."'
ORDER BY start ASC");
}
function get_gaps_time( $start, $end )
{
if($this->week)
return new requete($this->db,
"SELECT start as date FROM pl2_gap
WHERE id_planning = $this->id
UNION DISTINCT SELECT end as date
FROM pl2_gap
WHERE id_planning = $this->id
ORDER BY date ASC");
else
return new requete($this->db,
"SELECT start as date FROM pl2_gap
WHERE id_planning = $this->id
AND end > '".date("Y-m-d H:i:s",$start)."'
AND start < '".date("Y-m-d H:i:s",$end)."'
UNION DISTINCT
SELECT end as date FROM pl2_gap
WHERE id_planning = $this->id
AND end > '".date("Y-m-d H:i:s",$start)."'
AND start < '".date("Y-m-d H:i:s",$end)."'
ORDER BY date ASC");
}
function get_gaps_names()
{
return new requete($this->db,
"SELECT DISTINCT gap_name FROM pl2_gap WHERE id_planning = $this->id");
"SELECT DISTINCT gap_name FROM pl2_gap WHERE id_planning = $this->id ORDER BY gap_name");
}
function get_gaps_from_names( $name )
{
return new requete($this->db,
"SELECT id_gap FROM pl2_gap WHERE id_planning = $this->id AND gap_name = '$name'");
"SELECT id_gap FROM pl2_gap WHERE id_planning = $this->id AND gap_name = '$name' ORDER BY start");
}
function get_week_start( $date )
{
if($this->weekly)
{
$diff = $date - $this->start;
$date = $date - ($diff % ($this->weekly*3600*24));
}
else
{
$req = new requete($this->db,
"SELECT start FROM pl2_gap
WHERE id_planning = $this->id
AND start > ".date("Y-m-d H:i:s",$date)."
ORDER BY start ASC LIMIT 1");
if($req->lines == 1)
{
list( $tmp ) = $req->get_row();
$date = strtotime( $tmp );
}
}
return $date;
}
function get_users_for_gap( $gap_id, $date )
......
......@@ -43,7 +43,7 @@ require_once($topdir."include/entities/planning2.inc.php");
* applications lourdes (un bouton, un datagrid...)
* en reprennant le parallèle avec le modèle MVC, ici c'est le V : View
*/
require_once($topdir."include/cts/planning.inc.php");
require_once($topdir."include/cts/planning2.inc.php");
/*
* Une fois que l'on a inclus tout ce dont on a besoin, on crée une instance de
......@@ -105,8 +105,14 @@ while( list($gap_id) = $gaps->get_row())
$planning->get_users_for_gap($gap_id,strtotime('2013-06-25 00:00:00'));
list( $id_utl, $nom_utl) = $users->get_row();
echo "Utl $id_utl: $nom_utl\n";
$planningv = new planningv("Plop",$site->db,2,strtotime('2013-06-15 00:00:00'), strtotime('2013-06-25 00:00:00'));
$cts->add($planningv,true);
}
$site->add_contents($cts);
$site->end_page();
echo mysql_error ();
......
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