upgrade
134
plugin/buycourses/CHANGELOG.md
Normal file
@@ -0,0 +1,134 @@
|
||||
v7.4 - 2022-04-28
|
||||
====
|
||||
Add subscriptions support.
|
||||
|
||||
If the plugin has already been installed, the update.php script must be executed (load plugin/buycourses/update.php in your browser) to update the database structure by adding the plugin_buycourses_subscription, plugin_buycourses_subscription_rel_sale, plugin_buycourses_subscription_period and plugin_buycourses_coupon_rel_subscription_sale.
|
||||
|
||||
v7.3 - 2022-04-28
|
||||
====
|
||||
Add Cecabank payments support.
|
||||
|
||||
If the plugin has already been installed, the update.php script must be executed (load plugin/buycourses/update.php in your browser) to update the structure of the tables in the database.
|
||||
|
||||
v7.2 - 2021-11-22
|
||||
====
|
||||
Add Stripe payments support.
|
||||
|
||||
If the plugin has already been installed, the update.php script must be executed (load plugin/buycourses/update.php in your browser) to update the structure of the tables in the database.
|
||||
|
||||
v7.1 - 2021-10-26
|
||||
====
|
||||
Fix install issue with DB field type.
|
||||
|
||||
v7.0 - 2021-08-12
|
||||
====
|
||||
Added support for discount coupons.
|
||||
Added a better table view for the sales report.
|
||||
Multiple fixes to navigation-related issues.
|
||||
|
||||
WARNING: Updating this plugin (or Chamilo) without going through the specific update procedure for this plugin will break your sales pages.
|
||||
|
||||
The file [your-host]/plugin/buycourses/update.php *MUST* be executed to update the structure of the tables
|
||||
in the database.
|
||||
|
||||
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
|
||||
====
|
||||
|
||||
This version includes two additional modules (taxes and invoices),
|
||||
which can be enabled from the configuration.
|
||||
|
||||
The file update.php must be executed to update the structure of the tables
|
||||
in the database.
|
||||
|
||||
|
||||
v4.0 - 2017-04-25
|
||||
====
|
||||
|
||||
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
|
||||
to your settings_current table. No documentation is available at this time on
|
||||
how to do that, so please check up the code. Sorry about that.
|
||||
|
||||
|
||||
v3.0 - 2015-09-25
|
||||
====
|
||||
|
||||
This version has been fixed and improved for Chamilo LMS 1.10.x.
|
||||
|
||||
- A new user interface for platform admins and users.
|
||||
- Avoid data redundancy by adding courses/sessions to catalog
|
||||
- The catalog of sessions can be configured to offer some courses or sessions
|
||||
in a currency other than the others courses or sessions
|
||||
- The sales have a status: Pending, Completed, Canceled
|
||||
- The Peding Orders pages has been replaced by a Sales Report.
|
||||
Allowing filter the sales by its status
|
||||
- The plugin Registration page was removed. Instead the Chamilo LMS
|
||||
registrarion page is used.
|
||||
- Added the ability to record beneficiaries with the sale of courses/sessions
|
||||
|
||||
##Changes in database structure
|
||||
|
||||
The database structure has been changed totally. The previous database
|
||||
structure was formed for the tables:
|
||||
|
||||
- `plugin_buy_course` The registered courses in the platform
|
||||
- `plugin_buy_course_country` The list of countries with their currencies
|
||||
- `plugin_buy_course_paypal` The PayPal account info
|
||||
- `plugin_buy_course_sale` The sales of courses that were made
|
||||
- `plugin_buy_course_temporal` The pending orders of courses that were made
|
||||
- `plugin_buy_course_transfer` The bank accounts for transfers
|
||||
- `plugin_buy_session` The registered courses in the platform
|
||||
- `plugin_buy_session_course` The courses in sessions
|
||||
- `plugin_buy_session_sale` The sales of session that were made
|
||||
- `plugin_buy_session_temporary` The pending orders of session that were made
|
||||
|
||||
To avoid the data redundancy, the `plugin_buy_course`, `plugin_buy_session`
|
||||
and `plugin_buy_session_course` tables were replaced for the
|
||||
`plugin_buycourses_item` table. And the `plugin_buy_course_sale`,
|
||||
`plugin_buy_course_temporal`, `plugin_buy_session_sale` and
|
||||
`plugin_buy_session_temporary` tables were replaced for the
|
||||
`plugin_buycourses_item` table.
|
||||
|
||||
The __new database__ structure is formed for the tables:
|
||||
|
||||
- `plugin_buycourses_currency` The list of countries with their currencies
|
||||
- `plugin_buycourses_item` The registered courses and sessions in the platform
|
||||
- `plugin_buycourses_item_re_beneficiary` The beneficiaries users with the sale of courses
|
||||
- `plugin_buycourses_paypal_account` The PayPal account info
|
||||
- `plugin_buycourses_sale` The sales of courses and sessions that were made
|
||||
- `plugin_buycourses_transfer` The bank accounts for transfers
|
||||
|
||||
---
|
||||
|
||||
v2.0 - 2014-10-14
|
||||
=================
|
||||
This version adds support for sales of sessions access.
|
||||
A session can be purchased as soon as it is given a price, granted the current
|
||||
date is either previous to the session start date, between the start and end,
|
||||
or no date has been defined for the session.
|
||||
Students are subscribed automatically once they have paid. There is no
|
||||
intermediary step.
|
||||
This version does not work (yet) with the session period defined by user
|
||||
(a special feature introduced in Chamilo 1.9.10).
|
||||
|
||||
Upgrade procedure
|
||||
-----------------
|
||||
If you are working with this plugin since earlier versions, you will have to
|
||||
look at the installer to *fix* your plugin tables (add a few fields).
|
||||
|
||||
v1.0 - 2014-06-30 (or something)
|
||||
=================
|
||||
This is the first release of the plugin, with only the PayPal payment method
|
||||
in working state and only for courses.
|
||||
37
plugin/buycourses/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
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.
|
||||
|
||||
Do not enable this plugin in any "Region". This is a known issue, but it works without
|
||||
region assignation.
|
||||
|
||||
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)
|
||||
- Stripe payments (requieres a merchant account oin Stripe at configuration time)
|
||||
- Cecabank payments (Spanish payment gateway)
|
||||
|
||||
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](../../plugin/buycourses/CHANGELOG.md)
|
||||
3
plugin/buycourses/admin.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// Redirect to buycourses/index.php
|
||||
header('location: index.php');
|
||||
4
plugin/buycourses/config.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
require_once __DIR__.'/../../main/inc/global.inc.php';
|
||||
996
plugin/buycourses/database.php
Normal file
@@ -0,0 +1,996 @@
|
||||
<?php
|
||||
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
|
||||
/**
|
||||
* Plugin database installation script. Can only be executed if included
|
||||
* inside another script loading global.inc.php.
|
||||
*
|
||||
* Check if script can be called.
|
||||
*/
|
||||
if (!function_exists('api_get_path')) {
|
||||
exit('This script must be loaded through the Chamilo plugin installer sequence');
|
||||
}
|
||||
|
||||
$entityManager = Database::getManager();
|
||||
$pluginSchema = new Schema();
|
||||
$connection = $entityManager->getConnection();
|
||||
$platform = $connection->getDatabasePlatform();
|
||||
$sm = $connection->getSchemaManager();
|
||||
|
||||
// Create tables
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_PAYPAL)) {
|
||||
$paypalTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_PAYPAL);
|
||||
$paypalTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$paypalTable->addColumn('username', Types::STRING);
|
||||
$paypalTable->addColumn('password', Types::STRING);
|
||||
$paypalTable->addColumn('signature', Types::STRING);
|
||||
$paypalTable->addColumn('sandbox', Types::BOOLEAN);
|
||||
$paypalTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_TRANSFER)) {
|
||||
$transferTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_TRANSFER);
|
||||
$transferTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$transferTable->addColumn('name', Types::STRING);
|
||||
$transferTable->addColumn('account', Types::STRING);
|
||||
$transferTable->addColumn('swift', Types::STRING);
|
||||
$transferTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_TPV_REDSYS)) {
|
||||
$tpvRedsysTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_TPV_REDSYS);
|
||||
$tpvRedsysTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$tpvRedsysTable->addColumn('merchantcode', Types::STRING);
|
||||
$tpvRedsysTable->addColumn('terminal', Types::STRING);
|
||||
$tpvRedsysTable->addColumn('currency', Types::STRING);
|
||||
$tpvRedsysTable->addColumn('kc', Types::STRING);
|
||||
$tpvRedsysTable->addColumn('url_redsys', Types::STRING);
|
||||
$tpvRedsysTable->addColumn('url_redsys_sandbox', Types::STRING);
|
||||
$tpvRedsysTable->addColumn('sandbox', Types::BOOLEAN);
|
||||
$tpvRedsysTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_CURRENCY)) {
|
||||
$currencyTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_CURRENCY);
|
||||
$currencyTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$currencyTable->addColumn(
|
||||
'country_code',
|
||||
Types::STRING,
|
||||
['length' => 2]
|
||||
);
|
||||
$currencyTable->addColumn(
|
||||
'country_name',
|
||||
Types::STRING,
|
||||
['length' => 255]
|
||||
);
|
||||
$currencyTable->addColumn(
|
||||
'iso_code',
|
||||
Types::STRING,
|
||||
['length' => 3]
|
||||
);
|
||||
$currencyTable->addColumn('status', Types::BOOLEAN);
|
||||
$currencyTable->addUniqueIndex(['country_code']);
|
||||
$currencyTable->addIndex(['iso_code']);
|
||||
$currencyTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_ITEM)) {
|
||||
$itemTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_ITEM);
|
||||
$itemTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$itemTable->addColumn('product_type', Types::INTEGER);
|
||||
$itemTable->addColumn(
|
||||
'product_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$itemTable->addColumn(
|
||||
'price',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2]
|
||||
);
|
||||
$itemTable->addColumn(
|
||||
'currency_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$itemTable->addColumn(
|
||||
'tax_perc',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true, 'notnull' => false]
|
||||
);
|
||||
$itemTable->setPrimaryKey(['id']);
|
||||
$itemTable->addForeignKeyConstraint(
|
||||
$currencyTable,
|
||||
['currency_id'],
|
||||
['id'],
|
||||
['onDelete' => 'CASCADE']
|
||||
);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_ITEM_BENEFICIARY)) {
|
||||
$itemBeneficiary = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_ITEM_BENEFICIARY);
|
||||
$itemBeneficiary->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$itemBeneficiary->addColumn(
|
||||
'item_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$itemBeneficiary->addColumn(
|
||||
'user_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$itemBeneficiary->addColumn(
|
||||
'commissions',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$itemBeneficiary->setPrimaryKey(['id']);
|
||||
$itemBeneficiary->addForeignKeyConstraint(
|
||||
$itemTable,
|
||||
['item_id'],
|
||||
['id'],
|
||||
['onDelete' => 'CASCADE']
|
||||
);
|
||||
}
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_COMMISSION)) {
|
||||
$commissions = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_COMMISSION);
|
||||
$commissions->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$commissions->addColumn(
|
||||
'commission',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$commissions->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_PAYPAL_PAYOUTS)) {
|
||||
$saleCommissions = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_PAYPAL_PAYOUTS);
|
||||
$saleCommissions->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$saleCommissions->addColumn('date', Types::DATETIME_MUTABLE);
|
||||
$saleCommissions->addColumn('payout_date', Types::DATETIME_MUTABLE);
|
||||
$saleCommissions->addColumn(
|
||||
'sale_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$saleCommissions->addColumn(
|
||||
'user_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$saleCommissions->addColumn(
|
||||
'commission',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2]
|
||||
);
|
||||
$saleCommissions->addColumn(
|
||||
'status',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$saleCommissions->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_SALE)) {
|
||||
$saleTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SALE);
|
||||
$saleTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$saleTable->addColumn('reference', Types::STRING);
|
||||
$saleTable->addColumn('date', Types::DATETIME_MUTABLE);
|
||||
$saleTable->addColumn(
|
||||
'user_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$saleTable->addColumn('product_type', Types::INTEGER);
|
||||
$saleTable->addColumn('product_name', Types::STRING);
|
||||
$saleTable->addColumn(
|
||||
'product_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$saleTable->addColumn(
|
||||
'price',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2]
|
||||
);
|
||||
$saleTable->addColumn(
|
||||
'price_without_tax',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2, 'notnull' => false]
|
||||
);
|
||||
$saleTable->addColumn(
|
||||
'tax_perc',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true, 'notnull' => false]
|
||||
);
|
||||
$saleTable->addColumn(
|
||||
'tax_amount',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2, 'notnull' => false]
|
||||
);
|
||||
$saleTable->addColumn(
|
||||
'currency_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$saleTable->addColumn('status', Types::INTEGER);
|
||||
$saleTable->addColumn('payment_type', Types::INTEGER);
|
||||
$saleTable->addColumn('invoice', Types::INTEGER);
|
||||
$saleTable->addColumn(
|
||||
'price_without_discount',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2, 'notnull' => false]
|
||||
);
|
||||
$saleTable->addColumn(
|
||||
'discount_amount',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2, 'notnull' => false]
|
||||
);
|
||||
$saleTable->setPrimaryKey(['id']);
|
||||
$saleTable->addForeignKeyConstraint(
|
||||
$currencyTable,
|
||||
['currency_id'],
|
||||
['id'],
|
||||
['onDelete' => 'CASCADE']
|
||||
);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_SERVICES)) {
|
||||
$servicesTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SERVICES);
|
||||
$servicesTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$servicesTable->addColumn('name', Types::STRING);
|
||||
$servicesTable->addColumn('description', Types::TEXT);
|
||||
$servicesTable->addColumn(
|
||||
'price',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2]
|
||||
);
|
||||
$servicesTable->addColumn('duration_days', Types::INTEGER);
|
||||
$servicesTable->addColumn('applies_to', Types::INTEGER);
|
||||
$servicesTable->addColumn('owner_id', Types::INTEGER);
|
||||
$servicesTable->addColumn('visibility', Types::INTEGER);
|
||||
$servicesTable->addColumn('video_url', Types::STRING);
|
||||
$servicesTable->addColumn('image', Types::STRING);
|
||||
$servicesTable->addColumn('service_information', Types::TEXT);
|
||||
$servicesTable->addColumn('tax_perc', Types::INTEGER);
|
||||
$servicesTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_SERVICES_SALE)) {
|
||||
$servicesNodeTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SERVICES_SALE);
|
||||
$servicesNodeTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$servicesNodeTable->addColumn(
|
||||
'service_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$servicesNodeTable->addColumn('reference', Types::STRING);
|
||||
$servicesNodeTable->addColumn('currency_id', Types::INTEGER);
|
||||
$servicesNodeTable->addColumn(
|
||||
'price',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2]
|
||||
);
|
||||
$servicesNodeTable->addColumn(
|
||||
'price_without_tax',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2, 'notnull' => false]
|
||||
);
|
||||
$servicesNodeTable->addColumn(
|
||||
'tax_perc',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true, 'notnull' => false]
|
||||
);
|
||||
$servicesNodeTable->addColumn(
|
||||
'tax_amount',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2, 'notnull' => false]
|
||||
);
|
||||
$servicesNodeTable->addColumn('node_type', Types::INTEGER);
|
||||
$servicesNodeTable->addColumn('node_id', Types::INTEGER);
|
||||
$servicesNodeTable->addColumn('buyer_id', Types::INTEGER);
|
||||
$servicesNodeTable->addColumn('buy_date', Types::DATETIME_MUTABLE);
|
||||
$servicesNodeTable->addColumn(
|
||||
'date_start',
|
||||
Types::DATETIME_MUTABLE,
|
||||
['notnull' => false]
|
||||
);
|
||||
$servicesNodeTable->addColumn(
|
||||
'date_end',
|
||||
Types::DATETIME_MUTABLE
|
||||
);
|
||||
$servicesNodeTable->addColumn('status', Types::INTEGER);
|
||||
$servicesNodeTable->addColumn('payment_type', Types::INTEGER);
|
||||
$servicesNodeTable->addColumn('invoice', Types::INTEGER);
|
||||
$servicesNodeTable->addColumn(
|
||||
'price_without_discount',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2, 'notnull' => false]
|
||||
);
|
||||
$servicesNodeTable->addColumn(
|
||||
'discount_amount',
|
||||
Types::DECIMAL,
|
||||
['scale' => 2, 'notnull' => false]
|
||||
);
|
||||
$servicesNodeTable->setPrimaryKey(['id']);
|
||||
$servicesNodeTable->addForeignKeyConstraint(
|
||||
$servicesTable,
|
||||
['service_id'],
|
||||
['id'],
|
||||
['onDelete' => 'CASCADE']
|
||||
);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_CULQI)) {
|
||||
$culqiTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_CULQI);
|
||||
$culqiTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$culqiTable->addColumn('commerce_code', Types::STRING);
|
||||
$culqiTable->addColumn('api_key', Types::STRING);
|
||||
$culqiTable->addColumn('integration', Types::INTEGER);
|
||||
$culqiTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG)) {
|
||||
$globalTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG);
|
||||
$globalTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$globalTable->addColumn('terms_and_conditions', Types::TEXT);
|
||||
$globalTable->addColumn('global_tax_perc', Types::INTEGER);
|
||||
$globalTable->addColumn('tax_applies_to', Types::INTEGER);
|
||||
$globalTable->addColumn('tax_name', Types::STRING);
|
||||
$globalTable->addColumn('seller_name', Types::STRING);
|
||||
$globalTable->addColumn('seller_id', Types::STRING);
|
||||
$globalTable->addColumn('seller_address', Types::STRING);
|
||||
$globalTable->addColumn('seller_email', Types::STRING);
|
||||
$globalTable->addColumn('next_number_invoice', Types::INTEGER);
|
||||
$globalTable->addColumn('invoice_series', Types::STRING);
|
||||
$globalTable->addColumn('sale_email', Types::STRING);
|
||||
$globalTable->addColumn('info_email_extra', Types::TEXT);
|
||||
$globalTable->setPrimaryKey(['id']);
|
||||
} else {
|
||||
$globalTable = $pluginSchema->getTable(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG);
|
||||
|
||||
if (!$globalTable->hasColumn('info_email_extra')) {
|
||||
$globalTable->addColumn('info_email_extra', Types::TEXT);
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_INVOICE)) {
|
||||
$invoiceTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_INVOICE);
|
||||
$invoiceTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$invoiceTable->addColumn('sale_id', Types::INTEGER);
|
||||
$invoiceTable->addColumn('is_service', Types::INTEGER);
|
||||
$invoiceTable->addColumn(
|
||||
'num_invoice',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true, 'notnull' => false]
|
||||
);
|
||||
$invoiceTable->addColumn(
|
||||
'year',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true, 'notnull' => false]
|
||||
);
|
||||
$invoiceTable->addColumn('serie', Types::STRING);
|
||||
$invoiceTable->addColumn('date_invoice', Types::DATETIME_MUTABLE);
|
||||
$invoiceTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_COUPON)) {
|
||||
$couponTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_COUPON);
|
||||
$couponTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$couponTable->addColumn('code', Types::STRING);
|
||||
$couponTable->addColumn('discount_type', Types::INTEGER);
|
||||
$couponTable->addColumn('discount_amount', Types::INTEGER);
|
||||
$couponTable->addColumn('valid_start', Types::DATETIME_MUTABLE);
|
||||
$couponTable->addColumn('valid_end', Types::DATETIME_MUTABLE);
|
||||
$couponTable->addColumn('delivered', Types::INTEGER);
|
||||
$couponTable->addColumn('active', Types::BOOLEAN);
|
||||
$couponTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_COUPON_ITEM)) {
|
||||
$couponItemTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_COUPON_ITEM);
|
||||
$couponItemTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$couponItemTable->addColumn('coupon_id', Types::INTEGER);
|
||||
$couponItemTable->addColumn('product_type', Types::INTEGER);
|
||||
$couponItemTable->addColumn('product_id', Types::INTEGER);
|
||||
$couponItemTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_COUPON_SERVICE)) {
|
||||
$couponService = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_COUPON_SERVICE);
|
||||
$couponService->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$couponService->addColumn('coupon_id', Types::INTEGER);
|
||||
$couponService->addColumn('service_id', Types::INTEGER);
|
||||
$couponService->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_SUBSCRIPTION)) {
|
||||
$subscriptionTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SUBSCRIPTION);
|
||||
$subscriptionTable->addColumn(
|
||||
'product_type',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$subscriptionTable->addColumn(
|
||||
'product_id',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$subscriptionTable->addColumn(
|
||||
'duration',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$subscriptionTable->addColumn('currency_id', Types::INTEGER);
|
||||
$subscriptionTable->addColumn('price', Types::DECIMAL);
|
||||
$subscriptionTable->addColumn('tax_perc', Types::INTEGER);
|
||||
$subscriptionTable->setPrimaryKey(['product_type', 'product_id', 'duration']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_SUBSCRIPTION_SALE)) {
|
||||
$subscriptionSaleTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SUBSCRIPTION_SALE);
|
||||
$subscriptionSaleTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$subscriptionSaleTable->addColumn('currency_id', Types::INTEGER);
|
||||
$subscriptionSaleTable->addColumn('reference', Types::STRING);
|
||||
$subscriptionSaleTable->addColumn('date', Types::DATETIME_MUTABLE);
|
||||
$subscriptionSaleTable->addColumn('user_id', Types::INTEGER);
|
||||
$subscriptionSaleTable->addColumn('product_type', Types::INTEGER);
|
||||
$subscriptionSaleTable->addColumn('product_name', Types::STRING);
|
||||
$subscriptionSaleTable->addColumn('product_id', Types::INTEGER);
|
||||
$subscriptionSaleTable->addColumn('price', Types::DECIMAL);
|
||||
$subscriptionSaleTable->addColumn('price_without_tax', Types::DECIMAL, ['notnull' => false]);
|
||||
$subscriptionSaleTable->addColumn('tax_perc', Types::INTEGER, ['notnull' => false]);
|
||||
$subscriptionSaleTable->addColumn('tax_amount', Types::DECIMAL, ['notnull' => false]);
|
||||
$subscriptionSaleTable->addColumn('status', Types::INTEGER);
|
||||
$subscriptionSaleTable->addColumn('payment_type', Types::INTEGER);
|
||||
$subscriptionSaleTable->addColumn('invoice', Types::INTEGER);
|
||||
$subscriptionSaleTable->addColumn('price_without_discount', Types::DECIMAL);
|
||||
$subscriptionSaleTable->addColumn('discount_amount', Types::DECIMAL);
|
||||
$subscriptionSaleTable->addColumn('subscription_end', Types::DATETIME_MUTABLE);
|
||||
$subscriptionSaleTable->addColumn('expired', Types::BOOLEAN);
|
||||
$subscriptionSaleTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_SUBSCRIPTION_PERIOD)) {
|
||||
$subscriptionPeriodTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SUBSCRIPTION_PERIOD);
|
||||
$subscriptionPeriodTable->addColumn(
|
||||
'duration',
|
||||
Types::INTEGER,
|
||||
['unsigned' => true]
|
||||
);
|
||||
$subscriptionPeriodTable->addColumn('name', Types::STRING);
|
||||
$subscriptionPeriodTable->setPrimaryKey(['duration']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_COUPON_SALE)) {
|
||||
$couponSaleTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_COUPON_SALE);
|
||||
$couponSaleTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$couponSaleTable->addColumn('coupon_id', Types::INTEGER);
|
||||
$couponSaleTable->addColumn('sale_id', Types::INTEGER);
|
||||
$couponSaleTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_COUPON_SERVICE_SALE)) {
|
||||
$couponSaleTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_COUPON_SERVICE_SALE);
|
||||
$couponSaleTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$couponSaleTable->addColumn('coupon_id', Types::INTEGER);
|
||||
$couponSaleTable->addColumn('service_sale_id', Types::INTEGER);
|
||||
$couponSaleTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_STRIPE)) {
|
||||
$stripeTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_STRIPE);
|
||||
$stripeTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$stripeTable->addColumn('account_id', Types::STRING);
|
||||
$stripeTable->addColumn('secret_key', Types::STRING);
|
||||
$stripeTable->addColumn('endpoint_secret', Types::STRING);
|
||||
$stripeTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_TPV_CECABANK)) {
|
||||
$tpvCecabankTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_TPV_CECABANK);
|
||||
$tpvCecabankTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$tpvCecabankTable->addColumn('crypto_key', Types::STRING);
|
||||
$tpvCecabankTable->addColumn('merchant_id', Types::STRING);
|
||||
$tpvCecabankTable->addColumn('acquirer_bin', Types::STRING);
|
||||
$tpvCecabankTable->addColumn('terminal_id', Types::STRING);
|
||||
$tpvCecabankTable->addColumn('cypher', Types::STRING);
|
||||
$tpvCecabankTable->addColumn('exponent', Types::STRING);
|
||||
$tpvCecabankTable->addColumn('supported_payment', Types::STRING);
|
||||
$tpvCecabankTable->addColumn('url', Types::STRING);
|
||||
$tpvCecabankTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
if (false === $sm->tablesExist(BuyCoursesPlugin::TABLE_COUPON_SUBSCRIPTION_SALE)) {
|
||||
$couponSubscriptionSaleTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_COUPON_SUBSCRIPTION_SALE);
|
||||
$couponSubscriptionSaleTable->addColumn(
|
||||
'id',
|
||||
Types::INTEGER,
|
||||
['autoincrement' => true, 'unsigned' => true]
|
||||
);
|
||||
$couponSubscriptionSaleTable->addColumn('coupon_id', Types::INTEGER);
|
||||
$couponSubscriptionSaleTable->addColumn('sale_id', Types::INTEGER);
|
||||
$couponSubscriptionSaleTable->setPrimaryKey(['id']);
|
||||
}
|
||||
|
||||
$queries = $pluginSchema->toSql($platform);
|
||||
|
||||
foreach ($queries as $query) {
|
||||
Database::query($query);
|
||||
}
|
||||
|
||||
// Insert data
|
||||
$paypalTable = Database::get_main_table(BuyCoursesPlugin::TABLE_PAYPAL);
|
||||
$currencyTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CURRENCY);
|
||||
$itemTable = Database::get_main_table(BuyCoursesPlugin::TABLE_ITEM);
|
||||
$saleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SALE);
|
||||
$commissionTable = Database::get_main_table(BuyCoursesPlugin::TABLE_COMMISSION);
|
||||
$extraFieldTable = Database::get_main_table(TABLE_EXTRA_FIELD);
|
||||
$culqiTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CULQI);
|
||||
$globalTable = Database::get_main_table(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG);
|
||||
$tpvRedsysTable = Database::get_main_table(BuyCoursesPlugin::TABLE_TPV_REDSYS);
|
||||
$stripeTable = Database::get_main_table(BuyCoursesPlugin::TABLE_STRIPE);
|
||||
|
||||
$paypalExtraField = Database::select(
|
||||
"*",
|
||||
$extraFieldTable,
|
||||
[
|
||||
'where' => ['variable = ?' => 'paypal'],
|
||||
],
|
||||
'first'
|
||||
);
|
||||
|
||||
if (!$paypalExtraField) {
|
||||
Database::insert(
|
||||
$extraFieldTable,
|
||||
[
|
||||
'extra_field_type' => 1,
|
||||
'field_type' => 1,
|
||||
'variable' => 'paypal',
|
||||
'display_text' => 'Paypal',
|
||||
'default_value' => '',
|
||||
'field_order' => 0,
|
||||
'visible_to_self' => 1,
|
||||
'changeable' => 1,
|
||||
'filter' => 0,
|
||||
'created_at' => api_get_utc_datetime(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Database::insert(
|
||||
$paypalTable,
|
||||
[
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'signature' => '',
|
||||
'sandbox' => true,
|
||||
]
|
||||
);
|
||||
|
||||
Database::insert(
|
||||
$tpvRedsysTable,
|
||||
[
|
||||
'url_redsys' => 'https://sis.redsys.es/sis/realizarPago',
|
||||
'url_redsys_sandbox' => 'https://sis-t.redsys.es:25443/sis/realizarPago',
|
||||
]
|
||||
);
|
||||
|
||||
Database::insert(
|
||||
$culqiTable,
|
||||
[
|
||||
'commerce_code' => '',
|
||||
'api_key' => '',
|
||||
'integration' => 1,
|
||||
]
|
||||
);
|
||||
|
||||
Database::insert(
|
||||
$globalTable,
|
||||
[
|
||||
'terms_and_conditions' => '',
|
||||
]
|
||||
);
|
||||
|
||||
Database::insert(
|
||||
$commissionTable,
|
||||
[
|
||||
'commission' => 0,
|
||||
]
|
||||
);
|
||||
|
||||
Database::insert(
|
||||
$stripeTable,
|
||||
[
|
||||
'account_id' => '',
|
||||
'secret_key' => '',
|
||||
'endpoint_secret' => '',
|
||||
]
|
||||
);
|
||||
|
||||
$currencies = [
|
||||
['AD', 'Andorra', 'EUR', 'AND'],
|
||||
['AE', 'United Arab Emirates', 'AED', 'ARE'],
|
||||
['AF', 'Afghanistan', 'AFN', 'AFG'],
|
||||
['AG', 'Antigua and Barbuda', 'XCD', 'ATG'],
|
||||
['AI', 'Anguilla', 'XCD', 'AIA'],
|
||||
['AL', 'Albania', 'ALL', 'ALB'],
|
||||
['AM', 'Armenia', 'AMD', 'ARM'],
|
||||
['AO', 'Angola', 'AOA', 'AGO'],
|
||||
['AR', 'Argentina', 'ARS', 'ARG'],
|
||||
['AS', 'American Samoa', 'USD', 'ASM'],
|
||||
['AT', 'Austria', 'EUR', 'AUT'],
|
||||
['AU', 'Australia', 'AUD', 'AUS'],
|
||||
['AW', 'Aruba', 'AWG', 'ABW'],
|
||||
['AX', 'Åland', 'EUR', 'ALA'],
|
||||
['AZ', 'Azerbaijan', 'AZN', 'AZE'],
|
||||
['BA', 'Bosnia and Herzegovina', 'BAM', 'BIH'],
|
||||
['BB', 'Barbados', 'BBD', 'BRB'],
|
||||
['BD', 'Bangladesh', 'BDT', 'BGD'],
|
||||
['BE', 'Belgium', 'EUR', 'BEL'],
|
||||
['BF', 'Burkina Faso', 'XOF', 'BFA'],
|
||||
['BG', 'Bulgaria', 'BGN', 'BGR'],
|
||||
['BH', 'Bahrain', 'BHD', 'BHR'],
|
||||
['BI', 'Burundi', 'BIF', 'BDI'],
|
||||
['BJ', 'Benin', 'XOF', 'BEN'],
|
||||
['BL', 'Saint Barthélemy', 'EUR', 'BLM'],
|
||||
['BM', 'Bermuda', 'BMD', 'BMU'],
|
||||
['BN', 'Brunei', 'BND', 'BRN'],
|
||||
['BO', 'Bolivia', 'BOB', 'BOL'],
|
||||
['BQ', 'Bonaire', 'USD', 'BES'],
|
||||
['BR', 'Brazil', 'BRL', 'BRA'],
|
||||
['BS', 'Bahamas', 'BSD', 'BHS'],
|
||||
['BT', 'Bhutan', 'BTN', 'BTN'],
|
||||
['BV', 'Bouvet Island', 'NOK', 'BVT'],
|
||||
['BW', 'Botswana', 'BWP', 'BWA'],
|
||||
['BY', 'Belarus', 'BYR', 'BLR'],
|
||||
['BZ', 'Belize', 'BZD', 'BLZ'],
|
||||
['CA', 'Canada', 'CAD', 'CAN'],
|
||||
['CC', 'Cocos [Keeling] Islands', 'AUD', 'CCK'],
|
||||
['CD', 'Congo', 'CDF', 'COD'],
|
||||
['CF', 'Central African Republic', 'XAF', 'CAF'],
|
||||
['CG', 'Republic of the Congo', 'XAF', 'COG'],
|
||||
['CH', 'Switzerland', 'CHF', 'CHE'],
|
||||
['CI', 'Ivory Coast', 'XOF', 'CIV'],
|
||||
['CK', 'Cook Islands', 'NZD', 'COK'],
|
||||
['CL', 'Chile', 'CLP', 'CHL'],
|
||||
['CM', 'Cameroon', 'XAF', 'CMR'],
|
||||
['CN', 'China', 'CNY', 'CHN'],
|
||||
['CO', 'Colombia', 'COP', 'COL'],
|
||||
['CR', 'Costa Rica', 'CRC', 'CRI'],
|
||||
['CU', 'Cuba', 'CUP', 'CUB'],
|
||||
['CV', 'Cape Verde', 'CVE', 'CPV'],
|
||||
['CW', 'Curacao', 'ANG', 'CUW'],
|
||||
['CX', 'Christmas Island', 'AUD', 'CXR'],
|
||||
['CY', 'Cyprus', 'EUR', 'CYP'],
|
||||
['CZ', 'Czechia', 'CZK', 'CZE'],
|
||||
['DE', 'Germany', 'EUR', 'DEU'],
|
||||
['DJ', 'Djibouti', 'DJF', 'DJI'],
|
||||
['DK', 'Denmark', 'DKK', 'DNK'],
|
||||
['DM', 'Dominica', 'XCD', 'DMA'],
|
||||
['DO', 'Dominican Republic', 'DOP', 'DOM'],
|
||||
['DZ', 'Algeria', 'DZD', 'DZA'],
|
||||
['EC', 'Ecuador', 'USD', 'ECU'],
|
||||
['EE', 'Estonia', 'EUR', 'EST'],
|
||||
['EG', 'Egypt', 'EGP', 'EGY'],
|
||||
['EH', 'Western Sahara', 'MAD', 'ESH'],
|
||||
['ER', 'Eritrea', 'ERN', 'ERI'],
|
||||
['ES', 'Spain', 'EUR', 'ESP'],
|
||||
['ET', 'Ethiopia', 'ETB', 'ETH'],
|
||||
['FI', 'Finland', 'EUR', 'FIN'],
|
||||
['FJ', 'Fiji', 'FJD', 'FJI'],
|
||||
['FK', 'Falkland Islands', 'FKP', 'FLK'],
|
||||
['FM', 'Micronesia', 'USD', 'FSM'],
|
||||
['FO', 'Faroe Islands', 'DKK', 'FRO'],
|
||||
['FR', 'France', 'EUR', 'FRA'],
|
||||
['GA', 'Gabon', 'XAF', 'GAB'],
|
||||
['GB', 'United Kingdom', 'GBP', 'GBR'],
|
||||
['GD', 'Grenada', 'XCD', 'GRD'],
|
||||
['GE', 'Georgia', 'GEL', 'GEO'],
|
||||
['GF', 'French Guiana', 'EUR', 'GUF'],
|
||||
['GG', 'Guernsey', 'GBP', 'GGY'],
|
||||
['GH', 'Ghana', 'GHS', 'GHA'],
|
||||
['GI', 'Gibraltar', 'GIP', 'GIB'],
|
||||
['GL', 'Greenland', 'DKK', 'GRL'],
|
||||
['GM', 'Gambia', 'GMD', 'GMB'],
|
||||
['GN', 'Guinea', 'GNF', 'GIN'],
|
||||
['GP', 'Guadeloupe', 'EUR', 'GLP'],
|
||||
['GQ', 'Equatorial Guinea', 'XAF', 'GNQ'],
|
||||
['GR', 'Greece', 'EUR', 'GRC'],
|
||||
['GS', 'South Georgia and the South Sandwich Islands', 'GBP', 'SGS'],
|
||||
['GT', 'Guatemala', 'GTQ', 'GTM'],
|
||||
['GU', 'Guam', 'USD', 'GUM'],
|
||||
['GW', 'Guinea-Bissau', 'XOF', 'GNB'],
|
||||
['GY', 'Guyana', 'GYD', 'GUY'],
|
||||
['HK', 'Hong Kong', 'HKD', 'HKG'],
|
||||
['HM', 'Heard Island and McDonald Islands', 'AUD', 'HMD'],
|
||||
['HN', 'Honduras', 'HNL', 'HND'],
|
||||
['HR', 'Croatia', 'HRK', 'HRV'],
|
||||
['HT', 'Haiti', 'HTG', 'HTI'],
|
||||
['HU', 'Hungary', 'HUF', 'HUN'],
|
||||
['ID', 'Indonesia', 'IDR', 'IDN'],
|
||||
['IE', 'Ireland', 'EUR', 'IRL'],
|
||||
['IL', 'Israel', 'ILS', 'ISR'],
|
||||
['IM', 'Isle of Man', 'GBP', 'IMN'],
|
||||
['IN', 'India', 'INR', 'IND'],
|
||||
['IO', 'British Indian Ocean Territory', 'USD', 'IOT'],
|
||||
['IQ', 'Iraq', 'IQD', 'IRQ'],
|
||||
['IR', 'Iran', 'IRR', 'IRN'],
|
||||
['IS', 'Iceland', 'ISK', 'ISL'],
|
||||
['IT', 'Italy', 'EUR', 'ITA'],
|
||||
['JE', 'Jersey', 'GBP', 'JEY'],
|
||||
['JM', 'Jamaica', 'JMD', 'JAM'],
|
||||
['JO', 'Jordan', 'JOD', 'JOR'],
|
||||
['JP', 'Japan', 'JPY', 'JPN'],
|
||||
['KE', 'Kenya', 'KES', 'KEN'],
|
||||
['KG', 'Kyrgyzstan', 'KGS', 'KGZ'],
|
||||
['KH', 'Cambodia', 'KHR', 'KHM'],
|
||||
['KI', 'Kiribati', 'AUD', 'KIR'],
|
||||
['KM', 'Comoros', 'KMF', 'COM'],
|
||||
['KN', 'Saint Kitts and Nevis', 'XCD', 'KNA'],
|
||||
['KP', 'North Korea', 'KPW', 'PRK'],
|
||||
['KR', 'South Korea', 'KRW', 'KOR'],
|
||||
['KW', 'Kuwait', 'KWD', 'KWT'],
|
||||
['KY', 'Cayman Islands', 'KYD', 'CYM'],
|
||||
['KZ', 'Kazakhstan', 'KZT', 'KAZ'],
|
||||
['LA', 'Laos', 'LAK', 'LAO'],
|
||||
['LB', 'Lebanon', 'LBP', 'LBN'],
|
||||
['LC', 'Saint Lucia', 'XCD', 'LCA'],
|
||||
['LI', 'Liechtenstein', 'CHF', 'LIE'],
|
||||
['LK', 'Sri Lanka', 'LKR', 'LKA'],
|
||||
['LR', 'Liberia', 'LRD', 'LBR'],
|
||||
['LS', 'Lesotho', 'LSL', 'LSO'],
|
||||
['LT', 'Lithuania', 'LTL', 'LTU'],
|
||||
['LU', 'Luxembourg', 'EUR', 'LUX'],
|
||||
['LV', 'Latvia', 'LVL', 'LVA'],
|
||||
['LY', 'Libya', 'LYD', 'LBY'],
|
||||
['MA', 'Morocco', 'MAD', 'MAR'],
|
||||
['MC', 'Monaco', 'EUR', 'MCO'],
|
||||
['MD', 'Moldova', 'MDL', 'MDA'],
|
||||
['ME', 'Montenegro', 'EUR', 'MNE'],
|
||||
['MF', 'Saint Martin', 'EUR', 'MAF'],
|
||||
['MG', 'Madagascar', 'MGA', 'MDG'],
|
||||
['MH', 'Marshall Islands', 'USD', 'MHL'],
|
||||
['MK', 'Macedonia', 'MKD', 'MKD'],
|
||||
['ML', 'Mali', 'XOF', 'MLI'],
|
||||
['MM', 'Myanmar [Burma]', 'MMK', 'MMR'],
|
||||
['MN', 'Mongolia', 'MNT', 'MNG'],
|
||||
['MO', 'Macao', 'MOP', 'MAC'],
|
||||
['MP', 'Northern Mariana Islands', 'USD', 'MNP'],
|
||||
['MQ', 'Martinique', 'EUR', 'MTQ'],
|
||||
['MR', 'Mauritania', 'MRO', 'MRT'],
|
||||
['MS', 'Montserrat', 'XCD', 'MSR'],
|
||||
['MT', 'Malta', 'EUR', 'MLT'],
|
||||
['MU', 'Mauritius', 'MUR', 'MUS'],
|
||||
['MV', 'Maldives', 'MVR', 'MDV'],
|
||||
['MW', 'Malawi', 'MWK', 'MWI'],
|
||||
['MX', 'Mexico', 'MXN', 'MEX'],
|
||||
['MY', 'Malaysia', 'MYR', 'MYS'],
|
||||
['MZ', 'Mozambique', 'MZN', 'MOZ'],
|
||||
['NA', 'Namibia', 'NAD', 'NAM'],
|
||||
['NC', 'New Caledonia', 'XPF', 'NCL'],
|
||||
['NE', 'Niger', 'XOF', 'NER'],
|
||||
['NF', 'Norfolk Island', 'AUD', 'NFK'],
|
||||
['NG', 'Nigeria', 'NGN', 'NGA'],
|
||||
['NI', 'Nicaragua', 'NIO', 'NIC'],
|
||||
['NL', 'Netherlands', 'EUR', 'NLD'],
|
||||
['NO', 'Norway', 'NOK', 'NOR'],
|
||||
['NP', 'Nepal', 'NPR', 'NPL'],
|
||||
['NR', 'Nauru', 'AUD', 'NRU'],
|
||||
['NU', 'Niue', 'NZD', 'NIU'],
|
||||
['NZ', 'New Zealand', 'NZD', 'NZL'],
|
||||
['OM', 'Oman', 'OMR', 'OMN'],
|
||||
['PA', 'Panama', 'PAB', 'PAN'],
|
||||
['PE', 'Peru', 'PEN', 'PER'],
|
||||
['PF', 'French Polynesia', 'XPF', 'PYF'],
|
||||
['PG', 'Papua New Guinea', 'PGK', 'PNG'],
|
||||
['PH', 'Philippines', 'PHP', 'PHL'],
|
||||
['PK', 'Pakistan', 'PKR', 'PAK'],
|
||||
['PL', 'Poland', 'PLN', 'POL'],
|
||||
['PM', 'Saint Pierre and Miquelon', 'EUR', 'SPM'],
|
||||
['PN', 'Pitcairn Islands', 'NZD', 'PCN'],
|
||||
['PR', 'Puerto Rico', 'USD', 'PRI'],
|
||||
['PS', 'Palestine', 'ILS', 'PSE'],
|
||||
['PT', 'Portugal', 'EUR', 'PRT'],
|
||||
['PW', 'Palau', 'USD', 'PLW'],
|
||||
['PY', 'Paraguay', 'PYG', 'PRY'],
|
||||
['QA', 'Qatar', 'QAR', 'QAT'],
|
||||
['RE', 'Réunion', 'EUR', 'REU'],
|
||||
['RO', 'Romania', 'RON', 'ROU'],
|
||||
['RS', 'Serbia', 'RSD', 'SRB'],
|
||||
['RU', 'Russia', 'RUB', 'RUS'],
|
||||
['RW', 'Rwanda', 'RWF', 'RWA'],
|
||||
['SA', 'Saudi Arabia', 'SAR', 'SAU'],
|
||||
['SB', 'Solomon Islands', 'SBD', 'SLB'],
|
||||
['SC', 'Seychelles', 'SCR', 'SYC'],
|
||||
['SD', 'Sudan', 'SDG', 'SDN'],
|
||||
['SE', 'Sweden', 'SEK', 'SWE'],
|
||||
['SG', 'Singapore', 'SGD', 'SGP'],
|
||||
['SH', 'Saint Helena', 'SHP', 'SHN'],
|
||||
['SI', 'Slovenia', 'EUR', 'SVN'],
|
||||
['SJ', 'Svalbard and Jan Mayen', 'NOK', 'SJM'],
|
||||
['SK', 'Slovakia', 'EUR', 'SVK'],
|
||||
['SL', 'Sierra Leone', 'SLL', 'SLE'],
|
||||
['SM', 'San Marino', 'EUR', 'SMR'],
|
||||
['SN', 'Senegal', 'XOF', 'SEN'],
|
||||
['SO', 'Somalia', 'SOS', 'SOM'],
|
||||
['SR', 'Suriname', 'SRD', 'SUR'],
|
||||
['SS', 'South Sudan', 'SSP', 'SSD'],
|
||||
['ST', 'São Tomé and Príncipe', 'STD', 'STP'],
|
||||
['SV', 'El Salvador', 'USD', 'SLV'],
|
||||
['SX', 'Sint Maarten', 'ANG', 'SXM'],
|
||||
['SY', 'Syria', 'SYP', 'SYR'],
|
||||
['SZ', 'Swaziland', 'SZL', 'SWZ'],
|
||||
['TC', 'Turks and Caicos Islands', 'USD', 'TCA'],
|
||||
['TD', 'Chad', 'XAF', 'TCD'],
|
||||
['TF', 'French Southern Territories', 'EUR', 'ATF'],
|
||||
['TG', 'Togo', 'XOF', 'TGO'],
|
||||
['TH', 'Thailand', 'THB', 'THA'],
|
||||
['TJ', 'Tajikistan', 'TJS', 'TJK'],
|
||||
['TK', 'Tokelau', 'NZD', 'TKL'],
|
||||
['TL', 'East Timor', 'USD', 'TLS'],
|
||||
['TM', 'Turkmenistan', 'TMT', 'TKM'],
|
||||
['TN', 'Tunisia', 'TND', 'TUN'],
|
||||
['TO', 'Tonga', 'TOP', 'TON'],
|
||||
['TR', 'Turkey', 'TRY', 'TUR'],
|
||||
['TT', 'Trinidad and Tobago', 'TTD', 'TTO'],
|
||||
['TV', 'Tuvalu', 'AUD', 'TUV'],
|
||||
['TW', 'Taiwan', 'TWD', 'TWN'],
|
||||
['TZ', 'Tanzania', 'TZS', 'TZA'],
|
||||
['UA', 'Ukraine', 'UAH', 'UKR'],
|
||||
['UG', 'Uganda', 'UGX', 'UGA'],
|
||||
['UM', 'U.S. Minor Outlying Islands', 'USD', 'UMI'],
|
||||
['US', 'United States', 'USD', 'USA'],
|
||||
['UY', 'Uruguay', 'UYU', 'URY'],
|
||||
['UZ', 'Uzbekistan', 'UZS', 'UZB'],
|
||||
['VA', 'Vatican City', 'EUR', 'VAT'],
|
||||
['VC', 'Saint Vincent and the Grenadines', 'XCD', 'VCT'],
|
||||
['VE', 'Venezuela', 'VEF', 'VEN'],
|
||||
['VG', 'British Virgin Islands', 'USD', 'VGB'],
|
||||
['VI', 'U.S. Virgin Islands', 'USD', 'VIR'],
|
||||
['VN', 'Vietnam', 'VND', 'VNM'],
|
||||
['VU', 'Vanuatu', 'VUV', 'VUT'],
|
||||
['WF', 'Wallis and Futuna', 'XPF', 'WLF'],
|
||||
['WS', 'Samoa', 'WST', 'WSM'],
|
||||
['XK', 'Kosovo', 'EUR', 'XKX'],
|
||||
['YE', 'Yemen', 'YER', 'YEM'],
|
||||
['YT', 'Mayotte', 'EUR', 'MYT'],
|
||||
['ZA', 'South Africa', 'ZAR', 'ZAF'],
|
||||
['ZM', 'Zambia', 'ZMK', 'ZMB'],
|
||||
['ZW', 'Zimbabwe', 'ZWL', 'ZWE'],
|
||||
];
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$value = Database::select(
|
||||
"*",
|
||||
$currencyTable,
|
||||
[
|
||||
'where' => ['country_code = ?' => $currency[0]],
|
||||
],
|
||||
'first'
|
||||
);
|
||||
|
||||
if (!empty($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Database::insert(
|
||||
$currencyTable,
|
||||
[
|
||||
'country_code' => $currency[0],
|
||||
'country_name' => $currency[1],
|
||||
'iso_code' => $currency[2],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$fieldlabel = 'buycourses_company';
|
||||
$fieldtype = '1';
|
||||
$fieldtitle = BuyCoursesPlugin::get_lang('Company');
|
||||
$fielddefault = '';
|
||||
$field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
|
||||
|
||||
$fieldlabel = 'buycourses_vat';
|
||||
$fieldtype = '1';
|
||||
$fieldtitle = BuyCoursesPlugin::get_lang('VAT');
|
||||
$fielddefault = '';
|
||||
$field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
|
||||
|
||||
$fieldlabel = 'buycourses_address';
|
||||
$fieldtype = '1';
|
||||
$fieldtitle = BuyCoursesPlugin::get_lang('Address');
|
||||
$fielddefault = '';
|
||||
$field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
|
||||
7
plugin/buycourses/index.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* Show form.
|
||||
*/
|
||||
require_once 'config.php';
|
||||
require_once 'src/index.buycourses.php';
|
||||
16
plugin/buycourses/install.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* This script is included by main/admin/settings.lib.php and generally
|
||||
* includes things to execute in the main database (settings_current table).
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
/**
|
||||
* Initialization.
|
||||
*/
|
||||
require_once __DIR__.'/config.php';
|
||||
if (!api_is_platform_admin()) {
|
||||
exit('You must have admin permissions to install plugins');
|
||||
}
|
||||
BuyCoursesPlugin::create()->install();
|
||||
99
plugin/buycourses/lang/brazilian.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
$strings['plugin_title'] = "Vender cursos";
|
||||
$strings['plugin_comment'] = "Venda cursos diretamente através de seu portal Chamilo, usando uma conta do PayPal para receber fundos Nem a associação Chamilo nem os desenvolvedores envolvidos poderia ser considerado responsável de qualquer problema que você pode sofrer de usar este plugin..";
|
||||
$strings['show_main_menu_tab'] = "Mostrar guia no menu principal";
|
||||
$strings['show_main_menu_tab_help'] = "No caso de não querer mostrar a guia, você pode criar esse link em sua página Chamilo: %s";
|
||||
$strings['include_sessions'] = "Incluir sessões";
|
||||
$strings['paypal_enable'] = "Ativar PayPal";
|
||||
$strings['transfer_enable'] = "Permitir transferência bancária";
|
||||
$strings['unregistered_users_enable'] = "Permitir que usuários anônimos";
|
||||
$strings['Free'] = "GRÁTIS";
|
||||
$strings['banktransfer'] = "Transferência Bancária";
|
||||
$strings['SaleStatusPending'] = "Venda pendente";
|
||||
$strings['SaleStatusCanceled'] = "Venda cancelada";
|
||||
$strings['SaleStatusCompleted'] = "Venda concluída";
|
||||
$strings['CourseListOnSale'] = "Lista de cursos à venda";
|
||||
$strings['AvailableCourses'] = "Campos disponíveis";
|
||||
$strings['Price'] = "Preço";
|
||||
$strings['SearchFilter'] = "Filtrar Pesquisa";
|
||||
$strings['MinimumPrice'] = "Preço mínimo";
|
||||
$strings['MaximumPrice'] = "Preço máximo";
|
||||
$strings['AvailableCoursesConfiguration'] = "Configuração cursos disponíveis";
|
||||
$strings['PaymentsConfiguration'] = "Configurar pagamentos";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheCourse'] = "Você está registrado no curso.";
|
||||
$strings['SeeDescription'] = "Descriçao";
|
||||
$strings['Buy'] = "Comprar";
|
||||
$strings['WaitingToReceiveThePayment'] = "Atualmente pendente de pagamento";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheSession'] = "Você já está registrado na sessão";
|
||||
$strings['ItemNotSaved'] = "Item não salvo";
|
||||
$strings['TitlePlugin'] = "Tudo o que você precisa para ensinar e vender cursos on-line";
|
||||
$strings['PluginPresentation'] = "O BuyCourses Plugin dá-lhe os meios para vender seus cursos ou sessões e ensinar on-line, através de apenas alguns passos e configurações simples. O que você está esperando para começar a vender cursos através Chamilo LMS?";
|
||||
$strings['Instructions'] = "Instruções";
|
||||
$strings['InstructionsStepOne'] = "Criar um curso ou sessão na plataforma.";
|
||||
$strings['InstructionsStepTwo'] = "Em - <strong>configurar pagamento</strong> - Defina a moeda com a qual você gostaria de vender seus cursos ou sessões";
|
||||
$strings['InstructionsStepThree'] = "Para configurar cursos para vender. Vá em: <strong> configurar cursos e preços.</strong>";
|
||||
$strings['BuyCourses'] = "Comprar cursos";
|
||||
$strings['ConfigurationOfCoursesAndPrices'] = "Configurar cursos e preços ";
|
||||
$strings['SalesReport'] = "Relatório de vendas";
|
||||
$strings['UserInformation'] = "Detalhes do comprador";
|
||||
$strings['PaymentMethods'] = "Métodos de pagamento";
|
||||
$strings['ConfirmOrder'] = "Confirmar pedido";
|
||||
$strings['PurchaseData'] = "Dados de Compra";
|
||||
$strings['bc_subject'] = "Confirmação de ordem do curso";
|
||||
$strings['PurchaseStatusX'] = "Estado de compra: %s";
|
||||
$strings['PendingReasonByTransfer'] = "<b> Pendente </b> Aguardando confirmação da transferência.";
|
||||
$strings['CancelOrder'] = "Anular ordem";
|
||||
$strings['BankAccountInformation'] = "Detalhes da conta bancária";
|
||||
$strings['BankAccount'] = "Contas bancárias";
|
||||
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Uma vez confirmada, você receberá um e-mail com os dados bancários e uma referência de ordem.";
|
||||
$strings['SubscriptionToCourseXSuccessful'] = "Sua inscrição para <a href=\"%s\"><strong>\"%s\"</strong></a> foi concluída com sucesso.";
|
||||
$strings['OrderCanceled'] = "Ordem cancelada";
|
||||
$strings['OrderStatus'] = "Status do pedido";
|
||||
$strings['SearchByStatus'] = "Pesquisar por estado";
|
||||
$strings['OrderReference'] = "Código de encomenda";
|
||||
$strings['OrderDate'] = "Data do pedido";
|
||||
$strings['ProductType'] = "Tipo de produto";
|
||||
$strings['SubscribeUser'] = "Inscrever utilizador";
|
||||
$strings['DeleteOrder'] = "Excluir a ordem";
|
||||
$strings['ErrorContactPlatformAdmin'] = "Por favor entre em contato com o administrador da plataforma de erro desconhecido..";
|
||||
$strings['PendingReasonByAddress'] = ". <b> Pendente </b> Você não digitou um endereço de entrega confirmado.";
|
||||
$strings['PendingReasonByAuthorization'] = "<b> Pendentes </b> fundos Nós ainda não capturados..";
|
||||
$strings['PendingReasonByEcheck'] = "<b> Pendente </b> O pagamento foi feito por um eCheck que ainda não foi eliminada.";
|
||||
$strings['PendingReasonByIntl'] = "<b> Pendente </b> Nós não temos um mecanismo de retirada de fundos..";
|
||||
$strings['PendingReasonByMulticurrency'] = "<b> Pendente </b> Nós não equilibrar na moeda enviado.";
|
||||
$strings['PendingReasonByOrder'] = "<b> Pendente </b> Ordem feita Nós ainda não capturado fundos...";
|
||||
$strings['PendingReasonByPaymentReview'] = "<b> Pendente </b> O pagamento está sendo revisto pelo PayPal para o risco.";
|
||||
$strings['PendingReasonByRegulatoryReview'] = "<b> Pendente </b> O pagamento está sendo revisado para conformidade com regulamentações governamentais..";
|
||||
$strings['PendingReasonByUnilateral'] = "<b> Pendente </b> O e-mail ainda não está registrado o confirmou..";
|
||||
$strings['PendingReasonByUpgrade'] = "<b> Pendente </b> O pagamento foi feito por cartão de crédito..";
|
||||
$strings['PendingReasonByVerify'] = "<b> Pendente </b> Desculpe Nós ainda não são verificados no PayPal...";
|
||||
$strings['PendingReasonByOther'] = "<b> Pendente </b> Por favor, entre em contato com o administrador da plataforma..";
|
||||
$strings['PayPalPaymentOKPleaseConfirm'] = "PayPal relata a transação está pronto para ser executado. Para confirmar que você está OK para prosseguir, clique no botão de confirmação abaixo. Uma vez clicado, você será registrado para o curso e os fundos serão transferido da sua conta PayPal para a nossa loja. Você sempre pode acessar seus cursos através da aba 'Meus cursos' Obrigado por seu costume.!";
|
||||
$strings['Sandbox'] = "Ambiente de teste";
|
||||
$strings['PayPalConfig'] = "Configuração PayPal:";
|
||||
$strings['TransfersConfig'] = "Configurar transferências bancárias:";
|
||||
$strings['PluginInstruction'] = "Você pode ativar ou desativar a opção de pagar via PayPal ou transferência bancária na seção de configuração do plugin.";
|
||||
$strings['ClickHere'] = "<i> Clique aqui </i> para obter mais detalhes";
|
||||
$strings['CurrencyType'] = "Tipo de moeda";
|
||||
$strings['InfoCurrency'] = "Define a moeda para o pagamento de seus cursos.";
|
||||
$strings['ApiUsername'] = "Nome de usuário API";
|
||||
$strings['ApiPassword'] = "Senha API";
|
||||
$strings['ApiSignature'] = "Assinatura API";
|
||||
$strings['InfoApiCredentials'] = "Para gerar as suas credenciais de API para integrar Chamilo com a sua conta PayPal, você deve seguir os seguintes passos";
|
||||
$strings['InfoApiStepOne'] = "Vá para a sua conta do PayPal, <strong> Resumo </strong>, então <front> preferências do vendedor </front> na <front> Ferramentas de Vendas </front> menu (se o fizer não ter este item de menu, você pode precisar de obter a autorização para vender o material através do PayPal em primeiro lugar).";
|
||||
$strings['InfoApiStepTwo'] = "No parágrafo <strong> Acesso API </strong>, clique em <strong> Atualizar </strong>";
|
||||
$strings['InfoApiStepThree'] = "Na opção 2 (credenciais de solicitação de API para criar o seu próprio nome de usuário e senha API), clique no botão <strong> Exibir API Assinatura link </strong>, e copiar as credenciais apresentadas à direita no formulário do plugin BuyCourses.";
|
||||
$strings['ErrorOccurred'] = "<strong> Ocorreu um erro </strong> Código: %s. Mensagem: %s. Por favor, entre em contato com o Admin da plataforma.";
|
||||
$strings['VisibleInCatalog'] = "Visível no catálogo";
|
||||
$strings['Beneficiaries'] = "Beneficiários";
|
||||
$strings['AvailableCourse'] = "Campo disponível";
|
||||
$strings['ShowOnCourseCatalog'] = "Mostrar no catálogo de cursos";
|
||||
$strings['ByStatus'] = "Por estado";
|
||||
$strings['ByUser'] = "Por usuário";
|
||||
$strings['ByEmail'] = "Por email";
|
||||
$strings['PaymentMethod'] = "Método de pagamento";
|
||||
$strings['SWIFT'] = "Código SWIFT";
|
||||
$strings['SWIFT_help'] = "Formato padrão de Códigos de Identificação Bancária (BIC) e serve como um identificador exclusivo de um banco ou instituição financeira";
|
||||
$strings['ExportReport'] = "Exportar Relatório de Vendas";
|
||||
$strings['OrderTime'] = "Hora do pedido";
|
||||
$strings['SelectDateRange'] = "Selecione uma data de início e uma data de término para o relatório";
|
||||
135
plugin/buycourses/lang/dutch.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
$strings['plugin_title'] = "Sell courses";
|
||||
$strings['plugin_comment'] = "Sell courses directly through your Chamilo portal, using a PayPal account to receive funds. Neither the Chamilo association nor the developers involved could be considered responsible of any issue you might suffer using this plugin.";
|
||||
$strings['show_main_menu_tab'] = "Show tab in hoofdmenu";
|
||||
$strings['show_main_menu_tab_help'] = "In case of not wanting to show the tab, you can create this link in your Chamilo homepage : %s";
|
||||
$strings['public_main_menu_tab'] = "Show tab in main menu aan anonyme gebruikers";
|
||||
$strings['include_sessions'] = "Inclusief sessies";
|
||||
$strings['paypal_enable'] = "Instellen van PayPal";
|
||||
$strings['commissions_enable'] = "Instellen van Opdrachten";
|
||||
$strings['transfer_enable'] = "Instellen van bankoverschrijving";
|
||||
$strings['unregistered_users_enable'] = "Sta anonieme gebruikers toe";
|
||||
$strings['Free'] = "FREE";
|
||||
$strings['PaypalPayoutCommissions'] = "Paypal Uitbetaal Opdrachten";
|
||||
$strings['MyPayouts'] = "Mijn Betalingsoverzicht";
|
||||
$strings['Commission'] = "Commissie";
|
||||
$strings['Commissions'] = "Commissies";
|
||||
$strings['SetCommissions'] = "Set commissies";
|
||||
$strings['CommissionsConfig'] = "Configureren Commissies";
|
||||
$strings['PayoutReport'] = "Uitbetalingen rapport";
|
||||
$strings['Stats'] = "Statistieken";
|
||||
$strings['InfoCommissions'] = "Vul hier de omzet commissie als een percentage(% ) , de organisatie die het platform controleert. Deze percentage wordt in mindering gebracht op de door docenten ontvangen bedrag voor elke cursus of sessie dat verkocht is.";
|
||||
$strings['NeedToSelectPaymentType'] = "Hier u betalings type selecteren";
|
||||
$strings['IndividualPayout'] = "Individuele uitbetalingen";
|
||||
$strings['CancelPayout'] = "Annuleer Uitbetalingen";
|
||||
$strings['ContinuePayout'] = "Continue Uitbetalingen";
|
||||
$strings['ProceedPayout'] = "Ga verder met de betaling";
|
||||
$strings['TheActualPlatformCommissionIsX'] = "De huidige platform commissie <b> %s </b>. Deze percentage zal invermindering gebracht worden van de totale prijs van het product. Het verschil in het bedrag zal aan de volgende commissies toegepast worden.";
|
||||
$strings['CoursesInSessionsDoesntDisplayHere'] = "De cursussen die binnen een training zitten worden niet weergegeven in de lijst van de cursussen als afzonderlijke producten.";
|
||||
$strings['WantToSellCourses'] = "Wilt u leren en wat geld verdienen met uw eigen cursussen? Deze lijst kan worden gevuld met de verkoop van uw cursussen via dit platform. Neem contact op met ons.";
|
||||
$strings['SelectOptionToProceed'] = "Selecteer de optie om verder te gaan";
|
||||
$strings['VerifyTotalAmountToProceedPayout'] = "Controleer het totale bedrag voor over te gaan tot de betaling van commissies. Dit bedrag heeft geen extra kosten voor PayPal rekening houder. De cursussen verkopen die niet meetellen met een Paypal-account voor de begunstigden niet in aanmerking genomen.";
|
||||
$strings['TotalAcounts'] = "Totaal van de rekeningen:";
|
||||
$strings['TotalPayout'] = "Totaal te betalen:";
|
||||
$strings['PayoutDate'] = "Betaaldatum:";
|
||||
$strings['CautionThisProcessCantBeCanceled'] = "<b>Let op</b>:Dit proces kan een paar minuten duren en kan niet worden geannuleerd.";
|
||||
$strings['ProcessingPayoutsDontCloseThisWindow'] = "<b>Verder gaan met betalingen. Dit venster niet sluiten totdat dit proces is afgerond.</b>";
|
||||
$strings['PayoutSuccess'] = "Betalingen met succes verwerkt";
|
||||
$strings['Buyer'] = "Koper";
|
||||
$strings['BankTransfer'] = "Bankoverschrijving";
|
||||
$strings['SaleInfo'] = "Verkoop Informatie";
|
||||
$strings['SaleStatusPending'] = "Verkoop in behandeling";
|
||||
$strings['SaleStatusCanceled'] = "Verkoop geannuleerd";
|
||||
$strings['SaleStatusCompleted'] = "verkoop afgerond";
|
||||
$strings['PayoutStatusPending'] = "Betaling in behandeling";
|
||||
$strings['PayoutStatusCanceled'] = "Betaling geannuleerd";
|
||||
$strings['PayoutStatusCompleted'] = "Betaling afgerond";
|
||||
$strings['PayoutsTotalPending'] = "Onafgehandelde betalingen:";
|
||||
$strings['PayoutsTotalCanceled'] = "Geannuleerde betalingen:";
|
||||
$strings['PayoutsTotalCompleted'] = "Afgeronde betalingen:";
|
||||
$strings['TotalAmount'] = "Totaalbedrag:";
|
||||
$strings['CourseListOnSale'] = "Lijst van cursussen in verkoop";
|
||||
$strings['AvailableCourses'] = "Beschikbare Cursussen";
|
||||
$strings['Price'] = "Prijs";
|
||||
$strings['SearchFilter'] = "Zoekmachine";
|
||||
$strings['MinimumPrice'] = "Minimuum prijs";
|
||||
$strings['MaximumPrice'] = "Maximuumm prijs";
|
||||
$strings['AvailableCoursesConfiguration'] = "Beschikbare cursussen overzicht";
|
||||
$strings['PaymentsConfiguration'] = "Betalingsoverzicht";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheCourse'] = "Je bent geregistreerd voor de cursus.";
|
||||
$strings['SeeDescription'] = "Omschrijving";
|
||||
$strings['Buy'] = "Koop / inschrijven";
|
||||
$strings['WaitingToReceiveThePayment'] = "In afwachting van uw betaling";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheSession'] = "Je bent geregistreerd voor de sessie";
|
||||
$strings['ItemNotSaved'] = "Item niet opgeslagen";
|
||||
$strings['TitlePlugin'] = "Alles wat je nodig hebt om online cursussen te onderwijzen en te verkopen";
|
||||
$strings['PluginPresentation'] = "The BuyCourses Plugin gives you the means to sell your courses or sessions and teach online, through only a few simple steps and settings. What are you waiting for? Start selling courses through Chamilo LMS!";
|
||||
$strings['Instructions'] = "Instructies";
|
||||
$strings['InstructionsStepOne'] = "Maak een cursus of een sessie op het platform.";
|
||||
$strings['InstructionsStepTwo'] = "In de <strong> betaling </strong>, stelt de valuta waarmee u wilt uw cursussen of sessies te verkopen.";
|
||||
$strings['InstructionsStepThree'] = "Overzicht van cursussen om te verkopen in de <strong> Cursussen en prijzen </strong> Instellingen.";
|
||||
$strings['BuyCourses'] = "Cursussen Kopen";
|
||||
$strings['ConfigurationOfCoursesAndPrices'] = "Cursussen en Prijzen overzicht";
|
||||
$strings['SalesReport'] = "Verkoopcijfers";
|
||||
$strings['UserInformation'] = "Gegevens van de koper";
|
||||
$strings['PaymentMethods'] = "Betaal methodes";
|
||||
$strings['ConfirmOrder'] = "Bevestig bestelling";
|
||||
$strings['PurchaseData'] = "Aankoopgegevens";
|
||||
$strings['bc_subject'] = "Bevestiging cursus order";
|
||||
$strings['PurchaseStatusX'] = "Aankoop status: %s";
|
||||
$strings['PendingReasonByTransfer'] = "<b> In afwachting </b>. In afwachting van de overdracht bevestiging";
|
||||
$strings['CancelOrder'] = "Annuleer order";
|
||||
$strings['BankAccountInformation'] = "Bankgegevens";
|
||||
$strings['BankAccount'] = "Bankrekening";
|
||||
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Eenmaal bevestigd, ontvangt u een e-mail met de bankgegevens en een orderreferentie.";
|
||||
$strings['SubscriptionToCourseXSuccessful'] = "Uw aankoop op <a href=\"%s\"><strong>\"%s\"</strong></a> werd met succes afgerond.";
|
||||
$strings['OrderCanceled'] = "Order geannuleerd";
|
||||
$strings['OrderStatus'] = "Bestelstatus";
|
||||
$strings['PayoutStatus'] = "Betalingsstatus";
|
||||
$strings['SearchByStatus'] = "Zoeken op status";
|
||||
$strings['OrderReference'] = "Bestelreferentie";
|
||||
$strings['OrderDate'] = "Besteldatum";
|
||||
$strings['OrderPrice'] = "Bestel prijs";
|
||||
$strings['ProductType'] = "Artikel type";
|
||||
$strings['SubscribeUser'] = "Onderteken gebruiker";
|
||||
$strings['DeleteOrder'] = "Verwijder bestelling";
|
||||
$strings['ErrorContactPlatformAdmin'] = "Onbekende fout. Neem contact op met het platform administrator.";
|
||||
$strings['PendingReasonByAddress'] = "<b>in afwachting</b>. Je hebt een bevestigde verzendadres niet in te voeren.";
|
||||
$strings['PendingReasonByAuthorization'] = "<b>in afwachting</b>. We hebben nog geen betalingen.";
|
||||
$strings['PendingReasonByEcheck'] = "<b>in afwachting</b>. De betaling is verricht door een eCheck die nog niet is vrijgemaakt";
|
||||
$strings['PendingReasonByIntl'] = "<b>in afwachting</b>.We hebben geen terugtrekking mechanisme voor betalingen.";
|
||||
$strings['PendingReasonByMulticurrency'] = "<b>in afwachting</b>. We hebben niet in evenwicht te brengen in de valuta verzonden.";
|
||||
$strings['PendingReasonByOrder'] = "<b>in afwachting</b>. Bestelling. We hebben nog geen betalingen.";
|
||||
$strings['PendingReasonByPaymentReview'] = "<b>in afwachting</b>. De betaling wordt beoordeeld door PayPal voor risico.";
|
||||
$strings['PendingReasonByRegulatoryReview'] = "<b>in afwachting</b>. De betaling wordt beoordeeld voor de naleving van regelgeving van de overheid.";
|
||||
$strings['PendingReasonByUnilateral'] = "<b>in afwachting</b>. Het e-mailadres is nog niet geregistreerd of bevestigd.";
|
||||
$strings['PendingReasonByUpgrade'] = "<b>in afwachting</b>. De betaling werd gedaan via credit card.";
|
||||
$strings['PendingReasonByVerify'] = "<b>in afwachting</b>. Sorry. We zijn nog niet in Paypal geverifieerd.";
|
||||
$strings['PendingReasonByOther'] = "<b>in afwachting</b>. Neem contact op met het platform admin.";
|
||||
$strings['PayPalPaymentOKPleaseConfirm'] = "PayPal rapporteert de transactie nu worden gestart. Om te erkennen dat u op OK om verder te gaan, klikt u op de knop bevestiging hieronder. Eenmaal geklikt, wordt u ingeschreven voor de cursus en het geld zal naar onze winkel worden overgedragen van uw PayPal-rekening. U kunt altijd toegang tot uw cursussen via het tabblad 'Mijn cursussen'. Dank u voor uw aankoop";
|
||||
$strings['Sandbox'] = "Test omgeving";
|
||||
$strings['PayPalAccount'] = "Paypal rekening";
|
||||
$strings['NoPayPalAccountDetected'] = "Geen Paypal account gedetecteerd";
|
||||
$strings['PayPalConfig'] = "PayPal bevestiging:";
|
||||
$strings['TransfersConfig'] = "Bank overschrijving bevestiging:";
|
||||
$strings['PluginInstruction'] = "U kunt de optie in- of uitschakelen om te betalen via PayPal of overschrijving instellen in de configuratie sectie van de plugin.";
|
||||
$strings['ClickHere'] = "<i>Click here</i> voor meer details";
|
||||
$strings['CurrencyType'] = "Valuta type";
|
||||
$strings['InfoCurrency'] = "Stel in de valuta voor de betaling van uw cursussen.";
|
||||
$strings['ApiUsername'] = "API Gebruikersnaam";
|
||||
$strings['ApiPassword'] = "API Paswoord";
|
||||
$strings['ApiSignature'] = "API Handtekening";
|
||||
$strings['InfoApiCredentials'] = "To generate your API credentials to integrate Chamilo with your PayPal account, you must follow the following steps";
|
||||
$strings['InfoApiStepOne'] = "Ga naar je PayPal-account, <strong> Overzicht </strong> en <front> verkoper voorkeuren </front> in het <front> Verkoop Tools </front> menu (als je niet dit menu-item hebt, om spullen te verkopen moet u eerst via PayPal om de toestemming te krijgen ).";
|
||||
$strings['InfoApiStepTwo'] = "In paragraaf <strong> API-toegang </strong>, klikt u op <strong> Bijwerken </strong>";
|
||||
$strings['InfoApiStepThree'] = "In optie 2 (API Request referenties aan uw eigen API gebruikersnaam en wachtwoord), klikt u op de <strong> Bekijk API Handtekening </strong>, en kopieer de getoonde rechtsaf de Cursusshop plugin vorm referenties";
|
||||
$strings['ErrorOccurred'] = "<strong> Er is een fout opgetreden </strong>. Code:% s. Bericht:% s. Neem contact op met naar platform admin";
|
||||
$strings['VisibleInCatalog'] = "Zichtbaar in catalogus";
|
||||
$strings['Beneficiaries'] = "begunstigden";
|
||||
$strings['AvailableCourse'] = "beschikbare cursus";
|
||||
$strings['ShowOnCourseCatalog'] = "Toon op de cursusoverzicht";
|
||||
$strings['ByStatus'] = "Door de status";
|
||||
$strings['ByUser'] = "Door de gebruiker";
|
||||
$strings['PaymentMethod'] = "Betaal methodes";
|
||||
$strings['SWIFT'] = "SWIFT code";
|
||||
$strings['SWIFT_help'] = "Standaardformaat van Bank Identifier Codes (BIC) en dient als een unieke identificatiecode voor een bank of financiële instelling";
|
||||
321
plugin/buycourses/lang/english.php
Normal file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
$strings['plugin_title'] = "Sell courses";
|
||||
$strings['plugin_comment'] = "Sell courses directly through your Chamilo portal, using a PayPal account to receive funds. Neither the Chamilo association nor the developers involved could be considered responsible of any issue you might suffer using this plugin.";
|
||||
$strings['show_main_menu_tab'] = "Show tab in main menu";
|
||||
$strings['show_main_menu_tab_help'] = "In case of not wanting to show the tab, you can create this link in your Chamilo homepage : %s";
|
||||
$strings['public_main_menu_tab'] = "Show tab in main menu to anonymous users too";
|
||||
$strings['include_sessions'] = "Include sessions";
|
||||
$strings['paypal_enable'] = "Enable PayPal";
|
||||
$strings['commissions_enable'] = "Enable Commissions";
|
||||
$strings['transfer_enable'] = "Enable bank transfer";
|
||||
$strings['unregistered_users_enable'] = "Allow anonymous users";
|
||||
$strings['invoicing_enable'] = "Enable Invoicing";
|
||||
$strings['tax_enable'] = "Enable Taxation";
|
||||
$strings['Free'] = "FREE";
|
||||
$strings['PaypalPayoutCommissions'] = "Paypal Payout Commissions";
|
||||
$strings['MyPayouts'] = "My payments";
|
||||
$strings['Commission'] = "Commission";
|
||||
$strings['Commissions'] = "Commissions";
|
||||
$strings['SetCommissions'] = "Set commissions";
|
||||
$strings['CommissionsConfig'] = "Configure Commissions";
|
||||
$strings['PayoutReport'] = "Payouts report";
|
||||
$strings['Stats'] = "Statistics";
|
||||
$strings['InfoCommissions'] = "Enter here the sales commission as a percentage (% ) , the organization that controls the platform. This percentage is deducted from the amount received by teachers for each course or Session sold on the platform.";
|
||||
$strings['NeedToSelectPaymentType'] = "Need to select payment type";
|
||||
$strings['IndividualPayout'] = "Individual payout";
|
||||
$strings['CancelPayout'] = "Cancel payout";
|
||||
$strings['ContinuePayout'] = "Continue Payout";
|
||||
$strings['ProceedPayout'] = "Proceed with payment";
|
||||
$strings['TheActualPlatformCommissionIsX'] = "The current platform commission is <b> %s </b>. This percentage will be discounted from the total product price. The difference will be the amount to apply the following commissions.";
|
||||
$strings['CoursesInSessionsDoesntDisplayHere'] = "The courses which are inside a training session don't appear in the list of courses to configure as individual products.";
|
||||
$strings['WantToSellCourses'] = "Do you want to teach and earn some money with your own courses? This list could be filled with your earnings selling courses through this platform. Get in touch with us.";
|
||||
$strings['SelectOptionToProceed'] = "Select option to proceed";
|
||||
$strings['VerifyTotalAmountToProceedPayout'] = "Please check the total amount to proceed with the payment of commissions. This amount doesn't take extra costs for PayPal into account. The courses sales that do not count with a Paypal account for the beneficiaries will not be considered.";
|
||||
$strings['TotalAcounts'] = "Total of accounts:";
|
||||
$strings['TotalPayout'] = "Total to be paid:";
|
||||
$strings['PayoutDate'] = "Payment date:";
|
||||
$strings['CautionThisProcessCantBeCanceled'] = "<b>Caution</b>: this process can take a few minutes and cannot be cancelled.";
|
||||
$strings['ProcessingPayoutsDontCloseThisWindow'] = "<b>Proceeding with payments. Don't close this window until this process is finalized.</b>";
|
||||
$strings['PayoutSuccess'] = "Payments processed successfully";
|
||||
$strings['Buyer'] = "Buyer";
|
||||
$strings['BankTransfer'] = "Bank transfer";
|
||||
$strings['SaleInfo'] = "Sale information";
|
||||
$strings['SaleStatusPending'] = "Sale pending";
|
||||
$strings['SaleStatusCanceled'] = "Sale canceled";
|
||||
$strings['SaleStatusCompleted'] = "Sale completed";
|
||||
$strings['PayoutStatusPending'] = "Payment pending";
|
||||
$strings['PayoutStatusCanceled'] = "Payment cancelled";
|
||||
$strings['PayoutStatusCompleted'] = "Payment completed";
|
||||
$strings['PayoutsTotalPending'] = "Pending payments:";
|
||||
$strings['PayoutsTotalCanceled'] = "Cancelled payments:";
|
||||
$strings['PayoutsTotalCompleted'] = "Completed payments:";
|
||||
$strings['Total'] = "Total";
|
||||
$strings['TotalAmount'] = "Total amount:";
|
||||
$strings['CourseListOnSale'] = "List of courses on sale";
|
||||
$strings['AvailableCourses'] = "Available Courses";
|
||||
$strings['Price'] = "Price";
|
||||
$strings['SearchFilter'] = "Search filter";
|
||||
$strings['MinimumPrice'] = "Minimum price";
|
||||
$strings['MaximumPrice'] = "Maximum price";
|
||||
$strings['AvailableCoursesConfiguration'] = "Available courses configuration";
|
||||
$strings['PaymentsConfiguration'] = "Payments configuration";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheCourse'] = "You are already registered in the course.";
|
||||
$strings['SeeDescription'] = "Description";
|
||||
$strings['Buy'] = "Buy";
|
||||
$strings['WaitingToReceiveThePayment'] = "Currently pending payment";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheSession'] = "You are already registered in the session";
|
||||
$strings['ItemNotSaved'] = "Item not saved";
|
||||
$strings['TitlePlugin'] = "Everything you need to teach and sell courses online";
|
||||
$strings['PluginPresentation'] = "The BuyCourses Plugin gives you the means to sell your courses or sessions and teach online, through only a few simple steps and settings. What are you waiting for? Start selling courses through Chamilo LMS!";
|
||||
$strings['Instructions'] = "Instructions";
|
||||
$strings['InstructionsStepOne'] = "Create a course or session on the platform.";
|
||||
$strings['InstructionsStepTwo'] = "In the <strong>payment settings</strong>, set the currency with which you would like to sell your courses or sessions.";
|
||||
$strings['InstructionsStepThree'] = "Configure courses to sell in the <strong>Courses and prices</strong > settings.";
|
||||
$strings['BuyCourses'] = "Buy courses";
|
||||
$strings['ConfigurationOfCoursesAndPrices'] = "Courses and prices configuration";
|
||||
$strings['SalesReport'] = "Sales report";
|
||||
$strings['UserInformation'] = "Buyer's details";
|
||||
$strings['PaymentMethods'] = "Payment methods";
|
||||
$strings['ConfirmOrder'] = "Confirm order";
|
||||
$strings['PurchaseData'] = "Purchase data";
|
||||
$strings['bc_subject'] = "Confirmation of course order";
|
||||
$strings['PurchaseStatusX'] = "Purchase status: %s";
|
||||
$strings['PendingReasonByTransfer'] = "<b>Pending</b>. Awaiting for transfer confirmation";
|
||||
$strings['CancelOrder'] = "Cancel order";
|
||||
$strings['BankAccountInformation'] = "Bank account details";
|
||||
$strings['BankAccount'] = "Bank account";
|
||||
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Once confirmed, you will receive an e-mail with the bank details and an order reference.";
|
||||
$strings['SubscriptionToCourseXSuccessful'] = "Completed process. Your subscription to <a href=\"%s\"><strong>\"%s\"</strong></a> was completed successfully.";
|
||||
$strings['OrderCanceled'] = "Order canceled";
|
||||
$strings['OrderStatus'] = "Order status";
|
||||
$strings['PayoutStatus'] = "Payment status";
|
||||
$strings['SearchByStatus'] = "Search by status";
|
||||
$strings['OrderReference'] = "Order reference";
|
||||
$strings['OrderDate'] = "Order date";
|
||||
$strings['OrderPrice'] = "Order price";
|
||||
$strings['ProductType'] = "Product type";
|
||||
$strings['SubscribeUser'] = "Subscribe user";
|
||||
$strings['DeleteOrder'] = "Delete order";
|
||||
$strings['ErrorContactPlatformAdmin'] = "Unknown error. Please contact the platform administrator.";
|
||||
$strings['PendingReasonByAddress'] = "<b>Pending</b>. You did not enter a confirmed shipping address.";
|
||||
$strings['PendingReasonByAuthorization'] = "<b>Pending</b>. We have not yet captured funds.";
|
||||
$strings['PendingReasonByEcheck'] = "<b>Pending</b>. The payment was made by an eCheck that has not yet cleared";
|
||||
$strings['PendingReasonByIntl'] = "<b>Pending</b>. We have no a withdrawal mechanism for funds.";
|
||||
$strings['PendingReasonByMulticurrency'] = "<b>Pending</b>. We have not balance in the currency sent.";
|
||||
$strings['PendingReasonByOrder'] = "<b>Pending</b>. Order made. We have not yet captured funds.";
|
||||
$strings['PendingReasonByPaymentReview'] = "<b>Pending</b>. The payment is being reviewed by PayPal for risk.";
|
||||
$strings['PendingReasonByRegulatoryReview'] = "<b>Pending</b>. The payment is being reviewed for compliance with government regulations.";
|
||||
$strings['PendingReasonByUnilateral'] = "<b>Pending</b>. The email address is not yet registered o confirmed.";
|
||||
$strings['PendingReasonByUpgrade'] = "<b>Pending</b>. The payment was made via credit card.";
|
||||
$strings['PendingReasonByVerify'] = "<b>Pending</b>. Sorry. We are not yet verified in PayPal.";
|
||||
$strings['PendingReasonByOther'] = "<b>Pending</b>. Please contact with the platform admin.";
|
||||
$strings['PayPalPaymentOKPleaseConfirm'] = "PayPal reports the transaction is ready to be executed. To acknowledge that you are OK to proceed, please click the confirmation button below. Once clicked, you will be registered to the course and the funds will be transferred from your PayPal account to our shop. You can always access your courses through the 'My courses' tab. Thank you for your custom!";
|
||||
$strings['Sandbox'] = "Test environment";
|
||||
$strings['PayPalAccount'] = "Paypal account";
|
||||
$strings['NoPayPalAccountDetected'] = "No Paypal account detected";
|
||||
$strings['PayPalConfig'] = "PayPal configuration:";
|
||||
$strings['TransfersConfig'] = "Bank transfers configuration:";
|
||||
$strings['PluginInstruction'] = "You can enable or disable the option to pay via PayPal, Culqi or bank transfer settings in the configuration section of the plugin.";
|
||||
$strings['ClickHere'] = "<i>Click here</i> for more details";
|
||||
$strings['CurrencyType'] = "Currency type";
|
||||
$strings['InfoCurrency'] = "Sets the currency for the payment of your courses.";
|
||||
$strings['ApiUsername'] = "API Username";
|
||||
$strings['ApiPassword'] = "API Password";
|
||||
$strings['ApiSignature'] = "API Signature";
|
||||
$strings['InfoApiCredentials'] = "To generate your API credentials to integrate Chamilo with your PayPal account, you must follow the following steps";
|
||||
$strings['InfoApiStepOne'] = "Go to your PayPal account, <strong>Summary</strong>, then <front>Seller preferences</front> in the <front>Selling Tools</front> menu (if you do not have this menu entry, you might need to get the authorization to sell stuff through PayPal first).";
|
||||
$strings['InfoApiStepTwo'] = "In paragraph <strong>API access</strong>, click <strong>Update</strong>";
|
||||
$strings['InfoApiStepThree'] = "In Option 2 (Request API credentials to create your own API username and password), click the <strong>View API Signature</strong> link, and copy the credentials shown right into the BuyCourses plugin form";
|
||||
$strings['ErrorOccurred'] = "<strong>An error ocurred</strong>. Code: %s. Message: %s. Please contact to platform admin";
|
||||
$strings['VisibleInCatalog'] = "Visible in catalog";
|
||||
$strings['Beneficiaries'] = "Beneficiaries";
|
||||
$strings['AvailableCourse'] = "Available course";
|
||||
$strings['ShowOnCourseCatalog'] = "Show on course catalog";
|
||||
$strings['ByStatus'] = "By status";
|
||||
$strings['ByUser'] = "By user";
|
||||
$strings['ByEmail'] = "By email";
|
||||
$strings['PaymentMethod'] = "Payment method";
|
||||
$strings['SWIFT'] = "SWIFT code";
|
||||
$strings['SWIFT_help'] = "Standard format of Bank Identifier Codes (BIC) and serves as a unique identifier for a bank or financial institution";
|
||||
$strings['PleaseSelectThePaymentMethodBeforeConfirmYourOrder'] = "Please select your favorite payment method before confirming your order";
|
||||
$strings['NoPaymentOptionAvailable'] = 'No payment option available. Please report to the administrator.';
|
||||
$strings['XIsOnlyPaymentMethodAvailable'] = '%s is the only payment method available for this purchase.';
|
||||
$strings['hide_free_text'] = "Hide 'Free' text";
|
||||
$strings['culqi_enable'] = "Enable culqi";
|
||||
$strings['include_services'] = "Include services";
|
||||
$strings['CurrencyIsNotConfigured'] = "Please, configure a currency before continuing.";
|
||||
$strings['Services'] = "Services";
|
||||
$strings['Service'] = "Service";
|
||||
$strings['NewService'] = "New service";
|
||||
$strings['ServiceName'] = "Service name";
|
||||
$strings['AppliesTo'] = "Applies to";
|
||||
$strings['ServiceInformation'] = "Service information";
|
||||
$strings['ListOfServicesOnSale'] = "List of services on sale";
|
||||
$strings['GlobalConfig'] = "Global configuration";
|
||||
$strings['WriteHereTheTermsAndConditionsOfYourECommerce'] = "Write here the terms and conditions of your e-commerce";
|
||||
$strings['EditService'] = "Edit service";
|
||||
$strings['DeleteThisService'] = "Delete this service";
|
||||
$strings['IConfirmIReadAndAcceptTermsAndCondition'] = "I confirm I read and accept the terms and conditions";
|
||||
$strings['PleaseSelectTheCorrectInfoToApplyTheService'] = "Please select the correct info to apply the service";
|
||||
$strings['SaleStatusCancelled'] = "Sale cancelled";
|
||||
$strings['ServiceSaleInfo'] = "Service sale info";
|
||||
$strings['ServiceId'] = "Service Id";
|
||||
$strings['BoughtBy'] = "Bought by";
|
||||
$strings['PurchaserUser'] = "Purchaser user";
|
||||
$strings['Pending'] = "Pending";
|
||||
$strings['Names'] = "Names";
|
||||
$strings['SellerName'] = "Seller name";
|
||||
$strings['SellerId'] = "Seller id";
|
||||
$strings['SellerAddress'] = "Seller address";
|
||||
$strings['SellerEmail'] = "Seller e-mail";
|
||||
$strings['NextNumberInvoice'] = "Next invoice number";
|
||||
$strings['NextNumberInvoiceDescription'] = "Number of the following invoice";
|
||||
$strings['InvoiceSeries'] = "Invoice series";
|
||||
$strings['InvoiceSeriesDescription'] = "Optional parameter: Example invoice Id <series><year>/<number>";
|
||||
$strings['InvoiceView'] = "View invoice";
|
||||
$strings['NoInvoiceEnable'] = "No invoicing block enable";
|
||||
$strings['Company'] = "Company";
|
||||
$strings['VAT'] = "VAT";
|
||||
$strings['Address'] = "Address";
|
||||
$strings['InvoiceNumber'] = "Invoice number";
|
||||
$strings['InvoiceDate'] = "Invoice date";
|
||||
$strings['Invoice'] = "Invoice";
|
||||
$strings['SaleEmail'] = "Sales e-mail";
|
||||
$strings['PurchaseDetailsIntro'] = "Purchase details";
|
||||
$strings['PurchaseDetailsEnd'] = "Regards";
|
||||
$strings['ProductName'] = "Product name";
|
||||
$strings['BankAccountIntro'] = "Bank Account Info";
|
||||
$strings['AdditionalInfoRequired'] = 'More information needed';
|
||||
$strings['SubscriptionToServiceXSuccessful'] = "Subscription to service %s completed.";
|
||||
$strings['ClickHereToFinish'] = "Click here to finish";
|
||||
$strings['OrderCancelled'] = "Order cancelled";
|
||||
$strings['use_currency_symbol'] = "Use currency symbol";
|
||||
$strings['ExportReport'] = "Export Sales Report";
|
||||
$strings['OrderTime'] = "Order time";
|
||||
$strings['SelectDateRange'] = "Select a <strong>start date</strong> and <strong>end date</strong> for the report";
|
||||
$strings['ServiceAdded'] = "Service added";
|
||||
$strings['ServiceEdited'] = "Service updated";
|
||||
$strings['ListOfServicesOnSale'] = "List of services for sale";
|
||||
$strings['AdditionalInfo'] = "Additional information";
|
||||
$strings['culqi_enable'] = "Enable Culqi";
|
||||
$strings['CulqiConfig'] = "Culqi configuration:";
|
||||
$strings['InfoCulqiCredentials'] = "To obtain your credentials, you will need to create an account on Culqi and enter the development mode, copy the merchant code in your dashboard, then enter the API Keys section and copy the corresponding key to paste it here.";
|
||||
$strings['CommerceCode'] = "Merchant code";
|
||||
$strings['NoTermsAndConditionsProvided'] = "No defined terms and conditions";
|
||||
$strings['GlobalConfig'] = "Global configuration:";
|
||||
$strings['MyServices'] = "My services";
|
||||
$strings['SalePrice'] = "Sale price";
|
||||
$strings['YouNeedToBeRegisteredInAtLeastOneCourse'] = "You need to be registered in at least one course";
|
||||
$strings['YouNeedToBeRegisteredInAtLeastOneSession'] = "You need to be registered in at least one session";
|
||||
$strings['IfYouWantToGetTheCertificateAndOrSkillsAsociatedToThisCourseYouNeedToBuyTheCertificateServiceYouCanGoToServiceCatalogClickingHere'] = "To obtain the certificate and/or the skills associated to this course, you need to buy the <b> Certificate </b> service. Go to the services catalogue to buy it by clicking <a target='_blank' href='%s'>here</a>";
|
||||
$strings['ServiceDeleted'] = 'Service deleted';
|
||||
$strings['YourCoursesNeedAtLeastOneLearningPath'] = 'The courses to which you are subscribed need at least one learning path that contains a final certificate item';
|
||||
$strings['GlobalTaxPerc'] = "Global tax rate";
|
||||
$strings['GlobalTaxPercDescription'] = "Default tax rate that will be used unless there is a specific tax rate for the course, session or service.";
|
||||
$strings['TaxPerc'] = "Tax rate";
|
||||
$strings['TaxPercDescription'] = "If left blank, the global tax rate will be used.";
|
||||
$strings['ByDefault'] = "by default (global value)";
|
||||
$strings['OnlyCourses'] = "Only courses";
|
||||
$strings['OnlySessions'] = "Only sessions";
|
||||
$strings['OnlyServices'] = "Only services";
|
||||
$strings['TaxAppliesTo'] = "Tax applied to";
|
||||
$strings['AllCoursesSessionsAndServices'] = "All (courses, sessions and services)";
|
||||
$strings['TaxNameCustom'] = "Tax name";
|
||||
$strings['TaxNameExamples'] = "VAT, IVA, IGV, TVA, IV ...";
|
||||
$strings['ErrorUpdateFieldDB'] = "Error updating the database fields";
|
||||
$strings['tpv_redsys_enable'] = "Enable RedSys POS";
|
||||
$strings['tpv_redsys_enable_help'] = "In order to use the RedSys POS payment method, it is necessary to download the \"REST INTEGRATION - PHP API \" files at the following link <a href='https://pagosonline.redsys.es/descargas.html'>web de RedSys</a> and locate the file <strong>apiRedSys.php</strong> in the <em>plugin/buycourses/resources</em> directory.";
|
||||
$strings['NotFindRedsysFile'] = "The <strong>apiRedsys.php</strong> file cannot be found in <em>plugin/buycourses/resources</em> directory";
|
||||
$strings['TpvPayment'] = "POS payment";
|
||||
$strings['TpvRedsysConfig'] = "Redsys POS configuration";
|
||||
$strings['DS_MERCHANT_MERCHANTCODE'] = "Trade number (FUC)";
|
||||
$strings['DS_MERCHANT_TERMINAL'] = "Terminal number";
|
||||
$strings['DS_MERCHANT_CURRENCY'] = "Terminal currency";
|
||||
$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 form fields with the information provided by the Redsys POS Technical Support:";
|
||||
$strings['InfoEmailExtra'] = "Extra info in payment e-mail";
|
||||
$strings['Coupon'] = "Coupon";
|
||||
$strings['DiscountAmount'] = "Discount amount";
|
||||
$strings['RedeemCoupon'] = "Redeem";
|
||||
$strings['NeedToAddCouponCode'] = "A coupon code has not been entered";
|
||||
$strings['CouponNotValid'] = "This coupon is not valid";
|
||||
$strings['CouponRedeemed'] = "Coupon redeemed";
|
||||
$strings['CouponDiscount'] = "Discount";
|
||||
$strings['CouponStatus'] = "Coupon status";
|
||||
$strings['CouponPercentage'] = "Percentage";
|
||||
$strings['CouponAmount'] = "Amount";
|
||||
$strings['CouponList'] = "Coupon list";
|
||||
$strings['CouponCode'] = "Coupon code";
|
||||
$strings['CouponDiscountType'] = "Discount type";
|
||||
$strings['CouponDateStart'] = "Valid from";
|
||||
$strings['CouponDateEnd'] = "Expires on";
|
||||
$strings['CouponDelivered'] = "Delivered";
|
||||
$strings['CouponDisable'] = "Disable";
|
||||
$strings['CouponEnable'] = "Enable";
|
||||
$strings['CouponCodeUsed'] = "Coupon code already used";
|
||||
$strings['CouponNoExists'] = "Coupon no exists";
|
||||
$strings['CouponErrorInsert'] = "Error inserting new coupon";
|
||||
$strings['CouponActive'] = "Active";
|
||||
$strings['CouponDisabled'] = "Disabled";
|
||||
$strings['CouponUpdate'] = "Coupon updated";
|
||||
$strings['CouponsConfiguration'] = "Coupons configuration";
|
||||
$strings['CouponAdd'] = "New coupon";
|
||||
$strings['ConfigureCoupon'] = "Configure coupon";
|
||||
$strings['DiscountCoupon'] = "Discount coupons";
|
||||
$strings['CouponsCode'] = "Code";
|
||||
$strings['DoYouHaveACoupon'] = "Do you have a coupon?";
|
||||
$strings['stripe_enable'] = "Enable Stripe";
|
||||
$strings['StripeConfig'] = "Stripe configuration:";
|
||||
$strings['InfoStripeCredentials'] = "To obtain the credentials you must first create an account in Stripe, copy the account id from your profile, go to the API Keys configuration section and copy the secret key, finally you must go to the Developers button (top right), register a new Endpoint in the Webhooks section, pointing to https://{site}/plugin/buycourses/src/stripe_response.php for the checkout.session.completed event type and copy the secret of the Endpoint.";
|
||||
$strings['StripeAccountId'] = "Account id:";
|
||||
$strings['StripeSecret'] = "Secret key:";
|
||||
$strings['StripeEndpointSecret'] = "Endpoint secret:";
|
||||
$strings['PendingReasonByStripe'] = "<b>Pending</b>. Awaiting for payment confirmation ...";
|
||||
$strings['cecabank_enable'] = "Enable Cecabank POS";
|
||||
$strings['TpvCecabank'] = "POS payment (Cecabank)";
|
||||
$strings['CecaSecret'] = "Secret";
|
||||
$strings['CecaUrl'] = "Url";
|
||||
$strings['CecaMerchanId'] = "Merchant";
|
||||
$strings['CecaAcquirerId'] = "Adquirer";
|
||||
$strings['CecaTerminalId'] = "Terminal";
|
||||
$strings['CecaCypher'] = "Cypher";
|
||||
$strings['CecaCurrency'] = "Currency";
|
||||
$strings['CecaExponent'] = "Exponent";
|
||||
$strings['CecaSupportedPayment'] = "Payment supported";
|
||||
$strings['CecabankConfig'] = "Cecabank configuration";
|
||||
$strings['Country'] = "Country";
|
||||
$strings['PaymentType'] = "Payment type";
|
||||
$strings['CountryRelPaymentConfig'] = "Payment type configuration for the country";
|
||||
$strings['CountryRelPaymentMessage'] = "To process an order, the type of payment per country must be defined, otherwise the order will not be allowed to go through.";
|
||||
$strings['CountryEmpty'] = "To process an order, you need to define the Country field in the user profile.";
|
||||
$strings['Duration'] = "Duration";
|
||||
$strings['SubscriptionAdd'] = "Add subscription";
|
||||
$strings['SubscriptionList'] = "Subscription list";
|
||||
$strings['SubscriptionListOnSale'] = "Subscriptions on sale";
|
||||
$strings['SelectSubscription'] = "Select duration";
|
||||
$strings['SubscriptionNotValid'] = "Subscription not valid";
|
||||
$strings['SubscriptionSalesReport'] = "Sales report";
|
||||
$strings['BuySubscriptions'] = "Buy subscriptions";
|
||||
$strings['ConfigurationOfSubscriptionsAndPrices'] = "Subscriptions and prices configuration";
|
||||
$strings['FrequencyConfig'] = "Duration config";
|
||||
$strings['Subscriptions'] = "Subscriptions";
|
||||
$strings['HasSubscriptions'] = "Has subscriptions";
|
||||
$strings['FrequencyRemoved'] = "Period removed";
|
||||
$strings['SubscriptionPeriodOnUse'] = "Subscription period in use";
|
||||
$strings['FrequencyNotExits'] = "Period does not exist";
|
||||
$strings['FrequencyIncorrect'] = "Period incorrect";
|
||||
$strings['SubscriptionFrequencyValueDays'] = "Value on days";
|
||||
$strings['FrequencyNotUpdated'] = "Period not updated";
|
||||
$strings['FrequencyNotSaved'] = "Period not saved";
|
||||
$strings['NeedToAddDuration'] = "Need to add duration";
|
||||
$strings['SubscriptionNotValid'] = "Subscription not valid";
|
||||
$strings['SelecSubscription'] = "Select a subscription";
|
||||
$strings['ConfigureSubscriptionsFrequencies'] = "Configure subscriptions periods";
|
||||
$strings['FrequencyAdd'] = "Add periods";
|
||||
$strings['SubscriptionAlreadyExists'] = "Subscription already exists";
|
||||
$strings['SubscriptionPeriodDuration'] = "Subscription duration (in days)";
|
||||
$strings['Product'] = "Product name";
|
||||
$strings['YouProductIsActivatedYouCanNowAccessIt'] = "Your product is now activated and you can now have access to it.";
|
||||
$strings['hide_shopping_cart_from_course_catalogue'] = "Hide shopping cart from the course catalogue and leave the subscribe button";
|
||||
250
plugin/buycourses/lang/french.php
Normal file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
$strings['plugin_title'] = "Vente de cours";
|
||||
$strings['plugin_comment'] = "Vendez vos cours directement depuis votre portail Chamilo, au travers d'un compte PayPal. Ni l'association Chamilo ni les développeurs impliqués dans le développement de ce plugin ne sauraient être tenus responsables d'un quelconque inconvénient causé par celui-ci.";
|
||||
$strings['show_main_menu_tab'] = "Montrer l'onglet dans le menu principal";
|
||||
$strings['show_main_menu_tab_help'] = "Dans le cas où vous ne souhaitez pas montrer l'onglet, il est possible de rajouter le lien suivant à votre portail Chamilo: %s";
|
||||
$strings['include_sessions'] = "Inclure les sessions";
|
||||
$strings['paypal_enable'] = "Activer PayPal";
|
||||
$strings['commissions_enable'] = "Activer commissions";
|
||||
$strings['transfer_enable'] = "Activer les transferts bancaires";
|
||||
$strings['unregistered_users_enable'] = "Permettre l'accès aux utilisateurs non enregistrés sur la plateforme";
|
||||
$strings['Free'] = "GRATUIT";
|
||||
$strings['PaypalPayoutCommissions'] = "Commissions PayPal Payouts";
|
||||
$strings['MyPayouts'] = "Mes paiements";
|
||||
$strings['Commission'] = "Commission";
|
||||
$strings['Commissions'] = "Commissions";
|
||||
$strings['SetCommissions'] = "Établir commissions";
|
||||
$strings['CommissionsConfig'] = "Configurer Commissions";
|
||||
$strings['PayoutReport'] = "Rapport de paiements";
|
||||
$strings['Stats'] = "Statistiques";
|
||||
$strings['InfoCommissions'] = "Saisissez ici la commission de vente en pourcentage ( % ) , l'organisation qui contrôle la plate-forme . Ce pourcentage est déduit du montant reçu par les enseignants pour chaque cours ou session vendus sur la plate-forme.";
|
||||
$strings['NeedToSelectPaymentType'] = "Besoin pour sélectionner le type de paiement";
|
||||
$strings['IndividualPayout'] = "Paiement individuel";
|
||||
$strings['CancelPayout'] = "Annuler paiement";
|
||||
$strings['ContinuePayout'] = "Continuer paiement";
|
||||
$strings['ProceedPayout'] = "Confirmer le paiement";
|
||||
$strings['TheActualPlatformCommissionIsX'] = "La commission de la plateforme est actuellement établie à <b> %s </b>. Ce pourcentage sera soustrait du prix total du produit. La différence sera répartie selon les commissions définies ci-dessous.";
|
||||
$strings['CoursesInSessionsDoesntDisplayHere'] = "Les cours qui se trouvent dans une session n'apparaissent pas dans la liste de cours individuels.";
|
||||
$strings['WantToSellCourses'] = "Envie d'enseigner et de gagner un peu d'argent avec vos propres cours? Cette liste pourraît être pleine de ventes de vos cours. Contactez-nous.";
|
||||
$strings['SelectOptionToProceed'] = "Sélectionnez une option pour continuer";
|
||||
$strings['VerifyTotalAmountToProceedPayout'] = "Veuillez vérifier le montant total avant de continuer le paiement des commissions. Ce montant ne prend pas en compte le coût additionnel éventuellement perçu par PayPal. Les ventes de cours pour lesquelles les bénéficiaires n'ont pas de compte PayPal configuré ne seront pas prises en compte.";
|
||||
$strings['TotalAcounts'] = "Total des comptes:";
|
||||
$strings['TotalPayout'] = "Total à payer:";
|
||||
$strings['PayoutDate'] = "Date de paiement:";
|
||||
$strings['CautionThisProcessCantBeCanceled'] = "<b>Attention</b>: ce processus peut prendre quelques minutes et ne peut pas être interrompu.";
|
||||
$strings['ProcessingPayoutsDontCloseThisWindow'] = "<b>Exécution des paiements. Ne fermez pas cette fenêtre avant que le processus ne soit finalisé.</b>";
|
||||
$strings['PayoutSuccess'] = "Paiements effectués avec succès";
|
||||
$strings['Buyer'] = "Acheteur";
|
||||
$strings['BankTransfer'] = "Transfert bancaire";
|
||||
$strings['SaleInfo'] = "Information vente";
|
||||
$strings['SaleStatusPending'] = "Vente non confirmée";
|
||||
$strings['SaleStatusCanceled'] = "Vente annulée";
|
||||
$strings['SaleStatusCompleted'] = "Vente finalisée";
|
||||
$strings['PayoutStatusPending'] = "Paiement en attente";
|
||||
$strings['PayoutStatusCanceled'] = "Paiement annulé";
|
||||
$strings['PayoutStatusCompleted'] = "Paiement complété";
|
||||
$strings['PayoutsTotalPending'] = "Paiements en attente:";
|
||||
$strings['PayoutsTotalCanceled'] = "Paiements annulés:";
|
||||
$strings['PayoutsTotalCompleted'] = "Paiements complétés:";
|
||||
$strings['TotalAmount'] = "Montant total:";
|
||||
$strings['CourseListOnSale'] = "Liste de cours en vente";
|
||||
$strings['AvailableCourses'] = "Cours disponibles";
|
||||
$strings['Price'] = "Prix";
|
||||
$strings['SearchFilter'] = "Filtre de recherche";
|
||||
$strings['MinimumPrice'] = "Prix minimum";
|
||||
$strings['MaximumPrice'] = "Prix maximum";
|
||||
$strings['AvailableCoursesConfiguration'] = "Configuration des cours disponibles";
|
||||
$strings['PaymentsConfiguration'] = "Configuration des paiements";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheCourse'] = "L'utilisateur est déjà inscrit au cours";
|
||||
$strings['SeeDescription'] = "Voir description";
|
||||
$strings['Buy'] = "Acheter";
|
||||
$strings['WaitingToReceiveThePayment'] = "En attente de réception du paiement";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheSession'] = "Vous êtes déjà inscrit à cette session";
|
||||
$strings['ItemNotSaved'] = "Article non sauvé";
|
||||
$strings['TitlePlugin'] = "Tout le nécessaire pour enseigner et vendre des cours en ligne";
|
||||
$strings['PluginPresentation'] = "Le plugin BuyCourses vous donne les moyens nécessaires pour vendre vos cours ou vos sessions existants et d'enseigner en ligne, en quelques étapes très simples. Qu'attendez-vous? Commencez à vendre des cours grâce à Chamilo dès maintenant!";
|
||||
$strings['Instructions'] = "Instructions d'utilisation";
|
||||
$strings['InstructionsStepOne'] = "Créer un cours ou une session de formation sur la plateforme.";
|
||||
$strings['InstructionsStepTwo'] = "Dans la section <strong>configuration de paiements</strong>, configurer le type de devise dans lequel vous souhaitez vendre vos cours et sessions";
|
||||
$strings['InstructionsStepThree'] = "Configurer les cours à vendre dans la section <strong>Configuration de cours et prix</strong>";
|
||||
$strings['BuyCourses'] = "Acheter des cours";
|
||||
$strings['ConfigurationOfCoursesAndPrices'] = "Configuration des cours et prix";
|
||||
$strings['SalesReport'] = "Rapport des ventes";
|
||||
$strings['UserInformation'] = "Fiche acheteur";
|
||||
$strings['PaymentMethods'] = "Méthodes de paiement";
|
||||
$strings['ConfirmOrder'] = "Confirmer commande";
|
||||
$strings['PurchaseData'] = "Détails d'achat";
|
||||
$strings['bc_subject'] = "Confirmation de commande de cours";
|
||||
$strings['PurchaseStatusX'] = "État de la vente: %s";
|
||||
$strings['PendingReasonByTransfer'] = "<b>En attente</b>. Transfert pas encore confirmé";
|
||||
$strings['CancelOrder'] = "Annuler la commande";
|
||||
$strings['BankAccountInformation'] = "Détails du compte bancaire";
|
||||
$strings['BankAccount'] = "Compte bancaire";
|
||||
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Une fois confirmée, vous recevrez un e-mail avec les données bancaires et la référence de la commande";
|
||||
$strings['SubscriptionToCourseXSuccessful'] = "Votre inscription au <a href=\"%s\"><strong>\"%s\"</strong></a> est terminée.";
|
||||
$strings['OrderCanceled'] = "Commande annulée";
|
||||
$strings['OrderStatus'] = "Statut de commande";
|
||||
$strings['PayoutStatus'] = "État du paiement";
|
||||
$strings['SearchByStatus'] = "Recherche par statut";
|
||||
$strings['OrderReference'] = "Référence de la commande";
|
||||
$strings['OrderDate'] = "Date de commande";
|
||||
$strings['OrderPrice'] = "Commande Prix";
|
||||
$strings['ProductType'] = "Type de produit";
|
||||
$strings['SubscribeUser'] = "Inscrire utilisateur";
|
||||
$strings['DeleteOrder'] = "Éliminer la commande";
|
||||
$strings['ErrorContactPlatformAdmin'] = "Une erreur inconnue s'est produite. Veuillez contacter l'administrateur de la plateforme.";
|
||||
$strings['PendingReasonByAddress'] = "<b>En attente</b>. Il manque une adresse de livraison.";
|
||||
$strings['PendingReasonByAuthorization'] = "<b>En attente</b>. Nous n'avons pas confirmé la réception des fonds.";
|
||||
$strings['PendingReasonByEcheck'] = "<b>En attente</b>. Le paiement a été fait via un chèque qui n'a pas encore été libéré";
|
||||
$strings['PendingReasonByIntl'] = "<b>En attente</b>. Aucun moyen de toucher les fonds.";
|
||||
$strings['PendingReasonByMulticurrency'] = "<b>En attente</b>. Nous n'avons pas de compte dans la devise indiquée.";
|
||||
$strings['PendingReasonByOrder'] = "<b>En attente</b>. Commande enregistrée. Les fonds n'ont pas encore été libérés.";
|
||||
$strings['PendingReasonByPaymentReview'] = "<b>En attente</b>. Le paiement est en révision anti-fraude chez PayPal.";
|
||||
$strings['PendingReasonByRegulatoryReview'] = "<b>En attente</b>. Le paiement est actuellement revu pour correspondre aux règles mises en vigueur par le gouvernement.";
|
||||
$strings['PendingReasonByUnilateral'] = "<b>En attente</b>. L'adresse e-mail n'est pas encore confirmée ou enregistrée.";
|
||||
$strings['PendingReasonByUpgrade'] = "<b>En attente</b>. Le paiement a été fait par carte de crédit.";
|
||||
$strings['PendingReasonByVerify'] = "<b>En attente</b>. Désolé, nous n'avons pas encore vérifié sur PayPal.";
|
||||
$strings['PendingReasonByOther'] = "<b>En attente</b>. Veuillez contacter l'administrateur.";
|
||||
$strings['PayPalPaymentOKPleaseConfirm'] = "PayPal nous indique que la transaction est prête à être exécutée. Par mesure de sécurité, nous vous demandons de bien vouloir confirmer une dernière fois la transaction en cliquant sur le bouton de confirmation ci-dessous. Une fois cliqué, vous serez immédiatement enregistré au cours, et les fonds correspondants seront soustraits de votre compte PayPal. Vous pouvez accéder à vos cours à tout moment à partir de l'onglet 'Mes cours'. Merci de votre fidélité!";
|
||||
$strings['Sandbox'] = "Environnement de test";
|
||||
$strings['PayPalAccount'] = "Compte Paypal";
|
||||
$strings['NoPayPalAccountDetected'] = "Pas de compte paypal détecté";
|
||||
$strings['PayPalConfig'] = "Configuration PayPal:";
|
||||
$strings['TransfersConfig'] = "Configuration des transfers bancaires:";
|
||||
$strings['PluginInstruction'] = "Vous pouvez activer ou désactiver l'option de paiements via PayPal, Culqi ou de transferts bancaires dans la section de configuration des plugins.";
|
||||
$strings['ClickHere'] = "Cliquez ici pour plus d'infos";
|
||||
$strings['CurrencyType'] = "Type de devise";
|
||||
$strings['InfoCurrency'] = "Permet de configurer la devise pour l'achat des cours.";
|
||||
$strings['ApiUsername'] = "Nom d'utilisateur de l'API";
|
||||
$strings['ApiPassword'] = "Mot de passe de l'API";
|
||||
$strings['ApiSignature'] = "Signature de l'API";
|
||||
$strings['InfoApiCredentials'] = "Pour générer vos données API pour intégrer votre compte PayPal à Chamilo, il vous faudra suivre les étapes suivantes";
|
||||
$strings['InfoApiStepOne'] = "Aller dans l'option <strong>profil</strong> de PayPal, et ensuite dans <strong>Outils de vente</strong>";
|
||||
$strings['InfoApiStepTwo'] = "Dans la section <strong>API d'accès</strong>, cliquer sur l'option <strong>Mettre à jour</strong>";
|
||||
$strings['InfoApiStepThree'] = "Dans l'option 2 de Configuration des données et permissions API, cliquer sur <strong>Voir signature API</strong>. Copier ces donées dans le formulaire de configuration de ce plugin";
|
||||
$strings['ErrorOccurred'] = "<strong>Une erreur est survenue</strong>. Code: %s. Message: %s. Veuillez contacter l'administrateur de la plateforme";
|
||||
$strings['VisibleInCatalog'] = "Visible dans le catalogue";
|
||||
$strings['Beneficiaries'] = "Bénéficiaires";
|
||||
$strings['AvailableCourse'] = "Cours disponibles";
|
||||
$strings['ShowOnCourseCatalog'] = "Afficher dans le catalogue de cours";
|
||||
$strings['ByStatus'] = "Par statut";
|
||||
$strings['ByUser'] = "Par utilisateur";
|
||||
$strings['ByEmail'] = "Par email";
|
||||
$strings['PaymentMethod'] = "Méthodes de paiement";
|
||||
$strings['SWIFT'] = "Code SWIFT";
|
||||
$strings['SWIFT_help'] = "Format standard des codes d'identification de banque (BIC) et sert un identifiant unique pour une banque ou une institution financière.";
|
||||
$strings['PleaseSelectThePaymentMethodBeforeConfirmYourOrder'] = 'Veuillez sélectionner votre méthode de paiement préférée avant de confirmer';
|
||||
$strings['NoPaymentOptionAvailable'] = 'Aucune méthode de paiement disponible. Merci de bien vouloir rapporter ce problème à l\'administrateur.';
|
||||
$strings['XIsOnlyPaymentMethodAvailable'] = '%s est la seule méthode de paiement disponible pour cet achat.';
|
||||
$strings['public_main_menu_tab'] = "Montrer l'onglet dans le menu principal aux utilisateurs anonyme également";
|
||||
$strings['culqi_enable'] = "Activé culqi";
|
||||
$strings['include_services'] = "Inclure les services";
|
||||
$strings['hide_free_text'] = "Cacher le texte 'Free' ou 'Gratuit'";
|
||||
$strings['Services'] = "Services";
|
||||
$strings['ServiceName'] = "Nom du service";
|
||||
$strings['AppliesTo'] = "S'applique à";
|
||||
$strings['ListOfServicesOnSale'] = "Liste de services en vente";
|
||||
$strings['GlobalConfig'] = "Configuration globale";
|
||||
$strings['WriteHereTheTermsAndConditionsOfYourECommerce'] = "Écrire les conditions de ventes de votre e-commerce";
|
||||
$strings['NewService'] = "Nouveau service";
|
||||
$strings['Service'] = "Service";
|
||||
$strings['ServiceInformation'] = "Information sur le service";
|
||||
$strings['EditService'] = "Edition du service";
|
||||
$strings['DeleteThisService'] = "Supprimer ce service";
|
||||
$strings['IConfirmIReadAndAcceptTermsAndCondition'] = "Je confirme que j'ai lu et que j'accepte les termes et conditions";
|
||||
$strings['PleaseSelectTheCorrectInfoToApplyTheService'] = "Veuillez choisir l'information à appliquer au service";
|
||||
$strings['SaleStatusCancelled'] = "Vente annulée";
|
||||
$strings['ServiceSaleInfo'] = "Information de vente";
|
||||
$strings['ServiceId'] = "Id du service";
|
||||
$strings['BoughtBy'] = "Acheté par";
|
||||
$strings['PurchaserUser'] = "Utilisateur acheteur";
|
||||
$strings['Pending'] = "En attente";
|
||||
$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";
|
||||
$strings['Coupon'] = "Coupon";
|
||||
$strings['DiscountAmount'] = "Ristourne totale";
|
||||
$strings['RedeemCoupon'] = "Échanger";
|
||||
$strings['NeedToAddCouponCode'] = "Aucun code de coupon n'a été introduit";
|
||||
$strings['CouponNotValid'] = "Ce coupon n'est pas valable";
|
||||
$strings['CouponRedeemed'] = "Coupon échangé";
|
||||
$strings['CouponDiscount'] = "Ristourne";
|
||||
$strings['CouponStatus'] = "Statut du coupon";
|
||||
$strings['CouponPercentage'] = "Pourcentage";
|
||||
$strings['CouponAmount'] = "Montant";
|
||||
$strings['CouponList'] = "Liste des coupons";
|
||||
$strings['CouponCode'] = "Code du coupon";
|
||||
$strings['CouponDiscountType'] = "Type de ristourne";
|
||||
$strings['CouponDateStart'] = "Valable apd";
|
||||
$strings['CouponDateEnd'] = "Expire le";
|
||||
$strings['CouponDelivered'] = "Livré";
|
||||
$strings['CouponDisable'] = "Désactivé";
|
||||
$strings['CouponEnable'] = "Activé";
|
||||
$strings['CouponCodeUsed'] = "Code de coupon déjà utilisé";
|
||||
$strings['CouponNoExists'] = "Ce coupon n'existe pas";
|
||||
$strings['CouponErrorInsert'] = "Erreur lors de l'insertion du coupon";
|
||||
$strings['CouponActive'] = "Actif";
|
||||
$strings['CouponDisabled'] = "Désactivé";
|
||||
$strings['CouponUpdate'] = "Coupon mis à jour";
|
||||
$strings['CouponsConfiguration'] = "Configuration coupons";
|
||||
$strings['CouponAdd'] = "Nouveau coupon";
|
||||
$strings['ConfigureCoupon'] = "Configurer le coupon";
|
||||
$strings['DiscountCoupon'] = "Coupons de ristourne";
|
||||
$strings['CouponsCode'] = "Code";
|
||||
$strings['DoYouHaveACoupon'] = "Vous avez un coupon?";
|
||||
$strings['stripe_enable'] = "Activer Stripe";
|
||||
$strings['StripeConfig'] = "Configuration de Stripe:";
|
||||
$strings['InfoStripeCredentials'] = "Pour obtenir les données de connexion, vous devez d'abord réer un compte Stripe (ce qui prend un certain temps), puis copier l'ID du compte depuis votre profil et le renseigner ici. Puis aller dans la configuration des clefs API et copier la clef secrète. Enfin, suivre le bouton 'Développeurs' (haut droite), enregistrer un nouveau Endpoint dans la section Webhooks, le pointer vers l'URL https://{site}/plugin/buycourses/src/stripe_response.php et l'associer à l'événement checkout.session.completed et copier le secret du Endpoint ici.";
|
||||
$strings['StripeAccountId'] = "ID du compte:";
|
||||
$strings['StripeSecret'] = "Clef secrète:";
|
||||
$strings['StripeEndpointSecret'] = "Clef secrète du Endpoint:";
|
||||
$strings['PendingReasonByStripe'] = "<b>Un instant...</b>. En attente de confirmation du paiement...";
|
||||
$strings['cecabank_enable'] = "Activer Cecabank POS";
|
||||
$strings['TpvCecabank'] = "Paiement POS (Cecabank)";
|
||||
$strings['CecaSecret'] = "Clef secrète";
|
||||
$strings['CecaUrl'] = "URL";
|
||||
$strings['CecaMerchanId'] = "Marchand";
|
||||
$strings['CecaAcquirerId'] = "Acquéreur";
|
||||
$strings['CecaTerminalId'] = "Terminal";
|
||||
$strings['CecaCypher'] = "Chiffrage";
|
||||
$strings['CecaCurrency'] = "Devise";
|
||||
$strings['CecaExponent'] = "Exposant";
|
||||
$strings['CecaSupportedPayment'] = "Paiement supporté";
|
||||
$strings['CecabankConfig'] = "Configuration de Cecabank";
|
||||
$strings['Country'] = "Pays";
|
||||
$strings['PaymentType'] = "Type de paiement";
|
||||
$strings['CountryRelPaymentConfig'] = "Configuration du type de paiement par pays";
|
||||
$strings['CountryRelPaymentMessage'] = "Pour faire une commande, il est nécessaire de définir le type de paiement par pays. Sinon, il est impossible de clôturer la commande";
|
||||
$strings['CountryEmpty'] = "Pour passer commande, il est nécessaire de définir le champ Pays dans le profil utilisateur.";
|
||||
$strings['Duration'] = "Durée";
|
||||
$strings['SubscriptionAdd'] = "Ajouter souscription";
|
||||
$strings['SubscriptionList'] = "Liste des souscriptions";
|
||||
$strings['SubscriptionListOnSale'] = "Souscriptions en promo";
|
||||
$strings['SelectSubscription'] = "Sélectionner la durée";
|
||||
$strings['SubscriptionNotValid'] = "Souscription non valable";
|
||||
$strings['SubscriptionSalesReport'] = "Rapport de ventes";
|
||||
$strings['BuySubscriptions'] = "Souscrire";
|
||||
$strings['ConfigurationOfSubscriptionsAndPrices'] = "Configuration des souscriptions et prix";
|
||||
$strings['FrequencyConfig'] = "Configuration périodes";
|
||||
$strings['Subscriptions'] = "Souscriptions";
|
||||
$strings['HasSubscriptions'] = "A des souscriptions";
|
||||
$strings['FrequencyRemoved'] = "Période supprimée";
|
||||
$strings['SubscriptionPeriodOnUse'] = "Période de souscription utilisée";
|
||||
$strings['FrequencyNotExits'] = "Cette période n'existe pas";
|
||||
$strings['FrequencyIncorrect'] = "Période incorrecte";
|
||||
$strings['SubscriptionFrequencyValueDays'] = "Valeur en jours";
|
||||
$strings['FrequencyNotUpdated'] = "Période non mise à jour";
|
||||
$strings['FrequencyNotSaved'] = "Période non sauvegardée";
|
||||
$strings['NeedToAddDuration'] = "Une durée est nécessaire";
|
||||
$strings['SubscriptionNotValid'] = "Souscription non valable";
|
||||
$strings['SelecSubscription'] = "Sélectionnez une souscription";
|
||||
$strings['ConfigureSubscriptionsFrequencies'] = "Configurez des périodes de souscription";
|
||||
$strings['FrequencyAdd'] = "Ajouter période";
|
||||
$strings['SubscriptionAlreadyExists'] = "La souscription existe déjà";
|
||||
$strings['SubscriptionPeriodDuration'] = "Durée de souscription (en jours)";
|
||||
$strings['Product'] = "Produit";
|
||||
$strings['SalePrice'] = "Prix";
|
||||
$strings['YouProductIsActivatedYouCanNowAccessIt'] = "Votre abonnement a été activé, vous avez maintenant accès au module choisi.";
|
||||
$strings['hide_shopping_cart_from_course_catalogue'] = "Cacher le chariot de vente dans le catalogue de cours et laisse le bouton s'inscrire";
|
||||
321
plugin/buycourses/lang/spanish.php
Normal file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
$strings['plugin_title'] = "Venta de cursos";
|
||||
$strings['plugin_comment'] = "Vender cursos a través de PayPal directamente desde su portal Chamilo. La asociación Chamilo y los desarrolladores involucrados no pueden ser considerados responsables de cualquier inconveniente que se presente.";
|
||||
$strings['show_main_menu_tab'] = "Mostrar pestaña en el menu principal";
|
||||
$strings['show_main_menu_tab_help'] = "En caso de no querer mostrar la pestaña, puede agregar el siguiente enlace a su portal Chamilo: %s";
|
||||
$strings['public_main_menu_tab'] = "Mostrar pestaña a usuarios sin login";
|
||||
$strings['include_sessions'] = "Incluir sesiones";
|
||||
$strings['paypal_enable'] = "Habilitar PayPal";
|
||||
$strings['commissions_enable'] = "Habilitar Comisiones";
|
||||
$strings['transfer_enable'] = "Habilitar transferencia";
|
||||
$strings['unregistered_users_enable'] = "Permitir usuarios sin registro en la plataforma";
|
||||
$strings['invoicing_enable'] = "Habilitar Facturación";
|
||||
$strings['tax_enable'] = "Habilitar Impuestos";
|
||||
$strings['Free'] = "GRATIS";
|
||||
$strings['PaypalPayoutCommissions'] = "Pagar comisiones por Paypal";
|
||||
$strings['MyPayouts'] = "Mis Pagos";
|
||||
$strings['Commission'] = "Comisión";
|
||||
$strings['Commissions'] = "Comisiones";
|
||||
$strings['SetCommissions'] = "Aplicar comisiones";
|
||||
$strings['CommissionsConfig'] = "Configurar Comisiones";
|
||||
$strings['PayoutReport'] = "Reporte de Pagos";
|
||||
$strings['Stats'] = "Estadísticas";
|
||||
$strings['InfoCommissions'] = "Ingrese aquí la comisión de ventas, en porcentaje (%), para la organización que controla la plataforma. Este porcentaje se deducirá del monto percibido por los docentes por cada curso o sesión vendido en la plataforma.";
|
||||
$strings['NeedToSelectPaymentType'] = "Necesita seleccionar el tipo de pago";
|
||||
$strings['IndividualPayout'] = "Pago individual";
|
||||
$strings['CancelPayout'] = "Cancelar Payout";
|
||||
$strings['ContinuePayout'] = "Continuar con el Pago";
|
||||
$strings['ProceedPayout'] = "Proceder con el Pago";
|
||||
$strings['TheActualPlatformCommissionIsX'] = "La actual comisión de la plataforma es de <b> %s </b>, este porcentaje será descontado del total del precio del producto cuya diferencia será el monto base para aplicar estas comisiones.";
|
||||
$strings['CoursesInSessionsDoesntDisplayHere'] = "Los cursos que se encuentren dentro de una sesión de formación no aparecerán en la lista de cursos a configurar como productos individuales.";
|
||||
$strings['WantToSellCourses'] = "¿Quieres enseñar y ganar dinero con tus propios cursos?, Esta lista puede estar llena de tus ganancias vendiendo cursos a través de esta plataforma!. Informate con nosotros! ";
|
||||
$strings['SelectOptionToProceed'] = "Selecciona una opción para proceder";
|
||||
$strings['VerifyTotalAmountToProceedPayout'] = "Por favor verificar el monto total para proceder con el pago de comisiones, este monto no considera cargos extras por paypal, las ventas de cursos que no cuenten con una cuenta de Paypal para el o los beneficiarios no serán consideradas.";
|
||||
$strings['TotalAcounts'] = "Total de cuentas:";
|
||||
$strings['TotalPayout'] = "Total a pagar:";
|
||||
$strings['PayoutDate'] = "Fecha del Pago:";
|
||||
$strings['CautionThisProcessCantBeCanceled'] = "<b>Precaución</b>: este proceso puede tomar unos minutos y no puede ser cancelado.";
|
||||
$strings['ProcessingPayoutsDontCloseThisWindow'] = "<b>Procesando los pagos, no cierre esta ventana hasta que haya finalizado</b>";
|
||||
$strings['PayoutSuccess'] = "Los pagos se han realizado con éxito";
|
||||
$strings['Buyer'] = "Comprador";
|
||||
$strings['BankTransfer'] = "Transferencia Bancaria";
|
||||
$strings['SaleInfo'] = "Información de la venta";
|
||||
$strings['SaleStatusPending'] = "Venta pendiente";
|
||||
$strings['SaleStatusCanceled'] = "Venta cancelada";
|
||||
$strings['SaleStatusCompleted'] = "Venta completada";
|
||||
$strings['PayoutStatusPending'] = "Pago pendiente";
|
||||
$strings['PayoutStatusCanceled'] = "Pago cancelado";
|
||||
$strings['PayoutStatusCompleted'] = "Pago completado";
|
||||
$strings['PayoutsTotalPending'] = "Pagos pendientes:";
|
||||
$strings['PayoutsTotalCanceled'] = "Pagos cancelados:";
|
||||
$strings['PayoutsTotalCompleted'] = "Pagos completados:";
|
||||
$strings['Total'] = "Total";
|
||||
$strings['TotalAmount'] = "Monto total:";
|
||||
$strings['CourseListOnSale'] = "Lista de cursos a la venta";
|
||||
$strings['AvailableCourses'] = "Cursos disponibles";
|
||||
$strings['Price'] = "Precio";
|
||||
$strings['SearchFilter'] = "Filtro de búsqueda";
|
||||
$strings['MinimumPrice'] = "Precio mínimo";
|
||||
$strings['MaximumPrice'] = "Precio máximo";
|
||||
$strings['AvailableCoursesConfiguration'] = "Configuración de cursos disponibles";
|
||||
$strings['PaymentsConfiguration'] = "Configuración de Pagos";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheCourse'] = "Usted ya está registrado en el curso.";
|
||||
$strings['SeeDescription'] = "Ver descripción";
|
||||
$strings['Buy'] = "Comprar";
|
||||
$strings['WaitingToReceiveThePayment'] = "Se encuentra a la espera de recibir el pago";
|
||||
$strings['TheUserIsAlreadyRegisteredInTheSession'] = "Usted ya está registrado en la sesión";
|
||||
$strings['ItemNotSaved'] = "Elemento no guardado";
|
||||
$strings['TitlePlugin'] = "Todo lo que necesita para enseñar y vender cursos en línea";
|
||||
$strings['PluginPresentation'] = "El Plugin BuyCourses le da los recursos para vender sus cursos o sus sesiones ya creados y enseñar en línea, todo en unos simples pasos y configuraciones. ¿Qué espera? Empiece a vender cursos a través de Chamilo ahora!";
|
||||
$strings['Instructions'] = "Instrucciones de uso";
|
||||
$strings['InstructionsStepOne'] = "Crea un curso o una sesión de formación en la plataforma.";
|
||||
$strings['InstructionsStepTwo'] = "En la sección <strong>configuración de pagos</strong>, configure el tipo de moneda con el que venderá sus cursos o sesiones.";
|
||||
$strings['InstructionsStepThree'] = "Configure los cursos a vender en la sección <strong>Configuración de cursos y precios</strong>";
|
||||
$strings['BuyCourses'] = "Comprar cursos";
|
||||
$strings['ConfigurationOfCoursesAndPrices'] = "Configuración de cursos y precios";
|
||||
$strings['SalesReport'] = "Reporte de ventas";
|
||||
$strings['UserInformation'] = "Ficha del comprador";
|
||||
$strings['PaymentMethods'] = "Métodos de pago";
|
||||
$strings['ConfirmOrder'] = "Confirmar Orden";
|
||||
$strings['PurchaseData'] = "Datos de la compra";
|
||||
$strings['bc_subject'] = "Confirmación pedido de cursos";
|
||||
$strings['PurchaseStatusX'] = "Estado de la compra: %s";
|
||||
$strings['PendingReasonByTransfer'] = "<b>Pendiente</b>. Esperando la confirmación de la transferencia";
|
||||
$strings['CancelOrder'] = "Cancelar Orden";
|
||||
$strings['BankAccountInformation'] = "Información de la Cuenta Bancaria";
|
||||
$strings['BankAccount'] = "Cuenta Bancaria";
|
||||
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Una vez confirmado, recibira un e-mail con los datos bancarios y una referencia del pedido.";
|
||||
$strings['SubscriptionToCourseXSuccessful'] = "<p class=\"lead\">Proceso completado. Tu subscripción a <a href=\"%s\"><strong>\"%s\"</strong></a> se realizó correctamente.</p>";
|
||||
$strings['OrderCanceled'] = "Pedido cancelado";
|
||||
$strings['OrderStatus'] = "Estado del pedido";
|
||||
$strings['PayoutStatus'] = "Estado del pago";
|
||||
$strings['SearchByStatus'] = "Buscar por estado";
|
||||
$strings['OrderReference'] = "Referencia del pedido";
|
||||
$strings['OrderDate'] = "Fecha del pedido";
|
||||
$strings['OrderPrice'] = "Precio del pedido";
|
||||
$strings['ProductType'] = "Tipo de producto";
|
||||
$strings['SubscribeUser'] = "Inscribir usuario";
|
||||
$strings['DeleteOrder'] = "Eliminar pedido";
|
||||
$strings['ErrorContactPlatformAdmin'] = "Se ha producido un error desconocido. Por favor, póngase en contacto con el administrador de la plataforma.";
|
||||
$strings['PendingReasonByAddress'] = "<b>Pendiente</b>. No has ingresado una dirección de correo confirmada.";
|
||||
$strings['PendingReasonByAuthorization'] = "<b>Pendiente</b>. No hemos recibido los fondos.";
|
||||
$strings['PendingReasonByEcheck'] = "<b>Pendiente</b>. El pago fue hecho a través de un eCheck que aún no está declarado";
|
||||
$strings['PendingReasonByIntl'] = "<b>Pendiente</b>. No tenemos un mecanismo de retiro de fondos.";
|
||||
$strings['PendingReasonByMulticurrency'] = "<b>Pending</b>. No podemos realizar el cambio de moneda.";
|
||||
$strings['PendingReasonByOrder'] = "<b>Pendiente</b>. Pedido realizado. No hemos recibido los fondos.";
|
||||
$strings['PendingReasonByPaymentReview'] = "<b>Pendiente</b>. El pago está siendo revisado por PayPal por riesgo.";
|
||||
$strings['PendingReasonByRegulatoryReview'] = "<b>Pendiente</b>. El pago está siendo revisado por cumplimiento con regulaciones gubernamentales.";
|
||||
$strings['PendingReasonByUnilateral'] = "<b>Pendiente</b>. La dirección de correo electrónico aún no está registrada o confirmada.";
|
||||
$strings['PendingReasonByUpgrade'] = "<b>Pendiente</b>. El pago fue realizado a través de una tarjeta de crédito.";
|
||||
$strings['PendingReasonByVerify'] = "<b>Pendiente</b>. Lo sentimos. Todavía no estamos verificados en PayPal.";
|
||||
$strings['PendingReasonByOther'] = "<b>Pendiente</b>. Por favor contacta al administrador de la plataforma.";
|
||||
$strings['PayPalPaymentOKPleaseConfirm'] = "PayPal nos indicó que todo estaba listo para ejecutar el pago. Por seguridad, le pedimos confirme una última vez su pedido dando clic en el botón de confirmación a bajo. Una vez le haya dado clic, será registrado al curso y el monto correspondiente será retirado de su cuenta PayPal. Siempre puede acceder a sus cursos a partir de la pestaña 'Mis cursos'. Gracias por su compra!";
|
||||
$strings['Sandbox'] = "Entorno de Pruebas";
|
||||
$strings['PayPalAccount'] = "Cuenta de Paypal";
|
||||
$strings['NoPayPalAccountDetected'] = "No se ingresó una cuenta de Paypal";
|
||||
$strings['PayPalConfig'] = "Configuración PayPal:";
|
||||
$strings['TransfersConfig'] = "Configuración de transferencias:";
|
||||
$strings['PluginInstruction'] = "Puede activar o desactivar la opción de pagos vía PayPal, Culqi o configuración de transferencias bancarias, en la sección del configuración del plugin.";
|
||||
$strings['ClickHere'] = "<i>Clic aquí</i> para más detalles";
|
||||
$strings['CurrencyType'] = "Tipo de moneda";
|
||||
$strings['InfoCurrency'] = "Permite configurar el tipo de moneda (de pago) para sus cursos.";
|
||||
$strings['ApiUsername'] = "Nombre de usuario de API";
|
||||
$strings['ApiPassword'] = "Contraseña de API";
|
||||
$strings['ApiSignature'] = "Firma";
|
||||
$strings['InfoApiCredentials'] = "Para generar tu credenciales API para integrar su cuenta PayPal con Chamilo LMS, deberá seguir los siguientes pasos";
|
||||
$strings['InfoApiStepOne'] = "Ir a la opción de <strong>Perfil de PayPal</strong>, luego en <strong>Mis herramientas de venta</strong>";
|
||||
$strings['InfoApiStepTwo'] = "En el apartado <strong>Acceso API</strong>, dar clic en la opción <strong>Actualizar</strong>";
|
||||
$strings['InfoApiStepThree'] = "En la opción 2, de Configuración de credenciales y permisos de API, dar clic en <strong>Ver firma de API</strong>. Copiar los datos de las credenciales en el formulario de configuración de este plugin";
|
||||
$strings['ErrorOccurred'] = "<strong>Ocurrio un error</strong>. Codigo: %s. Mensaje: %s. Por favor, contacta al administrador de la plataforma.";
|
||||
$strings['VisibleInCatalog'] = "Visible en el catálogo";
|
||||
$strings['Beneficiaries'] = "Beneficiarios";
|
||||
$strings['AvailableCourse'] = "Curso disponible";
|
||||
$strings['ShowOnCourseCatalog'] = "Mostrar en el catálogo de cursos";
|
||||
$strings['ByStatus'] = "Por estado";
|
||||
$strings['ByUser'] = "Por usuario";
|
||||
$strings['ByEmail'] = "Por email";
|
||||
$strings['PaymentMethod'] = "Método de pago";
|
||||
$strings['SWIFT'] = "Código SWIFT";
|
||||
$strings['SWIFT_help'] = "Formato estándar de los Códigos de Identificación Bancaria (BIC) que sirve como identificador único para un banco o institución financiera.";
|
||||
$strings['PleaseSelectThePaymentMethodBeforeConfirmYourOrder'] = "Seleccione su método de pago preferido antes de confirmar su pedido";
|
||||
$strings['NoPaymentOptionAvailable'] = 'No hay opción de pago disponible. Por favor reporte este problema al administrador.';
|
||||
$strings['XIsOnlyPaymentMethodAvailable'] = '%s es la única opción de pago disponible para esta compra.';
|
||||
$strings['hide_free_text'] = "Esconder texto 'Gratis'";
|
||||
$strings['culqi_enable'] = "Activar culqi";
|
||||
$strings['include_services'] = "Incluir Servicios";
|
||||
$strings['CurrencyIsNotConfigured'] = "Configure una moneda antes de seguir.";
|
||||
$strings['Services'] = "Servicios";
|
||||
$strings['Service'] = "Servicio";
|
||||
$strings['NewService'] = "Nuevo servicio";
|
||||
$strings['ServiceName'] = "Nombre de servicio";
|
||||
$strings['AppliesTo'] = "Aplicado a";
|
||||
$strings['ServiceInformation'] = "Información del servicio";
|
||||
$strings['ListOfServicesOnSale'] = "Lista de servicios en venta";
|
||||
$strings['GlobalConfig'] = "Configuración global";
|
||||
$strings['WriteHereTheTermsAndConditionsOfYourECommerce'] = "Escriba aquí los términos y condiciones de su portal e-commerce";
|
||||
$strings['EditService'] = "Editar servicio";
|
||||
$strings['DeleteThisService'] = "Borrar servicio";
|
||||
$strings['IConfirmIReadAndAcceptTermsAndCondition'] = "He leído y acepto los términos y condiciones";
|
||||
$strings['PleaseSelectTheCorrectInfoToApplyTheService'] = "Porfavor Seleccione la información correcta para aplicar el servicio";
|
||||
$strings['SaleStatusCancelled'] = "Venta anulada";
|
||||
$strings['ServiceSaleInfo'] = "Información del servicio";
|
||||
$strings['ServiceId'] = "Id de servicio";
|
||||
$strings['BoughtBy'] = "Comprado por";
|
||||
$strings['PurchaserUser'] = "Usuario comprador";
|
||||
$strings['Pending'] = "Pendiente";
|
||||
$strings['Names'] = "Nombres";
|
||||
$strings['SellerName'] = "Nombre vendedor";
|
||||
$strings['SellerId'] = "Identificador vendedor";
|
||||
$strings['SellerAddress'] = "Dirección vendedor";
|
||||
$strings['SellerEmail'] = "E-mail vendedor";
|
||||
$strings['NextNumberInvoice'] = "Número siguiente factura";
|
||||
$strings['NextNumberInvoiceDescription'] = "Número de la siguiente factura asignado de forma manual";
|
||||
$strings['InvoiceSeries'] = "Serie factura";
|
||||
$strings['InvoiceSeriesDescription'] = "Parámetro opcional: Ejemplo de numeración factura <serie><año>/<número>";
|
||||
$strings['InvoiceView'] = "Ver factura";
|
||||
$strings['NoInvoiceEnable'] = "No está habilitado el bloque de facturación";
|
||||
$strings['Company'] = "Empresa";
|
||||
$strings['VAT'] = "CIF";
|
||||
$strings['Address'] = "Dirección";
|
||||
$strings['InvoiceNumber'] = "Num. factura";
|
||||
$strings['InvoiceDate'] = "Fecha de emisión";
|
||||
$strings['Invoice'] = "Factura";
|
||||
$strings['SaleEmail'] = "E-mail de ventas";
|
||||
$strings['PurchaseDetailsIntro'] = "Detalles de la comprar";
|
||||
$strings['PurchaseDetailsEnd'] = "Atentamente";
|
||||
$strings['ProductName'] = "Nombre producto";
|
||||
$strings['BankAccountIntro'] = "Información cuentas bancarias";
|
||||
$strings['AdditionalInfoRequired'] = 'Se requiere que se elija la información adicional antes de proceder';
|
||||
$strings['SubscriptionToServiceXSuccessful'] = "La subscripción al servicio %s ha sido satisfactoria";
|
||||
$strings['ClickHereToFinish'] = "De clic aquí para terminar";
|
||||
$strings['OrderCancelled'] = "Pedido anulado";
|
||||
$strings['use_currency_symbol'] = "Usar símbolo de la moneda";
|
||||
$strings['ExportReport'] = "Exportar reporte de ventas";
|
||||
$strings['OrderTime'] = "Fecha del pedido";
|
||||
$strings['SelectDateRange'] = "Seleccione una <strong>fecha de inicio</strong> y una <strong>fecha de fin</strong> para el reporte";
|
||||
$strings['ServiceAdded'] = "Servicio agregado";
|
||||
$strings['ServiceEdited'] = "Servicio editado";
|
||||
$strings['ListOfServicesOnSale'] = "Lista de servicios a la venta";
|
||||
$strings['AdditionalInfo'] = "Información adicional";
|
||||
$strings['culqi_enable'] = "Habilitar Culqi";
|
||||
$strings['CulqiConfig'] = "Configuración de CULQI:";
|
||||
$strings['InfoCulqiCredentials'] = "Para obtener las credenciales es necesario crearse una cuenta en Culqi e ingresar en modo desarrollo, copiar el código de comercio que se encuentra en su panel de control, luego ingresar al apartado de API Keys y generar la Key correspondiente para copiarla aquí";
|
||||
$strings['CommerceCode'] = "Codigo de comercio";
|
||||
$strings['NoTermsAndConditionsProvided'] = "Terminos y condiciones no establecidos";
|
||||
$strings['GlobalConfig'] = "Configuración global:";
|
||||
$strings['MyServices'] = "Mis servicios";
|
||||
$strings['SalePrice'] = "Precio de venta";
|
||||
$strings['YouNeedToBeRegisteredInAtLeastOneCourse'] = "Necesitas estar registrado en al menos un curso";
|
||||
$strings['YouNeedToBeRegisteredInAtLeastOneSession'] = "Necesitas estar registrado en al menos una sesión";
|
||||
$strings['IfYouWantToGetTheCertificateAndOrSkillsAsociatedToThisCourseYouNeedToBuyTheCertificateServiceYouCanGoToServiceCatalogClickingHere'] = "Si quieres obtener el certificado y/o las competencias asociadas a este curso, necesitas comprar el servicio de <b> Certificado </b>, puedes ir al catálogo de servicios para comprarlo haciendo click <a target='_blank' href='%s'>AQUÍ</a>";
|
||||
$strings['ServiceDeleted'] = 'Servicio eliminado';
|
||||
$strings['YourCoursesNeedAtLeastOneLearningPath'] = 'Los cursos en los que estás registrado necesitan tener al menos una lección que contenga un item de cerficado final';
|
||||
$strings['GlobalTaxPerc'] = "Porcentaje del impuesto global";
|
||||
$strings['GlobalTaxPercDescription'] = "Porcentaje por defecto que se usará, excepto si existe un impuesto específico en el curso, sesión o servicio.";
|
||||
$strings['TaxPerc'] = "Porcentaje del impuesto";
|
||||
$strings['TaxPercDescription'] = "Si se deja vacío se usará valor global por defecto.";
|
||||
$strings['ByDefault'] = "por defecto (valor global)";
|
||||
$strings['OnlyCourses'] = "Solo Cursos";
|
||||
$strings['OnlySessions'] = "Solo Sesiones";
|
||||
$strings['OnlyServices'] = "Solo Servicios";
|
||||
$strings['TaxAppliesTo'] = "Impuestos aplicados a";
|
||||
$strings['AllCoursesSessionsAndServices'] = "Todos (Cursos, sesiones y servicios)";
|
||||
$strings['TaxNameCustom'] = "Nombre del impuesto";
|
||||
$strings['TaxNameExamples'] = "VAT, IVA, IGV, TVA, IV ...";
|
||||
$strings['ErrorUpdateFieldDB'] = "Error al actualizar los campos de la base de datos";
|
||||
$strings['tpv_redsys_enable'] = "Habilitar TPV RedSys";
|
||||
$strings['tpv_redsys_enable_help'] = "Para poder utilizar la modalidad de pago del TPV de RedSys es necesario descargar los ficheros de \"INTEGRACIÓN REST - API PHP\" en el siguiente enlace <a href='https://pagosonline.redsys.es/descargas.html'>web de RedSys</a> y ubicar el fichero el fichero <strong>apiRedSys.php</strong> en el directorio <em>plugin/buycourses/resources</em>.";
|
||||
$strings['NotFindRedsysFile'] = "No se encuentra en el directorio <em>plugin/buycourses/resources</em> el fichero <strong>apiRedsys.php</strong>";
|
||||
$strings['TpvPayment'] = "Pago con tarjeta";
|
||||
$strings['TpvRedsysConfig'] = "Configuración TPV Redsys";
|
||||
$strings['DS_MERCHANT_MERCHANTCODE'] = "Número de comercio (FUC)";
|
||||
$strings['DS_MERCHANT_TERMINAL'] = "Número de terminal";
|
||||
$strings['DS_MERCHANT_CURRENCY'] = "Moneda del terminal";
|
||||
$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";
|
||||
$strings['Coupon'] = "Cupón";
|
||||
$strings['DiscountAmount'] = "Descuento total";
|
||||
$strings['RedeemCoupon'] = "Canjear";
|
||||
$strings['NeedToAddCouponCode'] = "No se ha introducido un código de cupón";
|
||||
$strings['CouponNotValid'] = "El cupón no es valido";
|
||||
$strings['CouponRedeemed'] = "Cupón canjeado";
|
||||
$strings['CouponDiscount'] = "Descuento";
|
||||
$strings['CouponStatus'] = "Estado cupón";
|
||||
$strings['CouponPercentage'] = "Porcentaje";
|
||||
$strings['CouponAmount'] = "Valor";
|
||||
$strings['CouponList'] = "Lista de cupones";
|
||||
$strings['CouponCode'] = "Código del cupón";
|
||||
$strings['CouponDiscountType'] = "Tipo de descuento";
|
||||
$strings['CouponDateStart'] = "Valido desde";
|
||||
$strings['CouponDateEnd'] = "Caduca el";
|
||||
$strings['CouponDelivered'] = "Canjeados";
|
||||
$strings['CouponDisable'] = "Desactivar";
|
||||
$strings['CouponEnable'] = "Activar";
|
||||
$strings['CouponCodeUsed'] = "Código de cupón ya usado";
|
||||
$strings['CouponNoExists'] = "El cupón no existe";
|
||||
$strings['CouponErrorInsert'] = "Error añadiendo nuevo cupón";
|
||||
$strings['CouponActive'] = "Activo";
|
||||
$strings['CouponDisabled'] = "Desactivado";
|
||||
$strings['CouponUpdate'] = "Cupón actualizado";
|
||||
$strings['CouponsConfiguration'] = "Configuración de cupones";
|
||||
$strings['CouponAdd'] = "Nuevo cupón";
|
||||
$strings['ConfigureCoupon'] = "Configurar cupón";
|
||||
$strings['DiscountCoupons'] = "Cupones descuento";
|
||||
$strings['CouponsCode'] = "Código";
|
||||
$strings['DoYouHaveACoupon'] = "¿Tienes un cupón?";
|
||||
$strings['stripe_enable'] = "Activar Stripe";
|
||||
$strings['StripeConfig'] = "Configuración de Stripe:";
|
||||
$strings['InfoStripeCredentials'] = "Para obtener las credenciales debes crear una cuenta en Stripe, copiar el id de cuenta de tu perfil, ir a la sección de configuración de las claves API y copiar la secret key, por último deberá registrar un nuevo Endpoint en la sección de webhooks a https://{site}/plugin/buycourses/src/stripe_response.php para el tipo de evento checkout.session.completed y copiar el secret del Endpoint.";
|
||||
$strings['StripeAccountId'] = "Id de la cuenta:";
|
||||
$strings['StripeSecret'] = "Secret key:";
|
||||
$strings['StripeEndpointSecret'] = "Endpoint secret:";
|
||||
$strings['PendingReasonByStripe'] = "<b>Pendiente</b>. Esperando confirmación del pago ...";
|
||||
$strings['cecabank_enable'] = "Habilitar TPV Cecabank";
|
||||
$strings['TpvCecabank'] = "Pago con tarjeta (Cecabank)";
|
||||
$strings['CecaSecret'] = "Secret";
|
||||
$strings['CecaUrl'] = "Url";
|
||||
$strings['CecaMerchanId'] = "Merchant";
|
||||
$strings['CecaAcquirerId'] = "Adquirer";
|
||||
$strings['CecaTerminalId'] = "Terminal";
|
||||
$strings['CecaCypher'] = "Cypher";
|
||||
$strings['CecaCurrency'] = "Moneda";
|
||||
$strings['CecaExponent'] = "Exponent";
|
||||
$strings['CecaSupportedPayment'] = "Pago soportado";
|
||||
$strings['CecabankConfig'] = "Configuración Cecabank";
|
||||
$strings['Country'] = "País";
|
||||
$strings['PaymentType'] = "Tipo de pago";
|
||||
$strings['CountryRelPaymentConfig'] = "Configuración del tipo de pago por país";
|
||||
$strings['CountryRelPaymentMessage'] = "Para realizar un pedido es necesario definir el tipo de pago por país, en caso contrario no se permite la realización del pedido";
|
||||
$strings['CountryEmpty'] = "Para realizar un pedido es necesario definir en el perfil del usuario el campo país";
|
||||
$strings['Duration'] = "Duración";
|
||||
$strings['SubscriptionAdd'] = "Añadir suscripción";
|
||||
$strings['SubscriptionList'] = "Lista de suscripciones";
|
||||
$strings['SubscriptionListOnSale'] = "Lista de suscripciones a la venta";
|
||||
$strings['SelectSubscription'] = "Seleciona duración";
|
||||
$strings['SubscriptionNotValid'] = "Suscripción no valida";
|
||||
$strings['SubscriptionSalesReport'] = "Reporte de ventas";
|
||||
$strings['BuySubscriptions'] = "Compra suscripciones";
|
||||
$strings['ConfigurationOfSubscriptionsAndPrices'] = "Configuración de suscripciones y precios";
|
||||
$strings['FrequencyConfig'] = "Configuración periodos";
|
||||
$strings['Subscriptions'] = "Suscripciones";
|
||||
$strings['HasSubscriptions'] = "Tiene suscripciones";
|
||||
$strings['FrequencyRemoved'] = "Periodo eliminado";
|
||||
$strings['SubscriptionPeriodOnUse'] = "Periodo de suscription en uso";
|
||||
$strings['FrequencyNotExits'] = "El periodo no existe";
|
||||
$strings['FrequencyIncorrect'] = "Periodo incorrecto";
|
||||
$strings['SubscriptionFrequencyValueDays'] = "Valor de la suscripción en días";
|
||||
$strings['FrequencyNotUpdated'] = "Periodo no actualizado";
|
||||
$strings['FrequencyNotSaved'] = "Periodo no guardado";
|
||||
$strings['NeedToAddDuration'] = "Hay que especificar una duración";
|
||||
$strings['SubscriptionNotValid'] = "Suscripción no valida";
|
||||
$strings['SelecSubscription'] = "Seleccione una suscripción";
|
||||
$strings['ConfigureSubscriptionsFrequencies'] = "Configurar los períodos de suscripciones";
|
||||
$strings['FrequencyAdd'] = "Agregar período";
|
||||
$strings['SubscriptionAlreadyExists'] = "La suscripción ya existe";
|
||||
$strings['SubscriptionPeriodDuration'] = "Duración de suscripción (en días)";
|
||||
$strings['Product'] = "Producto";
|
||||
$strings['YouProductIsActivatedYouCanNowAccessIt'] = "Tu producto esta activado y puedes ahora acceder a este.";
|
||||
$strings['hide_shopping_cart_from_course_catalogue'] = "Esconder el carito de compra del catalogo de curso y dejar el boton de subscripcion a curso";
|
||||
13
plugin/buycourses/plugin.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* This script is a configuration file for the date plugin. You can use it as a master for other platform plugins (course plugins are slightly different).
|
||||
* These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins).
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
/**
|
||||
* Plugin details (must be present).
|
||||
*/
|
||||
require_once __DIR__.'/config.php';
|
||||
$plugin_info = BuyCoursesPlugin::create()->get_info();
|
||||
421
plugin/buycourses/resources/css/style.css
Normal file
@@ -0,0 +1,421 @@
|
||||
.buy-courses-tabs {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.buy-courses-page-header {
|
||||
padding-bottom: 9px;
|
||||
margin: 40px 0 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.buy-courses-block-button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
line-height: 35px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.buy-courses-cross-out {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.buy-courses-title-color {
|
||||
color: #5DC3E1;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.buy-courses-description-service {
|
||||
text-align: justify;
|
||||
font-size: 18px;
|
||||
line-height: 1.42857;
|
||||
}
|
||||
|
||||
/* PROCESS BUY */
|
||||
.buy-info .price, .service-buy .price {
|
||||
font-size: 24px;
|
||||
line-height: 32px;
|
||||
font-weight: bold;
|
||||
padding-bottom: 10px;
|
||||
padding-top: 10px;
|
||||
letter-spacing: -0.020em;
|
||||
}
|
||||
|
||||
.buy-info .price-details-tax, .service-buy .price-details-tax {
|
||||
font-size: 18px;
|
||||
line-height: 24px;
|
||||
font-weight: bold;
|
||||
padding-bottom: 0px;
|
||||
padding-top: 10px;
|
||||
letter-spacing: -0.020em;
|
||||
}
|
||||
|
||||
.buy-info .buy-item .title {
|
||||
margin-top: 5px;
|
||||
font-weight: bold;
|
||||
line-height: 24px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.buy-info .buy-item .description, .buy-info .buy-item .coaches {
|
||||
margin-bottom: 20px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.buy-info .buy-item .list-description {
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.buy-info .buy-item .date {
|
||||
margin-bottom: 10px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.buy-info .coupon-question, .service-buy .coupon {
|
||||
font-size: 16px;
|
||||
line-height: 6px;
|
||||
font-weight: bold;
|
||||
padding-bottom: 10px;
|
||||
padding-top: 24px;
|
||||
letter-spacing: -0.020em;
|
||||
}
|
||||
|
||||
.buy-info .coupon, .service-buy .coupon {
|
||||
line-height: 32px;
|
||||
font-weight: bold;
|
||||
padding-bottom: 10px;
|
||||
padding-top: 10px;
|
||||
letter-spacing: -0.1em;
|
||||
}
|
||||
|
||||
.buy-summary {
|
||||
margin-top: 10px;
|
||||
border-top: 1px solid #CCCCCC;
|
||||
}
|
||||
|
||||
.panel-box-buy {
|
||||
box-shadow: 0 15px 30px rgba(0, 0, 0, .1);
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.buy-summary .alert-info {
|
||||
color: #31708f;
|
||||
background-color: #e8f2f8;
|
||||
border-color: #bce8f1;
|
||||
}
|
||||
|
||||
.btn.btn-default.btn-sm {
|
||||
white-space: unset;
|
||||
}
|
||||
|
||||
tr.sale-row {
|
||||
font-size: 12px;
|
||||
}
|
||||
tr.sale-columns {
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
background-color: #e6e6e6;
|
||||
}
|
||||
tr.sale-columns th{
|
||||
vertical-align: middle !important;
|
||||
text-align: center;
|
||||
}
|
||||
@-moz-keyframes wobblebar-loader {
|
||||
0% {
|
||||
left: 4px;
|
||||
}
|
||||
3% {
|
||||
left: 204px;
|
||||
}
|
||||
6% {
|
||||
left: 4px;
|
||||
}
|
||||
9% {
|
||||
left: 204px;
|
||||
}
|
||||
12% {
|
||||
left: 4px;
|
||||
}
|
||||
15% {
|
||||
left: 204px;
|
||||
}
|
||||
18% {
|
||||
left: 32px;
|
||||
}
|
||||
27% {
|
||||
left: 32px;
|
||||
}
|
||||
30% {
|
||||
left: 204px;
|
||||
}
|
||||
33% {
|
||||
left: 4px;
|
||||
}
|
||||
36% {
|
||||
left: 204px;
|
||||
}
|
||||
39% {
|
||||
left: 4px;
|
||||
}
|
||||
42% {
|
||||
left: 204px;
|
||||
}
|
||||
45% {
|
||||
left: 4px;
|
||||
}
|
||||
48% {
|
||||
left: 204px;
|
||||
}
|
||||
51% {
|
||||
left: 152px;
|
||||
}
|
||||
63% {
|
||||
left: 152px;
|
||||
}
|
||||
66% {
|
||||
left: 4px;
|
||||
}
|
||||
69% {
|
||||
left: 204px;
|
||||
}
|
||||
72% {
|
||||
left: 4px;
|
||||
}
|
||||
75% {
|
||||
left: 204px;
|
||||
}
|
||||
78% {
|
||||
left: 4px;
|
||||
}
|
||||
81% {
|
||||
left: 204px;
|
||||
}
|
||||
84% {
|
||||
left: 72px;
|
||||
}
|
||||
94% {
|
||||
left: 72px;
|
||||
}
|
||||
97% {
|
||||
left: 204px;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes wobblebar-loader {
|
||||
0% {
|
||||
left: 4px;
|
||||
}
|
||||
3% {
|
||||
left: 204px;
|
||||
}
|
||||
6% {
|
||||
left: 4px;
|
||||
}
|
||||
9% {
|
||||
left: 204px;
|
||||
}
|
||||
12% {
|
||||
left: 4px;
|
||||
}
|
||||
15% {
|
||||
left: 204px;
|
||||
}
|
||||
18% {
|
||||
left: 32px;
|
||||
}
|
||||
27% {
|
||||
left: 32px;
|
||||
}
|
||||
30% {
|
||||
left: 204px;
|
||||
}
|
||||
33% {
|
||||
left: 4px;
|
||||
}
|
||||
36% {
|
||||
left: 204px;
|
||||
}
|
||||
39% {
|
||||
left: 4px;
|
||||
}
|
||||
42% {
|
||||
left: 204px;
|
||||
}
|
||||
45% {
|
||||
left: 4px;
|
||||
}
|
||||
48% {
|
||||
left: 204px;
|
||||
}
|
||||
51% {
|
||||
left: 152px;
|
||||
}
|
||||
63% {
|
||||
left: 152px;
|
||||
}
|
||||
66% {
|
||||
left: 4px;
|
||||
}
|
||||
69% {
|
||||
left: 204px;
|
||||
}
|
||||
72% {
|
||||
left: 4px;
|
||||
}
|
||||
75% {
|
||||
left: 204px;
|
||||
}
|
||||
78% {
|
||||
left: 4px;
|
||||
}
|
||||
81% {
|
||||
left: 204px;
|
||||
}
|
||||
84% {
|
||||
left: 72px;
|
||||
}
|
||||
94% {
|
||||
left: 72px;
|
||||
}
|
||||
97% {
|
||||
left: 204px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes wobblebar-loader {
|
||||
0% {
|
||||
left: 4px;
|
||||
}
|
||||
3% {
|
||||
left: 204px;
|
||||
}
|
||||
6% {
|
||||
left: 4px;
|
||||
}
|
||||
9% {
|
||||
left: 204px;
|
||||
}
|
||||
12% {
|
||||
left: 4px;
|
||||
}
|
||||
15% {
|
||||
left: 204px;
|
||||
}
|
||||
18% {
|
||||
left: 32px;
|
||||
}
|
||||
27% {
|
||||
left: 32px;
|
||||
}
|
||||
30% {
|
||||
left: 204px;
|
||||
}
|
||||
33% {
|
||||
left: 4px;
|
||||
}
|
||||
36% {
|
||||
left: 204px;
|
||||
}
|
||||
39% {
|
||||
left: 4px;
|
||||
}
|
||||
42% {
|
||||
left: 204px;
|
||||
}
|
||||
45% {
|
||||
left: 4px;
|
||||
}
|
||||
48% {
|
||||
left: 204px;
|
||||
}
|
||||
51% {
|
||||
left: 152px;
|
||||
}
|
||||
63% {
|
||||
left: 152px;
|
||||
}
|
||||
66% {
|
||||
left: 4px;
|
||||
}
|
||||
69% {
|
||||
left: 204px;
|
||||
}
|
||||
72% {
|
||||
left: 4px;
|
||||
}
|
||||
75% {
|
||||
left: 204px;
|
||||
}
|
||||
78% {
|
||||
left: 4px;
|
||||
}
|
||||
81% {
|
||||
left: 204px;
|
||||
}
|
||||
84% {
|
||||
left: 72px;
|
||||
}
|
||||
94% {
|
||||
left: 72px;
|
||||
}
|
||||
97% {
|
||||
left: 204px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Landscape phones and down */
|
||||
@media (max-width: 480px) {
|
||||
.panel-box-buy {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.buy-summary .pull-right {
|
||||
float: left !important;
|
||||
}
|
||||
|
||||
.buy-summary .btn-success {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* :not(:required) hides this rule from IE9 and below */
|
||||
.wobblebar-loader:not(:required) {
|
||||
background: #2E6DA4;
|
||||
-moz-border-radius: 10.66667px;
|
||||
-webkit-border-radius: 10.66667px;
|
||||
border-radius: 10.66667px;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-indent: -9999px;
|
||||
width: 228px;
|
||||
height: 21.33333px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.wobblebar-loader:not(:required)::after {
|
||||
-moz-animation: wobblebar-loader 15000ms infinite ease;
|
||||
-webkit-animation: wobblebar-loader 15000ms infinite ease;
|
||||
animation: wobblebar-loader 15000ms infinite ease;
|
||||
background: white;
|
||||
display: block;
|
||||
-moz-border-radius: 7.11111px;
|
||||
-webkit-border-radius: 7.11111px;
|
||||
border-radius: 7.11111px;
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 3.55556px;
|
||||
left: 4px;
|
||||
width: 21.33333px;
|
||||
height: 14.22222px;
|
||||
}
|
||||
|
||||
div.items-course-info h4.title {
|
||||
font-weight: bold;
|
||||
height: 2.8em;
|
||||
}
|
||||
|
||||
@media (min-width: 991px) {
|
||||
.col-sm-6 .items-course .items-course-image figure {
|
||||
max-height: 135px;
|
||||
}
|
||||
}
|
||||
BIN
plugin/buycourses/resources/img/128/backlogs.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
plugin/buycourses/resources/img/128/buycourses.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
plugin/buycourses/resources/img/128/buysubscriptions.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
plugin/buycourses/resources/img/128/discount.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
plugin/buycourses/resources/img/128/paymentsettings.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
plugin/buycourses/resources/img/128/settings.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
plugin/buycourses/resources/img/128/subscriptionssettings.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
plugin/buycourses/resources/img/32/backlogs.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
plugin/buycourses/resources/img/32/buycourses.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
plugin/buycourses/resources/img/32/buysubscription.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
plugin/buycourses/resources/img/32/buysubscriptions.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
plugin/buycourses/resources/img/32/discount.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
plugin/buycourses/resources/img/32/paymentsettings.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
plugin/buycourses/resources/img/32/settings.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
plugin/buycourses/resources/img/32/subscriptionsettings.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
plugin/buycourses/resources/img/32/subscriptionssettings.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
plugin/buycourses/resources/img/42/backlogs.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
plugin/buycourses/resources/img/42/buycourses.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
plugin/buycourses/resources/img/42/buysubscriptions.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
plugin/buycourses/resources/img/42/discount.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
plugin/buycourses/resources/img/42/paymentsettings.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
plugin/buycourses/resources/img/42/settings.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
plugin/buycourses/resources/img/42/subscriptionssettings.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
plugin/buycourses/resources/img/64/backlogs.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
plugin/buycourses/resources/img/64/buycourses.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
plugin/buycourses/resources/img/64/buysubscriptions.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
plugin/buycourses/resources/img/64/discount.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
plugin/buycourses/resources/img/64/paymentsettings.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
plugin/buycourses/resources/img/64/settings.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
plugin/buycourses/resources/img/64/subscriptionssettings.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
145
plugin/buycourses/resources/js/commissions.js
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
function showSliders(maxPercentage, type, defaultValues) {
|
||||
|
||||
defaultValues = defaultValues || "0";
|
||||
|
||||
var sliderCounter = 1;
|
||||
var percentage = 0;
|
||||
var minPercentage = 0;
|
||||
|
||||
$("#selectBox option:selected").each(function() {
|
||||
|
||||
var count = $("#selectBox option:selected").length;
|
||||
|
||||
percentage = maxPercentage / count;
|
||||
percentage = parseInt(percentage);
|
||||
|
||||
verifyMaxPercentage = percentage * count;
|
||||
if (verifyMaxPercentage !== maxPercentage && sliderCounter === 1) {
|
||||
percentage = percentage + (maxPercentage - verifyMaxPercentage);
|
||||
}
|
||||
|
||||
beneficiaryId = $(this).val();
|
||||
beneficiaryName = $(this).text();
|
||||
|
||||
var verify;
|
||||
|
||||
var slidersValue = defaultValues.toString().split(',');
|
||||
|
||||
if (type === 'default') {
|
||||
|
||||
percentage = slidersValue[sliderCounter - 1];
|
||||
percentage = parseInt(percentage);
|
||||
$("#panelSliders").append("<span id=" + beneficiaryId + ">" + beneficiaryName + "</span> - [ <span class='value' >" + percentage + "</span> % ] <div class='panelSliders'></div>");
|
||||
|
||||
} else if (type === 'renew') {
|
||||
|
||||
$("#panelSliders").append("<span id=" + beneficiaryId + " >" + beneficiaryName + "</span> - [ <span class='value' >" + percentage + "</span> % ] <div class='panelSliders'></div>");
|
||||
|
||||
}
|
||||
|
||||
verifyPaypalAccountByBeneficiary(beneficiaryId);
|
||||
|
||||
sliderCounter++;
|
||||
stepSlide = count - 1;
|
||||
|
||||
if (stepSlide === 0) {
|
||||
(type === 'default') ? minPercentage = 0 : minPercentage = 100;
|
||||
(type === 'default') ? stepSlide = 100 : stepSlide = 1;
|
||||
}
|
||||
|
||||
|
||||
$( "#panelSliders .panelSliders" ).slider({
|
||||
value: percentage,
|
||||
min: minPercentage,
|
||||
max: maxPercentage,
|
||||
step: stepSlide,
|
||||
animate: true,
|
||||
slide: function( event, ui ) {
|
||||
|
||||
$(this).prev(".value").text(ui.value);
|
||||
|
||||
var total = 0;
|
||||
var sliders = $( "#panelSliders .panelSliders" );
|
||||
|
||||
sliders.not(this).each(function() {
|
||||
value = $(this).slider("option", "value");
|
||||
total += value;
|
||||
});
|
||||
|
||||
total += ui.value;
|
||||
var delta = 100 - total;
|
||||
|
||||
sliders.not(this).each(function() {
|
||||
|
||||
var t = $(this);
|
||||
value = t.slider("option", "value");
|
||||
|
||||
var newValue = value + (delta/stepSlide);
|
||||
|
||||
if (newValue < 0 || ui.value == 100)
|
||||
newValue = 0;
|
||||
if (newValue > 100)
|
||||
newValue = 100;
|
||||
|
||||
t.prev('.value').text(newValue);
|
||||
t.slider('value', newValue);
|
||||
|
||||
});
|
||||
|
||||
$("[name=\'commissions\']").val(getSlidersValues());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("[name=\'commissions\']").val(getSlidersValues());
|
||||
showCorrectSliderHandler();
|
||||
};
|
||||
|
||||
function getSlidersValues() {
|
||||
var commissions = "";
|
||||
|
||||
$( "#panelSliders .panelSliders" ).each(function() {
|
||||
commissions += $(this).prev(".value").text() + ',';
|
||||
});
|
||||
|
||||
commissions = commissions.substring(0, commissions.length-1);
|
||||
|
||||
return commissions;
|
||||
}
|
||||
|
||||
function showCorrectSliderHandler() {
|
||||
var correctHandler = [];
|
||||
|
||||
$("#panelSliders > span").each(function () {
|
||||
if ($(this).hasClass('value')) {
|
||||
correctHandler.push($(this).text());
|
||||
}
|
||||
});
|
||||
|
||||
var counter = 0;
|
||||
|
||||
$("#panelSliders .panelSliders > span").each(function () {
|
||||
if ($(this).hasClass('ui-slider-handle')) {
|
||||
$(this).css('left', correctHandler[counter]+'%');
|
||||
counter++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function verifyPaypalAccountByBeneficiary(userId) {
|
||||
|
||||
return $.ajax({
|
||||
data: 'id='+userId,
|
||||
url: 'buycourses.ajax.php?a=verifyPaypal',
|
||||
type: 'POST',
|
||||
success: function(response) {
|
||||
$("#"+userId).append(' '+response);
|
||||
}
|
||||
});
|
||||
}
|
||||
1
plugin/buycourses/resources/js/modals.js
Normal file
6146
plugin/buycourses/src/buy_course_plugin.class.php
Normal file
612
plugin/buycourses/src/buycourses.ajax.php
Normal file
@@ -0,0 +1,612 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Chamilo\CoreBundle\Entity\Course;
|
||||
use Chamilo\CoreBundle\Entity\Session;
|
||||
use Chamilo\CourseBundle\Entity\CLp;
|
||||
use Chamilo\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Responses to AJAX calls.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
if (api_is_anonymous()) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$culqiEnable = $plugin->get('culqi_enable');
|
||||
$action = isset($_GET['a']) ? $_GET['a'] : null;
|
||||
|
||||
$em = Database::getManager();
|
||||
|
||||
switch ($action) {
|
||||
case 'verifyPaypal':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$userId = isset($_POST['id']) ? (int) $_POST['id'] : '';
|
||||
$isUserHavePaypalAccount = $plugin->verifyPaypalAccountByBeneficiary($userId);
|
||||
if ($isUserHavePaypalAccount) {
|
||||
echo '';
|
||||
} else {
|
||||
echo '<b style="color: red; font-size: 70%;">* '.$plugin->get_lang('NoPayPalAccountDetected').'</b>';
|
||||
}
|
||||
break;
|
||||
case 'saleInfo':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$saleId = isset($_POST['id']) ? (int) $_POST['id'] : '';
|
||||
$sale = $plugin->getSale($saleId);
|
||||
$productType = $sale['product_type'] == 1 ? get_lang('Course') : get_lang('Session');
|
||||
$paymentType = $sale['payment_type'] == 1 ? 'Paypal' : $plugin->get_lang('BankTransfer');
|
||||
$productInfo = $sale['product_type'] == 1
|
||||
? api_get_course_info_by_id($sale['product_id'])
|
||||
: api_get_session_info($sale['product_id']);
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
if ($sale['product_type'] == 1) {
|
||||
$productImage = $productInfo['course_image_large'];
|
||||
} else {
|
||||
$productImage = ($productInfo['image'])
|
||||
? $productInfo['image']
|
||||
: Template::get_icon_path('session_default.png');
|
||||
}
|
||||
|
||||
$userInfo = api_get_user_info($sale['user_id']);
|
||||
|
||||
$html = '<h2>'.$sale['product_name'].'</h2>';
|
||||
$html .= '<div class="row">';
|
||||
$html .= '<div class="col-sm-6 col-md-6">';
|
||||
$html .= '<ul>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('OrderPrice').':</b> '.$sale['total_price'].'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('CurrencyType').':</b> '.$currency['iso_code'].'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('ProductType').':</b> '.$productType.'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('OrderDate').':</b> '.
|
||||
api_format_date(
|
||||
$sale['date'],
|
||||
DATE_TIME_FORMAT_LONG_24H
|
||||
).'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('Buyer').':</b> '.$userInfo['complete_name'].'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('PaymentMethods').':</b> '.$paymentType.'</li>';
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="col-sm-6 col-md-6">';
|
||||
$html .= '<img class="thumbnail" src="'.$productImage.'" >';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
echo $html;
|
||||
break;
|
||||
case 'stats':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$stats = [];
|
||||
$stats['completed_count'] = 0;
|
||||
$stats['completed_total_amount'] = 0;
|
||||
$stats['pending_count'] = 0;
|
||||
$stats['pending_total_amount'] = 0;
|
||||
$stats['canceled_count'] = 0;
|
||||
$stats['canceled_total_amount'] = 0;
|
||||
|
||||
$completedPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED);
|
||||
$pendingPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING);
|
||||
$canceledPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_CANCELED);
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
foreach ($completedPayouts as $completed) {
|
||||
$stats['completed_count'] = count($completedPayouts);
|
||||
$stats['completed_total_amount'] += $completed['commission'];
|
||||
$stats['completed_total_amount'] = number_format($stats['completed_total_amount'], 2);
|
||||
}
|
||||
|
||||
foreach ($pendingPayouts as $pending) {
|
||||
$stats['pending_count'] = count($pendingPayouts);
|
||||
$stats['pending_total_amount'] += $pending['commission'];
|
||||
$stats['pending_total_amount'] = number_format($stats['pending_total_amount'], 2);
|
||||
}
|
||||
|
||||
foreach ($canceledPayouts as $canceled) {
|
||||
$stats['canceled_count'] = count($canceledPayouts);
|
||||
$stats['canceled_total_amount'] += $canceled['commission'];
|
||||
$stats['canceled_total_amount'] = number_format($stats['canceled_total_amount'], 2);
|
||||
}
|
||||
|
||||
$html = '<div class="row">'
|
||||
.'<p>'
|
||||
.'<ul>'
|
||||
.'<li>'.get_plugin_lang("PayoutsTotalCompleted", "BuyCoursesPlugin").' <b>'.$stats['completed_count']
|
||||
.'</b> - '.get_plugin_lang("TotalAmount", "BuyCoursesPlugin").' <b>'.$stats['completed_total_amount'].' '
|
||||
.$currency['iso_code'].'</b></li>'
|
||||
.'<li>'.get_plugin_lang("PayoutsTotalPending", "BuyCoursesPlugin").' <b>'.$stats['pending_count'].'</b> - '
|
||||
.get_plugin_lang("TotalAmount", "BuyCoursesPlugin").' <b>'.$stats['pending_total_amount'].' '
|
||||
.$currency['iso_code'].'</b></li>'
|
||||
.'<li>'.get_plugin_lang("PayoutsTotalCanceled", "BuyCoursesPlugin").' <b>'.$stats['canceled_count']
|
||||
.'</b> - '.get_plugin_lang("TotalAmount", "BuyCoursesPlugin").' <b>'.$stats['canceled_total_amount'].' '
|
||||
.$currency['iso_code'].'</b></li>'
|
||||
.'</ul>'
|
||||
.'</p>';
|
||||
$html .= '</div>';
|
||||
echo $html;
|
||||
break;
|
||||
case 'processPayout':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$html = '';
|
||||
$allPays = [];
|
||||
$totalAccounts = 0;
|
||||
$totalPayout = 0;
|
||||
|
||||
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : '';
|
||||
|
||||
if (!$payouts) {
|
||||
echo Display::return_message(
|
||||
get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"),
|
||||
'error',
|
||||
false
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($payouts as $index => $id) {
|
||||
$allPays[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id);
|
||||
}
|
||||
|
||||
foreach ($allPays as $payout) {
|
||||
$totalPayout += number_format($payout['commission'], 2);
|
||||
$totalAccounts++;
|
||||
}
|
||||
|
||||
$currentCurrency = $plugin->getSelectedCurrency();
|
||||
$isoCode = $currentCurrency['iso_code'];
|
||||
$html .= '<p>'.get_plugin_lang("VerifyTotalAmountToProceedPayout", "BuyCoursesPlugin").'</p>';
|
||||
$html .= ''
|
||||
.'<p>'
|
||||
.'<ul>'
|
||||
.'<li>'.get_plugin_lang("TotalAcounts", "BuyCoursesPlugin").' <b>'.$totalAccounts.'</b></li>'
|
||||
.'<li>'.get_plugin_lang("TotalPayout", "BuyCoursesPlugin").' <b>'.$isoCode.' '.$totalPayout.'</b></li>'
|
||||
.'</ul>'
|
||||
.'</p>';
|
||||
$html .= '<p>'.get_plugin_lang("CautionThisProcessCantBeCanceled", "BuyCoursesPlugin").'</p>';
|
||||
$html .= '<br /><br />';
|
||||
$html .= '<div id="spinner" class="text-center"></div>';
|
||||
|
||||
echo $html;
|
||||
break;
|
||||
case 'proceedPayout':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$paypalParams = $plugin->getPaypalParams();
|
||||
|
||||
$pruebas = $paypalParams['sandbox'] == 1;
|
||||
$paypalUsername = $paypalParams['username'];
|
||||
$paypalPassword = $paypalParams['password'];
|
||||
$paypalSignature = $paypalParams['signature'];
|
||||
|
||||
require_once "paypalfunctions.php";
|
||||
|
||||
$allPayouts = [];
|
||||
$totalAccounts = 0;
|
||||
$totalPayout = 0;
|
||||
|
||||
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : '';
|
||||
|
||||
if (!$payouts) {
|
||||
echo Display::return_message(
|
||||
get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"),
|
||||
'error',
|
||||
false
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($payouts as $index => $id) {
|
||||
$allPayouts[] = $plugin->getPayouts(
|
||||
BuyCoursesPlugin::PAYOUT_STATUS_PENDING,
|
||||
$id
|
||||
);
|
||||
}
|
||||
|
||||
$currentCurrency = $plugin->getSelectedCurrency();
|
||||
$isoCode = $currentCurrency['iso_code'];
|
||||
$result = MassPayment($allPayouts, $isoCode);
|
||||
if ($result['ACK'] === 'Success') {
|
||||
foreach ($allPayouts as $payout) {
|
||||
$plugin->setStatusPayouts(
|
||||
$payout['id'],
|
||||
BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED
|
||||
);
|
||||
if ($plugin->get('invoicing_enable') === 'true') {
|
||||
$plugin->setInvoice($payout['id']);
|
||||
}
|
||||
}
|
||||
|
||||
echo Display::return_message(
|
||||
get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"),
|
||||
'success',
|
||||
false
|
||||
);
|
||||
} else {
|
||||
echo Display::return_message(
|
||||
'<b>'.$result['L_SEVERITYCODE0'].' '.$result['L_ERRORCODE0'].'</b> - '.$result['L_SHORTMESSAGE0']
|
||||
.'<br /><ul><li>'.$result['L_LONGMESSAGE0'].'</li></ul>',
|
||||
'error',
|
||||
false
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'cancelPayout':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
// $payoutId only gets used in setStatusPayout(), where it is filtered
|
||||
$payoutId = isset($_POST['id']) ? $_POST['id'] : '';
|
||||
$plugin->setStatusPayouts(
|
||||
$payoutId,
|
||||
BuyCoursesPlugin::PAYOUT_STATUS_CANCELED
|
||||
);
|
||||
|
||||
echo '';
|
||||
|
||||
break;
|
||||
case 'culqi_cargo':
|
||||
if (!$culqiEnable) {
|
||||
break;
|
||||
}
|
||||
|
||||
$tokenId = $_REQUEST['token_id'];
|
||||
$saleId = $_REQUEST['sale_id'];
|
||||
|
||||
if (!$tokenId || !$saleId) {
|
||||
break;
|
||||
}
|
||||
$sale = $plugin->getSale($saleId);
|
||||
if (!$sale) {
|
||||
break;
|
||||
}
|
||||
|
||||
require_once 'Requests.php';
|
||||
Requests::register_autoloader();
|
||||
require_once 'culqi.php';
|
||||
|
||||
$culqiParams = $plugin->getCulqiParams();
|
||||
|
||||
// API Key y autenticación
|
||||
$SECRET_API_KEY = $culqiParams['api_key'];
|
||||
$culqi = new Culqi\Culqi(['api_key' => $SECRET_API_KEY]);
|
||||
|
||||
$environment = $culqiParams['integration'];
|
||||
$environment = $environment
|
||||
? BuyCoursesPlugin::CULQI_INTEGRATION_TYPE
|
||||
: BuyCoursesPlugin::CULQI_PRODUCTION_TYPE;
|
||||
|
||||
$culqi->setEnv($environment);
|
||||
|
||||
$user = api_get_user_info();
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
try {
|
||||
$cargo = $culqi->Cargos->create([
|
||||
"moneda" => $currency['iso_code'],
|
||||
"monto" => intval(floatval($sale['price']) * 100),
|
||||
"usuario" => $user['username'],
|
||||
"descripcion" => $sale['product_name'],
|
||||
"pedido" => $sale['reference'],
|
||||
"codigo_pais" => "PE",
|
||||
"direccion" => get_lang('None'),
|
||||
"ciudad" => get_lang('None'),
|
||||
"telefono" => 0,
|
||||
"nombres" => $user['firstname'],
|
||||
"apellidos" => $user['lastname'],
|
||||
"correo_electronico" => $user['email'],
|
||||
"token" => $tokenId,
|
||||
]);
|
||||
|
||||
if (is_object($cargo)) {
|
||||
$saleIsCompleted = $plugin->completeSale($sale['id']);
|
||||
|
||||
if ($saleIsCompleted) {
|
||||
Display::addFlash(
|
||||
$plugin->getSubscriptionSuccessMessage($sale)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($cargo);
|
||||
} catch (Exception $e) {
|
||||
$cargo = json_decode($e->getMessage(), true);
|
||||
$plugin->cancelSale($sale['id']);
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
if (is_array($cargo)) {
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
sprintf($plugin->get_lang('ErrorOccurred'), $cargo['codigo'], $cargo['mensaje']),
|
||||
'error',
|
||||
false
|
||||
)
|
||||
);
|
||||
} else {
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('ErrorContactPlatformAdmin'),
|
||||
'error',
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'culqi_cargo_service':
|
||||
if (!$culqiEnable) {
|
||||
break;
|
||||
}
|
||||
|
||||
$tokenId = $_REQUEST['token_id'];
|
||||
$serviceSaleId = $_REQUEST['service_sale_id'];
|
||||
|
||||
if (!$tokenId || !$serviceSaleId) {
|
||||
break;
|
||||
}
|
||||
|
||||
$serviceSale = $plugin->getServiceSale($serviceSaleId);
|
||||
|
||||
if (!$serviceSale) {
|
||||
break;
|
||||
}
|
||||
|
||||
require_once 'Requests.php';
|
||||
Requests::register_autoloader();
|
||||
require_once 'culqi.php';
|
||||
$culqiParams = $plugin->getCulqiParams();
|
||||
|
||||
// API Key y autenticación
|
||||
$SECRET_API_KEY = $culqiParams['api_key'];
|
||||
$culqi = new Culqi\Culqi(['api_key' => $SECRET_API_KEY]);
|
||||
|
||||
$environment = $culqiParams['integration'];
|
||||
$environment = $environment
|
||||
? BuyCoursesPlugin::CULQI_INTEGRATION_TYPE
|
||||
: BuyCoursesPlugin::CULQI_PRODUCTION_TYPE;
|
||||
|
||||
$culqi->setEnv($environment);
|
||||
$user = api_get_user_info();
|
||||
|
||||
try {
|
||||
$cargo = $culqi->Cargos->create([
|
||||
"moneda" => $serviceSale['currency'],
|
||||
"monto" => intval(floatval($serviceSale['price']) * 100),
|
||||
"usuario" => $user['username'],
|
||||
"descripcion" => $serviceSale['service']['name'],
|
||||
"pedido" => $serviceSale['reference'],
|
||||
"codigo_pais" => "PE",
|
||||
"direccion" => get_lang('None'),
|
||||
"ciudad" => get_lang('None'),
|
||||
"telefono" => 0,
|
||||
"nombres" => $user['firstname'],
|
||||
"apellidos" => $user['lastname'],
|
||||
"correo_electronico" => $user['email'],
|
||||
"token" => $tokenId,
|
||||
]);
|
||||
|
||||
if (is_object($cargo)) {
|
||||
$saleIsCompleted = $plugin->completeServiceSale($serviceSale['id']);
|
||||
if ($saleIsCompleted) {
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
sprintf(
|
||||
$plugin->get_lang('SubscriptionToCourseXSuccessful'),
|
||||
$serviceSale['service']['name']
|
||||
),
|
||||
'success'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($cargo);
|
||||
} catch (Exception $e) {
|
||||
$cargo = json_decode($e->getMessage(), true);
|
||||
$plugin->cancelServiceSale($serviceSale['id']);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
|
||||
if (is_array($cargo)) {
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
sprintf($plugin->get_lang('ErrorOccurred'), $cargo['codigo'], $cargo['mensaje']),
|
||||
'error',
|
||||
false
|
||||
)
|
||||
);
|
||||
} else {
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('ErrorContactPlatformAdmin'),
|
||||
'error',
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'service_sale_info':
|
||||
$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
|
||||
$serviceSale = $plugin->getServiceSale($id);
|
||||
$isAdmin = api_is_platform_admin();
|
||||
if (!$serviceSale) {
|
||||
break;
|
||||
}
|
||||
|
||||
$ajaxCallFile = $plugin->getPath('SRC').'buycourses.ajax.php';
|
||||
$serviceImg = $plugin->getPath('SERVICE_IMAGES').$serviceSale['service']['image'];
|
||||
$html = "<img class='img-responsive text-center' src='$serviceImg'>";
|
||||
$html .= "<br />";
|
||||
$html .= "<legend>{$plugin->get_lang('ServiceInformation')}</legend>";
|
||||
$html .= "<ul>";
|
||||
$html .= "<li><b>{$plugin->get_lang('ServiceName')}:</b> {$serviceSale['service']['name']}</li> ";
|
||||
$html .= "<li><b>{$plugin->get_lang('Description')}:</b> {$serviceSale['service']['description']}</li> ";
|
||||
$nodeType = $serviceSale['node_type'];
|
||||
$nodeName = '';
|
||||
if ($nodeType == BuyCoursesPlugin::SERVICE_TYPE_USER) {
|
||||
$nodeType = get_lang('User');
|
||||
/** @var User $user */
|
||||
$user = UserManager::getManager()->find($serviceSale['node_id']);
|
||||
$nodeName = $user ? $user->getCompleteNameWithUsername() : null;
|
||||
} else {
|
||||
if ($nodeType == BuyCoursesPlugin::SERVICE_TYPE_COURSE) {
|
||||
$nodeType = get_lang('Course');
|
||||
/** @var Course $course */
|
||||
$course = $em->find('ChamiloCoreBundle:Course', $serviceSale['node_id']);
|
||||
$nodeName = $course ? $course->getTitle() : null;
|
||||
} else {
|
||||
if ($nodeType == BuyCoursesPlugin::SERVICE_TYPE_SESSION) {
|
||||
$nodeType = get_lang('Session');
|
||||
/** @var Session $session */
|
||||
$session = $em->find('ChamiloCoreBundle:Session', $serviceSale['node_id']);
|
||||
$nodeName = $session ? $session->getName() : null;
|
||||
} else {
|
||||
if ($nodeType == BuyCoursesPlugin::SERVICE_TYPE_LP_FINAL_ITEM) {
|
||||
$nodeType = get_lang('TemplateTitleCertificate');
|
||||
/** @var CLp $lp */
|
||||
$lp = $em->find('ChamiloCourseBundle:CLp', $serviceSale['node_id']);
|
||||
$nodeName = $lp ? $lp->getName() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$html .= "</ul>";
|
||||
$html .= "<legend>{$plugin->get_lang('SaleInfo')}</legend>";
|
||||
$html .= "<ul>";
|
||||
$html .= "<li><b>{$plugin->get_lang('BoughtBy')}:</b> {$serviceSale['buyer']['name']}</li> ";
|
||||
$html .= "<li><b>{$plugin->get_lang('PurchaserUser')}:</b> {$serviceSale['buyer']['username']}</li> ";
|
||||
$html .= "<li><b>{$plugin->get_lang('Total')}:</b> {$serviceSale['service']['total_price']}</li> ";
|
||||
$orderDate = api_format_date($serviceSale['buy_date'], DATE_FORMAT_LONG);
|
||||
$html .= "<li><b>{$plugin->get_lang('OrderDate')}:</b> $orderDate</li> ";
|
||||
$paymentType = $serviceSale['payment_type'];
|
||||
if ($paymentType == BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL) {
|
||||
$paymentType = 'PayPal';
|
||||
} else {
|
||||
if ($paymentType == BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER) {
|
||||
$paymentType = $plugin->get_lang('BankTransfer');
|
||||
} else {
|
||||
if ($paymentType == BuyCoursesPlugin::PAYMENT_TYPE_CULQI) {
|
||||
$paymentType = 'Culqi';
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= "<li><b>{$plugin->get_lang('PaymentMethod')}:</b> $paymentType</li> ";
|
||||
$status = $serviceSale['status'];
|
||||
$buttons = '';
|
||||
if ($status == BuyCoursesPlugin::SERVICE_STATUS_COMPLETED) {
|
||||
$status = $plugin->get_lang('Active');
|
||||
} else {
|
||||
if ($status == BuyCoursesPlugin::SERVICE_STATUS_PENDING) {
|
||||
$status = $plugin->get_lang('Pending');
|
||||
if ($isAdmin) {
|
||||
$buttons .= "<a id='{$serviceSale['id']}' tag='service_sale_confirm' class='btn btn-success pull-left'>{$plugin->get_lang('ConfirmOrder')}</a>";
|
||||
$buttons .= "<a id='{$serviceSale['id']}' tag='service_sale_cancel' class='btn btn-danger pull-right'>{$plugin->get_lang('CancelOrder')}</a>";
|
||||
}
|
||||
} else {
|
||||
if ($status == BuyCoursesPlugin::SERVICE_STATUS_CANCELLED) {
|
||||
$status = $plugin->get_lang('Cancelled');
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= "<li><b>{$plugin->get_lang('Status')}:</b> $status</li> ";
|
||||
$html .= "</ul>";
|
||||
$html .= "<br />";
|
||||
$html .= "<div class='row'>";
|
||||
$html .= "<div class='col-md-2'></div>";
|
||||
$html .= "<div class='col-md-8 text-center'>";
|
||||
$html .= "<div class='bc-action-buttons'>";
|
||||
$html .= $buttons;
|
||||
$html .= "</div>";
|
||||
$html .= "</div>";
|
||||
$html .= "<div class='col-md-2'></div>";
|
||||
$html .= "<script>";
|
||||
$html .= "$('.bc-action-buttons a').click(function() {";
|
||||
$html .= "var id = $(this).attr('id');";
|
||||
$html .= "var action = $(this).attr('tag');";
|
||||
$html .= "$.ajax({";
|
||||
$html .= "data: 'id='+id,";
|
||||
$html .= "url: '$ajaxCallFile?a='+action,";
|
||||
$html .= "type: 'POST',";
|
||||
$html .= "beforeSend: function() {";
|
||||
$processingLoaderText = $plugin->get_lang('ProcessingDontCloseThisWindow');
|
||||
$html .= "$('.bootbox-close-button').remove();";
|
||||
$html .= "$('.btn-default').attr('disabled', true);";
|
||||
$html .= "$('.bc-action-buttons').html('<div class=\"wobblebar-loader\"></div><p> $processingLoaderText</p>');";
|
||||
$html .= "},";
|
||||
$html .= "success: function(response) {";
|
||||
$html .= "$('.bc-action-buttons').html(response);";
|
||||
$html .= "},";
|
||||
$html .= "});";
|
||||
$html .= "});";
|
||||
$html .= "</script>";
|
||||
|
||||
echo $html;
|
||||
break;
|
||||
case 'service_sale_confirm':
|
||||
$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
|
||||
$serviceSale = $plugin->getServiceSale($id);
|
||||
$response = $plugin->completeServiceSale($id);
|
||||
$html = "<div class='text-center'>";
|
||||
|
||||
if ($response) {
|
||||
$html .= Display::return_message(
|
||||
sprintf($plugin->get_lang('SubscriptionToServiceXSuccessful'), $serviceSale['service']['name']),
|
||||
'success'
|
||||
);
|
||||
} else {
|
||||
$html .= Display::return_message('Error - '.$plugin->get_lang('ErrorContactPlatformAdmin'), 'error');
|
||||
}
|
||||
|
||||
$html .= "<a id='finish-button' class='btn btn-primary'>".$plugin->get_lang('ClickHereToFinish')."</a>";
|
||||
$html .= "</div>";
|
||||
$html .= "<script>";
|
||||
$html .= "$('#finish-button').click(function() {";
|
||||
$html .= "location.reload();";
|
||||
$html .= "});";
|
||||
$html .= "</script>";
|
||||
echo $html;
|
||||
break;
|
||||
case 'service_sale_cancel':
|
||||
$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
|
||||
$response = $plugin->cancelServiceSale($id);
|
||||
$html = '';
|
||||
$html .= "<div class='text-center'>";
|
||||
|
||||
if ($response) {
|
||||
$html .= Display::return_message(
|
||||
$plugin->get_lang('OrderCancelled'),
|
||||
'warning'
|
||||
);
|
||||
} else {
|
||||
$html .= Display::return_message('Error - '.$plugin->get_lang('ErrorContactPlatformAdmin'), 'error');
|
||||
}
|
||||
|
||||
$html .= "<a id='finish-button' class='btn btn-primary'>".$plugin->get_lang('ClickHereToFinish')."</a>";
|
||||
$html .= "</div>";
|
||||
$html .= "<script>";
|
||||
$html .= "$('#finish-button').click(function() {";
|
||||
$html .= "location.reload();";
|
||||
$html .= "});";
|
||||
$html .= "</script>";
|
||||
echo $html;
|
||||
break;
|
||||
}
|
||||
30
plugin/buycourses/src/cecabank_cancel.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Success page for the purchase of a course in the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$cecabankEnabled = $plugin->get('cecabank_enable') === 'true';
|
||||
|
||||
if (!$cecabankEnabled) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sale = $plugin->getSale($_SESSION['bc_sale_id']);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('ErrorContactPlatformAdmin'), 'error')
|
||||
);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/course_catalog.php');
|
||||
exit;
|
||||
53
plugin/buycourses/src/cecabank_response.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Success page for the purchase of a course in the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$cecabankEnabled = $plugin->get('cecabank_enable') === 'true';
|
||||
|
||||
if (!$cecabankEnabled) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$receivedAmount = (float) $_POST['Importe'];
|
||||
|
||||
if (empty($_POST['Num_operacion']) || empty($_POST['Firma']) || empty($receivedAmount)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$signature = $plugin->getCecabankSignature($_POST['Num_operacion'], $receivedAmount);
|
||||
|
||||
if ($signature != $_POST['Firma']) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sale = $plugin->getSaleFromReference($_POST['Num_operacion']);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$buyingCourse = false;
|
||||
$buyingSession = false;
|
||||
|
||||
switch ($sale['product_type']) {
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
|
||||
$buyingCourse = true;
|
||||
$course = $plugin->getCourseInfo($sale['product_id']);
|
||||
break;
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
|
||||
$buyingSession = true;
|
||||
$session = $plugin->getSessionInfo($sale['product_id']);
|
||||
break;
|
||||
}
|
||||
|
||||
$saleIsCompleted = $plugin->completeSale($sale['id']);
|
||||
if ($saleIsCompleted) {
|
||||
$plugin->storePayouts($sale['id']);
|
||||
}
|
||||
30
plugin/buycourses/src/cecabank_success.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Success page for the purchase of a course in the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$cecabankEnabled = $plugin->get('cecabank_enable') === 'true';
|
||||
|
||||
if (!$cecabankEnabled) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sale = $plugin->getSale($_SESSION['bc_sale_id']);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
$plugin->getSubscriptionSuccessMessage($sale)
|
||||
);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/course_catalog.php');
|
||||
exit;
|
||||
204
plugin/buycourses/src/configure_coupon.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Configuration script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$couponId = $_REQUEST['id'];
|
||||
|
||||
if (!isset($couponId)) {
|
||||
api_not_allowed();
|
||||
}
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$coupon = $plugin->getCouponInfo($couponId);
|
||||
|
||||
if (!isset($coupon)) {
|
||||
api_not_allowed();
|
||||
}
|
||||
|
||||
$couponDateRangeFrom = $coupon['valid_start'];
|
||||
$couponDateRangeTo = $coupon['valid_end'];
|
||||
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
$entityManager = Database::getManager();
|
||||
$userRepo = UserManager::getRepository();
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
if (empty($currency)) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CurrencyIsNotConfigured'), 'error')
|
||||
);
|
||||
}
|
||||
|
||||
$currencyIso = null;
|
||||
|
||||
$coursesList = CourseManager::get_courses_list(
|
||||
0,
|
||||
0,
|
||||
'title',
|
||||
'asc',
|
||||
-1,
|
||||
null,
|
||||
api_get_current_access_url_id(),
|
||||
false,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
foreach ($coursesList as $course) {
|
||||
$courses[$course['id']] = $course['title'];
|
||||
}
|
||||
|
||||
$sessionsList = SessionManager::get_sessions_list(
|
||||
[],
|
||||
[],
|
||||
null,
|
||||
null,
|
||||
api_get_current_access_url_id(),
|
||||
[]
|
||||
);
|
||||
|
||||
foreach ($sessionsList as $session) {
|
||||
$sessions[$session['id']] = $session['name'];
|
||||
}
|
||||
|
||||
$servicesList = $plugin->getAllServices();
|
||||
|
||||
foreach ($servicesList as $service) {
|
||||
$services[$service['id']] = $service['name'];
|
||||
}
|
||||
|
||||
$discountTypes = $plugin->getCouponDiscountTypes();
|
||||
|
||||
// Build the form
|
||||
$form = new FormValidator('add_coupon');
|
||||
$form->addText('code', $plugin->get_lang('CouponCode'), false);
|
||||
$form->addText('discount_type', $plugin->get_lang('CouponDiscountType'), false);
|
||||
$form->addText('discount_amount', $plugin->get_lang('CouponDiscount'), false);
|
||||
$form->addDateRangePicker(
|
||||
'date',
|
||||
get_lang('Date'),
|
||||
true,
|
||||
[
|
||||
'value' => "$couponDateRangeFrom / $couponDateRangeTo",
|
||||
]
|
||||
);
|
||||
|
||||
$form->addCheckBox('active', $plugin->get_lang('CouponActive'));
|
||||
$form->addElement(
|
||||
'advmultiselect',
|
||||
'courses',
|
||||
get_lang('Courses'),
|
||||
$courses
|
||||
);
|
||||
|
||||
if ($includeSession) {
|
||||
$form->addElement(
|
||||
'advmultiselect',
|
||||
'sessions',
|
||||
get_lang('Sessions'),
|
||||
$sessions
|
||||
);
|
||||
}
|
||||
|
||||
if ($includeServices) {
|
||||
$form->addElement(
|
||||
'advmultiselect',
|
||||
'services',
|
||||
get_lang('Services'),
|
||||
$services
|
||||
);
|
||||
}
|
||||
|
||||
$form->addHidden('id', null);
|
||||
|
||||
$coursesAdded = $coupon["courses"];
|
||||
if (!empty($coursesAdded)) {
|
||||
$coursesAdded = array_column($coursesAdded, 'id');
|
||||
}
|
||||
|
||||
$sessionsAdded = $coupon["sessions"];
|
||||
if (!empty($sessionsAdded)) {
|
||||
$sessionsAdded = array_column($sessionsAdded, 'id');
|
||||
}
|
||||
|
||||
$servicesAdded = $coupon["services"];
|
||||
if (!empty($servicesAdded)) {
|
||||
$servicesAdded = array_column($servicesAdded, 'id');
|
||||
}
|
||||
|
||||
$formDefaults = [
|
||||
'id' => $coupon['id'],
|
||||
'code' => $coupon['code'],
|
||||
'discount_type' => $discountTypes[$coupon['discount_type']],
|
||||
'discount_amount' => $coupon['discount_amount'],
|
||||
'date' => "$couponDateRangeFrom / $couponDateRangeTo",
|
||||
'active' => $coupon['active'],
|
||||
'courses' => $coursesAdded,
|
||||
'sessions' => $sessionsAdded,
|
||||
'services' => $servicesAdded,
|
||||
];
|
||||
|
||||
$button = $form->addButtonSave(get_lang('Save'));
|
||||
if (empty($currency)) {
|
||||
$button->setAttribute('disabled');
|
||||
}
|
||||
|
||||
$form->freeze(['code', 'discount_type', 'discount_amount']);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->exportValues();
|
||||
|
||||
$coupon['id'] = $formValues['id'];
|
||||
$coupon['valid_start'] = $formValues['date_start'];
|
||||
$coupon['valid_end'] = $formValues['date_end'];
|
||||
$coupon['active'] = $formValues['active'];
|
||||
$coupon['courses'] = isset($formValues['courses']) ? $formValues['courses'] : [];
|
||||
$coupon['sessions'] = isset($formValues['sessions']) ? $formValues['sessions'] : [];
|
||||
$coupon['services'] = isset($formValues['services']) ? $formValues['services'] : [];
|
||||
|
||||
$result = $plugin->updateCouponData($coupon);
|
||||
|
||||
if ($result) {
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('CouponUpdate'),
|
||||
'success',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/configure_coupon.php?id='.$coupon["id"]);
|
||||
} else {
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->setDefaults($formDefaults);
|
||||
|
||||
$templateName = $plugin->get_lang('ConfigureCoupon');
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'paymentsetup.php',
|
||||
'name' => get_lang('Configuration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'coupons.php',
|
||||
'name' => $plugin->get_lang('CouponList'),
|
||||
];
|
||||
|
||||
$template = new Template($templateName);
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $form->returnForm());
|
||||
$template->display_one_col_template();
|
||||
363
plugin/buycourses/src/configure_course.php
Normal file
@@ -0,0 +1,363 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Configuration script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
|
||||
$type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : 0;
|
||||
|
||||
if (empty($id) || empty($type)) {
|
||||
api_not_allowed();
|
||||
}
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$commissionsEnable = $plugin->get('commissions_enable');
|
||||
|
||||
if ($commissionsEnable == 'true') {
|
||||
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_PLUGIN_PATH)
|
||||
.'buycourses/resources/js/commissions.js"></script>';
|
||||
$commissions = '';
|
||||
}
|
||||
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
$editingCourse = $type === BuyCoursesPlugin::PRODUCT_TYPE_COURSE;
|
||||
$editingSession = $type === BuyCoursesPlugin::PRODUCT_TYPE_SESSION;
|
||||
|
||||
$entityManager = Database::getManager();
|
||||
$userRepo = UserManager::getRepository();
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
if (empty($currency)) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CurrencyIsNotConfigured'), 'error')
|
||||
);
|
||||
$currency = null;
|
||||
}
|
||||
|
||||
$currencyIso = null;
|
||||
|
||||
if ($editingCourse) {
|
||||
$course = $entityManager->find('ChamiloCoreBundle:Course', $id);
|
||||
|
||||
if (!$course) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
/*if (!$plugin->isValidCourse($course)) {
|
||||
api_not_allowed(true);
|
||||
}*/
|
||||
|
||||
$courseItem = $plugin->getCourseForConfiguration($course, $currency);
|
||||
$defaultBeneficiaries = [];
|
||||
$teachers = $course->getTeachers();
|
||||
$teachersOptions = [];
|
||||
|
||||
foreach ($teachers as $courseTeacher) {
|
||||
$teacher = $courseTeacher->getUser();
|
||||
$teachersOptions[] = [
|
||||
'text' => $teacher->getCompleteName(),
|
||||
'value' => $teacher->getId(),
|
||||
];
|
||||
$defaultBeneficiaries[] = $teacher->getId();
|
||||
}
|
||||
|
||||
if (!empty($courseItem['item_id'])) {
|
||||
$currentBeneficiaries = $plugin->getItemBeneficiaries($courseItem['course_id']);
|
||||
if (!empty($currentBeneficiaries)) {
|
||||
$defaultBeneficiaries = array_column($currentBeneficiaries, 'user_id');
|
||||
if ($commissionsEnable === 'true') {
|
||||
$defaultCommissions = array_column($currentBeneficiaries, 'commissions');
|
||||
foreach ($defaultCommissions as $defaultCommission) {
|
||||
$commissions .= $defaultCommission.',';
|
||||
}
|
||||
$commissions = substr($commissions, 0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
$currencyIso = $courseItem['currency'];
|
||||
$formDefaults = [
|
||||
'product_type' => get_lang('Course'),
|
||||
'id' => $courseItem['course_id'],
|
||||
'type' => BuyCoursesPlugin::PRODUCT_TYPE_COURSE,
|
||||
'name' => $courseItem['course_title'],
|
||||
'visible' => $courseItem['visible'],
|
||||
'price' => $courseItem['price'],
|
||||
'tax_perc' => $courseItem['tax_perc'],
|
||||
'beneficiaries' => $defaultBeneficiaries,
|
||||
$commissionsEnable == 'true' ? 'commissions' : '' => $commissionsEnable == 'true' ? $commissions : '',
|
||||
];
|
||||
} else {
|
||||
$formDefaults = [
|
||||
'product_type' => get_lang('Course'),
|
||||
'id' => $courseItem['course_id'],
|
||||
'type' => BuyCoursesPlugin::PRODUCT_TYPE_COURSE,
|
||||
'name' => $courseItem['course_title'],
|
||||
'visible' => false,
|
||||
'price' => 0,
|
||||
'tax_perc' => 0,
|
||||
'beneficiaries' => [],
|
||||
$commissionsEnable == 'true' ? 'commissions' : '' => $commissionsEnable == 'true' ? '' : '',
|
||||
];
|
||||
}
|
||||
} elseif ($editingSession) {
|
||||
if (!$includeSession) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$session = $entityManager->find('ChamiloCoreBundle:Session', $id);
|
||||
if (!$session) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sessionItem = $plugin->getSessionForConfiguration($session, $currency);
|
||||
$generalCoach = $session->getGeneralCoach();
|
||||
$generalCoachOption = [
|
||||
'text' => $generalCoach->getCompleteName(),
|
||||
'value' => $generalCoach->getId(),
|
||||
];
|
||||
$defaultBeneficiaries = [
|
||||
$generalCoach->getId(),
|
||||
];
|
||||
$courseCoachesOptions = [];
|
||||
$sessionCourses = $session->getCourses();
|
||||
|
||||
foreach ($sessionCourses as $sessionCourse) {
|
||||
$courseCoaches = $userRepo->getCoachesForSessionCourse($session, $sessionCourse->getCourse());
|
||||
|
||||
foreach ($courseCoaches as $courseCoach) {
|
||||
if ($generalCoach->getId() === $courseCoach->getId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$courseCoachesOptions[] = [
|
||||
'text' => $courseCoach->getCompleteName(),
|
||||
'value' => $courseCoach->getId(),
|
||||
];
|
||||
$defaultBeneficiaries[] = $courseCoach->getId();
|
||||
}
|
||||
}
|
||||
|
||||
if ($sessionItem['item_id']) {
|
||||
$currentBeneficiaries = $plugin->getItemBeneficiaries($sessionItem['item_id']);
|
||||
}
|
||||
|
||||
if (!empty($currentBeneficiaries)) {
|
||||
$defaultBeneficiaries = array_column($currentBeneficiaries, 'user_id');
|
||||
|
||||
if ($commissionsEnable == 'true') {
|
||||
$defaultCommissions = array_column($currentBeneficiaries, 'commissions');
|
||||
|
||||
foreach ($defaultCommissions as $defaultCommission) {
|
||||
$commissions .= $defaultCommission.',';
|
||||
}
|
||||
|
||||
$commissions = substr($commissions, 0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
$currencyIso = $sessionItem['currency'];
|
||||
$formDefaults = [
|
||||
'product_type' => get_lang('Session'),
|
||||
'id' => $session->getId(),
|
||||
'type' => BuyCoursesPlugin::PRODUCT_TYPE_SESSION,
|
||||
'name' => $sessionItem['session_name'],
|
||||
'visible' => $sessionItem['visible'],
|
||||
'price' => $sessionItem['price'],
|
||||
'tax_perc' => $sessionItem['tax_perc'],
|
||||
'beneficiaries' => $defaultBeneficiaries,
|
||||
$commissionsEnable == 'true' ? 'commissions' : '' => $commissionsEnable == 'true' ? $commissions : '',
|
||||
];
|
||||
} else {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
if ($commissionsEnable === 'true') {
|
||||
$htmlHeadXtra[] = "
|
||||
<script>
|
||||
$(function() {
|
||||
if ($('[name=\"commissions\"]').val() === '') {
|
||||
$('#panelSliders').html(
|
||||
'<button id=\"setCommissionsButton\" class=\"btn btn-warning\">'
|
||||
+ '".get_plugin_lang('SetCommissions', 'BuyCoursesPlugin')."'
|
||||
);
|
||||
} else {
|
||||
showSliders(100, 'default', '".$commissions."');
|
||||
}
|
||||
|
||||
var maxPercentage = 100;
|
||||
$('#selectBox').on('change', function() {
|
||||
$('#panelSliders').html('');
|
||||
});
|
||||
|
||||
$('#setCommissionsButton').on('click', function() {
|
||||
$('#panelSliders').html('');
|
||||
showSliders(maxPercentage, 'renew');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
";
|
||||
}
|
||||
|
||||
$globalSettingsParams = $plugin->getGlobalParameters();
|
||||
|
||||
$form = new FormValidator('beneficiaries');
|
||||
$form->addText('product_type', $plugin->get_lang('ProductType'), false);
|
||||
$form->addText('name', get_lang('Name'), false);
|
||||
$form->addCheckBox(
|
||||
'visible',
|
||||
$plugin->get_lang('VisibleInCatalog'),
|
||||
$plugin->get_lang('ShowOnCourseCatalog')
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'price',
|
||||
[$plugin->get_lang('Price'), null, $currencyIso],
|
||||
['step' => 0.01]
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'tax_perc',
|
||||
[$plugin->get_lang('TaxPerc'), $plugin->get_lang('TaxPercDescription'), '%'],
|
||||
['step' => 1, 'placeholder' => $globalSettingsParams['global_tax_perc'].'% '.$plugin->get_lang('ByDefault')]
|
||||
);
|
||||
$beneficiariesSelect = $form->addSelect(
|
||||
'beneficiaries',
|
||||
$plugin->get_lang('Beneficiaries'),
|
||||
null,
|
||||
['multiple' => 'multiple', 'id' => 'selectBox']
|
||||
);
|
||||
|
||||
if ($editingCourse) {
|
||||
$teachersOptions = api_unique_multidim_array($teachersOptions, 'value');
|
||||
$beneficiariesSelect->addOptGroup($teachersOptions, get_lang('Teachers'));
|
||||
} elseif ($editingSession) {
|
||||
$courseCoachesOptions = api_unique_multidim_array($courseCoachesOptions, 'value');
|
||||
$beneficiariesSelect->addOptGroup([$generalCoachOption], get_lang('SessionGeneralCoach'));
|
||||
$beneficiariesSelect->addOptGroup($courseCoachesOptions, get_lang('SessionCourseCoach'));
|
||||
}
|
||||
|
||||
if ($commissionsEnable === 'true') {
|
||||
$platformCommission = $plugin->getPlatformCommission();
|
||||
$form->addHtml(
|
||||
'
|
||||
<div class="form-group">
|
||||
<label for="sliders" class="col-sm-2 control-label">
|
||||
'.get_plugin_lang('Commissions', 'BuyCoursesPlugin').'
|
||||
</label>
|
||||
<div class="col-sm-8">
|
||||
'.Display::return_message(
|
||||
sprintf($plugin->get_lang('TheActualPlatformCommissionIsX'), $platformCommission['commission'].'%'),
|
||||
'info',
|
||||
false
|
||||
).'
|
||||
<div id="panelSliders"></div>
|
||||
</div>
|
||||
</div>'
|
||||
);
|
||||
$form->addHidden('commissions', '');
|
||||
}
|
||||
|
||||
$form->addHidden('type', null);
|
||||
$form->addHidden('id', null);
|
||||
$button = $form->addButtonSave(get_lang('Save'));
|
||||
|
||||
if (empty($currency)) {
|
||||
$button->setAttribute('disabled');
|
||||
}
|
||||
|
||||
$form->freeze(['product_type', 'name']);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->exportValues();
|
||||
$id = $formValues['id'];
|
||||
$type = $formValues['type'];
|
||||
|
||||
$productItem = $plugin->getItemByProduct($id, $type);
|
||||
if (isset($formValues['visible'])) {
|
||||
$taxPerc = $formValues['tax_perc'] != '' ? (int) $formValues['tax_perc'] : null;
|
||||
if (!empty($productItem)) {
|
||||
$plugin->updateItem(
|
||||
[
|
||||
'price' => floatval($formValues['price']),
|
||||
'tax_perc' => $taxPerc,
|
||||
],
|
||||
$id,
|
||||
$type
|
||||
);
|
||||
} else {
|
||||
$itemId = $plugin->registerItem([
|
||||
'currency_id' => (int) $currency['id'],
|
||||
'product_type' => $type,
|
||||
'product_id' => $id,
|
||||
'price' => floatval($_POST['price']),
|
||||
'tax_perc' => $taxPerc,
|
||||
]);
|
||||
$productItem['id'] = $itemId;
|
||||
}
|
||||
|
||||
$plugin->deleteItemBeneficiaries($productItem['id']);
|
||||
|
||||
if (isset($formValues['beneficiaries'])) {
|
||||
if ($commissionsEnable === 'true') {
|
||||
$usersId = $formValues['beneficiaries'];
|
||||
$commissions = explode(',', $formValues['commissions']);
|
||||
$commissions = (count($usersId) != count($commissions))
|
||||
? array_fill(0, count($usersId), 0)
|
||||
: $commissions;
|
||||
$beneficiaries = array_combine($usersId, $commissions);
|
||||
} else {
|
||||
$usersId = $formValues['beneficiaries'];
|
||||
$commissions = array_fill(0, count($usersId), 0);
|
||||
$beneficiaries = array_combine($usersId, $commissions);
|
||||
}
|
||||
$plugin->registerItemBeneficiaries($productItem['id'], $beneficiaries);
|
||||
}
|
||||
} else {
|
||||
if (!empty($productItem['id'])) {
|
||||
$plugin->deleteItem($productItem['id']);
|
||||
}
|
||||
}
|
||||
$url = 'list.php';
|
||||
if ($type == 2) {
|
||||
$url = 'list_session.php';
|
||||
}
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/'.$url);
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->setDefaults($formDefaults);
|
||||
|
||||
$templateName = '';
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'paymentsetup.php',
|
||||
'name' => get_lang('Configuration'),
|
||||
];
|
||||
switch ($type) {
|
||||
case 2:
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'list_session.php',
|
||||
'name' => $plugin->get_lang('Sessions'),
|
||||
];
|
||||
$templateName = $plugin->get_lang('Sessions');
|
||||
break;
|
||||
default:
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'list.php',
|
||||
'name' => $plugin->get_lang('AvailableCourses'),
|
||||
];
|
||||
$templateName = $plugin->get_lang('AvailableCourse');
|
||||
}
|
||||
|
||||
$template = new Template($templateName);
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $form->returnForm());
|
||||
$template->display_one_col_template();
|
||||
119
plugin/buycourses/src/configure_frequency.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Configuration page for subscriptions for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
if (isset($_GET['action'], $_GET['d'], $_GET['n'])) {
|
||||
if ($_GET['action'] == 'delete_frequency') {
|
||||
if (is_numeric($_GET['d'])) {
|
||||
$frequency = $plugin->selectFrequency($_GET['d']);
|
||||
|
||||
if (!empty($frequency)) {
|
||||
$subscriptionsItems = $plugin->getSubscriptionsItemsByDuration($_GET['d']);
|
||||
|
||||
if (empty($subscriptionsItems)) {
|
||||
$plugin->deleteFrequency($_GET['d']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('FrequencyRemoved'), 'success')
|
||||
);
|
||||
} else {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('SubscriptionPeriodOnUse'), 'error')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('FrequencyNotExits'), 'error')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('FrequencyIncorrect'), 'error')
|
||||
);
|
||||
}
|
||||
|
||||
header('Location: '.api_get_self());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$frequencies = $plugin->getFrequenciesList();
|
||||
|
||||
$globalSettingsParams = $plugin->getGlobalParameters();
|
||||
|
||||
$form = new FormValidator('add_frequency');
|
||||
|
||||
$form->addText('name', get_lang('Name'), false);
|
||||
|
||||
$form->addElement(
|
||||
'number',
|
||||
'duration',
|
||||
[$plugin->get_lang('Duration'), $plugin->get_lang('Days')],
|
||||
['step' => 1, 'placeholder' => $plugin->get_lang('SubscriptionFrequencyValueDays')]
|
||||
);
|
||||
|
||||
$button = $form->addButtonSave(get_lang('Save'));
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$duration = $formValues['duration'];
|
||||
$name = $formValues['name'];
|
||||
|
||||
$frequency = $plugin->selectFrequency($duration);
|
||||
|
||||
if (!empty($frequency)) {
|
||||
$result = $plugin->updateFrequency($duration, $name);
|
||||
|
||||
if (!isset($result)) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('FrequencyNotUpdated'), 'error')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$result = $plugin->addFrequency($duration, $name);
|
||||
|
||||
if (!isset($result)) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('FrequencyNotSaved'), 'error')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/configure_frequency.php');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
//$form->setDefaults($formDefaults);
|
||||
|
||||
$templateName = $plugin->get_lang('FrequencyAdd');
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'subscriptions_courses.php',
|
||||
'name' => get_lang('Configuration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'subscriptions_courses.php',
|
||||
'name' => $plugin->get_lang('SubscriptionList'),
|
||||
];
|
||||
|
||||
$template = new Template($templateName);
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('items_form', $form->returnForm());
|
||||
$template->assign('frequencies_list', $frequencies);
|
||||
|
||||
$content = $template->fetch('buycourses/view/configure_frequency.tpl');
|
||||
$template->assign('content', $content);
|
||||
|
||||
$template->display_one_col_template();
|
||||
246
plugin/buycourses/src/configure_subscription.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Configuration page for subscriptions for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
|
||||
$type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : 0;
|
||||
|
||||
if (!isset($id) || !isset($type)) {
|
||||
api_not_allowed();
|
||||
}
|
||||
|
||||
$queryString = 'id='.intval($_REQUEST['id']).'&type='.intval($_REQUEST['type']);
|
||||
|
||||
$editingCourse = $type === BuyCoursesPlugin::PRODUCT_TYPE_COURSE;
|
||||
$editingSession = $type === BuyCoursesPlugin::PRODUCT_TYPE_SESSION;
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
|
||||
if (isset($_GET['action'], $_GET['d'])) {
|
||||
if ($_GET['action'] == 'delete_frequency') {
|
||||
$plugin->deleteSubscription($type, $id, $_GET['d']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('ItemRemoved'), 'success')
|
||||
);
|
||||
|
||||
header('Location: '.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$entityManager = Database::getManager();
|
||||
$userRepo = UserManager::getRepository();
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
if (empty($currency)) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CurrencyIsNotConfigured'), 'error')
|
||||
);
|
||||
}
|
||||
|
||||
$subscriptions = $plugin->getSubscriptions($type, $id);
|
||||
|
||||
$taxtPerc = 0;
|
||||
|
||||
if (isset($subscriptions) && !empty($subscriptions)) {
|
||||
$taxtPerc = $subscriptions[0]['tax_perc'];
|
||||
}
|
||||
|
||||
$currencyIso = null;
|
||||
|
||||
if ($editingCourse) {
|
||||
$course = $entityManager->find('ChamiloCoreBundle:Course', $id);
|
||||
if (!$course) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$courseItem = $plugin->getCourseForConfiguration($course, $currency);
|
||||
|
||||
$currencyIso = $courseItem['currency'];
|
||||
$formDefaults = [
|
||||
'product_type' => get_lang('Course'),
|
||||
'id' => $courseItem['course_id'],
|
||||
'type' => BuyCoursesPlugin::PRODUCT_TYPE_COURSE,
|
||||
'name' => $courseItem['course_title'],
|
||||
'visible' => $courseItem['visible'],
|
||||
'tax_perc' => $taxtPerc,
|
||||
];
|
||||
} elseif ($editingSession) {
|
||||
if (!$includeSession) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$session = $entityManager->find('ChamiloCoreBundle:Session', $id);
|
||||
if (!$session) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sessionItem = $plugin->getSessionForConfiguration($session, $currency);
|
||||
|
||||
$currencyIso = $sessionItem['currency'];
|
||||
$formDefaults = [
|
||||
'product_type' => get_lang('Session'),
|
||||
'id' => $session->getId(),
|
||||
'type' => BuyCoursesPlugin::PRODUCT_TYPE_SESSION,
|
||||
'name' => $sessionItem['session_name'],
|
||||
'visible' => $sessionItem['visible'],
|
||||
'tax_perc' => $taxtPerc,
|
||||
];
|
||||
} else {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$globalSettingsParams = $plugin->getGlobalParameters();
|
||||
|
||||
$form = new FormValidator('add_subscription');
|
||||
|
||||
$form->addText('product_type', $plugin->get_lang('ProductType'), false);
|
||||
$form->addText('name', get_lang('Name'), false);
|
||||
|
||||
$form->freeze(['product_type', 'name']);
|
||||
|
||||
$form->addElement(
|
||||
'number',
|
||||
'tax_perc',
|
||||
[$plugin->get_lang('TaxPerc'), $plugin->get_lang('TaxPercDescription'), '%'],
|
||||
['step' => 1, 'placeholder' => $globalSettingsParams['global_tax_perc'].'% '.$plugin->get_lang('ByDefault')]
|
||||
);
|
||||
|
||||
$frequenciesOptions = $plugin->getFrequencies();
|
||||
|
||||
$frequencyForm = new FormValidator('frequency_config', 'post', api_get_self().'?'.$queryString);
|
||||
|
||||
$frequencyFormDefaults = [
|
||||
'id' => $id,
|
||||
'type' => $type,
|
||||
'tax_perc' => $taxtPerc,
|
||||
'currency_id' => $currency['id'],
|
||||
];
|
||||
|
||||
$frequencyForm->setDefaults($frequencyFormDefaults);
|
||||
|
||||
if ($frequencyForm->validate()) {
|
||||
$frequencyFormValues = $frequencyForm->getSubmitValues();
|
||||
|
||||
$subscription['product_id'] = $frequencyFormValues['id'];
|
||||
$subscription['product_type'] = $frequencyFormValues['type'];
|
||||
$subscription['tax_perc'] = $frequencyFormValues['tax_perc'] != '' ? (int) $frequencyFormValues['tax_perc'] : null;
|
||||
$subscription['currency_id'] = $currency['id'];
|
||||
$duration = $frequencyFormValues['duration'];
|
||||
$price = $frequencyFormValues['price'];
|
||||
|
||||
for ($i = 0; $i <= count($subscriptions); $i++) {
|
||||
if ($subscriptions[$i]['duration'] == $duration) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('SubscriptionAlreadyExists'), 'error')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$subscription['frequencies'] = [['duration' => $duration, 'price' => $price]];
|
||||
|
||||
$result = $plugin->addNewSubscription($subscription);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
$frequencyForm->addElement(
|
||||
'select',
|
||||
'duration',
|
||||
$plugin->get_lang('Duration'),
|
||||
$frequenciesOptions,
|
||||
['cols-size' => [2, 8, 2]]
|
||||
);
|
||||
|
||||
$frequencyForm->addElement(
|
||||
'number',
|
||||
'price',
|
||||
[$plugin->get_lang('Price'), null, $currencyIso],
|
||||
false,
|
||||
[
|
||||
'step' => 1,
|
||||
'cols-size' => [3, 8, 1],
|
||||
]
|
||||
);
|
||||
|
||||
$frequencyForm->addHidden('type', $type);
|
||||
$frequencyForm->addHidden('id', $id);
|
||||
$frequencyForm->addHidden('tax_perc', $taxtPerc);
|
||||
$frequencyForm->addHidden('currency_id', $currency['id']);
|
||||
$frequencyForm->addButtonCreate('Add');
|
||||
|
||||
for ($i = 0; $i < count($subscriptions); $i++) {
|
||||
if ($subscriptions[$i]['duration'] > 0) {
|
||||
$subscriptions[$i]['durationName'] = $frequenciesOptions[$subscriptions[$i]['duration']];
|
||||
}
|
||||
}
|
||||
|
||||
$form->addHidden('type', $type);
|
||||
$form->addHidden('id', $id);
|
||||
$button = $form->addButtonSave(get_lang('Save'));
|
||||
|
||||
if (empty($currency)) {
|
||||
$button->setAttribute('disabled');
|
||||
}
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$id = $formValues['id'];
|
||||
$type = $formValues['type'];
|
||||
$taxPerc = $formValues['tax_perc'] != '' ? (int) $formValues['tax_perc'] : null;
|
||||
|
||||
$result = $plugin->updateSubscriptions($type, $id, $taxPerc);
|
||||
|
||||
if ($result) {
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/subscriptions_courses.php');
|
||||
} else {
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->setDefaults($formDefaults);
|
||||
|
||||
$templateName = $plugin->get_lang('SubscriptionAdd');
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'subscriptions_courses.php',
|
||||
'name' => get_lang('Configuration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'subscriptions_courses.php',
|
||||
'name' => $plugin->get_lang('SubscriptionList'),
|
||||
];
|
||||
|
||||
$template = new Template($templateName);
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('items_form', $form->returnForm());
|
||||
$template->assign('frequency_form', $frequencyForm->returnForm());
|
||||
$template->assign('subscriptions', $subscriptions);
|
||||
$template->assign('currencyIso', $currencyIso);
|
||||
|
||||
$content = $template->fetch('buycourses/view/configure_subscription.tpl');
|
||||
$template->assign('content', $content);
|
||||
|
||||
$template->display_one_col_template();
|
||||
167
plugin/buycourses/src/coupon_add.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Configuration script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
$entityManager = Database::getManager();
|
||||
$userRepo = UserManager::getRepository();
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
if (empty($currency)) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CurrencyIsNotConfigured'), 'error')
|
||||
);
|
||||
}
|
||||
|
||||
$currencyIso = null;
|
||||
|
||||
$coursesList = CourseManager::get_courses_list(
|
||||
0,
|
||||
0,
|
||||
'title',
|
||||
'asc',
|
||||
-1,
|
||||
null,
|
||||
api_get_current_access_url_id(),
|
||||
false,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
foreach ($coursesList as $course) {
|
||||
$courses[$course['id']] = $course['title'];
|
||||
}
|
||||
|
||||
$sessionsList = SessionManager::get_sessions_list(
|
||||
[],
|
||||
[],
|
||||
null,
|
||||
null,
|
||||
api_get_current_access_url_id(),
|
||||
[]
|
||||
);
|
||||
|
||||
foreach ($sessionsList as $session) {
|
||||
$sessions[$session['id']] = $session['name'];
|
||||
}
|
||||
|
||||
$servicesList = $plugin->getAllServices();
|
||||
|
||||
foreach ($servicesList as $service) {
|
||||
$services[$service['id']] = $service['name'];
|
||||
}
|
||||
|
||||
$discountTypes = $plugin->getCouponDiscountTypes();
|
||||
|
||||
// Build the form
|
||||
$form = new FormValidator('add_coupon');
|
||||
$form->addText('code', $plugin->get_lang('CouponCode'), true);
|
||||
$form->addRadio('discount_type', $plugin->get_lang('CouponDiscountType'), $discountTypes);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'discount_amount',
|
||||
[$plugin->get_lang('CouponDiscount'), null, $currencyIso],
|
||||
['step' => 1]
|
||||
);
|
||||
$form->addDateRangePicker('date', get_lang('Date'), true);
|
||||
$form->addCheckBox('active', get_lang('Active'));
|
||||
$form->addElement(
|
||||
'advmultiselect',
|
||||
'courses',
|
||||
get_lang('Courses'),
|
||||
$courses
|
||||
);
|
||||
|
||||
if ($includeSession) {
|
||||
$form->addElement(
|
||||
'advmultiselect',
|
||||
'sessions',
|
||||
get_lang('Sessions'),
|
||||
$sessions
|
||||
);
|
||||
}
|
||||
|
||||
if ($includeServices) {
|
||||
$form->addElement(
|
||||
'advmultiselect',
|
||||
'services',
|
||||
get_lang('Services'),
|
||||
$services
|
||||
);
|
||||
}
|
||||
|
||||
$button = $form->addButtonSave(get_lang('Save'));
|
||||
|
||||
if (empty($currency)) {
|
||||
$button->setAttribute('disabled');
|
||||
}
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->exportValues();
|
||||
|
||||
$coupon['code'] = $formValues['code'];
|
||||
$coupon['discount_type'] = $formValues['discount_type'];
|
||||
$coupon['discount_amount'] = $formValues['discount_amount'];
|
||||
$coupon['valid_start'] = $formValues['date_start'];
|
||||
$coupon['valid_end'] = $formValues['date_end'];
|
||||
$coupon['active'] = $formValues['active'];
|
||||
|
||||
if ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_PERCENTAGE && $coupon['discount_amount'] > 100) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CouponDiscountExceed100'), 'error', false)
|
||||
);
|
||||
}
|
||||
|
||||
$coupon['courses'] = isset($formValues['courses']) ? $formValues['courses'] : [];
|
||||
$coupon['sessions'] = isset($formValues['sessions']) ? $formValues['sessions'] : [];
|
||||
$coupon['services'] = isset($formValues['services']) ? $formValues['services'] : [];
|
||||
|
||||
$result = $plugin->addNewCoupon($coupon);
|
||||
|
||||
if ($result) {
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/coupons.php');
|
||||
} else {
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$formDefaults = [
|
||||
'code' => '',
|
||||
'discount_type' => null,
|
||||
'discount_amount' => 0,
|
||||
'active' => 0,
|
||||
'courses' => [],
|
||||
'sessions' => [],
|
||||
'services' => [],
|
||||
];
|
||||
|
||||
$form->setDefaults($formDefaults);
|
||||
|
||||
$templateName = $plugin->get_lang('CouponAdd');
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'paymentsetup.php',
|
||||
'name' => get_lang('Configuration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'coupons.php',
|
||||
'name' => $plugin->get_lang('CouponList'),
|
||||
];
|
||||
|
||||
$template = new Template($templateName);
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $form->returnForm());
|
||||
$template->display_one_col_template();
|
||||
109
plugin/buycourses/src/coupons.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of couponsof the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
if (isset($_GET['coupon_id'])) {
|
||||
$coupon = $plugin->getCouponInfo($_GET['coupon_id']);
|
||||
|
||||
if (empty($coupon)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$urlToRedirect = api_get_self().'?';
|
||||
|
||||
switch ($_GET['action']) {
|
||||
case 'deactivate':
|
||||
//activate coupon
|
||||
break;
|
||||
case 'activate':
|
||||
//deactivate coupon
|
||||
break;
|
||||
}
|
||||
|
||||
header("Location: $urlToRedirect");
|
||||
exit;
|
||||
}
|
||||
|
||||
$discountTypes = $plugin->getCouponDiscountTypes();
|
||||
$couponStatuses = $plugin->getCouponStatuses();
|
||||
|
||||
$selectedFilterType = '0';
|
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::COUPON_STATUS_ACTIVE;
|
||||
|
||||
$form = new FormValidator('search', 'get');
|
||||
|
||||
if ($form->validate()) {
|
||||
$selectedStatus = $form->getSubmitValue('status');
|
||||
|
||||
if ($selectedStatus === false) {
|
||||
$selectedStatus = BuyCoursesPlugin::COUPON_STATUS_ACTIVE;
|
||||
}
|
||||
|
||||
if ($selectedFilterType === false) {
|
||||
$selectedFilterType = '0';
|
||||
}
|
||||
}
|
||||
|
||||
$form->addHtml('<div id="report-by-status" '.($selectedFilterType !== '0' ? 'style="display:none"' : '').'>');
|
||||
$form->addSelect('status', $plugin->get_lang('CouponStatus'), $couponStatuses);
|
||||
$form->addHtml('</div>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
$form->setDefaults([
|
||||
'filter_type' => $selectedFilterType,
|
||||
'status' => $selectedStatus,
|
||||
]);
|
||||
|
||||
$coupons = $plugin->getCouponsListByStatus($selectedStatus);
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
foreach ($coupons as &$coupon) {
|
||||
if ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_PERCENTAGE) {
|
||||
$coupon['discount_value'] = $coupon['discount_amount']." %";
|
||||
} elseif ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_AMOUNT) {
|
||||
$coupon['discount_value'] = $plugin->getPriceWithCurrencyFromIsoCode($coupon['discount_amount'], $currency['iso_code']);
|
||||
}
|
||||
$coupon['discount_type'] = $discountTypes[$coupon['discount_type']];
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => '../index.php', 'name' => $plugin->get_lang('plugin_title')];
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = $plugin->get_lang('CouponList');
|
||||
$template = new Template($templateName);
|
||||
|
||||
$toolbar = Display::url(
|
||||
Display::returnFontAwesomeIcon('fas fa-plus').
|
||||
$plugin->get_lang('CouponAdd'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/coupon_add.php',
|
||||
['class' => 'btn btn-primary']
|
||||
);
|
||||
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('selected_status', $selectedStatus);
|
||||
$template->assign('coupon_list', $coupons);
|
||||
$template->assign('coupon_status_active', BuyCoursesPlugin::COUPON_STATUS_ACTIVE);
|
||||
$template->assign('coupon_status_disable', BuyCoursesPlugin::COUPON_STATUS_DISABLE);
|
||||
|
||||
$content = $template->fetch('buycourses/view/coupons.tpl');
|
||||
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
100
plugin/buycourses/src/course_catalog.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of courses.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
$nameFilter = '';
|
||||
$minFilter = 0;
|
||||
$maxFilter = 0;
|
||||
|
||||
$form = new FormValidator(
|
||||
'search_filter_form',
|
||||
'get',
|
||||
null,
|
||||
null,
|
||||
[],
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$nameFilter = isset($formValues['name']) ? $formValues['name'] : null;
|
||||
$minFilter = isset($formValues['min']) ? $formValues['min'] : 0;
|
||||
$maxFilter = isset($formValues['max']) ? $formValues['max'] : 0;
|
||||
}
|
||||
|
||||
$form->addHeader($plugin->get_lang('SearchFilter'));
|
||||
$form->addText('name', get_lang('CourseName'), false);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'min',
|
||||
$plugin->get_lang('MinimumPrice'),
|
||||
['step' => '0.01', 'min' => '0']
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'max',
|
||||
$plugin->get_lang('MaximumPrice'),
|
||||
['step' => '0.01', 'min' => '0']
|
||||
);
|
||||
$form->addHtml('<hr>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
|
||||
$pageSize = BuyCoursesPlugin::PAGINATION_PAGE_SIZE;
|
||||
$currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$first = $pageSize * ($currentPage - 1);
|
||||
$courseList = $plugin->getCatalogCourseList($first, $pageSize, $nameFilter, $minFilter, $maxFilter);
|
||||
$totalItems = $plugin->getCatalogCourseList($first, $pageSize, $nameFilter, $minFilter, $maxFilter, 'count');
|
||||
$pagesCount = ceil($totalItems / $pageSize);
|
||||
|
||||
$pagination = BuyCoursesPlugin::returnPagination(api_get_self(), $currentPage, $pagesCount, $totalItems);
|
||||
|
||||
// View
|
||||
if (api_is_platform_admin()) {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'list.php',
|
||||
'name' => $plugin->get_lang('AvailableCoursesConfiguration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'paymentsetup.php',
|
||||
'name' => $plugin->get_lang('PaymentsConfiguration'),
|
||||
];
|
||||
} else {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'course_panel.php',
|
||||
'name' => get_lang('TabsDashboard'),
|
||||
];
|
||||
}
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = $plugin->get_lang('CourseListOnSale');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('search_filter_form', $form->returnForm());
|
||||
$tpl->assign('showing_courses', true);
|
||||
$tpl->assign('courses', $courseList);
|
||||
$tpl->assign('sessions_are_included', $includeSessions);
|
||||
$tpl->assign('services_are_included', $includeServices);
|
||||
$tpl->assign('pagination', $pagination);
|
||||
|
||||
$countSessions = $plugin->getCatalogSessionList($first, $pageSize, $nameFilter, $minFilter, $maxFilter, 'count');
|
||||
|
||||
$tpl->assign('coursesExist', true);
|
||||
$tpl->assign('sessionExist', $countSessions > 0);
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/catalog.tpl');
|
||||
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
67
plugin/buycourses/src/course_panel.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* User Panel.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
$userInfo = api_get_user_info();
|
||||
|
||||
$productTypes = $plugin->getProductTypes();
|
||||
$saleStatuses = $plugin->getSaleStatuses();
|
||||
$paymentTypes = $plugin->getPaymentTypes();
|
||||
|
||||
$sales = $plugin->getSaleListByUserId($userInfo['id']);
|
||||
|
||||
$saleList = [];
|
||||
|
||||
foreach ($sales as $sale) {
|
||||
if ($sale['product_type'] == 1) {
|
||||
$saleList[] = [
|
||||
'id' => $sale['id'],
|
||||
'reference' => $sale['reference'],
|
||||
'date' => api_format_date($sale['date'], DATE_TIME_FORMAT_LONG_24H),
|
||||
'currency' => $sale['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'product_name' => $sale['product_name'],
|
||||
'product_type' => $productTypes[$sale['product_type']],
|
||||
'payment_type' => $paymentTypes[$sale['payment_type']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$toolbar = Display::toolbarButton(
|
||||
$plugin->get_lang('CourseListOnSale'),
|
||||
'course_catalog.php',
|
||||
'search-plus',
|
||||
'primary',
|
||||
['title' => $plugin->get_lang('CourseListOnSale')]
|
||||
);
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = get_lang('TabsDashboard');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('showing_courses', true);
|
||||
$tpl->assign('sessions_are_included', $includeSessions);
|
||||
$tpl->assign('services_are_included', $includeServices);
|
||||
$tpl->assign('sale_list', $saleList);
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/course_panel.tpl');
|
||||
|
||||
$tpl->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
14
plugin/buycourses/src/error.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* Errors management for the Buy Courses plugin - Redirects to course_catalog.php.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
/**
|
||||
* Config.
|
||||
*/
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
|
||||
header('Location: course_catalog.php');
|
||||
exit;
|
||||
63
plugin/buycourses/src/export_report.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
//Initialization
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$form = new FormValidator('export_validate');
|
||||
|
||||
$form->addDatePicker('date_start', get_lang('DateStart'), false);
|
||||
$form->addDatePicker('date_end', get_lang('DateEnd'), false);
|
||||
$form->addButton('export_sales', get_lang('ExportExcel'), 'check', 'primary');
|
||||
$salesStatus = [];
|
||||
|
||||
if ($form->validate()) {
|
||||
$reportValues = $form->getSubmitValues();
|
||||
|
||||
$dateStart = $reportValues['date_start'];
|
||||
$dateEnd = $reportValues['date_end'];
|
||||
|
||||
if ($dateStart == null || $dateEnd == null) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('SelectDateRange'), 'error', false)
|
||||
);
|
||||
} elseif ($dateStart > $dateEnd) {
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('EndDateCannotBeBeforeTheStartDate'), 'error', false)
|
||||
);
|
||||
} else {
|
||||
$salesStatus = $plugin->getSaleListReport($dateStart, $dateEnd);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($salesStatus)) {
|
||||
$archiveFile = 'export_report_sales_'.api_get_local_time();
|
||||
Export::arrayToXls($salesStatus, $archiveFile);
|
||||
}
|
||||
$interbreadcrumb[] = [
|
||||
'url' => '../index.php', 'name' => $plugin->get_lang('plugin_title'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/src/sales_report.php',
|
||||
'name' => $plugin->get_lang('SalesReport'),
|
||||
];
|
||||
|
||||
$templateName = $plugin->get_lang('ExportReport');
|
||||
$toolbar = Display::url(
|
||||
Display::return_icon('back.png', get_lang('GoBack'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/sales_report.php'
|
||||
);
|
||||
$template = new Template($templateName);
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$content = $template->fetch('buycourses/view/export_report.tpl');
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
63
plugin/buycourses/src/export_subscription_report.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
//Initialization
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$form = new FormValidator('export_validate');
|
||||
|
||||
$form->addDatePicker('date_start', get_lang('DateStart'), false);
|
||||
$form->addDatePicker('date_end', get_lang('DateEnd'), false);
|
||||
$form->addButton('export_sales', get_lang('ExportExcel'), 'check', 'primary');
|
||||
$salesStatus = [];
|
||||
|
||||
if ($form->validate()) {
|
||||
$reportValues = $form->getSubmitValues();
|
||||
|
||||
$dateStart = $reportValues['date_start'];
|
||||
$dateEnd = $reportValues['date_end'];
|
||||
|
||||
if ($dateStart == null || $dateEnd == null) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('SelectDateRange'), 'error', false)
|
||||
);
|
||||
} elseif ($dateStart > $dateEnd) {
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('EndDateCannotBeBeforeTheStartDate'), 'error', false)
|
||||
);
|
||||
} else {
|
||||
$salesStatus = $plugin->getSubscriptionSaleListReport($dateStart, $dateEnd);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($salesStatus)) {
|
||||
$archiveFile = 'export_report_sales_'.api_get_local_time();
|
||||
Export::arrayToXls($salesStatus, $archiveFile);
|
||||
}
|
||||
$interbreadcrumb[] = [
|
||||
'url' => '../index.php', 'name' => $plugin->get_lang('plugin_title'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/src/subscription_sales_report.php',
|
||||
'name' => $plugin->get_lang('SubscriptionSalesReport'),
|
||||
];
|
||||
|
||||
$templateName = $plugin->get_lang('ExportReport');
|
||||
$toolbar = Display::url(
|
||||
Display::return_icon('back.png', get_lang('GoBack'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/subscription_sales_report.php'
|
||||
);
|
||||
$template = new Template($templateName);
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$content = $template->fetch('buycourses/view/export_report.tpl');
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
47
plugin/buycourses/src/expresscheckout.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* PayPal Express Checkout Module.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
/**
|
||||
* Init.
|
||||
*/
|
||||
require_once 'paypalfunctions.php';
|
||||
/**
|
||||
* The paymentAmount is the total value of
|
||||
* the shopping cart, that was set
|
||||
* earlier in a session variable
|
||||
* by the shopping cart page.
|
||||
*/
|
||||
$paymentAmount = $_SESSION["Payment_Amount"];
|
||||
|
||||
/**
|
||||
* The currencyCodeType and paymentType
|
||||
* are set to the selections made on the Integration Assistant.
|
||||
*/
|
||||
$paymentType = "Sale";
|
||||
|
||||
/**
|
||||
* Calls the SetExpressCheckout API call
|
||||
* The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php,
|
||||
* it is included at the top of this file.
|
||||
*/
|
||||
$resArray = CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
|
||||
RedirectToPayPal($resArray["TOKEN"]);
|
||||
} else {
|
||||
//Display a user friendly Error on the page using any of the following error information returned by PayPal
|
||||
$ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
|
||||
$ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
|
||||
$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
|
||||
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
|
||||
|
||||
echo "SetExpressCheckout API call failed. ";
|
||||
echo "Detailed Error Message: ".$ErrorLongMsg;
|
||||
echo "Short Error Message: ".$ErrorShortMsg;
|
||||
echo "Error Code: ".$ErrorCode;
|
||||
echo "Error Severity Code: ".$ErrorSeverityCode;
|
||||
}
|
||||
48
plugin/buycourses/src/index.buycourses.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Index of the Buy Courses plugin courses list.
|
||||
*/
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$allow = $plugin->get('unregistered_users_enable');
|
||||
|
||||
$userIsAdmin = api_is_platform_admin();
|
||||
|
||||
if (($allow === 'true' && api_is_anonymous()) || !api_is_anonymous()) {
|
||||
$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'buycourses/';
|
||||
|
||||
$countCourses = $plugin->getCatalogCourseList(
|
||||
0,
|
||||
BuyCoursesPlugin::PAGINATION_PAGE_SIZE,
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
'count'
|
||||
);
|
||||
|
||||
if ($countCourses > 0 && !$userIsAdmin) {
|
||||
api_location($webPluginPath.'src/course_catalog.php');
|
||||
}
|
||||
|
||||
$countSessions = $plugin->getCatalogSessionList(
|
||||
0,
|
||||
BuyCoursesPlugin::PAGINATION_PAGE_SIZE,
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
'count'
|
||||
);
|
||||
|
||||
if ($countSessions > 0 && !$userIsAdmin) {
|
||||
api_location($webPluginPath.'src/session_catalog.php');
|
||||
}
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$tpl = new Template();
|
||||
$content = $tpl->fetch('buycourses/view/index.tpl');
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template(false);
|
||||
}
|
||||
1
plugin/buycourses/src/index.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
||||
155
plugin/buycourses/src/invoice.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
|
||||
|
||||
/**
|
||||
* Print invoice of the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$invoicingEnable = $plugin->get('invoicing_enable') === 'true';
|
||||
if (!$invoicingEnable) {
|
||||
api_not_allowed(true, $plugin->get_lang('NoInvoiceEnable'));
|
||||
}
|
||||
|
||||
$saleId = isset($_GET['invoice']) ? (int) $_GET['invoice'] : 0;
|
||||
$isService = isset($_GET['is_service']) ? (int) $_GET['is_service'] : 0;
|
||||
|
||||
$globalParameters = $plugin->getGlobalParameters();
|
||||
$infoSale = $plugin->getDataSaleInvoice($saleId, $isService);
|
||||
$buyer = api_get_user_info($infoSale['user_id']);
|
||||
$extraUserInfoData = UserManager::get_extra_user_data($infoSale['user_id']);
|
||||
$infoInvoice = $plugin->getDataInvoice($saleId, $isService);
|
||||
|
||||
$taxAppliesTo = $globalParameters['tax_applies_to'];
|
||||
$taxEnable = $plugin->get('tax_enable') === 'true' &&
|
||||
($taxAppliesTo == BuyCoursesPlugin::TAX_APPLIES_TO_ALL ||
|
||||
($taxAppliesTo == BuyCoursesPlugin::TAX_APPLIES_TO_ONLY_COURSE && !$isService) ||
|
||||
($taxAppliesTo == BuyCoursesPlugin::TAX_APPLIES_TO_ONLY_SESSION && $isService));
|
||||
|
||||
$htmlText = '<html>';
|
||||
$htmlText .= '<link rel="stylesheet" type="text/css" href="plugin.css">';
|
||||
$htmlText .= '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CSS_PATH).'base.css">';
|
||||
$htmlText .= '<body>';
|
||||
|
||||
$organization = ChamiloApi::getPlatformLogo('', [], true);
|
||||
// Use custom logo image.
|
||||
$pdfLogo = api_get_setting('pdf_logo_header');
|
||||
if ($pdfLogo === 'true') {
|
||||
$visualTheme = api_get_visual_theme();
|
||||
$img = api_get_path(SYS_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png';
|
||||
if (file_exists($img)) {
|
||||
$organization = "<img src='$img'>";
|
||||
}
|
||||
}
|
||||
$htmlText .= $organization;
|
||||
|
||||
// Seller and customer info
|
||||
$htmlText .= '<table width="100%">';
|
||||
$htmlText .= '<tr>';
|
||||
$htmlText .= '<td>';
|
||||
$htmlText .= '<b>'.$globalParameters['seller_name'].'</b><br/>';
|
||||
$htmlText .= $globalParameters['seller_id'].'<br/>';
|
||||
$htmlText .= $globalParameters['seller_address'].'<br/>';
|
||||
$htmlText .= $globalParameters['seller_email'].'<br/>';
|
||||
$htmlText .= '</td>';
|
||||
$htmlText .= '<td style="text-align:right;">';
|
||||
$htmlText .= '<b>'.$buyer['complete_name'].'</b><br/>';
|
||||
$htmlText .= ($extraUserInfoData['buycourses_company'] ? $extraUserInfoData['buycourses_company'].'<br>' : '');
|
||||
$htmlText .= ($extraUserInfoData['buycourses_vat'] ? $extraUserInfoData['buycourses_vat'].'<br>' : '');
|
||||
$htmlText .= ($extraUserInfoData['buycourses_address'] ? $extraUserInfoData['buycourses_address'].'<br/>' : '');
|
||||
$htmlText .= ($buyer['phone'] ? $buyer['phone'].'<br/>' : '');
|
||||
$htmlText .= ($buyer['email'] ? $buyer['email'].'<br>' : '');
|
||||
$htmlText .= '</td>';
|
||||
$htmlText .= '</tr>';
|
||||
$htmlText .= '</table>';
|
||||
|
||||
$htmlText .= '<br><br>';
|
||||
$htmlText .= '<p>';
|
||||
$htmlText .= $plugin->get_lang('InvoiceDate').': <span style="font-weight:bold;">'
|
||||
.api_convert_and_format_date($infoInvoice['date_invoice'], DATE_TIME_FORMAT_LONG_24H).'</span><br>';
|
||||
$htmlText .= $plugin->get_lang('InvoiceNumber').': <span style="font-weight:bold;">'
|
||||
.$infoInvoice['serie'].$infoInvoice['year'].'/'.$infoInvoice['num_invoice'].'</span><br>';
|
||||
$htmlText .= '</p><br><br>';
|
||||
|
||||
$header = [
|
||||
$plugin->get_lang('OrderReference'),
|
||||
$plugin->get_lang('ProductType'),
|
||||
$plugin->get_lang('Price'),
|
||||
];
|
||||
|
||||
if ($taxEnable) {
|
||||
$header[] = $globalParameters['tax_name'];
|
||||
$header[] = $plugin->get_lang('Total');
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$row = [
|
||||
$infoSale['reference'],
|
||||
$infoSale['product_name'],
|
||||
];
|
||||
|
||||
//var_dump($infoSale);exit;
|
||||
$isoCode = $plugin->getCurrency($infoSale['currency_id'])['iso_code'];
|
||||
|
||||
if ($taxEnable) {
|
||||
$row[] = $plugin->getPriceWithCurrencyFromIsoCode($infoSale['price_without_tax'], $isoCode);
|
||||
$row[] = $plugin->getPriceWithCurrencyFromIsoCode($infoSale['tax_amount'], $isoCode).' ('.(int) $infoSale['tax_perc'].'%)';
|
||||
}
|
||||
|
||||
$totalPrice = $plugin->getPriceWithCurrencyFromIsoCode(
|
||||
$infoSale['price'],
|
||||
$plugin->getCurrency($infoSale['currency_id'])['iso_code']
|
||||
);
|
||||
|
||||
$row[] = $totalPrice;
|
||||
$data[] = $row;
|
||||
|
||||
$totalPrice = $plugin->getPriceWithCurrencyFromIsoCode(
|
||||
$infoSale['price'],
|
||||
$plugin->getCurrency($infoSale['currency_id'])['iso_code']
|
||||
);
|
||||
|
||||
if ($taxEnable) {
|
||||
$row = [
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
$plugin->get_lang('TotalPayout'),
|
||||
$totalPrice,
|
||||
];
|
||||
} else {
|
||||
$row = [
|
||||
'',
|
||||
$plugin->get_lang('TotalPayout'),
|
||||
$totalPrice,
|
||||
];
|
||||
}
|
||||
$data[] = $row;
|
||||
$attr = [];
|
||||
$attr['class'] = 'table table-hover table-striped data_table';
|
||||
$attr['width'] = '100%';
|
||||
$htmlText .= Display::table($header, $data, $attr);
|
||||
$htmlText .= '</body></html>';
|
||||
|
||||
$fileName = $infoInvoice['serie'].$infoInvoice['year'].'-'.$infoInvoice['num_invoice'];
|
||||
$fileName = api_replace_dangerous_char($fileName);
|
||||
$params = [
|
||||
'filename' => $fileName,
|
||||
'pdf_title' => $plugin->get_lang('Invoice'),
|
||||
'pdf_description' => '',
|
||||
'format' => 'A4',
|
||||
'orientation' => 'P',
|
||||
];
|
||||
$pdf = new PDF($params['format'], $params['orientation'], $params);
|
||||
@$pdf->content_to_pdf($htmlText, '', $fileName, null, 'D', false, null, false, false, false);
|
||||
exit;
|
||||
87
plugin/buycourses/src/list.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* Configuration script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
$taxEnable = $plugin->get('tax_enable') === 'true';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
get_lang('Info').' - '.$plugin->get_lang('CoursesInSessionsDoesntDisplayHere'),
|
||||
'info'
|
||||
)
|
||||
);
|
||||
|
||||
$pageSize = BuyCoursesPlugin::PAGINATION_PAGE_SIZE;
|
||||
$type = isset($_GET['type']) ? (int) $_GET['type'] : BuyCoursesPlugin::PRODUCT_TYPE_COURSE;
|
||||
$currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$first = $pageSize * ($currentPage - 1);
|
||||
|
||||
$qb = $plugin->getCourseList($first, $pageSize);
|
||||
$query = $qb->getQuery();
|
||||
$courses = new Paginator($query, $fetchJoinCollection = true);
|
||||
foreach ($courses as $course) {
|
||||
$item = $plugin->getItemByProduct($course->getId(), BuyCoursesPlugin::PRODUCT_TYPE_COURSE);
|
||||
$course->buyCourseData = [];
|
||||
if ($item !== false) {
|
||||
$course->buyCourseData = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$totalItems = count($courses);
|
||||
$pagesCount = ceil($totalItems / $pageSize);
|
||||
|
||||
$pagination = BuyCoursesPlugin::returnPagination(
|
||||
api_get_self(),
|
||||
$currentPage,
|
||||
$pagesCount,
|
||||
$totalItems,
|
||||
['type' => $type]
|
||||
);
|
||||
|
||||
// breadcrumbs
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php',
|
||||
'name' => $plugin->get_lang('plugin_title'),
|
||||
];
|
||||
|
||||
$templateName = $plugin->get_lang('AvailableCourses');
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
$tpl->assign('product_type_course', BuyCoursesPlugin::PRODUCT_TYPE_COURSE);
|
||||
$tpl->assign('product_type_session', BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
|
||||
$tpl->assign('courses', $courses);
|
||||
$tpl->assign('course_pagination', $pagination);
|
||||
$tpl->assign('sessions_are_included', $includeSession);
|
||||
$tpl->assign('services_are_included', $includeServices);
|
||||
$tpl->assign('tax_enable', $taxEnable);
|
||||
|
||||
if ($taxEnable) {
|
||||
$globalParameters = $plugin->getGlobalParameters();
|
||||
$tpl->assign('global_tax_perc', $globalParameters['global_tax_perc']);
|
||||
$tpl->assign('tax_applies_to', $globalParameters['tax_applies_to']);
|
||||
$tpl->assign('tax_name', $globalParameters['tax_name']);
|
||||
}
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/list.tpl');
|
||||
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
96
plugin/buycourses/src/list_coupon.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of couponsof the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
if (isset($_GET['coupon_id'])) {
|
||||
$coupon = $plugin->getCouponInfo($_GET['coupon_id']);
|
||||
|
||||
if (empty($coupon)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$urlToRedirect = api_get_self().'?';
|
||||
|
||||
switch ($_GET['action']) {
|
||||
case 'deactivate':
|
||||
//activate coupon
|
||||
break;
|
||||
case 'activate':
|
||||
//deactivate coupon
|
||||
break;
|
||||
}
|
||||
|
||||
header("Location: $urlToRedirect");
|
||||
exit;
|
||||
}
|
||||
|
||||
$discountTypes = $plugin->getCouponDiscountTypes();
|
||||
$couponStatuses = $plugin->getCouponStatuses();
|
||||
|
||||
$selectedFilterType = '0';
|
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::COUPON_STATUS_ACTIVE;
|
||||
|
||||
$form = new FormValidator('search', 'get');
|
||||
|
||||
if ($form->validate()) {
|
||||
$selectedStatus = $form->getSubmitValue('status');
|
||||
|
||||
if ($selectedStatus === false) {
|
||||
$selectedStatus = BuyCoursesPlugin::COUPON_STATUS_ACTIVE;
|
||||
}
|
||||
|
||||
if ($selectedFilterType === false) {
|
||||
$selectedFilterType = '0';
|
||||
}
|
||||
}
|
||||
|
||||
$form->addHtml('<div id="report-by-status" '.($selectedFilterType !== '0' ? 'style="display:none"' : '').'>');
|
||||
$form->addSelect('status', $plugin->get_lang('CouponStatus'), $couponStatuses);
|
||||
$form->addHtml('</div>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
$form->setDefaults([
|
||||
'filter_type' => $selectedFilterType,
|
||||
'status' => $selectedStatus,
|
||||
]);
|
||||
|
||||
$coupons = $plugin->getCouponsListByStatus($selectedStatus);
|
||||
|
||||
foreach ($coupons as &$coupon) {
|
||||
if ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_PERCENTAGE) {
|
||||
$coupon['discount_value'] = $coupon['discount_amount']." %";
|
||||
} elseif ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_AMOUNT) {
|
||||
$coupon['discount_value'] = $plugin->getPriceWithCurrencyFromIsoCode($coupon['discount_amount'], $coupon['iso_code']);
|
||||
}
|
||||
$coupon['discount_type'] = $discountTypes[$coupon['discount_type']];
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => '../index.php', 'name' => $plugin->get_lang('plugin_title')];
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = $plugin->get_lang('CouponList');
|
||||
$template = new Template($templateName);
|
||||
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('selected_status', $selectedStatus);
|
||||
$template->assign('coupon_list', $coupons);
|
||||
$template->assign('coupon_status_active', BuyCoursesPlugin::COUPON_STATUS_ACTIVE);
|
||||
$template->assign('coupon_status_disable', BuyCoursesPlugin::COUPON_STATUS_DISABLE);
|
||||
|
||||
$content = $template->fetch('buycourses/view/list_coupon.tpl');
|
||||
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
71
plugin/buycourses/src/list_service.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* Configuration script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
if (!$includeServices) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$taxEnable = $plugin->get('tax_enable') === 'true';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
get_lang('Info').' - '.$plugin->get_lang('CoursesInSessionsDoesntDisplayHere'),
|
||||
'info'
|
||||
)
|
||||
);
|
||||
|
||||
$pageSize = BuyCoursesPlugin::PAGINATION_PAGE_SIZE;
|
||||
$currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$first = $pageSize * ($currentPage - 1);
|
||||
|
||||
$services = $plugin->getServices($first, $pageSize);
|
||||
$totalItems = $plugin->getServices(0, 1000000000, 'count');
|
||||
$pagesCount = ceil($totalItems / $pageSize);
|
||||
|
||||
$pagination = BuyCoursesPlugin::returnPagination(api_get_self(), $currentPage, $pagesCount, $totalItems);
|
||||
|
||||
// breadcrumbs
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php',
|
||||
'name' => $plugin->get_lang('plugin_title'),
|
||||
];
|
||||
|
||||
$templateName = $plugin->get_lang('Services');
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
$tpl->assign('product_type_course', BuyCoursesPlugin::PRODUCT_TYPE_COURSE);
|
||||
$tpl->assign('product_type_session', BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
|
||||
$tpl->assign('sessions_are_included', $includeSession);
|
||||
$tpl->assign('services_are_included', $includeServices);
|
||||
$tpl->assign('tax_enable', $taxEnable);
|
||||
$tpl->assign('services', $services);
|
||||
$tpl->assign('service_pagination', $pagination);
|
||||
|
||||
if ($taxEnable) {
|
||||
$globalParameters = $plugin->getGlobalParameters();
|
||||
$tpl->assign('global_tax_perc', $globalParameters['global_tax_perc']);
|
||||
$tpl->assign('tax_applies_to', $globalParameters['tax_applies_to']);
|
||||
$tpl->assign('tax_name', $globalParameters['tax_name']);
|
||||
}
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/list.tpl');
|
||||
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
89
plugin/buycourses/src/list_session.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* Configuration script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
|
||||
if (!$includeSession) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
$taxEnable = $plugin->get('tax_enable') === 'true';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
get_lang('Info').' - '.$plugin->get_lang('CoursesInSessionsDoesntDisplayHere'),
|
||||
'info'
|
||||
)
|
||||
);
|
||||
|
||||
$pageSize = BuyCoursesPlugin::PAGINATION_PAGE_SIZE;
|
||||
$currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$first = $pageSize * ($currentPage - 1);
|
||||
|
||||
// breadcrumbs
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php',
|
||||
'name' => $plugin->get_lang('plugin_title'),
|
||||
];
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = $plugin->get_lang('Sessions');
|
||||
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
$tpl->assign('product_type_course', BuyCoursesPlugin::PRODUCT_TYPE_COURSE);
|
||||
$tpl->assign('product_type_session', BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
|
||||
$tpl->assign('sessions_are_included', $includeSession);
|
||||
$tpl->assign('services_are_included', $includeServices);
|
||||
$tpl->assign('tax_enable', $taxEnable);
|
||||
|
||||
$query = CoursesAndSessionsCatalog::browseSessions(null, ['start' => $first, 'length' => $pageSize], true);
|
||||
$sessions = new Paginator($query, $fetchJoinCollection = true);
|
||||
foreach ($sessions as $session) {
|
||||
$item = $plugin->getItemByProduct($session->getId(), BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
|
||||
$session->buyCourseData = [];
|
||||
if ($item !== false) {
|
||||
$session->buyCourseData = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$totalItems = count($sessions);
|
||||
$pagesCount = ceil($totalItems / $pageSize);
|
||||
|
||||
$pagination = BuyCoursesPlugin::returnPagination(
|
||||
api_get_self(),
|
||||
$currentPage,
|
||||
$pagesCount,
|
||||
$totalItems,
|
||||
['type' => BuyCoursesPlugin::PRODUCT_TYPE_SESSION]
|
||||
);
|
||||
|
||||
$tpl->assign('sessions', $sessions);
|
||||
$tpl->assign('session_pagination', $pagination);
|
||||
|
||||
if ($taxEnable) {
|
||||
$globalParameters = $plugin->getGlobalParameters();
|
||||
$tpl->assign('global_tax_perc', $globalParameters['global_tax_perc']);
|
||||
$tpl->assign('tax_applies_to', $globalParameters['tax_applies_to']);
|
||||
$tpl->assign('tax_name', $globalParameters['tax_name']);
|
||||
}
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/list.tpl');
|
||||
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
221
plugin/buycourses/src/panel.ajax.php
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Responses to AJAX calls.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable');
|
||||
$commissionsEnable = $plugin->get('commissions_enable');
|
||||
|
||||
$action = isset($_GET['a']) ? $_GET['a'] : null;
|
||||
|
||||
switch ($action) {
|
||||
case 'saleInfo':
|
||||
//$saleId is only used in getSale() and is always filtered there
|
||||
$saleId = isset($_POST['id']) ? $_POST['id'] : '';
|
||||
$sale = $plugin->getSale($saleId);
|
||||
$productType = ($sale['product_type'] == 1) ? get_lang('Course') : get_lang('Session');
|
||||
$paymentType = ($sale['payment_type'] == 1) ? 'Paypal' : $plugin->get_lang('BankTransfer');
|
||||
$productInfo = ($sale['product_type'] == 1)
|
||||
? api_get_course_info_by_id($sale['product_id'])
|
||||
: api_get_session_info($sale['product_id']);
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
if ($sale['product_type'] == 1) {
|
||||
$productImage = $productInfo['course_image_large'];
|
||||
} else {
|
||||
$productImage = ($productInfo['image'])
|
||||
? $productInfo['image']
|
||||
: Template::get_icon_path('session_default.png');
|
||||
}
|
||||
|
||||
$userInfo = api_get_user_info($sale['user_id']);
|
||||
|
||||
$html = '<h2>'.$sale['product_name'].'</h2>';
|
||||
$html .= '<div class="row">';
|
||||
$html .= '<div class="col-sm-6 col-md-6">';
|
||||
$html .= '<ul>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('OrderPrice').':</b> '.$sale['price'].'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('CurrencyType').':</b> '.$currency['iso_code'].'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('ProductType').':</b> '.$productType.'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('OrderDate').':</b> '
|
||||
.api_format_date($sale['date'], DATE_TIME_FORMAT_LONG_24H).'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('Buyer').':</b> '.$userInfo['complete_name'].'</li>';
|
||||
$html .= '<li><b>'.$plugin->get_lang('PaymentMethods').':</b> '.$paymentType.'</li>';
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="col-sm-6 col-md-6">';
|
||||
$html .= '<img class="thumbnail" src="'.$productImage.'" >';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
echo $html;
|
||||
break;
|
||||
case 'stats':
|
||||
$stats = [];
|
||||
$stats['completed_count'] = 0;
|
||||
$stats['completed_total_amount'] = 0;
|
||||
$stats['pending_count'] = 0;
|
||||
$stats['pending_total_amount'] = 0;
|
||||
$stats['canceled_count'] = 0;
|
||||
$stats['canceled_total_amount'] = 0;
|
||||
|
||||
$completedPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED);
|
||||
$pendingPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING);
|
||||
$canceledPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_CANCELED);
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
foreach ($completedPayouts as $completed) {
|
||||
$stats['completed_count'] = count($completedPayouts);
|
||||
$stats['completed_total_amount'] += $completed['commission'];
|
||||
$stats['completed_total_amount'] = number_format($stats['completed_total_amount'], 2);
|
||||
}
|
||||
|
||||
foreach ($pendingPayouts as $pending) {
|
||||
$stats['pending_count'] = count($pendingPayouts);
|
||||
$stats['pending_total_amount'] += $pending['commission'];
|
||||
$stats['pending_total_amount'] = number_format($stats['pending_total_amount'], 2);
|
||||
}
|
||||
|
||||
foreach ($canceledPayouts as $canceled) {
|
||||
$stats['canceled_count'] = count($canceledPayouts);
|
||||
$stats['canceled_total_amount'] += $canceled['commission'];
|
||||
$stats['canceled_total_amount'] = number_format($stats['canceled_total_amount'], 2);
|
||||
}
|
||||
|
||||
$html = '
|
||||
<div class="row">
|
||||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
'.get_plugin_lang("PayoutsTotalCompleted", "BuyCoursesPlugin").'
|
||||
<b>'.$stats['completed_count'].'</b> - '.get_plugin_lang("TotalAmount", "BuyCoursesPlugin").'
|
||||
<b>'.$stats['completed_total_amount'].' '.$currency['iso_code'].'</b>
|
||||
</li>
|
||||
<li>'.get_plugin_lang("PayoutsTotalPending", "BuyCoursesPlugin").'
|
||||
<b>'.$stats['pending_count'].'</b> - '.get_plugin_lang("TotalAmount", "BuyCoursesPlugin").'
|
||||
<b>'.$stats['pending_total_amount'].' '.$currency['iso_code'].'</b>
|
||||
</li>
|
||||
<li>'.get_plugin_lang("PayoutsTotalCanceled", "BuyCoursesPlugin").'
|
||||
<b>'.$stats['canceled_count'].'</b> - '.get_plugin_lang("TotalAmount", "BuyCoursesPlugin").'
|
||||
<b>'.$stats['canceled_total_amount'].' '.$currency['iso_code'].'</b>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
';
|
||||
echo $html;
|
||||
break;
|
||||
case 'processPayout':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$html = '';
|
||||
$allPays = [];
|
||||
$totalAccounts = 0;
|
||||
$totalPayout = 0;
|
||||
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : '';
|
||||
|
||||
if (!$payouts) {
|
||||
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($payouts as $index => $id) {
|
||||
$allPays[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id);
|
||||
}
|
||||
|
||||
foreach ($allPays as $payout) {
|
||||
$totalPayout += number_format($payout['commission'], 2);
|
||||
$totalAccounts++;
|
||||
}
|
||||
|
||||
$currentCurrency = $plugin->getSelectedCurrency();
|
||||
|
||||
$isoCode = $currentCurrency['iso_code'];
|
||||
|
||||
$html .= '<p>'.get_plugin_lang("VerifyTotalAmountToProceedPayout", "BuyCoursesPlugin").'</p>';
|
||||
$html .= '
|
||||
<p>
|
||||
<ul>
|
||||
<li>'.get_plugin_lang("TotalAcounts", "BuyCoursesPlugin").' <b>'.$totalAccounts.'</b></li>
|
||||
<li>'.get_plugin_lang("TotalPayout", "BuyCoursesPlugin").' <b>'.$isoCode.' '.$totalPayout.'</b></li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>'.get_plugin_lang("CautionThisProcessCantBeCanceled", "BuyCoursesPlugin").'</p>
|
||||
<br /><br />
|
||||
<div id="spinner" class="text-center"></div>
|
||||
';
|
||||
|
||||
echo $html;
|
||||
break;
|
||||
|
||||
case 'proceedPayout':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$paypalParams = $plugin->getPaypalParams();
|
||||
$pruebas = $paypalParams['sandbox'] == 1;
|
||||
$paypalUsername = $paypalParams['username'];
|
||||
$paypalPassword = $paypalParams['password'];
|
||||
$paypalSignature = $paypalParams['signature'];
|
||||
require_once "paypalfunctions.php";
|
||||
$allPayouts = [];
|
||||
$totalAccounts = 0;
|
||||
$totalPayout = 0;
|
||||
|
||||
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : '';
|
||||
|
||||
if (!$payouts) {
|
||||
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($payouts as $index => $id) {
|
||||
$allPayouts[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id);
|
||||
}
|
||||
|
||||
$currentCurrency = $plugin->getSelectedCurrency();
|
||||
|
||||
$isoCode = $currentCurrency['iso_code'];
|
||||
|
||||
$result = MassPayment($allPayouts, $isoCode);
|
||||
|
||||
if ($result['ACK'] === 'Success') {
|
||||
foreach ($allPayouts as $payout) {
|
||||
$plugin->setStatusPayouts($payout['id'], BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED);
|
||||
}
|
||||
echo Display::return_message(get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"), 'success', false);
|
||||
} else {
|
||||
echo Display::return_message(
|
||||
'<b>'.$result['L_SEVERITYCODE0'].' '.$result['L_ERRORCODE0'].'</b> - '
|
||||
.$result['L_SHORTMESSAGE0'].'<br /><ul><li>'.$result['L_LONGMESSAGE0'].'</li></ul>',
|
||||
'error',
|
||||
false
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'cancelPayout':
|
||||
if (api_is_anonymous()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$payoutId = isset($_POST['id']) ? $_POST['id'] : '';
|
||||
$plugin->setStatusPayouts($payoutId, BuyCoursesPlugin::PAYOUT_STATUS_CANCELED);
|
||||
echo '';
|
||||
break;
|
||||
}
|
||||
exit;
|
||||
538
plugin/buycourses/src/paymentsetup.php
Normal file
@@ -0,0 +1,538 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Configuration page for payment methods for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable');
|
||||
$transferEnable = $plugin->get('transfer_enable');
|
||||
$tpvRedsysEnable = $plugin->get('tpv_redsys_enable');
|
||||
$commissionsEnable = $plugin->get('commissions_enable');
|
||||
$culqiEnable = $plugin->get('culqi_enable');
|
||||
$stripeEnable = $plugin->get('stripe_enable') === 'true';
|
||||
$cecabankEnable = $plugin->get('cecabank_enable') === 'true';
|
||||
|
||||
if (isset($_GET['action'], $_GET['id'])) {
|
||||
if ($_GET['action'] == 'delete_taccount') {
|
||||
$plugin->deleteTransferAccount($_GET['id']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('ItemRemoved'), 'success')
|
||||
);
|
||||
|
||||
header('Location: '.api_get_self());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$globalSettingForm = new FormValidator('currency');
|
||||
|
||||
if ($globalSettingForm->validate()) {
|
||||
$globalSettingFormValues = $globalSettingForm->getSubmitValues();
|
||||
|
||||
$plugin->saveCurrency($globalSettingFormValues['currency']);
|
||||
unset($globalSettingFormValues['currency']);
|
||||
$plugin->saveGlobalParameters($globalSettingFormValues);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self());
|
||||
exit;
|
||||
}
|
||||
|
||||
$currencies = $plugin->getCurrencies();
|
||||
|
||||
$currencySelect = $globalSettingForm->addSelect(
|
||||
'currency',
|
||||
[
|
||||
$plugin->get_lang('CurrencyType'),
|
||||
$plugin->get_lang('InfoCurrency'),
|
||||
],
|
||||
[get_lang('Select')]
|
||||
);
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$currencyText = implode(
|
||||
' => ',
|
||||
[
|
||||
$currency['country_name'],
|
||||
$currency['iso_code'],
|
||||
]
|
||||
);
|
||||
$currencyValue = $currency['id'];
|
||||
$currencySelect->addOption($currencyText, $currencyValue);
|
||||
|
||||
if ($currency['status']) {
|
||||
$currencySelect->setSelected($currencyValue);
|
||||
}
|
||||
}
|
||||
|
||||
$globalSettingForm->addTextarea(
|
||||
'terms_and_conditions',
|
||||
[
|
||||
get_lang('TermsAndConditions'),
|
||||
$plugin->get_lang('WriteHereTheTermsAndConditionsOfYourECommerce'),
|
||||
]
|
||||
);
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'text',
|
||||
'sale_email',
|
||||
$plugin->get_lang('SaleEmail')
|
||||
);
|
||||
|
||||
$taxEnable = $plugin->get('tax_enable') === 'true';
|
||||
$invoicingEnable = $plugin->get('invoicing_enable') === 'true';
|
||||
|
||||
if ($taxEnable) {
|
||||
$globalSettingForm->addHtml('<hr/>');
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'number',
|
||||
'global_tax_perc',
|
||||
[$plugin->get_lang('GlobalTaxPerc'), $plugin->get_lang('GlobalTaxPercDescription'), '%'],
|
||||
['step' => 1]
|
||||
);
|
||||
|
||||
$taxAppliesTo = $plugin->getTaxAppliesTo();
|
||||
|
||||
$taxTypeSelect = $globalSettingForm->addSelect(
|
||||
'tax_applies_to',
|
||||
$plugin->get_lang('TaxAppliesTo'),
|
||||
[get_lang('Select')]
|
||||
);
|
||||
|
||||
foreach ($taxAppliesTo as $key => $value) {
|
||||
$optionText = $value;
|
||||
$optionyValue = $key;
|
||||
|
||||
$taxTypeSelect->addOption($optionText, $optionyValue);
|
||||
}
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'text',
|
||||
'tax_name',
|
||||
$plugin->get_lang('TaxNameCustom'),
|
||||
['placeholder' => $plugin->get_lang('TaxNameExamples')]
|
||||
);
|
||||
}
|
||||
|
||||
if ($invoicingEnable) {
|
||||
$globalSettingForm->addHtml('<hr/>');
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'text',
|
||||
'seller_name',
|
||||
$plugin->get_lang('SellerName')
|
||||
);
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'text',
|
||||
'seller_id',
|
||||
$plugin->get_lang('SellerId')
|
||||
);
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'text',
|
||||
'seller_address',
|
||||
$plugin->get_lang('SellerAddress')
|
||||
);
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'text',
|
||||
'seller_email',
|
||||
$plugin->get_lang('SellerEmail')
|
||||
);
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'number',
|
||||
'next_number_invoice',
|
||||
[$plugin->get_lang('NextNumberInvoice'), $plugin->get_lang('NextNumberInvoiceDescription')],
|
||||
['step' => 1]
|
||||
);
|
||||
|
||||
$globalSettingForm->addElement(
|
||||
'text',
|
||||
'invoice_series',
|
||||
[$plugin->get_lang('InvoiceSeries'), $plugin->get_lang('InvoiceSeriesDescription')]
|
||||
);
|
||||
}
|
||||
|
||||
$globalSettingForm->addButtonSave(get_lang('Save'));
|
||||
$globalSettingForm->setDefaults($plugin->getGlobalParameters());
|
||||
|
||||
$termsAndConditionsForm = new FormValidator('termsconditions');
|
||||
|
||||
$paypalForm = new FormValidator('paypal');
|
||||
|
||||
if ($paypalForm->validate()) {
|
||||
$paypalFormValues = $paypalForm->getSubmitValues();
|
||||
|
||||
$plugin->savePaypalParams($paypalFormValues);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self());
|
||||
exit;
|
||||
}
|
||||
|
||||
$paypalForm->addText(
|
||||
'username',
|
||||
$plugin->get_lang('ApiUsername'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$paypalForm->addText(
|
||||
'password',
|
||||
$plugin->get_lang('ApiPassword'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$paypalForm->addText(
|
||||
'signature',
|
||||
$plugin->get_lang('ApiSignature'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$paypalForm->addCheckBox('sandbox', null, $plugin->get_lang('Sandbox'));
|
||||
$paypalForm->addButtonSave(get_lang('Save'));
|
||||
$paypalForm->setDefaults($plugin->getPaypalParams());
|
||||
|
||||
// TPV Redsys
|
||||
$htmlTpvRedsys = Display::return_message($plugin->get_lang('NotFindRedsysFile'), 'warning', false);
|
||||
if (file_exists(api_get_path(SYS_PLUGIN_PATH).'buycourses/resources/apiRedsys.php')) {
|
||||
$tpvRedsysForm = new FormValidator('tpv_redsys');
|
||||
$tpvRedsysForm->addHtml(
|
||||
Display::return_message($plugin->get_lang('InfoTpvRedsysApiCredentials'), 'info', false)
|
||||
);
|
||||
|
||||
if ($tpvRedsysForm->validate()) {
|
||||
$tpvRedsysFormValues = $tpvRedsysForm->getSubmitValues();
|
||||
|
||||
$plugin->saveTpvRedsysParams($tpvRedsysFormValues);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self());
|
||||
exit;
|
||||
}
|
||||
|
||||
$tpvRedsysForm->addText(
|
||||
'merchantcode',
|
||||
[$plugin->get_lang('DS_MERCHANT_MERCHANTCODE'), 'DS_MERCHANT_MERCHANTCODE'],
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$tpvRedsysForm->addText(
|
||||
'terminal',
|
||||
[$plugin->get_lang('DS_MERCHANT_TERMINAL'), 'DS_MERCHANT_TERMINAL'],
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$tpvRedsysForm->addText(
|
||||
'currency',
|
||||
[$plugin->get_lang('DS_MERCHANT_CURRENCY'), 'DS_MERCHANT_CURRENCY'],
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$tpvRedsysForm->addText(
|
||||
'kc',
|
||||
$plugin->get_lang('kc'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$tpvRedsysForm->addText(
|
||||
'url_redsys',
|
||||
$plugin->get_lang('url_redsys'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$tpvRedsysForm->addText(
|
||||
'url_redsys_sandbox',
|
||||
$plugin->get_lang('url_redsys_sandbox'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$tpvRedsysForm->addCheckBox('sandbox', null, $plugin->get_lang('Sandbox'));
|
||||
$tpvRedsysForm->addButtonSave(get_lang('Save'));
|
||||
$tpvRedsysForm->setDefaults($plugin->getTpvRedsysParams());
|
||||
|
||||
$htmlTpvRedsys = $tpvRedsysForm->returnForm();
|
||||
}
|
||||
|
||||
// Platform Commissions
|
||||
|
||||
$commissionForm = new FormValidator('commissions');
|
||||
|
||||
if ($commissionForm->validate()) {
|
||||
$commissionFormValues = $commissionForm->getSubmitValues();
|
||||
|
||||
$plugin->updateCommission($commissionFormValues);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self());
|
||||
exit;
|
||||
}
|
||||
|
||||
$commissionForm->addElement(
|
||||
'number',
|
||||
'commission',
|
||||
[$plugin->get_lang('Commission'), null, '%'],
|
||||
['step' => 1, 'cols-size' => [3, 7, 1], 'min' => 0, 'max' => 100]
|
||||
);
|
||||
|
||||
$commissionForm->addButtonSave(get_lang('Save'));
|
||||
$commissionForm->setDefaults($plugin->getPlatformCommission());
|
||||
|
||||
$transferForm = new FormValidator('transfer_account');
|
||||
|
||||
if ($transferForm->validate()) {
|
||||
$transferFormValues = $transferForm->getSubmitValues();
|
||||
|
||||
$plugin->saveTransferAccount($transferFormValues);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self());
|
||||
exit;
|
||||
}
|
||||
|
||||
$transferForm->addText(
|
||||
'tname',
|
||||
get_lang('Name'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$transferForm->addText(
|
||||
'taccount',
|
||||
$plugin->get_lang('BankAccount'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$transferForm->addText(
|
||||
'tswift',
|
||||
[$plugin->get_lang('SWIFT'), $plugin->get_lang('SWIFT_help')],
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$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');
|
||||
|
||||
if ($culqiForm->validate()) {
|
||||
$culqiFormValues = $culqiForm->getSubmitValues();
|
||||
|
||||
$plugin->saveCulqiParameters($culqiFormValues);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self());
|
||||
exit;
|
||||
}
|
||||
|
||||
$culqiForm->addText(
|
||||
'commerce_code',
|
||||
$plugin->get_lang('CommerceCode'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$culqiForm->addText(
|
||||
'api_key',
|
||||
$plugin->get_lang('ApiPassword'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$culqiForm->addCheckBox('integration', null, $plugin->get_lang('Sandbox'));
|
||||
$culqiForm->addButtonSave(get_lang('Save'));
|
||||
$culqiForm->setDefaults($plugin->getCulqiParams());
|
||||
|
||||
// Stripe main configuration
|
||||
|
||||
$stripeForm = new FormValidator('stripe_config');
|
||||
|
||||
if ($stripeForm->validate()) {
|
||||
$stripeFormValues = $stripeForm->getSubmitValues();
|
||||
|
||||
$plugin->saveStripeParameters($stripeFormValues);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self());
|
||||
exit;
|
||||
}
|
||||
|
||||
$stripeForm->addText(
|
||||
'account_id',
|
||||
$plugin->get_lang('StripeAccountId'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$stripeForm->addText(
|
||||
'secret_key',
|
||||
$plugin->get_lang('StripeSecret'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$stripeForm->addText(
|
||||
'endpoint_secret',
|
||||
$plugin->get_lang('StripeEndpointSecret'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$stripeForm->addButtonSave(get_lang('Save'));
|
||||
$stripeForm->setDefaults($plugin->getStripeParams());
|
||||
|
||||
// Cecabank main configuration
|
||||
|
||||
$cecabankForm = new FormValidator('cecabank_config');
|
||||
|
||||
if ($cecabankForm->validate()) {
|
||||
$cecabankFormValues = $cecabankForm->getSubmitValues();
|
||||
|
||||
$plugin->saveCecabankParameters($cecabankFormValues);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('Saved'), 'success')
|
||||
);
|
||||
|
||||
header('Location:'.api_get_self());
|
||||
exit;
|
||||
}
|
||||
|
||||
$cecabankForm->addText(
|
||||
'crypto_key',
|
||||
$plugin->get_lang('CecaSecret'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$cecabankForm->addText(
|
||||
'url',
|
||||
$plugin->get_lang('CecaUrl'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$cecabankForm->addText(
|
||||
'merchant_id',
|
||||
$plugin->get_lang('CecaMerchanId'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$cecabankForm->addText(
|
||||
'acquirer_bin',
|
||||
$plugin->get_lang('CecaAcquirerId'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$cecabankForm->addText(
|
||||
'terminal_id',
|
||||
$plugin->get_lang('CecaTerminalId'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$cecabankForm->addText(
|
||||
'cypher',
|
||||
$plugin->get_lang('CecaCypher'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$cecabankForm->addText(
|
||||
'exponent',
|
||||
$plugin->get_lang('CecaExponent'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$cecabankForm->addText(
|
||||
'supported_payment',
|
||||
$plugin->get_lang('CecaSupportedPayment'),
|
||||
false,
|
||||
['cols-size' => [3, 8, 1]]
|
||||
);
|
||||
$cecabankForm->addButtonSave(get_lang('Save'));
|
||||
$cecabankForm->setDefaults($plugin->getCecabankParams());
|
||||
|
||||
// breadcrumbs
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php',
|
||||
'name' => $plugin->get_lang('plugin_title'),
|
||||
];
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = $plugin->get_lang('PaymentsConfiguration');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('header', $templateName);
|
||||
$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);
|
||||
$tpl->assign('commissions_enable', $commissionsEnable);
|
||||
$tpl->assign('transfer_enable', $transferEnable);
|
||||
$tpl->assign('culqi_enable', $culqiEnable);
|
||||
$tpl->assign('tpv_redsys_enable', $tpvRedsysEnable);
|
||||
$tpl->assign('tpv_redsys_form', $htmlTpvRedsys);
|
||||
$tpl->assign('stripe_enable', $stripeEnable);
|
||||
$tpl->assign('stripe_form', $stripeForm->returnForm());
|
||||
$tpl->assign('cecabank_enable', $cecabankEnable);
|
||||
$tpl->assign('cecabank_form', $cecabankForm->returnForm());
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/paymentsetup.tpl');
|
||||
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
65
plugin/buycourses/src/payout_panel.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* User Panel.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
/**
|
||||
* Initialization.
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
|
||||
$userInfo = api_get_user_info();
|
||||
|
||||
$payouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED, 0, $userInfo['id']);
|
||||
|
||||
$payoutList = [];
|
||||
|
||||
foreach ($payouts as $payout) {
|
||||
$payoutList[] = [
|
||||
'id' => $payout['id'],
|
||||
'sale_id' => $payout['sale_id'],
|
||||
'reference' => $payout['sale_reference'],
|
||||
'date' => api_format_date($payout['date'], DATE_TIME_FORMAT_LONG_24H),
|
||||
'payout_date' => ($payout['payout_date'] === '0000-00-00 00:00:00')
|
||||
? '-'
|
||||
: api_format_date($payout['payout_date'], DATE_TIME_FORMAT_LONG_24H),
|
||||
'currency' => $payout['iso_code'],
|
||||
'price' => $payout['item_price'],
|
||||
'commission' => $payout['commission'],
|
||||
'paypal_account' => $payout['paypal_account'],
|
||||
'status' => $payout['status'],
|
||||
];
|
||||
}
|
||||
|
||||
$toolbar = Display::toolbarButton(
|
||||
$plugin->get_lang('CourseListOnSale'),
|
||||
'course_catalog.php',
|
||||
'search-plus',
|
||||
'primary',
|
||||
['title' => $plugin->get_lang('CourseListOnSale')]
|
||||
);
|
||||
|
||||
$templateName = get_lang('TabsDashboard');
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('showing_courses', true);
|
||||
$tpl->assign('sessions_are_included', $includeSessions);
|
||||
$tpl->assign('payout_list', $payoutList);
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/payout_panel.tpl');
|
||||
|
||||
$tpl->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
94
plugin/buycourses/src/payout_report.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* List of pending payments of the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
//Initialization
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
$htmlHeadXtra[] =
|
||||
'<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$commissionsEnable = $plugin->get('commissions_enable');
|
||||
$payoutStatuses = $plugin->getPayoutStatuses();
|
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_COMPLETED;
|
||||
|
||||
if ($commissionsEnable !== "true") {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$form = new FormValidator('search', 'get');
|
||||
|
||||
if ($form->validate()) {
|
||||
$selectedStatus = $form->getSubmitValue('status');
|
||||
|
||||
if ($selectedStatus === false) {
|
||||
$selectedStatus = BuyCoursesPlugin::PAYOUT_STATUS_PENDING;
|
||||
}
|
||||
}
|
||||
|
||||
$form->addSelect('status', $plugin->get_lang('PayoutStatus'), $payoutStatuses);
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
$form->setDefaults([
|
||||
'status' => $selectedStatus,
|
||||
]);
|
||||
|
||||
switch ($selectedStatus) {
|
||||
case '2':
|
||||
$payouts = $plugin->getPayouts($selectedStatus);
|
||||
|
||||
break;
|
||||
case '1':
|
||||
$payouts = $plugin->getPayouts($selectedStatus);
|
||||
|
||||
break;
|
||||
case '0':
|
||||
default:
|
||||
$payouts = $plugin->getPayouts();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$payoutList = [];
|
||||
|
||||
foreach ($payouts as $payout) {
|
||||
$payoutList[] = [
|
||||
'id' => $payout['id'],
|
||||
'sale_id' => $payout['sale_id'],
|
||||
'reference' => $payout['sale_reference'],
|
||||
'date' => api_format_date($payout['date'], DATE_TIME_FORMAT_LONG_24H),
|
||||
'payout_date' => ($payout['payout_date'] === '0000-00-00 00:00:00')
|
||||
? '-'
|
||||
: api_format_date($payout['payout_date'], DATE_TIME_FORMAT_LONG_24H),
|
||||
'currency' => $payout['iso_code'],
|
||||
'price' => $payout['item_price'],
|
||||
'commission' => $payout['commission'],
|
||||
'beneficiary' => api_get_person_name($payout['firstname'], $payout['lastname']),
|
||||
'paypal_account' => $payout['paypal_account'],
|
||||
'status' => $payout['status'],
|
||||
];
|
||||
}
|
||||
|
||||
$templateName = $plugin->get_lang('PayoutReport');
|
||||
|
||||
$template = new Template($templateName);
|
||||
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('payout_list', $payoutList);
|
||||
$template->assign('selected_status', $selectedStatus);
|
||||
|
||||
$content = $template->fetch('buycourses/view/payout_report.tpl');
|
||||
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
55
plugin/buycourses/src/paypal_payout.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List page for Paypal Payout for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
/**
|
||||
* Initialization.
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable');
|
||||
$commissionsEnable = $plugin->get('commissions_enable');
|
||||
|
||||
if ($paypalEnable !== "true" && $commissionsEnable !== "true") {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$payouts = $plugin->getPayouts();
|
||||
|
||||
$payoutList = [];
|
||||
|
||||
foreach ($payouts as $payout) {
|
||||
$payoutList[] = [
|
||||
'id' => $payout['id'],
|
||||
'reference' => $payout['sale_reference'],
|
||||
'date' => api_format_date($payout['date'], DATE_TIME_FORMAT_LONG_24H),
|
||||
'currency' => $payout['iso_code'],
|
||||
'price' => $payout['item_price'],
|
||||
'commission' => $payout['commission'],
|
||||
'paypal_account' => $payout['paypal_account'],
|
||||
];
|
||||
}
|
||||
|
||||
$templateName = $plugin->get_lang('PaypalPayoutCommissions');
|
||||
|
||||
$template = new Template($templateName);
|
||||
|
||||
$template->assign('payout_list', $payoutList);
|
||||
|
||||
$content = $template->fetch('buycourses/view/paypal_payout.tpl');
|
||||
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
432
plugin/buycourses/src/paypalfunctions.php
Normal file
@@ -0,0 +1,432 @@
|
||||
<?php
|
||||
/*
|
||||
* PayPal API Module
|
||||
*
|
||||
* Defines all the global variables and the wrapper functions
|
||||
*/
|
||||
$PROXY_HOST = '127.0.0.1';
|
||||
$PROXY_PORT = '808';
|
||||
|
||||
$SandboxFlag = $pruebas;
|
||||
|
||||
/**
|
||||
* PayPal API Credentials
|
||||
* Replace <API_USERNAME> with your API Username
|
||||
* Replace <API_PASSWORD> with your API Password
|
||||
* Replace <API_SIGNATURE> with your Signature.
|
||||
*/
|
||||
$API_UserName = $paypalUsername;
|
||||
$API_Password = $paypalPassword;
|
||||
$API_Signature = $paypalSignature;
|
||||
|
||||
// BN Code is only applicable for partners
|
||||
$sBNCode = "PP-ECWizard";
|
||||
|
||||
/**
|
||||
* Define the PayPal Redirect URLs.
|
||||
* This is the URL that the buyer is first sent to do authorize payment with their paypal account
|
||||
* change the URL depending if you are testing on the sandbox or the live PayPal site.
|
||||
*
|
||||
* For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
|
||||
* For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token=
|
||||
*/
|
||||
if ($SandboxFlag == true) {
|
||||
$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
|
||||
$PAYPAL_URL = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
|
||||
} else {
|
||||
$API_Endpoint = "https://api-3t.paypal.com/nvp";
|
||||
$PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
|
||||
}
|
||||
|
||||
$USE_PROXY = false;
|
||||
$version = "93";
|
||||
|
||||
if (session_id() == "") {
|
||||
session_start();
|
||||
}
|
||||
|
||||
/**
|
||||
* An express checkout transaction starts with a token, that
|
||||
* identifies to PayPal your transaction
|
||||
* In this example, when the script sees a token, the script
|
||||
* knows that the buyer has already authorized payment through
|
||||
* paypal. If no token was found, the action is to send the buyer
|
||||
* to PayPal to first authorize payment.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Purpose: Prepares the parameters for the SetExpressCheckout API Call.
|
||||
* Inputs:
|
||||
* paymentAmount: Total value of the shopping cart
|
||||
* currencyCodeType: Currency code value the PayPal API
|
||||
* paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
|
||||
* returnURL: the page where buyers return to after they are done with the payment review on PayPal
|
||||
* cancelURL: the page where buyers return to when they cancel the payment review on PayPal.
|
||||
*/
|
||||
function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $extra)
|
||||
{
|
||||
// Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
|
||||
$nvpstr = "&PAYMENTREQUEST_0_AMT=".$paymentAmount;
|
||||
$nvpstr .= "&PAYMENTREQUEST_0_ITEMAMT=".$paymentAmount;
|
||||
$nvpstr .= "&PAYMENTREQUEST_0_PAYMENTACTION=".$paymentType;
|
||||
$nvpstr .= "&RETURNURL=".$returnURL;
|
||||
$nvpstr .= "&CANCELURL=".$cancelURL;
|
||||
$nvpstr .= "&PAYMENTREQUEST_0_CURRENCYCODE=".$currencyCodeType;
|
||||
$nvpstr .= $extra;
|
||||
|
||||
$_SESSION["currencyCodeType"] = $currencyCodeType;
|
||||
$_SESSION["PaymentType"] = $paymentType;
|
||||
|
||||
/**
|
||||
* Make the API call to PayPal
|
||||
* If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.
|
||||
* If an error occured, show the resulting errors.
|
||||
*/
|
||||
$resArray = hash_call("SetExpressCheckout", $nvpstr);
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
|
||||
$token = urldecode($resArray["TOKEN"]);
|
||||
$_SESSION['TOKEN'] = $token;
|
||||
}
|
||||
|
||||
return $resArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: Prepares the parameters for the SetExpressCheckout API Call.
|
||||
* Inputs:
|
||||
* paymentAmount: Total value of the shopping cart
|
||||
* currencyCodeType: Currency code value the PayPal API
|
||||
* paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
|
||||
* returnURL: the page where buyers return to after they are done with the payment review on PayPal
|
||||
* cancelURL: the page where buyers return to when they cancel the payment review on PayPal
|
||||
* shipToName: the Ship to name entered on the merchant's site
|
||||
* shipToStreet: the Ship to Street entered on the merchant's site
|
||||
* shipToCity: the Ship to City entered on the merchant's site
|
||||
* shipToState: the Ship to State entered on the merchant's site
|
||||
* shipToCountryCode: the Code for Ship to Country entered on the merchant's site
|
||||
* shipToZip: the Ship to ZipCode entered on the merchant's site
|
||||
* shipToStreet2: the Ship to Street2 entered on the merchant's site
|
||||
* phoneNum: the phoneNum entered on the merchant's site.
|
||||
*/
|
||||
function CallMarkExpressCheckout(
|
||||
$paymentAmount,
|
||||
$currencyCodeType,
|
||||
$paymentType,
|
||||
$returnURL,
|
||||
$cancelURL,
|
||||
$shipToName,
|
||||
$shipToStreet,
|
||||
$shipToCity,
|
||||
$shipToState,
|
||||
$shipToCountryCode,
|
||||
$shipToZip,
|
||||
$shipToStreet2,
|
||||
$phoneNum
|
||||
) {
|
||||
// Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
|
||||
$nvpstr = "&PAYMENTREQUEST_0_AMT=".$paymentAmount;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_PAYMENTACTION=".$paymentType;
|
||||
$nvpstr = $nvpstr."&RETURNURL=".$returnURL;
|
||||
$nvpstr = $nvpstr."&CANCELURL=".$cancelURL;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_CURRENCYCODE=".$currencyCodeType;
|
||||
$nvpstr = $nvpstr."&ADDROVERRIDE=1";
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTONAME=".$shipToName;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTREET=".$shipToStreet;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTREET2=".$shipToStreet2;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOCITY=".$shipToCity;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTATE=".$shipToState;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=".$shipToCountryCode;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOZIP=".$shipToZip;
|
||||
$nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOPHONENUM=".$phoneNum;
|
||||
|
||||
$_SESSION["currencyCodeType"] = $currencyCodeType;
|
||||
$_SESSION["PaymentType"] = $paymentType;
|
||||
|
||||
/**
|
||||
* Make the API call to PayPal
|
||||
* If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.
|
||||
* If an error occured, show the resulting errors.
|
||||
*/
|
||||
$resArray = hash_call("SetExpressCheckout", $nvpstr);
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
|
||||
$token = urldecode($resArray["TOKEN"]);
|
||||
$_SESSION['TOKEN'] = $token;
|
||||
}
|
||||
|
||||
return $resArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call.
|
||||
*
|
||||
* Inputs:
|
||||
* None
|
||||
* Returns:
|
||||
* The NVP Collection object of the GetExpressCheckoutDetails Call Response.
|
||||
*/
|
||||
function GetShippingDetails($token)
|
||||
{
|
||||
/**
|
||||
* At this point, the buyer has completed authorizing the payment
|
||||
* at PayPal. The function will call PayPal to obtain the details
|
||||
* of the authorization, including any shipping information of the
|
||||
* buyer. Remember, the authorization is not a completed transaction
|
||||
* at this state - the buyer still needs an additional step to finalize
|
||||
* the transaction.
|
||||
*
|
||||
* Build a second API request to PayPal, using the token as the
|
||||
* ID to get the details on the payment authorization
|
||||
*/
|
||||
$nvpstr = "&TOKEN=".$token;
|
||||
|
||||
/**
|
||||
* Make the API call and store the results in an array.
|
||||
* If the call was a success, show the authorization details, and provide
|
||||
* an action to complete the payment.
|
||||
* If failed, show the error.
|
||||
*/
|
||||
$resArray = hash_call("GetExpressCheckoutDetails", $nvpstr);
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
|
||||
$_SESSION['payer_id'] = $resArray['PAYERID'];
|
||||
}
|
||||
|
||||
return $resArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call.
|
||||
* Inputs:
|
||||
* sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart.
|
||||
* Returns:
|
||||
* The NVP Collection object of the GetExpressCheckoutDetails Call Response.
|
||||
*/
|
||||
function ConfirmPayment($FinalPaymentAmt)
|
||||
{
|
||||
/**
|
||||
* Gather the information to make the final call to
|
||||
* finalize the PayPal payment. The variable nvpstr
|
||||
* holds the name value pairs.
|
||||
*/
|
||||
|
||||
//Format the other parameters that were stored in the session from the previous calls
|
||||
|
||||
$token = urlencode($_SESSION['TOKEN']);
|
||||
$paymentType = urlencode($_SESSION['PaymentType']);
|
||||
$currencyCodeType = urlencode($_SESSION['currencyCodeType']);
|
||||
$payerID = urlencode($_SESSION['payer_id']);
|
||||
$serverName = urlencode($_SERVER['SERVER_NAME']);
|
||||
|
||||
$nvpstr =
|
||||
'&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTREQUEST_0_PAYMENTACTION='.$paymentType.'&PAYMENTREQUEST_0_AMT='
|
||||
.$FinalPaymentAmt;
|
||||
$nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE='.$currencyCodeType.'&IPADDRESS='.$serverName;
|
||||
$nvpstr = '&'.http_build_query([
|
||||
'TOKEN' => $token,
|
||||
'PAYERID' => $payerID,
|
||||
'PAYMENTACTION' => $paymentType,
|
||||
'PAYMENTREQUEST_0_AMT' => $FinalPaymentAmt,
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => $currencyCodeType,
|
||||
'IPADDRESS' => $serverName,
|
||||
'paymentactionspecified' => 'true',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Make the call to PayPal to finalize payment
|
||||
* If an error occured, show the resulting errors.
|
||||
*/
|
||||
$resArray = hash_call("DoExpressCheckoutPayment", $nvpstr);
|
||||
|
||||
/**
|
||||
* Display the API response back to the browser.
|
||||
* If the response from PayPal was a success, display the response parameters
|
||||
* If the response was an error, display the errors received using APIError.php.
|
||||
*/
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
return $resArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: This function makes a DoDirectPayment API call
|
||||
* Inputs:
|
||||
* paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
|
||||
* paymentAmount: total value of the shopping cart
|
||||
* currencyCode: currency code value the PayPal API
|
||||
* firstName: first name as it appears on credit card
|
||||
* lastName: last name as it appears on credit card
|
||||
* street: buyer's street address line as it appears on credit card
|
||||
* city: buyer's city
|
||||
* state: buyer's state
|
||||
* countryCode: buyer's country code
|
||||
* zip: buyer's zip
|
||||
* creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... )
|
||||
* creditCardNumber: buyers credit card number without any spaces, dashes or any other characters
|
||||
* expDate: credit card expiration date
|
||||
* cvv2: Card Verification Value
|
||||
* Returns:
|
||||
* The NVP Collection object of the DoDirectPayment Call Response.
|
||||
*/
|
||||
function DirectPayment(
|
||||
$paymentType,
|
||||
$paymentAmount,
|
||||
$creditCardType,
|
||||
$creditCardNumber,
|
||||
$expDate,
|
||||
$cvv2,
|
||||
$firstName,
|
||||
$lastName,
|
||||
$street,
|
||||
$city,
|
||||
$state,
|
||||
$zip,
|
||||
$countryCode,
|
||||
$currencyCode
|
||||
) {
|
||||
//Construct the parameter string that describes DoDirectPayment
|
||||
$nvpstr = "&AMT=".$paymentAmount;
|
||||
$nvpstr = $nvpstr."&CURRENCYCODE=".$currencyCode;
|
||||
$nvpstr = $nvpstr."&PAYMENTACTION=".$paymentType;
|
||||
$nvpstr = $nvpstr."&CREDITCARDTYPE=".$creditCardType;
|
||||
$nvpstr = $nvpstr."&ACCT=".$creditCardNumber;
|
||||
$nvpstr = $nvpstr."&EXPDATE=".$expDate;
|
||||
$nvpstr = $nvpstr."&CVV2=".$cvv2;
|
||||
$nvpstr = $nvpstr."&FIRSTNAME=".$firstName;
|
||||
$nvpstr = $nvpstr."&LASTNAME=".$lastName;
|
||||
$nvpstr = $nvpstr."&STREET=".$street;
|
||||
$nvpstr = $nvpstr."&CITY=".$city;
|
||||
$nvpstr = $nvpstr."&STATE=".$state;
|
||||
$nvpstr = $nvpstr."&COUNTRYCODE=".$countryCode;
|
||||
$nvpstr = $nvpstr."&IPADDRESS=".$_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$resArray = hash_call("DoDirectPayment", $nvpstr);
|
||||
|
||||
return $resArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: This function makes a MassPay API call
|
||||
* Inputs:
|
||||
* Beneficiarie: Array that contains the Beneficiearie paypal account and the payout amount
|
||||
* Currency Code: The currency Iso code
|
||||
* Returns:
|
||||
* The NVP Collection object of the MassPay Call Response.
|
||||
*/
|
||||
function MassPayment(array $beneficiaries, $currencyCode)
|
||||
{
|
||||
$nvpstr = "&RECEIVERTYPE=EmailAddress";
|
||||
$nvpstr .= "&CURRENCYCODE=".$currencyCode;
|
||||
|
||||
$index = 0;
|
||||
|
||||
foreach ($beneficiaries as $beneficiary) {
|
||||
$nvpstr .= "&L_EMAIL".$index."=".$beneficiary['paypal_account'];
|
||||
$nvpstr .= "&L_AMT".$index."=".$beneficiary['commission'];
|
||||
$index++;
|
||||
}
|
||||
|
||||
$resArray = hash_call("MassPay", $nvpstr);
|
||||
|
||||
return $resArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* hash_call: Function to perform the API call to PayPal using API signature.
|
||||
*
|
||||
* @methodName is name of API method.
|
||||
* @nvpStr is nvp string.
|
||||
* returns an associtive array containing the response from the server.
|
||||
*/
|
||||
function hash_call($methodName, $nvpStr)
|
||||
{
|
||||
//declaring of global variables
|
||||
global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature;
|
||||
global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
|
||||
global $sBNCode;
|
||||
|
||||
//setting the curl parameters.
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
||||
//turning off the server and peer verification(TrustManager Concept).
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
|
||||
//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
|
||||
//Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
|
||||
if ($USE_PROXY) {
|
||||
curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT);
|
||||
}
|
||||
|
||||
//NVPRequest for submitting to server
|
||||
$nvpreq = "METHOD=".urlencode($methodName)."&VERSION=".urlencode($version).
|
||||
"&PWD=".urlencode($API_Password)."&USER=".urlencode($API_UserName).
|
||||
"&SIGNATURE=".urlencode($API_Signature).$nvpStr."&BUTTONSOURCE=".urlencode($sBNCode);
|
||||
|
||||
//setting the nvpreq as POST FIELD to curl
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
|
||||
//getting response from server
|
||||
$response = curl_exec($ch);
|
||||
//converting NVPResponse to an Associative Array
|
||||
$nvpResArray = deformatNVP($response);
|
||||
$nvpReqArray = deformatNVP($nvpreq);
|
||||
|
||||
$_SESSION['nvpReqArray'] = $nvpReqArray;
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
// moving to display page to display curl errors
|
||||
$_SESSION['curl_error_no'] = curl_errno($ch);
|
||||
$_SESSION['curl_error_msg'] = curl_error($ch);
|
||||
//Execute the Error handling module to display errors.
|
||||
} else {
|
||||
//closing the curl
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
return $nvpResArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: Redirects to PayPal.com site.
|
||||
* Inputs: NVP string.
|
||||
*/
|
||||
function RedirectToPayPal($token)
|
||||
{
|
||||
global $PAYPAL_URL;
|
||||
// Redirect to paypal.com here
|
||||
$payPalURL = $PAYPAL_URL.$token;
|
||||
header("Location: ".$payPalURL);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will take NVPString and convert it to an Associative Array and it will decode the response.
|
||||
* It is usefull to search for a particular key and displaying arrays.
|
||||
*
|
||||
* @nvpstr is NVPString.
|
||||
* @nvpArray is Associative Array.
|
||||
*/
|
||||
function deformatNVP($nvpstr)
|
||||
{
|
||||
$intial = 0;
|
||||
$nvpArray = [];
|
||||
|
||||
while (strlen($nvpstr)) {
|
||||
//postion of Key
|
||||
$keypos = strpos($nvpstr, '=');
|
||||
//position of value
|
||||
$valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr);
|
||||
/*getting the Key and Value values and storing in a Associative Array*/
|
||||
$keyval = substr($nvpstr, $intial, $keypos);
|
||||
$valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1);
|
||||
//decoding the respose
|
||||
$nvpArray[urldecode($keyval)] = urldecode($valval);
|
||||
$nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr));
|
||||
}
|
||||
|
||||
return $nvpArray;
|
||||
}
|
||||
188
plugin/buycourses/src/process.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
use ChamiloSession as Session;
|
||||
|
||||
/**
|
||||
* Process payments for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$currentUserId = api_get_user_id();
|
||||
|
||||
$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(
|
||||
WEB_PLUGIN_PATH
|
||||
).'buycourses/resources/css/style.css"/>';
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
$paypalEnabled = $plugin->get('paypal_enable') === 'true';
|
||||
$transferEnabled = $plugin->get('transfer_enable') === 'true';
|
||||
$culqiEnabled = $plugin->get('culqi_enable') === 'true';
|
||||
$tpvRedsysEnable = $plugin->get('tpv_redsys_enable') === 'true';
|
||||
$stripeEnable = $plugin->get('stripe_enable') === 'true';
|
||||
$tpvCecabankEnable = $plugin->get('cecabank_enable') === 'true';
|
||||
|
||||
if (!$paypalEnabled && !$transferEnabled && !$culqiEnabled && !$tpvRedsysEnable && !$stripeEnable && !$tpvCecabankEnable) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['t'], $_REQUEST['i'])) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
$buyingCourse = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_COURSE;
|
||||
$buyingSession = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_SESSION;
|
||||
$queryString = 'i='.intval($_REQUEST['i']).'&t='.intval($_REQUEST['t']);
|
||||
|
||||
$coupon = null;
|
||||
|
||||
if (isset($_REQUEST['c'])) {
|
||||
$couponId = (int) $_REQUEST['c'];
|
||||
if ($buyingCourse) {
|
||||
$coupon = $plugin->getCoupon($couponId, BuyCoursesPlugin::PRODUCT_TYPE_COURSE, $_REQUEST['i']);
|
||||
} else {
|
||||
$coupon = $plugin->getCoupon($couponId, BuyCoursesPlugin::PRODUCT_TYPE_SESSION, $_REQUEST['i']);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($currentUserId)) {
|
||||
Session::write('buy_course_redirect', api_get_self().'?'.$queryString);
|
||||
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($buyingCourse) {
|
||||
$courseInfo = $plugin->getCourseInfo($_REQUEST['i'], $coupon);
|
||||
$item = $plugin->getItemByProduct($_REQUEST['i'], BuyCoursesPlugin::PRODUCT_TYPE_COURSE);
|
||||
} elseif ($buyingSession) {
|
||||
$sessionInfo = $plugin->getSessionInfo($_REQUEST['i'], $coupon);
|
||||
$item = $plugin->getItemByProduct($_REQUEST['i'], BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
|
||||
}
|
||||
|
||||
$form = new FormValidator('confirm_sale');
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (!$formValues['payment_type']) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('NeedToSelectPaymentType'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
$saleId = $plugin->registerSale($item['id'], $formValues['payment_type'], $formValues['c']);
|
||||
|
||||
if ($saleId !== false) {
|
||||
$_SESSION['bc_sale_id'] = $saleId;
|
||||
|
||||
if (isset($formValues['c'])) {
|
||||
$couponSaleId = $plugin->registerCouponSale($saleId, $formValues['c']);
|
||||
if ($couponSaleId !== false) {
|
||||
$plugin->updateCouponDelivered($formValues['c']);
|
||||
$_SESSION['bc_coupon_id'] = $formValues['c'];
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/process_confirm.php');
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$paymentTypesOptions = $plugin->getPaymentTypes(true);
|
||||
|
||||
$count = count($paymentTypesOptions);
|
||||
if ($count === 0) {
|
||||
$form->addHtml($plugin->get_lang('NoPaymentOptionAvailable'));
|
||||
$form->addHtml('<br />');
|
||||
$form->addHtml('<br />');
|
||||
} elseif ($count === 1) {
|
||||
// get the only array item
|
||||
foreach ($paymentTypesOptions as $type => $value) {
|
||||
$form->addHtml(sprintf($plugin->get_lang('XIsOnlyPaymentMethodAvailable'), $value));
|
||||
$form->addHtml('<br />');
|
||||
$form->addHtml('<br />');
|
||||
$form->addHidden('payment_type', $type);
|
||||
}
|
||||
} else {
|
||||
$form->addHtml(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('PleaseSelectThePaymentMethodBeforeConfirmYourOrder'),
|
||||
'info'
|
||||
)
|
||||
);
|
||||
$form->addRadio('payment_type', null, $paymentTypesOptions);
|
||||
}
|
||||
|
||||
$form->addHidden('t', intval($_REQUEST['t']));
|
||||
$form->addHidden('i', intval($_REQUEST['i']));
|
||||
if ($coupon != null) {
|
||||
$form->addHidden('c', intval($coupon['id']));
|
||||
}
|
||||
$form->addButton('submit', $plugin->get_lang('ConfirmOrder'), 'check', 'success', 'btn-lg pull-right');
|
||||
|
||||
$formCoupon = new FormValidator('confirm_coupon');
|
||||
if ($formCoupon->validate()) {
|
||||
$formCouponValues = $formCoupon->getSubmitValues();
|
||||
|
||||
if (!$formCouponValues['coupon_code']) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('NeedToAddCouponCode'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($buyingCourse) {
|
||||
$coupon = $plugin->getCouponByCode($formCouponValues['coupon_code'], BuyCoursesPlugin::PRODUCT_TYPE_COURSE, $_REQUEST['i']);
|
||||
} else {
|
||||
$coupon = $plugin->getCouponByCode($formCouponValues['coupon_code'], BuyCoursesPlugin::PRODUCT_TYPE_SESSION, $_REQUEST['i']);
|
||||
}
|
||||
|
||||
if ($coupon == null) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CouponNotValid'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CouponRedeemed'), 'success', false)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/process.php?i='.$_REQUEST['i'].'&t='.$_REQUEST['t'].'&c='.$coupon['id']);
|
||||
|
||||
exit;
|
||||
}
|
||||
$formCoupon->addText('coupon_code', $plugin->get_lang('CouponsCode'), true);
|
||||
$formCoupon->addHidden('t', intval($_GET['t']));
|
||||
$formCoupon->addHidden('i', intval($_GET['i']));
|
||||
$formCoupon->addButton('submit', $plugin->get_lang('RedeemCoupon'), 'check', 'success', 'btn-lg pull-right');
|
||||
|
||||
// View
|
||||
$templateName = $plugin->get_lang('PaymentMethods');
|
||||
$interbreadcrumb[] = ['url' => 'course_catalog.php', 'name' => $plugin->get_lang('CourseListOnSale')];
|
||||
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('item_type', (int) $_GET['t']);
|
||||
$tpl->assign('buying_course', $buyingCourse);
|
||||
$tpl->assign('buying_session', $buyingSession);
|
||||
$tpl->assign('user', api_get_user_info());
|
||||
$tpl->assign('form_coupon', $formCoupon->returnForm());
|
||||
$tpl->assign('form', $form->returnForm());
|
||||
|
||||
if ($buyingCourse) {
|
||||
$tpl->assign('course', $courseInfo);
|
||||
} elseif ($buyingSession) {
|
||||
$tpl->assign('session', $sessionInfo);
|
||||
}
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/process.tpl');
|
||||
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
597
plugin/buycourses/src/process_confirm.php
Normal file
@@ -0,0 +1,597 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Process purchase confirmation script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$saleId = $_SESSION['bc_sale_id'];
|
||||
$couponId = (!empty($_SESSION['bc_coupon_id']) ?? '');
|
||||
|
||||
if (empty($saleId)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sale = $plugin->getSale($saleId);
|
||||
|
||||
$coupon = [];
|
||||
if (!empty($couponId)) {
|
||||
$coupon = $plugin->getCoupon($couponId, $sale['product_type'], $sale['product_id']);
|
||||
}
|
||||
|
||||
$userInfo = api_get_user_info($sale['user_id']);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$currency = $plugin->getCurrency($sale['currency_id']);
|
||||
$globalParameters = $plugin->getGlobalParameters();
|
||||
|
||||
switch ($sale['payment_type']) {
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL:
|
||||
$paypalParams = $plugin->getPaypalParams();
|
||||
|
||||
$pruebas = $paypalParams['sandbox'] == 1;
|
||||
$paypalUsername = $paypalParams['username'];
|
||||
$paypalPassword = $paypalParams['password'];
|
||||
$paypalSignature = $paypalParams['signature'];
|
||||
|
||||
require_once "paypalfunctions.php";
|
||||
|
||||
$i = 0;
|
||||
$extra = "&L_PAYMENTREQUEST_0_NAME0={$sale['product_name']}";
|
||||
$extra .= "&L_PAYMENTREQUEST_0_AMT0={$sale['price']}";
|
||||
$extra .= "&L_PAYMENTREQUEST_0_QTY0=1";
|
||||
|
||||
$expressCheckout = CallShortcutExpressCheckout(
|
||||
$sale['price'],
|
||||
$currency['iso_code'],
|
||||
'paypal',
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/success.php',
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/error.php',
|
||||
$extra
|
||||
);
|
||||
|
||||
if ($expressCheckout["ACK"] !== 'Success') {
|
||||
$erroMessage = vsprintf(
|
||||
$plugin->get_lang('ErrorOccurred'),
|
||||
[$expressCheckout['L_ERRORCODE0'], $expressCheckout['L_LONGMESSAGE0']]
|
||||
);
|
||||
Display::addFlash(
|
||||
Display::return_message($erroMessage, 'error', false)
|
||||
);
|
||||
header('Location: ../index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($globalParameters['sale_email'])) {
|
||||
$messageConfirmTemplate = new Template();
|
||||
$messageConfirmTemplate->assign('user', $userInfo);
|
||||
$messageConfirmTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $sale['date'],
|
||||
'product' => $sale['product_name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'reference' => $sale['reference'],
|
||||
]
|
||||
);
|
||||
|
||||
api_mail_html(
|
||||
'',
|
||||
$globalParameters['sale_email'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageConfirmTemplate->fetch('buycourses/view/message_confirm.tpl')
|
||||
);
|
||||
}
|
||||
|
||||
RedirectToPayPal($expressCheckout["TOKEN"]);
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER:
|
||||
$buyingCourse = false;
|
||||
$buyingSession = false;
|
||||
|
||||
switch ($sale['product_type']) {
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
|
||||
$buyingCourse = true;
|
||||
$course = $plugin->getCourseInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
|
||||
$buyingSession = true;
|
||||
$session = $plugin->getSessionInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
}
|
||||
|
||||
$transferAccounts = $plugin->getTransferAccounts();
|
||||
$infoEmailExtra = $plugin->getTransferInfoExtra()['tinfo_email_extra'];
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelSale($sale['id']);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$messageTemplate = new Template();
|
||||
$messageTemplate->assign('user', $userInfo);
|
||||
$messageTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $sale['date'],
|
||||
'product' => $sale['product_name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'reference' => $sale['reference'],
|
||||
]
|
||||
);
|
||||
$messageTemplate->assign('transfer_accounts', $transferAccounts);
|
||||
$messageTemplate->assign('info_email_extra', $infoEmailExtra);
|
||||
|
||||
MessageManager::send_message_simple(
|
||||
$userInfo['user_id'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageTemplate->fetch('buycourses/view/message_transfer.tpl')
|
||||
);
|
||||
|
||||
if (!empty($globalParameters['sale_email'])) {
|
||||
$messageConfirmTemplate = new Template();
|
||||
$messageConfirmTemplate->assign('user', $userInfo);
|
||||
$messageConfirmTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $sale['date'],
|
||||
'product' => $sale['product_name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'reference' => $sale['reference'],
|
||||
]
|
||||
);
|
||||
|
||||
api_mail_html(
|
||||
'',
|
||||
$globalParameters['sale_email'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageConfirmTemplate->fetch('buycourses/view/message_confirm.tpl')
|
||||
);
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
sprintf(
|
||||
$plugin->get_lang('PurchaseStatusX'),
|
||||
$plugin->get_lang('PendingReasonByTransfer')
|
||||
),
|
||||
'success',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/course_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
|
||||
|
||||
$template = new Template();
|
||||
|
||||
if ($buyingCourse) {
|
||||
$template->assign('course', $course);
|
||||
} elseif ($buyingSession) {
|
||||
$template->assign('session', $session);
|
||||
}
|
||||
|
||||
$template->assign('buying_course', $buyingCourse);
|
||||
$template->assign('buying_session', $buyingSession);
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $sale['product_name']);
|
||||
$template->assign('price', $sale['price']);
|
||||
$template->assign('currency', $sale['currency_id']);
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('transfer_accounts', $transferAccounts);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('is_bank_transfer', true);
|
||||
|
||||
$content = $template->fetch('buycourses/view/process_confirm.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_CULQI:
|
||||
// We need to include the main online script, acording to the Culqi documentation the JS needs to be loeaded
|
||||
// directly from the main url "https://integ-pago.culqi.com" because a local copy of this JS is not supported
|
||||
$htmlHeadXtra[] = '<script src="//integ-pago.culqi.com/js/v1"></script>';
|
||||
|
||||
$buyingCourse = false;
|
||||
$buyingSession = false;
|
||||
|
||||
switch ($sale['product_type']) {
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
|
||||
$buyingCourse = true;
|
||||
$course = $plugin->getCourseInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
|
||||
$buyingSession = true;
|
||||
$session = $plugin->getSessionInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
}
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelSale($sale['id']);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('OrderCanceled'),
|
||||
'warning',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButton(
|
||||
'cancel',
|
||||
$plugin->get_lang('CancelOrder'),
|
||||
'times',
|
||||
'danger',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'cancel']
|
||||
);
|
||||
|
||||
$template = new Template();
|
||||
|
||||
if ($buyingCourse) {
|
||||
$template->assign('course', $course);
|
||||
} elseif ($buyingSession) {
|
||||
$template->assign('session', $session);
|
||||
}
|
||||
|
||||
$template->assign('buying_course', $buyingCourse);
|
||||
$template->assign('buying_session', $buyingSession);
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $sale['product_name']);
|
||||
$template->assign('price', floatval($sale['price']));
|
||||
$template->assign('currency', $plugin->getSelectedCurrency());
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('sale', $sale);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('is_culqi_payment', true);
|
||||
$template->assign('culqi_params', $culqiParams = $plugin->getCulqiParams());
|
||||
|
||||
$content = $template->fetch('buycourses/view/process_confirm.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_TPV_REDSYS:
|
||||
$tpvRedsysParams = $plugin->getTpvRedsysParams();
|
||||
|
||||
require_once '../resources/apiRedsys.php';
|
||||
$tpv = new RedsysAPI();
|
||||
|
||||
$merchantcode = $tpvRedsysParams['merchantcode'];
|
||||
$terminal = $tpvRedsysParams['terminal'];
|
||||
$currency = $tpvRedsysParams['currency'];
|
||||
$transactionType = "0";
|
||||
$urlMerchant = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/tpv_response.php';
|
||||
$urlSuccess = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/tpv_success.php';
|
||||
$urlFailed = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/tpv_error.php';
|
||||
$order = str_pad(strval($saleId), 4, "0", STR_PAD_LEFT);
|
||||
$amount = $sale['price'] * 100;
|
||||
$description = $plugin->get_lang('OrderReference').": ".$sale['reference'];
|
||||
$tpv->setParameter("DS_MERCHANT_AMOUNT", $amount);
|
||||
$tpv->setParameter("DS_MERCHANT_ORDER", $order);
|
||||
$tpv->setParameter("DS_MERCHANT_MERCHANTCODE", $merchantcode);
|
||||
$tpv->setParameter("DS_MERCHANT_CURRENCY", $currency);
|
||||
$tpv->setParameter("DS_MERCHANT_TRANSACTIONTYPE", $transactionType);
|
||||
$tpv->setParameter("DS_MERCHANT_TERMINAL", $terminal);
|
||||
$tpv->setParameter("DS_MERCHANT_MERCHANTURL", $urlMerchant);
|
||||
$tpv->setParameter("DS_MERCHANT_URLOK", $urlSuccess);
|
||||
$tpv->setParameter("DS_MERCHANT_URLKO", $urlFailed);
|
||||
$tpv->setParameter("DS_MERCHANT_PRODUCTDESCRIPTION", $description);
|
||||
|
||||
$version = "HMAC_SHA256_V1";
|
||||
$kc = $tpvRedsysParams['kc'];
|
||||
|
||||
$urlTpv = $tpvRedsysParams['url_redsys'];
|
||||
$sandboxFlag = $tpvRedsysParams['sandbox'] == 1;
|
||||
if ($sandboxFlag === true) {
|
||||
$urlTpv = $tpvRedsysParams['url_redsys_sandbox'];
|
||||
}
|
||||
|
||||
$params = $tpv->createMerchantParameters();
|
||||
$signature = $tpv->createMerchantSignature($kc);
|
||||
|
||||
echo '<form name="tpv_chamilo" action="'.$urlTpv.'" method="POST">';
|
||||
echo '<input type="hidden" name="Ds_SignatureVersion" value="'.$version.'" />';
|
||||
echo '<input type="hidden" name="Ds_MerchantParameters" value="'.$params.'" />';
|
||||
echo '<input type="hidden" name="Ds_Signature" value="'.$signature.'" />';
|
||||
echo '</form>';
|
||||
|
||||
echo '<SCRIPT language=javascript>';
|
||||
echo 'document.tpv_chamilo.submit();';
|
||||
echo '</script>';
|
||||
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_STRIPE:
|
||||
$buyingCourse = false;
|
||||
$buyingSession = false;
|
||||
|
||||
switch ($sale['product_type']) {
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
|
||||
$buyingCourse = true;
|
||||
$course = $plugin->getCourseInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
|
||||
$buyingSession = true;
|
||||
$session = $plugin->getSessionInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
}
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelSale($sale['id']);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$stripeParams = $plugin->getStripeParams();
|
||||
$currency = $plugin->getCurrency($sale['currency_id']);
|
||||
|
||||
\Stripe\Stripe::setApiKey($stripeParams['secret_key']);
|
||||
\Stripe\Stripe::setAppInfo("ChamiloBuyCoursesPlugin");
|
||||
|
||||
$session = \Stripe\Checkout\Session::create([
|
||||
'payment_method_types' => ['card'],
|
||||
'line_items' => [[
|
||||
'price_data' => [
|
||||
'unit_amount_decimal' => $sale['price'] * 100,
|
||||
'currency' => $currency['iso_code'],
|
||||
'product_data' => [
|
||||
'name' => $sale['product_name'],
|
||||
],
|
||||
],
|
||||
'quantity' => 1,
|
||||
]],
|
||||
'customer_email' => $_SESSION['_user']['email'],
|
||||
'mode' => 'payment',
|
||||
'success_url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/src/stripe_success.php',
|
||||
'cancel_url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/src/stripe_cancel.php',
|
||||
]);
|
||||
|
||||
if (!empty($session)) {
|
||||
$plugin->updateSaleReference($saleId, $session->id);
|
||||
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.$session->url);
|
||||
} else {
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('ErrorOccurred'),
|
||||
'error',
|
||||
false
|
||||
)
|
||||
);
|
||||
header('Location: ../index.php');
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
|
||||
|
||||
$template = new Template();
|
||||
|
||||
if ($buyingCourse) {
|
||||
$template->assign('course', $course);
|
||||
} elseif ($buyingSession) {
|
||||
$template->assign('session', $session);
|
||||
}
|
||||
|
||||
$template->assign('buying_course', $buyingCourse);
|
||||
$template->assign('buying_session', $buyingSession);
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $sale['product_name']);
|
||||
$template->assign('price', $sale['price']);
|
||||
$template->assign('currency', $sale['currency_id']);
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('transfer_accounts', $transferAccounts);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('is_bank_transfer', false);
|
||||
|
||||
$content = $template->fetch('buycourses/view/process_confirm.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
|
||||
break;
|
||||
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_TPV_CECABANK:
|
||||
$buyingCourse = false;
|
||||
$buyingSession = false;
|
||||
|
||||
switch ($sale['product_type']) {
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
|
||||
$buyingCourse = true;
|
||||
$course = $plugin->getCourseInfo($sale['product_id']);
|
||||
break;
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
|
||||
$buyingSession = true;
|
||||
$session = $plugin->getSessionInfo($sale['product_id']);
|
||||
break;
|
||||
}
|
||||
|
||||
$cecabankParams = $plugin->getcecabankParams();
|
||||
$currency = $plugin->getCurrency($sale['currency_id']);
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelSale($sale['id']);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$urlTpv = $cecabankParams['url'];
|
||||
$currency = $plugin->getCurrency($sale['currency_id']);
|
||||
$signature = $plugin->getCecabankSignature($sale['reference'], $sale['price']);
|
||||
|
||||
echo '<form name="tpv_chamilo" action="'.$urlTpv.'" method="POST">';
|
||||
echo '<input type="hidden" name="MerchantID" value="'.$cecabankParams['merchant_id'].'" />';
|
||||
echo '<input type="hidden" name="AcquirerBIN" value="'.$cecabankParams['acquirer_bin'].'" />';
|
||||
echo '<input type="hidden" name="TerminalID" value="'.$cecabankParams['terminal_id'].'" />';
|
||||
echo '<input type="hidden" name="URL_OK" value="'.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/cecabank_success.php'.'" />';
|
||||
echo '<input type="hidden" name="URL_NOK" value="'.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/cecabank_cancel.php'.'" />';
|
||||
echo '<input type="hidden" name="Firma" value="'.$signature.'" />';
|
||||
echo '<input type="hidden" name="Cifrado" value="'.$cecabankParams['cypher'].'" />';
|
||||
echo '<input type="hidden" name="Num_operacion" value="'.$sale['reference'].'" />';
|
||||
echo '<input type="hidden" name="Importe" value="'.($sale['price'] * 100).'" />';
|
||||
echo '<input type="hidden" name="TipoMoneda" value="978" />';
|
||||
echo '<input type="hidden" name="Exponente" value="'.$cecabankParams['exponent'].'" />';
|
||||
echo '<input type="hidden" name="Pago_soportado" value="'.$cecabankParams['supported_payment'].'" />';
|
||||
echo '</form>';
|
||||
|
||||
echo '<SCRIPT language=javascript>';
|
||||
echo 'document.tpv_chamilo.submit();';
|
||||
echo '</script>';
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
|
||||
|
||||
$template = new Template();
|
||||
|
||||
if ($buyingCourse) {
|
||||
$template->assign('course', $course);
|
||||
} elseif ($buyingSession) {
|
||||
$template->assign('session', $session);
|
||||
}
|
||||
|
||||
$template->assign('buying_course', $buyingCourse);
|
||||
$template->assign('buying_session', $buyingSession);
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $sale['product_name']);
|
||||
$template->assign('price', $sale['price']);
|
||||
$template->assign('currency', $sale['currency_id']);
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('transfer_accounts', $transferAccounts);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('is_bank_transfer', false);
|
||||
|
||||
$content = $template->fetch('buycourses/view/process_confirm.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
|
||||
break;
|
||||
}
|
||||
375
plugin/buycourses/src/process_subscription_confirm.php
Normal file
@@ -0,0 +1,375 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Process purchase confirmation script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$saleId = $_SESSION['bc_sale_id'];
|
||||
$couponId = $_SESSION['bc_coupon_id'];
|
||||
|
||||
if (empty($saleId)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sale = $plugin->getSubscriptionSale($saleId);
|
||||
|
||||
if (!empty($couponId)) {
|
||||
$coupon = $plugin->getCoupon($couponId, $sale['product_type'], $sale['product_id']);
|
||||
}
|
||||
|
||||
$userInfo = api_get_user_info($sale['user_id']);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$currency = $plugin->getCurrency($sale['currency_id']);
|
||||
$globalParameters = $plugin->getGlobalParameters();
|
||||
|
||||
switch ($sale['payment_type']) {
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL:
|
||||
$paypalParams = $plugin->getPaypalParams();
|
||||
|
||||
$pruebas = $paypalParams['sandbox'] == 1;
|
||||
$paypalUsername = $paypalParams['username'];
|
||||
$paypalPassword = $paypalParams['password'];
|
||||
$paypalSignature = $paypalParams['signature'];
|
||||
|
||||
require_once "paypalfunctions.php";
|
||||
|
||||
$i = 0;
|
||||
$extra = "&L_PAYMENTREQUEST_0_NAME0={$sale['product_name']}";
|
||||
$extra .= "&L_PAYMENTREQUEST_0_AMT0={$sale['price']}";
|
||||
$extra .= "&L_PAYMENTREQUEST_0_QTY0=1";
|
||||
|
||||
$expressCheckout = CallShortcutExpressCheckout(
|
||||
$sale['price'],
|
||||
$currency['iso_code'],
|
||||
'paypal',
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/success.php',
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/error.php',
|
||||
$extra
|
||||
);
|
||||
|
||||
if ($expressCheckout["ACK"] !== 'Success') {
|
||||
$erroMessage = vsprintf(
|
||||
$plugin->get_lang('ErrorOccurred'),
|
||||
[$expressCheckout['L_ERRORCODE0'], $expressCheckout['L_LONGMESSAGE0']]
|
||||
);
|
||||
Display::addFlash(
|
||||
Display::return_message($erroMessage, 'error', false)
|
||||
);
|
||||
header('Location: ../index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($globalParameters['sale_email'])) {
|
||||
$messageConfirmTemplate = new Template();
|
||||
$messageConfirmTemplate->assign('user', $userInfo);
|
||||
$messageConfirmTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $sale['date'],
|
||||
'product' => $sale['product_name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'reference' => $sale['reference'],
|
||||
]
|
||||
);
|
||||
|
||||
api_mail_html(
|
||||
'',
|
||||
$globalParameters['sale_email'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageConfirmTemplate->fetch('buycourses/view/message_confirm.tpl')
|
||||
);
|
||||
}
|
||||
|
||||
RedirectToPayPal($expressCheckout["TOKEN"]);
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER:
|
||||
$buyingCourse = false;
|
||||
$buyingSession = false;
|
||||
|
||||
switch ($sale['product_type']) {
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
|
||||
$buyingCourse = true;
|
||||
$course = $plugin->getSubscriptionCourseInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
|
||||
$buyingSession = true;
|
||||
$session = $plugin->getSubscriptionSessionInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
}
|
||||
|
||||
$transferAccounts = $plugin->getTransferAccounts();
|
||||
$infoEmailExtra = $plugin->getTransferInfoExtra()['tinfo_email_extra'];
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelSubscriptionSale($sale['id']);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$messageTemplate = new Template();
|
||||
$messageTemplate->assign('user', $userInfo);
|
||||
$messageTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $sale['date'],
|
||||
'product' => $sale['product_name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'reference' => $sale['reference'],
|
||||
]
|
||||
);
|
||||
$messageTemplate->assign('transfer_accounts', $transferAccounts);
|
||||
$messageTemplate->assign('info_email_extra', $infoEmailExtra);
|
||||
|
||||
MessageManager::send_message_simple(
|
||||
$userInfo['user_id'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageTemplate->fetch('buycourses/view/message_transfer.tpl')
|
||||
);
|
||||
|
||||
if (!empty($globalParameters['sale_email'])) {
|
||||
$messageConfirmTemplate = new Template();
|
||||
$messageConfirmTemplate->assign('user', $userInfo);
|
||||
$messageConfirmTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $sale['date'],
|
||||
'product' => $sale['product_name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'reference' => $sale['reference'],
|
||||
]
|
||||
);
|
||||
|
||||
api_mail_html(
|
||||
'',
|
||||
$globalParameters['sale_email'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageConfirmTemplate->fetch('buycourses/view/message_confirm.tpl')
|
||||
);
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
sprintf(
|
||||
$plugin->get_lang('PurchaseStatusX'),
|
||||
$plugin->get_lang('PendingReasonByTransfer')
|
||||
),
|
||||
'success',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/course_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
|
||||
|
||||
$template = new Template();
|
||||
|
||||
if ($buyingCourse) {
|
||||
$template->assign('course', $course);
|
||||
} elseif ($buyingSession) {
|
||||
$template->assign('session', $session);
|
||||
}
|
||||
|
||||
$template->assign('buying_course', $buyingCourse);
|
||||
$template->assign('buying_session', $buyingSession);
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $sale['product_name']);
|
||||
$template->assign('price', $sale['price']);
|
||||
$template->assign('currency', $sale['currency_id']);
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('transfer_accounts', $transferAccounts);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('is_bank_transfer', true);
|
||||
|
||||
$content = $template->fetch('buycourses/view/subscription_process_confirm.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_CULQI:
|
||||
// We need to include the main online script, acording to the Culqi documentation the JS needs to be loeaded
|
||||
// directly from the main url "https://integ-pago.culqi.com" because a local copy of this JS is not supported
|
||||
$htmlHeadXtra[] = '<script src="//integ-pago.culqi.com/js/v1"></script>';
|
||||
|
||||
$buyingCourse = false;
|
||||
$buyingSession = false;
|
||||
|
||||
switch ($sale['product_type']) {
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
|
||||
$buyingCourse = true;
|
||||
$course = $plugin->getSubscriptionCourseInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
|
||||
$buyingSession = true;
|
||||
$session = $plugin->getSubscriptionSessionInfo($sale['product_id'], $coupon);
|
||||
break;
|
||||
}
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelSubscriptionSale($sale['id']);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('OrderCanceled'),
|
||||
'warning',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButton(
|
||||
'cancel',
|
||||
$plugin->get_lang('CancelOrder'),
|
||||
'times',
|
||||
'danger',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'cancel']
|
||||
);
|
||||
|
||||
$template = new Template();
|
||||
|
||||
if ($buyingCourse) {
|
||||
$template->assign('course', $course);
|
||||
} elseif ($buyingSession) {
|
||||
$template->assign('session', $session);
|
||||
}
|
||||
|
||||
$template->assign('buying_course', $buyingCourse);
|
||||
$template->assign('buying_session', $buyingSession);
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $sale['product_name']);
|
||||
$template->assign('price', floatval($sale['price']));
|
||||
$template->assign('currency', $plugin->getSelectedCurrency());
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('sale', $sale);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('is_culqi_payment', true);
|
||||
$template->assign('culqi_params', $culqiParams = $plugin->getCulqiParams());
|
||||
|
||||
$content = $template->fetch('buycourses/view/subscription_process_confirm.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_TPV_REDSYS:
|
||||
$tpvRedsysParams = $plugin->getTpvRedsysParams();
|
||||
|
||||
require_once '../resources/apiRedsys.php';
|
||||
$tpv = new RedsysAPI();
|
||||
|
||||
$merchantcode = $tpvRedsysParams['merchantcode'];
|
||||
$terminal = $tpvRedsysParams['terminal'];
|
||||
$currency = $tpvRedsysParams['currency'];
|
||||
$transactionType = "0";
|
||||
$urlMerchant = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/tpv_response.php';
|
||||
$urlSuccess = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/tpv_success.php';
|
||||
$urlFailed = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/tpv_error.php';
|
||||
$order = str_pad(strval($saleId), 4, "0", STR_PAD_LEFT);
|
||||
$amount = $sale['price'] * 100;
|
||||
$description = $plugin->get_lang('OrderReference').": ".$sale['reference'];
|
||||
$tpv->setParameter("DS_MERCHANT_AMOUNT", $amount);
|
||||
$tpv->setParameter("DS_MERCHANT_ORDER", $order);
|
||||
$tpv->setParameter("DS_MERCHANT_MERCHANTCODE", $merchantcode);
|
||||
$tpv->setParameter("DS_MERCHANT_CURRENCY", $currency);
|
||||
$tpv->setParameter("DS_MERCHANT_TRANSACTIONTYPE", $transactionType);
|
||||
$tpv->setParameter("DS_MERCHANT_TERMINAL", $terminal);
|
||||
$tpv->setParameter("DS_MERCHANT_MERCHANTURL", $urlMerchant);
|
||||
$tpv->setParameter("DS_MERCHANT_URLOK", $urlSuccess);
|
||||
$tpv->setParameter("DS_MERCHANT_URLKO", $urlFailed);
|
||||
$tpv->setParameter("DS_MERCHANT_PRODUCTDESCRIPTION", $description);
|
||||
|
||||
$version = "HMAC_SHA256_V1";
|
||||
$kc = $tpvRedsysParams['kc'];
|
||||
|
||||
$urlTpv = $tpvRedsysParams['url_redsys'];
|
||||
$sandboxFlag = $tpvRedsysParams['sandbox'] == 1;
|
||||
if ($sandboxFlag === true) {
|
||||
$urlTpv = $tpvRedsysParams['url_redsys_sandbox'];
|
||||
}
|
||||
|
||||
$params = $tpv->createMerchantParameters();
|
||||
$signature = $tpv->createMerchantSignature($kc);
|
||||
|
||||
echo '<form name="tpv_chamilo" action="'.$urlTpv.'" method="POST">';
|
||||
echo '<input type="hidden" name="Ds_SignatureVersion" value="'.$version.'" />';
|
||||
echo '<input type="hidden" name="Ds_MerchantParameters" value="'.$params.'" />';
|
||||
echo '<input type="hidden" name="Ds_Signature" value="'.$signature.'" />';
|
||||
echo '</form>';
|
||||
|
||||
echo '<SCRIPT language=javascript>';
|
||||
echo 'document.tpv_chamilo.submit();';
|
||||
echo '</script>';
|
||||
|
||||
break;
|
||||
}
|
||||
216
plugin/buycourses/src/sales_report.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of pending payments of the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable');
|
||||
$commissionsEnable = $plugin->get('commissions_enable');
|
||||
$includeServices = $plugin->get('include_services');
|
||||
$invoicingEnable = $plugin->get('invoicing_enable') === 'true';
|
||||
|
||||
if (isset($_GET['order'])) {
|
||||
$sale = $plugin->getSale($_GET['order']);
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$urlToRedirect = api_get_self().'?';
|
||||
|
||||
switch ($_GET['action']) {
|
||||
case 'confirm':
|
||||
$plugin->completeSale($sale['id']);
|
||||
$plugin->storePayouts($sale['id']);
|
||||
Display::addFlash(
|
||||
$plugin->getSubscriptionSuccessMessage($sale)
|
||||
);
|
||||
|
||||
$urlToRedirect .= http_build_query([
|
||||
'status' => BuyCoursesPlugin::SALE_STATUS_COMPLETED,
|
||||
'sale' => $sale['id'],
|
||||
]);
|
||||
break;
|
||||
case 'cancel':
|
||||
$plugin->cancelSale($sale['id']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('OrderCanceled'),
|
||||
'warning'
|
||||
)
|
||||
);
|
||||
|
||||
$urlToRedirect .= http_build_query([
|
||||
'status' => BuyCoursesPlugin::SALE_STATUS_CANCELED,
|
||||
'sale' => $sale['id'],
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
header("Location: $urlToRedirect");
|
||||
exit;
|
||||
}
|
||||
|
||||
$productTypes = $plugin->getProductTypes();
|
||||
$saleStatuses = $plugin->getSaleStatuses();
|
||||
$paymentTypes = $plugin->getPaymentTypes();
|
||||
|
||||
$selectedFilterType = '0';
|
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_PENDING;
|
||||
$selectedSale = isset($_GET['sale']) ? intval($_GET['sale']) : 0;
|
||||
$dateStart = isset($_GET['date_start']) ? $_GET['date_start'] : date('Y-m-d H:i', mktime(0, 0, 0));
|
||||
$dateEnd = isset($_GET['date_end']) ? $_GET['date_end'] : date('Y-m-d H:i', mktime(23, 59, 59));
|
||||
$searchTerm = '';
|
||||
$email = '';
|
||||
|
||||
$form = new FormValidator('search', 'get');
|
||||
|
||||
if ($form->validate()) {
|
||||
$selectedFilterType = $form->getSubmitValue('filter_type');
|
||||
$selectedStatus = $form->getSubmitValue('status');
|
||||
$searchTerm = $form->getSubmitValue('user');
|
||||
$dateStart = $form->getSubmitValue('date_start');
|
||||
$dateEnd = $form->getSubmitValue('date_end');
|
||||
$email = $form->getSubmitValue('email');
|
||||
|
||||
if ($selectedStatus === false) {
|
||||
$selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING;
|
||||
}
|
||||
|
||||
if ($selectedFilterType === false) {
|
||||
$selectedFilterType = '0';
|
||||
}
|
||||
}
|
||||
|
||||
$form->addRadio(
|
||||
'filter_type',
|
||||
get_lang('Filter'),
|
||||
[
|
||||
$plugin->get_lang('ByStatus'),
|
||||
$plugin->get_lang('ByUser'),
|
||||
$plugin->get_lang('ByDate'),
|
||||
$plugin->get_lang('ByEmail'),
|
||||
]
|
||||
);
|
||||
$form->addHtml('<div id="report-by-status" '.($selectedFilterType !== '0' ? 'style="display:none"' : '').'>');
|
||||
$form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses);
|
||||
$form->addHtml('</div>');
|
||||
$form->addHtml('<div id="report-by-user" '.($selectedFilterType !== '1' ? 'style="display:none"' : '').'>');
|
||||
$form->addText('user', get_lang('UserName'), false);
|
||||
$form->addHtml('</div>');
|
||||
$form->addHtml('<div id="report-by-date" '.($selectedFilterType !== '2' ? 'style="display:none"' : '').'>');
|
||||
$form->addDateRangePicker('date', get_lang('Date'), false);
|
||||
$form->addHtml('</div>');
|
||||
$form->addHtml('<div id="report-by-email" '.($selectedFilterType !== '3' ? 'style="display:none"' : '').'>');
|
||||
$form->addText('email', get_lang('Email'), false);
|
||||
$form->addHtml('</div>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
$form->setDefaults([
|
||||
'filter_type' => $selectedFilterType,
|
||||
'status' => $selectedStatus,
|
||||
'date_start' => $dateStart,
|
||||
'date_end' => $dateEnd,
|
||||
'email' => $email,
|
||||
]);
|
||||
|
||||
switch ($selectedFilterType) {
|
||||
case '0':
|
||||
$sales = $plugin->getSaleListByStatus($selectedStatus);
|
||||
break;
|
||||
case '1':
|
||||
$sales = $plugin->getSaleListByUser($searchTerm);
|
||||
break;
|
||||
case '2':
|
||||
$sales = $plugin->getSaleListByDate($dateStart, $dateEnd);
|
||||
break;
|
||||
case '3':
|
||||
$sales = $plugin->getSaleListByEmail($email);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($sales as &$sale) {
|
||||
$sale['product_type'] = $productTypes[$sale['product_type']];
|
||||
$sale['payment_type'] = $paymentTypes[$sale['payment_type']];
|
||||
$sale['complete_user_name'] = api_get_person_name($sale['firstname'], $sale['lastname']);
|
||||
$sale['num_invoice'] = $plugin->getNumInvoice($sale['id'], 0);
|
||||
$sale['total_price'] = $plugin->getPriceWithCurrencyFromIsoCode($sale['price'], $sale['iso_code']);
|
||||
if (isset($sale['discount_amount']) && $sale['discount_amount'] != 0) {
|
||||
$sale['total_discount'] = $plugin->getPriceWithCurrencyFromIsoCode($sale['discount_amount'], $sale['iso_code']);
|
||||
$sale['coupon_code'] = $plugin->getSaleCouponCode($sale['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => '../index.php', 'name' => $plugin->get_lang('plugin_title')];
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js();
|
||||
$htmlHeadXtra[] = BuyCoursesPlugin::getSalesReportScript($sales, $invoicingEnable);
|
||||
|
||||
$templateName = $plugin->get_lang('SalesReport');
|
||||
$template = new Template($templateName);
|
||||
|
||||
$toolbar = Display::url(
|
||||
Display::returnFontAwesomeIcon('file-excel-o').
|
||||
get_lang('GenerateReport'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/export_report.php',
|
||||
['class' => 'btn btn-primary']
|
||||
);
|
||||
|
||||
if ($paypalEnable === 'true' && $commissionsEnable === 'true') {
|
||||
$toolbar .= Display::toolbarButton(
|
||||
$plugin->get_lang('PaypalPayoutCommissions'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/paypal_payout.php',
|
||||
'paypal',
|
||||
'primary',
|
||||
['title' => $plugin->get_lang('PaypalPayoutCommissions')]
|
||||
);
|
||||
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
}
|
||||
|
||||
if ($commissionsEnable === 'true') {
|
||||
$toolbar .= Display::toolbarButton(
|
||||
$plugin->get_lang('PayoutReport'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/payout_report.php',
|
||||
'money',
|
||||
'info',
|
||||
['title' => $plugin->get_lang('PayoutReport')]
|
||||
);
|
||||
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
}
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('selected_sale', $selectedSale);
|
||||
$template->assign('selected_status', $selectedStatus);
|
||||
$template->assign('services_are_included', $includeServices);
|
||||
$template->assign('sale_list', $sales);
|
||||
$template->assign('sale_status_canceled', BuyCoursesPlugin::SALE_STATUS_CANCELED);
|
||||
$template->assign('sale_status_pending', BuyCoursesPlugin::SALE_STATUS_PENDING);
|
||||
$template->assign('sale_status_completed', BuyCoursesPlugin::SALE_STATUS_COMPLETED);
|
||||
$template->assign('invoicing_enable', $invoicingEnable);
|
||||
|
||||
$content = $template->fetch('buycourses/view/sales_report.tpl');
|
||||
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
101
plugin/buycourses/src/service_catalog.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* List of services.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
$nameFilter = null;
|
||||
$minFilter = 0;
|
||||
$maxFilter = 0;
|
||||
$appliesToFilter = '';
|
||||
|
||||
$form = new FormValidator(
|
||||
'search_filter_form',
|
||||
'get',
|
||||
null,
|
||||
null,
|
||||
[],
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$nameFilter = isset($formValues['name']) ? $formValues['name'] : null;
|
||||
$minFilter = isset($formValues['min']) ? $formValues['min'] : 0;
|
||||
$maxFilter = isset($formValues['max']) ? $formValues['max'] : 0;
|
||||
$appliesToFilter = isset($formValues['applies_to']) ? $formValues['applies_to'] : '';
|
||||
}
|
||||
|
||||
$form->addHeader($plugin->get_lang('SearchFilter'));
|
||||
$form->addText('name', $plugin->get_lang('ServiceName'), false);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'min',
|
||||
$plugin->get_lang('MinimumPrice'),
|
||||
['step' => '0.01', 'min' => '0']
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'max',
|
||||
$plugin->get_lang('MaximumPrice'),
|
||||
['step' => '0.01', 'min' => '0']
|
||||
);
|
||||
$appliesToOptions = [
|
||||
'' => get_lang('Any'),
|
||||
0 => get_lang('None'),
|
||||
1 => get_lang('User'),
|
||||
2 => get_lang('Course'),
|
||||
3 => get_lang('Session'),
|
||||
4 => get_lang('TemplateTitleCertificate'),
|
||||
];
|
||||
$form->addSelect('applies_to', $plugin->get_lang('AppliesTo'), $appliesToOptions);
|
||||
$form->addHtml('<hr>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
|
||||
$pageSize = BuyCoursesPlugin::PAGINATION_PAGE_SIZE;
|
||||
$currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$first = $pageSize * ($currentPage - 1);
|
||||
$serviceList = $plugin->getCatalogServiceList($first, $pageSize, $nameFilter, $minFilter, $maxFilter, $appliesToFilter);
|
||||
$totalItems = $plugin->getCatalogServiceList($first, $pageSize, $nameFilter, $minFilter, $maxFilter, $appliesToFilter, 'count');
|
||||
$pagesCount = ceil($totalItems / $pageSize);
|
||||
$pagination = BuyCoursesPlugin::returnPagination(api_get_self(), $currentPage, $pagesCount, $totalItems);
|
||||
|
||||
// View
|
||||
if (api_is_platform_admin()) {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'list.php',
|
||||
'name' => $plugin->get_lang('AvailableCoursesConfiguration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'paymentsetup.php',
|
||||
'name' => $plugin->get_lang('PaymentsConfiguration'),
|
||||
];
|
||||
} else {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => '../index.php',
|
||||
'name' => $plugin->get_lang('UserPanel'),
|
||||
];
|
||||
}
|
||||
|
||||
$templateName = $plugin->get_lang('ListOfServicesOnSale');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('search_filter_form', $form->returnForm());
|
||||
$tpl->assign('showing_services', true);
|
||||
$tpl->assign('services', $serviceList);
|
||||
$tpl->assign('sessions_are_included', $includeSessions);
|
||||
$tpl->assign('services_are_included', $includeServices);
|
||||
$tpl->assign('pagination', $pagination);
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/catalog.tpl');
|
||||
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
35
plugin/buycourses/src/service_error.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* Errors management for the Buy Courses plugin - Redirects to service_catalog.php with a error msg.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
if (isset($_SESSION['bc_service_sale_id'])) {
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$serviceSaleId = $_SESSION['bc_service_sale_id'];
|
||||
unset($_SESSION['bc_service_sale_id']);
|
||||
$serviceSale = $plugin->getServiceSale($serviceSaleId);
|
||||
|
||||
$plugin->cancelServiceSale(intval($serviceSaleId));
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('OrderCancelled'),
|
||||
'error',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('ErrorOccurred'), 'error', false)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
|
||||
exit;
|
||||
42
plugin/buycourses/src/service_information.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Service information page
|
||||
* Show information about a service (for custom purposes).
|
||||
*
|
||||
* @author José Loguercio Silva <jose.loguercio@beeznest.com>
|
||||
*
|
||||
* @package chamilo.buycourses_plugin
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../../../main/inc/global.inc.php';
|
||||
|
||||
$serviceId = isset($_GET['service_id']) ? intval($_GET['service_id']) : false;
|
||||
$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(
|
||||
WEB_PLUGIN_PATH
|
||||
).'buycourses/resources/css/style.css"/>';
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
if (!$includeServices) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$service = $plugin->getService($serviceId);
|
||||
|
||||
if (!$service['id']) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$template = new Template(false);
|
||||
$template->assign('pageUrl', api_get_path(WEB_PATH)."service/{$serviceId}/information/");
|
||||
$template->assign('service', $service);
|
||||
$template->assign('essence', Essence\Essence::instance());
|
||||
|
||||
$content = $template->fetch('buycourses/view/service_information.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
74
plugin/buycourses/src/service_panel.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* User Panel.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../../../main/inc/global.inc.php';
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
$servicesOnly = $plugin->get('show_services_only') === 'true';
|
||||
|
||||
$userInfo = api_get_user_info();
|
||||
|
||||
if (!$userInfo) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
$serviceTypes = $plugin->getServiceTypes();
|
||||
$serviceSaleStatuses['status_cancelled'] = BuyCoursesPlugin::SERVICE_STATUS_CANCELLED;
|
||||
$serviceSaleStatuses['status_pending'] = BuyCoursesPlugin::SERVICE_STATUS_PENDING;
|
||||
$serviceSaleStatuses['status_completed'] = BuyCoursesPlugin::SERVICE_STATUS_COMPLETED;
|
||||
|
||||
$serviceSales = $plugin->getServiceSales($userInfo['user_id']);
|
||||
$saleList = [];
|
||||
|
||||
foreach ($serviceSales as $sale) {
|
||||
$saleList[] = [
|
||||
'id' => $sale['id'],
|
||||
'name' => $sale['service']['name'],
|
||||
'service_type' => $serviceTypes[$sale['service']['applies_to']],
|
||||
'applies_to' => $sale['service']['applies_to'],
|
||||
'reference' => $sale['reference'],
|
||||
'date' => api_format_date(api_get_local_time($sale['buy_date']), DATE_TIME_FORMAT_LONG_24H),
|
||||
'date_end' => api_format_date(api_get_local_time($sale['date_end']), DATE_TIME_FORMAT_LONG_24H),
|
||||
'currency' => $sale['currency'],
|
||||
'price' => $sale['price'],
|
||||
'status' => $sale['status'],
|
||||
];
|
||||
}
|
||||
|
||||
$toolbar = Display::toolbarButton(
|
||||
$plugin->get_lang('CourseListOnSale'),
|
||||
'course_catalog.php',
|
||||
'search-plus',
|
||||
'primary',
|
||||
['title' => $plugin->get_lang('CourseListOnSale')]
|
||||
);
|
||||
|
||||
$webPluginPath = api_get_path(WEB_PLUGIN_PATH);
|
||||
$htmlHeadXtra[] = api_get_css($webPluginPath.'buycourses/resources/css/style.css');
|
||||
$htmlHeadXtra[] = api_get_js_simple($webPluginPath.'buycourses/resources/js/modals.js');
|
||||
|
||||
$templateName = $plugin->get_lang('TabsDashboard');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('showing_courses', true);
|
||||
$tpl->assign('services_are_included', $includeServices);
|
||||
$tpl->assign('sessions_are_included', $includeSessions);
|
||||
$tpl->assign('service_sale_statuses', $serviceSaleStatuses);
|
||||
$tpl->assign('sale_list', $saleList);
|
||||
if ($servicesOnly) {
|
||||
$tpl->assign('show_services_only', true);
|
||||
}
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/service_panel.tpl');
|
||||
|
||||
$tpl->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
304
plugin/buycourses/src/service_process.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
use Chamilo\CoreBundle\Entity\Session;
|
||||
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
|
||||
use Chamilo\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Process payments for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
if (!isset($_REQUEST['t'], $_REQUEST['i'])) {
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$currentUserId = api_get_user_id();
|
||||
$serviceId = (int) $_REQUEST['i'];
|
||||
$type = (int) $_REQUEST['t'];
|
||||
|
||||
if (empty($currentUserId)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(
|
||||
WEB_PLUGIN_PATH
|
||||
).'buycourses/resources/css/style.css"/>';
|
||||
$em = Database::getManager();
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeServices = $plugin->get('include_services');
|
||||
$additionalQueryString = '';
|
||||
if ($includeServices !== 'true') {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$typeUser = $type === BuyCoursesPlugin::SERVICE_TYPE_USER;
|
||||
$typeCourse = $type === BuyCoursesPlugin::SERVICE_TYPE_COURSE;
|
||||
$typeSession = $type === BuyCoursesPlugin::SERVICE_TYPE_SESSION;
|
||||
$typeFinalLp = $type === BuyCoursesPlugin::SERVICE_TYPE_LP_FINAL_ITEM;
|
||||
$queryString = 'i='.$serviceId.'&t='.$type.$additionalQueryString;
|
||||
|
||||
if (isset($_REQUEST['c'])) {
|
||||
$couponCode = $_REQUEST['c'];
|
||||
$coupon = $plugin->getCouponServiceByCode($couponCode, $_REQUEST['i']);
|
||||
}
|
||||
|
||||
$serviceInfo = $plugin->getService($serviceId, $coupon);
|
||||
$userInfo = api_get_user_info($currentUserId);
|
||||
|
||||
$form = new FormValidator('confirm_sale');
|
||||
$paymentTypesOptions = $plugin->getPaymentTypes(true);
|
||||
|
||||
$form->addHtml(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('PleaseSelectThePaymentMethodBeforeConfirmYourOrder'),
|
||||
'info'
|
||||
)
|
||||
);
|
||||
$form->addRadio('payment_type', null, $paymentTypesOptions);
|
||||
|
||||
$infoRequired = false;
|
||||
if ($typeUser || $typeCourse || $typeSession || $typeFinalLp) {
|
||||
$infoRequired = true;
|
||||
$form->addHtml(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('PleaseSelectTheCorrectInfoToApplyTheService'),
|
||||
'info'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$selectOptions = [
|
||||
0 => get_lang('None'),
|
||||
];
|
||||
|
||||
if ($typeUser) {
|
||||
$users = UserManager::getRepository()->findAll();
|
||||
$selectOptions[$userInfo['user_id']] = api_get_person_name(
|
||||
$userInfo['firstname'],
|
||||
$userInfo['lastname']
|
||||
).' ('.get_lang('Myself').')';
|
||||
|
||||
if (!empty($users)) {
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
if (intval($userInfo['user_id']) !== intval($user->getId())) {
|
||||
$selectOptions[$user->getId()] = $user->getCompleteNameWithUsername();
|
||||
}
|
||||
}
|
||||
}
|
||||
$form->addSelect('info_select', get_lang('User'), $selectOptions);
|
||||
} elseif ($typeCourse) {
|
||||
/** @var User $user */
|
||||
$user = UserManager::getRepository()->find($currentUserId);
|
||||
$courses = $user->getCourses();
|
||||
$checker = false;
|
||||
foreach ($courses as $course) {
|
||||
$checker = true;
|
||||
$selectOptions[$course->getCourse()->getId()] = $course->getCourse()->getTitle();
|
||||
}
|
||||
if (!$checker) {
|
||||
$form->addHtml(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('YouNeedToBeRegisteredInAtLeastOneCourse'),
|
||||
'error'
|
||||
)
|
||||
);
|
||||
}
|
||||
$form->addSelect('info_select', get_lang('Course'), $selectOptions);
|
||||
} elseif ($typeSession) {
|
||||
$sessions = [];
|
||||
/** @var User $user */
|
||||
$user = UserManager::getRepository()->find($currentUserId);
|
||||
$userSubscriptions = $user->getSessionCourseSubscriptions();
|
||||
|
||||
/** @var SessionRelCourseRelUser $userSubscription */
|
||||
foreach ($userSubscriptions as $userSubscription) {
|
||||
$sessions[$userSubscription->getSession()->getId()] = $userSubscription->getSession()->getName();
|
||||
}
|
||||
|
||||
$sessionsAsGeneralCoach = $user->getSessionAsGeneralCoach();
|
||||
/** @var Session $sessionAsGeneralCoach */
|
||||
foreach ($sessionsAsGeneralCoach as $sessionAsGeneralCoach) {
|
||||
$sessions[$sessionAsGeneralCoach->getId()] = $sessionAsGeneralCoach->getName();
|
||||
}
|
||||
|
||||
if (!$sessions) {
|
||||
$form->addHtml(Display::return_message($plugin->get_lang('YouNeedToBeRegisteredInAtLeastOneSession'), 'error'));
|
||||
} else {
|
||||
$selectOptions = $sessions;
|
||||
$form->addSelect('info_select', get_lang('Session'), $selectOptions);
|
||||
}
|
||||
} elseif ($typeFinalLp) {
|
||||
// We need here to check the current user courses first
|
||||
/** @var User $user */
|
||||
$user = UserManager::getRepository()->find($currentUserId);
|
||||
$courses = $user->getCourses();
|
||||
$courseLpList = [];
|
||||
$sessionLpList = [];
|
||||
$checker = false;
|
||||
foreach ($courses as $course) {
|
||||
// Now get all the courses lp's
|
||||
$thisLpList = $em->getRepository('ChamiloCourseBundle:CLp')->findBy(['cId' => $course->getCourse()->getId()]);
|
||||
foreach ($thisLpList as $lp) {
|
||||
$courseLpList[$lp->getCId()] = $lp->getName().' ('.$course->getCourse()->getTitle().')';
|
||||
}
|
||||
}
|
||||
|
||||
// Here now checking the current user sessions
|
||||
$sessions = $user->getSessionCourseSubscriptions();
|
||||
foreach ($sessions as $session) {
|
||||
$thisLpList = $em
|
||||
->getRepository('ChamiloCourseBundle:CLp')
|
||||
->findBy(['sessionId' => $session->getSession()->getId()]);
|
||||
|
||||
// Here check all the lpItems
|
||||
foreach ($thisLpList as $lp) {
|
||||
$thisLpItems = $em->getRepository('ChamiloCourseBundle:CLpItem')->findBy(['lpId' => $lp->getId()]);
|
||||
|
||||
foreach ($thisLpItems as $item) {
|
||||
//Now only we need the final item and return the current LP
|
||||
if ($item->getItemType() == TOOL_LP_FINAL_ITEM) {
|
||||
$checker = true;
|
||||
$sessionLpList[$lp->getCId()] = $lp->getName().' ('.$session->getSession()->getName().')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$thisLpList = $em->getRepository('ChamiloCourseBundle:CLp')->findBy(['cId' => $session->getCourse()->getId()]);
|
||||
|
||||
// Here check all the lpItems
|
||||
foreach ($thisLpList as $lp) {
|
||||
$thisLpItems = $em->getRepository('ChamiloCourseBundle:CLpItem')->findBy(['lpId' => $lp->getId()]);
|
||||
foreach ($thisLpItems as $item) {
|
||||
//Now only we need the final item and return the current LP
|
||||
if ($item->getItemType() == TOOL_LP_FINAL_ITEM) {
|
||||
$checker = true;
|
||||
$sessionLpList[$lp->getCId()] = $lp->getName().' ('.$session->getSession()->getName().')';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$selectOptions = $selectOptions + $courseLpList + $sessionLpList;
|
||||
if (!$checker) {
|
||||
$form->addHtml(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('YourCoursesNeedAtLeastOneLearningPath'),
|
||||
'error'
|
||||
)
|
||||
);
|
||||
}
|
||||
$form->addSelect('info_select', get_lang('LearningPath'), $selectOptions);
|
||||
}
|
||||
|
||||
$form->addHidden('t', intval($_GET['t']));
|
||||
$form->addHidden('i', intval($_GET['i']));
|
||||
$form->addButton('submit', $plugin->get_lang('ConfirmOrder'), 'check', 'success');
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (!isset($formValues['payment_type'])) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('NeedToSelectPaymentType'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
$infoSelected = [];
|
||||
if ($infoRequired) {
|
||||
if (isset($formValues['info_select'])) {
|
||||
$infoSelected = $formValues['info_select'];
|
||||
} else {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('AdditionalInfoRequired'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$serviceSaleId = $plugin->registerServiceSale(
|
||||
$serviceId,
|
||||
$formValues['payment_type'],
|
||||
$infoSelected,
|
||||
$formValues['c']
|
||||
);
|
||||
|
||||
if ($serviceSaleId !== false) {
|
||||
$_SESSION['bc_service_sale_id'] = $serviceSaleId;
|
||||
|
||||
if (isset($formValues['c'])) {
|
||||
$couponSaleId = $plugin->registerCouponServiceSale($serviceSaleId, $formValues['c']);
|
||||
if ($couponSaleId !== false) {
|
||||
$plugin->updateCouponDelivered($formValues['c']);
|
||||
$_SESSION['bc_coupon_id'] = $formValues['c'];
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_process_confirm.php');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$formCoupon = new FormValidator('confirm_coupon');
|
||||
if ($formCoupon->validate()) {
|
||||
$formCouponValues = $formCoupon->getSubmitValues();
|
||||
|
||||
if (!$formCouponValues['coupon_code']) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('NeedToAddCouponCode'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
$coupon = $plugin->getCouponServiceByCode($formCouponValues['coupon_code'], $formCouponValues['i']);
|
||||
|
||||
if ($coupon == null) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CouponNotValid'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CouponRedeemed'), 'success', false)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_process.php?i='.$_REQUEST['i'].'&t='.$_REQUEST['t'].'&c='.$formCouponValues['coupon_code']);
|
||||
|
||||
exit;
|
||||
}
|
||||
$formCoupon->addText('coupon_code', $plugin->get_lang('CouponsCode'), true);
|
||||
$formCoupon->addHidden('t', intval($_GET['t']));
|
||||
$formCoupon->addHidden('i', intval($_GET['i']));
|
||||
if ($coupon != null) {
|
||||
$form->addHidden('c', intval($coupon['id']));
|
||||
}
|
||||
$formCoupon->addButton('submit', $plugin->get_lang('RedeemCoupon'), 'check', 'success', 'btn-lg pull-right');
|
||||
|
||||
// View
|
||||
$templateName = $plugin->get_lang('PaymentMethods');
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'service_catalog.php',
|
||||
'name' => $plugin->get_lang('ListOfServicesOnSale'),
|
||||
];
|
||||
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('buying_service', true);
|
||||
$tpl->assign('service', $serviceInfo);
|
||||
$tpl->assign('user', api_get_user_info());
|
||||
$tpl->assign('form_coupon', $formCoupon->returnForm());
|
||||
$tpl->assign('form', $form->returnForm());
|
||||
$content = $tpl->fetch('buycourses/view/service_process.tpl');
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
385
plugin/buycourses/src/service_process_confirm.php
Normal file
@@ -0,0 +1,385 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
use ChamiloSession as Session;
|
||||
|
||||
/**
|
||||
* Process purchase confirmation script for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$serviceSaleId = Session::read('bc_service_sale_id');
|
||||
$couponId = Session::read('bc_coupon_id');
|
||||
|
||||
if (empty($serviceSaleId)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$serviceSale = $plugin->getServiceSale($serviceSaleId, $coupon);
|
||||
$userInfo = api_get_user_info($serviceSale['buyer']['id']);
|
||||
|
||||
if (!empty($couponId)) {
|
||||
$coupon = $plugin->getCouponService($couponId, $serviceSale['service_id']);
|
||||
$serviceSale['item'] = $plugin->getService($serviceSale['service_id'], $coupon);
|
||||
}
|
||||
|
||||
if (empty($serviceSale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$currency = $plugin->getCurrency($serviceSale['currency_id']);
|
||||
$globalParameters = $plugin->getGlobalParameters();
|
||||
|
||||
switch ($serviceSale['payment_type']) {
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL:
|
||||
$paypalParams = $plugin->getPaypalParams();
|
||||
|
||||
$pruebas = $paypalParams['sandbox'] == 1;
|
||||
$paypalUsername = $paypalParams['username'];
|
||||
$paypalPassword = $paypalParams['password'];
|
||||
$paypalSignature = $paypalParams['signature'];
|
||||
|
||||
// This var $itemPrice may be "0" if the transaction does not include a one-time purchase such as when you set up
|
||||
// a billing agreement for a recurring payment that is not immediately charged. When the field is set to 0,
|
||||
// purchase-specific fields are ignored. This little condition handle this fact.
|
||||
$itemPrice = $serviceSale['price'];
|
||||
|
||||
$returnUrl = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_success.php';
|
||||
$cancelUrl = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_error.php';
|
||||
|
||||
// The extra params for handle the hard job, this var is VERY IMPORTANT !!
|
||||
$extra = '';
|
||||
require_once 'paypalfunctions.php';
|
||||
|
||||
$extra .= "&L_PAYMENTREQUEST_0_NAME0={$serviceSale['service']['name']}";
|
||||
$extra .= "&L_PAYMENTREQUEST_0_QTY0=1";
|
||||
$extra .= "&L_PAYMENTREQUEST_0_AMT0=$itemPrice";
|
||||
|
||||
// Full Checkout express
|
||||
$expressCheckout = CallShortcutExpressCheckout(
|
||||
$itemPrice,
|
||||
$currency['iso_code'],
|
||||
'paypal',
|
||||
$returnUrl,
|
||||
$cancelUrl,
|
||||
$extra
|
||||
);
|
||||
|
||||
if ($expressCheckout['ACK'] !== 'Success') {
|
||||
$erroMessage = vsprintf(
|
||||
$plugin->get_lang('ErrorOccurred'),
|
||||
[$expressCheckout['L_ERRORCODE0'], $expressCheckout['L_LONGMESSAGE0']]
|
||||
);
|
||||
Display::addFlash(
|
||||
Display::return_message($erroMessage, 'error', false)
|
||||
);
|
||||
|
||||
$plugin->cancelServiceSale($serviceSale['id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($globalParameters['sale_email'])) {
|
||||
$messageConfirmTemplate = new Template();
|
||||
$messageConfirmTemplate->assign('user', $userInfo);
|
||||
$messageConfirmTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $serviceSale['buy_date'],
|
||||
'product' => $serviceSale['service']['name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $serviceSale['price'],
|
||||
'reference' => $serviceSale['reference'],
|
||||
]
|
||||
);
|
||||
|
||||
api_mail_html(
|
||||
'',
|
||||
$globalParameters['sale_email'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageConfirmTemplate->fetch('buycourses/view/message_confirm.tpl')
|
||||
);
|
||||
}
|
||||
|
||||
RedirectToPayPal($expressCheckout['TOKEN']);
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER:
|
||||
$transferAccounts = $plugin->getTransferAccounts();
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelServiceSale($serviceSale['id']);
|
||||
|
||||
unset($_SESSION['bc_service_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('OrderCancelled'), 'error', false)
|
||||
);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$messageTemplate = new Template();
|
||||
$messageTemplate->assign(
|
||||
'service_sale',
|
||||
[
|
||||
'name' => $serviceSale['service']['name'],
|
||||
'buyer' => $serviceSale['buyer']['name'],
|
||||
'buy_date' => $serviceSale['buy_date'],
|
||||
'start_date' => $serviceSale['start_date'],
|
||||
'end_date' => $serviceSale['end_date'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $serviceSale['price'],
|
||||
'reference' => $serviceSale['reference'],
|
||||
]
|
||||
);
|
||||
$messageTemplate->assign('transfer_accounts', $transferAccounts);
|
||||
$buyer = api_get_user_info($serviceSale['buyer']['id']);
|
||||
|
||||
MessageManager::send_message_simple(
|
||||
$buyer['user_id'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageTemplate->fetch('buycourses/view/service_message_transfer.tpl')
|
||||
);
|
||||
|
||||
if (!empty($globalParameters['sale_email'])) {
|
||||
$messageConfirmTemplate = new Template();
|
||||
$messageConfirmTemplate->assign('user', $userInfo);
|
||||
$messageConfirmTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $serviceSale['buy_date'],
|
||||
'product' => $serviceSale['service']['name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $serviceSale['price'],
|
||||
'reference' => $serviceSale['reference'],
|
||||
]
|
||||
);
|
||||
|
||||
api_mail_html(
|
||||
'',
|
||||
$globalParameters['sale_email'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageConfirmTemplate->fetch('buycourses/view/message_confirm.tpl')
|
||||
);
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
sprintf(
|
||||
$plugin->get_lang('PurchaseStatusX'),
|
||||
$plugin->get_lang('PendingReasonByTransfer')
|
||||
),
|
||||
'success',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
unset($_SESSION['bc_service_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButton(
|
||||
'cancel',
|
||||
$plugin->get_lang('CancelOrder'),
|
||||
'times',
|
||||
'danger',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'cancel']
|
||||
);
|
||||
|
||||
$template = new Template();
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $serviceSale['service']['name']);
|
||||
$template->assign('price', $serviceSale['price']);
|
||||
$template->assign('currency', $serviceSale['currency_id']);
|
||||
$template->assign('buying_service', $serviceSale);
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('service', $serviceSale['service']);
|
||||
$template->assign('service_item', $serviceSale['item']);
|
||||
$template->assign('transfer_accounts', $transferAccounts);
|
||||
$template->assign('form', $form->returnForm());
|
||||
|
||||
$content = $template->fetch('buycourses/view/process_confirm.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
break;
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_CULQI:
|
||||
// We need to include the main online script, acording to the Culqi documentation the JS needs to be loeaded
|
||||
// directly from the main url "https://integ-pago.culqi.com" because a local copy of this JS is not supported
|
||||
$htmlHeadXtra[] = '<script src="//integ-pago.culqi.com/js/v1"></script>';
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelServiceSale($serviceSale['id']);
|
||||
|
||||
unset($_SESSION['bc_service_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('OrderCanceled'),
|
||||
'warning',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButton(
|
||||
'cancel',
|
||||
$plugin->get_lang('CancelOrder'),
|
||||
'times',
|
||||
'danger',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'cancel']
|
||||
);
|
||||
|
||||
$template = new Template();
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $serviceSale['service']['name']);
|
||||
$template->assign('price', floatval($serviceSale['price']));
|
||||
$template->assign('currency', $plugin->getSelectedCurrency());
|
||||
$template->assign('buying_service', $serviceSale);
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('service', $serviceSale['service']);
|
||||
$template->assign('service_item', $serviceSale['item']);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('is_culqi_payment', true);
|
||||
$template->assign('culqi_params', $culqiParams = $plugin->getCulqiParams());
|
||||
$content = $template->fetch('buycourses/view/process_confirm.tpl');
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
break;
|
||||
|
||||
case BuyCoursesPlugin::PAYMENT_TYPE_TPV_CECABANK:
|
||||
$cecabankParams = $plugin->getcecabankParams();
|
||||
$currency = $plugin->getCurrency($sale['currency_id']);
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelServiceSale($sale['id']);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
unset($_SESSION['bc_coupon_id']);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$urlTpv = $cecabankParams['merchart_id'];
|
||||
$currency = $plugin->getCurrency($sale['currency_id']);
|
||||
$signature = $plugin->getCecabankSignature($sale['reference'], $sale['price']);
|
||||
|
||||
echo '<form name="tpv_chamilo" action="'.$urlTpv.'" method="POST">';
|
||||
echo '<input type="hidden" name="MerchantID" value="'.$cecabankParams['merchant_id'].'" />';
|
||||
echo '<input type="hidden" name="AcquirerBIN" value="'.$cecabankParams['acquirer_bin'].'" />';
|
||||
echo '<input type="hidden" name="TerminalID" value="'.$cecabankParams['terminal_id'].'" />';
|
||||
echo '<input type="hidden" name="URL_OK" value="'.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/cecabank_success.php'.'" />';
|
||||
echo '<input type="hidden" name="URL_NOK" value="'.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/cecabank_cancel.php'.'" />';
|
||||
echo '<input type="hidden" name="Firma" value="'.$signature.'" />';
|
||||
echo '<input type="hidden" name="Cifrado" value="'.$cecabankParams['cypher'].'" />';
|
||||
echo '<input type="hidden" name="Num_operacion" value="'.$sale['reference'].'" />';
|
||||
echo '<input type="hidden" name="Importe" value="'.($sale['price'] * 100).'" />';
|
||||
echo '<input type="hidden" name="TipoMoneda" value="'.$cecabankParams['currency'].'" />';
|
||||
echo '<input type="hidden" name="Exponente" value="'.$cecabankParams['exponent'].'" />';
|
||||
echo '<input type="hidden" name="Pago_soportado" value="'.$cecabankParams['supported_payment'].'" />';
|
||||
echo '</form>';
|
||||
|
||||
echo '<SCRIPT language=javascript>';
|
||||
echo 'document.tpv_chamilo.submit();';
|
||||
echo '</script>';
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success',
|
||||
'default',
|
||||
null,
|
||||
['id' => 'confirm']
|
||||
);
|
||||
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
|
||||
|
||||
$template = new Template();
|
||||
$template->assign('terms', $globalParameters['terms_and_conditions']);
|
||||
$template->assign('title', $serviceSale['service']['name']);
|
||||
$template->assign('price', $serviceSale['price']);
|
||||
$template->assign('currency', $serviceSale['currency_id']);
|
||||
$template->assign('buying_service', $serviceSale);
|
||||
$template->assign('user', $userInfo);
|
||||
$template->assign('service', $serviceSale['service']);
|
||||
$template->assign('service_item', $serviceSale['item']);
|
||||
$template->assign('transfer_accounts', $transferAccounts);
|
||||
$template->assign('form', $form->returnForm());
|
||||
|
||||
$content = $template->fetch('buycourses/view/process_confirm.tpl');
|
||||
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
|
||||
break;
|
||||
}
|
||||
103
plugin/buycourses/src/service_sales_report.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of pending payments of the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable');
|
||||
$commissionsEnable = $plugin->get('commissions_enable');
|
||||
$includeServices = $plugin->get('include_services');
|
||||
$invoicingEnable = $plugin->get('invoicing_enable') === 'true';
|
||||
|
||||
$saleStatuses = $plugin->getServiceSaleStatuses();
|
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_PENDING;
|
||||
$form = new FormValidator('search', 'get');
|
||||
|
||||
if ($form->validate()) {
|
||||
$selectedStatus = $form->getSubmitValue('status');
|
||||
if ($selectedStatus === false) {
|
||||
$selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING;
|
||||
}
|
||||
}
|
||||
|
||||
$form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses, ['cols-size' => [0, 0, 0]]);
|
||||
$form->addText('user', get_lang('User'), false, ['cols-size' => [0, 0, 0]]);
|
||||
$form->addButtonSearch(get_lang('Search'), 'search');
|
||||
|
||||
$servicesSales = $plugin->getServiceSales(0, $selectedStatus);
|
||||
|
||||
foreach ($servicesSales as &$sale) {
|
||||
if (isset($sale['discount_amount']) && $sale['discount_amount'] != 0) {
|
||||
$sale['total_discount'] = $plugin->getPriceWithCurrencyFromIsoCode($sale['discount_amount'], $sale['iso_code']);
|
||||
$sale['coupon_code'] = $plugin->getServiceSaleCouponCode($sale['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => '../index.php', 'name' => $plugin->get_lang('plugin_title')];
|
||||
|
||||
$webPluginPath = api_get_path(WEB_PLUGIN_PATH);
|
||||
$htmlHeadXtra[] = api_get_css($webPluginPath.'buycourses/resources/css/style.css');
|
||||
$htmlHeadXtra[] = api_get_css($webPluginPath.'buycourses/resources/js/modals.js');
|
||||
|
||||
$templateName = $plugin->get_lang('SalesReport');
|
||||
|
||||
$template = new Template($templateName);
|
||||
|
||||
$toolbar = Display::url(
|
||||
Display::returnFontAwesomeIcon('file-excel-o').
|
||||
get_lang('GenerateReport'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/export_report.php',
|
||||
['class' => 'btn btn-primary']
|
||||
);
|
||||
|
||||
if ($paypalEnable == 'true' && $commissionsEnable == 'true') {
|
||||
$toolbar .= Display::toolbarButton(
|
||||
$plugin->get_lang('PaypalPayoutCommissions'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/paypal_payout.php',
|
||||
'paypal',
|
||||
'primary',
|
||||
['title' => $plugin->get_lang('PaypalPayoutCommissions')]
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
|
||||
if ($commissionsEnable == 'true') {
|
||||
$toolbar = Display::toolbarButton(
|
||||
$plugin->get_lang('PayoutReport'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/payout_report.php',
|
||||
'money',
|
||||
'info',
|
||||
['title' => $plugin->get_lang('PayoutReport')]
|
||||
);
|
||||
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
}
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('showing_services', true);
|
||||
$template->assign('services_are_included', $includeServices);
|
||||
$template->assign('sale_list', $servicesSales);
|
||||
$template->assign('sale_status_cancelled', BuyCoursesPlugin::SERVICE_STATUS_CANCELLED);
|
||||
$template->assign('sale_status_pending', BuyCoursesPlugin::SERVICE_STATUS_PENDING);
|
||||
$template->assign('sale_status_completed', BuyCoursesPlugin::SERVICE_STATUS_COMPLETED);
|
||||
$template->assign('invoicing_enable', $invoicingEnable);
|
||||
$content = $template->fetch('buycourses/view/service_sales_report.tpl');
|
||||
$template->assign('content', $content);
|
||||
$template->assign('header', $templateName);
|
||||
$template->display_one_col_template();
|
||||
186
plugin/buycourses/src/service_success.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Success page for the purchase of a service in the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$paypalEnabled = $plugin->get('paypal_enable') === 'true';
|
||||
|
||||
if (!$paypalEnabled) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$serviceSaleId = $_SESSION['bc_service_sale_id'];
|
||||
$serviceSale = $plugin->getServiceSale($serviceSaleId);
|
||||
$itemPrice = $serviceSale['price'];
|
||||
|
||||
if (empty($serviceSale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$paypalParams = $plugin->getPaypalParams();
|
||||
|
||||
$pruebas = $paypalParams['sandbox'] == 1;
|
||||
$paypalUsername = $paypalParams['username'];
|
||||
$paypalPassword = $paypalParams['password'];
|
||||
$paypalSignature = $paypalParams['signature'];
|
||||
|
||||
require_once "paypalfunctions.php";
|
||||
|
||||
$buyerInformation = GetShippingDetails(urlencode($_SESSION['TOKEN']));
|
||||
|
||||
$form = new FormValidator(
|
||||
'success',
|
||||
'POST',
|
||||
api_get_self(),
|
||||
null,
|
||||
null,
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
$form->addButton(
|
||||
'confirm',
|
||||
$plugin->get_lang('ConfirmOrder'),
|
||||
'check',
|
||||
'success'
|
||||
);
|
||||
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
if (isset($formValues['cancel'])) {
|
||||
$plugin->cancelServiceSale($serviceSale['id']);
|
||||
|
||||
unset($_SESSION['bc_service_sale_id']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('OrderCancelled'), 'error', false)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$confirmPayments = ConfirmPayment($itemPrice);
|
||||
if ($confirmPayments['ACK'] !== 'Success') {
|
||||
$erroMessage = vsprintf(
|
||||
$plugin->get_lang('ErrorOccurred'),
|
||||
[$expressCheckout['L_ERRORCODE0'], $confirmPayments['L_LONGMESSAGE0']]
|
||||
);
|
||||
Display::addFlash(
|
||||
Display::return_message($erroMessage, 'error', false)
|
||||
);
|
||||
unset($_SESSION['wizard']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
switch ($confirmPayments["PAYMENTINFO_0_PAYMENTSTATUS"]) {
|
||||
case 'Completed':
|
||||
$serviceSaleIsCompleted = $plugin->completeServiceSale($serviceSale['id']);
|
||||
|
||||
if ($serviceSaleIsCompleted) {
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
sprintf($plugin->get_lang('SubscriptionToServiceXSuccessful'), $serviceSale['service']['name']),
|
||||
'success'
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('ErrorContactPlatformAdmin'), 'error')
|
||||
);
|
||||
break;
|
||||
case 'Pending':
|
||||
switch ($confirmPayments["PAYMENTINFO_0_PENDINGREASON"]) {
|
||||
case 'address':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByAddress');
|
||||
break;
|
||||
case 'authorization':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByAuthorization');
|
||||
break;
|
||||
case 'echeck':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByEcheck');
|
||||
break;
|
||||
case 'intl':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByIntl');
|
||||
break;
|
||||
case 'multicurrency':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByMulticurrency');
|
||||
break;
|
||||
case 'order':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByOrder');
|
||||
break;
|
||||
case 'paymentreview':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByPaymentReview');
|
||||
break;
|
||||
case 'regulatoryreview':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByRegulatoryReview');
|
||||
break;
|
||||
case 'unilateral':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByUnilateral');
|
||||
break;
|
||||
case 'upgrade':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByUpgrade');
|
||||
break;
|
||||
case 'verify':
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByVerify');
|
||||
break;
|
||||
case 'other':
|
||||
default:
|
||||
$purchaseStatus = $plugin->get_lang('PendingReasonByOther');
|
||||
break;
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
sprintf($plugin->get_lang('PurchaseStatusX'), $purchaseStatus),
|
||||
'warning',
|
||||
false
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$plugin->cancelServiceSale(intval($serviceSale['id']));
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('ErrorContactPlatformAdmin'), 'error')
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
unset($_SESSION['bc_service_sale_id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$token = isset($_GET['token']) ? Security::remove_XSS($_GET['token']) : null;
|
||||
if (empty($token)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = [
|
||||
"url" => "service_catalog.php",
|
||||
"name" => $plugin->get_lang('ListOfServicesOnSale'),
|
||||
];
|
||||
|
||||
$templateName = $plugin->get_lang('PaymentMethods');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('title', $serviceSale['service']['name']);
|
||||
$tpl->assign('price', $serviceSale['price']);
|
||||
$tpl->assign('currency', $serviceSale['currency_id']);
|
||||
$tpl->assign('service', $serviceSale);
|
||||
$tpl->assign('buying_service', true);
|
||||
$tpl->assign('user', api_get_user_info($serviceSale['buyer']['id']));
|
||||
$tpl->assign('form', $form->returnForm());
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/success.tpl');
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
141
plugin/buycourses/src/services_add.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Create new Services for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
$em = Database::getManager();
|
||||
$users = UserManager::getRepository()->findAll();
|
||||
$userOptions = [];
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$userOptions[$user->getId()] = $user->getCompleteNameWithUsername();
|
||||
}
|
||||
}
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
$htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css');
|
||||
$htmlHeadXtra[] = api_get_asset('cropper/dist/cropper.min.js');
|
||||
|
||||
//view
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php',
|
||||
'name' => $plugin->get_lang('plugin_title'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'list_service.php',
|
||||
'name' => $plugin->get_lang('Services'),
|
||||
];
|
||||
|
||||
$globalSettingsParams = $plugin->getGlobalParameters();
|
||||
|
||||
$formDefaultValues = [
|
||||
'price' => 0,
|
||||
'tax_perc' => $globalSettingsParams['global_tax_perc'],
|
||||
'duration_days' => 0,
|
||||
'applies_to' => 0,
|
||||
'visibility' => true,
|
||||
];
|
||||
|
||||
$form = new FormValidator('Services');
|
||||
$form->addText('name', $plugin->get_lang('ServiceName'));
|
||||
$form->addHtmlEditor('description', $plugin->get_lang('Description'));
|
||||
$form->addElement(
|
||||
'number',
|
||||
'price',
|
||||
[$plugin->get_lang('Price'), null, $currency['iso_code']],
|
||||
['step' => 0.01]
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'tax_perc',
|
||||
[$plugin->get_lang('TaxPerc'), $plugin->get_lang('TaxPercDescription'), '%'],
|
||||
['step' => 1, 'placeholder' => $globalSettingsParams['global_tax_perc'].'% '.$plugin->get_lang('ByDefault')]
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'duration_days',
|
||||
[$plugin->get_lang('Duration'), null, get_lang('Days')],
|
||||
['step' => 1]
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
$plugin->get_lang('AppliesTo'),
|
||||
get_lang('None'),
|
||||
0
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
null,
|
||||
get_lang('User'),
|
||||
1
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
null,
|
||||
get_lang('Course'),
|
||||
2
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
null,
|
||||
get_lang('Session'),
|
||||
3
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
null,
|
||||
get_lang('TemplateTitleCertificate'),
|
||||
4
|
||||
);
|
||||
$form->addSelect(
|
||||
'owner_id',
|
||||
get_lang('Owner'),
|
||||
$userOptions
|
||||
);
|
||||
$form->addCheckBox('visibility', $plugin->get_lang('VisibleInCatalog'));
|
||||
$form->addFile(
|
||||
'picture',
|
||||
(get_lang(
|
||||
'AddImage'
|
||||
)),
|
||||
['id' => 'picture', 'class' => 'picture-form', 'crop_image' => true, 'crop_ratio' => '16 / 9']
|
||||
);
|
||||
$form->addText('video_url', get_lang('VideoUrl'), false);
|
||||
$form->addHtmlEditor('service_information', $plugin->get_lang('ServiceInformation'), false);
|
||||
$form->addButtonSave(get_lang('Add'));
|
||||
$form->setDefaults($formDefaultValues);
|
||||
|
||||
if ($form->validate()) {
|
||||
$values = $form->getSubmitValues();
|
||||
|
||||
$plugin->storeService($values);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('ServiceAdded'), 'success')
|
||||
);
|
||||
|
||||
header('Location: list_service.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$templateName = $plugin->get_lang('NewService');
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $form->returnForm());
|
||||
$tpl->display_one_col_template();
|
||||
161
plugin/buycourses/src/services_edit.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Create new Services for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../../../main/inc/global.inc.php';
|
||||
|
||||
$serviceId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
|
||||
|
||||
if (!$serviceId) {
|
||||
header('Location: list.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
$users = UserManager::getRepository()->findAll();
|
||||
$userOptions = [];
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$userOptions[$user->getId()] = $user->getCompleteNameWithUsername();
|
||||
}
|
||||
}
|
||||
|
||||
api_protect_admin_script(true);
|
||||
$htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css');
|
||||
$htmlHeadXtra[] = api_get_asset('cropper/dist/cropper.min.js');
|
||||
|
||||
//view
|
||||
// breadcrumbs
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_PLUGIN_PATH).'buycourses/index.php',
|
||||
'name' => $plugin->get_lang('plugin_title'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'list_service.php',
|
||||
'name' => $plugin->get_lang('Services'),
|
||||
];
|
||||
|
||||
$globalSettingsParams = $plugin->getGlobalParameters();
|
||||
$service = $plugin->getService($serviceId);
|
||||
|
||||
$formDefaultValues = [
|
||||
'name' => $service['name'],
|
||||
'description' => $service['description'],
|
||||
'price' => $service['price'],
|
||||
'tax_perc' => $service['tax_perc'],
|
||||
'duration_days' => $service['duration_days'],
|
||||
'owner_id' => intval($service['owner_id']),
|
||||
'applies_to' => intval($service['applies_to']),
|
||||
'visibility' => ($service['visibility'] == 1) ? true : false,
|
||||
'image' => is_file(api_get_path(SYS_PLUGIN_PATH).'buycourses/uploads/services/images/simg-'.$serviceId.'.png')
|
||||
? api_get_path(WEB_PLUGIN_PATH).'buycourses/uploads/services/images/simg-'.$serviceId.'.png'
|
||||
: api_get_path(WEB_CODE_PATH).'img/session_default.png',
|
||||
'video_url' => $service['video_url'],
|
||||
'service_information' => $service['service_information'],
|
||||
];
|
||||
|
||||
$form = new FormValidator('Services');
|
||||
$form->addText('name', $plugin->get_lang('ServiceName'));
|
||||
$form->addHtmlEditor('description', $plugin->get_lang('Description'));
|
||||
$form->addElement(
|
||||
'number',
|
||||
'price',
|
||||
[$plugin->get_lang('Price'), null, $currency['iso_code']],
|
||||
['step' => 0.01]
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'tax_perc',
|
||||
[$plugin->get_lang('TaxPerc'), $plugin->get_lang('TaxPercDescription'), '%'],
|
||||
['step' => 1, 'placeholder' => $globalSettingsParams['global_tax_perc'].'% '.$plugin->get_lang('ByDefault')]
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'duration_days',
|
||||
[$plugin->get_lang('Duration'), null, get_lang('Days')],
|
||||
['step' => 1]
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
$plugin->get_lang('AppliesTo'),
|
||||
get_lang('None'),
|
||||
0
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
null,
|
||||
get_lang('User'),
|
||||
1
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
null,
|
||||
get_lang('Course'),
|
||||
2
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
null,
|
||||
get_lang('Session'),
|
||||
3
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'applies_to',
|
||||
null,
|
||||
get_lang('TemplateTitleCertificate'),
|
||||
4
|
||||
);
|
||||
$form->addSelect(
|
||||
'owner_id',
|
||||
get_lang('Owner'),
|
||||
$userOptions
|
||||
);
|
||||
$form->addCheckBox('visibility', $plugin->get_lang('VisibleInCatalog'));
|
||||
$form->addFile(
|
||||
'picture',
|
||||
$formDefaultValues['image'] != '' ? get_lang('UpdateImage') : get_lang('AddImage'),
|
||||
['id' => 'picture', 'class' => 'picture-form', 'crop_image' => true, 'crop_ratio' => '16 / 9']
|
||||
);
|
||||
$form->addText('video_url', get_lang('VideoUrl'), false);
|
||||
$form->addHtmlEditor('service_information', $plugin->get_lang('ServiceInformation'), false);
|
||||
$form->addHidden('id', $serviceId);
|
||||
$form->addButtonSave(get_lang('Edit'));
|
||||
$form->addHtml('<br /><br /><br /><br />');
|
||||
$form->addButtonDelete($plugin->get_lang('DeleteThisService'), 'delete_service');
|
||||
$form->setDefaults($formDefaultValues);
|
||||
if ($form->validate()) {
|
||||
$values = $form->getSubmitValues();
|
||||
|
||||
if (isset($values['delete_service'])) {
|
||||
$plugin->deleteService($serviceId);
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('ServiceDeleted'), 'error')
|
||||
);
|
||||
} else {
|
||||
$plugin->updateService($values, $serviceId);
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('ServiceEdited'), 'success')
|
||||
);
|
||||
}
|
||||
header('Location: list_service.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$templateName = $plugin->get_lang('EditService');
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $form->returnForm());
|
||||
$tpl->display_one_col_template();
|
||||
127
plugin/buycourses/src/session_catalog.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of courses.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
if (!$includeSessions) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$nameFilter = null;
|
||||
$minFilter = 0;
|
||||
$maxFilter = 0;
|
||||
$sessionCategory = isset($_GET['session_category']) ? (int) $_GET['session_category'] : 0;
|
||||
$form = new FormValidator(
|
||||
'search_filter_form',
|
||||
'get',
|
||||
null,
|
||||
null,
|
||||
[],
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
$form->removeAttribute('class');
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$nameFilter = isset($formValues['name']) ? $formValues['name'] : null;
|
||||
$minFilter = isset($formValues['min']) ? $formValues['min'] : 0;
|
||||
$maxFilter = isset($formValues['max']) ? $formValues['max'] : 0;
|
||||
$sessionCategory = isset($formValues['session_category']) ? $formValues['session_category'] : $sessionCategory;
|
||||
}
|
||||
|
||||
$form->addHeader($plugin->get_lang('SearchFilter'));
|
||||
|
||||
$categoriesOptions = [
|
||||
'0' => get_lang('AllCategories'),
|
||||
];
|
||||
$categoriesList = SessionManager::get_all_session_category();
|
||||
if ($categoriesList != false) {
|
||||
foreach ($categoriesList as $categoryItem) {
|
||||
$categoriesOptions[$categoryItem['id']] = $categoryItem['name'];
|
||||
}
|
||||
}
|
||||
$form->addSelect(
|
||||
'session_category',
|
||||
get_lang('SessionCategory'),
|
||||
$categoriesOptions,
|
||||
[
|
||||
'id' => 'session_category',
|
||||
]
|
||||
);
|
||||
|
||||
$form->addText('name', get_lang('SessionName'), false);
|
||||
|
||||
$form->addElement(
|
||||
'number',
|
||||
'min',
|
||||
$plugin->get_lang('MinimumPrice'),
|
||||
['step' => '0.01', 'min' => '0']
|
||||
);
|
||||
$form->addElement(
|
||||
'number',
|
||||
'max',
|
||||
$plugin->get_lang('MaximumPrice'),
|
||||
['step' => '0.01', 'min' => '0']
|
||||
);
|
||||
$form->addHtml('<hr>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
|
||||
$form->setDefaults(
|
||||
[
|
||||
'session_category' => $sessionCategory,
|
||||
]
|
||||
);
|
||||
$pageSize = BuyCoursesPlugin::PAGINATION_PAGE_SIZE;
|
||||
$currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$first = $pageSize * ($currentPage - 1);
|
||||
$sessionList = $plugin->getCatalogSessionList($first, $pageSize, $nameFilter, $minFilter, $maxFilter, 'all', $sessionCategory);
|
||||
$totalItems = $plugin->getCatalogSessionList($first, $pageSize, $nameFilter, $minFilter, $maxFilter, 'count', $sessionCategory);
|
||||
$pagesCount = ceil($totalItems / $pageSize);
|
||||
$pagination = BuyCoursesPlugin::returnPagination(api_get_self(), $currentPage, $pagesCount, $totalItems);
|
||||
|
||||
// View
|
||||
if (api_is_platform_admin()) {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'list.php',
|
||||
'name' => $plugin->get_lang('AvailableCoursesConfiguration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'paymentsetup.php',
|
||||
'name' => $plugin->get_lang('PaymentsConfiguration'),
|
||||
];
|
||||
}
|
||||
|
||||
$templateName = $plugin->get_lang('CourseListOnSale');
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$template = new Template($templateName);
|
||||
$template->assign('search_filter_form', $form->returnForm());
|
||||
$template->assign('sessions_are_included', $includeSessions);
|
||||
$template->assign('services_are_included', $includeServices);
|
||||
$template->assign('showing_sessions', true);
|
||||
$template->assign('sessions', $sessionList);
|
||||
$template->assign('pagination', $pagination);
|
||||
|
||||
$countCourses = $plugin->getCatalogCourseList($first, $pageSize, $nameFilter, $minFilter, $maxFilter, 'count');
|
||||
|
||||
$template->assign('coursesExist', $countCourses > 0);
|
||||
$template->assign('sessionExist', true);
|
||||
|
||||
$content = $template->fetch('buycourses/view/catalog.tpl');
|
||||
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
67
plugin/buycourses/src/session_panel.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* User Panel.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
$userInfo = api_get_user_info();
|
||||
|
||||
$productTypes = $plugin->getProductTypes();
|
||||
$saleStatuses = $plugin->getSaleStatuses();
|
||||
$paymentTypes = $plugin->getPaymentTypes();
|
||||
|
||||
$sales = $plugin->getSaleListByUserId($userInfo['id']);
|
||||
|
||||
$saleList = [];
|
||||
|
||||
foreach ($sales as $sale) {
|
||||
if ($sale['product_type'] == 2) {
|
||||
$saleList[] = [
|
||||
'id' => $sale['id'],
|
||||
'reference' => $sale['reference'],
|
||||
'date' => api_format_date($sale['date'], DATE_TIME_FORMAT_LONG_24H),
|
||||
'currency' => $sale['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'product_name' => $sale['product_name'],
|
||||
'product_type' => $productTypes[$sale['product_type']],
|
||||
'payment_type' => $paymentTypes[$sale['payment_type']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$toolbar = Display::toolbarButton(
|
||||
$plugin->get_lang('CourseListOnSale'),
|
||||
'course_catalog.php',
|
||||
'search-plus',
|
||||
'primary',
|
||||
['title' => $plugin->get_lang('CourseListOnSale')]
|
||||
);
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = get_lang('TabsDashboard');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('showing_courses', true);
|
||||
$tpl->assign('sessions_are_included', $includeSessions);
|
||||
$tpl->assign('services_are_included', $includeServices);
|
||||
$tpl->assign('sale_list', $saleList);
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/session_panel.tpl');
|
||||
|
||||
$tpl->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
30
plugin/buycourses/src/stripe_cancel.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Success page for the purchase of a course in the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$stripeEnabled = $plugin->get('stripe_enable') === 'true';
|
||||
|
||||
if (!$stripeEnabled) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sale = $plugin->getSale($_SESSION['bc_sale_id']);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('ErrorContactPlatformAdmin'), 'error')
|
||||
);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/course_catalog.php');
|
||||
exit;
|
||||
65
plugin/buycourses/src/stripe_response.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$stripeEnabled = $plugin->get('stripe_enable') === 'true';
|
||||
|
||||
if (!$stripeEnabled) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$stripeParams = $plugin->getStripeParams();
|
||||
|
||||
$payload = @file_get_contents('php://input');
|
||||
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
|
||||
$event = null;
|
||||
|
||||
try {
|
||||
$event = \Stripe\Webhook::constructEvent(
|
||||
$payload, $sig_header, $stripeParams['endpoint_secret']
|
||||
);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
http_response_code(400);
|
||||
exit();
|
||||
} catch (\Stripe\Exception\SignatureVerificationException $e) {
|
||||
http_response_code(400);
|
||||
exit();
|
||||
}
|
||||
|
||||
switch ($event->type) {
|
||||
case 'checkout.session.completed':
|
||||
$checkoutSession = $event->data->object;
|
||||
|
||||
$sale = $plugin->getSaleFromReference($checkoutSession->id);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$buyingCourse = false;
|
||||
$buyingSession = false;
|
||||
|
||||
switch ($sale['product_type']) {
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
|
||||
$buyingCourse = true;
|
||||
$course = $plugin->getCourseInfo($sale['product_id']);
|
||||
break;
|
||||
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
|
||||
$buyingSession = true;
|
||||
$session = $plugin->getSessionInfo($sale['product_id']);
|
||||
break;
|
||||
}
|
||||
|
||||
$saleIsCompleted = $plugin->completeSale($sale['id']);
|
||||
|
||||
if ($saleIsCompleted) {
|
||||
$plugin->storePayouts($sale['id']);
|
||||
}
|
||||
|
||||
// no break
|
||||
default:
|
||||
echo 'Received unknown event type '.$event->type;
|
||||
}
|
||||
|
||||
http_response_code(200);
|
||||
78
plugin/buycourses/src/stripe_success.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Success page for the purchase of a course in the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$stripeEnabled = $plugin->get('stripe_enable') === 'true';
|
||||
|
||||
if (!$stripeEnabled) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sale = $plugin->getSale($_SESSION['bc_sale_id']);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$userInfo = api_get_user_info($sale['user_id']);
|
||||
$currency = $plugin->getCurrency($sale['currency_id']);
|
||||
$globalParameters = $plugin->getGlobalParameters();
|
||||
|
||||
if (!empty($globalParameters['sale_email'])) {
|
||||
$messageConfirmBuyerTemplate = new Template();
|
||||
$messageConfirmBuyerTemplate->assign('user', $userInfo);
|
||||
$messageConfirmBuyerTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $sale['date'],
|
||||
'product' => $sale['product_name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'reference' => $sale['reference'],
|
||||
]
|
||||
);
|
||||
|
||||
api_mail_html(
|
||||
$userInfo['complete_name'],
|
||||
$userInfo['email'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageConfirmBuyerTemplate->fetch('buycourses/view/message_confirm_buyer.tpl'),
|
||||
'',
|
||||
$globalParameters['sale_email']
|
||||
);
|
||||
|
||||
$messageConfirmTemplate = new Template();
|
||||
$messageConfirmTemplate->assign('user', $userInfo);
|
||||
$messageConfirmTemplate->assign(
|
||||
'sale',
|
||||
[
|
||||
'date' => $sale['date'],
|
||||
'product' => $sale['product_name'],
|
||||
'currency' => $currency['iso_code'],
|
||||
'price' => $sale['price'],
|
||||
'reference' => $sale['reference'],
|
||||
]
|
||||
);
|
||||
|
||||
api_mail_html(
|
||||
'',
|
||||
$globalParameters['sale_email'],
|
||||
$plugin->get_lang('bc_subject'),
|
||||
$messageConfirmTemplate->fetch('buycourses/view/message_confirm.tpl')
|
||||
);
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
$plugin->getSubscriptionSuccessMessage($sale)
|
||||
);
|
||||
|
||||
unset($_SESSION['bc_sale_id']);
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/course_catalog.php');
|
||||
exit;
|
||||
234
plugin/buycourses/src/subscription_add.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Configuration page for subscriptions for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
api_protect_admin_script(true);
|
||||
|
||||
$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
|
||||
$type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : 0;
|
||||
|
||||
if (empty($id) || empty($type)) {
|
||||
api_not_allowed();
|
||||
}
|
||||
|
||||
$queryString = 'id='.intval($_REQUEST['id']).'&type='.intval($_REQUEST['type']);
|
||||
|
||||
$editingCourse = $type === BuyCoursesPlugin::PRODUCT_TYPE_COURSE;
|
||||
$editingSession = $type === BuyCoursesPlugin::PRODUCT_TYPE_SESSION;
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
|
||||
$entityManager = Database::getManager();
|
||||
$userRepo = UserManager::getRepository();
|
||||
$currency = $plugin->getSelectedCurrency();
|
||||
|
||||
if (empty($currency)) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CurrencyIsNotConfigured'), 'error')
|
||||
);
|
||||
}
|
||||
|
||||
$currencyIso = null;
|
||||
|
||||
if ($editingCourse) {
|
||||
$course = $entityManager->find('ChamiloCoreBundle:Course', $id);
|
||||
if (!$course) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$courseItem = $plugin->getCourseForConfiguration($course, $currency);
|
||||
|
||||
$currencyIso = $courseItem['currency'];
|
||||
$formDefaults = [
|
||||
'product_type' => get_lang('Course'),
|
||||
'id' => $courseItem['course_id'],
|
||||
'type' => BuyCoursesPlugin::PRODUCT_TYPE_COURSE,
|
||||
'name' => $courseItem['course_title'],
|
||||
'visible' => $courseItem['visible'],
|
||||
'price' => $courseItem['price'],
|
||||
'tax_perc' => $courseItem['tax_perc'],
|
||||
'currency_id' => $currency['id'],
|
||||
];
|
||||
} elseif ($editingSession) {
|
||||
if (!$includeSession) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$session = $entityManager->find('ChamiloCoreBundle:Session', $id);
|
||||
if (!$session) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$sessionItem = $plugin->getSessionForConfiguration($session, $currency);
|
||||
|
||||
$currencyIso = $sessionItem['currency'];
|
||||
$formDefaults = [
|
||||
'product_type' => get_lang('Session'),
|
||||
'id' => $session->getId(),
|
||||
'type' => BuyCoursesPlugin::PRODUCT_TYPE_SESSION,
|
||||
'name' => $sessionItem['session_name'],
|
||||
'visible' => $sessionItem['visible'],
|
||||
'price' => $sessionItem['price'],
|
||||
'tax_perc' => $sessionItem['tax_perc'],
|
||||
'currency_id' => $currency['id'],
|
||||
];
|
||||
} else {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$globalSettingsParams = $plugin->getGlobalParameters();
|
||||
|
||||
$form = new FormValidator('add_subscription');
|
||||
|
||||
$form->addText('product_type', $plugin->get_lang('ProductType'), false);
|
||||
$form->addText('name', get_lang('Name'), false);
|
||||
|
||||
$form->freeze(['product_type', 'name']);
|
||||
|
||||
$form->addElement(
|
||||
'number',
|
||||
'tax_perc',
|
||||
[$plugin->get_lang('TaxPerc'), $plugin->get_lang('TaxPercDescription'), '%'],
|
||||
['step' => 1, 'placeholder' => $globalSettingsParams['global_tax_perc'].'% '.$plugin->get_lang('ByDefault')]
|
||||
);
|
||||
|
||||
$frequencies = $plugin->getFrequencies();
|
||||
|
||||
$selectOptions = '';
|
||||
foreach ($frequencies as $key => $frequency) {
|
||||
$selectOptions .= '<option value="'.$key.'">'.$frequency.'</option>';
|
||||
}
|
||||
|
||||
if (empty($frequencies)) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('FrequencyIsNotConfigured'), 'error')
|
||||
);
|
||||
}
|
||||
|
||||
$platformCommission = $plugin->getPlatformCommission();
|
||||
$form->addHtml(
|
||||
'
|
||||
<div class="form-group">
|
||||
<div class="col-sm-11">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">'.$plugin->get_lang('FrequencyConfig').'</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-5">
|
||||
<div class="form-group ">
|
||||
<label for="duration" class="col-sm-3 control-label">
|
||||
'.$plugin->get_lang('Duration').'
|
||||
</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="dropdown bootstrap-select form-control bs3 dropup">
|
||||
<select class="selectpicker form-control"
|
||||
data-live-search="true" name="duration" id="duration" tabindex="null">
|
||||
'.$selectOptions.'
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-1"></div>
|
||||
</div>
|
||||
<div class="form-group ">
|
||||
<label for="price" class="col-sm-3 control-label">
|
||||
'.$plugin->get_lang('Price').'
|
||||
</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" name="price" type="number" step="0.01" id="price">
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
'.$currencyIso.'
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<a class=" btn btn-primary " name="add" type="submit"><em class="fa fa-plus"></em> Add</a>
|
||||
</div>
|
||||
<div class="col-sm-2"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-7">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$plugin->get_lang('Duration').'</th>
|
||||
<th>'.$plugin->get_lang('Price').'</th>
|
||||
<th>'.$plugin->get_lang('Actions').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
</div>
|
||||
</div>
|
||||
'
|
||||
);
|
||||
|
||||
$form->addHidden('type', null);
|
||||
$form->addHidden('id', null);
|
||||
$button = $form->addButtonSave(get_lang('Save'));
|
||||
|
||||
if (empty($currency) || empty($frequencies)) {
|
||||
$button->setAttribute('disabled');
|
||||
}
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$subscription['product_id'] = $formValues['id'];
|
||||
$subscription['product_type'] = $formValues['type'];
|
||||
$subscription['currency_id'] = $currency['id'];
|
||||
$subscription['tax_perc'] = $formValues['tax_perc'] != '' ? (int) $formValues['tax_perc'] : null;
|
||||
$subscription['frequencies'] = isset($formValues['frequencies']) ? $formValues['frequencies'] : [];
|
||||
|
||||
$result = $plugin->addNewSubscription($subscription);
|
||||
|
||||
if ($result) {
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/subscriptions_courses.php');
|
||||
} else {
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$form->setDefaults($formDefaults);
|
||||
|
||||
$templateName = $plugin->get_lang('SubscriptionAdd');
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'subscriptions_courses.php',
|
||||
'name' => get_lang('Configuration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'subscriptions_courses.php',
|
||||
'name' => $plugin->get_lang('SubscriptionList'),
|
||||
];
|
||||
|
||||
$template = new Template($templateName);
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('items_form', $form->returnForm());
|
||||
$template->assign('currencyIso', $currencyIso);
|
||||
|
||||
$content = $template->fetch('buycourses/view/subscription_add.tpl');
|
||||
$template->assign('content', $content);
|
||||
|
||||
$template->display_one_col_template();
|
||||
88
plugin/buycourses/src/subscription_course_catalog.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of subscriptions.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
$nameFilter = '';
|
||||
|
||||
$form = new FormValidator(
|
||||
'search_filter_form',
|
||||
'get',
|
||||
null,
|
||||
null,
|
||||
[],
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$nameFilter = isset($formValues['name']) ? $formValues['name'] : null;
|
||||
}
|
||||
|
||||
$form->addHeader($plugin->get_lang('SearchFilter'));
|
||||
$form->addText('name', get_lang('CourseName'), false);
|
||||
$form->addHtml('<hr>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
|
||||
$pageSize = BuyCoursesPlugin::PAGINATION_PAGE_SIZE;
|
||||
$currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$first = $pageSize * ($currentPage - 1);
|
||||
$courseList = $plugin->getCatalogSubscriptionCourseList($first, $pageSize, $nameFilter);
|
||||
$totalItems = $plugin->getCatalogSubscriptionCourseList($first, $pageSize, $nameFilter, 'count');
|
||||
$pagesCount = ceil($totalItems / $pageSize);
|
||||
|
||||
$pagination = BuyCoursesPlugin::returnPagination(api_get_self(), $currentPage, $pagesCount, $totalItems);
|
||||
|
||||
// View
|
||||
if (api_is_platform_admin()) {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'subscriptions_courses.php',
|
||||
'name' => $plugin->get_lang('AvailableCoursesConfiguration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'paymentsetup.php',
|
||||
'name' => $plugin->get_lang('PaymentsConfiguration'),
|
||||
];
|
||||
} else {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'course_panel.php',
|
||||
'name' => get_lang('TabsDashboard'),
|
||||
];
|
||||
}
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = $plugin->get_lang('SubscriptionListOnSale');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('search_filter_form', $form->returnForm());
|
||||
$tpl->assign('showing_courses', true);
|
||||
$tpl->assign('courses', $courseList);
|
||||
$tpl->assign('sessions_are_included', $includeSessions);
|
||||
$tpl->assign('pagination', $pagination);
|
||||
|
||||
$sessionList = $plugin->getCatalogSubscriptionSessionList($first, $pageSize, $nameFilter, 'first', 0);
|
||||
$coursesExist = true;
|
||||
$sessionExist = true;
|
||||
if (count($sessionList) <= 0) {
|
||||
$sessionExist = false;
|
||||
}
|
||||
|
||||
$tpl->assign('coursesExist', $coursesExist);
|
||||
$tpl->assign('sessionExist', $sessionExist);
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/subscription_catalog.tpl');
|
||||
|
||||
$tpl->assign('header', $templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
266
plugin/buycourses/src/subscription_process.php
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
use ChamiloSession as Session;
|
||||
|
||||
/**
|
||||
* Process payments for the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$currentUserId = api_get_user_id();
|
||||
|
||||
$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(
|
||||
WEB_PLUGIN_PATH
|
||||
).'buycourses/resources/css/style.css"/>';
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSession = $plugin->get('include_sessions') === 'true';
|
||||
$paypalEnabled = $plugin->get('paypal_enable') === 'true';
|
||||
$transferEnabled = $plugin->get('transfer_enable') === 'true';
|
||||
$culqiEnabled = $plugin->get('culqi_enable') === 'true';
|
||||
$tpvRedsysEnable = $plugin->get('tpv_redsys_enable') === 'true';
|
||||
|
||||
if (!$paypalEnabled && !$transferEnabled && !$culqiEnabled && !$tpvRedsysEnable) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['t'], $_REQUEST['i'])) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$buyingCourse = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_COURSE;
|
||||
$buyingSession = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_SESSION;
|
||||
$queryString = 'i='.intval($_REQUEST['i']).'&t='.intval($_REQUEST['t']);
|
||||
|
||||
if (isset($_REQUEST['c'])) {
|
||||
$couponCode = $_REQUEST['c'];
|
||||
if ($buyingCourse) {
|
||||
$coupon = $plugin->getCouponByCode($couponCode, BuyCoursesPlugin::PRODUCT_TYPE_COURSE, $_REQUEST['i']);
|
||||
} else {
|
||||
$coupon = $plugin->getCouponByCode($couponCode, BuyCoursesPlugin::PRODUCT_TYPE_SESSION, $_REQUEST['i']);
|
||||
}
|
||||
|
||||
$queryString .= 'c='.$coupon['code'];
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['d'])) {
|
||||
$duration = $_REQUEST['d'];
|
||||
if ($buyingCourse) {
|
||||
$subscriptionItem = $plugin->getSubscription(BuyCoursesPlugin::PRODUCT_TYPE_COURSE, $_REQUEST['i'], $duration, $coupon);
|
||||
} else {
|
||||
$subscriptionItem = $plugin->getSubscription(BuyCoursesPlugin::PRODUCT_TYPE_SESSION, $_REQUEST['i'], $duration, $coupon);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($currentUserId)) {
|
||||
Session::write('buy_course_redirect', api_get_self().'?'.$queryString);
|
||||
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$subscriptionItems = $plugin->getSubscriptionsItemsByProduct($_REQUEST['i'], $_REQUEST['t']);
|
||||
|
||||
if (!isset($subscriptionItems) || empty($subscriptionItems)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
if (!isset($subscriptionItem) || empty($subscriptionItem)) {
|
||||
$subscriptionItem = $plugin->getSubscription($subscriptionItems[0]['product_type'], $subscriptionItems[0]['product_id'], $subscriptionItems[0]['duration'], $coupon);
|
||||
}
|
||||
|
||||
$queryString .= 'd='.intval($subscriptionItem['duration']);
|
||||
|
||||
if ($buyingCourse) {
|
||||
$courseInfo = $plugin->getSubscriptionCourseInfo($_REQUEST['i'], $coupon);
|
||||
$item = $plugin->getSubscriptionItemByProduct($_REQUEST['i'], BuyCoursesPlugin::PRODUCT_TYPE_COURSE);
|
||||
} elseif ($buyingSession) {
|
||||
$sessionInfo = $plugin->getSubscriptionSessionInfo($_REQUEST['i'], $coupon);
|
||||
$item = $plugin->getSubscriptionItemByProduct($_REQUEST['i'], BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
|
||||
}
|
||||
|
||||
$form = new FormValidator('confirm_sale');
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
|
||||
if (!$formValues['payment_type']) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('NeedToSelectPaymentType'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
$saleId = $plugin->registerSubscriptionSale($item['product_id'], $item['product_type'], $formValues['payment_type'], $formValues['d'], $formValues['c']);
|
||||
|
||||
if ($saleId !== false) {
|
||||
$_SESSION['bc_sale_id'] = $saleId;
|
||||
|
||||
if (isset($formValues['c'])) {
|
||||
$couponSaleId = $plugin->registerCouponSubscriptionSale($saleId, $formValues['c']);
|
||||
if ($couponSaleId !== false) {
|
||||
$plugin->updateCouponDelivered($formValues['c']);
|
||||
$_SESSION['bc_coupon_id'] = $formValues['c'];
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/process_subscription_confirm.php');
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$paymentTypesOptions = $plugin->getPaymentTypes(true);
|
||||
|
||||
$count = count($paymentTypesOptions);
|
||||
if ($count === 0) {
|
||||
$form->addHtml($plugin->get_lang('NoPaymentOptionAvailable'));
|
||||
$form->addHtml('<br />');
|
||||
$form->addHtml('<br />');
|
||||
} elseif ($count === 1) {
|
||||
// get the only array item
|
||||
foreach ($paymentTypesOptions as $type => $value) {
|
||||
$form->addHtml(sprintf($plugin->get_lang('XIsOnlyPaymentMethodAvailable'), $value));
|
||||
$form->addHtml('<br />');
|
||||
$form->addHtml('<br />');
|
||||
$form->addHidden('payment_type', $type);
|
||||
}
|
||||
} else {
|
||||
$form->addHtml(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('PleaseSelectThePaymentMethodBeforeConfirmYourOrder'),
|
||||
'info'
|
||||
)
|
||||
);
|
||||
$form->addRadio('payment_type', null, $paymentTypesOptions);
|
||||
}
|
||||
|
||||
$form->addHidden('t', intval($_GET['t']));
|
||||
$form->addHidden('i', intval($_GET['i']));
|
||||
if ($coupon != null) {
|
||||
$form->addHidden('c', intval($coupon['id']));
|
||||
}
|
||||
$form->addButton('submit', $plugin->get_lang('ConfirmOrder'), 'check', 'success', 'btn-lg pull-right');
|
||||
|
||||
$formSubscription = new FormValidator('confirm_subscription');
|
||||
if ($formSubscription->validate()) {
|
||||
$formSubscriptionValues = $formSubscription->getSubmitValues();
|
||||
|
||||
if (!$formSubscriptionValues['duration']) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('NeedToAddDuration'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($buyingCourse) {
|
||||
$subscription = $plugin->getSubscription(BuyCoursesPlugin::PRODUCT_TYPE_COURSE, $_REQUEST['i'], $formSubscriptionValues['duration']);
|
||||
} else {
|
||||
$subscription = $plugin->getSubscription(BuyCoursesPlugin::PRODUCT_TYPE_SESSION, $_REQUEST['i'], $formSubscriptionValues['duration']);
|
||||
}
|
||||
|
||||
if ($subscription == null) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('SubscriptionNotValid'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/subscription_process.php?i='.$_REQUEST['i'].'&t='.$_REQUEST['t'].'&d='.$formSubscriptionValues['duration']);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$frequencies = $plugin->getFrequencies();
|
||||
$selectedFrequencies = [];
|
||||
|
||||
foreach ($subscriptionItems as $si) {
|
||||
if (isset($frequencies[$si['duration']])) {
|
||||
$selectedFrequencies[$si['duration']] = $frequencies[$si['duration']].' - '.$si['price_formatted'].' '.$si['iso_code'];
|
||||
}
|
||||
}
|
||||
|
||||
$formSubscription->addRadio('duration', null, $selectedFrequencies);
|
||||
|
||||
if (!empty($selectedFrequencies)) {
|
||||
$formSubscriptionDefaults['duration'] = $subscriptionItem['duration'];
|
||||
$formSubscription->setDefaults($formSubscriptionDefaults);
|
||||
}
|
||||
|
||||
$selectedDurationName = $frequencies[$subscriptionItem['duration']];
|
||||
|
||||
$formSubscription->addHidden('t', intval($_GET['t']));
|
||||
$formSubscription->addHidden('i', intval($_GET['i']));
|
||||
|
||||
$form->addHidden('d', $subscriptionItem['duration']);
|
||||
|
||||
$formCoupon = new FormValidator('confirm_coupon');
|
||||
if ($formCoupon->validate()) {
|
||||
$formCouponValues = $formCoupon->getSubmitValues();
|
||||
|
||||
if (!$formCouponValues['coupon_code']) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('NeedToAddCouponCode'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($buyingCourse) {
|
||||
$coupon = $plugin->getCouponByCode($formCouponValues['coupon_code'], BuyCoursesPlugin::PRODUCT_TYPE_COURSE, $_REQUEST['i']);
|
||||
} else {
|
||||
$coupon = $plugin->getCouponByCode($formCouponValues['coupon_code'], BuyCoursesPlugin::PRODUCT_TYPE_SESSION, $_REQUEST['i']);
|
||||
}
|
||||
|
||||
if ($coupon == null) {
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CouponNotValid'), 'error', false)
|
||||
);
|
||||
header('Location:'.api_get_self().'?'.$queryString);
|
||||
exit;
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message($plugin->get_lang('CouponRedeemed'), 'success', false)
|
||||
);
|
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/subscription_process.php?i='.$_REQUEST['i'].'&t='.$_REQUEST['t'].'&d='.$_REQUEST['d'].'&c='.$formCouponValues['coupon_code']);
|
||||
|
||||
exit;
|
||||
}
|
||||
$formCoupon->addText('coupon_code', $plugin->get_lang('CouponsCode'), true);
|
||||
$formCoupon->addHidden('t', intval($_GET['t']));
|
||||
$formCoupon->addHidden('i', intval($_GET['i']));
|
||||
$formCoupon->addHidden('d', $subscriptionItem['duration']);
|
||||
$formCoupon->addButton('submit', $plugin->get_lang('RedeemCoupon'), 'check', 'success', 'btn-lg pull-right');
|
||||
|
||||
// View
|
||||
$templateName = $plugin->get_lang('PaymentMethods');
|
||||
$interbreadcrumb[] = ['url' => 'subscription_course_catalog.php', 'name' => $plugin->get_lang('CourseListOnSale')];
|
||||
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('item_type', (int) $_GET['t']);
|
||||
$tpl->assign('buying_course', $buyingCourse);
|
||||
$tpl->assign('buying_session', $buyingSession);
|
||||
$tpl->assign('user', api_get_user_info());
|
||||
$tpl->assign('form_coupon', $formCoupon->returnForm());
|
||||
$tpl->assign('message_payment', $messagePayment);
|
||||
$tpl->assign('selected_duration_name', $selectedDurationName);
|
||||
$tpl->assign('form', $form->returnForm());
|
||||
$tpl->assign('form_subscription', $formSubscription->returnForm());
|
||||
|
||||
if ($buyingCourse) {
|
||||
$tpl->assign('course', $courseInfo);
|
||||
} elseif ($buyingSession) {
|
||||
$tpl->assign('session', $sessionInfo);
|
||||
}
|
||||
|
||||
$tpl->assign('subscription', $subscriptionItem);
|
||||
|
||||
$content = $tpl->fetch('buycourses/view/subscription_process.tpl');
|
||||
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
201
plugin/buycourses/src/subscription_sales_report.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of pending subscriptions payments of the Buy Courses plugin.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once '../config.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable');
|
||||
$commissionsEnable = $plugin->get('commissions_enable');
|
||||
$includeServices = $plugin->get('include_services');
|
||||
$invoicingEnable = $plugin->get('invoicing_enable') === 'true';
|
||||
|
||||
if (isset($_GET['order'])) {
|
||||
$sale = $plugin->getSubscriptionSale($_GET['order']);
|
||||
|
||||
if (empty($sale)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$urlToRedirect = api_get_self().'?';
|
||||
|
||||
switch ($_GET['action']) {
|
||||
case 'confirm':
|
||||
$plugin->completeSubscriptionSale($sale['id']);
|
||||
$plugin->storeSubscriptionPayouts($sale['id']);
|
||||
Display::addFlash(
|
||||
$plugin->getSubscriptionSuccessMessage($sale)
|
||||
);
|
||||
|
||||
$urlToRedirect .= http_build_query([
|
||||
'status' => BuyCoursesPlugin::SALE_STATUS_COMPLETED,
|
||||
'sale' => $sale['id'],
|
||||
]);
|
||||
break;
|
||||
case 'cancel':
|
||||
$plugin->cancelSubscriptionSale($sale['id']);
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
$plugin->get_lang('OrderCanceled'),
|
||||
'warning'
|
||||
)
|
||||
);
|
||||
|
||||
$urlToRedirect .= http_build_query([
|
||||
'status' => BuyCoursesPlugin::SALE_STATUS_CANCELED,
|
||||
'sale' => $sale['id'],
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
header("Location: $urlToRedirect");
|
||||
exit;
|
||||
}
|
||||
|
||||
$productTypes = $plugin->getProductTypes();
|
||||
$saleStatuses = $plugin->getSaleStatuses();
|
||||
$paymentTypes = $plugin->getPaymentTypes();
|
||||
|
||||
$selectedFilterType = '0';
|
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_PENDING;
|
||||
$selectedSale = isset($_GET['sale']) ? intval($_GET['sale']) : 0;
|
||||
$dateStart = isset($_GET['date_start']) ? $_GET['date_start'] : date('Y-m-d H:i', mktime(0, 0, 0));
|
||||
$dateEnd = isset($_GET['date_end']) ? $_GET['date_end'] : date('Y-m-d H:i', mktime(23, 59, 59));
|
||||
$searchTerm = '';
|
||||
$email = '';
|
||||
|
||||
$form = new FormValidator('search', 'get');
|
||||
|
||||
if ($form->validate()) {
|
||||
$selectedFilterType = $form->getSubmitValue('filter_type');
|
||||
$selectedStatus = $form->getSubmitValue('status');
|
||||
$searchTerm = $form->getSubmitValue('user');
|
||||
$dateStart = $form->getSubmitValue('date_start');
|
||||
$dateEnd = $form->getSubmitValue('date_end');
|
||||
$email = $form->getSubmitValue('email');
|
||||
|
||||
if ($selectedStatus === false) {
|
||||
$selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING;
|
||||
}
|
||||
|
||||
if ($selectedFilterType === false) {
|
||||
$selectedFilterType = '0';
|
||||
}
|
||||
}
|
||||
|
||||
$form->addRadio(
|
||||
'filter_type',
|
||||
get_lang('Filter'),
|
||||
[
|
||||
$plugin->get_lang('ByStatus'),
|
||||
$plugin->get_lang('ByUser'),
|
||||
$plugin->get_lang('ByDate'),
|
||||
$plugin->get_lang('ByEmail'),
|
||||
]
|
||||
);
|
||||
$form->addHtml('<div id="report-by-status" '.($selectedFilterType !== '0' ? 'style="display:none"' : '').'>');
|
||||
$form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses);
|
||||
$form->addHtml('</div>');
|
||||
$form->addHtml('<div id="report-by-user" '.($selectedFilterType !== '1' ? 'style="display:none"' : '').'>');
|
||||
$form->addText('user', get_lang('UserName'), false);
|
||||
$form->addHtml('</div>');
|
||||
$form->addHtml('<div id="report-by-date" '.($selectedFilterType !== '2' ? 'style="display:none"' : '').'>');
|
||||
$form->addDateRangePicker('date', get_lang('Date'), false);
|
||||
$form->addHtml('</div>');
|
||||
$form->addHtml('<div id="report-by-email" '.($selectedFilterType !== '3' ? 'style="display:none"' : '').'>');
|
||||
$form->addText('email', get_lang('Email'), false);
|
||||
$form->addHtml('</div>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
$form->setDefaults([
|
||||
'filter_type' => $selectedFilterType,
|
||||
'status' => $selectedStatus,
|
||||
'date_start' => $dateStart,
|
||||
'date_end' => $dateEnd,
|
||||
'email' => $email,
|
||||
]);
|
||||
|
||||
switch ($selectedFilterType) {
|
||||
case '0':
|
||||
$sales = $plugin->getSubscriptionSaleListByStatus($selectedStatus);
|
||||
break;
|
||||
case '1':
|
||||
$sales = $plugin->getSubscriptionSaleListByUser($searchTerm);
|
||||
break;
|
||||
case '2':
|
||||
$sales = $plugin->getSubscriptionSaleListByDate($dateStart, $dateEnd);
|
||||
break;
|
||||
case '3':
|
||||
$sales = $plugin->getSubscriptionSaleListByEmail($email);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($sales as &$sale) {
|
||||
$sale['product_type'] = $productTypes[$sale['product_type']];
|
||||
$sale['payment_type'] = $paymentTypes[$sale['payment_type']];
|
||||
$sale['complete_user_name'] = api_get_person_name($sale['firstname'], $sale['lastname']);
|
||||
$sale['num_invoice'] = $plugin->getNumInvoice($sale['id'], 0);
|
||||
$sale['total_price'] = $plugin->getPriceWithCurrencyFromIsoCode($sale['price'], $sale['iso_code']);
|
||||
if (isset($sale['discount_amount']) && $sale['discount_amount'] != 0) {
|
||||
$sale['total_discount'] = $plugin->getPriceWithCurrencyFromIsoCode($sale['discount_amount'], $sale['iso_code']);
|
||||
$sale['coupon_code'] = $plugin->getSaleCouponCode($sale['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => '../index.php', 'name' => $plugin->get_lang('plugin_title')];
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$templateName = $plugin->get_lang('SalesReport');
|
||||
$template = new Template($templateName);
|
||||
|
||||
$toolbar = Display::url(
|
||||
Display::returnFontAwesomeIcon('file-excel-o').
|
||||
get_lang('GenerateReport'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/export_subscription_report.php',
|
||||
['class' => 'btn btn-primary']
|
||||
);
|
||||
|
||||
if ($paypalEnable === 'true' && $commissionsEnable === 'true') {
|
||||
$toolbar .= Display::toolbarButton(
|
||||
$plugin->get_lang('PaypalPayoutCommissions'),
|
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/paypal_payout.php',
|
||||
'paypal',
|
||||
'primary',
|
||||
['title' => $plugin->get_lang('PaypalPayoutCommissions')]
|
||||
);
|
||||
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$toolbar])
|
||||
);
|
||||
$template->assign('form', $form->returnForm());
|
||||
$template->assign('selected_sale', $selectedSale);
|
||||
$template->assign('selected_status', $selectedStatus);
|
||||
$template->assign('services_are_included', $includeServices);
|
||||
$template->assign('sale_list', $sales);
|
||||
$template->assign('sale_status_canceled', BuyCoursesPlugin::SALE_STATUS_CANCELED);
|
||||
$template->assign('sale_status_pending', BuyCoursesPlugin::SALE_STATUS_PENDING);
|
||||
$template->assign('sale_status_completed', BuyCoursesPlugin::SALE_STATUS_COMPLETED);
|
||||
$template->assign('invoicing_enable', $invoicingEnable);
|
||||
|
||||
$content = $template->fetch('buycourses/view/subscription_sales_report.tpl');
|
||||
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||
114
plugin/buycourses/src/subscription_session_catalog.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* List of sessions.
|
||||
*
|
||||
* @package chamilo.plugin.buycourses
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../../../main/inc/global.inc.php';
|
||||
|
||||
$plugin = BuyCoursesPlugin::create();
|
||||
$includeSessions = $plugin->get('include_sessions') === 'true';
|
||||
$includeServices = $plugin->get('include_services') === 'true';
|
||||
|
||||
if (!$includeSessions) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$nameFilter = null;
|
||||
$sessionCategory = isset($_GET['session_category']) ? (int) $_GET['session_category'] : 0;
|
||||
$form = new FormValidator(
|
||||
'search_filter_form',
|
||||
'get',
|
||||
null,
|
||||
null,
|
||||
[],
|
||||
FormValidator::LAYOUT_INLINE
|
||||
);
|
||||
|
||||
$form->removeAttribute('class');
|
||||
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$nameFilter = isset($formValues['name']) ? $formValues['name'] : null;
|
||||
$sessionCategory = isset($formValues['session_category']) ? $formValues['session_category'] : $sessionCategory;
|
||||
}
|
||||
|
||||
$form->addHeader($plugin->get_lang('SearchFilter'));
|
||||
|
||||
$categoriesOptions = [
|
||||
'0' => get_lang('AllCategories'),
|
||||
];
|
||||
$categoriesList = SessionManager::get_all_session_category();
|
||||
if ($categoriesList != false) {
|
||||
foreach ($categoriesList as $categoryItem) {
|
||||
$categoriesOptions[$categoryItem['id']] = $categoryItem['name'];
|
||||
}
|
||||
}
|
||||
$form->addSelect(
|
||||
'session_category',
|
||||
get_lang('SessionCategory'),
|
||||
$categoriesOptions,
|
||||
[
|
||||
'id' => 'session_category',
|
||||
]
|
||||
);
|
||||
|
||||
$form->addText('name', get_lang('SessionName'), false);
|
||||
|
||||
$form->addHtml('<hr>');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
|
||||
$form->setDefaults(
|
||||
[
|
||||
'session_category' => $sessionCategory,
|
||||
]
|
||||
);
|
||||
$pageSize = BuyCoursesPlugin::PAGINATION_PAGE_SIZE;
|
||||
$currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$first = $pageSize * ($currentPage - 1);
|
||||
$sessionList = $plugin->getCatalogSubscriptionSessionList($first, $pageSize, $nameFilter, 'all', $sessionCategory);
|
||||
$totalItems = $plugin->getCatalogSubscriptionSessionList($first, $pageSize, $nameFilter, 'count', $sessionCategory);
|
||||
$pagesCount = ceil($totalItems / $pageSize);
|
||||
$pagination = BuyCoursesPlugin::returnPagination(api_get_self(), $currentPage, $pagesCount, $totalItems);
|
||||
|
||||
// View
|
||||
if (api_is_platform_admin()) {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'subscriptions_sessions.php',
|
||||
'name' => $plugin->get_lang('AvailableCoursesConfiguration'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'paymentsetup.php',
|
||||
'name' => $plugin->get_lang('PaymentsConfiguration'),
|
||||
];
|
||||
}
|
||||
|
||||
$templateName = $plugin->get_lang('CourseListOnSale');
|
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css');
|
||||
|
||||
$template = new Template($templateName);
|
||||
$template->assign('search_filter_form', $form->returnForm());
|
||||
$template->assign('sessions_are_included', $includeSessions);
|
||||
$template->assign('showing_sessions', true);
|
||||
$template->assign('sessions', $sessionList);
|
||||
$template->assign('pagination', $pagination);
|
||||
|
||||
$courseList = $plugin->getCatalogSubscriptionCourseList($first, $pageSize, $nameFilter);
|
||||
$coursesExist = true;
|
||||
$sessionExist = true;
|
||||
if (count($courseList) <= 0) {
|
||||
$coursesExist = false;
|
||||
}
|
||||
$template->assign('coursesExist', $coursesExist);
|
||||
$template->assign('sessionExist', $sessionExist);
|
||||
|
||||
$content = $template->fetch('buycourses/view/subscription_catalog.tpl');
|
||||
|
||||
$template->assign('header', $templateName);
|
||||
$template->assign('content', $content);
|
||||
$template->display_one_col_template();
|
||||