Merge branch '16.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/langs/en_US/admin.lang
This commit is contained in:
Laurent Destailleur 2022-07-16 02:26:35 +02:00
commit 1855236027
9 changed files with 139 additions and 46 deletions

View File

@ -47,8 +47,9 @@ if (!in_array('clicktodial', $conf->modules)) {
if ($action == 'setvalue' && $user->admin) {
$result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
$result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
$result3 = dolibarr_set_const($db, "CLICKTODIAL_KEY_FOR_CIDLOOKUP", GETPOST("CLICKTODIAL_KEY_FOR_CIDLOOKUP"), 'chaine', 0, '', $conf->entity);
if ($result1 >= 0 && $result2 >= 0) {
if ($result1 >= 0 && $result2 >= 0 && $result3 >= 0) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
@ -80,7 +81,7 @@ print '<input type="hidden" name="action" value="setvalue">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td class="minwidth200">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
@ -89,21 +90,21 @@ print '<tr class="oddeven"><td>';
print $langs->trans("ClickToDialUseTelLink").'</td><td>';
print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", $conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS, 1).'<br>';
print '<br>';
print $langs->trans("ClickToDialUseTelLinkDesc");
print '<span class="opacitymedium small">'.$langs->trans("ClickToDialUseTelLinkDesc").'</span>';
print '</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("DefaultLink").'</td><td>';
print '<input class="quatrevingtpercent" type="text" id="CLICKTODIAL_URL" name="CLICKTODIAL_URL"'.($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS ? ' disabled="disabled"' : '').' value="'.$conf->global->CLICKTODIAL_URL.'"><br>';
print '<input class="quatrevingtpercent" type="text" id="CLICKTODIAL_URL" name="CLICKTODIAL_URL"'.(getDolGlobalString('CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS') ? ' disabled="disabled"' : '').' value="'.getDolGlobalString('CLICKTODIAL_URL').'"><br>';
print ajax_autoselect('CLICKTODIAL_URL');
print '<br>';
print $langs->trans("ClickToDialUrlDesc").'<br>';
print '<br>';
print '<span class="opacitymedium">';
print $langs->trans("Examples").':<br>';
print 'https://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__<br>';
print 'sip:__PHONETO__@my.sip.server';
print '* https://myphoneserver/phoneurl?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__<br>';
print '* sip:__PHONETO__@my.sip.server';
print '</span>';
//if (! empty($user->clicktodial_url))
@ -114,6 +115,37 @@ print '</span>';
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SecurityKey").'</td>';
print '<td>';
global $dolibarr_main_url_root;
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Url for CIDLookup
//print '<div class="div-table-responsive-no-min">';
//print $langs->trans("URLToLaunchCronJobs").':<br>';
$url = $urlwithroot.'/public/clicktodial/cidlookup.php?securitykey='.getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP', 'ValueToDefine').'&phone=...';
//print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
//print '</div>';
//print '<br>';
print '<span class="opacitymedium">'.$langs->trans("CIDLookupURL").'</span>';
print '<br>'.$url;
print '<br>';
print '<br>';
print '<input type="text" class="flat minwidth300" id="CLICKTODIAL_KEY_FOR_CIDLOOKUP" name="CLICKTODIAL_KEY_FOR_CIDLOOKUP" value="'.(GETPOST('CLICKTODIAL_KEY_FOR_CIDLOOKUP') ? GETPOST('CLICKTODIAL_KEY_FOR_CIDLOOKUP') : (!empty($conf->global->CLICKTODIAL_KEY_FOR_CIDLOOKUP) ? $conf->global->CLICKTODIAL_KEY_FOR_CIDLOOKUP : '')).'">';
if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
}
print '</td>';
print '</tr>';
print '</table>';
print '</div>';
@ -156,6 +188,23 @@ if (!empty($conf->global->CLICKTODIAL_URL)) {
}
}
if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#generate_token").click(function() {
console.log("Click done");
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#CLICKTODIAL_KEY_FOR_CIDLOOKUP").val(token);
});
});
});';
print '</script>';
}
// End of page
llxFooter();
$db->close();

View File

@ -1316,7 +1316,7 @@ class DolGraph
if (empty($showlegend)) {
$this->stringtoshow .= 'legend: { display: false }, '."\n";
} else {
$this->stringtoshow .= 'legend: { maxWidth: '.round($this->width / 2).', labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ? 'right' : 'top') . '\' },'."\n";
$this->stringtoshow .= 'legend: { maxWidth: '.round(intVal($this->width) / 2).', labels: { boxWidth: 15 }, position: \'' . (($showlegend && $showlegend == 2) ? 'right' : 'top') . '\' },'."\n";
}
$this->stringtoshow .= "}, \n";

View File

