27require_once DOL_DOCUMENT_ROOT .
'/core/class/commonobject.class.php';
28require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/bookkeepingtemplateline.class.php';
38 public $module =
'accountancy';
43 public $element =
'accounting_transaction_template';
48 public $table_element =
'accounting_transaction_template';
53 public $ismultientitymanaged = 1;
58 public $isextrafieldmanaged = 1;
63 public $picto =
'fa-list';
94 public $fields = array(
95 "rowid" => array(
"type" =>
"integer",
"label" =>
"TechnicalID",
"enabled" => 1,
'position' => 1,
'notnull' => 1,
"visible" => 0,
"noteditable" => 1,
"index" => 1,
"css" =>
"left",
"comment" =>
"Id"),
96 "entity" => array(
"type" =>
"integer",
"label" =>
"Entity",
"enabled" => 1,
'position' => 5,
'notnull' => 1,
"visible" => 0,
"index" => 1,
"default" =>
'1'),
97 "code" => array(
"type" =>
"varchar(128)",
"label" =>
"Code",
"enabled" => 1,
'position' => 10,
'notnull' => 1,
"visible" => 1,
"index" => 1,
"searchall" => 1,
"css" =>
"minwidth300",
"help" =>
"UniqueCodeForTemplate"),
98 "label" => array(
"type" =>
"varchar(255)",
"label" =>
"Label",
"enabled" => 1,
'position' => 20,
'notnull' => 0,
"visible" => 1,
"css" =>
"minwidth300"),
99 "date_creation" => array(
"type" =>
"datetime",
"label" =>
"DateCreation",
"enabled" => 1,
'position' => 500,
'notnull' => 1,
"visible" => -2),
100 "tms" => array(
"type" =>
"timestamp",
"label" =>
"DateModification",
"enabled" => 1,
'position' => 501,
'notnull' => 0,
"visible" => -2),
101 "fk_user_creat" => array(
"type" =>
"integer:User:user/class/user.class.php",
"label" =>
"UserAuthor",
"picto" =>
"user",
"enabled" => 1,
'position' => 510,
'notnull' => 1,
"visible" =>
"-2",
"csslist" =>
"tdoverflowmax150"),
102 "fk_user_modif" => array(
"type" =>
"integer:User:user/class/user.class.php",
"label" =>
"UserModif",
"picto" =>
"user",
"enabled" => 1,
'position' => 511,
'notnull' => -1,
"visible" =>
"-2",
"csslist" =>
"tdoverflowmax150"),
103 "import_key" => array(
"type" =>
"varchar(14)",
"label" =>
"ImportId",
"enabled" => 1,
'position' => 1000,
'notnull' => -1,
"visible" => -2),
130 public $date_creation;
140 public $fk_user_creat;
145 public $fk_user_modif;
155 public $table_element_line =
'accounting_transaction_template_det';
160 public $lines = array();
170 global
$conf, $langs;
174 if (!
getDolGlobalInt(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid'], $this->fields[
'code']) && is_array($this->fields[
'rowid'])) {
175 $this->fields[
'rowid'][
'visible'] = 0;
177 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
178 $this->fields[
'entity'][
'enabled'] = 0;
182 foreach ($this->fields as $key => $val) {
183 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
184 unset($this->fields[$key]);
189 if (is_object($langs)) {
190 foreach ($this->fields as $key => $val) {
191 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
192 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
193 $this->fields[$key][
'arrayofkeyval'][$key2] = (
string) $langs->trans($val2);
210 return $resultcreate;
222 global $langs, $extrafields;
232 $result =
$object->fetchCommon($fromid);
233 if ($result > 0 && !empty(
$object->table_element_line)) {
247 $object->context[
'createfromclone'] =
'createfromclone';
248 $result =
$object->createCommon($user);
258 foreach ($this->lines as $linetoclone) {
260 unset($linetoclone->id);
261 unset($linetoclone->fk_user_creat);
262 $linetoclone->fk_transaction_template =
$object->id;
265 $linetoclone->createCommon($user);
269 unset(
$object->context[
'createfromclone']);
276 $this->db->rollback();
290 public function fetch($id, $code =
null, $noextrafields = 0, $nolines = 0)
292 $result = $this->
fetchCommon($id, $code,
'', $noextrafields);
293 if ($result > 0 && !empty($this->table_element_line) && empty($nolines)) {
307 $this->lines = array();
310 $result = $objectline->fetchAll(
'ASC',
'rowid', 0, 0, array(
'customsql' =>
'fk_transaction_template = ' . ((
int) $this->
id)));
312 if (is_numeric($result)) {
316 $this->lines = $result;
340 public function delete(
User $user, $notrigger = 0)
342 global
$conf, $langs;
351 $sql =
"DELETE FROM ".$this->db->prefix().$obj_line->table_element;
352 $sql .=
" WHERE fk_transaction_template = ".((int) $this->
id);
354 dol_syslog(get_class($this).
"::delete sql=".$sql, LOG_DEBUG);
356 $resql = $this->db->query($sql);
358 $this->errors[] = $this->db->lasterror();
360 dol_syslog(get_class($this).
"::delete error deleting lines: ".$this->db->lasterror(), LOG_ERR);
366 $result = $this->call_trigger(strtoupper(get_class($this)).
'_DELETE', $user);
375 $sql =
"DELETE FROM ".$this->db->prefix().$this->table_element;
376 $sql .=
" WHERE rowid = ".((int) $this->
id);
378 dol_syslog(get_class($this).
"::delete sql=".$sql, LOG_DEBUG);
380 $resql = $this->db->query($sql);
382 $this->errors[] = $this->db->lasterror();
383 $this->error = $this->db->lasterror();
385 dol_syslog(get_class($this).
"::delete error deleting main object: ".$this->db->lasterror(), LOG_ERR);
394 $this->error = implode(
', ', $this->errors);
395 $this->db->rollback();
411 if ($tmpline->fetch($idline) > 0) {
412 return $tmpline->delete($user);
425 $this->lines = array();
428 $result = $objectline->fetchAll(
'ASC',
'rowid', 0, 0, array(
'customsql' =>
'fk_transaction_template = ' . ((
int) $this->
id)));
430 if (is_numeric($result)) {
434 $this->lines = $result;
446 global $langs,
$conf;
447 $langs->load(
"accountancy");
465 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
467 global
$conf, $langs, $hookmanager;
469 if (!empty(
$conf->dol_no_mouse_hover)) {
475 $label =
img_picto(
'', $this->picto) .
' <u>' . $langs->trans(
"BookkeepingTemplate") .
'</u>';
476 if (isset($this->code)) {
477 $label .=
'<br><b>' . $langs->trans(
'Code') .
':</b> ' . $this->code;
479 if (isset($this->label)) {
480 $label .=
'<br><b>' . $langs->trans(
'Label') .
':</b> ' . $this->label;
483 $url = DOL_URL_ROOT .
'/accountancy/admin/template/card.php?id=' . $this->id;
485 if ($option !=
'nolink') {
487 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
488 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
489 $add_save_lastsearch_values = 1;
491 if ($add_save_lastsearch_values) {
492 $url .=
'&save_lastsearch_values=1';
497 if (empty($notooltip)) {
499 $label = $langs->trans(
"ShowBookkeepingTemplate");
503 $linkclose .=
' class="classfortooltip' . ($morecss ?
' ' . $morecss :
'') .
'"';
505 $linkclose = ($morecss ?
' class="' . $morecss .
'"' :
'');
508 if ($option ==
'nolink') {
509 $linkstart =
'<span';
511 $linkstart =
'<a href="' . $url .
'"';
513 $linkstart .= $linkclose .
'>';
514 if ($option ==
'nolink') {
515 $linkend =
'</span>';
520 $result .= $linkstart;
523 $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);
526 if ($withpicto != 2) {
527 $result .= $this->code;
if(! $sortfield) if(! $sortorder) $object
Class for BookkeepingTemplate.
getLinesArray()
Create an array of lines.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
fetchLines($noextrafields=0)
Load object lines in memory from the database.
LibStatut($status, $mode=0)
Return label of a given status.
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0)
Return label of status.
create(User $user, $notrigger=0)
Create object into database.
createFromClone(User $user, $fromid)
Clone an object into another one.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
update(User $user, $notrigger=0)
Update object into database.
fetch($id, $code=null, $noextrafields=0, $nolines=0)
Load object in memory from the database.
Class for BookkeepingTemplateLine.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php