';
@@ -307,12 +301,12 @@ if ($resql) {
// Action
print '';
- if ($user->admin) {
- print '';
+ if ($user->rights->accounting->chartofaccount) {
+ print 'id).'">';
print img_edit();
print '';
print ' ';
- print '';
+ print 'id). '">';
print img_delete();
print '';
}
diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index 822a4d19bcd..8e77c4a5dab 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -26,6 +26,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
+require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
@@ -159,13 +160,15 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$result = $object->update($user);
if ($result > 0) {
- header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+ $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
+ header("Location: " . $urltogo);
exit();
} else {
$mesg = $object->error;
}
} else {
- header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+ $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
+ header("Location: " . $urltogo);
exit();
}
} else if ($action == 'delete' && $user->rights->accounting->chartofaccount) {
@@ -196,6 +199,9 @@ $form = new Form($db);
$htmlacc = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
+$accountsystem = new AccountancySystem($db);
+$accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
+
// Create mode
if ($action == 'create') {
print load_fiche_titre($langs->trans('NewAccountingAccount'));
@@ -208,36 +214,45 @@ if ($action == 'create') {
print '';
+ // Chart of account
+ print '| ' . $langs->trans("Chartofaccounts") . ' | ';
+ print '';
+ print $accountsystem->ref;
+ print ' | ';
+
+
// Account number
print '| ' . $langs->trans("AccountNumber") . ' | ';
- print ' | ';
+ print ' | ';
// Label
print '| ' . $langs->trans("Label") . ' | ';
- print ' | ';
+ print ' | ';
// Account parent
print '| ' . $langs->trans("Accountparent") . ' | ';
print '';
- print $htmlacc->select_account($object->account_parent, 'account_parent', 1);
+ print $htmlacc->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
print ' | ';
// Category
print '| ' . $langs->trans("AccountingCategory") . ' | ';
print '';
- $formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
+ $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
print ' | ';
// Chart of accounts type
print '| ' . $langs->trans("Pcgtype") . ' | ';
print '';
- print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type');
+ print '';
+ //print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type', 1);
print ' | ';
// Chart of acounts subtype
print '| ' . $langs->trans("Pcgsubtype") . ' | ';
print '';
- print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype');
+ print '';
+ //print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype', 1);
print ' | ';
print ' ';
@@ -268,7 +283,8 @@ if ($action == 'create') {
print '';
print '';
print '';
-
+ print '';
+
print '';
diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php
index dd7d0c70897..a1c90a97b5b 100644
--- a/htdocs/accountancy/class/accountancysystem.class.php
+++ b/htdocs/accountancy/class/accountancysystem.class.php
@@ -47,6 +47,55 @@ class AccountancySystem
$this->db = $db;
}
+
+ /**
+ * Load record in memory
+ *
+ * @param int $rowid Id
+ * @param string $ref ref
+ * @return int <0 if KO, Id of record if OK and found
+ */
+ function fetch($rowid = 0, $ref = '')
+ {
+ global $conf;
+
+ if ($rowid > 0 || $ref)
+ {
+ $sql = "SELECT a.pcg_version, a.label, a.active";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a";
+ $sql .= " WHERE";
+ if ($rowid) {
+ $sql .= " a.rowid = '" . $rowid . "'";
+ } elseif ($ref) {
+ $sql .= " a.pcg_version = '" . $ref . "'";
+ }
+
+ dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if ($result) {
+ $obj = $this->db->fetch_object($result);
+
+ if ($obj) {
+ $this->id = $obj->rowid;
+ $this->rowid = $obj->rowid;
+ $this->pcg_version = $obj->pcg_version;
+ $this->ref = $obj->pcg_version;
+ $this->label = $obj->label;
+ $this->active = $obj->active;
+
+ return $this->id;
+ } else {
+ return 0;
+ }
+ } else {
+ $this->error = "Error " . $this->db->lasterror();
+ $this->errors[] = "Error " . $this->db->lasterror();
+ }
+ }
+ return - 1;
+ }
+
+
/**
* Insert accountancy system name into database
*
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 9749e38007f..aee7d7172c6 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -150,12 +150,19 @@ class AccountingAccount extends CommonObject
if (isset($this->active))
$this->active = trim($this->active);
- // Check parameters
- // Put here code to add control on parameters values
+ if (empty($this->pcg_type) || $this->pcg_type == '-1')
+ {
+ $this->pcg_type = 'XXXXXX';
+ }
+ if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
+ {
+ $this->pcg_subtype = 'XXXXXX';
+ }
+ // Check parameters
+ // Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account(";
-
$sql .= "datec";
$sql .= ", entity";
$sql .= ", fk_pcg_version";
@@ -167,9 +174,7 @@ class AccountingAccount extends CommonObject
$sql .= ", fk_accounting_category";
$sql .= ", fk_user_author";
$sql .= ", active";
-
$sql .= ") VALUES (";
-
$sql .= " '" . $this->db->idate($now) . "'";
$sql .= ", " . $conf->entity;
$sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
@@ -225,11 +230,22 @@ class AccountingAccount extends CommonObject
/**
* Update record
*
- * @param User $user Use making update
- * @return int <0 if KO, >0 if OK
+ * @param User $user Use making update
+ * @return int <0 if KO, >0 if OK
*/
- function update($user) {
- $this->db->begin();
+ function update($user)
+ {
+ // Check parameters
+ if (empty($this->pcg_type) || $this->pcg_type == '-1')
+ {
+ $this->pcg_type = 'XXXXXX';
+ }
+ if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
+ {
+ $this->pcg_subtype = 'XXXXXX';
+ }
+
+ $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
@@ -241,7 +257,6 @@ class AccountingAccount extends CommonObject
$sql .= " , fk_accounting_category = '" . $this->account_category . "'";
$sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = '" . $this->active . "'";
-
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php
index 376e5b00d56..06c9dcacc71 100644
--- a/htdocs/accountancy/class/html.formventilation.class.php
+++ b/htdocs/accountancy/class/html.formventilation.class.php
@@ -180,11 +180,15 @@ class FormVentilation extends Form
$options = array();
$out = ajax_combobox($htmlname, $event);
- while ($obj = $this->db->fetch_object($resql)) {
- $options[$obj->pcg_type] = $obj->pcg_type;
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ if ($obj->pcg_type != '-1')
+ {
+ $options[$obj->pcg_type] = $obj->pcg_type;
+ }
}
- $out .= Form::selectarray($htmlname, $options, $selectid, $showempty);
+ $out .= Form::selectarray($htmlname, $options, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth200');
$this->db->free($resql);
return $out;
@@ -200,7 +204,8 @@ class FormVentilation extends Form
*
* @return string String with HTML select
*/
- function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) {
+ function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array())
+ {
global $conf;
$sql = "SELECT DISTINCT pcg_subtype ";
@@ -221,11 +226,15 @@ class FormVentilation extends Form
$options = array();
$out = ajax_combobox($htmlname, $event);
- while ($obj = $this->db->fetch_object($resql)) {
- $options[$obj->pcg_subtype] = $obj->pcg_subtype;
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ if ($obj->pcg_type != '-1')
+ {
+ $options[$obj->pcg_subtype] = $obj->pcg_subtype;
+ }
}
- $out .= Form::selectarray($htmlname, $options, $selectid, $showempty);
+ $out .= Form::selectarray($htmlname, $options, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth200');
$this->db->free($resql);
return $out;
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index 8c7f6903bb3..36d32436e82 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -90,31 +90,35 @@ class FormAccounting
$num = $db->num_rows($resql);
if ($num)
{
- print '';
+ if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
else
{
- print $langs->trans("ErrorNoAccountingCategoryForThisCountry",$mysoc->country_code);
+ $out .= $langs->trans("ErrorNoAccountingCategoryForThisCountry",$mysoc->country_code);
}
}
else
{
dol_print_error($db,$db->lasterror());
}
+
+ $out .= ajax_combobox($htmlname, $event);
+
+ print $out;
}
}
diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang
index 1afd69b73e0..08f17ed995e 100644
--- a/htdocs/langs/en_US/compta.lang
+++ b/htdocs/langs/en_US/compta.lang
@@ -13,8 +13,8 @@ LTReportBuildWithOptionDefinedInModule=Amounts shown here are calculated using r
Param=Setup
RemainingAmountPayment=Amount payment remaining :
Account=Account
-Accountparent=Account parent
-Accountsparent=Accounts parent
+Accountparent=Parent account
+Accountsparent=Parent accounts
Income=Income
Outcome=Expense
ReportInOut=Income / Expense
|