diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php
index da23d3cc33b..2ed3ad44695 100644
--- a/htdocs/accountancy/admin/accountmodel.php
+++ b/htdocs/accountancy/admin/accountmodel.php
@@ -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/class/doleditor.class.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
-$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';
-$confirm=GETPOST('confirm', 'alpha');
-$id=31;
-$rowid=GETPOST('rowid', 'alpha');
-$code=GETPOST('code', 'alpha');
+$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
+$confirm = GETPOST('confirm', 'alpha');
+$id = 31;
+$rowid = GETPOST('rowid', 'alpha');
+$code = GETPOST('code', 'alpha');
$acts[0] = "activate";
$acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
-$listoffset=GETPOST('listoffset', 'alpha');
-$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000;
+$listoffset = GETPOST('listoffset', 'alpha');
+$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
$active = 1;
$sortfield = GETPOST("sortfield", 'aZ09comma');
$sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
-$offset = $listlimit * $page ;
+$offset = $listlimit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -72,7 +72,7 @@ $search_country_id = GETPOST('search_country_id', 'int');
// Security check
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
@@ -82,56 +82,56 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// 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
-$tablib=array();
-$tablib[31]= "Pcg_version";
+$tablib = array();
+$tablib[31] = "Pcg_version";
// Requests to extract data
-$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 = 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";
// Criteria to sort dictionaries
-$tabsqlsort=array();
-$tabsqlsort[31]="pcg_version ASC";
+$tabsqlsort = array();
+$tabsqlsort[31] = "pcg_version ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
-$tabfield=array();
-$tabfield[31]= "pcg_version,label,country_id,country";
+$tabfield = array();
+$tabfield[31] = "pcg_version,label,country_id,country";
// Nom des champs d'edition pour modification d'un enregistrement
-$tabfieldvalue=array();
-$tabfieldvalue[31]= "pcg_version,label,country";
+$tabfieldvalue = array();
+$tabfieldvalue[31] = "pcg_version,label,country";
// Nom des champs dans la table pour insertion d'un enregistrement
-$tabfieldinsert=array();
-$tabfieldinsert[31]= "pcg_version,label,fk_country";
+$tabfieldinsert = array();
+$tabfieldinsert[31] = "pcg_version,label,fk_country";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on
-$tabrowid=array();
-$tabrowid[31]= "";
+$tabrowid = array();
+$tabrowid[31] = "";
// Condition to show dictionary in setup page
-$tabcond=array();
-$tabcond[31]= ! empty($conf->accounting->enabled);
+$tabcond = array();
+$tabcond[31] = !empty($conf->accounting->enabled);
// List of help for fields
-$tabhelp=array();
+$tabhelp = array();
$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET)
-$tabfieldcheck=array();
+$tabfieldcheck = array();
$tabfieldcheck[31] = array();
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$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
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{
- $listfield=explode(',', str_replace(' ', '', $tabfield[$id]));
- $listfieldinsert=explode(',', $tabfieldinsert[$id]);
- $listfieldmodify=explode(',', $tabfieldinsert[$id]);
- $listfieldvalue=explode(',', $tabfieldvalue[$id]);
+ $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
+ $listfieldinsert = explode(',', $tabfieldinsert[$id]);
+ $listfieldmodify = explode(',', $tabfieldinsert[$id]);
+ $listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled
- $ok=1;
+ $ok = 1;
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 ((! GETPOSTISSET($value)) || GETPOST($value) == '')
+ if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory
+ if ((!GETPOSTISSET($value)) || GETPOST($value) == '')
{
- $ok=0;
- $fieldnamekey=$listfield[$f];
+ $ok = 0;
+ $fieldnamekey = $listfield[$f];
// We take translate key of field
- if ($fieldnamekey == 'pcg_version') $fieldnamekey='Pcg_version';
- if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
+ if ($fieldnamekey == 'pcg_version') $fieldnamekey = 'Pcg_version';
+ if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
}
// Other checks
- if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array($_POST["type"], array('system','systemauto'))) {
- $ok=0;
+ if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array($_POST["type"], array('system', 'systemauto'))) {
+ $ok = 0;
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
}
if (GETPOSTISSET("pcg_version"))
{
if (GETPOST("pcg_version") == '0')
{
- $ok=0;
+ $ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
/*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')).'
';
}*/
}
- 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');
}
@@ -199,13 +199,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
- $newid=0;
+ $newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
- $newid=($obj->newid + 1);
+ $newid = ($obj->newid + 1);
} else {
dol_print_error($db);
}
@@ -214,16 +214,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
- if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
- $sql.= $tabrowid[$id].",";
- $sql.= $tabfieldinsert[$id];
- $sql.=",active)";
- $sql.= " VALUES(";
+ if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
+ $sql .= $tabrowid[$id].",";
+ $sql .= $tabfieldinsert[$id];
+ $sql .= ",active)";
+ $sql .= " VALUES(";
// List of values
- if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
- $sql.= $newid.",";
- $i=0;
+ if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
+ $sql .= $newid.",";
+ $i = 0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') {
@@ -232,19 +232,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
- if ($i) $sql.=",";
- if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
- else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+ if ($i) $sql .= ",";
+ if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
+ else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
- $sql.=",1)";
+ $sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
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
{
@@ -260,16 +260,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha'))
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
+ else { $rowidcol = "rowid"; }
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
- if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
+ if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{
- $sql.= $tabrowid[$id]."=";
- $sql.= "'".$db->escape($rowid)."', ";
+ $sql .= $tabrowid[$id]."=";
+ $sql .= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
@@ -280,18 +280,18 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
- if ($i) $sql.=",";
- $sql.= $field."=";
- if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
- else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+ if ($i) $sql .= ",";
+ $sql .= $field."=";
+ if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
+ else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
- $sql.= " WHERE ".$rowidcol." = '".$rowid."'";
+ $sql .= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
- if (! $resql)
+ if (!$resql)
{
setEventMessages($db->error(), null, 'errors');
}
@@ -306,14 +306,14 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
+ else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
- if (! $result)
+ if (!$result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
@@ -329,8 +329,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate
if ($action == $acts[0])
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
+ else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
@@ -349,8 +349,8 @@ if ($action == $acts[0])
// disable
if ($action == $acts[1])
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
+ else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
@@ -369,8 +369,8 @@ if ($action == $acts[1])
// favorite
if ($action == 'activate_favorite')
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
+ else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
@@ -389,8 +389,8 @@ if ($action == 'activate_favorite')
// disable favorite
if ($action == 'disable_favorite')
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
+ else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
@@ -412,12 +412,12 @@ if ($action == 'disable_favorite')
*/
$form = new Form($db);
-$formadmin=new FormAdmin($db);
+$formadmin = new FormAdmin($db);
llxHeader();
-$titre=$langs->trans($tablib[$id]);
-$linkback='';
+$titre = $langs->trans($tablib[$id]);
+$linkback = '';
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
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);
@@ -435,22 +435,22 @@ if ($action == 'delete')
if ($id)
{
// Complete requete recherche valeurs avec critere de tri
- $sql=$tabsql[$id];
+ $sql = $tabsql[$id];
if ($search_country_id > 0)
{
- if (preg_match('/ WHERE /', $sql)) $sql.= " AND ";
- else $sql.=" WHERE ";
- $sql.= " c.rowid = ".$search_country_id;
+ if (preg_match('/ WHERE /', $sql)) $sql .= " AND ";
+ else $sql .= " WHERE ";
+ $sql .= " c.rowid = ".$search_country_id;
}
// If sort order is "country", we use country_code instead
- if ($sortfield == 'country') $sortfield='country_code';
- $sql.=$db->order($sortfield, $sortorder);
- $sql.=$db->plimit($listlimit+1, $offset);
+ if ($sortfield == 'country') $sortfield = 'country_code';
+ $sql .= $db->order($sortfield, $sortorder);
+ $sql .= $db->plimit($listlimit + 1, $offset);
//print $sql;
- $fieldlist=explode(',', $tabfield[$id]);
+ $fieldlist = explode(',', $tabfield[$id]);
print '