Skip to content
Snippets Groups Projects
Commit 95cf36c4 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix use the getUrl function instead of hard coded curl

parent 0ee93fb0
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ $action=GETPOST('action','aZ09');
/*
* Actions
*/
if (preg_match('/set_(.*)/',$action,$reg))
{
$code=$reg[1];
......@@ -82,7 +83,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'title_setup')
$head=categoriesadmin_prepare_head();
dol_fiche_head($head, 'setup', $langs->trans("Categories"), 0, 'category');
dol_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category');
print '<table class="noborder" width="100%">';
......
......@@ -68,7 +68,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'title_setup')
$head = categoriesadmin_prepare_head();
dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), 0, 'category');
dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), -1, 'category');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
......
......@@ -247,12 +247,18 @@ ComposedProduct=Sub-product
MinSupplierPrice=Minimum supplier price
MinCustomerPrice=Minimum customer price
DynamicPriceConfiguration=Dynamic price configuration
DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value.
DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able to use and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value.
AddVariable=Add Variable
AddUpdater=Add Updater
GlobalVariables=Global variables
VariableToUpdate=Variable to update
GlobalVariableUpdaters=Global variable updaters
GlobalVariableUpdaterType0=JSON data
GlobalVariableUpdaterHelp0=Parses JSON data from specified URL, VALUE specifies the location of relevant value,
GlobalVariableUpdaterHelpFormat0=Format for request {"URL": "http://example.com/urlofjson", "VALUE": "array1,array2,targetvalue"}
GlobalVariableUpdaterType1=WebService data
GlobalVariableUpdaterHelp1=Parses WebService data from specified URL, NS specifies the namespace, VALUE specifies the location of relevant value, DATA should contain the data to send and METHOD is the calling WS method
GlobalVariableUpdaterHelpFormat1=Format for request is {"URL": "http://example.com/urlofws", "VALUE": "array,targetvalue", "NS": "http://example.com/urlofns", "METHOD": "myWSMethod", "DATA": {"your": "data", "to": "send"}}
UpdateInterval=Update interval (minutes)
LastUpdated=Latest update
CorrectlyUpdated=Correctly updated
......
......@@ -54,9 +54,11 @@ if ($action == 'edit_updater') {
}
}
/*
* Actions
*/
if (!empty($action) && empty($cancel)) {
//Global variable actions
if ($action == 'create_variable' || $action == 'edit_variable') {
......
......@@ -464,24 +464,18 @@ class PriceGlobalVariableUpdater
}
$result = "";
if ($this->type == 0) {
//CURL client
$handle = curl_init();
curl_setopt_array($handle, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
CURLOPT_POST => false,
CURLOPT_HEADER => false,
));
$result = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
// Call JSON request
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
$tmpresult=getURLContent($url);
$code=$tmpresult['http_code'];
$result=$tmpresult['content'];
if (!isset($result)) {
$this->error = $langs->trans("ErrorGlobalVariableUpdater0", "empty response");
return -1;
}
if ($code !== 200) {
$this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code);
$this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code.' '.$tmpresult['curl_error_msg']);
return -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment