diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index a14eff9a1bb..7473eb9044b 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -204,21 +204,22 @@ if (empty($reshook)) {
}
if (!$error) {
- $object->title = GETPOST('title', 'alphanohtml');
- $object->note_private = GETPOST('note_private', 'restricthtml');
- $object->note_public = GETPOST('note_public', 'restricthtml');
- $object->model_pdf = GETPOST('modelpdf', 'alphanohtml');
- $object->usenewprice = GETPOST('usenewprice', 'alphanohtml');
+ $object->subtype = GETPOST('subtype');
+ $object->title = GETPOST('title', 'alphanohtml');
+ $object->note_private = GETPOST('note_private', 'restricthtml');
+ $object->note_public = GETPOST('note_public', 'restricthtml');
+ $object->model_pdf = GETPOST('modelpdf', 'alphanohtml');
+ $object->usenewprice = GETPOST('usenewprice', 'alphanohtml');
- $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
- $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
+ $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
+ $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
- $object->frequency = $frequency;
- $object->unit_frequency = GETPOST('unit_frequency', 'alpha');
- $object->nb_gen_max = $nb_gen_max;
- $object->auto_validate = GETPOST('auto_validate', 'int');
- $object->generate_pdf = GETPOST('generate_pdf', 'int');
- $object->fk_project = $projectid;
+ $object->frequency = $frequency;
+ $object->unit_frequency = GETPOST('unit_frequency', 'alpha');
+ $object->nb_gen_max = $nb_gen_max;
+ $object->auto_validate = GETPOST('auto_validate', 'int');
+ $object->generate_pdf = GETPOST('generate_pdf', 'int');
+ $object->fk_project = $projectid;
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
$object->date_when = $date_next_execution;
@@ -1002,6 +1003,13 @@ if ($action == 'create') {
print '
| '.$langs->trans("Customer").' | '.$object->thirdparty->getNomUrl(1, 'customer').' | ';
print '
';
+ // Invoice subtype
+ if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
+ print "| ".$langs->trans("InvoiceSubtype")." | ";
+ print $form->getSelectInvoiceSubtype(GETPOSTISSET('subtype') ? GETPOST('subtype') : $object->subtype, 'subtype', -1, 0, 0, '');
+ print " |
";
+ }
+
$note_public = GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : $object->note_public;
$note_private = GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : $object->note_private;
@@ -1285,14 +1293,24 @@ if ($action == 'create') {
print '';
+ // Invoice subtype
+ if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
+ print "| ".$langs->trans("InvoiceSubtype")." | ";
+ print $object->getSubtypeLabel('facture_rec');
+ print " |
";
+ }
+
+ // Author
print '| '.$langs->trans("Author").' | ';
print $author->getNomUrl(-1);
print " |
";
+ // Amount (excl. tax)
print '| '.$langs->trans("AmountHT").' | ';
print ''.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).' | ';
print '
';
+ // Amount tax
print '| '.$langs->trans("AmountVAT").' | '.price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency).' | ';
print '
';
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index e526b4049f2..0a6ad7c2423 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -7,6 +7,7 @@
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2015 Marcos García
* Copyright (C) 2017-2020 Frédéric France
+ * Copyright (C) 2023 Nick Fragoulis
*
* 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
@@ -174,7 +175,8 @@ class FactureRec extends CommonInvoice
'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),
'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),
'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),
@@ -273,6 +275,7 @@ class FactureRec extends CommonInvoice
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (";
$sql .= "titre";
$sql .= ", fk_soc";
+ $sql .= ", subtype";
$sql .= ", entity";
$sql .= ", datec";
$sql .= ", amount";
@@ -301,6 +304,7 @@ class FactureRec extends CommonInvoice
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'";
$sql .= ", ".((int) $this->socid);
+ $sql .= ", ".($this->subtype ? "'".$this->db->escape($this->subtype)."'" : "null");
$sql .= ", ".((int) $conf->entity);
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", ".(!empty($facsrc->total_ttc) ? ((float) $facsrc->total_ttc) : '0');
@@ -545,7 +549,7 @@ class FactureRec extends CommonInvoice
{
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.note_private, f.note_public, f.fk_user_author';
$sql .= ', f.modelpdf as model_pdf';
@@ -583,6 +587,7 @@ class FactureRec extends CommonInvoice
$this->titre = $obj->title; // deprecated
$this->title = $obj->title;
$this->ref = $obj->title;
+ $this->subtype = $obj->subtype;
$this->suspended = $obj->suspended;
$this->total_ht = $obj->total_ht;
$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->type = self::TYPE_STANDARD;
+ $facture->subtype = $facturerec->subtype;
$facture->statut = self::STATUS_DRAFT; // deprecated
$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.
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index c1e9c9afeae..e4e072e87b3 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -694,6 +694,27 @@ abstract class CommonInvoice extends CommonObject
$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) {
$subtypeLabel = '';