Merge remote-tracking branch 'upstream/develop' into s_code_syntax

This commit is contained in:
Frédéric FRANCE 2021-02-28 17:49:17 +01:00
commit 9e8aefbc75
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
280 changed files with 12825 additions and 10899 deletions

View File

@ -63,7 +63,9 @@ if (GETPOST('addbox')) {
* View * View
*/ */
llxHeader('', $langs->trans("AccountancyArea")); $help_url = '';
llxHeader('', $langs->trans("AccountancyArea"), $help_url);
if ($conf->accounting->enabled) { if ($conf->accounting->enabled) {
$step = 0; $step = 0;
@ -91,7 +93,7 @@ if ($conf->accounting->enabled) {
} }
print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial); print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
print "<br>\n"; print "<br>\n";

View File

@ -34,7 +34,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adm
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'companies')); $langs->loadLangs(array('admin', 'companies'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$error = 0; $error = 0;
@ -45,11 +47,12 @@ $error = 0;
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (($action == 'update' && !GETPOST("cancel", 'alpha')) if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|| ($action == 'updateedit')) || ($action == 'updateedit')) {
{
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity);
@ -64,8 +67,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity);
if ($action != 'updateedit' && !$error) if ($action != 'updateedit' && !$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
@ -131,7 +133,9 @@ print '<input name="town" class="minwidth100" id="town" value="'.(GETPOSTISSET('
print '<tr class="oddeven"><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">'; print '<tr class="oddeven"><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
print img_picto('', 'globe-americas', 'class="paddingrightonly"'); print img_picto('', 'globe-americas', 'class="paddingrightonly"');
print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'country_id'); print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">'; print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';

View File

@ -28,8 +28,9 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'agenda')); $langs->loadLangs(array('admin', 'other', 'agenda'));
@ -45,12 +46,10 @@ $sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position";
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql .= " ORDER BY a.rang ASC"; $sql .= " ORDER BY a.rang ASC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$triggers[$i]['rowid'] = $obj->rowid; $triggers[$i]['rowid'] = $obj->rowid;
$triggers[$i]['code'] = $obj->code; $triggers[$i]['code'] = $obj->code;
@ -73,36 +72,32 @@ if ($resql)
*/ */
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
{
$search_event = ''; $search_event = '';
$action = ''; $action = '';
} }
if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) // To avoid the save when we click on search if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { // To avoid the save when we click on search
{
$action = ''; $action = '';
} }
if ($action == "save" && empty($cancel)) if ($action == "save" && empty($cancel)) {
{
$i = 0; $i = 0;
$db->begin(); $db->begin();
foreach ($triggers as $trigger) foreach ($triggers as $trigger) {
{
$keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; $keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
//print "param=".$param." - ".$_POST[$param]; //print "param=".$param." - ".$_POST[$param];
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) {
{
$res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
$db->commit(); $db->commit();
} else { } else {
@ -155,17 +150,27 @@ print '<th class="liste_titre" colspan="2">'.$langs->trans("ActionsEvents").'</t
print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param ? $param : '').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param ? $param : '').'">'.$langs->trans("None").'</a></th>'; print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param ? $param : '').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param ? $param : '').'">'.$langs->trans("None").'</a></th>';
print '</tr>'."\n"; print '</tr>'."\n";
// Show each trigger (list is in c_action_trigger) // Show each trigger (list is in c_action_trigger)
if (!empty($triggers)) if (!empty($triggers)) {
{ foreach ($triggers as $trigger) {
foreach ($triggers as $trigger)
{
$module = $trigger['element']; $module = $trigger['element'];
if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur'; if ($module == 'order_supplier' || $module == 'invoice_supplier') {
if ($module == 'shipping') $module = 'expedition_bon'; $module = 'fournisseur';
if ($module == 'member') $module = 'adherent'; }
if ($module == 'project') $module = 'projet'; if ($module == 'shipping') {
if ($module == 'proposal_supplier') $module = 'supplier_proposal'; $module = 'expedition_bon';
if ($module == 'contact') $module = 'societe'; }
if ($module == 'member') {
$module = 'adherent';
}
if ($module == 'project') {
$module = 'projet';
}
if ($module == 'proposal_supplier') {
$module = 'supplier_proposal';
}
if ($module == 'contact') {
$module = 'societe';
}
// If 'element' value is myobject@mymodule instead of mymodule // If 'element' value is myobject@mymodule instead of mymodule
$tmparray = explode('@', $module); $tmparray = explode('@', $module);
@ -174,14 +179,16 @@ if (!empty($triggers))
} }
//print 'module='.$module.' code='.$trigger['code'].'<br>'; //print 'module='.$module.' code='.$trigger['code'].'<br>';
if (!empty($conf->$module->enabled)) if (!empty($conf->$module->enabled)) {
{
// Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; continue;
}
if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
continue;
}
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code'])) if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code'])) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$trigger['code'].'</td>'; print '<td>'.$trigger['code'].'</td>';
print '<td>'.$trigger['label'].'</td>'; print '<td>'.$trigger['label'].'</td>';

View File

@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'agenda')); $langs->loadLangs(array('admin', 'other', 'agenda'));
@ -43,13 +44,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield $elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -82,8 +87,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -96,8 +100,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -109,8 +112,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('agenda', 'admin', 'other')); $langs->loadLangs(array('agenda', 'admin', 'other'));
@ -41,7 +43,9 @@ $def = array();
$actiontest = GETPOST('test', 'alpha'); $actiontest = GETPOST('test', 'alpha');
$actionsave = GETPOST('save', 'alpha'); $actionsave = GETPOST('save', 'alpha');
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; if (empty($conf->global->AGENDA_EXT_NB)) {
$conf->global->AGENDA_EXT_NB = 5;
}
$MAXAGENDA = $conf->global->AGENDA_EXT_NB; $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
// List of available colors // List of available colors
@ -52,8 +56,7 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', '
* Actions * Actions
*/ */
if ($actionsave) if ($actionsave) {
{
$db->begin(); $db->begin();
$disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha');
@ -63,17 +66,17 @@ if ($actionsave)
$error = 0; $error = 0;
// Save agendas // Save agendas
while ($i <= $MAXAGENDA) while ($i <= $MAXAGENDA) {
{
$name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha')); $name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha'));
$src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha')); $src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha'));
$offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha')); $offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha'));
$color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha')); $color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha'));
if ($color == '-1') $color = ''; if ($color == '-1') {
$color = '';
}
$enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha')); $enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha'));
if (!empty($src) && !dol_is_url($src)) if (!empty($src) && !dol_is_url($src)) {
{
setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors'); setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
$error++; $error++;
$errorsaved++; $errorsaved++;
@ -82,34 +85,48 @@ if ($actionsave)
//print '-name='.$name.'-color='.$color; //print '-name='.$name.'-color='.$color;
$res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$i++; $i++;
} }
// Save nb of agenda // Save nb of agenda
if (!$error) if (!$error) {
{
$res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; $error++;
}
if (empty($conf->global->AGENDA_EXT_NB)) {
$conf->global->AGENDA_EXT_NB = 5;
}
$MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB; $MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB;
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
$db->rollback(); $db->rollback();
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); if (empty($errorsaved)) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} }
} }
@ -143,7 +160,11 @@ print "<br>\n";
$selectedvalue = $conf->global->AGENDA_DISABLE_EXT; $selectedvalue = $conf->global->AGENDA_DISABLE_EXT;
if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1; if ($selectedvalue == 1) {
$selectedvalue = 0;
} else {
$selectedvalue = 1;
}
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
@ -157,12 +178,10 @@ print "</tr>";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("ExtSitesEnableThisTool")."</td>"; print "<td>".$langs->trans("ExtSitesEnableThisTool")."</td>";
print '<td class="center">'; print '<td class="center">';
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print ajax_constantonoff('AGENDA_DISABLE_EXT', array('enabled'=>array(0=>'.hideifnotset')), null, 1); print ajax_constantonoff('AGENDA_DISABLE_EXT', array('enabled'=>array(0=>'.hideifnotset')), null, 1);
} else { } else {
if (empty($conf->global->AGENDA_DISABLE_EXT)) if (empty($conf->global->AGENDA_DISABLE_EXT)) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -194,8 +213,7 @@ print '<td class="right">'.$langs->trans("Color").'</td>';
print "</tr>"; print "</tr>";
$i = 1; $i = 1;
while ($i <= $MAXAGENDA) while ($i <= $MAXAGENDA) {
{
$key = $i; $key = $i;
$name = 'AGENDA_EXT_NAME'.$key; $name = 'AGENDA_EXT_NAME'.$key;
$src = 'AGENDA_EXT_SRC'.$key; $src = 'AGENDA_EXT_SRC'.$key;

View File

@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'agenda', 'users')); $langs->loadLangs(array('admin', 'other', 'agenda', 'users'));
@ -52,12 +53,10 @@ $type = 'action';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
$reg = array(); $reg = array();
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -65,27 +64,23 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
} }
} }
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($action == 'set') if ($action == 'set') {
{
$getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE'); $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE');
$defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter; $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter;
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
} elseif ($action == 'specimen') // For orders } elseif ($action == 'specimen') { // For orders
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
@ -95,25 +90,21 @@ if ($action == 'set')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db, $commande); $module = new $classname($db, $commande);
if ($module->write_file($commande, $langs) > 0) if ($module->write_file($commande, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -124,27 +115,20 @@ if ($action == 'set')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'setmodel') {
// Activate a model
// Activate a model
elseif ($action == 'setmodel')
{
//print "sssd".$value; //print "sssd".$value;
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->ACTION_EVENT_ADDON_PDF = $value; $conf->global->ACTION_EVENT_ADDON_PDF = $value;
@ -152,8 +136,7 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }
@ -193,12 +176,10 @@ $sql .= " WHERE type = 'action'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -207,8 +188,7 @@ if ($resql)
dol_print_error($db); dol_print_error($db);
} }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
{
print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); print load_fiche_titre($langs->trans("AgendaModelModule"), '', '');
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
@ -223,19 +203,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/action/doc"); $dir = dol_buildpath($reldir."core/modules/action/doc");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -249,17 +224,17 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print "<td>\n"; print "<td>\n";
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db, $specimenthirdparty); $module = new $classname($db, $specimenthirdparty);
if (method_exists($module, 'info')) if (method_exists($module, 'info')) {
print $module->info($langs); print $module->info($langs);
else print $module->description; } else {
print $module->description;
}
print "</td>\n"; print "</td>\n";
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
@ -275,8 +250,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -324,8 +298,7 @@ print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE").'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n"; print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n"; print '<td class="right">'."\n";
//print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list //print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
@ -342,8 +315,7 @@ $tmplist = array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_mon
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW); print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
print '</td></tr>'."\n"; print '</td></tr>'."\n";
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
{
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->'; print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n"; print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";

View File

@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php'; require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "agenda")); $langs->loadLangs(array("admin", "other", "agenda"));
@ -47,12 +48,10 @@ $type = 'action';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -60,25 +59,21 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
} }
} }
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($action == 'set') if ($action == 'set') {
{
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
} elseif ($action == 'specimen') // For orders } elseif ($action == 'specimen') { // For orders
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
@ -88,25 +83,21 @@ if ($action == 'set')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db, $commande); $module = new $classname($db, $commande);
if ($module->write_file($commande, $langs) > 0) if ($module->write_file($commande, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -117,27 +108,20 @@ if ($action == 'set')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'setmodel') {
// Activate a model
// Activate a model
elseif ($action == 'setmodel')
{
//print "sssd".$value; //print "sssd".$value;
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that has been read in front of the new set // The constant that has been read in front of the new set
// is therefore passed through a variable to have a coherent display // is therefore passed through a variable to have a coherent display
$conf->global->ACTION_EVENT_ADDON_PDF = $value; $conf->global->ACTION_EVENT_ADDON_PDF = $value;
@ -145,8 +129,7 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }

View File

@ -29,8 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "agenda")); $langs->loadLangs(array("admin", "other", "agenda"));
@ -39,8 +40,7 @@ $def = array();
$actionsave = GETPOST('save', 'alpha'); $actionsave = GETPOST('save', 'alpha');
// Sauvegardes parametres // Sauvegardes parametres
if ($actionsave) if ($actionsave) {
{
$i = 0; $i = 0;
$db->begin(); $db->begin();
@ -50,8 +50,7 @@ if ($actionsave)
$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
if ($i >= 4) if ($i >= 4) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -66,7 +65,9 @@ if ($actionsave)
* View * View
*/ */
if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100; if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) {
$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
}
$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; $wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
@ -97,8 +98,9 @@ print "</tr>";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>"; print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">'; print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
}
print '</td>'; print '</td>';
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
print "</tr>"; print "</tr>";
@ -183,8 +185,7 @@ $message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'<br>';
print info_admin($message); print info_admin($message);
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
print "\n".'<script type="text/javascript">'; print "\n".'<script type="text/javascript">';
print '$(document).ready(function () { print '$(document).ready(function () {
$("#generate_token").click(function() { $("#generate_token").click(function() {

View File

@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); $langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$actionsave = GETPOST('save', 'alpha'); $actionsave = GETPOST('save', 'alpha');
@ -51,8 +52,7 @@ $type = 'bankaccount';
// Order display of bank account // Order display of bank account
if ($action == 'setbankorder') { if ($action == 'setbankorder') {
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -62,16 +62,14 @@ if ($action == 'setbankorder') {
// Auto report last num releve on conciliate // Auto report last num releve on conciliate
if ($action == 'setreportlastnumreleve') { if ($action == 'setreportlastnumreleve') {
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'unsetreportlastnumreleve') { } elseif ($action == 'unsetreportlastnumreleve') {
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -81,16 +79,14 @@ if ($action == 'setreportlastnumreleve') {
// Colorize movements // Colorize movements
if ($action == 'setbankcolorizemovement') { if ($action == 'setbankcolorizemovement') {
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'unsetbankcolorizemovement') { } elseif ($action == 'unsetbankcolorizemovement') {
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -98,31 +94,34 @@ if ($action == 'setbankcolorizemovement') {
} }
} }
if ($actionsave) if ($actionsave) {
{
$db->begin(); $db->begin();
$i = 1; $errorsaved = 0; $i = 1; $errorsaved = 0;
$error = 0; $error = 0;
// Save colors // Save colors
while ($i <= 2) while ($i <= 2) {
{
$color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'); $color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha');
if ($color == '-1') $color = ''; if ($color == '-1') {
$color = '';
}
$res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$i++; $i++;
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
$db->rollback(); $db->rollback();
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); if (empty($errorsaved)) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} }
} }
@ -175,12 +174,12 @@ if ($action == 'set') {
} elseif ($action == 'del') { } elseif ($action == 'del') {
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) { if ($ret > 0) {
if ($conf->global->BANKADDON_PDF == "$value") if ($conf->global->BANKADDON_PDF == "$value") {
dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity); dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity);
} }
} }
// Set default model } elseif ($action == 'setdoc') {
elseif ($action == 'setdoc') { // Set default model
if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
// The constant that was read before the new set // The constant that was read before the new set
// We therefore requires a variable to have a coherent view // We therefore requires a variable to have a coherent view
@ -247,8 +246,9 @@ while ($i < $nbofbank) {
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmparray = explode(' ', $bankorder[$i][2]); $tmparray = explode(' ', $bankorder[$i][2]);
foreach ($tmparray as $key => $val) { foreach ($tmparray as $key => $val) {
if ($key > 0) if ($key > 0) {
print ', '; print ', ';
}
print $langs->trans($val); print $langs->trans($val);
} }
print "</td>\n"; print "</td>\n";
@ -333,18 +333,22 @@ foreach ($dirmodels as $reldir) {
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
$modulequalified = 0; $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) }
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0; $modulequalified = 0;
}
if ($modulequalified) { if ($modulequalified) {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print(empty($module->name) ? $name : $module->name); print(empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) if (method_exists($module, 'info')) {
print $module->info($langs); print $module->info($langs);
else print $module->description; } else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
@ -436,11 +440,9 @@ if ($conf->global->BANK_COLORIZE_MOVEMENT) {
print "</tr>\n"; print "</tr>\n";
if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) {
{
$i = 1; $i = 1;
while ($i <= 2) while ($i <= 2) {
{
$key = $i; $key = $i;
$color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;

View File

@ -39,13 +39,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'bank_account'; //Must be the $element of the class that manage extrafield $elementtype = 'bank_account'; //Must be the $element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -79,8 +83,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -90,8 +93,7 @@ if ($action != 'create' && $action != 'edit')
/* /*
* Creation of an optional field * Creation of an optional field
*/ */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -101,8 +103,7 @@ if ($action == 'create')
/* /*
* Edition of an optional field * Edition of an optional field
*/ */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -42,21 +44,17 @@ $action = GETPOST('action', 'aZ09');
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setbarcodeproducton') if ($action == 'setbarcodeproducton') {
{
$barcodenumberingmodule = GETPOST('value', 'alpha'); $barcodenumberingmodule = GETPOST('value', 'alpha');
$res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) {
{
$res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
} }
} elseif ($action == 'setbarcodeproductoff') } elseif ($action == 'setbarcodeproductoff') {
{
$res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity); $res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
} }
if ($action == 'setcoder') if ($action == 'setcoder') {
{
$coder = GETPOST('coder', 'alpha'); $coder = GETPOST('coder', 'alpha');
$code_id = GETPOST('code_id', 'int'); $code_id = GETPOST('code_id', 'int');
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
@ -65,9 +63,10 @@ if ($action == 'setcoder')
$sqlp .= " AND entity = ".$conf->entity; $sqlp .= " AND entity = ".$conf->entity;
$resql = $db->query($sqlp); $resql = $db->query($sqlp);
if (!$resql) dol_print_error($db); if (!$resql) {
} elseif ($action == 'update') dol_print_error($db);
{ }
} elseif ($action == 'update') {
$location = GETPOST('GENBARCODE_LOCATION', 'alpha'); $location = GETPOST('GENBARCODE_LOCATION', 'alpha');
$res = dolibarr_set_const($db, "GENBARCODE_LOCATION", $location, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "GENBARCODE_LOCATION", $location, 'chaine', 0, '', $conf->entity);
$coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE', 'alpha'); $coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE', 'alpha');
@ -75,31 +74,26 @@ if ($action == 'setcoder')
$coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY', 'alpha'); $coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY', 'alpha');
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity);
if ($res > 0) if ($res > 0) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'updateengine') } elseif ($action == 'updateengine') {
{
$sql = "SELECT rowid, coder"; $sql = "SELECT rowid, coder";
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
$sql .= " WHERE entity = ".$conf->entity; $sql .= " WHERE entity = ".$conf->entity;
$sql .= " ORDER BY code"; $sql .= " ORDER BY code";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (GETPOST('coder'.$obj->rowid, 'alpha')) if (GETPOST('coder'.$obj->rowid, 'alpha')) {
{
$coder = GETPOST('coder'.$obj->rowid, 'alpha'); $coder = GETPOST('coder'.$obj->rowid, 'alpha');
$code_id = $obj->rowid; $code_id = $obj->rowid;
@ -109,7 +103,9 @@ if ($action == 'setcoder')
$sqlp .= " AND entity = ".$conf->entity; $sqlp .= " AND entity = ".$conf->entity;
$upsql = $db->query($sqlp); $upsql = $db->query($sqlp);
if (!$upsql) dol_print_error($db); if (!$upsql) {
dol_print_error($db);
}
} }
$i++; $i++;
@ -140,25 +136,21 @@ clearstatcache();
// Scan list of all barcode included provided by external modules // Scan list of all barcode included provided by external modules
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']); $dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
foreach ($dirbarcode as $reldir) foreach ($dirbarcode as $reldir) {
{
$dir = dol_buildpath($reldir); $dir = dol_buildpath($reldir);
$newdir = dol_osencode($dir); $newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) continue; if (!is_dir($newdir)) {
continue;
}
$handle = @opendir($newdir); $handle = @opendir($newdir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
{ if (is_readable($newdir.$file)) {
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') if (preg_match('/(.*)\.modules\.php$/i', $file, $reg)) {
{
if (is_readable($newdir.$file))
{
if (preg_match('/(.*)\.modules\.php$/i', $file, $reg))
{
$filebis = $reg[1]; $filebis = $reg[1];
// Loading encoding class // Loading encoding class
@ -167,11 +159,14 @@ foreach ($dirbarcode as $reldir)
$module = new $classname($db); $module = new $classname($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
$barcodelist[$filebis] = $module->info(); $barcodelist[$filebis] = $module->info();
} }
} }
@ -188,8 +183,7 @@ foreach ($dirbarcode as $reldir)
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', ''); print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', '');
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax)) {
{
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updateengine">'; print '<input type="hidden" name="action" value="updateengine">';
@ -210,13 +204,11 @@ $sql .= " ORDER BY code";
dol_syslog("admin/barcode.php", LOG_DEBUG); dol_syslog("admin/barcode.php", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
@ -230,29 +222,28 @@ if ($resql)
// Show example // Show example
print '<td class="center">'; print '<td class="center">';
if ($obj->coder && $obj->coder != -1) if ($obj->coder && $obj->coder != -1) {
{
$result = 0; $result = 0;
foreach ($dirbarcode as $reldir) foreach ($dirbarcode as $reldir) {
{
$dir = dol_buildpath($reldir, 0); $dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir); $newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) continue; if (!is_dir($newdir)) {
continue;
}
$result = @include_once $newdir.$obj->coder.'.modules.php'; $result = @include_once $newdir.$obj->coder.'.modules.php';
if ($result) break; if ($result) {
break;
} }
if ($result) }
{ if ($result) {
$classname = "mod".ucfirst($obj->coder); $classname = "mod".ucfirst($obj->coder);
if (class_exists($classname)) if (class_exists($classname)) {
{
$module = new $classname($db); $module = new $classname($db);
if ($module->encodingIsSupported($obj->encoding)) if ($module->encodingIsSupported($obj->encoding)) {
{
// Build barcode on disk (not used, this is done to make debug easier) // Build barcode on disk (not used, this is done to make debug easier)
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
// Generate on the fly and output barcode with generator // Generate on the fly and output barcode with generator
@ -280,8 +271,7 @@ if ($resql)
} }
print "</table>\n"; print "</table>\n";
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax)) {
{
print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'"></div>'; print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'"></div>';
print '</form>'; print '</form>';
} }
@ -306,14 +296,12 @@ print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
// Chemin du binaire genbarcode sous linux // Chemin du binaire genbarcode sous linux
if (!isset($_SERVER['WINDIR'])) if (!isset($_SERVER['WINDIR'])) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("GenbarcodeLocation").'</td>'; print '<td>'.$langs->trans("GenbarcodeLocation").'</td>';
print '<td width="60" class="center">'; print '<td width="60" class="center">';
print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">'; print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">';
if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION)) if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION)) {
{
$langs->load("errors"); $langs->load("errors");
print '<br><font class="error">'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).'</font>'; print '<br><font class="error">'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).'</font>';
} }
@ -321,8 +309,7 @@ if (!isset($_SERVER['WINDIR']))
} }
// Module products // Module products
if (!empty($conf->product->enabled)) if (!empty($conf->product->enabled)) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>'; print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
print '<td width="60" class="right">'; print '<td width="60" class="right">';
@ -331,8 +318,7 @@ if (!empty($conf->product->enabled))
} }
// Module thirdparty // Module thirdparty
if (!empty($conf->societe->enabled)) if (!empty($conf->societe->enabled)) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>'; print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
print '<td width="60" class="right">'; print '<td width="60" class="right">';
@ -351,8 +337,7 @@ print '<br>';
// Select barcode numbering module // Select barcode numbering module
if ($conf->product->enabled) if ($conf->product->enabled) {
{
print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', ''); print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', '');
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -366,23 +351,18 @@ if ($conf->product->enabled)
$dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
foreach ($dirbarcodenum as $dirroot) foreach ($dirbarcodenum as $dirroot) {
{
$dir = dol_buildpath($dirroot, 0); $dir = dol_buildpath($dirroot, 0);
$handle = @opendir($dir); $handle = @opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (preg_match('/^mod_barcode_product_.*php$/', $file)) {
{
if (preg_match('/^mod_barcode_product_.*php$/', $file))
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
try { try {
dol_include_once($dirroot.$file.'.php'); dol_include_once($dirroot.$file.'.php');
} catch (Exception $e) } catch (Exception $e) {
{
dol_syslog($e->getMessage(), LOG_ERR); dol_syslog($e->getMessage(), LOG_ERR);
} }
@ -394,8 +374,7 @@ if ($conf->product->enabled)
print '</td>'; print '</td>';
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n"; print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'mrp', 'other')); $langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -45,23 +47,24 @@ $type = 'bom';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstbom = GETPOST('maskconstBom', 'alpha'); $maskconstbom = GETPOST('maskconstBom', 'alpha');
$maskbom = GETPOST('maskBom', 'alpha'); $maskbom = GETPOST('maskBom', 'alpha');
if ($maskconstbom) $res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity); if ($maskconstbom) {
$res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$bom = new BOM($db); $bom = new BOM($db);
@ -70,25 +73,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($bom, $langs) > 0) if ($module->write_file($bom, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -99,26 +98,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->BOM_ADDON_PDF == "$value") {
if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "BOM_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "BOM_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that was read before the new set // The constant that was read before the new set
// We therefore requires a variable to have a coherent view // We therefore requires a variable to have a coherent view
$conf->global->BOM_ADDON_PDF = $value; $conf->global->BOM_ADDON_PDF = $value;
@ -126,39 +118,37 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// TODO Check if numbering module chosen can be activated // TODO Check if numbering module chosen can be activated
// by calling method canBeActivated // by calling method canBeActivated
dolibarr_set_const($db, "BOM_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "BOM_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_BOM_DRAFT_WATERMARK') } elseif ($action == 'set_BOM_DRAFT_WATERMARK') {
{
$draft = GETPOST("BOM_DRAFT_WATERMARK"); $draft = GETPOST("BOM_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "BOM_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BOM_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_BOM_FREE_TEXT') } elseif ($action == 'set_BOM_FREE_TEXT') {
{
$freetext = GETPOST("BOM_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST("BOM_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "BOM_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BOM_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -200,19 +190,14 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/bom/"); $dir = dol_buildpath($reldir."core/modules/bom/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -220,11 +205,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db); $module = new $file($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -235,13 +223,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->BOM_ADDON == $file) if ($conf->global->BOM_ADDON == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -261,8 +251,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -297,12 +288,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -324,31 +313,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/bom".$valdir; $realpath = $reldir."core/modules/bom".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -356,21 +337,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -384,8 +370,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->BOM_ADDON_PDF == $name) if ($conf->global->BOM_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -395,8 +380,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -412,8 +396,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -448,7 +431,9 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -457,8 +442,7 @@ print '<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'BOM_FREE_TEXT'; $variablename = 'BOM_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -39,13 +39,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'bom_bom'; $elementtype = 'bom_bom';
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -78,8 +82,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -89,8 +92,7 @@ if ($action != 'create' && $action != 'edit')
/* /*
* Creation of an optional field * Creation of an optional field
*/ */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -100,8 +102,7 @@ if ($action == 'create')
/* /*
* Edition of an optional field * Edition of an optional field
*/ */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -34,14 +34,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); $langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipts_mint.php'; if (empty($conf->global->CHEQUERECEIPTS_ADDON)) {
$conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipts_mint.php';
}
@ -49,37 +52,38 @@ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_AD
* Actions * Actions
*/ */
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha'); $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha');
$maskchequereceipts = GETPOST('maskchequereceipts', 'alpha'); $maskchequereceipts = GETPOST('maskchequereceipts', 'alpha');
if ($maskconstchequereceipts) $res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity); if ($maskconstchequereceipts) {
$res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'setmod') if ($action == 'setmod') {
{
dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON", $value, 'chaine', 0, '', $conf->entity);
} }
if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') {
{
$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -118,45 +122,43 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/cheque/"); $dir = dol_buildpath($reldir."core/modules/cheque/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
{
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
{
$filebis = $file; $filebis = $file;
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = preg_replace('/\.php$/', '', $file); $classname = preg_replace('/\.php$/', '', $file);
// For compatibility // For compatibility
if (!is_file($dir.$filebis)) if (!is_file($dir.$filebis)) {
{
$filebis = $file."/".$file.".modules.php"; $filebis = $file."/".$file.".modules.php";
$classname = "mod_chequereceipt_".$file; $classname = "mod_chequereceipt_".$file;
} }
// Check if there is a filter on country // Check if there is a filter on country
preg_match('/\-(.*)_(.*)$/', $classname, $reg); preg_match('/\-(.*)_(.*)$/', $classname, $reg);
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
continue;
}
$classname = preg_replace('/\-.*$/', '', $classname); $classname = preg_replace('/\-.*$/', '', $classname);
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
{
// Charging the numbering class // Charging the numbering class
require_once $dir.$filebis; require_once $dir.$filebis;
$module = new $classname($db); $module = new $classname($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
@ -171,13 +173,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->CHEQUERECEIPTS_ADDON == $file || $conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) if ($conf->global->CHEQUERECEIPTS_ADDON == $file || $conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -194,8 +198,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValue").': '; $htmltooltip .= $langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -205,9 +210,10 @@ foreach ($dirmodels as $reldir)
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) // If module is the one used, we show existing errors if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) { // If module is the one used, we show existing errors
{ if (!empty($module->error)) {
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); dol_htmloutput_mesg($module->error, '', 'error', 1);
}
} }
print '</td>'; print '</td>';
@ -246,14 +252,15 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT'; $variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -42,13 +44,11 @@ if (!in_array('clicktodial', $conf->modules)) {
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) 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); $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); $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
if ($result1 >= 0 && $result2 >= 0) if ($result1 >= 0 && $result2 >= 0) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -117,12 +117,13 @@ print '<div class="center"><br><input type="submit" class="button" value="'.$lan
print '</form><br><br>'; print '</form><br><br>';
if (!empty($conf->global->CLICKTODIAL_URL)) if (!empty($conf->global->CLICKTODIAL_URL)) {
{
$user->fetch_clicktodial(); $user->fetch_clicktodial();
$phonefortest = $mysoc->phone; $phonefortest = $mysoc->phone;
if (GETPOST('phonefortest')) $phonefortest = GETPOST('phonefortest'); if (GETPOST('phonefortest')) {
$phonefortest = GETPOST('phonefortest');
}
print '<form action="'.$_SERVER["PHP_SELF"].'">'; print '<form action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
@ -132,12 +133,17 @@ if (!empty($conf->global->CLICKTODIAL_URL))
print '</form>'; print '</form>';
$setupcomplete = 1; $setupcomplete = 1;
if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete = 0; if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) {
if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete = 0; $setupcomplete = 0;
if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete = 0; }
if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) {
$setupcomplete = 0;
}
if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) {
$setupcomplete = 0;
}
if ($setupcomplete) if ($setupcomplete) {
{
print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL'); print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
} else { } else {
$langs->load("errors"); $langs->load("errors");

View File

@ -39,7 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'orders', 'other')); $langs->loadLangs(array('admin', 'errors', 'orders', 'other'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -54,23 +56,24 @@ $type = 'order';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstorder = GETPOST('maskconstorder', 'alpha'); $maskconstorder = GETPOST('maskconstorder', 'alpha');
$maskorder = GETPOST('maskorder', 'alpha'); $maskorder = GETPOST('maskorder', 'alpha');
if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); if ($maskconstorder) {
$res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$commande = new Commande($db); $commande = new Commande($db);
@ -79,25 +82,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($commande, $langs) > 0) if ($module->write_file($commande, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -108,23 +107,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set') {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') { } elseif ($action == 'del') {
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->COMMANDE_ADDON_PDF == "$value") {
if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') { if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that was read before the new set // The constant that was read before the new set
// We therefore requires a variable to have a coherent view // We therefore requires a variable to have a coherent view
$conf->global->COMMANDE_ADDON_PDF = $value; $conf->global->COMMANDE_ADDON_PDF = $value;
@ -132,8 +127,7 @@ elseif ($action == 'setdoc') {
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') { } elseif ($action == 'setmod') {
@ -141,29 +135,29 @@ elseif ($action == 'setdoc') {
// by calling method canBeActivated // by calling method canBeActivated
dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') } elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') {
{
$draft = GETPOST("COMMANDE_DRAFT_WATERMARK"); $draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_ORDER_FREE_TEXT') } elseif ($action == 'set_ORDER_FREE_TEXT') {
{
$freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -172,54 +166,52 @@ elseif ($action == 'setdoc') {
// Activate Set Shippable Icon In List // Activate Set Shippable Icon In List
$setshippableiconinlist = GETPOST('value', 'int'); $setshippableiconinlist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'setribchq') } elseif ($action == 'setribchq') {
{
$rib = GETPOST('rib', 'alpha'); $rib = GETPOST('rib', 'alpha');
$chq = GETPOST('chq', 'alpha'); $chq = GETPOST('chq', 'alpha');
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} } elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') {
// Activate ask for payment bank
// Activate ask for payment bank
elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
{
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} } elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') {
// Activate ask for warehouse
// Activate ask for warehouse
elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
{
$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -262,19 +254,14 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/commande/"); $dir = dol_buildpath($reldir."core/modules/commande/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -282,11 +269,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db); $module = new $file($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -297,13 +287,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->COMMANDE_ADDON == $file) if ($conf->global->COMMANDE_ADDON == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -323,8 +315,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -359,12 +352,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -387,31 +378,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/commande".$valdir; $realpath = $reldir."core/modules/commande".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -419,21 +402,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -447,8 +435,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->COMMANDE_ADDON_PDF == $name) if ($conf->global->COMMANDE_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -458,8 +445,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -480,8 +466,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -528,26 +513,21 @@ print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>"; print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
print "<td>"; print "<td>";
if (empty($conf->facture->enabled)) if (empty($conf->facture->enabled)) {
{ if (!empty($conf->banque->enabled)) {
if (!empty($conf->banque->enabled))
{
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0"; $sql .= " WHERE clos = 0";
$sql .= " AND courant = 1"; $sql .= " AND courant = 1";
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num > 0) if ($num > 0) {
{
print '<select name="rib" class="flat" id="rib">'; print '<select name="rib" class="flat" id="rib">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
@ -572,8 +552,7 @@ print "</td></tr>";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>"; print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
print "<td>"; print "<td>";
if (empty($conf->facture->enabled)) if (empty($conf->facture->enabled)) {
{
print '<select class="flat" name="chq" id="chq">'; print '<select class="flat" name="chq" id="chq">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>'; print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
@ -585,12 +564,10 @@ if (empty($conf->facture->enabled))
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
@ -626,7 +603,9 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -635,8 +614,7 @@ print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'ORDER_FREE_TEXT'; $variablename = 'ORDER_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$langs->load("admin"); $langs->load("admin");
$langs->load("other"); $langs->load("other");
@ -48,13 +49,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->trans($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->trans($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield $elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -87,8 +92,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -101,8 +105,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -114,8 +117,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -43,7 +43,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adm
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'companies', 'bills')); $langs->loadLangs(array('admin', 'companies', 'bills'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$error = 0; $error = 0;
@ -57,14 +59,14 @@ $hookmanager->initHooks(array('admincompany', 'globaladmin'));
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (($action == 'update' && !GETPOST("cancel", 'alpha')) if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|| ($action == 'updateedit')) || ($action == 'updateedit')) {
{
$tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0); $tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0);
if (!empty($tmparray['id'])) if (!empty($tmparray['id'])) {
{
$mysoc->country_id = $tmparray['id']; $mysoc->country_id = $tmparray['id'];
$mysoc->country_code = $tmparray['code']; $mysoc->country_code = $tmparray['code'];
$mysoc->country_label = $tmparray['label']; $mysoc->country_label = $tmparray['label'];
@ -76,8 +78,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
} }
$tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0); $tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
if (!empty($tmparray['id'])) if (!empty($tmparray['id'])) {
{
$mysoc->state_id = $tmparray['id']; $mysoc->state_id = $tmparray['id'];
$mysoc->state_code = $tmparray['code']; $mysoc->state_code = $tmparray['code'];
$mysoc->state_label = $tmparray['label']; $mysoc->state_label = $tmparray['label'];
@ -107,59 +108,58 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
$arrayofimages = array('logo', 'logo_squarred'); $arrayofimages = array('logo', 'logo_squarred');
foreach ($arrayofimages as $varforimage) foreach ($arrayofimages as $varforimage) {
{
if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported. if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported.
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
break; break;
} }
if ($_FILES[$varforimage]["tmp_name"]) if ($_FILES[$varforimage]["tmp_name"]) {
{
$reg = array(); $reg = array();
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
{
$original_file = $reg[1]; $original_file = $reg[1];
$isimage = image_format_supported($original_file); $isimage = image_format_supported($original_file);
if ($isimage >= 0) if ($isimage >= 0) {
{
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
if (!is_dir($dirforimage)) if (!is_dir($dirforimage)) {
{
dol_mkdir($dirforimage); dol_mkdir($dirforimage);
} }
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
if ($result > 0) if ($result > 0) {
{
$constant = "MAIN_INFO_SOCIETE_LOGO"; $constant = "MAIN_INFO_SOCIETE_LOGO";
if ($varforimage == 'logo_squarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; if ($varforimage == 'logo_squarred') {
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
}
dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
// Create thumbs of logo (Note that PDF use original file and not thumbs) // Create thumbs of logo (Note that PDF use original file and not thumbs)
if ($isimage > 0) if ($isimage > 0) {
{
// Create thumbs // Create thumbs
//$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
// Create small thumb, Used on logon for example // Create small thumb, Used on logon for example
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
{
$imgThumbSmall = $reg[1]; // Save only basename $imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
} else dol_syslog($imgThumbSmall); } else {
dol_syslog($imgThumbSmall);
}
// Create mini thumb, Used on menu or for setup page for example // Create mini thumb, Used on menu or for setup page for example
$imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality); $imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
{
$imgThumbMini = $reg[1]; // Save only basename $imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
} else dol_syslog($imgThumbMini); } else {
} else dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING); dol_syslog($imgThumbMini);
}
} else {
dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
}
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) { } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
@ -198,13 +198,11 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
$usevat = GETPOST("optiontva", 'aZ09'); $usevat = GETPOST("optiontva", 'aZ09');
$uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09'); $uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
$uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09'); $uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
if ($uselocaltax1 == 'localtax1on' && !$usevat) if ($uselocaltax1 == 'localtax1on' && !$usevat) {
{
setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors'); setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
$error++; $error++;
} }
if ($uselocaltax2 == 'localtax2on' && !$usevat) if ($uselocaltax2 == 'localtax2on' && !$usevat) {
{
setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors'); setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
$error++; $error++;
} }
@ -213,8 +211,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
if ($_POST["optionlocaltax1"] == "localtax1on") if ($_POST["optionlocaltax1"] == "localtax1on") {
{
if (!GETPOSTISSET('lt1')) { if (!GETPOSTISSET('lt1')) {
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
} else { } else {
@ -222,8 +219,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
} }
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
} }
if ($_POST["optionlocaltax2"] == "localtax2on") if ($_POST["optionlocaltax2"] == "localtax2on") {
{
if (!GETPOSTISSET('lt2')) { if (!GETPOSTISSET('lt2')) {
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
} else { } else {
@ -232,8 +228,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
} }
if (!$error) if (!$error) {
{
if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form. if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
@ -242,24 +237,22 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
$db->rollback(); $db->rollback();
} }
if ($action != 'updateedit' && !$error) if ($action != 'updateedit' && !$error) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
} }
if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumbs if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs
{ if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"])) {
if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"]))
{
$isimage = image_format_supported($_GET["file"]); $isimage = image_format_supported($_GET["file"]);
// Create thumbs of logo // Create thumbs of logo
if ($isimage > 0) if ($isimage > 0) {
{
$constant = "MAIN_INFO_SOCIETE_LOGO"; $constant = "MAIN_INFO_SOCIETE_LOGO";
if ($action == 'addthumbsquarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; if ($action == 'addthumbsquarred') {
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
}
$reg = array(); $reg = array();
@ -268,19 +261,21 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
// Create small thumb. Used on logon for example // Create small thumb. Used on logon for example
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality); $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
{
$imgThumbSmall = $reg[1]; // Save only basename $imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
} else dol_syslog($imgThumbSmall); } else {
dol_syslog($imgThumbSmall);
}
// Create mini thumbs. Used on menu or for setup page for example // Create mini thumbs. Used on menu or for setup page for example
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality); $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
{
$imgThumbMini = $reg[1]; // Save only basename $imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
} else dol_syslog($imgThumbMini); } else {
dol_syslog($imgThumbMini);
}
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
@ -299,54 +294,67 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
} }
if ($action == 'removelogo' || $action == 'removelogosquarred') if ($action == 'removelogo' || $action == 'removelogosquarred') {
{
$constant = "MAIN_INFO_SOCIETE_LOGO"; $constant = "MAIN_INFO_SOCIETE_LOGO";
if ($action == 'removelogosquarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; if ($action == 'removelogosquarred') {
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$logofilename = $mysoc->logo; $logofilename = $mysoc->logo;
$logofilenamebis = $mysoc->logo_squarred; $logofilenamebis = $mysoc->logo_squarred;
if ($action == 'removelogosquarred') if ($action == 'removelogosquarred') {
{
$logofilename = $mysoc->logo_squarred; $logofilename = $mysoc->logo_squarred;
$logofilenamebis = $mysoc->logo; $logofilenamebis = $mysoc->logo;
} }
$logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename; $logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logofile); if ($logofilename != '' && $logofilename != $logofilenamebis) {
dol_delete_file($logofile);
}
dolibarr_del_const($db, $constant, $conf->entity); dolibarr_del_const($db, $constant, $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred = ''; if ($action == 'removelogosquarred') {
else $mysoc->logo = ''; $mysoc->logo_squarred = '';
} else {
$mysoc->logo = '';
}
$logofilename = $mysoc->logo_small; $logofilename = $mysoc->logo_small;
$logofilenamebis = $mysoc->logo_squarred_small; $logofilenamebis = $mysoc->logo_squarred_small;
if ($action == 'removelogosquarred') if ($action == 'removelogosquarred') {
{
$logofilename = $mysoc->logo_squarred_small; $logofilename = $mysoc->logo_squarred_small;
$logofilenamebis = $mysoc->logo_small; $logofilenamebis = $mysoc->logo_small;
} }
$logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename; $logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logosmallfile); if ($logofilename != '' && $logofilename != $logofilenamebis) {
dol_delete_file($logosmallfile);
}
dolibarr_del_const($db, $constant."_SMALL", $conf->entity); dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred_small = ''; if ($action == 'removelogosquarred') {
else $mysoc->logo_small = ''; $mysoc->logo_squarred_small = '';
} else {
$mysoc->logo_small = '';
}
$logofilename = $mysoc->logo_mini; $logofilename = $mysoc->logo_mini;
$logofilenamebis = $mysoc->logo_squarred_mini; $logofilenamebis = $mysoc->logo_squarred_mini;
if ($action == 'removelogosquarred') if ($action == 'removelogosquarred') {
{
$logofilename = $mysoc->logo_squarred_mini; $logofilename = $mysoc->logo_squarred_mini;
$logofilenamebis = $mysoc->logo_mini; $logofilenamebis = $mysoc->logo_mini;
} }
$logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename; $logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logominifile); if ($logofilename != '' && $logofilename != $logofilenamebis) {
dol_delete_file($logominifile);
}
dolibarr_del_const($db, $constant."_MINI", $conf->entity); dolibarr_del_const($db, $constant."_MINI", $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini = ''; if ($action == 'removelogosquarred') {
else $mysoc->logo_mini = ''; $mysoc->logo_squarred_mini = '';
} else {
$mysoc->logo_mini = '';
}
} }
@ -411,13 +419,14 @@ print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth200" id="MAIN_INFO_SO
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">'; print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
print img_picto('', 'globe-americas', 'class="paddingrightonly"'); print img_picto('', 'globe-americas', 'class="paddingrightonly"');
print $form->select_country($mysoc->country_id, 'country_id'); print $form->select_country($mysoc->country_id, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">'; print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
$state_id = 0; $state_id = 0;
if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) {
{
$tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
$state_id = $tmp[0]; $state_id = $tmp[0];
} }
@ -523,8 +532,7 @@ if (!empty($mysoc->logo_squarred_small)) {
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo_squarred).'">'; print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo_squarred).'">';
print '</div>'; print '</div>';
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>'; print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
} } else {
else {
print '<div class="inline-block valignmiddle">'; print '<div class="inline-block valignmiddle">';
print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">'; print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
print '</div>'; print '</div>';
@ -572,11 +580,9 @@ if ($mysoc->country_code) {
print '</td></tr>'; print '</td></tr>';
// ProfId1 // ProfId1
if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">'; print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -585,11 +591,9 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
} }
// ProfId2 // ProfId2
if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">'; print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -598,11 +602,9 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-')
} }
// ProfId3 // ProfId3
if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">'; print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -611,11 +613,9 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-')
} }
// ProfId4 // ProfId4
if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">'; print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -624,11 +624,9 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-')
} }
// ProfId5 // ProfId5
if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '').'">'; print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -637,11 +635,9 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-')
} }
// ProfId6 // ProfId6
if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '').'">'; print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -689,7 +685,9 @@ print "</tr>\n";
print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>"; print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
print '<td colspan="2">'; print '<td colspan="2">';
$tooltiphelp = ''; $tooltiphelp = '';
if ($mysoc->country_code == 'FR') $tooltiphelp = '<i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>"; if ($mysoc->country_code == 'FR') {
$tooltiphelp = '<i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
}
print "<label for=\"use_vat\">".$form->textwithpicto($langs->trans("VATIsUsedDesc"), $tooltiphelp)."</label>"; print "<label for=\"use_vat\">".$form->textwithpicto($langs->trans("VATIsUsedDesc"), $tooltiphelp)."</label>";
print "</td></tr>\n"; print "</td></tr>\n";
@ -697,7 +695,9 @@ print "</td></tr>\n";
print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="no_vat" value="0"'.(empty($conf->global->FACTURE_TVAOPTION) ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>"; print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="no_vat" value="0"'.(empty($conf->global->FACTURE_TVAOPTION) ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
print '<td colspan="2">'; print '<td colspan="2">';
$tooltiphelp = ''; $tooltiphelp = '';
if ($mysoc->country_code == 'FR') $tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n"; if ($mysoc->country_code == 'FR') {
$tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
}
print "<label for=\"no_vat\">".$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>"; print "<label for=\"no_vat\">".$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
print "</td></tr>\n"; print "</td></tr>\n";
@ -711,8 +711,7 @@ print '<td width="25%">'.$form->textwithpicto($langs->transcountry("LocalTax1Man
print '<td class="right">&nbsp;</td>'; print '<td class="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
if ($mysoc->useLocalTax(1)) if ($mysoc->useLocalTax(1)) {
{
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax1" id="lt1" value="localtax1on"'.(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>"; print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax1" id="lt1" value="localtax1on"'.(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
@ -720,8 +719,7 @@ if ($mysoc->useLocalTax(1))
$tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code); $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
$tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : ""); $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
print '<label for="lt1">'.$form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>"; print '<label for="lt1">'.$form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
if (!isOnlyOneLocalTax(1)) if (!isOnlyOneLocalTax(1)) {
{
print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: '; print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
$formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1"); $formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
} }
@ -740,8 +738,7 @@ if ($mysoc->useLocalTax(1))
print "<label for=\"nolt1\">".$form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>"; print "<label for=\"nolt1\">".$form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
print "</td></tr>\n"; print "</td></tr>\n";
} else { } else {
if (empty($mysoc->country_code)) if (empty($mysoc->country_code)) {
{
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>'; print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else { } else {
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).'</td></tr>'; print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).'</td></tr>';
@ -758,8 +755,7 @@ print '<td width="25%">'.$form->textwithpicto($langs->transcountry("LocalTax2Man
print '<td class="right">&nbsp;</td>'; print '<td class="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
if ($mysoc->useLocalTax(2)) if ($mysoc->useLocalTax(2)) {
{
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax2" id="lt2" value="localtax2on"'.(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>"; print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax2" id="lt2" value="localtax2on"'.(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
@ -767,8 +763,7 @@ if ($mysoc->useLocalTax(2))
print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>"; print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
$tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code); $tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
$tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : ""); $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
if (!isOnlyOneLocalTax(2)) if (!isOnlyOneLocalTax(2)) {
{
print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: '; print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
$formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
} }
@ -786,8 +781,7 @@ if ($mysoc->useLocalTax(2))
print "</div>"; print "</div>";
print "</td></tr>\n"; print "</td></tr>\n";
} else { } else {
if (empty($mysoc->country_code)) if (empty($mysoc->country_code)) {
{
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>'; print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else { } else {
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).'</td></tr>'; print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).'</td></tr>';
@ -804,8 +798,7 @@ print '<tr class="liste_titre">';
print '<td width="25%">'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td>'.$langs->trans("Description").'</td>'; print '<td width="25%">'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>'; print '<td class="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
if ($mysoc->useRevenueStamp()) if ($mysoc->useRevenueStamp()) {
{
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("UseRevenueStamp"); print $langs->trans("UseRevenueStamp");
@ -814,8 +807,7 @@ if ($mysoc->useRevenueStamp())
print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp")); print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
print "</td></tr>\n"; print "</td></tr>\n";
} else { } else {
if (empty($mysoc->country_code)) if (empty($mysoc->country_code)) {
{
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>'; print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else { } else {
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).'</td></tr>'; print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).'</td></tr>';

View File

@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'compta', 'accountancy')); $langs->loadLangs(array('admin', 'compta', 'accountancy'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -56,8 +57,7 @@ $list = array(
$accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE; $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
if ($action == 'update') if ($action == 'update') {
{
$error = 0; $error = 0;
$accounting_modes = array( $accounting_modes = array(
@ -85,21 +85,34 @@ if ($action == 'update')
} }
$report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha'); $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
if (!empty($report_include_varpay)) if (!empty($report_include_varpay)) {
if ($report_include_varpay == 'yes') if ($report_include_varpay == 'yes') {
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) {
if ($report_include_varpay == 'no') $error++;
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++; }
}
}
if ($report_include_varpay == 'no') {
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) {
$error++;
}
}
$report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha'); $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
if (!empty($report_include_loan)) if (!empty($report_include_loan)) {
if ($report_include_loan == 'yes') if ($report_include_loan == 'yes') {
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) {
if ($report_include_loan == 'no') $error++;
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++; }
}
}
if ($report_include_loan == 'no') {
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) {
$error++;
}
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -157,8 +170,7 @@ print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n"; print "</tr>\n";
foreach ($list as $key) foreach ($list as $key) {
{
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'sendings', 'deliveries')); $langs->loadLangs(array('admin', 'sendings', 'deliveries'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -43,8 +44,7 @@ $action = GETPOST('action', 'aZ09');
*/ */
// Shipment note // Shipment note
if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) {
{
// This option should always be set to on when module is on. // This option should always be set to on when module is on.
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity);
} }
@ -64,14 +64,12 @@ if ($action == 'disable_sending')
*/ */
// Delivery note // Delivery note
if ($action == 'activate_delivery') if ($action == 'activate_delivery') {
{
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this
dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity);
header("Location: confexped.php"); header("Location: confexped.php");
exit; exit;
} elseif ($action == 'disable_delivery') } elseif ($action == 'disable_delivery') {
{
dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity); dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity);
header("Location: confexped.php"); header("Location: confexped.php");
exit; exit;
@ -131,8 +129,7 @@ print '<td>';
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
if (empty($conf->global->MAIN_SUBMODULE_DELIVERY)) if (empty($conf->global->MAIN_SUBMODULE_DELIVERY)) {
{
print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
} else { } else {
print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>'; print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';

View File

@ -30,8 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$rowid = GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$entity = GETPOST('entity', 'int'); $entity = GETPOST('entity', 'int');
@ -49,37 +50,38 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (empty($sortfield)) $sortfield = 'entity,name'; if (empty($sortfield)) {
if (empty($sortorder)) $sortorder = 'ASC'; $sortfield = 'entity,name';
}
if (empty($sortorder)) {
$sortorder = 'ASC';
}
/* /*
* Actions * Actions
*/ */
if ($action == 'add' || (GETPOST('add') && $action != 'update')) if ($action == 'add' || (GETPOST('add') && $action != 'update')) {
{
$error = 0; $error = 0;
if (empty($constname)) if (empty($constname)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors');
$error++; $error++;
} }
if ($constvalue == '') if ($constvalue == '') {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Value")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Value")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{ if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0) {
if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0)
{
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action = ""; $action = "";
$constname = ""; $constname = "";
@ -92,50 +94,44 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update'))
} }
// Mass update // Mass update
if (!empty($consts) && $action == 'update') if (!empty($consts) && $action == 'update') {
{
$nbmodified = 0; $nbmodified = 0;
foreach ($consts as $const) foreach ($consts as $const) {
{ if (!empty($const["check"])) {
if (!empty($const["check"])) if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0) {
{
if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0)
{
$nbmodified++; $nbmodified++;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
if ($nbmodified > 0) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); if ($nbmodified > 0) {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
}
$action = ''; $action = '';
} }
// Mass delete // Mass delete
if (!empty($consts) && $action == 'delete') if (!empty($consts) && $action == 'delete') {
{
$nbdeleted = 0; $nbdeleted = 0;
foreach ($consts as $const) foreach ($consts as $const) {
{ if (!empty($const["check"])) { // Is checkbox checked
if (!empty($const["check"])) // Is checkbox checked if (dolibarr_del_const($db, $const["rowid"], -1) >= 0) {
{
if (dolibarr_del_const($db, $const["rowid"], -1) >= 0)
{
$nbdeleted++; $nbdeleted++;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
if ($nbdeleted > 0) setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); if ($nbdeleted > 0) {
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
$action = ''; $action = '';
} }
// Delete line from delete picto // Delete line from delete picto
if ($action == 'delete') if ($action == 'delete') {
{ if (dolibarr_del_const($db, $rowid, $entity) >= 0) {
if (dolibarr_del_const($db, $rowid, $entity) >= 0)
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -153,8 +149,7 @@ $wikihelp = 'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
llxHeader('', $langs->trans("Setup"), $wikihelp); llxHeader('', $langs->trans("Setup"), $wikihelp);
// Add logic to show/hide buttons // Add logic to show/hide buttons
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
?> ?>
<script type="text/javascript"> <script type="text/javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
@ -196,8 +191,7 @@ print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '
print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity) {
{
print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
} }
print getTitleFieldOfList("", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList("", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
@ -219,8 +213,7 @@ print '</td>';
print '<td>'; print '<td>';
print '</td>'; print '</td>';
// Limit to superadmin // Limit to superadmin
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity) {
{
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">'; print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
print '</td>'; print '</td>';
@ -245,20 +238,23 @@ $sql .= ", tms";
$sql .= ", entity"; $sql .= ", entity";
$sql .= " FROM ".MAIN_DB_PREFIX."const"; $sql .= " FROM ".MAIN_DB_PREFIX."const";
$sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; $sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
if ((empty($user->entity) || $user->admin) && $debug) {} // to force for superadmin to debug if ((empty($user->entity) || $user->admin) && $debug) {
elseif (!GETPOST('visible') || GETPOST('visible') != 'all') $sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits } elseif (!GETPOST('visible') || GETPOST('visible') != 'all') {
if (GETPOST('name')) $sql .= natural_search("name", GETPOST('name')); // to force for superadmin to debug
$sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits
}
if (GETPOST('name')) {
$sql .= natural_search("name", GETPOST('name'));
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
dol_syslog("Const::listConstant", LOG_DEBUG); dol_syslog("Const::listConstant", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print "\n"; print "\n";
@ -284,8 +280,7 @@ if ($result)
print '</td>'; print '</td>';
// Entity limit to superadmin // Entity limit to superadmin
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity) {
{
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="1" name="const['.$i.'][entity]" value="'.$obj->entity.'">'; print '<input type="text" class="flat" size="1" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
print '</td>'; print '</td>';
@ -295,8 +290,7 @@ if ($result)
print '<input type="hidden" name="const['.$i.'][entity]" value="'.$obj->entity.'">'; print '<input type="hidden" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
} }
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">'; print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
@ -313,8 +307,7 @@ if ($result)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print '<br>'; print '<br>';
print '<div id="updateconst" class="right">'; print '<div id="updateconst" class="right">';
print '<input type="submit" name="update" class="button marginbottomonly" value="'.$langs->trans("Modify").'">'; print '<input type="submit" name="update" class="button marginbottomonly" value="'.$langs->trans("Modify").'">';

View File

@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "errors", "contracts")); $langs->loadLangs(array("admin", "errors", "contracts"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -39,8 +41,7 @@ $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha');
$type = 'contract'; $type = 'contract';
if (empty($conf->global->CONTRACT_ADDON)) if (empty($conf->global->CONTRACT_ADDON)) {
{
$conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; $conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
} }
@ -51,22 +52,23 @@ if (empty($conf->global->CONTRACT_ADDON))
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconst = GETPOST('maskconstcontract', 'alpha'); $maskconst = GETPOST('maskconstcontract', 'alpha');
$maskvalue = GETPOST('maskcontract', 'alpha'); $maskvalue = GETPOST('maskcontract', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if ($maskconst) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') // For contract } elseif ($action == 'specimen') { // For contract
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$contract = new Contrat($db); $contract = new Contrat($db);
@ -75,25 +77,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($contract, $langs) > 0) if ($module->write_file($contract, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=contract&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=contract&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -104,26 +102,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->CONTRACT_ADDON_PDF == "$value") {
if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "CONTRACT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "CONTRACT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->CONTRACT_ADDON_PDF = $value; $conf->global->CONTRACT_ADDON_PDF = $value;
@ -131,18 +122,15 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "CONTRACT_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "CONTRACT_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_other') } elseif ($action == 'set_other') {
{
$freetext = GETPOST('CONTRACT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('CONTRACT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
@ -152,10 +140,11 @@ elseif ($action == 'setdoc')
$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha'); $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++; if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -197,19 +186,14 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/contract/"); $dir = dol_buildpath($reldir."core/modules/contract/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -217,11 +201,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db); $module = new $file($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -232,14 +219,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);
} else {
print $tmp;
} }
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->CONTRACT_ADDON == "$file") if ($conf->global->CONTRACT_ADDON == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -258,8 +246,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -294,12 +283,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -321,31 +308,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/contract".$valdir; $realpath = $reldir."core/modules/contract".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -353,21 +332,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -381,8 +365,7 @@ foreach ($dirmodels as $reldir)
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->CONTRACT_ADDON_PDF == $name) if ($conf->global->CONTRACT_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -392,8 +375,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -412,8 +394,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -452,15 +433,16 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
print '<br>'; print '<br>';
$variablename = 'CONTRACT_FREE_TEXT'; $variablename = 'CONTRACT_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -28,8 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "agenda")); $langs->loadLangs(array("admin", "other", "agenda"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Parameters // Parameters
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -71,8 +72,7 @@ $head = dav_admin_prepare_head();
print dol_get_fiche_head($head, 'webdav', '', -1, 'action'); print dol_get_fiche_head($head, 'webdav', '', -1, 'action');
if ($action == 'edit') if ($action == 'edit') {
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -80,9 +80,10 @@ if ($action == 'edit')
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val) foreach ($arrayofparameters as $key => $val) {
{ if (isset($val['enabled']) && empty($val['enabled'])) {
if (isset($val['enabled']) && empty($val['enabled'])) continue; continue;
}
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
@ -93,11 +94,9 @@ if ($action == 'edit')
} }
print $form->textwithpicto($label, $tooltiphelp); print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td>';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
{
print $langs->trans("AlwaysActive"); print $langs->trans("AlwaysActive");
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
{
print $form->selectyesno($key, $conf->global->$key, 1); print $form->selectyesno($key, $conf->global->$key, 1);
} else { } else {
print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">'; print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">';
@ -117,8 +116,7 @@ if ($action == 'edit')
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val) foreach ($arrayofparameters as $key => $val) {
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
$label = $langs->trans($key); $label = $langs->trans($key);
@ -128,11 +126,9 @@ if ($action == 'edit')
} }
print $form->textwithpicto($label, $tooltiphelp); print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td>';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
{
print $langs->trans("AlwaysActive"); print $langs->trans("AlwaysActive");
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
{
print yn($conf->global->$key); print yn($conf->global->$key);
} else { } else {
print $conf->global->$key; print $conf->global->$key;
@ -174,8 +170,7 @@ $message = '';
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>'; $url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', '{url}')); $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', '{url}'));
$message .= '<br>'; $message .= '<br>';
if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) {
{
$urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : ''); $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>'; $url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', '{url}')); $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', '{url}'));

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
global $conf; global $conf;
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other")); $langs->loadLangs(array("admin", "other"));
@ -43,19 +45,16 @@ $action = GETPOST('action', 'aZ09');
*/ */
// Set modes // Set modes
if ($action == 'set') if ($action == 'set') {
{
$db->begin(); $db->begin();
$result1 = dolibarr_set_const($db, "DEBUGBAR_LOGS_LINES_NUMBER", GETPOST('DEBUGBAR_LOGS_LINES_NUMBER', 'int'), 'chaine', 0, '', 0); $result1 = dolibarr_set_const($db, "DEBUGBAR_LOGS_LINES_NUMBER", GETPOST('DEBUGBAR_LOGS_LINES_NUMBER', 'int'), 'chaine', 0, '', 0);
$result2 = dolibarr_set_const($db, "DEBUGBAR_USE_LOG_FILE", GETPOST('DEBUGBAR_USE_LOG_FILE', 'int'), 'chaine', 0, '', 0); $result2 = dolibarr_set_const($db, "DEBUGBAR_USE_LOG_FILE", GETPOST('DEBUGBAR_USE_LOG_FILE', 'int'), 'chaine', 0, '', 0);
if ($result1 < 0 || $result2 < 0) if ($result1 < 0 || $result2 < 0) {
{
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -76,8 +75,7 @@ $form = new Form($db);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup');
if (!function_exists('mb_check_encoding')) if (!function_exists('mb_check_encoding')) {
{
$langs->load("errors"); $langs->load("errors");
print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error'); print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error');
} }

View File

@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors')); $langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$id = GETPOST('rowid', 'int'); $id = GETPOST('rowid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = 'page,param'; if (!$sortfield) {
if (!$sortorder) $sortorder = 'ASC'; $sortfield = 'page,param';
}
if (!$sortorder) {
$sortorder = 'ASC';
}
$defaulturl = GETPOST('defaulturl', 'alphanohtml'); $defaulturl = GETPOST('defaulturl', 'alphanohtml');
$defaultkey = GETPOST('defaultkey', 'alphanohtml'); $defaultkey = GETPOST('defaultkey', 'alphanohtml');
@ -71,18 +79,23 @@ $hookmanager->initHooks(array('admindefaultvalues', 'globaladmin'));
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
{
$defaulturl = ''; $defaulturl = '';
$defaultkey = ''; $defaultkey = '';
$defaultvalue = ''; $defaultvalue = '';
@ -90,60 +103,51 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_array_options = array(); $search_array_options = array();
} }
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') {
{ if (GETPOST('value')) {
if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity);
else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity); } else {
dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity);
}
} }
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) {
{
$error = 0; $error = 0;
if (($action == 'add' || (GETPOST('add') && $action != 'update'))) if (($action == 'add' || (GETPOST('add') && $action != 'update'))) {
{ if (empty($defaulturl)) {
if (empty($defaulturl))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
$error++; $error++;
} }
if (empty($defaultkey)) if (empty($defaultkey)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
$error++; $error++;
} }
} }
if (GETPOST('actionmodify')) if (GETPOST('actionmodify')) {
{ if (empty($urlpage)) {
if (empty($urlpage))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
$error++; $error++;
} }
if (empty($key)) if (empty($key)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
$error++; $error++;
} }
} }
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
if ($action == 'add' || (GETPOST('add') && $action != 'update')) if ($action == 'add' || (GETPOST('add') && $action != 'update')) {
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")";
} }
if (GETPOST('actionmodify')) if (GETPOST('actionmodify')) {
{
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
$sql .= " WHERE rowid = ".$id; $sql .= " WHERE rowid = ".$id;
} }
$result = $db->query($sql); $result = $db->query($sql);
if ($result > 0) if ($result > 0) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action = ""; $action = "";
@ -159,13 +163,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
} }
// Delete line from delete picto // Delete line from delete picto
if ($action == 'delete') if ($action == 'delete') {
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."default_values WHERE rowid = ".$db->escape($id); $sql = "DELETE FROM ".MAIN_DB_PREFIX."default_values WHERE rowid = ".$db->escape($id);
// Delete const // Delete const
$result = $db->query($sql); $result = $db->query($sql);
if ($result >= 0) if ($result >= 0) {
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -187,8 +189,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp);
$param = '&mode='.$mode; $param = '&mode='.$mode;
$enabledisablehtml = $langs->trans("EnableDefaultValues").' '; $enabledisablehtml = $langs->trans("EnableDefaultValues").' ';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
{
// Button off, click to enable // Button off, click to enable
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;token='.newToken().'&amp;value=1'.$param.'">'; $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;token='.newToken().'&amp;value=1'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
@ -205,16 +206,30 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl
print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n";
print "<br>\n"; print "<br>\n";
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); }
if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); $param .= '&limit='.urlencode($limit);
if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); }
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($defaulturl) {
$param .= '&defaulturl='.urlencode($defaulturl);
}
if ($defaultkey) {
$param .= '&defaultkey='.urlencode($defaultkey);
}
if ($defaultvalue) {
$param .= '&defaultvalue='.urlencode($defaultvalue);
}
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -226,12 +241,10 @@ $head = defaultvalues_prepare_head();
print dol_get_fiche_head($head, $mode, '', -1, ''); print dol_get_fiche_head($head, $mode, '', -1, '');
if ($mode == 'sortorder') if ($mode == 'sortorder') {
{
print info_admin($langs->trans("WarningSettingSortOrder")).'<br>'; print info_admin($langs->trans("WarningSettingSortOrder")).'<br>';
} }
if ($mode == 'mandatory') if ($mode == 'mandatory') {
{
print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'<br>'; print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'<br>';
} }
@ -244,15 +257,17 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
// Page // Page
$texthelp = $langs->trans("PageUrlForDefaultValues"); $texthelp = $langs->trans("PageUrlForDefaultValues");
if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); if ($mode == 'createform') {
else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
} else {
$texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
}
$texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate"); $texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
$texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp); $texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp);
print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder);
// Field // Field
$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField"); $texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
if ($mode != 'sortorder') if ($mode != 'sortorder') {
{
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
} else { } else {
$texthelp = 'field or alias.field'; $texthelp = 'field or alias.field';
@ -260,15 +275,12 @@ if ($mode != 'sortorder')
} }
print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory') {
{ if ($mode != 'sortorder') {
if ($mode != 'sortorder')
{
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST $substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
unset($substitutionarray['__USER_SIGNATURE__']); unset($substitutionarray['__USER_SIGNATURE__']);
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach ($substitutionarray as $key => $val) foreach ($substitutionarray as $key => $val) {
{
$texthelp .= $key.' -> '.$val.'<br>'; $texthelp .= $key.' -> '.$val.'<br>';
} }
$textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip'); $textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
@ -279,8 +291,11 @@ if ($mode != 'focus' && $mode != 'mandatory')
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
} }
// Entity // Entity
if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); if (!empty($conf->multicompany->enabled) && !$user->entity) {
else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
} else {
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
}
// Actions // Actions
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
@ -299,15 +314,13 @@ print '<td>';
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag(GETPOST('defaultkey', 'alphanohtml')).'">'; print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag(GETPOST('defaultkey', 'alphanohtml')).'">';
print '</td>'; print '</td>';
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory') {
{
print '<td>'; print '<td>';
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">'; print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">';
print '</td>'; print '</td>';
} }
// Limit to superadmin // Limit to superadmin
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity) {
{
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity
print '</td>'; print '</td>';
@ -318,7 +331,9 @@ if (!empty($conf->multicompany->enabled) && !$user->entity)
} }
print '<td class="center">'; print '<td class="center">';
$disabled = ''; $disabled = '';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"'; if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
$disabled = ' disabled="disabled"';
}
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">'; print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
print "</td>\n"; print "</td>\n";
print '</tr>'; print '</tr>';
@ -333,13 +348,11 @@ $sql .= $db->order($sortfield, $sortorder);
dol_syslog("translation::select from table", LOG_DEBUG); dol_syslog("translation::select from table", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print "\n"; print "\n";
@ -348,27 +361,35 @@ if ($result)
// Page // Page
print '<td>'; print '<td>';
if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page; if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) {
else print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">'; print $obj->page;
} else {
print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">';
}
print '</td>'."\n"; print '</td>'."\n";
// Field // Field
print '<td>'; print '<td>';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
else print '<input type="text" name="key" value="'.dol_escape_htmltag($obj->param).'">'; print $obj->param;
} else {
print '<input type="text" name="key" value="'.dol_escape_htmltag($obj->param).'">';
}
print '</td>'."\n"; print '</td>'."\n";
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory') {
{
print '<td>'; print '<td>';
/*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">'; /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">'; print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">'; print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">'; print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
*/ */
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value); if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">'; print dol_escape_htmltag($obj->value);
} else {
print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">';
}
print '</td>'; print '</td>';
} }
@ -376,8 +397,7 @@ if ($result)
// Actions // Actions
print '<td class="center">'; print '<td class="center">';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
{
print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>'; print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>'; print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
} else { } else {

View File

@ -30,10 +30,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
if (empty($action)) $action = 'edit'; if (empty($action)) {
$action = 'edit';
}
// Define list of managed delays // Define list of managed delays
$modules = array( $modules = array(
@ -166,16 +170,11 @@ if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
* Actions * Actions
*/ */
if ($action == 'update') if ($action == 'update') {
{ foreach ($modules as $module => $delays) {
foreach ($modules as $module => $delays) if (!empty($conf->$module->enabled)) {
{ foreach ($delays as $delay) {
if (!empty($conf->$module->enabled)) if (GETPOST($delay['code']) != '') {
{
foreach ($delays as $delay)
{
if (GETPOST($delay['code']) != '')
{
dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
} }
} }
@ -187,10 +186,14 @@ if ($action == 'update')
// For update value with percentage // For update value with percentage
$plus = ''; $plus = '';
if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
$plus = '_PERCENTAGE';
}
// Update values // Update values
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
}
} }
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -213,8 +216,7 @@ print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceD
print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n"; print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
print "<br>\n"; print "<br>\n";
if ($action == 'edit') if ($action == 'edit') {
{
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -222,12 +224,9 @@ if ($action == 'edit')
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
foreach ($modules as $module => $delays) foreach ($modules as $module => $delays) {
{ if (!empty($conf->$module->enabled)) {
if (!empty($conf->$module->enabled)) foreach ($delays as $delay) {
{
foreach ($delays as $delay)
{
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>'; print '<td width="20px">'.img_object('', $delay['img']).'</td>';
@ -259,12 +258,9 @@ if ($action == 'edit')
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
foreach ($modules as $module => $delays) foreach ($modules as $module => $delays) {
{ if (!empty($conf->$module->enabled)) {
if (!empty($conf->$module->enabled)) foreach ($delays as $delay) {
{
foreach ($delays as $delay)
{
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>'; print '<td width="20px">'.img_object('', $delay['img']).'</td>';
@ -300,15 +296,21 @@ if ($conf->global->MAIN_DISABLE_METEO != 1) {
if ($action == 'edit') { if ($action == 'edit') {
$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
else $str_mode_enabled = $str_mode_percentage; $str_mode_enabled = $str_mode_std;
} else {
$str_mode_enabled = $str_mode_percentage;
}
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>'; print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />'; print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
print '<br><br>'; print '<br><br>';
} else { } else {
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
else print $langs->trans('MeteoPercentageModEnabled'); print $langs->trans('MeteoStdModEnabled');
} else {
print $langs->trans('MeteoPercentageModEnabled');
}
print '<br><br>'; print '<br><br>';
} }
@ -316,10 +318,18 @@ if ($conf->global->MAIN_DISABLE_METEO != 1) {
$cursor = 10; // By default $cursor = 10; // By default
//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
//if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP; //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
$level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0; $level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) {
$level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1; $level0 = $conf->global->MAIN_METEO_LEVEL0;
$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2; }
$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3; $level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) {
$level1 = $conf->global->MAIN_METEO_LEVEL1;
}
$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) {
$level2 = $conf->global->MAIN_METEO_LEVEL2;
}
$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) {
$level3 = $conf->global->MAIN_METEO_LEVEL3;
}
$text = ''; $options = 'class="valignmiddle" height="60px"'; $text = ''; $options = 'class="valignmiddle" height="60px"';

View File

@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); $langs->loadLangs(array("admin", "sendings", "deliveries", "other"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -52,39 +54,40 @@ $type = 'delivery';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha');
$maskdelivery = GETPOST('maskdelivery', 'alpha'); $maskdelivery = GETPOST('maskdelivery', 'alpha');
if ($maskconstdelivery) $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); if ($maskconstdelivery) {
$res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'set_DELIVERY_FREE_TEXT') if ($action == 'set_DELIVERY_FREE_TEXT') {
{
$free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'specimen') if ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$sending = new Delivery($db); $sending = new Delivery($db);
@ -93,25 +96,21 @@ if ($action == 'specimen')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($sending, $langs) > 0) if ($module->write_file($sending, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -124,24 +123,21 @@ if ($action == 'specimen')
} }
} }
if ($action == 'set') if ($action == 'set') {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
if ($action == 'del') if ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->DELIVERY_ADDON_PDF == "$value") {
if ($conf->global->DELIVERY_ADDON_PDF == "$value") dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity);
}
} }
} }
if ($action == 'setdoc') if ($action == 'setdoc') {
{ if (dolibarr_set_const($db, "DELIVERY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
if (dolibarr_set_const($db, "DELIVERY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->DELIVERY_ADDON_PDF = $value; $conf->global->DELIVERY_ADDON_PDF = $value;
@ -149,14 +145,12 @@ if ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }
if ($action == 'setmod') if ($action == 'setmod') {
{
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
@ -197,17 +191,13 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/delivery/"); $dir = dol_buildpath($reldir."core/modules/delivery/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) { if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
@ -215,11 +205,14 @@ foreach ($dirmodels as $reldir)
$module = new $file; $module = new $file;
if ($module->isEnabled()) if ($module->isEnabled()) {
{
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
@ -231,13 +224,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -254,8 +249,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -294,12 +290,10 @@ $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -320,28 +314,21 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/delivery/doc/"); $dir = dol_buildpath($reldir."core/modules/delivery/doc/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -349,21 +336,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -377,8 +369,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->DELIVERY_ADDON_PDF == "$name") if ($conf->global->DELIVERY_ADDON_PDF == "$name") {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -396,8 +387,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -430,7 +420,9 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -439,8 +431,7 @@ print '<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'DELIVERY_FREE_TEXT'; $variablename = 'DELIVERY_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries')); $langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries'));
@ -45,13 +46,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'delivery'; //Must be the $table_element of the class that manage extrafield $elementtype = 'delivery'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -84,8 +89,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -98,8 +102,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -111,8 +114,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'sendings')); $langs->loadLangs(array('admin', 'other', 'sendings'));
@ -46,13 +47,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'deliverydet'; //Must be the $table_element of the class that manage extrafield $elementtype = 'deliverydet'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -85,8 +90,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -99,8 +103,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -112,8 +115,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,9 @@
* or see https://www.gnu.org/ * or see https://www.gnu.org/
*/ */
if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1); if (!defined('REQUIRE_JQUERY_BLOCKUI')) {
define('REQUIRE_JQUERY_BLOCKUI', 1);
}
if (!defined('NOTOKENRENEWAL')) { if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); define('NOTOKENRENEWAL', 1);
} }
@ -47,7 +49,8 @@ try {
$url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality; $url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
$api = new PrestaShopWebservice( $api = new PrestaShopWebservice(
$conf->global->MAIN_MODULE_DOLISTORE_API_SRV, $conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
$conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api $conf->global->MAIN_MODULE_DOLISTORE_API_KEY,
$dolistore->debug_api
); );
//echo $url; //echo $url;
$request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); $request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
@ -56,7 +59,11 @@ try {
} catch (PrestaShopWebserviceException $e) { } catch (PrestaShopWebserviceException $e) {
// Here we are dealing with errors // Here we are dealing with errors
$trace = $e->getTrace(); $trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) die('Bad ID'); if ($trace[0]['args'][0] == 404) {
elseif ($trace[0]['args'][0] == 401) die('Bad auth key'); die('Bad ID');
else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); } elseif ($trace[0]['args'][0] == 401) {
die('Bad auth key');
} else {
die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
}
} }

View File

@ -71,8 +71,9 @@ class PrestaShopWebservice
*/ */
public function __construct($url, $key, $debug = true) public function __construct($url, $key, $debug = true)
{ {
if (!extension_loaded('curl')) if (!extension_loaded('curl')) {
throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library');
}
$this->url = $url; $this->url = $url;
$this->key = $key; $this->key = $key;
$this->debug = $debug; $this->debug = $debug;
@ -88,8 +89,7 @@ class PrestaShopWebservice
protected function checkStatusCode($status_code) protected function checkStatusCode($status_code)
{ {
$error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.'; $error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.';
switch ($status_code) switch ($status_code) {
{
case 200: case 200:
case 201: case 201:
break; break;
@ -132,25 +132,27 @@ class PrestaShopWebservice
$session = curl_init($url); $session = curl_init($url);
$curl_options = array(); $curl_options = array();
foreach ($defaultParams as $defkey => $defval) foreach ($defaultParams as $defkey => $defval) {
{ if (isset($curl_params[$defkey])) {
if (isset($curl_params[$defkey]))
$curl_options[$defkey] = $curl_params[$defkey]; $curl_options[$defkey] = $curl_params[$defkey];
else { } else {
$curl_options[$defkey] = $defaultParams[$defkey]; $curl_options[$defkey] = $defaultParams[$defkey];
} }
} }
foreach ($curl_params as $defkey => $defval) foreach ($curl_params as $defkey => $defval) {
if (!isset($curl_options[$defkey])) if (!isset($curl_options[$defkey])) {
$curl_options[$defkey] = $curl_params[$defkey]; $curl_options[$defkey] = $curl_params[$defkey];
}
}
dol_syslog("curl curl_options = ".var_export($curl_options, true)); dol_syslog("curl curl_options = ".var_export($curl_options, true));
curl_setopt_array($session, $curl_options); curl_setopt_array($session, $curl_options);
$response = curl_exec($session); $response = curl_exec($session);
$index = strpos($response, "\r\n\r\n"); $index = strpos($response, "\r\n\r\n");
if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') {
throw new PrestaShopWebserviceException('Bad HTTP response'); throw new PrestaShopWebserviceException('Bad HTTP response');
}
$header = substr($response, 0, $index); $header = substr($response, 0, $index);
$body = substr($response, $index + 4); $body = substr($response, $index + 4);
@ -158,40 +160,40 @@ class PrestaShopWebservice
$headerArrayTmp = explode("\n", $header); $headerArrayTmp = explode("\n", $header);
$headerArray = array(); $headerArray = array();
foreach ($headerArrayTmp as &$headerItem) foreach ($headerArrayTmp as &$headerItem) {
{
$tmp = explode(':', $headerItem); $tmp = explode(':', $headerItem);
$tmp = array_map('trim', $tmp); $tmp = array_map('trim', $tmp);
if (count($tmp) == 2) if (count($tmp) == 2) {
$headerArray[$tmp[0]] = $tmp[1]; $headerArray[$tmp[0]] = $tmp[1];
} }
if (array_key_exists('PSWS-Version', $headerArray))
{
$this->version = $headerArray['PSWS-Version'];
if (
version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 ||
version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1
)
throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library');
} }
if ($this->debug) if (array_key_exists('PSWS-Version', $headerArray)) {
{ $this->version = $headerArray['PSWS-Version'];
if (version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 ||
version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1
) {
throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library');
}
}
if ($this->debug) {
$this->printDebug('HTTP REQUEST HEADER', curl_getinfo($session, CURLINFO_HEADER_OUT)); $this->printDebug('HTTP REQUEST HEADER', curl_getinfo($session, CURLINFO_HEADER_OUT));
$this->printDebug('HTTP RESPONSE HEADER', $header); $this->printDebug('HTTP RESPONSE HEADER', $header);
} }
$status_code = curl_getinfo($session, CURLINFO_HTTP_CODE); $status_code = curl_getinfo($session, CURLINFO_HTTP_CODE);
if ($status_code === 0) if ($status_code === 0) {
throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session)); throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session));
}
curl_close($session); curl_close($session);
if ($this->debug) if ($this->debug) {
{ if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST') {
if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST')
$this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS])); $this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS]));
if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') }
if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') {
$this->printDebug('RETURN HTTP BODY', $body); $this->printDebug('RETURN HTTP BODY', $body);
} }
}
return array('status_code' => $status_code, 'response' => $body, 'header' => $header); return array('status_code' => $status_code, 'response' => $body, 'header' => $header);
} }
@ -227,13 +229,11 @@ class PrestaShopWebservice
*/ */
protected function parseXML($response) protected function parseXML($response)
{ {
if ($response != '') if ($response != '') {
{
libxml_clear_errors(); libxml_clear_errors();
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA); $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
if (libxml_get_errors()) if (libxml_get_errors()) {
{
$msg = var_export(libxml_get_errors(), true); $msg = var_export(libxml_get_errors(), true);
libxml_clear_errors(); libxml_clear_errors();
throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg); throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg);
@ -261,14 +261,15 @@ class PrestaShopWebservice
$xml = ''; $xml = '';
$url = ''; $url = '';
if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) {
{
$url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']); $url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']);
$xml = $options['postXml']; $xml = $options['postXml'];
if (isset($options['id_shop'])) if (isset($options['id_shop'])) {
$url .= '&id_shop='.$options['id_shop']; $url .= '&id_shop='.$options['id_shop'];
if (isset($options['id_group_shop'])) }
if (isset($options['id_group_shop'])) {
$url .= '&id_group_shop='.$options['id_group_shop']; $url .= '&id_group_shop='.$options['id_group_shop'];
}
} else { } else {
throw new PrestaShopWebserviceException('Bad parameters given'); throw new PrestaShopWebserviceException('Bad parameters given');
} }
@ -310,24 +311,28 @@ class PrestaShopWebservice
*/ */
public function get($options) public function get($options)
{ {
if (isset($options['url'])) if (isset($options['url'])) {
$url = $options['url']; $url = $options['url'];
elseif (isset($options['resource'])) } elseif (isset($options['resource'])) {
{
$url = $this->url.'/api/'.$options['resource']; $url = $this->url.'/api/'.$options['resource'];
$url_params = array(); $url_params = array();
if (isset($options['id'])) if (isset($options['id'])) {
$url .= '/'.$options['id']; $url .= '/'.$options['id'];
}
// @CHANGE LDR // @CHANGE LDR
//$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop'); //$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop');
$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'date'); $params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'date');
foreach ($params as $p) foreach ($params as $p) {
foreach ($options as $k => $o) foreach ($options as $k => $o) {
if (strpos($k, $p) !== false) if (strpos($k, $p) !== false) {
$url_params[$k] = $options[$k]; $url_params[$k] = $options[$k];
if (count($url_params) > 0) }
}
}
if (count($url_params) > 0) {
$url .= '?'.http_build_query($url_params); $url .= '?'.http_build_query($url_params);
}
} else { } else {
throw new PrestaShopWebserviceException('Bad parameters given '); throw new PrestaShopWebserviceException('Bad parameters given ');
} }
@ -347,22 +352,26 @@ class PrestaShopWebservice
*/ */
public function head($options) public function head($options)
{ {
if (isset($options['url'])) if (isset($options['url'])) {
$url = $options['url']; $url = $options['url'];
elseif (isset($options['resource'])) } elseif (isset($options['resource'])) {
{
$url = $this->url.'/api/'.$options['resource']; $url = $this->url.'/api/'.$options['resource'];
$url_params = array(); $url_params = array();
if (isset($options['id'])) if (isset($options['id'])) {
$url .= '/'.$options['id']; $url .= '/'.$options['id'];
}
$params = array('filter', 'display', 'sort', 'limit'); $params = array('filter', 'display', 'sort', 'limit');
foreach ($params as $p) foreach ($params as $p) {
foreach ($options as $k => $o) foreach ($options as $k => $o) {
if (strpos($k, $p) !== false) if (strpos($k, $p) !== false) {
$url_params[$k] = $options[$k]; $url_params[$k] = $options[$k];
if (count($url_params) > 0) }
}
}
if (count($url_params) > 0) {
$url .= '?'.http_build_query($url_params); $url .= '?'.http_build_query($url_params);
}
} else { } else {
throw new PrestaShopWebserviceException('Bad parameters given'); throw new PrestaShopWebserviceException('Bad parameters given');
} }
@ -386,16 +395,17 @@ class PrestaShopWebservice
public function edit($options) public function edit($options)
{ {
$xml = ''; $xml = '';
if (isset($options['url'])) if (isset($options['url'])) {
$url = $options['url']; $url = $options['url'];
elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) } elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) {
{
$url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']); $url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']);
$xml = $options['putXml']; $xml = $options['putXml'];
if (isset($options['id_shop'])) if (isset($options['id_shop'])) {
$url .= '&id_shop='.$options['id_shop']; $url .= '&id_shop='.$options['id_shop'];
if (isset($options['id_group_shop'])) }
if (isset($options['id_group_shop'])) {
$url .= '&id_group_shop='.$options['id_group_shop']; $url .= '&id_group_shop='.$options['id_group_shop'];
}
} else { } else {
throw new PrestaShopWebserviceException('Bad parameters given'); throw new PrestaShopWebserviceException('Bad parameters given');
} }

View File

@ -17,8 +17,7 @@
*/ */
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
if (!class_exists('PrestaShopWebservice')) // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors. if (!class_exists('PrestaShopWebservice')) { // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors.
{
include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php'; include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php';
} }
@ -67,7 +66,9 @@ class Dolistore
$langtmp = explode('_', $langs->defaultlang); $langtmp = explode('_', $langs->defaultlang);
$lang = $langtmp[0]; $lang = $langtmp[0];
$lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1 $lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1
if (!in_array($lang, array_keys($lang_array))) $lang = 'en'; if (!in_array($lang, array_keys($lang_array))) {
$lang = 'en';
}
$this->lang = $lang_array[$lang]; $this->lang = $lang_array[$lang];
} }
@ -99,9 +100,11 @@ class Dolistore
} catch (PrestaShopWebserviceException $e) { } catch (PrestaShopWebserviceException $e) {
// Here we are dealing with errors // Here we are dealing with errors
$trace = $e->getTrace(); $trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) die('Bad ID'); if ($trace[0]['args'][0] == 404) {
elseif ($trace[0]['args'][0] == 401) die('Bad auth key'); die('Bad ID');
else { } elseif ($trace[0]['args'][0] == 401) {
die('Bad auth key');
} else {
print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'<br>'; print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'<br>';
print $e->getMessage(); print $e->getMessage();
} }
@ -180,9 +183,11 @@ class Dolistore
} catch (PrestaShopWebserviceException $e) { } catch (PrestaShopWebserviceException $e) {
// Here we are dealing with errors // Here we are dealing with errors
$trace = $e->getTrace(); $trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) die('Bad ID'); if ($trace[0]['args'][0] == 404) {
elseif ($trace[0]['args'][0] == 401) die('Bad auth key'); die('Bad ID');
else { } elseif ($trace[0]['args'][0] == 401) {
die('Bad auth key');
} else {
print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'<br>'; print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'<br>';
print $e->getMessage(); print $e->getMessage();
} }
@ -199,7 +204,9 @@ class Dolistore
public function get_categories($parent = 0) public function get_categories($parent = 0)
{ {
// phpcs:enable // phpcs:enable
if (!isset($this->categories)) die('not possible'); if (!isset($this->categories)) {
die('not possible');
}
if ($parent != 0) { if ($parent != 0) {
$html = '<ul>'; $html = '<ul>';
} else { } else {
@ -207,8 +214,7 @@ class Dolistore
} }
$nbofcateg = count($this->categories); $nbofcateg = count($this->categories);
for ($i = 0; $i < $nbofcateg; $i++) for ($i = 0; $i < $nbofcateg; $i++) {
{
$cat = $this->categories[$i]; $cat = $this->categories[$i];
if ($cat->is_root_category == 1 && $parent == 0) { if ($cat->is_root_category == 1 && $parent == 0) {
$html .= '<li class="root"><h3 class="nomargesupinf"><a class="nomargesupinf link2cat" href="?mode=marketplace&categorie='.$cat->id.'" '; $html .= '<li class="root"><h3 class="nomargesupinf"><a class="nomargesupinf link2cat" href="?mode=marketplace&categorie='.$cat->id.'" ';
@ -282,19 +288,31 @@ class Dolistore
if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) { if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) {
if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) { if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) {
//compatible //compatible
$version = '<span class="compatible">'.$langs->trans('CompatibleUpTo', $product->dolibarr_max, $version = '<span class="compatible">'.$langs->trans(
$product->dolibarr_min, $product->dolibarr_max).'</span>'; 'CompatibleUpTo',
$product->dolibarr_max,
$product->dolibarr_min,
$product->dolibarr_max
).'</span>';
$compatible = ''; $compatible = '';
} else { } else {
//never compatible, module expired //never compatible, module expired
$version = '<span class="notcompatible">'.$langs->trans('NotCompatible', DOL_VERSION, $version = '<span class="notcompatible">'.$langs->trans(
$product->dolibarr_min, $product->dolibarr_max).'</span>'; 'NotCompatible',
DOL_VERSION,
$product->dolibarr_min,
$product->dolibarr_max
).'</span>';
$compatible = 'NotCompatible'; $compatible = 'NotCompatible';
} }
} else { } else {
//need update //need update
$version = '<span class="compatibleafterupdate">'.$langs->trans('CompatibleAfterUpdate', DOL_VERSION, $version = '<span class="compatibleafterupdate">'.$langs->trans(
$product->dolibarr_min, $product->dolibarr_max).'</span>'; 'CompatibleAfterUpdate',
DOL_VERSION,
$product->dolibarr_min,
$product->dolibarr_max
).'</span>';
$compatible = 'NotCompatible'; $compatible = 'NotCompatible';
} }

View File

@ -29,17 +29,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
* Action * Action
*/ */
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -47,11 +47,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
} }
} }
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -91,15 +89,12 @@ print '<td>'.$langs->trans("ECMAutoTree").'</td>';
print '<td class="center" width="20">&nbsp;</td>'; print '<td class="center" width="20">&nbsp;</td>';
print '<td class="center" width="100">'; print '<td class="center" width="100">';
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print ajax_constantonoff('ECM_AUTO_TREE_ENABLED'); print ajax_constantonoff('ECM_AUTO_TREE_ENABLED');
} else { } else {
if (empty($conf->global->ECM_AUTO_TREE_ENABLED)) if (empty($conf->global->ECM_AUTO_TREE_ENABLED)) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ECM_AUTO_TREE_ENABLED&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ECM_AUTO_TREE_ENABLED&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} elseif (!empty($conf->global->USER_MAIL_REQUIRED)) } elseif (!empty($conf->global->USER_MAIL_REQUIRED)) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ECM_AUTO_TREE_ENABLED&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ECM_AUTO_TREE_ENABLED&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
} }
} }

View File

@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'ecm')); $langs->loadLangs(array('admin', 'other', 'ecm'));

View File

@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'ecm')); $langs->loadLangs(array('admin', 'other', 'ecm'));

View File

@ -33,8 +33,12 @@ include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectorfilter.class
include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php'; include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php';
include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php'; include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php';
if (!$user->admin) accessforbidden(); if (!$user->admin) {
if (empty($conf->emailcollector->enabled)) accessforbidden(); accessforbidden();
}
if (empty($conf->emailcollector->enabled)) {
accessforbidden();
}
// Load traductions files required by page // Load traductions files required by page
$langs->loadLangs(array("admin", "mails", "other")); $langs->loadLangs(array("admin", "mails", "other"));
@ -65,11 +69,17 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
$search_all = GETPOST("search_all", 'alpha'); $search_all = GETPOST("search_all", 'alpha');
$search = array(); $search = array();
foreach ($object->fields as $key => $val) { foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); if (GETPOST('search_'.$key, 'alpha')) {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
} }
if (GETPOST('saveoperation2')) $action = 'updateoperation'; if (GETPOST('saveoperation2')) {
if (empty($action) && empty($id) && empty($ref)) $action = 'view'; $action = 'updateoperation';
}
if (empty($action) && empty($id) && empty($ref)) {
$action = 'view';
}
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
@ -93,15 +103,18 @@ $debuginfo = '';
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
$error = 0; $error = 0;
$permissiontoadd = 1; $permissiontoadd = 1;
$permissiontodelete = 1; $permissiontodelete = 1;
if (empty($backtopage)) $backtopage = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.($id > 0 ? $id : '__ID__'); if (empty($backtopage)) {
$backtopage = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.($id > 0 ? $id : '__ID__');
}
$backurlforlist = DOL_URL_ROOT.'/admin/emailcollector_list.php'; $backurlforlist = DOL_URL_ROOT.'/admin/emailcollector_list.php';
// Actions cancel, add, update, delete or clone // Actions cancel, add, update, delete or clone
@ -114,8 +127,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
} }
if (GETPOST('addfilter', 'alpha')) if (GETPOST('addfilter', 'alpha')) {
{
$emailcollectorfilter = new EmailCollectorFilter($db); $emailcollectorfilter = new EmailCollectorFilter($db);
$emailcollectorfilter->type = GETPOST('filtertype', 'aZ09'); $emailcollectorfilter->type = GETPOST('filtertype', 'aZ09');
$emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha'); $emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha');
@ -123,16 +135,14 @@ if (GETPOST('addfilter', 'alpha'))
$emailcollectorfilter->status = 1; $emailcollectorfilter->status = 1;
$result = $emailcollectorfilter->create($user); $result = $emailcollectorfilter->create($user);
if ($result > 0) if ($result > 0) {
{
$object->fetchFilters(); $object->fetchFilters();
} else { } else {
setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors'); setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors');
} }
} }
if ($action == 'deletefilter') if ($action == 'deletefilter') {
{
$emailcollectorfilter = new EmailCollectorFilter($db); $emailcollectorfilter = new EmailCollectorFilter($db);
$emailcollectorfilter->fetch(GETPOST('filterid', 'int')); $emailcollectorfilter->fetch(GETPOST('filterid', 'int'));
if ($emailcollectorfilter->id > 0) { if ($emailcollectorfilter->id > 0) {
@ -145,8 +155,7 @@ if ($action == 'deletefilter')
} }
} }
if (GETPOST('addoperation', 'alpha')) if (GETPOST('addoperation', 'alpha')) {
{
$emailcollectoroperation = new EmailCollectorAction($db); $emailcollectoroperation = new EmailCollectorAction($db);
$emailcollectoroperation->type = GETPOST('operationtype', 'aZ09'); $emailcollectoroperation->type = GETPOST('operationtype', 'aZ09');
$emailcollectoroperation->actionparam = GETPOST('operationparam', 'restricthtml'); $emailcollectoroperation->actionparam = GETPOST('operationparam', 'restricthtml');
@ -177,8 +186,7 @@ if (GETPOST('addoperation', 'alpha'))
} }
} }
if ($action == 'updateoperation') if ($action == 'updateoperation') {
{
$emailcollectoroperation = new EmailCollectorAction($db); $emailcollectoroperation = new EmailCollectorAction($db);
$emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int')); $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
@ -193,8 +201,7 @@ if ($action == 'updateoperation')
if (!$error) { if (!$error) {
$result = $emailcollectoroperation->update($user); $result = $emailcollectoroperation->update($user);
if ($result > 0) if ($result > 0) {
{
$object->fetchActions(); $object->fetchActions();
} else { } else {
$error++; $error++;
@ -202,8 +209,7 @@ if ($action == 'updateoperation')
} }
} }
} }
if ($action == 'deleteoperation') if ($action == 'deleteoperation') {
{
$emailcollectoroperation = new EmailCollectorAction($db); $emailcollectoroperation = new EmailCollectorAction($db);
$emailcollectoroperation->fetch(GETPOST('operationid', 'int')); $emailcollectoroperation->fetch(GETPOST('operationid', 'int'));
if ($emailcollectoroperation->id > 0) { if ($emailcollectoroperation->id > 0) {
@ -216,13 +222,11 @@ if ($action == 'deleteoperation')
} }
} }
if ($action == 'confirm_collect') if ($action == 'confirm_collect') {
{
dol_include_once('/emailcollector/class/emailcollector.class.php'); dol_include_once('/emailcollector/class/emailcollector.class.php');
$res = $object->doCollectOneCollector(); $res = $object->doCollectOneCollector();
if ($res > 0) if ($res > 0) {
{
$debuginfo = $object->debuginfo; $debuginfo = $object->debuginfo;
setEventMessages($object->lastresult, null, 'mesgs'); setEventMessages($object->lastresult, null, 'mesgs');
} else { } else {
@ -282,8 +286,7 @@ if ($action == 'create') {
} }
// Part to edit record // Part to edit record
if (($id || $ref) && $action == 'edit') if (($id || $ref) && $action == 'edit') {
{
print load_fiche_titre($langs->trans("EmailCollector")); print load_fiche_titre($langs->trans("EmailCollector"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -314,8 +317,7 @@ if (($id || $ref) && $action == 'edit')
} }
// Part to show record // Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
{
$res = $object->fetch_optionals(); $res = $object->fetch_optionals();
$object->fetchFilters(); $object->fetchFilters();
@ -327,8 +329,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = ''; $formconfirm = '';
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') if ($action == 'delete') {
{
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEmailCollector'), $langs->trans('ConfirmDeleteEmailCollector'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEmailCollector'), $langs->trans('ConfirmDeleteEmailCollector'), 'confirm_delete', '', 0, 1);
} }
@ -350,8 +351,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Call Hook formConfirm // Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; if (empty($reshook)) {
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; $formconfirm .= $hookmanager->resPrint;
} elseif ($reshook > 0) {
$formconfirm = $hookmanager->resPrint;
}
// Print form confirm // Print form confirm
print $formconfirm; print $formconfirm;
@ -414,8 +418,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$connectstringsource = ''; $connectstringsource = '';
$connectstringtarget = ''; $connectstringtarget = '';
if (function_exists('imap_open')) if (function_exists('imap_open')) {
{
// Note: $object->host has been loaded by the fetch // Note: $object->host has been loaded by the fetch
$usessl = 1; $usessl = 1;
@ -432,8 +435,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
$connection = imap_open($connectstringsource, $object->login, $object->password); $connection = imap_open($connectstringsource, $object->login, $object->password);
} catch (Exception $e) } catch (Exception $e) {
{
print $e->getMessage(); print $e->getMessage();
} }
@ -442,8 +444,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtml .= 'IMAP functions not available on your PHP. '; $morehtml .= 'IMAP functions not available on your PHP. ';
} }
if (!$connection) if (!$connection) {
{
$morehtml .= 'Failed to open IMAP connection '.$connectstringsource; $morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
if (function_exists('imap_last_error')) { if (function_exists('imap_last_error')) {
$morehtml .= '<br>'.imap_last_error(); $morehtml .= '<br>'.imap_last_error();
@ -453,8 +454,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtml .= imap_num_msg($connection); $morehtml .= imap_num_msg($connection);
} }
if ($connection) if ($connection) {
{
imap_close($connection); imap_close($connection);
} }
@ -545,8 +545,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button" value="'.$langs->trans("Add").'"></td>'; print '<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button" value="'.$langs->trans("Add").'"></td>';
print '</tr>'; print '</tr>';
// List filters // List filters
foreach ($object->filters as $rulefilter) foreach ($object->filters as $rulefilter) {
{
$rulefilterobj = new EmailCollectorFilter($db); $rulefilterobj = new EmailCollectorFilter($db);
$rulefilterobj->fetch($rulefilter['id']); $rulefilterobj->fetch($rulefilter['id']);
@ -580,9 +579,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
'recordevent'=>'RecordEvent'); 'recordevent'=>'RecordEvent');
if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; if ($conf->projet->enabled) {
if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature'; }
if ($conf->ticket->enabled) {
$arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
}
if ($conf->recruitment->enabled) {
$arrayoftypes['candidature'] = 'CreateCandidature';
}
// support hook for add action // support hook for add action
$parameters = array('arrayoftypes' => $arrayoftypes); $parameters = array('arrayoftypes' => $arrayoftypes);
@ -591,7 +596,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($res) { if ($res) {
$arrayoftypes = $hookmanager->resArray; $arrayoftypes = $hookmanager->resArray;
} else { } else {
foreach ($hookmanager->resArray as $k=>$desc) { foreach ($hookmanager->resArray as $k => $desc) {
$arrayoftypes[$k] = $desc; $arrayoftypes[$k] = $desc;
} }
} }
@ -611,8 +616,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$table_element_line = 'emailcollector_emailcollectoraction'; $table_element_line = 'emailcollector_emailcollectoraction';
$fk_element = 'position'; $fk_element = 'position';
$i = 0; $i = 0;
foreach ($object->actions as $ruleaction) foreach ($object->actions as $ruleaction) {
{
$ruleactionobj = new EmailcollectorAction($db); $ruleactionobj = new EmailcollectorAction($db);
$ruleactionobj->fetch($ruleaction['id']); $ruleactionobj->fetch($ruleaction['id']);
@ -620,16 +624,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'; print '<td>';
print '<!-- type of action: '.$ruleaction['type'].' -->'; print '<!-- type of action: '.$ruleaction['type'].' -->';
print $langs->trans($arrayoftypes[$ruleaction['type']]); print $langs->trans($arrayoftypes[$ruleaction['type']]);
if (in_array($ruleaction['type'], array('recordevent'))) if (in_array($ruleaction['type'], array('recordevent'))) {
{
print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
} elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) { } elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) {
print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp')); print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
} }
print '</td>'; print '</td>';
print '<td class="wordbreak">'; print '<td class="wordbreak">';
if ($action == 'editoperation' && $ruleaction['id'] == $operationid) if ($action == 'editoperation' && $ruleaction['id'] == $operationid) {
{
print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>'; print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>'; print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
print '<input type="submit" class="button button-save" name="saveoperation2" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button button-save" name="saveoperation2" value="'.$langs->trans("Save").'">';
@ -640,8 +642,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</td>'; print '</td>';
// Move up/down // Move up/down
print '<td class="center linecolmove tdlineupdown">'; print '<td class="center linecolmove tdlineupdown">';
if ($i > 0) if ($i > 0) {
{
print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=up&amp;rowid='.$ruleaction['id'].'">'.img_up('default', 0, 'imgupforline').'</a>'; print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=up&amp;rowid='.$ruleaction['id'].'">'.img_up('default', 0, 'imgupforline').'</a>';
} }
if ($i < count($object->actions) - 1) { if ($i < count($object->actions) - 1) {
@ -681,10 +682,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Edit // Edit
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Edit").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Edit").'</a></div>';
@ -703,8 +705,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</div>'."\n"; print '</div>'."\n";
} }
if (!empty($debuginfo)) if (!empty($debuginfo)) {
{
print info_admin($debuginfo); print info_admin($debuginfo);
} }
} }

View File

@ -51,7 +51,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -70,13 +72,16 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST) // Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. if (!$sortfield) {
if (!$sortorder) $sortorder = "ASC"; $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) // Protection if external user if ($user->socid > 0) { // Protection if external user
{
//$socid = $user->socid; //$socid = $user->socid;
accessforbidden(); accessforbidden();
} }
@ -85,22 +90,23 @@ if ($user->socid > 0) // Protection if external user
// Initialize array of search criterias // Initialize array of search criterias
$search_all = GETPOST("search_all", 'alphanohtml'); $search_all = GETPOST("search_all", 'alphanohtml');
$search = array(); $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if (GETPOST('search_'.$key, 'alpha') !== '') {
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); $search[$key] = GETPOST('search_'.$key, 'alpha');
}
} }
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array(); $fieldstosearchall = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if ($val['searchall']) {
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; $fieldstosearchall['t.'.$key] = $val['label'];
}
} }
// Definition of array of fields for columns // Definition of array of fields for columns
$arrayfields = array(); $arrayfields = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
// If $val['visible']==0, then we never show the field // If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) { if (!empty($val['visible'])) {
$visible = dol_eval($val['visible'], 1); $visible = dol_eval($val['visible'], 1);
@ -113,10 +119,8 @@ foreach ($object->fields as $key => $val)
} }
} }
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
{ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array( $arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
@ -138,8 +142,12 @@ $permissiontoread = $user->admin;
$permissiontoadd = $user->admin; $permissiontoadd = $user->admin;
$permissiontodelete = $user->admin; $permissiontodelete = $user->admin;
if (!$user->admin) accessforbidden(); if (!$user->admin) {
if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled'); accessforbidden();
}
if (empty($conf->emailcollector->enabled)) {
accessforbidden('Module not enabled');
}
@ -147,31 +155,33 @@ if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled')
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
{ foreach ($object->fields as $key => $val) {
foreach ($object->fields as $key => $val)
{
$search[$key] = ''; $search[$key] = '';
} }
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
{
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
} }
@ -197,13 +207,14 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")
// Build and execute select // Build and execute select
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$sql = 'SELECT '; $sql = 'SELECT ';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$sql .= 't.'.$key.', '; $sql .= 't.'.$key.', ';
} }
// Add fields from extrafields // Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) { if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
} }
// Add fields from hooks // Add fields from hooks
$parameters = array(); $parameters = array();
@ -211,20 +222,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql); $sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
else $sql .= " WHERE 1 = 1"; }
foreach ($search as $key => $val) if ($object->ismultientitymanaged == 1) {
{ $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
if ($key == 'status' && $search[$key] == -1) continue; } else {
$sql .= " WHERE 1 = 1";
}
foreach ($search as $key => $val) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) { if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') $search[$key] = ''; if ($search[$key] == '-1') {
$search[$key] = '';
}
$mode_search = 2; $mode_search = 2;
} }
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); if ($search[$key] != '') {
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
}
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
} }
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
// Add where from extra fields // Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks // Add where from hooks
@ -253,26 +276,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
{
$num = $nbtotalofrecords; $num = $nbtotalofrecords;
} else { } else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset); if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -281,8 +302,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
} }
// Direct jump if only one record found // Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$id = $obj->rowid; $id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id); header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id);
@ -313,14 +333,24 @@ jQuery(document).ready(function() {
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
foreach ($search as $key => $val) }
{ if ($limit > 0 && $limit != $conf->liste_limit) {
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); $param .= '&limit='.urlencode($limit);
else $param .= '&search_'.$key.'='.urlencode($search[$key]); }
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
} else {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
} }
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -329,12 +359,18 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); if ($permissiontodelete) {
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -363,11 +399,13 @@ $moreforfilter.= '</div>';*/
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) {
else $moreforfilter = $hookmanager->resPrint; $moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter)) if (!empty($moreforfilter)) {
{
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter; print $moreforfilter;
print '</div>'; print '</div>';
@ -384,20 +422,26 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
// Fields title search // Fields title search
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; if ($key == 'status') {
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked'])) } elseif (in_array($val['type'], array('timestamp'))) {
{ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
elseif (strpos($val['type'], 'integer:') === 0) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
}
print '</td>'; print '</td>';
} }
} }
@ -419,15 +463,18 @@ print '</tr>'."\n";
// Fields title label // Fields title label
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; if ($key == 'status') {
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked'])) } elseif (in_array($val['type'], array('timestamp'))) {
{ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
} }
} }
@ -444,11 +491,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line // Detect if we need a fetch on each output line
$needToFetchEachLine = 0; $needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) if (preg_match('/\$object/', $val)) {
{ $needToFetchEachLine++; // There is at least one compute field that use $object
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object }
} }
} }
@ -457,38 +504,51 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$i = 0; $i = 0;
$totalarray = array(); $totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num)) while ($i < ($limit ? min($num, $limit) : $num)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object // Store properties in $object
$object->setVarsFromFetchObj($obj); $object->setVarsFromFetchObj($obj);
// Show here line of result // Show here line of result
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; if (in_array($val['type'], array('timestamp'))) {
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked'])) if (!empty($arrayfields['t.'.$key]['checked'])) {
{
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status') print $object->getLibStatut(5); if ($key == 'status') {
else print $object->showOutputField($val, $key, $object->$key, ''); print $object->getLibStatut(5);
} else {
print $object->showOutputField($val, $key, $object->$key, '');
}
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
if (!empty($val['isameasure'])) $totalarray['nbfield']++;
{ }
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; if (!empty($val['isameasure'])) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
$totalarray['val']['t.'.$key] += $object->$key; $totalarray['val']['t.'.$key] += $object->$key;
} }
} }
@ -501,14 +561,17 @@ while ($i < ($limit ? min($num, $limit) : $num))
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Action column // Action column
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0; $selected = 0;
if (in_array($object->id, $arrayofselected)) $selected = 1; if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n"; print '</tr>'."\n";
@ -520,10 +583,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found // If no record found
if ($num == 0) if ($num == 0) {
{
$colspan = 1; $colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
} }
@ -539,10 +605,11 @@ print '</div>'."\n";
print '</form>'."\n"; print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
{
$hidegeneratedfilelistifempty = 1; $hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db); $formfile = new FormFile($db);

View File

@ -34,13 +34,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'actioncomm'; $elementtype = 'actioncomm';
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -73,8 +77,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -84,8 +87,7 @@ if ($action != 'create' && $action != 'edit')
/* /*
* Creation of an optional field * Creation of an optional field
*/ */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -95,8 +97,7 @@ if ($action == 'create')
/* /*
* Edition of an optional field * Edition of an optional field
*/ */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -44,7 +44,9 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -57,17 +59,18 @@ $eventstolog = $securityevent->eventstolog;
* Actions * Actions
*/ */
if ($action == "save") if ($action == "save") {
{
$i = 0; $i = 0;
$db->begin(); $db->begin();
foreach ($eventstolog as $key => $arr) foreach ($eventstolog as $key => $arr) {
{
$param = 'MAIN_LOGEVENTS_'.$arr['id']; $param = 'MAIN_LOGEVENTS_'.$arr['id'];
if (GETPOST($param, 'alphanohtml')) dolibarr_set_const($db, $param, GETPOST($param, 'alphanohtml'), 'chaine', 0, '', $conf->entity); if (GETPOST($param, 'alphanohtml')) {
else dolibarr_del_const($db, $param, $conf->entity); dolibarr_set_const($db, $param, GETPOST($param, 'alphanohtml'), 'chaine', 0, '', $conf->entity);
} else {
dolibarr_del_const($db, $param, $conf->entity);
}
} }
$db->commit(); $db->commit();
@ -110,10 +113,8 @@ print getTitleFieldOfList("LogEvents", 0, $_SERVER["PHP_SELF"], '', '', '', '',
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
print "</tr>\n"; print "</tr>\n";
// Loop on each event type // Loop on each event type
foreach ($eventstolog as $key => $arr) foreach ($eventstolog as $key => $arr) {
{ if ($arr['id']) {
if ($arr['id'])
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$arr['id'].'</td>'; print '<td>'.$arr['id'].'</td>';
print '<td class="center">'; print '<td class="center">';

View File

@ -37,8 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); $langs->loadLangs(array("admin", "sendings", "deliveries", "other"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -46,8 +47,7 @@ $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha');
$type = 'shipping'; $type = 'shipping';
if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) {
{
$conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor'; $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor';
} }
@ -58,43 +58,39 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconst = GETPOST('maskconstexpedition', 'alpha'); $maskconst = GETPOST('maskconstexpedition', 'alpha');
$maskvalue = GETPOST('maskexpedition', 'alpha'); $maskvalue = GETPOST('maskexpedition', 'alpha');
if (!empty($maskconst)) if (!empty($maskconst)) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
if (isset($res))
{
if ($res > 0)
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
else setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_param')
{ if (isset($res)) {
if ($res > 0) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
} elseif ($action == 'set_param') {
$freetext = GETPOST('SHIPPING_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('SHIPPING_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if ($res <= 0) if ($res <= 0) {
{
$error++; $error++;
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
$draft = GETPOST('SHIPPING_DRAFT_WATERMARK', 'alpha'); $draft = GETPOST('SHIPPING_DRAFT_WATERMARK', 'alpha');
$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if ($res <= 0) if ($res <= 0) {
{
$error++; $error++;
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$exp = new Expedition($db); $exp = new Expedition($db);
@ -103,25 +99,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($exp, $langs) > 0) if ($module->write_file($exp, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -132,26 +124,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->EXPEDITION_ADDON_PDF == "$value") {
if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->EXPEDITION_ADDON_PDF = $value; $conf->global->EXPEDITION_ADDON_PDF = $value;
@ -159,12 +144,10 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmodel') } elseif ($action == 'setmodel') {
{
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity);
} }
@ -201,17 +184,13 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/expedition/"); $dir = dol_buildpath($reldir."core/modules/expedition/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
if (preg_match('/^mod_expedition_([a-z0-9_]*)\.php$/', $file)) { if (preg_match('/^mod_expedition_([a-z0-9_]*)\.php$/', $file)) {
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
@ -219,11 +198,14 @@ foreach ($dirmodels as $reldir)
$module = new $file; $module = new $file;
if ($module->isEnabled()) if ($module->isEnabled()) {
{
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
print '<tr><td>'.$module->name."</td>\n"; print '<tr><td>'.$module->name."</td>\n";
print '<td>'; print '<td>';
@ -236,13 +218,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;token='.newToken().'&amp;value='.$file.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;token='.newToken().'&amp;value='.$file.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
@ -261,8 +245,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -300,12 +285,10 @@ $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -326,30 +309,22 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/expedition".$valdir); $dir = dol_buildpath($reldir."core/modules/expedition".$valdir);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -357,21 +332,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr><td width="100">'; print '<tr><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -385,8 +365,7 @@ foreach ($dirmodels as $reldir)
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->EXPEDITION_ADDON_PDF == $name) if ($conf->global->EXPEDITION_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -396,8 +375,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
@ -413,8 +391,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -453,14 +430,15 @@ print "</tr>";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<tr><td>'; print '<tr><td>';
print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'SHIPPING_FREE_TEXT'; $variablename = 'SHIPPING_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries')); $langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries'));
@ -45,13 +46,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'expedition'; //Must be the $table_element of the class that manage extrafield $elementtype = 'expedition'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -84,8 +89,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -98,8 +102,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -111,8 +114,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'sendings')); $langs->loadLangs(array('admin', 'other', 'sendings'));
@ -46,13 +47,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'expeditiondet'; //Must be the $table_element of the class that manage extrafield $elementtype = 'expeditiondet'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -85,8 +90,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -99,8 +103,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -112,8 +115,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -30,8 +30,9 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'trips', 'other')); $langs->loadLangs(array('admin', 'errors', 'trips', 'other'));
@ -42,13 +43,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'expensereport'; //Must be the $table_element of the class that manage extrafield $elementtype = 'expensereport'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -78,8 +83,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -92,8 +96,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -105,8 +108,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -33,7 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php'
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); $langs->loadLangs(array("admin", "trips", "errors", "other", "dict"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$error = 0; $error = 0;
@ -45,13 +47,13 @@ $coef = GETPOST('coef', 'int');
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
$fk_range = GETPOST('fk_range'); $fk_range = GETPOST('fk_range');
if ($action == 'updateik') if ($action == 'updateik') {
{
$expIk = new ExpenseReportIk($db); $expIk = new ExpenseReportIk($db);
if ($id > 0) if ($id > 0) {
{
$result = $expIk->fetch($id); $result = $expIk->fetch($id);
if ($result < 0) dol_print_error('', $expIk->error, $expIk->errors); if ($result < 0) {
dol_print_error('', $expIk->error, $expIk->errors);
}
} }
$expIk->setValues($_POST); $expIk->setValues($_POST);
@ -64,13 +66,13 @@ if ($action == 'updateik')
} else { } else {
setEventMessages($expIk->error, $expIk->errors, 'errors'); setEventMessages($expIk->error, $expIk->errors, 'errors');
} }
} elseif ($action == 'delete') // TODO add confirm } elseif ($action == 'delete') { // TODO add confirm
{
$expIk = new ExpenseReportIk($db); $expIk = new ExpenseReportIk($db);
if ($id > 0) if ($id > 0) {
{
$result = $expIk->fetch($id); $result = $expIk->fetch($id);
if ($result < 0) dol_print_error('', $expIk->error, $expIk->errors); if ($result < 0) {
dol_print_error('', $expIk->error, $expIk->errors);
}
$expIk->delete($user); $expIk->delete($user);
} }
@ -102,8 +104,7 @@ print '<br><br>';
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">'; echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
if ($action == 'edit') if ($action == 'edit') {
{
echo '<input type="hidden" name="id" value="'.$id.'" />'; echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '<input type="hidden" name="fk_c_exp_tax_cat" value="'.$fk_c_exp_tax_cat.'" />'; echo '<input type="hidden" name="fk_c_exp_tax_cat" value="'.$fk_c_exp_tax_cat.'" />';
echo '<input type="hidden" name="fk_range" value="'.$fk_range.'" />'; echo '<input type="hidden" name="fk_range" value="'.$fk_range.'" />';
@ -114,8 +115,7 @@ echo '<input type="hidden" name="token" value="'.newToken().'" />';
echo '<table class="noborder centpercent">'; echo '<table class="noborder centpercent">';
foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) {
{
$title = ($Tab['active'] == 1) ? $langs->trans($Tab['label']) : $form->textwithpicto($langs->trans($Tab['label']), $langs->trans('expenseReportCatDisabled'), 1, 'help', '', 0, 3); $title = ($Tab['active'] == 1) ? $langs->trans($Tab['label']) : $form->textwithpicto($langs->trans($Tab['label']), $langs->trans('expenseReportCatDisabled'), 1, 'help', '', 0, 3);
echo '<tr class="liste_titre">'; echo '<tr class="liste_titre">';
echo '<td>'.$title.'</td>'; echo '<td>'.$title.'</td>';
@ -125,16 +125,22 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
echo '</tr>'; echo '</tr>';
if ($Tab['active'] == 0) continue; if ($Tab['active'] == 0) {
continue;
}
$tranche = 1; $tranche = 1;
foreach ($Tab['ranges'] as $k => $range) foreach ($Tab['ranges'] as $k => $range) {
{ if (isset($Tab['ranges'][$k + 1])) {
if (isset($Tab['ranges'][$k + 1])) $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k + 1]->range_ik - 1)); $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k + 1]->range_ik - 1));
else $label = $langs->trans('expenseReportRangeMoreThan', $range->range_ik); } else {
$label = $langs->trans('expenseReportRangeMoreThan', $range->range_ik);
}
if ($range->range_active == 0) $label = $form->textwithpicto($label, $langs->trans('expenseReportRangeDisabled'), 1, 'help', '', 0, 3); if ($range->range_active == 0) {
$label = $form->textwithpicto($label, $langs->trans('expenseReportRangeDisabled'), 1, 'help', '', 0, 3);
}
echo '<tr class="oddeven">'; echo '<tr class="oddeven">';
@ -143,15 +149,19 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
// Offset // Offset
echo '<td class="nowraponall">'; echo '<td class="nowraponall">';
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" class="maxwidth100" name="ikoffset" value="'.$range->ik->ikoffset.'" />'; if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) {
else { echo '<input type="text" class="maxwidth100" name="ikoffset" value="'.$range->ik->ikoffset.'" />';
} else {
echo $range->ik->ikoffset; echo $range->ik->ikoffset;
} }
echo '</td>'; echo '</td>';
// Coef // Coef
echo '<td class="nowraponall">'; echo '<td class="nowraponall">';
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" class="maxwidth100" name="coef" value="'.$range->ik->coef.'" />'; if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) {
else echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined')); echo '<input type="text" class="maxwidth100" name="coef" value="'.$range->ik->coef.'" />';
} else {
echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined'));
}
echo '</td>'; echo '</td>';
// Total for one // Total for one
@ -159,15 +169,15 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
// Action // Action
echo '<td class="right">'; echo '<td class="right">';
if ($range->range_active == 1) if ($range->range_active == 1) {
{ if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) {
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat)
{
echo '<input id="" class="button button-save" name="save" value="'.$langs->trans("Save").'" type="submit" />'; echo '<input id="" class="button button-save" name="save" value="'.$langs->trans("Save").'" type="submit" />';
echo '<input class="button button-cancel" value="'.$langs->trans("Cancel").'" onclick="javascript:history.go(-1)" type="button" />'; echo '<input class="button button-cancel" value="'.$langs->trans("Cancel").'" onclick="javascript:history.go(-1)" type="button" />';
} else { } else {
echo '<a class="editfielda marginrightonly paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$range->ik->id.'&fk_c_exp_tax_cat='.$range->fk_c_exp_tax_cat.'&fk_range='.$range->rowid.'">'.img_edit().'</a>'; echo '<a class="editfielda marginrightonly paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$range->ik->id.'&fk_c_exp_tax_cat='.$range->fk_c_exp_tax_cat.'&fk_range='.$range->rowid.'">'.img_edit().'</a>';
if (!empty($range->ik->id)) echo '<a class="paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$range->ik->id.'">'.img_delete().'</a>'; if (!empty($range->ik->id)) {
echo '<a class="paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$range->ik->id.'">'.img_delete().'</a>';
}
// TODO add delete link // TODO add delete link
} }
} }

View File

@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'exports', 'other')); $langs->loadLangs(array('admin', 'exports', 'other'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');

View File

@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
$langs->load("admin"); $langs->load("admin");
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$def = array(); $def = array();
$lastexternalrss = 0; $lastexternalrss = 0;
@ -53,31 +55,28 @@ $sql = "SELECT ".$db->decrypt('name')." as name FROM ".MAIN_DB_PREFIX."const";
$sql .= " WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'"; $sql .= " WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'";
//print $sql; //print $sql;
$result = $db->query($sql); // We can't use SELECT MAX() because EXTERNAL_RSS_URLRSS_10 is lower than EXTERNAL_RSS_URLRSS_9 $result = $db->query($sql); // We can't use SELECT MAX() because EXTERNAL_RSS_URLRSS_10 is lower than EXTERNAL_RSS_URLRSS_9
if ($result) if ($result) {
{ while ($obj = $db->fetch_object($result)) {
while ($obj = $db->fetch_object($result))
{
preg_match('/([0-9]+)$/i', $obj->name, $reg); preg_match('/([0-9]+)$/i', $obj->name, $reg);
if ($reg[1] && $reg[1] > $lastexternalrss) $lastexternalrss = $reg[1]; if ($reg[1] && $reg[1] > $lastexternalrss) {
$lastexternalrss = $reg[1];
}
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
if ($action == 'add' || GETPOST("modify")) if ($action == 'add' || GETPOST("modify")) {
{
$external_rss_title = "external_rss_title_".GETPOST("norss", 'int'); $external_rss_title = "external_rss_title_".GETPOST("norss", 'int');
$external_rss_urlrss = "external_rss_urlrss_".GETPOST("norss", 'int'); $external_rss_urlrss = "external_rss_urlrss_".GETPOST("norss", 'int');
if (!empty($_POST[$external_rss_urlrss])) if (!empty($_POST[$external_rss_urlrss])) {
{
$boxlabel = '(ExternalRSSInformations)'; $boxlabel = '(ExternalRSSInformations)';
//$external_rss_url = "external_rss_url_" . $_POST["norss"]; //$external_rss_url = "external_rss_url_" . $_POST["norss"];
$db->begin(); $db->begin();
if ($_POST["modify"]) if ($_POST["modify"]) {
{
// Supprime boite box_external_rss de definition des boites // Supprime boite box_external_rss de definition des boites
/* $sql = "UPDATE ".MAIN_DB_PREFIX."boxes_def"; /* $sql = "UPDATE ".MAIN_DB_PREFIX."boxes_def";
$sql.= " SET name = '".$db->escape($boxlabel)."'"; $sql.= " SET name = '".$db->escape($boxlabel)."'";
@ -94,18 +93,18 @@ if ($action == 'add' || GETPOST("modify"))
// Ajoute boite box_external_rss dans definition des boites // Ajoute boite box_external_rss dans definition des boites
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)";
$sql .= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss", 'int').' ('.GETPOST($external_rss_title, 'alpha')).")')"; $sql .= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss", 'int').' ('.GETPOST($external_rss_title, 'alpha')).")')";
if (!$db->query($sql)) if (!$db->query($sql)) {
{
dol_print_error($db); dol_print_error($db);
$err++; $err++;
} }
} }
$result1 = dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), GETPOST($external_rss_title, 'alpha'), 'chaine', 0, '', $conf->entity); $result1 = dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), GETPOST($external_rss_title, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result1) $result2 = dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity); if ($result1) {
$result2 = dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity);
}
if ($result1 && $result2) if ($result1 && $result2) {
{
$db->commit(); $db->commit();
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
@ -116,10 +115,8 @@ if ($action == 'add' || GETPOST("modify"))
} }
} }
if ($_POST["delete"]) if ($_POST["delete"]) {
{ if (GETPOST("norss", 'int')) {
if (GETPOST("norss", 'int'))
{
$db->begin(); $db->begin();
// Supprime boite box_external_rss de definition des boites // Supprime boite box_external_rss de definition des boites
@ -127,12 +124,10 @@ if ($_POST["delete"])
$sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'"; $sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
@ -144,8 +139,7 @@ if ($_POST["delete"])
$sql .= " WHERE rowid = ".$obj->rowid; $sql .= " WHERE rowid = ".$obj->rowid;
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
$db->rollback(); $db->rollback();
dol_print_error($db, "sql=".$sql); dol_print_error($db, "sql=".$sql);
exit; exit;
@ -163,10 +157,11 @@ if ($_POST["delete"])
$result1 = dolibarr_del_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), $conf->entity); $result1 = dolibarr_del_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), $conf->entity);
if ($result1) $result2 = dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity); if ($result1) {
$result2 = dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity);
}
if ($result1 && $result2) if ($result1 && $result2) {
{
$db->commit(); $db->commit();
header("Location: external_rss.php"); header("Location: external_rss.php");
exit; exit;
@ -228,14 +223,12 @@ $sql .= " ORDER BY note";
dol_syslog("select rss boxes", LOG_DEBUG); dol_syslog("select rss boxes", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$boxlist = InfoBox::listBoxes($db, 'activated', -1, null); $boxlist = InfoBox::listBoxes($db, 'activated', -1, null);
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
preg_match('/^([0-9]+)/i', $obj->note, $reg); preg_match('/^([0-9]+)/i', $obj->note, $reg);
@ -279,29 +272,34 @@ if ($resql)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("Status")."</td>"; print "<td>".$langs->trans("Status")."</td>";
print "<td>"; print "<td>";
if ($result > 0 && empty($rss->error)) if ($result > 0 && empty($rss->error)) {
{
print '<font class="ok">'.$langs->trans("Online").'</div>'; print '<font class="ok">'.$langs->trans("Online").'</div>';
} else { } else {
print '<font class="error">'.$langs->trans("Offline"); print '<font class="error">'.$langs->trans("Offline");
$langs->load("errors"); $langs->load("errors");
if ($rssparser->error) print ' - '.$langs->trans($rssparser->error); if ($rssparser->error) {
print ' - '.$langs->trans($rssparser->error);
}
print '</div>'; print '</div>';
} }
print "</td>"; print "</td>";
print '</tr>'."\n"; print '</tr>'."\n";
// Logo // Logo
if ($result > 0 && empty($rss->error)) if ($result > 0 && empty($rss->error)) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("Logo")."</td>"; print "<td>".$langs->trans("Logo")."</td>";
print '<td>'; print '<td>';
$imageurl = $rssparser->getImageUrl(); $imageurl = $rssparser->getImageUrl();
$linkrss = $rssparser->getLink(); $linkrss = $rssparser->getLink();
if (!preg_match('/^http/', $imageurl)) $imageurl = $linkrss.$imageurl; if (!preg_match('/^http/', $imageurl)) {
if ($imageurl) print '<img height="32" src="'.$imageurl.'">'; $imageurl = $linkrss.$imageurl;
else print $langs->trans("None"); }
if ($imageurl) {
print '<img height="32" src="'.$imageurl.'">';
} else {
print $langs->trans("None");
}
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
} }
@ -336,10 +334,8 @@ $db->close();
*/ */
function _isInBoxList($idrss, array $boxlist) function _isInBoxList($idrss, array $boxlist)
{ {
foreach ($boxlist as $box) foreach ($boxlist as $box) {
{ if ($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== false) {
if ($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== false)
{
return true; return true;
} }
} }

View File

@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'other', 'bills')); $langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -51,8 +53,7 @@ $type = 'invoice';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
$maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha');
$maskconstcredit = GETPOST('maskconstcredit', 'alpha'); $maskconstcredit = GETPOST('maskconstcredit', 'alpha');
@ -61,21 +62,29 @@ if ($action == 'updateMask')
$maskreplacement = GETPOST('maskreplacement', 'alpha'); $maskreplacement = GETPOST('maskreplacement', 'alpha');
$maskcredit = GETPOST('maskcredit', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha');
$maskdeposit = GETPOST('maskdeposit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha');
if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); if ($maskconstinvoice) {
if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); }
if ($maskconstdeposit) $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); if ($maskconstreplacement) {
$res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
}
if ($maskconstcredit) {
$res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
}
if ($maskconstdeposit) {
$res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$facture = new Facture($db); $facture = new Facture($db);
@ -84,25 +93,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($facture, $langs) > 0) if ($module->write_file($facture, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -113,24 +118,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model // Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->FACTURE_ADDON_PDF == "$value") {
if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
} }
} }
// Set default model } elseif ($action == 'setdoc') {
elseif ($action == 'setdoc') // Set default model
{ if (dolibarr_set_const($db, "FACTURE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
if (dolibarr_set_const($db, "FACTURE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->FACTURE_ADDON_PDF = $value; $conf->global->FACTURE_ADDON_PDF = $value;
@ -138,90 +138,86 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'setribchq') } elseif ($action == 'setribchq') {
{
$rib = GETPOST('rib', 'alpha'); $rib = GETPOST('rib', 'alpha');
$chq = GETPOST('chq', 'alpha'); $chq = GETPOST('chq', 'alpha');
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') } elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') {
{
$draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha');
$res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_INVOICE_FREE_TEXT') } elseif ($action == 'set_INVOICE_FREE_TEXT') {
{
$freetext = GETPOST('INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'setforcedate') } elseif ($action == 'setforcedate') {
{
$forcedate = GETPOST('forcedate', 'alpha'); $forcedate = GETPOST('forcedate', 'alpha');
$res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'setDefaultPDFModulesByType') } elseif ($action == 'setDefaultPDFModulesByType') {
{
$invoicetypemodels = GETPOST('invoicetypemodels'); $invoicetypemodels = GETPOST('invoicetypemodels');
if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) {
{
$error = 0; $error = 0;
foreach ($invoicetypemodels as $type => $value) foreach ($invoicetypemodels as $type => $value) {
{
$res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -264,44 +260,42 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/facture/"); $dir = dol_buildpath($reldir."core/modules/facture/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
{
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
{
$filebis = $file; $filebis = $file;
$classname = preg_replace('/\.php$/', '', $file); $classname = preg_replace('/\.php$/', '', $file);
// For compatibility // For compatibility
if (!is_file($dir.$filebis)) if (!is_file($dir.$filebis)) {
{
$filebis = $file."/".$file.".modules.php"; $filebis = $file."/".$file.".modules.php";
$classname = "mod_facture_".$file; $classname = "mod_facture_".$file;
} }
// Check if there is a filter on country // Check if there is a filter on country
preg_match('/\-(.*)_(.*)$/', $classname, $reg); preg_match('/\-(.*)_(.*)$/', $classname, $reg);
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
continue;
}
$classname = preg_replace('/\-.*$/', '', $classname); $classname = preg_replace('/\-.*$/', '', $classname);
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
{
// Charging the numbering class // Charging the numbering class
require_once $dir.$filebis; require_once $dir.$filebis;
$module = new $classname($db); $module = new $classname($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
print "</td><td>\n"; print "</td><td>\n";
@ -316,14 +310,16 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
//print "> ".$conf->global->FACTURE_ADDON." - ".$file; //print "> ".$conf->global->FACTURE_ADDON." - ".$file;
if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -341,8 +337,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValueForInvoices").': '; $htmltooltip .= $langs->trans("NextValueForInvoices").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -354,8 +351,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValueForReplacements").': '; $htmltooltip .= $langs->trans("NextValueForReplacements").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -368,8 +366,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; $htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -381,8 +380,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValueForDeposit").': '; $htmltooltip .= $langs->trans("NextValueForDeposit").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval; $htmltooltip .= $nextval;
} else { } else {
$htmltooltip .= $langs->trans($module->error); $htmltooltip .= $langs->trans($module->error);
@ -392,9 +392,10 @@ foreach ($dirmodels as $reldir)
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors if ($conf->global->FACTURE_ADDON.'.php' == $file) { // If module is the one used, we show existing errors
{ if (!empty($module->error)) {
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); dol_htmloutput_mesg($module->error, '', 'error', 1);
}
} }
print '</td>'; print '</td>';
@ -426,12 +427,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -454,31 +453,23 @@ clearstatcache();
$activatedModels = array(); $activatedModels = array();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/facture".$valdir; $realpath = $reldir."core/modules/facture".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -486,21 +477,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -514,8 +510,7 @@ foreach ($dirmodels as $reldir)
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->FACTURE_ADDON_PDF == "$name") if ($conf->global->FACTURE_ADDON_PDF == "$name") {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').'</a>';
@ -525,8 +520,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -547,8 +541,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -566,8 +559,7 @@ foreach ($dirmodels as $reldir)
} }
print '</table>'; print '</table>';
if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) { // Hidden conf
{
/* /*
* Document templates generators * Document templates generators
*/ */
@ -589,13 +581,11 @@ if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
); );
if (!empty($conf->global->INVOICE_USE_SITUATION)) if (!empty($conf->global->INVOICE_USE_SITUATION)) {
{
$listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
} }
foreach ($listtype as $type => $trans) foreach ($listtype as $type => $trans) {
{
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
$current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
print '<tr >'; print '<tr >';
@ -629,24 +619,20 @@ print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>"; print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
print "<td>"; print "<td>";
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled)) {
{
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0"; $sql .= " WHERE clos = 0";
$sql .= " AND courant = 1"; $sql .= " AND courant = 1";
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num > 0) if ($num > 0) {
{
print '<select name="rib" class="flat" id="rib">'; print '<select name="rib" class="flat" id="rib">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
@ -679,12 +665,10 @@ $sql .= " AND courant = 1";
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
@ -726,7 +710,9 @@ print '</form>';
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@ -735,8 +721,7 @@ print '<input type="hidden" name="action" value="set_INVOICE_FREE_TEXT" />';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'INVOICE_FREE_TEXT'; $variablename = 'INVOICE_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'other', 'bills')); $langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -60,7 +62,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader( llxHeader(
"", $langs->trans("BillsSetup"), "",
$langs->trans("BillsSetup"),
'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura' 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
); );

View File

@ -41,7 +41,9 @@ $action = GETPOST('action', 'aZ09');
// Full (not sure this one is used) // Full (not sure this one is used)
$mode = GETPOST('mode') ?GETPOST('mode', 'alpha') : 'dolibarr_notes'; $mode = GETPOST('mode') ?GETPOST('mode', 'alpha') : 'dolibarr_notes';
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
// Constant and translation of the module description // Constant and translation of the module description
$modules = array( $modules = array(
@ -86,29 +88,24 @@ $picto = array(
* Actions * Actions
*/ */
foreach ($modules as $const => $desc) foreach ($modules as $const => $desc) {
{ if ($action == 'activate_'.strtolower($const)) {
if ($action == 'activate_'.strtolower($const))
{
dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity);
// If fckeditor is active in the product/service description, it is activated in the forms // If fckeditor is active in the product/service description, it is activated in the forms
if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) {
{
dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity);
} }
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
if ($action == 'disable_'.strtolower($const)) if ($action == 'disable_'.strtolower($const)) {
{
dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const, $conf->entity); dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const, $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
} }
if (GETPOST('save', 'alpha')) if (GETPOST('save', 'alpha')) {
{
$error = 0; $error = 0;
$fckeditor_skin = GETPOST('fckeditor_skin', 'alpha'); $fckeditor_skin = GETPOST('fckeditor_skin', 'alpha');
@ -129,8 +126,7 @@ if (GETPOST('save', 'alpha'))
$error++; $error++;
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -147,8 +143,7 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_valu
print load_fiche_titre($langs->trans("AdvancedEditor"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("AdvancedEditor"), $linkback, 'title_setup');
print '<br>'; print '<br>';
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax)) {
{
setEventMessages(array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), null, 'errors'); setEventMessages(array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), null, 'errors');
} else { } else {
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -158,10 +153,11 @@ if (empty($conf->use_javascript_ajax))
print "</tr>\n"; print "</tr>\n";
// Modules // Modules
foreach ($modules as $const => $desc) foreach ($modules as $const => $desc) {
{
// If this condition is not met, the option is not offered // If this condition is not met, the option is not offered
if (!$conditions[$const]) continue; if (!$conditions[$const]) {
continue;
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="16">'.img_object("", $picto[$const]).'</td>'; print '<td width="16">'.img_object("", $picto[$const]).'</td>';
@ -169,11 +165,9 @@ if (empty($conf->use_javascript_ajax))
print '<td class="center" width="100">'; print '<td class="center" width="100">';
$constante = 'FCKEDITOR_ENABLE_'.$const; $constante = 'FCKEDITOR_ENABLE_'.$const;
$value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0);
if ($value == 0) if ($value == 0) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=activate_'.strtolower($const).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=activate_'.strtolower($const).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
} elseif ($value == 1) } elseif ($value == 1) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=disable_'.strtolower($const).'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=disable_'.strtolower($const).'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
} }
@ -194,20 +188,24 @@ if (empty($conf->use_javascript_ajax))
$listofmodes = array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline'); $listofmodes = array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline');
$linkstomode = ''; $linkstomode = '';
foreach ($listofmodes as $newmode) foreach ($listofmodes as $newmode) {
{ if ($linkstomode) {
if ($linkstomode) $linkstomode .= ' - '; $linkstomode .= ' - ';
}
$linkstomode .= '<a href="'.$_SERVER["PHP_SELF"].'?mode='.$newmode.'">'; $linkstomode .= '<a href="'.$_SERVER["PHP_SELF"].'?mode='.$newmode.'">';
if ($mode == $newmode) $linkstomode .= '<strong>'; if ($mode == $newmode) {
$linkstomode .= '<strong>';
}
$linkstomode .= $newmode; $linkstomode .= $newmode;
if ($mode == $newmode) $linkstomode .= '</strong>'; if ($mode == $newmode) {
$linkstomode .= '</strong>';
}
$linkstomode .= '</a>'; $linkstomode .= '</a>';
} }
$linkstomode .= ''; $linkstomode .= '';
print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, ''); print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, '');
print '<input type="hidden" name="mode" value="'.dol_escape_htmltag($mode).'">'; print '<input type="hidden" name="mode" value="'.dol_escape_htmltag($mode).'">';
if ($mode != 'Full_inline') if ($mode != 'Full_inline') {
{
$uselocalbrowser = true; $uselocalbrowser = true;
$readonly = ($mode == 'dolibarr_readonly' ? 1 : 0); $readonly = ($mode == 'dolibarr_readonly' ? 1 : 0);
$editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly);

View File

@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'interventions', 'other')); $langs->loadLangs(array('admin', 'errors', 'interventions', 'other'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -52,22 +54,23 @@ $type = 'ficheinter';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconst = GETPOST('maskconst', 'alpha'); $maskconst = GETPOST('maskconst', 'alpha');
$maskvalue = GETPOST('maskvalue', 'alpha'); $maskvalue = GETPOST('maskvalue', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if ($maskconst) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') // For fiche inter } elseif ($action == 'specimen') { // For fiche inter
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$inter = new Fichinter($db); $inter = new Fichinter($db);
@ -76,25 +79,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($inter, $langs) > 0) if ($module->write_file($inter, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -105,26 +104,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->FICHEINTER_ADDON_PDF == "$value") {
if ($conf->global->FICHEINTER_ADDON_PDF == "$value") dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->FICHEINTER_ADDON_PDF = $value; $conf->global->FICHEINTER_ADDON_PDF = $value;
@ -132,51 +124,49 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "FICHEINTER_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FICHEINTER_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_FICHINTER_FREE_TEXT') } elseif ($action == 'set_FICHINTER_FREE_TEXT') {
{
$freetext = GETPOST('FICHINTER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('FICHINTER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_FICHINTER_DRAFT_WATERMARK') } elseif ($action == 'set_FICHINTER_DRAFT_WATERMARK') {
{
$draft = GETPOST('FICHINTER_DRAFT_WATERMARK', 'alpha'); $draft = GETPOST('FICHINTER_DRAFT_WATERMARK', 'alpha');
$res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') } elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') {
{
$val = GETPOST('FICHINTER_PRINT_PRODUCTS', 'alpha'); $val = GETPOST('FICHINTER_PRINT_PRODUCTS', 'alpha');
$res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -257,19 +247,14 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/fichinter/"); $dir = dol_buildpath($reldir."core/modules/fichinter/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) {
{
if (preg_match('/^(mod_.*)\.php$/i', $file, $reg))
{
$file = $reg[1]; $file = $reg[1];
$classname = substr($file, 4); $classname = substr($file, 4);
@ -277,11 +262,14 @@ foreach ($dirmodels as $reldir)
$module = new $file; $module = new $file;
if ($module->isEnabled()) if ($module->isEnabled()) {
{
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
@ -294,13 +282,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->FICHEINTER_ADDON == $classname) if ($conf->global->FICHEINTER_ADDON == $classname) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -317,8 +307,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -354,12 +345,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -381,29 +370,22 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$realpath = $reldir."core/modules/fichinter/doc"; $realpath = $reldir."core/modules/fichinter/doc";
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -411,21 +393,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -439,8 +426,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->FICHEINTER_ADDON_PDF == "$name") if ($conf->global->FICHEINTER_ADDON_PDF == "$name") {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -465,8 +451,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -500,7 +485,9 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -509,8 +496,7 @@ print '<input type="hidden" name="action" value="set_FICHINTER_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'FICHINTER_FREE_TEXT'; $variablename = 'FICHINTER_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@ -541,8 +527,9 @@ print '<input type="hidden" name="action" value="set_FICHINTER_PRINT_PRODUCTS">'
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("PrintProductsOnFichinter").' ('.$langs->trans("PrintProductsOnFichinterDetails").')</td>'; print $langs->trans("PrintProductsOnFichinter").' ('.$langs->trans("PrintProductsOnFichinterDetails").')</td>';
print '<td align="center"><input type="checkbox" name="FICHINTER_PRINT_PRODUCTS" '; print '<td align="center"><input type="checkbox" name="FICHINTER_PRINT_PRODUCTS" ';
if ($conf->global->FICHINTER_PRINT_PRODUCTS) if ($conf->global->FICHINTER_PRINT_PRODUCTS) {
print 'checked '; print 'checked ';
}
print '/>'; print '/>';
print '</td><td class="right">'; print '</td><td class="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

View File

@ -28,8 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php';
// Security check // Security check
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "errors")); $langs->loadLangs(array("admin", "errors"));
@ -41,8 +42,7 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'set') if ($action == 'set') {
{
$error = 0; $error = 0;
$gimcdf = GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE"); $gimcdf = GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE");
@ -52,22 +52,23 @@ if ($action == 'set')
$error++; $error++;
} }
if (!$error && $gimcdf && !file_exists($gimcdf)) if (!$error && $gimcdf && !file_exists($gimcdf)) {
{
setEventMessages($langs->trans("ErrorFileNotFound", $gimcdf), null, 'errors'); setEventMessages($langs->trans("ErrorFileNotFound", $gimcdf), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity);
if (!$res1 > 0) $error++; if (!$res1 > 0) {
$error++;
}
$res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity);
if (!$res2 > 0) $error++; if (!$res2 > 0) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -75,7 +76,9 @@ if ($action == 'set')
} }
} }
if (!isset($conf->global->GEOIP_VERSION)) $conf->global->GEOIP_VERSION = '2'; if (!isset($conf->global->GEOIP_VERSION)) {
$conf->global->GEOIP_VERSION = '2';
}
/* /*
@ -92,8 +95,7 @@ print '<br>';
$version = ''; $version = '';
$geoip = ''; $geoip = '';
if (!empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) if (!empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) {
{
$geoip = new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE); $geoip = new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
} }
@ -113,11 +115,11 @@ print '<tr class="oddeven"><td width="50%">'.$langs->trans("GeoIPLibVersion").'<
print '<td colspan="2">'; print '<td colspan="2">';
$arrayofvalues = array('php' => 'Native PHP functions', '1' => 'Embedded GeoIP v1', '2' => 'Embedded GeoIP v2'); $arrayofvalues = array('php' => 'Native PHP functions', '1' => 'Embedded GeoIP v1', '2' => 'Embedded GeoIP v2');
print $form->selectarray('geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION : '2')); print $form->selectarray('geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION : '2'));
if ($conf->global->GEOIP_VERSION == 'php') if ($conf->global->GEOIP_VERSION == 'php') {
{ if ($geoip) {
if ($geoip) $version = $geoip->getVersion(); $version = $geoip->getVersion();
if ($version) }
{ if ($version) {
print '<br>'.$langs->trans("Version").': '.$version; print '<br>'.$langs->trans("Version").': '.$version;
} }
} }
@ -127,8 +129,7 @@ print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
if ($conf->global->GEOIP_VERSION == 'php') if ($conf->global->GEOIP_VERSION == 'php') {
{
print 'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).' or /pathtodatafile/GeoLite2-Country.mmdb<br>'; print 'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).' or /pathtodatafile/GeoLite2-Country.mmdb<br>';
} }
print '<input size="50" type="text" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.dol_escape_htmltag($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE).'">'; print '<input size="50" type="text" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.dol_escape_htmltag($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE).'">';
@ -150,22 +151,27 @@ print '<br>';
$url2 = 'http://www.maxmind.com/en/city?rId=awstats'; $url2 = 'http://www.maxmind.com/en/city?rId=awstats';
print $langs->trans("YouCanDownloadAdvancedDatFileTo", '<a href="'.$url2.'" target="_blank">'.$url2.'</a>'); print $langs->trans("YouCanDownloadAdvancedDatFileTo", '<a href="'.$url2.'" target="_blank">'.$url2.'</a>');
if ($geoip) if ($geoip) {
{
print '<br><br>'; print '<br><br>';
print '<br><span class="opacitymedium">'.$langs->trans("TestGeoIPResult", $ip).':</span>'; print '<br><span class="opacitymedium">'.$langs->trans("TestGeoIPResult", $ip).':</span>';
$ip = '24.24.24.24'; $ip = '24.24.24.24';
print '<br>'.$ip.' -> '; print '<br>'.$ip.' -> ';
$result = dol_print_ip($ip, 1); $result = dol_print_ip($ip, 1);
if ($result) print $result; if ($result) {
else print $langs->trans("Error"); print $result;
} else {
print $langs->trans("Error");
}
$ip = '2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a'; // should be France $ip = '2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a'; // should be France
print '<br>'.$ip.' -> '; print '<br>'.$ip.' -> ';
$result = dol_print_ip($ip, 1); $result = dol_print_ip($ip, 1);
if ($result) print $result; if ($result) {
else print $langs->trans("Error"); print $result;
} else {
print $langs->trans("Error");
}
/* We disable this test because dol_print_ip need an ip as input /* We disable this test because dol_print_ip need an ip as input
@ -179,17 +185,22 @@ if ($geoip)
$ip = getUserRemoteIP(); $ip = getUserRemoteIP();
//$ip='91.161.249.43'; //$ip='91.161.249.43';
$isip = is_ip($ip); $isip = is_ip($ip);
if ($isip == 1) if ($isip == 1) {
{
print '<br>'.$ip.' -> '; print '<br>'.$ip.' -> ';
$result = dol_print_ip($ip, 1); $result = dol_print_ip($ip, 1);
if ($result) print $result; if ($result) {
else print $langs->trans("Error"); print $result;
} else {
print $langs->trans("Error");
}
} else { } else {
print '<br>'.$ip.' -> '; print '<br>'.$ip.' -> ';
$result = dol_print_ip($ip, 1); $result = dol_print_ip($ip, 1);
if ($result) print $result; if ($result) {
else print $langs->trans("NotAPublicIp"); print $result;
} else {
print $langs->trans("NotAPublicIp");
}
} }
$geoip->close(); $geoip->close();

View File

@ -33,7 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "errors", "holiday")); $langs->loadLangs(array("admin", "errors", "holiday"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -41,8 +43,7 @@ $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha');
$type = 'contract'; $type = 'contract';
if (empty($conf->global->HOLIDAY_ADDON)) if (empty($conf->global->HOLIDAY_ADDON)) {
{
$conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
} }
@ -53,22 +54,23 @@ if (empty($conf->global->HOLIDAY_ADDON))
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconst = GETPOST('maskconstholiday', 'alpha'); $maskconst = GETPOST('maskconstholiday', 'alpha');
$maskvalue = GETPOST('maskholiday', 'alpha'); $maskvalue = GETPOST('maskholiday', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if ($maskconst) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') // For contract } elseif ($action == 'specimen') { // For contract
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$holiday = new Holiday($db); $holiday = new Holiday($db);
@ -77,25 +79,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($holiday, $langs) > 0) if ($module->write_file($holiday, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -106,26 +104,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->HOLIDAY_ADDON_PDF == "$value") {
if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "HOLIDAY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "HOLIDAY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->HOLIDAY_ADDON_PDF = $value; $conf->global->HOLIDAY_ADDON_PDF = $value;
@ -133,28 +124,26 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "HOLIDAY_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "HOLIDAY_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_other') } elseif ($action == 'set_other') {
{
$freetext = GETPOST('HOLIDAY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('HOLIDAY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
$draft = GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha'); $draft = GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha');
$res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!$res1 > 0 || !$res2 > 0) $error++; if (!$res1 > 0 || !$res2 > 0) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -197,19 +186,14 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/holiday/"); $dir = dol_buildpath($reldir."core/modules/holiday/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -217,11 +201,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db); $module = new $file($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -232,13 +219,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->HOLIDAY_ADDON == "$file") if ($conf->global->HOLIDAY_ADDON == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -257,8 +246,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -305,12 +295,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -333,31 +321,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/holiday".$valdir; $realpath = $reldir."core/modules/holiday".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -365,21 +345,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -393,8 +378,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->HOLIDAY_ADDON_PDF == $name) if ($conf->global->HOLIDAY_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -404,8 +388,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -424,8 +407,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -467,15 +449,16 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
print '<br>'; print '<br>';
$variablename = 'HOLIDAY_FREE_TEXT'; $variablename = 'HOLIDAY_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -30,8 +30,9 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'holiday', 'other')); $langs->loadLangs(array('admin', 'errors', 'holiday', 'other'));
@ -42,13 +43,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'holiday'; //Must be the $table_element of the class that manage extrafield $elementtype = 'holiday'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -78,8 +83,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -92,8 +96,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -105,8 +108,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -36,12 +36,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'projects', 'hrm', 'agenda')); $langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'projects', 'hrm', 'agenda'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search
if (!defined("MAIN_MOTD")) define("MAIN_MOTD", ""); if (!defined("MAIN_MOTD")) {
define("MAIN_MOTD", "");
}
@ -51,22 +55,25 @@ if (!defined("MAIN_MOTD")) define("MAIN_MOTD", "");
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (GETPOST('cancel', 'alpha')) if (GETPOST('cancel', 'alpha')) {
{
$action = ''; $action = '';
} }
// Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff) // Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff)
$regs = array(); $regs = array();
if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) { if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) {
if ($regs[1] == 'set') dolibarr_set_const($db, $regs[2], 1, 'chaine', 0, '', $conf->entity); if ($regs[1] == 'set') {
else dolibarr_del_const($db, $regs[2], $conf->entity); dolibarr_set_const($db, $regs[2], 1, 'chaine', 0, '', $conf->entity);
} else {
dolibarr_del_const($db, $regs[2], $conf->entity);
}
} }
if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKGROUND)) if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKGROUND)) {
{
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -86,8 +93,7 @@ if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKG
$mysoc->logo_mini='';*/ $mysoc->logo_mini='';*/
} }
if ($action == 'update') if ($action == 'update') {
{
dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity); //dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity);
@ -99,58 +105,100 @@ if ($action == 'update')
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/ else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLELINK'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLELINK'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLELINK', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLELINK', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLELINK', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLELINK', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity);
} else {
dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity);
} else {
dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity);
}
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity); if ($val == '') {
else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity);
} else {
dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity);
}
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity);
@ -171,27 +219,21 @@ if ($action == 'update')
//dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities //dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities
$varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/'; $varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/';
if ($_FILES[$varforimage]["tmp_name"]) if ($_FILES[$varforimage]["tmp_name"]) {
{
$reg = array(); $reg = array();
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
{
$original_file = $reg[1]; $original_file = $reg[1];
$isimage = image_format_supported($original_file); $isimage = image_format_supported($original_file);
if ($isimage >= 0) if ($isimage >= 0) {
{
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
if (!is_dir($dirforimage)) if (!is_dir($dirforimage)) {
{
dol_mkdir($dirforimage); dol_mkdir($dirforimage);
} }
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
if ($result > 0) if ($result > 0) {
{
dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND", $original_file, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND", $original_file, 'chaine', 0, '', $conf->entity);
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
{
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$tmparray = explode(':', $result); $tmparray = explode(':', $result);
@ -380,8 +422,7 @@ complete_substitutions_array($substitutionarray, $langs);
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach ($substitutionarray as $key => $val) foreach ($substitutionarray as $key => $val) {
{
$texthelp .= $key.'<br>'; $texthelp .= $key.'<br>';
} }
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
@ -417,8 +458,7 @@ $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'obje
complete_substitutions_array($substitutionarray, $langs); complete_substitutions_array($substitutionarray, $langs);
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach ($substitutionarray as $key => $val) foreach ($substitutionarray as $key => $val) {
{
$texthelp .= $key.'<br>'; $texthelp .= $key.'<br>';
} }
print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin'); print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin');
@ -431,10 +471,11 @@ print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="imagebackground">'.$langs->trans("BackgroundImageLogin").' (png,jpg)</label></td><td colspan="2">'; print '<tr class="oddeven"><td><label for="imagebackground">'.$langs->trans("BackgroundImageLogin").' (png,jpg)</label></td><td colspan="2">';
print '<div class="centpercent inline-block">'; print '<div class="centpercent inline-block">';
$disabled = ''; $disabled = '';
if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) $disabled = ' disabled="disabled"'; if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) {
$disabled = ' disabled="disabled"';
}
print '<input type="file" class="flat class=minwidth200" name="imagebackground" id="imagebackground"'.$disabled.'>'; print '<input type="file" class="flat class=minwidth200" name="imagebackground" id="imagebackground"'.$disabled.'>';
if ($disabled) if ($disabled) {
{
print '('.$langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND").') '; print '('.$langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND").') ';
} }
if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) {

View File

@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'exports', 'other')); $langs->loadLangs(array('admin', 'exports', 'other'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');

View File

@ -27,7 +27,9 @@ require '../main.inc.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'companies')); $langs->loadLangs(array('admin', 'companies'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('homesetup')); $hookmanager->initHooks(array('homesetup'));
@ -45,16 +47,15 @@ llxHeader('', $langs->trans("Setup"), $wikihelp);
print load_fiche_titre($langs->trans("SetupArea"), '', 'tools'); print load_fiche_titre($langs->trans("SetupArea"), '', 'tools');
if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) {
{
$conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD_SETUPPAGE); $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD_SETUPPAGE);
if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) {
{
$i = 0; $i = 0;
while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) {
{
$tmp = explode('|', $reg[1]); $tmp = explode('|', $reg[1]);
if (!empty($tmp[1])) $langs->load($tmp[1]); if (!empty($tmp[1])) {
$langs->load($tmp[1]);
}
$conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE); $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE);
$i++; $i++;
} }
@ -77,10 +78,11 @@ print '</span>';
print '<br>'; print '<br>';
// Show info setup company // Show info setup company
if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1; if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
$setupcompanynotcomplete = 1;
}
print img_picto('', 'puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); print img_picto('', 'puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup"));
if (!empty($setupcompanynotcomplete)) if (!empty($setupcompanynotcomplete)) {
{
$langs->load("errors"); $langs->load("errors");
$warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"'); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"');
print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit').'">'.$warnpicto.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>'; print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit').'">'.$warnpicto.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
@ -91,8 +93,7 @@ print '<br>';
// Show info setup module // Show info setup module
print img_picto('', 'puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); print img_picto('', 'puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules"));
if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled
{
$langs->load("errors"); $langs->load("errors");
$warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"');
print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home">'.$warnpicto.$langs->trans("WarningEnableYourModulesApplications").'</a></div>'; print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home">'.$warnpicto.$langs->trans("WarningEnableYourModulesApplications").'</a></div>';
@ -106,8 +107,7 @@ print '<br>';
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook)) {
{
// Show into other // Show into other
print '<span class="opacitymedium">'.$langs->trans("SetupDescription5")."</span><br>"; print '<span class="opacitymedium">'.$langs->trans("SetupDescription5")."</span><br>";
print "<br>"; print "<br>";

View File

@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -48,32 +49,57 @@ $hookmanager->initHooks(array('adminldap', 'globaladmin'));
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{ if ($action == 'setvalue' && $user->admin) {
if ($action == 'setvalue' && $user->admin)
{
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (!dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST', GETPOST("host", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE', GETPOST("slave", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_SERVER_PORT', GETPOST("port", 'int'), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_SERVER_DN', GETPOST("dn", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_ADMIN_DN', GETPOST("admin", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST', GETPOST("host", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_ADMIN_PASS', GETPOST("pass", 'none'), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS', GETPOST("usetls", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE', GETPOST("activesynchro", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE', GETPOST("slave", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE', GETPOST("activecontact", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE', GETPOST("activemembers", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_SERVER_PORT', GETPOST("port", 'int'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_SERVER_DN', GETPOST("dn", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_ADMIN_DN', GETPOST("admin", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_ADMIN_PASS', GETPOST("pass", 'none'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS', GETPOST("usetls", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE', GETPOST("activesynchro", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE', GETPOST("activecontact", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE', GETPOST("activemembers", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -96,8 +122,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
$head = ldap_prepare_head(); $head = ldap_prepare_head();
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (!function_exists("ldap_connect")) if (!function_exists("ldap_connect")) {
{
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
} }
@ -126,15 +151,13 @@ $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr");
$arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP"); $arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP");
print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE); print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE);
print '</td><td>'.$langs->trans("LDAPDnSynchroActiveExample"); print '</td><td>'.$langs->trans("LDAPDnSynchroActiveExample");
if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) {
{
print '<br><font class="error">'.$langs->trans("LDAPSetupNotComplete").'</font>'; print '<br><font class="error">'.$langs->trans("LDAPSetupNotComplete").'</font>';
} }
print '</td></tr>'; print '</td></tr>';
// Synchro contact active // Synchro contact active
if (!empty($conf->societe->enabled)) if (!empty($conf->societe->enabled)) {
{
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnContactActive").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnContactActive").'</td><td>';
$arraylist = array(); $arraylist = array();
$arraylist['0'] = $langs->trans("No"); $arraylist['0'] = $langs->trans("No");
@ -144,8 +167,7 @@ if (!empty($conf->societe->enabled))
} }
// Synchro member active // Synchro member active
if (!empty($conf->adherent->enabled)) if (!empty($conf->adherent->enabled)) {
{
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberActive").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberActive").'</td><td>';
$arraylist = array(); $arraylist = array();
$arraylist['0'] = $langs->trans("No"); $arraylist['0'] = $langs->trans("No");
@ -156,8 +178,7 @@ if (!empty($conf->adherent->enabled))
} }
// Synchro member type active // Synchro member type active
if (!empty($conf->adherent->enabled)) if (!empty($conf->adherent->enabled)) {
{
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberTypeActive").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberTypeActive").'</td><td>';
$arraylist = array(); $arraylist = array();
$arraylist['0'] = $langs->trans("No"); $arraylist['0'] = $langs->trans("No");
@ -209,8 +230,7 @@ print '</td><td>'.$langs->trans("LDAPServerExample").'</td></tr>';
// Port // Port
print '<tr class="oddeven"><td>'.$langs->trans("LDAPServerPort").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("LDAPServerPort").'</td><td>';
if (!empty($conf->global->LDAP_SERVER_PORT)) if (!empty($conf->global->LDAP_SERVER_PORT)) {
{
print '<input size="25" type="text" name="port" value="'.$conf->global->LDAP_SERVER_PORT.'">'; print '<input size="25" type="text" name="port" value="'.$conf->global->LDAP_SERVER_PORT.'">';
} else { } else {
print '<input size="25" type="text" name="port" value="389">'; print '<input size="25" type="text" name="port" value="389">';
@ -241,8 +261,7 @@ print '</td><td>'.$langs->trans("LDAPAdminDnExample").'</td></tr>';
// Pass // Pass
print '<tr class="oddeven"><td>'.$langs->trans("LDAPPassword").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("LDAPPassword").'</td><td>';
if (!empty($conf->global->LDAP_ADMIN_PASS)) if (!empty($conf->global->LDAP_ADMIN_PASS)) {
{
print '<input size="25" type="password" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">'; // je le met en visible pour test print '<input size="25" type="password" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">'; // je le met en visible pour test
} else { } else {
print '<input size="25" type="text" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">'; print '<input size="25" type="text" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">';
@ -263,29 +282,23 @@ print '<br>';
/* /*
* Test de la connexion * Test de la connexion
*/ */
if (function_exists("ldap_connect")) if (function_exists("ldap_connect")) {
{ if (!empty($conf->global->LDAP_SERVER_HOST)) {
if (!empty($conf->global->LDAP_SERVER_HOST))
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test">'.$langs->trans("LDAPTestConnect").'</a><br><br>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test">'.$langs->trans("LDAPTestConnect").'</a><br><br>';
} }
if ($_GET["action"] == 'test') if ($_GET["action"] == 'test') {
{
$ldap = new Ldap(); // Les parametres sont passes et recuperes via $conf $ldap = new Ldap(); // Les parametres sont passes et recuperes via $conf
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
// Test ldap connect and bind // Test ldap connect and bind
print img_picto('', 'info').' '; print img_picto('', 'info').' ';
print '<font class="ok">'.$langs->trans("LDAPTCPConnectOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).'</font>'; print '<font class="ok">'.$langs->trans("LDAPTCPConnectOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).'</font>';
print '<br>'; print '<br>';
if ($conf->global->LDAP_ADMIN_DN && !empty($conf->global->LDAP_ADMIN_PASS)) if ($conf->global->LDAP_ADMIN_DN && !empty($conf->global->LDAP_ADMIN_PASS)) {
{ if ($result == 2) {
if ($result == 2)
{
print img_picto('', 'info').' '; print img_picto('', 'info').' ';
print '<font class="ok">'.$langs->trans("LDAPBindOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).'</font>'; print '<font class="ok">'.$langs->trans("LDAPBindOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).'</font>';
print '<br>'; print '<br>';
@ -304,8 +317,7 @@ if (function_exists("ldap_connect"))
// Test ldap_getversion // Test ldap_getversion
if (($ldap->getVersion() == 3)) if (($ldap->getVersion() == 3)) {
{
print img_picto('', 'info').' '; print img_picto('', 'info').' ';
print '<font class="ok">'.$langs->trans("LDAPSetupForVersion3").'</font>'; print '<font class="ok">'.$langs->trans("LDAPSetupForVersion3").'</font>';
print '<br>'; print '<br>';

View File

@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "errors")); $langs->loadLangs(array("admin", "errors"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -44,38 +45,72 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (!dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
// This one must be after the others // This one must be after the others
$valkey = ''; $valkey = '';
$key = GETPOST("key"); $key = GETPOST("key");
if ($key) $valkey = $conf->global->$key; if ($key) {
if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; $valkey = $conf->global->$key;
}
if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -100,8 +135,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
$head = ldap_prepare_head(); $head = ldap_prepare_head();
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (!function_exists("ldap_connect")) if (!function_exists("ldap_connect")) {
{
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
} }
@ -265,10 +299,8 @@ $objectclass = $conf->global->LDAP_CONTACT_OBJECT_CLASS;
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
if (function_exists("ldap_connect")) if (function_exists("ldap_connect")) {
{ if ($_GET["action"] == 'test') {
if ($_GET["action"] == 'test')
{
// Creation objet // Creation objet
$object = new Contact($db); $object = new Contact($db);
$object->initAsSpecimen(); $object->initAsSpecimen();
@ -277,8 +309,7 @@ if (function_exists("ldap_connect"))
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info); $dn = $object->_load_ldap_dn($info);
@ -286,8 +317,7 @@ if (function_exists("ldap_connect"))
$result2 = $ldap->add($dn, $info, $user); // Now the test $result2 = $ldap->add($dn, $info, $user); // Now the test
$result3 = $ldap->delete($dn); // Clean what we did $result3 = $ldap->delete($dn); // Clean what we did
if ($result2 > 0) if ($result2 > 0) {
{
print img_picto('', 'info').' '; print img_picto('', 'info').' ';
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>'; print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
} else { } else {

View File

@ -36,8 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "errors")); $langs->loadLangs(array("admin", "errors"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -46,28 +47,42 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; $error++;
}
if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
//if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',GETPOST("fieldname", 'alphanohtml'),'chaine',0,'',$conf->entity)) $error++; //if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',GETPOST("fieldname", 'alphanohtml'),'chaine',0,'',$conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
// This one must be after the others // This one must be after the others
$valkey = ''; $valkey = '';
$key = GETPOST("key"); $key = GETPOST("key");
if ($key) $valkey = $conf->global->$key; if ($key) {
if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; $valkey = $conf->global->$key;
}
if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -90,8 +105,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
$head = ldap_prepare_head(); $head = ldap_prepare_head();
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (!function_exists("ldap_connect")) if (!function_exists("ldap_connect")) {
{
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
} }
@ -190,8 +204,7 @@ print '</form>';
/* /*
* Test de la connexion * Test de la connexion
*/ */
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
{
$butlabel = $langs->trans("LDAPTestSynchroGroup"); $butlabel = $langs->trans("LDAPTestSynchroGroup");
$testlabel = 'testgroup'; $testlabel = 'testgroup';
$key = $conf->global->LDAP_KEY_GROUPS; $key = $conf->global->LDAP_KEY_GROUPS;
@ -201,10 +214,8 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
} }
if (function_exists("ldap_connect")) if (function_exists("ldap_connect")) {
{ if ($_GET["action"] == 'testgroup') {
if ($_GET["action"] == 'testgroup')
{
// Creation objet // Creation objet
$object = new UserGroup($db); $object = new UserGroup($db);
$object->initAsSpecimen(); $object->initAsSpecimen();
@ -213,8 +224,7 @@ if (function_exists("ldap_connect"))
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info); $dn = $object->_load_ldap_dn($info);
@ -227,8 +237,7 @@ if (function_exists("ldap_connect"))
$result2 = $ldap->add($dn, $info, $user); // Now the test $result2 = $ldap->add($dn, $info, $user); // Now the test
$result3 = $ldap->delete($dn); // Clean what we did $result3 = $ldap->delete($dn); // Clean what we did
if ($result2 > 0) if ($result2 > 0) {
{
print img_picto('', 'info').' '; print img_picto('', 'info').' ';
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>'; print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
} else { } else {

View File

@ -36,8 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors')); $langs->loadLangs(array('admin', 'errors'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -45,54 +46,116 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
// Members // Members
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
// Subscriptions // Subscriptions
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
// This one must be after the others // This one must be after the others
$valkey = ''; $valkey = '';
$key = GETPOST("key"); $key = GETPOST("key");
if ($key) $valkey = $conf->global->$key; if ($key) {
if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; $valkey = $conf->global->$key;
}
if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -117,8 +180,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
$head = ldap_prepare_head(); $head = ldap_prepare_head();
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (!function_exists("ldap_connect")) if (!function_exists("ldap_connect")) {
{
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
} }
@ -377,8 +439,7 @@ print '</form>';
/* /*
* Test de la connexion * Test de la connexion
*/ */
if (!empty($conf->global->LDAP_MEMBER_ACTIVE)) if (!empty($conf->global->LDAP_MEMBER_ACTIVE)) {
{
$butlabel = $langs->trans("LDAPTestSynchroMember"); $butlabel = $langs->trans("LDAPTestSynchroMember");
$testlabel = 'testmember'; $testlabel = 'testmember';
$key = $conf->global->LDAP_KEY_MEMBERS; $key = $conf->global->LDAP_KEY_MEMBERS;
@ -388,10 +449,8 @@ if (!empty($conf->global->LDAP_MEMBER_ACTIVE))
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
} }
if (function_exists("ldap_connect")) if (function_exists("ldap_connect")) {
{ if ($_GET["action"] == 'testmember') {
if ($_GET["action"] == 'testmember')
{
// Creation objet // Creation objet
$object = new Adherent($db); $object = new Adherent($db);
$object->initAsSpecimen(); $object->initAsSpecimen();
@ -400,8 +459,7 @@ if (function_exists("ldap_connect"))
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info); $dn = $object->_load_ldap_dn($info);
@ -409,8 +467,7 @@ if (function_exists("ldap_connect"))
$result2 = $ldap->add($dn, $info, $user); // Now the test $result2 = $ldap->add($dn, $info, $user); // Now the test
$result3 = $ldap->delete($dn); // Clean what we did $result3 = $ldap->delete($dn); // Clean what we did
if ($result2 > 0) if ($result2 > 0) {
{
print img_picto('', 'info').' '; print img_picto('', 'info').' ';
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>'; print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
} else { } else {

View File

@ -36,8 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors')); $langs->loadLangs(array('admin', 'errors'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -46,26 +47,38 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
// This one must be after the others // This one must be after the others
$valkey = ''; $valkey = '';
$key = GETPOST("key"); $key = GETPOST("key");
if ($key) $valkey = $conf->global->$key; if ($key) {
if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) $error++; $valkey = $conf->global->$key;
}
if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -88,8 +101,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
$head = ldap_prepare_head(); $head = ldap_prepare_head();
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (!function_exists("ldap_connect")) if (!function_exists("ldap_connect")) {
{
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
} }
@ -172,8 +184,7 @@ print '</form>';
/* /*
* Test de la connexion * Test de la connexion
*/ */
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
{
$butlabel = $langs->trans("LDAPTestSynchroMemberType"); $butlabel = $langs->trans("LDAPTestSynchroMemberType");
$testlabel = 'testmembertype'; $testlabel = 'testmembertype';
$key = $conf->global->LDAP_KEY_MEMBERS_TYPES; $key = $conf->global->LDAP_KEY_MEMBERS_TYPES;
@ -183,10 +194,8 @@ if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
} }
if (function_exists("ldap_connect")) if (function_exists("ldap_connect")) {
{ if ($_GET["action"] == 'testmembertype') {
if ($_GET["action"] == 'testmembertype')
{
// Creation objet // Creation objet
$object = new AdherentType($db); $object = new AdherentType($db);
$object->initAsSpecimen(); $object->initAsSpecimen();
@ -195,8 +204,7 @@ if (function_exists("ldap_connect"))
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info); $dn = $object->_load_ldap_dn($info);
@ -209,8 +217,7 @@ if (function_exists("ldap_connect"))
$result2 = $ldap->add($dn, $info, $user); // Now the test $result2 = $ldap->add($dn, $info, $user); // Now the test
$result3 = $ldap->delete($dn); // Clean what we did $result3 = $ldap->delete($dn); // Clean what we did
if ($result2 > 0) if ($result2 > 0) {
{
print img_picto('', 'info').' '; print img_picto('', 'info').' ';
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>'; print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
} else { } else {

View File

@ -37,8 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors')); $langs->loadLangs(array('admin', 'errors'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -46,47 +47,103 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (!dolibarr_set_const($db, 'LDAP_USER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_USER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'LDAP_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) $error++; $error++;
if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), 'chaine', 0, '', $conf->entity)) $error++; }
if (!dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), 'chaine', 0, '', $conf->entity)) {
$error++;
}
// This one must be after the others // This one must be after the others
$valkey = ''; $valkey = '';
$key = GETPOST("key"); $key = GETPOST("key");
if ($key) $valkey = $conf->global->$key; if ($key) {
if (!dolibarr_set_const($db, 'LDAP_KEY_USERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; $valkey = $conf->global->$key;
}
if (!dolibarr_set_const($db, 'LDAP_KEY_USERS', $valkey, 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -111,8 +168,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
$head = ldap_prepare_head(); $head = ldap_prepare_head();
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (!function_exists("ldap_connect")) if (!function_exists("ldap_connect")) {
{
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
} }
@ -346,8 +402,7 @@ print '</form>';
/* /*
* Test de la connexion * Test de la connexion
*/ */
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
{
$butlabel = $langs->trans("LDAPTestSynchroUser"); $butlabel = $langs->trans("LDAPTestSynchroUser");
$testlabel = 'testuser'; $testlabel = 'testuser';
$key = $conf->global->LDAP_KEY_USERS; $key = $conf->global->LDAP_KEY_USERS;
@ -355,8 +410,7 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
$objectclass = $conf->global->LDAP_USER_OBJECT_CLASS; $objectclass = $conf->global->LDAP_USER_OBJECT_CLASS;
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') } elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
{
$butlabel = $langs->trans("LDAPTestSearch"); $butlabel = $langs->trans("LDAPTestSearch");
$testlabel = 'testsearchuser'; $testlabel = 'testsearchuser';
$key = $conf->global->LDAP_KEY_USERS; $key = $conf->global->LDAP_KEY_USERS;
@ -365,10 +419,8 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
} }
if (function_exists("ldap_connect")) if (function_exists("ldap_connect")) {
{ if ($action == 'testuser') {
if ($action == 'testuser')
{
// Creation objet // Creation objet
$object = new User($db); $object = new User($db);
$object->initAsSpecimen(); $object->initAsSpecimen();
@ -379,8 +431,7 @@ if (function_exists("ldap_connect"))
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info); $dn = $object->_load_ldap_dn($info);
@ -388,8 +439,7 @@ if (function_exists("ldap_connect"))
$result2 = $ldap->add($dn, $info, $user); // Now the test $result2 = $ldap->add($dn, $info, $user); // Now the test
$result3 = $ldap->delete($dn); // Clean what we did $result3 = $ldap->delete($dn); // Clean what we did
if ($result2 > 0) if ($result2 > 0) {
{
print img_picto('', 'info').' '; print img_picto('', 'info').' ';
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>'; print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
} else { } else {
@ -413,8 +463,7 @@ if (function_exists("ldap_connect"))
} }
} }
if ($action == 'testsearchuser') if ($action == 'testsearchuser') {
{
// Creation objet // Creation objet
$object = new User($db); $object = new User($db);
$object->initAsSpecimen(); $object->initAsSpecimen();
@ -425,8 +474,7 @@ if (function_exists("ldap_connect"))
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$required_fields = array( $required_fields = array(
$conf->global->LDAP_KEY_USERS, $conf->global->LDAP_KEY_USERS,
$conf->global->LDAP_FIELD_FULLNAME, $conf->global->LDAP_FIELD_FULLNAME,
@ -453,17 +501,13 @@ if (function_exists("ldap_connect"))
$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
//$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, '', 1); //$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, '', 1);
if (is_array($ldapusers)) if (is_array($ldapusers)) {
{
$liste = array(); $liste = array();
foreach ($ldapusers as $key => $ldapuser) foreach ($ldapusers as $key => $ldapuser) {
{
// Define the label string for this user // Define the label string for this user
$label = ''; $label = '';
foreach ($required_fields as $value) foreach ($required_fields as $value) {
{ if ($value) {
if ($value)
{
$label .= $value."=".$ldapuser[$value]." "; $label .= $value."=".$ldapuser[$value]." ";
} }
} }

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('companies', 'products', 'admin')); $langs->loadLangs(array('companies', 'products', 'admin'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$currencycode = GETPOST('currencycode', 'alpha'); $currencycode = GETPOST('currencycode', 'alpha');
@ -49,39 +51,33 @@ $valmainmaxdecimalstot = GETPOST($mainmaxdecimalstot, 'int');
$valmainmaxdecimalsshown = GETPOST($mainmaxdecimalsshown, 'int'); $valmainmaxdecimalsshown = GETPOST($mainmaxdecimalsshown, 'int');
$valmainroundingruletot = price2num(GETPOST($mainroundingruletot, 'alpha')); $valmainroundingruletot = price2num(GETPOST($mainroundingruletot, 'alpha'));
if ($action == 'update') if ($action == 'update') {
{
$error = 0; $error = 0;
$MAXDEC = 8; $MAXDEC = 8;
if ($_POST[$mainmaxdecimalsunit] > $MAXDEC if ($_POST[$mainmaxdecimalsunit] > $MAXDEC
|| $_POST[$mainmaxdecimalstot] > $MAXDEC || $_POST[$mainmaxdecimalstot] > $MAXDEC
|| $_POST[$mainmaxdecimalsshown] > $MAXDEC) || $_POST[$mainmaxdecimalsshown] > $MAXDEC) {
{
$error++; $error++;
setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors'); setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors');
} }
if ($_POST[$mainmaxdecimalsunit].(!empty($currencycode) ? '_'.$currencycode : '') < 0 if ($_POST[$mainmaxdecimalsunit].(!empty($currencycode) ? '_'.$currencycode : '') < 0
|| $_POST[$mainmaxdecimalstot] < 0 || $_POST[$mainmaxdecimalstot] < 0
|| $_POST[$mainmaxdecimalsshown] < 0) || $_POST[$mainmaxdecimalsshown] < 0) {
{
$langs->load("errors"); $langs->load("errors");
$error++; $error++;
setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors'); setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors');
} }
if ($valmainroundingruletot) if ($valmainroundingruletot) {
{ if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) {
if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1)
{
$langs->load("errors"); $langs->load("errors");
$error++; $error++;
setEventMessages($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), null, 'errors'); setEventMessages($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), null, 'errors');
} }
} }
if (!$error) if (!$error) {
{
dolibarr_set_const($db, $mainmaxdecimalsunit, $valmainmaxdecimalsunit, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $mainmaxdecimalsunit, $valmainmaxdecimalsunit, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalstot, $valmainmaxdecimalstot, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $mainmaxdecimalstot, $valmainmaxdecimalstot, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalsshown, $valmainmaxdecimalsshown, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $mainmaxdecimalsshown, $valmainmaxdecimalsshown, 'chaine', 0, '', $conf->entity);
@ -109,24 +105,20 @@ print load_fiche_titre($title, '', 'title_setup');
$aCurrencies = array($conf->currency); // Default currency always first position $aCurrencies = array($conf->currency); // Default currency always first position
if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
$sql = 'SELECT rowid, code FROM '.MAIN_DB_PREFIX.'multicurrency'; $sql = 'SELECT rowid, code FROM '.MAIN_DB_PREFIX.'multicurrency';
$sql .= ' WHERE entity = '.$conf->entity; $sql .= ' WHERE entity = '.$conf->entity;
$sql .= ' AND code != "'.$conf->currency.'"'; // Default currency always first position $sql .= ' AND code != "'.$conf->currency.'"'; // Default currency always first position
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{ while ($obj = $db->fetch_object($resql)) {
while ($obj = $db->fetch_object($resql))
{
$aCurrencies[] = $obj->code; $aCurrencies[] = $obj->code;
} }
} }
if (!empty($aCurrencies) && count($aCurrencies) > 1) if (!empty($aCurrencies) && count($aCurrencies) > 1) {
{
$head = multicurrencyLimitPrepareHead($aCurrencies); $head = multicurrencyLimitPrepareHead($aCurrencies);
print dol_get_fiche_head($head, $currencycode, '', -1, ''); print dol_get_fiche_head($head, $currencycode, '', -1, '');
@ -136,8 +128,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY
print '<span class="opacitymedium">'.$langs->trans("LimitsDesc")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("LimitsDesc")."</span><br>\n";
print "<br>\n"; print "<br>\n";
if ($action == 'edit') if ($action == 'edit') {
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -203,16 +194,13 @@ if ($action == 'edit')
print '</div>'; print '</div>';
} }
if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
{ if (!empty($aCurrencies) && count($aCurrencies) > 1) {
if (!empty($aCurrencies) && count($aCurrencies) > 1)
{
print dol_get_fiche_end(); print dol_get_fiche_end();
} }
} }
if (empty($mysoc->country_code)) if (empty($mysoc->country_code)) {
{
$langs->load("errors"); $langs->load("errors");
$warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
print '<br><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a>'; print '<br><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a>';
@ -252,26 +240,22 @@ if (empty($mysoc->country_code))
$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($mysoc->country_code)."' AND (t.taux <> 0 OR t.localtax1 <>0 OR t.localtax2 <>0)"; $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($mysoc->country_code)."' AND (t.taux <> 0 OR t.localtax1 <>0 OR t.localtax2 <>0)";
$sql .= " ORDER BY t.taux ASC"; $sql .= " ORDER BY t.taux ASC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num) {
{ for ($i = 0; $i < $num; $i++) {
for ($i = 0; $i < $num; $i++)
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2); $vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2);
} }
} }
} else dol_print_error($db); } else {
dol_print_error($db);
}
if (count($vat_rates)) if (count($vat_rates)) {
{ foreach ($vat_rates as $vatarray) {
foreach ($vat_rates as $vatarray)
{
$vat = $vatarray['vat_rate']; $vat = $vatarray['vat_rate'];
for ($qty = 1; $qty <= 2; $qty++) for ($qty = 1; $qty <= 2; $qty++) {
{
$vattxt = $vat.($vatarray['code'] ? ' ('.$vatarray['code'].')' : ''); $vattxt = $vat.($vatarray['code'] ? ' ('.$vatarray['code'].')' : '');
$localtax_array = getLocalTaxesFromRate($vattxt, 0, $mysoc, $mysoc); $localtax_array = getLocalTaxesFromRate($vattxt, 0, $mysoc, $mysoc);

View File

@ -26,14 +26,17 @@ require '../main.inc.php';
// Class // Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'loan')); $langs->loadLangs(array('admin', 'loan'));
// Security check // Security check
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -48,8 +51,7 @@ $list = array(
* Actions * Actions
*/ */
if ($action == 'update') if ($action == 'update') {
{
$error = 0; $error = 0;
foreach ($list as $constname) { foreach ($list as $constname) {
@ -60,8 +62,7 @@ if ($action == 'update')
} }
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -75,7 +76,9 @@ if ($action == 'update')
llxHeader(); llxHeader();
$form = new Form($db); $form = new Form($db);
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); if (!empty($conf->accounting->enabled)) {
$formaccounting = new FormAccounting($db);
}
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup'); print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup');
@ -92,8 +95,7 @@ print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans('Options').'</td>'; print '<td colspan="3">'.$langs->trans('Options').'</td>';
print "</tr>\n"; print "</tr>\n";
foreach ($list as $key) foreach ($list as $key) {
{
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
@ -102,8 +104,7 @@ foreach ($list as $key)
// Value // Value
print '<td>'; print '<td>';
if (!empty($conf->accounting->enabled)) if (!empty($conf->accounting->enabled)) {
{
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
} else { } else {
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">'; print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "mails")); $langs->loadLangs(array("admin", "mails"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -41,8 +43,7 @@ $form = new Form($db);
* Actions * Actions
*/ */
if ($action == 'setvalue') if ($action == 'setvalue') {
{
$db->begin(); $db->begin();
$mailfrom = GETPOST('MAILING_EMAIL_FROM', 'alpha'); $mailfrom = GETPOST('MAILING_EMAIL_FROM', 'alpha');
@ -53,17 +54,27 @@ if ($action == 'setvalue')
$contactbulkdefault = GETPOST('MAILING_CONTACT_DEFAULT_BULK_STATUS', 'int'); $contactbulkdefault = GETPOST('MAILING_CONTACT_DEFAULT_BULK_STATUS', 'int');
$res = dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO", $mailerror, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO", $mailerror, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, "MAILING_CONTACT_DEFAULT_BULK_STATUS", $contactbulkdefault, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MAILING_CONTACT_DEFAULT_BULK_STATUS", $contactbulkdefault, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
// Create temporary encryption key if nedded // Create temporary encryption key if nedded
$res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) { if (!$error) {
@ -77,9 +88,10 @@ if ($action == 'setvalue')
if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
$setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -95,8 +107,7 @@ llxHeader('', $langs->trans("MailingSetup"));
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup');
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
print "\n".'<script type="text/javascript">'; print "\n".'<script type="text/javascript">';
print '$(document).ready(function () { print '$(document).ready(function () {
$("#generate_token").click(function() { $("#generate_token").click(function() {
@ -126,13 +137,17 @@ print "</tr>\n";
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("MailingEMailFrom").'</td><td>'; print $langs->trans("MailingEMailFrom").'</td><td>';
print '<input size="32" type="text" name="MAILING_EMAIL_FROM" value="'.$conf->global->MAILING_EMAIL_FROM.'">'; print '<input size="32" type="text" name="MAILING_EMAIL_FROM" value="'.$conf->global->MAILING_EMAIL_FROM.'">';
if (!empty($conf->global->MAILING_EMAIL_FROM) && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail")); if (!empty($conf->global->MAILING_EMAIL_FROM) && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) {
print ' '.img_warning($langs->trans("BadEMail"));
}
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("MailingEMailError").'</td><td>'; print $langs->trans("MailingEMailError").'</td><td>';
print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf->global->MAILING_EMAIL_ERRORSTO.'">'; print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf->global->MAILING_EMAIL_ERRORSTO.'">';
if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && !isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail")); if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && !isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) {
print ' '.img_warning($langs->trans("BadEMail"));
}
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
@ -147,7 +162,9 @@ print '</td></tr>';
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("ActivateCheckReadKey").'</td><td>'; print $langs->trans("ActivateCheckReadKey").'</td><td>';
print '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAILING_EMAIL_UNSUBSCRIBE_KEY" value="'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY.'">'; print '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAILING_EMAIL_UNSUBSCRIBE_KEY" value="'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY.'">';
if (!empty($conf->use_javascript_ajax)) print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
}
print '</td></tr>'; print '</td></tr>';
// default blacklist from mailing // default blacklist from mailing

View File

@ -35,7 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "members", "mailmanspip")); $langs->loadLangs(array("admin", "members", "mailmanspip"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$type = array('yesno', 'texte', 'chaine'); $type = array('yesno', 'texte', 'chaine');
@ -49,21 +51,20 @@ $testunsubscribeemail = GETPOST("testunsubscribeemail");
*/ */
// Action updated or added a constant // Action updated or added a constant
if ($action == 'update' || $action == 'add') if ($action == 'update' || $action == 'add') {
{ foreach ($_POST['constname'] as $key => $val) {
foreach ($_POST['constname'] as $key => $val)
{
$constname = $_POST["constname"][$key]; $constname = $_POST["constname"][$key];
$constvalue = $_POST["constvalue"][$key]; $constvalue = $_POST["constvalue"][$key];
$consttype = $_POST["consttype"][$key]; $consttype = $_POST["consttype"][$key];
$constnote = $_POST["constnote"][$key]; $constnote = $_POST["constnote"][$key];
$res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -71,30 +72,24 @@ if ($action == 'update' || $action == 'add')
} }
// Action activation d'un sous module du module adherent // Action activation d'un sous module du module adherent
if ($action == 'set') if ($action == 'set') {
{
$result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
if ($result < 0) if ($result < 0) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// Action desactivation d'un sous module du module adherent // Action desactivation d'un sous module du module adherent
if ($action == 'unset') if ($action == 'unset') {
{
$result = dolibarr_del_const($db, $_GET["name"], $conf->entity); $result = dolibarr_del_const($db, $_GET["name"], $conf->entity);
if ($result < 0) if ($result < 0) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
if (($action == 'testsubscribe' || $action == 'testunsubscribe') && !empty($conf->global->ADHERENT_USE_MAILMAN)) if (($action == 'testsubscribe' || $action == 'testunsubscribe') && !empty($conf->global->ADHERENT_USE_MAILMAN)) {
{
$email = GETPOST($action.'email'); $email = GETPOST($action.'email');
if (!isValidEmail($email)) if (!isValidEmail($email)) {
{
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors'); setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
} else { } else {
@ -107,22 +102,18 @@ if (($action == 'testsubscribe' || $action == 'testunsubscribe') && !empty($conf
/*$object->element='member'; /*$object->element='member';
$object->type='Preferred Partners'; */ $object->type='Preferred Partners'; */
if ($action == 'testsubscribe') if ($action == 'testsubscribe') {
{
$result = $mailmanspip->add_to_mailman($object); $result = $mailmanspip->add_to_mailman($object);
if ($result < 0) if ($result < 0) {
{
$error++; $error++;
setEventMessages($mailmanspip->error, $mailmanspip->errors, 'errors'); setEventMessages($mailmanspip->error, $mailmanspip->errors, 'errors');
} else { } else {
setEventMessages($langs->trans("MailmanCreationSuccess"), null); setEventMessages($langs->trans("MailmanCreationSuccess"), null);
} }
} }
if ($action == 'testunsubscribe') if ($action == 'testunsubscribe') {
{
$result = $mailmanspip->del_to_mailman($object); $result = $mailmanspip->del_to_mailman($object);
if ($result < 0) if ($result < 0) {
{
$error++; $error++;
setEventMessages($mailmanspip->error, $mailmanspip->errors, 'errors'); setEventMessages($mailmanspip->error, $mailmanspip->errors, 'errors');
} else { } else {
@ -147,8 +138,7 @@ print load_fiche_titre($langs->trans("MailmanSpipSetup"), $linkback, 'title_setu
$head = mailmanspip_admin_prepare_head(); $head = mailmanspip_admin_prepare_head();
if (!empty($conf->global->ADHERENT_USE_MAILMAN)) if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
{
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -216,8 +206,7 @@ if (!empty($conf->global->ADHERENT_USE_MAILMAN))
} }
if (!empty($conf->global->ADHERENT_USE_MAILMAN)) if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
{
print '<form action="'.$_SERVER["PHP_SELF"].'">'; print '<form action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="testsubscribe">'; print '<input type="hidden" name="action" value="testsubscribe">';

View File

@ -33,13 +33,14 @@ $langs->loadLangs(array("companies", "products", "admin", "mails", "other", "err
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$usersignature = $user->signature; $usersignature = $user->signature;
// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
if ($action == 'test' || $action == 'send') if ($action == 'test' || $action == 'send') {
{
$usersignature = dol_string_nohtmltag($usersignature, 2); $usersignature = dol_string_nohtmltag($usersignature, 2);
} }
@ -65,8 +66,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs);
* Actions * Actions
*/ */
if ($action == 'update' && !$cancel) if ($action == 'update' && !$cancel) {
{
if (!$error && !GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) { if (!$error && !GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MAIN_MAIL_EMAIL_FROM")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MAIN_MAIL_EMAIL_FROM")), null, 'errors');
@ -118,8 +118,12 @@ $trackid = (($action == 'testhtml') ? "testhtml" : "test");
$sendcontext = ''; $sendcontext = '';
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action = 'test'; if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') {
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $action = 'testhtml'; $action = 'test';
}
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') {
$action = 'testhtml';
}
@ -138,11 +142,17 @@ if (preg_match('/^mac/i', PHP_OS)) {
$linuxlike = 0; $linuxlike = 0;
} }
if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE = 'mail'; if (empty($conf->global->MAIN_MAIL_SENDMODE)) {
$conf->global->MAIN_MAIL_SENDMODE = 'mail';
}
$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port'); $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port');
if (!$port) $port = 25; if (!$port) {
$port = 25;
}
$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get('SMTP'); $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get('SMTP');
if (!$server) $server = '127.0.0.1'; if (!$server) {
$server = '127.0.0.1';
}
$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; $wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
@ -156,13 +166,13 @@ $head = email_admin_prepare_head();
$listofmethods = array(); $listofmethods = array();
$listofmethods['mail'] = 'PHP mail function'; $listofmethods['mail'] = 'PHP mail function';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
if (version_compare(phpversion(), '7.0', '>=')) $listofmethods['swiftmailer'] = 'Swift Mailer socket library'; if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
if ($action == 'edit') if ($action == 'edit') {
{ if ($conf->use_javascript_ajax) {
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () { print 'jQuery(document).ready(function () {
function initfields() function initfields()
@ -185,8 +195,7 @@ if ($action == 'edit')
jQuery(".smtp_method").hide(); jQuery(".smtp_method").hide();
jQuery(".dkim").hide(); jQuery(".dkim").hide();
'; ';
if ($linuxlike) if ($linuxlike) {
{
print ' print '
jQuery("#MAIN_MAIL_SMTP_SERVER").hide(); jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
jQuery("#MAIN_MAIL_SMTP_PORT").hide(); jQuery("#MAIN_MAIL_SMTP_PORT").hide();
@ -312,12 +321,13 @@ if ($action == 'edit')
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
{
print $form->selectarray('MAIN_MAIL_SENDMODE', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE); print $form->selectarray('MAIN_MAIL_SENDMODE', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE);
} else { } else {
$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
if (empty($text)) $text = $langs->trans("Undefined"); if (empty($text)) {
$text = $langs->trans("Undefined");
}
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
print '<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.$conf->global->MAIN_MAIL_SENDMODE.'">'; print '<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.$conf->global->MAIN_MAIL_SENDMODE.'">';
@ -336,12 +346,14 @@ if ($action == 'edit')
print '<td>'; print '<td>';
$mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ''); $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '');
$smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); if ($linuxlike) {
else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver); print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
} else {
print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
}
print '</td><td>'; print '</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'" autocomplete="off">'; print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'" autocomplete="off">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.'">'; print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.'">';
print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>'; print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
@ -358,20 +370,21 @@ if ($action == 'edit')
// Port // Port
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') {
{
print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
print '</td><td>'; print '</td><td>';
print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>'; print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
} else { } else {
$mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ''); $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '');
$smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined"); $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); if ($linuxlike) {
else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport); print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
} else {
print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
}
print '</td><td>'; print '</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.'">'; print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.'">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.'">'; print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.'">';
print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>'; print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
@ -385,13 +398,11 @@ if ($action == 'edit')
print '</td></tr>'; print '</td></tr>';
// ID // ID
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
{
$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : ''); $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : '');
print '<tr class="drag drop oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'; print '<tr class="drag drop oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.'">'; print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.'">';
} else { } else {
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
@ -402,15 +413,13 @@ if ($action == 'edit')
} }
// PW // PW
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
{
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : ''); $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : '');
print '<tr class="drag drop oddeven"><td>'; print '<tr class="drag drop oddeven"><td>';
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword")); print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword"));
print '</td><td>'; print '</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.'" autocomplete="off">'; print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.'" autocomplete="off">';
} else { } else {
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
@ -422,46 +431,54 @@ if ($action == 'edit')
// TLS // TLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// STARTTLS // STARTTLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// SMTP_ALLOW_SELF_SIGNED // SMTP_ALLOW_SELF_SIGNED
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// DKIM // DKIM
print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>'; print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// DKIM Domain // DKIM Domain
@ -538,16 +555,20 @@ if ($action == 'edit')
// Disable // Disable
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn($conf->global->MAIN_DISABLE_ALL_MAILS); print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn($conf->global->MAIN_DISABLE_ALL_MAILS);
if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled")); if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
print img_warning($langs->trans("Disabled"));
}
print '</td></tr>'; print '</td></tr>';
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
// Force e-mail recipient // Force e-mail recipient
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.$conf->global->MAIN_MAIL_FORCE_SENDTO; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.$conf->global->MAIN_MAIL_FORCE_SENDTO;
if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) {
{ if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) {
if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); print img_warning($langs->trans("ErrorBadEMail"));
else print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue")); } else {
print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
}
} }
print '</td></tr>'; print '</td></tr>';
} }
@ -565,7 +586,9 @@ if ($action == 'edit')
// Method // Method
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
if (empty($text)) $text = $langs->trans("Undefined").img_warning(); if (empty($text)) {
$text = $langs->trans("Undefined").img_warning();
}
print $text; print $text;
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
@ -575,78 +598,81 @@ if ($action == 'edit')
print '</td></tr>'; print '</td></tr>';
// Host server // Host server
if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) {
{
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
} else { } else {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'</td></tr>';
} }
// Port // Port
if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) {
{
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
} else { } else {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'</td></tr>';
} }
// SMTPS ID // SMTPS ID
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
{
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.'</td></tr>';
} }
// SMTPS PW // SMTPS PW
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
{
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'</td></tr>';
} }
// TLS // TLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_TLS); print yn($conf->global->MAIN_MAIL_EMAIL_TLS);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
}
print '</td></tr>'; print '</td></tr>';
// STARTTLS // STARTTLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS); print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
}
print '</td></tr>'; print '</td></tr>';
// SMTP_ALLOW_SELF_SIGNED // SMTP_ALLOW_SELF_SIGNED
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED); print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
}
print '</td></tr>'; print '</td></tr>';
if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') {
{
// DKIM // DKIM
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED); print yn($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// Domain // Domain
@ -681,8 +707,11 @@ if ($action == 'edit')
// From // From
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).'</td>';
print '<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM; print '<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("Mandatory")); if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) {
elseif (!isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); print img_warning($langs->trans("Mandatory"));
} elseif (!isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
print img_warning($langs->trans("ErrorBadEMail"));
}
print '</td></tr>'; print '</td></tr>';
// Default from type // Default from type
@ -692,36 +721,31 @@ if ($action == 'edit')
$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile'; $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')'; $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')';
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) if ($obj) {
{
$liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>';
} }
$i++; $i++;
} }
} else dol_print_error($db); } else {
dol_print_error($db);
}
print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>'; print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
print '<td>'; print '<td>';
if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'robot') if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'robot') {
{
print $langs->trans('RobotEmail'); print $langs->trans('RobotEmail');
} elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user') } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user') {
{
print $langs->trans('UserEmail'); print $langs->trans('UserEmail');
} elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'company') } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'company') {
{
print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>'); print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>');
} else { } else {
$id = preg_replace('/senderprofile_/', '', $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE); $id = preg_replace('/senderprofile_/', '', $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE);
if ($id > 0) if ($id > 0) {
{
include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php';
$emailsenderprofile = new EmailSenderProfile($db); $emailsenderprofile = new EmailSenderProfile($db);
$emailsenderprofile->fetch($id); $emailsenderprofile->fetch($id);
@ -733,16 +757,19 @@ if ($action == 'edit')
// Errors To // Errors To
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
print '<td>'.$conf->global->MAIN_MAIL_ERRORS_TO; print '<td>'.$conf->global->MAIN_MAIL_ERRORS_TO;
if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
print img_warning($langs->trans("ErrorBadEMail"));
}
print '</td></tr>'; print '</td></tr>';
// Autocopy to // Autocopy to
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
print '<td>'; print '<td>';
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
{
print $conf->global->MAIN_MAIL_AUTOCOPY_TO; print $conf->global->MAIN_MAIL_AUTOCOPY_TO;
if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
print img_warning($langs->trans("ErrorBadEMail"));
}
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }
@ -764,10 +791,8 @@ if ($action == 'edit')
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) {
{ if (function_exists('fsockopen') && $port && $server) {
if (function_exists('fsockopen') && $port && $server)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect&date='.dol_now().'#formmailaftertstconnect">'.$langs->trans("DoTestServerAvailability").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect&date='.dol_now().'#formmailaftertstconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
} }
} else { } else {
@ -776,8 +801,7 @@ if ($action == 'edit')
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSend").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSend").'</a>';
if (!empty($conf->fckeditor->enabled)) if (!empty($conf->fckeditor->enabled)) {
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSendHTML").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSendHTML").'</a>';
} }
} }
@ -785,8 +809,7 @@ if ($action == 'edit')
print '</div>'; print '</div>';
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
{
/* /*
// Warning 1 // Warning 1
if ($linuxlike) if ($linuxlike)
@ -801,57 +824,52 @@ if ($action == 'edit')
print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
} }
if (!in_array($action, array('testconnect', 'test', 'testhtml'))) if (!in_array($action, array('testconnect', 'test', 'testhtml'))) {
{
$text = ''; $text = '';
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') {
{
//$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS //$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS
} }
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') {
{ if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD)) {
if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD))
{
// List of string to add in SPF if the setup use the mail method. Example 'include:sendgrid.net include:spf.mydomain.com' // List of string to add in SPF if the setup use the mail method. Example 'include:sendgrid.net include:spf.mydomain.com'
$text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD); $text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
} else { } else {
// MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'. // MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'.
if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
{
// List of IP show as record to add in SPF if we use the mail method // List of IP show as record to add in SPF if we use the mail method
$text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); $text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
} }
} }
} else { } else {
if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
{
// List of IP show as record to add as allowed IP if we use the smtp method. Value is '1.2.3.4, [aaaa:bbbb:cccc:dddd]' // List of IP show as record to add as allowed IP if we use the smtp method. Value is '1.2.3.4, [aaaa:bbbb:cccc:dddd]'
// TODO Add a key to allow to show the IP/name of server detected dynamically // TODO Add a key to allow to show the IP/name of server detected dynamically
$text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); $text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
} }
if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) // Should be required only if you have preset the Dolibarr to use your own SMTP and you want to warn users to update their domain name to match your SMTP server. if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) { // Should be required only if you have preset the Dolibarr to use your own SMTP and you want to warn users to update their domain name to match your SMTP server.
{
// List of string to add in SPF if we use the smtp method. Example 'include:spf.mydomain.com' // List of string to add in SPF if we use the smtp method. Example 'include:spf.mydomain.com'
$text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD); $text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
} }
} }
if ($text) print info_admin($text); if ($text) {
print info_admin($text);
}
} }
// Run the test to connect // Run the test to connect
if ($action == 'testconnect') if ($action == 'testconnect') {
{
print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>'; print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
print load_fiche_titre($langs->trans("DoTestServerAvailability")); print load_fiche_titre($langs->trans("DoTestServerAvailability"));
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext); $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
$result = $mail->check_server_port($server, $port); $result = $mail->check_server_port($server, $port);
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>'; if ($result) {
else { print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
} else {
$errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port); $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
if ($mail->error) { if ($mail->error) {
@ -865,8 +883,7 @@ if ($action == 'edit')
} }
// Show email send test form // Show email send test form
if ($action == 'test' || $action == 'testhtml') if ($action == 'test' || $action == 'testhtml') {
{
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>'; print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
@ -906,8 +923,7 @@ if ($action == 'edit')
$formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
// Init list of files // Init list of files
if (GETPOST("mode", "aZ09") == 'init') if (GETPOST("mode", "aZ09") == 'init') {
{
$formmail->clear_attached_files(); $formmail->clear_attached_files();
} }

View File

@ -32,12 +32,13 @@ $langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'err
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$usersignature = $user->signature; $usersignature = $user->signature;
// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
if ($action == 'test' || $action == 'send') if ($action == 'test' || $action == 'send') {
{
$usersignature = dol_string_nohtmltag($usersignature); $usersignature = dol_string_nohtmltag($usersignature);
} }
@ -58,8 +59,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs);
* Actions * Actions
*/ */
if ($action == 'update' && empty($_POST["cancel"])) if ($action == 'update' && empty($_POST["cancel"])) {
{
// Send mode parameters // Send mode parameters
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"), 'chaine', 0, '', $conf->entity);
@ -85,8 +85,12 @@ $trackid = (($action == 'testhtml') ? "testhtml" : "test");
$sendcontext = 'emailing'; // Force to use dedicated context of setup for emailing $sendcontext = 'emailing'; // Force to use dedicated context of setup for emailing
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if ($action == 'presend' && GETPOST('trackid') == 'test') $action = 'test'; if ($action == 'presend' && GETPOST('trackid') == 'test') {
if ($action == 'presend' && GETPOST('trackid') == 'testhtml') $action = 'testhtml'; $action = 'test';
}
if ($action == 'presend' && GETPOST('trackid') == 'testhtml') {
$action = 'testhtml';
}
@ -98,14 +102,24 @@ if ($action == 'presend' && GETPOST('trackid') == 'testhtml') $action = 'testh
$form = new Form($db); $form = new Form($db);
$linuxlike = 1; $linuxlike = 1;
if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; if (preg_match('/^win/i', PHP_OS)) {
if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; $linuxlike = 0;
}
if (preg_match('/^mac/i', PHP_OS)) {
$linuxlike = 0;
}
if (empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING)) $conf->global->MAIN_MAIL_SENDMODE_EMAILING = 'default'; if (empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING)) {
$conf->global->MAIN_MAIL_SENDMODE_EMAILING = 'default';
}
$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ini_get('smtp_port'); $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ini_get('smtp_port');
if (!$port) $port = 25; if (!$port) {
$port = 25;
}
$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : ini_get('SMTP'); $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : ini_get('SMTP');
if (!$server) $server = '127.0.0.1'; if (!$server) {
$server = '127.0.0.1';
}
$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; $wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
@ -121,13 +135,13 @@ $listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
$listofmethods['mail'] = 'PHP mail function'; $listofmethods['mail'] = 'PHP mail function';
//$listofmethods['simplemail']='Simplemail class'; //$listofmethods['simplemail']='Simplemail class';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
if (version_compare(phpversion(), '7.0', '>=')) $listofmethods['swiftmailer'] = 'Swift Mailer socket library'; if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
if ($action == 'edit') if ($action == 'edit') {
{ if ($conf->use_javascript_ajax) {
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () { print 'jQuery(document).ready(function () {
function initfields() function initfields()
@ -151,8 +165,7 @@ if ($action == 'edit')
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0); jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
'; ';
if ($linuxlike) if ($linuxlike) {
{
print ' print '
jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").hide(); jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").hide();
jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").hide(); jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").hide();
@ -242,12 +255,13 @@ if ($action == 'edit')
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
{
print $form->selectarray('MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_EMAILING); print $form->selectarray('MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_EMAILING);
} else { } else {
$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING];
if (empty($text)) $text = $langs->trans("Undefined"); if (empty($text)) {
$text = $langs->trans("Undefined");
}
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
print '<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="'.$conf->global->MAIN_MAIL_SENDMODE_EMAILING.'">'; print '<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="'.$conf->global->MAIN_MAIL_SENDMODE_EMAILING.'">';
@ -257,20 +271,21 @@ if ($action == 'edit')
// Host server // Host server
print '<tr class="oddeven hideifdefault"><td>'; print '<tr class="oddeven hideifdefault"><td>';
if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail') if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail') {
{
print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
print '</td><td>'; print '</td><td>';
print $langs->trans("SeeLocalSendMailSetup"); print $langs->trans("SeeLocalSendMailSetup");
} else { } else {
$mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : ''); $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : '');
$smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); if ($linuxlike) {
else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver); print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
} else {
print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
}
print '</td><td>'; print '</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="'.$mainserver.'">'; print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="'.$mainserver.'">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="'.$mainserver.'">'; print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="'.$mainserver.'">';
print '<span id="smtp_server_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>'; print '<span id="smtp_server_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
@ -286,20 +301,21 @@ if ($action == 'edit')
// Port // Port
print '<tr class="oddeven hideifdefault"><td>'; print '<tr class="oddeven hideifdefault"><td>';
if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail') if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail') {
{
print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
print '</td><td>'; print '</td><td>';
print $langs->trans("SeeLocalSendMailSetup"); print $langs->trans("SeeLocalSendMailSetup");
} else { } else {
$mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ''); $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : '');
$smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined"); $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); if ($linuxlike) {
else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport); print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
} else {
print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
}
print '</td><td>'; print '</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="'.$mainport.'">'; print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="'.$mainport.'">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="'.$mainport.'">'; print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="'.$mainport.'">';
print '<span id="smtp_port_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>'; print '<span id="smtp_port_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
@ -313,13 +329,11 @@ if ($action == 'edit')
print '</td></tr>'; print '</td></tr>';
// ID // ID
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
{
$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING : ''); $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING : '');
print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'; print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="'.$mainstmpid.'">'; print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="'.$mainstmpid.'">';
} else { } else {
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
@ -330,13 +344,11 @@ if ($action == 'edit')
} }
// PW // PW
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
{
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING : ''); $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING : '');
print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'; print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="'.$mainsmtppw.'">'; print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="'.$mainsmtppw.'">';
} else { } else {
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
@ -349,37 +361,43 @@ if ($action == 'edit')
// TLS // TLS
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// STARTTLS // STARTTLS
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// SMTP_ALLOW_SELF_SIGNED_EMAILING // SMTP_ALLOW_SELF_SIGNED_EMAILING
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -405,71 +423,74 @@ if ($action == 'edit')
// Method // Method
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING];
if (empty($text)) $text = $langs->trans("Undefined").img_warning(); if (empty($text)) {
$text = $langs->trans("Undefined").img_warning();
}
print $text; print $text;
print '</td></tr>'; print '</td></tr>';
if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') {
{
// Host server // Host server
if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) {
{
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
} else { } else {
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : '').'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : '').'</td></tr>';
} }
// Port // Port
if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) {
{
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
} else { } else {
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : '').'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : '').'</td></tr>';
} }
// SMTPS ID // SMTPS ID
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
{
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING.'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING.'</td></tr>';
} }
// SMTPS PW // SMTPS PW
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
{
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING).'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING).'</td></tr>';
} }
// TLS // TLS
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING); print yn($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// STARTTLS // STARTTLS
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING); print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// SMTP_ALLOW_SELF_SIGNED_EMAILING // SMTP_ALLOW_SELF_SIGNED_EMAILING
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING); print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
} }
@ -478,8 +499,7 @@ if ($action == 'edit')
print dol_get_fiche_end(); print dol_get_fiche_end();
if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
{
print '<br>'; print '<br>';
/* /*
// Warning 1 // Warning 1
@ -502,12 +522,9 @@ if ($action == 'edit')
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') {
{ if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'mail' || !$linuxlike) {
if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'mail' || !$linuxlike) if (function_exists('fsockopen') && $port && $server) {
{
if (function_exists('fsockopen') && $port && $server)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
} }
} else { } else {
@ -516,8 +533,7 @@ if ($action == 'edit')
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
if (!empty($conf->fckeditor->enabled)) if (!empty($conf->fckeditor->enabled)) {
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
} }
} }
@ -525,23 +541,22 @@ if ($action == 'edit')
print '</div>'; print '</div>';
if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) {
{
$text = $langs->trans("WarningPHPMail"); $text = $langs->trans("WarningPHPMail");
print info_admin($text); print info_admin($text);
} }
// Run the test to connect // Run the test to connect
if ($action == 'testconnect') if ($action == 'testconnect') {
{
print load_fiche_titre($langs->trans("DoTestServerAvailability")); print load_fiche_titre($langs->trans("DoTestServerAvailability"));
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext); $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
$result = $mail->check_server_port($server, $port); $result = $mail->check_server_port($server, $port);
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>'; if ($result) {
else { print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
} else {
$errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port); $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
if ($mail->error) { if ($mail->error) {
@ -554,8 +569,7 @@ if ($action == 'edit')
} }
// Show email send test form // Show email send test form
if ($action == 'test' || $action == 'testhtml') if ($action == 'test' || $action == 'testhtml') {
{
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>'; print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
@ -592,8 +606,7 @@ if ($action == 'edit')
$formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
// Init list of files // Init list of files
if (GETPOST("mode") == 'init') if (GETPOST("mode") == 'init') {
{
$formmail->clear_attached_files(); $formmail->clear_attached_files();
} }

View File

@ -50,7 +50,9 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -67,13 +69,16 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST) // Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. if (!$sortfield) {
if (!$sortorder) $sortorder = "ASC"; $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) // Protection if external user if ($user->socid > 0) { // Protection if external user
{
//$socid = $user->socid; //$socid = $user->socid;
accessforbidden(); accessforbidden();
} }
@ -82,30 +87,31 @@ if ($user->socid > 0) // Protection if external user
// Initialize array of search criterias // Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha'); $search_all = GETPOST("search_all", 'alpha');
$search = array(); $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if (GETPOST('search_'.$key, 'alpha')) {
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); $search[$key] = GETPOST('search_'.$key, 'alpha');
}
} }
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array(); $fieldstosearchall = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if ($val['searchall']) {
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; $fieldstosearchall['t.'.$key] = $val['label'];
}
} }
// Definition of fields for list // Definition of fields for list
$arrayfields = array(); $arrayfields = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
// If $val['visible']==0, then we never show the field // If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); if (!empty($val['visible'])) {
$arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
}
} }
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
{ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array( $arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
@ -132,15 +138,20 @@ if ($id > 0) {
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Actions cancel, add, update, delete or clone // Actions cancel, add, update, delete or clone
$backurlforlist = $_SERVER["PHP_SELF"].'?action=list'; $backurlforlist = $_SERVER["PHP_SELF"].'?action=list';
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
@ -149,18 +160,15 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
{ foreach ($object->fields as $key => $val) {
foreach ($object->fields as $key => $val)
{
$search[$key] = ''; $search[$key] = '';
} }
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
{
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
} }
@ -170,8 +178,7 @@ if (empty($reshook))
$uploaddir = $conf->admin->dir_output.'/senderprofiles'; $uploaddir = $conf->admin->dir_output.'/senderprofiles';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($action == 'delete') if ($action == 'delete') {
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_email_senderprofile WHERE rowid = ".GETPOST('id', 'int'); $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_email_senderprofile WHERE rowid = ".GETPOST('id', 'int');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
@ -213,13 +220,14 @@ print "<br>\n";
// Build and execute select // Build and execute select
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$sql = 'SELECT '; $sql = 'SELECT ';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$sql .= 't.'.$key.', '; $sql .= 't.'.$key.', ';
} }
// Add fields from extrafields // Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) { if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
} }
// Add fields from hooks // Add fields from hooks
$parameters = array(); $parameters = array();
@ -227,20 +235,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql); $sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
else $sql .= " WHERE 1 = 1"; }
foreach ($search as $key => $val) if ($object->ismultientitymanaged == 1) {
{ $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
if ($key == 'status' && $search[$key] == -1) continue; } else {
$sql .= " WHERE 1 = 1";
}
foreach ($search as $key => $val) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0 || $key == 'active') { if (strpos($object->fields[$key]['type'], 'integer:') === 0 || $key == 'active') {
if ($search[$key] == '-1') $search[$key] = ''; if ($search[$key] == '-1') {
$search[$key] = '';
}
$mode_search = 2; $mode_search = 2;
} }
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); if ($search[$key] != '') {
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
}
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
} }
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
// Add where from extra fields // Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -270,26 +290,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
{
$num = $nbtotalofrecords; $num = $nbtotalofrecords;
} else { } else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset); if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -298,8 +316,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
} }
// Direct jump if only one record found // Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$id = $obj->rowid; $id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/monmodule/emailsenderprofile_card.php?id='.$id); header("Location: ".DOL_URL_ROOT.'/monmodule/emailsenderprofile_card.php?id='.$id);
@ -327,14 +344,24 @@ jQuery(document).ready(function() {
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
foreach ($search as $key => $val) }
{ if ($limit > 0 && $limit != $conf->liste_limit) {
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); $param .= '&limit='.urlencode($limit);
else $param .= '&search_'.$key.'='.urlencode($search[$key]); }
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
} else {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
} }
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -348,7 +375,9 @@ $arrayofmassactions = array(
$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="'.($action == 'create' ? 'add' : ($action == 'edit' ? 'update' : 'list')).'">'; print '<input type="hidden" name="action" value="'.($action == 'create' ? 'add' : ($action == 'edit' ? 'update' : 'list')).'">';
@ -430,9 +459,10 @@ $objecttmp = new EmailSenderProfile($db);
//$trackid = (($action == 'testhtml') ? "testhtml" : "test"); //$trackid = (($action == 'testhtml') ? "testhtml" : "test");
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all) if ($search_all) {
{ foreach ($fieldstosearchall as $key => $val) {
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); $fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
} }
@ -443,11 +473,13 @@ $moreforfilter.= '</div>';*/
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) {
else $moreforfilter = $hookmanager->resPrint; $moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter)) if (!empty($moreforfilter)) {
{
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter; print $moreforfilter;
print '</div>'; print '</div>';
@ -464,20 +496,26 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
// Fields title search // Fields title search
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; if ($key == 'status') {
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked'])) } elseif (in_array($val['type'], array('timestamp'))) {
{ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
elseif (strpos($val['type'], 'integer:') === 0) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
}
print '</td>'; print '</td>';
} }
} }
@ -498,15 +536,18 @@ print '</tr>'."\n";
// Fields title label // Fields title label
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; if ($key == 'status') {
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked'])) } elseif (in_array($val['type'], array('timestamp'))) {
{ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
} }
} }
@ -524,11 +565,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line // Detect if we need a fetch on each output line
$needToFetchEachLine = 0; $needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) if (preg_match('/\$object/', $val)) {
{ $needToFetchEachLine++; // There is at least one compute field that use $object
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object }
} }
} }
@ -537,37 +578,50 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$i = 0; $i = 0;
$totalarray = array(); $totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num)) while ($i < ($limit ? min($num, $limit) : $num)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object // Store properties in $object
$object->setVarsFromFetchObj($obj); $object->setVarsFromFetchObj($obj);
// Show here line of result // Show here line of result
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; if (in_array($val['type'], array('timestamp'))) {
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) if (!empty($arrayfields['t.'.$key]['checked'])) {
{
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status' || $key == 'active') print $object->getLibStatut(5); if ($key == 'status' || $key == 'active') {
else print $object->showOutputField($val, $key, $object->$key, ''); print $object->getLibStatut(5);
} else {
print $object->showOutputField($val, $key, $object->$key, '');
}
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
if (!empty($val['isameasure'])) $totalarray['nbfield']++;
{ }
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; if (!empty($val['isameasure'])) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
$totalarray['val']['t.'.$key] += $object->$key; $totalarray['val']['t.'.$key] += $object->$key;
} }
} }
@ -581,21 +635,32 @@ while ($i < ($limit ? min($num, $limit) : $num))
// Action column // Action column
print '<td class="nowrap center">'; print '<td class="nowrap center">';
$url = $_SERVER["PHP_SELF"].'?id='.$obj->rowid; $url = $_SERVER["PHP_SELF"].'?id='.$obj->rowid;
if ($limit) $url .= '&limit='.urlencode($limit); if ($limit) {
if ($page) $url .= '&page='.urlencode($page); $url .= '&limit='.urlencode($limit);
if ($sortfield) $url .= '&sortfield='.urlencode($sortfield); }
if ($sortorder) $url .= '&page='.urlencode($sortorder); if ($page) {
$url .= '&page='.urlencode($page);
}
if ($sortfield) {
$url .= '&sortfield='.urlencode($sortfield);
}
if ($sortorder) {
$url .= '&page='.urlencode($sortorder);
}
print '<a class="editfielda reposition marginrightonly marginleftonly" href="'.$url.'&action=edit&rowid='.$obj->rowid.'">'.img_edit().'</a>'; print '<a class="editfielda reposition marginrightonly marginleftonly" href="'.$url.'&action=edit&rowid='.$obj->rowid.'">'.img_edit().'</a>';
//print ' &nbsp; '; //print ' &nbsp; ';
print '<a class=" marginrightonly marginleftonly" href="'.$url.'&action=delete&token='.newToken().'">'.img_delete().'</a> &nbsp; '; print '<a class=" marginrightonly marginleftonly" href="'.$url.'&action=delete&token='.newToken().'">'.img_delete().'</a> &nbsp; ';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0; $selected = 0;
if (in_array($object->id, $arrayofselected)) $selected = 1; if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n"; print '</tr>'."\n";
@ -607,10 +672,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found // If no record found
if ($num == 0) if ($num == 0) {
{
$colspan = 1; $colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
} }
@ -626,10 +694,11 @@ print '</div>'."\n";
print '</form>'."\n"; print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
{
$hidegeneratedfilelistifempty = 1; $hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db); $formfile = new FormFile($db);

File diff suppressed because it is too large Load Diff

View File

@ -32,12 +32,13 @@ $langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'err
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$usersignature = $user->signature; $usersignature = $user->signature;
// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
if ($action == 'test' || $action == 'send') if ($action == 'test' || $action == 'send') {
{
$usersignature = dol_string_nohtmltag($usersignature); $usersignature = dol_string_nohtmltag($usersignature);
} }
@ -58,8 +59,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs);
* Actions * Actions
*/ */
if ($action == 'update' && empty($_POST["cancel"])) if ($action == 'update' && empty($_POST["cancel"])) {
{
// Send mode parameters // Send mode parameters
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity);
@ -84,8 +84,12 @@ $trackid = (($action == 'testhtml') ? "testhtml" : "test");
$sendcontext = 'ticket'; // Force to use dedicated context of setup for ticket $sendcontext = 'ticket'; // Force to use dedicated context of setup for ticket
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if ($action == 'presend' && GETPOST('trackid') == 'test') $action = 'test'; if ($action == 'presend' && GETPOST('trackid') == 'test') {
if ($action == 'presend' && GETPOST('trackid') == 'testhtml') $action = 'testhtml'; $action = 'test';
}
if ($action == 'presend' && GETPOST('trackid') == 'testhtml') {
$action = 'testhtml';
}
@ -97,14 +101,24 @@ if ($action == 'presend' && GETPOST('trackid') == 'testhtml') $action = 'testh
$form = new Form($db); $form = new Form($db);
$linuxlike = 1; $linuxlike = 1;
if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; if (preg_match('/^win/i', PHP_OS)) {
if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; $linuxlike = 0;
}
if (preg_match('/^mac/i', PHP_OS)) {
$linuxlike = 0;
}
if (empty($conf->global->MAIN_MAIL_SENDMODE_TICKET)) $conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default'; if (empty($conf->global->MAIN_MAIL_SENDMODE_TICKET)) {
$conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default';
}
$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get('smtp_port'); $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get('smtp_port');
if (!$port) $port = 25; if (!$port) {
$port = 25;
}
$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get('SMTP'); $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get('SMTP');
if (!$server) $server = '127.0.0.1'; if (!$server) {
$server = '127.0.0.1';
}
$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; $wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
@ -120,13 +134,13 @@ $listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
$listofmethods['mail'] = 'PHP mail function'; $listofmethods['mail'] = 'PHP mail function';
//$listofmethods['simplemail']='Simplemail class'; //$listofmethods['simplemail']='Simplemail class';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
if (version_compare(phpversion(), '7.0', '>=')) $listofmethods['swiftmailer'] = 'Swift Mailer socket library'; if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
if ($action == 'edit') if ($action == 'edit') {
{ if ($conf->use_javascript_ajax) {
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () { print 'jQuery(document).ready(function () {
function initfields() function initfields()
@ -148,8 +162,7 @@ if ($action == 'edit')
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
'; ';
if ($linuxlike) if ($linuxlike) {
{
print ' print '
jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide(); jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide(); jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
@ -231,12 +244,13 @@ if ($action == 'edit')
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
{
print $form->selectarray('MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET); print $form->selectarray('MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET);
} else { } else {
$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET]; $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET];
if (empty($text)) $text = $langs->trans("Undefined"); if (empty($text)) {
$text = $langs->trans("Undefined");
}
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
print '<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="'.$conf->global->MAIN_MAIL_SENDMODE_TICKET.'">'; print '<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="'.$conf->global->MAIN_MAIL_SENDMODE_TICKET.'">';
@ -246,20 +260,21 @@ if ($action == 'edit')
// Host server // Host server
print '<tr class="oddeven hideifdefault"><td>'; print '<tr class="oddeven hideifdefault"><td>';
if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') {
{
print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
print '</td><td>'; print '</td><td>';
print $langs->trans("SeeLocalSendMailSetup"); print $langs->trans("SeeLocalSendMailSetup");
} else { } else {
$mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ''); $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '');
$smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); if ($linuxlike) {
else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver); print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
} else {
print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
}
print '</td><td>'; print '</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.'">'; print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.'">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.'">'; print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.'">';
print '<span id="smtp_server_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>'; print '<span id="smtp_server_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
@ -275,20 +290,21 @@ if ($action == 'edit')
// Port // Port
print '<tr class="oddeven hideifdefault"><td>'; print '<tr class="oddeven hideifdefault"><td>';
if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') {
{
print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
print '</td><td>'; print '</td><td>';
print $langs->trans("SeeLocalSendMailSetup"); print $langs->trans("SeeLocalSendMailSetup");
} else { } else {
$mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ''); $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '');
$smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined"); $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); if ($linuxlike) {
else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport); print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
} else {
print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
}
print '</td><td>'; print '</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.'">'; print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.'">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.'">'; print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.'">';
print '<span id="smtp_port_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>'; print '<span id="smtp_port_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
@ -302,13 +318,11 @@ if ($action == 'edit')
print '</td></tr>'; print '</td></tr>';
// ID // ID
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
{
$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET : ''); $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET : '');
print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'; print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.'">'; print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.'">';
} else { } else {
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
@ -319,13 +333,11 @@ if ($action == 'edit')
} }
// PW // PW
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
{
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET : ''); $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET : '');
print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'; print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
{
print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.'">'; print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.'">';
} else { } else {
$htmltext = $langs->trans("ContactSuperAdminForChange"); $htmltext = $langs->trans("ContactSuperAdminForChange");
@ -338,25 +350,29 @@ if ($action == 'edit')
// TLS // TLS
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// STARTTLS // STARTTLS
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1); print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -382,60 +398,61 @@ if ($action == 'edit')
// Method // Method
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET]; $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET];
if (empty($text)) $text = $langs->trans("Undefined").img_warning(); if (empty($text)) {
$text = $langs->trans("Undefined").img_warning();
}
print $text; print $text;
print '</td></tr>'; print '</td></tr>';
if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') {
{
// Host server // Host server
if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')) if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')) {
{
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
} else { } else {
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '').'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '').'</td></tr>';
} }
// Port // Port
if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')) if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')) {
{
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
} else { } else {
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '').'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '').'</td></tr>';
} }
// SMTPS ID // SMTPS ID
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
{
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.'</td></tr>';
} }
// SMTPS PW // SMTPS PW
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
{
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).'</td></tr>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).'</td></tr>';
} }
// TLS // TLS
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET); print yn($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
// STARTTLS // STARTTLS
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>'; print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
{ if (function_exists('openssl_open')) {
if (function_exists('openssl_open'))
{
print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET); print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET);
} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else {
} else print yn(0).' ('.$langs->trans("NotSupported").')'; print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>'; print '</td></tr>';
} }
@ -444,8 +461,7 @@ if ($action == 'edit')
print dol_get_fiche_end(); print dol_get_fiche_end();
if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
{
print '<br>'; print '<br>';
/* /*
// Warning 1 // Warning 1
@ -468,12 +484,9 @@ if ($action == 'edit')
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') {
{ if ($conf->global->MAIN_MAIL_SENDMODE_TICKET != 'mail' || !$linuxlike) {
if ($conf->global->MAIN_MAIL_SENDMODE_TICKET != 'mail' || !$linuxlike) if (function_exists('fsockopen') && $port && $server) {
{
if (function_exists('fsockopen') && $port && $server)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
} }
} else { } else {
@ -482,8 +495,7 @@ if ($action == 'edit')
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
if (!empty($conf->fckeditor->enabled)) if (!empty($conf->fckeditor->enabled)) {
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
} }
} }
@ -491,23 +503,22 @@ if ($action == 'edit')
print '</div>'; print '</div>';
if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) {
{
$text = $langs->trans("WarningPHPMail"); $text = $langs->trans("WarningPHPMail");
print info_admin($text); print info_admin($text);
} }
// Run the test to connect // Run the test to connect
if ($action == 'testconnect') if ($action == 'testconnect') {
{
print load_fiche_titre($langs->trans("DoTestServerAvailability")); print load_fiche_titre($langs->trans("DoTestServerAvailability"));
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext); $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
$result = $mail->check_server_port($server, $port); $result = $mail->check_server_port($server, $port);
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>'; if ($result) {
else { print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
} else {
$errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port); $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
if ($mail->error) { if ($mail->error) {
@ -520,8 +531,7 @@ if ($action == 'edit')
} }
// Show email send test form // Show email send test form
if ($action == 'test' || $action == 'testhtml') if ($action == 'test' || $action == 'testhtml') {
{
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>'; print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
@ -558,8 +568,7 @@ if ($action == 'edit')
$formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
// Init list of files // Init list of files
if (GETPOST("mode") == 'init') if (GETPOST("mode") == 'init') {
{
$formmail->clear_attached_files(); $formmail->clear_attached_files();
} }

View File

@ -34,13 +34,14 @@ $cancel = GETPOST('cancel', 'alpha');
$langs->loadLangs(array("companies", "products", "admin", "users", "other")); $langs->loadLangs(array("companies", "products", "admin", "users", "other"));
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$dirstandard = array(); $dirstandard = array();
$dirsmartphone = array(); $dirsmartphone = array();
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
foreach ($dirmenus as $dirmenu) foreach ($dirmenus as $dirmenu) {
{
$dirstandard[] = $dirmenu.'standard'; $dirstandard[] = $dirmenu.'standard';
$dirsmartphone[] = $dirmenu.'smartphone'; $dirsmartphone[] = $dirmenu.'smartphone';
} }
@ -60,8 +61,7 @@ error_reporting($err);
* Actions * Actions
*/ */
if ($action == 'update' && !$cancel) if ($action == 'update' && !$cancel) {
{
$_SESSION["mainmenu"] = "home"; // Le gestionnaire de menu a pu changer $_SESSION["mainmenu"] = "home"; // Le gestionnaire de menu a pu changer
dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD', 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD', 'alpha'), 'chaine', 0, '', $conf->entity);
@ -74,27 +74,27 @@ if ($action == 'update' && !$cancel)
$listofmenuhandler = array(); $listofmenuhandler = array();
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_STANDARD', 'alpha'))] = 1; $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_STANDARD', 'alpha'))] = 1;
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_STANDARD', 'alpha'))] = 1; $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_STANDARD', 'alpha'))] = 1;
if (GETPOST('MAIN_MENU_SMARTPHONE', 'alpha')) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'))] = 1; if (GETPOST('MAIN_MENU_SMARTPHONE', 'alpha')) {
if (GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha')) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha'))] = 1; $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'))] = 1;
}
if (GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha')) {
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha'))] = 1;
}
// Initialize menu handlers // Initialize menu handlers
foreach ($listofmenuhandler as $key => $val) foreach ($listofmenuhandler as $key => $val) {
{
// Load sql init_menu_handler.sql file // Load sql init_menu_handler.sql file
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
foreach ($dirmenus as $dirmenu) foreach ($dirmenus as $dirmenu) {
{
$file = 'init_menu_'.$key.'.sql'; $file = 'init_menu_'.$key.'.sql';
$fullpath = dol_buildpath($dirmenu.$file); $fullpath = dol_buildpath($dirmenu.$file);
//print 'action='.$action.' Search menu into fullpath='.$fullpath.'<br>';exit; //print 'action='.$action.' Search menu into fullpath='.$fullpath.'<br>';exit;
if (file_exists($fullpath)) if (file_exists($fullpath)) {
{
$db->begin(); $db->begin();
$result = run_sql($fullpath, 1, '', 1, $key, 'none'); $result = run_sql($fullpath, 1, '', 1, $key, 'none');
if ($result > 0) if ($result > 0) {
{
$db->commit(); $db->commit();
} else { } else {
$error++; $error++;
@ -105,8 +105,7 @@ if ($action == 'update' && !$cancel)
} }
} }
if (!$error) if (!$error) {
{
$db->close(); $db->close();
// We make a header redirect because we need to change menu NOW. // We make a header redirect because we need to change menu NOW.
@ -180,8 +179,7 @@ print '<td>';
$formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) ? $conf->global->MAIN_MENU_SMARTPHONE : $conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) ? '' : ' disabled'); $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) ? $conf->global->MAIN_MENU_SMARTPHONE : $conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) ? '' : ' disabled');
if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE_FORCED) if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE_FORCED)
|| (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE))) || (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE))) {
{
print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme")); print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
} }
@ -190,8 +188,7 @@ print '<td>';
$formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? $conf->global->MAIN_MENUFRONT_SMARTPHONE : $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? '' : ' disabled'); $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? $conf->global->MAIN_MENUFRONT_SMARTPHONE : $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? '' : ' disabled');
if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
|| (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE))) || (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE))) {
{
print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme")); print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
} }

View File

@ -31,13 +31,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("other", "admin")); $langs->loadLangs(array("other", "admin"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$dirstandard = array(); $dirstandard = array();
$dirsmartphone = array(); $dirsmartphone = array();
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
foreach ($dirmenus as $dirmenu) foreach ($dirmenus as $dirmenu) {
{
$dirstandard[] = $dirmenu.'standard'; $dirstandard[] = $dirmenu.'standard';
$dirsmartphone[] = $dirmenu.'smartphone'; $dirsmartphone[] = $dirmenu.'smartphone';
} }
@ -54,8 +55,12 @@ $menu_handler_smartphone = preg_replace('/(_frontoffice\.php|_menu\.php)/i', '',
$menu_handler = $menu_handler_top; $menu_handler = $menu_handler_top;
if (GETPOST("handler_origine")) $menu_handler = GETPOST("handler_origine"); if (GETPOST("handler_origine")) {
if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler"); $menu_handler = GETPOST("handler_origine");
}
if (GETPOST("menu_handler")) {
$menu_handler = GETPOST("menu_handler");
}
$menu_handler_to_search = preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)?/i', '', $menu_handler); $menu_handler_to_search = preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)?/i', '', $menu_handler);
@ -64,8 +69,7 @@ $menu_handler_to_search = preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php
* Actions * Actions
*/ */
if ($action == 'up') if ($action == 'up') {
{
$current = array(); $current = array();
$previous = array(); $previous = array();
@ -77,8 +81,7 @@ if ($action == 'up')
$result = $db->query($sql); $result = $db->query($sql);
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$current['rowid'] = $obj->rowid; $current['rowid'] = $obj->rowid;
$current['order'] = $obj->position; $current['order'] = $obj->position;
@ -100,8 +103,7 @@ if ($action == 'up')
$result = $db->query($sql); $result = $db->query($sql);
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$previous['rowid'] = $obj->rowid; $previous['rowid'] = $obj->rowid;
$previous['order'] = $obj->position; $previous['order'] = $obj->position;
@ -118,8 +120,7 @@ if ($action == 'up')
$sql .= " WHERE m.rowid = ".$previous['rowid']; // Descend celui du dessus $sql .= " WHERE m.rowid = ".$previous['rowid']; // Descend celui du dessus
dol_syslog("admin/menus/index.php ".$sql); dol_syslog("admin/menus/index.php ".$sql);
$db->query($sql); $db->query($sql);
} elseif ($action == 'down') } elseif ($action == 'down') {
{
$current = array(); $current = array();
$next = array(); $next = array();
@ -131,8 +132,7 @@ if ($action == 'up')
$result = $db->query($sql); $result = $db->query($sql);
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$current['rowid'] = $obj->rowid; $current['rowid'] = $obj->rowid;
$current['order'] = $obj->position; $current['order'] = $obj->position;
@ -154,8 +154,7 @@ if ($action == 'up')
$result = $db->query($sql); $result = $db->query($sql);
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$next['rowid'] = $obj->rowid; $next['rowid'] = $obj->rowid;
$next['order'] = $obj->position; $next['order'] = $obj->position;
@ -172,15 +171,13 @@ if ($action == 'up')
$sql .= " WHERE m.rowid = ".$next['rowid']; $sql .= " WHERE m.rowid = ".$next['rowid'];
dol_syslog("admin/menus/index.php ".$sql); dol_syslog("admin/menus/index.php ".$sql);
$db->query($sql); $db->query($sql);
} elseif ($action == 'confirm_delete' && $confirm == 'yes') } elseif ($action == 'confirm_delete' && $confirm == 'yes') {
{
$db->begin(); $db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
$sql .= " WHERE rowid = ".GETPOST('menuId', 'int'); $sql .= " WHERE rowid = ".GETPOST('menuId', 'int');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs'); setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
@ -231,8 +228,7 @@ print "<br>\n";
// Confirmation for remove menu entry // Confirmation for remove menu entry
if ($action == 'delete') if ($action == 'delete') {
{
$sql = "SELECT m.titre as title"; $sql = "SELECT m.titre as title";
$sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql .= " WHERE m.rowid = ".GETPOST('menuId', 'int'); $sql .= " WHERE m.rowid = ".GETPOST('menuId', 'int');
@ -243,8 +239,7 @@ if ($action == 'delete')
} }
$newcardbutton = ''; $newcardbutton = '';
if ($user->admin) if ($user->admin) {
{
$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF'])); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF']));
} }
@ -277,8 +272,7 @@ print '<td colspan="2">';
$rangLast = 0; $rangLast = 0;
$idLast = -1; $idLast = -1;
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
/*-------------------- MAIN ----------------------- /*-------------------- MAIN -----------------------
tableau des elements de l'arbre: tableau des elements de l'arbre:
c'est un tableau a 2 dimensions. c'est un tableau a 2 dimensions.
@ -304,14 +298,14 @@ if ($conf->use_javascript_ajax)
$sql .= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same) $sql .= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same)
$res = $db->query($sql); $res = $db->query($sql);
if ($res) if ($res) {
{
$num = $db->num_rows($res); $num = $db->num_rows($res);
$i = 1; $i = 1;
while ($menu = $db->fetch_array($res)) while ($menu = $db->fetch_array($res)) {
{ if (!empty($menu['langs'])) {
if (!empty($menu['langs'])) $langs->load($menu['langs']); $langs->load($menu['langs']);
}
$titre = $langs->trans($menu['titre']); $titre = $langs->trans($menu['titre']);
$entry = '<table class="nobordernopadding centpercent"><tr><td>'; $entry = '<table class="nobordernopadding centpercent"><tr><td>';
@ -365,14 +359,14 @@ if ($conf->use_javascript_ajax)
// Process remaining records (records that are not linked to root by any path) // Process remaining records (records that are not linked to root by any path)
$remainingdata = array(); $remainingdata = array();
foreach ($data as $datar) foreach ($data as $datar) {
{ if (empty($datar['rowid']) || !empty($tree_recur_alreadyadded[$datar['rowid']])) {
if (empty($datar['rowid']) || !empty($tree_recur_alreadyadded[$datar['rowid']])) continue; continue;
}
$remainingdata[] = $datar; $remainingdata[] = $datar;
} }
if (count($remainingdata)) if (count($remainingdata)) {
{
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -382,8 +376,7 @@ if ($conf->use_javascript_ajax)
print '<tr>'; print '<tr>';
print '<td colspan="2">'; print '<td colspan="2">';
foreach ($remainingdata as $datar) foreach ($remainingdata as $datar) {
{
$father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
//print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'<br>'."\n"; //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'<br>'."\n";
tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1);

View File

@ -21,8 +21,12 @@
* \brief Page to activate/disable all modules * \brief Page to activate/disable all modules
*/ */
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu if (!defined('NOREQUIREMENU')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disabled because this page is into a popup on module search page and we want to avoid to have an Anti CSRF token error (done if MAIN_SECURITY_CSRF_WITH_TOKEN is on) when we make a second search after closing popup. define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disabled because this page is into a popup on module search page and we want to avoid to have an Anti CSRF token error (done if MAIN_SECURITY_CSRF_WITH_TOKEN is on) when we make a second search after closing popup.
}
require '../main.inc.php'; require '../main.inc.php';
@ -36,10 +40,13 @@ $langs->loadLangs(array('errors', 'admin', 'modulebuilder', 'exports'));
$mode = GETPOST('mode', 'alpha'); $mode = GETPOST('mode', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
if (empty($mode)) $mode = 'desc'; if (empty($mode)) {
$mode = 'desc';
}
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
@ -80,25 +87,19 @@ $i = 0; // is a sequencer of modules found
$j = 0; // j is module number. Automatically affected if module number not defined. $j = 0; // j is module number. Automatically affected if module number not defined.
$modNameLoaded = array(); $modNameLoaded = array();
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir) {
{
// Load modules attributes in arrays (name, numero, orders) from dir directory // Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>"; //print $dir."\n<br>";
dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)"); dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
$handle = @opendir($dir); $handle = @opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
//print "$i ".$file."\n<br>"; //print "$i ".$file."\n<br>";
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
{
$modName = substr($file, 0, dol_strlen($file) - 10); $modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName) if ($modName) {
{ if (!empty($modNameLoaded[$modName])) {
if (!empty($modNameLoaded[$modName]))
{
$mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>"; $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
setEventMessages($mesg, null, 'warnings'); setEventMessages($mesg, null, 'warnings');
dol_syslog($mesg, LOG_ERR); dol_syslog($mesg, LOG_ERR);
@ -107,14 +108,12 @@ foreach ($modulesdir as $dir)
try { try {
$res = include_once $dir.$file; $res = include_once $dir.$file;
if (class_exists($modName)) if (class_exists($modName)) {
{
try { try {
$objMod = new $modName($db); $objMod = new $modName($db);
$modNameLoaded[$modName] = $dir; $modNameLoaded[$modName] = $dir;
if (!$objMod->numero > 0 && $modName != 'modUser') if (!$objMod->numero > 0 && $modName != 'modUser') {
{
dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
} }
$j = $objMod->numero; $j = $objMod->numero;
@ -123,21 +122,24 @@ foreach ($modulesdir as $dir)
// We discard modules according to features level (PS: if module is activated we always show it) // We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) {
if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; $modulequalified = 0;
if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0; }
if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) {
$modulequalified = 0;
}
if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) {
$modulequalified = 0;
}
// We discard modules according to property disabled // We discard modules according to property disabled
//if (! empty($objMod->hidden)) $modulequalified=0; //if (! empty($objMod->hidden)) $modulequalified=0;
if ($modulequalified > 0) if ($modulequalified > 0) {
{
$publisher = dol_escape_htmltag($objMod->getPublisher()); $publisher = dol_escape_htmltag($objMod->getPublisher());
$external = ($objMod->isCoreOrExternalModule() == 'external'); $external = ($objMod->isCoreOrExternalModule() == 'external');
if ($external) if ($external) {
{ if ($publisher) {
if ($publisher)
{
$arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher;
} else { } else {
$arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers");
@ -147,14 +149,15 @@ foreach ($modulesdir as $dir)
} }
// Define array $categ with categ with at least one qualified module // Define array $categ with categ with at least one qualified module
if ($modulequalified > 0) if ($modulequalified > 0) {
{
$modules[$i] = $objMod; $modules[$i] = $objMod;
$filename[$i] = $modName; $filename[$i] = $modName;
// Gives the possibility to the module, to provide his own family info and position of this family // Gives the possibility to the module, to provide his own family info and position of this family
if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
if (!is_array($familyinfo)) $familyinfo = array(); if (!is_array($familyinfo)) {
$familyinfo = array();
}
$familyinfo = array_merge($familyinfo, $objMod->familyinfo); $familyinfo = array_merge($familyinfo, $objMod->familyinfo);
$familykey = key($objMod->familyinfo); $familykey = key($objMod->familyinfo);
} else { } else {
@ -162,8 +165,7 @@ foreach ($modulesdir as $dir)
} }
$moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); $moduleposition = ($objMod->module_position ? $objMod->module_position : '50');
if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) {
{
$moduleposition = '80'; // External modules at end by default $moduleposition = '80'; // External modules at end by default
} }
@ -172,21 +174,26 @@ foreach ($modulesdir as $dir)
//print $i.'-'.$dirmod[$i].'<br>'; //print $i.'-'.$dirmod[$i].'<br>';
// Set categ[$i] // Set categ[$i]
$specialstring = 'unknown'; $specialstring = 'unknown';
if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; if ($objMod->version == 'development' || $objMod->version == 'experimental') {
if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories $specialstring = 'expdev';
else $categ[$specialstring] = 1; }
if (isset($categ[$specialstring])) {
$categ[$specialstring]++; // Array of all different modules categories
} else {
$categ[$specialstring] = 1;
}
$j++; $j++;
$i++; $i++;
} else dol_syslog("Module ".get_class($objMod)." not qualified"); } else {
} catch (Exception $e) dol_syslog("Module ".get_class($objMod)." not qualified");
{ }
} catch (Exception $e) {
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
} }
} else { } else {
print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>"; print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
} }
} catch (Exception $e) } catch (Exception $e) {
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
} }
} }
@ -206,11 +213,9 @@ asort($orders);
unset($objMod); unset($objMod);
$i = 0; $i = 0;
foreach ($orders as $tmpkey => $tmpvalue) foreach ($orders as $tmpkey => $tmpvalue) {
{
$tmpMod = $modules[$tmpkey]; $tmpMod = $modules[$tmpkey];
if ($tmpMod->numero == $id) if ($tmpMod->numero == $id) {
{
$key = $i; $key = $i;
$modName = $filename[$tmpkey]; $modName = $filename[$tmpkey];
$dirofmodule = $dirmod[$tmpkey]; $dirofmodule = $dirmod[$tmpkey];
@ -236,20 +241,21 @@ $moduledir = strtolower(preg_replace('/^mod/i', '', get_class($objMod)));
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
$text = '<span class="opacitymedium">'.$langs->trans("LastActivationDate").':</span> '; $text = '<span class="opacitymedium">'.$langs->trans("LastActivationDate").':</span> ';
if (!empty($conf->global->$const_name)) $text .= dol_print_date($objMod->getLastActivationDate(), 'dayhour'); if (!empty($conf->global->$const_name)) {
else $text .= $langs->trans("Disabled"); $text .= dol_print_date($objMod->getLastActivationDate(), 'dayhour');
} else {
$text .= $langs->trans("Disabled");
}
$tmp = $objMod->getLastActivationInfo(); $tmp = $objMod->getLastActivationInfo();
$authorid = $tmp['authorid']; $authorid = $tmp['authorid'];
if ($authorid > 0) if ($authorid > 0) {
{
$tmpuser = new User($db); $tmpuser = new User($db);
$tmpuser->fetch($authorid); $tmpuser->fetch($authorid);
$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationAuthor").':</span> '; $text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationAuthor").':</span> ';
$text .= $tmpuser->getNomUrl(1); $text .= $tmpuser->getNomUrl(1);
} }
$ip = $tmp['ip']; $ip = $tmp['ip'];
if ($ip) if ($ip) {
{
$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationIP").':</span> '; $text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationIP").':</span> ';
$text .= $ip; $text .= $ip;
} }
@ -267,16 +273,13 @@ print '<br>';
print dol_get_fiche_head($head, $mode, '', -1); print dol_get_fiche_head($head, $mode, '', -1);
if (!$modulename) if (!$modulename) {
{
dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING); dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
} }
// Load all lang files of module // Load all lang files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles)) if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
{ foreach ($objMod->langfiles as $domain) {
foreach ($objMod->langfiles as $domain)
{
$langs->load($domain); $langs->load($domain);
} }
} }
@ -287,24 +290,30 @@ if (isset($objMod->langfiles) && is_array($objMod->langfiles))
// Version (with picto warning or not) // Version (with picto warning or not)
$version = $objMod->getVersion(0); $version = $objMod->getVersion(0);
$versiontrans = ''; $versiontrans = '';
if (preg_match('/development/i', $version)) $versiontrans .= img_warning($langs->trans("Development"), 'style="float: left"'); if (preg_match('/development/i', $version)) {
if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), 'style="float: left"'); $versiontrans .= img_warning($langs->trans("Development"), 'style="float: left"');
if (preg_match('/deprecated/i', $version)) $versiontrans .= img_warning($langs->trans("Deprecated"), 'style="float: left"'); }
if (preg_match('/experimental/i', $version)) {
$versiontrans .= img_warning($langs->trans("Experimental"), 'style="float: left"');
}
if (preg_match('/deprecated/i', $version)) {
$versiontrans .= img_warning($langs->trans("Deprecated"), 'style="float: left"');
}
$versiontrans .= $objMod->getVersion(1); $versiontrans .= $objMod->getVersion(1);
// Define imginfo // Define imginfo
$imginfo = "info"; $imginfo = "info";
if ($objMod->isCoreOrExternalModule() == 'external') if ($objMod->isCoreOrExternalModule() == 'external') {
{
$imginfo = "info_black"; $imginfo = "info_black";
} }
// Define text of description of module // Define text of description of module
$text = ''; $text = '';
if ($mode == 'desc') if ($mode == 'desc') {
{ if ($moduledesc) {
if ($moduledesc) $text .= '<br>'.$moduledesc.'<br><br><br>'; $text .= '<br>'.$moduledesc.'<br><br><br>';
}
$text .= '<span class="opacitymedium">'.$langs->trans("Version").':</span> '.$version; $text .= '<span class="opacitymedium">'.$langs->trans("Version").':</span> '.$version;
@ -312,13 +321,18 @@ if ($mode == 'desc')
$text .= '<br><span class="opacitymedium">'.$langs->trans("DescriptorFile").':</span> '.$moduledescriptorfile; $text .= '<br><span class="opacitymedium">'.$langs->trans("DescriptorFile").':</span> '.$moduledescriptorfile;
$textexternal = ''; $textexternal = '';
if ($objMod->isCoreOrExternalModule() == 'external') if ($objMod->isCoreOrExternalModule() == 'external') {
{
$textexternal .= '<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule); $textexternal .= '<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule);
if ($objMod->editor_name != 'dolibarr') $textexternal .= '<br><span class="opacitymedium">'.$langs->trans("Publisher").':</span> '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); if ($objMod->editor_name != 'dolibarr') {
$textexternal .= '<br><span class="opacitymedium">'.$langs->trans("Publisher").':</span> '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name);
}
$editor_url = $objMod->editor_url; $editor_url = $objMod->editor_url;
if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; if (!preg_match('/^http/', $editor_url)) {
if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' <a href="'.$editor_url.'" target="_blank">'.$objMod->editor_url.'</a>'; $editor_url = 'http://'.$editor_url;
}
if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) {
$textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' <a href="'.$editor_url.'" target="_blank">'.$objMod->editor_url.'</a>';
}
$text .= $textexternal; $text .= $textexternal;
$text .= '<br>'; $text .= '<br>';
} else { } else {
@ -326,109 +340,119 @@ if ($mode == 'desc')
} }
$moduledesclong = $objMod->getDescLong(); $moduledesclong = $objMod->getDescLong();
if ($moduledesclong) $text .= '<br><hr><div class="moduledesclong">'.$moduledesclong.'<div>'; if ($moduledesclong) {
$text .= '<br><hr><div class="moduledesclong">'.$moduledesclong.'<div>';
}
} }
if ($mode == 'feature') if ($mode == 'feature') {
{
$text .= '<br><strong>'.$langs->trans("DependsOn").':</strong> '; $text .= '<br><strong>'.$langs->trans("DependsOn").':</strong> ';
if (count($objMod->depends)) $text .= join(',', $objMod->depends); if (count($objMod->depends)) {
else $text .= $langs->trans("None"); $text .= join(',', $objMod->depends);
} else {
$text .= $langs->trans("None");
}
$text .= '<br><strong>'.$langs->trans("RequiredBy").':</strong> '; $text .= '<br><strong>'.$langs->trans("RequiredBy").':</strong> ';
if (count($objMod->requiredby)) $text .= join(',', $objMod->requiredby); if (count($objMod->requiredby)) {
else $text .= $langs->trans("None"); $text .= join(',', $objMod->requiredby);
} else {
$text .= $langs->trans("None");
}
$text .= '<br><br>'; $text .= '<br><br>';
$text .= '<br><strong>'.$langs->trans("AddDataTables").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddDataTables").':</strong> ';
$sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); $sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back'));
if (count($sqlfiles) > 0) if (count($sqlfiles) > 0) {
{
$text .= $langs->trans("Yes").' ('; $text .= $langs->trans("Yes").' (';
$i = 0; $i = 0;
foreach ($sqlfiles as $val) foreach ($sqlfiles as $val) {
{
$text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name']));
$i++; $i++;
} }
$text .= ')'; $text .= ')';
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddDictionaries").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddDictionaries").':</strong> ';
if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) {
{
$i = 0; $i = 0;
foreach ($objMod->dictionaries['tablib'] as $val) foreach ($objMod->dictionaries['tablib'] as $val) {
{
$text .= ($i ? ', ' : '').$val; $text .= ($i ? ', ' : '').$val;
$i++; $i++;
} }
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddData").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddData").':</strong> ';
$filedata = dol_buildpath($moduledir.'/sql/data.sql'); $filedata = dol_buildpath($moduledir.'/sql/data.sql');
if (dol_is_file($filedata)) if (dol_is_file($filedata)) {
{
$text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)';
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddRemoveTabs").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddRemoveTabs").':</strong> ';
if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) {
{
$i = 0; $i = 0;
foreach ($objMod->tabs as $val) foreach ($objMod->tabs as $val) {
{ if (is_array($val)) {
if (is_array($val)) $val = $val['data']; $val = $val['data'];
if (is_string($val)) }
{ if (is_string($val)) {
$tmp = explode(':', $val, 3); $tmp = explode(':', $val, 3);
$text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1]; $text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1];
$i++; $i++;
} }
} }
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddModels").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddModels").':</strong> ';
if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) {
{
$text .= $langs->trans("Yes"); $text .= $langs->trans("Yes");
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddSubstitutions").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddSubstitutions").':</strong> ';
if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) {
{
$text .= $langs->trans("Yes"); $text .= $langs->trans("Yes");
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddSheduledJobs").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddSheduledJobs").':</strong> ';
if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) {
{
$i = 0; $i = 0;
foreach ($objMod->cronjobs as $val) foreach ($objMod->cronjobs as $val) {
{
$text .= ($i ? ', ' : '').($val['label']); $text .= ($i ? ', ' : '').($val['label']);
$i++; $i++;
} }
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddTriggers").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddTriggers").':</strong> ';
$moreinfoontriggerfile = ''; $moreinfoontriggerfile = '';
if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) {
{
$yesno = 'Yes'; $yesno = 'Yes';
} else { } else {
$yesno = 'No'; $yesno = 'No';
@ -436,10 +460,8 @@ if ($mode == 'feature')
require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
$interfaces = new Interfaces($db); $interfaces = new Interfaces($db);
$triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers')); $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers'));
foreach ($triggers as $triggercursor) foreach ($triggers as $triggercursor) {
{ if ($triggercursor['module'] == $moduledir) {
if ($triggercursor['module'] == $moduledir)
{
$yesno = 'Yes'; $yesno = 'Yes';
$moreinfoontriggerfile = ' ('.$triggercursor['relpath'].')'; $moreinfoontriggerfile = ' ('.$triggercursor['relpath'].')';
} }
@ -450,33 +472,30 @@ if ($mode == 'feature')
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddBoxes").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddBoxes").':</strong> ';
if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) {
{
$i = 0; $i = 0;
foreach ($objMod->boxes as $val) foreach ($objMod->boxes as $val) {
{
$text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]);
$i++; $i++;
} }
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddHooks").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddHooks").':</strong> ';
if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) {
{
$i = 0; $i = 0;
foreach ($objMod->module_parts['hooks'] as $key => $val) foreach ($objMod->module_parts['hooks'] as $key => $val) {
{ if ($key === 'entity') {
if ($key === 'entity') continue; continue;
}
// For special values // For special values
if ($key === 'data') if ($key === 'data') {
{ if (is_array($val)) {
if (is_array($val)) foreach ($val as $value) {
{
foreach ($val as $value)
{
$text .= ($i ? ', ' : '').($value); $text .= ($i ? ', ' : '').($value);
$i++; $i++;
} }
@ -488,54 +507,57 @@ if ($mode == 'feature')
$text .= ($i ? ', ' : '').($val); $text .= ($i ? ', ' : '').($val);
$i++; $i++;
} }
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddPermissions").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddPermissions").':</strong> ';
if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) {
{
$i = 0; $i = 0;
foreach ($objMod->rights as $val) foreach ($objMod->rights as $val) {
{
$text .= ($i ? ', ' : '').($val[1]); $text .= ($i ? ', ' : '').($val[1]);
$i++; $i++;
} }
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddMenus").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddMenus").':</strong> ';
if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1 if (isset($objMod->menu) && !empty($objMod->menu)) { // objMod can be an array or just an int 1
{
$text .= $langs->trans("Yes"); $text .= $langs->trans("Yes");
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddExportProfiles").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddExportProfiles").':</strong> ';
if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) {
{
$i = 0; $i = 0;
foreach ($objMod->export_label as $val) foreach ($objMod->export_label as $val) {
{
$text .= ($i ? ', ' : '').($val); $text .= ($i ? ', ' : '').($val);
$i++; $i++;
} }
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
$text .= '<br><strong>'.$langs->trans("AddImportProfiles").':</strong> '; $text .= '<br><strong>'.$langs->trans("AddImportProfiles").':</strong> ';
if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) {
{
$i = 0; $i = 0;
foreach ($objMod->import_label as $val) foreach ($objMod->import_label as $val) {
{
$text .= ($i ? ', ' : '').($val); $text .= ($i ? ', ' : '').($val);
$i++; $i++;
} }
} else $text .= $langs->trans("No"); } else {
$text .= $langs->trans("No");
}
$text .= '<br>'; $text .= '<br>';
@ -544,11 +566,13 @@ if ($mode == 'feature')
} }
if ($mode == 'changelog') if ($mode == 'changelog') {
{
$changelog = $objMod->getChangeLog(); $changelog = $objMod->getChangeLog();
if ($changelog) $text .= '<div class="moduledesclong">'.$changelog.'<div>'; if ($changelog) {
else $text .= '<div class="moduledesclong">'.$langs->trans("NotAvailable").'</div>'; $text .= '<div class="moduledesclong">'.$changelog.'<div>';
} else {
$text .= '<div class="moduledesclong">'.$langs->trans("NotAvailable").'</div>';
}
} }
print $text; print $text;

View File

@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'mrp', 'other')); $langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -46,23 +48,24 @@ $type = 'mrp';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstmrp = GETPOST('maskconstMo', 'alpha'); $maskconstmrp = GETPOST('maskconstMo', 'alpha');
$maskmrp = GETPOST('maskMo', 'alpha'); $maskmrp = GETPOST('maskMo', 'alpha');
if ($maskconstmrp) $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity); if ($maskconstmrp) {
$res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$mo = new MO($db); $mo = new MO($db);
@ -71,25 +74,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($mrp, $langs) > 0) if ($module->write_file($mrp, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -100,26 +99,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->MRP_MO_ADDON_PDF == "$value") {
if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "MRP_MO_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "MRP_MO_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that was read before the new set // The constant that was read before the new set
// We therefore requires a variable to have a coherent view // We therefore requires a variable to have a coherent view
$conf->global->MRP_MO_ADDON_PDF = $value; $conf->global->MRP_MO_ADDON_PDF = $value;
@ -127,39 +119,37 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// TODO Check if numbering module chosen can be activated // TODO Check if numbering module chosen can be activated
// by calling method canBeActivated // by calling method canBeActivated
dolibarr_set_const($db, "MRP_MO_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MRP_MO_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK') } elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK') {
{
$draft = GETPOST("MRP_MO_DRAFT_WATERMARK"); $draft = GETPOST("MRP_MO_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "MRP_MO_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MRP_MO_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_MRP_MO_FREE_TEXT') } elseif ($action == 'set_MRP_MO_FREE_TEXT') {
{
$freetext = GETPOST("MRP_MO_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST("MRP_MO_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "MRP_MO_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MRP_MO_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -201,19 +191,14 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/mrp/"); $dir = dol_buildpath($reldir."core/modules/mrp/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -221,11 +206,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db); $module = new $file($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -236,13 +224,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->MRP_MO_ADDON == $file) if ($conf->global->MRP_MO_ADDON == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -262,8 +252,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -298,12 +289,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -325,31 +314,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/mrp".$valdir; $realpath = $reldir."core/modules/mrp".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -357,21 +338,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -385,8 +371,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->MRP_MO_ADDON_PDF == $name) if ($conf->global->MRP_MO_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -396,8 +381,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -413,8 +397,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -449,7 +432,9 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -458,8 +443,7 @@ print '<input type="hidden" name="action" value="set_MRP_MO_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'MRP_MO_FREE_TEXT'; $variablename = 'MRP_MO_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -39,13 +39,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'mrp_mo'; $elementtype = 'mrp_mo';
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -78,8 +82,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -89,8 +92,7 @@ if ($action != 'create' && $action != 'edit')
/* /*
* Creation of an optional field * Creation of an optional field
*/ */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -100,8 +102,7 @@ if ($action == 'create')
/* /*
* Edition of an optional field * Edition of an optional field
*/ */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -46,31 +46,26 @@ $action = GETPOST('action', 'aZ09');
*/ */
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
$value = GETPOST($code, 'alpha'); $value = GETPOST($code, 'alpha');
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
if (dolibarr_del_const($db, $code, 0) > 0) if (dolibarr_del_const($db, $code, 0) > 0) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'add_currency') if ($action == 'add_currency') {
{
$error = 0; $error = 0;
$langs->loadCacheCurrencies(''); $langs->loadCacheCurrencies('');
@ -81,59 +76,55 @@ if ($action == 'add_currency')
$currency->code = $code; $currency->code = $code;
$currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code; $currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code;
if (empty($rate)) if (empty($rate)) {
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{ if ($currency->create($user) > 0) {
if ($currency->create($user) > 0) if ($currency->addRate($rate)) {
{ setEventMessages($langs->trans('RecordSaved'), array());
if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array()); } else {
else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors'); setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors');
} else setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors');
} }
} elseif ($action == 'update_currency') } else {
{ setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors');
}
}
} elseif ($action == 'update_currency') {
$error = 0; $error = 0;
if (GETPOST('updatecurrency', 'alpha')) if (GETPOST('updatecurrency', 'alpha')) {
{
$fk_multicurrency = GETPOST('fk_multicurrency', 'int'); $fk_multicurrency = GETPOST('fk_multicurrency', 'int');
$rate = price2num(GETPOST('rate', 'alpha')); $rate = price2num(GETPOST('rate', 'alpha'));
$currency = new MultiCurrency($db); $currency = new MultiCurrency($db);
if (empty($rate)) if (empty($rate)) {
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{ if ($currency->fetch($fk_multicurrency) > 0) {
if ($currency->fetch($fk_multicurrency) > 0)
{
$result = $currency->updateRate($rate); $result = $currency->updateRate($rate);
if ($result < 0) { if ($result < 0) {
setEventMessages(null, $currency->errors, 'errors'); setEventMessages(null, $currency->errors, 'errors');
} }
} }
} }
} elseif (GETPOST('deletecurrency', 'alpha')) } elseif (GETPOST('deletecurrency', 'alpha')) {
{
$fk_multicurrency = GETPOST('fk_multicurrency', 'int'); $fk_multicurrency = GETPOST('fk_multicurrency', 'int');
$currency = new MultiCurrency($db); $currency = new MultiCurrency($db);
if ($currency->fetch($fk_multicurrency) > 0) if ($currency->fetch($fk_multicurrency) > 0) {
{ if ($currency->delete() > 0) {
if ($currency->delete() > 0) setEventMessages($langs->trans('RecordDeleted'), array()); setEventMessages($langs->trans('RecordDeleted'), array());
else setEventMessages($langs->trans('ErrorDeleteCurrencyFail'), array(), 'errors'); } else {
setEventMessages($langs->trans('ErrorDeleteCurrencyFail'), array(), 'errors');
} }
} }
} elseif ($action == 'setapilayer') }
{ } elseif ($action == 'setapilayer') {
if (GETPOSTISSET('modify_apilayer')) if (GETPOSTISSET('modify_apilayer')) {
{
dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha')); dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha'));
dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha'));
//dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha'));
@ -149,10 +140,8 @@ if ($action == 'add_currency')
$TCurrency = array(); $TCurrency = array();
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{ while ($obj = $db->fetch_object($resql)) {
while ($obj = $db->fetch_object($resql))
{
$currency = new MultiCurrency($db); $currency = new MultiCurrency($db);
$currency->fetch($obj->rowid); $currency->fetch($obj->rowid);
$TCurrency[] = $currency; $TCurrency[] = $currency;
@ -209,8 +198,7 @@ if ($conf->use_javascript_ajax) {
print '</td></tr>'; print '</td></tr>';
// Online payment with currency on document. This option should be on by default. // Online payment with currency on document. This option should be on by default.
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").'</td>'; print '<td>'.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").'</td>';
print '<td class="center">'; print '<td class="center">';
@ -256,8 +244,7 @@ print '</table>';
print '<br>'; print '<br>';
if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) {
{
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" id="form_sync">'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" id="form_sync">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setapilayer">'; print '<input type="hidden" name="action" value="setapilayer">';
@ -328,9 +315,10 @@ print '<td>'.$conf->currency.$form->textwithpicto(' ', $langs->trans("BaseCurren
print '<td class="right">1</td>'; print '<td class="right">1</td>';
print '</tr>'; print '</tr>';
foreach ($TCurrency as &$currency) foreach ($TCurrency as &$currency) {
{ if ($currency->code == $conf->currency) {
if ($currency->code == $conf->currency) continue; continue;
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$currency->code.' - '.$currency->name.'</td>'; print '<td>'.$currency->code.' - '.$currency->name.'</td>';

View File

@ -47,16 +47,15 @@ $error = 0;
*/ */
// Action to update or add a constant // Action to update or add a constant
if ($action == 'settemplates') if ($action == 'settemplates') {
{
$db->begin(); $db->begin();
if (!$error && is_array($_POST)) if (!$error && is_array($_POST)) {
{
$reg = array(); $reg = array();
foreach ($_POST as $key => $val) foreach ($_POST as $key => $val) {
{ if (!preg_match('/^constvalue_(.*)_TEMPLATE/', $key, $reg)) {
if (!preg_match('/^constvalue_(.*)_TEMPLATE/', $key, $reg)) continue; continue;
}
$triggername = $reg[1]; $triggername = $reg[1];
$constvalue = GETPOST($key, 'alpha'); $constvalue = GETPOST($key, 'alpha');
@ -79,8 +78,7 @@ if ($action == 'settemplates')
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -91,16 +89,16 @@ if ($action == 'settemplates')
} }
} }
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$db->begin(); $db->begin();
$result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", GETPOST("email_from", "restricthtml"), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", GETPOST("email_from", "restricthtml"), 'chaine', 0, '', $conf->entity);
if ($result < 0) $error++; if ($result < 0) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -112,16 +110,15 @@ if ($action == 'setvalue' && $user->admin)
} }
if ($action == 'setfixednotif' && $user->admin) if ($action == 'setfixednotif' && $user->admin) {
{
$db->begin(); $db->begin();
if (!$error && is_array($_POST)) if (!$error && is_array($_POST)) {
{
$reg = array(); $reg = array();
foreach ($_POST as $key => $val) foreach ($_POST as $key => $val) {
{ if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) {
if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; continue;
}
$newval = ''; $newval = '';
$newkey = ''; $newkey = '';
@ -129,29 +126,25 @@ if ($action == 'setfixednotif' && $user->admin)
$shortkey = preg_replace('/_key$/', '', $key); $shortkey = preg_replace('/_key$/', '', $key);
//print $shortkey.'<br>'; //print $shortkey.'<br>';
if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) {
{
dolibarr_del_const($db, 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity); dolibarr_del_const($db, 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity);
$newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount'));
$newval = GETPOST($shortkey.'_key'); $newval = GETPOST($shortkey.'_key');
//print $newkey.' - '.$newval.'<br>'; //print $newkey.' - '.$newval.'<br>';
} elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg)) } elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg)) {
{
// Add a new entry // Add a new entry
$newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount'));
$newval = GETPOST($shortkey.'_key'); $newval = GETPOST($shortkey.'_key');
} }
if ($newkey && $newval) if ($newkey && $newval) {
{
$result = dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity);
} }
} }
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -179,7 +172,9 @@ print load_fiche_titre($langs->trans("NotificationSetup"), $linkback, 'title_set
print '<span class="opacitymedium">'; print '<span class="opacitymedium">';
print $langs->trans("NotificationsDesc").'<br>'; print $langs->trans("NotificationsDesc").'<br>';
print $langs->trans("NotificationsDescUser").'<br>'; print $langs->trans("NotificationsDescUser").'<br>';
if (!empty($conf->societe->enabled)) print $langs->trans("NotificationsDescContact").'<br>'; if (!empty($conf->societe->enabled)) {
print $langs->trans("NotificationsDescContact").'<br>';
}
print $langs->trans("NotificationsDescGlobal").'<br>'; print $langs->trans("NotificationsDescGlobal").'<br>';
print '</span>'; print '</span>';
print '<br>'; print '<br>';
@ -198,7 +193,9 @@ print '<tr class="oddeven"><td>';
print $langs->trans("NotificationEMailFrom").'</td>'; print $langs->trans("NotificationEMailFrom").'</td>';
print '<td>'; print '<td>';
print '<input size="32" type="email" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">'; print '<input size="32" type="email" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail")); if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) {
print ' '.img_warning($langs->trans("ErrorBadEMail"));
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
@ -217,7 +214,9 @@ print '<input type="hidden" name="action" value="settemplates">';
// Notification per contacts // Notification per contacts
$title = $langs->trans("ListOfNotificationsPerUser"); $title = $langs->trans("ListOfNotificationsPerUser");
if (!empty($conf->societe->enabled)) $title = $langs->trans("ListOfNotificationsPerUserOrContact"); if (!empty($conf->societe->enabled)) {
$title = $langs->trans("ListOfNotificationsPerUserOrContact");
}
print load_fiche_titre($title, '', ''); print load_fiche_titre($title, '', '');
// Load array of available notifications // Load array of available notifications
@ -228,28 +227,44 @@ $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
// Editing global variables not related to a specific theme // Editing global variables not related to a specific theme
$constantes = array(); $constantes = array();
foreach ($listofnotifiedevents as $notifiedevent) foreach ($listofnotifiedevents as $notifiedevent) {
{
$label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
$elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); if ($notifiedevent['elementtype'] == 'order_supplier') {
elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); $elementLabel = $langs->trans('SupplierOrder');
elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); } elseif ($notifiedevent['elementtype'] == 'propal') {
elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); $elementLabel = $langs->trans('Proposal');
elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention'); } elseif ($notifiedevent['elementtype'] == 'facture') {
elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping'); $elementLabel = $langs->trans('Bill');
elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('ExpenseReport'); } elseif ($notifiedevent['elementtype'] == 'commande') {
$elementLabel = $langs->trans('Order');
} elseif ($notifiedevent['elementtype'] == 'ficheinter') {
$elementLabel = $langs->trans('Intervention');
} elseif ($notifiedevent['elementtype'] == 'shipping') {
$elementLabel = $langs->trans('Shipping');
} elseif ($notifiedevent['elementtype'] == 'expensereport') {
$elementLabel = $langs->trans('ExpenseReport');
}
if ($notifiedevent['elementtype'] == 'propal') $model = 'propal_send'; if ($notifiedevent['elementtype'] == 'propal') {
elseif ($notifiedevent['elementtype'] == 'commande') $model = 'order_send'; $model = 'propal_send';
elseif ($notifiedevent['elementtype'] == 'facture') $model = 'facture_send'; } elseif ($notifiedevent['elementtype'] == 'commande') {
elseif ($notifiedevent['elementtype'] == 'shipping') $model = 'shipping_send'; $model = 'order_send';
elseif ($notifiedevent['elementtype'] == 'ficheinter') $model = 'fichinter_send'; } elseif ($notifiedevent['elementtype'] == 'facture') {
elseif ($notifiedevent['elementtype'] == 'expensereport') $model = 'expensereport_send'; $model = 'facture_send';
elseif ($notifiedevent['elementtype'] == 'order_supplier') $model = 'order_supplier_send'; } elseif ($notifiedevent['elementtype'] == 'shipping') {
//elseif ($notifiedevent['elementtype'] == 'invoice_supplier') $model = 'invoice_supplier_send'; $model = 'shipping_send';
elseif ($notifiedevent['elementtype'] == 'member') $model = 'member'; } elseif ($notifiedevent['elementtype'] == 'ficheinter') {
$model = 'fichinter_send';
} elseif ($notifiedevent['elementtype'] == 'expensereport') {
$model = 'expensereport_send';
} elseif ($notifiedevent['elementtype'] == 'order_supplier') {
$model = 'order_supplier_send';
// } elseif ($notifiedevent['elementtype'] == 'invoice_supplier') $model = 'invoice_supplier_send';
} elseif ($notifiedevent['elementtype'] == 'member') {
$model = 'member';
}
$constantes[$notifiedevent['code'].'_TEMPLATE'] = array('type'=>'emailtemplate:'.$model, 'label'=>$label); $constantes[$notifiedevent['code'].'_TEMPLATE'] = array('type'=>'emailtemplate:'.$model, 'label'=>$label);
} }
@ -269,20 +284,29 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
print '<td>'; print '<td>';
$i = 0; $i = 0;
foreach ($listofnotifiedevents as $notifiedevent) foreach ($listofnotifiedevents as $notifiedevent) {
{
$label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
$elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); if ($notifiedevent['elementtype'] == 'order_supplier') {
elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); $elementLabel = $langs->trans('SupplierOrder');
elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); } elseif ($notifiedevent['elementtype'] == 'propal') {
elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); $elementLabel = $langs->trans('Proposal');
elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention'); } elseif ($notifiedevent['elementtype'] == 'facture') {
elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping'); $elementLabel = $langs->trans('Bill');
elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('ExpenseReport'); } elseif ($notifiedevent['elementtype'] == 'commande') {
$elementLabel = $langs->trans('Order');
} elseif ($notifiedevent['elementtype'] == 'ficheinter') {
$elementLabel = $langs->trans('Intervention');
} elseif ($notifiedevent['elementtype'] == 'shipping') {
$elementLabel = $langs->trans('Shipping');
} elseif ($notifiedevent['elementtype'] == 'expensereport') {
$elementLabel = $langs->trans('ExpenseReport');
}
if ($i) print ', '; if ($i) {
print ', ';
}
print $label; print $label;
$i++; $i++;
@ -316,19 +340,26 @@ print '<td>'.$langs->trans("Threshold").'</td>';
print '<td></td>'; print '<td></td>';
print "</tr>\n"; print "</tr>\n";
foreach ($listofnotifiedevents as $notifiedevent) foreach ($listofnotifiedevents as $notifiedevent) {
{
$label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
$elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
// Special cases // Special cases
if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); if ($notifiedevent['elementtype'] == 'order_supplier') {
elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); $elementLabel = $langs->trans('SupplierOrder');
elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); } elseif ($notifiedevent['elementtype'] == 'propal') {
elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); $elementLabel = $langs->trans('Proposal');
elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention'); } elseif ($notifiedevent['elementtype'] == 'facture') {
elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping'); $elementLabel = $langs->trans('Bill');
elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('ExpenseReport'); } elseif ($notifiedevent['elementtype'] == 'commande') {
$elementLabel = $langs->trans('Order');
} elseif ($notifiedevent['elementtype'] == 'ficheinter') {
$elementLabel = $langs->trans('Intervention');
} elseif ($notifiedevent['elementtype'] == 'shipping') {
$elementLabel = $langs->trans('Shipping');
} elseif ($notifiedevent['elementtype'] == 'expensereport') {
$elementLabel = $langs->trans('ExpenseReport');
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$elementLabel.'</td>'; print '<td>'.$elementLabel.'</td>';
@ -336,9 +367,10 @@ foreach ($listofnotifiedevents as $notifiedevent)
print '<td>'.$label.'</td>'; print '<td>'.$label.'</td>';
print '<td>'; print '<td>';
// Notification with threshold // Notification with threshold
foreach ($conf->global as $key => $val) foreach ($conf->global as $key => $val) {
{ if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; continue;
}
$param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1];
$value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param;
@ -346,12 +378,15 @@ foreach ($listofnotifiedevents as $notifiedevent)
$s = '<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key" value="'.dol_escape_htmltag($value).'">'; // Do not use type="email" here, we must be able to enter a list of email with , separator. $s = '<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key" value="'.dol_escape_htmltag($value).'">'; // Do not use type="email" here, we must be able to enter a list of email with , separator.
$arrayemail = explode(',', $value); $arrayemail = explode(',', $value);
$showwarning = 0; $showwarning = 0;
foreach ($arrayemail as $keydet => $valuedet) foreach ($arrayemail as $keydet => $valuedet) {
{
$valuedet = trim($valuedet); $valuedet = trim($valuedet);
if (!empty($valuedet) && !isValidEmail($valuedet, 1)) $showwarning++; if (!empty($valuedet) && !isValidEmail($valuedet, 1)) {
$showwarning++;
}
}
if ((!empty($conf->global->$param)) && $showwarning) {
$s .= ' '.img_warning($langs->trans("ErrorBadEMail"));
} }
if ((!empty($conf->global->$param)) && $showwarning) $s .= ' '.img_warning($langs->trans("ErrorBadEMail"));
print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'<br>'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'<br>'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2);
print '<br>'; print '<br>';
} }
@ -362,9 +397,10 @@ foreach ($listofnotifiedevents as $notifiedevent)
print '<td>'; print '<td>';
// Notification with threshold // Notification with threshold
foreach ($conf->global as $key => $val) foreach ($conf->global as $key => $val) {
{ if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; continue;
}
print $langs->trans("AmountHT").' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_amount" value="'.dol_escape_htmltag($reg[1]).'">'; print $langs->trans("AmountHT").' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_amount" value="'.dol_escape_htmltag($reg[1]).'">';
print '<br>'; print '<br>';
@ -383,7 +419,9 @@ print '</table>';
print '<div class="opacitymedium">'; print '<div class="opacitymedium">';
print '* '.$langs->trans("GoOntoUserCardToAddMore").'<br>'; print '* '.$langs->trans("GoOntoUserCardToAddMore").'<br>';
if (!empty($conf->societe->enabled)) print '** '.$langs->trans("GoOntoContactCardToAddMore").'<br>'; if (!empty($conf->societe->enabled)) {
print '** '.$langs->trans("GoOntoContactCardToAddMore").'<br>';
}
print '</div>'; print '</div>';

View File

@ -37,8 +37,9 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai
$langs->loadLangs(array('admin', 'oauth')); $langs->loadLangs(array('admin', 'oauth'));
// Security check // Security check
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -47,21 +48,21 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'update') if ($action == 'update') {
{
$error = 0; $error = 0;
foreach ($list as $constname) { foreach ($list as $constname) {
$constvalue = GETPOST($constname[1], 'alpha'); $constvalue = GETPOST($constname[1], 'alpha');
if (!dolibarr_set_const($db, $constname[1], $constvalue, 'chaine', 0, '', $conf->entity)) if (!dolibarr_set_const($db, $constname[1], $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
$constvalue = GETPOST($constname[2], 'alpha');
if (!dolibarr_set_const($db, $constname[2], $constvalue, 'chaine', 0, '', $conf->entity))
$error++; $error++;
} }
$constvalue = GETPOST($constname[2], 'alpha');
if (!dolibarr_set_const($db, $constname[2], $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null); setEventMessages($langs->trans("SetupSaved"), null);
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -95,11 +96,14 @@ print '<table class="noborder centpercent">';
$i = 0; $i = 0;
// $list is defined into oauth.lib.php // $list is defined into oauth.lib.php
foreach ($list as $key) foreach ($list as $key) {
{
$supported = 0; $supported = 0;
if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; if (in_array($key[0], array_keys($supportedoauth2array))) {
if (!$supported) continue; // show only supported $supported = 1;
}
if (!$supported) {
continue; // show only supported
}
$i++; $i++;
@ -108,12 +112,13 @@ foreach ($list as $key)
$label = $langs->trans($key[0]); $label = $langs->trans($key[0]);
print '<td>'.$label.'</td>'; print '<td>'.$label.'</td>';
print '<td>'; print '<td>';
if (!empty($key[3])) print $langs->trans($key[3]); if (!empty($key[3])) {
print $langs->trans($key[3]);
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
if ($supported) if ($supported) {
{
$redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php';
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>'; print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';

View File

@ -32,7 +32,9 @@ use OAuth\Common\Storage\DoliStorage;
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'printing', 'oauth')); $langs->loadLangs(array('admin', 'printing', 'oauth'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$mode = GETPOST('mode', 'alpha'); $mode = GETPOST('mode', 'alpha');
@ -40,9 +42,13 @@ $value = GETPOST('value', 'alpha');
$varname = GETPOST('varname', 'alpha'); $varname = GETPOST('varname', 'alpha');
$driver = GETPOST('driver', 'alpha'); $driver = GETPOST('driver', 'alpha');
if (!empty($driver)) $langs->load($driver); if (!empty($driver)) {
$langs->load($driver);
}
if (!$mode) $mode = 'setup'; if (!$mode) {
$mode = 'setup';
}
/* /*
@ -56,8 +62,7 @@ if (!$mode) $mode = 'setup';
exit; exit;
}*/ }*/
if ($action == 'setconst' && $user->admin) if ($action == 'setconst' && $user->admin) {
{
$error = 0; $error = 0;
$db->begin(); $db->begin();
@ -72,11 +77,12 @@ if ($action == 'setconst' && $user->admin)
$constnote = dol_escape_htmltag($setupconst['note']); $constnote = dol_escape_htmltag($setupconst['note']);
$result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity); $result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
if (!$result > 0) $error++; if (!$result > 0) {
$error++;
}
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null); setEventMessages($langs->trans("SetupSaved"), null);
} else { } else {
@ -86,15 +92,15 @@ if ($action == 'setconst' && $user->admin)
$action = ''; $action = '';
} }
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$db->begin(); $db->begin();
$result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
if (!$result > 0) $error++; if (!$result > 0) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null); setEventMessages($langs->trans("SetupSaved"), null);
} else { } else {
@ -129,20 +135,21 @@ if (GETPOST('error')) {
setEventMessages(GETPOST('error'), null, 'errors'); setEventMessages(GETPOST('error'), null, 'errors');
} }
if ($mode == 'setup' && $user->admin) if ($mode == 'setup' && $user->admin) {
{
print '<span class="opacitymedium">'.$langs->trans("OAuthSetupForLogin")."</span><br><br>\n"; print '<span class="opacitymedium">'.$langs->trans("OAuthSetupForLogin")."</span><br><br>\n";
foreach ($list as $key) foreach ($list as $key) {
{
$supported = 0; $supported = 0;
if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; if (in_array($key[0], array_keys($supportedoauth2array))) {
if (!$supported) continue; // show only supported $supported = 1;
}
if (!$supported) {
continue; // show only supported
}
$OAUTH_SERVICENAME = 'Unknown'; $OAUTH_SERVICENAME = 'Unknown';
if ($key[0] == 'OAUTH_GITHUB_NAME') if ($key[0] == 'OAUTH_GITHUB_NAME') {
{
$OAUTH_SERVICENAME = 'GitHub'; $OAUTH_SERVICENAME = 'GitHub';
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service). // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect. // We pass this param list in to 'state' because we need it before and after the redirect.
@ -150,8 +157,7 @@ if ($mode == 'setup' && $user->admin)
$urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/'; $urltocheckperms = 'https://github.com/settings/applications/';
} elseif ($key[0] == 'OAUTH_GOOGLE_NAME') } elseif ($key[0] == 'OAUTH_GOOGLE_NAME') {
{
$OAUTH_SERVICENAME = 'Google'; $OAUTH_SERVICENAME = 'Google';
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service). // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect. // We pass this param list in to 'state' because we need it before and after the redirect.
@ -163,14 +169,12 @@ if ($mode == 'setup' && $user->admin)
$urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://security.google.com/settings/security/permissions'; $urltocheckperms = 'https://security.google.com/settings/security/permissions';
} elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME') } elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME') {
{
$OAUTH_SERVICENAME = 'StripeTest'; $OAUTH_SERVICENAME = 'StripeTest';
$urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = ''; $urltodelete = '';
$urltocheckperms = ''; $urltocheckperms = '';
} elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME') } elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME') {
{
$OAUTH_SERVICENAME = 'StripeLive'; $OAUTH_SERVICENAME = 'StripeLive';
$urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = ''; $urltodelete = '';
@ -191,8 +195,7 @@ if ($mode == 'setup' && $user->admin)
$storage = new DoliStorage($db, $conf); $storage = new DoliStorage($db, $conf);
try { try {
$tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME); $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
} catch (Exception $e) } catch (Exception $e) {
{
// Return an error if token not found // Return an error if token not found
} }
@ -211,11 +214,9 @@ if ($mode == 'setup' && $user->admin)
$refreshtoken = $tokenobj->getRefreshToken(); $refreshtoken = $tokenobj->getRefreshToken();
$endoflife = $tokenobj->getEndOfLife(); $endoflife = $tokenobj->getEndOfLife();
if ($endoflife == $tokenobj::EOL_NEVER_EXPIRES) if ($endoflife == $tokenobj::EOL_NEVER_EXPIRES) {
{
$expiredat = $langs->trans("Never"); $expiredat = $langs->trans("Never");
} elseif ($endoflife == $tokenobj::EOL_UNKNOWN) } elseif ($endoflife == $tokenobj::EOL_UNKNOWN) {
{
$expiredat = $langs->trans("Unknown"); $expiredat = $langs->trans("Unknown");
} else { } else {
$expiredat = dol_print_date($endoflife, "dayhour"); $expiredat = dol_print_date($endoflife, "dayhour");
@ -255,24 +256,24 @@ if ($mode == 'setup' && $user->admin)
print $langs->trans("IsTokenGenerated"); print $langs->trans("IsTokenGenerated");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if (is_object($tokenobj)) print $langs->trans("HasAccessToken"); if (is_object($tokenobj)) {
else print $langs->trans("NoAccessToken"); print $langs->trans("HasAccessToken");
} else {
print $langs->trans("NoAccessToken");
}
print '</td>'; print '</td>';
print '<td>'; print '<td>';
// Links to delete/checks token // Links to delete/checks token
if (is_object($tokenobj)) if (is_object($tokenobj)) {
{
//test on $storage->hasAccessToken($OAUTH_SERVICENAME) ? //test on $storage->hasAccessToken($OAUTH_SERVICENAME) ?
print '<a class="button" href="'.$urltodelete.'">'.$langs->trans('DeleteAccess').'</a><br>'; print '<a class="button" href="'.$urltodelete.'">'.$langs->trans('DeleteAccess').'</a><br>';
} }
// Request remote token // Request remote token
if ($urltorenew) if ($urltorenew) {
{
print '<a class="button" href="'.$urltorenew.'">'.$langs->trans('RequestAccess').'</a><br>'; print '<a class="button" href="'.$urltorenew.'">'.$langs->trans('RequestAccess').'</a><br>';
} }
// Check remote access // Check remote access
if ($urltocheckperms) if ($urltocheckperms) {
{
print '<br>'.$langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME).': <a href="'.$urltocheckperms.'" target="_'.strtolower($OAUTH_SERVICENAME).'">'.$urltocheckperms.'</a>'; print '<br>'.$langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME).': <a href="'.$urltocheckperms.'" target="_'.strtolower($OAUTH_SERVICENAME).'">'.$urltocheckperms.'</a>';
} }
print '</td>'; print '</td>';
@ -283,8 +284,7 @@ if ($mode == 'setup' && $user->admin)
//var_dump($key); //var_dump($key);
print $langs->trans("Token").'</td>'; print $langs->trans("Token").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
if (is_object($tokenobj)) if (is_object($tokenobj)) {
{
//var_dump($tokenobj); //var_dump($tokenobj);
print $tokenobj->getAccessToken().'<br>'; print $tokenobj->getAccessToken().'<br>';
//print 'Refresh: '.$tokenobj->getRefreshToken().'<br>'; //print 'Refresh: '.$tokenobj->getRefreshToken().'<br>';
@ -297,8 +297,7 @@ if ($mode == 'setup' && $user->admin)
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
if (is_object($tokenobj)) if (is_object($tokenobj)) {
{
// Token refresh // Token refresh
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td'.($key['required'] ? ' class="required"' : '').'>'; print '<td'.($key['required'] ? ' class="required"' : '').'>';
@ -332,8 +331,7 @@ if ($mode == 'setup' && $user->admin)
print '</table>'; print '</table>';
if (!empty($driver)) if (!empty($driver)) {
{
if ($submit_enabled) { if ($submit_enabled) {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>'; print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>';
} }
@ -344,13 +342,11 @@ if ($mode == 'setup' && $user->admin)
} }
} }
if ($mode == 'test' && $user->admin) if ($mode == 'test' && $user->admin) {
{
print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n"; print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
if (!empty($driver)) if (!empty($driver)) {
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
$classname = 'printing_'.$driver; $classname = 'printing_'.$driver;
$langs->load($driver); $langs->load($driver);
@ -370,8 +366,7 @@ if ($mode == 'test' && $user->admin)
print '</table>'; print '</table>';
} }
if ($mode == 'userconf' && $user->admin) if ($mode == 'userconf' && $user->admin) {
{
print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n"; print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n";
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';

View File

@ -31,7 +31,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adm
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'companies', 'other')); $langs->loadLangs(array('admin', 'companies', 'other'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$error = 0; $error = 0;
@ -42,11 +44,12 @@ $error = 0;
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (($action == 'update' && !GETPOST("cancel", 'alpha')) if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|| ($action == 'updateedit')) || ($action == 'updateedit')) {
{
dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_MONDAY", GETPOST("monday", 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_MONDAY", GETPOST("monday", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_TUESDAY", GETPOST("tuesday", 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_TUESDAY", GETPOST("tuesday", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_WEDNESDAY", GETPOST("wednesday", 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_WEDNESDAY", GETPOST("wednesday", 'alpha'), 'chaine', 0, '', $conf->entity);
@ -55,8 +58,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SATURDAY", GETPOST("saturday", 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SATURDAY", GETPOST("saturday", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SUNDAY", GETPOST('sunday', 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SUNDAY", GETPOST('sunday', 'alpha'), 'chaine', 0, '', $conf->entity);
if ($action != 'updateedit' && !$error) if ($action != 'updateedit' && !$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
@ -81,8 +83,7 @@ print dol_get_fiche_head($head, 'openinghours', $langs->trans("Company"), -1, 'c
print '<span class="opacitymedium">'.$langs->trans("OpeningHoursDesc")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("OpeningHoursDesc")."</span><br>\n";
print "<br>\n"; print "<br>\n";
if (empty($action) || $action == 'edit' || $action == 'updateedit') if (empty($action) || $action == 'edit' || $action == 'updateedit') {
{
/** /**
* Edit parameters * Edit parameters
*/ */

View File

@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'orders')); $langs->loadLangs(array('admin', 'other', 'orders'));
@ -43,13 +44,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commande'; //Must be the $table_element of the class that manage extrafield $elementtype = 'commande'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -81,8 +86,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -95,8 +99,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -108,8 +111,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadlangs(array('admin', 'other', 'orders')); $langs->loadlangs(array('admin', 'other', 'orders'));
@ -44,13 +45,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commandedet'; //Must be the $table_element of the class that manage extrafield $elementtype = 'commandedet'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -82,8 +87,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -96,8 +100,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -109,8 +112,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "errors", "bills")); $langs->loadLangs(array("admin", "other", "errors", "bills"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -38,49 +40,53 @@ $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha');
$type = 'invoice'; $type = 'invoice';
if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_payment_cicada.php'; if (empty($conf->global->PAYMENT_ADDON)) {
$conf->global->PAYMENT_ADDON = 'mod_payment_cicada.php';
}
/* /*
* Actions * Actions
*/ */
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstpayment = GETPOST('maskconstpayment', 'alpha'); $maskconstpayment = GETPOST('maskconstpayment', 'alpha');
$maskpayment = GETPOST('maskpayment', 'alpha'); $maskpayment = GETPOST('maskpayment', 'alpha');
if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); if ($maskconstpayment) {
$res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'setmod') if ($action == 'setmod') {
{
dolibarr_set_const($db, "PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity);
} }
if ($action == 'setparams') if ($action == 'setparams') {
{
$freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, "PAYMENTS_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PAYMENTS_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if ($error) if ($error) {
{
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
} }
@ -121,41 +127,40 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/payment/"); $dir = dol_buildpath($reldir."core/modules/payment/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
{
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
{
$filebis = $file; $filebis = $file;
$classname = preg_replace('/\.php$/', '', $file); $classname = preg_replace('/\.php$/', '', $file);
// For compatibility // For compatibility
if (!is_file($dir.$filebis)) if (!is_file($dir.$filebis)) {
{
$filebis = $file."/".$file.".modules.php"; $filebis = $file."/".$file.".modules.php";
$classname = "mod_payment_".$file; $classname = "mod_payment_".$file;
} }
// Check if there is a filter on country // Check if there is a filter on country
preg_match('/\-(.*)_(.*)$/', $classname, $reg); preg_match('/\-(.*)_(.*)$/', $classname, $reg);
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
continue;
}
$classname = preg_replace('/\-.*$/', '', $classname); $classname = preg_replace('/\-.*$/', '', $classname);
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
{
// Charging the numbering class // Charging the numbering class
require_once $dir.$filebis; require_once $dir.$filebis;
$module = new $classname($db); $module = new $classname($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) { if ($module->isEnabled()) {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
@ -172,14 +177,16 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
//print "> ".$conf->global->PAYMENT_ADDON." - ".$file; //print "> ".$conf->global->PAYMENT_ADDON." - ".$file;
if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmo&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmo&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -196,8 +203,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValue").': '; $htmltooltip .= $langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -207,9 +215,10 @@ foreach ($dirmodels as $reldir)
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors if ($conf->global->PAYMENT_ADDON.'.php' == $file) { // If module is the one used, we show existing errors
{ if (!empty($module->error)) {
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); dol_htmloutput_mesg($module->error, '', 'error', 1);
}
} }
print '</td>'; print '</td>';

View File

@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->loadLangs(array("admin", "withdrawals")); $langs->loadLangs(array("admin", "withdrawals"));
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$type = 'paymentorder'; $type = 'paymentorder';
@ -44,15 +46,16 @@ $type = 'paymentorder';
* Actions * Actions
*/ */
if ($action == "set") if ($action == "set") {
{
$db->begin(); $db->begin();
$id = GETPOST('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 'int'); $id = GETPOST('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 'int');
$account = new Account($db); $account = new Account($db);
if ($account->fetch($id) > 0) { if ($account->fetch($id) > 0) {
$res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT", $id, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT", $id, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
/* /*
$res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
@ -77,10 +80,11 @@ if ($action == "set")
if (!($res > 0)) $error++; if (!($res > 0)) $error++;
*/ */
if (GETPOST("PAYMENTBYBANKTRANSFER_USER") > 0) if (GETPOST("PAYMENTBYBANKTRANSFER_USER") > 0) {
{
$res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_USER", GETPOST("PAYMENTBYBANKTRANSFER_USER"), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_USER", GETPOST("PAYMENTBYBANKTRANSFER_USER"), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
/* /*
if (GETPOST("PAYMENTBYBANKTRANSFER_END_TO_END") || GETPOST("PAYMENTBYBANKTRANSFER_END_TO_END") == "") if (GETPOST("PAYMENTBYBANKTRANSFER_END_TO_END") || GETPOST("PAYMENTBYBANKTRANSFER_END_TO_END") == "")
@ -94,12 +98,12 @@ if ($action == "set")
if (!($res > 0)) $error++; if (!($res > 0)) $error++;
} }
*/ */
if (GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS") || GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS") == "") if (GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS") || GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS") == "") {
{
$res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ADDDAYS", GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS"), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ADDDAYS", GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS"), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
} elseif (!$error) $error++;
{ }
} elseif (!$error) {
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -108,8 +112,7 @@ if ($action == "set")
} }
} }
if ($action == "addnotif") if ($action == "addnotif") {
{
$bon = new BonPrelevement($db); $bon = new BonPrelevement($db);
$bon->AddNotification($db, GETPOST('user', 'int'), $action); $bon->AddNotification($db, GETPOST('user', 'int'), $action);
@ -117,8 +120,7 @@ if ($action == "addnotif")
exit; exit;
} }
if ($action == "deletenotif") if ($action == "deletenotif") {
{
$bon = new BonPrelevement($db); $bon = new BonPrelevement($db);
$bon->DeleteNotificationById(GETPOST('notif', 'int')); $bon->DeleteNotificationById(GETPOST('notif', 'int'));
@ -190,7 +192,9 @@ print '</td></tr>';
//ADDDAYS //ADDDAYS
print '<tr class="oddeven"><td>'.$langs->trans("ADDDAYS").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("ADDDAYS").'</td>';
print '<td class="left">'; print '<td class="left">';
if (!$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS) $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS = 0; if (!$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS) {
$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS = 0;
}
print '<input type="text" name="PAYMENTBYBANKTRANSFER_ADDDAYS" value="'.$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS.'" size="15" ></td>'; print '<input type="text" name="PAYMENTBYBANKTRANSFER_ADDDAYS" value="'.$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS.'" size="15" ></td>';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';

View File

@ -35,7 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks')); $langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
@ -49,8 +51,7 @@ if ($cancel) {
$action = ''; $action = '';
} }
if ($action == 'update') if ($action == 'update') {
{
dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity);
@ -111,30 +112,34 @@ $arraydetailsforpdffoot = array(
$s = $langs->trans("LibraryToBuildPDF")."<br>"; $s = $langs->trans("LibraryToBuildPDF")."<br>";
$i = 0; $i = 0;
$pdf = pdf_getInstance('A4'); $pdf = pdf_getInstance('A4');
if (class_exists('FPDF') && !class_exists('TCPDF')) if (class_exists('FPDF') && !class_exists('TCPDF')) {
{ if ($i) {
if ($i) $s .= ' + '; $s .= ' + ';
}
$s .= 'FPDF'; $s .= 'FPDF';
$s .= ' ('.@constant('FPDF_PATH').')'; $s .= ' ('.@constant('FPDF_PATH').')';
$i++; $i++;
} }
if (class_exists('TCPDF')) if (class_exists('TCPDF')) {
{ if ($i) {
if ($i) $s .= ' + '; $s .= ' + ';
}
$s .= 'TCPDF'; $s .= 'TCPDF';
$s .= ' ('.@constant('TCPDF_PATH').')'; $s .= ' ('.@constant('TCPDF_PATH').')';
$i++; $i++;
} }
if (class_exists('FPDI')) if (class_exists('FPDI')) {
{ if ($i) {
if ($i) $s .= ' + '; $s .= ' + ';
}
$s .= 'FPDI'; $s .= 'FPDI';
$s .= ' ('.@constant('FPDI_PATH').')'; $s .= ' ('.@constant('FPDI_PATH').')';
$i++; $i++;
} }
if (class_exists('TCPDI')) if (class_exists('TCPDI')) {
{ if ($i) {
if ($i) $s .= ' + '; $s .= ' + ';
}
$s .= 'TCPDI'; $s .= 'TCPDI';
$s .= ' ('.@constant('TCPDI_PATH').')'; $s .= ' ('.@constant('TCPDI_PATH').')';
$i++; $i++;
@ -162,7 +167,9 @@ print '<table summary="more" class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
$selected = (isset($conf->global->MAIN_PDF_FORMAT) ? $conf->global->MAIN_PDF_FORMAT : ''); $selected = (isset($conf->global->MAIN_PDF_FORMAT) ? $conf->global->MAIN_PDF_FORMAT : '');
if (empty($selected)) $selected = dol_getDefaultFormat(); if (empty($selected)) {
$selected = dol_getDefaultFormat();
}
// Show pdf format // Show pdf format
@ -203,17 +210,16 @@ print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (!empty($conf->global->
print '</td></tr>'; print '</td></tr>';
// Show prof id in address into pdf // Show prof id in address into pdf
for ($i = 1; $i <= 6; $i++) for ($i = 1; $i <= 6; $i++) {
{ if (!$noCountryCode) {
if (!$noCountryCode)
{
$pid = $langs->transcountry("ProfId".$i, $mysoc->country_code); $pid = $langs->transcountry("ProfId".$i, $mysoc->country_code);
if ($pid == '-') $pid = false; if ($pid == '-') {
$pid = false;
}
} else { } else {
$pid = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; $pid = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
} }
if ($pid) if ($pid) {
{
print '<tr class="oddeven"><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid.'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid.'</td><td>';
$keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS'; $keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS';
print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode); print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode);
@ -231,18 +237,15 @@ print '<br>';
// Localtaxes // Localtaxes
$locales = ''; $locales = '';
$text = ''; $text = '';
if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) {
{ if ($mysoc->useLocalTax(1)) {
if ($mysoc->useLocalTax(1))
{
$locales = $langs->transcountry("LT1", $mysoc->country_code); $locales = $langs->transcountry("LT1", $mysoc->country_code);
$text = '<tr class="oddeven"><td>'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)).'</td><td>'; $text = '<tr class="oddeven"><td>'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)).'</td><td>';
$text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1); $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1);
$text .= '</td></tr>'; $text .= '</td></tr>';
} }
if ($mysoc->useLocalTax(2)) if ($mysoc->useLocalTax(2)) {
{
$locales .= ($locales ? ' & ' : '').$langs->transcountry("LT2", $mysoc->country_code); $locales .= ($locales ? ' & ' : '').$langs->transcountry("LT2", $mysoc->country_code);
$text .= '<tr class="oddeven"><td>'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)).'</td><td>'; $text .= '<tr class="oddeven"><td>'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)).'</td><td>';
@ -252,8 +255,7 @@ if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2))
} }
$title = $langs->trans("PDFRulesForSalesTax"); $title = $langs->trans("PDFRulesForSalesTax");
if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) {
{
$title .= ' - '.$langs->trans("PDFLocaltax", $locales); $title .= ' - '.$langs->trans("PDFLocaltax", $locales);
} }

View File

@ -33,7 +33,9 @@ $langs->loadLangs(array('admin', 'users', 'other'));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$entity = $conf->entity; $entity = $conf->entity;
@ -42,16 +44,14 @@ $entity = $conf->entity;
* Actions * Actions
*/ */
if ($action == 'add') if ($action == 'add') {
{
$sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1"; $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1";
$sql .= " WHERE id = ".GETPOST("pid", 'int'); $sql .= " WHERE id = ".GETPOST("pid", 'int');
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$db->query($sql); $db->query($sql);
} }
if ($action == 'remove') if ($action == 'remove') {
{
$sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0"; $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0";
$sql .= " WHERE id = ".GETPOST('pid', 'int'); $sql .= " WHERE id = ".GETPOST('pid', 'int');
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
@ -76,32 +76,24 @@ $db->begin();
$modules = array(); $modules = array();
$modulesdir = dolGetModulesDirs(); $modulesdir = dolGetModulesDirs();
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir) {
{
$handle = @opendir(dol_osencode($dir)); $handle = @opendir(dol_osencode($dir));
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
{
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
{
$modName = substr($file, 0, dol_strlen($file) - 10); $modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName) if ($modName) {
{
include_once $dir.$file; include_once $dir.$file;
$objMod = new $modName($db); $objMod = new $modName($db);
// Load all lang files of module // Load all lang files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles)) if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
{ foreach ($objMod->langfiles as $domain) {
foreach ($objMod->langfiles as $domain)
{
$langs->load($domain); $langs->load($domain);
} }
} }
// Load all permissions // Load all permissions
if ($objMod->rights_class) if ($objMod->rights_class) {
{
$ret = $objMod->insert_permissions(0, $entity); $ret = $objMod->insert_permissions(0, $entity);
$modules[$objMod->rights_class] = $objMod; $modules[$objMod->rights_class] = $objMod;
//print "modules[".$objMod->rights_class."]=$objMod;"; //print "modules[".$objMod->rights_class."]=$objMod;";
@ -131,7 +123,9 @@ print '<td>'.$langs->trans("Module").'</td>';
print '<td class="center">'.$langs->trans("Default").'</td>'; print '<td class="center">'.$langs->trans("Default").'</td>';
print '<td class="center">&nbsp;</td>'; print '<td class="center">&nbsp;</td>';
print '<td>'.$langs->trans("Permissions").'</td>'; print '<td>'.$langs->trans("Permissions").'</td>';
if ($user->admin) print '<td class="right">'.$langs->trans("ID").'</td>'; if ($user->admin) {
print '<td class="right">'.$langs->trans("ID").'</td>';
}
print '</tr>'."\n"; print '</tr>'."\n";
//print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS; //print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS;
@ -139,32 +133,29 @@ $sql = "SELECT r.id, r.libelle as label, r.module, r.module_position, r.perms, r
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
$sql .= " AND r.entity = ".$entity; $sql .= " AND r.entity = ".$entity;
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
$sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
}
$sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$oldmod = ''; $oldmod = '';
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
if (empty($modules[$obj->module])) if (empty($modules[$obj->module])) {
{
$i++; $i++;
continue; continue;
} }
// Save field module_position in database if value is still zero // Save field module_position in database if value is still zero
if (empty($obj->module_position)) if (empty($obj->module_position)) {
{ if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) {
if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0))
{
// TODO Define familyposition // TODO Define familyposition
$family = (!empty($modules[$obj->module]->family_position) ? $modules[$obj->module]->family_position : ''); $family = (!empty($modules[$obj->module]->family_position) ? $modules[$obj->module]->family_position : '');
$familyposition = 0; $familyposition = 0;
@ -177,23 +168,19 @@ if ($result)
// Check if permission we found is inside a module definition. If not, we discard it. // Check if permission we found is inside a module definition. If not, we discard it.
$found = false; $found = false;
foreach ($modules[$obj->module]->rights as $key => $val) foreach ($modules[$obj->module]->rights as $key => $val) {
{ if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) {
if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms))
{
$found = true; $found = true;
break; break;
} }
} }
if (!$found) if (!$found) {
{
$i++; $i++;
continue; continue;
} }
// Break found, it's a new module to catch // Break found, it's a new module to catch
if (isset($obj->module) && ($oldmod <> $obj->module)) if (isset($obj->module) && ($oldmod <> $obj->module)) {
{
$oldmod = $obj->module; $oldmod = $obj->module;
// Break detected, we get objMod // Break detected, we get objMod
@ -210,7 +197,9 @@ if ($result)
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
// Permission id // Permission id
if ($user->admin) print '<td class="right"></td>'; if ($user->admin) {
print '<td class="right"></td>';
}
print '</tr>'."\n"; print '</tr>'."\n";
} }
@ -223,8 +212,7 @@ if ($result)
print '</td>'; print '</td>';
// Tick // Tick
if ($obj->bydefault == 1) if ($obj->bydefault == 1) {
{
print '<td class="center">'; print '<td class="center">';
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&amp;action=remove">'; print '<a class="reposition" href="perms.php?pid='.$obj->id.'&amp;action=remove">';
//print img_edit_remove(); //print img_edit_remove();
@ -250,13 +238,17 @@ if ($result)
print '<td>'.$perm_libelle.'</td>'; print '<td>'.$perm_libelle.'</td>';
// Permission id // Permission id
if ($user->admin) print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>'; if ($user->admin) {
print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>';
}
print '</tr>'."\n"; print '</tr>'."\n";
$i++; $i++;
} }
} else dol_print_error($db); } else {
dol_print_error($db);
}
print '</table>'; print '</table>';
print '</div>'; print '</div>';

View File

@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->loadLangs(array("admin", "withdrawals")); $langs->loadLangs(array("admin", "withdrawals"));
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$type = 'paymentorder'; $type = 'paymentorder';
@ -46,16 +48,16 @@ $error = 0;
* Actions * Actions
*/ */
if ($action == "set") if ($action == "set") {
{
$db->begin(); $db->begin();
$id = GETPOST('PRELEVEMENT_ID_BANKACCOUNT', 'int'); $id = GETPOST('PRELEVEMENT_ID_BANKACCOUNT', 'int');
$account = new Account($db); $account = new Account($db);
if ($account->fetch($id) > 0) if ($account->fetch($id) > 0) {
{
$res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
/* /*
$res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
@ -72,7 +74,9 @@ if ($action == "set")
$res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
*/ */
} else $error++; } else {
$error++;
}
/* Moved to account /* Moved to account
$res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity);
@ -80,19 +84,27 @@ if ($action == "set")
*/ */
if (GETPOST("PRELEVEMENT_USER") > 0) { if (GETPOST("PRELEVEMENT_USER") > 0) {
$res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END") == "") { if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END") == "") {
$res = dolibarr_set_const($db, "PRELEVEMENT_END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD") == "") { if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD") == "") {
$res = dolibarr_set_const($db, "PRELEVEMENT_USTRD", GETPOST("PRELEVEMENT_USTRD"), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_USTRD", GETPOST("PRELEVEMENT_USTRD"), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
$res = dolibarr_set_const($db, "PRELEVEMENT_ADDDAYS", GETPOST("PRELEVEMENT_ADDDAYS"), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_ADDDAYS", GETPOST("PRELEVEMENT_ADDDAYS"), 'chaine', 0, '', $conf->entity);
if (! ($res > 0)) $error++; if (! ($res > 0)) {
$error++;
}
if (! $error) { if (! $error) {
$db->commit(); $db->commit();
@ -103,8 +115,7 @@ if ($action == "set")
} }
} }
if ($action == "addnotif") if ($action == "addnotif") {
{
$bon = new BonPrelevement($db); $bon = new BonPrelevement($db);
$bon->AddNotification($db, GETPOST('user', 'int'), $action); $bon->AddNotification($db, GETPOST('user', 'int'), $action);
@ -112,8 +123,7 @@ if ($action == "addnotif")
exit; exit;
} }
if ($action == "deletenotif") if ($action == "deletenotif") {
{
$bon = new BonPrelevement($db); $bon = new BonPrelevement($db);
$bon->DeleteNotificationById(GETPOST('notif', 'int')); $bon->DeleteNotificationById(GETPOST('notif', 'int'));
@ -195,7 +205,9 @@ print '</td></tr>';
//ADDDAYS //ADDDAYS
print '<tr class="oddeven"><td>'.$langs->trans("ADDDAYS").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("ADDDAYS").'</td>';
print '<td class="left">'; print '<td class="left">';
if (empty($conf->global->PRELEVEMENT_ADDDAYS)) $conf->global->PRELEVEMENT_ADDDAYS = 0; if (empty($conf->global->PRELEVEMENT_ADDDAYS)) {
$conf->global->PRELEVEMENT_ADDDAYS = 0;
}
print '<input type="text" name="PRELEVEMENT_ADDDAYS" value="'.$conf->global->PRELEVEMENT_ADDDAYS.'" size="5" ></td>'; print '<input type="text" name="PRELEVEMENT_ADDDAYS" value="'.$conf->global->PRELEVEMENT_ADDDAYS.'" size="5" ></td>';
print '</td></tr>'; print '</td></tr>';

View File

@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "errors", "propal")); $langs->loadLangs(array("admin", "other", "errors", "propal"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -55,12 +57,15 @@ $error = 0;
if ($action == 'updateMask') { if ($action == 'updateMask') {
$maskconstpropal = GETPOST('maskconstpropal', 'alpha'); $maskconstpropal = GETPOST('maskconstpropal', 'alpha');
$maskpropal = GETPOST('maskpropal', 'alpha'); $maskpropal = GETPOST('maskpropal', 'alpha');
if ($maskconstpropal) $res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity); if ($maskconstpropal) {
$res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -74,11 +79,9 @@ if ($action == 'updateMask') {
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php");
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
@ -90,8 +93,7 @@ if ($action == 'updateMask') {
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($propal, $langs) > 0) if ($module->write_file($propal, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -109,10 +111,11 @@ if ($action == 'updateMask') {
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -121,10 +124,11 @@ if ($action == 'updateMask') {
$draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha'); $draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha');
$res = dolibarr_set_const($db, "PROPALE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PROPALE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -134,10 +138,11 @@ if ($action == 'updateMask') {
$res = dolibarr_set_const($db, "PROPOSAL_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PROPOSAL_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -145,10 +150,11 @@ if ($action == 'updateMask') {
} elseif ($action == 'setdefaultduration') { } elseif ($action == 'setdefaultduration') {
$res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -156,7 +162,9 @@ if ($action == 'updateMask') {
} elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { } elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -169,7 +177,9 @@ if ($action == 'updateMask') {
} elseif ($action == 'del') { } elseif ($action == 'del') {
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) { if ($ret > 0) {
if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity); if ($conf->global->PROPALE_ADDON_PDF == "$value") {
dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity);
}
} }
} elseif ($action == 'setdoc') { } elseif ($action == 'setdoc') {
if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
@ -224,19 +234,14 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/propale"); $dir = dol_buildpath($reldir."core/modules/propale");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.'/'.$file.'.php'; require_once $dir.'/'.$file.'.php';
@ -244,11 +249,14 @@ foreach ($dirmodels as $reldir)
$module = new $file; $module = new $file;
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -259,13 +267,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->PROPALE_ADDON == "$file") if ($conf->global->PROPALE_ADDON == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -285,8 +295,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -321,12 +332,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -348,31 +357,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/propale".$valdir; $realpath = $reldir."core/modules/propale".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -380,20 +381,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) { if ($modulequalified) {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -407,8 +414,7 @@ foreach ($dirmodels as $reldir)
// Defaut // Defaut
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->PROPALE_ADDON_PDF == "$name") if ($conf->global->PROPALE_ADDON_PDF == "$name") {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -418,8 +424,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = $langs->trans("Name").': '.$module->name; $htmltooltip = $langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -440,8 +445,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -487,26 +491,21 @@ print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>"; print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
print "<td>"; print "<td>";
if (empty($conf->facture->enabled)) if (empty($conf->facture->enabled)) {
{ if (!empty($conf->banque->enabled)) {
if (!empty($conf->banque->enabled))
{
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0"; $sql .= " WHERE clos = 0";
$sql .= " AND courant = 1"; $sql .= " AND courant = 1";
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num > 0) if ($num > 0) {
{
print '<select name="rib" class="flat" id="rib">'; print '<select name="rib" class="flat" id="rib">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
@ -531,8 +530,7 @@ print "</td></tr>";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>"; print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
print "<td>"; print "<td>";
if (empty($conf->facture->enabled)) if (empty($conf->facture->enabled)) {
{
print '<select class="flat" name="chq" id="chq">'; print '<select class="flat" name="chq" id="chq">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>'; print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
@ -544,12 +542,10 @@ if (empty($conf->facture->enabled))
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
@ -612,7 +608,9 @@ print '</form>';
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -621,8 +619,7 @@ print '<input type="hidden" name="action" value="set_PROPOSAL_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'PROPOSAL_FREE_TEXT'; $variablename = 'PROPOSAL_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("other", "users", "admin")); $langs->loadLangs(array("other", "users", "admin"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$upload_dir = $conf->admin->dir_temp; $upload_dir = $conf->admin->dir_temp;
@ -38,21 +40,17 @@ $upload_dir = $conf->admin->dir_temp;
* Actions * Actions
*/ */
if (GETPOST('action', 'aZ09') == 'set_proxy') if (GETPOST('action', 'aZ09') == 'set_proxy') {
{ if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT"))) {
if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT")))
{
setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors'); setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
$error++; $error++;
} }
if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT"))) if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT"))) {
{
setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors'); setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$result = 0; $result = 0;
$result += dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine', 0, '', $conf->entity); $result += dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine', 0, '', $conf->entity);
$result += dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine', 0, '', $conf->entity); $result += dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine', 0, '', $conf->entity);
@ -61,11 +59,12 @@ if (GETPOST('action', 'aZ09') == 'set_proxy')
$result += dolibarr_set_const($db, 'MAIN_PROXY_PORT', GETPOST("MAIN_PROXY_PORT"), 'chaine', 0, '', $conf->entity); $result += dolibarr_set_const($db, 'MAIN_PROXY_PORT', GETPOST("MAIN_PROXY_PORT"), 'chaine', 0, '', $conf->entity);
$result += dolibarr_set_const($db, 'MAIN_PROXY_USER', GETPOST("MAIN_PROXY_USER"), 'chaine', 0, '', $conf->entity); $result += dolibarr_set_const($db, 'MAIN_PROXY_USER', GETPOST("MAIN_PROXY_USER"), 'chaine', 0, '', $conf->entity);
$result += dolibarr_set_const($db, 'MAIN_PROXY_PASS', GETPOST("MAIN_PROXY_PASS"), 'chaine', 0, '', $conf->entity); $result += dolibarr_set_const($db, 'MAIN_PROXY_PASS', GETPOST("MAIN_PROXY_PASS"), 'chaine', 0, '', $conf->entity);
if ($result < 5) dol_print_error($db); if ($result < 5) {
dol_print_error($db);
}
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} }
} }
@ -97,8 +96,7 @@ $head = security_prepare_head();
print dol_get_fiche_head($head, 'proxy', '', -1); print dol_get_fiche_head($head, 'proxy', '', -1);
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () { print 'jQuery(document).ready(function () {
function initfields() function initfields()

View File

@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "receiptprinter")); $langs->loadLangs(array("admin", "receiptprinter"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$mode = GETPOST('mode', 'alpha'); $mode = GETPOST('mode', 'alpha');
@ -49,7 +51,9 @@ $templateid = GETPOST('templateid', 'int');
$printer = new dolReceiptPrinter($db); $printer = new dolReceiptPrinter($db);
if (!$mode) $mode = 'config'; if (!$mode) {
$mode = 'config';
}
// used in library escpos maybe useful if php doesn't support gzdecode // used in library escpos maybe useful if php doesn't support gzdecode
if (!function_exists('gzdecode')) { if (!function_exists('gzdecode')) {
@ -84,10 +88,11 @@ if ($action == 'addprinter' && $user->admin) {
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); $result = $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter);
if ($result > 0) $error++; if ($result > 0) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("PrinterAdded", $printername), null); setEventMessages($langs->trans("PrinterAdded", $printername), null);
} else { } else {
@ -108,10 +113,11 @@ if ($action == 'deleteprinter' && $user->admin) {
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->deletePrinter($printerid); $result = $printer->deletePrinter($printerid);
if ($result > 0) $error++; if ($result > 0) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("PrinterDeleted", $printername), null); setEventMessages($langs->trans("PrinterDeleted", $printername), null);
} else { } else {
@ -132,7 +138,9 @@ if ($action == 'updateprinter' && $user->admin) {
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); $result = $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid);
if ($result > 0) $error++; if ($result > 0) {
$error++;
}
if (!$error) { if (!$error) {
$db->commit(); $db->commit();
@ -198,7 +206,9 @@ if ($action == 'updatetemplate' && $user->admin) {
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->updateTemplate($templatename, $template, $templateid); $result = $printer->updateTemplate($templatename, $template, $templateid);
if ($result > 0) $error++; if ($result > 0) {
$error++;
}
if (!$error) { if (!$error) {
$db->commit(); $db->commit();
@ -221,7 +231,9 @@ if ($action == 'addtemplate' && $user->admin) {
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->addTemplate($templatename, $template); $result = $printer->addTemplate($templatename, $template);
if ($result > 0) $error++; if ($result > 0) {
$error++;
}
if (!$error) { if (!$error) {
$db->commit(); $db->commit();
@ -244,7 +256,9 @@ if ($action == 'deletetemplate' && $user->admin) {
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->deleteTemplate($templateid); $result = $printer->deleteTemplate($templateid);
if ($result > 0) $error++; if ($result > 0) {
$error++;
}
if (!$error) { if (!$error) {
$db->commit(); $db->commit();

View File

@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$langs->load("admin"); $langs->load("admin");
$langs->load("other"); $langs->load("other");
@ -48,13 +49,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->trans($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->trans($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'reception'; //Must be the $table_element of the class that manage extrafield $elementtype = 'reception'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -87,8 +92,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -101,8 +105,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -114,8 +117,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
$langs->loadLangs(array("admin", "receptions", 'other')); $langs->loadLangs(array("admin", "receptions", 'other'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -43,14 +45,12 @@ $type = 'reception';
* Actions * Actions
*/ */
if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) {
{
// This option should always be set to on when module is on. // This option should always be set to on when module is on.
dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity);
} }
if (empty($conf->global->RECEPTION_ADDON_NUMBER)) if (empty($conf->global->RECEPTION_ADDON_NUMBER)) {
{
$conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl'; $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl';
} }
@ -61,43 +61,39 @@ if (empty($conf->global->RECEPTION_ADDON_NUMBER))
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconst = GETPOST('maskconstreception', 'alpha'); $maskconst = GETPOST('maskconstreception', 'alpha');
$maskvalue = GETPOST('maskreception', 'alpha'); $maskvalue = GETPOST('maskreception', 'alpha');
if (!empty($maskconst)) if (!empty($maskconst)) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
if (isset($res))
{
if ($res > 0)
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
else setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_param')
{ if (isset($res)) {
if ($res > 0) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
} elseif ($action == 'set_param') {
$freetext = GETPOST('RECEPTION_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('RECEPTION_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "RECEPTION_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "RECEPTION_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if ($res <= 0) if ($res <= 0) {
{
$error++; $error++;
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
$draft = GETPOST('RECEPTION_DRAFT_WATERMARK', 'alpha'); $draft = GETPOST('RECEPTION_DRAFT_WATERMARK', 'alpha');
$res = dolibarr_set_const($db, "RECEPTION_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "RECEPTION_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if ($res <= 0) if ($res <= 0) {
{
$error++; $error++;
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$exp = new Reception($db); $exp = new Reception($db);
@ -106,25 +102,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($exp, $langs) > 0) if ($module->write_file($exp, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=reception&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=reception&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -135,26 +127,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->RECEPTION_ADDON_PDF == "$value") {
if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity);
} }
} }
} elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') if (dolibarr_set_const($db, "RECEPTION_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "RECEPTION_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->RECEPTION_ADDON_PDF = $value; $conf->global->RECEPTION_ADDON_PDF = $value;
@ -162,12 +147,10 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmodel') } elseif ($action == 'setmodel') {
{
dolibarr_set_const($db, "RECEPTION_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "RECEPTION_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity);
} }
@ -206,30 +189,28 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/reception"); $dir = dol_buildpath($reldir."core/modules/reception");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 14) == 'mod_reception_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 14) == 'mod_reception_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.'/'.$file.'.php'; require_once $dir.'/'.$file.'.php';
$module = new $file; $module = new $file;
if ($module->isEnabled()) if ($module->isEnabled()) {
{
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
print '<tr><td>'.$module->nom."</td>\n"; print '<tr><td>'.$module->nom."</td>\n";
print '<td>'; print '<td>';
@ -242,13 +223,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->RECEPTION_ADDON_NUMBER == "$file") if ($conf->global->RECEPTION_ADDON_NUMBER == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;token='.newToken().'&amp;value='.urlencode($file).'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;token='.newToken().'&amp;value='.urlencode($file).'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
@ -267,8 +250,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -306,12 +290,10 @@ $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -332,31 +314,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/reception".$valdir; $realpath = $reldir."core/modules/reception".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -364,21 +338,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr><td width="100">'; print '<tr><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -392,8 +371,7 @@ foreach ($dirmodels as $reldir)
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->RECEPTION_ADDON_PDF == $name) if ($conf->global->RECEPTION_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -403,8 +381,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -422,8 +399,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');

View File

@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
$langs->loadLangs(array("admin", "resource")); $langs->loadLangs(array("admin", "resource"));
// Security check // Security check
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -44,12 +45,9 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'updateoptions') if ($action == 'updateoptions') {
{ if (GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT') != '') {
if (GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT') != '') if (dolibarr_set_const($db, "RESOURCE_USE_SEARCH_TO_SELECT", GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'), 'chaine', 0, '', $conf->entity)) {
{
if (dolibarr_set_const($db, "RESOURCE_USE_SEARCH_TO_SELECT", GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'), 'chaine', 0, '', $conf->entity))
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -86,8 +84,7 @@ print '<td></td>';
// Utilisation formulaire Ajax sur choix produit // Utilisation formulaire Ajax sur choix produit
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="80%">'.$langs->trans("UseSearchToSelectResource").'</td>'; print '<td width="80%">'.$langs->trans("UseSearchToSelectResource").'</td>';
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax)) {
{
print '<td class="nowrap right" colspan="2">'; print '<td class="nowrap right" colspan="2">';
print $langs->trans("NotAvailableWhenAjaxDisabled"); print $langs->trans("NotAvailableWhenAjaxDisabled");
print '</td>'; print '</td>';

View File

@ -30,8 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'resource')); $langs->loadLangs(array('admin', 'other', 'resource'));
@ -42,13 +43,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'resource'; //Must be the $table_element of the class that manage extrafield $elementtype = 'resource'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -81,8 +86,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -95,8 +99,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -108,8 +111,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -32,7 +32,9 @@ $action = GETPOST('action', 'aZ09');
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("users", "admin", "other")); $langs->loadLangs(array("users", "admin", "other"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
// Allow/Disallow change to clear passwords once passwords are crypted // Allow/Disallow change to clear passwords once passwords are crypted
$allow_disable_encryption = true; $allow_disable_encryption = true;
@ -40,10 +42,8 @@ $allow_disable_encryption = true;
/* /*
* Actions * Actions
*/ */
if ($action == 'setgeneraterule') if ($action == 'setgeneraterule') {
{ if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity))
{
dol_print_error($db); dol_print_error($db);
} else { } else {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
@ -51,8 +51,7 @@ if ($action == 'setgeneraterule')
} }
} }
if ($action == 'activate_encrypt') if ($action == 'activate_encrypt') {
{
$error = 0; $error = 0;
$db->begin(); $db->begin();
@ -64,23 +63,19 @@ if ($action == 'activate_encrypt')
$sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value $sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$numrows = $db->num_rows($resql); $numrows = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $numrows) while ($i < $numrows) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (dol_hash($obj->pass)) if (dol_hash($obj->pass)) {
{
$sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL";
$sql .= " WHERE rowid=".$obj->rowid; $sql .= " WHERE rowid=".$obj->rowid;
//print $sql; //print $sql;
$resql2 = $db->query($sql); $resql2 = $db->query($sql);
if (!$resql2) if (!$resql2) {
{
dol_print_error($db); dol_print_error($db);
$error++; $error++;
break; break;
@ -89,12 +84,13 @@ if ($action == 'activate_encrypt')
$i++; $i++;
} }
} }
} else dol_print_error($db); } else {
dol_print_error($db);
}
//print $error." ".$sql; //print $error." ".$sql;
//exit; //exit;
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
header("Location: security.php"); header("Location: security.php");
exit; exit;
@ -102,23 +98,19 @@ if ($action == 'activate_encrypt')
$db->rollback(); $db->rollback();
dol_print_error($db, ''); dol_print_error($db, '');
} }
} elseif ($action == 'disable_encrypt') } elseif ($action == 'disable_encrypt') {
{
//On n'autorise pas l'annulation de l'encryption car les mots de passe ne peuvent pas etre decodes //On n'autorise pas l'annulation de l'encryption car les mots de passe ne peuvent pas etre decodes
//Do not allow "disable encryption" as passwords cannot be decrypted //Do not allow "disable encryption" as passwords cannot be decrypted
if ($allow_disable_encryption) if ($allow_disable_encryption) {
{
dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity); dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity);
} }
header("Location: security.php"); header("Location: security.php");
exit; exit;
} }
if ($action == 'activate_encryptdbpassconf') if ($action == 'activate_encryptdbpassconf') {
{
$result = encodedecode_dbpassconf(1); $result = encodedecode_dbpassconf(1);
if ($result > 0) if ($result > 0) {
{
sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait.
// database value not required // database value not required
@ -128,11 +120,9 @@ if ($action == 'activate_encryptdbpassconf')
} else { } else {
setEventMessages($langs->trans('InstrucToEncodePass', dol_encode($dolibarr_main_db_pass)), null, 'warnings'); setEventMessages($langs->trans('InstrucToEncodePass', dol_encode($dolibarr_main_db_pass)), null, 'warnings');
} }
} elseif ($action == 'disable_encryptdbpassconf') } elseif ($action == 'disable_encryptdbpassconf') {
{
$result = encodedecode_dbpassconf(0); $result = encodedecode_dbpassconf(0);
if ($result > 0) if ($result > 0) {
{
sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait.
// database value not required // database value not required
@ -144,20 +134,17 @@ if ($action == 'activate_encryptdbpassconf')
} }
} }
if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') {
{
dolibarr_set_const($db, "MAIN_SECURITY_DISABLEFORGETPASSLINK", '1', 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SECURITY_DISABLEFORGETPASSLINK", '1', 'chaine', 0, '', $conf->entity);
header("Location: security.php"); header("Location: security.php");
exit; exit;
} elseif ($action == 'disable_MAIN_SECURITY_DISABLEFORGETPASSLINK') } elseif ($action == 'disable_MAIN_SECURITY_DISABLEFORGETPASSLINK') {
{
dolibarr_del_const($db, "MAIN_SECURITY_DISABLEFORGETPASSLINK", $conf->entity); dolibarr_del_const($db, "MAIN_SECURITY_DISABLEFORGETPASSLINK", $conf->entity);
header("Location: security.php"); header("Location: security.php");
exit; exit;
} }
if ($action == 'updatepattern') if ($action == 'updatepattern') {
{
$pattern = GETPOST("pattern", "alpha"); $pattern = GETPOST("pattern", "alpha");
$explodePattern = explode(';', $pattern); $explodePattern = explode(';', $pattern);
@ -212,12 +199,9 @@ $dir = "../core/modules/security/generate";
clearstatcache(); clearstatcache();
$handle = opendir($dir); $handle = opendir($dir);
$i = 1; $i = 1;
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) {
{
if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg))
{
// Charging the numbering class // Charging the numbering class
$classname = $reg[1]; $classname = $reg[1];
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
@ -238,14 +222,16 @@ print '<td>'.$langs->trans("Example").'</td>';
print '<td class="center">'.$langs->trans("Activated").'</td>'; print '<td class="center">'.$langs->trans("Activated").'</td>';
print '</tr>'; print '</tr>';
foreach ($arrayhandler as $key => $module) foreach ($arrayhandler as $key => $module) {
{
// Show modules according to features level // Show modules according to features level
if (!empty($module->version) && $module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if (!empty($module->version) && $module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if (!empty($module->version) && $module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if (!empty($module->version) && $module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print ucfirst($key); print ucfirst($key);
print "</td><td>\n"; print "</td><td>\n";
@ -259,13 +245,15 @@ foreach ($arrayhandler as $key => $module)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td width="100" align="center">'; print '<td width="100" align="center">';
if ($conf->global->USER_PASSWORD_GENERATED == $key) if ($conf->global->USER_PASSWORD_GENERATED == $key) {
{
print img_picto('', 'tick'); print img_picto('', 'tick');
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setgeneraterule&amp;token='.newToken().'&amp;value='.$key.'">'.$langs->trans("Activate").'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=setgeneraterule&amp;token='.newToken().'&amp;value='.$key.'">'.$langs->trans("Activate").'</a>';
@ -402,24 +390,20 @@ print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td colspan="3">'.$langs->trans("DoNotStoreClearPassword").'</td>'; print '<td colspan="3">'.$langs->trans("DoNotStoreClearPassword").'</td>';
print '<td align="center" width="60">'; print '<td align="center" width="60">';
if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
{
print img_picto($langs->trans("Active"), 'tick'); print img_picto($langs->trans("Active"), 'tick');
} }
print '</td>'; print '</td>';
if (!$conf->global->DATABASE_PWD_ENCRYPTED) if (!$conf->global->DATABASE_PWD_ENCRYPTED) {
{
print '<td align="center" width="100">'; print '<td align="center" width="100">';
print '<a href="security.php?action=activate_encrypt">'.$langs->trans("Activate").'</a>'; print '<a href="security.php?action=activate_encrypt">'.$langs->trans("Activate").'</a>';
print "</td>"; print "</td>";
} }
// Database conf file encryption // Database conf file encryption
if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
{
print '<td align="center" width="100">'; print '<td align="center" width="100">';
if ($allow_disable_encryption) if ($allow_disable_encryption) {
{
//On n'autorise pas l'annulation de l'encryption car les mots de passe ne peuvent pas etre decodes //On n'autorise pas l'annulation de l'encryption car les mots de passe ne peuvent pas etre decodes
//Do not allow "disable encryption" as passwords cannot be decrypted //Do not allow "disable encryption" as passwords cannot be decrypted
print '<a href="security.php?action=disable_encrypt">'.$langs->trans("Disable").'</a>'; print '<a href="security.php?action=disable_encrypt">'.$langs->trans("Disable").'</a>';
@ -436,25 +420,21 @@ print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td colspan="3">'.$langs->trans("MainDbPasswordFileConfEncrypted").'</td>'; print '<td colspan="3">'.$langs->trans("MainDbPasswordFileConfEncrypted").'</td>';
print '<td align="center" width="60">'; print '<td align="center" width="60">';
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
{
print img_picto($langs->trans("Active"), 'tick'); print img_picto($langs->trans("Active"), 'tick');
} }
print '</td>'; print '</td>';
print '<td align="center" width="100">'; print '<td align="center" width="100">';
if (empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) if (empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) {
{
$langs->load("errors"); $langs->load("errors");
print img_warning($langs->trans("WarningPassIsEmpty")); print img_warning($langs->trans("WarningPassIsEmpty"));
} else { } else {
if (empty($dolibarr_main_db_encrypted_pass)) if (empty($dolibarr_main_db_encrypted_pass)) {
{
print '<a href="security.php?action=activate_encryptdbpassconf">'.$langs->trans("Activate").'</a>'; print '<a href="security.php?action=activate_encryptdbpassconf">'.$langs->trans("Activate").'</a>';
} }
if (!empty($dolibarr_main_db_encrypted_pass)) if (!empty($dolibarr_main_db_encrypted_pass)) {
{
print '<a href="security.php?action=disable_encryptdbpassconf">'.$langs->trans("Disable").'</a>'; print '<a href="security.php?action=disable_encryptdbpassconf">'.$langs->trans("Disable").'</a>';
} }
} }
@ -469,19 +449,16 @@ print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td colspan="3">'.$langs->trans("DisableForgetPasswordLinkOnLogonPage").'</td>'; print '<td colspan="3">'.$langs->trans("DisableForgetPasswordLinkOnLogonPage").'</td>';
print '<td align="center" width="60">'; print '<td align="center" width="60">';
if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) {
{
print img_picto($langs->trans("Active"), 'tick'); print img_picto($langs->trans("Active"), 'tick');
} }
print '</td>'; print '</td>';
if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) {
{
print '<td align="center" width="100">'; print '<td align="center" width="100">';
print '<a href="security.php?action=activate_MAIN_SECURITY_DISABLEFORGETPASSLINK">'.$langs->trans("Activate").'</a>'; print '<a href="security.php?action=activate_MAIN_SECURITY_DISABLEFORGETPASSLINK">'.$langs->trans("Activate").'</a>';
print "</td>"; print "</td>";
} }
if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) {
{
print '<td align="center" width="100">'; print '<td align="center" width="100">';
print '<a href="security.php?action=disable_MAIN_SECURITY_DISABLEFORGETPASSLINK">'.$langs->trans("Disable").'</a>'; print '<a href="security.php?action=disable_MAIN_SECURITY_DISABLEFORGETPASSLINK">'.$langs->trans("Disable").'</a>';
print "</td>"; print "</td>";
@ -494,10 +471,8 @@ print '</table>';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
if (GETPOST('info', 'int') > 0) if (GETPOST('info', 'int') > 0) {
{ if (function_exists('password_hash')) {
if (function_exists('password_hash'))
{
print $langs->trans("Note: The function password_hash exists on your PHP")."<br>\n"; print $langs->trans("Note: The function password_hash exists on your PHP")."<br>\n";
} else { } else {
print $langs->trans("Note: The function password_hash does not exists on your PHP")."<br>\n"; print $langs->trans("Note: The function password_hash does not exists on your PHP")."<br>\n";

View File

@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('users', 'admin', 'other')); $langs->loadLangs(array('users', 'admin', 'other'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -43,15 +44,13 @@ $upload_dir = $conf->admin->dir_temp;
* Actions * Actions
*/ */
if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_add_file_process($upload_dir, 1, 0, 'userfile'); dol_add_file_process($upload_dir, 1, 0, 'userfile');
} }
if ($action == 'updateform') if ($action == 'updateform') {
{
$antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'restricthtml'); // Use GETPOST restricthtml because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe $antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'restricthtml'); // Use GETPOST restricthtml because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe
$antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'restricthtml'); // Use GETPOST restricthtml because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib" $antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'restricthtml'); // Use GETPOST restricthtml because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib"
$antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command $antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command
@ -61,19 +60,19 @@ if ($action == 'updateform')
$res4 = dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity);
$res5 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity); $res5 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity);
$res6 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity); $res6 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity);
if ($res3 && $res4 && $res5 && $res6) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); if ($res3 && $res4 && $res5 && $res6) {
} setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
} elseif ($action == 'delete') {
// Delete file
// Delete file
elseif ($action == 'delete')
{
$langs->load("other"); $langs->load("other");
$file = $conf->admin->dir_temp.'/'.GETPOST('urlfile', 'alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $conf->admin->dir_temp.'/'.GETPOST('urlfile', 'alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret = dol_delete_file($file); $ret = dol_delete_file($file);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile', 'alpha')), null, 'mesgs'); if ($ret) {
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors'); setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile', 'alpha')), null, 'mesgs');
} else {
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors');
}
Header('Location: '.$_SERVER["PHP_SELF"]); Header('Location: '.$_SERVER["PHP_SELF"]);
exit; exit;
} }
@ -116,8 +115,11 @@ print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td colspan="2">'.$langs->trans("MaxSizeForUploadedFiles").'.'; print '<td colspan="2">'.$langs->trans("MaxSizeForUploadedFiles").'.';
$max = @ini_get('upload_max_filesize'); $max = @ini_get('upload_max_filesize');
if (isset($max)) print ' '.$langs->trans("MustBeLowerThanPHPLimit", ((int) $max) * 1024, $langs->trans("Kb")).'.'; if (isset($max)) {
else print ' '.$langs->trans("NoMaxSizeByPHPLimit").'.'; print ' '.$langs->trans("MustBeLowerThanPHPLimit", ((int) $max) * 1024, $langs->trans("Kb")).'.';
} else {
print ' '.$langs->trans("NoMaxSizeByPHPLimit").'.';
}
print '</td>'; print '</td>';
print '<td class="nowrap">'; print '<td class="nowrap">';
print '<input class="flat" name="MAIN_UPLOAD_DOC" type="text" size="6" value="'.htmlentities($conf->global->MAIN_UPLOAD_DOC).'"> '.$langs->trans("Kb"); print '<input class="flat" name="MAIN_UPLOAD_DOC" type="text" size="6" value="'.htmlentities($conf->global->MAIN_UPLOAD_DOC).'"> '.$langs->trans("Kb");
@ -142,13 +144,11 @@ print '<span class="opacitymedium">'.$langs->trans("AntiVirusCommandExample").'<
// Check command in inside safe_mode // Check command in inside safe_mode
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) {
{
$langs->load("errors"); $langs->load("errors");
$basedir = preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND)); $basedir = preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND));
$listdir = explode(';', ini_get('safe_mode_exec_dir')); $listdir = explode(';', ini_get('safe_mode_exec_dir'));
if (!in_array($basedir, $listdir)) if (!in_array($basedir, $listdir)) {
{
print img_warning($langs->trans('WarningSafeModeOnCheckExecDir')); print img_warning($langs->trans('WarningSafeModeOnCheckExecDir'));
dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING);
} }

View File

@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("users", "admin", "other")); $langs->loadLangs(array("users", "admin", "other"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -42,12 +43,10 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -55,18 +54,18 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
} }
} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1]; $code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'updateform') } elseif ($action == 'updateform') {
{
$res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
$res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
if ($res1 && $res2) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); if ($res1 && $res2) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
} }
@ -107,14 +106,11 @@ print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>'; print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
print '<td class="right">'; print '<td class="right">';
if (function_exists("imagecreatefrompng")) if (function_exists("imagecreatefrompng")) {
{ if (!empty($conf->use_javascript_ajax)) {
if (!empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA'); print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
} else { } else {
if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
@ -130,12 +126,10 @@ print '</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>'; print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
print '<td class="right">'; print '<td class="right">';
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS'); print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
} else { } else {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
@ -158,7 +152,9 @@ print "</tr>\n";
$sessiontimeout = ini_get("session.gc_maxlifetime"); $sessiontimeout = ini_get("session.gc_maxlifetime");
if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout; if (empty($conf->global->MAIN_SESSION_TIMEOUT)) {
$conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">'; print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
if (ini_get("session.gc_probability") == 0) { if (ini_get("session.gc_probability") == 0) {
@ -173,7 +169,9 @@ print '</td>';
print '</tr>'; print '</tr>';
if (empty($conf->global->MAIN_APPLICATION_TITLE)) $conf->global->MAIN_APPLICATION_TITLE = ""; if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
$conf->global->MAIN_APPLICATION_TITLE = "";
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">'; print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">';
print '</td>'; print '</td>';

View File

@ -35,7 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "members", "mailmanspip")); $langs->loadLangs(array("admin", "members", "mailmanspip"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$type = array('yesno', 'texte', 'chaine'); $type = array('yesno', 'texte', 'chaine');
@ -48,18 +50,15 @@ $action = GETPOST('action', 'aZ09');
*/ */
// Action mise a jour ou ajout d'une constante // Action mise a jour ou ajout d'une constante
if ($action == 'update' || $action == 'add') if ($action == 'update' || $action == 'add') {
{
$constnamearray = GETPOST("constname", 'array'); $constnamearray = GETPOST("constname", 'array');
$constvaluearray = GETPOST("constvalue", 'array'); $constvaluearray = GETPOST("constvalue", 'array');
$consttypearray = GETPOST("consttype", 'array'); $consttypearray = GETPOST("consttype", 'array');
$constnotearray = GETPOST("constnote", 'array'); $constnotearray = GETPOST("constnote", 'array');
// Action mise a jour ou ajout d'une constante // Action mise a jour ou ajout d'une constante
if ($action == 'update' || $action == 'add') if ($action == 'update' || $action == 'add') {
{ foreach ($constnamearray as $key => $val) {
foreach ($constnamearray as $key => $val)
{
$constname = dol_escape_htmltag($constnamearray[$key]); $constname = dol_escape_htmltag($constnamearray[$key]);
$constvalue = dol_escape_htmltag($constvaluearray[$key]); $constvalue = dol_escape_htmltag($constvaluearray[$key]);
$consttype = dol_escape_htmltag($consttypearray[$key]); $consttype = dol_escape_htmltag($consttypearray[$key]);
@ -67,11 +66,12 @@ if ($action == 'update' || $action == 'add')
$res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -80,21 +80,17 @@ if ($action == 'update' || $action == 'add')
} }
// Action activation d'un sous module du module adherent // Action activation d'un sous module du module adherent
if ($action == 'set') if ($action == 'set') {
{
$result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
if ($result < 0) if ($result < 0) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// Action desactivation d'un sous module du module adherent // Action desactivation d'un sous module du module adherent
if ($action == 'unset') if ($action == 'unset') {
{
$result = dolibarr_del_const($db, $_GET["name"], $conf->entity); $result = dolibarr_del_const($db, $_GET["name"], $conf->entity);
if ($result < 0) if ($result < 0) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -120,8 +116,7 @@ $head = mailmanspip_admin_prepare_head();
/* /*
* Spip * Spip
*/ */
if (!empty($conf->global->ADHERENT_USE_SPIP)) if (!empty($conf->global->ADHERENT_USE_SPIP)) {
{
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';

Some files were not shown because too many files have changed in this diff Show More