roykin/modules/be2bill/ajax.php
2017-06-14 11:41:31 +02:00

51 lines
1.7 KiB
PHP
Executable File

<?php
/**
* 1997-2016 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to modules@quadra-informatique.fr so we can send you a copy immediately.
*
* @author Quadra Informatique <modules@quadra-informatique.fr>
* @copyright 1997-2016 Quadra Informatique
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
include_once('../../config/config.inc.php');
include_once('../../init.php');
include_once('../../modules/be2bill/classes/Be2billXml.php');
include_once('../../modules/be2bill/be2bill.php');
$be2bill = new Be2bill();
/* Default answer */
$result = array(
'answer' => true,
'msg' => ''
);
/* need reset tables */
if (Tools::getValue('action') == 'reset_tables') {
Be2billXml::insertXmlToDb();
$result['answer'] = true;
$result['msg'] = $be2bill->l('Reset complete');
}
/* need update tables */
if (Tools::getValue('action') == 'update_tables') {
if (Be2billXml::paymentsNeedUpgrade()) {
Be2billXml::insertXmlToDb();
$result['answer'] = true;
$result['msg'] = $be2bill->l('Update complete');
$result['xml_version'] = (string)Configuration::getGlobalValue('BE2BILL_XML_VERSION');
} else {
$result['answer'] = true;
$result['msg'] = $be2bill->l('Udpate not needed, tables already up to date');
$result['xml_version'] = (string)Configuration::getGlobalValue('BE2BILL_XML_VERSION');
}
}
header('Content-type: application/json');
echo(Tools::jsonEncode($result));