39function is_empty($var, $allow_false =
false, $allow_ws =
false)
41 if (is_null($var) || !isset($var) || ($allow_ws ==
false && trim($var) ==
"" && !is_bool($var)) || ($allow_false ===
false && $var ===
false) || (is_array($var) && empty($var))) {
60 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/accountancy/admin/card.php', [
'id' =>
$object->id]);
61 $head[$h][1] = $langs->trans(
"AccountAccounting");
62 $head[$h][2] =
'card';
92 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/accountancy/bookkeeping/card.php', [
'piece_num' =>
$object->piece_num,
'mode' => $mode,
'type' => $type,
'backtopage' => $backtopage]);
93 $head[$h][1] = $langs->trans(
"Transaction");
94 $head[$h][2] =
'transaction';
116 global $langs,
$conf;
121 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/accountancy/admin/template/card.php', [
'id' =>
$object->id]);
122 $head[$h][1] = $langs->trans(
"BookkeepingTemplate");
123 $head[$h][2] =
'card';
141 $account = rtrim($account,
"0");
154 if ($account < 0 ||
is_empty($account)) {
165 $i = strlen($account);
192 if ($accounta < 0 ||
is_empty($accounta)) {
203 $i = strlen($accounta);
233 if (empty($auxiliary_account))
return true;
236 $sql =
"SELECT rowid, account_number, centralized";
237 $sql .=
" FROM ".MAIN_DB_PREFIX.
"accounting_account";
239 if ($general_account_id > 0) {
240 $sql .=
" rowid = ".((int) $general_account_id);
242 $sql .=
" account_number = '".$db->escape($general_account).
"'";
244 $sql .=
" AND entity = ". ((int)
$conf->entity);
245 $sql .=
" AND fk_pcg_version IN (SELECT pcg_version FROM ".MAIN_DB_PREFIX.
"accounting_system WHERE rowid = ".((int)
getDolGlobalInt(
'CHARTOFACCOUNTS')).
")";
247 $resql =
$db->query($sql);
249 $obj =
$db->fetch_object($resql);
250 if ($obj && empty($obj->centralized)) {
275function journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink =
'', $moreparam = array(), $calcmode =
'', $varlink =
'', $moreoptions = array())
279 print
"\n\n<!-- start banner journal -->\n";
282 $varlink =
'?'.$varlink;
287 $head[$h][0] = $_SERVER[
"PHP_SELF"].$varlink;
288 $head[$h][1] = $langs->trans(
"Journalization");
289 $head[$h][2] =
'journal';
291 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].$varlink.
'">';
292 print
'<input type="hidden" name="token" value="'.newToken().
'">';
296 foreach ($moreparam as $key => $value) {
297 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
299 print
'<table class="border centpercent tableforfield">';
303 print
'<td class="titlefieldcreate">'.$langs->trans(
"Name").
'</td>';
304 print
'<td colspan="3">';
312 print
'<td>'.$langs->trans(
"CalculationMode").
'</td>';
314 print
'<td colspan="3">';
320 print
'</td><td colspan="2">'.$variant;
328 print
'<td>'.$langs->trans(
"ReportPeriod").
'</td>';
330 print
'<td colspan="3">';
338 print
'</td><td colspan="2">'.$periodlink;
345 print
'<td>'.$langs->trans(
"ReportDescription").
'</td>';
346 print
'<td colspan="3">'.$description.
'</td>';
351 foreach ($moreoptions as $key => $value) {
353 print
'<td>'.$langs->trans($key).
'</td>';
354 print
'<td colspan="3">'.$value.
'</td>';
362 print
'<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans(
"Refresh").
'"></div>';
366 print
"\n<!-- end banner journal -->\n\n";
384 $periodbydefaultontransfer =
getDolGlobalInt(
'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', 0);
385 if ($periodbydefaultontransfer == 2) {
386 $sql =
"SELECT date_start, date_end FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear";
387 $sql .=
" WHERE date_start < '".$db->idate(
dol_now()).
"' AND date_end > '".
$db->idate(
dol_now()).
"'";
388 $sql .=
$db->plimit(1);
389 $res =
$db->query($sql);
390 if (
$db->num_rows($res) > 0) {
391 $obj =
$db->fetch_object($res);
401 $year_end = $year_start + 1;
402 $month_end = $month_start - 1;
403 if ($month_end < 1) {
411 } elseif ($periodbydefaultontransfer == 1) {
414 $pastmonthyear = $year_current;
415 if ($pastmonth == 0) {
422 $pastmonthyear = $year_current;
423 if ($pastmonth == 0) {
430 'date_end' => $date_end,
431 'pastmonthyear' => $pastmonthyear,
432 'pastmonth' => $pastmonth
450 if ($from_time ===
null) {
456 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
459 $sql =
"SELECT date_start, date_end FROM ".$db->prefix().
"accounting_fiscalyear";
460 $sql .=
" WHERE date_start <= '".$db->idate($from_time, $gm).
"'";
461 if ($withenddateonly) {
462 $sql .=
" AND (date_end >= '".$db->idate($from_time, $gm).
"')";
464 $sql .=
" AND (date_end >= '".$db->idate($from_time, $gm).
"' OR date_end IS NULL)";
467 $sql .=
" AND entity IN (".getEntity(
'accounting_fiscalyear').
")";
468 $sql .=
$db->order(
'date_start',
'DESC');
469 $sql .=
$db->plimit(1);
471 $res =
$db->query($sql);
473 if (
$db->num_rows($res) > 0) {
475 $obj =
$db->fetch_object($res);
482 $conf_fiscal_month_start =
getDolGlobalInt(
'SOCIETE_FISCAL_MONTH_START');
483 if ($conf_fiscal_month_start >= 1 && $conf_fiscal_month_start <= 12) {
484 $month_start = $conf_fiscal_month_start;
486 $year_start = $now_arr[
'year'];
487 if ($conf_fiscal_month_start > $now_arr[
'mon']) {
490 $year_end = $year_start + 1;
491 $month_end = $month_start - 1;
492 if ($month_end < 1) {
502 'date_end' => $date_end,
517 $sql =
"SELECT date_start, date_end FROM ".$db->prefix().
"accounting_fiscalyear";
518 $sql .=
" WHERE date_start > '".$db->idate($after_date, $gm).
"'";
519 $sql .=
" AND entity IN (".getEntity(
'accounting_fiscalyear').
")";
520 $sql .=
$db->order(
'date_start',
'ASC');
521 $sql .=
$db->plimit(1);
523 $res =
$db->query($sql);
525 if ($res &&
$db->num_rows($res) > 0) {
526 $obj =
$db->fetch_object($res);
529 $date_end =
$db->jdate($obj->date_end, $gm);
533 'date_end' => $date_end,
if(! $sortfield) if(! $sortorder) $object
accounting_transaction_prepare_head(BookKeeping $object, $mode='', $type='', $backtopage='/accountancy/bookkeeping/listbyaccount.php')
Prepare array with list of tabs for accounting transaction.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
accounting_prepare_head(AccountingAccount $object)
Prepare array with list of tabs.
getCurrentPeriodOfFiscalYear($db, $conf, $from_time=null, $gm='tzserver', $withenddateonly=1)
Get current period of fiscal year?
accountingTransactionTemplatePrepareHead(BookkeepingTemplate $object)
Prepare array with list of tabs for accounting transaction template.
journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='', $moreoptions=array())
Show header of a page used to transfer/dispatch data in accounting.
is_empty($var, $allow_false=false, $allow_ws=false)
Check if a value is empty with some options.
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
clean_account($account)
Return accounting account without zero on the right.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
checkGeneralAccountAllowsAuxiliary($db, $general_account, $auxiliary_account, $general_account_id=0)
Check if a general accounting account allows the use of an auxiliary account.
getNextFiscalYear($db, $after_date, $gm='tzserver')
Get next fiscal year period after a given date.
Class to manage accounting accounts.
Class to manage Ledger (General Ledger and Subledger)
Class for BookkeepingTemplate.
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.