partenariats.php 3.26 KB
Newer Older
mbriand's avatar
mbriand committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
<?php
/* Copyright 2010
 * - Mathieu Briand <briandmathieu CHEZ hyprua POINT org>
 *
 * Ce fichier fait partie du site de l'Association des Étudiants de
 * l'UTBM, http://ae.utbm.fr.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License a
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */
/** Affiche les utilisateurs en attente des avantages des partenaires
 */

$topdir = "../";
mbriand's avatar
mbriand committed
27
require_once($topdir. "include/site.inc.php");
mbriand's avatar
mbriand committed
28
require_once($topdir. "include/cts/sqltable2.inc.php");
mbriand's avatar
mbriand committed
29
require_once($topdir. "include/entities/partenariat_utl.inc.php");
mbriand's avatar
mbriand committed
30 31 32 33

$partenaires=array(1=>"Société Générale", 2=>"SMEREB");

$site = new site ();
mbriand's avatar
mbriand committed
34 35

if ( !$site->user->is_in_group("gestion_ae") )
36
  $site->error_forbidden("services","group","gestion_ae");
mbriand's avatar
mbriand committed
37

mbriand's avatar
mbriand committed
38
$site->add_js("js/sqltable2.js");
39
$site->start_page("services","Partenariats en attente");
mbriand's avatar
mbriand committed
40
$partenariat = new Partenariat($site->db, $site->dbrw);
mbriand's avatar
mbriand committed
41 42 43

if ($_REQUEST['action'] == "add")
{
mbriand's avatar
mbriand committed
44
  $partenariat->load_by_partenariat_utilisateur($_REQUEST['id_partenariat'], $_REQUEST['id_utilisateur']);
mbriand's avatar
mbriand committed
45 46 47 48 49 50 51
  if($partenariat->is_valid())
    $this->add_contents(new error("Partenariat en attente déjà enregistré pour l'utilisateur"));
  else
    $partenariat->add($_REQUEST['id_partenariat'], $_REQUEST['id_utilisateur']);
}
elseif ($_REQUEST['action'] == "deletes")
{
mbriand's avatar
mbriand committed
52
  foreach($_REQUEST['id_partenariat_utls'] as $id )
mbriand's avatar
mbriand committed
53
  {
mbriand's avatar
mbriand committed
54
    $partenariat->load_by_id($id);
mbriand's avatar
mbriand committed
55 56 57 58
    $partenariat->remove();
  }
}

mbriand's avatar
mbriand committed
59 60 61 62 63 64
$sql = "SELECT `partenariats_utl`.`id_partenariat_utl`, `partenariats_utl`.`id_partenariat`, ".
      "`partenariats_utl`.`date_partenariat`, " .
      "CONCAT(`utilisateurs`.`prenom_utl`,' ',`utilisateurs`.`nom_utl`) as `nom_utilisateur` ".
      "FROM `partenariats_utl` ".
      "LEFT JOIN `utilisateurs` USING (`id_utilisateur`) ".
      "ORDER BY `partenariats_utl`.`id_partenariat`, `nom_utilisateur`";
mbriand's avatar
mbriand committed
65

mbriand's avatar
mbriand committed
66
$cts = new contents("Partenariats en attente");
mbriand's avatar
mbriand committed
67

mbriand's avatar
mbriand committed
68
$tbl = new sqltable2("partenariats_utl", null, "partenariats.php");
mbriand's avatar
mbriand committed
69 70
$tbl->add_batch_action("deletes", "Supprimer");
$tbl->add_column_text('id_partenariat', 'Partenaire');
mbriand's avatar
mbriand committed
71
$tbl->set_column_enumeration('id_partenariat', $partenaires);
mbriand's avatar
mbriand committed
72
$tbl->add_column_text('nom_utilisateur', 'Nom');
mbriand's avatar
mbriand committed
73
$tbl->add_column_date('date_partenariat', 'Date');
mbriand's avatar
mbriand committed
74
$tbl->set_sql($site->db, 'id_partenariat_utl', $sql);
mbriand's avatar
mbriand committed
75 76
$cts->add($tbl,true);

mbriand's avatar
bleh  
mbriand committed
77
$frm = new form("partenariat","partenariats.php",true,"POST", "Ajouter un partenariat en attente");
mbriand's avatar
mbriand committed
78
$frm->add_hidden("action","add");
mbriand's avatar
mbriand committed
79
$frm->add_select_field("id_partenariat", "Partenaire", $partenaires);
mbriand's avatar
mbriand committed
80
$utl = new utilisateur($site->db);
mbriand's avatar
mbriand committed
81
$frm->add_entity_smartselect ("id_utilisateur","Cotisant", $utl, false, true);
mbriand's avatar
mbriand committed
82
$frm->add_submit("submit","Ajouter");
mbriand's avatar
mbriand committed
83 84 85 86 87 88 89 90
$cts->add($frm,true);


$site->add_contents($cts);
$site->end_page();


?>