32 public $element=
'accounting_journal';
37 public $table_element=
'accounting_journal';
42 public $fk_element =
'';
48 public $ismultientitymanaged = 0;
53 public $picto =
'generic';
89 function fetch($rowid = null, $journal_code = null)
93 if ($rowid || $journal_code)
95 $sql =
"SELECT rowid, code, label, nature, active";
96 $sql.=
" FROM ".MAIN_DB_PREFIX.
"accounting_journal";
99 $sql .=
" rowid = " . (int) $rowid;
101 elseif ($journal_code)
103 $sql .=
" code = '" . $this->db->escape($journal_code) .
"'";
104 $sql .=
" AND entity = " . $conf->entity;
107 dol_syslog(get_class($this).
"::fetch sql=" . $sql, LOG_DEBUG);
108 $result = $this->db->query($sql);
111 $obj = $this->db->fetch_object($result);
114 $this->
id = $obj->rowid;
115 $this->rowid = $obj->rowid;
117 $this->code = $obj->code;
118 $this->ref = $obj->code;
119 $this->
label = $obj->label;
120 $this->nature = $obj->nature;
121 $this->active = $obj->active;
130 $this->error =
"Error " . $this->db->lasterror();
131 $this->errors[] =
"Error " . $this->db->lasterror();
149 function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
151 $sql =
"SELECT rowid, code, label, nature, active";
152 $sql .=
' FROM ' . MAIN_DB_PREFIX . $this->table_element .
' as t';
155 if (count($filter) > 0) {
156 foreach ( $filter as $key => $value ) {
157 if ($key ==
't.code' || $key ==
't.label' || $key ==
't.nature') {
158 $sqlwhere[] = $key .
'\'' . $this->db->escape($value) .
'\'';
159 } elseif ($key ==
't.rowid' || $key ==
't.active') {
160 $sqlwhere[] = $key .
'=' . $value;
164 $sql .=
' WHERE 1 = 1';
165 $sql .=
" AND entity IN (" .
getEntity(
'accountancy') .
")";
166 if (count($sqlwhere) > 0) {
167 $sql .=
' AND ' . implode(
' ' . $filtermode .
' ', $sqlwhere);
170 if (! empty($sortfield)) {
171 $sql .= $this->db->order($sortfield, $sortorder);
173 if (! empty($limit)) {
174 $sql .=
' ' . $this->db->plimit($limit + 1, $offset);
176 $this->lines = array();
178 dol_syslog(get_class($this) .
"::fetch sql=" . $sql, LOG_DEBUG);
179 $resql = $this->db->query($sql);
181 $num = $this->db->num_rows(
$resql);
183 while ( $obj = $this->db->fetch_object(
$resql) ) {
184 $line =
new self($this->db);
186 $line->id = $obj->rowid;
187 $line->code = $obj->code;
188 $line->label = $obj->label;
189 $line->nature = $obj->nature;
190 $line->active = $obj->active;
192 $this->lines[] = $line;
199 $this->errors[] =
'Error ' . $this->db->lasterror();
200 dol_syslog(__METHOD__ .
' ' . join(
',', $this->errors), LOG_ERR);
216 function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle=
'',$notooltip=0)
218 global $langs, $conf, $user;
220 if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;
224 $url = DOL_URL_ROOT .
'/accountancy/admin/journals_list.php?id=35';
226 $label =
'<u>' . $langs->trans(
"ShowAccountingJournal") .
'</u>';
227 if (! empty($this->code))
228 $label .=
'<br><b>'.$langs->trans(
'Code') .
':</b> ' . $this->code;
229 if (! empty($this->
label))
230 $label .=
'<br><b>'.$langs->trans(
'Label') .
':</b> ' . $this->label;
231 if ($moretitle) $label.=
' - '.$moretitle;
234 if (empty($notooltip))
236 if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
238 $label=$langs->trans(
"ShowAccoutingJournal");
239 $linkclose.=
' alt="'.dol_escape_htmltag($label, 1).
'"';
241 $linkclose.=
' title="'.dol_escape_htmltag($label, 1).
'"';
242 $linkclose.=
' class="classfortooltip"';
245 $linkstart=
'<a href="'.$url.
'"';
246 $linkstart.=$linkclose.
'>';
256 $label_link = $this->code;
257 if ($withlabel) $label_link .=
' - ' . $this->label;
259 $result .= $linkstart;
260 if ($withpicto) $result.=
img_object(($notooltip?
'':$label), ($this->picto?$this->picto:
'generic'), ($notooltip?(($withpicto != 2) ?
'class="paddingright"' :
''):
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip?0:1);
261 if ($withpicto != 2) $result.= $label_link;
275 return $this->
LibType($this->nature,$mode);
291 $langs->loadLangs(array(
"accountancy"));
296 if ($nature == 9)
return $langs->trans(
'AccountingJournalType9');
297 if ($nature == 5)
return $langs->trans(
'AccountingJournalType5');
298 if ($nature == 4)
return $langs->trans(
'AccountingJournalType4');
299 if ($nature == 3)
return $langs->trans(
'AccountingJournalType3');
300 if ($nature == 2)
return $langs->trans(
'AccountingJournalType2');
301 if ($nature == 1)
return $langs->trans(
'AccountingJournalType1');
305 if ($nature == 9)
return $langs->trans(
'AccountingJournalType9');
306 if ($nature == 5)
return $langs->trans(
'AccountingJournalType5');
307 if ($nature == 4)
return $langs->trans(
'AccountingJournalType4');
308 if ($nature == 3)
return $langs->trans(
'AccountingJournalType3');
309 if ($nature == 2)
return $langs->trans(
'AccountingJournalType2');
310 if ($nature == 1)
return $langs->trans(
'AccountingJournalType1');
print $object label
hash of file content (md5_file(dol_osencode($destfull))
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
getNomUrl($withpicto=0, $withlabel=0, $nourl=0, $moretitle='', $notooltip=0)
Return clicable name (with picto eventually)
__construct($db)
Constructor.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
getLibType($mode=0)
Retourne le libelle du statut d'un user (actif, inactif)
LibType($nature, $mode=0)
Return type of an accounting journal.
fetch($rowid=null, $journal_code=null)
Load an object from database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load object in memory from the database.
Class to manage accounting accounts.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)