Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer
2020-02-18 22:47:25 +00:00
parent dacf896f80
commit fd48877dc6
27 changed files with 723 additions and 723 deletions

View File

@@ -39,31 +39,31 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.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("errors","admin","companies","resource","holiday","compta","accountancy","hrm")); $langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "compta", "accountancy", "hrm"));
$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
$confirm=GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$id=31; $id = 31;
$rowid=GETPOST('rowid', 'alpha'); $rowid = GETPOST('rowid', 'alpha');
$code=GETPOST('code', 'alpha'); $code = GETPOST('code', 'alpha');
$acts[0] = "activate"; $acts[0] = "activate";
$acts[1] = "disable"; $acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on'); $actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
$listoffset=GETPOST('listoffset', 'alpha'); $listoffset = GETPOST('listoffset', 'alpha');
$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000; $listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
$active = 1; $active = 1;
$sortfield = GETPOST("sortfield", 'aZ09comma'); $sortfield = GETPOST("sortfield", 'aZ09comma');
$sortorder = GETPOST("sortorder", 'aZ09comma'); $sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOST("page", 'int'); $page = 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 = $listlimit * $page ; $offset = $listlimit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@@ -72,7 +72,7 @@ $search_country_id = GETPOST('search_country_id', 'int');
// Security check // Security check
if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) accessforbidden();
if (! $user->rights->accounting->chartofaccount) accessforbidden(); if (!$user->rights->accounting->chartofaccount) 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
@@ -82,56 +82,56 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties // Put here declaration of dictionaries properties
// Name of SQL tables of dictionaries // Name of SQL tables of dictionaries
$tabname=array(); $tabname = array();
$tabname[31]= MAIN_DB_PREFIX."accounting_system"; $tabname[31] = MAIN_DB_PREFIX."accounting_system";
// Dictionary labels // Dictionary labels
$tablib=array(); $tablib = array();
$tablib[31]= "Pcg_version"; $tablib[31] = "Pcg_version";
// Requests to extract data // Requests to extract data
$tabsql=array(); $tabsql = array();
$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_country=c.rowid and c.active=1"; $tabsql[31] = "SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_country=c.rowid and c.active=1";
// Criteria to sort dictionaries // Criteria to sort dictionaries
$tabsqlsort=array(); $tabsqlsort = array();
$tabsqlsort[31]="pcg_version ASC"; $tabsqlsort[31] = "pcg_version ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire // Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array(); $tabfield = array();
$tabfield[31]= "pcg_version,label,country_id,country"; $tabfield[31] = "pcg_version,label,country_id,country";
// Nom des champs d'edition pour modification d'un enregistrement // Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array(); $tabfieldvalue = array();
$tabfieldvalue[31]= "pcg_version,label,country"; $tabfieldvalue[31] = "pcg_version,label,country";
// Nom des champs dans la table pour insertion d'un enregistrement // Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array(); $tabfieldinsert = array();
$tabfieldinsert[31]= "pcg_version,label,fk_country"; $tabfieldinsert[31] = "pcg_version,label,fk_country";
// Nom du rowid si le champ n'est pas de type autoincrement // Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on // Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on // "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array(); $tabrowid = array();
$tabrowid[31]= ""; $tabrowid[31] = "";
// Condition to show dictionary in setup page // Condition to show dictionary in setup page
$tabcond=array(); $tabcond = array();
$tabcond[31]= ! empty($conf->accounting->enabled); $tabcond[31] = !empty($conf->accounting->enabled);
// List of help for fields // List of help for fields
$tabhelp=array(); $tabhelp = array();
$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); $tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET) // List of check for fields (NOT USED YET)
$tabfieldcheck=array(); $tabfieldcheck = array();
$tabfieldcheck[31] = array(); $tabfieldcheck[31] = array();
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array(); $elementList = array();
$sourceList=array(); $sourceList = array();
@@ -147,38 +147,38 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x',
// Actions add or modify an entry into a dictionary // Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
$listfield=explode(',', str_replace(' ', '', $tabfield[$id])); $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert=explode(',', $tabfieldinsert[$id]); $listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify=explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue=explode(',', $tabfieldvalue[$id]); $listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled // Check that all fields are filled
$ok=1; $ok = 1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value)
{ {
if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory
if ((! GETPOSTISSET($value)) || GETPOST($value) == '') if ((!GETPOSTISSET($value)) || GETPOST($value) == '')
{ {
$ok=0; $ok = 0;
$fieldnamekey=$listfield[$f]; $fieldnamekey = $listfield[$f];
// We take translate key of field // We take translate key of field
if ($fieldnamekey == 'pcg_version') $fieldnamekey='Pcg_version'; if ($fieldnamekey == 'pcg_version') $fieldnamekey = 'Pcg_version';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
} }
} }
// Other checks // Other checks
if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array($_POST["type"], array('system','systemauto'))) { if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array($_POST["type"], array('system', 'systemauto'))) {
$ok=0; $ok = 0;
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
} }
if (GETPOSTISSET("pcg_version")) if (GETPOSTISSET("pcg_version"))
{ {
if (GETPOST("pcg_version") == '0') if (GETPOST("pcg_version") == '0')
{ {
$ok=0; $ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
} }
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
@@ -187,9 +187,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>'; $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/ }*/
} }
if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) if (isset($_POST["country"]) && ($_POST["country"] == '0') && ($id != 2))
{ {
$ok=0; $ok = 0;
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
} }
@@ -199,13 +199,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id]) if ($tabrowid[$id])
{ {
// Recupere id libre pour insertion // Recupere id libre pour insertion
$newid=0; $newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$newid=($obj->newid + 1); $newid = ($obj->newid + 1);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
@@ -214,16 +214,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry // Add new entry
$sql = "INSERT INTO ".$tabname[$id]." ("; $sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields // List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql.= $tabrowid[$id].","; $sql .= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id]; $sql .= $tabfieldinsert[$id];
$sql.=",active)"; $sql .= ",active)";
$sql.= " VALUES("; $sql .= " VALUES(";
// List of values // List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql.= $newid.","; $sql .= $newid.",";
$i=0; $i = 0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value)
{ {
if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') { if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') {
@@ -232,19 +232,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($value == 'entity') { elseif ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql.=","; if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql.=",1)"; $sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG); dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) // Add is ok if ($result) // Add is ok
{ {
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST=array('id'=>$id); // Clean $_POST array, we keep only $_POST = array('id'=>$id); // Clean $_POST array, we keep only
} }
else else
{ {
@@ -260,16 +260,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha'))
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs // Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{ {
$sql.= $tabrowid[$id]."="; $sql .= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', "; $sql .= "'".$db->escape($rowid)."', ";
} }
$i = 0; $i = 0;
foreach ($listfieldmodify as $field) foreach ($listfieldmodify as $field)
@@ -280,18 +280,18 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($field == 'entity') { elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql.=","; if ($i) $sql .= ",";
$sql.= $field."="; $sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql.= " WHERE ".$rowidcol." = '".$rowid."'"; $sql .= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if (! $resql) if (!$resql)
{ {
setEventMessages($db->error(), null, 'errors'); setEventMessages($db->error(), null, 'errors');
} }
@@ -306,14 +306,14 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) if (!$result)
{ {
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{ {
@@ -329,8 +329,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0])
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
@@ -349,8 +349,8 @@ if ($action == $acts[0])
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1])
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
@@ -369,8 +369,8 @@ if ($action == $acts[1])
// favorite // favorite
if ($action == 'activate_favorite') if ($action == 'activate_favorite')
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
@@ -389,8 +389,8 @@ if ($action == 'activate_favorite')
// disable favorite // disable favorite
if ($action == 'disable_favorite') if ($action == 'disable_favorite')
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
@@ -412,12 +412,12 @@ if ($action == 'disable_favorite')
*/ */
$form = new Form($db); $form = new Form($db);
$formadmin=new FormAdmin($db); $formadmin = new FormAdmin($db);
llxHeader(); llxHeader();
$titre=$langs->trans($tablib[$id]); $titre = $langs->trans($tablib[$id]);
$linkback=''; $linkback = '';
print load_fiche_titre($titre, $linkback, 'title_accountancy'); print load_fiche_titre($titre, $linkback, 'title_accountancy');
@@ -425,7 +425,7 @@ print load_fiche_titre($titre, $linkback, 'title_accountancy');
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.urlencode($page).'&':'').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.urlencode($page).'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
} }
//var_dump($elementList); //var_dump($elementList);
@@ -435,22 +435,22 @@ if ($action == 'delete')
if ($id) if ($id)
{ {
// Complete requete recherche valeurs avec critere de tri // Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id]; $sql = $tabsql[$id];
if ($search_country_id > 0) if ($search_country_id > 0)
{ {
if (preg_match('/ WHERE /', $sql)) $sql.= " AND "; if (preg_match('/ WHERE /', $sql)) $sql .= " AND ";
else $sql.=" WHERE "; else $sql .= " WHERE ";
$sql.= " c.rowid = ".$search_country_id; $sql .= " c.rowid = ".$search_country_id;
} }
// If sort order is "country", we use country_code instead // If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code'; if ($sortfield == 'country') $sortfield = 'country_code';
$sql.=$db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$sql.=$db->plimit($listlimit+1, $offset); $sql .= $db->plimit($listlimit + 1, $offset);
//print $sql; //print $sql;
$fieldlist=explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
@@ -461,10 +461,10 @@ if ($id)
// Form to add a new line // Form to add a new line
if ($tabname[$id]) if ($tabname[$id])
{ {
$alabelisused=0; $alabelisused = 0;
$var=false; $var = false;
$fieldlist=explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
// Line for title // Line for title
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@@ -472,33 +472,33 @@ if ($id)
{ {
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow = $langs->trans($valuetoshow); // try to translate
$class="left"; $class = "left";
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label')
{ {
$valuetoshow=$langs->trans("Label"); $valuetoshow = $langs->trans("Label");
} }
if ($fieldlist[$field]=='country') { if ($fieldlist[$field] == 'country') {
if (in_array('region_id', $fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input if (in_array('region_id', $fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input
$valuetoshow=$langs->trans("Country"); $valuetoshow = $langs->trans("Country");
} }
if ($fieldlist[$field]=='country_id') { $valuetoshow=''; } if ($fieldlist[$field] == 'country_id') { $valuetoshow = ''; }
if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); }
if ($valuetoshow != '') { if ($valuetoshow != '') {
print '<td class="'.$class.'">'; print '<td class="'.$class.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>'; print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
} elseif (! empty($tabhelp[$id][$value])) { } elseif (!empty($tabhelp[$id][$value])) {
print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
} else { } else {
print $valuetoshow; print $valuetoshow;
} }
print '</td>'; print '</td>';
} }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
} }
print '<td>'; print '<td>';
@@ -518,14 +518,14 @@ if ($id)
foreach ($fieldlist as $key=>$val) foreach ($fieldlist as $key=>$val)
{ {
if (GETPOST($val)) if (GETPOST($val))
$obj->$val=GETPOST($val); $obj->$val = GETPOST($val);
} }
} }
$tmpaction = 'create'; $tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook))
{ {
@@ -537,32 +537,32 @@ if ($id)
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
$colspan=count($fieldlist)+3; $colspan = count($fieldlist) + 3;
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
} }
// List of available values in database // List of available values in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG); dol_syslog("htdocs/admin/dict", 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;
$param = '&id='.$id; $param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id;
$paramwithsearch = $param; $paramwithsearch = $param;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
// There is several pages // There is several pages
if ($num > $listlimit) if ($num > $listlimit)
{ {
print '<tr class="none"><td class="right" colspan="'.(3+count($fieldlist)).'">'; print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>'); print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>'; print '</td></tr>';
} }
@@ -570,9 +570,9 @@ if ($id)
print '<tr class="liste_titre liste_titre_add">'; print '<tr class="liste_titre liste_titre_add">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$showfield=1; // By defaut $showfield = 1; // By defaut
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; }
if ($showfield) if ($showfield)
{ {
@@ -590,17 +590,17 @@ if ($id)
} }
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre right" colspan="2">'; print '<td class="liste_titre right" colspan="2">';
$searchpicto=$form->showFilterAndCheckAddButtons(0); $searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Title of lines // Title of lines
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print getTitleFieldOfList($langs->trans("Pcg_version"), 0, $_SERVER["PHP_SELF"], "pcg_version", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, ''); print getTitleFieldOfList($langs->trans("Pcg_version"), 0, $_SERVER["PHP_SELF"], "pcg_version", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], "label", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, ''); print getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], "label", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Country"), 0, $_SERVER["PHP_SELF"], "country_code", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, ''); print getTitleFieldOfList($langs->trans("Country"), 0, $_SERVER["PHP_SELF"], "country_code", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
@@ -613,81 +613,81 @@ if ($id)
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
//print_r($obj); //print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
{ {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">'; print '<input type="hidden" name="rowid" value="'.$rowid.'">';
$tmpaction='edit'; $tmpaction = 'edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit'); if (empty($reshook)) fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit');
print '<td colspan="3" class="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>'; print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
} }
else else
{ {
$tmpaction = 'view'; $tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook))
{ {
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$showfield=1; $showfield = 1;
$class="left"; $class = "left";
$valuetoshow=$obj->{$fieldlist[$field]}; $valuetoshow = $obj->{$fieldlist[$field]};
if ($value == 'type_template') if ($value == 'type_template')
{ {
$valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
} }
if ($value == 'element') if ($value == 'element')
{ {
$valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
} }
elseif ($value == 'source') elseif ($value == 'source')
{ {
$valuetoshow = isset($sourceList[$valuetoshow])?$sourceList[$valuetoshow]:$valuetoshow; $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
} }
elseif ($valuetoshow=='all') { elseif ($valuetoshow == 'all') {
$valuetoshow=$langs->trans('All'); $valuetoshow = $langs->trans('All');
} }
elseif ($fieldlist[$field]=='country') { elseif ($fieldlist[$field] == 'country') {
if (empty($obj->country_code)) if (empty($obj->country_code))
{ {
$valuetoshow='-'; $valuetoshow = '-';
} }
else else
{ {
$key=$langs->trans("Country".strtoupper($obj->country_code)); $key = $langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country); $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
} }
} }
elseif ($fieldlist[$field]=='country_id') { elseif ($fieldlist[$field] == 'country_id') {
$showfield=0; $showfield = 0;
} }
$class='tddict'; $class = 'tddict';
if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto';
// Show value for field // Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>'; if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
} }
} }
// Can an entry be erased or disabled ? // Can an entry be erased or disabled ?
$iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):''); $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
if ($param) $url .= '&'.$param; if ($param) $url .= '&'.$param;
$url.='&'; $url .= '&';
// Active // Active
print '<td class="center nowrap">'; print '<td class="center nowrap">';
@@ -737,10 +737,10 @@ $db->close();
*/ */
function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = '') function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = '')
{ {
global $conf,$langs,$db; global $conf, $langs, $db;
global $form; global $form;
global $region_id; global $region_id;
global $elementList,$sourceList; global $elementList, $sourceList;
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
@@ -758,15 +758,15 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
continue; continue;
} // For state page, we do not show the country input (we link to region, not country) } // For state page, we do not show the country input (we link to region, not country)
print '<td>'; print '<td>';
$fieldname='country'; $fieldname = 'country';
print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'country_id') elseif ($fieldlist[$field] == 'country_id')
{ {
if (! in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
{ {
$country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
print '<td>'; print '<td>';
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
print '</td>'; print '</td>';
@@ -776,24 +776,24 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
if ($fieldlist[$field] == 'type_cdr') print '<td class="center">'; if ($fieldlist[$field] == 'type_cdr') print '<td class="center">';
else print '<td>'; else print '<td>';
if ($fieldlist[$field] == 'type_cdr') { if ($fieldlist[$field] == 'type_cdr') {
print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
} else { } else {
print $form->selectyesno($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1); print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
} }
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
} }
else else
{ {
print '<td>'; print '<td>';
$size=''; $class=''; $size = ''; $class = '';
if ($fieldlist[$field]=='code') $size='size="8" '; if ($fieldlist[$field] == 'code') $size = 'size="8" ';
if ($fieldlist[$field]=='position') $size='size="4" '; if ($fieldlist[$field] == 'position') $size = 'size="4" ';
if ($fieldlist[$field]=='libelle') $size='centpercent'; if ($fieldlist[$field] == 'libelle') $size = 'centpercent';
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" ';
print '<input type="text" '.$size.' class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">'; print '<input type="text" '.$size.' class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
} }
} }

View File

@@ -153,7 +153,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'formula' && empty($_POST['formula'])) continue;
if ($value == 'range_account' && empty($_POST['range_account'])) continue; if ($value == 'range_account' && empty($_POST['range_account'])) continue;
if ($value == 'country' || $value == 'country_id') continue; if ($value == 'country' || $value == 'country_id') continue;
if (! GETPOSTISSET($value) || GETPOST($value) == '') if (!GETPOSTISSET($value) || GETPOST($value) == '')
{ {
$ok = 0; $ok = 0;
$fieldnamekey = $listfield[$f]; $fieldnamekey = $listfield[$f];

View File

@@ -32,13 +32,13 @@ if (!$user->admin)
accessforbidden(); accessforbidden();
// 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"));
$action=GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$securityevent=new Events($db); $securityevent = new Events($db);
$eventstolog=$securityevent->eventstolog; $eventstolog = $securityevent->eventstolog;
/* /*
@@ -46,13 +46,13 @@ $eventstolog=$securityevent->eventstolog;
*/ */
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')) dolibarr_set_const($db, $param, GETPOST($param, 'alphanohtml'), 'chaine', 0, '', $conf->entity);
else dolibarr_del_const($db, $param, $conf->entity); else dolibarr_del_const($db, $param, $conf->entity);
} }
@@ -67,7 +67,7 @@ if ($action == "save")
* View * View
*/ */
$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
llxHeader('', $langs->trans("Audit"), $wikihelp); llxHeader('', $langs->trans("Audit"), $wikihelp);
//$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>';
@@ -81,7 +81,7 @@ 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="save">'; print '<input type="hidden" name="action" value="save">';
$head=security_prepare_head(); $head = security_prepare_head();
dol_fiche_head($head, 'audit', $langs->trans("Security"), -1); dol_fiche_head($head, 'audit', $langs->trans("Security"), -1);
@@ -97,9 +97,9 @@ foreach ($eventstolog as $key => $arr)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$arr['id'].'</td>'; print '<td>'.$arr['id'].'</td>';
print '<td>'; print '<td>';
$key='MAIN_LOGEVENTS_'.$arr['id']; $key = 'MAIN_LOGEVENTS_'.$arr['id'];
$value=$conf->global->$key; $value = $conf->global->$key;
print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.($value?' checked':'').'>'; print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.($value ? ' checked' : '').'>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
} }

