Example #1
0
function bulletin_valid($mdl)
{
    global $tpl, $srcdir;
    include_once $srcdir . "/libs/intra.php";
    bulletin_toTemplate($_REQUEST['id']);
    $intra = new EIntranet();
    if (!isset($_REQUEST['period'])) {
        $tpl->assign('attrib', $intra->getSpicesList());
        $tpl->display($srcdir . '/libs/bulletins/epitech/choose.tpl');
        quit();
    }
}
Example #2
0
/**
 * Détails d'un utilisateur
 * Et optionnellement sa vie.
 */
function user_view()
{
    global $pdo, $tpl, $srcdir;
    $utime = microtime(true);
    $sql = $pdo->prepare('SELECT * FROM users LEFT JOIN user_types ON ut_id = user_type WHERE user_id = ?');
    $sql->bindValue(1, $_REQUEST['user']);
    $sql->execute();
    $user = $sql->fetch();
    $tpl->assign('user', $user);
    $sql = $pdo->prepare('SELECT * FROM user_sections LEFT JOIN sections ON section_id = us_section WHERE us_user = ?');
    $sql->bindValue(1, $user['user_id']);
    $sql->execute();
    $sections = array();
    while ($line = $sql->fetch()) {
        $sections[] = $line['section_id'];
        $tpl->append('sections', $line);
    }
    //List events
    $sql = $pdo->prepare('SELECT * FROM event_staff' . ' LEFT JOIN events ON event_id = est_event' . ' LEFT JOIN sections ON section_id = est_section' . ' WHERE est_user = ?' . ' ORDER BY event_start DESC');
    $sql->bindValue(1, $user['user_id']);
    $sql->execute();
    while ($event = $sql->fetch(PDO::FETCH_ASSOC)) {
        $tpl->append('events', $event);
    }
    $sql = $pdo->prepare('SELECT * FROM sections WHERE section_type = "primary"');
    $sql->execute();
    while ($line = $sql->fetch()) {
        if (!in_array($line['section_id'], $sections)) {
            $tpl->append('section_list', $line);
        }
    }
    $mdt = new Modele('user_mandate');
    $mdt->find(array('um_user' => $_REQUEST['user']));
    while ($mdt->next()) {
        $tpl->append('mandates', $mdt->um_mandate);
    }
    $mdl = new Modele('card');
    $mdl->find(array('card_user' => $_REQUEST['user']));
    while ($l = $mdl->next()) {
        $o = new Modele('card');
        $o->fetch($mdl->card_id);
        $tpl->append('cards', $o);
    }
    require_once $srcdir . '/libs/GoogleApi.php';
    $api = new GoogleApi();
    $mls = $api->findUserGroups($user['user_email']);
    $groups = array();
    if (isset($mls->groups)) {
        $tpl->assign('groups', $mls->groups);
        foreach ($mls->groups as $group) {
            $groups[] = $group->email;
        }
    }
    $allGroups = $api->getGroupsList();
    foreach ($allGroups->groups as $group) {
        if (!in_array($group->email, $groups)) {
            $tpl->append('otherGroups', $group);
        }
    }
    //Get Bocal data
    if ($user['user_login']) {
        include_once $srcdir . '/libs/bocal.php';
        $bocal = new Bocal();
        $bdata = $bocal->getUser($user['user_login']);
        $tpl->assign('bocal', $bdata);
        if ($bdata !== false) {
            include_once $srcdir . '/libs/intra.php';
            $intra = new EIntranet();
            $tpl->assign('intra', $intra->getUserInfos($user['user_login']));
        }
    }
    //Get activities
    $sql = $pdo->prepare('SELECT * FROM marks ' . 'LEFT JOIN participations ON part_id = mark_participation ' . 'LEFT JOIN sections ON part_section = section_id ' . 'LEFT JOIN events ON part_event = event_id ' . 'WHERE mark_user = ? ' . 'ORDER BY part_attribution_date DESC');
    $sql->bindValue(1, $user['user_id']);
    $sql->execute();
    while ($line = $sql->fetch()) {
        $tpl->append('activities', $line);
    }
    //Compta
    $mdl = new Modele('user_accounts');
    $mdl->find(array('ua_user' => $user['user_id']));
    $accounts = array(array('ua_id' => 0, 'ua_identifier' => 'Chèque', 'ua_type' => 'cheq', 'ua_number' => ''));
    while ($mdl->next()) {
        $accounts[] = $mdl->toArray();
    }
    $tpl->assign('accounts', $accounts);
    //Fin compta
    $tpl->assign('time', microtime(true) - $utime);
    $tpl->display('user_details.tpl');
    quit();
}