|
@@ -48,64 +48,114 @@ class AccountingJournal extends CommonObject
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Load an object from database
|
|
|
- *
|
|
|
- * @param int $id Id of record to load
|
|
|
- * @return int <0 if KO, >0 if OK
|
|
|
- */
|
|
|
- function fetch($id)
|
|
|
+ * Load an object from database
|
|
|
+ *
|
|
|
+ * @param int $rowid Id of record to load
|
|
|
+ * @param string $journal_code Journal code
|
|
|
+ * @return int <0 if KO, Id of record if OK and found
|
|
|
+ */
|
|
|
+ function fetch($rowid = null, $journal_code = null)
|
|
|
{
|
|
|
- $sql = "SELECT rowid, code, label, nature, active";
|
|
|
- $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
|
|
|
- $sql.= " WHERE rowid = ".$id;
|
|
|
-
|
|
|
- dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG);
|
|
|
- $result = $this->db->query($sql);
|
|
|
- if ( $result )
|
|
|
+ if ($rowid || $journal_code)
|
|
|
{
|
|
|
- $obj = $this->db->fetch_object($result);
|
|
|
+ $sql = "SELECT rowid, code, label, nature, active";
|
|
|
+ $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
|
|
|
+ $sql .= " WHERE";
|
|
|
+ if ($rowid) {
|
|
|
+ $sql .= " rowid = '" . $rowid . "'";
|
|
|
+ } elseif ($journal_code) {
|
|
|
+ $sql .= " code = '" . $journal_code . "'";
|
|
|
+ }
|
|
|
|
|
|
- $this->id = $obj->rowid;
|
|
|
+ dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG);
|
|
|
+ $result = $this->db->query($sql);
|
|
|
+ if ($result)
|
|
|
+ {
|
|
|
+ $obj = $this->db->fetch_object($result);
|
|
|
|
|
|
- $this->code = $obj->code;
|
|
|
- $this->ref = $obj->code;
|
|
|
- $this->label = $obj->label;
|
|
|
- $this->nature = $obj->nature;
|
|
|
- $this->active = $obj->active;
|
|
|
+ if ($obj) {
|
|
|
+ $this->id = $obj->rowid;
|
|
|
+ $this->rowid = $obj->rowid;
|
|
|
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $this->error=$this->db->lasterror();
|
|
|
- return -1;
|
|
|
+ $this->code = $obj->code;
|
|
|
+ $this->ref = $obj->code;
|
|
|
+ $this->label = $obj->label;
|
|
|
+ $this->nature = $obj->nature;
|
|
|
+ $this->active = $obj->active;
|
|
|
+
|
|
|
+ return $this->id;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $this->error = "Error " . $this->db->lasterror();
|
|
|
+ $this->errors[] = "Error " . $this->db->lasterror();
|
|
|
+ }
|
|
|
}
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Return clicable name (with picto eventually)
|
|
|
*
|
|
|
- * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
|
|
- * @return string Chaine avec URL
|
|
|
+ * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
|
|
+ * @param int $withlabel 0=No label, 1=Include label of journal
|
|
|
+ * @param int $nourl 1=Disable url
|
|
|
+ * @param string $moretitle Add more text to title tooltip
|
|
|
+ * @param int $notooltip 1=Disable tooltip
|
|
|
+ * @return string String with URL
|
|
|
*/
|
|
|
- function getNomUrl($withpicto = 0) {
|
|
|
- global $langs;
|
|
|
+ function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0)
|
|
|
+ {
|
|
|
+ global $langs, $conf, $user;
|
|
|
+
|
|
|
+ if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
|
|
|
|
|
|
$result = '';
|
|
|
|
|
|
- $link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/journals_card.php?id=' . $this->id . '">';
|
|
|
- $linkend = '</a>';
|
|
|
+ $url = DOL_URL_ROOT . '/accountancy/admin/journals_list.php?id=35';
|
|
|
|
|
|
$picto = 'billr';
|
|
|
+ $label='';
|
|
|
+
|
|
|
+ $label = '<u>' . $langs->trans("ShowAccountingJournal") . '</u>';
|
|
|
+ if (! empty($this->code))
|
|
|
+ $label .= '<br><b>'.$langs->trans('Code') . ':</b> ' . $this->code;
|
|
|
+ if (! empty($this->label))
|
|
|
+ $label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $this->label;
|
|
|
+ if ($moretitle) $label.=' - '.$moretitle;
|
|
|
+
|
|
|
+ $linkclose='';
|
|
|
+ if (empty($notooltip))
|
|
|
+ {
|
|
|
+ if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
|
|
+ {
|
|
|
+ $label=$langs->trans("ShowAccoutingJournal");
|
|
|
+ $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
|
|
+ }
|
|
|
+ $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
|
|
|
+ $linkclose.=' class="classfortooltip"';
|
|
|
+ }
|
|
|
+
|
|
|
+ $linkstart='<a href="'.$url.'"';
|
|
|
+ $linkstart.=$linkclose.'>';
|
|
|
+ $linkend='</a>';
|
|
|
+
|
|
|
+ if ($nourl)
|
|
|
+ {
|
|
|
+ $linkstart = '';
|
|
|
+ $linkclose = '';
|
|
|
+ $linkend = '';
|
|
|
+ }
|
|
|
|
|
|
- $label = $langs->trans("Show") . ': ' . $this->code . ' - ' . $this->label;
|
|
|
+ $label_link = $this->code;
|
|
|
+ if ($withlabel) $label_link .= ' - ' . $this->label;
|
|
|
|
|
|
- if ($withpicto)
|
|
|
- $result .= ($link . img_object($label, $picto) . $linkend);
|
|
|
- if ($withpicto && $withpicto != 2)
|
|
|
- $result .= ' ';
|
|
|
- if ($withpicto != 2)
|
|
|
- $result .= $link . $this->code . ' - ' . $this->label . $linkend;
|
|
|
+ if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
|
|
|
+ if ($withpicto && $withpicto != 2) $result .= ' ';
|
|
|
+ if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend;
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
@@ -136,19 +186,19 @@ class AccountingJournal extends CommonObject
|
|
|
if ($mode == 0)
|
|
|
{
|
|
|
$prefix='';
|
|
|
- if ($nature == 9) return $langs->trans('AccountingJournalTypeHasNew');
|
|
|
- if ($nature == 3) return $langs->trans('AccountingJournalTypeBank');
|
|
|
- if ($nature == 2) return $langs->trans('AccountingJournalTypePurchase');
|
|
|
- if ($nature == 1) return $langs->trans('AccountingJournalTypeSale');
|
|
|
- if ($nature == 0) return $langs->trans('AccountingJournalTypeVariousOperation');
|
|
|
+ if ($nature == 9) return $langs->trans('AccountingJournalType9');
|
|
|
+ if ($nature == 4) return $langs->trans('AccountingJournalType4');
|
|
|
+ if ($nature == 3) return $langs->trans('AccountingJournalType3');
|
|
|
+ if ($nature == 2) return $langs->trans('AccountingJournalType2');
|
|
|
+ if ($nature == 1) return $langs->trans('AccountingJournalType1');
|
|
|
}
|
|
|
if ($mode == 1)
|
|
|
{
|
|
|
- if ($nature == 9) return $langs->trans('AccountingJournalTypeHasNew');
|
|
|
- if ($nature == 3) return $langs->trans('AccountingJournalTypeBank');
|
|
|
- if ($nature == 2) return $langs->trans('AccountingJournalTypePurchase');
|
|
|
- if ($nature == 1) return $langs->trans('AccountingJournalTypeSale');
|
|
|
- if ($nature == 0) return $langs->trans('AccountingJournalTypeVariousOperation');
|
|
|
+ if ($nature == 9) return $langs->trans('AccountingJournalType9');
|
|
|
+ if ($nature == 4) return $langs->trans('AccountingJournalType4');
|
|
|
+ if ($nature == 3) return $langs->trans('AccountingJournalType3');
|
|
|
+ if ($nature == 2) return $langs->trans('AccountingJournalType2');
|
|
|
+ if ($nature == 1) return $langs->trans('AccountingJournalType1');
|
|
|
}
|
|
|
}
|
|
|
}
|