diff --git a/plugin/buy_courses/database.php b/plugin/buy_courses/database.php
index 7209a36a67..d8e83f1928 100644
--- a/plugin/buy_courses/database.php
+++ b/plugin/buy_courses/database.php
@@ -12,9 +12,9 @@ $sql = "CREATE TABLE IF NOT EXISTS $table (
id_course INT unsigned NOT NULL DEFAULT '0',
code VARCHAR(40),
title VARCHAR(250),
- visible CHAR(2) NOT NULL DEFAULT '',
+ visible int(1),
price FLOAT(11,2) NOT NULL DEFAULT '0',
- synchronized CHAR(2) NOT NULL DEFAULT '')";
+ sync int(1))";
Database::query($sql);
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id, code, title FROM $tableCourse";
diff --git a/plugin/buy_courses/js/funciones.js b/plugin/buy_courses/js/funciones.js
index b55cd1e0d9..e69d30e7b0 100644
--- a/plugin/buy_courses/js/funciones.js
+++ b/plugin/buy_courses/js/funciones.js
@@ -46,8 +46,8 @@ $(document).ready(function () {
});
- $('#sincronizar').click(function (e) {
- $.post("function.php", {tab: "sincronizar"},
+ $('#sync').click(function (e) {
+ $.post("function.php", {tab: "sync"},
function (data) {
if (data.status == "false") {
alert(data.contenido);
@@ -71,7 +71,7 @@ $(document).ready(function () {
var vmostrar = "NO";
}
var vcategoria = $("#categoria_cursos").attr("value");
- $.post("function.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria},
+ $.post("function.php", {tab: "courses_filter", course: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria},
function (data) {
if (data.status == "false") {
alert(data.contenido);
@@ -86,11 +86,11 @@ $(document).ready(function () {
e.stopPropagation();
});
- $("#save_money").click(function (e) {
- var tipo_moneda = $("#tipo_moneda").attr("value");
- $.post("function.php", {tab: "guardar_moneda", moneda: tipo_moneda},
+ $("#save_currency").click(function (e) {
+ var currency_type = $("#currency_type").attr("value");
+ $.post("function.php", {tab: "save_currency", currency: currency_type},
function (data) {
- alert(data.contenido);
+ alert(data.content);
}, "json");
e.preventDefault();
@@ -106,9 +106,9 @@ $(document).ready(function () {
} else {
var vsandbox = "NO";
}
- $.post("function.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox},
+ $.post("function.php", {tab: "save_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox},
function (data) {
- alert(data.contenido);
+ alert(data.content);
}, "json");
e.preventDefault();
@@ -143,13 +143,13 @@ $(document).ready(function () {
});
$("#cancelapedido").click(function (e) {
- $.post("function.php", {tab: "borrar_variables"});
+ $.post("function.php", {tab: "unset_variables"});
window.location.replace("list.php");
});
- $(".borrar_pedido").click(function (e) {
+ $(".clear_order").click(function (e) {
var vid = $(this).parent().attr("id");
- $.post("function.php", {tab: "borrar_pedido", id: vid},
+ $.post("function.php", {tab: "clear_order", id: vid},
function (data) {
location.reload();
}, "json");
@@ -158,9 +158,9 @@ $(document).ready(function () {
e.stopPropagation();
});
- $(".confirmar_pedido").click(function (e) {
+ $(".confirm_order").click(function (e) {
var vid = $(this).parent().attr("id");
- $.post("function.php", {tab: "confirmar_pedido", id: vid},
+ $.post("function.php", {tab: "confirm_order", id: vid},
function (data) {
location.reload();
}, "json");
@@ -169,32 +169,6 @@ $(document).ready(function () {
e.stopPropagation();
});
- $(".setting_tpv").click(function () {
- var vcod = $(this).attr("id");
- $.post("function.php", {tab: "cargar_tpv_configuracion", cod: vcod},
- function (data) {
- $("#resultado_tpv").html(data.contenido);
- $("#guardar_datos_tpv").click(function (e) {
- var vcod = $("#conf_tpv").attr("value");
- var num = $("#num_parametros").attr("value");
- var vaction = $("#action").attr("value");
- var array = [];
- for (var i = 0; i < num; i++) {
- var selector = '#valor_tpv' + i;
- array.push($(selector).attr("value"));
- }
- $.post("function.php", {tab: "save_tpv", cod: vcod, nump: num, action: vaction, parametros: array},
- function (data) {
- alert(data.contenido);
- $("#resultado_tpv").html("");
- }, "json");
-
- e.preventDefault();
- e.stopPropagation();
- });
- }, "json");
- });
-
$(".slt_tpv").change(function () {
var vcod = $(this).attr("value");
$.post("function.php", {tab: "activar_tpv", cod: vcod});
diff --git a/plugin/buy_courses/lang/english.php b/plugin/buy_courses/lang/english.php
index 2e051170da..bf8bbf21ad 100644
--- a/plugin/buy_courses/lang/english.php
+++ b/plugin/buy_courses/lang/english.php
@@ -1,27 +1,29 @@
- */
-
//Needed in order to show the plugin title
-$strings['plugin_title'] = "Buy Courses";
+$strings['plugin_title'] = "Comprar cursos";
$strings['plugin_comment'] = "Configurar precios, tipos de pago, visibilidad de cursos.";
$strings['Visible'] = "Mostrar en el listado";
$strings['Options'] = "Opciones";
$strings['Price'] = "Precio";
-$strings['sincronizar'] = "Sincronizar cursos de la base de datos";
+$strings['SyncCourseDatabase'] = "Sincronizar cursos de la base de datos";
$strings['Private'] = "Privado - acceso autorizado sólo para los miembros del curso";
$strings['CourseVisibilityClosed'] = "Cerrado - no hay acceso a este curso";
$strings['OpenToThePlatform'] = "Abierto - acceso autorizado sólo para los usuarios registrados en la plataforma";
$strings['OpenToTheWorld'] = "Público - acceso autorizado a cualquier persona";
+$strings['bc_setting_courses_available'] = "Configuración de cursos disponibles";
+$strings['bc_setting_pay'] = "Configuración pagos";
+
$strings['Description'] = "Descripción";
$strings['Buy'] = "Comprar";
+$strings['Filtro_buscar'] = "Filtro de busqueda";
+$strings['Curso'] = "Curso";
+$strings['Price_Maximum'] = "Precio mayor de";
+$strings['Price_Minimum'] = "Precio menor de";
+$strings['Mostrar_disponibles'] = "Mostrar cursos disponibles";
+$strings['Categorias'] = "Categorias";
$strings['paypal_enable'] = "Habilitar PayPal";
$strings['tarjet_credit_enable'] = "Habilitar TPV";
@@ -42,4 +44,9 @@ $strings['bc_confi_index'] = 'Configuraci�n cursos y precio';
$strings['bc_pagos_index'] = 'Configuraci�n pagos';
$strings['bc_pending'] = 'Pedidos pendientes de pago';
-$strings['Ref_pedido'] = 'Referencia del pedido';
\ No newline at end of file
+$strings['Ref_pedido'] = 'Referencia del pedido';
+$strings['transferencia_bancaria'] = 'Transferencia Bancaria';
+$strings['paypal'] = 'PayPal';
+$strings['confirmar_compra'] = 'Confirmar compra de curso';
+
+$strings['The_User_Is_Already_Registered'] = 'El usuario ya está registrado';
diff --git a/plugin/buy_courses/lang/spanish.php b/plugin/buy_courses/lang/spanish.php
index d65bc1298c..2fd61ff4a6 100644
--- a/plugin/buy_courses/lang/spanish.php
+++ b/plugin/buy_courses/lang/spanish.php
@@ -6,16 +6,13 @@ $strings['plugin_comment'] = "Configurar precios, tipos de pago, visibilidad de
$strings['Visible'] = "Mostrar en el listado";
$strings['Options'] = "Opciones";
$strings['Price'] = "Precio";
-$strings['sincronizar'] = "Sincronizar cursos de la base de datos";
+$strings['SyncCourseDatabase'] = "Sincronizar cursos de la base de datos";
$strings['Private'] = "Privado - acceso autorizado sólo para los miembros del curso";
$strings['CourseVisibilityClosed'] = "Cerrado - no hay acceso a este curso";
$strings['OpenToThePlatform'] = "Abierto - acceso autorizado sólo para los usuarios registrados en la plataforma";
$strings['OpenToTheWorld'] = "Público - acceso autorizado a cualquier persona";
-$strings['bc_setting_courses_available'] = "Configuración de cursos disponibles";
-$strings['bc_setting_pay'] = "Configuración pagos";
-
$strings['Description'] = "Descripción";
$strings['Buy'] = "Comprar";
$strings['Filtro_buscar'] = "Filtro de busqueda";
@@ -36,15 +33,27 @@ $strings['Cancelacionpedido'] = "El pedido se ha cancelado.";
$strings['AlreadyBuy'] = "Ya est� matriculado en el curso";
$strings['Message_conf_transf'] = "Una vez confirmado, recibira un e-mail con los datos bancarios y una referencia del pedido.";
$strings['bc_subject'] = "Confirmaci�n pedido de cursos";
-$strings['bc_message'] = "Estimado {{name}}.
En cuanto recibamos confirmación de pago procederemos a dar de alta su usuario en el curso {{curso}}.
No olvide indicar en el concepto de la transferencia el número de referencia del pedido:
En cuanto recibamos confirmación de pago procederemos a dar de alta su usuario en el curso {{curso}}.
No olvide indicar en el concepto de la transferencia el número de referencia del pedido:
';
-$sql = "SELECT * FROM $tbl_course_description WHERE c_id = " . $course_info['real_id'] . " AND session_id = 0 ORDER BY id";
+$sql = "SELECT * FROM $tbl_course_description WHERE c_id = " . intval($course_info['real_id']) . " AND session_id = 0 ORDER BY id";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($description = Database::fetch_object($result)) {
diff --git a/plugin/buy_courses/src/buy_course.lib.php b/plugin/buy_courses/src/buy_course.lib.php
index 9067a6ffbb..2ef98e3fad 100644
--- a/plugin/buy_courses/src/buy_course.lib.php
+++ b/plugin/buy_courses/src/buy_course.lib.php
@@ -7,25 +7,28 @@ require_once '../../../main/inc/global.inc.php';
require_once '../config.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
-function sincronizar()
+function sync()
{
- $sql = "UPDATE plugin_buycourses SET synchronized='NO'";
+ $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
+ $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
+
+ $sql = "UPDATE $tableBuyCourse SET sync = 0";
Database::query($sql);
- $sql = "SELECT id FROM course";
+ $sql = "SELECT id FROM $tableCourse";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
- $sql = "SELECT 1 FROM plugin_buycourses WHERE id_course='" . $row['id'] . "';";
- $tmp = Database::query($sql);
+ $sql = "SELECT 1 FROM $tableBuyCourse WHERE id_course='" . $row['id'] . "';";
+ Database::query($sql);
if (Database::affected_rows() > 0) {
- $sql = "UPDATE plugin_buycourses SET synchronized='SI' WHERE id_course='" . $row['id'] . "';";
+ $sql = "UPDATE $tableBuyCourse SET sync = 1 WHERE id_course='" . $row['id'] . "';";
Database::query($sql);
} else {
- $sql = "INSERT INTO plugin_buycourses (id_course,visible,synchronized) VALUES ('" . $row['id'] . "','NO','SI');";
+ $sql = "INSERT INTO $tableBuyCourse (id_course, visible, sync) VALUES ('" . $row['id'] . "', 0, 1);";
Database::query($sql);
}
}
- $sql = "DELETE FROM plugin_buycourses WHERE synchronized='NO';";
+ $sql = "DELETE FROM $tableBuyCourse WHERE sync = 0;";
Database::query($sql);
}
@@ -33,67 +36,92 @@ function listCourses()
{
$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
- $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM $tableBuyCourse a, $tableCourse b WHERE a.id_course = b.id;";
+ $sql = "SELECT a.id_course, a.visible, a.price, b.*
+ FROM $tableBuyCourse a, $tableCourse b
+ WHERE a.id_course = b.id;";
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
+
return $aux;
}
-function listado_cursos_user()
+function userCourseList()
{
- $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM plugin_buycourses a, course b WHERE a.id_course=b.id AND a.visible='SI';";
+ $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
+ $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
+ $tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+ $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
+
+ $sql = "SELECT a.id_course, a.visible, a.price, b.*
+ FROM $tableBuyCourse a, $tableCourse b
+ WHERE a.id_course = b.id AND a.visible = 1;";
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {
- //Comprobamos profesor
- $sql = "SELECT lastname,firstname FROM course_rel_user a, user b WHERE a.course_code='" . $row['code'] . "' AND a.role<>'' AND a.role<>'NULL' AND a.user_id=b.user_id;";
+ //check teacher
+ $sql = "SELECT lastname, firstname
+ FROM course_rel_user a, user b
+ WHERE a.course_code='" . $row['code'] . "'
+ AND a.role<>'' AND a.role<>'NULL'
+ AND a.user_id=b.user_id;";
+
$tmp = Database::query($sql);
- $fila = Database::fetch_assoc($tmp);
- $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname'];
- //Comprobamos si el alumno est� matriculado
+ $rowTmp = Database::fetch_assoc($tmp);
+ $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname'];
+ //check if the user is enrolled
if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') {
- $sql = "SELECT 1 FROM course_rel_user WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';";
- $tmp = Database::query($sql);
+ $sql = "SELECT 1 FROM $tableCourseRelUser
+ WHERE course_code='" . $row['code'] . "'
+ AND user_id='" . $_SESSION['_user']['user_id'] . "';";
+ Database::query($sql);
if (Database::affected_rows() > 0) {
- $row['matriculado'] = "SI";
+ $row['enrolled'] = "YES";
} else {
- $sql = "SELECT 1 FROM plugin_bc_temporal WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';";
- $tmp2 = Database::query($sql);
+ $sql = "SELECT 1 FROM $tableBuyCourseTemporal
+ WHERE course_code='" . $row['code'] . "'
+ AND user_id='" . $_SESSION['_user']['user_id'] . "';";
+ Database::query($sql);
if (Database::affected_rows() > 0) {
- $row['matriculado'] = "TMP";
+ $row['enrolled'] = "TMP";
} else {
- $row['matriculado'] = "NO";
+ $row['enrolled'] = "NO";
}
}
} else {
- $sql = "SELECT 1 FROM plugin_bc_temporal WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';";
- $tmp2 = Database::query($sql);
+ $sql = "SELECT 1 FROM $tableBuyCourseTemporal
+ WHERE course_code='" . $row['code'] . "'
+ AND user_id='" . $_SESSION['_user']['user_id'] . "';";
+ Database::query($sql);
if (Database::affected_rows() > 0) {
- $row['matriculado'] = "TMP";
+ $row['enrolled'] = "TMP";
} else {
- $row['matriculado'] = "NO";
+ $row['enrolled'] = "NO";
}
}
- //Comprobamos imagen
+ //check images
if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) {
- $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png";
+ $row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png";
} else {
- $row['imagen_curso'] = "main/img/without_picture.png";
+ $row['course_img'] = "main/img/without_picture.png";
}
$row['price'] = number_format($row['price'], 2, '.', ' ');
$aux[] = $row;
}
+
return $aux;
}
-function comprueba_curso_user($course, $user)
+function checkUserCourse($course, $user)
{
- $sql = "SELECT 1 FROM course_rel_user WHERE course_code='" . $course . "' AND user_id='" . $user . "';";
- $tmp = Database::query($sql);
+ $tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+ $sql = "SELECT 1 FROM $tableCourseRelUser
+ WHERE course_code='" . $course . "'
+ AND user_id='" . $user . "';";
+ Database::query($sql);
if (Database::affected_rows() > 0) {
return true;
} else {
@@ -101,10 +129,13 @@ function comprueba_curso_user($course, $user)
}
}
-function comprueba_curso_user_transf($course, $user)
+function checkUserCourseTransference($course, $user)
{
- $sql = "SELECT 1 FROM plugin_bc_temporal WHERE course_code='" . $course . "' AND user_id='" . $user . "';";
- $tmp = Database::query($sql);
+ $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
+ $sql = "SELECT 1 FROM $tableBuyCourseTemporal
+ WHERE course_code='" . $course . "'
+ AND user_id='" . $user . "';";
+ Database::query($sql);
if (Database::affected_rows() > 0) {
return true;
} else {
@@ -112,24 +143,26 @@ function comprueba_curso_user_transf($course, $user)
}
}
-function listado_categorias()
+function listCategories()
{
- $sql = "SELECT code, name FROM course_category";
+ $tblCourseCategory = Database::get_main_table(TABLE_MAIN_CATEGORY);
+ $sql = "SELECT code, name FROM $tblCourseCategory";
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
+
return $aux;
}
/**
* Return an icon representing the visibility of the course
*/
-function get_course_visibility_icon($v)
+function getCourseVisibilityIcon($option)
{
$style = 'margin-bottom:-5px;margin-right:5px;';
- switch ($v) {
+ switch ($option) {
case 0:
return Display::return_icon('bullet_red.gif', get_lang('CourseVisibilityClosed'), array('style' => $style));
break;
@@ -147,109 +180,118 @@ function get_course_visibility_icon($v)
}
}
-function listado_monedas()
+function listCurrency()
{
- $sql = "SELECT * FROM plugin_buycourses_countries ORDER BY country_name ASC";
+ $tableBuyCourseCountry = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY);
+ $sql = "SELECT * FROM $tableBuyCourseCountry
+ ORDER BY country_name ASC";
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
+
return $aux;
}
function listAccounts()
{
- $sql = "SELECT * FROM plugin_bc_transf";
+ $tableBuyCourseTransference = Database::get_main_table(TABLE_BUY_COURSE_TRANSFERENCE);
+ $sql = "SELECT * FROM $tableBuyCourseTransference";
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
+
return $aux;
}
-function parametros_paypal()
+function paypalParameters()
{
- $sql = "SELECT * FROM plugin_bc_paypal";
+ $tableBuyCoursePaypal = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL);
+ $sql = "SELECT * FROM $tableBuyCoursePaypal";
$res = Database::query($sql);
- $aux = array();
$row = Database::fetch_assoc($res);
+
return $row;
}
-function parametros_transf()
+function transferenceParameters()
{
- $sql = "SELECT * FROM plugin_bc_transf";
+ $tableBuyCourseTransference = Database::get_main_table(TABLE_BUY_COURSE_TRANSFERENCE);
+ $sql = "SELECT * FROM $tableBuyCourseTransference";
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
+
return $aux;
}
-function busca_moneda()
+function findCurrency()
{
- $sql = "SELECT * FROM plugin_buycourses_countries WHERE status='1';";
+ $tableBuyCourseCountry = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY);
+ $sql = "SELECT * FROM $tableBuyCourseCountry WHERE status='1';";
$res = Database::query($sql);
- $aux = array();
$row = Database::fetch_assoc($res);
+
return $row['currency_code'];
}
-function info_curso($code)
+function courseInfo($code)
{
- $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM plugin_buycourses a, course b WHERE a.id_course=b.id AND a.visible='SI' AND b.id='" . $code . "';";
+ $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
+ $tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+ $tableUser = Database::get_main_table(TABLE_MAIN_USER);
+
+ $sql = "SELECT a.id_course, a.visible, a.price, b.*
+ FROM $tableBuyCourse a, course b
+ WHERE a.id_course=b.id
+ AND a.visible = 1
+ AND b.id = '" . $code . "';";
$res = Database::query($sql);
- $aux = array();
$row = Database::fetch_assoc($res);
- //Comprobamos profesor
- $sql = "SELECT lastname,firstname FROM course_rel_user a, user b WHERE a.course_code='" . $row['code'] . "' AND a.role<>'' AND a.role<>'NULL' AND a.user_id=b.user_id;";
+ // Check teacher
+ $sql = "SELECT lastname, firstname
+ FROM $tableCourseRelUser a, $tableUser b
+ WHERE a.course_code = '" . $row['code'] . "'
+ AND a.role <> '' AND a.role <> 'NULL'
+ AND a.user_id = b.user_id;";
$tmp = Database::query($sql);
- $fila = Database::fetch_assoc($tmp);
- $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname'];
- //Comprobamos si el alumno est� matriculado
+ $rowTmp = Database::fetch_assoc($tmp);
+ $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname'];
+ //Check if student is enrolled
if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') {
- $sql = "SELECT 1 FROM course_rel_user WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';";
- $tmp = Database::query($sql);
+ $sql = "SELECT 1 FROM $tableCourseRelUser
+ WHERE course_code='" . $row['code'] . "'
+ AND user_id='" . $_SESSION['_user']['user_id'] . "';";
+ Database::query($sql);
if (Database::affected_rows() > 0) {
- $row['matriculado'] = "SI";
+ $row['enrolled'] = "YES";
} else {
- $row['matriculado'] = "NO";
+ $row['enrolled'] = "NO";
}
} else {
- $row['matriculado'] = "NO";
+ $row['enrolled'] = "NO";
}
- //Comprobamos imagen
+ //check img
if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) {
- $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png";
+ $row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png";
} else {
- $row['imagen_curso'] = "main/img/without_picture.png";
+ $row['course_img'] = "main/img/without_picture.png";
}
$row['price'] = number_format($row['price'], 2, '.', ' ');
return $row;
}
-
-/**
- * function texto_aleatorio (integer $long = 5, boolean $lestras_min = true, boolean $letras_max = true, boolean $num = true))
- *
- * Permite generar contrasenhas de manera aleatoria.
- *
- * @$long: Especifica la longitud de la contrasenha
- * @$letras_min: Podra usar letas en minusculas
- * @$letras_max: Podra usar letas en mayusculas
- * @$num: Podra usar numeros
- *
- * return string
- */
-function texto_aleatorio($long = 6, $letras_min = true, $letras_max = true, $num = true)
+function randomText($long = 6, $minWords = true, $maxWords = true, $number = true)
{
- $salt = $letras_min ? 'abchefghknpqrstuvwxyz' : '';
- $salt .= $letras_max ? 'ACDEFHKNPRSTUVWXYZ' : '';
- $salt .= $num ? (strlen($salt) ? '2345679' : '0123456789') : '';
+ $salt = $minWords ? 'abchefghknpqrstuvwxyz' : '';
+ $salt .= $maxWords ? 'ACDEFHKNPRSTUVWXYZ' : '';
+ $salt .= $number ? (strlen($salt) ? '2345679' : '0123456789') : '';
if (strlen($salt) == 0) {
return '';
@@ -261,8 +303,8 @@ function texto_aleatorio($long = 6, $letras_min = true, $letras_max = true, $num
srand((double)microtime() * 1000000);
while ($i < $long) {
- $num = rand(0, strlen($salt) - 1);
- $str .= substr($salt, $num, 1);
+ $number = rand(0, strlen($salt) - 1);
+ $str .= substr($salt, $number, 1);
$i++;
}
@@ -271,26 +313,30 @@ function texto_aleatorio($long = 6, $letras_min = true, $letras_max = true, $num
function calculateReference()
{
- $sql = "SELECT MAX(cod) FROM plugin_bc_temporal";
+ $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
+ $sql = "SELECT MAX(cod) as cod FROM $tableBuyCourseTemporal";
$res = Database::query($sql);
$row = Database::fetch_assoc($res);
- if ($row['MAX(cod)'] != '') {
- $reference = $row['MAX(cod)'];
+ if ($row['cod'] != '') {
+ $reference = $row['cod'];
} else {
$reference = '1';
}
- $randomText = texto_aleatorio();
+ $randomText = randomText();
$reference .= $randomText;
+
return $reference;
}
-function listado_pendientes()
+function pendingList()
{
- $sql = "SELECT * FROM plugin_bc_temporal;";
+ $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
+ $sql = "SELECT * FROM $tableBuyCourseTemporal;";
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
+
return $aux;
}
\ No newline at end of file
diff --git a/plugin/buy_courses/src/configuration.php b/plugin/buy_courses/src/configuration.php
index aec7563f84..de4694beae 100644
--- a/plugin/buy_courses/src/configuration.php
+++ b/plugin/buy_courses/src/configuration.php
@@ -6,35 +6,37 @@ require_once dirname(__FILE__) . '/buy_course.lib.php';
require_once '../../../main/inc/global.inc.php';
require_once 'buy_course_plugin.class.php';
+$plugin = Buy_CoursesPlugin::create();
+
$_cid = 0;
-$interbreadcrumb[] = array("url" => "list.php", "name" => 'Listado de cursos a la venta');
-$interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => get_lang('Configuración pagos'));
+$interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale'));
+$interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => get_lang('Configuration'));
-$tpl = new Template('Configuración de cursos disponibles');
+$tpl = new Template('availableCourses');
$teacher = api_is_platform_admin();
api_protect_course_script(true);
if ($teacher) {
- // SINCRONIZAR TABLA DE CURSOS CON TABLA DEL PLUGIN
- sincronizar();
- $visibilidad = array();
- $visibilidad[] = get_course_visibility_icon('0');
- $visibilidad[] = get_course_visibility_icon('1');
- $visibilidad[] = get_course_visibility_icon('2');
- $visibilidad[] = get_course_visibility_icon('3');
+ // sync course table with the plugin
+ sync();
+ $visibility = array();
+ $visibility[] = getCourseVisibilityIcon('0');
+ $visibility[] = getCourseVisibilityIcon('1');
+ $visibility[] = getCourseVisibilityIcon('2');
+ $visibility[] = getCourseVisibilityIcon('3');
$coursesList = listCourses();
- $ruta = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png';
- $ruta2 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/save.png';
- $tipo_moneda = busca_moneda();
+ $confirmationImgPath = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png';
+ $saveImgPath = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/save.png';
+ $currencyType = findCurrency();
$tpl->assign('server', $_configuration['root_web']);
- $tpl->assign('cursos', $coursesList);
- $tpl->assign('visibilidad', $visibilidad);
- $tpl->assign('ruta_imagen_ok', $ruta);
- $tpl->assign('ruta_imagen_save', $ruta2);
- $tpl->assign('moneda', $tipo_moneda);
+ $tpl->assign('courses', $coursesList);
+ $tpl->assign('visibility', $visibility);
+ $tpl->assign('confirmation_img', $confirmationImgPath);
+ $tpl->assign('save_img', $saveImgPath);
+ $tpl->assign('currency', $currencyType);
$listing_tpl = 'buy_courses/view/configuration.tpl';
$content = $tpl->fetch($listing_tpl);
diff --git a/plugin/buy_courses/src/error.php b/plugin/buy_courses/src/error.php
index 6d714d551a..c81e2f234d 100644
--- a/plugin/buy_courses/src/error.php
+++ b/plugin/buy_courses/src/error.php
@@ -1,18 +1,18 @@
\ No newline at end of file
diff --git a/plugin/buy_courses/src/function.php b/plugin/buy_courses/src/function.php
index 5025bcc6fc..9faa85599b 100644
--- a/plugin/buy_courses/src/function.php
+++ b/plugin/buy_courses/src/function.php
@@ -17,105 +17,68 @@ $tableUser = Database::get_main_table(TABLE_MAIN_USER);
$plugin = Buy_CoursesPlugin::create();
$buy_name = $plugin->get_lang('Buy');
-function quitar_html($cadena)
-{
- $txt = str_replace("
", chr(13) . chr(10), $cadena);
- $txt = str_replace("
", chr(13) . chr(10), $txt);
- $txt = str_replace("
", "", $txt); - $txt = str_replace("", chr(13) . chr(10), $txt); - $txt = str_replace("", " algo ", $txt); - $txt = str_replace("", chr(13) . chr(10), $txt); - $txt = strip_tags($txt); - $txt = str_replace(" ", " ", $txt); - $txt = str_replace("Á", "�", $txt); - $txt = str_replace("á", "�", $txt); - $txt = str_replace("É", "�", $txt); - $txt = str_replace("é", "�", $txt); - $txt = str_replace("Í", "�", $txt); - $txt = str_replace("í", "�", $txt); - $txt = str_replace("Ó", "�", $txt); - $txt = str_replace("ó", "�", $txt); - $txt = str_replace("Ú", "�", $txt); - $txt = str_replace("ú", "�", $txt); - $txt = str_replace("Ñ", "�", $txt); - $txt = str_replace("ñ", "�", $txt); - $txt = str_replace(""", '"', $txt); - $txt = str_replace("ª", '�', $txt); - $txt = str_replace("º", '�', $txt); - $txt = str_replace("&", '&', $txt); - $txt = str_replace("•", '�', $txt); - $txt = str_replace("€", '�', $txt); - - return $txt; -} - -if ($_REQUEST['tab'] == 'sincronizar') { - $sql = "SELECT code,title FROM $tableCourse;"; +if ($_REQUEST['tab'] == 'sync') { + $sql = "SELECT code, title FROM $tableCourse;"; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { $aux_code .= $row['code']; $aux_title .= $row['title']; } - echo json_encode(array("status" => "true", "contenido" => $contenido)); + echo json_encode(array("status" => "true", "content" => $content)); } -if ($_REQUEST['tab'] == 'filtro_cursos') { - $curso = $_REQUEST['curso']; - $priceMin = $_REQUEST['pricemin']; - $priceMax = $_REQUEST['pricemax']; - $mostrar = $_REQUEST['mostrar']; - $categoria = $_REQUEST['categoria']; - $server = $_configuration['root_web']; - - $filtro = ''; - if ($curso != '') { - $filtro .= "b.title LIKE '%" . $curso . "%'"; +if ($_REQUEST['tab'] == 'courses_filter') { + $course = Database::escape_string($_REQUEST['course']); + $priceMin = Database::escape_string($_REQUEST['pricemin']); + $priceMax = Database::escape_string($_REQUEST['pricemax']); + $show = Database::escape_string($_REQUEST['show']); + $category = Database::escape_string($_REQUEST['category']); + $server = Database::escape_string($_configuration['root_web']); + + $filter = ''; + if ($course != '') { + $filter .= "b.title LIKE '%" . $course . "%'"; } if ($priceMin != '') { - if ($filtro == '') { - $filtro .= "a.price >= '" . $priceMin . "'"; + if ($filter == '') { + $filter .= "a.price >= '" . $priceMin . "'"; } else { - $filtro .= " AND a.price >= '" . $priceMin . "'"; + $filter .= " AND a.price >= '" . $priceMin . "'"; } } if ($priceMax != '') { - if ($filtro == '') { - $filtro .= "a.price <= '" . $priceMax . "'"; + if ($filter == '') { + $filter .= "a.price <= '" . $priceMax . "'"; } else { - $filtro .= " AND a.price <= '" . $priceMax . "'"; + $filter .= " AND a.price <= '" . $priceMax . "'"; } } - if ($categoria != '') { - if ($filtro == '') { - $filtro .= "b.category_code='" . $categoria . "'"; + if ($category != '') { + if ($filter == '') { + $filter .= "b.category_code='" . $category . "'"; } else { - $filtro .= " AND b.category_code='" . $categoria . "'"; + $filter .= " AND b.category_code='" . $category . "'"; } } - if ($filtro == '') { + if ($filter == '') { $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM $tableBuyCourse a, $tableCourse b WHERE a.id_course = b.id - AND a.visible = 'SI';"; + AND a.visible = 1;"; } else { $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM $tableBuyCourse a, $tableCourse b - WHERE a.id_course=b.id - AND a.visible='SI' AND " . $filtro . ";"; + WHERE a.id_course = b.id + AND a.visible = 1 AND " . $filter . ";"; } - //echo $sql; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { - //Comprobamos profesor + //Check teacher $sql = "SELECT lastname, firstname FROM $tableCourseRelUser a, $tableUser b WHERE a.course_code = '" . $row['code'] . "' @@ -124,94 +87,94 @@ if ($_REQUEST['tab'] == 'filtro_cursos') { AND a.user_id = b.user_id;"; $tmp = Database::query($sql); - $fila = Database::fetch_assoc($tmp); - $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname']; - //Comprobamos si el alumno est� matriculado + $rowTmp = Database::fetch_assoc($tmp); + $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; + //Check if the student is enrolled if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { $sql = "SELECT 1 FROM $tableCourseRelUser - WHERE course_code='" . $row['code'] . "' - AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + WHERE course_code = '" . $row['code'] . "' + AND user_id = " . intval($_SESSION['_user']['user_id']) . ";"; $tmp = Database::query($sql); if (Database::affected_rows() > 0) { - $row['matriculado'] = "SI"; + $row['enrolled'] = "SI"; } else { - $row['matriculado'] = "NO"; + $row['enrolled'] = "NO"; } } else { - $row['matriculado'] = "NO"; + $row['enrolled'] = "NO"; } //Comprobamos imagen if (file_exists("../../../courses/" . $row['code'] . "/course-pic85x85.png")) { - $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png"; + $row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png"; } else { - $row['imagen_curso'] = "main/img/without_picture.png"; + $row['course_img'] = "main/img/without_picture.png"; } - if ($mostrar == "SI" && $row['matriculado'] == "SI") { - //No hacemos nada + if ($show == "YES" && $row['enrolled'] == "YES") { + ; } else { $aux[] = $row; } } - foreach ($aux as $curso) { //{% for curso in cursos %} - $contenido .= '
| Configuración TPV " . $row['title'] . ": | |
| URL TPV: | |
| " . $parametros[$i] . ": | |
| "; - $contenido .= " | "; - $contenido .= ""; - $contenido .= ""; - $contenido .= ""; - $contenido .= " |
| {{ 'Name'|get_lang }} | -{{ 'Account'|get_lang }} | -{{ 'SWIFT'|get_lang }} | -{{ 'Options'|get_lang }} | -
|---|---|---|---|
| {{ 'Name'|get_lang }} | +{{ 'Account'|get_lang }} | +{{ 'SWIFT'|get_lang }} | +{{ 'Options'|get_lang }} | +
| {{ transf.name | e }} | -{{ transf.account | e }} | -{{ transf.swift | e }} | -
- |
-
| - | - | - |
- |
-
| {{ transf.name | e }} | +{{ transf.account | e }} | +{{ transf.swift | e }} | +
+ |
+
| + | + | + |
+ |
+