Merge branch 'nosolored-1.11.x_buycourses_features' into 1.11.x

pull/3683/head
Yannick Warnier 5 years ago
commit 255943be0e
  1. 13
      plugin/buycourses/CHANGELOG.md
  2. 33
      plugin/buycourses/README.md
  3. 12
      plugin/buycourses/database.php
  4. 1
      plugin/buycourses/lang/english.php
  5. 1
      plugin/buycourses/lang/french.php
  6. 1
      plugin/buycourses/lang/spanish.php
  7. 42
      plugin/buycourses/src/buy_course_plugin.class.php
  8. 25
      plugin/buycourses/src/paymentsetup.php
  9. 2
      plugin/buycourses/src/process_confirm.php
  10. 1
      plugin/buycourses/view/message_transfer.tpl
  11. 3
      plugin/buycourses/view/paymentsetup.tpl

@ -1,3 +1,12 @@
v6.0 - 2020-11-29
====
Added support for purchase instructions e-mail customization (although this
does not support multiple languages at the moment).
This requires changes to the DB tables:
```sql
ALTER TABLE plugin_buycourses_global_config ADD COLUMN info_email_extra TEXT;
```
v5.0 - 2019-02-06
====
@ -11,8 +20,8 @@ The file update.php must be executed to update the structure of the tables
v4.0 - 2017-04-25
====
This version includes the Culqi payment gateway and introduces an additional
option to show the Buy Courses tab to anonymous users.
This version includes the Culqi payment gateway v1.0 (now expired) and introduces
an additional option to show the Buy Courses tab to anonymous users.
To enable these features, if you have already installed this plugin on your
portal prior to this version, you will need to add the corresponding settings

