diff --git a/htdocs/accountancy/admin/journals.php b/htdocs/accountancy/admin/journals.php
deleted file mode 100644
index 677f2a743e5..00000000000
--- a/htdocs/accountancy/admin/journals.php
+++ /dev/null
@@ -1,168 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * \file htdocs/accountancy/admin/journals.php
- * \ingroup Advanced accountancy
- * \brief Setup page to configure journals
- */
-require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
-
-$action = GETPOST('action');
-
-// Load variable for pagination
-$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
-$sortfield = GETPOST('sortfield','alpha');
-$sortorder = GETPOST('sortorder','alpha');
-$page = GETPOST('page','int');
-if ($page == -1) { $page = 0; }
-$offset = $limit * $page;
-$pageprev = $page - 1;
-$pagenext = $page + 1;
-if (! $sortfield) $sortfield="j.rowid"; // Set here default search field
-if (! $sortorder) $sortorder="ASC";
-
-$langs->load("admin");
-$langs->load("compta");
-$langs->load("accountancy");
-
-// Security check
-if ($user->societe_id > 0)
- accessforbidden();
-if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we shoul be able to see fiscal year.
- accessforbidden();
-
-$error = 0;
-
-// List of status
-/*
-static $tmptype2label = array (
- '0' => 'AccountingJournalTypeVariousOperation',
- '1' => 'AccountingJournalTypeSale',
- '2' => 'AccountingJournalTypePurchase',
- '3' => 'AccountingJournalTypeBank',
- '9' => 'AccountingJournalTypeHasNew'
-);
-$type2label = array (
- ''
-);
-foreach ( $tmptype2label as $key => $val )
- $type2label[$key] = $langs->trans($val);
-*/
-
-$errors = array ();
-
-$object = new AccountingJournal($db);
-
-
-/*
- * Actions
- */
-
-
-
-/*
- * View
- */
-$title = $langs->trans('AccountingJournals');
-$helpurl = "";
-llxHeader('', $title, $helpurl);
-
-$max = 100;
-$form = new Form($db);
-
-$linkback = '' . $langs->trans("BackToModuleList") . '';
-print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
-
-$head = admin_accounting_prepare_head(null);
-
-dol_fiche_head($head, 'journal', $langs->trans("Configuration"), -1, 'cron');
-
-$sql = "SELECT j.rowid, j.code, j.label, j.nature, j.active";
-$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_journal as j";
-// $sql .= " WHERE j.entity = " . $conf->entity;
-$sql.=$db->order($sortfield,$sortorder);
-
-// Count total nb of records
-$nbtotalofrecords = '';
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
-{
- $result = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($result);
-}
-
-$sql.= $db->plimit($limit+1, $offset);
-
-$result = $db->query($sql);
-if ($result) {
- $num = $db->num_rows($result);
-
- $i = 0;
-
- // $title = $langs->trans('AccountingJournals');
- // print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 1);
-
- // Load attribute_label
- print '
';
- print '';
- // print '| ' . $langs->trans("Ref") . ' | ';
- print '' . $langs->trans("Code") . ' | ';
- print '' . $langs->trans("Label") . ' | ';
- print '' . $langs->trans("Nature") . ' | ';
- print '
';
-
- if ($num) {
- $accountingjournalstatic = new AccountingJournal($db);
-
- while ( $i < $num && $i < $max ) {
- $obj = $db->fetch_object($result);
- $accountingjournalstatic->id = $obj->rowid;
- print '';
- print '| ' . img_object($langs->trans("ShowJournal"), "technic") . ' ' . $obj->code . ' | ';
- print '' . $obj->label . ' | ';
- print '' . $accountingjournalstatic->LibType($obj->nature, 0) . ' | ';
- print '
';
- $i ++;
- }
- } else {
- print '| ' . $langs->trans("None") . ' |
';
- }
- print '
';
-} else {
- dol_print_error($db);
-}
-
-dol_fiche_end();
-
-// Buttons
-print '';
-
-llxFooter();
-$db->close();
\ No newline at end of file
diff --git a/htdocs/accountancy/admin/journals_card.php b/htdocs/accountancy/admin/journals_card.php
deleted file mode 100644
index 9e04d75ce9f..00000000000
--- a/htdocs/accountancy/admin/journals_card.php
+++ /dev/null
@@ -1,294 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/accountancy/admin/journals_card.php
- * \ingroup Advanced accountancy
- * \brief Page to show an accounting journal
- */
-require '../../main.inc.php';
-
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
-
-$langs->load("admin");
-$langs->load("compta");
-$langs->load("accountancy");
-
-// Security check
-if ($user->societe_id > 0)
- accessforbidden();
-if (empty($user->rights->accounting->fiscalyear))
- accessforbidden();
-
-$error = 0;
-
-$action = GETPOST('action', 'alpha');
-$confirm = GETPOST('confirm', 'alpha');
-$id = GETPOST('id', 'int');
-
-// List of status
-static $tmptype2label = array (
- '0' => 'AccountingJournalTypeVariousOperation',
- '1' => 'AccountingJournalTypeSale',
- '2' => 'AccountingJournalTypePurchase',
- '3' => 'AccountingJournalTypeBank',
- '9' => 'AccountingJournalTypeHasNew'
-);
-$type2label = array (
- ''
-);
-foreach ( $tmptype2label as $key => $val )
- $type2label[$key] = $langs->trans($val);
-
-$object = new AccountingJournal($db);
-
-/*
- * Actions
- */
-
-if ($action == 'confirm_delete' && $confirm == "yes") {
- $result = $object->delete($id);
- if ($result >= 0) {
- header("Location: journals.php");
- exit();
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- }
-}
-
-else if ($action == 'add') {
- if (! GETPOST('cancel', 'alpha')) {
- $error = 0;
-
- $object->code = GETPOST('code', 'alpha');
- $object->label = GETPOST('label', 'alpha');
- $object->nature = GETPOST('nature', 'int');
-
- if (empty($object->code)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Code")), null, 'errors');
- $error ++;
- }
- if (empty($object->label)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
- $error ++;
- }
-
- if (! $error) {
- $db->begin();
-
- $id = $object->create($user);
-
- if ($id > 0) {
- $db->commit();
-
- header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
- exit();
- } else {
- $db->rollback();
-
- setEventMessages($object->error, $object->errors, 'errors');
- $action = 'create';
- }
- } else {
- $action = 'create';
- }
- } else {
- header("Location: ./journals.php");
- exit();
- }
-}
-
-// Update record
-else if ($action == 'update') {
- if (! GETPOST('cancel', 'alpha')) {
- $result = $object->fetch($id);
-
- $object->code = GETPOST('code', 'alpha');
- $object->label = GETPOST('label', 'alpha');
- $object->nature = GETPOST('nature', 'int');
-
- if (empty($object->code)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Code")), null, 'errors');
- $error ++;
- }
- if (empty($object->label)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
- $error ++;
- }
-
- $result = $object->update($user);
-
- if ($result > 0) {
- header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
- exit();
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- } else {
- header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
- exit();
- }
-}
-
-
-
-/*
- * View
- */
-
-$title = $langs->trans("Journal") . " - " . $langs->trans("Card");
-$helpurl = "";
-llxHeader("",$title,$helpurl);
-
-$form = new Form($db);
-
-if ($action == 'create')
-{
- print load_fiche_titre($langs->trans("NewAccountingJournal"));
-
- print '';
-} else if ($id) {
- $result = $object->fetch($id);
- if ($result > 0) {
- $head = accounting_journal_prepare_head($object);
-
- if ($action == 'edit') {
- dol_fiche_head($head, 'card', $langs->trans("AccountingJournal"), 0, 'cron');
-
- print '';
-
- dol_fiche_end();
- } else {
- /*
- * Confirm delete
- */
- if ($action == 'delete') {
- print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
- }
-
- dol_fiche_head($head, 'card', $langs->trans("AccountingJournal"), 0, 'cron');
-
- print '';
-
- $linkback = '' . $langs->trans("BackToList") . '';
-
- // Ref
- print '| ' . $langs->trans("Code") . ' | ';
- print $object->code;
- print ' | ';
- print $linkback;
- print ' |
';
-
- // Label
- print '| ';
- print $form->editfieldkey("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32');
- print ' | ';
- print $form->editfieldval("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32');
- print " |
";
-
- // Nature
- print '| ' . $langs->trans("Type") . ' | ' . $object->getLibType(0) . ' |
';
-
- print "
";
-
- dol_fiche_end();
-
- if (! empty($user->rights->accounting->fiscalyear))
- {
- /*
- * Barre d'actions
- */
- print '';
- }
- }
- } else {
- dol_print_error($db);
- }
-}
-
-llxFooter();
-$db->close();
diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php
new file mode 100644
index 00000000000..be532c7c25f
--- /dev/null
+++ b/htdocs/accountancy/admin/journals_list.php
@@ -0,0 +1,758 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * \file htdocs/accountancy/admin/journals_list.php
+ * \ingroup Advanced accountancy
+ * \brief Setup page to configure journals
+ */
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+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';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+
+$langs->load("admin");
+$langs->load("compta");
+$langs->load("accountancy");
+
+$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
+$confirm=GETPOST('confirm','alpha');
+$id=GETPOST('id','int');
+$rowid=GETPOST('rowid','alpha');
+
+// Security access
+if (! empty($user->rights->accountancy->chartofaccount))
+{
+ accessforbidden();
+}
+
+$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');
+$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
+$active = 1;
+
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0 ; }
+$offset = $listlimit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+$error = 0;
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('admin'));
+
+// This page is a generic page to edit dictionaries
+// Put here declaration of dictionaries properties
+
+// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
+$taborder=array(35);
+
+// Name of SQL tables of dictionaries
+$tabname=array();
+$tabname[35]= MAIN_DB_PREFIX."accounting_journal";
+
+// Dictionary labels
+$tablib=array();
+$tablib[35]= "DictionaryAccountancyJournal";
+
+// Requests to extract data
+$tabsql=array();
+$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a";
+
+// Criteria to sort dictionaries
+$tabsqlsort=array();
+$tabsqlsort[35]="code ASC";
+
+// Nom des champs en resultat de select pour affichage du dictionnaire
+$tabfield=array();
+$tabfield[35]= "code,label,nature";
+
+// Nom des champs d'edition pour modification d'un enregistrement
+$tabfieldvalue=array();
+$tabfieldvalue[35]= "code,label,nature";
+
+// Nom des champs dans la table pour insertion d'un enregistrement
+$tabfieldinsert=array();
+$tabfieldinsert[35]= "code,label,nature";
+
+// 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[35]= "";
+
+// Condition to show dictionary in setup page
+$tabcond=array();
+$tabcond[35]= ! empty($conf->accounting->enabled);
+
+// List of help for fields
+$tabhelp=array();
+$tabhelp[35] = array('code'=>$langs->trans("EnterAnyCode"));
+
+// List of check for fields (NOT USED YET)
+$tabfieldcheck=array();
+$tabfieldcheck[35] = array();
+
+// Complete all arrays with entries found into modules
+complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck);
+
+
+// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
+$elementList = array();
+ $sourceList = array(
+ '1' => $langs->trans('AccountingJournalType0'),
+ '2' => $langs->trans('AccountingJournalType1'),
+ '3' => $langs->trans('AccountingJournalType2'),
+ '4' => $langs->trans('AccountingJournalType3'),
+ '9' => $langs->trans('AccountingJournalType9')
+ );
+
+/*
+ * Actions
+ */
+
+if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x'))
+{
+ $search_country_id = '';
+}
+
+// Actions add or modify an entry into a dictionary
+if (GETPOST('actionadd') || GETPOST('actionmodify'))
+{
+ $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;
+ foreach ($listfield as $f => $value)
+ {
+ if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
+ if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
+ if ($fieldnamekey == 'nature') $fieldnamekey = 'Nature';
+ }
+ // Other checks
+ if (isset($_POST["code"]))
+ {
+ if ($_POST["code"]=='0')
+ {
+ $ok=0;
+ setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
+ }
+ /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
+ {
+ $ok = 0;
+ $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
';
+ }*/
+ }
+
+ // Clean some parameters
+ if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
+ if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
+ if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
+
+ // Si verif ok et action add, on ajoute la ligne
+ if ($ok && GETPOST('actionadd'))
+ {
+ if ($tabrowid[$id])
+ {
+ // Recupere id libre pour insertion
+ $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);
+
+ } else {
+ dol_print_error($db);
+ }
+ }
+
+ // 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(";
+
+ // List of values
+ 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') {
+ $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
+ }
+ else if ($value == 'entity') {
+ $_POST[$listfieldvalue[$i]] = $conf->entity;
+ }
+ if ($i) $sql.=",";
+ if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
+ else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+ $i++;
+ }
+ $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
+ }
+ else
+ {
+ if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
+ setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
+ }
+ else {
+ dol_print_error($db);
+ }
+ }
+ }
+
+ // Si verif ok et action modify, on modifie la ligne
+ if ($ok && GETPOST('actionmodify'))
+ {
+ 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))
+ {
+ $sql.= $tabrowid[$id]."=";
+ $sql.= "'".$db->escape($rowid)."', ";
+ }
+ $i = 0;
+ foreach ($listfieldmodify as $field)
+ {
+ if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') {
+ $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
+ }
+ else if ($field == 'entity') {
+ $_POST[$listfieldvalue[$i]] = $conf->entity;
+ }
+ if ($i) $sql.=",";
+ $sql.= $field."=";
+ if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
+ else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+ $i++;
+ }
+ $sql.= " WHERE ".$rowidcol." = '".$rowid."'";
+
+ dol_syslog("actionmodify", LOG_DEBUG);
+ //print $sql;
+ $resql = $db->query($sql);
+ if (! $resql)
+ {
+ setEventMessages($db->error(), null, 'errors');
+ }
+ }
+ //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
+}
+
+if (GETPOST('actioncancel'))
+{
+ //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
+}
+
+if ($action == 'confirm_delete' && $confirm == 'yes') // delete
+{
+ 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 ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
+ {
+ setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
+}
+
+// activate
+if ($action == $acts[0])
+{
+ if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+ else { $rowidcol="rowid"; }
+
+ if ($rowid) {
+ $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
+ }
+ elseif ($_GET["code"]) {
+ $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$_GET["code"]."'";
+ }
+
+ $result = $db->query($sql);
+ if (!$result)
+ {
+ dol_print_error($db);
+ }
+}
+
+// disable
+if ($action == $acts[1])
+{
+ if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+ else { $rowidcol="rowid"; }
+
+ if ($rowid) {
+ $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
+ }
+ elseif ($_GET["code"]) {
+ $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$_GET["code"]."'";
+ }
+
+ $result = $db->query($sql);
+ if (!$result)
+ {
+ dol_print_error($db);
+ }
+}
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formadmin=new FormAdmin($db);
+
+llxHeader();
+
+$titre=$langs->trans("DictionarySetup");
+$linkback='';
+if ($id)
+{
+ $titre.=' - '.$langs->trans($tablib[$id]);
+ $titlepicto='title_accountancy';
+}
+
+print load_fiche_titre($titre,$linkback,$titlepicto);
+
+if (empty($id))
+{
+ print $langs->trans("DictionaryDesc");
+ print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n";
+}
+print "
\n";
+
+
+// Confirmation de la suppression de la ligne
+if ($action == 'delete')
+{
+ print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
+}
+//var_dump($elementList);
+
+/*
+ * Show a dictionary
+ */
+if ($id)
+{
+ // Complete requete recherche valeurs avec critere de tri
+ $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 ($sortfield)
+ {
+ // If sort order is "country", we use country_code instead
+ if ($sortfield == 'country') $sortfield='country_code';
+ $sql.= " ORDER BY ".$sortfield;
+ if ($sortorder)
+ {
+ $sql.=" ".strtoupper($sortorder);
+ }
+ $sql.=", ";
+ // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
+ $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]);
+ $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]);
+ }
+ else {
+ $sql.=" ORDER BY ";
+ }
+ $sql.=$tabsqlsort[$id];
+ $sql.=$db->plimit($listlimit+1,$offset);
+ //print $sql;
+
+ $fieldlist=explode(',',$tabfield[$id]);
+
+ print '';
+}
+
+print '
';
+
+
+llxFooter();
+$db->close();
+
+
+/**
+ * Show fields in insert/edit mode
+ *
+ * @param array $fieldlist Array of fields
+ * @param Object $obj If we show a particular record, obj is filled with record fields
+ * @param string $tabname Name of SQL table
+ * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
+ * @return void
+ */
+function fieldList($fieldlist, $obj='', $tabname='', $context='')
+{
+ global $conf,$langs,$db;
+ global $form, $mysoc;
+ global $region_id;
+ global $elementList,$sourceList,$localtax_typeList;
+ global $bc;
+
+ $formadmin = new FormAdmin($db);
+ $formcompany = new FormCompany($db);
+
+ foreach ($fieldlist as $field => $value)
+ {
+ if ($fieldlist[$field] == 'nature')
+ {
+ print '';
+ print $form->selectarray('nature', $sourceList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
+ print ' | ';
+ }
+ elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
+ print ' | ';
+ }
+ else
+ {
+ print '';
+ $size=''; $class='';
+ if ($fieldlist[$field]=='code') $class='maxwidth100';
+ if ($fieldlist[$field]=='label') $class='quatrevingtpercent';
+ if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
+ print '';
+ print ' | ';
+ }
+ }
+}
\ No newline at end of file
diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php
index d7cc61d6418..064f56bddd6 100644
--- a/htdocs/accountancy/class/accountingjournal.class.php
+++ b/htdocs/accountancy/class/accountingjournal.class.php
@@ -82,208 +82,6 @@ class AccountingJournal extends CommonObject
}
}
- /**
- * Insert journal in database
- *
- * @param User $user Use making action
- * @param int $notrigger Disable triggers
- * @return int <0 if KO, >0 if OK
- */
- function create($user, $notrigger = 0)
- {
- global $conf;
- $error = 0;
- $now = dol_now();
-
- // Clean parameters
- if (isset($this->code))
- $this->code = trim($this->code);
- if (isset($this->label))
- $this->label = trim($this->label);
-
- // Check parameters
- if (empty($this->nature) || $this->nature == '-1')
- {
- $this->nature = '0';
- }
-
- // Insert request
- $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_journal(";
- $sql .= "code";
- $sql .= ", label";
- $sql .= ", nature";
- $sql .= ", active";
- $sql .= ") VALUES (";
- $sql .= " " . (empty($this->code) ? 'NULL' : "'" . $this->db->escape($this->code) . "'");
- $sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
- $sql .= ", " . (empty($this->nature) ? '0' : "'" . $this->db->escape($this->nature) . "'");
- $sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active));
- $sql .= ")";
-
- $this->db->begin();
-
- dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (! $resql) {
- $error ++;
- $this->errors[] = "Error " . $this->db->lasterror();
- }
-
- if (! $error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_journal");
-
- // if (! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
-
- // // Call triggers
- // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- // $interface=new Interfaces($this->db);
- // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
- // if ($result < 0) { $error++; $this->errors=$interface->errors; }
- // // End call triggers
- // }
- }
-
- // Commit or rollback
- if ($error) {
- foreach ( $this->errors as $errmsg ) {
- dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
- $this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
- }
- $this->db->rollback();
- return - 1 * $error;
- } else {
- $this->db->commit();
- return $this->id;
- }
- }
-
- /**
- * Update record
- *
- * @param User $user Use making update
- * @return int <0 if KO, >0 if OK
- */
- function update($user)
- {
- // Check parameters
- if (empty($this->nature) || $this->nature == '-1')
- {
- $this->nature = '0';
- }
-
- $this->db->begin();
-
- $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
- $sql .= " SET code = " . ($this->code ? "'" . $this->db->escape($this->code) . "'" : "null");
- $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
- $sql .= " , nature = " . ($this->nature ? "'" . $this->db->escape($this->nature) . "'" : "0");
- $sql .= " , active = '" . $this->active . "'";
- $sql .= " WHERE rowid = " . $this->id;
-
- dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result) {
- $this->db->commit();
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- $this->db->rollback();
- return - 1;
- }
- }
-
- /**
- * Check usage of accounting journal
- *
- * @return int <0 if KO, >0 if OK
- */
- function checkUsage() {
- global $langs;
-
- $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
- $sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
- $sql .= "UNION";
- $sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det";
- $sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
-
- dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG);
- $resql = $this->db->query($sql);
-
- if ($resql) {
- $num = $this->db->num_rows($resql);
- if ($num > 0) {
- $this->error = $langs->trans('ErrorAccountingJournalIsAlreadyUse');
- return 0;
- } else {
- return 1;
- }
- } else {
- $this->error = $this->db->lasterror();
- return - 1;
- }
- }
-
- /**
- * Delete object in database
- *
- * @param User $user User that deletes
- * @param int $notrigger 0=triggers after, 1=disable triggers
- * @return int <0 if KO, >0 if OK
- */
- function delete($user, $notrigger = 0) {
- $error = 0;
-
- $result = $this->checkUsage();
-
- if ($result > 0) {
-
- $this->db->begin();
-
- // if (! $error) {
- // if (! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
-
- // // Call triggers
- // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- // $interface=new Interfaces($this->db);
- // $result=$interface->run_triggers('ACCOUNTANCY_ACCOUNT_DELETE',$this,$user,$langs,$conf);
- // if ($result < 0) { $error++; $this->errors=$interface->errors; }
- // // End call triggers
- // }
- // }
-
- if (! $error) {
- $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_journal";
- $sql .= " WHERE rowid=" . $this->id;
-
- dol_syslog(get_class($this) . "::delete sql=" . $sql);
- $resql = $this->db->query($sql);
- if (! $resql) {
- $error ++;
- $this->errors[] = "Error " . $this->db->lasterror();
- }
- }
-
- // Commit or rollback
- if ($error) {
- foreach ( $this->errors as $errmsg ) {
- dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
- $this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
- }
- $this->db->rollback();
- return - 1 * $error;
- } else {
- $this->db->commit();
- return 1;
- }
- } else {
- return - 1;
- }
- }
-
/**
* Return clicable name (with picto eventually)
*
@@ -311,64 +109,6 @@ class AccountingJournal extends CommonObject
return $result;
}
- /**
- * Deactivate journal
- *
- * @param int $id Id
- * @return int <0 if KO, >0 if OK
- */
- function journal_deactivate($id) {
- $result = $this->checkUsage();
-
- if ($result > 0) {
- $this->db->begin();
-
- $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
- $sql .= "SET active = '0'";
- $sql .= " WHERE rowid = " . $this->db->escape($id);
-
- dol_syslog(get_class($this) . "::deactivate sql=" . $sql, LOG_DEBUG);
- $result = $this->db->query($sql);
-
- if ($result) {
- $this->db->commit();
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- $this->db->rollback();
- return - 1;
- }
- } else {
- return - 1;
- }
- }
-
- /**
- * Activate journal
- *
- * @param int $id Id
- * @return int <0 if KO, >0 if OK
- */
- function journal_activate($id) {
- $this->db->begin();
-
- $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
- $sql .= "SET active = '1'";
- $sql .= " WHERE rowid = " . $this->db->escape($id);
-
- dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result) {
- $this->db->commit();
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- $this->db->rollback();
- return - 1;
- }
- }
-
-
/**
* Retourne le libelle du statut d'un user (actif, inactif)
*
diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql
index 54cddfcaa96..9106c345fda 100644
--- a/htdocs/core/menus/init_menu_auguria.sql
+++ b/htdocs/core/menus/init_menu_auguria.sql
@@ -211,14 +211,15 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__);
-- Setup
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__);
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__);
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__);
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 22, __ENTITY__);
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2458__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2451__+MAX_llx_menu__, '/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__);
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/admin/dict.php?id=10&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__);
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__);
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__);
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2458__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2451__+MAX_llx_menu__, '/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/admin/dict.php?id=10&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 80, __ENTITY__);
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 90, __ENTITY__);
-- Binding
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__);
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index dffc5f9af1b..aa905b4ef93 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -165,7 +165,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
if (! empty($conf->loan->enabled)) $menuqualified++;
$tmpentry=array(
'enabled'=>$menuqualified,
- 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)),
+ 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)),
'module'=>'comptabilite|accounting|facture|supplier_invoice|don|tax|salaries|loan');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
@@ -947,26 +947,27 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
{
$langs->load("accountancy");
- $permtoshowmenu=(! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire);
+ $permtoshowmenu=(! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire);
$newmenu->add("/accountancy/index.php?leftmenu=accountancy",$langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
// Chart of account
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1);
- if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 10);
- if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 20);
- if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 22);
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 10);
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 20);
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 30);
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 31);
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40);
if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled))
{
- if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30);
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50);
}
if (! empty($conf->tax->enabled))
{
- if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30);
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50);
}
if (! empty($conf->expensereport->enabled))
{
- if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30);
+ if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50);
}
/* not required yet, already supported by default account
if (! empty($conf->loan->enabled))
@@ -977,7 +978,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
{
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47);
}*/
- if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50);
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 60);
// Binding
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer');
diff --git a/htdocs/install/mysql/data/llx_accounting.sql b/htdocs/install/mysql/data/llx_accounting.sql
index 5f0e8dd5416..e81d13dd2b8 100644
--- a/htdocs/install/mysql/data/llx_accounting.sql
+++ b/htdocs/install/mysql/data/llx_accounting.sql
@@ -27,15 +27,11 @@
-- de l'install et tous les sigles '--' sont supprimés.
--
-delete from llx_accounting_account;
-delete from llx_accounting_system;
-delete from llx_accounting_journal;
-
-INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Journal des ventes', 1, 1);
-INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Journal des achats', 2, 1);
-INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (3,'BQ', 'Journal de banque', 3, 1);
-INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Journal des opérations diverses', 0, 1);
-INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Journal des à-nouveaux', 9, 1);
+INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('VT', 'Journal des ventes', 2, 1);
+INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('AC', 'Journal des achats', 3, 1);
+INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('BQ', 'Journal de banque', 4, 1);
+INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('OD', 'Journal des opérations diverses', 1, 1);
+INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('AN', 'Journal des à-nouveaux', 9, 1);
--
-- Descriptif des plans comptables FR PCG99-ABREGE
--
diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.sql b/htdocs/install/mysql/tables/llx_accounting_journal.sql
index d9c6ea76e3e..bccfb234c3e 100644
--- a/htdocs/install/mysql/tables/llx_accounting_journal.sql
+++ b/htdocs/install/mysql/tables/llx_accounting_journal.sql
@@ -22,6 +22,6 @@ create table llx_accounting_journal
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(32) NOT NULL,
label varchar(128) NOT NULL,
- nature smallint DEFAULT 0 NOT NULL, -- type of journals (0:various operations / 1:sale / 2:purchase / 3:bank / 9: has-new)
+ nature smallint DEFAULT 0 NOT NULL, -- type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
active smallint DEFAULT 0
)ENGINE=innodb;
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index ca32d62e45a..a5788736fbd 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -205,11 +205,11 @@ NewAccountingJournal=New accounting journal
ShowAccoutingJournal=Show accounting journal
Code=Code
Nature=Nature
-AccountingJournalTypeVariousOperation=Various operation
-AccountingJournalTypeSale=Sale
-AccountingJournalTypePurchase=Purchase
-AccountingJournalTypeBank=Bank
-AccountingJournalTypeHasNew=Has-new
+AccountingJournalType1=Various operation
+AccountingJournalType2=Sales
+AccountingJournalType3=Purchases
+AccountingJournalType4=Bank
+AccountingJournalType9=Has-new
ErrorAccountingJournalIsAlreadyUse=This journal is already use
## Export
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 7f0596d33cd..4b56ef00ae1 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -859,6 +859,7 @@ DictionaryOrderMethods=Ordering methods
DictionarySource=Origin of proposals/orders
DictionaryAccountancyCategory=Accounting account groups
DictionaryAccountancysystem=Models for chart of accounts
+DictionaryAccountancyJournal=Accounting journals
DictionaryEMailTemplates=Emails templates
DictionaryUnits=Units
DictionaryProspectStatus=Prospection status