@ -217,7 +217,7 @@ foreach ($arrayoftype as $key => $val) {
if (dol_eval($val['enabled'], 1, 1, '1')) {
$newarrayoftype[$key] = $arrayoftype[$key];
}
if ($val['langs']) {
if (!empty($val['langs'])) {
$langs->load($val['langs']);
}
}
@ -970,31 +970,31 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
// Add main fields of object
foreach ($object->fields as $key => $val) {
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
$position = (!empty($val['position']) ? $val['position'] : 0);
$position = (empty($val['position']) ? 0 : intVal($val['position']));
$arrayofmesures[$tablealias.'.'.$key.'-sum'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
'position' => ($position+($count * 100000)).'.1',
'position' => ($position + ($count * 100000)).'.1',
'table' => $object->table_element
);
$arrayofmesures[$tablealias.'.'.$key.'-average'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
'position' => ($position+($count * 100000)).'.2',
'position' => ($position + ($count * 100000)).'.2',
'table' => $object->table_element
);
$arrayofmesures[$tablealias.'.'.$key.'-min'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
'position' => ($position+($count * 100000)).'.3',
'position' => ($position + ($count * 100000)).'.3',
'table' => $object->table_element
);
$arrayofmesures[$tablealias.'.'.$key.'-max'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
'position' => ($position+($count * 100000)).'.4',
'position' => ($position + ($count * 100000)).'.4',
'table' => $object->table_element
);
}
}
// Add extrafields to Measures
if ($object->isextrafieldmanaged) {
if (!empty($object->isextrafieldmanaged)) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
$position = (!empty($val['position']) ? $val['position'] : 0);
@ -1098,26 +1098,27 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
continue;
}
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$position = (!empty($val['position']) ? $val['position'] : 0);
$position = (empty($val['position']) ? 0 : intVal($val['position']));
$arrayofxaxis[$tablealias.'.'.$key.'-year'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>',
'position' => ($position+($count * 100000)).'.1',
'position' => ($position + ($count * 100000)).'.1',
'table' => $object->table_element
);
$arrayofxaxis[$tablealias.'.'.$key.'-month'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
'position' => ($position+($count * 100000)).'.2',
'position' => ($position + ($count * 100000)).'.2',
'table' => $object->table_element
);
$arrayofxaxis[$tablealias.'.'.$key.'-day'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
'position' => ($position+($count * 100000)).'.3',
'position' => ($position + ($count * 100000)).'.3',
'table' => $object->table_element
);
} else {
$position = (empty($val['position']) ? 0 : intVal($val['position']));
$arrayofxaxis[$tablealias.'.'.$key] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']),
'position' => ($position+($count * 100000)),
'position' => ($position + ($count * 100000)),
'table' => $object->table_element
);
}
@ -1125,7 +1126,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
}
// Add extrafields to X-Axis
if ($object->isextrafieldmanaged) {
if (!empty($object->isextrafieldmanaged)) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;
@ -1196,7 +1197,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
// Add main fields of object
foreach ($object->fields as $key => $val) {
if (!$val['isameasure']) {
if (empty($val['isameasure'])) {
if (in_array($key, array(
'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
@ -1218,26 +1219,27 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
continue;
}
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$position = (!empty($val['position']) ? $val['position'] : 0);
$position = (empty($val['position']) ? 0 : intVal($val['position']));
$arrayofgroupby[$tablealias.'.'.$key.'-year'] = array(
'label' => img_picto('', $object->picto,
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($position+($count * 100000)).'.1',
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($position + ($count * 100000)).'.1',
'table' => $object->table_element
);
$arrayofgroupby[$tablealias.'.'.$key.'-month'] = array(
'label' => img_picto('', $object->picto,
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($position+($count * 100000)).'.2',
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($position + ($count * 100000)).'.2',
'table' => $object->table_element
);
$arrayofgroupby[$tablealias.'.'.$key.'-day'] = array(
'label' => img_picto('', $object->picto,
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($position+($count * 100000)).'.3',
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($position + ($count * 100000)).'.3',
'table' => $object->table_element
);
} else {
$position = (empty($val['position']) ? 0 : intVal($val['position']));
$arrayofgroupby[$tablealias.'.'.$key] = array(
'label' => img_picto('', $object->picto,
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position+($count * 100000)),
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position + ($count * 100000)),
'table' => $object->table_element
);
}
@ -1245,7 +1247,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
}
// Add extrafields to Group by
if ($object->isextrafieldmanaged) {
if (! empty($object->isextrafieldmanaged)) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;

View File

@ -133,15 +133,16 @@ if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#generate_token").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#CRON_KEY").val(token);
});
});
});';
console.log("Click done");
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#CRON_KEY").val(token);
});
});
});';
print '</script>';
}

View File

