2020-03-03 10:33:32 +01:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.n.c.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-03-03 10:33:32 +01:00
|
|
|
|
|
|
|
namespace Traits;
|
|
|
|
|
|
|
|
trait ReferenceTrait
|
|
|
|
{
|
|
|
|
abstract public function getReferenceName();
|
|
|
|
|
|
|
|
abstract public function getReferenceNumber();
|
|
|
|
|
|
|
|
abstract public function getReferenceDate();
|
|
|
|
|
2020-10-15 17:00:43 +02:00
|
|
|
abstract public function getReferenceRagioneSociale();
|
|
|
|
|
|
|
|
public function getReference($show_ragione_sociale = NULL)
|
2020-03-03 10:33:32 +01:00
|
|
|
{
|
2020-07-02 15:27:18 +02:00
|
|
|
// Informazioni disponibili
|
2020-03-03 10:33:32 +01:00
|
|
|
$name = $this->getReferenceName();
|
2020-07-06 13:19:20 +02:00
|
|
|
|
2020-03-03 10:33:32 +01:00
|
|
|
$number = $this->getReferenceNumber();
|
|
|
|
$date = $this->getReferenceDate();
|
|
|
|
|
2020-10-15 17:38:11 +02:00
|
|
|
$ragione_sociale = $this->getReferenceRagioneSociale();
|
2020-10-15 17:00:43 +02:00
|
|
|
|
2020-07-02 15:27:18 +02:00
|
|
|
// Testi predefiniti
|
2020-10-15 17:38:11 +02:00
|
|
|
if (!empty($date) && !empty($number) && !empty($ragione_sociale) && !empty($show_ragione_sociale) ) {
|
2020-10-15 17:00:43 +02:00
|
|
|
$description = tr('_DOC_ num. _NUM_ del _DATE_ (_RAGIONE_SOCIALE_)');
|
|
|
|
}
|
|
|
|
elseif (!empty($date) && !empty($number)) {
|
2020-07-02 15:27:18 +02:00
|
|
|
$description = tr('_DOC_ num. _NUM_ del _DATE_');
|
2020-03-03 10:33:32 +01:00
|
|
|
} elseif (!empty($number)) {
|
2020-07-02 15:27:18 +02:00
|
|
|
$description = tr('_DOC_ num. _NUM_');
|
2020-03-03 10:33:32 +01:00
|
|
|
} elseif (!empty($date)) {
|
2020-07-02 15:27:18 +02:00
|
|
|
$description = tr('_DOC_ del _DATE_');
|
2020-03-03 10:33:32 +01:00
|
|
|
} else {
|
2020-07-02 15:27:18 +02:00
|
|
|
$description = tr('_DOC_');
|
2020-03-03 10:33:32 +01:00
|
|
|
}
|
|
|
|
|
2020-07-02 15:27:18 +02:00
|
|
|
// Creazione descrizione
|
|
|
|
$description = replace($description, [
|
|
|
|
'_DOC_' => $name,
|
|
|
|
'_NUM_' => $number,
|
2020-10-15 17:38:11 +02:00
|
|
|
'_RAGIONE_SOCIALE_' => $ragione_sociale,
|
2020-07-02 15:27:18 +02:00
|
|
|
'_DATE_' => dateFormat($date),
|
|
|
|
]);
|
|
|
|
|
2020-03-03 10:33:32 +01:00
|
|
|
return $description;
|
|
|
|
}
|
|
|
|
}
|