. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 52.223.31.75 / Your IP : 172.31.6.220 [ Web Server : Apache/2.4.66 () OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux ip-172-31-14-81.eu-central-1.compute.internal 4.14.281-212.502.amzn2.x86_64 #1 SMP Thu May 26 09:52:17 UTC 2022 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE Domains : 4 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/ripara.co/app/helpers/ |
Upload File : |
<?php
class Content extends DBLink
{
// The values of these constants MUST match the values in the DB.
// Media types
const MEDIATYPE_FILE = 1;
const MEDIATYPE_YTVIDEO = 2;
const MEDIATYPE_LINK = 3;
const MEDIATYPE_LOCALVIDEO = 4;
const MEDIATYPE_YOUTUBEUPLOAD = 5;
// Pages
const PAGE_GRAPH = 1;
const PAGE_MENU = 2;
const PAGE_OVERVIEW = 3;
const PAGE_MORE = 4;
const PAGE_POLICY = 5;
const PAGE_EXPERTS = 6;
const PAGE_LINKS = 7;
const PAGE_EMPLOYEES = 8;
const PAGE_LOGIN = 9;
public function __construct()
{
parent::__construct(FILE_INI_MDADB);
$this->SafeFetch("SET CHARACTER SET utf8 ");
}
/*
*
* @author Giuseppe Paglialonga
*
*@Peo,
*
*/
//PRODOTTI IN VENDITA
public function getProdottiVendita(){
$query = "SELECT * FROM prodottoinvendita";
return $this->SafeFetch($query);
}
public function insertProdottoVendita($nome, $prezzo, $foto, $descrizione, $quantita, $costospedizione, $tipoprodotto, $idcategoria, $codice, $attivo, $sconto){
$anome=$this->quoteText($nome);
$aprezzo=$this->quoteText($prezzo);
$afoto= $this->quoteText($foto);
$adescrizione=$this->quoteText($descrizione);
$aquantita=$this->quoteText($quantita);
$acostospedizione=$this->quoteText($costospedizione);
$atipoprodotto=$this->quoteText($tipoprodotto);
$aidcategoria=$this->quoteInt($idcategoria);
$attivo=$this->quoteInt($attivo);
$codice=$this->quoteText($codice);
$sconto=$this->quoteText($sconto);
$query = "INSERT INTO prodottoinvendita (nome, prezzo, foto, descrizione, quantita, costospedizione, tipoprodotto, idcategoria, codice, attivo, sconto) VALUES($anome, $aprezzo,$afoto, $adescrizione, $aquantita, $acostospedizione, $atipoprodotto, $aidcategoria, $codice, $attivo, $sconto)";
return $this->SafeInsert($query);
}
public function updateProdottoVendita($idprodotto,$nome, $prezzo, $foto, $descrizione, $quantita, $costospedizione, $tipoprodotto, $idcategoria, $codice, $attivo, $sconto){
$codice=$this->quoteText($codice);
$anome=$this->quoteText($nome);
$aidprodotto=$this->quoteInt($idprodotto);
$aprezzo=$this->quoteText($prezzo);
$afoto= $this->quoteText($foto);
$adescrizione=$this->quoteText($descrizione);
$aquantita=$this->quoteText($quantita);
$acostospedizione=$this->quoteText($costospedizione);
$atipoprodotto=$this->quoteText($tipoprodotto);
$aidcategoria=$this->quoteInt($idcategoria);
$sconto=$this->quoteText($sconto);
if($foto!=null)
$query = "UPDATE prodottoinvendita SET nome=$anome, prezzo=$aprezzo, foto=$afoto, descrizione=$adescrizione, quantita=$aquantita, costospedizione=$acostospedizione, tipoprodotto=$atipoprodotto, idcategoria=$aidcategoria, codice=$codice, attivo=$attivo, sconto=$sconto WHERE idprodotto=$aidprodotto";
else
$query = "UPDATE prodottoinvendita SET nome=$anome, prezzo=$aprezzo, descrizione=$adescrizione, quantita=$aquantita, costospedizione=$acostospedizione, tipoprodotto=$atipoprodotto, idcategoria=$aidcategoria, codice=$codice, attivo=$attivo, sconto=$sconto WHERE idprodotto=$aidprodotto";
return $this->SafeExec($query);
}
public function getFotoProdottoVendita($idprodotto){
$aidprodotto=$this->quoteInt($idprodotto);
$query = "SELECT * FROM prodottoinvendita where idprodotto = $aidprodotto";
return json_decode($this->SafeFetch($query)[0]['foto'],true);
}
public function deleteProdottoVendita($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM prodottoinvendita where idprodotto = $aid";
return $this->SafeExec($query);
}
public function deleteFotoProdottoVendita($idprodotto, $filename){
$idprodotto = $this->QuoteInt($idprodotto);
$query = "SELECT * FROM prodottoinvendita where idprodotto = $idprodotto";
$prod= json_decode($this->SafeFetch($query)[0]['foto'], true);
$filename = end(explode("/", $filename));
$arr=array();
$skip=false;
for ($i=0; $i < count($prod); $i++) {
if(end(explode("/",$prod[$i])) == $filename){
$skip=true;
}else{
$arr[]=$prod[$i];
}
}
if($skip){
$foto=$this->quoteText(json_encode($arr));
$query = "UPDATE prodottoinvendita SET foto=$foto WHERE idprodotto=$idprodotto";
return $this->SafeExec($query);
}else{
return false;
}
}
//ORDINI
public function getTnx($txn_id){
$txn_id=$this->quoteText($txn_id);
$query = "SELECT * FROM transazioni WHERE txn_id LIKE $txn_id";
return $this->SafeFetch($query)[0];
}
public function getOrdini(){
$query = "SELECT ordine.*, ragionesociale, sede, idordine, idpagamento, indirizzospedizione, timestamp, sconto, prodotti, nomestato FROM ordine LEFT JOIN cliente on ordine.idcliente=cliente.idcliente LEFT join stati on stati.idstato = ordine.idstato";
return $this->SafeFetch($query);
}
public function getClienteOrdine(){
$query = "SELECT CONCAT(indirizzo, ' ', citta) as indirizzo, cap, idcliente, ragionesociale FROM cliente";
return $this->SafeFetch($query);
}
public function insertOrdine($tipopagamento, $idstato, $indirizzospedizione, $idcliente, $sconto, $prodotti){
$atipopagamento=$this->quoteInt($tipopagamento);
$aidstato= $this->quoteInt($idstato);
$aindirizzospedizione=$this->quoteText($indirizzospedizione);
$aidstato=$this->quoteInt($idstato);
$aidcliente=$this->quoteInt($idcliente);
$asconto=$this->quoteText($sconto);
$aprodotti=$this->quoteText($prodotti);
$asconto=$this->quoteText($sconto);
$query = "INSERT INTO ordine (idpagamento, idstato, indirizzospedizione, idcliente, sconto, prodotti) VALUES($atipopagamento, $aidstato, $aindirizzospedizione, $aidcliente, $asconto, $aprodotti)";
return $this->SafeInsert($query);
}
public function updateOrdine($idordine, $tipopagamento, $idstato, $indirizzospedizione, $idcliente, $sconto, $prodotti){
$aidordine=$this->quoteInt($idordine);
$atipopagamento=$this->quoteInt($tipopagamento);
$aidstato= $this->quoteInt($idstato);
$aindirizzospedizione=$this->quoteText($indirizzospedizione);
$aidstato=$this->quoteInt($idstato);
$aidcliente=$this->quoteInt($idcliente);
$asconto=$this->quoteText($sconto);
$aprodotti=$this->quoteText($prodotti);
$query = "UPDATE ordine SET idpagamento=$atipopagamento, idstato= $aidstato, indirizzospedizione=$aindirizzospedizione, idcliente=$aidcliente, sconto=$asconto, prodotti= $aprodotti WHERE idordine=$aidordine";
return $this->SafeExec($query);
}
public function deleteOrdine($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM ordine where idordine = $aid";
return $this->SafeExec($query);
}
//CATEGORIE PRODOTTI
public function getCategorieProdotto(){
$query = "SELECT * FROM categoria_prodottovendita";
return $this->SafeFetch($query);
}
public function deleteCategoriaVendita($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM categoria_prodottovendita where idcategoria = $aid";
return $this->SafeInsert($query);
}
public function insertCategoriaVendita($nome, $id_category_google, $id_category_facebook, $foto){
$anome=$this->quoteText($nome);
$aid_category_google=$this->quoteInt($id_category_google);
$aid_category_facebook=$this->quoteInt($id_category_facebook);
$anome=$this->quoteText($nome);
$afoto=$this->quoteText($foto);
$query = "INSERT INTO categoria_prodottovendita (nomecategoria, fotocategoria, id_category_google, id_category_facebook) VALUES ($anome, $afoto, $aid_category_google, $aid_category_facebook)";
return $this->SafeInsert($query);
}
public function updateCategoriaVendita($idCategoria, $nome, $id_category_google, $id_category_facebook, $foto){
$aidCategoria=$this->quoteInt($idCategoria);
$anome=$this->quoteText($nome);
$aid_category_google=$this->quoteInt($id_category_google);
$aid_category_facebook=$this->quoteInt($id_category_facebook);
if($foto){
$afoto=$this->quoteText($foto);
$query = "UPDATE categoria_prodottovendita SET nomecategoria= $anome, id_category_google=$aid_category_google, id_category_facebook=$aid_category_facebook, fotocategoria= $afoto WHERE idcategoria=$aidCategoria";
}else{
$query = "UPDATE categoria_prodottovendita SET nomecategoria= $anome, id_category_google=$aid_category_google, id_category_facebook=$aid_category_facebook WHERE idcategoria=$aidCategoria";
}
// echo $query;
$this->SafeExec($query);
return true;
}
/*
*
* @author Giuseppe Paglialonga
*
*@Peo,
*
*/
//marca
public function deleteSede($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM sede where idsede = $aid";
return $this->SafeInsert($query);
}
public function insertSede($nomesede,$descrizione, $telefono, $linkmap){
$anomesede=$this->quoteText($nomesede);
$adescrizione=$this->quoteText($descrizione);
$atelefono=$this->quoteText($telefono);
$alinkmap=$this->quoteText($linkmap);
$query = "INSERT INTO sede (nomesede, descrizione, telefono, linkmap) VALUES($anomesede,$adescrizione, $atelefono, $alinkmap)";
return $this->SafeExec($query);
}
public function editSede($idsede, $nomesede,$descrizione, $telefono, $linkmap){
$aid=$this->quoteInt($idsede);
$anomesede=$this->quoteText($nomesede);
$adescrizione=$this->quoteText($descrizione);
$atelefono=$this->quoteText($telefono);
$alinkmap=$this->quoteText($linkmap);
$query = "UPDATE sede SET nomesede=$anomesede, descrizione=$adescrizione, telefono=$atelefono, linkmap=$alinkmap WHERE idsede=$aid";
return $this->SafeExec($query);
}
//pagamenti
public function getPagamenti(){
$query = "SELECT * FROM pagamento";
return $this->SafeFetch($query);
}
public function deletePagamento($id){
if($id == 1 || $id == 2){
return -1;
}
$aid = $this->QuoteInt($id);
$query = "DELETE FROM pagamento where idpagamento = $aid";
return $this->SafeInsert($query);
}
public function insertPagamento($nomepagamento,$costopagamento,$attivo){
$nomepagamento=$this->quoteText($nomepagamento);
$costopagamento=$this->quoteText($costopagamento);
$attivo=$this->quoteText($attivo);
$query = "INSERT INTO pagamento (nomepagamento, costopagamento, attivo) VALUES($nomepagamento,$costopagamento, $attivo)";
return $this->SafeExec($query);
}
public function editPagamento($idpagamento, $nomepagamento,$costopagamento,$attivo){
$idpagamento=$this->quoteInt($idpagamento);
$nomepagamento=$this->quoteText($nomepagamento);
$costopagamento=$this->quoteText($costopagamento);
$attivo=$this->quoteText($attivo);
$query = "UPDATE pagamento SET nomepagamento=$nomepagamento, costopagamento=$costopagamento , attivo=$attivo WHERE idpagamento=$idpagamento";
return $this->SafeExec($query);
}
public function deleteStat($id){
if($id == 8 || $id == 9 || $id == 10){
return -1;
}
$aid = $this->QuoteInt($id);
$query = "DELETE FROM stati where idstato = $aid";
return $this->SafeInsert($query);
}
public function insertStat($nomestato,$descrizione){
$anomestato=$this->quoteText($nomestato);
$adescrizione=$this->quoteText($descrizione);
$query = "INSERT INTO stati (nomestato, descrizione) VALUES($anomestato,$adescrizione)";
return $this->SafeExec($query);
}
public function editStat($idstato, $nomestato,$descrizione){
$aid=$this->quoteInt($idstato);
$anomestato=$this->quoteText($nomestato);
$adescrizione=$this->quoteText($descrizione);
$query = "UPDATE stati SET nomestato=$anomestato, descrizione=$adescrizione WHERE idstato=$aid";
return $this->SafeExec($query);
}
public function deleteMarca($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM marca where idmarca = $aid";
return $this->SafeInsert($query);
}
public function insertMarca($nomeMarca,$fotoMarca){
$aidMarca=$this->quoteInt($idMarca);
$anomeMarca=$this->quoteText($nomeMarca);
$afotoMarca=$this->quoteText($fotoMarca);
$query = "INSERT INTO marca (nomeMarca,fotoMarca) VALUES($anomeMarca,$afotoMarca)";
return $this->SafeExec($query);
}
public function editMarca($idMarca, $nomeMarca,$fotoMarca){
$aidMarca=$this->quoteInt($idMarca);
$anomeMarca=$this->quoteText($nomeMarca);
$aidCategoria=$this->quoteInt($idCategoria);
if($fotoMarca){
$afotoMarca=$this->quoteText($fotoMarca);
$query = "UPDATE marca SET nomeMarca= $anomeMarca, fotoMarca= $afotoMarca WHERE idmarca=$aidMarca";
}else{
$query = "UPDATE marca SET nomeMarca= $anomeMarca WHERE idmarca=$aidMarca";
}
$this->SafeInsert($query);
return true;
}
//device
public function deleteDevice($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM device where iddevice = $aid";
return $this->SafeInsert($query);
}
public function insertDevice($idMarca,$modello,$fotoDevice, $idCategoria){
$aidMarca=$this->quoteInt($idMarca);
$amodello=$this->quoteText($modello);
$afotoDevice=$this->quoteText($fotoDevice);
$aidCategoria=$this->quoteInt($idCategoria);
$query = "INSERT INTO device (idMarca,modello,fotoDevice,idCategoria) VALUES($aidMarca,$amodello,$afotoDevice,$aidCategoria)";
return $this->SafeExec($query);
}
public function editDevice($idDevice, $idMarca,$modello,$fotoDevice, $idCategoria){
$aidDevice=$this->quoteInt($idDevice);
$aidMarca=$this->quoteInt($idMarca);
$amodello=$this->quoteText($modello);
$aidCategoria=$this->quoteInt($idCategoria);
if($fotoDevice){
$afotoDevice=$this->quoteText($fotoDevice);
$query = "UPDATE device SET idMarca= $aidMarca, modello= $amodello,fotoDevice= $afotoDevice,idCategoria= $aidCategoria WHERE iddevice=$aidDevice";
}else{
$query = "UPDATE device SET idMarca= $aidMarca, modello= $amodello, idCategoria= $aidCategoria WHERE iddevice=$aidDevice";
}
$this->SafeExec($query);
return true;
}
//cliente
public function deleteCliente($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM cliente where id = $aid";
return $this->SafeInsert($query);
}
public function insertCliente($ragioneSociale, $indirizzo, $citta, $piva, $codicefiscale, $telefono, $cellulare, $email, $note, $sede){
$aragioneSociale=$this->quoteText($ragioneSociale);
$aindirizzo=$this->quoteText($indirizzo);
$acitta=$this->quoteText($citta);
$apiva=$this->quoteText($piva);
$acodicefiscale=$this->quoteText($codicefiscale);
$atelefono=$this->quoteText($telefono);
$acellulare=$this->quoteText($cellulare);
$aemail=$this->quoteText($email);
$anote=$this->quoteText($note);
$asede=$this->quoteText($sede);
$query = "INSERT INTO cliente (ragioneSociale,indirizzo,citta,piva,codicefiscale,telefono,cellulare,email,note,sede) VALUES($aragioneSociale,$aindirizzo,$acitta,$apiva,$acodicefiscale,$atelefono,$acellulare,$aemail,$anote,$asede)";
return $this->SafeInsert($query);
}
public function editCliente($idCliente, $ragioneSociale, $indirizzo, $citta, $piva, $codicefiscale, $telefono, $cellulare, $email, $note, $sede){
$aidCliente=$this->quoteInt($idCliente);
$aragioneSociale=$this->quoteText($ragioneSociale);
$aindirizzo=$this->quoteText($indirizzo);
$acitta=$this->quoteText($citta);
$apiva=$this->quoteText($piva);
$acodicefiscale=$this->quoteText($codicefiscale);
$atelefono=$this->quoteText($telefono);
$acellulare=$this->quoteText($cellulare);
$aemail=$this->quoteText($email);
$anote=$this->quoteText($note);
$asede=$this->quoteText($sede);
$query = "UPDATE cliente SET ragioneSociale= $aragioneSociale, indirizzo= $aindirizzo,citta= $acitta,piva= $apiva,codicefiscale= $acodicefiscale,telefono= $atelefono,cellulare= $acellulare,email= $aemail,note= $anote,sede= $asede WHERE idcliente=$aidCliente";
$this->SafeExec($query);
return true;
}
public function deleteCategor($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM categoria where idcategoria = $aid";
return $this->SafeInsert($query);
}
public function insertCategor($nome, $foto){
$anome=$this->quoteText($nome);
$afoto=$this->quoteText($foto);
$query = "INSERT INTO categoria (nomecategoria, fotocategoria) VALUES ($anome, $afoto)";
return $this->SafeExec($query);
}
public function editCategor($idCategoria, $nome, $foto){
$aidCategoria=$this->quoteInt($idCategoria);
$anome=$this->quoteText($nome);
if($foto){
$afoto=$this->quoteText($foto);
$query = "UPDATE categoria SET nomecategoria= $anome, fotocategoria= $afoto WHERE idcategoria=$aidCategoria";
}else{
$query = "UPDATE categoria SET nomecategoria= $anome WHERE idcategoria=$aidCategoria";
}
$this->SafeExec($query);
return true;
}
public function deleteRiparazione($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM riparazione where idRiparazione = $aid";
return $this->SafeInsert($query);
}
public function insertRiparazione($idDevice, $idcliente, $dataIngresso,$dataRiconsegna,$serialeImei,$accessoriConsegnati,$descrizioneProblema,$descrizioneRiparazione,$fotoRiparazione,$totaleCostoRiparazione, $preventivoRiparazione, $note, $sede, $stato, $prodotti, $id_user){
$aid_user=$this->quoteInt($id_user);
$aidcliente=$this->quoteInt($idcliente);
$astato=$this->quoteInt($stato);
$aidDevice=$this->quoteInt($idDevice);
$adataIngresso=$this->quoteText($dataIngresso);
$asede=$this->quoteInt($sede);
$adataRiconsegna=$this->quoteText($dataRiconsegna);
$aserialeImei=$this->quoteText($serialeImei);
$aaccessoriConsegnati=$this->quoteText($accessoriConsegnati);
$adescrizioneProblema=$this->quoteText($descrizioneProblema);
$adescrizioneRiparazione=$this->quoteText($descrizioneRiparazione);
$afotoRiparazione=$this->quoteText($fotoRiparazione);
$atotaleCostoRiparazione=$this->quoteText($totaleCostoRiparazione);
$apreventivoRiparazione=$this->quoteText($preventivoRiparazione);
$anote=$this->quoteText($note);
if($asede<1){
$asede =1;
}
$query = "INSERT INTO riparazione (iddevice,idcliente,dataingresso,datariconsegna,serialeimei,accessoriconsegnati,descrizioneproblema,descrizioneriparazione,fotoriparazione,totalecostoriparazione,preventivoriparazione,note,stato, sede, id_user_insert, id_user_updated) VALUES ($aidDevice, $aidcliente, $adataIngresso, $adataRiconsegna, $aserialeImei,$aaccessoriConsegnati,$adescrizioneProblema, $adescrizioneRiparazione, $afotoRiparazione, $atotaleCostoRiparazione, $apreventivoRiparazione, $anote, $astato, $asede, $aid_user, $aid_user)";
$idriparazione = $this->SafeInsert($query);
if($idriparazione){
$aidriparazione = $this->quoteInt($idriparazione);
//per ogni prodotti
$controllo = 1;
$prodotti = unserialize($prodotti);
foreach ($prodotti as $key => $value) {
$aidprodotto = $this->quoteInt($value->id);
$aquantita = $this->quoteInt($value->quantita);
$aquery = "INSERT INTO riparazioneprodotti (idriparazione, idprodotto, quantita) VALUES ($aidriparazione, $aidprodotto, $aquantita) ";
if(!$this->SafeExec($aquery)){
$scontrollo = 0;
}
}
}
if($controllo){return $idriparazione;}
return false;
}
public function editRiparazione($idRiparazione, $idDevice, $idcliente, $dataIngresso,$dataRiconsegna,$serialeImei,$accessoriConsegnati,$descrizioneProblema,$descrizioneRiparazione,$fotoRiparazione,$totaleCostoRiparazione, $preventivoRiparazione, $note,$sede, $stato, $prodotti, $id_user){
$astato=$this->quoteInt($stato);
$asede=$this->quoteInt($sede);
$aid_user=$this->quoteInt($id_user);
if($asede<1){
$asede =1;
}
$aidRiparazione=$this->quoteInt($idRiparazione);
$aidcliente=$this->quoteInt($idcliente);
$aidDevice=$this->quoteInt($idDevice);
$adataIngresso=$this->quoteText($dataIngresso);
$adataRiconsegna=$this->quoteText($dataRiconsegna);
$aserialeImei=$this->quoteText($serialeImei);
$aaccessoriConsegnati=$this->quoteText($accessoriConsegnati);
$adescrizioneProblema=$this->quoteText($descrizioneProblema);
$adescrizioneRiparazione=$this->quoteText($descrizioneRiparazione);
$afotoRiparazione=$this->quoteText($fotoRiparazione);
$atotaleCostoRiparazione=$this->quoteText($totaleCostoRiparazione);
$apreventivoRiparazione=$this->quoteText($preventivoRiparazione);
$anote=$this->quoteText($note);
$query = "UPDATE riparazione SET iddevice='$aidDevice', idcliente= $aidcliente, datariconsegna=$adataRiconsegna, serialeimei= $aserialeImei,accessoriconsegnati= $aaccessoriConsegnati, descrizioneproblema= $adescrizioneProblema, descrizioneriparazione=$adescrizioneRiparazione,fotoriparazione = $afotoRiparazione, totalecostoriparazione=$atotaleCostoRiparazione, preventivoriparazione= $apreventivoRiparazione, note=$anote, stato=$astato, sede=$asede, id_user_updated=$aid_user WHERE idriparazione = $aidRiparazione";
return $this->SafeExec($query);
//cancello i vecchi prodotti
$aid = $this->quoteInt($id);
$query = "DELETE FROM riparazioneprodotti where idriparazione = $aidRiparazione";
return $this->SafeInsert($query);
//aggiungo i nuovi prodotti
$aidriparazione = $aidRiparazione;
//per ogni prodotti
$controllo = 1;
$prodotti = unserialize($prodotti);
foreach ($prodotti as $key => $value) {
$aidprodotto = $this->quoteInt($value->id);
$aquantita = $this->quoteInt($value->quantita);
$aquery = "INSERT INTO riparazioneprodotti (idriparazione, idprodotto, quantita) VALUES ($aidriparazione, $aidprodotto, $aquantita) ";
if(!$this->SafeExec($aquery)){
$controllo = 0;
echo mysql_error();
}
}
if($controllo){return true;}
return false;
}
public function cambiaStatoRiparazione($id_riparazione, $id_stato_pre, $id_stato, $id_user, $id_user_real){
$id_stato_pre=$this->quoteInt($id_stato_pre);
$id_stato=$this->quoteInt($id_stato);
$id_user=$this->quoteInt($id_user);
$id_user_real=$this->quoteInt($id_user_real);
$id_riparazione=$this->quoteInt($id_riparazione);
$aquery = "INSERT INTO cambi_stati_riparazione (id_riparazione, id_stato_pre, id_stato, id_user, id_user_real) VALUES ($id_riparazione, $id_stato_pre, $id_stato, $id_user, $id_user_real) ";
return $this->SafeInsert($aquery);
}
public function getStatiRiparazione($id_riparazione){
$id_riparazione=$this->quoteInt($id_riparazione);
$query = "SELECT * FROM cambi_stati_riparazione WHERE id_riparazione = $id_riparazione order by timestamp ASC";
$one= $this->SafeFetch($query);
foreach ($one as $key => $value) {
$id_user = $this->quoteInt($value['id_user']);
$aquery = "SELECT firstname,lastname FROM user WHERE id_user = $id_user";
$aone= $this->SafeFetch($aquery);
$one[$key]['nome_user'] = $aone[0]["firstname"]. " " . $aone[0]["lastname"];
$id_user_real = $this->quoteInt($value['id_user_real']);
$aquery = "SELECT firstname,lastname FROM user WHERE id_user = $id_user_real";
$aone= $this->SafeFetch($aquery);
$one[$key]['nome_user_real'] = $aone[0]["firstname"]. " " . $aone[0]["lastname"];
$id_stato = $this->quoteInt($value['id_stato']);
$aquery = "SELECT nomestato FROM stati WHERE idstato = $id_stato";
$aone= $this->SafeFetch($aquery);
$one[$key]['nome_stato'] = $aone[0]["nomestato"];
$id_stato_pre = $this->quoteInt($value['id_stato_pre']);
$aquery = "SELECT nomestato FROM stati WHERE idstato = $id_stato_pre";
$aone= $this->SafeFetch($aquery);
$one[$key]['nome_stato_pre'] = $aone[0]["nomestato"];
}
return $one;
}
public function deleteProdotto($id){
$aid = $this->quoteInt($id);
$query = "DELETE FROM prodotto where idprodotto = $aid";
return $this->SafeInsert($query);
}
public function insertProdotto($nome, $descrizione, $costo, $codice, $disponibile, $foto, $idevice, $riparazione){
$acosto=$this->quoteText($costo);
$acodice=$this->quoteText($codice);
$adisponibile=$this->quoteInt($disponibile);
$afoto=$this->quoteText($foto);
$adescrizione=$this->quoteText($descrizione);
$anome=$this->quoteText($nome);
$ariparazione=$this->quoteText($riparazione);
$aidevice=$this->quoteInt($idevice);
$query = "INSERT INTO prodotto (costo, codice, disponibile, foto, descrizione, nome, iddevice, riparazione) VALUES ($acosto, $acodice, $adisponibile, $afoto, $adescrizione, $anome, $aidevice, $ariparazione) ";
return $this->SafeInsert($query);
}
public function updateProdotto($id, $nome, $descrizione, $costo, $codice, $disponibile, $foto, $idevice, $riparazione){
$aid = $this->quoteInt($id);
$acosto=$this->quoteText($costo);
$adescrizione=$this->quoteText($descrizione);
$anome=$this->quoteText($nome);
$acodice=$this->quoteText($codice);
$adisponibile=$this->quoteInt($disponibile);
$aidevice=$this->quoteInt($idevice);
$ariparazione=$this->quoteText($riparazione);
if($foto){
$afoto=$this->quoteText($foto);
$query = "UPDATE prodotto SET costo=$acosto, codice= $acodice, iddevice=$aidevice, riparazione=$ariparazione, descrizione=$adescrizione, disponibile= $adisponibile, foto=$afoto, nome=$anome WHERE idprodotto = $aid";
}else{
$query = "UPDATE prodotto SET costo=$acosto, codice= $acodice, iddevice=$aidevice, riparazione=$ariparazione, descrizione=$adescrizione, disponibile= $adisponibile, nome=$anome WHERE idprodotto = $aid";
}
$this->SafeExec($query);
return true;
}
public function getProdotto($iddevice){
if($iddevice){
$aiddevice=$this->quoteInt($iddevice);
$query = "SELECT * FROM prodotto LEFT JOIN device using (iddevice) where iddevice = $aiddevice";
}else{
$query = "SELECT * FROM prodotto LEFT JOIN device using (iddevice)";
}
return $this->SafeFetch($query);
}
public function getMarche(){
$query = "SELECT * FROM marca";
return $this->SafeFetch($query);
}
public function getCategor(){
$query = "SELECT * FROM categoria";
return $this->SafeFetch($query);
}
public function getStati(){
$query = "SELECT * FROM stati";
return $this->SafeFetch($query);
}
public function getSedi(){
$query = "SELECT * FROM sede";
return $this->SafeFetch($query);
}
public function getCitta(){
$query = "SELECT id_comune, nome_comune, catasto, sigla_provincia FROM comuni join province using (id_provincia) order by nome_comune ASC";
return $this->SafeFetch($query);
}
public function getDevices(){
$query = "SELECT * FROM device join categoria using (idcategoria) JOIN marca using(idmarca)";
return $this->SafeFetch($query);
}
public function getCliente($idcliente){
$idclientee=$this->quoteInt($idcliente);
$query = "SELECT * FROM cliente where idcliente =$idclientee ";//. $idcliente;
return $this->SafeFetch($query);
}
public function getClienti(){
$query = "SELECT * FROM cliente";
return $this->SafeFetch($query);
}
public function getRiparazioni($where=null){
if(!$where){
//$query = "SELECT * FROM cliente JOin riparazione using (idcliente) JOIN device using (iddevice) JOIN Marca Using (idmarca) JOIN Categoria using (idcategoria) JOin stati on riparazione.stato = stati.idstato order by dataingresso DESC";
$query = "SELECT riparazione.*,cliente.*, device.*, marca.*, categoria.*, stati.*, CONCAT(t1.firstname, ' ', t1.lastname) as name_user_updated, CONCAT(t2.firstname, ' ', t2.lastname) as name_user_insert, riparazione.note as note FROM cliente LEFT JOIN riparazione using (idcliente) LEFT JOIN device using (iddevice) LEFT JOIN marca Using (idmarca) JOIN categoria using (idcategoria) LEFT JOin stati on riparazione.stato = stati.idstato LEFT JOIN user t2 ON t2.id_user = riparazione.id_user_insert LEFT JOIN user t1 ON t1.id_user = riparazione.id_user_updated order by dataingresso DESC";
$riparazioni= $this->SafeFetch($query);
/* foreach ($riparazioni as $key => $value) {
$aidriparazione = $riparazioni[$key]['idriparazione'];
$aquery = "SELECT * FROM riparazioneprodotti JOIN prodotto using (idprodotto) WHERE idriparazione= $aidriparazione";
$riparazioni[$key]['prodotti'] = $this->SafeFetch($aquery);
}*/
return $riparazioni;
}else{
if(strlen((string)$where)==4){
$where.="-01-01";
}
$awhere = $this->quoteText($where);
$query = "SELECT riparazione.*,cliente.*, device.*, marca.*, categoria.*, stati.*, CONCAT(t1.firstname, ' ', t1.lastname) as name_user_updated, CONCAT(t2.firstname, ' ', t2.lastname) as name_user_insert, riparazione.note as note FROM cliente LEFT JOIN riparazione using (idcliente) LEFT JOIN device using (iddevice) LEFT JOIN marca Using (idmarca) JOIN categoria using (idcategoria) LEFT JOin stati on riparazione.stato = stati.idstato LEFT JOIN user t2 ON t2.id_user = riparazione.id_user_insert LEFT JOIN user t1 ON t1.id_user = riparazione.id_user_updated WHERE dataIngresso>$awhere order by dataingresso DESC";
// $query = "SELECT * FROM riparazione WHERE dataIngresso>$awhere order by dataingresso DESC";
return $this->SafeFetch($query);
}
}
public function getProdottiRiparazione($idriparazione)
{
$aidriparazione = $this->quoteInt($idriparazione);
$aquery = "SELECT * FROM riparazioneprodotti JOIN prodotto using (idprodotto) WHERE idriparazione= $aidriparazione";
return $this->SafeFetch($aquery);
}
public function getRiparazioniSede($sede, $where){
$riparazioni=[];
if(!$where){
$asede = $this->quoteInt($sede);
//$query = "SELECT * FROM cliente JOin riparazione using (idcliente) JOIN device using (iddevice) JOIN Marca Using (idmarca) JOIN Categoria using (idcategoria) JOin stati on riparazione.stato = stati.idstato WHERE riparazione.sede = $asede order by dataingresso DESC";
$query = "SELECT riparazione.*, cliente.*, device.*, marca.*, categoria.*, stati.*, CONCAT(t1.firstname, ' ', t1.lastname) as name_user_updated, CONCAT(t2.firstname, ' ', t2.lastname) as name_user_insert, riparazione.note as note, riparazione.sede as sede FROM cliente JOin riparazione using (idcliente) JOIN device using (iddevice) JOIN marca Using (idmarca) JOIN categoria using (idcategoria) JOin stati on riparazione.stato = stati.idstato LEFT JOIN user t2 ON t2.id_user = riparazione.id_user_insert LEFT JOIN user t1 ON t1.id_user = riparazione.id_user_updated WHERE riparazione.sede = $asede order by dataingresso DESC";
$riparazioni= $this->SafeFetch($query);
/* foreach ($riparazioni as $key => $value) {
$aidriparazione = $riparazioni[$key]['idriparazione'];
$aquery = "SELECT * FROM riparazioneprodotti JOIN prodotto using (idprodotto) WHERE idriparazione= $aidriparazione";
$riparazioni[$key]['prodotti'] = $this->SafeFetch($aquery);
}*/
}else{
$asede = $this->quoteInt($sede);
if(strlen((string)$where)==4){
$where.="-01-01";
}
$awhere = $this->quoteText($where);
//$query = "SELECT * FROM cliente JOin riparazione using (idcliente) JOIN device using (iddevice) JOIN Marca Using (idmarca) JOIN Categoria using (idcategoria) JOin stati on riparazione.stato = stati.idstato WHERE riparazione.sede = $asede order by dataingresso DESC";
$query = "SELECT riparazione.*, cliente.*, device.*, marca.*, categoria.*, stati.*, CONCAT(t1.firstname, ' ', t1.lastname) as name_user_updated, CONCAT(t2.firstname, ' ', t2.lastname) as name_user_insert, riparazione.note as note, riparazione.sede as sede FROM cliente JOin riparazione using (idcliente) JOIN device using (iddevice) JOIN marca Using (idmarca) JOIN categoria using (idcategoria) JOin stati on riparazione.stato = stati.idstato LEFT JOIN user t2 ON t2.id_user = riparazione.id_user_insert LEFT JOIN user t1 ON t1.id_user = riparazione.id_user_updated WHERE riparazione.sede = $asede and dataIngresso>$awhere order by dataingresso DESC";
$riparazioni= $this->SafeFetch($query);
}
return $riparazioni;
}
public function getRiparazione($idRiparazione){
$jidRiparazione = $this->QuoteInt($idRiparazione);
$query = "SELECT * FROM riparazione WHERE idRiparazione = ". $jidRiparazione;
return $this->SafeFetch($query);
}
public function getMenu($user_type_id, $parent_id = -1){
$quser_type_id = $this->QuoteInt($user_type_id);
$qparent_id = $this->QuoteInt($parent_id);
$query = "SELECT * "
."FROM menu "
."WHERE user_type_id = $quser_type_id and parent = $qparent_id order by orderer";
return $this->SafeFetch($query);
}
/*
* Regione - provincia - comune
* @author Angelo Pescatore
* Gennaio 2016
*
*/
public function getRegioni(){
$query = "SELECT * FROM regione ". " order by name";;
return $this->SafeFetch($query);
}
public function getProvince($id_regione){
$jid_regione = $this->QuoteInt($id_regione);
$query = "SELECT * FROM provincia WHERE id_regione = ". $jid_regione . " order by nome_provincia ASC";
return $this->SafeFetch($query);
}
public function getComuni($id_provincia){
$jid_provincia = $this->QuoteInt($id_provincia);
$query = "SELECT * FROM comune WHERE id_provincia = ". $jid_provincia . " order by name ASC";
return $this->SafeFetch($query);
}
public function getUrlUAP(){
$ret = $this->getConfiguration();
return $ret['urlfileuap'];
}
public function getLastDateTimeCTI(){
$ret = $this->getConfiguration();
return $ret['last_date_time_cti'];
}
public function insertLastDateTimeCTI($data){
$adata = $this->QuoteText($data);
$query = "UPDATE config SET last_date_time_cti=$adata where id = 1";
return $this->SafeInsert($query);
}
private function getConfiguration(){
$query = "SELECT * FROM config where id = 1 LIMIT 1";
$one= $this->SafeFetch($query);
return $one[0];
}
public function insertAllarme($chiave, $valore, $tipo, $operatore){
$achiave = $this->QuoteText($chiave);
$avalore = $this->QuoteText($valore);
$aoperatore = $this->QuoteText($operatore);
$atipo = $this->QuoteText($tipo);
$query = "INSERT INTO allarme (chiave, valore, tipo, operatore) VALUES ($achiave, $avalore, $atipo, $aoperatore) ";
return $this->SafeInsert($query);
}
public function deleteAllarme($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM allarme where id = $aid";
return $this->SafeInsert($query);
}
public function updateAllarme($id, $chiave, $valore, $tipo, $operatore){
$achiave = $this->QuoteText($chiave);
$avalore = $this->QuoteText($valore);
$atipo = $this->QuoteText($tipo);
$aoperatore = $this->QuoteText($operatore);
$aid = $this->QuoteInt($id);
$query = "UPDATE allarme SET chiave=$achiave, valore=$avalore, tipo=$atipo, operatore=$aoperatore where id = $aid";
return $this->SafeInsert($query);
}
public function getAllarmi($where = null){
if($where){
$awhere = $this->QuoteText($where);
$query = "SELECT * FROM allarme WHERE tipo = $awhere";
}else{
$query = "SELECT * FROM allarme";
}
$one= $this->SafeFetch($query);
return $one;
}
public function insertRegoleAllarme($soglia, $allarmi,$tipo, $titolo){
$atitolo = $this->QuoteText($titolo);
$atipo = $this->QuoteText($tipo);
$aallarmi = $this->QuoteText(json_encode(unserialize($allarmi)));
$asoglia = $this->QuoteInt($soglia);
$query = "INSERT INTO regole (soglia, allarmi, tipo, titolo) VALUES ($asoglia, $aallarmi, $atipo, $atitolo) ";
return $this->SafeInsert($query);
}
public function deleteRegoleAllarme($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM regole where id = $aid";
return $this->SafeInsert($query);
}
public function updateRegoleAllarme($id, $soglia, $allarmi, $tipo, $titolo){
$atitolo = $this->QuoteText($titolo);
$atipo = $this->QuoteText($tipo);
$aallarmi = $this->QuoteText(json_encode(unserialize($allarmi)));
$asoglia = $this->QuoteInt($soglia);
$aid = $this->QuoteInt($id);
$query = "UPDATE regole SET soglia=$asoglia, allarmi=$aallarmi, tipo=$atipo, titolo=$atitolo where id = $aid";
return $this->SafeInsert($query);
}
public function getRegoleAllarmi($where = null){
if($where){
$awhere = $this->QuoteText($where);
$query = "SELECT * FROM regole WHERE tipo = $awhere";
}else{
$query = "SELECT * FROM regole";
}
$one= $this->SafeFetch($query);
return $one;
}
//configurazione
public function getAliasDataSource($where = null){
if($where){
$awhere = $this->QuoteText($where);
$query = "SELECT * FROM aliasdatasource WHERE tipo = $awhere";
}else{
$query = "SELECT * FROM aliasdatasource";
}
$one= $this->SafeFetch($query);
return $one;
}
public function insertAliasDataSource($chiave, $valore, $tipo){
$achiave = $this->QuoteText($chiave);
$atipo = $this->QuoteText($tipo);
$avalore = $this->QuoteText($valore);
$query = "INSERT INTO aliasdatasource (chiave, valore, tipo) VALUES ($achiave, $avalore, $atipo) ";
return $this->SafeInsert($query);
}
public function updateAliasDataSource($id, $chiave, $valore, $tipo){
$achiave = $this->QuoteText($chiave);
$avalore = $this->QuoteText($valore);
$atipo = $this->QuoteText($tipo);
$aid = $this->QuoteInt($id);
$query = "UPDATE aliasdatasource SET chiave=$achiave, valore=$avalore, tipo=$atipo where id = $aid";
return $this->SafeInsert($query);
}
public function deleteAliasDataSource($id){
$aid = $this->QuoteInt($id);
$query = "DELETE from aliasdatasource where id = $aid";
return $this->SafeInsert($query);
}
public function getAliasRc(){
$query = "SELECT * FROM aliasrc";
$one= $this->SafeFetch($query);
return $one;
}
public function insertAliasRc($chiave, $valore){
$achiave = $this->QuoteText($chiave);
$avalore = $this->QuoteText($valore);
$query = "INSERT INTO aliasrc (chiave, valore) VALUES ($achiave, $avalore) ";
return $this->SafeInsert($query);
}
public function updateAliasRc($id, $chiave, $valore){
$achiave = $this->QuoteText($chiave);
$avalore = $this->QuoteText($valore);
$aid = $this->QuoteInt($id);
$query = "UPDATE aliasrc SET chiave=$achiave, valore=$avalore where id = $aid";
return $this->SafeInsert($query);
}
public function deleteAliasRc($id){
$aid = $this->QuoteInt($id);
$query = "DELETE from aliasrc where id = $aid";
return $this->SafeInsert($query);
}
public function getCampioObbligatoriScheda(){
$query = "SELECT DISTINCT * FROM campiobbligatorischeda";
$one= $this->SafeFetch($query);
return $one;
}
public function insertCampioObbligatoriScheda( $valore){
$avalore = $this->QuoteText($valore);
$query = "INSERT INTO campiobbligatorischeda (valore) VALUES ($avalore) ";
return $this->SafeInsert($query);
}
public function updateCampioObbligatoriScheda($id, $valore){
$avalore = $this->QuoteText($valore);
$aid = $this->QuoteInt($id);
$query = "UPDATE campiobbligatorischeda SET valore=$avalore where id = $aid";
return $this->SafeInsert($query);
}
public function deleteCampioObbligatoriScheda($id){
if($id!="*"){
$aid = $this->QuoteInt($id);
$query = "DELETE from campiobbligatorischeda where id = $aid";
}else{
$query = "DELETE from campiobbligatorischeda";
}
return $this->SafeInsert($query);
}
public function getGraficoCn(){
$query = "SELECT * FROM graficocn";
$one= $this->SafeFetch($query);
return $one;
}
public function insertGraficoCn( $valore, $tipo){
$avalore = $this->QuoteText($valore);
$atipo = $this->QuoteInt($tipo);
$query = "INSERT INTO graficocn (valore,tipo) VALUES ($avalore,$atipo) ";
return $this->SafeInsert($query);
}
public function updateGraficoCn($id, $valore){
$avalore = $this->QuoteText($valore);
$aid = $this->QuoteInt($id);
$query = "UPDATE graficocn SET valore=$avalore where id = $aid";
return $this->SafeInsert($query);
}
public function deleteGraficoCn(){
$query = "DELETE from graficocn";
return $this->SafeInsert($query);
}
public function getGraficoRc(){
$query = "SELECT * FROM graficorc";
$one= $this->SafeFetch($query);
return $one;
}
public function getGraficoRcVT($valore, $tipo){
$avalore = $this->QuoteText($valore);
$atipo = $this->QuoteInt($tipo);
$query = "SELECT * FROM graficorc WHERE valore = $avalore and tipo = $atipo";
$one= $this->SafeFetch($query);
return count($one)?false:true;
}
public function insertGraficoRc( $valore, $tipo){
if($this->getGraficoRcVT($valore, $tipo)){
$avalore = $this->QuoteText($valore);
$atipo = $this->QuoteInt($tipo);
$query = "INSERT INTO graficorc (valore,tipo) VALUES ($avalore,$atipo) ";
return $this->SafeInsert($query);
}
return 1;
}
public function updateGraficoRc($id, $valore){
$avalore = $this->QuoteText($valore);
$aid = $this->QuoteInt($id);
$query = "UPDATE graficorc SET valore=$avalore where id = $aid";
return $this->SafeInsert($query);
}
public function deleteGraficoRc(){
$query = "DELETE from graficorc";
return $this->SafeInsert($query);
}
public function getCategorie(){
$query = "SELECT * FROM categorie";
$one= $this->SafeFetch($query);
return $one;
}
public function insertCategoria($titolo, $descrizione, $permessiw, $permessir, $colore){
$atitolo = $this->QuoteText($titolo);
$adescrizione = $this->QuoteText($descrizione);
$apermessiw = $this->QuoteText($permessiw);
$apermessir = $this->QuoteText($permessir);
$acolore = $this->QuoteText($colore);
$query = "INSERT INTO categorie (titolo, descrizione, permessiW, permessiR, colore) "
."VALUES ($atitolo, $adescrizione, $apermessiw, $apermessir, $acolore)";//, $qpassword, $qfirstname, $qlastname, $qemail, $qcreated_by)";
return $this->SafeInsert($query);
}
public function editCategoria($id, $titolo, $descrizione, $permessiw, $permessir, $colore){
$aid = $this->QuoteInt($id);
$atitolo = $this->QuoteText($titolo);
$adescrizione = $this->QuoteText($descrizione);
$apermessiw = $this->QuoteText($permessiw);
$apermessir = $this->QuoteText($permessir);
$acolore = $this->QuoteText($colore);
$query = "UPDATE categorie SET titolo = $atitolo, descrizione = $adescrizione, permessiW=$apermessiw, permessiR=$apermessir, colore=$acolore WHERE id_cat = $aid";
return $this->SafeExec($query);
}
public function deleteCategoria($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM categorie WHERE id_cat = $aid";
return $this->SafeExec($query);
}
public function getBlog($where){
$query = "SELECT blog.*, nomecategoria, CONCAT(t1.firstname, ' ', t1.lastname) as name_user_updated, CONCAT(t2.firstname, ' ', t2.lastname) as name_user_insert FROM blog LEFT JOIN user t2 ON t2.id_user = blog.id_user_insert LEFT JOIN user t1 ON t1.id_user = blog.id_user_updated LEFT JOIN categoriablog on blog.idcategoria = categoriablog.idcategoria";
if($where){
$where = $this->QuoteInt($where);
$query.= "where blog.icategoria = $where";
}
return $this->SafeFetch($query);
}
public function getCommenti($id_blog){
$id_blog = $this->QuoteInt($id_blog);
$query = "SELECT * from commenti_blog WHERE id_blog = $id_blog";
return $this->SafeFetch($query);
}
public function removeCommento($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM commenti_blog WHERE id = $aid";
return $this->SafeExec($query);
}
public function deleteBlog($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM blog where id = $aid";
return $this->SafeInsert($query);
}
public function insertBlog($titolo, $testo, $idcategoria, $foto, $id_user){
$aid_user=$this->quoteInt($id_user);
$atitolo=$this->quoteText($titolo);
$atesto=$this->quoteText($testo);
$afoto=$this->quoteText($foto);
$aidcategoria=$this->quoteInt($idcategoria);
$query = "INSERT INTO blog (titolo, testo, foto, idcategoria, id_user_insert, id_user_updated) VALUES ($atitolo, $atesto, $afoto, $aidcategoria,$aid_user,$aid_user)";
return $this->SafeExec($query);
}
public function updateBlog($id, $titolo, $testo, $idcategoria, $foto, $id_user){
$aid=$this->quoteInt($id);
$aid_user=$this->quoteInt($id_user);
$atitolo=$this->quoteText($titolo);
$atesto=$this->quoteText($testo);
$aidcategoria=$this->quoteInt($idcategoria);
if($foto){
$afoto=$this->quoteText($foto);
$query = "UPDATE blog SET titolo= $atitolo, foto=$afoto, testo=$atesto, idcategoria=$aidcategoria, id_user_updated=$aid_user WHERE id=$aid";
}else{
$query = "UPDATE blog SET titolo= $atitolo, testo=$atesto, idcategoria=$aidcategoria, id_user_updated=$aid_user WHERE id=$aid";
}
$this->SafeExec($query);
return true;
}
//**********
public function getCategorieBlog(){
$query = "SELECT * FROM categoriablog";
$one= $this->SafeFetch($query);
return $one;
}
public function deleteCategoriaBlog($id){
$aid = $this->QuoteInt($id);
$query = "DELETE FROM categoriablog where idcategoria = $aid";
return $this->SafeInsert($query);
}
public function insertCategoriaBlog($nome, $foto){
$anome=$this->quoteText($nome);
$afoto=$this->quoteText($foto);
$query = "INSERT INTO categoriablog (nomecategoria, fotocategoria) VALUES ($anome, $afoto)";
return $this->SafeExec($query);
}
public function updateCategoriaBlog($idCategoria, $nome, $foto){
$aidCategoria=$this->quoteInt($idCategoria);
$anome=$this->quoteText($nome);
if($foto){
$afoto=$this->quoteText($foto);
$query = "UPDATE categoriablog SET nomecategoria= $anome, fotocategoria= $afoto WHERE idcategoria=$aidCategoria";
}else{
$query = "UPDATE categoriablog SET nomecategoria= $anome WHERE idcategoria=$aidCategoria";
}
$this->SafeExec($query);
return true;
}
//FINE CONFIGURAZIONE
/*
* EXAMPLE
* @author Angelo Pescatore
* Gennaio 2016
*
public function getTitoliStudi(){
$query = "SELECT * FROM titolo_studio";
return $this->SafeFetch($query);
}
public function insertPromotore($nome){
$anome = $this->QuoteText($nome);
$query = "INSERT INTO promoter (name_promoter) VALUES ($anome) ";
return $this->SafeInsert($query);
}
public function updatePromotore($id, $nome){
$anome = $this->QuoteText($nome);
$aid = $this->QuoteInt($id);
$query = "UPDATE promoter SET name_promoter = $anome WHERE id_promoter = $aid ";
return $this->SafeInsert($query);
}
public function getPromotori(){
$query = "SELECT * FROM promoter ";
return $this->SafeFetch($query);
}
*/
}
?>