openstamanager/modules/fatture/variables.php

60 lines
2.7 KiB
PHP
Raw Normal View History

<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright (C) DevCode s.r.l.
2020-09-07 15:04:06 +02:00
*
* 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/>.
*/
$r = $dbo->fetchOne('SELECT co_documenti.*,
2021-01-28 21:13:48 +01:00
an_anagrafiche.pec,
IF( (an_referenti.email IS NOT NULL AND an_referenti.email!=""), an_referenti.email, an_anagrafiche.email) AS email,
an_anagrafiche.idconto_cliente,
an_anagrafiche.idconto_fornitore,
an_anagrafiche.ragione_sociale,
an_referenti.nome,
2019-07-22 11:44:04 +02:00
co_tipidocumento.descrizione AS tipo_documento,
2021-01-28 21:13:48 +01:00
(SELECT pec FROM em_accounts WHERE em_accounts.id='.prepare($template['id_account']).') AS is_pec
2019-07-22 11:44:04 +02:00
FROM co_documenti
2021-01-28 21:13:48 +01:00
INNER JOIN an_anagrafiche ON co_documenti.idanagrafica = an_anagrafiche.idanagrafica
INNER JOIN co_tipidocumento ON co_tipidocumento.id = co_documenti.idtipodocumento
LEFT OUTER JOIN an_referenti ON an_referenti.id = co_documenti.idreferente
2019-07-22 11:44:04 +02:00
WHERE co_documenti.id='.prepare($id_record));
2019-07-25 17:39:55 +02:00
if (!empty(setting('Logo stampe'))) {
$logo_azienda = base_url().'/'.Models\Upload::where('filename', setting('Logo stampe'))->first()->fileurl;
2019-07-25 18:05:47 +02:00
} else {
$logo_azienda = str_replace(base_dir(), base_url(), App::filepath('templates/base|custom|/logo_azienda.jpg'));
2019-07-25 17:39:55 +02:00
$logo_azienda = str_replace('\\', '/', $logo_azienda);
}
2019-01-29 18:54:32 +01:00
2019-08-28 16:58:47 +02:00
$r_user = $dbo->fetchOne('SELECT * FROM an_anagrafiche WHERE idanagrafica='.prepare(Auth::user()['idanagrafica']));
$r_company = $dbo->fetchOne('SELECT * FROM an_anagrafiche WHERE idanagrafica='.prepare(setting('Azienda predefinita')));
// Variabili da sostituire
return [
2021-01-28 21:13:48 +01:00
'email' => $options['is_pec'] ? $r['pec'] : $r['email'],
'id_anagrafica' => $r['idanagrafica'],
2018-12-23 14:01:59 +01:00
'ragione_sociale' => $r['ragione_sociale'],
'numero' => empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno'],
2019-07-22 11:44:04 +02:00
'tipo_documento' => $r['tipo_documento'],
'note' => $r['note'],
'data' => Translator::dateToLocale($r['data']),
2019-07-04 20:54:09 +02:00
'logo_azienda' => !empty($logo_azienda) ? '<img src="'.$logo_azienda.'" />' : '',
'nome_utente' => $r_user['ragione_sociale'],
'telefono_utente' => $r_user['cellulare'],
'sito_web' => $r_company['sitoweb'],
'nome_referente' => $r['nome'],
];