FIX Edit of personalized groups
This commit is contained in:
parent
7f23a396a9
commit
3ab5c3e6ab
@ -60,7 +60,7 @@ $accountingcategory = new AccountancyCategory($db);
|
|||||||
|
|
||||||
// si ajout de comptes
|
// si ajout de comptes
|
||||||
if (! empty($selectcpt)) {
|
if (! empty($selectcpt)) {
|
||||||
$cpts = array ();
|
$cpts = array();
|
||||||
foreach ($selectcpt as $selectedoption) {
|
foreach ($selectcpt as $selectedoption) {
|
||||||
if (! array_key_exists($selectedoption, $cpts))
|
if (! array_key_exists($selectedoption, $cpts))
|
||||||
$cpts[$selectedoption] = "'" . $selectedoption . "'";
|
$cpts[$selectedoption] = "'" . $selectedoption . "'";
|
||||||
@ -71,13 +71,13 @@ if (! empty($selectcpt)) {
|
|||||||
if ($return<0) {
|
if ($return<0) {
|
||||||
setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
|
setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
|
setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($action == 'delete') {
|
if ($action == 'delete') {
|
||||||
if ($cpt_id) {
|
if ($cpt_id) {
|
||||||
if ($accountingcategory->deleteCptCat($cpt_id)) {
|
if ($accountingcategory->deleteCptCat($cpt_id)) {
|
||||||
setEventMessages($langs->trans('CategoryDeleted'), null, 'mesgs');
|
setEventMessages($langs->trans('AccountRemovedFromGroup'), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans('errors'), null, 'errors');
|
setEventMessages($langs->trans('errors'), null, 'errors');
|
||||||
}
|
}
|
||||||
@ -173,8 +173,9 @@ if ($action == 'display' || $action == 'delete') {
|
|||||||
print '<td>' . $cpt->label . '</td>';
|
print '<td>' . $cpt->label . '</td>';
|
||||||
print '<td class="right">';
|
print '<td class="right">';
|
||||||
print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=" . $cat_id . "&cptid=" . $cpt->rowid."'>";
|
print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=" . $cat_id . "&cptid=" . $cpt->rowid."'>";
|
||||||
print img_delete($langs->trans("DeleteFromCat")).' ';
|
print $langs->trans("DeleteFromCat");
|
||||||
print $langs->trans("DeleteFromCat")."</a>";
|
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
|
||||||
|
print "</a>";
|
||||||
print "</td>";
|
print "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -514,7 +514,7 @@ class AccountancyCategory // extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Function to select accounting category of an accounting account present in chart of accounts
|
* Function to select accounting category of an accounting account present in chart of accounts
|
||||||
*
|
*
|
||||||
* @param int $id Id category
|
* @param int $id Id of category to know which account to exclude
|
||||||
*
|
*
|
||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
@ -569,12 +569,13 @@ class AccountancyCategory // extends CommonObject
|
|||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||||
|
|
||||||
$sql = "SELECT aa.rowid,aa.account_number ";
|
$sql = "SELECT aa.rowid, aa.account_number";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||||
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
|
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
|
||||||
$sql .= " AND aa.active = 1";
|
$sql .= " AND aa.active = 1";
|
||||||
$sql .= " AND aa.entity = " . $conf->entity;
|
$sql .= " AND aa.entity = " . $conf->entity;
|
||||||
|
$sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
@ -587,10 +588,16 @@ class AccountancyCategory // extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( $obj = $this->db->fetch_object($resql))
|
$accountincptsadded=array();
|
||||||
|
while ($obj = $this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
if (array_key_exists(length_accountg($obj->account_number), $cpts))
|
$account_number_formated=length_accountg($obj->account_number);
|
||||||
|
if (! empty($accountincptsadded[$account_number_formated])) continue;
|
||||||
|
|
||||||
|
if (array_key_exists($account_number_formated, $cpts))
|
||||||
{
|
{
|
||||||
|
$accountincptsadded[$account_number_formated]=1;
|
||||||
|
// We found an account number that is in list $cpts of account to add
|
||||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account";
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account";
|
||||||
$sql .= " SET fk_accounting_category=" . $id_cat;
|
$sql .= " SET fk_accounting_category=" . $id_cat;
|
||||||
$sql .= " WHERE rowid=".$obj->rowid;
|
$sql .= " WHERE rowid=".$obj->rowid;
|
||||||
|
|||||||
@ -256,7 +256,7 @@ NotYetAccounted=Not yet accounted in ledger
|
|||||||
|
|
||||||
## Admin
|
## Admin
|
||||||
ApplyMassCategories=Apply mass categories
|
ApplyMassCategories=Apply mass categories
|
||||||
AddAccountFromBookKeepingWithNoCategories=Available account not yet in a personalized group
|
AddAccountFromBookKeepingWithNoCategories=Available account not yet in the personalized group
|
||||||
CategoryDeleted=Category for the accounting account has been removed
|
CategoryDeleted=Category for the accounting account has been removed
|
||||||
AccountingJournals=Accounting journals
|
AccountingJournals=Accounting journals
|
||||||
AccountingJournal=Accounting journal
|
AccountingJournal=Accounting journal
|
||||||
@ -308,6 +308,7 @@ PredefinedGroups=Predefined groups
|
|||||||
WithoutValidAccount=Without valid dedicated account
|
WithoutValidAccount=Without valid dedicated account
|
||||||
WithValidAccount=With valid dedicated account
|
WithValidAccount=With valid dedicated account
|
||||||
ValueNotIntoChartOfAccount=This value of accounting account does not exist into chart of account
|
ValueNotIntoChartOfAccount=This value of accounting account does not exist into chart of account
|
||||||
|
AccountRemovedFromGroup=Account removed from group
|
||||||
|
|
||||||
## Dictionary
|
## Dictionary
|
||||||
Range=Range of accounting account
|
Range=Range of accounting account
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user