26require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
36 public $element =
'fiscalyear';
41 public $picto =
'calendar';
46 public $table_element =
'accounting_fiscalyear';
51 public $table_element_line =
'';
56 public $fk_element =
'';
62 public $ismultientitymanaged = 1;
113 const STATUS_OPEN = 0;
114 const STATUS_CLOSED = 1;
143 $sql =
"INSERT INTO ".$this->db->prefix().
"accounting_fiscalyear (";
145 $sql .=
", date_start";
146 $sql .=
", date_end";
150 $sql .=
", fk_user_author";
151 $sql .=
") VALUES (";
152 $sql .=
" '".$this->db->escape($this->label).
"'";
153 $sql .=
", '".$this->db->idate($this->date_start).
"'";
154 $sql .=
", ".($this->date_end ?
"'".$this->db->idate($this->date_end).
"'" :
"null");
156 $sql .=
", ".((int) $conf->entity);
157 $sql .=
", '".$this->db->idate($now).
"'";
158 $sql .=
", ".((int) $user->id);
161 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
162 $result = $this->db->query($sql);
164 $this->
id = $this->db->last_insert_id($this->db->prefix().
"accounting_fiscalyear");
166 $result = $this->
update($user);
171 $this->error = $this->db->lasterror();
172 $this->db->rollback();
176 $this->error = $this->db->lasterror().
" sql=".$sql;
177 $this->db->rollback();
191 if (empty($this->date_start) && empty($this->date_end)) {
192 $this->error =
'ErrorBadParameter';
198 $sql =
"UPDATE ".$this->db->prefix().
"accounting_fiscalyear";
199 $sql .=
" SET label = '".$this->db->escape($this->label).
"'";
200 $sql .=
", date_start = '".$this->db->idate($this->date_start).
"'";
201 $sql .=
", date_end = ".($this->date_end ?
"'".$this->db->idate($this->date_end).
"'" :
"null");
202 $sql .=
", statut = '".$this->db->escape($this->
status ? $this->
status : 0).
"'";
203 $sql .=
", fk_user_modif = ".((int) $user->id);
204 $sql .=
" WHERE rowid = ".((int) $this->
id);
206 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
207 $result = $this->db->query($sql);
212 $this->error = $this->db->lasterror();
214 $this->db->rollback();
227 $sql =
"SELECT rowid, label, date_start, date_end, statut as status";
228 $sql .=
" FROM ".$this->db->prefix().
"accounting_fiscalyear";
229 $sql .=
" WHERE rowid = ".((int) $id);
231 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
232 $result = $this->db->query($sql);
234 $obj = $this->db->fetch_object($result);
236 $this->
id = $obj->rowid;
237 $this->
ref = $obj->rowid;
238 $this->date_start = $this->db->jdate($obj->date_start);
239 $this->date_end = $this->db->jdate($obj->date_end);
240 $this->label = $obj->label;
241 $this->
statut = $obj->status;
242 $this->
status = $obj->status;
246 $this->error = $this->db->lasterror();
257 public function delete($id)
261 $sql =
"DELETE FROM ".$this->db->prefix().
"accounting_fiscalyear WHERE rowid = ".((int) $id);
263 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
264 $result = $this->db->query($sql);
269 $this->error = $this->db->lasterror();
270 $this->db->rollback();
286 $langs->load(
'compta');
289 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <b><u>'.$langs->trans(
"FiscalPeriod").
'</u></b>';
290 if (isset($this->
status)) {
291 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
293 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
294 if (isset($this->date_start)) {
295 $datas[
'date_start'] =
'<br><b>'.$langs->trans(
'DateStart').
':</b> '.
dol_print_date($this->date_start,
'day');
297 if (isset($this->date_start)) {
298 $datas[
'date_end'] =
'<br><b>'.$langs->trans(
'DateEnd').
':</b> '.
dol_print_date($this->date_end,
'day');
312 public function getNomUrl($withpicto = 0, $notooltip = 0, $save_lastsearch_value = -1)
314 global $conf, $langs, $user;
316 if (empty($this->
ref)) {
317 $this->
ref = $this->id;
320 if (!empty($conf->dol_no_mouse_hover)) {
324 if (!$user->hasRight(
'accounting',
'fiscalyear',
'write')) {
330 'objecttype' => $this->element,
334 $classfortooltip =
'classfortooltip';
337 $classfortooltip =
'classforajaxtooltip';
338 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
339 $label =
'ToComplete';
343 $url = DOL_URL_ROOT.
'/accountancy/admin/fiscalyear_card.php?id='.$this->id;
345 if ($option !==
'nolink') {
347 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
348 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
349 $add_save_lastsearch_values = 1;
351 if ($add_save_lastsearch_values) {
352 $url .=
'&save_lastsearch_values=1';
357 if (empty($notooltip) && $user->hasRight(
'accounting',
'fiscalyear',
'write')) {
359 $label = $langs->trans(
"FiscalYear");
360 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
362 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
363 $linkclose .= $dataparams.
' class="'.$classfortooltip.
'"';
366 $linkstart =
'<a href="'.$url.
'"';
367 $linkstart .= $linkclose.
'>';
370 if ($option ===
'nolink') {
375 $result .= $linkstart;
377 $result .=
img_object(($notooltip ?
'' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') : $dataparams.
' class="'.(($withpicto != 2) ?
'paddingright ' :
'').$classfortooltip.
'"'), 0, 0, $notooltip ? 0 : 1);
379 if ($withpicto != 2) {
380 $result .= $this->ref;
409 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
412 $this->labelStatus[self::STATUS_OPEN] = $langs->transnoentitiesnoconv(
'FiscalYearOpened');
413 $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv(
'FiscalYearClosed');
414 $this->labelStatusShort[self::STATUS_OPEN] = $langs->transnoentitiesnoconv(
'FiscalYearOpenedShort');
415 $this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv(
'FiscalYearClosedShort');
418 $statusType =
'status4';
420 if ($status == self::STATUS_CLOSED) {
421 $statusType =
'status6';
424 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
435 $sql =
"SELECT fy.rowid, fy.datec, fy.fk_user_author, fy.fk_user_modif,";
436 $sql .=
" fy.tms as datem";
437 $sql .=
" FROM ".$this->db->prefix().
"accounting_fiscalyear as fy";
438 $sql .=
" WHERE fy.rowid = ".((int) $id);
440 dol_syslog(get_class($this).
"::fetch info", LOG_DEBUG);
441 $result = $this->db->query($sql);
444 if ($this->db->num_rows($result)) {
445 $obj = $this->db->fetch_object($result);
447 $this->
id = $obj->rowid;
449 $this->user_creation_id = $obj->fk_user_author;
450 $this->user_modification_id = $obj->fk_user_modif;
451 $this->date_creation = $this->db->jdate($obj->datec);
452 $this->date_modification = $this->db->jdate($obj->datem);
454 $this->db->free($result);
471 if (empty($datestart)) {
472 $datestart = $this->date_start;
474 if (empty($dateend)) {
475 $dateend = $this->date_end;
478 $sql =
"SELECT count(DISTINCT piece_num) as nb";
479 $sql .=
" FROM ".$this->db->prefix().
"accounting_bookkeeping";
480 $sql .=
" WHERE entity IN (".getEntity(
'bookkeeping', 0).
")";
481 $sql .=
" AND doc_date >= '".$this->db->idate($datestart).
"' and doc_date <= '".$this->db->idate($dateend).
"'";
483 $resql = $this->db->query($sql);
485 $obj = $this->db->fetch_object($resql);
505 if (empty($datestart)) {
506 $datestart = $this->date_start;
508 if (empty($dateend)) {
509 $dateend = $this->date_end;
512 $sql =
"SELECT count(rowid) as nb";
513 $sql .=
" FROM ".$this->db->prefix().
"accounting_bookkeeping ";
514 $sql .=
" WHERE entity IN (".getEntity(
'bookkeeping', 0).
")";
515 $sql .=
" AND doc_date >= '".$this->db->idate($datestart).
"' and doc_date <= '".$this->db->idate($dateend).
"'";
517 $resql = $this->db->query($sql);
519 $obj = $this->db->fetch_object($resql);
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Class to manage Dolibarr database access.
Class to manage fiscal year.
fetch($id)
Load an object from database.
getTooltipContentArray($params)
getTooltipContentArray
create($user)
Create object in database.
getAccountancyEntriesByFiscalYear($datestart='', $dateend='')
Return the number of entries by fiscal year.
getAccountancyMovementsByFiscalYear($datestart='', $dateend='')
Return the number of movements by fiscal year.
update($user)
Update record.
__construct(DoliDB $db)
Constructor.
info($id)
Information on record.
getLibStatut($mode=0)
Give a label from a status.
getNomUrl($withpicto=0, $notooltip=0, $save_lastsearch_value=-1)
Return clicable link of object (with eventually picto)
LibStatut($status, $mode=0)
Give a label from a status.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e e e e e statut