Modify Path, names and format code - refs bcourse

1.9.x
Francis Gonzales 12 years ago
parent b038c1e98f
commit b6dce2af30
  1. 4
      plugin/buy_courses/config.php
  2. 38
      plugin/buy_courses/database.php
  3. 26
      plugin/buy_courses/js/funciones.js
  4. 8
      plugin/buy_courses/src/buy_course.lib.php
  5. 2
      plugin/buy_courses/src/buy_course_plugin.class.php
  6. 4
      plugin/buy_courses/src/configuration.php
  7. 84
      plugin/buy_courses/src/function.php
  8. 2
      plugin/buy_courses/src/paymentsetup.php
  9. 4
      plugin/buy_courses/view/list.tpl

@ -8,6 +8,6 @@ define('TABLE_BUY_COURSE_TRANSFERENCE', 'plugin_buy_course_transference');
define('TABLE_BUY_COURSE_TEMPORAL', 'plugin_buy_course_temporal');
define('TABLE_BUY_COURSE_SALE', 'plugin_buy_course_sale');
require_once '../../main/inc/global.inc.php';
require_once __DIR__ . '/../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once 'src/buy_course_plugin.class.php';
require_once api_get_path(PLUGIN_PATH) . 'buy_courses/src/buy_course_plugin.class.php';

@ -10,12 +10,14 @@ $table = Database::get_main_table(TABLE_BUY_COURSE);
$sql = "CREATE TABLE IF NOT EXISTS $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
id_course INT unsigned NOT NULL DEFAULT '0',
code VARCHAR(40),
title VARCHAR(250),
visible CHAR(2) NOT NULL DEFAULT '',
price FLOAT(11,2) NOT NULL DEFAULT '0',
synchronized CHAR(2) NOT NULL DEFAULT '')";
Database::query($sql);
$sql = "SELECT id, code, title FROM course";
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id, code, title FROM $tableCourse";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$presql = "INSERT INTO $table (id_course, code, title, visible) VALUES ('" . $row['id'] . "','" . $row['code'] . "','" . $row['title'] . "','NO')";
@ -311,23 +313,23 @@ Database::query($sql);
$table = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
$sql = "CREATE TABLE IF NOT EXISTS $table (
cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
user_id INT unsigned NOT NULL,
name VARCHAR(255) NOT NULL DEFAULT '',
course_code VARCHAR(200) NOT NULL DEFAULT '',
title VARCHAR(200) NOT NULL DEFAULT '',
reference VARCHAR(20) NOT NULL DEFAULT '',
price FLOAT(11,2) NOT NULL DEFAULT '0',
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
user_id INT unsigned NOT NULL,
name VARCHAR(255) NOT NULL DEFAULT '',
course_code VARCHAR(200) NOT NULL DEFAULT '',
title VARCHAR(200) NOT NULL DEFAULT '',
reference VARCHAR(20) NOT NULL DEFAULT '',
price FLOAT(11,2) NOT NULL DEFAULT '0',
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
Database::query($sql);
$table = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
$table = Database::get_main_table(TABLE_BUY_COURSE_SALE);
$sql = "CREATE TABLE IF NOT EXISTS $table (
cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
user_id INT unsigned NOT NULL,
course_code VARCHAR(200) NOT NULL DEFAULT '',
price FLOAT(11,2) NOT NULL DEFAULT '0',
payment_type VARCHAR(100) NOT NULL DEFAULT '',
status VARCHAR(20) NOT NULL DEFAULT '',
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
user_id INT unsigned NOT NULL,
course_code VARCHAR(200) NOT NULL DEFAULT '',
price FLOAT(11,2) NOT NULL DEFAULT '0',
payment_type VARCHAR(100) NOT NULL DEFAULT '',
status VARCHAR(20) NOT NULL DEFAULT '',
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
Database::query($sql);