@ -2284,4 +2284,5 @@ AlwaysEnabled=Always Enabled
DoesNotWorkWithAllThemes=Will not work with all themes
NoName=No name
ShowAdvancedOptions= Show advanced options
HideAdvancedoptions= Hide advanced options
HideAdvancedoptions= Hide advanced options
CIDLookupURL=The module brings an URL that can be used by an external tool to get the name of a thirdparty or contact from its phone number. URL to use is:

View File

@ -212,7 +212,7 @@ print '<input type="hidden" name="action" value="remises">';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("MARGIN_METHODE_FOR_DISCOUNT").'</td>';
print '<td class="left">';
print Form::selectarray('MARGIN_METHODE_FOR_DISCOUNT', $methods, $conf->global->MARGIN_METHODE_FOR_DISCOUNT);
print Form::selectarray('MARGIN_METHODE_FOR_DISCOUNT', $methods, getDolGlobalString('MARGIN_METHODE_FOR_DISCOUNT'));
print '</td>';
print '<td>';
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
@ -230,7 +230,7 @@ print '<td>'.$langs->trans("AgentContactType").'</td>';
print '<td class="left">';
$formcompany = new FormCompany($db);
$facture = new Facture($db);
print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE", "internal", "code", 1, "maxwidth250");
print $formcompany->selectTypeContact($facture, getDolGlobalString('AGENT_CONTACT_TYPE'), "AGENT_CONTACT_TYPE", "internal", "code", 1, "maxwidth250");
print '</td>';
print '<td>';
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';

View File

@ -16,20 +16,45 @@
*/
/**
* \file htdocs/asterisk/cidlookup.php
* \file htdocs/public/clicktodial/cidlookup.php
* \brief Script to search companies names based on incoming calls, from caller phone number
* \remarks To use this script, your Asterisk must be compiled with CURL,
* and your dialplan must be something like this:
* \remarks To use this script, your Asterisk must be compiled with CURL, and your dialplan must be something like this:
*
* exten => s,1,Set(CALLERID(name)=${CURL(http://IP-DOLIBARR:80/asterisk/cidlookup.php?phone=${CALLERID(num)})})
* exten => s,1,Set(CALLERID(name)=${CURL(http://IP-DOLIBARR:80/asterisk/cidlookup.php?phone=${CALLERID(num)}&securitykey=SECURITYKEY)})
*
* Change IP-DOLIBARR to the IP address of your dolibarr server
* Change SECURITYKEY to the value defined into your setup of module ClickToDial
*/
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOLOGIN')) {
define('NOLOGIN', '1');
}
if (!defined('NOIPCHECK')) {
define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
include '../master.inc.php';
// So log file will have a suffix
if (!defined('USESUFFIXINLOG')) {
define('USESUFFIXINLOG', '_cidlookup');
}
include '../../main.inc.php';
$phone = GETPOST('phone');
$securitykey = GETPOST('securitykey');
$notfound = $langs->trans("Unknown");
// Security check
@ -38,12 +63,27 @@ if (empty($conf->clicktodial->enabled)) {
exit;
}
/*
* View
*/
if (empty($securitykey)) {
echo 'Securitykey is required. Check setup of clicktodial module.';
exit;
}
if ($securitykey != getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP')) {
echo 'Securitykey is wrong.';
exit;
}
// Check parameters
if (empty($phone)) {
print "Error: Url must be called with parameter phone=phone to search\n";
exit;
}
$sql = "SELECT s.nom as name FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
$sql .= " WHERE s.entity IN (".getEntity('societe').")";

View File

@ -93,7 +93,7 @@ if (empty($key)) {
echo 'Securitykey is required. Check setup of cron jobs module.';
exit;
}
if ($key != $conf->global->CRON_KEY) {
if ($key != getDolGlobalString('CRON_KEY')) {
echo 'Securitykey is wrong.';
exit;
}

View File

@ -127,7 +127,7 @@ class RecruitmentCandidature extends CommonObject
//'fk_recruitment_origin' => array('type'=>'integer:CRecruitmentOrigin:recruitment/class/crecruitmentorigin.class.php', 'label'=>'Origin', 'enabled'=>'1', 'position'=>45, 'visible'=>1, 'index'=>1),
'remuneration_requested' => array('type'=>'integer', 'label'=>'RequestedRemuneration', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,),
'remuneration_proposed' => array('type'=>'integer', 'label'=>'ProposedRemuneration', 'enabled'=>'1', 'position'=>81, 'notnull'=>0, 'visible'=>-1,),
'description' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>500, 'notnull'=>0, 'visible'=>3,),
'description' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>500, 'notnull'=>0, 'visible'=>3, 'css'=>'wordbreak'),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'default'=>0, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Received', '3'=>'ContractProposed', '5'=>'ContractSigned', '8'=>'Refused', '9'=>'Canceled')),