public function index()
 {
     $session_id = 10;
     $students = Student::getList('SELECT session_id, firstname, photo, gender FROM student WHERE session_id=' . $session_id . ' ORDER BY firstname');
     $vars = array('title' => 'Presence V 1.0', 'description' => 'Les étudiants de votre groupe', 'url_trombino' => IMG_HTTP . 'trombino/', 'students' => $students);
     $this->render('trombino', $vars);
 }
예제 #2
0
 public function insert()
 {
     if (!$this->title) {
         return "Inserire il titolo dell'avviso";
     }
     if (!$this->text) {
         return "Inserire il testo dell'avviso";
     }
     if (!is_array($this->id_dest)) {
         return "Selezionare almeno un destinatario";
     }
     $tabella = "avvisi";
     $campi = array("titolo", "testo", "id_studente", "invio_mail");
     $valori = array($this->title, $this->text, implode(";", $this->id_dest), $this->mail_send);
     $auth = $this->connector->insert($tabella, $campi, $valori);
     if (mysql_errno() == 1062) {
         return "Avviso già presente";
     } else {
         if (mysql_errno() > 0) {
             return "Errore interno numero: " . mysql_errno();
         }
     }
     if ($this->mail_send) {
         $student = new Student();
         $student->setConnector($this->connector);
         $lista = array();
         if (in_array(0, $this->id_dest)) {
             $lista = $student->getList();
         } else {
             foreach ($this->id_dest as $id_dest) {
                 $tmp_stud = $student->getById($id_dest);
                 $lista[] = $tmp_stud;
             }
         }
         $errore = "";
         foreach ($lista as $student) {
             $student->setConnector($this->connector);
             $destinatario = $student->email;
             $mittente_mail = "";
             $oggetto = "";
             $messaggio = "";
             $intestazioni = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nFrom: {$mittente_mail}";
             //invio la mail
             $risultato = mail($destinatario, $oggetto, $messaggio, $intestazioni);
             //reindirizzamento
             if (!$risultato) {
                 $errore .= "Problema nell'inoltro dell'email all'indirizzo {$destinatario}. L'avviso è stato comunque registrato sul portale<br>";
             }
         }
         if ($errore != "") {
             return $errore;
         }
     }
 }
 public function index()
 {
     if (!User::isLogged()) {
         $this->response->redirect(ROOT_HTTP . 'login');
     }
     $day = $this->getParam(0, date('Y-m-d'));
     $session_id = 10;
     $students = Student::getList('SELECT * FROM student WHERE session_id=' . $session_id);
     foreach ($students as $student) {
         $student->setPresence($day);
     }
     $vars = array('title' => 'Feuille de présence WebForce 3', 'description' => '', 'url_trombino' => IMG_HTTP . 'trombino/', 'students' => $students);
     $this->render('presence', $vars);
 }
예제 #4
0
/**
 * @author Christian Rizza
 * www.crizza.com
 * email: christian@crizza.com
 */
