<?php
include("Config.php");
/* Nomi delle tabelle utilizzate */
/* Nomi delle tabelle utilizzate */
$config_table = $table_prefix."_anagrafica";
$admin_table = $table_prefix."_admin";
$orders_table = $table_prefix."_ordini";
$customers_table = $table_prefix."_clienti";
$suppliers_table = $table_prefix."_fornitori";
$invoices_table = $table_prefix."_fatture_vendita";
$spl_invoices_table = $table_prefix."_fatture_acquisto";
$credit_notes_table = $table_prefix."_note_credito";
$spl_credit_notes_table = $table_prefix."_note_credito_fornitori";
$debt_notes_table = $table_prefix."_note_debito";
$spl_debt_notes_table = $table_prefix."_note_debito_fornitori";
$vat_table = $table_prefix."_codici_iva";
$payment_table = $table_prefix."_tipi_pagamento";
$bank_table = $table_prefix."_banche";
$mov_table = $table_prefix."_movimenti";
$terms_table = $table_prefix."_scadenzario";
$terms_table_iva = $table_prefix."_scadenzario_iva";
function connectToDB()
{
global $link, $Host, $Database, $User, $Password;
$link = mysql_pconnect($Host, $User, $Password);
if (! $link)
die("Impossibile connettersi a MySql");
mysql_select_db( $Database, $link)
or die ("Impossibile connettersi al database");
}
function getRow( $table, $fnm, $fval)
{
global $link;
$query= "SELECT * FROM $table WHERE $fnm = '".addslashes($fval)."'";
$result = mysql_query($query, $link);
if (! $result )
die (" Errore di getRow: ".mysql_error());
$record=mysql_fetch_array( $result);
if (is_array($record))
return array_map('stripslashes_deep', $record);
else
return $record;
}
//wrapper function per una generica query
function gendynQuery ($query)
{
global $link;
$result = mysql_query($query,$link);
if (! $result )
{
// questo e' buono per il debug
$result = "<br>Errore nell'esecuzione di <b>dynQuery</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
// funzione che compone una query con i parametri: tabella, where, orderby, limit e passo (riga di inizio e n. record)
// restituisce la risorsa
function dynQuery ($select, $tabella, $where=1, $orderby=2, $limit=0, $passo=40)
{
global $link, $_SESSION;
if ($orderby == '2 ')
{
$query = "SELECT $select FROM $tabella WHERE $where LIMIT $limit, $passo";
}
else
{
$query = "SELECT $select FROM $tabella WHERE $where ORDER BY $orderby LIMIT $limit, $passo";
}
$result = mysql_query($query, $link);
if (! $result )
{
// questo e' buono per il debug
$result = "<br>Errore nell'esecuzione di <b>dynQuery</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
//error_log($query,0); // per visualizzare la query - debug
return $result;
}
function dynCountRows($result)
{
return mysql_num_rows($result);
}
// funzione che svincola il fetching dal DBMS specifico, questa funziona con mysql
// wrap function to manage the quote problem
function dbms_fetch_array ($resource)
{
$record=mysql_fetch_array( $resource);
if (is_array($record))
return array_map('stripslashes_deep', $record);
else
return $record;
}
function configInsert ($Ragione_Sociale,$Cognome, $Nome, $PI, $CF, $Indirizzo, $Citta, $CAP, $Provincia, $Telefono, $Telefono2, $Telefono3,$Fax, $Cell, $E_mail,$Web, $REA, $CS)
{
global $link, $config_table;
$query = " INSERT INTO ".$config_table."
(
Ragione_Sociale,
Cognome,
Nome,
PI,
CF,
Indirizzo,
Citta,
CAP,
Provincia,
Telefono,
Telefono2,
Telefono3,
Fax,
Cell,
E_mail,
Web,
REA,
CS
)
VALUES
(
'".addslashes_deep($Ragione_Sociale)."',
'".addslashes_deep($Cognome)."',
'".addslashes_deep($Nome)."',
'".addslashes_deep($PI)."',
'".addslashes_deep($CF)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Citta)."',
'".addslashes_deep($CAP)."',
'".addslashes_deep($Provincia)."',
'".addslashes_deep($Telefono)."',
'".addslashes_deep($Telefono2)."',
'".addslashes_deep($Telefono3)."',
'".addslashes_deep($Fax)."',
'".addslashes_deep($Cell)."',
'".addslashes_deep($E_mail)."',
'".addslashes_deep($Web)."',
'".addslashes_deep($REA)."',
'".addslashes_deep($CS)."'
)";
//error_log($query,0);
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>configInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function configUpdate($ID_Azienda, $Ragione_Sociale, $Cognome, $Nome, $PI, $CF, $Indirizzo, $Citta, $CAP, $Provincia, $Telefono, $Telefono2, $Telefono3, $Fax, $Cell, $E_mail, $Web, $REA, $CS)
{
global $link, $config_table;
$query = "UPDATE ".$config_table."
SET
Ragione_Sociale='".addslashes_deep($Ragione_Sociale)."',
Cognome='".addslashes_deep($Cognome)."',
Nome='".addslashes_deep($Nome)."',
PI='".addslashes_deep($PI)."',
CF='".addslashes_deep($CF)."',
Indirizzo='".addslashes_deep($Indirizzo)."',
Citta='".addslashes_deep($Citta)."',
CAP='".addslashes_deep($CAP)."',
Provincia='".addslashes_deep($Provincia)."',
Telefono='".addslashes_deep($Telefono)."',
Telefono2='".addslashes_deep($Telefono2)."',
Telefono3='".addslashes_deep($Telefono3)."',
Fax='".addslashes_deep($Fax)."',
Cell='".addslashes_deep($Cell)."',
E_mail='".addslashes_deep($E_mail)."',
Web='".addslashes_deep($Web)."',
REA='".addslashes_deep($REA)."',
CS='".addslashes_deep($CS)."'
WHERE
ID_Azienda='$ID_Azienda'";
$result = mysql_query ($query, $link);
if (! $result )
die ("errore di aggiornamento ".mysql_error() );
}
function clientInsert ($Ragione_Sociale,$Cognome, $Nome,$PI,$CF, $Indirizzo,$Citta, $CAP, $Provincia, $Telefono, $Telefono2, $Telefono3,$Fax, $Cell,$E_mail,$Password,$Web)
{
global $link, $customers_table;
$query = " INSERT INTO ".$customers_table."
(
Ragione_Sociale,
Cognome,
Nome,
PI,
CF,
Indirizzo,
Citta,
CAP,
Provincia,
Telefono,
Telefono2,
Telefono3,
Fax,
Cell,
E_mail,
Password,
Web
)
VALUES
(
'".addslashes_deep($Ragione_Sociale)."',
'".addslashes_deep($Cognome)."',
'".addslashes_deep($Nome)."',
'".addslashes_deep($PI)."',
'".addslashes_deep($CF)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Citta)."',
'".addslashes_deep($CAP)."',
'".addslashes_deep($Provincia)."',
'".addslashes_deep($Telefono)."',
'".addslashes_deep($Telefono2)."',
'".addslashes_deep($Telefono3)."',
'".addslashes_deep($Fax)."',
'".addslashes_deep($Cell)."',
'".addslashes_deep($E_mail)."',
'".addslashes_deep($Password)."',
'".addslashes_deep($Web)."'
)";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>dynQuery</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function supplierInsert ($Ragione_Sociale,$Cognome, $Nome,$PI,$CF, $Indirizzo,$Citta, $CAP,$Provincia, $Telefono, $Telefono2, $Telefono3,$Fax, $Cell,$E_mail,$Password,$Web)
{
global $link, $suppliers_table;
$query = " INSERT INTO ".$suppliers_table."
(
Ragione_Sociale,
Cognome,
Nome,
PI,
CF,
Indirizzo,
Citta,
CAP,
Provincia,
Telefono,
Telefono2,
Telefono3,
Fax,
Cell,
E_mail,
Password,
Web
)
VALUES
(
'".addslashes_deep($Ragione_Sociale)."',
'".addslashes_deep($Cognome)."',
'".addslashes_deep($Nome)."',
'".addslashes_deep($PI)."',
'".addslashes_deep($CF)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Citta)."',
'".addslashes_deep($CAP)."',
'".addslashes_deep($Provincia)."',
'".addslashes_deep($Telefono)."',
'".addslashes_deep($Telefono2)."',
'".addslashes_deep($Telefono3)."',
'".addslashes_deep($Fax)."',
'".addslashes_deep($Cell)."',
'".addslashes_deep($E_mail)."',
'".addslashes_deep($Password)."',
'".addslashes_deep($Web)."'
)";
//error_log($query,0);
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>dynQuery</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function clientUpdate($ID_Cliente, $Ragione_Sociale, $Cognome, $Nome, $PI, $CF, $Indirizzo, $Citta, $CAP, $Provincia, $Telefono, $Telefono2, $Telefono3, $Fax, $Cell, $Password, $Web, $E_Mail)
{
global $link, $customers_table;
$query = "UPDATE ".$customers_table."
SET
Ragione_Sociale='".addslashes_deep($Ragione_Sociale)."',
Cognome='".addslashes_deep($Cognome)."',
Nome='".addslashes_deep($Nome)."',
PI='".addslashes_deep($PI)."',
CF='".addslashes_deep($CF)."',
Indirizzo='".addslashes_deep($Indirizzo)."',
Citta='".addslashes_deep($Citta)."',
CAP='".addslashes_deep($CAP)."',
Provincia='".addslashes_deep($Provincia)."',
Telefono='".addslashes_deep($Telefono)."',
Telefono2='".addslashes_deep($Telefono2)."',
Telefono3='".addslashes_deep($Telefono3)."',
Fax='".addslashes_deep($Fax)."',
Cell='".addslashes_deep($Cell)."',
E_Mail='".addslashes_deep($E_Mail)."',
Password='".addslashes_deep($Password)."',
Web='".addslashes_deep($Web)."'
WHERE
ID_Cliente='".$ID_Cliente."'";
$result = mysql_query ($query, $link);
if (! $result )
die ("errore di aggiornamento ".mysql_error() );
}
function supplierUpdate($ID_Fornitore, $Ragione_Sociale, $Cognome, $Nome, $PI, $CF, $Indirizzo, $Citta, $CAP, $Provincia, $Telefono, $Telefono2, $Telefono3, $Fax, $Cell, $Password, $Web, $E_Mail)
{
global $link, $suppliers_table;
$query = "UPDATE ".$suppliers_table."
SET
Ragione_Sociale='".addslashes_deep($Ragione_Sociale)."',
Cognome='".addslashes_deep($Cognome)."',
Nome='".addslashes_deep($Nome)."',
PI='".addslashes_deep($PI)."',
CF='".addslashes_deep($CF)."',
Indirizzo='".addslashes_deep($Indirizzo)."',
Citta='".addslashes_deep($Citta)."',
CAP='".addslashes_deep($CAP)."',
Provincia='".addslashes_deep($Provincia)."',
Telefono='".addslashes_deep($Telefono)."',
Telefono2='".addslashes_deep($Telefono2)."',
Telefono3='".addslashes_deep($Telefono3)."',
Fax='".addslashes_deep($Fax)."',
Cell='".addslashes_deep($Cell)."',
E_Mail='".addslashes_deep($E_Mail)."',
Password='".addslashes_deep($Password)."',
Web='".addslashes_deep($Web)."'
WHERE
ID_Fornitore='$ID_Fornitore'";
$result = mysql_query ($query, $link);
if (! $result )
die ("errore di aggiornamento ".mysql_error() );
}
function orderInsert ($ID_Cliente, $Protocollo, $Oggetto, $ID_Fattura, $Data_Ordine, $Data_Scadenza, $Tipo_Pagamento, $Prezzo, $Iva, $Rit,$Ragione_Sociale, $Cognome, $Nome, $PI, $CF, $Indirizzo, $Citta, $CAP, $Provincia, $Telefono, $Fax, $E_mail, $Status)
{
global $link, $orders_table;
$query = " INSERT INTO ".$orders_table."
(
ID_Cliente,
Protocollo,
Oggetto,
ID_Fattura,
Data_Ordine,
Data_Scadenza,
Tipo_Pagamento,
Prezzo,
Iva,
Ritenuta,
Ragione_Sociale,
Cognome,
Nome,
PI,
CF,
Indirizzo,
Citta,
CAP,
Provincia,
Telefono,
Fax,
E_mail,
Status
)
VALUES
(
'$ID_Cliente',
'".addslashes_deep($Protocollo)."',
'".addslashes_deep($Oggetto)."',
'$ID_Fattura',
'$Data_Ordine',
'$Data_Scadenza',
'$Tipo_Pagamento',
'$Prezzo',
'$Iva',
'$Rit',
'".addslashes_deep($Ragione_Sociale)."',
'".addslashes_deep($Cognome)."',
'".addslashes_deep($Nome)."',
'".addslashes_deep($PI)."',
'".addslashes_deep($CF)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Citta)."',
'".addslashes_deep($CAP)."',
'".addslashes_deep($Provincia)."',
'".addslashes_deep($Telefono)."',
'".addslashes_deep($Fax)."',
'".addslashes_deep($E_mail)."',
'".addslashes_deep($Status)."'
)";
//error_log($query,0);
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>orderInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function orderUpdate($ID_Ordine, $ID_Cliente, $Protocollo, $Oggetto, $ID_Fattura, $Data_Ordine, $Data_Scadenza, $Tipo_Pagamento, $Prezzo, $Iva, $Ragione_Sociale, $Cognome, $Nome, $PI, $CF, $Indirizzo, $Citta, $CAP, $Provincia, $Telefono, $Fax, $E_mail, $Status)
{
global $link, $orders_table;
$query = "UPDATE ".$orders_table."
SET
ID_Cliente='$ID_Cliente',
Protocollo='".addslashes_deep($Protocollo)."'
Oggetto='".addslashes_deep($Oggetto)."',
ID_Fattura='$ID_Fattura',
Data_Ordine='$Data_Ordine',
Data_Scadenza='$Data_Scadenza',
Tipo_Pagamento='$Tipo_Pagamento',
Prezzo='$Prezzo',
Iva='$Iva',
Ragione_Sociale='".addslashes_deep($Ragione_Sociale)."',
Cognome='".addslashes_deep($Cognome)."',
Nome='".addslashes_deep($Nome)."',
PI='".addslashes_deep($PI)."',
CF='".addslashes_deep($CF)."',
Indirizzo='".addslashes_deep($Indirizzo)."',
Citta='".addslashes_deep($Citta)."',
CAP='".addslashes_deep($CAP)."',
Provincia='".addslashes_deep($Provincia)."',
Telefono='".addslashes_deep($Telefono)."',
Fax='".addslashes_deep($Fax)."',
E_mail='".addslashes_deep($E_mail)."',
Status='".addslashes_deep($Status)."'
WHERE
ID_Ordine='$ID_Ordine'";
$result = mysql_query ($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>orderUpdate</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function bankInsert ($Banca, $Indirizzo, $Agenzia, $Abi, $Cab, $Conto, $Titolare,$CIN,$iban)
{
global $link, $bank_table;
$query = " INSERT INTO ".$bank_table."
(
Banca,
Indirizzo,
Agenzia,
Abi,
Cab,
Conto,
Titolare,
CIN,
iban
)
VALUES
(
'".addslashes_deep($Banca)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Agenzia)."',
'".addslashes_deep($Abi)."',
'".addslashes_deep($Cab)."',
'".addslashes_deep($Conto)."',
'".addslashes_deep($Titolare)."',
'".addslashes_deep($CIN)."',
'".addslashes_deep($iban)."'
)";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>dynQuery</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function bankUpdate($ID_Banca, $Banca, $Agenzia, $Indirizzo, $Abi, $Cab, $Conto, $Titolare,$CIN,$iban)
{
global $link, $bank_table;
$Indirizzo = addslashes($Indirizzo); // aggiunge i caratteri di escape dove serve
// todo: implementare una funzione che passeggia sull'array facendo il trim e
// lo slash davanti ai caratteri che necessitano
$query = "UPDATE ".$bank_table."
SET
Banca='".addslashes_deep($Banca)."',
Agenzia='".addslashes_deep($Agenzia)."',
Indirizzo='".addslashes_deep($Indirizzo)."',
Abi='".addslashes_deep($Abi)."',
Cab='".addslashes_deep($Cab)."',
Conto='".addslashes_deep($Conto)."',
Titolare='".addslashes_deep($Titolare)."',
CIN='".addslashes_deep($CIN)."',
iban='".addslashes_deep($iban)."'
WHERE
ID_Banca='$ID_Banca'";
//error_log($query,0);
$result = mysql_query ($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>bankUpdate</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
// print $query;
return $result;
}
function invoiceInsert ($Prog_Fattura_Annuo, $ID_Cliente, $ID_Banca, $Data_Fattura, $Ragione_Sociale, $PI, $Indirizzo, $Citta, $CAP, $Provincia, $Totale, $Tipo_Pagamento, $Scadenza,$Note)
{
global $link, $invoices_table;
$query = " INSERT INTO ".$invoices_table."
(
Prog_Fattura_Annuo,
ID_Cliente,
ID_Banca,
Data_Fattura,
Ragione_Sociale,
PI,
Indirizzo,
Citta,
CAP,
Provincia,
Totale,
Tipo_Pagamento,
Scadenza,
Note
)
VALUES
(
'$Prog_Fattura_Annuo',
'$ID_Cliente',
'$ID_Banca',
'$Data_Fattura',
'".addslashes_deep($Ragione_Sociale)."',
'".addslashes_deep($PI)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Citta)."',
'".addslashes_deep($CAP)."',
'".addslashes_deep($Provincia)."',
'$Totale',
'$Tipo_Pagamento',
'$Scadenza',
'".addslashes_deep($Note)."'
)";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>invoiceInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function invoiceUpdate ($ID_Fattura, $ID_Cliente, $ID_Banca, $Data_Fattura, $Ragione_Sociale, $PI, $Indirizzo, $Citta, $CAP, $Provincia, $Totale, $Tipo_Pagamento, $Scadenza,$Note)
{
global $link, $invoices_table;
$query = "UPDATE ".$invoices_table."
SET
ID_Cliente='$ID_Cliente',
ID_Banca='$ID_Banca',
Data_Fattura='$Data_Fattura',
Ragione_Sociale='".addslashes_deep($Ragione_Sociale)."',
PI='".addslashes_deep($PI)."',
Indirizzo='".addslashes_deep($Indirizzo)."',
Citta='".addslashes_deep($Citta)."',
CAP='".addslashes_deep($CAP)."',
Provincia='".addslashes_deep($Provincia)."',
Totale='$Totale',
Tipo_Pagamento='$Tipo_Pagamento',
Scadenza='$Scadenza',
Note='".addslashes_deep($Note)."'
WHERE
ID_Fattura='$ID_Fattura'";
$result = mysql_query ($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>invoiceUpdate</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function noteInsert ($ptable,$Prog_Nota_Annuo, $ID_Fattura, $ID_Cliente, $Ragione_Sociale, $PI, $Indirizzo, $Citta, $CAP, $Provincia, $Data_Nota, $Descrizione, $Iva, $Totale, $Note)
{
global $link;
$query = "INSERT INTO ".$ptable."
(
Prog_Nota_Annuo,
ID_Fattura,
ID_Cliente,
Ragione_Sociale,
PI,
Indirizzo,
Citta,
CAP,
Provincia,
Data_Nota,
Descrizione,
Iva,
Totale,
Note
)
VALUES
(
'$Prog_Nota_Annuo',
'$ID_Fattura',
'$ID_Cliente',
'".addslashes_deep($Ragione_Sociale)."',
'".addslashes_deep($PI)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Citta)."',
'".addslashes_deep($CAP)."',
'".addslashes_deep($Provincia)."',
'$Data_Nota',
'".addslashes_deep($Descrizione)."',
'$Iva',
'$Totale',
'".addslashes_deep($Note)."'
)";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>noteInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function noteUpdate ($ptable,$ID_Nota, $ID_Cliente, $ID_Fattura, $Data_Nota, $Ragione_Sociale, $PI, $Indirizzo, $Citta, $CAP, $Provincia, $Descrizione, $Totale, $Iva, $Tipo_Pagamento, $Note)
{
global $link;
$query = " UPDATE ".$ptable." SET
ID_Cliente = '$ID_Cliente',
ID_Fattura = '$ID_Fattura',
Data_Nota = '$Data_Nota',
Ragione_Sociale = '".addslashes_deep($Ragione_Sociale)."',
PI = '".addslashes_deep($PI)."',
Indirizzo = '".addslashes_deep($Indirizzo)."',
Citta = '".addslashes_deep($Citta)."',
CAP = '".addslashes_deep($CAP)."',
Provincia = '".addslashes_deep($Provincia)."',
Descrizione = '".addslashes_deep($Descrizione)."',
Totale = '$Totale',
Iva = '$Iva',
Tipo_Pagamento = '$Tipo_Pagamento',
Note = '".addslashes_deep($Note)."'
WHERE
ID_Nota = '$ID_Nota'
";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>spl_noteInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function spl_invoiceInsert ($ID_Fornitore, $N_Fattura, $Data_Fattura, $Ragione_Sociale, $PI, $Indirizzo, $Citta, $CAP, $Provincia, $Descrizione, $Totale, $Imposta, $Tipo_Pagamento, $Data_Scadenza, $Note,$Ritenuta)
{
global $link, $spl_invoices_table;
$query = " INSERT INTO ".$spl_invoices_table."
(
ID_Fornitore,
N_Fattura,
Data_Fattura,
Ragione_Sociale,
PI,
Indirizzo,
Citta,
CAP,
Provincia,
Descrizione,
Totale,
Imposta,
Tipo_Pagamento,
Scadenza,
Note,
Ritenuta
)
VALUES
(
'$ID_Fornitore',
'".addslashes_deep($N_Fattura)."',
'$Data_Fattura',
'".addslashes_deep($Ragione_Sociale)."',
'".addslashes_deep($PI)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Citta)."',
'".addslashes_deep($CAP)."',
'".addslashes_deep($Provincia)."',
'".addslashes_deep($Descrizione)."',
'$Totale',
'$Imposta',
'$Tipo_Pagamento',
'$Data_Scadenza',
'".addslashes_deep($Note)."',
'$Ritenuta'
)";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>spl_invoiceInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function spl_invoiceUpdate($ID_Fattura_Acquisto, $ID_Fornitore, $N_Fattura, $Data_Fattura, $Ragione_Sociale, $PI, $Indirizzo, $Citta, $CAP, $Provincia, $Descrizione, $Totale, $Imposta, $Tipo_Pagamento, $Data_Scadenza, $Note, $Ritenuta)
{
global $link, $spl_invoices_table;
$query = "UPDATE ".$spl_invoices_table."
SET
ID_Fattura_Acquisto = '$ID_Fattura_Acquisto',
ID_Fornitore = '$ID_Fornitore',
N_Fattura = '".addslashes_deep($N_Fattura)."',
Data_Fattura = '$Data_Fattura',
Ragione_Sociale='".addslashes_deep($Ragione_Sociale)."',
PI='".addslashes_deep($PI)."',
Indirizzo='".addslashes_deep($Indirizzo)."',
Citta='".addslashes_deep($Citta)."',
CAP='".addslashes_deep($CAP)."',
Provincia='".addslashes_deep($Provincia)."',
Descrizione = '".addslashes_deep($Descrizione)."',
Totale = '$Totale',
Imposta = '$Imposta',
Tipo_Pagamento = '$Tipo_Pagamento',
Scadenza = '$Data_Scadenza',
Note = '".addslashes_deep($Note)."',
Ritenuta = '$Ritenuta'
WHERE
ID_Fattura_Acquisto='$ID_Fattura_Acquisto'";
$result = mysql_query ($query, $link);
//error_log($query,0);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>spl_invoiceUpdate</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function spl_noteInsert ($ID_Fornitore, $N_Nota, $ID_Fattura_Acquisto, $Data_Nota, $Ragione_Sociale, $PI, $Indirizzo, $Citta, $CAP, $Provincia, $Descrizione, $Totale, $Imposta, $Tipo_Pagamento, $Note)
{
global $link, $spl_credit_notes_table;
$query = " INSERT INTO ".$spl_credit_notes_table."
(
ID_Fornitore,
N_Nota,
ID_Fattura_Acquisto,
Data_Nota,
Ragione_Sociale,
PI,
Indirizzo,
Citta,
CAP,
Provincia,
Descrizione,
Totale,
Imposta,
Tipo_Pagamento,
Note
)
VALUES
(
'$ID_Fornitore',
'".addslashes_deep($N_Nota)."',
'$ID_Fattura_Acquisto',
'$Data_Nota',
'".addslashes_deep($Ragione_Sociale)."',
'".addslashes_deep($PI)."',
'".addslashes_deep($Indirizzo)."',
'".addslashes_deep($Citta)."',
'".addslashes_deep($CAP)."',
'".addslashes_deep($Provincia)."',
'".addslashes_deep($Descrizione)."',
'$Totale',
'$Imposta',
'$Tipo_Pagamento',
'".addslashes_deep($Note)."'
)";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>spl_noteInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function spl_noteUpdate ($ID_Nota, $ID_Fornitore, $N_Nota, $ID_Fattura_Acquisto, $Data_Nota, $Ragione_Sociale, $PI, $Indirizzo, $Citta, $CAP, $Provincia, $Descrizione, $Totale, $Imposta, $Tipo_Pagamento, $Note)
{
global $link, $spl_credit_notes_table;
$query = " UPDATE ".$spl_credit_notes_table." SET
ID_Fornitore = '$ID_Fornitore',
N_Nota = '".addslashes_deep($N_Nota)."',
ID_Fattura_Acquisto = '$ID_Fattura_Acquisto',
Data_Nota = '$Data_Nota',
Ragione_Sociale = '".addslashes_deep($Ragione_Sociale)."',
PI = '".addslashes_deep($PI)."',
Indirizzo = '".addslashes_deep($Indirizzo)."',
Citta = '".addslashes_deep($Citta)."',
CAP = '".addslashes_deep($CAP)."',
Provincia = '".addslashes_deep($Provincia)."',
Descrizione = '".addslashes_deep($Descrizione)."',
Totale = '$Totale',
Imposta = '$Imposta',
Tipo_Pagamento = '$Tipo_Pagamento',
Note = '".addslashes_deep($Note)."'
WHERE
ID_Nota = '$ID_Nota'
";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>spl_noteInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function movInsert ($ID_Cliente,$ID_Fornitore,
$Ragione_Sociale,$Data_Valuta,
$Tipo_Pagamento,
$Entrate,$Uscite,
$ID_Banca,$Descrizione)
{
global $link, $mov_table;
$query = " INSERT INTO ".$mov_table."
(
ID_Cliente,
ID_Fornitore,
Ragione_Sociale,
Data_Valuta,
Tipo_Pagamento,
Entrate,
Uscite,
ID_Banca,
Descrizione
)
VALUES
(
'$ID_Cliente',
'$ID_Fornitore',
'".addslashes_deep($Ragione_Sociale)."',
'$Data_Valuta',
'$Tipo_Pagamento',
'$Entrate',
'$Uscite',
'$ID_Banca',
'".addslashes_deep($Descrizione)."'
)";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>spl_noteInsert</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function movUpdate ($ID_Movimento,
$ID_Cliente,
$ID_Fornitore,
$Ragione_Sociale,
$Data_Valuta,
$Entrate,
$Uscite,
$ID_Banca,
$Descrizione)
{
global $link, $mov_table;
$query = " UPDATE ".$mov_table." SET
ID_Cliente = '$ID_Cliente',
ID_Fornitore = '$ID_Fornitore',
Ragione_Sociale = '".addslashes_deep($Ragione_Sociale)."',
Data_Valuta = '$Data_Valuta',
Entrate = '$Entrate',
Uscite = '$Uscite',
ID_Banca = '$ID_Banca',
Descrizione = '".addslashes_deep($Descrizione)."'
WHERE
ID_Movimento = '$ID_Movimento'
";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>movUpdate</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function refMovUpdate ($ID_Movimento,
$ID_Fattura)
{
global $link, $mov_table;
$query = " UPDATE ".$mov_table." SET
ID_Fattura = '$ID_Fattura'
WHERE
ID_Movimento = '$ID_Movimento'
";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>refMovUpdate</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function vatInsert ($Percentuale,$Descrizione, $Codice,$Indetraibile)
{
global $link, $vat_table;
$query = " INSERT INTO ".$vat_table."
(
Percentuale,
Descrizione,
Codice,
Indetraibile
)
VALUES
(
'$Percentuale',
'$Descrizione',
'$Codice',
'$Indetraibile'
)";
$result = mysql_query($query, $link);
if (! $result )
{
$result = "<br>Errore nell'esecuzione di <b>dynQuery</b> <br>Query= <b>$query</b> <br> Errore Mysql = <b>".mysql_error()."</b><br>";
print $result;
}
return $result;
}
function delRow( $table, $fname, $fval)
{
global $link;
$result = mysql_query("DELETE FROM $table WHERE $fname = '$fval'", $link);
if (! $result )
die (" Errore di cancellazione: ".mysql_error());
}
// restituisce il numero di record in una tabella
function recordCount($table)
{
global $link;
$result = mysql_query("SELECT * FROM $table" ,$link);
$count = mysql_num_rows($result);
return $count;
}
// restituisce il numero record di una query
function queryCount($table, $where)
{
global $link;
$result = mysql_query("SELECT * FROM ".$table." WHERE ".$where."" ,$link);
$count = mysql_num_rows($result);
return $count;
}
?>