38function is_empty($var, $allow_false =
false, $allow_ws =
false)
40 if (!isset($var) || is_null($var) || ($allow_ws ==
false && trim($var) ==
"" && !is_bool($var)) || ($allow_false ===
false && is_bool($var) && $var ===
false) || (is_array($var) && empty($var))) {
59 $head[$h][0] = DOL_URL_ROOT.
'/accountancy/admin/card.php?id='.
$object->id;
60 $head[$h][1] = $langs->trans(
"AccountAccounting");
61 $head[$h][2] =
'card';
83 $account = rtrim($account,
"0");
98 if ($account < 0 ||
is_empty($account)) {
109 $i = strlen($account);
137 if ($accounta < 0 ||
is_empty($accounta)) {
148 $i = strlen($accounta);
184function journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink =
'', $moreparam = array(), $calcmode =
'', $varlink =
'', $moreoptions = array())
188 print
"\n\n<!-- start banner journal -->\n";
191 $varlink =
'?'.$varlink;
196 $head[$h][0] = $_SERVER[
"PHP_SELF"].$varlink;
197 $head[$h][1] = $langs->trans(
"Journalization");
198 $head[$h][2] =
'journal';
200 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].$varlink.
'">';
201 print
'<input type="hidden" name="token" value="'.newToken().
'">';
205 foreach ($moreparam as $key => $value) {
206 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
208 print
'<table class="border centpercent tableforfield">';
212 print
'<td class="titlefieldcreate">'.$langs->trans(
"Name").
'</td>';
213 print
'<td colspan="3">';
221 print
'<td>'.$langs->trans(
"CalculationMode").
'</td>';
223 print
'<td colspan="3">';
229 print
'</td><td colspan="2">'.$variant;
237 print
'<td>'.$langs->trans(
"ReportPeriod").
'</td>';
239 print
'<td colspan="3">';
247 print
'</td><td colspan="2">'.$periodlink;
254 print
'<td>'.$langs->trans(
"ReportDescription").
'</td>';
255 print
'<td colspan="3">'.$description.
'</td>';
260 foreach ($moreoptions as $key => $value) {
262 print
'<td>'.$langs->trans($key).
'</td>';
263 print
'<td colspan="3">'.$value.
'</td>';
271 print
'<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans(
"Refresh").
'"></div>';
275 print
"\n<!-- end banner journal -->\n\n";
293 $periodbydefaultontransfer =
getDolGlobalInt(
'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', 0);
294 if ($periodbydefaultontransfer == 2) {
295 $sql =
"SELECT date_start, date_end FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear";
296 $sql .=
" WHERE date_start < '".$db->idate(
dol_now()).
"' AND date_end > '".$db->idate(
dol_now()).
"'";
297 $sql .= $db->plimit(1);
298 $res = $db->query($sql);
299 if ($res->num_rows > 0) {
300 $obj = $db->fetch_object($res);
302 $date_start = $db->jdate($obj->date_start);
303 $date_end = $db->jdate($obj->date_end);
308 $year_start = $year_start - 1;
310 $year_end = $year_start + 1;
311 $month_end = $month_start - 1;
312 if ($month_end < 1) {
316 $date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
319 } elseif ($periodbydefaultontransfer == 1) {
322 $pastmonthyear = $year_current;
323 if ($pastmonth == 0) {
330 $pastmonthyear = $year_current;
331 if ($pastmonth == 0) {
338 'date_start' => $date_start,
339 'date_end' => $date_end,
340 'pastmonthyear' => $pastmonthyear,
341 'pastmonth' => $pastmonth
357 if ($from_time ===
null) {
360 $from_db_time = $db->idate($from_time);
362 $sql =
"SELECT date_start, date_end FROM ".$db->prefix().
"accounting_fiscalyear";
363 $sql .=
" WHERE date_start <= '".$db->escape($from_db_time).
"' AND date_end >= '".$db->escape($from_db_time).
"'";
364 $sql .= $db->order(
'date_start',
'DESC');
365 $sql .= $db->plimit(1);
366 $res = $db->query($sql);
367 if ($db->num_rows($res) > 0) {
368 $obj = $db->fetch_object($res);
370 $date_start = $db->jdate($obj->date_start);
371 $date_end = $db->jdate($obj->date_end);
374 $conf_fiscal_month_start = (int) $conf->global->SOCIETE_FISCAL_MONTH_START;
375 if ($conf_fiscal_month_start >= 1 && $conf_fiscal_month_start <= 12) {
376 $month_start = $conf_fiscal_month_start;
378 $year_start = $now_arr[
'year'];
379 if ($conf_fiscal_month_start > $now_arr[
'mon']) {
380 $year_start = $year_start - 1;
382 $year_end = $year_start + 1;
383 $month_end = $month_start - 1;
384 if ($month_end < 1) {
388 $date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
393 'date_start' => $date_start,
394 'date_end' => $date_end,
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
getCurrentPeriodOfFiscalYear($db, $conf, $from_time=null)
Get current period of fiscal year.
accounting_prepare_head(AccountingAccount $object)
Prepare array with list of tabs.
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.
Class to manage accounting accounts.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
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 dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.