openstamanager/modules/fatture/variables.php

71 lines
3.4 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.*,
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.pec,
an_anagrafiche.ragione_sociale,
2019-07-22 11:44:04 +02:00
co_tipidocumento.descrizione AS tipo_documento,
2019-08-29 10:25:14 +02: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
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'))) {
2022-03-02 12:18:09 +01:00
$logo_azienda = base_url().'/'.Models\Upload::where('filename', setting('Logo stampe'))->first()->fileurl;
2019-07-25 18:05:47 +02:00
} else {
2022-03-02 12:18:09 +01:00
$logo_azienda = str_replace(base_dir(), base_url(), AppLegacy::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
//cliente
2019-04-12 01:11:32 +02:00
if ($r['idconto_cliente'] != '') {
$conto = $r['idconto_cliente'];
$conto_descrizione = $dbo->fetchOne('SELECT CONCAT ((SELECT numero FROM co_pianodeiconti2 WHERE id=co_pianodeiconti3.idpianodeiconti2), ".", numero, " ", descrizione) AS descrizione FROM co_pianodeiconti3 WHERE id='.prepare($conto))['descrizione'];
}
//Fornitore
2019-04-12 01:11:32 +02:00
elseif ($r['idconto_fornitore'] != '') {
$conto = $r['idconto_fornitore'];
$conto_descrizione = $dbo->fetchOne('SELECT CONCAT ((SELECT numero FROM co_pianodeiconti2 WHERE id=co_pianodeiconti3.idpianodeiconti2), ".", numero, " ", descrizione) AS descrizione FROM co_pianodeiconti3 WHERE id='.prepare($conto))['descrizione'];
}
$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 [
2018-11-12 18:49:51 +01:00
'email' => $r['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'],
2021-01-04 18:54:23 +01:00
'data' => dateFormat($r['data']),
2019-07-04 20:54:09 +02:00
'logo_azienda' => !empty($logo_azienda) ? '<img src="'.$logo_azienda.'" />' : '',
'conto' => $conto,
'conto_descrizione' => $conto_descrizione,
'nome_utente' => $r_user['ragione_sociale'],
'telefono_utente' => $r_user['cellulare'],
'sito_web' => $r_company['sitoweb'],
];