<?php
namespace AppBundle\Controller;
use \Pimcore\Controller\FrontendController;
use \Symfony\Component\HttpFoundation\Request;
use \Pimcore\Model\DataObject;
use \Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/*
use \AppBundle\Form\LoginFormType;
use \AppBundle\Model\DataObject\User;
use \Pimcore\Controller\Configuration\TemplatePhp;
use \Symfony\Component\Routing\Annotation\Route;
use \Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use \Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
*/
//use Symfony\Component\HttpFoundation\Response;
//use Symfony\Component\Routing\Annotation\Route;
//use \Pimcore\Bundle\AdminBundle\Controller\Rest\AbstractRestController;
//use Pimcore\Model\Asset;
class ProvaController extends FrontendController
{
public function defaultAction(Request $request)
{
}
public function defaultpdfAction(Request $request)
{
}
public function devtestAction(Request $request)
{
}
public function imptestAction(Request $request)
{
}
public function sitocusAction(Request $request)
{
}
public function prodcuspdfAction(Request $request)
{
}
public function palportalAction(Request $request)
{
}
public function prodcusAction(Request $request)
{
$this->view->req=$request->getLocale();
$this->denyAccessUnlessGranted('ROLE_USER');
//$this->denyAccessUnlessGranted('ROLE_ADMIN', null, 'User tried to access a page without having ROLE_ADMIN');
}
public function prodcleanAction(Request $request)
{
}
public function listcleanAction(Request $request)
{
}
public function listcleanpdfAction(Request $request)
{
}
public function listpagepdfAction(Request $request)
{
}
public function listpagenewpdfAction(Request $request)
{
//proprietà PROP se è pari a UL=unlimited tira fuori tutti i design che esistono!!
//usare con cautela
$PROP=$this->view->document->getProperty('PROP');
$mySelection=$this->view->document->getProperty('selezione') ?: "list_2020_it";
$elencoDesign = new \Pimcore\Model\DataObject\Design\Listing();
if ($PROP=='UL') {
$elencoDesign=$this->getAllDesignUL();
} else{
$id=$this->view->document->getProperty('cartella')->getId();
$elencoDesign=$this->getAllDesign($id);
}
if ($elencoDesign->count()<1) return;
$pagesToRender=array();
foreach ($elencoDesign as $design) {
$prodbaselist = new DataObject\Variante\Listing();
$prodbaselist->setObjectTypes([DataObject\AbstractObject::OBJECT_TYPE_OBJECT]);
$prodbaselist->setLimit(30);
$prodbaselist->setOrderKey("o_key");
$prodbaselist->setOrder("asc");
$prodbaselist->setCondition("o_parentId = '".$design->getId()."' and ".$mySelection."=1");
$prodbaselist->load();
if ($prodbaselist->count()>0) {
//preparo array dei plus e degli optional
$myPlusAll=array();
$myAccAll=array();
$currId=0;
$tiretype='';
foreach ($prodbaselist as $entry) {
$currId = $entry->getId();
$tiretype = $entry->getDatitec();
$myPlusAll=array_merge($myPlusAll,$entry->getPlus());
$myAccAll=array_merge($myAccAll,$entry->getAccessori());
}
$myPlusAll=array_unique($myPlusAll);
$myAccAll=array_unique($myAccAll);
//************************************* INIZIO COSTRUISCO LISTA FOCOLARI E KIT *************************************
$compFocolari=array();
$compFocolari2D=array();
$compKit=array();
foreach ($prodbaselist as $prodbase) {
$composizioneP=$prodbase->getComposizione();
//il prodotto base è virtuale (ci sono varianti)
if ($prodbase->getVirtual()) {
$idPB=$prodbase->getId();
//listo le vrianti sotto il prodotto base corrente
$prodbaseVarList = new DataObject\Variante\Listing();
$prodbaseVarList->setObjectTypes([DataObject\AbstractObject::OBJECT_TYPE_VARIANT]);
$prodbaseVarList->setLimit(10);
$prodbaseVarList->setCondition("o_parentId = ".$idPB);
$prodbaseVarList->load();
if ($prodbaseVarList->count()>0) {
foreach($prodbaseVarList as $final) {
$composizioneP = $final->getComposizione();
//ho la composizione della Variante "n"
foreach ($composizioneP as $key) {
$miocod = $key->getCodice();
$miodes = $key->getDescrizione();
//destino a lista Focolari o Kit in base al codice
if (substr($miocod,0,2)=='80') {
$compFocolari[]=$miocod;
$loc_matcol=$key->getDesc_bella();
if (!is_null($final->getMat_col())) $loc_matcol=$final->getMat_col()->getMat_Col();
$addendo=array("cod"=>$miocod,"pbase"=>$prodbase->getKey(),"matcol"=>$loc_matcol);
$compFocolari2D[]=$addendo;
//echo "aggiunto 1";
} else {
$compKit[]=$miocod;
}
}
}
}
// il prodotto base non è virtuale
} else {
foreach ($composizioneP as $key) {
$miocod = $key->getCodice();
$miodes = $key->getDescrizione();
//destino a lista Focolari o Kitin base al codice
if (substr($miocod,0,2)=='80') {
$compFocolari[]=$miocod;
$loc_matcol=$key->getDesc_bella();
if (!is_null($final) and !is_null($final->getMat_col())) $loc_matcol=$final->getMat_col()->getMat_Col();
$addendo=array("cod"=>$miocod,"pbase"=>$prodbase->getKey(),"matcol"=>$loc_matcol);
$compFocolari2D[]=$addendo;
//echo "aggiunto 1";
} else {
$compKit[]=$miocod;
}
}
} //fine di if..else su is Virtual
}
$compFocolari=array_unique($compFocolari);
// ----------------------------------------------
$numfoc= count($compFocolari);
$numpbase= count($prodbaselist);
$raggruppa=1;
if ($numfoc!=$numpbase) {
//echo "raggruppa";
//print_r($compFocolari2D);
} else {
//echo "non raggruppa";
$raggruppa=0;
}
// ----------------------------------------------
//sort($compFocolari);
$compKit=array_unique($compKit);
sort($compKit);
//************************************* FINE COSTRUISCO LISTA FOCOLARI E KIT *************************************
//************************ INIZIO TABELLA INFERIORE *************************
$class_name = get_class($tiretype);
$methods = get_class_methods($class_name);
$focAperto=0;
$focChiusoAria=0;
$focChiusoIdro=0;
$focPellAria=0;
$focPellIdro=0;
$stufAria=0;
$stufIdro=0;
$pellAria=0;
$pellIdro=0;
$data_tabella=0;
$arrayTest=array();
$arrayTestNew=array();
$nomefunzione='';
$pbase_idprod_prec=1;
$campi=array();
foreach($methods as $method)
{
$rigaDatiNewh=array();
$rigaDatiNew=array();
switch ($method) {
case "getFocolarepelletaria":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$nomefunzione=$method;
$focPellAria=1;
$campi=array("nome","incentivi","misure","pot_nom","rend_nom","auton","capacita_serb","consumi","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getFocolarepelletidro":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$nomefunzione=$method;
$focPellIdro=1;
$campi=array("nome","incentivi","misure","pot_nom","pot_acq","rend_nom","auton","capacita_serb","consumi","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getStufapelletaria":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$nomefunzione=$method;
$pellAria=1;
$campi=array("nome","incentivi","misure","pot_nom","rend_nom","auton","capacita_serb","consumi","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
//echo "Pellet aria<br />";
}
break;
case "getStufapelletidro":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$pellIdro=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_nom","pot_acq","rend_nom","auton","capacita_serb","consumi","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getFocolarelegnaaria":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$focChiusoAria=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_bruc","pot_nom","rend_nom","carico_cons","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getFocolarelegnaidro":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$focChiusoIdro=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_bruc","pot_nom","pot_acq","rend_nom","carico_cons","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getFocolareaperto":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$focAperto=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_nom","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getStufalegnaaria":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$stufAria=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_bruc","pot_nom","rend_nom","carico_cons","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getStufalegnaidro":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$stufIdro=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_bruc","pot_nom","pot_acq","rend_nom","carico_cons","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
default :
//echo "Prodotti senza dati tecnici";
//return;
break;
}
}
if (strlen($nomefunzione)<5) {
//echo "Prodotto senza dati tecnici";
//return;
} else {
//echo $nomefunzione."<br/>";
//print_r($arrayTestNew);
foreach ($prodbaselist as $prodbase) {
$campoTest= $prodbase->getId_prod() ?: $prodbase->getId();
// echo $campoTest;
if ($campoTest == $pbase_idprod_prec or is_null($prodbase->getDatitec()) or is_null(call_user_func(array($prodbase->getDatitec(),$nomefunzione)))) {
//id_prodotto uguale a quello di prima, non faccio nulla
//non c'è il brick, non faccio nulla
//echo "Non c'è".$nomefunzione."<br/>";
} else {
//recupero il dato del brick
$datoRiga=call_user_func(array($prodbase->getDatitec(),$nomefunzione));
foreach ($campi as $campo) {
$dato='';
$datoh='';
//echo "CAMPO:".$campo."<br/>";
switch ($campo) {
case 'nome':
$datoh=$this->get("translator")->trans("list_dati_nome");
$dato=$prodbase->getKey();
break;
case 'misure':
$datoh=$this->get("translator")->trans("list_dati_misure");
if (!is_null($prodbase->getDatitec()->getMisure())) {
$dato=explode(" ",$prodbase->getDatitec()->getMisure()->getLar())[0]."x".explode(" ",$prodbase->getDatitec()->getMisure()->getProf())[0]."x".$prodbase->getDatitec()->getMisure()->getAlt();
if (!is_null($prodbase->getDatitec()->getMisure()->getPeso())) $dato=$dato."<br/>".$prodbase->getDatitec()->getMisure()->getPeso();
if (substr($dato,0,1)=='0') $dato="";
}
break;
case 'combustibile':
$datoh=$this->get("translator")->trans("list_dati_combustibile");
$dato=(string)$datoRiga->getCombustibile();
break;
case 'pot_nom':
$datoh=$this->get("translator")->trans("list_dati_pot_nom");
$dato=(string)$datoRiga->getPot_nom();
break;
case 'pot_acq':
$datoh=$this->get("translator")->trans("list_dati_pot_acq");
$dato=(string)$datoRiga->getPot_acq();
break;
case 'pot_bruc':
$datoh=$this->get("translator")->trans("list_dati_pot_bruc");
$dato=(string)$datoRiga->getPot_bruc();
break;
case 'rend_nom':
$datoh=$this->get("translator")->trans("list_dati_rend_nom");
$dato=(string)$datoRiga->getRend_nom();
break;
case 'auton':
$datoh=$this->get("translator")->trans("list_dati_auton");
$dato=(string)$datoRiga->getAuton();
break;
case 'capacita_serb':
$datoh=$this->get("translator")->trans("list_dati_capacita_serb");
$dato=(string)$datoRiga->getCapacita_serb();
break;
case 'consumi':
$datoh=$this->get("translator")->trans("list_dati_consumi");
$dato=explode(" ",$datoRiga->getConsumo_min())[0]." - ".$datoRiga->getConsumo_max();
break;
case 'carico_cons':
$datoh=$this->get("translator")->trans("list_dati_carico_cons");
$dato=(string)$datoRiga->getCarico_cons();
break;
case 'u_fumi':
$datoh=$this->get("translator")->trans("list_dati_u_fumi");
$dato=(string)$datoRiga->getU_fumi();
break;
case 'c_nrg':
$datoh=$this->get("translator")->trans("list_dati_c_nrg");
$dato=$datoRiga->getClasse_nrg();
break;
case 'certificazioni':
$datoh=$this->get("translator")->trans("list_dati_certificazioni");
$allinc=$prodbase->getCertificazioni();
if (!is_null($allinc)) {
$content="";
foreach ($allinc as $key3) {
$miopic = $key3->getImg_cert();
if (!is_null($miopic) && $miopic instanceof \Pimcore\Model\Asset\Image) {
$dato=$dato.$miopic->getThumbnail("listmini")->getHtml();
}
}
}
break;
case 'incentivi':
$datoh=$this->get("translator")->trans("list_dati_incentivi");
$allinc=$prodbase->getIncentivi();
if (!is_null($allinc)) {
foreach ($allinc as $key2) {
$miopic = $key2->getImg_inc();
if (!is_null($miopic) && $miopic instanceof \Pimcore\Model\Asset\Image) {
$dato=$dato.$miopic->getThumbnail("listmini")->getHtml();
}
}
}
break;
default:
# code...
break;
}
$rigaDatiNewh[$campo]=$datoh;
$rigaDatiNew[$campo]=$dato;
}
$arrayTestNew[]=$rigaDatiNew;
$pbase_idprod_prec=$prodbase->getId_prod() ?: $prodbase->getId();
} //if uguale al precedente o mancano dati
} //foreach sui prodotti base
} //if di nomefunzione
$myArrayNew=$arrayTestNew;
$myArrayh=$rigaDatiNewh;
//************************ FINE TABELLA INFERIORE ***************************
//aggiunge il design e i prodotti all'array da renderizzare
$pagesToRender[]=array("design"=>$design,"prodottibase"=>$prodbaselist,"focolari"=>$compFocolari,"focolari2D"=>$compFocolari2D,"kit"=>$compKit,"raggruppa"=>$raggruppa,"optional"=>$myAccAll,"plus"=>$myPlusAll,"datih"=>$rigaDatiNewh,"dati"=>$arrayTestNew);
} else {
}
} //foreach design
$this->view->pages = $pagesToRender;
}
public function listinonewAction(Request $request)
{
//proprietà PROP se è pari a UL=unlimited tira fuori tutti i design che esistono!!
//usare con cautela
$PROP=$this->view->document->getProperty('PROP');
$mySelection=$this->view->document->getProperty('selezione') ?: "list_2020_it";
$elencoDesign = new \Pimcore\Model\DataObject\Design\Listing();
if ($PROP=='UL') {
$elencoDesign=$this->getAllDesignUL();
} else{
$id=$this->view->document->getProperty('cartella')->getId();
$elencoDesign=$this->getAllDesign($id);
}
if ($elencoDesign->count()<1) return;
$pagesToRender=array();
foreach ($elencoDesign as $design) {
$prodbaselist = new DataObject\Variante\Listing();
$prodbaselist->setObjectTypes([DataObject\AbstractObject::OBJECT_TYPE_OBJECT]);
$prodbaselist->setLimit(30);
$prodbaselist->setOrderKey("o_key");
$prodbaselist->setOrder("asc");
$prodbaselist->setCondition("o_parentId = '".$design->getId()."' and ".$mySelection."=1");
$prodbaselist->load();
if ($prodbaselist->count()>0) {
//preparo array dei plus e degli optional
$myPlusAll=array();
$myAccAll=array();
$currId=0;
$tiretype='';
foreach ($prodbaselist as $entry) {
$currId = $entry->getId();
$tiretype = $entry->getDatitec();
$myPlusAll=array_merge($myPlusAll,$entry->getPlus());
$myAccAll=array_merge($myAccAll,$entry->getAccessori());
}
$myPlusAll=array_unique($myPlusAll);
$myAccAll=array_unique($myAccAll);
//************************************* INIZIO COSTRUISCO LISTA FOCOLARI E KIT *************************************
$compFocolari=array();
$compFocolari2D=array();
$compKit=array();
foreach ($prodbaselist as $prodbase) {
$composizioneP=$prodbase->getComposizione();
//il prodotto base è virtuale (ci sono varianti)
if ($prodbase->getVirtual()) {
$idPB=$prodbase->getId();
//listo le vrianti sotto il prodotto base corrente
$prodbaseVarList = new DataObject\Variante\Listing();
$prodbaseVarList->setObjectTypes([DataObject\AbstractObject::OBJECT_TYPE_VARIANT]);
$prodbaseVarList->setLimit(10);
$prodbaseVarList->setCondition("o_parentId = ".$idPB);
$prodbaseVarList->load();
if ($prodbaseVarList->count()>0) {
foreach($prodbaseVarList as $final) {
$composizioneP = $final->getComposizione();
//ho la composizione della Variante "n"
foreach ($composizioneP as $key) {
$miocod = $key->getCodice();
$miodes = $key->getDescrizione();
//destino a lista Focolari o Kit in base al codice
if (substr($miocod,0,2)=='80') {
$compFocolari[]=$miocod;
$loc_matcol=$key->getDesc_bella();
if (!is_null($final->getMat_col())) $loc_matcol=$final->getMat_col()->getMat_Col();
$addendo=array("cod"=>$miocod,"pbase"=>$prodbase->getKey(),"matcol"=>$loc_matcol);
$compFocolari2D[]=$addendo;
//echo "aggiunto 1";
} else {
$compKit[]=$miocod;
}
}
}
}
// il prodotto base non è virtuale
} else {
foreach ($composizioneP as $key) {
$miocod = $key->getCodice();
$miodes = $key->getDescrizione();
//destino a lista Focolari o Kitin base al codice
if (substr($miocod,0,2)=='80') {
$compFocolari[]=$miocod;
$loc_matcol=$key->getDesc_bella();
if (!is_null($final) and !is_null($final->getMat_col())) $loc_matcol=$final->getMat_col()->getMat_Col();
$addendo=array("cod"=>$miocod,"pbase"=>$prodbase->getKey(),"matcol"=>$loc_matcol);
$compFocolari2D[]=$addendo;
//echo "aggiunto 1";
} else {
$compKit[]=$miocod;
}
}
} //fine di if..else su is Virtual
}
$compFocolari=array_unique($compFocolari);
// ----------------------------------------------
$numfoc= count($compFocolari);
$numpbase= count($prodbaselist);
$raggruppa=1;
if ($numfoc!=$numpbase) {
//echo "raggruppa";
//print_r($compFocolari2D);
} else {
//echo "non raggruppa";
$raggruppa=0;
}
// ----------------------------------------------
//sort($compFocolari);
$compKit=array_unique($compKit);
sort($compKit);
//************************************* FINE COSTRUISCO LISTA FOCOLARI E KIT *************************************
//************************ INIZIO TABELLA INFERIORE *************************
$class_name = get_class($tiretype);
$methods = get_class_methods($class_name);
$focAperto=0;
$focChiusoAria=0;
$focChiusoIdro=0;
$focPellAria=0;
$focPellIdro=0;
$stufAria=0;
$stufIdro=0;
$pellAria=0;
$pellIdro=0;
$data_tabella=0;
$arrayTest=array();
$arrayTestNew=array();
$nomefunzione='';
$pbase_idprod_prec=1;
$campi=array();
foreach($methods as $method)
{
$rigaDatiNewh=array();
$rigaDatiNew=array();
switch ($method) {
case "getFocolarepelletaria":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$nomefunzione=$method;
$focPellAria=1;
$campi=array("nome","incentivi","misure","pot_nom","rend_nom","auton","capacita_serb","consumi","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getFocolarepelletidro":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$nomefunzione=$method;
$focPellIdro=1;
$campi=array("nome","incentivi","misure","pot_nom","pot_acq","rend_nom","auton","capacita_serb","consumi","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getStufapelletaria":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$nomefunzione=$method;
$pellAria=1;
$campi=array("nome","incentivi","misure","pot_nom","rend_nom","auton","capacita_serb","consumi","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
//echo "Pellet aria<br />";
}
break;
case "getStufapelletidro":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$pellIdro=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_nom","pot_acq","rend_nom","auton","capacita_serb","consumi","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getFocolarelegnaaria":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$focChiusoAria=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_bruc","pot_nom","rend_nom","carico_cons","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getFocolarelegnaidro":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$focChiusoIdro=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_bruc","pot_nom","pot_acq","rend_nom","carico_cons","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getFocolareaperto":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$focAperto=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_nom","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getStufalegnaaria":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$stufAria=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_bruc","pot_nom","rend_nom","carico_cons","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
case "getStufalegnaidro":
if (!is_null(call_user_func(array($tiretype,$method))) && strlen(call_user_func(array($tiretype,$method))->getCombustibile())>0) {
$stufIdro=1;
$nomefunzione=$method;
$campi=array("nome","incentivi","misure","pot_bruc","pot_nom","pot_acq","rend_nom","carico_cons","u_fumi","c_nrg","certificazioni");
//aggiungo un dato come filler
$arrayTestNew[]=$campi;
}
break;
default :
//echo "Prodotti senza dati tecnici";
//return;
break;
}
}
if (strlen($nomefunzione)<5) {
//echo "Prodotto senza dati tecnici";
//return;
} else {
//echo $nomefunzione."<br/>";
//print_r($arrayTestNew);
foreach ($prodbaselist as $prodbase) {
$campoTest= $prodbase->getId_prod() ?: $prodbase->getId();
// echo $campoTest;
if ($campoTest == $pbase_idprod_prec or is_null($prodbase->getDatitec()) or is_null(call_user_func(array($prodbase->getDatitec(),$nomefunzione)))) {
//id_prodotto uguale a quello di prima, non faccio nulla
//non c'è il brick, non faccio nulla
//echo "Non c'è".$nomefunzione."<br/>";
} else {
//recupero il dato del brick
$datoRiga=call_user_func(array($prodbase->getDatitec(),$nomefunzione));
foreach ($campi as $campo) {
$dato='';
$datoh='';
//echo "CAMPO:".$campo."<br/>";
switch ($campo) {
case 'nome':
$datoh=$this->get("translator")->trans("list_dati_nome");
$dato=$prodbase->getKey();
break;
case 'misure':
$datoh=$this->get("translator")->trans("list_dati_misure");
if (!is_null($prodbase->getDatitec()->getMisure())) {
$dato=explode(" ",$prodbase->getDatitec()->getMisure()->getLar())[0]."x".explode(" ",$prodbase->getDatitec()->getMisure()->getProf())[0]."x".$prodbase->getDatitec()->getMisure()->getAlt();
if (!is_null($prodbase->getDatitec()->getMisure()->getPeso())) $dato=$dato."<br/>".$prodbase->getDatitec()->getMisure()->getPeso();
if (substr($dato,0,1)=='0') $dato="";
}
break;
case 'combustibile':
$datoh=$this->get("translator")->trans("list_dati_combustibile");
$dato=(string)$datoRiga->getCombustibile();
break;
case 'pot_nom':
$datoh=$this->get("translator")->trans("list_dati_pot_nom");
$dato=(string)$datoRiga->getPot_nom();
break;
case 'pot_acq':
$datoh=$this->get("translator")->trans("list_dati_pot_acq");
$dato=(string)$datoRiga->getPot_acq();
break;
case 'pot_bruc':
$datoh=$this->get("translator")->trans("list_dati_pot_bruc");
$dato=(string)$datoRiga->getPot_bruc();
break;
case 'rend_nom':
$datoh=$this->get("translator")->trans("list_dati_rend_nom");
$dato=(string)$datoRiga->getRend_nom();
break;
case 'auton':
$datoh=$this->get("translator")->trans("list_dati_auton");
$dato=(string)$datoRiga->getAuton();
break;
case 'capacita_serb':
$datoh=$this->get("translator")->trans("list_dati_capacita_serb");
$dato=(string)$datoRiga->getCapacita_serb();
break;
case 'consumi':
$datoh=$this->get("translator")->trans("list_dati_consumi");
$dato=explode(" ",$datoRiga->getConsumo_min())[0]." - ".$datoRiga->getConsumo_max();
break;
case 'carico_cons':
$datoh=$this->get("translator")->trans("list_dati_carico_cons");
$dato=(string)$datoRiga->getCarico_cons();
break;
case 'u_fumi':
$datoh=$this->get("translator")->trans("list_dati_u_fumi");
$dato=(string)$datoRiga->getU_fumi();
break;
case 'c_nrg':
$datoh=$this->get("translator")->trans("list_dati_c_nrg");
$dato=$datoRiga->getClasse_nrg();
break;
case 'certificazioni':
$datoh=$this->get("translator")->trans("list_dati_certificazioni");
$allinc=$prodbase->getCertificazioni();
if (!is_null($allinc)) {
$content="";
foreach ($allinc as $key3) {
$miopic = $key3->getImg_cert();
if (!is_null($miopic) && $miopic instanceof \Pimcore\Model\Asset\Image) {
$dato=$dato.$miopic->getThumbnail("listmini")->getHtml();
}
}
}
break;
case 'incentivi':
$datoh=$this->get("translator")->trans("list_dati_incentivi");
$allinc=$prodbase->getIncentivi();
if (!is_null($allinc)) {
foreach ($allinc as $key2) {
$miopic = $key2->getImg_inc();
if (!is_null($miopic) && $miopic instanceof \Pimcore\Model\Asset\Image) {
$dato=$dato.$miopic->getThumbnail("listmini")->getHtml();
}
}
}
break;
default:
# code...
break;
}
$rigaDatiNewh[$campo]=$datoh;
$rigaDatiNew[$campo]=$dato;
}
$arrayTestNew[]=$rigaDatiNew;
$pbase_idprod_prec=$prodbase->getId_prod() ?: $prodbase->getId();
} //if uguale al precedente o mancano dati
} //foreach sui prodotti base
} //if di nomefunzione
$myArrayNew=$arrayTestNew;
$myArrayh=$rigaDatiNewh;
//************************ FINE TABELLA INFERIORE ***************************
//aggiunge il design e i prodotti all'array da renderizzare
$pagesToRender[]=array("design"=>$design,"prodottibase"=>$prodbaselist,"focolari"=>$compFocolari,"focolari2D"=>$compFocolari2D,"kit"=>$compKit,"raggruppa"=>$raggruppa,"optional"=>$myAccAll,"plus"=>$myPlusAll,"datih"=>$rigaDatiNewh,"dati"=>$arrayTestNew);
} else {
}
} //foreach design
$this->view->pages = $pagesToRender;
}
public function listpagepalexpdfAction(Request $request)
{
}
public function listcleanmultiAction(Request $request)
{
}
public function deslistAction(Request $request)
{
}
public function assegnaAction(Request $request)
{
}
public function addplusAction(Request $request)
{
}
public function addcertAction(Request $request)
{
}
public function addincAction(Request $request)
{
}
public function addaccAction(Request $request)
{
}
public function addcompAction(Request $request)
{
}
//********************* FUNZIONI COMODE PER ESTRAZIONE DATI ********************************************
public function getAllDesign($myIDParent) {
//estrae tutti i design dal folder e poi disegna la pagina:
$entriesD = new \Pimcore\Model\DataObject\Design\Listing();
$entriesD->setObjectTypes([\Pimcore\Model\DataObject\AbstractObject::OBJECT_TYPE_OBJECT]);
$entriesD->setLimit(300);
$entriesD->setOrderKey("ordinamento");
$entriesD->setOrder("asc");
$entriesD->setCondition("o_parentId = '".$myIDParent."'");
$entriesD->load();
return $entriesD;
}
public function getAllDesignUL() {
//estrae tutti i design dal folder e poi disegna la pagina:
$entriesD = new \Pimcore\Model\DataObject\Design\Listing();
$entriesD->setObjectTypes([\Pimcore\Model\DataObject\AbstractObject::OBJECT_TYPE_OBJECT]);
$entriesD->setLimit(3000);
$entriesD->setOrderKey("o_path");
$entriesD->setOrder("asc");
$entriesD->load();
return $entriesD;
}
public function getPrezzo($mycode,$listino) {
if(!is_null($mycode->getPrz()) and !is_null($mycode->getPrz()->getPrezzi()) ) { //and !is_null($mycode->getPrz()->getPrezzi()->getLis_it_curr())) {
//echo $mycode.PHP_EOL;
$myclass=get_class($mycode);
return explode(" ",call_user_func(array($mycode->getPrz()->getPrezzi(),$listino)))[0];
//return explode(" ",$mycode->getPrz()->getPrezzi()->getLis_it_curr())[0];
}
return '';
}
public function getCosto($mycode,$listino) {
if(!is_null($mycode->getPrz()) and !is_null($mycode->getPrz()->getPrezzi())) {
//echo $mycode.PHP_EOL;
$myclass=get_class($mycode);
return explode(" ",call_user_func(array($mycode->getPrz()->getPrezzi(),"getCost_standard_curr")))[0];
//return explode(" ",$mycode->getPrz()->getPrezzi()->getLis_it_curr())[0];
}
return '';
}
public function getPrezzoCodice($mycodestring,$listino) {
$mycode = \Pimcore\Model\DataObject\Codice::getByCodice($mycodestring,1);
return \AppBundle\Controller\ProvaController::getPrezzo($mycode,$listino);
}
public function getDati($mycode,$listinoO,$listinoN) {
$prezzoO=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode,$listinoO)));
$prezzoN=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode,$listinoN)));
$costo=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getCosto($mycode,"null")));
$delta= (intval($prezzoO)==0) ? 0 : number_format(($prezzoN-$prezzoO)/$prezzoO*100,1);
$nettoNew=$prezzoN*0.6*0.9;
$marg= (intval($prezzoN)==0) ? 0 : number_format(($nettoNew-$costo)/$nettoNew*100,1);
$margAss= (intval($prezzoN)==0 || intval($costo)==0 ) ? 0 : number_format($nettoNew-$costo,0);
$dati=array("codice"=>$mycode->getCodice(),"prezzoO"=>$prezzoO,"prezzoN"=>$prezzoN,"costo"=>$costo,"deltaPp"=>$delta,"prezzoNnet"=>$nettoNew,"margNp"=>$marg,"margN"=>$margAss);
return $dati;
}
public function getDatiPrezziAll($mycode, $curr_or_new) {
$prezzo_IT = '';
$prezzo_ES = '';
$prezzo_FR = '';
$prezzo_DE = '';
$prezzo_UN = '';
if ($curr_or_new == 'curr') {
$prezzo_IT=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_it_curr')));
$prezzo_ES=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_es_curr')));
$prezzo_FR=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_fr_curr')));
$prezzo_DE=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_de_curr')));
$prezzo_UN=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_row_curr')));
} else {
$prezzo_IT=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_it_new')));
$prezzo_ES=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_es_new')));
$prezzo_FR=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_fr_new')));
$prezzo_DE=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_de_new')));
$prezzo_UN=intval(str_replace(".", "", \AppBundle\Controller\ProvaController::getPrezzo($mycode, 'getLis_row_new')));
}
return array("codice"=>$mycode->getCodice(), "prezzo_IT"=>$prezzo_IT,"prezzo_ES"=>$prezzo_ES,"prezzo_FR"=>$prezzo_FR, "prezzo_DE"=>$prezzo_DE, "prezzo_UN"=>$prezzo_UN);
}
//********************* FUNZIONI COMODE PER RENDERIZZARE ***********************************************
public function renderHeader($title) {
return '<tr>
<th class="prima titolo_tab" align="left" colspan="2">'.$title.'</th>
<th class="prima titolo_tab" align="center">€_old</th>
<th class="prima titolo_tab" align="center">€_new</th>
<th class="prima titolo_tab" align="center">[€]</th>
<th class="prima titolo_tab" align="center">Δ%</th>
<th class="prima titolo_tab" align="right">Δ€</th>
</tr>';
}
public function renderDati($desc,$mycode,$listinoO,$listinoN) {
$dati=\AppBundle\Controller\ProvaController::getDati($mycode,$listinoO,$listinoN);
return '<tr>
<td class="prima descrizione_opt" width="40%">'.$desc.'</td>
<td align="center" width="10%" class="codice"><a href="http://pim.palazzetti.it/admin/login/deeplink?object_'.$mycode->getId().'_object" target="_new">'.$dati["codice"].'</a></td>
<td align="center" width="10%" class="prezzo">'.$dati["prezzoO"].'</td>
<td align="center" width="10%" class="prezzo">'.$dati["prezzoN"].'</td>
<td align="center" width="10%" class="prezzo">'.$dati["costo"].'</td>
<td align="center" width="10%" class="prezzo">'.$dati["margNp"].'%</td>
<td align="right" width="10%" class="prezzo">'.$dati["margN"].'</td>
</tr>';
}
public function renderHeaderDatiAll($title) {
return '<tr>
<th class="prima titolo_tab" align="left" colspan="2">'.$title.'</th>
<th class="prima titolo_tab" align="center">€ IT</th>
<th class="prima titolo_tab" align="center">€ ES</th>
<th class="prima titolo_tab" align="center">€ FR</th>
<th class="prima titolo_tab" align="center">€ DE</th>
<th class="prima titolo_tab" align="center">€ EN</th>
</tr>';
}
public function renderDatiAll($desc,$mycode,$curr_or_new) {
$dati=\AppBundle\Controller\ProvaController::getDatiPrezziAll($mycode, $curr_or_new);
return '<tr>
<td class="prima descrizione_opt" width="40%">'.$desc.'</td>
<td align="center" width="10%" class="codice"><a href="http://pim.palazzetti.it/admin/login/deeplink?object_'.$mycode->getId().'_object" target="_new">'.$dati["codice"].'</a></td>
<td align="center" width="10%" class="prezzo">'.$dati["prezzo_IT"].'</td>
<td align="center" width="10%" class="prezzo">'.$dati["prezzo_ES"].'</td>
<td align="center" width="10%" class="prezzo">'.$dati["prezzo_FR"].'</td>
<td align="center" width="10%" class="prezzo">'.$dati["prezzo_DE"].'</td>
<td align="center" width="10%" class="prezzo">'.$dati["prezzo_UN"].'</td>
</tr>';
}
public function renderTable($myArrayh2,$myArray) {
$campi=$myArray[0];
$corpo='';
if (!is_null($myArrayh2) && !is_null($campi)) {
$corpo='<!-- CLASS RENDERER -->
<table class="display compact" width="100%" style="font-size: 8pt;border-collapse: collapse; margin-top: 10px;">
<thead><tr style="background:#cfd0d1">';
foreach ($campi as $dettS) {
if ($dettS=="incentivi") {
$corpo=$corpo.'<th width="100px" ';
} elseif ($dettS=="certificazioni") {
$corpo=$corpo.'<th width="130px" ';
} else {
$corpo=$corpo.'<th ';
}
$corpo=$corpo.' style="border: 1px solid #878786;text-align:center;">'.$myArrayh2[$dettS].'</th>';
}
$corpo=$corpo.'</tr></thead><tbody>';
//$myArray=$myArrayNew2;
$tot=count($myArray);
$newSpanner=array();
$i=1;
foreach ($campi as $dettS) {
$i=1;
$newSpanner[$i][$dettS]=1;
for ($j = $i+1; $j < count($myArray); $j++) {
if ($myArray[$i][$dettS]==$myArray[$j][$dettS] ) {
$newSpanner[$i][$dettS]++;
$newSpanner[$j][$dettS]=0;
} else {
$newSpanner[$j][$dettS]=1;
$i=$j;
}
}
}
for ($k = 1; $k < count($myArray); $k++) {
$corpo=$corpo.'<tr>';
foreach ($campi as $dettS) {
if($newSpanner[$k][$dettS]==0) {
} else if ($newSpanner[$k][$dettS]==1) {
$corpo=$corpo.'<td style="border: 1px solid #878786;text-align:center;">'.$myArray[$k][$dettS].'</td>';
} else {
$corpo=$corpo.'<td style="border: 1px solid #878786;text-align:center;" rowspan="'.$newSpanner[$k][$dettS].'">'.$myArray[$k][$dettS].'</td>';
}
}
$corpo=$corpo.'</tr>';
}
$corpo=$corpo.'</tbody></table>';
return $corpo;
} else {
return '';
}
}
}