28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancysystem.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
37$langs->loadLangs(array(
'accountancy',
'bills',
'compta'));
39$action =
GETPOST(
'action',
'aZ09');
40$backtopage =
GETPOST(
'backtopage',
'alpha');
44$cancel =
GETPOST(
'cancel',
'alpha');
46$account_number =
GETPOST(
'account_number',
'alphanohtml');
47$label =
GETPOST(
'label',
'alpha');
50if ($user->socid > 0) {
53if (!$user->hasRight(
'accounting',
'chartofaccount')) {
65if (
GETPOST(
'cancel',
'alpha')) {
66 $urltogo = $backtopage ? $backtopage : DOL_URL_ROOT.
'/accountancy/admin/account.php';
67 header(
"Location: ".$urltogo);
71if ($action ==
'add' && $user->hasRight(
'accounting',
'chartofaccount')) {
73 if (!$account_number) {
74 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountNumber")),
null,
'errors');
77 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
80 $sql =
"SELECT pcg_version FROM " . MAIN_DB_PREFIX .
"accounting_system WHERE rowid = ".((int)
getDolGlobalInt(
'CHARTOFACCOUNTS'));
82 dol_syslog(
'accountancy/admin/card.php:: $sql=' . $sql);
83 $result = $db->query($sql);
84 $obj = $db->fetch_object($result);
95 $object->fk_pcg_version = $obj->pcg_version;
97 $object->account_number = $account_number;
98 $object->account_parent = $account_parent;
109 } elseif ($res == -4) {
113 } elseif ($res < 0) {
120 $urltogo = $backtopage ? $backtopage : DOL_URL_ROOT.
'/accountancy/admin/account.php';
121 header(
"Location: " . $urltogo);
126} elseif ($action ==
'edit' && $user->hasRight(
'accounting',
'chartofaccount')) {
128 if (!$account_number) {
129 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountNumber")),
null,
'errors');
132 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
137 $sql =
"SELECT pcg_version FROM ".MAIN_DB_PREFIX.
"accounting_system WHERE rowid=".((int)
getDolGlobalInt(
'CHARTOFACCOUNTS'));
139 dol_syslog(
'accountancy/admin/card.php:: $sql=' . $sql);
140 $result2 = $db->query($sql);
141 $obj = $db->fetch_object($result2);
152 $object->fk_pcg_version = $obj->pcg_version;
154 $object->account_number = $account_number;
155 $object->account_parent = $account_parent;
160 $result =
$object->update($user);
163 $urltogo = $backtopage ? $backtopage : ($_SERVER[
"PHP_SELF"] .
"?id=" . $id);
164 header(
"Location: " . $urltogo);
166 } elseif ($result == -2) {
173 $urltogo = $backtopage ? $backtopage : ($_SERVER[
"PHP_SELF"].
"?id=".$id);
174 header(
"Location: ".$urltogo);
177} elseif ($action ==
'delete' && $user->hasRight(
'accounting',
'chartofaccount')) {
181 $result =
$object->delete($user);
184 header(
"Location: account.php");
199$form =
new Form($db);
205$title = $langs->trans(
'AccountAccounting').
" - ".$langs->trans(
'Card');
207$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
213if ($action ==
'create') {
216 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
217 print
'<input type="hidden" name="token" value="'.newToken().
'">';
218 print
'<input type="hidden" name="action" value="add">';
222 print
'<table class="border centpercent">';
225 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Chartofaccounts").
'</span></td>';
227 print $accountsystem->ref;
231 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"AccountNumber").
'</span></td>';
232 print
'<td><input name="account_number" size="30" value="'.$account_number.
'"></td></tr>';
235 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Label").
'</span></td>';
236 print
'<td><input name="label" size="70" value="'.$object->label.
'"></td></tr>';
239 print
'<tr><td>'.$langs->trans(
"LabelToShow").
'</td>';
240 print
'<td><input name="labelshort" size="70" value="'.$object->labelshort.
'"></td></tr>';
243 print
'<tr><td>'.$langs->trans(
"Accountparent").
'</td>';
245 print $formaccounting->select_account(
$object->account_parent,
'account_parent', 1, [], 0, 0,
'minwidth200');
250 print $form->textwithpicto($langs->trans(
"Pcgtype"), $langs->transnoentitiesnoconv(
"PcgtypeDesc"));
253 print
'<input type="text" name="pcg_type" list="pcg_type_datalist" value="'.dol_escape_htmltag(GETPOSTISSET(
'pcg_type') ?
GETPOST(
'pcg_type',
'alpha') :
$object->pcg_type).
'">';
255 print
'<datalist id="pcg_type_datalist">';
256 $sql =
"SELECT DISTINCT pcg_type FROM " . MAIN_DB_PREFIX .
"accounting_account";
257 $sql .=
" WHERE fk_pcg_version = '" . $db->escape($accountsystem->ref) .
"'";
258 $sql .=
' AND entity in ('.getEntity(
'accounting_account', 0).
')';
259 $sql .=
' LIMIT 50000';
260 $resql = $db->query($sql);
262 while ($obj = $db->fetch_object($resql)) {
271 print $form->textwithpicto($langs->trans(
"AccountingCategory"), $langs->transnoentitiesnoconv(
"AccountingAccountGroupsDesc"));
274 print $formaccounting->select_accounting_category(
$object->account_category,
'account_category', 1, 0, 1);
281 print
'<div class="center">';
282 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
283 print
' ';
284 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
288} elseif ($id > 0 || $ref) {
289 $result =
$object->fetch($id, $ref, 1);
295 if ($action ==
'update') {
296 print
dol_get_fiche_head($head,
'card', $langs->trans(
'AccountAccounting'), 0,
'accounting_account');
298 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
299 print
'<input type="hidden" name="token" value="'.newToken().
'">';
300 print
'<input type="hidden" name="action" value="edit">';
301 print
'<input type="hidden" name="id" value="'.$id.
'">';
302 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
304 print
'<table class="border centpercent">';
307 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"AccountNumber").
'</span></td>';
308 print
'<td><input name="account_number" size="30" value="'.$object->account_number.
'"></td></tr>';
311 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Label").
'</span></td>';
312 print
'<td><input name="label" size="70" value="'.$object->label.
'"></td></tr>';
315 print
'<tr><td>'.$langs->trans(
"LabelToShow").
'</td>';
316 print
'<td><input name="labelshort" size="70" value="'.$object->labelshort.
'"></td></tr>';
319 print
'<tr><td>'.$langs->trans(
"Accountparent").
'</td>';
322 print $formaccounting->select_account(
$object->account_parent,
'account_parent', 1, array(), 0, 0,
'minwidth100 maxwidth300 maxwidthonsmartphone', 1,
'');
327 print $form->textwithpicto($langs->trans(
"Pcgtype"), $langs->transnoentitiesnoconv(
"PcgtypeDesc"));
330 print
'<input type="text" name="pcg_type" list="pcg_type_datalist" value="'.dol_escape_htmltag(GETPOSTISSET(
'pcg_type') ?
GETPOST(
'pcg_type',
'alpha') :
$object->pcg_type).
'">';
332 print
'<datalist id="pcg_type_datalist">';
333 $sql =
'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX .
'accounting_account';
334 $sql .=
" WHERE fk_pcg_version = '" . $db->escape($accountsystem->ref) .
"'";
335 $sql .=
' AND entity in ('.getEntity(
'accounting_account', 0).
')';
336 $sql .=
' LIMIT 50000';
337 $resql = $db->query($sql);
339 while ($obj = $db->fetch_object($resql)) {
348 print $form->textwithpicto($langs->trans(
"AccountingCategory"), $langs->transnoentitiesnoconv(
"AccountingAccountGroupsDesc"));
351 print $formaccounting->select_accounting_category(
$object->account_category,
'account_category', 1);
358 print $form->buttonsSaveCancel();
363 $linkback =
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/account.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
365 print
dol_get_fiche_head($head,
'card', $langs->trans(
'AccountAccounting'), -1,
'accounting_account');
367 dol_banner_tab(
$object,
'ref', $linkback, 1,
'account_number',
'ref');
370 print
'<div class="fichecenter">';
371 print
'<div class="underbanner clearboth"></div>';
373 print
'<table class="border centpercent tableforfield">';
376 print
'<tr><td class="titlefield">'.$langs->trans(
"Label").
'</td>';
377 print
'<td colspan="2">'.$object->label.
'</td></tr>';
380 print
'<tr><td class="titlefield">'.$langs->trans(
"LabelToShow").
'</td>';
381 print
'<td colspan="2">'.$object->labelshort.
'</td></tr>';
385 if (!empty(
$object->account_parent)) {
386 $accp->fetch(
$object->account_parent,
'');
388 print
'<tr><td>'.$langs->trans(
"Accountparent").
'</td>';
389 print
'<td colspan="2">'.$accp->account_number.
' - '.$accp->label.
'</td></tr>';
393 print $form->textwithpicto($langs->trans(
"Pcgtype"), $langs->transnoentitiesnoconv(
"PcgtypeDesc"));
395 print
'<td colspan="2">'.$object->pcg_type.
'</td></tr>';
399 print $form->textwithpicto($langs->trans(
"AccountingCategory"), $langs->transnoentitiesnoconv(
"AccountingAccountGroupsDesc"));
400 print
"</td><td colspan='2'>".$object->account_category_label.
"</td>";
411 print
'<div class="tabsAction">';
413 if ($user->hasRight(
'accounting',
'chartofaccount')) {
414 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=update&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
'Modify').
'</a>';
416 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Modify').
'</a>';
420 $permissiontodelete = $user->hasRight(
'accounting',
'chartofaccount');
421 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
accounting_prepare_head(AccountingAccount $object)
Prepare array with list of tabs.
clean_account($account)
Return accounting account without zero on the right.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accountancy systems.
Class to manage accounting accounts.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.