View File

@@ -333,7 +333,7 @@ if (empty($reshook))
if ($i) $sql .= ", "; if ($i) $sql .= ", ";
$sql .= $field."="; $sql .= $field."=";
if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && ! GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work
elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
elseif ($keycode == 'content') { elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";

View File

@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.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"));
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
@@ -66,7 +66,7 @@ if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler");
if ($action == 'update') if ($action == 'update')
{ {
if (! $cancel) if (!$cancel)
{ {
$leftmenu = ''; $mainmenu = ''; $leftmenu = ''; $mainmenu = '';
if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha'))) if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha')))

View File

@@ -24,7 +24,7 @@
require '../main.inc.php'; 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/oauth.lib.php'; // This define $list require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // This define $list
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
use OAuth\Common\Storage\DoliStorage; use OAuth\Common\Storage\DoliStorage;
@@ -149,7 +149,7 @@ if ($mode == 'setup' && $user->admin)
$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.
$shortscope='user,public_repo'; $shortscope = 'user,public_repo';
$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&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/'; $urltocheckperms = 'https://github.com/settings/applications/';
@@ -159,7 +159,7 @@ if ($mode == 'setup' && $user->admin)
$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.
$shortscope='userinfo_email,userinfo_profile,cloud_print'; $shortscope = 'userinfo_email,userinfo_profile,cloud_print';
//$scope.=',gmail_full'; //$scope.=',gmail_full';
$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&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');

View File

@@ -29,12 +29,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 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', 'alpha'); $action = GETPOST('action', 'alpha');
@@ -44,8 +44,8 @@ $action=GETPOST('action', 'alpha');
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"]);
@@ -56,7 +56,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
dol_print_error($db); dol_print_error($db);
} }
} 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"]);
@@ -70,8 +70,8 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
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');
} }
@@ -83,7 +83,7 @@ elseif ($action == 'updateform')
$form = new Form($db); $form = new Form($db);
$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
llxHeader('', $langs->trans("Miscellaneous"), $wikihelp); llxHeader('', $langs->trans("Miscellaneous"), $wikihelp);
print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
@@ -97,7 +97,7 @@ 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="updateform">'; print '<input type="hidden" name="action" value="updateform">';
$head=security_prepare_head(); $head = security_prepare_head();
dol_fiche_head($head, 'misc', $langs->trans("Security"), -1); dol_fiche_head($head, 'misc', $langs->trans("Security"), -1);
@@ -115,7 +115,7 @@ 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');
} }
@@ -142,7 +142,7 @@ 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');
} }
@@ -173,8 +173,8 @@ print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n"; 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">';
print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"))); print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor")));
@@ -185,8 +185,8 @@ print '</td>';
print '</tr>'; print '</tr>';
$sessiontimeout=ini_get("session.gc_maxlifetime"); $sessiontimeout = ini_get("session.gc_maxlifetime");
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,10 +35,10 @@ 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');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@@ -58,19 +58,19 @@ if ($action == 'update' || $action == 'add')
// 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]);
$constnote = dol_escape_htmltag($constnotearray[$key]); $constnote = dol_escape_htmltag($constnotearray[$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');
} }
@@ -84,7 +84,7 @@ 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);
@@ -94,7 +94,7 @@ if ($action == 'set')
// 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);
@@ -107,12 +107,12 @@ if ($action == 'unset')
* View * View
*/ */
$help_url=''; $help_url = '';
llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url); llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url);
$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("MailmanSpipSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("MailmanSpipSetup"), $linkback, 'title_setup');
@@ -122,7 +122,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().'">';
@@ -131,12 +131,12 @@ if (! empty($conf->global->ADHERENT_USE_SPIP))
dol_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user'); dol_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user');
//$link=img_picto($langs->trans("Active"),'tick').' '; //$link=img_picto($langs->trans("Active"),'tick').' ';
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_SPIP">'; $link = '<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_SPIP">';
//$link.=$langs->trans("Disable"); //$link.=$langs->trans("Disable");
$link.=img_picto($langs->trans("Activated"), 'switch_on'); $link .= img_picto($langs->trans("Activated"), 'switch_on');
$link.='</a>'; $link .= '</a>';
// Edition des varibales globales // Edition des varibales globales
$constantes=array( $constantes = array(
'ADHERENT_SPIP_SERVEUR', 'ADHERENT_SPIP_SERVEUR',
'ADHERENT_SPIP_DB', 'ADHERENT_SPIP_DB',
'ADHERENT_SPIP_USER', 'ADHERENT_SPIP_USER',
@@ -158,10 +158,10 @@ else
{ {
dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user'); dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
$link='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_SPIP">'; $link = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_SPIP">';
//$link.=$langs->trans("Activate"); //$link.=$langs->trans("Activate");
$link.=img_picto($langs->trans("Disabled"), 'switch_off'); $link .= img_picto($langs->trans("Disabled"), 'switch_off');
$link.='</a>'; $link .= '</a>';
print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
dol_fiche_end(); dol_fiche_end();

View File

@@ -34,13 +34,13 @@ require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadlangs(array('errors', 'admin', 'companies', 'website')); $langs->loadlangs(array('errors', 'admin', 'companies', 'website'));
$action=GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; $action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view';
$confirm=GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$rowid=GETPOST('rowid', 'alpha'); $rowid = GETPOST('rowid', 'alpha');
$id=1; $id = 1;
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
@@ -52,7 +52,7 @@ $actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
$status = 1; $status = 1;
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $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 = GETPOST('page', 'int'); $page = GETPOST('page', 'int');
@@ -65,55 +65,55 @@ $pagenext = $page + 1;
$hookmanager->initHooks(array('website')); $hookmanager->initHooks(array('website'));
// Name of SQL tables of dictionaries // Name of SQL tables of dictionaries
$tabname=array(); $tabname = array();
$tabname[1] = MAIN_DB_PREFIX."website"; $tabname[1] = MAIN_DB_PREFIX."website";
// Dictionary labels // Dictionary labels
$tablib=array(); $tablib = array();
$tablib[1] = "Websites"; $tablib[1] = "Websites";
// Requests to extract data // Requests to extract data
$tabsql=array(); $tabsql = array();
$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.status FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')'; $tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.status FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')';
// Criteria to sort dictionaries // Criteria to sort dictionaries
$tabsqlsort=array(); $tabsqlsort = array();
$tabsqlsort[1] ="ref ASC"; $tabsqlsort[1] = "ref ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire // Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array(); $tabfield = array();
$tabfield[1] = "ref,description,virtualhost"; $tabfield[1] = "ref,description,virtualhost";
// Nom des champs d'edition pour modification d'un enregistrement // Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array(); $tabfieldvalue = array();
$tabfieldvalue[1] = "ref,description,virtualhost"; $tabfieldvalue[1] = "ref,description,virtualhost";
// Nom des champs dans la table pour insertion d'un enregistrement // Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array(); $tabfieldinsert = array();
$tabfieldinsert[1] = "ref,description,virtualhost,entity"; $tabfieldinsert[1] = "ref,description,virtualhost,entity";
// Nom du rowid si le champ n'est pas de type autoincrement // Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on // Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on // "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array(); $tabrowid = array();
$tabrowid[1] = ""; $tabrowid[1] = "";
// Condition to show dictionary in setup page // Condition to show dictionary in setup page
$tabcond=array(); $tabcond = array();
$tabcond[1] = (! empty($conf->website->enabled)); $tabcond[1] = (!empty($conf->website->enabled));
// List of help for fields // List of help for fields
$tabhelp=array(); $tabhelp = array();
$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>')); $tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'));
// List of check for fields (NOT USED YET) // List of check for fields (NOT USED YET)
$tabfieldcheck=array(); $tabfieldcheck = array();
$tabfieldcheck[1] = array(); $tabfieldcheck[1] = array();
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array(); $elementList = array();
$sourceList=array(); $sourceList = array();
/* /*
@@ -123,35 +123,35 @@ $sourceList=array();
// Actions add or modify a website // Actions add or modify a website
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
$listfield=explode(',', $tabfield[$id]); $listfield = explode(',', $tabfield[$id]);
$listfieldinsert=explode(',', $tabfieldinsert[$id]); $listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify=explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue=explode(',', $tabfieldvalue[$id]); $listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled // Check that all fields are filled
$ok=1; $ok = 1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value)
{ {
if ($value == 'ref' && (! GETPOSTISSET($value) || GETPOST($value) == '')) if ($value == 'ref' && (!GETPOSTISSET($value) || GETPOST($value) == ''))
{ {
$ok=0; $ok = 0;
$fieldnamekey=$listfield[$f]; $fieldnamekey = $listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
break; break;
} }
elseif ($value == 'ref' && ! preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value])) elseif ($value == 'ref' && !preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value]))
{ {
$ok=0; $ok = 0;
$fieldnamekey=$listfield[$f]; $fieldnamekey = $listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors');
break; break;
} }
} }
// Clean parameters // Clean parameters
if (! empty($_POST['ref'])) if (!empty($_POST['ref']))
{ {
$websitekey=strtolower($_POST['ref']); $websitekey = strtolower($_POST['ref']);
} }
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
@@ -160,13 +160,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id]) if ($tabrowid[$id])
{ {
// Recupere id libre pour insertion // Recupere id libre pour insertion
$newid=0; $newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$newid=($obj->newid + 1); $newid = ($obj->newid + 1);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
@@ -181,16 +181,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry // Add new entry
$sql = "INSERT INTO ".$tabname[$id]." ("; $sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields // List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql.= $tabrowid[$id].","; $sql .= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id]; $sql .= $tabfieldinsert[$id];
$sql.=",status)"; $sql .= ",status)";
$sql.= " VALUES("; $sql .= " VALUES(";
// List of values // List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql.= $newid.","; $sql .= $newid.",";
$i=0; $i = 0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value)
{ {
if ($value == 'entity') { if ($value == 'entity') {
@@ -199,19 +199,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($value == 'ref') { if ($value == 'ref') {
$_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]); $_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]);
} }
if ($i) $sql.=","; if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql.=",1)"; $sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG); dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) // Add is ok if ($result) // Add is ok
{ {
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
unset($_POST); // Clean $_POST array, we keep only unset($_POST); // Clean $_POST array, we keep only
} }
else else
{ {
@@ -227,22 +227,22 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha'))
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
$db->begin(); $db->begin();
$website=new Website($db); $website = new Website($db);
$rowid=GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$website->fetch($rowid); $website->fetch($rowid);
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs // Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{ {
$sql.= $tabrowid[$id]."="; $sql .= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', "; $sql .= "'".$db->escape($rowid)."', ";
} }
$i = 0; $i = 0;
foreach ($listfieldmodify as $field) foreach ($listfieldmodify as $field)
@@ -250,13 +250,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($field == 'entity') { if ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql.=","; if ($i) $sql .= ",";
$sql.= $field."="; $sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql.= " WHERE ".$rowidcol." = '".$rowid."'"; $sql .= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
@@ -266,8 +266,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09')); $newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09'));
if ($newname != $website->ref) if ($newname != $website->ref)
{ {
$srcfile=DOL_DATA_ROOT.'/website/'.$website->ref; $srcfile = DOL_DATA_ROOT.'/website/'.$website->ref;
$destfile=DOL_DATA_ROOT.'/website/'.$newname; $destfile = DOL_DATA_ROOT.'/website/'.$newname;
if (dol_is_dir($destfile)) if (dol_is_dir($destfile))
{ {
@@ -294,7 +294,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} }
if (! $error) if (!$error)
{ {
$db->commit(); $db->commit();
} }
@@ -313,8 +313,8 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
$website = new Website($db); $website = new Website($db);
$website->fetch($rowid); $website->fetch($rowid);
@@ -332,7 +332,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
$sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'"; $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) if (!$result)
{ {
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{ {
@@ -358,8 +358,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0])
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid ='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid ='".$rowid."'";
@@ -375,8 +375,8 @@ if ($action == $acts[0])
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1])
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid ='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid ='".$rowid."'";
@@ -396,16 +396,16 @@ if ($action == $acts[1])
*/ */
$form = new Form($db); $form = new Form($db);
$formadmin=new FormAdmin($db); $formadmin = new FormAdmin($db);
llxHeader('', $langs->trans("WebsiteSetup")); llxHeader('', $langs->trans("WebsiteSetup"));
$titre=$langs->trans("WebsiteSetup"); $titre = $langs->trans("WebsiteSetup");
$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($titre, $linkback, 'title_setup'); print load_fiche_titre($titre, $linkback, 'title_setup');
// Onglets // Onglets
$head=array(); $head = array();
$h = 0; $h = 0;
$head[$h][0] = DOL_URL_ROOT."/admin/website.php"; $head[$h][0] = DOL_URL_ROOT."/admin/website.php";
@@ -428,7 +428,7 @@ print "<br>\n";
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete', '', 0, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete', '', 0, 1);
} }
//var_dump($elementList); //var_dump($elementList);
@@ -438,12 +438,12 @@ if ($action == 'delete')
if ($id) if ($id)
{ {
// Complete requete recherche valeurs avec critere de tri // Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id]; $sql = $tabsql[$id];
$sql.=$db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$sql.=$db->plimit($limit+1, $offset); $sql .= $db->plimit($limit + 1, $offset);
//print $sql; //print $sql;
$fieldlist=explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
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().'">';
@@ -452,10 +452,10 @@ if ($id)
// Form to add a new line // Form to add a new line
if ($tabname[$id]) if ($tabname[$id])
{ {
$alabelisused=0; $alabelisused = 0;
$var=false; $var = false;
$fieldlist=explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
// Line for title // Line for title
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@@ -463,15 +463,15 @@ if ($id)
{ {
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow = $langs->trans($valuetoshow); // try to translate
$align=''; $align = '';
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
if ($valuetoshow != '') if ($valuetoshow != '')
{ {
print '<td class="'.$align.'">'; print '<td class="'.$align.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>'; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
elseif (! empty($tabhelp[$id][$value])) elseif (!empty($tabhelp[$id][$value]))
{ {
if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual'); if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual');
else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
@@ -479,7 +479,7 @@ if ($id)
else print $valuetoshow; else print $valuetoshow;
print '</td>'; print '</td>';
} }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
} }
print '<td colspan="4">'; print '<td colspan="4">';
@@ -496,7 +496,7 @@ if ($id)
foreach ($fieldlist as $key=>$val) foreach ($fieldlist as $key=>$val)
{ {
if (GETPOST($val, 'alpha')) if (GETPOST($val, 'alpha'))
$obj->$val=GETPOST($val); $obj->$val = GETPOST($val);
} }
} }
@@ -510,7 +510,7 @@ if ($id)
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
$colspan=count($fieldlist)+2; $colspan = count($fieldlist) + 2;
} }
print '</table>'; print '</table>';
@@ -518,7 +518,7 @@ if ($id)
// List of websites in database // List of websites in database
$resql=$db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@@ -540,10 +540,10 @@ if ($id)
{ {
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$showfield=1; // Par defaut $showfield = 1; // Par defaut
$align="left"; $align = "left";
$sortable=1; $sortable = 1;
$valuetoshow=''; $valuetoshow = '';
/* /*
$tmparray=getLabelOfField($fieldlist[$field]); $tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield']; $showfield=$tmp['showfield'];
@@ -551,20 +551,20 @@ if ($id)
$align=$tmp['align']; $align=$tmp['align'];
$sortable=$tmp['sortable']; $sortable=$tmp['sortable'];
*/ */
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); }
// Affiche nom du champ // Affiche nom du champ
if ($showfield) if ($showfield)
{ {
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), "", "align=".$align, $sortfield, $sortorder); print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder);
} }
} }
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page?'page='.$page.'&':''), "", 'align="center"', $sortfield, $sortorder); print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
@@ -575,34 +575,34 @@ if ($id)
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
//print_r($obj); //print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
{ {
$tmpaction='edit'; $tmpaction = 'edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit'); if (empty($reshook)) fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit');
print '<td colspan="3" class="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>'; print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
} }
else else
{ {
$tmpaction = 'view'; $tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook))
{ {
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$showfield=1; $showfield = 1;
$align="left"; $align = "left";
$fieldname=$fieldlist[$field]; $fieldname = $fieldlist[$field];
$valuetoshow=$obj->$fieldname; $valuetoshow = $obj->$fieldname;
// Show value for field // Show value for field
if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>'; if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>';
@@ -610,14 +610,14 @@ if ($id)
} }
// Can an entry be erased or disabled ? // Can an entry be erased or disabled ?
$iserasable=1; $isdisable=1; // true by default $iserasable = 1; $isdisable = 1; // true by default
if ($obj->status) $iserasable=0; // We can't delete a website on. Disable it first. if ($obj->status) $iserasable = 0; // We can't delete a website on. Disable it first.
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?urlencode($obj->code):'').'&amp;'; $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&amp;code='.(!empty($obj->code) ?urlencode($obj->code) : '').'&amp;';
// Active // Active
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status?1:0)].'">'.$actl[($obj->status?1:0)].'</a>'; print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'">'.$actl[($obj->status ? 1 : 0)].'</a>';
print "</td>"; print "</td>";
// Modify link // Modify link
@@ -660,10 +660,10 @@ $db->close();
*/ */
function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '') function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '')
{ {
global $conf,$langs,$db; global $conf, $langs, $db;
global $form; global $form;
global $region_id; global $region_id;
global $elementList,$sourceList,$localtax_typeList; global $elementList, $sourceList, $localtax_typeList;
global $bc; global $bc;
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
@@ -678,18 +678,18 @@ function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '')
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) { elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) {
print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldname)?$obj->$fieldname:'').'" size="10" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat" value="'.(!empty($obj->$fieldname) ? $obj->$fieldname : '').'" size="10" name="'.$fieldlist[$field].'"></td>';
} }
else else
{ {
print '<td>'; print '<td>';
$size=''; $size = '';
if ($fieldlist[$field]=='code') $size='size="8" '; if ($fieldlist[$field] == 'code') $size = 'size="8" ';
if ($fieldlist[$field]=='position') $size='size="4" '; if ($fieldlist[$field] == 'position') $size = 'size="4" ';
if ($fieldlist[$field]=='libelle') $size='size="32" '; if ($fieldlist[$field] == 'libelle') $size = 'size="32" ';
if ($fieldlist[$field]=='tracking') $size='size="92" '; if ($fieldlist[$field] == 'tracking') $size = 'size="92" ';
if ($fieldlist[$field]=='sortorder') $size='size="2" '; if ($fieldlist[$field] == 'sortorder') $size = 'size="2" ';
print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname)?$obj->$fieldname:'').'" name="'.$fieldlist[$field].'">'; print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname) ? $obj->$fieldname : '').'" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
} }
} }

