mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Refactoring generale
This commit is contained in:
@@ -7,7 +7,7 @@ include_once __DIR__.'/../../core.php';
|
||||
*/
|
||||
function add_movimento_magazzino($id_articolo, $qta, $array = [], $descrizone = '', $data = '')
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
if (empty($qta)) {
|
||||
return false;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$backup_dir = Backup::getDirectory();
|
||||
|
||||
switch (filter('op')) {
|
||||
case 'getfile':
|
||||
$file = filter('file');
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$backup_dir = Backup::getDirectory();
|
||||
|
||||
echo '<p>'.tr('Il backup è <b>molto importante</b> perché permette di creare una copia della propria installazione e relativi dati per poterla poi ripristinare in seguito a errori, cancellazioni accidentali o guasti hardware').'.</p>';
|
||||
|
||||
if (!extension_loaded('zip')) {
|
||||
|
||||
@@ -9,7 +9,7 @@ function get_new_numeroddt($data)
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = "SELECT IFNULL(MAX(numero),'0') AS max_numeroddt FROM dt_ddt WHERE DATE_FORMAT( data, '%Y' ) = '".date('Y', strtotime($data))."' AND idtipoddt IN(SELECT id FROM dt_tipiddt WHERE dir='".$dir."') ORDER BY CAST(numero AS UNSIGNED) DESC LIMIT 0,1";
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -24,7 +24,7 @@ function get_new_numerosecondarioddt($data)
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Calcolo il numero secondario se stabilito dalle impostazioni e se documento di vendita
|
||||
$formato_numero_secondario = setting('Formato numero secondario ddt');
|
||||
@@ -56,7 +56,7 @@ function rimuovi_articolo_daddt($idarticolo, $idddt, $idrigaddt)
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Leggo la quantità di questo articolo in ddt
|
||||
$query = 'SELECT qta, subtotale FROM dt_righe_ddt WHERE id='.prepare($idrigaddt);
|
||||
@@ -115,7 +115,7 @@ function rimuovi_articolo_daddt($idarticolo, $idddt, $idrigaddt)
|
||||
*/
|
||||
function get_imponibile_ddt($idddt)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(subtotale-sconto) AS imponibile FROM dt_righe_ddt GROUP BY idddt HAVING idddt='.prepare($idddt);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -128,7 +128,7 @@ function get_imponibile_ddt($idddt)
|
||||
*/
|
||||
function get_totale_ddt($idddt)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Sommo l'iva di ogni riga al totale
|
||||
$query = 'SELECT SUM(iva) AS iva FROM dt_righe_ddt GROUP BY idddt HAVING idddt='.prepare($idddt);
|
||||
@@ -146,7 +146,7 @@ function get_totale_ddt($idddt)
|
||||
*/
|
||||
function get_netto_ddt($idddt)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT ritenutaacconto,bollo FROM dt_ddt WHERE id='.prepare($idddt);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -159,7 +159,7 @@ function get_netto_ddt($idddt)
|
||||
*/
|
||||
function get_ivadetraibile_ddt($idddt)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(iva)-SUM(iva_indetraibile) AS iva_detraibile FROM dt_righe_ddt GROUP BY idddt HAVING idddt='.prepare($idddt);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -172,7 +172,7 @@ function get_ivadetraibile_ddt($idddt)
|
||||
*/
|
||||
function get_ivaindetraibile_ddt($idddt)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(iva_indetraibile) AS iva_indetraibile FROM dt_righe_ddt GROUP BY idddt HAVING idddt='.prepare($idddt);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -192,7 +192,7 @@ function ricalcola_costiagg_ddt($idddt, $idrivalsainps = '', $idritenutaacconto
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Se ci sono righe nel ddt faccio i conteggi, altrimenti azzero gli sconti e le spese aggiuntive (inps, ritenuta, marche da bollo)
|
||||
$query = "SELECT COUNT(id) AS righe FROM dt_righe_ddt WHERE idddt='$idddt'";
|
||||
@@ -288,7 +288,7 @@ function add_articolo_inddt($idddt, $idarticolo, $descrizione, $idiva, $qta, $id
|
||||
global $dir;
|
||||
global $idordine;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Lettura unità di misura dell'articolo
|
||||
if (empty($idum)) {
|
||||
@@ -337,7 +337,7 @@ function add_articolo_inddt($idddt, $idarticolo, $descrizione, $idiva, $qta, $id
|
||||
*/
|
||||
function get_stato_ddt($idddt)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$rs = $dbo->fetchArray('SELECT SUM(qta) AS qta, SUM(qta_evasa) AS qta_evasa FROM dt_righe_ddt GROUP BY idddt HAVING idddt='.prepare($idddt));
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ function get_new_numerosecondariofattura($data)
|
||||
*/
|
||||
function elimina_scadenza($iddocumento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query2 = 'DELETE FROM co_scadenziario WHERE iddocumento='.prepare($iddocumento);
|
||||
$dbo->query($query2);
|
||||
@@ -43,7 +43,7 @@ function elimina_scadenza($iddocumento)
|
||||
*/
|
||||
function aggiungi_scadenza($iddocumento, $pagamento = '', $pagato = 0)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$totale_da_pagare = 0.00;
|
||||
$totale_fattura = get_totale_fattura($iddocumento);
|
||||
@@ -155,7 +155,7 @@ function aggiungi_scadenza($iddocumento, $pagamento = '', $pagato = 0)
|
||||
*/
|
||||
function aggiorna_scadenziario($iddocumento, $totale_pagato, $data_pagamento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Lettura righe scadenziario
|
||||
$query = "SELECT * FROM co_scadenziario WHERE iddocumento='$iddocumento' AND ABS(pagato) < ABS(da_pagare) ORDER BY scadenza ASC";
|
||||
@@ -211,7 +211,7 @@ function aggiorna_scadenziario($iddocumento, $totale_pagato, $data_pagamento)
|
||||
*/
|
||||
function elimina_movimento($iddocumento, $anche_prima_nota = 0)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query2 = 'DELETE FROM co_movimenti WHERE iddocumento='.prepare($iddocumento).' AND primanota='.prepare($anche_prima_nota);
|
||||
$dbo->query($query2);
|
||||
@@ -225,7 +225,7 @@ function elimina_movimento($iddocumento, $anche_prima_nota = 0)
|
||||
*/
|
||||
function aggiungi_movimento($iddocumento, $dir, $primanota = 0)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Totale marca da bollo, inps, ritenuta, idagente
|
||||
$query = 'SELECT data, bollo, ritenutaacconto, rivalsainps FROM co_documenti WHERE id='.prepare($iddocumento);
|
||||
@@ -424,7 +424,7 @@ function aggiungi_movimento($iddocumento, $dir, $primanota = 0)
|
||||
*/
|
||||
function get_new_idmastrino($table = 'co_movimenti')
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT MAX(idmastrino) AS maxidmastrino FROM '.$table;
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -437,7 +437,7 @@ function get_new_idmastrino($table = 'co_movimenti')
|
||||
*/
|
||||
function get_imponibile_fattura($iddocumento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(co_righe_documenti.subtotale - co_righe_documenti.sconto) AS imponibile FROM co_righe_documenti GROUP BY iddocumento HAVING iddocumento='.prepare($iddocumento);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -450,7 +450,7 @@ function get_imponibile_fattura($iddocumento)
|
||||
*/
|
||||
function get_totale_fattura($iddocumento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Sommo l'iva di ogni riga al totale
|
||||
$query = 'SELECT SUM(iva) AS iva FROM co_righe_documenti GROUP BY iddocumento HAVING iddocumento='.prepare($iddocumento);
|
||||
@@ -487,7 +487,7 @@ function get_totale_fattura($iddocumento)
|
||||
*/
|
||||
function get_netto_fattura($iddocumento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT ritenutaacconto, bollo FROM co_documenti WHERE id='.prepare($iddocumento);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -506,7 +506,7 @@ function get_netto_fattura($iddocumento)
|
||||
*/
|
||||
function get_ivadetraibile_fattura($iddocumento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(iva)-SUM(iva_indetraibile) AS iva_detraibile FROM co_righe_documenti GROUP BY iddocumento HAVING iddocumento='.prepare($iddocumento);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -519,7 +519,7 @@ function get_ivadetraibile_fattura($iddocumento)
|
||||
*/
|
||||
function get_ivaindetraibile_fattura($iddocumento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(iva_indetraibile) AS iva_indetraibile FROM co_righe_documenti GROUP BY iddocumento HAVING iddocumento='.prepare($iddocumento);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -539,7 +539,7 @@ function ricalcola_costiagg_fattura($iddocumento, $idrivalsainps = '', $idritenu
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Se ci sono righe in fattura faccio i conteggi, altrimenti azzero gli sconti e le spese aggiuntive (inps, ritenuta, marche da bollo)
|
||||
$query = 'SELECT COUNT(id) AS righe FROM co_righe_documenti WHERE iddocumento='.prepare($iddocumento);
|
||||
@@ -579,7 +579,7 @@ function ricalcola_costiagg_fattura($iddocumento, $idrivalsainps = '', $idritenu
|
||||
|
||||
// Leggo la marca da bollo se c'è e se il netto a pagare supera la soglia
|
||||
$bolli = ($dir == 'uscita') ? $bolli : setting('Importo marca da bollo');
|
||||
$bolli = Translator::getFormatter()->parse($bolli);
|
||||
$bolli = formatter()->parse($bolli);
|
||||
|
||||
$marca_da_bollo = 0;
|
||||
if (abs($bolli) > 0 && abs($netto_a_pagare > setting("Soglia minima per l'applicazione della marca da bollo"))) {
|
||||
@@ -611,7 +611,7 @@ function add_articolo_infattura($iddocumento, $idarticolo, $descrizione, $idiva,
|
||||
global $idddt;
|
||||
global $idordine;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
if (empty($idddt)) {
|
||||
$idddt = 0;
|
||||
@@ -703,7 +703,7 @@ function rimuovi_articolo_dafattura($idarticolo, $iddocumento, $idrigadocumento)
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Leggo la quantità di questo articolo in fattura
|
||||
$query = 'SELECT qta, idintervento, idpreventivo, idordine, idddt, subtotale, descrizione FROM co_righe_documenti WHERE id='.prepare($idrigadocumento);
|
||||
@@ -779,7 +779,7 @@ function rimuovi_articolo_dafattura($idarticolo, $iddocumento, $idrigadocumento)
|
||||
|
||||
function rimuovi_riga_fattura($id_documento, $id_riga, $dir)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Leggo la quantità di questo articolo in fattura
|
||||
$riga = $dbo->fetchOne('SELECT * FROM co_righe_documenti WHERE id='.prepare($id_riga));
|
||||
|
||||
@@ -190,10 +190,10 @@ switch (post('op')) {
|
||||
|
||||
$stato = $dbo->selectOne('in_statiintervento', '*', ['idstatointervento' => post('idstatointervento')]);
|
||||
// Notifica chiusura intervento
|
||||
if (!empty($stato['notifica']) && !empty($stato['destinatari'])) {
|
||||
if (!empty($stato['notifica']) && !empty($stato['destinatari']) && $stato['idstatointervento'] != $record['idstatointervento']) {
|
||||
$n = new Notifications\EmailNotification();
|
||||
|
||||
$n->setTemplate('Stato intervento', $id_record);
|
||||
$n->setTemplate($stato['id_email'], $id_record);
|
||||
$n->setReceivers($stato['destinatari']);
|
||||
|
||||
$n->send();
|
||||
@@ -614,7 +614,7 @@ switch (post('op')) {
|
||||
if (!empty($stato['notifica']) && !empty($stato['destinatari'])) {
|
||||
$n = new Notifications\EmailNotification();
|
||||
|
||||
$n->setTemplate('Stato intervento', $id_record);
|
||||
$n->setTemplate($stato['id_email'], $id_record);
|
||||
$n->setReceivers($stato['destinatari']);
|
||||
|
||||
$n->send();
|
||||
|
||||
@@ -144,7 +144,7 @@ if (empty($data)) {
|
||||
if (null !== filter('data')) {
|
||||
$data = filter('data');
|
||||
} else {
|
||||
$data = date(Translator::getFormatter()->getDatePattern());
|
||||
$data = date(formatter()->getDatePattern());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ include_once __DIR__.'/../../core.php';
|
||||
*/
|
||||
function get_ore_intervento($idintervento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
$totale_ore = 0;
|
||||
|
||||
$rs = $dbo->fetchArray('SELECT idintervento, TIMESTAMPDIFF( MINUTE, orario_inizio, orario_fine ) / 60 AS tot_ore FROM in_interventi_tecnici WHERE idintervento = '.prepare($idintervento));
|
||||
@@ -31,7 +31,7 @@ function get_ore_intervento($idintervento)
|
||||
*/
|
||||
function link_componente_to_articolo($idintervento, $idimpianto, $idarticolo, $qta)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
if (!empty($idimpianto) && !empty($idintervento)) {
|
||||
//Leggo la data dell'intervento
|
||||
@@ -52,7 +52,7 @@ function link_componente_to_articolo($idintervento, $idimpianto, $idarticolo, $q
|
||||
|
||||
function add_tecnico($idintervento, $idtecnico, $inizio, $fine, $idcontratto = null)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Controllo sull'identità del tecnico
|
||||
$tecnico = $dbo->fetchOne('SELECT an_anagrafiche.idanagrafica, an_anagrafiche.email FROM an_anagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica INNER JOIN an_tipianagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE an_anagrafiche.idanagrafica = '.prepare($idtecnico)." AND an_tipianagrafiche.descrizione = 'Tecnico'");
|
||||
@@ -176,7 +176,7 @@ function add_tecnico($idintervento, $idtecnico, $inizio, $fine, $idcontratto = n
|
||||
|
||||
function get_costi_intervento($id_intervento)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$decimals = setting('Cifre decimali per importi');
|
||||
|
||||
@@ -354,7 +354,7 @@ function calcola_ore_intervento($orario_inizio, $orario_fine)
|
||||
|
||||
function aggiungi_intervento_in_fattura($id_intervento, $id_fattura, $descrizione, $id_iva, $id_conto)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$id_ritenuta_acconto = setting("Percentuale ritenuta d'acconto");
|
||||
$id_rivalsa_inps = setting('Percentuale rivalsa INPS');
|
||||
|
||||
@@ -9,7 +9,7 @@ function get_new_numeroordine($data)
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = "SELECT numero AS max_numeroordine FROM or_ordini WHERE DATE_FORMAT( data, '%Y' ) = ".prepare(date('Y', strtotime($data))).' AND idtipoordine IN(SELECT id FROM or_tipiordine WHERE dir='.prepare($dir).') ORDER BY CAST(numero AS UNSIGNED) DESC LIMIT 0,1';
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -25,7 +25,7 @@ function get_new_numerosecondarioordine($data)
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Calcolo il numero secondario se stabilito dalle impostazioni e se documento di vendita
|
||||
$formato_numero_secondario = setting('Formato numero secondario ordine');
|
||||
@@ -53,7 +53,7 @@ function get_new_numerosecondarioordine($data)
|
||||
*/
|
||||
function get_imponibile_ordine($idordine)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(subtotale-sconto) AS imponibile FROM or_righe_ordini GROUP BY idordine HAVING idordine='.prepare($idordine);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -66,7 +66,7 @@ function get_imponibile_ordine($idordine)
|
||||
*/
|
||||
function get_totale_ordine($idordine)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Sommo l'iva di ogni riga al totale
|
||||
$query = 'SELECT SUM(iva) AS iva FROM or_righe_ordini GROUP BY idordine HAVING idordine='.prepare($idordine);
|
||||
@@ -84,7 +84,7 @@ function get_totale_ordine($idordine)
|
||||
*/
|
||||
function get_netto_ordine($idordine)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT ritenutaacconto,bollo FROM or_ordini WHERE id='.prepare($idordine);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -97,7 +97,7 @@ function get_netto_ordine($idordine)
|
||||
*/
|
||||
function get_ivadetraibile_ordine($idordine)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(iva)-SUM(iva_indetraibile) AS iva_detraibile FROM or_righe_ordini GROUP BY idordine HAVING idordine='.prepare($idordine);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -110,7 +110,7 @@ function get_ivadetraibile_ordine($idordine)
|
||||
*/
|
||||
function get_ivaindetraibile_ordine($idordine)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(iva_indetraibile) AS iva_indetraibile FROM or_righe_ordini GROUP BY idordine HAVING idordine='.prepare($idordine);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -131,7 +131,7 @@ function add_articolo_inordine($idordine, $idarticolo, $descrizione, $idiva, $qt
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Lettura unità di misura dell'articolo
|
||||
if (empty($idum)) {
|
||||
@@ -162,7 +162,7 @@ function rimuovi_articolo_daordine($idarticolo, $idordine, $idrigaordine)
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$non_rimovibili = seriali_non_rimuovibili('id_riga_ordine', $idrigaordine, $dir);
|
||||
if (!empty($non_rimovibili)) {
|
||||
@@ -190,7 +190,7 @@ function ricalcola_costiagg_ordine($idordine, $idrivalsainps = '', $idritenutaac
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Se ci sono righe nel ordine faccio i conteggi, altrimenti azzero gli sconti e le spese aggiuntive (inps, ritenuta, marche da bollo)
|
||||
$query = 'SELECT COUNT(id) AS righe FROM or_righe_ordini WHERE idordine='.prepare($idordine);
|
||||
@@ -279,7 +279,7 @@ function ricalcola_costiagg_ordine($idordine, $idrivalsainps = '', $idritenutaac
|
||||
*/
|
||||
function get_stato_ordine($idordine)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$rs_ordine = $dbo->fetchArray("SELECT IFNULL(SUM(qta), 0) AS qta FROM or_righe_ordini WHERE idordine='".$idordine."'");
|
||||
$qta_ordine = $rs_ordine[0]['qta'];
|
||||
|
||||
@@ -11,7 +11,7 @@ function rimuovi_articolo_dapreventivo($idarticolo, $idpreventivo, $idriga)
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Leggo la quantità di questo articolo nell'ordine
|
||||
$query = 'SELECT qta, subtotale FROM co_righe_preventivi WHERE id='.prepare($idriga);
|
||||
@@ -35,7 +35,7 @@ function ricalcola_costiagg_preventivo($idpreventivo, $idrivalsainps = '', $idri
|
||||
{
|
||||
global $dir;
|
||||
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Se ci sono righe nel ordine faccio i conteggi, altrimenti azzero gli sconti e le spese aggiuntive (inps, ritenuta, marche da bollo)
|
||||
$query = 'SELECT COUNT(id) AS righe FROM co_righe_preventivi WHERE idpreventivo='.prepare($idpreventivo);
|
||||
@@ -99,7 +99,7 @@ function ricalcola_costiagg_preventivo($idpreventivo, $idrivalsainps = '', $idri
|
||||
|
||||
function get_imponibile_preventivo($idpreventivo)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$query = 'SELECT SUM(co_righe_preventivi.subtotale - co_righe_preventivi.sconto) AS imponibile FROM co_righe_preventivi GROUP BY idpreventivo HAVING idpreventivo='.prepare($idpreventivo);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@@ -112,7 +112,7 @@ function get_imponibile_preventivo($idpreventivo)
|
||||
*/
|
||||
function get_stato_preventivo($idpreventivo)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
$rs = $dbo->fetchArray('SELECT SUM(qta) AS qta, SUM(qta_evasa) AS qta_evasa FROM co_righe_preventivi GROUP BY idpreventivo HAVING idpreventivo='.prepare($idpreventivo));
|
||||
|
||||
@@ -134,7 +134,7 @@ function get_stato_preventivo($idpreventivo)
|
||||
*/
|
||||
function update_budget_preventivo($idpreventivo)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
// Totale articoli
|
||||
$rs = $dbo->fetchArray('SELECT SUM(subtotale) AS totale FROM co_righe_preventivi GROUP BY idpreventivo HAVING idpreventivo='.prepare($idpreventivo));
|
||||
|
||||
@@ -37,11 +37,11 @@ if ($record['can_delete']) {
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Template email'); ?>", "name": "email", "value": "$id_email$", "values": "query=SELECT id, name AS descrizione FROM zz_emails WHERE id_module = <?php echo Modules::get('Interventi')['id']; ?> AND deleted_at IS NULL" ]}
|
||||
{[ "type": "select", "label": "<?php echo tr('Template email'); ?>", "name": "email", "value": "$id_email$", "values": "query=SELECT id, name AS descrizione FROM zz_emails WHERE id_module = <?php echo Modules::get('Interventi')['id']; ?> AND deleted_at IS NULL", "disabled": <?php echo intval(empty($record['notifica'])); ?> ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "<?php echo tr('Destinatari'); ?>", "name": "destinatari", "value": "$destinatari$" ]}
|
||||
{[ "type": "text", "label": "<?php echo tr('Destinatari'); ?>", "name": "destinatari", "value": "$destinatari$", "disabled": <?php echo intval(empty($record['notifica'])); ?> ]}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
switch ($resource) {
|
||||
case 'login':
|
||||
// Controllo sulle credenziali
|
||||
if (Auth::getInstance()->attempt($request['username'], $request['password'])) {
|
||||
$user = Auth::getInstance()->getUser();
|
||||
$token = Auth::getInstance()->getToken();
|
||||
if (auth()->attempt($request['username'], $request['password'])) {
|
||||
$user = auth()->getUser();
|
||||
$token = auth()->getToken();
|
||||
|
||||
// Informazioni da restituire tramite l'API
|
||||
$response['user'] = $dbo->fetchOne('SELECT `ragione_sociale`, `codice`, `piva`, `codice_fiscale`, `indirizzo`, `citta`, `provincia`, (SELECT `nome` FROM `an_nazioni` WHERE `an_nazioni`.`id` = `an_anagrafiche`.`id_nazione`) AS nazione, `telefono`, `fax`, `cellulare`, `an_anagrafiche`.`email` FROM `zz_users` LEFT JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `zz_users`.`idanagrafica` WHERE `id` = :id', [
|
||||
|
||||
@@ -12,7 +12,7 @@ if (post('op') == 'change_pwd') {
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$token = Auth::getInstance()->getToken();
|
||||
$token = auth()->getToken();
|
||||
|
||||
$rs = $dbo->fetchArray('SELECT * FROM an_anagrafiche WHERE idanagrafica = '.prepare($user['idanagrafica']));
|
||||
$anagrafica = [];
|
||||
|
||||
@@ -4,7 +4,7 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
function menuSelection($element, $group_id, $depth, $perms_values, $perms_names)
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
$dbo = database();
|
||||
|
||||
++$depth;
|
||||
$name = $element['title'];
|
||||
|
||||
Reference in New Issue
Block a user