Ejemplo n.º 1
0
function compta_add()
{
    global $tpl;
    $mdl = new Modele('user_accounts');
    $fields = array('ua_identifier', 'ua_number');
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $info = array_merge($_POST, array('ua_user' => $_SESSION['user']['user_id']));
        $info['ua_number'] = strtoupper(str_replace(' ', '', $info['ua_number']));
        if (checkIBAN($info['ua_number'])) {
            if ($mdl->addFrom($info)) {
                redirect("compta", "index", array('hsuccess' => 1));
            } else {
                $tpl->assign('hsuccess', false);
            }
        } else {
            $tpl->assign('hsuccess', "Le numero IBAN est invalide");
        }
    }
    $tpl->assign('form', $mdl->edit($fields));
    display();
}
Ejemplo n.º 2
0
/**
 * Modification du profil utilisateur
 * @global type $tpl
 */
function index_profile()
{
    global $tpl, $srcdir, $pdo;
    $mdl = new Modele('users');
    $mdl->fetch($_SESSION['user']['user_id']);
    if (isset($_POST['edit'])) {
        $tpl->assign('hsuccess', $mdl->modFrom($_POST));
    }
    if (isset($_POST['editpass'])) {
        if ($_POST['pwd1'] == '' || $_POST['oldpass'] != md5($_SESSION['user']['user_pass'] . $_SESSION['random'])) {
            $tpl->assign('hsuccess', false);
        } else {
            $tpl->assign('hsuccess', $mdl->modFrom(array('user_pass' => $_POST['pwd1']), false));
        }
    }
    $mdt = new Modele('mandate');
    if ($mdt->find('`mandate_start` < now() and `mandate_end` > now()')) {
        while ($line = $mdt->next()) {
            $tpl->append('mandate', $line);
        }
    }
    $mdtu = $pdo->prepare('SELECT * FROM user_mandate LEFT JOIN mandate ON um_mandate = mandate_id WHERE um_user = ? ORDER BY `mandate_end` DESC');
    $mdtu->bindValue(1, $_SESSION['user']['user_id']);
    $mdtu->execute();
    while ($line = $mdtu->fetch()) {
        $tpl->append('usr_mandate', $line);
    }
    $_SESSION['random'] = md5(uniqid('epicenote'));
    $tpl->assign('random', $_SESSION['random']);
    $tpl->assign('isMember', hasAcl(ACL_USER));
    $tpl->assign('form', $mdl->edit());
    $mdl = new Modele('card');
    $mdl->find(array('card_user' => $_SESSION['user']['user_id']));
    $l = $mdl->next();
    if (!$l) {
        $tpl->assign('cards', false);
    }
    while ($l) {
        $o = new Modele('card');
        $o->fetch($mdl->card_id);
        $tpl->append('cards', $o);
        $l = $mdl->next();
    }
    //GoogleAuthentificator
    require_once $srcdir . '/libs/GoogleAuthenticator/GoogleAuthenticator.php';
    $api = new GoogleAuthenticator();
    $_SESSION['user']['GoogleAuthenticator'] = $api->generateSecret();
    $tpl->assign('GoogleAuth', $api);
    //FIN GoogleAuthentificator
    display();
}
Ejemplo n.º 3
0
function section_addpoints()
{
    global $tpl, $pdo;
    $section = new Modele('sections');
    $section->fetch($_REQUEST['section']);
    $tpl->assign('section', $section);
    $queryFields = array('part_duration', 'part_title', 'part_justification');
    $mdl = new Modele('participations');
    $tpl->assign('form', $mdl->edit($queryFields));
    if (isset($_POST['edit'])) {
        $data = array('part_section' => $section->section_id, 'part_attribution_date' => date('Y-m-d'), 'part_status' => 'SUBMITTED');
        foreach ($queryFields as $field) {
            $data[$field] = $_POST[$field];
        }
        if (!$mdl->addFrom($data)) {
            redirect('section', 'details', array('section' => $section->section_id, 'hsuccess' => '0'));
        }
        $sql = $pdo->prepare('SELECT * FROM user_sections LEFT JOIN users ON user_id = us_user WHERE us_section = ? ORDER BY user_name');
        $sql->bindValue(1, $section->section_id);
        $sql->execute();
        $mdlMark = new Modele('marks');
        $dataMark = array('mark_participation' => $mdl->getKey());
        while ($user = $sql->fetch()) {
            if (in_array($user['user_id'], $_POST['staffs'])) {
                $dataMark['mark_user'] = $user['user_id'];
                $dataMark['mark_period'] = $_POST['type-' . $user['user_type']];
                $mdlMark->addFrom($dataMark);
            }
        }
        redirect('section', 'details', array('section' => $section->section_id, 'hsuccess' => '1'));
    }
    $types = new Modele('user_types');
    $types->find();
    while ($type = $types->next()) {
        $periods = $pdo->prepare('SELECT * FROM periods WHERE period_start < NOW() AND period_end > NOW() AND period_type = ? AND period_state = "ACTIVE"');
        $periods->bindValue(1, $types->ut_id);
        $periods->execute();
        $repPeriods = array();
        while ($period = $periods->fetch()) {
            $repPeriods[] = $period;
        }
        $tpl->append('types', array('id' => $types->ut_id, 'name' => $types->ut_name, 'periods' => $repPeriods));
    }
    $sql = $pdo->prepare('SELECT * FROM user_sections LEFT JOIN users ON user_id = us_user WHERE us_section = ? ORDER BY user_name');
    $sql->bindValue(1, $section->section_id);
    $sql->execute();
    while ($user = $sql->fetch()) {
        $tpl->append('staffs', $user);
    }
    display();
}
Ejemplo n.º 4
0
function trip_opt_edit()
{
    global $tpl;
    $opt = new Modele('trip_option_options');
    $opt->fetch($_GET['option']);
    $opt->assignTemplate('ooption');
    $mod = $opt->too_option;
    $mod->assignTemplate('option');
    $mdl = $mod->topt_trip;
    $mdl->assignTemplate('trip');
    $tpl->assign('form', $opt->edit(array('too_value', 'too_price')));
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        if ($opt->modFrom($_POST)) {
            redirect('trip', 'opt_list', array('option' => $mod->getKey(), 'hsuccess' => 1));
        }
        $tpl->assign('hsuccess', false);
    }
    display();
}
Ejemplo n.º 5
0
function event_addpoints()
{
    global $tpl, $pdo;
    $event = new Modele('events');
    $event->fetch($_GET['event']);
    $event->assignTemplate('event');
    $section = new Modele('sections');
    $section->fetch($_REQUEST['section']);
    $section->assignTemplate('section');
    $queryFields = array('part_duration', 'part_title', 'part_justification');
    $mdl = new Modele('participations');
    $tpl->assign('form', $mdl->edit($queryFields));
    if (isset($_POST['edit'])) {
        $data = array('part_section' => $section->section_id, 'part_attribution_date' => date('Y-m-d'), 'part_status' => 'SUBMITTED', 'part_event' => $event->getKey());
        foreach ($queryFields as $field) {
            $data[$field] = $_POST[$field];
        }
        if (!$mdl->addFrom($data)) {
            redirect('section', 'details', array('section' => $section->section_id, 'hsuccess' => '0'));
        }
        $sql = $pdo->prepare('SELECT * FROM event_staff LEFT JOIN users ON user_id = est_user WHERE est_section = ? AND est_event = ?');
        $sql->bindValue(1, $section->getKey());
        $sql->bindValue(2, $event->getKey());
        $sql->execute();
        $mdlMark = new Modele('marks');
        $dataMark = array('mark_participation' => $mdl->getKey());
        while ($user = $sql->fetch()) {
            $markOk = $_POST['staff-' . $user['user_id'] . '-ok'];
            $markPeriod = $_POST['staff-' . $user['user_id'] . '-period'];
            $markMark = $_POST['staff-' . $user['user_id'] . '-mark'];
            if ($markOk == 'YES') {
                $dataMark['mark_user'] = $user['user_id'];
                $dataMark['mark_period'] = $markPeriod;
                $dataMark['mark_mark'] = $markMark;
                $mdlMark->addFrom($dataMark);
            }
        }
        redirect('event', 'staff_activities', array('event' => $event->getKey(), 'section' => $section->section_id, 'hsuccess' => '1'));
    }
    $types = new Modele('user_types');
    $types->find();
    $repPeriods = array();
    while ($type = $types->next()) {
        $periods = $pdo->prepare('SELECT * FROM periods WHERE period_start < NOW() AND period_end > NOW() AND period_type = ? AND period_state = "ACTIVE"');
        $periods->bindValue(1, $types->ut_id);
        $periods->execute();
        while ($period = $periods->fetch()) {
            if (!isset($repPeriods[$types->ut_id])) {
                $repPeriods[$types->ut_id] = array();
            }
            $repPeriods[$types->ut_id][] = $period;
        }
    }
    $tpl->assign('periods', $repPeriods);
    $sql = $pdo->prepare('SELECT * FROM event_staff LEFT JOIN users ON user_id =est_user WHERE est_section = ? AND est_event = ? ORDER BY user_name');
    $sql->bindValue(1, $section->getKey());
    $sql->bindValue(2, $event->getKey());
    $sql->execute();
    while ($user = $sql->fetch()) {
        $tpl->append('staffs', $user);
    }
    display();
}