View File

@@ -21,14 +21,14 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($langs) || ! is_object($langs)) if (empty($langs) || !is_object($langs))
{ {
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("main","bills","cashdesk")); $langs->loadLangs(array("main", "bills", "cashdesk"));
// Object $form must de defined // Object $form must de defined
@@ -64,7 +64,7 @@ $id = $obj_facturation->id();
// Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ... // Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ...
$nbtoshow = $nbr_enreg; $nbtoshow = $nbr_enreg;
if (! empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) $nbtoshow = $conf_taille_listes; if (!empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) $nbtoshow = $conf_taille_listes;
for ($i = 0; $i < $nbtoshow; $i++) for ($i = 0; $i < $nbtoshow; $i++)
{ {
@@ -77,8 +77,8 @@ for ($i = 0; $i < $nbtoshow; $i++)
$label = $tab_designations[$i]['label']; $label = $tab_designations[$i]['label'];
print '<option '.$selected.' value="'.$tab_designations[$i]['rowid'].'">'.dol_trunc($tab_designations[$i]['ref'], 16).' - '.dol_trunc($label, 35, 'middle'); print '<option '.$selected.' value="'.$tab_designations[$i]['rowid'].'">'.dol_trunc($tab_designations[$i]['ref'], 16).' - '.dol_trunc($label, 35, 'middle');
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot) && $tab_designations[$i]['fk_product_type']==0) { if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot) && $tab_designations[$i]['fk_product_type'] == 0) {
print ' ('.$langs->trans("CashDeskStock").': '.(empty($tab_designations[$i]['reel'])?0:$tab_designations[$i]['reel']).')'; print ' ('.$langs->trans("CashDeskStock").': '.(empty($tab_designations[$i]['reel']) ? 0 : $tab_designations[$i]['reel']).')';
} }
print '</option>'."\n"; print '</option>'."\n";
} }
@@ -101,19 +101,19 @@ for ($i = 0; $i < $nbtoshow; $i++)
</tr> </tr>
<tr> <tr>
<td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtQte" name="txtQte" value="1" onkeyup="javascript: modif();" onfocus="javascript: this.select();" /> <td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtQte" name="txtQte" value="1" onkeyup="javascript: modif();" onfocus="javascript: this.select();" />
<?php print genkeypad("txtQte", "frmQte");?> <?php print genkeypad("txtQte", "frmQte"); ?>
</td> </td>
<!-- Show unit price --> <!-- Show unit price -->
<?php // TODO Remove the disabled and use this value when adding product into cart ?> <?php // TODO Remove the disabled and use this value when adding product into cart ?>
<td><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtPrixUnit" value="<?php echo price2num($obj_facturation->prix(), 'MU'); ?>" onchange="javascript: modif();" disabled /></td> <td><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtPrixUnit" value="<?php echo price2num($obj_facturation->prix(), 'MU'); ?>" onchange="javascript: modif();" disabled /></td>
<!-- Choix de la remise --> <!-- Choix de la remise -->
<td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/> <td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/>
<?php print genkeypad("txtRemise", "frmQte");?> <?php print genkeypad("txtRemise", "frmQte"); ?>
</td> </td>
<!-- Choix du taux de TVA --> <!-- Choix du taux de TVA -->
<td class="select_tva center"> <td class="select_tva center">
<?php <?php
$vatrate = $obj_facturation->vatrate; // To get vat rate we just have selected $vatrate = $obj_facturation->vatrate; // To get vat rate we just have selected
$buyer = new Societe($db); $buyer = new Societe($db);
if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]);
@@ -152,7 +152,7 @@ for ($i = 0; $i < $nbtoshow; $i++)
<td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtDu" value="<?php echo price2num($obj_facturation->prixTotalTtc(), 'MT'); ?>" disabled /></td> <td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtDu" value="<?php echo price2num($obj_facturation->prixTotalTtc(), 'MT'); ?>" disabled /></td>
<!-- Choix du montant encaisse --> <!-- Choix du montant encaisse -->
<td><input class="texte2 maxwidth100onsmartphone" type="text" id="txtEncaisse" name="txtEncaisse" value="" onkeyup="javascript: verifDifference();" onfocus="javascript: this.select();" /> <td><input class="texte2 maxwidth100onsmartphone" type="text" id="txtEncaisse" name="txtEncaisse" value="" onkeyup="javascript: verifDifference();" onfocus="javascript: this.select();" />
<?php print genkeypad("txtEncaisse", "frmDifference");?> <?php print genkeypad("txtEncaisse", "frmDifference"); ?>
</td> </td>
<!-- Affichage du montant rendu --> <!-- Affichage du montant rendu -->
<td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtRendu" value="0" disabled /></td> <td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtRendu" value="0" disabled /></td>

