mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 01:28:19 +01:00
NEW: Add invoice subtype in customer template invoice (#26543)
* Add invoice subtype in template invoice * Add invoice subtype in template invoice * Add invoice subtype in template invoice
This commit is contained in:
@@ -204,21 +204,22 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$object->title = GETPOST('title', 'alphanohtml');
|
$object->subtype = GETPOST('subtype');
|
||||||
$object->note_private = GETPOST('note_private', 'restricthtml');
|
$object->title = GETPOST('title', 'alphanohtml');
|
||||||
$object->note_public = GETPOST('note_public', 'restricthtml');
|
$object->note_private = GETPOST('note_private', 'restricthtml');
|
||||||
$object->model_pdf = GETPOST('modelpdf', 'alphanohtml');
|
$object->note_public = GETPOST('note_public', 'restricthtml');
|
||||||
$object->usenewprice = GETPOST('usenewprice', 'alphanohtml');
|
$object->model_pdf = GETPOST('modelpdf', 'alphanohtml');
|
||||||
|
$object->usenewprice = GETPOST('usenewprice', 'alphanohtml');
|
||||||
|
|
||||||
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
|
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
|
||||||
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
|
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
|
||||||
|
|
||||||
$object->frequency = $frequency;
|
$object->frequency = $frequency;
|
||||||
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
|
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
|
||||||
$object->nb_gen_max = $nb_gen_max;
|
$object->nb_gen_max = $nb_gen_max;
|
||||||
$object->auto_validate = GETPOST('auto_validate', 'int');
|
$object->auto_validate = GETPOST('auto_validate', 'int');
|
||||||
$object->generate_pdf = GETPOST('generate_pdf', 'int');
|
$object->generate_pdf = GETPOST('generate_pdf', 'int');
|
||||||
$object->fk_project = $projectid;
|
$object->fk_project = $projectid;
|
||||||
|
|
||||||
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
|
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
|
||||||
$object->date_when = $date_next_execution;
|
$object->date_when = $date_next_execution;
|
||||||
@@ -1002,6 +1003,13 @@ if ($action == 'create') {
|
|||||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1, 'customer').'</td>';
|
print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1, 'customer').'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Invoice subtype
|
||||||
|
if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
|
||||||
|
print "<tr><td>".$langs->trans("InvoiceSubtype")."</td><td>";
|
||||||
|
print $form->getSelectInvoiceSubtype(GETPOSTISSET('subtype') ? GETPOST('subtype') : $object->subtype, 'subtype', -1, 0, 0, '');
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
$note_public = GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : $object->note_public;
|
$note_public = GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : $object->note_public;
|
||||||
$note_private = GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : $object->note_private;
|
$note_private = GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : $object->note_private;
|
||||||
|
|
||||||
@@ -1285,14 +1293,24 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
print '<table class="border centpercent tableforfield">';
|
print '<table class="border centpercent tableforfield">';
|
||||||
|
|
||||||
|
// Invoice subtype
|
||||||
|
if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
|
||||||
|
print "<tr><td>".$langs->trans("InvoiceSubtype")."</td><td>";
|
||||||
|
print $object->getSubtypeLabel('facture_rec');
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Author
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>';
|
print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>';
|
||||||
print $author->getNomUrl(-1);
|
print $author->getNomUrl(-1);
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
|
// Amount (excl. tax)
|
||||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||||
print '<td>'.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).'</td>';
|
print '<td>'.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Amount tax
|
||||||
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency).'</td>';
|
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2017-2020 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2017-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||||
|
* Copyright (C) 2023 Nick Fragoulis
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -174,7 +175,8 @@ class FactureRec extends CommonInvoice
|
|||||||
'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15),
|
'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15),
|
||||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1),
|
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1),
|
||||||
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>25),
|
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>25),
|
||||||
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
|
'subtype' =>array('type'=>'smallint(6)', 'label'=>'InvoiceSubtype', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30),
|
||||||
|
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>35),
|
||||||
'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>55, 'isameasure'=>1),
|
'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>55, 'isameasure'=>1),
|
||||||
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'isameasure'=>1),
|
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'isameasure'=>1),
|
||||||
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>65, 'isameasure'=>1),
|
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>65, 'isameasure'=>1),
|
||||||
@@ -273,6 +275,7 @@ class FactureRec extends CommonInvoice
|
|||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (";
|
||||||
$sql .= "titre";
|
$sql .= "titre";
|
||||||
$sql .= ", fk_soc";
|
$sql .= ", fk_soc";
|
||||||
|
$sql .= ", subtype";
|
||||||
$sql .= ", entity";
|
$sql .= ", entity";
|
||||||
$sql .= ", datec";
|
$sql .= ", datec";
|
||||||
$sql .= ", amount";
|
$sql .= ", amount";
|
||||||
@@ -301,6 +304,7 @@ class FactureRec extends CommonInvoice
|
|||||||
$sql .= ") VALUES (";
|
$sql .= ") VALUES (";
|
||||||
$sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'";
|
$sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'";
|
||||||
$sql .= ", ".((int) $this->socid);
|
$sql .= ", ".((int) $this->socid);
|
||||||
|
$sql .= ", ".($this->subtype ? "'".$this->db->escape($this->subtype)."'" : "null");
|
||||||
$sql .= ", ".((int) $conf->entity);
|
$sql .= ", ".((int) $conf->entity);
|
||||||
$sql .= ", '".$this->db->idate($now)."'";
|
$sql .= ", '".$this->db->idate($now)."'";
|
||||||
$sql .= ", ".(!empty($facsrc->total_ttc) ? ((float) $facsrc->total_ttc) : '0');
|
$sql .= ", ".(!empty($facsrc->total_ttc) ? ((float) $facsrc->total_ttc) : '0');
|
||||||
@@ -545,7 +549,7 @@ class FactureRec extends CommonInvoice
|
|||||||
{
|
{
|
||||||
dol_syslog('FactureRec::fetch', LOG_DEBUG);
|
dol_syslog('FactureRec::fetch', LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.total_tva, f.localtax1, f.localtax2, f.total_ht, f.total_ttc';
|
$sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.subtype, f.total_tva, f.localtax1, f.localtax2, f.total_ht, f.total_ttc';
|
||||||
$sql .= ', f.date_lim_reglement as dlr';
|
$sql .= ', f.date_lim_reglement as dlr';
|
||||||
$sql .= ', f.note_private, f.note_public, f.fk_user_author';
|
$sql .= ', f.note_private, f.note_public, f.fk_user_author';
|
||||||
$sql .= ', f.modelpdf as model_pdf';
|
$sql .= ', f.modelpdf as model_pdf';
|
||||||
@@ -583,6 +587,7 @@ class FactureRec extends CommonInvoice
|
|||||||
$this->titre = $obj->title; // deprecated
|
$this->titre = $obj->title; // deprecated
|
||||||
$this->title = $obj->title;
|
$this->title = $obj->title;
|
||||||
$this->ref = $obj->title;
|
$this->ref = $obj->title;
|
||||||
|
$this->subtype = $obj->subtype;
|
||||||
$this->suspended = $obj->suspended;
|
$this->suspended = $obj->suspended;
|
||||||
$this->total_ht = $obj->total_ht;
|
$this->total_ht = $obj->total_ht;
|
||||||
$this->total_tva = $obj->total_tva;
|
$this->total_tva = $obj->total_tva;
|
||||||
@@ -1345,6 +1350,7 @@ class FactureRec extends CommonInvoice
|
|||||||
$facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice
|
$facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice
|
||||||
|
|
||||||
$facture->type = self::TYPE_STANDARD;
|
$facture->type = self::TYPE_STANDARD;
|
||||||
|
$facture->subtype = $facturerec->subtype;
|
||||||
$facture->statut = self::STATUS_DRAFT; // deprecated
|
$facture->statut = self::STATUS_DRAFT; // deprecated
|
||||||
$facture->status = self::STATUS_DRAFT;
|
$facture->status = self::STATUS_DRAFT;
|
||||||
$facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.
|
$facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.
|
||||||
|
|||||||
@@ -694,6 +694,27 @@ abstract class CommonInvoice extends CommonObject
|
|||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($resql) {
|
||||||
|
$subtypeLabel = '';
|
||||||
|
|
||||||
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
|
$subtypeLabel = $obj->label;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($subtypeLabel)) {
|
||||||
|
print ' ' . $subtypeLabel;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} elseif ($table === 'facture_rec' || $table === 'facture_fourn_rec') {
|
||||||
|
$sql = "SELECT s.label FROM " . MAIN_DB_PREFIX . $table . " AS f";
|
||||||
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_invoice_subtype AS s ON f.subtype = s.rowid";
|
||||||
|
$sql .= " WHERE f.titre = '".$this->db->escape($this->titre)."'";
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$subtypeLabel = '';
|
$subtypeLabel = '';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user