27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
37 public $element =
'fiscalyear';
42 public $picto =
'calendar';
47 public $table_element =
'accounting_fiscalyear';
52 public $table_element_line =
'';
57 public $fk_element =
'';
108 const STATUS_OPEN = 0;
109 const STATUS_CLOSED = 1;
121 $this->ismultientitymanaged = 1;
122 $this->labelStatusShort = array(self::STATUS_OPEN =>
'Opened', self::STATUS_CLOSED =>
'Closed');
123 $this->labelStatus = array(self::STATUS_OPEN =>
'Opened', self::STATUS_CLOSED =>
'Closed');
142 $sql =
"INSERT INTO ".$this->db->prefix().
"accounting_fiscalyear (";
144 $sql .=
", date_start";
145 $sql .=
", date_end";
149 $sql .=
", fk_user_author";
150 $sql .=
") VALUES (";
151 $sql .=
" '".$this->db->escape($this->label).
"'";
152 $sql .=
", '".$this->db->idate($this->date_start).
"'";
153 $sql .=
", ".($this->date_end ?
"'".$this->db->idate($this->date_end).
"'" :
"null");
155 $sql .=
", ".((int) $conf->entity);
156 $sql .=
", '".$this->db->idate($now).
"'";
157 $sql .=
", ".((int) $user->id);
160 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
161 $result = $this->db->query($sql);
163 $this->
id = $this->db->last_insert_id($this->db->prefix().
"accounting_fiscalyear");
165 $result = $this->
update($user);
170 $this->error = $this->db->lasterror();
171 $this->db->rollback();
175 $this->error = $this->db->lasterror().
" sql=".$sql;
176 $this->db->rollback();
190 if (empty($this->date_start) && empty($this->date_end)) {
191 $this->error =
'ErrorBadParameter';
197 $sql =
"UPDATE ".$this->db->prefix().
"accounting_fiscalyear";
198 $sql .=
" SET label = '".$this->db->escape($this->label).
"'";
199 $sql .=
", date_start = '".$this->db->idate($this->date_start).
"'";
200 $sql .=
", date_end = ".($this->date_end ?
"'".$this->db->idate($this->date_end).
"'" :
"null");
201 $sql .=
", statut = '".$this->db->escape($this->
status ? $this->
status : 0).
"'";
202 $sql .=
", fk_user_modif = ".((int) $user->id);
203 $sql .=
" WHERE rowid = ".((int) $this->
id);
205 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
206 $result = $this->db->query($sql);
211 $this->error = $this->db->lasterror();
213 $this->db->rollback();
226 $sql =
"SELECT rowid, label, date_start, date_end, statut as status";
227 $sql .=
" FROM ".$this->db->prefix().
"accounting_fiscalyear";
228 $sql .=
" WHERE rowid = ".((int) $id);
230 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
231 $result = $this->db->query($sql);
233 $obj = $this->db->fetch_object($result);
235 $this->
id = $obj->rowid;
236 $this->
ref = $obj->rowid;
237 $this->date_start = $this->db->jdate($obj->date_start);
238 $this->date_end = $this->db->jdate($obj->date_end);
239 $this->label = $obj->label;
240 $this->
statut = $obj->status;
241 $this->
status = $obj->status;
245 $this->error = $this->db->lasterror();
256 public function delete($user)
260 $sql =
"DELETE FROM ".$this->db->prefix().
"accounting_fiscalyear";
261 $sql .=
" WHERE rowid = ".((int) $this->
id);
263 $result = $this->db->query($sql);
268 $this->error = $this->db->lasterror();
269 $this->db->rollback();
285 $langs->load(
'compta');
288 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <b><u>'.$langs->trans(
"FiscalPeriod").
'</u></b>';
289 if (isset($this->
status)) {
290 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
292 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
293 if (isset($this->date_start)) {
294 $datas[
'date_start'] =
'<br><b>'.$langs->trans(
'DateStart').
':</b> '.
dol_print_date($this->date_start,
'day');
296 if (isset($this->date_start)) {
297 $datas[
'date_end'] =
'<br><b>'.$langs->trans(
'DateEnd').
':</b> '.
dol_print_date($this->date_end,
'day');
311 public function getNomUrl($withpicto = 0, $notooltip = 0, $save_lastsearch_value = -1)
313 global $conf, $langs, $user;
315 if (empty($this->
ref)) {
316 $this->
ref = (string) $this->
id;
319 if (!empty($conf->dol_no_mouse_hover)) {
323 if (!$user->hasRight(
'accounting',
'fiscalyear',
'write')) {
329 'objecttype' => $this->element,
333 $classfortooltip =
'classfortooltip';
336 $classfortooltip =
'classforajaxtooltip';
337 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
338 $label =
'ToComplete';
342 $url = DOL_URL_ROOT.
'/accountancy/admin/fiscalyear_card.php?id='.$this->id;
344 if ($option !==
'nolink') {
346 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
347 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
348 $add_save_lastsearch_values = 1;
350 if ($add_save_lastsearch_values) {
351 $url .=
'&save_lastsearch_values=1';
356 if (empty($notooltip) && $user->hasRight(
'accounting',
'fiscalyear',
'write')) {
358 $label = $langs->trans(
"FiscalPeriod");
359 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
361 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
362 $linkclose .= $dataparams.
' class="'.$classfortooltip.
'"';
365 $linkstart =
'<a href="'.$url.
'"';
366 $linkstart .= $linkclose.
'>';
369 if ($option ===
'nolink') {
374 $result .= $linkstart;
376 $result .=
img_object(($notooltip ?
'' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') : $dataparams.
' class="'.(($withpicto != 2) ?
'paddingright ' :
'').$classfortooltip.
'"'), 0, 0, $notooltip ? 0 : 1);
378 if ($withpicto != 2) {
379 $result .= $this->ref;
408 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
411 $this->labelStatus[self::STATUS_OPEN] = $langs->transnoentitiesnoconv(
'Draft');
412 $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv(
'Enabled');
413 $this->labelStatusShort[self::STATUS_OPEN] = $langs->transnoentitiesnoconv(
'Enabled');
414 $this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv(
'Disabled');
417 $statusType =
'status4';
419 if ($status == self::STATUS_CLOSED) {
420 $statusType =
'status6';
423 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
434 $sql =
"SELECT fy.rowid, fy.datec, fy.fk_user_author, fy.fk_user_modif,";
435 $sql .=
" fy.tms as datem";
436 $sql .=
" FROM ".$this->db->prefix().
"accounting_fiscalyear as fy";
437 $sql .=
" WHERE fy.rowid = ".((int) $id);
439 dol_syslog(get_class($this).
"::fetch info", LOG_DEBUG);
440 $result = $this->db->query($sql);
443 if ($this->db->num_rows($result)) {
444 $obj = $this->db->fetch_object($result);
446 $this->
id = $obj->rowid;
448 $this->user_creation_id = $obj->fk_user_author;
449 $this->user_modification_id = $obj->fk_user_modif;
450 $this->date_creation = $this->db->jdate($obj->datec);
451 $this->date_modification = $this->db->jdate($obj->datem);
453 $this->db->free($result);
470 if (empty($datestart)) {
471 $datestart = $this->date_start;
473 if (empty($dateend)) {
474 $dateend = $this->date_end;
477 $sql =
"SELECT count(DISTINCT piece_num) as nb";
478 $sql .=
" FROM ".$this->db->prefix().
"accounting_bookkeeping";
479 $sql .=
" WHERE entity IN (".getEntity(
'bookkeeping', 0).
")";
480 $sql .=
" AND doc_date >= '".$this->db->idate($datestart).
"' and doc_date <= '".$this->db->idate($dateend).
"'";
482 $resql = $this->db->query($sql);
484 $obj = $this->db->fetch_object($resql);
504 if (empty($datestart)) {
505 $datestart = $this->date_start;
507 if (empty($dateend)) {
508 $dateend = $this->date_end;
511 $sql =
"SELECT count(rowid) as nb";
512 $sql .=
" FROM ".$this->db->prefix().
"accounting_bookkeeping ";
513 $sql .=
" WHERE entity IN (".getEntity(
'bookkeeping', 0).
")";
514 $sql .=
" AND doc_date >= '".$this->db->idate($datestart).
"' and doc_date <= '".$this->db->idate($dateend).
"'";
516 $resql = $this->db->query($sql);
518 $obj = $this->db->fetch_object($resql);
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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).
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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut