Skip to content

Commit b6dce2a

Browse files
author
Francis Gonzales
committed
Modify Path, names and format code - refs bcourse
1 parent b038c1e commit b6dce2a

File tree

9 files changed

+102
-70
lines changed

9 files changed

+102
-70
lines changed

plugin/buy_courses/config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
define('TABLE_BUY_COURSE_TEMPORAL', 'plugin_buy_course_temporal');
99
define('TABLE_BUY_COURSE_SALE', 'plugin_buy_course_sale');
1010

11-
require_once '../../main/inc/global.inc.php';
11+
require_once __DIR__ . '/../../main/inc/global.inc.php';
1212
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
13-
require_once 'src/buy_course_plugin.class.php';
13+
require_once api_get_path(PLUGIN_PATH) . 'buy_courses/src/buy_course_plugin.class.php';

plugin/buy_courses/database.php

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
$sql = "CREATE TABLE IF NOT EXISTS $table (
1111
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
1212
id_course INT unsigned NOT NULL DEFAULT '0',
13+
code VARCHAR(40),
14+
title VARCHAR(250),
1315
visible CHAR(2) NOT NULL DEFAULT '',
1416
price FLOAT(11,2) NOT NULL DEFAULT '0',
1517
synchronized CHAR(2) NOT NULL DEFAULT '')";
1618
Database::query($sql);
17-
18-
$sql = "SELECT id, code, title FROM course";
19+
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
20+
$sql = "SELECT id, code, title FROM $tableCourse";
1921
$res = Database::query($sql);
2022
while ($row = Database::fetch_assoc($res)) {
2123
$presql = "INSERT INTO $table (id_course, code, title, visible) VALUES ('" . $row['id'] . "','" . $row['code'] . "','" . $row['title'] . "','NO')";
@@ -311,23 +313,23 @@
311313

312314
$table = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
313315
$sql = "CREATE TABLE IF NOT EXISTS $table (
314-
cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
315-
user_id INT unsigned NOT NULL,
316-
name VARCHAR(255) NOT NULL DEFAULT '',
317-
course_code VARCHAR(200) NOT NULL DEFAULT '',
318-
title VARCHAR(200) NOT NULL DEFAULT '',
319-
reference VARCHAR(20) NOT NULL DEFAULT '',
320-
price FLOAT(11,2) NOT NULL DEFAULT '0',
321-
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
316+
cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
317+
user_id INT unsigned NOT NULL,
318+
name VARCHAR(255) NOT NULL DEFAULT '',
319+
course_code VARCHAR(200) NOT NULL DEFAULT '',
320+
title VARCHAR(200) NOT NULL DEFAULT '',
321+
reference VARCHAR(20) NOT NULL DEFAULT '',
322+
price FLOAT(11,2) NOT NULL DEFAULT '0',
323+
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
322324
Database::query($sql);
323325

324-
$table = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
326+
$table = Database::get_main_table(TABLE_BUY_COURSE_SALE);
325327
$sql = "CREATE TABLE IF NOT EXISTS $table (
326-
cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
327-
user_id INT unsigned NOT NULL,
328-
course_code VARCHAR(200) NOT NULL DEFAULT '',
329-
price FLOAT(11,2) NOT NULL DEFAULT '0',
330-
payment_type VARCHAR(100) NOT NULL DEFAULT '',
331-
status VARCHAR(20) NOT NULL DEFAULT '',
332-
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
328+
cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
329+
user_id INT unsigned NOT NULL,
330+
course_code VARCHAR(200) NOT NULL DEFAULT '',
331+
price FLOAT(11,2) NOT NULL DEFAULT '0',
332+
payment_type VARCHAR(100) NOT NULL DEFAULT '',
333+
status VARCHAR(20) NOT NULL DEFAULT '',
334+
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
333335
Database::query($sql);

plugin/buy_courses/js/funciones.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $(document).ready(function () {
3030
var vvisible = $(this).parent().parent().prev().prev().children().attr("checked");
3131
var vprice = $(this).parent().parent().prev().children().attr("value");
3232
var idcurso = $(this).parent().parent().attr("id");
33-
$.post("function/func.php", {tab: "guardar_mod", id: idcurso, visible: vvisible, price: vprice},
33+
$.post("function.php", {tab: "save_mod", id: idcurso, visible: vvisible, price: vprice},
3434
function (data) {
3535
if (data.status == "false") {
3636
alert("Error database");
@@ -47,7 +47,7 @@ $(document).ready(function () {
4747
});
4848

4949
$('#sincronizar').click(function (e) {
50-
$.post("function/func.php", {tab: "sincronizar"},
50+
$.post("function.php", {tab: "sincronizar"},
5151
function (data) {
5252
if (data.status == "false") {
5353
alert(data.contenido);
@@ -71,7 +71,7 @@ $(document).ready(function () {
7171
var vmostrar = "NO";
7272
}
7373
var vcategoria = $("#categoria_cursos").attr("value");
74-
$.post("function/func.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria},
74+
$.post("function.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria},
7575
function (data) {
7676
if (data.status == "false") {
7777
alert(data.contenido);
@@ -88,7 +88,7 @@ $(document).ready(function () {
8888

8989
$("#save_money").click(function (e) {
9090
var tipo_moneda = $("#tipo_moneda").attr("value");
91-
$.post("function/func.php", {tab: "guardar_moneda", moneda: tipo_moneda},
91+
$.post("function.php", {tab: "guardar_moneda", moneda: tipo_moneda},
9292
function (data) {
9393
alert(data.contenido);
9494
}, "json");
@@ -106,7 +106,7 @@ $(document).ready(function () {
106106
} else {
107107
var vsandbox = "NO";
108108
}
109-
$.post("function/func.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox},
109+
$.post("function.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox},
110110
function (data) {
111111
alert(data.contenido);
112112
}, "json");
@@ -122,7 +122,7 @@ $(document).ready(function () {
122122
if (tname == '' || taccount == '') {
123123
alert("Complete los campos antes de insertar");
124124
} else {
125-
$.post("function/func.php", {tab: "add_account", name: tname, account: taccount, swift: tswift},
125+
$.post("function.php", {tab: "add_account", name: tname, account: taccount, swift: tswift},
126126
function (data) {
127127
location.reload();
128128
}, "json");
@@ -133,7 +133,7 @@ $(document).ready(function () {
133133

134134
$(".delete_account").click(function (e) {
135135
var vid = $(this).parent().attr("id");
136-
$.post("function/func.php", {tab: "delete_account", id: vid},
136+
$.post("function.php", {tab: "delete_account", id: vid},
137137
function (data) {
138138
location.reload();
139139
}, "json");
@@ -143,13 +143,13 @@ $(document).ready(function () {
143143
});
144144

145145
$("#cancelapedido").click(function (e) {
146-
$.post("function/func.php", {tab: "borrar_variables"});
146+
$.post("function.php", {tab: "borrar_variables"});
147147
window.location.replace("list.php");
148148
});
149149

150150
$(".borrar_pedido").click(function (e) {
151151
var vid = $(this).parent().attr("id");
152-
$.post("function/func.php", {tab: "borrar_pedido", id: vid},
152+
$.post("function.php", {tab: "borrar_pedido", id: vid},
153153
function (data) {
154154
location.reload();
155155
}, "json");
@@ -160,7 +160,7 @@ $(document).ready(function () {
160160

161161
$(".confirmar_pedido").click(function (e) {
162162
var vid = $(this).parent().attr("id");
163-
$.post("function/func.php", {tab: "confirmar_pedido", id: vid},
163+
$.post("function.php", {tab: "confirmar_pedido", id: vid},
164164
function (data) {
165165
location.reload();
166166
}, "json");
@@ -171,7 +171,7 @@ $(document).ready(function () {
171171

172172
$(".setting_tpv").click(function () {
173173
var vcod = $(this).attr("id");
174-
$.post("function/func.php", {tab: "cargar_tpv_configuracion", cod: vcod},
174+
$.post("function.php", {tab: "cargar_tpv_configuracion", cod: vcod},
175175
function (data) {
176176
$("#resultado_tpv").html(data.contenido);
177177
$("#guardar_datos_tpv").click(function (e) {
@@ -183,7 +183,7 @@ $(document).ready(function () {
183183
var selector = '#valor_tpv' + i;
184184
array.push($(selector).attr("value"));
185185
}
186-
$.post("function/func.php", {tab: "save_tpv", cod: vcod, nump: num, action: vaction, parametros: array},
186+
$.post("function.php", {tab: "save_tpv", cod: vcod, nump: num, action: vaction, parametros: array},
187187
function (data) {
188188
alert(data.contenido);
189189
$("#resultado_tpv").html("");
@@ -197,7 +197,7 @@ $(document).ready(function () {
197197

198198
$(".slt_tpv").change(function () {
199199
var vcod = $(this).attr("value");
200-
$.post("function/func.php", {tab: "activar_tpv", cod: vcod});
200+
$.post("function.php", {tab: "activar_tpv", cod: vcod});
201201
});
202202
});
203203

plugin/buy_courses/src/buy_course.lib.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @package chamilo.plugin.notify
55
*/
66
require_once '../../../main/inc/global.inc.php';
7+
require_once '../config.php';
78
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
89

910
function sincronizar()
@@ -28,9 +29,12 @@ function sincronizar()
2829
Database::query($sql);
2930
}
3031

31-
function listado_cursos()
32+
function listCourses()
3233
{
33-
$sql = "SELECT a.id_course, a.visible, a.price, b.* FROM plugin_buycourses a, course b WHERE a.id_course=b.id;";
34+
$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
35+
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
36+
$sql = "SELECT a.id_course, a.visible, a.price, b.* FROM $tableBuyCourse a, $tableCourse b WHERE a.id_course = b.id;";
37+
3438
$res = Database::query($sql);
3539
$aux = array();
3640
while ($row = Database::fetch_assoc($res)) {

plugin/buy_courses/src/buy_course_plugin.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function uninstall()
3939
$table = Database::get_main_table(TABLE_BUY_COURSE);
4040
$sql = "DROP TABLE IF EXISTS $table";
4141
Database::query($sql);
42-
42+
4343
$table = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY);
4444
$sql = "DROP TABLE IF EXISTS $table";
4545
Database::query($sql);

plugin/buy_courses/src/configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
$visibilidad[] = get_course_visibility_icon('2');
2525
$visibilidad[] = get_course_visibility_icon('3');
2626

27-
$lista_cursos = listado_cursos();
27+
$coursesList = listCourses();
2828
$ruta = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png';
2929
$ruta2 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/save.png';
3030
$tipo_moneda = busca_moneda();
3131

3232
$tpl->assign('server', $_configuration['root_web']);
33-
$tpl->assign('cursos', $lista_cursos);
33+
$tpl->assign('cursos', $coursesList);
3434
$tpl->assign('visibilidad', $visibilidad);
3535
$tpl->assign('ruta_imagen_ok', $ruta);
3636
$tpl->assign('ruta_imagen_save', $ruta2);

0 commit comments

Comments
 (0)