public function getListForStudent($student, $order = "data_esame") { $order = trim(filter_var($order, FILTER_SANITIZE_STRING)); //interrogazione tabella $sql = "select * from appelli where id_piano = '{$student->id_plan}' and id_appello not in (select id_appello from prenotazioni where id_studente = '{$student->id}') ORDER BY {$order}"; $auth = $this->connector->query($sql); $list = array(); // controllo sul risultato dell'interrogazione if (mysql_num_rows($auth) > 0) { $plan = new Plan(); $plan->setConnector($this->connector); $subject = new Subject(); $subject->setConnector($this->connector); while ($res = $this->connector->getObjectResult($auth)) { $book = new Booking($res->id_appello, $res->id_piano, $res->id_materia, $res->anno, $res->docente, $res->data_esame); //Calcolo le informazioni di servizio $currPlan = $plan->getById($book->plan_id); $book->course_name = $currPlan->course_name; $book->plan_code = $currPlan->plan_code; $book->subject_name = $subject->getById($book->subject_id)->name; $list[] = $book; } } return $list; }
public function getList($studend) { // interrogazione della tabella $sql = "SELECT * FROM esami WHERE id_studente='{$studend->id}'"; $auth = $this->connector->query($sql); $list = array(); if (mysql_num_rows($auth) > 0) { while ($res = $this->connector->getObjectResult($auth)) { $exam = new Exam(get_object_vars($res)); //Calcolo le informazioni di servizio $plan = new Plan(); $plan->setConnector($this->connector); $student_plan = $plan->getById($studend->id_plan); foreach ($student_plan->subjects as $subj) { if ($exam->id_subject == $subj->subject_id) { $exam->year = $subj->year; break; } } $subject = new Subject(); $subject->setConnector($this->connector); $exam->subject_name = $subject->getById($exam->id_subject)->name; $list[] = $exam; } } return $list; }
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"; } }
function ajax_process_payment_cielo() { global $campaign, $wpdb; $numero_cartao = preg_replace('/(\\d{12})/', "\$1", $_POST['card_number']); $plan = Plan::getById($campaign->plan_id); $valor = $plan->price; $validade = $_POST['expiry']['year'] . $_POST['expiry']['month']; $bandeira = $_POST['cctype']; $cod_seguranca = $_POST['card_code']; $nome_portador = $_POST['nome_portador']; $current_user = wp_get_current_user(); $dateTime = date("Y-m-d\\TH:i:s"); $log = array(); $log['id_transacao'] = uniqid(); $log['date'] = $dateTime; $log['valor'] = $valor; $log['user_id'] = $current_user->ID; $log['campaign_id'] = $campaign->id; //geramos uma entrada na TransactionLog para termos um ID dessa transação $wpdb->insert('transaction_log', $log); $log['id'] = $wpdb->insert_id; $log['numero_pedido'] = $log['id']; $request = array('forma-pagamento' => array('bandeira' => $bandeira), 'dados-cartao' => array('numero' => $numero_cartao, 'validade' => $validade, 'codigo-seguranca' => $cod_seguranca, 'nome-portador' => $nome_portador), 'dados-pedido' => array('valor' => $valor, 'data-hora' => $dateTime, 'descricao' => $plan->name, 'numero' => $log['id']), 'tid' => $log['id_transacao']); require_once 'cielo/Cielo.php'; $pgto = new Cielo($request); $result = $pgto->send(); $log['response'] = $result['resposta']; if (true === $result['sucesso']) { $campaign->setStatus(1); $log['aprovada'] = 1; echo 'success'; } else { echo 'erro'; } $wpdb->update('transaction_log', $log, array('id' => $log['id'])); exit; }
public function search($val, $order = "nome", $numRows = 1000000) { $order = trim(filter_var($order, FILTER_SANITIZE_STRING)); $numRows = (int) $numRows; // interrogazione della tabella $sql = "SELECT id_studente,nome,cognome,data_nascita,id_piano FROM studenti WHERE nome LIKE '%{$val}%' OR cognome LIKE '%{$val}%' ORDER BY {$order} LIMIT {$numRows}"; $auth = $this->connector->query($sql); $list = array(); if (mysql_num_rows($auth) > 0) { while ($res = $this->connector->getObjectResult($auth)) { $student = new Student(); $student->id = $res->id_studente; $student->name = $res->nome; $student->surname = $res->cognome; $student->date_born = $res->data_nascita; $student->id_plan = $res->id_piano; $plan = new Plan(); $plan->setConnector($this->connector); $student_plan = $plan->getById($student->id_plan); $student->course_name = $student_plan->course_name; $list[] = $student; } } return $list; }
function showPlan() { global $connector; global $result; $plan = new Plan(); $plan->setConnector($connector); $course = new Course(); $course->setConnector($connector); $subject = new Subject(); $subject->setConnector($connector); if ($_POST['operation']) { list($operation, $params) = explode("#", $_POST['operation']); switch ($operation) { case 'saveChanges': $plan->storeFormValues($_POST); $error_msg = $plan->insert(); if ($error_msg) { $result['edit'] = $plan; } break; case 'delete': $error_msg = $plan->delete($params); break; case 'edit': $result['edit'] = $plan->getById($params); break; case 'editChanges': $plan->storeFormValues($_POST); $error_msg = $plan->update(); break; default: $error_msg = "Operazione non valida"; } if ($error_msg != "") { $result["errorMessage"] = $error_msg; } elseif ($operation != 'edit') { $result["statusMessage"] = "Operazione completata!"; } } $result["courses"] = $course->getList("nome"); $result["plans"] = $plan->getList("codice"); $result["subjects"] = $subject->getList("nome"); $page = "plan.php"; include_once BASE_PATH . "template.php"; }