@ -30,7 +30,7 @@ $(document).ready(function () {
var vvisible = $(this).parent().parent().prev().prev().children().attr("checked");
var vprice = $(this).parent().parent().prev().children().attr("value");
var idcurso = $(this).parent().parent().attr("id");
$.post("function/func.php", {tab: "guardar_mod", id: idcurso, visible: vvisible, price: vprice},
$.post("function.php", {tab: "save_mod", id: idcurso, visible: vvisible, price: vprice},
function (data) {
if (data.status == "false") {
alert("Error database");
@ -47,7 +47,7 @@ $(document).ready(function () {
});
$('#sincronizar').click(function (e) {
$.post("function/func.php", {tab: "sincronizar"},
$.post("function.php", {tab: "sincronizar"},
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/func.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria},
$.post("function.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria},
function (data) {
if (data.status == "false") {
alert(data.contenido);
@ -88,7 +88,7 @@ $(document).ready(function () {
$("#save_money").click(function (e) {
var tipo_moneda = $("#tipo_moneda").attr("value");
$.post("function/func.php", {tab: "guardar_moneda", moneda: tipo_moneda},
$.post("function.php", {tab: "guardar_moneda", moneda: tipo_moneda},
function (data) {
alert(data.contenido);
}, "json");
@ -106,7 +106,7 @@ $(document).ready(function () {
} else {
var vsandbox = "NO";
}
$.post("function/func.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox},
$.post("function.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox},
function (data) {
alert(data.contenido);
}, "json");
@ -122,7 +122,7 @@ $(document).ready(function () {
if (tname == '' || taccount == '') {
alert("Complete los campos antes de insertar");
} else {
$.post("function/func.php", {tab: "add_account", name: tname, account: taccount, swift: tswift},
$.post("function.php", {tab: "add_account", name: tname, account: taccount, swift: tswift},
function (data) {
location.reload();
}, "json");
@ -133,7 +133,7 @@ $(document).ready(function () {
$(".delete_account").click(function (e) {
var vid = $(this).parent().attr("id");
$.post("function/func.php", {tab: "delete_account", id: vid},
$.post("function.php", {tab: "delete_account", id: vid},
function (data) {
location.reload();
}, "json");
@ -143,13 +143,13 @@ $(document).ready(function () {
});
$("#cancelapedido").click(function (e) {
$.post("function/func.php", {tab: "borrar_variables"});
$.post("function.php", {tab: "borrar_variables"});
window.location.replace("list.php");
});
$(".borrar_pedido").click(function (e) {
var vid = $(this).parent().attr("id");
$.post("function/func.php", {tab: "borrar_pedido", id: vid},
$.post("function.php", {tab: "borrar_pedido", id: vid},
function (data) {
location.reload();
}, "json");
@ -160,7 +160,7 @@ $(document).ready(function () {
$(".confirmar_pedido").click(function (e) {
var vid = $(this).parent().attr("id");
$.post("function/func.php", {tab: "confirmar_pedido", id: vid},
$.post("function.php", {tab: "confirmar_pedido", id: vid},
function (data) {
location.reload();
}, "json");
@ -171,7 +171,7 @@ $(document).ready(function () {
$(".setting_tpv").click(function () {
var vcod = $(this).attr("id");
$.post("function/func.php", {tab: "cargar_tpv_configuracion", cod: vcod},
$.post("function.php", {tab: "cargar_tpv_configuracion", cod: vcod},
function (data) {
$("#resultado_tpv").html(data.contenido);
$("#guardar_datos_tpv").click(function (e) {
@ -183,7 +183,7 @@ $(document).ready(function () {
var selector = '#valor_tpv' + i;
array.push($(selector).attr("value"));
}
$.post("function/func.php", {tab: "save_tpv", cod: vcod, nump: num, action: vaction, parametros: array},
$.post("function.php", {tab: "save_tpv", cod: vcod, nump: num, action: vaction, parametros: array},
function (data) {
alert(data.contenido);
$("#resultado_tpv").html("");
@ -197,7 +197,7 @@ $(document).ready(function () {
$(".slt_tpv").change(function () {
var vcod = $(this).attr("value");
$.post("function/func.php", {tab: "activar_tpv", cod: vcod});
$.post("function.php", {tab: "activar_tpv", cod: vcod});
});
});

@ -4,6 +4,7 @@
* @package chamilo.plugin.notify
*/
require_once '../../../main/inc/global.inc.php';
require_once '../config.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
function sincronizar()
@ -28,9 +29,12 @@ function sincronizar()
Database::query($sql);
}
function listado_cursos()
function listCourses()
{
$sql = "SELECT a.id_course, a.visible, a.price, b.* FROM plugin_buycourses a, course b WHERE a.id_course=b.id;";
$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;";
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {

@ -39,7 +39,7 @@ class Buy_CoursesPlugin extends Plugin
$table = Database::get_main_table(TABLE_BUY_COURSE);
$sql = "DROP TABLE IF EXISTS $table";
Database::query($sql);
$table = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY);
$sql = "DROP TABLE IF EXISTS $table";
Database::query($sql);

@ -24,13 +24,13 @@ if ($teacher) {
$visibilidad[] = get_course_visibility_icon('2');
$visibilidad[] = get_course_visibility_icon('3');
$lista_cursos = listado_cursos();
$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();
$tpl->assign('server', $_configuration['root_web']);
$tpl->assign('cursos', $lista_cursos);
$tpl->assign('cursos', $coursesList);
$tpl->assign('visibilidad', $visibilidad);
$tpl->assign('ruta_imagen_ok', $ruta);
$tpl->assign('ruta_imagen_save', $ruta2);

@ -2,9 +2,18 @@
require_once '../../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
require_once '../lib/buy_course_plugin.class.php';
require_once 'buy_course_plugin.class.php';
require_once api_get_path(LIBRARY_PATH) . 'course.lib.php';
$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
$tableBuyCourseCountry = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY);
$tableBuyCoursePaypal = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL);
$tableBuyCourseTransference = Database::get_main_table(TABLE_BUY_COURSE_TRANSFERENCE);
$tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
$plugin = Buy_CoursesPlugin::create();
$buy_name = $plugin->get_lang('Buy');
@ -45,7 +54,7 @@ function quitar_html($cadena)
}
if ($_REQUEST['tab'] == 'sincronizar') {
$sql = "SELECT code,title FROM course;";
$sql = "SELECT code,title FROM $tableCourse;";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$aux_code .= $row['code'];
@ -91,9 +100,15 @@ if ($_REQUEST['tab'] == 'filtro_cursos') {
}
if ($filtro == '') {
$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';";
$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';";
} else {
$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 " . $filtro . ";";
$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 . ";";
}
//echo $sql;
@ -101,13 +116,22 @@ if ($_REQUEST['tab'] == 'filtro_cursos') {
$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;";
$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<EFBFBD> matriculado
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'] . "';";
$sql = "SELECT 1 FROM $tableCourseRelUser
WHERE course_code='" . $row['code'] . "'
AND user_id='" . $_SESSION['_user']['user_id'] . "';";
$tmp = Database::query($sql);
if (Database::affected_rows() > 0) {
$row['matriculado'] = "SI";
@ -132,7 +156,6 @@ if ($_REQUEST['tab'] == 'filtro_cursos') {
}
foreach ($aux as $curso) { //{% for curso in cursos %}
$contenido .= '<div class="well_border span8">';
$contenido .= '<div class="row">';
@ -166,16 +189,14 @@ if ($_REQUEST['tab'] == 'filtro_cursos') {
$contenido .= '</div>';
} //{% endfor %}
echo json_encode(array("status" => "true", "contenido" => $contenido));
}
if ($_REQUEST['tab'] == 'guardar_moneda') {
$id = $_REQUEST['moneda'];
$sql = "UPDATE plugin_buycourses_countries SET status='0';";
$sql = "UPDATE $tableBuyCourseCountry SET status='0';";
$res = Database::query($sql);
$sql = "UPDATE plugin_buycourses_countries SET status='1' WHERE id_country='" . $id . "';";
$sql = "UPDATE $tableBuyCourseCountry SET status='1' WHERE id_country='" . $id . "';";
$res = Database::query($sql);
if (!res) {
$contenido = 'Problema al guardar el tipo de moneda: ' . Database::error();
@ -191,8 +212,13 @@ if ($_REQUEST['tab'] == 'guardar_paypal') {
$password = mysql_real_escape_string($_REQUEST['password']);
$signature = mysql_real_escape_string($_REQUEST['signature']);
$sandbox = mysql_real_escape_string($_REQUEST['sandbox']);
$sql = "UPDATE plugin_bc_paypal SET sandbox='" . $sandbox . "', username='" . $username . "', password='" . $password . "', signature='" . $signature . "' WHERE id='1';";
//echo $sql;
$sql = "UPDATE $tableBuyCoursePaypal
SET sandbox = '" . $sandbox . "',
username = '" . $username . "',
password = '" . $password . "',
signature = '" . $signature . "'
WHERE id = '1';";
$res = Database::query($sql);
if (!res) {
$contenido = 'Problema al guardar los parametros de paypal: ' . Database::error();
@ -207,9 +233,8 @@ if ($_REQUEST['tab'] == 'add_account') {
$name = mysql_real_escape_string($_REQUEST['name']);
$account = mysql_real_escape_string($_REQUEST['account']);
$swift = mysql_real_escape_string($_REQUEST['swift']);
$sql = "INSERT INTO plugin_bc_transf (name, account, swift) VALUES ('" . $name . "','" . $account . "', '" . $swift . "');";
//echo $sql;
$sql = "INSERT INTO $tableBuyCourseTransference (name, account, swift)
VALUES ('" . $name . "','" . $account . "', '" . $swift . "');";
$res = Database::query($sql);
if (!res) {
@ -223,8 +248,7 @@ if ($_REQUEST['tab'] == 'add_account') {
if ($_REQUEST['tab'] == 'delete_account') {
$id = substr($_REQUEST['id'], 6);
$sql = "DELETE FROM plugin_bc_transf WHERE id='" . $id . "';";
//echo $sql;
$sql = "DELETE FROM $tableBuyCourseTransference WHERE id='" . $id . "';";
$res = Database::query($sql);
if (!res) {
$contenido = 'Problema al borrar la cuenta: ' . Database::error();
@ -235,14 +259,17 @@ if ($_REQUEST['tab'] == 'delete_account') {
}
}
if ($_REQUEST['tab'] == 'guardar_mod') {
if ($_REQUEST['tab'] == 'save_mod') {
$id = substr($_REQUEST['id'], 5);
$visible = ($_REQUEST['visible'] == "checked") ? ('SI') : ('NO');
$price = mysql_real_escape_string($_REQUEST['price']);
$obj = $_REQUEST['obj'];
$sql = "UPDATE $tableBuyCourse
SET visible='" . $visible . "',
price='" . $price . "'
WHERE id_course='" . $id . "';";
$sql = "UPDATE plugin_buycourses SET visible='" . $visible . "', price='" . $price . "' WHERE id_course='" . $id . "';";
$res = Database::query($sql);
if (!res) {
$contenido = 'Problema al guardar el mensaje: ' . Database::error();
@ -269,8 +296,8 @@ if ($_REQUEST['tab'] == 'borrar_variables') {
if ($_REQUEST['tab'] == 'borrar_pedido') {
$id = substr($_REQUEST['id'], 6);
$sql = "DELETE FROM plugin_bc_temporal WHERE cod='" . $id . "';";
//echo $sql;
$sql = "DELETE FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';";
$res = Database::query($sql);
if (!res) {
$contenido = 'Problema al borrar la cuenta: ' . Database::error();
@ -283,7 +310,7 @@ if ($_REQUEST['tab'] == 'borrar_pedido') {
if ($_REQUEST['tab'] == 'confirmar_pedido') {
$id = substr($_REQUEST['id'], 6);
$sql = "SELECT * FROM plugin_bc_temporal WHERE cod='" . $id . "';";
$sql = "SELECT * FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';";
$res = Database::query($sql);
$row = Database::fetch_assoc($res);
@ -299,14 +326,13 @@ if ($_REQUEST['tab'] == 'confirmar_pedido') {
}
//Activamos al usuario su cuenta
if ($seguir) {
$TABLE_USER = Database::get_main_table(TABLE_MAIN_USER);
// 1. set account inactive
$sql = "UPDATE " . $TABLE_USER . " SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'";
$sql = "UPDATE $tableUser SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'";
Database::query($sql);
$sql = "DELETE FROM plugin_bc_temporal WHERE cod='" . $id . "';";
//echo $sql;
$sql = "DELETE FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';";
$res = Database::query($sql);
$contenido = 'Se ha realizado con exito la subscripcion y activacion del usuario';
echo json_encode(array("status" => "true", "contenido" => $contenido));
} else {
@ -347,9 +373,9 @@ if ($_REQUEST['tab'] == 'cargar_tpv_configuracion') {
if ($_REQUEST['tab'] == 'cargar_tpv_configuracion') {
$cod = $_REQUEST['cod'];
$sql = "UDPATE plugin_bc_tpv SET activo='NO'";
$sql = "UDPATE plugin_bc_tpv SET status='NO'";
Database::query($sql);
$sql = "UPDATE plugin_bc_tpv SET activo='SI' WHERE cod='" . $cod . "';";
$sql = "UPDATE plugin_bc_tpv SET status='SI' WHERE cod='" . $cod . "';";
Database::query($sql);
}

@ -4,7 +4,7 @@
*/
require_once dirname(__FILE__) . '/buy_course.lib.php';
require_once '../../../main/inc/global.inc.php';
require_once 'lib/buy_course_plugin.class.php';
require_once 'buy_course_plugin.class.php';
$_cid = 0;
$interbreadcrumb[] = array("url" => "list.php", "name" => 'Listado de cursos a la venta');

@ -62,9 +62,9 @@
<div class="cleared"></div>
<div class="btn-toolbar right">
<a class="ajax btn btn-primary" title=""
href="{{ server }}plugin/buy_courses/function/ajax.php?code={{ curso.code }}">{{ 'Description'|get_lang }}</a>
href="{{ server }}plugin/buy_courses/src/ajax.php?code={{ curso.code }}">{{ 'Description'|get_lang }}</a>
{% if curso.matriculado == "NO" %}
<a class="btn btn-success" title="" href="{{ server }}plugin/buy_courses/process.php?code={{ curso.id }}">{{
<a class="btn btn-success" title="" href="{{ server }}plugin/buy_courses/src/process.php?code={{ curso.id }}">{{
'Buy'|get_lang }}</a>
{% endif %}
</div>

Loading…
Cancel
Save