View File

@@ -433,7 +433,7 @@ class FormAdvTargetEmailing extends Form
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$out .= '<select id="'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">'; $out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($showempty) if ($showempty)
$out .= '<option value=""></option>'; $out .= '<option value=""></option>';
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);

View File

@@ -64,7 +64,7 @@ class Contact extends CommonObject
/** /**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/ */
public $fields=array( public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>15), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>15),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
@@ -358,7 +358,7 @@ class Contact extends CommonObject
if (!$error) if (!$error)
{ {
$result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ... $result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ...
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
@@ -1007,7 +1007,7 @@ class Contact extends CommonObject
{ {
$this->gender = 'man'; $this->gender = 'man';
} }
elseif(in_array($this->civility_id, array('MME','MLE')) || in_array($this->civility_code, array('MME','MLE'))) elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE')))
{ {
$this->gender = 'woman'; $this->gender = 'woman';
} }

View File

@@ -36,7 +36,7 @@ class CoreObject extends CommonObject
/** /**
* @var Array $_fields Fields to synchronize with Database * @var Array $_fields Fields to synchronize with Database
*/ */
protected $fields=array(); protected $fields = array();
/** /**
* Constructor * Constructor
@@ -70,8 +70,8 @@ class CoreObject extends CommonObject
else $this->{$field} = ''; else $this->{$field} = '';
} }
$this->to_delete=false; $this->to_delete = false;
$this->is_clone=false; $this->is_clone = false;
return true; return true;
} }
@@ -110,7 +110,7 @@ class CoreObject extends CommonObject
public function fetch($id, $loadChild = true) public function fetch($id, $loadChild = true)
{ {
$res = $this->fetchCommon($id); $res = $this->fetchCommon($id);
if($res>0) { if ($res > 0) {
if ($loadChild) $this->fetchChild(); if ($loadChild) $this->fetchChild();
} }
@@ -129,11 +129,11 @@ class CoreObject extends CommonObject
*/ */
public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false) public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false)
{ {
if(!empty($id)) if (!empty($id))
{ {
foreach($this->{$tabName} as $k=>&$object) foreach ($this->{$tabName} as $k=>&$object)
{ {
if($object->{$key} === $id) return $k; if ($object->{$key} === $id) return $k;
} }
} }
@@ -141,7 +141,7 @@ class CoreObject extends CommonObject
$className = ucfirst($tabName); $className = ucfirst($tabName);
$this->{$tabName}[$k] = new $className($this->db); $this->{$tabName}[$k] = new $className($this->db);
if($id>0 && $key==='id' && $try_to_load) if ($id > 0 && $key === 'id' && $try_to_load)
{ {
$this->{$tabName}[$k]->fetch($id); $this->{$tabName}[$k]->fetch($id);
} }
@@ -181,20 +181,20 @@ class CoreObject extends CommonObject
{ {
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
{ {
foreach($this->childtables as &$childTable) foreach ($this->childtables as &$childTable)
{ {
$className = ucfirst($childTable); $className = ucfirst($childTable);
$this->{$className}=array(); $this->{$className} = array();
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id;
$res = $this->db->query($sql); $res = $this->db->query($sql);
if($res) if ($res)
{ {
while($obj = $this->db->fetch_object($res)) while ($obj = $this->db->fetch_object($res))
{ {
$o=new $className($this->db); $o = new $className($this->db);
$o->fetch($obj->rowid); $o->fetch($obj->rowid);
$this->{$className}[] = $o; $this->{$className}[] = $o;
@@ -216,19 +216,19 @@ class CoreObject extends CommonObject
*/ */
public function saveChild(User &$user) public function saveChild(User &$user)
{ {
if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
{ {
foreach($this->childtables as &$childTable) foreach ($this->childtables as &$childTable)
{ {
$className = ucfirst($childTable); $className = ucfirst($childTable);
if(!empty($this->{$className})) if (!empty($this->{$className}))
{ {
foreach($this->{$className} as $i => &$object) foreach ($this->{$className} as $i => &$object)
{ {
$object->{$this->fk_element} = $this->id; $object->{$this->fk_element} = $this->id;
$object->update($user); $object->update($user);
if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]);
} }
} }
} }
@@ -245,7 +245,7 @@ class CoreObject extends CommonObject
public function update(User &$user) public function update(User &$user)
{ {
if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed
elseif (isset($this->to_delete) && $this->to_delete==true) return $this->delete($user); elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user);
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
@@ -253,7 +253,7 @@ class CoreObject extends CommonObject
$res = $this->updateCommon($user); $res = $this->updateCommon($user);
if ($res) if ($res)
{ {
$result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); $result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
else $this->saveChild($user); else $this->saveChild($user);
} }
@@ -284,17 +284,17 @@ class CoreObject extends CommonObject
*/ */
public function create(User &$user) public function create(User &$user)
{ {
if($this->id > 0) return $this->update($user); if ($this->id > 0) return $this->update($user);
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
$res = $this->createCommon($user); $res = $this->createCommon($user);
if($res) if ($res)
{ {
$this->id = $this->db->last_insert_id($this->table_element); $this->id = $this->db->last_insert_id($this->table_element);
$result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); $result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
else $this->saveChild($user); else $this->saveChild($user);
} }
@@ -330,20 +330,20 @@ class CoreObject extends CommonObject
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
$result = $this->call_trigger(strtoupper($this->element). '_DELETE', $user); $result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
if (!$error) if (!$error)
{ {
$this->deleteCommon($user); $this->deleteCommon($user);
if($this->withChild && !empty($this->childtables)) if ($this->withChild && !empty($this->childtables))
{ {
foreach($this->childtables as &$childTable) foreach ($this->childtables as &$childTable)
{ {
$className = ucfirst($childTable); $className = ucfirst($childTable);
if (!empty($this->{$className})) if (!empty($this->{$className}))
{ {
foreach($this->{$className} as &$object) foreach ($this->{$className} as &$object)
{ {
$object->delete($user); $object->delete($user);
} }
@@ -376,7 +376,7 @@ class CoreObject extends CommonObject
*/ */
public function getDate($field, $format = '') public function getDate($field, $format = '')
{ {
if(empty($this->{$field})) return ''; if (empty($this->{$field})) return '';
else else
{ {
return dol_print_date($this->{$field}, $format); return dol_print_date($this->{$field}, $format);

View File

@@ -767,7 +767,7 @@ class FormCompany extends Form
if ($rendermode === 'edit') if ($rendermode === 'edit')
{ {
$contactType = $contact->listeTypeContacts('external', '', 1, '', '', 'agenda'); // We exclude agenda as there is no contact on such element $contactType = $contact->listeTypeContacts('external', '', 1, '', '', 'agenda'); // We exclude agenda as there is no contact on such element
if (count($selected) > 0) { if (count($selected) > 0) {
$newselected = array(); $newselected = array();
foreach ($selected as $key=>$val) { foreach ($selected as $key=>$val) {

View File

@@ -36,11 +36,11 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/openid.class.php';
*/ */
function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
{ {
global $_POST,$db,$conf,$langs; global $_POST, $db, $conf, $langs;
dol_syslog("functions_openid::check_user_password_openid usertotest=".$usertotest); dol_syslog("functions_openid::check_user_password_openid usertotest=".$usertotest);
$login=''; $login = '';
// Get identity from user and redirect browser to OpenID Server // Get identity from user and redirect browser to OpenID Server
if (GETPOSISSET('username')) if (GETPOSISSET('username'))
@@ -48,14 +48,14 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
$openid = new SimpleOpenID(); $openid = new SimpleOpenID();
$openid->SetIdentity($_POST['username']); $openid->SetIdentity($_POST['username']);
$protocol = ($conf->file->main_force_https ? 'https://' : 'http://'); $protocol = ($conf->file->main_force_https ? 'https://' : 'http://');
$openid->SetTrustRoot($protocol . $_SERVER["HTTP_HOST"]); $openid->SetTrustRoot($protocol.$_SERVER["HTTP_HOST"]);
$openid->SetRequiredFields(array('email','fullname')); $openid->SetRequiredFields(array('email', 'fullname'));
$_SESSION['dol_entity'] = $_POST["entity"]; $_SESSION['dol_entity'] = $_POST["entity"];
//$openid->SetOptionalFields(array('dob','gender','postcode','country','language','timezone')); //$openid->SetOptionalFields(array('dob','gender','postcode','country','language','timezone'));
if ($openid->sendDiscoveryRequestToGetXRDS()) if ($openid->sendDiscoveryRequestToGetXRDS())
{ {
$openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script $openid->SetApprovedURL($protocol.$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script
$openid->Redirect(); // This will redirect user to OpenID Server $openid->Redirect(); // This will redirect user to OpenID Server
} }
else else
{ {
@@ -65,7 +65,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
return false; return false;
} }
// Perform HTTP Request to OpenID server to validate key // Perform HTTP Request to OpenID server to validate key
elseif($_GET['openid_mode'] == 'id_res') elseif ($_GET['openid_mode'] == 'id_res')
{ {
$openid = new SimpleOpenID(); $openid = new SimpleOpenID();
$openid->SetIdentity($_GET['openid_identity']); $openid->SetIdentity($_GET['openid_identity']);
@@ -74,23 +74,23 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
{ {
// OK HERE KEY IS VALID // OK HERE KEY IS VALID
$sql ="SELECT login"; $sql = "SELECT login";
$sql.=" FROM ".MAIN_DB_PREFIX."user"; $sql .= " FROM ".MAIN_DB_PREFIX."user";
$sql.=" WHERE openid = '".$db->escape($_GET['openid_identity'])."'"; $sql .= " WHERE openid = '".$db->escape($_GET['openid_identity'])."'";
$sql.=" AND entity IN (0," . ($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1) . ")"; $sql .= " AND entity IN (0,".($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1).")";
dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG); dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG);
$resql=$db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$obj=$db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) if ($obj)
{ {
$login=$obj->login; $login = $obj->login;
} }
} }
} }
elseif($openid->IsError() === true) elseif ($openid->IsError() === true)
{ {
// ON THE WAY, WE GOT SOME ERROR // ON THE WAY, WE GOT SOME ERROR
$error = $openid->GetError(); $error = $openid->GetError();

View File

@@ -39,9 +39,9 @@ class MailingTargets // This can't be abstract as it is used for some method
/** /**
* @var string Error code (or message) * @var string Error code (or message)
*/ */
public $error=''; public $error = '';
public $tooltip=''; public $tooltip = '';
/** /**
@@ -64,12 +64,12 @@ class MailingTargets // This can't be abstract as it is used for some method
global $langs, $form; global $langs, $form;
$langs->load("mails"); $langs->load("mails");
$transstring="MailingModuleDesc".$this->name; $transstring = "MailingModuleDesc".$this->name;
$s=''; $s = '';
if ($langs->trans($this->name) != $this->name) $s=$langs->trans($this->name); if ($langs->trans($this->name) != $this->name) $s = $langs->trans($this->name);
elseif ($langs->trans($transstring) != $transstring) $s=$langs->trans($transstring); elseif ($langs->trans($transstring) != $transstring) $s = $langs->trans($transstring);
else $s=$this->desc; else $s = $this->desc;
if ($this->tooltip && is_object($form)) $s .= ' '.$form->textwithpicto('', $langs->trans($this->tooltip), 1, 1); if ($this->tooltip && is_object($form)) $s .= ' '.$form->textwithpicto('', $langs->trans($this->tooltip), 1, 1);
return $s; return $s;
@@ -93,7 +93,7 @@ class MailingTargets // This can't be abstract as it is used for some method
*/ */
public function getNbOfRecipients($sql) public function getNbOfRecipients($sql)
{ {
$result=$this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
@@ -101,7 +101,7 @@ class MailingTargets // This can't be abstract as it is used for some method
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
@@ -130,18 +130,18 @@ class MailingTargets // This can't be abstract as it is used for some method
// Mise a jour nombre de destinataire dans table des mailings // Mise a jour nombre de destinataire dans table des mailings
$sql = "SELECT COUNT(*) nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql = "SELECT COUNT(*) nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " WHERE fk_mailing = ".$mailing_id; $sql .= " WHERE fk_mailing = ".$mailing_id;
$result=$this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$obj=$this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$nb=$obj->nb; $nb = $obj->nb;
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing"; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
$sql .= " SET nbemail = ".$nb." WHERE rowid = ".$mailing_id; $sql .= " SET nbemail = ".$nb." WHERE rowid = ".$mailing_id;
if (!$this->db->query($sql)) if (!$this->db->query($sql))
{ {
dol_syslog($this->db->error()); dol_syslog($this->db->error());
$this->error=$this->db->error(); $this->error = $this->db->error();
return -1; return -1;
} }
} }
@@ -169,26 +169,26 @@ class MailingTargets // This can't be abstract as it is used for some method
$num = count($cibles); $num = count($cibles);
foreach ($cibles as $targetarray) foreach ($cibles as $targetarray)
{ {
if (! empty($targetarray['email'])) // avoid empty email address if (!empty($targetarray['email'])) // avoid empty email address
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
$sql.= " (fk_mailing,"; $sql .= " (fk_mailing,";
$sql.= " fk_contact,"; $sql .= " fk_contact,";
$sql.= " lastname, firstname, email, other, source_url, source_id,"; $sql .= " lastname, firstname, email, other, source_url, source_id,";
$sql.= " tag,"; $sql .= " tag,";
$sql.= " source_type)"; $sql .= " source_type)";
$sql.= " VALUES (".$mailing_id.","; $sql .= " VALUES (".$mailing_id.",";
$sql.= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'") .","; $sql .= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'").",";
$sql.= "'".$this->db->escape($targetarray['lastname'])."',"; $sql .= "'".$this->db->escape($targetarray['lastname'])."',";
$sql.= "'".$this->db->escape($targetarray['firstname'])."',"; $sql .= "'".$this->db->escape($targetarray['firstname'])."',";
$sql.= "'".$this->db->escape($targetarray['email'])."',"; $sql .= "'".$this->db->escape($targetarray['email'])."',";
$sql.= "'".$this->db->escape($targetarray['other'])."',"; $sql .= "'".$this->db->escape($targetarray['other'])."',";
$sql.= "'".$this->db->escape($targetarray['source_url'])."',"; $sql .= "'".$this->db->escape($targetarray['source_url'])."',";
$sql.= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").","; $sql .= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
$sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; $sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
$sql .= "'".$this->db->escape($targetarray['source_type'])."')"; $sql .= "'".$this->db->escape($targetarray['source_type'])."')";
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$result=$this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$j++; $j++;
@@ -199,7 +199,7 @@ class MailingTargets // This can't be abstract as it is used for some method
{ {
// Si erreur autre que doublon // Si erreur autre que doublon
dol_syslog($this->db->error().' : '.$targetarray['email']); dol_syslog($this->db->error().' : '.$targetarray['email']);
$this->error=$this->db->error().' : '.$targetarray['email']; $this->error = $this->db->error().' : '.$targetarray['email'];
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@@ -232,8 +232,8 @@ class MailingTargets // This can't be abstract as it is used for some method
$sql .= " WHERE fk_mailing=".$mailing_id." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))"; $sql .= " WHERE fk_mailing=".$mailing_id." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))";
dol_syslog(__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG); dol_syslog(__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG);
$result=$this->db->query($sql); $result = $this->db->query($sql);
if (! $result) if (!$result)
{ {
dol_print_error($this->db); dol_print_error($this->db);
} }
@@ -258,7 +258,7 @@ class MailingTargets // This can't be abstract as it is used for some method
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " WHERE fk_mailing = ".$mailing_id; $sql .= " WHERE fk_mailing = ".$mailing_id;
if (! $this->db->query($sql)) if (!$this->db->query($sql))
{ {
dol_syslog($this->db->error()); dol_syslog($this->db->error());
} }

View File

@@ -29,8 +29,8 @@ use OAuth\Common\Consumer\Credentials;
use OAuth\OAuth2\Service\GitHub; use OAuth\OAuth2\Service\GitHub;
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
@@ -70,8 +70,8 @@ $credentials = new Credentials(
$currentUri->getAbsoluteUri() $currentUri->getAbsoluteUri()
); );
$requestedpermissionsarray=array(); $requestedpermissionsarray = array();
if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'user'. 'state' parameter is standard to retrieve some parameters back if (GETPOST('state')) $requestedpermissionsarray = explode(',', GETPOST('state')); // Example: 'user'. 'state' parameter is standard to retrieve some parameters back
if ($action != 'delete' && empty($requestedpermissionsarray)) if ($action != 'delete' && empty($requestedpermissionsarray))
{ {
print 'Error, parameter state is not defined'; print 'Error, parameter state is not defined';
@@ -99,11 +99,11 @@ if ($action == 'delete')
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
header('Location: ' . $backtourl); header('Location: '.$backtourl);
exit(); exit();
} }
if (! empty($_GET['code'])) // We are coming from oauth provider page if (!empty($_GET['code'])) // We are coming from oauth provider page
{ {
// We should have // We should have
//$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16))
@@ -132,12 +132,12 @@ if (! empty($_GET['code'])) // We are coming from oauth provider page
// parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri) // parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri)
// has not the ending parameter to true like the Google class constructor. // has not the ending parameter to true like the Google class constructor.
setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
unset($_SESSION["backtourlsavedbeforeoauthjump"]); unset($_SESSION["backtourlsavedbeforeoauthjump"]);
header('Location: ' . $backtourl); header('Location: '.$backtourl);
exit(); exit();
} catch (Exception $e) { } catch (Exception $e) {
print $e->getMessage(); print $e->getMessage();
@@ -145,7 +145,7 @@ if (! empty($_GET['code'])) // We are coming from oauth provider page
} }
else // If entry on page with no parameter, we arrive here else // If entry on page with no parameter, we arrive here
{ {
$_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; $_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl;
// This may create record into oauth_state before the header redirect. // This may create record into oauth_state before the header redirect.
// Creation of record with state in this tables depend on the Provider used (see its constructor). // Creation of record with state in this tables depend on the Provider used (see its constructor).
@@ -155,11 +155,11 @@ else // If entry on page with no parameter, we arrive here
} }
else else
{ {
$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
} }
// we go on oauth provider authorization page // we go on oauth provider authorization page
header('Location: ' . $url); header('Location: '.$url);
exit(); exit();
} }

View File

@@ -29,8 +29,8 @@ use OAuth\Common\Consumer\Credentials;
use OAuth\OAuth2\Service\Google; use OAuth\OAuth2\Service\Google;
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
@@ -70,8 +70,8 @@ $credentials = new Credentials(
$currentUri->getAbsoluteUri() $currentUri->getAbsoluteUri()
); );
$requestedpermissionsarray=array(); $requestedpermissionsarray = array();
if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to store a hash value and can be used to retrieve some parameters back if (GETPOST('state')) $requestedpermissionsarray = explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to store a hash value and can be used to retrieve some parameters back
if ($action != 'delete' && empty($requestedpermissionsarray)) if ($action != 'delete' && empty($requestedpermissionsarray))
{ {
print 'Error, parameter state is not defined'; print 'Error, parameter state is not defined';
@@ -105,11 +105,11 @@ if ($action == 'delete')
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
header('Location: ' . $backtourl); header('Location: '.$backtourl);
exit(); exit();
} }
if (! empty($_GET['code'])) // We are coming from oauth provider page if (!empty($_GET['code'])) // We are coming from oauth provider page
{ {
dol_syslog("We are coming from the oauth provider page"); dol_syslog("We are coming from the oauth provider page");
//llxHeader('',$langs->trans("OAuthSetup")); //llxHeader('',$langs->trans("OAuthSetup"));
@@ -130,12 +130,12 @@ if (! empty($_GET['code'])) // We are coming from oauth provider page
$token = $apiService->requestAccessToken($_GET['code'], $state); $token = $apiService->requestAccessToken($_GET['code'], $state);
setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
unset($_SESSION["backtourlsavedbeforeoauthjump"]); unset($_SESSION["backtourlsavedbeforeoauthjump"]);
header('Location: ' . $backtourl); header('Location: '.$backtourl);
exit(); exit();
} catch (Exception $e) { } catch (Exception $e) {
print $e->getMessage(); print $e->getMessage();
@@ -143,7 +143,7 @@ if (! empty($_GET['code'])) // We are coming from oauth provider page
} }
else // If entry on page with no parameter, we arrive here else // If entry on page with no parameter, we arrive here
{ {
$_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; $_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl;
// This may create record into oauth_state before the header redirect. // This may create record into oauth_state before the header redirect.
// Creation of record with state in this tables depend on the Provider used (see its constructor). // Creation of record with state in this tables depend on the Provider used (see its constructor).
@@ -153,11 +153,11 @@ else // If entry on page with no parameter, we arrive here
} }
else else
{ {
$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
} }
// we go on oauth provider authorization page // we go on oauth provider authorization page
header('Location: ' . $url); header('Location: '.$url);
exit(); exit();
} }

View File

@@ -26,7 +26,7 @@
* \ingroup agenda * \ingroup agenda
* \brief Trigger file for company - contactroles * \brief Trigger file for company - contactroles
*/ */
require_once DOL_DOCUMENT_ROOT . '/core/triggers/dolibarrtriggers.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
/** /**
* Class of triggered functions for agenda module * Class of triggered functions for agenda module
@@ -71,23 +71,23 @@ class InterfaceContactRoles extends DolibarrTriggers
if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE' if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE'
|| $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'PROPOSAL_SUPPLIER_CREATE' || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'PROPOSAL_SUPPLIER_CREATE'
|| $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE') { || $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE') {
dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc); $socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc);
if (! empty($socid) && $socid > 0) { if (!empty($socid) && $socid > 0) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$contactdefault = new Contact($this->db); $contactdefault = new Contact($this->db);
$contactdefault->socid = $socid; $contactdefault->socid = $socid;
$TContact = $contactdefault->getContactRoles($object->element); $TContact = $contactdefault->getContactRoles($object->element);
if (is_array($TContact) && ! empty($TContact)) { if (is_array($TContact) && !empty($TContact)) {
$TContactAlreadyLinked = array(); $TContactAlreadyLinked = array();
if ($object->id > 0) { if ($object->id > 0) {
$cloneFrom = dol_clone($object, 1); $cloneFrom = dol_clone($object, 1);
if (! empty($cloneFrom->id)) { if (!empty($cloneFrom->id)) {
$TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(- 1, 'external'), $cloneFrom->liste_contact(- 1, 'internal')); $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal'));
} }
} }
@@ -102,7 +102,7 @@ class InterfaceContactRoles extends DolibarrTriggers
foreach ($TContact as $infos) { foreach ($TContact as $infos) {
$res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']); $res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']);
if ($res > 0) if ($res > 0)
$nb ++; $nb++;
} }
if ($nb > 0) { if ($nb > 0) {

View File

@@ -29,12 +29,12 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("bills"); $langs->load("bills");
$chid=GETPOST("rowid"); $chid = GETPOST("rowid");
$action=GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$amounts = array(); $amounts = array();
// Security check // Security check
$socid=0; $socid = 0;
if ($user->socid > 0) { if ($user->socid > 0) {
$socid = $user->socid; $socid = $user->socid;
} }
@@ -48,7 +48,7 @@ $object = new Don($db);
if ($action == 'add_payment') if ($action == 'add_payment')
{ {
$error=0; $error = 0;
if ($_POST["cancel"]) if ($_POST["cancel"])
{ {
@@ -59,7 +59,7 @@ if ($action == 'add_payment')
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
if (! $_POST["paymenttype"] > 0) if (!$_POST["paymenttype"] > 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
$error++; $error++;
@@ -69,13 +69,13 @@ if ($action == 'add_payment')
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
$error++; $error++;
} }
if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0) if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
$error++; $error++;
} }
if (! $error) if (!$error)
{ {
$paymentid = 0; $paymentid = 0;
@@ -92,11 +92,11 @@ if ($action == 'add_payment')
if (count($amounts) <= 0) if (count($amounts) <= 0)
{ {
$error++; $error++;
$errmsg='ErrorNoPaymentDefined'; $errmsg = 'ErrorNoPaymentDefined';
setEventMessages($errmsg, null, 'errors'); setEventMessages($errmsg, null, 'errors');
} }
if (! $error) if (!$error)
{ {
$db->begin(); $db->begin();
@@ -104,34 +104,34 @@ if ($action == 'add_payment')
$payment = new PaymentDonation($db); $payment = new PaymentDonation($db);
$payment->chid = $chid; $payment->chid = $chid;
$payment->datepaid = $datepaid; $payment->datepaid = $datepaid;
$payment->amounts = $amounts; // Tableau de montant $payment->amounts = $amounts; // Tableau de montant
$payment->paymenttype = GETPOST("paymenttype", 'int'); $payment->paymenttype = GETPOST("paymenttype", 'int');
$payment->num_payment = GETPOST("num_payment", 'alphanohtml'); $payment->num_payment = GETPOST("num_payment", 'alphanohtml');
$payment->note_public = GETPOST("note_public", 'none'); $payment->note_public = GETPOST("note_public", 'none');
if (! $error) if (!$error)
{ {
$paymentid = $payment->create($user); $paymentid = $payment->create($user);
if ($paymentid < 0) if ($paymentid < 0)
{ {
$errmsg=$payment->error; $errmsg = $payment->error;
setEventMessages($errmsg, null, 'errors'); setEventMessages($errmsg, null, 'errors');
$error++; $error++;
} }
} }
if (! $error) if (!$error)
{ {
$result=$payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', ''); $result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', '');
if (! $result > 0) if (!$result > 0)
{ {
$errmsg=$payment->error; $errmsg = $payment->error;
setEventMessages($errmsg, null, 'errors'); setEventMessages($errmsg, null, 'errors');
$error++; $error++;
} }
} }
if (! $error) if (!$error)
{ {
$db->commit(); $db->commit();
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid; $loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
@@ -153,18 +153,18 @@ if ($action == 'add_payment')
* View * View
*/ */
$form=new Form($db); $form = new Form($db);
llxHeader(); llxHeader();
$sql = "SELECT sum(p.amount) as total"; $sql = "SELECT sum(p.amount) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
$sql.= " WHERE p.fk_donation = ".$chid; $sql .= " WHERE p.fk_donation = ".$chid;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$obj=$db->fetch_object($resql); $obj = $db->fetch_object($resql);
$sumpaid = $obj->total; $sumpaid = $obj->total;
$db->free(); $db->free();
} }
@@ -191,7 +191,7 @@ if ($action == 'create')
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">'; print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaid):0; $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaid) : 0;
print $form->selectDate($datepayment, '', 0, 0, 0, "add_payment", 1, 1, 0, '', '', $object->date, '', 1, $langs->trans("DonationDate")); print $form->selectDate($datepayment, '', 0, 0, 0, "add_payment", 1, 1, 0, '', '', $object->date, '', 1, $langs->trans("DonationDate"));
print "</td>"; print "</td>";
print '</tr>'; print '</tr>';
@@ -204,7 +204,7 @@ if ($action == 'create')
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('AccountToCredit').'</td>'; print '<td class="fieldrequired">'.$langs->trans('AccountToCredit').'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
$form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid") : $object->accountid, "accountid", 0, '', 1); // Show open bank account list $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid") : $object->accountid, "accountid", 0, '', 1); // Show open bank account list
print '</td></tr>'; print '</td></tr>';
// Number // Number
@@ -238,8 +238,8 @@ if ($action == 'create')
print '<td class="center">'.$langs->trans("Amount").'</td>'; print '<td class="center">'.$langs->trans("Amount").'</td>';
print "</tr>\n"; print "</tr>\n";
$total=0; $total = 0;
$totalrecu=0; $totalrecu = 0;
while ($i < $num) while ($i < $num)
{ {

View File

@@ -32,17 +32,17 @@ class ExpenseReportIk extends CoreObject
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
public $element='expenseik'; public $element = 'expenseik';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element='expensereport_ik'; public $table_element = 'expensereport_ik';
/** /**
* @var int Field with ID of parent key if this field has a parent * @var int Field with ID of parent key if this field has a parent
*/ */
public $fk_element='fk_expense_ik'; public $fk_element = 'fk_expense_ik';
/** /**
* c_exp_tax_cat Id * c_exp_tax_cat Id
@@ -72,10 +72,10 @@ class ExpenseReportIk extends CoreObject
* Attribute object linked with database * Attribute object linked with database
* @var array * @var array
*/ */
public $fields=array( public $fields = array(
'rowid'=>array('type'=>'integer','index'=>true) 'rowid'=>array('type'=>'integer', 'index'=>true)
,'fk_c_exp_tax_cat'=>array('type'=>'integer','index'=>true) ,'fk_c_exp_tax_cat'=>array('type'=>'integer', 'index'=>true)
,'fk_range'=>array('type'=>'integer','index'=>true) ,'fk_range'=>array('type'=>'integer', 'index'=>true)
,'coef'=>array('type'=>'double') ,'coef'=>array('type'=>'double')
,'ikoffset'=>array('type'=>'double') ,'ikoffset'=>array('type'=>'double')
); );
@@ -109,10 +109,10 @@ class ExpenseReportIk extends CoreObject
$categories = array(); $categories = array();
$sql = 'SELECT rowid, label, entity, active'; $sql = 'SELECT rowid, label, entity, active';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat';
$sql.= ' WHERE entity IN ('. getEntity('c_exp_tax_cat').')'; $sql .= ' WHERE entity IN ('.getEntity('c_exp_tax_cat').')';
if ($mode == 1) $sql.= ' AND active = 1'; if ($mode == 1) $sql .= ' AND active = 1';
elseif ($mode == 2) $sql.= 'AND active = 0'; elseif ($mode == 2) $sql .= 'AND active = 0';
dol_syslog(get_called_class().'::getTaxCategories sql='.$sql, LOG_DEBUG); dol_syslog(get_called_class().'::getTaxCategories sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
@@ -144,8 +144,8 @@ class ExpenseReportIk extends CoreObject
$ranges = self::getRangesByCategory($fk_c_exp_tax_cat); $ranges = self::getRangesByCategory($fk_c_exp_tax_cat);
// substract 1 because array start from 0 // substract 1 because array start from 0
if (empty($ranges) || !isset($ranges[$default_range-1])) return false; if (empty($ranges) || !isset($ranges[$default_range - 1])) return false;
else return $ranges[$default_range-1]; else return $ranges[$default_range - 1];
} }
/** /**
@@ -162,10 +162,10 @@ class ExpenseReportIk extends CoreObject
$ranges = array(); $ranges = array();
$sql = 'SELECT r.rowid FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r'; $sql = 'SELECT r.rowid FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
if ($active) $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)'; if ($active) $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
$sql.= ' WHERE r.fk_c_exp_tax_cat = '.$fk_c_exp_tax_cat; $sql .= ' WHERE r.fk_c_exp_tax_cat = '.$fk_c_exp_tax_cat;
if ($active) $sql.= ' AND r.active = 1 AND c.active = 1'; if ($active) $sql .= ' AND r.active = 1 AND c.active = 1';
$sql.= ' ORDER BY r.range_ik'; $sql .= ' ORDER BY r.range_ik';
dol_syslog(get_called_class().'::getRangesByCategory sql='.$sql, LOG_DEBUG); dol_syslog(get_called_class().'::getRangesByCategory sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
@@ -203,11 +203,11 @@ class ExpenseReportIk extends CoreObject
$ranges = array(); $ranges = array();
$sql = ' SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, c.label, i.rowid as fk_expense_ik, r.active as range_active, c.active as cat_active'; $sql = ' SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, c.label, i.rowid as fk_expense_ik, r.active as range_active, c.active as cat_active';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport_ik i ON (r.rowid = i.fk_range)'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport_ik i ON (r.rowid = i.fk_range)';
$sql.= ' WHERE r.entity IN (0, '. getEntity('').')'; $sql .= ' WHERE r.entity IN (0, '.getEntity('').')';
$sql.= ' ORDER BY r.fk_c_exp_tax_cat, r.range_ik'; $sql .= ' ORDER BY r.fk_c_exp_tax_cat, r.range_ik';
dol_syslog(get_called_class().'::getAllRanges sql='.$sql, LOG_DEBUG); dol_syslog(get_called_class().'::getAllRanges sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
@@ -239,14 +239,14 @@ class ExpenseReportIk extends CoreObject
*/ */
public static function getMaxRangeNumber($default_c_exp_tax_cat = 0) public static function getMaxRangeNumber($default_c_exp_tax_cat = 0)
{ {
global $db,$conf; global $db, $conf;
$sql = 'SELECT MAX(counted) as nbRange FROM ('; $sql = 'SELECT MAX(counted) as nbRange FROM (';
$sql.= ' SELECT COUNT(*) as counted'; $sql .= ' SELECT COUNT(*) as counted';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
$sql.= ' WHERE r.entity IN (0, '.$conf->entity.')'; $sql .= ' WHERE r.entity IN (0, '.$conf->entity.')';
if ($default_c_exp_tax_cat > 0) $sql .= ' AND r.fk_c_exp_tax_cat = '.$default_c_exp_tax_cat; if ($default_c_exp_tax_cat > 0) $sql .= ' AND r.fk_c_exp_tax_cat = '.$default_c_exp_tax_cat;
$sql.= ' GROUP BY r.fk_c_exp_tax_cat'; $sql .= ' GROUP BY r.fk_c_exp_tax_cat';
$sql .= ') as counts'; $sql .= ') as counts';
dol_syslog(get_called_class().'::getMaxRangeNumber sql='.$sql, LOG_DEBUG); dol_syslog(get_called_class().'::getMaxRangeNumber sql='.$sql, LOG_DEBUG);

View File

@@ -32,17 +32,17 @@ class ExpenseReportRule extends CoreObject
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
public $element='expenserule'; public $element = 'expenserule';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element='expensereport_rules'; public $table_element = 'expensereport_rules';
/** /**
* @var int Field with ID of parent key if this field has a parent * @var int Field with ID of parent key if this field has a parent
*/ */
public $fk_element='fk_expense_rule'; public $fk_element = 'fk_expense_rule';
/** /**
* date start * date start
@@ -111,8 +111,8 @@ class ExpenseReportRule extends CoreObject
* Attribute object linked with database * Attribute object linked with database
* @var array * @var array
*/ */
public $fields=array( public $fields = array(
'rowid'=>array('type'=>'integer','index'=>true) 'rowid'=>array('type'=>'integer', 'index'=>true)
,'dates'=>array('type'=>'date') ,'dates'=>array('type'=>'date')
,'datee'=>array('type'=>'date') ,'datee'=>array('type'=>'date')
,'amount'=>array('type'=>'double') ,'amount'=>array('type'=>'double')
@@ -154,25 +154,25 @@ class ExpenseReportRule extends CoreObject
$rules = array(); $rules = array();
$sql = 'SELECT er.rowid'; $sql = 'SELECT er.rowid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_rules er'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_rules er';
$sql.= ' WHERE er.entity IN (0,'. getEntity('').')'; $sql .= ' WHERE er.entity IN (0,'.getEntity('').')';
if (!empty($fk_c_type_fees)) if (!empty($fk_c_type_fees))
{ {
$sql.= ' AND er.fk_c_type_fees IN (-1, '.$fk_c_type_fees.')'; $sql .= ' AND er.fk_c_type_fees IN (-1, '.$fk_c_type_fees.')';
} }
if (!empty($date)) if (!empty($date))
{ {
$date = dol_print_date($date, '%Y-%m-%d'); $date = dol_print_date($date, '%Y-%m-%d');
$sql.= ' AND er.dates <= \''.$date.'\''; $sql .= ' AND er.dates <= \''.$date.'\'';
$sql.= ' AND er.datee >= \''.$date.'\''; $sql .= ' AND er.datee >= \''.$date.'\'';
} }
if ($fk_user > 0) if ($fk_user > 0)
{ {
$sql.= ' AND (er.is_for_all = 1'; $sql .= ' AND (er.is_for_all = 1';
$sql.= ' OR er.fk_user = '.$fk_user; $sql .= ' OR er.fk_user = '.$fk_user;
$sql.= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.$fk_user.') )'; $sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.$fk_user.') )';
} }
$sql.= ' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user'; $sql .= ' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user';
dol_syslog("ExpenseReportRule::getAllRule sql=".$sql); dol_syslog("ExpenseReportRule::getAllRule sql=".$sql);

View File

@@ -411,7 +411,7 @@ if ($step == 4 && $action == 'submitFormField')
$newcode = (string) preg_replace('/\./', '_', $code); $newcode = (string) preg_replace('/\./', '_', $code);
//print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n<br>"; //print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n<br>";
$filterqualified = 1; $filterqualified = 1;
if (! GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') $filterqualified = 0; if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') $filterqualified = 0;
elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) $filterqualified = 0; elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) $filterqualified = 0;
if ($filterqualified) if ($filterqualified)
{ {

View File

@@ -18,19 +18,19 @@ dol_include_once("/mymodule/class/myobject.class.php");
class mailing_mailinglist_mymodule_myobject extends MailingTargets class mailing_mailinglist_mymodule_myobject extends MailingTargets
{ {
// CHANGE THIS: Put here a name not already used // CHANGE THIS: Put here a name not already used
public $name='mailinglist_mymodule_myobject'; public $name = 'mailinglist_mymodule_myobject';
// CHANGE THIS: Put here a description of your selector module // CHANGE THIS: Put here a description of your selector module
public $desc='My object emailing target selector'; public $desc = 'My object emailing target selector';
// CHANGE THIS: Set to 1 if selector is available for admin users only // CHANGE THIS: Set to 1 if selector is available for admin users only
public $require_admin=0; public $require_admin = 0;
public $enabled=0; public $enabled = 0;
public $require_module=array(); public $require_module = array();
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/ */
public $picto='mymodule@mymodule'; public $picto = 'mymodule@mymodule';
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
@@ -47,10 +47,10 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
{ {
global $conf; global $conf;
$this->db=$db; $this->db = $db;
if (is_array($conf->modules)) if (is_array($conf->modules))
{ {
$this->enabled=in_array('mymodule', $conf->modules)?1:0; $this->enabled = in_array('mymodule', $conf->modules) ? 1 : 0;
} }
} }
@@ -65,20 +65,20 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
global $langs; global $langs;
$langs->load("members"); $langs->load("members");
$form=new Form($this->db); $form = new Form($this->db);
$arraystatus=array(1=>'Option 1', 2=>'Option 2'); $arraystatus = array(1=>'Option 1', 2=>'Option 2');
$s=''; $s = '';
$s.=$langs->trans("Status").': '; $s .= $langs->trans("Status").': ';
$s.='<select name="filter" class="flat">'; $s .= '<select name="filter" class="flat">';
$s.='<option value="none">&nbsp;</option>'; $s .= '<option value="none">&nbsp;</option>';
foreach($arraystatus as $status) foreach ($arraystatus as $status)
{ {
$s.='<option value="'.$status.'">'.$status.'</option>'; $s .= '<option value="'.$status.'">'.$status.'</option>';
} }
$s.='</select>'; $s .= '</select>';
$s.='<br>'; $s .= '<br>';
return $s; return $s;
} }
@@ -110,13 +110,13 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
$j = 0; $j = 0;
$sql = " select rowid as id, email, firstname, lastname, plan, partner"; $sql = " select rowid as id, email, firstname, lastname, plan, partner";
$sql.= " from ".MAIN_DB_PREFIX."myobject"; $sql .= " from ".MAIN_DB_PREFIX."myobject";
$sql.= " where email IS NOT NULL AND email != ''"; $sql .= " where email IS NOT NULL AND email != ''";
if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql.= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'"; if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'";
$sql.= " ORDER BY email"; $sql .= " ORDER BY email";
// Stocke destinataires dans target // Stocke destinataires dans target
$result=$this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
@@ -150,7 +150,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
else else
{ {
dol_syslog($this->db->error()); dol_syslog($this->db->error());
$this->error=$this->db->error(); $this->error = $this->db->error();
return -1; return -1;
} }
@@ -197,7 +197,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
*/ */
public function getNbOfRecipients($filter = 1, $option = '') public function getNbOfRecipients($filter = 1, $option = '')
{ {
$a=parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); $a = parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''");
if ($a < 0) return -1; if ($a < 0) return -1;
return $a; return $a;

View File

@@ -63,9 +63,9 @@ if ($action == 'edit_updater') {
if (!empty($action) && empty($cancel)) { if (!empty($action) && empty($cancel)) {
//Global variable actions //Global variable actions
if ($action == 'create_variable' || $action == 'edit_variable') { if ($action == 'create_variable' || $action == 'edit_variable') {
$price_globals->code = GETPOSTISSET('code')?GETPOST('code', 'alpha'):$price_globals->code; $price_globals->code = GETPOSTISSET('code') ?GETPOST('code', 'alpha') : $price_globals->code;
$price_globals->description = GETPOSTISSET('description')?GETPOST('description', 'alpha'):$price_globals->description; $price_globals->description = GETPOSTISSET('description') ?GETPOST('description', 'alpha') : $price_globals->description;
$price_globals->value = GETPOSTISSET('value')?GETPOST('value', 'int'):$price_globals->value; $price_globals->value = GETPOSTISSET('value') ?GETPOST('value', 'int') : $price_globals->value;
//Check if record already exists only when saving //Check if record already exists only when saving
if (!empty($save)) { if (!empty($save)) {
foreach ($price_globals->listGlobalVariables() as $entry) { foreach ($price_globals->listGlobalVariables() as $entry) {
@@ -101,11 +101,11 @@ if (!empty($action) && empty($cancel)) {
//Updaters actions //Updaters actions
if ($action == 'create_updater' || $action == 'edit_updater') { if ($action == 'create_updater' || $action == 'edit_updater') {
$price_updaters->type = GETPOSTISSET('type')?GETPOST('type', 'int'):$price_updaters->type; $price_updaters->type = GETPOSTISSET('type') ?GETPOST('type', 'int') : $price_updaters->type;
$price_updaters->description = GETPOSTISSET('description')?GETPOST('description', 'alpha'):$price_updaters->description; $price_updaters->description = GETPOSTISSET('description') ?GETPOST('description', 'alpha') : $price_updaters->description;
$price_updaters->parameters = GETPOSTISSET('parameters')?GETPOST('parameters'):$price_updaters->parameters; $price_updaters->parameters = GETPOSTISSET('parameters') ?GETPOST('parameters') : $price_updaters->parameters;
$price_updaters->fk_variable = GETPOSTISSET('fk_variable')?GETPOST('fk_variable', 'int'):$price_updaters->fk_variable; $price_updaters->fk_variable = GETPOSTISSET('fk_variable') ?GETPOST('fk_variable', 'int') : $price_updaters->fk_variable;
$price_updaters->update_interval = GETPOSTISSET('update_interval')?GETPOST('update_interval', 'int'):$price_updaters->update_interval; $price_updaters->update_interval = GETPOSTISSET('update_interval') ?GETPOST('update_interval', 'int') : $price_updaters->update_interval;
} }
if ($action == 'create_updater' && !empty($save)) { if ($action == 'create_updater' && !empty($save)) {
//Verify if process() works //Verify if process() works
@@ -150,7 +150,7 @@ $form = new Form($db);
llxHeader("", "", $langs->trans("CardProduct".$product->type)); llxHeader("", "", $langs->trans("CardProduct".$product->type));
$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("DynamicPriceConfiguration"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("DynamicPriceConfiguration"), $linkback, 'title_setup');
print '<span class="opacitymedium">'.$langs->trans("DynamicPriceDesc").'</span><br>'; print '<span class="opacitymedium">'.$langs->trans("DynamicPriceDesc").'</span><br>';
@@ -169,8 +169,8 @@ if ($action != 'create_updater' && $action != 'edit_updater')
print '<td width="80">&nbsp;</td>'; //Space for buttons print '<td width="80">&nbsp;</td>'; //Space for buttons
print '</tr>'; print '</tr>';
$arrayglobalvars=$price_globals->listGlobalVariables(); $arrayglobalvars = $price_globals->listGlobalVariables();
if (! empty($arrayglobalvars)) if (!empty($arrayglobalvars))
{ {
foreach ($arrayglobalvars as $i=>$entry) { foreach ($arrayglobalvars as $i=>$entry) {
$var = !$var; $var = !$var;
@@ -215,17 +215,17 @@ if ($action == 'create_variable' || $action == 'edit_variable') {
//Code //Code
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Variable").'</td>'; print '<td class="fieldrequired">'.$langs->trans("Variable").'</td>';
print '<td class="valeur"><input type="text" name="code" size="20" value="'.(empty($price_globals->code)?'':$price_globals->code).'"></td>'; print '<td class="valeur"><input type="text" name="code" size="20" value="'.(empty($price_globals->code) ? '' : $price_globals->code).'"></td>';
print '</tr>'; print '</tr>';
//Description //Description
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td class="valeur"><input type="text" name="description" size="50" value="'.(empty($price_globals->description)?'':$price_globals->description).'"></td>'; print '<td class="valeur"><input type="text" name="description" size="50" value="'.(empty($price_globals->description) ? '' : $price_globals->description).'"></td>';
print '</tr>'; print '</tr>';
//Value //Value
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Value").'</td>'; print '<td class="fieldrequired">'.$langs->trans("Value").'</td>';
print '<td class="valeur"><input type="text" name="value" size="10" value="'.(empty($price_globals->value)?'':$price_globals->value).'"></td>'; print '<td class="valeur"><input type="text" name="value" size="10" value="'.(empty($price_globals->value) ? '' : $price_globals->value).'"></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
@@ -254,7 +254,7 @@ if ($action != 'create_variable' && $action != 'edit_variable')
print '</tr>'; print '</tr>';
$arraypriceupdaters = $price_updaters->listUpdaters(); $arraypriceupdaters = $price_updaters->listUpdaters();
if (! empty($arraypriceupdaters)) if (!empty($arraypriceupdaters))
{ {
foreach ($arraypriceupdaters as $i=>$entry) { foreach ($arraypriceupdaters as $i=>$entry) {
$code = ""; $code = "";
@@ -308,19 +308,19 @@ if ($action == 'create_updater' || $action == 'edit_updater') {
print '<td class="fieldrequired">'.$langs->trans("VariableToUpdate").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("VariableToUpdate").'</td><td>';
$globals_list = array(); $globals_list = array();
foreach ($price_globals->listGlobalVariables() as $entry) { foreach ($price_globals->listGlobalVariables() as $entry) {
$globals_list[$entry->id]=$entry->code; $globals_list[$entry->id] = $entry->code;
} }
print $form->selectarray('fk_variable', $globals_list, (empty($price_updaters->fk_variable)?0:$price_updaters->fk_variable)); print $form->selectarray('fk_variable', $globals_list, (empty($price_updaters->fk_variable) ? 0 : $price_updaters->fk_variable));
print '</td></tr>'; print '</td></tr>';
//Description //Description
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td class="valeur"><input type="text" name="description" size="50" value="'.(empty($price_updaters->description)?'':$price_updaters->description).'"></td>'; print '<td class="valeur"><input type="text" name="description" size="50" value="'.(empty($price_updaters->description) ? '' : $price_updaters->description).'"></td>';
print '</tr>'; print '</tr>';
//Type //Type
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
$type = empty($price_updaters->type)?0:$price_updaters->type; $type = empty($price_updaters->type) ? 0 : $price_updaters->type;
$type_list = array(); $type_list = array();
foreach ($price_updaters->types as $val) { foreach ($price_updaters->types as $val) {
$type_list[$val] = $langs->trans("GlobalVariableUpdaterType".$val); $type_list[$val] = $langs->trans("GlobalVariableUpdaterType".$val);
@@ -342,14 +342,14 @@ if ($action == 'create_updater' || $action == 'edit_updater') {
$help = $langs->trans("GlobalVariableUpdaterHelp".$type).'<br><b>'.$langs->trans("GlobalVariableUpdaterHelpFormat".$type).'</b>'; $help = $langs->trans("GlobalVariableUpdaterHelp".$type).'<br><b>'.$langs->trans("GlobalVariableUpdaterHelpFormat".$type).'</b>';
print '<td class="fieldrequired">'.$form->textwithpicto($langs->trans("Parameters"), $help, 1).'</td><td>'; print '<td class="fieldrequired">'.$form->textwithpicto($langs->trans("Parameters"), $help, 1).'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('parameters', empty($price_updaters->parameters)?'':$price_updaters->parameters, '', 300, '', '', false, false, false, ROWS_8, '90%'); $doleditor = new DolEditor('parameters', empty($price_updaters->parameters) ? '' : $price_updaters->parameters, '', 300, '', '', false, false, false, ROWS_8, '90%');
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
print '</tr>'; print '</tr>';
//Interval //Interval
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("UpdateInterval").'</td>'; print '<td class="fieldrequired">'.$langs->trans("UpdateInterval").'</td>';
print '<td class="valeur"><input type="text" name="update_interval" size="10" value="'.(empty($price_updaters->update_interval)?'':$price_updaters->update_interval).'"></td>'; print '<td class="valeur"><input type="text" name="update_interval" size="10" value="'.(empty($price_updaters->update_interval) ? '' : $price_updaters->update_interval).'"></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';

View File

@@ -34,22 +34,22 @@ class Propalmergepdfproduct extends CommonObject
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
public $element='propal_merge_pdf_product'; public $element = 'propal_merge_pdf_product';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element='propal_merge_pdf_product'; public $table_element = 'propal_merge_pdf_product';
public $fk_product; public $fk_product;
public $file_name; public $file_name;
public $fk_user_author; public $fk_user_author;
public $fk_user_mod; public $fk_user_mod;
public $datec=''; public $datec = '';
public $tms=''; public $tms = '';
public $lang; public $lang;
public $lines=array(); public $lines = array();
@@ -75,16 +75,16 @@ class Propalmergepdfproduct extends CommonObject
public function create($user, $notrigger = 0) public function create($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product); if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product);
if (isset($this->file_name)) $this->file_name=trim($this->file_name); if (isset($this->file_name)) $this->file_name = trim($this->file_name);
if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author);
if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod); if (isset($this->fk_user_mod)) $this->fk_user_mod = trim($this->fk_user_mod);
if (isset($this->lang)) $this->lang=trim($this->lang); if (isset($this->lang)) $this->lang = trim($this->lang);
if (isset($this->import_key)) $this->import_key=trim($this->import_key); if (isset($this->import_key)) $this->import_key = trim($this->import_key);
@@ -94,41 +94,41 @@ class Propalmergepdfproduct extends CommonObject
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_merge_pdf_product("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_merge_pdf_product(";
$sql.= "fk_product,"; $sql .= "fk_product,";
$sql.= "file_name,"; $sql .= "file_name,";
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$sql.= "lang,"; $sql .= "lang,";
} }
$sql.= "fk_user_author,"; $sql .= "fk_user_author,";
$sql.= "fk_user_mod,"; $sql .= "fk_user_mod,";
$sql.= "datec"; $sql .= "datec";
$sql.= ") VALUES ("; $sql .= ") VALUES (";
$sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->db->escape($this->fk_product)."'").","; $sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").",";
$sql.= " ".(! isset($this->file_name)?'NULL':"'".$this->db->escape($this->file_name)."'").","; $sql .= " ".(!isset($this->file_name) ? 'NULL' : "'".$this->db->escape($this->file_name)."'").",";
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$sql.= " ".(! isset($this->lang)?'NULL':"'".$this->db->escape($this->lang)."'").","; $sql .= " ".(!isset($this->lang) ? 'NULL' : "'".$this->db->escape($this->lang)."'").",";
} }
$sql.= " ".$user->id.","; $sql .= " ".$user->id.",";
$sql.= " ".$user->id.","; $sql .= " ".$user->id.",";
$sql.= " '".$this->db->idate(dol_now())."'"; $sql .= " '".$this->db->idate(dol_now())."'";
$sql.= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (! $error) if (!$error)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product");
if (! $notrigger) if (!$notrigger)
{ {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger. // want this action calls a trigger.
@@ -145,13 +145,13 @@ class Propalmergepdfproduct extends CommonObject
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
foreach($this->errors as $errmsg) foreach ($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1 * $error;
} }
else else
{ {
@@ -169,33 +169,33 @@ class Propalmergepdfproduct extends CommonObject
*/ */
public function fetch($id) public function fetch($id)
{ {
global $langs,$conf; global $langs, $conf;
$sql = "SELECT"; $sql = "SELECT";
$sql.= " t.rowid,"; $sql .= " t.rowid,";
$sql.= " t.fk_product,"; $sql .= " t.fk_product,";
$sql.= " t.file_name,"; $sql .= " t.file_name,";
$sql.= " t.lang,"; $sql .= " t.lang,";
$sql.= " t.fk_user_author,"; $sql .= " t.fk_user_author,";
$sql.= " t.fk_user_mod,"; $sql .= " t.fk_user_mod,";
$sql.= " t.datec,"; $sql .= " t.datec,";
$sql.= " t.tms,"; $sql .= " t.tms,";
$sql.= " t.import_key"; $sql .= " t.import_key";
$sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t"; $sql .= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
$sql.= " WHERE t.rowid = ".$id; $sql .= " WHERE t.rowid = ".$id;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($this->db->num_rows($resql)) if ($this->db->num_rows($resql))
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->fk_product = $obj->fk_product; $this->fk_product = $obj->fk_product;
$this->file_name = $obj->file_name; $this->file_name = $obj->file_name;
@@ -214,7 +214,7 @@ class Propalmergepdfproduct extends CommonObject
} }
else else
{ {
$this->error="Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1; return -1;
} }
@@ -231,37 +231,37 @@ class Propalmergepdfproduct extends CommonObject
public function fetch_by_product($product_id, $lang = '') public function fetch_by_product($product_id, $lang = '')
{ {
// phpcs:enable // phpcs:enable
global $langs,$conf; global $langs, $conf;
$sql = "SELECT"; $sql = "SELECT";
$sql.= " t.rowid,"; $sql .= " t.rowid,";
$sql.= " t.fk_product,"; $sql .= " t.fk_product,";
$sql.= " t.file_name,"; $sql .= " t.file_name,";
$sql.= " t.lang,"; $sql .= " t.lang,";
$sql.= " t.fk_user_author,"; $sql .= " t.fk_user_author,";
$sql.= " t.fk_user_mod,"; $sql .= " t.fk_user_mod,";
$sql.= " t.datec,"; $sql .= " t.datec,";
$sql.= " t.tms,"; $sql .= " t.tms,";
$sql.= " t.import_key"; $sql .= " t.import_key";
$sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t"; $sql .= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
$sql.= " WHERE t.fk_product = ".$product_id; $sql .= " WHERE t.fk_product = ".$product_id;
if ($conf->global->MAIN_MULTILANGS && !empty($lang)) { if ($conf->global->MAIN_MULTILANGS && !empty($lang)) {
$sql.= " AND t.lang = '".$lang."'"; $sql .= " AND t.lang = '".$lang."'";
} }
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($this->db->num_rows($resql)) if ($this->db->num_rows($resql))
{ {
while($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$line = new PropalmergepdfproductLine(); $line = new PropalmergepdfproductLine();
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->fk_product = $obj->fk_product; $line->fk_product = $obj->fk_product;
$line->file_name = $obj->file_name; $line->file_name = $obj->file_name;
@@ -276,9 +276,9 @@ class Propalmergepdfproduct extends CommonObject
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$this->lines[$obj->file_name.'_'.$obj->lang]=$line; $this->lines[$obj->file_name.'_'.$obj->lang] = $line;
}else { } else {
$this->lines[$obj->file_name]=$line; $this->lines[$obj->file_name] = $line;
} }
} }
} }
@@ -288,7 +288,7 @@ class Propalmergepdfproduct extends CommonObject
} }
else else
{ {
$this->error="Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR);
return -1; return -1;
} }
@@ -305,14 +305,14 @@ class Propalmergepdfproduct extends CommonObject
public function update($user = 0, $notrigger = 0) public function update($user = 0, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product); if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product);
if (isset($this->file_name)) $this->file_name=trim($this->file_name); if (isset($this->file_name)) $this->file_name = trim($this->file_name);
if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod); if (isset($this->fk_user_mod)) $this->fk_user_mod = trim($this->fk_user_mod);
if (isset($this->lang)) $this->lang=trim($this->lang); if (isset($this->lang)) $this->lang = trim($this->lang);
// Check parameters // Check parameters
// Put here code to add a control on parameters values // Put here code to add a control on parameters values
@@ -320,21 +320,21 @@ class Propalmergepdfproduct extends CommonObject
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."propal_merge_pdf_product SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal_merge_pdf_product SET";
$sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null").","; $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").",";
$sql.= " file_name=".(isset($this->file_name)?"'".$this->db->escape($this->file_name)."'":"null").","; $sql .= " file_name=".(isset($this->file_name) ? "'".$this->db->escape($this->file_name)."'" : "null").",";
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$sql.= " lang=".(isset($this->lang)?"'".$this->db->escape($this->lang)."'":"null").","; $sql .= " lang=".(isset($this->lang) ? "'".$this->db->escape($this->lang)."'" : "null").",";
} }
$sql.= " fk_user_mod=".$user->id; $sql .= " fk_user_mod=".$user->id;
$sql.= " WHERE rowid=".$this->id; $sql .= " WHERE rowid=".$this->id;
$this->db->begin(); $this->db->begin();
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
//if (! $error) //if (! $error)
//{ //{
@@ -355,13 +355,13 @@ class Propalmergepdfproduct extends CommonObject
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
foreach($this->errors as $errmsg) foreach ($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1 * $error;
} }
else else
{ {
@@ -381,13 +381,13 @@ class Propalmergepdfproduct extends CommonObject
public function delete($user, $notrigger = 0) public function delete($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error = 0;
$this->db->begin(); $this->db->begin();
if (! $error) if (!$error)
{ {
if (! $notrigger) if (!$notrigger)
{ {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger. // want this action calls a trigger.
@@ -401,26 +401,26 @@ class Propalmergepdfproduct extends CommonObject
} }
} }
if (! $error) if (!$error)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
$sql.= " WHERE rowid=".$this->id; $sql .= " WHERE rowid=".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
} }
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
foreach($this->errors as $errmsg) foreach ($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1 * $error;
} }
else else
{ {
@@ -443,7 +443,7 @@ class Propalmergepdfproduct extends CommonObject
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
$error=0; $error = 0;
$this->db->begin(); $this->db->begin();
@@ -463,30 +463,30 @@ class Propalmergepdfproduct extends CommonObject
// } // }
//} //}
if (! $error) if (!$error)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
$sql.= " WHERE fk_product=".$product_id; $sql .= " WHERE fk_product=".$product_id;
if ($conf->global->MAIN_MULTILANGS && !empty($lang_id)) { if ($conf->global->MAIN_MULTILANGS && !empty($lang_id)) {
$sql.= " AND lang='".$lang_id."'"; $sql .= " AND lang='".$lang_id."'";
} }
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
} }
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
foreach($this->errors as $errmsg) foreach ($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1 * $error;
} }
else else
{ {
@@ -506,7 +506,7 @@ class Propalmergepdfproduct extends CommonObject
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
$error=0; $error = 0;
$this->db->begin(); $this->db->begin();
@@ -526,26 +526,26 @@ class Propalmergepdfproduct extends CommonObject
// } // }
//} //}
if (! $error) if (!$error)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
$sql.= " WHERE fk_product=".$this->fk_product." AND file_name='".$this->db->escape($this->file_name)."'"; $sql .= " WHERE fk_product=".$this->fk_product." AND file_name='".$this->db->escape($this->file_name)."'";
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
} }
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
foreach($this->errors as $errmsg) foreach ($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1 * $error;
} }
else else
{ {
@@ -565,40 +565,40 @@ class Propalmergepdfproduct extends CommonObject
*/ */
public function createFromClone(User $user, $fromid) public function createFromClone(User $user, $fromid)
{ {
$error=0; $error = 0;
$object=new Propalmergepdfproduct($this->db); $object = new Propalmergepdfproduct($this->db);
$this->db->begin(); $this->db->begin();
// Load source object // Load source object
$object->fetch($fromid); $object->fetch($fromid);
$object->id=0; $object->id = 0;
$object->statut=0; $object->statut = 0;
// Clear fields // Clear fields
// ... // ...
// Create clone // Create clone
$object->context['createfromclone']='createfromclone'; $object->context['createfromclone'] = 'createfromclone';
$result=$object->create($user); $result = $object->create($user);
// Other options // Other options
if ($result < 0) if ($result < 0)
{ {
$this->error=$object->error; $this->error = $object->error;
$this->errors=array_merge($this->errors, $object->errors); $this->errors = array_merge($this->errors, $object->errors);
$error++; $error++;
} }
if (! $error) if (!$error)
{ {
} }
unset($object->context['createfromclone']); unset($object->context['createfromclone']);
// End // End
if (! $error) if (!$error)
{ {
$this->db->commit(); $this->db->commit();
return $object->id; return $object->id;
@@ -619,15 +619,15 @@ class Propalmergepdfproduct extends CommonObject
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
$this->id=0; $this->id = 0;
$this->fk_product=''; $this->fk_product = '';
$this->file_name=''; $this->file_name = '';
$this->fk_user_author=''; $this->fk_user_author = '';
$this->fk_user_mod=''; $this->fk_user_mod = '';
$this->datec=''; $this->datec = '';
$this->tms=''; $this->tms = '';
$this->import_key=''; $this->import_key = '';
} }
} }
@@ -659,8 +659,8 @@ class PropalmergepdfproductLine
*/ */
public $fk_user_mod; public $fk_user_mod;
public $datec=''; public $datec = '';
public $tms=''; public $tms = '';
public $import_key; public $import_key;
/** /**

View File

@@ -16,12 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable token renewal if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
require '../../main.inc.php'; require '../../main.inc.php';
@@ -34,7 +34,7 @@ top_httphead();
// Registering the location of boxes // Registering the location of boxes
if (GETPOSTISSET('roworder')) { if (GETPOSTISSET('roworder')) {
$roworder=GETPOST('roworder', 'alpha', 2); $roworder = GETPOST('roworder', 'alpha', 2);
dol_syslog("AjaxOrderAttribute roworder=".$roworder, LOG_DEBUG); dol_syslog("AjaxOrderAttribute roworder=".$roworder, LOG_DEBUG);