Beispiel #1
0
function homepage()
{
    global $connector;
    global $result;
    if (isset($_SESSION['admin'])) {
        header("Location: admin/");
    }
    if (isset($_SESSION['login'])) {
        include_once "classes/Student.php";
        include_once "classes/Exam.php";
        include_once "classes/Plan.php";
        include_once "classes/Payment.php";
        include_once "classes/Notice.php";
        include_once "classes/Booking.php";
        include_once "classes/Document.php";
        $student = new Student();
        $student->setConnector($connector);
        $student = $student->getById($_SESSION['id_student']);
        $student->setConnector($connector);
        $exam = new Exam();
        $plan = new Plan();
        $payment = new Payment();
        $notice = new Notice();
        $booking = new Booking();
        $document = new Document();
        $exam->setConnector($connector);
        $plan->setConnector($connector);
        $payment->setConnector($connector);
        $notice->setConnector($connector);
        $booking->setConnector($connector);
        $document->setConnector($connector);
        if (isset($_POST['operation'])) {
            list($operation, $params) = explode("#", $_POST['operation']);
            switch ($operation) {
                case 'editChanges':
                    $student->storeFormValues($_POST);
                    $student->id = $params;
                    if (isset($_POST['password']) && $_POST['password'] != '') {
                        $student->generatePassword($_POST['password']);
                    }
                    $error_msg = $student->update();
                    break;
                case 'saveBook':
                    $error_msg = $booking->saveBooking($student->id, $params);
                    break;
                case 'sendMail':
                    $error_msg = sendMail();
                    break;
                default:
                    $error_msg = $operation . "#" . $params;
                    break;
            }
            if ($error_msg != "") {
                $result["errorMessage"] = $error_msg;
            } elseif ($operation != 'edit' && $operation != "nextPage") {
                $result["statusMessage"] = "Operazione completata!";
            }
        }
        if ($student) {
            $result["edit"] = $student;
            $result["edit"]->exam = $exam->getList($student);
            $result["edit"]->plan = $plan->getById($student->id_plan);
            $result['edit']->payment = $payment->getById($student->id);
            $result['edit']->notice = $notice->getList();
            $result['edit']->booking = $booking->getListForStudent($student);
            $result['edit']->booked = $booking->getBookedList($student->id);
            $result['edit']->document = $document->getList();
        }
        $page = "home.php";
        include_once BASE_PATH . "/template.php";
    } else {
        $page = "login.php";
        include_once BASE_PATH . "/template.php";
    }
}
Beispiel #2
0
 public function getList($order = "titolo")
 {
     $order = trim(filter_var($order, FILTER_SANITIZE_STRING));
     //interrogazione tabella
     $sql = "SELECT * FROM avvisi ORDER BY {$order}";
     $auth = $this->connector->query($sql);
     $list = array();
     // controllo sul risultato dell'interrogazione
     if (mysql_num_rows($auth) > 0) {
         $notice = new Notice();
         $notice->setConnector($this->connector);
         while ($res = $this->connector->getObjectResult($auth)) {
             $notice = new Notice($res->id_avviso, $res->titolo, $res->testo, $res->id_studente, $res->invio_mail);
             $list[] = $notice;
         }
     }
     return $list;
 }
Beispiel #3
0
function showNotice()
{
    global $connector;
    global $result;
    $notice = new Notice();
    $notice->setConnector($connector);
    $student = new Student();
    $student->setConnector($connector);
    if (isset($_POST['operation'])) {
        list($operation, $params) = explode("#", $_POST['operation']);
        switch ($operation) {
            case 'saveChanges':
                $notice->storeFormValues($_POST);
                $error_msg = $notice->insert();
                break;
            case 'delete':
                $error_msg = $notice->delete($params);
                break;
            default:
                $error_msg = "Operazione non valida";
        }
        if ($error_msg != "") {
            $result["errorMessage"] = $error_msg;
        } elseif ($operation != 'edit') {
            $result["statusMessage"] = "Operazione completata!";
        }
    }
    $result['students'] = $student->getList();
    $result['notices'] = $notice->getList();
    $page = "notice.php";
    include_once BASE_PATH . "template.php";
}