. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| 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/ascii/app/components/partner/ |
Upload File : |
<?php
include "helper/content.php";
//includo content del componente
class APIPartner extends API
{
/**
*@author Angelo Pescatore
*
*
Queste API permettono il crud sui permessi
*
*
*
*
*/
public function getTagPartner($idpartner)
{
$this->validateAuthAndGetUser();
if ($this->checkUserPermission() == true)
{
$contentOperations = new ContentPartner();
$result = $contentOperations->getTagPartner($idpartner);
return $this->printMessage($this->responseMessage($result, true));
}
else
{
return $this->printMessage($this->responseMessage("Partner non trovato!", false));
}
}
public function getPartners($lite = false)
{
$this->validateAuthAndGetUser();
if ($this->checkUserPermission() == true)
{
$result = $this->memcached->get("PARTNES");
if (!$result) {
$contentOperations = new ContentPartner();
$result = $contentOperations->getPartners();
$this->memcached->set("PARTNES", $result);
}
return $this->printMessage($this->responseMessage($result, true));
}
else
{
return $this->printMessage($this->responseMessage("Nessun Partner trovato!", false));
}
}
public function getPartner($id)
{
$this->validateAuthAndGetUser();
if ($this->checkUserPermission() == true)
{
$contentOperations = new ContentPartner();
$resu = array();
$result = $contentOperations->getPartner($id)[0];
/*foreach ($result as $key => $value)
{*/
$res = $contentOperations->getTagPartner($result['idpartner']);
if (count($res) > 0)
{
$result['tags'] = $res;
}
$res = $contentOperations->getStoricoPartner($result['idpartner']);
if (count($res) > 0)
{
$result['storico'] = $res;
}
//var_dump($resu);
return $this->printMessage($this->responseMessage($result, true));
}
else
{
return $this->printMessage($this->responseMessage("Nessun Partner trovato!", false));
}
}
public function getPartnerSoloEmail($lite = false)
{
$this->validateAuthAndGetUser();
if ($this->checkUserPermission() == true)
{
$result = $this->memcached->get("PARTNESSOLOEMAIL");
if (!$result) {
$contentOperations = new ContentPartner();
$result = $contentOperations->getPartnerSoloEmail();
$this->memcached->set("PARTNESSOLOEMAIL", $result);
}
//var_dump($resu);
return $this->printMessage($this->responseMessage($result, true));
}
else
{
return $this->printMessage($this->responseMessage("Nessun Partner trovato!", false));
}
}
public function getPartnerSoloId($lite = false)
{
$this->validateAuthAndGetUser();
if ($this->checkUserPermission() == true)
{
$result = $this->memcached->get("PARTNESSOLOID");
if (!$result) {
$contentOperations = new ContentPartner();
$result = $contentOperations->getPartnerSoloId();
$this->memcached->set("PARTNESSOLOID", $result);
}
//var_dump($resu);
return $this->printMessage($this->responseMessage($result, true));
}
else
{
return $this->printMessage($this->responseMessage("Nessun Partner trovato!", false));
}
}
public function deletePartner($id)
{
$this->validateAuthAndGetUser();
$contentOperations = new ContentPartner();
$result = $contentOperations->deletePartner($id);
$this->cancellaCachePartner();
return $this->printMessage($this->responseMessage("Partner eliminato con successo!", true));
}
public function insertPartner($ragioneSociale, $indirizzo, $citta, $piva, $codicefiscale, $telefono, $cellulare, $email, $password, $note, $sede, $cap, $standarpagamento, $iban, $iva, $tags, $filesname, $marketing, $recruiting, $datanascita, $fattura_elettronica, $pec, $titolo_studio, $nazione_nascita, $provincia_nascita, $comune_nascita, $azienda_privato, $partner_fornitore)
{
$iduserobj = $this->validateAuthAndGetUser();
if ($this->checkUserPermission() == true)
{
$cont = new ContentPartner();
$res = $cont->insertPartner($ragioneSociale, $indirizzo, $citta, $piva, $codicefiscale, $telefono, $cellulare, $email, $password, $note, $sede, $cap, $standarpagamento, $iban, $iva, $iduserobj['id_user'], $marketing, $recruiting, $datanascita, $fattura_elettronica, $pec, $titolo_studio, $nazione_nascita, $provincia_nascita, $comune_nascita, $azienda_privato, $partner_fornitore);
if ($res)
{
$tags = unserialize($tags);
foreach ($tags as $key => $value)
{
$this->aggiungiTag($value->text, $res, "partner");
}
/*
error_log("Inserito partner ". $res);
error_log("Files partner ". $filesname);
/*
$id_partner = $res;
$filesname= json_decode($filesname);
foreach ($filesname as $key => $value) {
$nome_file = getcwd() ."/../server/php/files/" . $value;
error_log("Inserimanto file partner ". $nome_file);
$api=new API();
$api->uploadFileClient($nome_file, $id_partner);
}
*/
$this->cancellaCachePartner();
return $this->printMessage($this->responseMessage($res, true));
}
else
{
return $this->printMessage($this->responseMessage("Inserimento Partner fallito", false));
}
}
else
{
return $this->printMessage($this->responseMessage("Operazione non permessa", false));
}
}
public function sincronizzaTagPartner($tag, $idpartner, $nometabella)
{
if ($this->checkUserPermission() == true)
{
$cont = new ContentPartner();
$res = $cont->getTags($idpartner, "partner");
$ct = count($tag);
$cr = count($res);
$sw = false;
for ($i = 0; $i < $cr; $i++)
{
if ($cont->rimuoviTag($res[$i]['id']))
$sw = true;
//
}
for ($j = 0; $j < $ct; $j++)
{
if ($cont->aggiungTag($tag[$j]->text, $idpartner, "partner"))
$sw = true;
}
if($ct==0 && $cr==0){
if ($cont->aggiungTag($tag[$j]->text, $idcentro, "centro"))
$sw = true;
}
}
return $sw;
}
private function cancellaCachePartner(){
$this->memcached->delete("PARTNESSOLOID");
$this->memcached->delete("PARTNESSOLOEMAIL");
$this->memcached->delete("PARTNES");
}
public function editPartner($idPartner, $ragioneSociale, $indirizzo, $citta, $piva, $codicefiscale, $telefono, $cellulare, $email, $password, $note, $sede, $cap, $standarpagamento, $iban, $iva, $tags, $filesname, $marketing, $recruiting, $datanascita, $fattura_elettronica, $pec, $titolo_studio, $nazione_nascita, $provincia_nascita, $comune_nascita, $azienda_privato, $partner_fornitore)
{
$iduserobj = $this->validateAuthAndGetUser();
if ($this->checkUserPermission() == true)
{
$sw = false;
$swt = false;
$cont = new ContentPartner();
$res = $cont->editPartner($idPartner, $ragioneSociale, $indirizzo, $citta, $piva, $codicefiscale, $telefono, $cellulare, $email, $password, $note, $sede, $cap, $standarpagamento, $iban, $iva, $iduserobj['id_user'],$marketing, $recruiting, $datanascita, $fattura_elettronica, $pec, $titolo_studio, $nazione_nascita, $provincia_nascita, $comune_nascita, $azienda_privato, $partner_fornitore);
$tags = unserialize($tags);
if ($res){
$sw = true;
$this->cancellaCachePartner();
}
if ($this->sincronizzaTagPartner($tags, $idPartner, "partner"))
$swt = true;
if ($sw && $swt)
return $this->printMessage($this->responseMessage("Editazione Partner:", true));
else if ($sw && !$swt)
{
return $this->printMessage($this->responseMessage("Editazione Partner: Tag non aggiornati", true));
}
}
else
{
return $this->printMessage($this->responseMessage("Operazione non permessa", false));
}
}
// public function getStandarPagamento()
// {
// $this->validateAuthAndGetUser();
// $contentOperations = new ContentPartner();
// $result = $contentOperations->getStandarPagamento();
// return $this->printMessage($this->responseMessage($result, true));
// }
/**
*
*
* FINE API COMPONENT
*
*/
}
?>