session_start();
define('BASE_PATH', "./");
include BASE_PATH . "config.php";
if (!isset($_SESSION['admin'])) {
    header("Location: index.php");
}
$conn = new MysqlConnector();
$conn->connect();
$student = new Student();
$student->setConnector($conn);
$lista = $student->getList();
foreach ($lista as $entry) {
    echo "Email: " . $entry->email . " ";
    $entry->setConnector($conn);
    if ($entry->generatePassword()) {
        echo "[Errore di invio] <br>";
    } else {
        echo "[OK] <br>";
    }
    $counter++;
}
$conn->disconnect();
?>


 public function data()
 {
     // Extractaire des data dans la base
     $datas = Data::getList('SELECT * FROM data ORDER BY date ASC');
     // Extractaire des students avec le tmp_id
     global $students;
     $students = Student::getList('SELECT id, tmp_id FROM student ORDER BY id ASC');
     function getRealStudentId($tmp_id)
     {
         global $students;
         //echo '<pre>'.print_r($students,true).'</pre>';
         foreach ($students as $student) {
             if ($student->tmp_id == $tmp_id) {
                 return $student->id;
             }
         }
         return 0;
     }
     //echo getRealStudentId(11);
     //exit;
     // Enlever la première ligne et formater les dates
     $data_bis = [];
     $date_sort = [];
     $presences = [];
     foreach ($datas as $index => $data) {
         if ($index == 0) {
             continue;
         }
         $data_row = [];
         $presences_row = [];
         $idx = 0;
         foreach ($data->getFields() as $key => $item) {
             $presences_row['student_id'] = null;
             if ($key == 'date') {
                 $arr = explode('/', $data->{$key});
                 $date = $arr[2] . '-' . sprintf('%02d', $arr[0]) . '-' . sprintf('%02d', $arr[1]);
                 $data_row[] = $date;
                 $date_sort[$index] = $date;
                 $presences_row['day'] = $date;
             } else {
                 $value = $data->{$key};
                 $data_row[] = $value;
                 $presences_row['student_id'] = getRealStudentId($idx);
                 //echo $idx.' '.getRealStudentId($idx);
                 $presences_row['r1'] = strpos($value, 'R1') === false ? null : 1;
                 $presences_row['r2'] = strpos($value, 'R2') === false ? null : 1;
                 $presences_row['d1'] = strpos($value, 'D1') === false ? null : 1;
                 $presences_row['d2'] = strpos($value, 'D2') === false ? null : 1;
                 $presences_row['absent'] = $value == 0 ? 1 : 0;
             }
             //echo '<pre>'.print_r($presences_row,true).'</pre>';
             //exit;
             $presences[] = $presences_row;
             $idx++;
         }
         //if ($index==1) echo '<br>';
         $data_bis[] = $data_row;
     }
     // Trier sur les dates
     array_multisort($date_sort, SORT_ASC, SORT_STRING, $data_bis);
     // Afficher la view
     $vars = ['datas' => $datas, 'presences' => $presences];
     $this->render('admin/data', $vars);
 }
예제 #6
0
function showStudent()
{
    global $connector;
    global $result;
    $student = new Student();
    $course = new Course();
    $plan = new Plan();
    $student->setConnector($connector);
    $course->setConnector($connector);
    $plan->setConnector($connector);
    if (isset($_POST['operation'])) {
        list($operation, $params) = explode("#", $_POST['operation']);
        switch ($operation) {
            case 'delete':
                $error_msg = $student->delete($params);
                break;
            case 'edit':
                $stud = $student->getById($params);
                $result['edit'] = $stud;
                $result['edit']->student = $stud;
                $exam = new Exam();
                $exam->setConnector($connector);
                $result['edit']->exam = $exam->getList($result['edit']->student);
                break;
            case 'editChanges':
                $student->storeFormValues($_POST);
                $error_msg = $student->update();
                break;
            case 'saveChanges':
                $student->storeFormValues($_POST);
                $error_msg = $student->insert();
                if ($error_msg) {
                    $result['edit'] = $student;
                }
                break;
            case 'nextPage':
                $student->storeFormValues($_POST);
                $result['edit'] = $student;
                break;
            case 'createPassword':
                $stud = $student->getById($params);
                $stud->setConnector($connector);
                $error_msg = $stud->generatePassword();
                $result['edit'] = $stud;
                break;
            default:
                $error_msg = "Operazione non valida";
        }
        if ($error_msg != "") {
            $result["errorMessage"] = $error_msg;
        } elseif ($operation != 'edit' && $operation != "nextPage") {
            $result["statusMessage"] = "Operazione completata!";
        }
    }
    if (isset($_POST['search'])) {
        $result["students"] = $student->search($_POST['search']);
    } else {
        $result["students"] = $student->getList();
    }
    $result["plans"] = $plan->getList("id_piano");
    $result["courses"] = $course->getList("nome");
    $page = "student.php";
    include_once BASE_PATH . "template.php";
}