@ -1,13 +1,32 @@
Buy Courses plugin for Chamilo LMS
=======================================
Users can access the purchases catalog to buy courses or sessions (since v2 of this plugin)
enabled for sale.
Buy Courses (course sales) plugin
=================================
This plugin transforms your Chamilo installation in an online shop by adding a catalogue
of courses and sessions that you have previously configured for sales.
If the user is not registered or logged in, he/she will be requested to register/login
before he/she can resume buying items.
Once the course or session is chosen, shows available payment types (currently only PayPal works)
Once the course or session is chosen, the plugin displays the available payment methods
and lets the user proceed with the purchase.
Currently, the plugin allows users to pay through:
- PayPal (requires a merchant account on PayPal at configuration time)
- Bank payments (requires manual confirmation of payments' reception)
- RedSys payments (Spanish payment gateway) (requires the download of an external file)
Finally, the user receives an e-mail confirming the purchase and him/her is can access to the
course/session.
The user receives an e-mail confirming the purchase and she/he can immediately
access to the course or session.
We recommend using sessions as this gives you more time-related availability options
(in the session configuration).
Updates
=========
You must load the update.php script for installations that were in
production before updating the code, as it will update the database structure to
enable new features.
Please note that updating Chamilo does *NOT* automatically update the plugins
structure.
You can find a history of changes in the [CHANGELOG.md file](./CHANGELOG.md)

@ -379,9 +379,21 @@ if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG)) {
$globalTable->addColumn('next_number_invoice', \Doctrine\DBAL\Types\Type::INTEGER);
$globalTable->addColumn('invoice_series', \Doctrine\DBAL\Types\Type::STRING);
$globalTable->addColumn('sale_email', \Doctrine\DBAL\Types\Type::STRING);
$globalTable->addColumn('info_email_extra', \Doctrine\DBAL\Types\Type::TEXT);
$globalTable->setPrimaryKey(['id']);
}
$settingsTable = BuyCoursesPlugin::TABLE_GLOBAL_CONFIG;
$sql = "SHOW COLUMNS FROM $settingsTable WHERE Field = 'info_email_extra'";
$res = Database::query($sql);
if (Database::num_rows($res) === 0) {
$sql = "ALTER TABLE $settingsTable ADD (info_email_extra TEXT NOT NULL)";
$res = Database::query($sql);
if (!$res) {
echo Display::return_message($this->get_lang('ErrorUpdateFieldDB'), 'warning');
}
}
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_INVOICE)) {
$invoiceTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_INVOICE);
$invoiceTable->addColumn(

@ -205,3 +205,4 @@ $strings['kc'] = "Secret encryption key";
$strings['url_redsys'] = "Redsys connection URL";
$strings['url_redsys_sandbox'] = "Redsys connection URL (Sandbox)";
$strings['InfoTpvRedsysApiCredentials'] = "You must complete the following fields of the form with the information provided by the Redsys POS Technical Support:";
$strings['InfoEmailExtra'] = "Extra info in payment e-mail";

@ -163,3 +163,4 @@ $strings['Names'] = "Nom";
$strings['ExportReport'] = "Export du rapport des ventes";
$strings['OrderTime'] = "Heure de commande";
$strings['SelectDateRange'] = "Sélectionnez une date de début et une date de fin pour le rapport";
$strings['InfoEmailExtra'] = "Informations additionnelles dans l'e-mail de paiement";

@ -226,3 +226,4 @@ $strings['kc'] = "Clave secreta de encriptación";
$strings['url_redsys'] = "URL conexión Redsys";
$strings['url_redsys_sandbox'] = "URL conexión Redsys (Pruebas)";
$strings['InfoTpvRedsysApiCredentials'] = "Deberá completar los siguientes campos del formulario con la información que les facilite el Soporte Técnico del TPV Redsys:";
$strings['InfoEmailExtra'] = "Información extra en e-mail";

@ -207,6 +207,17 @@ class BuyCoursesPlugin extends Plugin
}
}
$sql = "SHOW COLUMNS FROM $table WHERE Field = 'info_email_extra'";
$res = Database::query($sql);
if (Database::num_rows($res) === 0) {
$sql = "ALTER TABLE $table ADD (info_email_extra TEXT NOT NULL)";
$res = Database::query($sql);
if (!$res) {
echo Display::return_message($this->get_lang('ErrorUpdateFieldDB'), 'warning');
}
}
$table = self::TABLE_ITEM;
$sql = "SHOW COLUMNS FROM $table WHERE Field = 'tax_perc'";
$res = Database::query($sql);
@ -538,6 +549,37 @@ class BuyCoursesPlugin extends Plugin
);
}
/**
* Save email message information in transfer.
*
* @param array $params The transfer message
*
* @return int Rows affected. Otherwise return false
*/
public function saveTransferInfoEmail($params)
{
return Database::update(
Database::get_main_table(self::TABLE_GLOBAL_CONFIG),
['info_email_extra' => $params['tinfo_email_extra']],
['id = ?' => 1]
);
}
/**
* Gets message information for transfer email.
*
* @return array
*/
public function getTransferInfoExtra()
{
return Database::select(
'info_email_extra AS tinfo_email_extra',
Database::get_main_table(self::TABLE_GLOBAL_CONFIG),
['id = ?' => 1],
'first'
);
}
/**
* Get a list of transfer accounts.
*

@ -338,6 +338,30 @@ $transferForm->addButtonCreate(get_lang('Add'));
$transferAccounts = $plugin->getTransferAccounts();
$transferInfoForm = new FormValidator('transfer_info');
if ($transferInfoForm->validate()) {
$transferInfoFormValues = $transferInfoForm->getSubmitValues();
$plugin->saveTransferInfoEmail($transferInfoFormValues);
Display::addFlash(
Display::return_message(get_lang('Saved'), 'success')
);
header('Location:'.api_get_self());
exit;
}
$transferInfoForm->addHtmlEditor(
'tinfo_email_extra',
$plugin->get_lang('InfoEmailExtra'),
false,
false,
['ToolbarSet' => 'Minimal']
);
$transferInfoForm->addButtonCreate(get_lang('Save'));
$transferInfoForm->setDefaults($plugin->getTransferInfoExtra());
// Culqi main configuration
$culqiForm = new FormValidator('culqi_config');
@ -384,6 +408,7 @@ $tpl->assign('global_config_form', $globalSettingForm->returnForm());
$tpl->assign('paypal_form', $paypalForm->returnForm());
$tpl->assign('commission_form', $commissionForm->returnForm());
$tpl->assign('transfer_form', $transferForm->returnForm());
$tpl->assign('transfer_info_form', $transferInfoForm->returnForm());
$tpl->assign('culqi_form', $culqiForm->returnForm());
$tpl->assign('transfer_accounts', $transferAccounts);
$tpl->assign('paypal_enable', $paypalEnable);

@ -104,6 +104,7 @@ switch ($sale['payment_type']) {
}
$transferAccounts = $plugin->getTransferAccounts();
$infoEmailExtra = $plugin->getTransferInfoExtra()['tinfo_email_extra'];
$form = new FormValidator(
'success',
@ -139,6 +140,7 @@ switch ($sale['payment_type']) {
]
);
$messageTemplate->assign('transfer_accounts', $transferAccounts);
$messageTemplate->assign('info_email_extra', $infoEmailExtra);
MessageManager::send_message_simple(
$userInfo['user_id'],

@ -32,5 +32,6 @@
{% endfor %}
</tbody>
</table>
<p>{{ info_email_extra }}</p>
<p>{{ 'PurchaseDetailsEnd'|get_plugin_lang('BuyCoursesPlugin') }}</p>
</div>

@ -113,6 +113,9 @@
</table>
</div>
</div>
<div class="col-md-12">
{{ transfer_info_form }}
</div>
</div>
</div>
</div>

Loading…
Cancel
Save