src/Model/Templating/Templating.php line 1874

  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: mirko
  5.  * Date: 16/02/2019
  6.  * Time: 14:03
  7.  */
  8. namespace App\Model\Templating;
  9. use App\Controller\ServiziController;
  10. use App\Entity\AlberoMenuProdotti;
  11. use App\Entity\Categorie;
  12. use App\Entity\MetaTags;
  13. use App\Entity\MetaTagsDettagli;
  14. use App\Entity\PagineEComponenti;
  15. use App\Model\Caching\Caching_Categorie;
  16. use App\Model\Carrello\RitornoCalcoloPrezzoNetto;
  17. use App\Model\Costanti;
  18. use App\Model\Entita\AlberoCategorie;
  19. use App\Model\Entita\AssociazioneAttributi;
  20. use App\Model\Entita\Attributi;
  21. use App\Model\Entita\Categoria;
  22. use App\Model\Entita\Destinazioni;
  23. use App\Model\Entita\MappaCategoriaArticolo;
  24. use App\Model\Entita\RigaCarrello;
  25. use App\Model\Entita\TipologiaPreimpostataLista;
  26. use App\Model\Entita\Variante;
  27. use App\Model\GestioneTagHTML\GestioneTagHTML;
  28. use App\Model\RecuperoDati;
  29. use App\Model\SubstringWithFind;
  30. use App\Model\Translating\Translating;
  31. use Monolog\Logger;
  32. use Psr\Log\LoggerInterface;
  33. use Symfony\Bridge\Doctrine\ManagerRegistry;
  34. use Symfony\Bridge\Twig\AppVariable;
  35. use Symfony\Component\Routing\Router;
  36. use Twig\Environment;
  37. use Twig\Error\LoaderError;
  38. use Twig\Error\RuntimeError;
  39. use Twig\Error\SyntaxError;
  40. /**
  41.  *
  42.  */
  43. class Templating
  44. {
  45.     /**
  46.      * Templating constructor.
  47.      */
  48.     public function __construct()
  49.     {
  50.     }
  51.     /**
  52.      * @param $stringa
  53.      * @return RitornoDatoDb
  54.      */
  55.     public static function ConvertiStringaDatoDb($stringa){
  56.         $ritorno = new RitornoDatoDb();
  57.         $sbComponentId = SubstringWithFind::SubstringWithFind(
  58.             'component-id="',
  59.             '"',
  60.             $stringa,
  61.             0,
  62.             true
  63.         );
  64.         $ritorno->componentId = $sbComponentId->substring;
  65.         $sbClickAutomatico = SubstringWithFind::SubstringWithFind(
  66.             'data-dv-clic-linkautomatico="',
  67.             '"',
  68.             $stringa,
  69.             0,
  70.             true
  71.         );
  72.         $ritorno->clickLinkAutomatico = $sbClickAutomatico->substring;
  73.         $sbClick = SubstringWithFind::SubstringWithFind(
  74.             'data-dv-clic-link="',
  75.             '"',
  76.             $stringa,
  77.             0,
  78.             true
  79.         );
  80.         $ritorno->clickLink = $sbClick->substring;
  81.         $sbPercorso = SubstringWithFind::SubstringWithFind(
  82.             'percorso="',
  83.             '"',
  84.             $stringa,
  85.             0,
  86.             true
  87.         );
  88.         $ritorno->percorso = $sbPercorso->substring != '' ? explode(",", $sbPercorso->substring) : array();
  89.         $sbNomeColonna = SubstringWithFind::SubstringWithFind(
  90.             'nome-colonna="',
  91.             '"',
  92.             $stringa,
  93.             0,
  94.             true
  95.         );
  96.         $ritorno->nomeColonna = $sbNomeColonna->substring;
  97.         $sbTipoDato = SubstringWithFind::SubstringWithFind(
  98.             'tipo-dato="',
  99.             '"',
  100.             $stringa,
  101.             0,
  102.             true
  103.         );
  104.         $ritorno->tipoDato = strtolower($sbTipoDato->substring);
  105.         $sbDatoSpeciale = SubstringWithFind::SubstringWithFind(
  106.             'dato-speciale="',
  107.             '"',
  108.             $stringa,
  109.             0,
  110.             true
  111.         );
  112.         $ritorno->datoSpeciale = $sbDatoSpeciale->substring;
  113.         $sbStyle = SubstringWithFind::SubstringWithFind(
  114.             'style="',
  115.             '"',
  116.             $stringa,
  117.             0,
  118.             true
  119.         );
  120.         $ritorno->style = $sbStyle->substring;
  121.         $sbId = SubstringWithFind::SubstringWithFind(
  122.             ' id="',
  123.             '"',
  124.             $stringa,
  125.             0,
  126.             true
  127.         );
  128.         $ritorno->id = $sbId->substring;
  129.         $sbClass = SubstringWithFind::SubstringWithFind(
  130.             'class="',
  131.             '"',
  132.             $stringa,
  133.             0,
  134.             true
  135.         );
  136.         $ritorno->class = $sbClass->substring;
  137.         $sbImmagine = SubstringWithFind::SubstringWithFind(
  138.             'columndbimmagine="',
  139.             '"',
  140.             $stringa,
  141.             0,
  142.             true
  143.         );
  144.         $img = strtolower($sbImmagine->substring);
  145.         $sbsNumDec = SubstringWithFind::SubstringWithFind(
  146.             'numero-decimali="',
  147.             '"',
  148.             $stringa,
  149.             0,
  150.             true
  151.         );
  152.         $ritorno->numeroDecimali = $sbsNumDec->substring;
  153.         $sbSeparatoreMigliaia = SubstringWithFind::SubstringWithFind(
  154.             'separatore-migliaia="',
  155.             '"',
  156.             $stringa,
  157.             0,
  158.             true
  159.         );
  160.         $ritorno->separatoreMigliaia = $sbSeparatoreMigliaia->substring;
  161.         $sbSeparatoreDecimali = SubstringWithFind::SubstringWithFind(
  162.             'separatore-decimali="',
  163.             '"',
  164.             $stringa,
  165.             0,
  166.             true
  167.         );
  168.         $ritorno->separatoreDecimali = $sbSeparatoreDecimali->substring;
  169.         if ($img == '1'){
  170.             $ritorno->immagine = true;
  171.         }else {
  172.             $ritorno->immagine = false;
  173.         }
  174.         return $ritorno;
  175.     }
  176.     /**
  177.      * @param AppVariable|null $twigAppArray
  178.      * @return string
  179.      */
  180.     public static function estraiParametriGetDaTwigAppArray($twigAppArray = null){
  181.         $ritorno = '';
  182.         if ($twigAppArray) {
  183.             if ($twigAppArray->getRequest()) {
  184.                 if ($twigAppArray->getRequest()->getUri()) {
  185.                     $requestUri = $twigAppArray->getRequest()->getRequestUri();
  186.                     //Estraggo solo i parametri
  187.                     $indicePuntoDiDom = strpos($requestUri, '?', 0);
  188.                     if ($indicePuntoDiDom) {//Se non c'è il punto di domanda vuol dire che non sono presenti parametri GET
  189.                         $ritorno = substr($requestUri, $indicePuntoDiDom, strlen($requestUri) - $indicePuntoDiDom);
  190.                     }
  191.                 }
  192.             }
  193.         }
  194.         return $ritorno;
  195.     }
  196.     public static function ritornaStringaPagination($mostraAvanti, $mostraIndietro, $nrPagine, ServiziController $serviziController, $routeRiferimento, Router $router, $datiRiferimento, LoggerInterface $logger = null, $twigAppArray = null){
  197.         $paginaCorrente = 0;
  198.         $pagineTotali = $datiRiferimento["nrPagine"];
  199.         $htmlRitorno = '<nav aria-label="...">
  200.                 <ul class="pagination">';
  201.         if (array_key_exists(Costanti::T_PAGINA_CORRENTE, $datiRiferimento)){
  202.             $paginaCorrente = $datiRiferimento[Costanti::T_PAGINA_CORRENTE];
  203.         }
  204.         if ($paginaCorrente == 0){
  205.             $paginaCorrente = 1;
  206.         }
  207.         $arrayXRoute = array(
  208.             'page' => 1
  209.         );
  210.         //ottengo eventuali parametri get da appendere alla fine
  211.         $parametriGet = self::estraiParametriGetDaTwigAppArray($twigAppArray);
  212.         
  213.         if ($datiRiferimento['cat1'] != ''){
  214.             $arrayXRoute['categoria_1'] = str_replace('/', '£-£',$datiRiferimento['cat1']);
  215.         }
  216.         if ($datiRiferimento['cat2'] != ''){
  217.             $arrayXRoute['categoria_2'] = str_replace('/', '£-£',$datiRiferimento['cat2']);
  218.         }
  219.         if ($datiRiferimento['cat3'] != ''){
  220.             $arrayXRoute['categoria_3'] = str_replace('/', '£-£',$datiRiferimento['cat3']);
  221.         }
  222.         if ($datiRiferimento['cat4'] != ''){
  223.             $arrayXRoute['categoria_4'] = str_replace('/', '£-£',$datiRiferimento['cat4']);
  224.         }
  225.         if ($datiRiferimento['cat5'] != ''){
  226.             $arrayXRoute['categoria_5'] = str_replace('/', '£-£',$datiRiferimento['cat5']);
  227.         }
  228.         if ($mostraIndietro == '1' && $paginaCorrente > 1){
  229.             $arrayXRoute['page'] = $paginaCorrente - 1;
  230.             $htmlRitorno .= '<li><a href="' .  $router->generate($routeRiferimento, $arrayXRoute) . $parametriGet . '" aria-label="Previous"><span aria-hidden="true">«</span></a></li>';
  231.         }
  232.         $divisionePagine = ceil($nrPagine / 2) - 1;
  233.         $min = $paginaCorrente - $divisionePagine;
  234.         $max = $paginaCorrente + $divisionePagine;
  235.         if ($min <= 0){
  236.             $abs = abs($min) + 1;
  237.             $min = $min + $abs;
  238.             $max = $max + $abs;
  239.         }
  240.         for($i = $min; $i <= $max; $i++) {
  241.             if ($i <= $pagineTotali) {
  242.                 $arrayXRoute['page'] = $i;
  243.                 $attuale = ($i == $paginaCorrente ? true : false);
  244.                 $htmlRitorno .= '<li' . ($attuale ? ' class="active" ' : '') . '><a href="' . $router->generate($routeRiferimento, $arrayXRoute) . '">' . $i . ($attuale ? '<span class="sr-only">(current)</span>' : '') . '</a></li>';
  245.             }
  246.         }
  247.         if ($mostraAvanti == '1'){
  248.             if ($paginaCorrente + 1 <= $pagineTotali) {
  249.                 $arrayXRoute['page'] = $paginaCorrente + 1;
  250.                 $htmlRitorno .= '<li><a href="' . $router->generate($routeRiferimento, $arrayXRoute) . '" aria-label="Next"><span aria-hidden="true">»</span></a></li>';
  251.             }
  252.         }
  253.         return $htmlRitorno;
  254.     }
  255.     public static function convertiTestataDivSecondario($elementoCompleto, ServiziController $serviziController, Router $router, PagineEComponenti $pagina, $datiRiferimento  = null, LoggerInterface $logger = null, $ordineCasuale = false){
  256.         $sbStyle = SubstringWithFind::SubstringWithFind(
  257.             'style="',
  258.             '"',
  259.             $elementoCompleto,
  260.             0,
  261.             true
  262.         );
  263.         $stile = $sbStyle->substring;
  264.         $sbId = SubstringWithFind::SubstringWithFind(
  265.             'id="',
  266.             '"',
  267.             $elementoCompleto,
  268.             0,
  269.             true
  270.         );
  271.         $id = $sbId->substring;
  272.         $sbClass = SubstringWithFind::SubstringWithFind(
  273.             'class="',
  274.             '"',
  275.             $elementoCompleto,
  276.             0,
  277.             true
  278.         );
  279.         $class = $sbClass->substring;
  280.         $sbLinkAuto = SubstringWithFind::SubstringWithFind(
  281.             'data-dv-clic-linkautomatico="',
  282.             '"',
  283.             $elementoCompleto,
  284.             0,
  285.             true
  286.         );
  287.         $linkAuto = $sbLinkAuto->substring;
  288.         $sbClickLink = SubstringWithFind::SubstringWithFind(
  289.             'data-dv-clic-link="',
  290.             '"',
  291.             $elementoCompleto,
  292.             0,
  293.             true
  294.         );
  295.         $clickLink = $sbClickLink->substring;
  296.         if ($clickLink != ''){
  297.             $linkFinale = $clickLink;
  298.         }else{
  299.             $linkFinale = Templating::creaLinkAutomatico($linkAuto, $router, $datiRiferimento, $pagina, $ordineCasuale, $logger, $serviziController);
  300.         }
  301.         return '<a href="' . ($clickLink != '' ? $clickLink : $linkFinale) . '" style="' . $stile . '" class="' . $class . '" id="' . $id . '">';
  302.     }
  303.     /**
  304.      * @param $valoriSupporto array
  305.      * @return array
  306.      * <p>Questa funzione prende l'array valori di supporto e ritorna un array con le categorie esistenti e con pagina 1</p>
  307.      */
  308.     static function ottieniArrayRoutePerNavigazioneCategorie($valoriSupporto, LoggerInterface $logger = null){
  309.         $arrayRitorno = array();
  310.         if (array_key_exists('cat1', $valoriSupporto) && $valoriSupporto['cat1'] != ''){
  311.             $arrayRitorno['cat1'] = $valoriSupporto['cat1'];
  312.         }
  313.         if (array_key_exists('cat2', $valoriSupporto) && $valoriSupporto['cat2'] != ''){
  314.             $arrayRitorno['cat2'] = $valoriSupporto['cat2'];
  315.         }
  316.         if (array_key_exists('cat3', $valoriSupporto) && $valoriSupporto['cat3'] != ''){
  317.             $arrayRitorno['cat3'] = $valoriSupporto['cat3'];
  318.         }
  319.         if (array_key_exists('cat4', $valoriSupporto) && $valoriSupporto['cat4'] != ''){
  320.             $arrayRitorno['cat4'] = $valoriSupporto['cat4'];
  321.         }
  322.         if (array_key_exists('cat5', $valoriSupporto) && $valoriSupporto['cat5'] != ''){
  323.             $arrayRitorno['cat5'] = $valoriSupporto['cat5'];
  324.         }
  325.         
  326.         $elementoRiferimento = $valoriSupporto[Costanti::T_LISTA_CATEGORIE];
  327.         if (!array_key_exists('cat1', $valoriSupporto) || (array_key_exists('cat1', $valoriSupporto) && $valoriSupporto['cat1'] == '')){
  328.             $arrayRitorno['categoria_1'] = str_replace('/', '£-£', $elementoRiferimento->categoria->nomeUnivoco);
  329.         } else if (!array_key_exists('cat2', $valoriSupporto) || (array_key_exists('cat2', $valoriSupporto) && $valoriSupporto['cat2'] == '')){
  330.             $arrayRitorno['categoria_2'] = str_replace('/', '£-£', $elementoRiferimento->categoria->nomeUnivoco);
  331.         } else if (!array_key_exists('cat3', $valoriSupporto) || (array_key_exists('cat3', $valoriSupporto) && $valoriSupporto['cat3'] == '')){
  332.             $arrayRitorno['categoria_3'] = str_replace('/', '£-£', $elementoRiferimento->categoria->nomeUnivoco);
  333.         } else if (!array_key_exists('cat4', $valoriSupporto) || (array_key_exists('cat4', $valoriSupporto) && $valoriSupporto['cat4'] == '')){
  334.             $arrayRitorno['categoria_4'] = str_replace('/', '£-£', $elementoRiferimento->categoria->nomeUnivoco);
  335.         } else if (!array_key_exists('cat5', $valoriSupporto) || (array_key_exists('cat5', $valoriSupporto) && $valoriSupporto['cat5'] == '')){
  336.             $arrayRitorno['categoria_5'] = str_replace('/', '£-£', $elementoRiferimento->categoria->nomeUnivoco);
  337.         }
  338.         if ($logger){
  339.             $logger->debug('Elemento riferimento: ' . print_r($elementoRiferimento, true));
  340.             $logger->debug('Array ritorno: ' . print_r($arrayRitorno, true));
  341.         }
  342.         return $arrayRitorno;
  343.     }
  344.     /**
  345.      * @param $valoreLinkAutomatico string
  346.      * @param Router $router
  347.      * @param $valoriSupporto array
  348.      * @return string
  349.      */
  350.     static function creaLinkAutomatico($valoreLinkAutomatico, Router $router, $valoriSupporto, PagineEComponenti $pagina, $righeCasuali = false, LoggerInterface $logger = null, ServiziController $servizi = null){
  351.         $urlRitorno = '';
  352.         try {
  353.             switch ($valoreLinkAutomatico) {
  354.                 case 'pc_svuotaCarrello':
  355.                     {
  356.                         $urlRitorno = $router->generate('carrello_svuota_carrello');
  357.                         break;
  358.                     }
  359.                 case 'pc_applicaCoupon':
  360.                     {
  361.                         break;
  362.                     }
  363.                 case 'pc_checkout':
  364.                     {
  365.                         $urlRitorno = $router->generate('carrello_finalizza');
  366.                         break;
  367.                     }
  368.                 case 'pfc_completa':
  369.                     {
  370.                         break;
  371.                     }
  372.                 case 'cac_navigaCategoria':
  373.                     {
  374.                         if ($pagina->getTipoPagina() == 'componenteAlberoCategorie'){
  375.                             $urlRitorno = $router->generate('home_shop_comune_naviga', Templating::ottieniArrayRoutePerNavigazioneCategorie($valoriSupporto, $logger));
  376.                         }
  377.                         break;
  378.                     }
  379.                 case 'cu_profilo':
  380.                     {
  381.                         $urlRitorno = $router->generate('profilo');
  382.                         break;
  383.                     }
  384.                 case 'cu_gestisciDestinazioni':
  385.                     {
  386.                         $urlRitorno = $router->generate('profilo_destinazioni_lista');
  387.                         break;
  388.                     }
  389.                 case 'cu_gestisciMailSecondarie':
  390.                     {
  391.                         $urlRitorno = $router->generate('mailSecondarie_lista');
  392.                         break;
  393.                     }
  394.                 case 'cu_cambiaMail':
  395.                     {
  396.                         $urlRitorno = $router->generate('profilo_modifica');
  397.                         break;
  398.                     }
  399.                 case 'cu_cambiaPassword':
  400.                     {
  401.                         $urlRitorno = $router->generate('profile_change_password');
  402.                         break;
  403.                     }
  404.                 case 'rc_eliminaRiga':
  405.                     {
  406.                         $urlRitorno = $router->generate('carrello_elimina_riga', array(
  407.                             'idRiga' => get_object_vars($valoriSupporto[Costanti::T_RIGHE_CARRELLO])['id']
  408.                         ));
  409.                         break;
  410.                     }
  411.                 case 'rc_dettaglioArticolo':{
  412.                     $urlRitorno = $router->generate('home_shop_comune_dettaglio_prodotto', array(
  413.                         'codice' => $servizi->creaCodiceIdMappaPerDettaglioProdotto($valoriSupporto[Costanti::T_RIGHE_CARRELLO])
  414.                     ));
  415.                     break;
  416.                 }
  417.                 case 'ro_dettaglioArticolo':
  418.                 case 'ros_dettaglioArticolo':
  419.                     {
  420.                         if ($pagina->getTipoPagina() == 'paginaDettaglioArticolo'){
  421.                             $urlRitorno = $router->generate('home_shop_comune_dettaglio_prodotto', array(
  422.                                 'codice' => $servizi->creaCodiceIdMappaPerDettaglioProdotto($valoriSupporto[Costanti::T_DETTAGLIO_ARTICOLO_IDENTIFICATO])
  423.                             ));
  424.                         }else {
  425.                             if ($righeCasuali) {
  426.                                 $urlRitorno = $router->generate('home_shop_comune_dettaglio_prodotto', array(
  427.                                     'codice' => $servizi->creaCodiceIdMappaPerDettaglioProdotto($valoriSupporto[Costanti::T_RIGHE_SHOP_CASUALI])
  428.                                 ));
  429.                             } else {
  430.                                 $urlRitorno = $router->generate('home_shop_comune_dettaglio_prodotto', array(
  431.                                     'codice' => $servizi->creaCodiceIdMappaPerDettaglioProdotto($valoriSupporto[Costanti::T_RIGHE_SHOP])
  432.                                 ));
  433.                             }
  434.                         }
  435.                         //$logger->debug('dettagliArticolo: ' . print_r($valoriSupporto[Costanti::T_RIGHE_SHOP], true));
  436.                         break;
  437.                     }
  438.                 case 'shopcm_carrello_aggiungi':
  439.                     {
  440.                         if ($pagina->getTipoPagina() == 'paginaDettaglioArticolo'){
  441.                             $urlRitorno = $router->generate('shopcm_carrello_aggiungi', array(
  442.                                 'codice' => $servizi->creaCodiceIdMappaPerDettaglioProdotto($valoriSupporto[Costanti::T_DETTAGLIO_ARTICOLO_IDENTIFICATO])
  443.                             ));
  444.                         }else {
  445.                             if ($righeCasuali) {
  446.                                 $urlRitorno = $router->generate('shopcm_carrello_aggiungi', array(
  447.                                     'codice' => $servizi->creaCodiceIdMappaPerDettaglioProdotto($valoriSupporto[Costanti::T_RIGHE_SHOP_CASUALI])
  448.                                 ));
  449.                             } else {
  450.                                 $urlRitorno = $router->generate('shopcm_carrello_aggiungi', array(
  451.                                     'codice' => $servizi->creaCodiceIdMappaPerDettaglioProdotto($valoriSupporto[Costanti::T_RIGHE_SHOP])
  452.                                 ));
  453.                             }
  454.                         }
  455.                         break;
  456.                     }
  457.                 case 'ros_ordina':
  458.                     {
  459.                         $urlRitorno = '';
  460.                         break;
  461.                     }
  462.                 default:
  463.                 {
  464.                     $urlRitorno = $valoreLinkAutomatico;
  465.                     break;
  466.                 }
  467.             }
  468.         }catch (\Exception $ex){
  469.             if ($servizi){
  470.                 $servizi->DebuggaException($ex, 'Errore recupera link automatico. ValoreLinkAutomatico: ' . $valoreLinkAutomatico);
  471.             }
  472.             $urlRitorno = 'ERRORE RENDERING!';
  473.         }
  474.         return $urlRitorno;
  475.     }
  476.     public static function ottieniElementoDaUtilizzareInBaseATipoPagina($tipoPagina, $ordineCasuale = false, $moltiplicatore = false){
  477.         $elementoValoreDaUtilizzareComeBase = "";
  478.         switch ($tipoPagina){
  479.             case "componenteAlberoCategorie":
  480.             case "homeshop":{
  481.                 $elementoValoreDaUtilizzareComeBase = Costanti::T_LISTA_CATEGORIE;
  482.                 break;
  483.             }
  484.             case "rigaCarrello":
  485.             case "rigaOrdine":{
  486.                 $elementoValoreDaUtilizzareComeBase = "righe";
  487.                 break;
  488.             }
  489.             case "rigaHomeShop": {
  490.                 if ($ordineCasuale)
  491.                     $elementoValoreDaUtilizzareComeBase = Costanti::T_RIGHE_SHOP_CASUALI;
  492.                 else
  493.                     $elementoValoreDaUtilizzareComeBase = Costanti::T_RIGHE_SHOP;
  494.                 break;
  495.             }
  496.             case "componenteAttributoArticolo":{
  497.                 $elementoValoreDaUtilizzareComeBase = Costanti::T_ASSOCIAZIONE_ATTRIBUTI;
  498.                 break;
  499.             }
  500.             case "paginaCarrello":
  501.             case "paginaFinalizzaCarrello": {
  502.                 $elementoValoreDaUtilizzareComeBase = Costanti::T_CARRELLO;
  503.                 break;
  504.             }
  505.             case "paginaDettaglioArticolo":
  506.             case "dettaglioArticolo":
  507.             case "modalRichiestaPrezzo": {
  508.                 if ($moltiplicatore){
  509.                     if ($ordineCasuale){
  510.                         $elementoValoreDaUtilizzareComeBase = Costanti::T_RIGHE_SHOP_CASUALI;
  511.                     }else{
  512.                         $elementoValoreDaUtilizzareComeBase = Costanti::T_RIGHE_SHOP;
  513.                     }
  514.                 }else{
  515.                     $elementoValoreDaUtilizzareComeBase = Costanti::T_DETTAGLIO_ARTICOLO_IDENTIFICATO;
  516.                 }
  517.                 break;
  518.             }
  519.         }
  520.         return $elementoValoreDaUtilizzareComeBase;
  521.     }
  522.     public static function ritornaRoutePaginationInBaseATipoPagina($tipoPagina){
  523.         /*
  524.          * "Pagina standard" => 'paginaStandard',
  525.         "Pagina carrello" => 'paginaCarrello',
  526.         "Pagina finalizza carrello" => 'paginaFinalizzaCarrello',
  527.         "Pagina homeshop" => 'paginaHomeShop',
  528.         "Pagina dettaglio articolo" => "paginaDettaglioArticolo",
  529.         "Pagina dettaglio ordine" => "paginaDettaglioOrdine",
  530.         "Componente -> carrello" => "componenteCarrello",
  531.         "Componente -> alberoCategorie" => "componenteAlberoCategorie",
  532.         "Componente -> ordine" => "componenteOrdine",
  533.         "Componente -> utente" => "componenteUtente",
  534.         "Riga -> carrello" => "rigaCarrello",
  535.         "Riga -> ordine" => "rigaOrdine",
  536.         "Riga -> homeShop" => "rigaHomeShop",
  537.         "Mail standard" => 'mailStandard',
  538.         "Mail nuovo ordine" => 'mailNuovoOrdine',
  539.         "Mail ordine esportato" => 'mailOrdineEsportato',
  540.         "Mail ordine pagamento registrato" => "mailOrdinePagamentoRegistrato",
  541.         "Mail utente nuovo inserimento" => 'mailUtenteNuovoInserimento',
  542.         "Mail utente cambio mail" => "mailUtenteCambioMail",
  543.         "Mail utente cambio password" => "mailUtenteCambioPassword",
  544.         "Mail cambio stato pagamento" => 'mailCambioStatoPagamento'
  545.          */
  546.         $route = '';
  547.         switch ($tipoPagina){
  548.             case 'paginaHomeShop':{
  549.                 $route = 'home_shop_comune_naviga';
  550.                 break;
  551.             }
  552.         }
  553.         return $route;
  554.     }
  555.     /**
  556.      * @param $arrayValoriSupporto array
  557.      * @return int
  558.      */
  559.     public static function estraiLivelloDaArrayValoriSupporto($arrayValoriSupporto){
  560.         $ritornoLivello = 0;
  561.         if (array_key_exists('cat5', $arrayValoriSupporto) && $arrayValoriSupporto['cat5'] != ''){
  562.             $ritornoLivello = 5;
  563.         } else if (array_key_exists('cat4', $arrayValoriSupporto) && $arrayValoriSupporto['cat4'] != ''){
  564.             $ritornoLivello = 4;
  565.         } else if (array_key_exists('cat3', $arrayValoriSupporto) && $arrayValoriSupporto['cat3'] != ''){
  566.             $ritornoLivello = 3;
  567.         } else if (array_key_exists('cat2', $arrayValoriSupporto) && $arrayValoriSupporto['cat2'] != ''){
  568.             $ritornoLivello = 2;
  569.         } else if (array_key_exists('cat1', $arrayValoriSupporto) && $arrayValoriSupporto['cat1'] != ''){
  570.             $ritornoLivello = 1;
  571.         }
  572.         return $ritornoLivello;
  573.     }
  574.     /**
  575.      * @param $ritornoBreadcrumb RitornoBreadCrumb
  576.      * @param $valoriSupporto array
  577.      * @param $servizi ServiziController
  578.      * @param $locale
  579.      * @param Logger|null $logger
  580.      * @return array
  581.      */
  582.     public static function eseguiBreadcrumb($ritornoBreadcrumb, $valoriSupporto, $servizi, $locale, $logger = null){
  583.         $ritornoHtml = array(
  584.             'html' => '',
  585.             'css' => ''
  586.         );
  587.         $cat1 = ''; $cat2 = ''; $cat3 = ''; $cat4 = ''; $cat5 = '';
  588.         if(array_key_exists(Costanti::CATEGORIA_1_DB, $valoriSupporto))
  589.             $cat1 = $valoriSupporto[Costanti::CATEGORIA_1_DB];
  590.         if(array_key_exists(Costanti::CATEGORIA_2_DB, $valoriSupporto))
  591.             $cat2 = $valoriSupporto[Costanti::CATEGORIA_2_DB];
  592.         if(array_key_exists(Costanti::CATEGORIA_3_DB, $valoriSupporto))
  593.             $cat3 = $valoriSupporto[Costanti::CATEGORIA_3_DB];
  594.         if(array_key_exists(Costanti::CATEGORIA_4_DB, $valoriSupporto))
  595.             $cat4 = $valoriSupporto[Costanti::CATEGORIA_4_DB];
  596.         if(array_key_exists(Costanti::CATEGORIA_5_DB, $valoriSupporto))
  597.             $cat5 = $valoriSupporto[Costanti::CATEGORIA_5_DB];
  598.         //<ol class="breadcrumb">
  599.         //  <li><a href="#">Home</a></li>
  600.         //  <li><a href="#">Library</a></li>
  601.         //  <li class="active">Data</li>
  602.         //</ol>
  603.         $arrayPercorso = explode('.', $ritornoBreadcrumb->datoDaVisualizzare);
  604.         $colonnaDaPrendere = '';
  605.         if(count($arrayPercorso) > 0){
  606.             $colonnaDaPrendere = array_pop($arrayPercorso);
  607.         }else{
  608.             $colonnaDaPrendere = $ritornoBreadcrumb->datoDaVisualizzare;
  609.         }
  610.         $stileUltimoElemento = '';
  611.         if ($ritornoBreadcrumb->coloreElementoFinale != ''){
  612.             $stileUltimoElemento = ('style="color:' . $ritornoBreadcrumb->coloreElementoFinale . '" ');
  613.         }
  614.         $ritornoHtml['html'] .= '<ol class="breadcrumb">';
  615.         if($cat1){
  616.             if($cat2){
  617.                 $ritornoHtml['html'] .= '<li><a href="' . self::generaRouteNavigazioneCategorie($servizi->router, array($cat1)) .'"' . '>' . Templating::ritornaValoreDaPercorso($cat1, $arrayPercorso, $colonnaDaPrendere) . '</a></li>';
  618.             }else{
  619.                 $ritornoHtml['html'] .= '<li class="active">' . Templating::ritornaValoreDaPercorso($cat1, $arrayPercorso, $colonnaDaPrendere) . '</li>';
  620.             }
  621.         }
  622.         if($cat2){
  623.             if($cat3){
  624.                 $ritornoHtml['html'] .= '<li><a href="' . self::generaRouteNavigazioneCategorie($servizi->router, array($cat1, $cat2)) .'"' . '>' . Templating::ritornaValoreDaPercorso($cat2, $arrayPercorso, $colonnaDaPrendere) . '</a></li>';
  625.             }else{
  626.                 $ritornoHtml['html'] .= '<li class="active">' . Templating::ritornaValoreDaPercorso($cat2, $arrayPercorso, $colonnaDaPrendere) . '</li>';
  627.             }
  628.         }
  629.         if($cat3){
  630.             if($cat4){
  631.                 $ritornoHtml['html'] .= '<li><a href="' . self::generaRouteNavigazioneCategorie($servizi->router, array($cat1, $cat2, $cat3)) .'"' . '>' . Templating::ritornaValoreDaPercorso($cat3, $arrayPercorso, $colonnaDaPrendere) . '</a></li>';
  632.             }else{
  633.                 $ritornoHtml['html'] .= '<li class="active">' . Templating::ritornaValoreDaPercorso($cat3, $arrayPercorso, $colonnaDaPrendere) . '</li>';
  634.             }
  635.         }
  636.         if($cat4){
  637.             if($cat5){
  638.                 $ritornoHtml['html'] .= '<li><a href="' . self::generaRouteNavigazioneCategorie($servizi->router, array($cat1, $cat2, $cat3, $cat4)) .'"' . '>' . Templating::ritornaValoreDaPercorso($cat4, $arrayPercorso, $colonnaDaPrendere) . '</a></li>';
  639.             }else{
  640.                 $ritornoHtml['html'] .= '<li class="active">' . Templating::ritornaValoreDaPercorso($cat4, $arrayPercorso, $colonnaDaPrendere) . '</li>';
  641.             }
  642.         }
  643.         if($cat5){
  644.             $ritornoHtml['html'] .= '<li  class="active" ' . $stileUltimoElemento . '>' . Templating::ritornaValoreDaPercorso($cat5, $arrayPercorso, $colonnaDaPrendere) . '</li>';
  645.         }
  646.         return $ritornoHtml;
  647.     }
  648.     /**
  649.      * @param $router Router
  650.      * @param $arrayCategorie
  651.      * @return mixed
  652.      */
  653.     public static function generaRouteNavigazioneCategorie($router, $arrayCategorie){
  654.         $arr = array();
  655.         for($i = 0; $i < count($arrayCategorie); $i++){
  656.             $cat = $arrayCategorie[$i];
  657.             $nomeUnivoco = '';
  658.             if($cat instanceof Categoria){
  659.                 $nomeUnivoco = $cat->categoriaInLingua ? $cat->categoriaInLingua->nomeUnivoco : $cat->nomeUnivoco;
  660.             }else if ($cat instanceof Categorie){
  661.                 $nomeUnivoco = $cat->getNomeUnivoco();
  662.             } else {
  663.                 $nomeUnivoco = $cat;
  664.             }
  665.             $arr['categoria_' . ($i + 1)] = $nomeUnivoco;
  666.         }
  667.         return $router->generate('home_shop_comune_naviga', $arr);
  668.     }
  669.     /**
  670.      * @param $componente PagineEComponenti
  671.      * @param $ritornoMoltiplicatore RitornoDaMoltiplicatoreLayout
  672.      * @param $valoriSupporto array
  673.      * @param $servizi ServiziController
  674.      * @param $locale string
  675.      * @param $logger Logger|null
  676.      * @return array
  677.      */
  678.     public static function eseguiMoltiplicatoreLayout($componente, $ritornoMoltiplicatore, $valoriSupporto, $servizi, $locale, $ordineCasuale = false, $logger = null, $twigAppArray = null){
  679.         $ritornoHtml = array(
  680.             'html' => '',
  681.             'css' => ''
  682.         );
  683.         $elementoValoreDaUtilizzareComeBase = Templating::ottieniElementoDaUtilizzareInBaseATipoPagina($componente->getTipoPagina(), $ordineCasuale, true); //Array da scorrere per moltiplicare i dati
  684.         $eventualeLivelloCategorie = Templating::estraiLivelloDaArrayValoriSupporto($valoriSupporto); //Se Ã¨ uguale a 0 vuol dire che non sono specificati parametri 'cat'
  685.         if ($elementoValoreDaUtilizzareComeBase != ''){
  686.             if (!array_key_exists($elementoValoreDaUtilizzareComeBase, $valoriSupporto)){
  687.                 $ritornoHtml["html"] = $ritornoHtml["html"] . '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore Moltiplicatore layout. Chiave layout: ' . $elementoValoreDaUtilizzareComeBase . ' non trovato in array</p>';
  688.             }
  689.             else {
  690.                 $arrayElementi = $valoriSupporto[$elementoValoreDaUtilizzareComeBase]; //lista di elementi database da iterare per comporre il layout
  691.                 if ($ordineCasuale) {
  692.                     shuffle($arrayElementi);
  693.                 }
  694.                 //$logger->info("Elementi: " . count($arrayElementi));
  695.                 if($ritornoMoltiplicatore->numeroRisultati != '' && $ritornoMoltiplicatore->numeroRisultati < 25 && count($arrayElementi) >= $ritornoMoltiplicatore->numeroRisultati){
  696.                     $arrayElementi = array_splice($arrayElementi, 0, $ritornoMoltiplicatore->numeroRisultati);
  697.                 }
  698.                 $primo = true;
  699.                 $conta = 1;
  700.                 foreach ($arrayElementi as $elemento) {
  701.                     $valoriSupportoModificati = null;
  702.                     $valoriSupportoModificati = $valoriSupporto;
  703.                     $valoriSupportoModificati[$elementoValoreDaUtilizzareComeBase] = $elemento;
  704.                     //$logger->info("Conta: " . $conta . " " . json_encode($valoriSupportoModificati[$elementoValoreDaUtilizzareComeBase]));
  705.                     //Il parametro salta serve per quando devo eseguire il moltiplicatore delle categorie per identificare a che livello sono di iterazione in base alle variabili cat1 cat2 cat3 cat4 cat5
  706.                     $salta = false;
  707.                     if ($componente->getTipoPagina() == 'componenteAlberoCategorie'){
  708.                         //Se sto renderizzando un componente albero categorie eseguo il render solo del livello attuale
  709.                         if ($elemento->livello != $eventualeLivelloCategorie){
  710.                             $salta = true;
  711.                         }
  712.                     }
  713.                     if (!$salta) {
  714.                         $rit = $servizi->renderizzaPaginaOComponente($componente->getId(), null, $valoriSupportoModificati, $locale, '', $ordineCasuale, true, $twigAppArray);
  715.                         $ritornoHtml["html"] = $ritornoHtml["html"] . $rit["html"];
  716.                         if ($primo) { //Alla prima iterazione prendo il codice css
  717.                             $ritornoHtml["css"] = $ritornoHtml["css"] . $rit["css"];
  718.                             $primo = false;
  719.                         }
  720.                     }
  721.                     $conta++;
  722.                 }
  723.             }
  724.         }else{
  725.             $ritornoHtml["html"] = $ritornoHtml["html"] . '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore Moltiplicatore layout. Elemento valore non trovato. Tipo Pagina: ' . $componente->getTipoPagina() . '</p>';
  726.         }
  727.         return $ritornoHtml;
  728.     }
  729.     /**
  730.      * @param $elementoTagcompleto
  731.      * @param $elementoNuovo
  732.      * @param $elementoTestata
  733.      * @param $elementoDbDaVisualizzare
  734.      * @param $valoriSupporto
  735.      * @param $pagina
  736.      * @param $servizi
  737.      * @param $locale
  738.      * @param Router $router
  739.      * @param Translating $translating
  740.      * @param Logger|null $logger
  741.      * @param null $twigAppArray
  742.      * @return string
  743.      */
  744.     public static function eseguiStrutturaCoreNav($elementoTagcompleto, $elementoNuovo, $elementoTestata, $elementoDbDaVisualizzare, $valoriSupporto, PagineEComponenti $pagina, $servizi, $locale, Router $router, Translating $translating, LoggerInterface $logger = null, $twigAppArray = null)
  745.     {
  746.         $elementoValoreDaUtilizzareComeBase = Costanti::T_LISTA_CATEGORIE;
  747.         $listaChiaviParent = $valoriSupporto[Costanti::T_LISTA_CATEGORIE_CHIAVI_PARENT];
  748.         $ritornoBase = RitornoElementiBase::OttieniDaElementoTag($elementoTestata);
  749.         $ritornoBase->class .= ' toggle-bar'; //Aggiungo il toggle per mostrare il menu laterale
  750.         $content = $elementoNuovo;
  751.         $content = str_replace($elementoTestata, '', $content);
  752.         $content = str_replace('<TMPLT CORENAV />', '', $content);
  753.         $cs = SubstringWithFind::SubstringWithFind(
  754.             ' colore-sfondo="',
  755.             '"',
  756.             $elementoTestata,
  757.             0,
  758.             true
  759.         );
  760.         $coloreSfondo = $cs->substring;
  761.         if ($coloreSfondo == 'undefined' || $coloreSfondo == ''){
  762.             $coloreSfondo = 'black';
  763.         }
  764.         $ct = SubstringWithFind::SubstringWithFind(
  765.             ' colore-testo="',
  766.             '"',
  767.             $elementoTestata,
  768.             0,
  769.             true
  770.         );
  771.         $coloreTesto = $ct->substring;
  772.         if ($coloreTesto == 'undefined' || $coloreTesto == ''){
  773.             $coloreTesto = 'white';
  774.         }
  775.         $stringaDiComposizione = '';
  776.         $stringaDiComposizione .= '<style type="text/css"> .mf-nav { background-color: ' . $coloreSfondo . '; } .mf-nav a { color: ' . $coloreTesto . ' } </style>';
  777.         $stringaDiComposizione .= '<a ' . $ritornoBase->RitornaStringaElementiBase() . ' onclick="openCloseNav();">';
  778.         $stringaDiComposizione .= $content;
  779.         $stringaDiComposizione .= '</a>';
  780.         $stringaDiComposizione .= '<nav class="mf-nav">';
  781.         $stringaDiComposizione .= '<a href="javascript:void(0)" class="mf-nav-closebtn" onclick="openCloseNav()">&times;</a>';
  782.         $stringaDiComposizione .= '<ul class="mf-menu mf-menu-list">';
  783.         /** @var AlberoCategorie $item */
  784.         foreach ($valoriSupporto[$elementoValoreDaUtilizzareComeBase] as $item) {
  785.             if (!$item->parent){
  786.                 $stringaDiComposizione .= Templating::stampaElementoCoreNav($item, $listaChiaviParent, $elementoDbDaVisualizzare, 1, $pagina, array(), $router, $valoriSupporto, $translating, $servizi, $logger, '', $locale, $twigAppArray);
  787.             }
  788.         }
  789.         $stringaDiComposizione .= '</ul></nav>';
  790.         return $stringaDiComposizione;
  791.     }
  792.     /**
  793.      * @param AlberoCategorie $alberoDaEseguire
  794.      * @param $listaChiaviParent
  795.      * @param $elementoDbDaVisualizzare //Elemento per decodifica percorso db elemento
  796.      * @param $livello
  797.      * @param $pagina
  798.      * @param $arrayPathCategorie
  799.      * @param Router $router
  800.      * @param $valoriSupporto
  801.      * @param Translating $translating
  802.      * @param ServiziController $servizi
  803.      * @param Logger|null $logger
  804.      * @param string $ritornoHtml
  805.      * @param string $locale
  806.      * @param null $twigAppArray
  807.      * @return string
  808.      */
  809.     public static function stampaElementoCoreNav(AlberoCategorie $alberoDaEseguire, $listaChiaviParent, $elementoDbDaVisualizzare, $livello, PagineEComponenti $pagina, $arrayPathCategorie, Router $router, $valoriSupporto, Translating $translating, ServiziController $servizi, LoggerInterface $logger = null, $ritornoHtml = '', $locale = 'it', $twigAppArray = null){
  810.         $aggiuntaSeFigli = '';
  811.         $href = '#/';
  812.         $arrayPathCategorie2 = array_merge(array('categoria_' . $livello => str_replace('/', '£-£', $alberoDaEseguire->categoria->nomeUnivoco)), $arrayPathCategorie);
  813.         $page = 1;
  814.         if (array_key_exists('page', $valoriSupporto)){
  815.             $page = $valoriSupporto['page'];
  816.         }
  817.         $arraySecondarioCompleto = array_merge(array('page' => $page), $arrayPathCategorie2);
  818.         if ($alberoDaEseguire->hasChild){
  819.             $aggiuntaSeFigli = ' class="mf-dropdown"';
  820.         }else{
  821.             $href = $router->generate('home_shop_comune_naviga', $arraySecondarioCompleto);
  822.         }
  823.         $ritornoHtml .= '<li' . $aggiuntaSeFigli . '><a href="' . $href . '">' . Templating::ritornaValoreDaPercorsoValoriSpeciali($alberoDaEseguire, $elementoDbDaVisualizzare) . '</a>';
  824.         if ($alberoDaEseguire->hasChild){
  825.             $ritornoHtml .= '<ul class="mf-dropdown-menu">';
  826.             foreach ($listaChiaviParent[$alberoDaEseguire->id] as $item){
  827.                 $ritornoHtml .= self::stampaElementoCoreNav($item, $listaChiaviParent, $elementoDbDaVisualizzare, $livello + 1, $pagina, $arrayPathCategorie2, $router, $valoriSupporto, $translating, $servizi, $logger, '', $locale, $twigAppArray);
  828.             }
  829.             $ritornoHtml .= '</ul>';
  830.         }
  831.         $ritornoHtml .= '</li>';
  832.         return $ritornoHtml;
  833.     }
  834.     /**
  835.      * @param $elementoTagCompleto
  836.      * @param $valoriSupporto
  837.      * @param PagineEComponenti $pagina
  838.      * @param $servizi
  839.      * @param $locale
  840.      * @param Router $router
  841.      * @param Translating $translating
  842.      * @param null $ritornoHtml
  843.      * @param Logger|null $logger
  844.      * @param array|null $twigAppArray
  845.      * @return array
  846.      */
  847.     public static function eseguiGrigliaOrdinazioneVarianti($elementoTagCompleto, $valoriSupporto, PagineEComponenti $pagina, ServiziController $servizi, $locale, Router $router, Translating $translating, $ritornoHtml = null, $logger = null, $twigAppArray = null){
  848.         if (!$ritornoHtml) {
  849.             $ritornoHtml = array(
  850.                 'html' => '',
  851.                 'css' => ''
  852.             );
  853.         }
  854.         $html = "";
  855.         try {
  856.             $translating->CaricaTraduzioniDaFamiglia('home_shop', $locale);
  857.             $ritornoBase = RitornoElementiBase::OttieniDaElementoTag($elementoTagCompleto);
  858.             /** @var MappaCategoriaArticolo|null $mappaSelezionata */
  859.             $mappaSelezionata = (array_key_exists(Costanti::T_MAPPA_IDENTIFICATA, $valoriSupporto) ? $valoriSupporto[Costanti::T_MAPPA_IDENTIFICATA] : null);
  860.             $varianti = $mappaSelezionata->varianti;
  861.             $codiciInseriti = array();
  862.             /** @var Variante[] $variabiliInColonna */
  863.             $variabiliInColonna = array();
  864.             $arrayTemporaneo = array();
  865.             $headerRigaEsame = "";
  866.             foreach ($varianti as $v) {
  867.                 if (!in_array($v->codiceDimensione5, $codiciInseriti)) {
  868.                     array_push($codiciInseriti, $v->codiceDimensione5);
  869.                     array_push($variabiliInColonna, $v);
  870.                 }
  871.                 $headerAttuale = $servizi->generaHeaderRiga($v);
  872.                 if ($headerRigaEsame == "") {
  873.                     $headerRigaEsame = $headerAttuale;
  874.                 }
  875.                 if ($headerRigaEsame != $headerAttuale) {
  876.                     $visualizzazioneVarianti[$headerRigaEsame] = $arrayTemporaneo;
  877.                     $arrayTemporaneo = array();
  878.                     $headerRigaEsame = $headerAttuale;
  879.                 }
  880.                 if ($headerRigaEsame == $headerAttuale) {
  881.                     $arrayTemporaneo[$v->codiceDimensione5] = $v;
  882.                 }
  883.             }
  884.             if ($headerRigaEsame != "" && count($arrayTemporaneo) > 0) {
  885.                 $visualizzazioneVarianti[$headerRigaEsame] = $arrayTemporaneo;
  886.             }
  887.             $arrayDiVerificaEsistenza = array();
  888.             //Stampo la tabella / form
  889.             if (count($varianti) > 0) {
  890.                 $html .=(
  891.                     '<form method="POST" action="' . $router->generate('shopcm_carrello_aggiungi_multiplo') . '" class="' . $ritornoBase->class . '" id="' . $ritornoBase->id . '" style="' . $ritornoBase->style . '">
  892.                 <table class="table table-striped tabVarianti">
  893.                     <thead>
  894.                         <tr>
  895.                             <th></th>');
  896.                 foreach ($variabiliInColonna as $item) {
  897.                     $arrayDiVerificaEsistenza = array_merge($arrayDiVerificaEsistenza, array($item->codiceDimensione5));
  898.                     $html .= '<th>';
  899.                     if ($item->immagineDimensione5 != '') {
  900.                         $html .= ('<img src="' . $item->immagineDimensione5 . '" class="img img-responsive immagine-variante" /><br/>');
  901.                     }
  902.                     if ($item->descrizioneDimensione5 != '') {
  903.                         $html .= ('<span class="descrizione-variante-header">' . $item->descrizioneDimensione5 . '</span>');
  904.                     }
  905.                     $html .= '</th>';
  906.                 }
  907.                 $html .= ('             </tr>
  908.                     </thead>
  909.                     <tbody>');
  910.                 foreach (array_keys($visualizzazioneVarianti) as $key) {
  911.                     $html .= '<tr>';
  912.                     $listaVariabiliPresenti = $visualizzazioneVarianti[$key];
  913.                     $primaVariabileUtile = count($listaVariabiliPresenti) > 0 ? array_values($listaVariabiliPresenti)[0] : '';
  914.                     for ($i = 0; $i < count($variabiliInColonna); $i++) {
  915.                         $v = $variabiliInColonna[$i];
  916.                         if ($i == 0) { //Prima iterazione
  917.                             $html .= '<td class="td-stretto">';
  918.                             $img = $servizi->ottieniImmagineDaVariabileEsclusoLivello5($listaVariabiliPresenti[$v->codiceDimensione5]);
  919.                             if ($img != '') {
  920.                                 $html .= ('<img src="' . $img . '" class="img img-responsive immagine-variante" /><br />');
  921.                             }
  922.                             $html .= '<b>';
  923.                             $headerVariante = explode('/////', $key);
  924.                             for ($iv = 0; $iv < count($headerVariante); $iv++) {
  925.                                 $vrn = $headerVariante[$iv];
  926.                                 $html .= $vrn;
  927.                                 if ($iv != count($headerVariante) - 1)
  928.                                     $html .= '<br />';
  929.                             }
  930.                             $html .= '</b></td>';
  931.                         }
  932.                         //ALTRE ITERAZIONI CHE NON SONO LA PRIMA
  933.                         if (array_key_exists($v->codiceDimensione5, $listaVariabiliPresenti)) {
  934.                             /** @var Variante $varianteAtt */
  935.                             $varianteAtt = $listaVariabiliPresenti[$v->codiceDimensione5];
  936.                             $html .= ('<td class="cellaOrdinazioneArticolo">
  937.                                 <div class="input-group plus-minus-input form-inline" style="width: 100%;">
  938.                                     <div style="margin-left: 0;" class="input-group-button form-group">
  939.                                         <button type="button" class="button hollow circle" data-quantity="minus" data-field="form-ord_' . $varianteAtt->id . '">
  940.                                             <i class="fa fa-minus" aria-hidden="true"></i>
  941.                                         </button>
  942.                                     </div>
  943.                                     <input class="input-group-field qtaordinazione form-group" style="width: 55px;" type="number" name="form-ord_' . $varianteAtt->id . '" value="0">
  944.                                     <div style="margin-left: 0;"  class="input-group-button form-group">
  945.                                         <button type="button" class="button hollow circle" data-quantity="plus" data-field="form-ord_' . $varianteAtt->id . '">
  946.                                             <i class="fa fa-plus" aria-hidden="true"></i>
  947.                                         </button>
  948.                                     </div>
  949.                                 </div>
  950.                                 <div class="sezione-sotto-ordina">');
  951.                             if ($servizi->impostazioni->ritornaImpostazioneDaNome('MostraDisponibilitaShop') != "1") {
  952.                                 $html .= ('<span style="margin: 5px;" class="label label-primary">' . $mappaSelezionata->articolo->um->codice . '</span>');
  953.                             } else {
  954.                                 $numDecimali = 0;
  955.                                 $codiceUm = '';
  956.                                 if ($varianteAtt->mappa != null && $varianteAtt->mappa->articolo != null && $varianteAtt->mappa->articolo->um != null) {
  957.                                     $numDecimali = $varianteAtt->mappa->articolo->um->numeroDecimali;
  958.                                     $codiceUm = $varianteAtt->mappa->articolo->um->codice;
  959.                                 }
  960.                                 $disp = number_format($varianteAtt->disponibile, $numDecimali);
  961.                                 if ($disp > 0) {
  962.                                     $html .= ('<label style="margin: 5px;" class="label label-success">' . number_format($disp, $numDecimali, ',', '.') . ' ' . $codiceUm . '</label>');
  963.                                 } else {
  964.                                     $html .= ('<label style="margin: 5px;" class="label label-danger">' . $translating->OttieniElementoDizionario('home_shop_varianti_non_disponibile', 'home_shop')->valoreUscita . '</label>');
  965.                                 }
  966.                             }
  967.                             if ($varianteAtt->listino != null) {
  968.                                 if ($servizi->impostazioni->ritornaImpostazioneDaNome('MostraListinoScontiNettoVarianti') != "1") {
  969.                                     $html .= ('€ ' . number_format($varianteAtt->prezzoNettoCalcolato, $servizi->impostazioni->ritornaImpostazioneDaNome('NumeroDecimaliPrezzi'), '.', ','));
  970.                                 } else {
  971.                                     $html .= ('<br />
  972.                                         <div class="sezione-prezzo">
  973.                                             <span>' . (($varianteAtt->listino != null) ? ('€ ' . number_format($varianteAtt->listino->prezzo, $servizi->impostazioni->ritornaImpostazioneDaNome('NumeroDecimaliPrezzi'), '.', ',')) : '') . '</span>
  974.                                             <span>' . $servizi->ritornaStringaScontiPerVisualizzazione($varianteAtt->stringaSconti) . '</span>
  975.                                             <span style="font-weight: bold; color: red;">' . ('€ ' . number_format($varianteAtt->prezzoNettoCalcolato, $servizi->impostazioni->ritornaImpostazioneDaNome('NumeroDecimaliPrezzi'), '.', ',')) . '</span>
  976.                                         </div>');
  977.                                 }
  978.                             }
  979.                             $html .= '</div></td>';
  980.                         } else {
  981.                             $html .= '<td class="nonDisponibileClass"></td>';
  982.                         }
  983.                     }
  984.                     $html .= '</tr>';
  985.                 }
  986.             } else {
  987.                 //Se non c'è una variante
  988.             }
  989.             $html .= ('         </tbody>
  990.                 </table>
  991.                 <input type="submit" class="btn btn-success" style="float: right;" value="Aggiungi al carrello" />
  992.             </form>');
  993.             $ritornoHtml['html'] = $html;
  994.         }catch (\Throwable $ex){
  995.             $servizi->ScriviLogDebug($ex->getMessage() . "\n" . $ex->getTraceAsString());
  996.             $servizi->DebuggaException($ex, "Errore rendering template");
  997.         }
  998.         return $ritornoHtml;
  999.     }
  1000.     /**
  1001.      * @param $elementoTagCompleto
  1002.      * @param $valoriSupporto array
  1003.      * @param $servizi ServiziController
  1004.      * @param $locale string
  1005.      * @param $router Router
  1006.      * @param $translating Translating
  1007.      * @param $logger Logger
  1008.      * @param $twigAppArray array|null
  1009.      * @return array
  1010.      */
  1011.     public static function eseguiStrutturaMenuCategorieOrizzontaleDropdown($elementoTagCompleto, $valoriSupporto, PagineEComponenti $pagina, $servizi, $locale, Router $router, Translating $translating, $ritornoHtml = null, $logger = null, $twigAppArray = null)
  1012.     {
  1013.         if (!$ritornoHtml) {
  1014.             $ritornoHtml = array(
  1015.                 'html' => '',
  1016.                 'css' => ''
  1017.             );
  1018.         }
  1019.         //Array contentente tutti i collegamenti alle categorie parent
  1020.         $arrayCategorieParent = array_key_exists(Costanti::T_LISTA_CATEGORIE_CHIAVI_PARENT, $valoriSupporto) ?  $valoriSupporto[Costanti::T_LISTA_CATEGORIE_CHIAVI_PARENT] : array();
  1021.         //Estraiamo i dati per il layout
  1022.         $ritornoElemento = RitornoMenuOrizzontaleDropdown::OttieniDaElementoTag($elementoTagCompleto);
  1023.         $stringaHTML = '<nav class="' . $ritornoElemento->class . '" style="' . $ritornoElemento->style . 'width:100%;" ' . $ritornoElemento->RitornaStringaElementiBase() . '  >'
  1024.             . '<ul class="mf-gjs-dropdown nav-center">';
  1025.         //Qui devo generare tutte le voci di categorie
  1026.         if (!array_key_exists(Costanti::T_LISTA_CATEGORIE, $valoriSupporto)) {
  1027.             $ritornoHtml["html"] = $ritornoHtml["html"] . '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore Struttura menu categorie. Chiave layout: ' . Costanti::T_LISTA_CATEGORIE . ' non trovato in array</p>';
  1028.         } else {
  1029.             /** @var $arrayElementi AlberoCategorie[] */
  1030.             $arrayElementi = $valoriSupporto[Costanti::T_LISTA_CATEGORIE]; //lista di elementi database da iterare per comporre il layout
  1031.             //$logger->info("Elementi: " . count($arrayElementi));
  1032.             $rtt = "";
  1033.             //Iteriamo tra i primi alberi
  1034.             foreach($arrayElementi as $item){
  1035.                 $stringaHTML = $stringaHTML . Templating::stampaCategoriaOrizzontaleDropdown($item, $arrayCategorieParent, $ritornoElemento, $router, 0, 1);
  1036.             }
  1037.         }
  1038.         $stringaHTML .= '</ul></nav>';
  1039.         //Creo la stringa CSS per lo stile del menu
  1040.         $stringaCSS = '.mfs-gjs-dropbtn {' .
  1041.                         ($ritornoElemento->textBold ? 'font-weight: bold !important;' : '') .
  1042.                         ($ritornoElemento->textColor ? 'color: ' . $ritornoElemento->textColor . ' !important;' : '') . '
  1043.                         }
  1044.                         
  1045.                         .mfs-gjs-sub-dropbtn {' .
  1046.                         ($ritornoElemento->submenuTextBold ? 'font-weight: bold !important;' : '') .
  1047.                         ($ritornoElemento->submenuTextColor ? 'color: ' . $ritornoElemento->submenuTextColor . ' !important;' : '') . '
  1048.                         }
  1049.                         
  1050.                         .mfs-gjs-dropdown-content { ' .
  1051.                         ($ritornoElemento->submenuTextColor ? 'background: ' . $ritornoElemento->submenuTextColor . ' !important;' : '') . '
  1052.                         }';
  1053.         $ritornoHtml["html"] = $ritornoHtml["html"] . $stringaHTML;
  1054.         $ritornoHtml["css"] = $ritornoHtml["css"] . $stringaCSS;
  1055.         return $ritornoHtml;
  1056.     }
  1057.     /**
  1058.      * @param $albero AlberoCategorie
  1059.      * @param $arrayPathCategorie
  1060.      * @param $ritornoMenuOrizzontale RitornoMenuOrizzontaleDropdown
  1061.      * @return string
  1062.      */
  1063.     public static function stampaCategoriaOrizzontaleDropdown($albero, $arrayParent, $ritornoMenuOrizzontale, Router $router, $livello, $pagina, $arrayPathCategorie = array(), $htmlRitorno = ""){
  1064.         $ritorno = "";
  1065.         if($albero->livello == $livello) {
  1066.             $ritorno = $htmlRitorno;
  1067.             $arrayPathCategorie2 = array_merge(array('categoria_' . ($livello + 1) => str_replace('/', '£-£', $albero->categoria->nomeUnivoco)), $arrayPathCategorie);
  1068.             $arraySecondarioCompleto = array_merge(array('page' => $pagina), $arrayPathCategorie2);
  1069.             $testo = Templating::ritornaValoreDaPercorso($albero, $ritornoMenuOrizzontale->percorso, $ritornoMenuOrizzontale->nomeColonna);
  1070.             $ritorno = $ritorno . '<li>' .
  1071.                 '<a href="' . $router->generate('home_shop_comune_naviga', $arraySecondarioCompleto) . '" class="' . ($albero->hasChild && array_key_exists($albero->id, $arrayParent) ? 'nav-active' : '') . '">' . $testo . '</a>';
  1072.             //Verifico se ci sono figli da stampare
  1073.             if ($albero->hasChild && array_key_exists($albero->id, $arrayParent)) {
  1074.                 $ritorno = $ritorno . ' <ul> ';
  1075.                 /** @var AlberoCategorie $item */
  1076.                 foreach ($arrayParent[$albero->id] as $item) {
  1077.                     $ritorno .= Templating::stampaCategoriaOrizzontaleDropdown($item, $arrayParent, $ritornoMenuOrizzontale, $router, $livello + 1, $pagina, $arrayPathCategorie2, "");
  1078.                 }
  1079.                 $ritorno = $ritorno . '</ul>';
  1080.             }
  1081.             $ritorno = $ritorno . '</li>';
  1082.         }
  1083.         return $ritorno;
  1084.     }
  1085.     /**
  1086.      * @param $elementoTagCompleto
  1087.      * @param $valoriSupporto array
  1088.      * @param $servizi ServiziController
  1089.      * @param $locale string
  1090.      * @param $router Router
  1091.      * @param $translating Translating
  1092.      * @param $logger Logger|null
  1093.      * @param $twigAppArray array|null
  1094.      * @return array
  1095.      */
  1096.     public static function eseguiStrutturaMenuCategorie($elementoTagCompleto, $valoriSupporto, PagineEComponenti $pagina, $servizi, $locale, Router $router, Translating $translating, $ritornoHtml = null, $logger = null, $twigAppArray = null)
  1097.     {
  1098.         if (!$ritornoHtml) {
  1099.             $ritornoHtml = array(
  1100.                 'html' => '',
  1101.                 'css' => ''
  1102.             );
  1103.         }
  1104.         $elementoValoreDaUtilizzareComeBase = Costanti::T_LISTA_CATEGORIE;
  1105.         $livello1 = "";
  1106.         $livello2 = "";
  1107.         $livello3 = "";
  1108.         $livello4 = "";
  1109.         $livello5 = "";
  1110.         //substringo livello 1
  1111.         $sbs1 = SubstringWithFind::SubstringWithFind(
  1112.             '<TMPLT tp="SUB-MENU" livello="1" ',
  1113.             '</SUB-MENU>',
  1114.             $elementoTagCompleto);
  1115.         $livello1 = $sbs1->substring;
  1116.         //substringo livello 2
  1117.         $sbs2 = SubstringWithFind::SubstringWithFind(
  1118.             '<TMPLT tp="SUB-MENU" livello="2" ',
  1119.             '</SUB-MENU>',
  1120.             $elementoTagCompleto);
  1121.         $livello2 = $sbs2->substring;
  1122.         //substringo livello 3
  1123.         $sbs3 = SubstringWithFind::SubstringWithFind(
  1124.             '<TMPLT tp="SUB-MENU" livello="3" ',
  1125.             '</SUB-MENU>',
  1126.             $elementoTagCompleto);
  1127.         $livello3 = $sbs3->substring;
  1128.         //substringo livello 4
  1129.         $sbs4 = SubstringWithFind::SubstringWithFind(
  1130.             '<TMPLT tp="SUB-MENU" livello="4" ',
  1131.             '</SUB-MENU>',
  1132.             $elementoTagCompleto);
  1133.         $livello4 = $sbs4->substring;
  1134.         //substringo livello 5
  1135.         $sbs5 = SubstringWithFind::SubstringWithFind(
  1136.             '<TMPLT tp="SUB-MENU" livello="5" ',
  1137.             '</SUB-MENU>',
  1138.             $elementoTagCompleto);
  1139.         $livello5 = $sbs5->substring;
  1140.         $arrayTemplate = array(
  1141.             1 => $livello1,
  1142.             2 => $livello2,
  1143.             3 => $livello3,
  1144.             4 => $livello4,
  1145.             5 => $livello5
  1146.         );
  1147.         //$logger->debug('Livello1: ' . $livello1);
  1148.         //$logger->debug('Livello2: ' . $livello2);
  1149.         //$logger->debug('Livello3: ' . $livello3);
  1150.         //$logger->debug('Livello4: ' . $livello4);
  1151.         //$logger->debug('Livello5: ' . $livello5);
  1152.         $ritornoHtml['html'] =
  1153.             '<div class="nav-side-menu">
  1154.                 <i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i>
  1155.                 <div class="menu-list">
  1156.                     <ul id="menu-content" class="menu-content collapse out">';
  1157.             if (!array_key_exists($elementoValoreDaUtilizzareComeBase, $valoriSupporto)) {
  1158.                 $ritornoHtml["html"] = $ritornoHtml["html"] . '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore Struttura menu categorie. Chiave layout: ' . $elementoValoreDaUtilizzareComeBase . ' non trovato in array</p>';
  1159.             } else {
  1160.                 /** @var $arrayElementi AlberoCategorie[] */
  1161.                 $arrayElementi = $valoriSupporto[$elementoValoreDaUtilizzareComeBase]; //lista di elementi database da iterare per comporre il layout
  1162.                 //$logger->info("Elementi: " . count($arrayElementi));
  1163.                 $categoriePassate = array('', '', '', '', '');
  1164.                 if (array_key_exists('cat1', $valoriSupporto))
  1165.                     $categoriePassate[0] = $valoriSupporto['cat1'];
  1166.                 if (array_key_exists('cat2', $valoriSupporto))
  1167.                     $categoriePassate[1] = $valoriSupporto['cat2'];
  1168.                 if (array_key_exists('cat3', $valoriSupporto))
  1169.                     $categoriePassate[2] = $valoriSupporto['cat3'];
  1170.                 if (array_key_exists('cat4', $valoriSupporto))
  1171.                     $categoriePassate[3] = $valoriSupporto['cat4'];
  1172.                 if (array_key_exists('cat5', $valoriSupporto))
  1173.                     $categoriePassate[4] = $valoriSupporto['cat5'];
  1174.                 //$logger->debug('Categorie passate: ' . print_r($categoriePassate, true));
  1175.                 $primo = true;
  1176.                 foreach ($arrayElementi as $elemento) {
  1177.                     //$logger->debug('Elemento: ' . print_r($elemento, true));
  1178.                     if ($elemento->parent == null) {
  1179.                         $rtt = Templating::stampaMenuCategoria($elemento, $valoriSupporto[Costanti::T_LISTA_CATEGORIE_CHIAVI_PARENT], 1, array(), 1, $categoriePassate, $router, $arrayTemplate, $valoriSupporto, $pagina, $translating, $primo, $servizi, $ritornoHtml, $locale, $twigAppArray);
  1180.                         if ($primo) {
  1181.                             $ritornoHtml['css'] = $ritornoHtml['css'] . $rtt['css'];
  1182.                             $primo = false;
  1183.                         }
  1184.                         $ritornoHtml['html'] = $ritornoHtml['html'] . $rtt['html'];
  1185.                     }
  1186.                 }
  1187.             }
  1188.         /*} catch (\Exception $ex) {
  1189.             $servizi->DebuggaException($ex);
  1190.         }*/
  1191.         $ritornoHtml['html'] = $ritornoHtml['html'] .
  1192.             '        </ul>
  1193.                  </div>
  1194.             </div>';
  1195.         //$logger->debug('Ritorno finale HTML: ' . print_r($ritornoHtml, true));
  1196.         return $ritornoHtml;
  1197.     }
  1198.     public static function convertiInput($elementoTagCompleto, $valoriSupporto, ServiziController $serviziController, $locale, Router $router, Translating $translating, $ritornoHtml = null, LoggerInterface $logger = null){
  1199.         if (!$ritornoHtml){
  1200.             $ritornoHtml = '';
  1201.         }
  1202.     }
  1203.     public static function eseguiStrutturaVistaAttributi($elementoTagCompleto, $valoriSupporto, $servizi, $locale, Router $router, Translating $translating, $ritornoHtml = null, LoggerInterface $logger = null)
  1204.     {
  1205.         if (!$ritornoHtml) {
  1206.             $ritornoHtml = array(
  1207.                 'html' => '',
  1208.                 'css' => ''
  1209.             );
  1210.         }
  1211.         $sbsInizio = SubstringWithFind::SubstringWithFind(
  1212.             "<TMPLT ",
  1213.             ">",
  1214.             $elementoTagCompleto
  1215.         );
  1216.         $elementiBase = RitornoElementiBase::OttieniDaElementoTag($sbsInizio->substring);
  1217.         $elementoValoreDaUtilizzareComeBase = Costanti::T_ATTRIBUTI;
  1218.         $tagTitoloElaborato = GestioneTagHTML::ElaboraTagHTML($elementoTagCompleto, 'div', '', '', $logger);
  1219.         $tagInputElaborato = RitornoDaInput::OttieniDaElementoTag($elementoTagCompleto);
  1220.         //Tag button da inserire dopo il render delle righe degli attributi
  1221.         $tagDivButtonFiltra = GestioneTagHTML::ElaboraTagHTML($elementoTagCompleto, 'TMPLT', '', '<div tp="filtra-btn"', $logger);
  1222.         $tagButtonFiltra = GestioneTagHTML::ElaboraTagHTML($tagDivButtonFiltra->contenuto, 'TMPLT', '/', '', $logger);
  1223.         $stringaComposta = '';
  1224.         /** @var AssociazioneAttributi[] $listaAssociazioneAttributi */
  1225.         $listaAssociazioneAttributi = $valoriSupporto[$elementoValoreDaUtilizzareComeBase];
  1226.         if ($listaAssociazioneAttributi && count($listaAssociazioneAttributi) > 0) {
  1227.             $actionForm = $router->generate('home_shop_comune_naviga', $valoriSupporto);
  1228.             $stringaComposta .= '<form action="' . $actionForm . '" >';
  1229.             $stringaComposta .= '<div ';
  1230.             if ($elementiBase->id != '')
  1231.                 $stringaComposta .= 'id="' . $elementiBase->id . '" ';
  1232.             if ($elementiBase->class != '')
  1233.                 $stringaComposta .= 'class="' . $elementiBase->class . '" ';
  1234.             if ($elementiBase->style != '')
  1235.                 $stringaComposta .= 'style="' . $elementiBase->style . '" ';
  1236.             $stringaComposta .= '>';
  1237.             $stringaElementiBaseInput = $tagInputElaborato->elementiBase->RitornaStringaElementiBase();
  1238.             foreach ($listaAssociazioneAttributi as $ass) {
  1239.                 //ottento il titolo attributo da mostrare
  1240.                 $logger->debug('Associazione: ' . var_export($ass, true));
  1241.                 if ($ass->attributo && $ass->attributo->attributoInLingua && $ass->attributo->attributoInLingua->testoVisualizzato){
  1242.                     $stringaComposta .= $tagTitoloElaborato->RitornaStringaHTMLModificandoIlContenuto($ass->attributo->attributoInLingua->testoVisualizzato);
  1243.                 }
  1244.                 //Scrivo l'input
  1245.                 $stringaComposta .= '<input ' . $stringaElementiBaseInput . ' ';
  1246.                 $valorePlaceholder = '';
  1247.                 if ($tagInputElaborato->placeholderDb != '' && $tagInputElaborato->placeholderDb){
  1248.                     $json = json_decode($tagInputElaborato->placeholderDb, true);
  1249.                     $percorso = $json["percorso"] != '' ? explode(",", $json["percorso"]) : array();
  1250.                     $valorePlaceholder = Templating::ritornaValoreDaPercorso($ass, $percorso, $json["nomeColonna"], null);
  1251.                 }else if ($tagInputElaborato->placeholderDiz != '' && $tagInputElaborato->placeholderDiz){
  1252.                     $json = json_decode($tagInputElaborato->placeholderDiz, true);
  1253.                     $valorePlaceholder = $translating->OttieniElementoDizionario($json["identificativo"], $json["famiglia"])->valoreUscita;
  1254.                 }
  1255.                 if ($valorePlaceholder != '')
  1256.                     $stringaComposta .= 'placeholder="' . $valorePlaceholder . '" ';
  1257.                 $valoreTitle = '';
  1258.                 if ($tagInputElaborato->titleDb != '' && $tagInputElaborato->titleDb){
  1259.                     $json = json_decode($tagInputElaborato->titleDb, true);
  1260.                     $percorso = $json["percorso"] != '' ? explode(",", $json["percorso"]) : array();
  1261.                     $valoreTitle = Templating::ritornaValoreDaPercorso($ass, $percorso, $json["nomeColonna"], null);
  1262.                 }else if ($tagInputElaborato->titleDiz != '' && $tagInputElaborato->titleDiz){
  1263.                     $json = json_decode($tagInputElaborato->titleDiz, true);
  1264.                     $valoreTitle = $translating->OttieniElementoDizionario($json["identificativo"], $json["famiglia"])->valoreUscita;
  1265.                 }
  1266.                 if ($valoreTitle != '')
  1267.                     $stringaComposta .= 'title="' . $valoreTitle . '" ';
  1268.                 //chiudo tag input
  1269.                 $stringaComposta .= ' name="' . $ass->attributo->attributoInLingua->testoVisualizzato . '" />';
  1270.             }
  1271.             //Renderizzo il div che contiene il button di submit
  1272.             $stringaComposta .=  str_replace('tp="filtra-btn"', '', $tagDivButtonFiltra->tagApertura);
  1273.             //<TMPLT tp="BUTTON" id="ioodi" class="" style="" linkautomatico="" clic-link="" testo="Filtra" identificativo="" famiglia="" />
  1274.             $stringaComposta .= '<button type="submit" ' . $tagButtonFiltra->ritornoBase->RitornaStringaElementiBase() . '>';
  1275.             $testo = EstraiElementoDaStringa::Estrai($tagButtonFiltra->tagApertura, ' testo="')->elementoEstratto;
  1276.             $identificativo = EstraiElementoDaStringa::Estrai($tagButtonFiltra->tagApertura, ' identificativo="')->elementoEstratto;
  1277.             $famiglia = EstraiElementoDaStringa::Estrai($tagButtonFiltra->tagApertura, ' famiglia="')->elementoEstratto;
  1278.             if ($identificativo != '' && $famiglia != ''){
  1279.                 $valoreDizionario = $translating->OttieniElementoDizionario($identificativo, $famiglia)->valoreUscita;
  1280.                 $stringaComposta .= $valoreDizionario;
  1281.             }else{
  1282.                 $stringaComposta .= $testo;
  1283.             }
  1284.             $stringaComposta .= '</button>';
  1285.             $stringaComposta .= $tagDivButtonFiltra->tagChiusura;
  1286.             $stringaComposta .= '</div></form>';
  1287.         }
  1288.         $ritornoHtml['html'] = $stringaComposta;
  1289.         return $ritornoHtml;
  1290.     }
  1291.     static function stampaMenuCategoria($alberoParent, $listaChiaviParent, $livello, $arrayPathCategorie, $pagina, $categoriePassate, Router $router, $arrayTemplate, $valoriSupporto, PagineEComponenti $paginaEComponente, Translating $translating, $primaIterazione, ServiziController $serviziController, $ritorno, $locale = 'it', $twigAppArray = null){
  1292.         if (!$ritorno) {
  1293.             $ritorno = array(
  1294.                 'html' => '',
  1295.                 'css' => ''
  1296.             );
  1297.         }
  1298.         $htmlRitorno = '';
  1299.         $valoriSupportoModificati = null;
  1300.         $valoriSupportoModificati = $valoriSupporto;
  1301.         $valoriSupportoModificati[Costanti::T_LISTA_CATEGORIE] = $alberoParent;
  1302.         //========================================== LAYOUT INTERNO AL LINK ============================================================
  1303.         //Rimuovo la parte del sub menu superflua
  1304.         $substring = SubstringWithFind::SubstringWithFind(
  1305.             '<TMPLT tp="SUB-MENU" livello="' . $livello . '" component-id="">',
  1306.             '</SUB-MENU>',
  1307.             $arrayTemplate[$livello],
  1308.             0,
  1309.             true
  1310.         );
  1311.         $contenuto = Templating::convertiLayoutStrutturaCategoria($substring->substring, $alberoParent, null, $valoriSupportoModificati, $paginaEComponente, $translating, $serviziController, $locale, $twigAppArray);
  1312.         //==============================================================================================================================
  1313.         if ($primaIterazione){
  1314.             $ritorno['css'] = $contenuto['css'];
  1315.         }
  1316.         /** @var AlberoCategorie $alberoParent */
  1317.         $htmlRitorno = '';
  1318.         $identSez = 'menu' . $alberoParent->categoria->nomeUnivoco;
  1319.         $htmlRitorno .= '<li ' . ($alberoParent->hasChild ? 'data-toggle="collapse" data-target="#' . $identSez . '" class="collapsed"' : '') . '>';
  1320.         $arrayPathCategorie2 = array_merge(array('categoria_' . $livello => str_replace('/', '£-£', $alberoParent->categoria->nomeUnivoco)), $arrayPathCategorie);
  1321.         $arraySecondarioCompleto = array_merge(array('page' => $pagina), $arrayPathCategorie2);
  1322.         $htmlRitorno .= '<a title="' . $alberoParent->categoria->categoriaInLingua->nome . '" href="' . $router->generate('home_shop_comune_naviga', $arraySecondarioCompleto) . '">' . $contenuto['html'] . '</a>';
  1323.         $htmlRitorno .= '</li>';
  1324.         if ($alberoParent->hasChild && array_key_exists($alberoParent->id, $listaChiaviParent)){
  1325.             $collapse = 'collapse';
  1326.             if ($categoriePassate[$livello - 1] == $alberoParent->categoria->nomeUnivoco)
  1327.                 $collapse = '';
  1328.             $htmlRitorno .= '<ul class="sub-menu ' . $collapse . '" id="' . $identSez . '" >';
  1329.             foreach($listaChiaviParent[$alberoParent->id] as $item){
  1330.                 $rtt = self::stampaMenuCategoria($item, $listaChiaviParent, $livello + 1, $arrayPathCategorie2, $pagina, $categoriePassate, $router, $arrayTemplate, $valoriSupporto, $paginaEComponente, $translating, $primaIterazione, $serviziController, $ritorno, $locale);
  1331.                 $htmlRitorno .= $rtt['html'];
  1332.                 $ritorno['css'] = $ritorno['css'] . $rtt['css'];
  1333.             }
  1334.             $htmlRitorno .= '</ul>';
  1335.         }
  1336.         $ritorno['html'] = $htmlRitorno;
  1337.         return $ritorno;
  1338.     }
  1339.     /**
  1340.      * @param $ritornoConvertDb RitornoDatoDb
  1341.      * @param ServiziController $serviziController
  1342.      * @return string
  1343.      */
  1344.     public static function ritornaValoreDatoDbSpeciale($ritornoConvertDb, ServiziController $serviziController, $valoreRiferimento){
  1345.         $ritorno = '';
  1346.         switch ($ritornoConvertDb->datoSpeciale){
  1347.             case 'risaliImgCategorie':{
  1348.                 if ($valoreRiferimento instanceof AlberoMenuProdotti || $valoreRiferimento instanceof AlberoCategorie){
  1349.                     $ritorno  = $serviziController->saliAlberoPerImmagine($valoreRiferimento);
  1350.                 } else if ($valoreRiferimento instanceof  MappaCategoriaArticolo){
  1351.                     $ritorno = $serviziController->ottieniImmagineDaMappaCategoriaArticolo($valoreRiferimento);
  1352.                 } else if ($valoreRiferimento instanceof Variante){
  1353.                     $ritorno = $serviziController->ottieniImmagineDaVariabileEsclusoLivello5($valoreRiferimento);
  1354.                 } else if ($valoreRiferimento instanceof RigaCarrello) {
  1355.                     $ritorno = $serviziController->ottieniImmagineDaMappaCategoriaArticolo($valoreRiferimento->mappaCategoriaArticolo);
  1356.                 } else{
  1357.                     $ritorno = '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB conversione dato speciale. Type valore riferimento: ' . get_class($valoreRiferimento) . ' non mappata</p>';
  1358.                 }
  1359.                 break;
  1360.             }
  1361.             case 'prezzoBarratoSeScontato':{
  1362.                 if($valoreRiferimento instanceof  MappaCategoriaArticolo){
  1363.                     /** @var $valoreRiferimento MappaCategoriaArticolo */
  1364.                     if($valoreRiferimento->valoriCalcolati && $valoreRiferimento->valoriCalcolati->scontisticaPresente){
  1365.                         //In questo caso devo barrare il prezzo
  1366.                         $prezzoLordo = $valoreRiferimento->valoriCalcolati->primoListino;
  1367.                         if ($ritornoConvertDb && $ritornoConvertDb->tipoDato == 'double') {
  1368.                             $numDec = $ritornoConvertDb->numeroDecimali != '' ? $ritornoConvertDb->numeroDecimali : '0';
  1369.                             $sepDec = $ritornoConvertDb->separatoreDecimali != '' ? $ritornoConvertDb->separatoreDecimali : '.';
  1370.                             $sepMigl = $ritornoConvertDb->separatoreMigliaia != '' ? $ritornoConvertDb->separatoreMigliaia : ',';
  1371.                             $prezzoLordo = number_format($prezzoLordo, $numDec, $sepDec, $sepMigl);
  1372.                         }
  1373.                         $ritorno = ('<span style="text-decoration: line-through;">€ ' . $prezzoLordo . '</span><br/>');
  1374.                         $prezzoNetto = $valoreRiferimento->valoriCalcolati->prezzoNettoCalcolato;
  1375.                         if ($ritornoConvertDb && $ritornoConvertDb->tipoDato == 'double') {
  1376.                             $numDec = $ritornoConvertDb->numeroDecimali != '' ? $ritornoConvertDb->numeroDecimali : '0';
  1377.                             $sepDec = $ritornoConvertDb->separatoreDecimali != '' ? $ritornoConvertDb->separatoreDecimali : '.';
  1378.                             $sepMigl = $ritornoConvertDb->separatoreMigliaia != '' ? $ritornoConvertDb->separatoreMigliaia : ',';
  1379.                             $prezzoNetto = number_format($prezzoNetto, $numDec, $sepDec, $sepMigl);
  1380.                         }
  1381.                         $ritorno .= ('<span>€ ' . $prezzoNetto . '</span>');
  1382.                     }else{
  1383.                         $ritorno = $valoreRiferimento->valoriCalcolati->prezzoNettoCalcolato;
  1384.                         if ($ritornoConvertDb && $ritornoConvertDb->tipoDato == 'double') {
  1385.                             $numDec = $ritornoConvertDb->numeroDecimali != '' ? $ritornoConvertDb->numeroDecimali : '0';
  1386.                             $sepDec = $ritornoConvertDb->separatoreDecimali != '' ? $ritornoConvertDb->separatoreDecimali : '.';
  1387.                             $sepMigl = $ritornoConvertDb->separatoreMigliaia != '' ? $ritornoConvertDb->separatoreMigliaia : ',';
  1388.                             $ritorno = number_format($ritorno, $numDec, $sepDec, $sepMigl);
  1389.                         }
  1390.                     }
  1391.                 }
  1392.                 break;
  1393.             }
  1394.             default:{
  1395.                 $ritorno = '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB conversione dato speciale. Valore dato speciale: ' . $ritornoConvertDb->datoSpeciale . ' non gestito</p>';
  1396.                 break;
  1397.             }
  1398.         }
  1399.         return $ritorno;
  1400.     }
  1401.     /**
  1402.      * @param $html
  1403.      * @param $alberoParent AlberoMenuProdotti
  1404.      * @param $ritorno
  1405.      * @param $valoriSupporto
  1406.      * @param Translating $translating
  1407.      * @param string $locale
  1408.      * @param array|null $twigAppArray
  1409.      * @return array
  1410.      */
  1411.     static function convertiLayoutStrutturaCategoria($html, $alberoParent, $ritorno, $valoriSupporto, PagineEComponenti $pagina, Translating $translating, ServiziController $serviziController, $ordineCasuale = false, $locale = 'it', $twigAppArray = null){
  1412.         if (!$ritorno){
  1413.             $ritorno = array(
  1414.                 'html' => '',
  1415.                 'css' => ''
  1416.             );
  1417.         }
  1418.         $ritorno['html'] = $html;
  1419.         while(strpos($ritorno["html"], "<TMPLT ") !== false) {
  1420.             //se trovo l'elemento TMPLT effettuo l'azione in base al tp
  1421.             //substringo l'intero tag
  1422.             $sbs1 = SubstringWithFind::SubstringWithFind(
  1423.                 '<TMPLT ',
  1424.                 '/>',
  1425.                 $ritorno['html']);
  1426.             $elementoTagCompleto = $sbs1->substring;
  1427.             //ottengo il tp
  1428.             $sbTipo = SubstringWithFind::SubstringWithFind(
  1429.                 'tp="',
  1430.                 '"',
  1431.                 $elementoTagCompleto,
  1432.                 0,
  1433.                 true
  1434.             );
  1435.             $tipo = $sbTipo->substring;
  1436.             switch ($tipo) {
  1437.                 case "DATO-DB":
  1438.                     {
  1439.                         $ritornoConvertDb = Templating::ConvertiStringaDatoDb($elementoTagCompleto);
  1440.                         $valoreSostituito = "";
  1441.                         $chiaveRighe = Costanti::T_LISTA_CATEGORIE;
  1442.                         if (array_key_exists($chiaveRighe, $valoriSupporto)) {
  1443.                             $valoreSostituito = '';
  1444.                             if ($ritornoConvertDb->datoSpeciale != '' && $ritornoConvertDb->datoSpeciale == 'risaliImgCategorie') {
  1445.                                 $valoreSostituito = Templating::ritornaValoreDatoDbSpeciale($ritornoConvertDb, $serviziController, $valoriSupporto[$chiaveRighe]);
  1446.                             } else {
  1447.                                 $serviziController->ScriviLogDebug(print_r($valoriSupporto[$chiaveRighe], true));
  1448.                                 $valoreSostituito = Templating::ritornaValoreDaPercorso($valoriSupporto[$chiaveRighe], $ritornoConvertDb->percorso, $ritornoConvertDb->nomeColonna, $ritornoConvertDb);
  1449.                             }
  1450.                             if ($valoreSostituito != '' && $valoreSostituito) {
  1451.                                 if ($ritornoConvertDb->immagine) {
  1452.                                     if ($serviziController->imageNotFound == null){
  1453.                                         $serviziController->imageNotFound = $serviziController->impostazioni->ritornaImpostazioneDaNome('ImmagineNonPresenteProdotto');
  1454.                                     }
  1455.                                     $valoreSostituito = '<img src="' . ($valoreSostituito != '' ? $valoreSostituito : $serviziController->imageNotFound ) . '" class="' . $ritornoConvertDb->class . '" id="' . $ritornoConvertDb->id . '" />';
  1456.                                 }
  1457.                                 $valoreSostituito = '<span style="' . $ritornoConvertDb->style . '" class="' . $ritornoConvertDb->class . '" id="' . $ritornoConvertDb->id . '">' . $valoreSostituito . '</span>';
  1458.                                 $ritorno['html'] = str_replace($elementoTagCompleto, $valoreSostituito, $ritorno['html']);
  1459.                             } else {
  1460.                                 $ritorno['html'] = str_replace($elementoTagCompleto, 'Errore! Dato database non trovato!', $ritorno['html']);
  1461.                             }
  1462.                         } else {
  1463.                             $ritorno['html'] = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB in struttura categoria. Chiave righe: ' . $chiaveRighe . ' non trovata</p>', $ritorno['html']);
  1464.                         }
  1465.                         break;
  1466.                     }
  1467.                 case "ELEMENTO-DIZIONARIO":
  1468.                     {
  1469.                         $ritornoDizionario = Templating\RitornoElementoDizionario::OttieniDaElementoTag($elementoTagCompleto);
  1470.                         $traduzione = $translating->OttieniElementoDizionario($ritornoDizionario->identificativo, $ritornoDizionario->famiglia);
  1471.                         $ritornoElementiBase = Templating\RitornoElementiBase::OttieniDaElementoTag($elementoTagCompleto);
  1472.                         if ($traduzione){
  1473.                             if ($ritornoDizionario->link != '' || $ritornoDizionario->linkAutomatico != ''){
  1474.                                 $link = $ritornoDizionario->link;
  1475.                                 if ($ritornoDizionario->linkAutomatico != ''){
  1476.                                     $link = Templating::creaLinkAutomatico($ritornoDizionario->linkAutomatico, $serviziController->router, $valoriSupporto, $pagina, $ordineCasuale, $serviziController->logger, $serviziController);
  1477.                                 }
  1478.                                 $valFinale = '<a ' . $ritornoElementiBase->RitornaStringaElementiBase() . ' title="' . $traduzione->valoreUscita . '" href="' . $link . '" >' . $traduzione->valoreUscita . '</a>';
  1479.                             }else{
  1480.                                 $valFinale = '<span ' . $ritornoElementiBase->RitornaStringaElementiBase() . '>' . $traduzione->valoreUscita . '</span>';
  1481.                             }
  1482.                             $ritorno['html'] = str_replace($elementoTagCompleto, $valFinale, $ritorno['html']);
  1483.                         }else{
  1484.                             $ritorno['html'] = str_replace($elementoTagCompleto, '<p style="color: red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore! Identificativo o famiglia non trovato!</p>', $ritorno['html']);
  1485.                         }
  1486.                         break;
  1487.                     }
  1488.                 case "SUB-MENU":{
  1489.                     break;
  1490.                 }
  1491.                 case "DIV-CLICCABILE":{
  1492.                     $sbs1 = SubstringWithFind::SubstringWithFind(
  1493.                         '<TMPLT ',
  1494.                         '<TMPLT DIV-CLICCABILE />',
  1495.                         $ritorno['html']);
  1496.                     $elementoNuovo = $sbs1->substring;
  1497.                     $sbsTestata = SubstringWithFind::SubstringWithFind(
  1498.                         '<TMPLT ',
  1499.                         '>',
  1500.                         $elementoNuovo
  1501.                     );
  1502.                     //$this->logger->debug('Sbs testata: ' . $sbsTestata->substring);
  1503.                     $stringaSostituireTestata = Templating::convertiTestataDivSecondario($sbsTestata->substring, $serviziController, $serviziController->router, $valoriSupporto, $serviziController->logger, $ordineCasuale);
  1504.                     //$this->logger->debug('Stringa sostituire testat: ' . $stringaSostituireTestata);
  1505.                     $elementoNuovo = str_replace($sbsTestata->substring, $stringaSostituireTestata, $elementoNuovo);
  1506.                     $elementoNuovo = str_replace('<TMPLT DIV-CLICCABILE />', '</a>', $elementoNuovo);
  1507.                     $ritorno['html'] = str_replace($sbs1->substring, $elementoNuovo, $ritorno['html']);
  1508.                     break;
  1509.                 }
  1510.                 case "BUTTON":{
  1511.                     $ritornoButton = RitornoButton::RitonaDaTagCompleto($elementoTagCompleto);
  1512.                     $valoreLink = $ritornoButton->clicLink;
  1513.                     if ($ritornoButton->linkAutomatico != ''){
  1514.                         $valoreLink = Templating::creaLinkAutomatico($ritornoButton->linkAutomatico, $serviziController->router, $valoriSupporto, $pagina, $ordineCasuale, $serviziController->logger, $serviziController);
  1515.                     }
  1516.                     $testo = $ritornoButton->testo;
  1517.                     if ($ritornoButton->identificativo != ''){
  1518.                         $trad = $serviziController->translating->OttieniElementoDizionario($ritornoButton->identificativo, $ritornoButton->famiglia);
  1519.                         $testo = $trad->valoreUscita;
  1520.                     }
  1521.                     $stringaSostituzione = '<button href="' . $valoreLink . '" id="' . $ritornoButton->id . '" class="' . $ritornoButton->class . '" style="' . $ritornoButton->style . '">' . $testo . '</button>';
  1522.                     $ritorno['html'] = str_replace($elementoTagCompleto, $stringaSostituzione, $ritorno['html']);
  1523.                     break;
  1524.                 }
  1525.                 default:{
  1526.                     $ritorno['html'] = str_replace($elementoTagCompleto, '<p style="color: red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore convertiLayoutStrutturaCategoria! Tipo non gestito:' . $tipo . '</p>', $ritorno['html']);
  1527.                     break;
  1528.                 }
  1529.             }
  1530.         }
  1531.         return $ritorno;
  1532.     }
  1533.     /**
  1534.      * @param $array
  1535.      * @param array $valori //è il percorso con i vari step per entrare in dettaglio nell'array ($array)
  1536.      * @param string $colonnaDaPrendere
  1537.      * @param RitornoDatoDb $ritornoDatoDb //Se Ã¨ null non effettuo il check sul tipo di dato
  1538.      * @return mixed
  1539.      */
  1540.     public static function ritornaValoreDaPercorso($array, $valori = array(), $colonnaDaPrendere = "", RitornoDatoDb $ritornoDatoDb = null){
  1541.         if (count($valori) > 0 && $array != null){
  1542.             $array2 = (is_array($array) ? $array : get_object_vars($array))[array_shift($valori)];
  1543.             return Templating::ritornaValoreDaPercorso($array2, $valori, $colonnaDaPrendere, $ritornoDatoDb);
  1544.         }else{
  1545.             $valore = '';
  1546.             if ($array != null && array_key_exists($colonnaDaPrendere, (is_array($array) ? $array : get_object_vars($array)))) {
  1547.                 $valore = (is_array($array) ? $array : get_object_vars($array))[$colonnaDaPrendere];
  1548.                 if ($ritornoDatoDb && $ritornoDatoDb->tipoDato == 'double') {
  1549.                     $numDec = $ritornoDatoDb->numeroDecimali != '' ? $ritornoDatoDb->numeroDecimali : '0';
  1550.                     $sepDec = $ritornoDatoDb->separatoreDecimali != '' ? $ritornoDatoDb->separatoreDecimali : '.';
  1551.                     $sepMigl = $ritornoDatoDb->separatoreMigliaia != '' ? $ritornoDatoDb->separatoreMigliaia : ',';
  1552.                     $valore = number_format($valore, $numDec, $sepDec, $sepMigl);
  1553.                 }
  1554.             }
  1555.             return $valore;
  1556.         }
  1557.     }
  1558.     /**
  1559.      * @param $elemento
  1560.      * @param $ritornoElementiBase RitornoElementiBase
  1561.      * @return string
  1562.      */
  1563.     public static function ritornaSelectTipologiePreimpostate($elemento, RitornoElementiBase $ritornoElementiBase, ServiziController $servizi){
  1564.         $stringaSelect = '';
  1565.         /** @var $elemento MappaCategoriaArticolo */
  1566.         if ($elemento instanceof MappaCategoriaArticolo){
  1567.             if ($elemento->articolo && $elemento->articolo->usaTipologiePreimpostate && $elemento->articolo->tipologiaPreimpostata && $elemento->articolo->tipologiaPreimpostata->liste && count($elemento->articolo->tipologiaPreimpostata->liste) > 0){
  1568.                 $stringaSelect = '<select ' . $ritornoElementiBase->RitornaStringaElementiBase() . ' >';
  1569.                 /** @var TipologiaPreimpostataLista $itm */
  1570.                 foreach ($elemento->articolo->tipologiaPreimpostata->liste as $itm){
  1571.                     $servizi->impostazioni->caricaCacheImpostazioniDaNomi(array('MostraDisponibilitaShop', 'NascondiPrezziShop', ''));
  1572.                     $mostraDisponibilita = $servizi->impostazioni->ritornaImpostazioneDaNome('MostraDisponibilitaShop');
  1573.                     $nascondiPrezzi = $servizi->impostazioni->ritornaImpostazioneDaNome('NascondiPrezziShop');
  1574.                     $stringaPrezzo = '';
  1575.                     $stringaDisponibile = '';
  1576.                     $nettoCad = 0;
  1577.                     if (!$nascondiPrezzi) {
  1578.                         /** @var $ritornoNettoCad RitornoCalcoloPrezzoNetto */
  1579.                         $ritornoNettoCad = $servizi->calcolaPrezzoNettoMappaOVariante($elemento);
  1580.                         $nettoCad = $ritornoNettoCad->prezzoNetto * $itm->fattoreMoltiplicazione;
  1581.                         $stringaPrezzo = ' -- â‚¬ ' . str_replace('.', ',', $nettoCad);
  1582.                     }
  1583.                     $disponibile = 0;
  1584.                     if ($mostraDisponibilita) {
  1585.                         /** @var RitornoCalcoloDisponibile $ritornoDisponibile */
  1586.                         $ritornoDisponibile = $servizi->calcolaDisponibileMappaOVariante($elemento, $servizi->impostazioni);
  1587.                         $disponibile = floor($ritornoDisponibile->disponibileFinale / $itm->fattoreMoltiplicazione);
  1588.                         $stringaDisponibile = ' -- ' . $servizi->translating->OttieniElementoDizionario('home_shop_disponibile_select_tipologie_preimpostate', 'home_shop')->valoreUscita . ' ' . str_replace('.',',', $disponibile);
  1589.                     }
  1590.                     $stringaSelect .= '<option value="' . $itm->id . '">' . $itm->nomeVisualizzato . $stringaDisponibile . $stringaPrezzo . '</option>';
  1591.                 }
  1592.                 $stringaSelect .= '</select>';
  1593.             }
  1594.         }else{
  1595.         }
  1596.         return $stringaSelect;
  1597.     }
  1598.     /**
  1599.      * @param $entita //Entità database dove iniziare il percorso di decodifica
  1600.      * @param $percorso //Stringa contenente il percorso per la decodica con in fondo il nome della colonna finale attributi.attributiInLingua.testoVisualizzato
  1601.      * @return mixed
  1602.      */
  1603.     public static function ritornaValoreDaPercorsoValoriSpeciali($entita, $percorso){
  1604.         $arrayPercorso = explode(".", $percorso);
  1605.         $colonnaDaPrendere = array_pop($arrayPercorso); //Elimino l'ultimo e lo salvo nella colonna da prendere
  1606.         $ritornoDatoDb = new RitornoDatoDb();
  1607.         $ritornoDatoDb->percorso = $percorso;
  1608.         return self::ritornaValoreDaPercorso($entita, $arrayPercorso, $colonnaDaPrendere, $ritornoDatoDb);
  1609.     }
  1610.     /** @return array */
  1611.     public static function PagineEComponentiRitornaTipiPagina(){
  1612.         return array(
  1613.             "Pagina standard" => 'paginaStandard',
  1614.             "Pagina carrello" => 'paginaCarrello',
  1615.             "Pagina finalizza carrello" => 'paginaFinalizzaCarrello',
  1616.             "Pagina homeshop" => 'paginaHomeShop',
  1617.             "Pagina dettaglio articolo" => "paginaDettaglioArticolo",
  1618.             "Pagina dettaglio ordine" => "paginaDettaglioOrdine",
  1619.             "Pagina gestione utente" => "paginaGestioneUtente",
  1620.             "Componente -> carrello" => "componenteCarrello",
  1621.             "Componente -> alberoCategorie" => "componenteAlberoCategorie",
  1622.             "Componente -> ordine" => "componenteOrdine",
  1623.             "Componente -> utente" => "componenteUtente",
  1624.             "Componente -> attributo articolo" => "componenteAttributoArticolo",
  1625.             "Riga -> carrello" => "rigaCarrello",
  1626.             "Riga -> ordine" => "rigaOrdine",
  1627.             "Riga -> homeShop" => "rigaHomeShop",
  1628.             "Riga -> magazzino secondario" => "rigaMagazzinoSecondario",
  1629.             "Mail standard" => 'mailStandard',
  1630.             "Mail nuovo ordine" => 'mailNuovoOrdine',
  1631.             "Mail ordine esportato" => 'mailOrdineEsportato',
  1632.             "Mail ordine pagamento registrato" => "mailOrdinePagamentoRegistrato",
  1633.             "Mail utente nuovo inserimento" => 'mailUtenteNuovoInserimento',
  1634.             "Mail utente cambio mail" => "mailUtenteCambioMail",
  1635.             "Mail utente cambio password" => "mailUtenteCambioPassword",
  1636.             "Mail cambio stato pagamento" => 'mailCambioStatoPagamento',
  1637.             "Mail invio contatto offerta" => 'mailInvioContattoOfferta',
  1638.             "Modal richiesta prezzo" => 'modalRichiestaPrezzo',
  1639.             "Modal conferma ordinazione magazzini secondari" => 'modalOrdinazioneMagazziniSecondari'
  1640.         );
  1641.     }
  1642.     /**
  1643.      * @return array
  1644.      */
  1645.     public static function RitornaTipiPaginaPerMetaTag(){
  1646.         return array(
  1647.             "Homeshop" => 'homeshop',
  1648.             "Dettaglio articolo" => 'dettaglioArticolo',
  1649.             "" => ''
  1650.         );
  1651.     }
  1652.     /**
  1653.      * @param $route
  1654.      * @param $variabiliTemplate
  1655.      * @param ManagerRegistry $doctrine
  1656.      * @param ServiziController $serviziController
  1657.      * @param null $idPagina
  1658.      * @return string
  1659.      */
  1660.     public static function ritornaMetaTagsRoute($route, $variabiliTemplate, ManagerRegistry $doctrine, ServiziController $serviziController, $idPagina = null){
  1661.         $ritorno = '';
  1662.         $pagina = null;
  1663.         if ($idPagina != ''){
  1664.             $pagina = $doctrine->getRepository(PagineEComponenti::class)->find($idPagina);
  1665.         }
  1666.         $tipoRiferimento = '';
  1667.         switch (strtolower($route)){
  1668.             case "home_shop_comune":
  1669.             case "shop_comune_cerca_generico":
  1670.             case "home_shop_comune_naviga":{
  1671.                 $tipoRiferimento = 'homeshop';
  1672.                 break;
  1673.             }
  1674.             case "home_shop_comune_dettaglio_prodotto":{
  1675.                 $tipoRiferimento = 'dettaglioArticolo';
  1676.                 break;
  1677.             }
  1678.         }
  1679.         /** @var MetaTags[] $metaTagsRilevati */
  1680.         $metaTagsRilevati = $doctrine->getRepository(MetaTags::class)->createQueryBuilder('metaTags')
  1681.             ->where('metaTags.attiva = :atv')->setParameter('atv', true)
  1682.             ->andWhere("metaTags.categoriaPagina = :tp OR metaTags.categoriaPagina = ''")->setParameter('tp', $tipoRiferimento)
  1683.             ->getQuery()->getResult();
  1684.         foreach ($metaTagsRilevati as $meta){
  1685.             /** @var MetaTagsDettagli $dettaglio */
  1686.             foreach ($meta->getDettagli() as $dettaglio){
  1687.                 $stringa = $dettaglio->getValore();
  1688.                 while(strpos($stringa, '<TMPLT tp="DATO-DB"') !== false) {
  1689.                     //se trovo l'elemento TMPLT effettuo l'azione in base al tp
  1690.                     //substringo l'intero tag
  1691.                     $sbs1 = SubstringWithFind::SubstringWithFind(
  1692.                         '<TMPLT ',
  1693.                         '/>',
  1694.                         $stringa);
  1695.                     $elementoTagCompleto = $sbs1->substring;
  1696.                     $ritornoConvertDb = Templating::ConvertiStringaDatoDb($elementoTagCompleto);
  1697.                     $cacheCategorie = new Caching_Categorie($serviziController);
  1698.                     $valoreSostituito = "";
  1699.                     $chiaveRighe = '';
  1700.                     if ($tipoRiferimento == 'homeshop'){
  1701.                         if (array_key_exists('cat1', $variabiliTemplate) && $variabiliTemplate['cat1'] != '') {
  1702.                             $arr = $cacheCategorie->getCategoriaDaNomeUnivoco($variabiliTemplate['cat1']);
  1703.                             //$arr = $doctrine->getRepository(Categorie::class)->findOneBy(array('nomeUnivoco' => $variabiliTemplate['cat1']));
  1704.                             $valoreSostituito = Templating::elaboraDatoDbPerMetaTag($arr, $ritornoConvertDb, $stringa);
  1705.                             $stringa = str_replace($elementoTagCompleto, $valoreSostituito, $stringa);
  1706.                         }else{
  1707.                             $stringa = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB CAT1. Chiave righe: ' . $chiaveRighe . ' non trovata</p>', $stringa);
  1708.                         }
  1709.                         if (array_key_exists('cat2', $variabiliTemplate) && $variabiliTemplate['cat1'] != '') {
  1710.                             $arr = $cacheCategorie->getCategoriaDaNomeUnivoco($variabiliTemplate['cat2']);
  1711.                             //$arr = $doctrine->getRepository(Categorie::class)->findOneBy(array('nomeUnivoco' => $variabiliTemplate['cat2']));
  1712.                             $valoreSostituito = Templating::elaboraDatoDbPerMetaTag($arr, $ritornoConvertDb, $stringa);
  1713.                             $stringa = str_replace($elementoTagCompleto, $valoreSostituito, $stringa);
  1714.                         }else{
  1715.                             $stringa = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB CAT12. Chiave righe: ' . $chiaveRighe . ' non trovata</p>', $stringa);
  1716.                         }
  1717.                         if (array_key_exists('cat3', $variabiliTemplate) && $variabiliTemplate['cat3'] != '') {
  1718.                             $arr = $cacheCategorie->getCategoriaDaNomeUnivoco($variabiliTemplate['cat3']);
  1719.                             //$arr = $doctrine->getRepository(Categorie::class)->findOneBy(array('nomeUnivoco' => $variabiliTemplate['cat3']));
  1720.                             $valoreSostituito = Templating::elaboraDatoDbPerMetaTag($arr, $ritornoConvertDb, $stringa);
  1721.                             $stringa = str_replace($elementoTagCompleto, $valoreSostituito, $stringa);
  1722.                         }else{
  1723.                             $stringa = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB CAT3. Chiave righe: ' . $chiaveRighe . ' non trovata</p>', $stringa);
  1724.                         }
  1725.                         if (array_key_exists('cat4', $variabiliTemplate) && $variabiliTemplate['cat4'] != '') {
  1726.                             $arr = $cacheCategorie->getCategoriaDaNomeUnivoco($variabiliTemplate['cat4']);
  1727.                             //$arr = $doctrine->getRepository(Categorie::class)->findOneBy(array('nomeUnivoco' => $variabiliTemplate['cat4']));
  1728.                             $valoreSostituito = Templating::elaboraDatoDbPerMetaTag($arr, $ritornoConvertDb, $stringa);
  1729.                             $stringa = str_replace($elementoTagCompleto, $valoreSostituito, $stringa);
  1730.                         }else{
  1731.                             $stringa = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB CAT4. Chiave righe: ' . $chiaveRighe . ' non trovata</p>', $stringa);
  1732.                         }
  1733.                         if (array_key_exists('cat5', $variabiliTemplate) && $variabiliTemplate['cat5'] != '') {
  1734.                             $arr = $cacheCategorie->getCategoriaDaNomeUnivoco($variabiliTemplate['cat5']);
  1735.                             //$arr = $doctrine->getRepository(Categorie::class)->findOneBy(array('nomeUnivoco' => $variabiliTemplate['cat5']));
  1736.                             $valoreSostituito = Templating::elaboraDatoDbPerMetaTag($arr, $ritornoConvertDb, $stringa);
  1737.                             $stringa = str_replace($elementoTagCompleto, $valoreSostituito, $stringa);
  1738.                         }else{
  1739.                             $stringa = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB CAT1. Chiave righe: ' . $chiaveRighe . ' non trovata</p>', $stringa);
  1740.                         }
  1741.                     }else {
  1742.                         $chiaveRighe = Templating::ottieniElementoDaUtilizzareInBaseATipoPagina($tipoRiferimento);
  1743.                         if (array_key_exists($chiaveRighe, $variabiliTemplate)) {
  1744.                             $valoreSostituito = Templating::elaboraDatoDbPerMetaTag($variabiliTemplate[$chiaveRighe], $ritornoConvertDb, $stringa);
  1745.                             $stringa = str_replace($elementoTagCompleto, $valoreSostituito, $stringa);
  1746.                         }else{
  1747.                             $stringa = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Errore DATO-DB. Chiave righe: ' . $chiaveRighe . ' non trovata</p>', $stringa);
  1748.                         }
  1749.                     }
  1750.                 }
  1751.                 //cerco il tag speciale {%{
  1752.                 while(strpos($stringa, '{%{') !== false) {
  1753.                     $sbs2 = SubstringWithFind::SubstringWithFind(
  1754.                         '{%{',
  1755.                         '}‰}',
  1756.                         $stringa);
  1757.                     $elementoTagCompleto = $sbs2->substring;
  1758.                     $sbs1 = SubstringWithFind::SubstringWithFind(
  1759.                         '{%{',
  1760.                         '}‰}',
  1761.                         $stringa,
  1762.                         0,
  1763.                         true);
  1764.                     $valoreSpeciale = $sbs1->substring;
  1765.                     $chiaveRighe = Templating::ottieniElementoDaUtilizzareInBaseATipoPagina($tipoRiferimento);
  1766.                     switch ($valoreSpeciale){
  1767.                         case 'img':{
  1768.                             if ($tipoRiferimento == 'dettaglioArticolo') {
  1769.                                 $pathImg = $serviziController->ottieniImmagineDaMappaCategoriaArticolo($variabiliTemplate[$chiaveRighe], true);
  1770.                                 $stringa = str_replace($elementoTagCompleto, $pathImg, $stringa);
  1771.                             }else{
  1772.                                 $stringa = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Tipo riferimento non mappato in risoluzione meta tags</p>', $stringa);
  1773.                             }
  1774.                             break;
  1775.                         }
  1776.                         case 'url':{
  1777.                             $stringa = str_replace($elementoTagCompleto, $serviziController->requestStack->getCurrentRequest()->getRequestUri(), $stringa);
  1778.                             break;
  1779.                         }
  1780.                         case 'prezzoNetto':{
  1781.                             if ($tipoRiferimento == 'dettaglioArticolo') {
  1782.                                 $stringa = str_replace($elementoTagCompleto, $serviziController->calcolaPrezzoNettoMappaOVariante($variabiliTemplate[$chiaveRighe]), $stringa);
  1783.                             }else{
  1784.                                 $stringa = str_replace($elementoTagCompleto, '<p style="color:red; font-weight: bold; text-decoration: underline; font-style: oblique;">Tipo riferimento non mappato in risoluzione meta tags</p>', $stringa);
  1785.                             }
  1786.                             break;
  1787.                         }
  1788.                     }
  1789.                 }
  1790.                 $ritorno .= $stringa . ' ';
  1791.             }
  1792.         }
  1793.         return $ritorno;
  1794.     }
  1795.     public static function elaboraDatoDbPerMetaTag($arrayValori, RitornoDatoDb $ritornoConvertDb, $elementoTagCompleto)
  1796.     {
  1797.         $valoreSostituito = Templating::ritornaValoreDaPercorso($arrayValori, $ritornoConvertDb->percorso, $ritornoConvertDb->nomeColonna, $ritornoConvertDb);
  1798.         $ritorno = '';
  1799.         if ($valoreSostituito != '' && $valoreSostituito) {
  1800.             $ritorno .= str_replace($elementoTagCompleto, $valoreSostituito, $elementoTagCompleto);
  1801.         } else {
  1802.             $ritorno .= 'Errore! Dato database non trovato!';
  1803.         }
  1804.         return $ritorno;
  1805.     }
  1806.     /**
  1807.      * @param $tipoPagina
  1808.      * @param $valoriSupporto
  1809.      * @param Environment $twig
  1810.      * @param bool $soloForm
  1811.      * @return string|null
  1812.      * @throws LoaderError
  1813.      * @throws RuntimeError
  1814.      * @throws SyntaxError
  1815.      */
  1816.     public static function ritornaDefaultLayoutPagineEComponenti($tipoPagina, $valoriSupporto, Environment $twig, $soloForm = false){
  1817.         $template = "";
  1818.         if ($soloForm){
  1819.             $valoriSupporto['soloForm'] = '1';
  1820.         }
  1821.         switch ($tipoPagina){
  1822.             case "paginaStandard":
  1823.             case "componenteCarrello":
  1824.             case "componenteVMAC":
  1825.             case "componenteOrdine":
  1826.             case "componenteUtente":
  1827.             case "rigaCarrello":
  1828.             case "rigaOrdine":
  1829.             case "rigaHomeShop":
  1830.             case "mailStandard":{
  1831.                 break;
  1832.             }
  1833.             case "modalRichiestaPrezzo":{
  1834.                 $template = $twig->render('ZZ_front_end/modal/modal_richiesta_prezzo_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1835.                 break;
  1836.             }
  1837.             case "paginaCarrello":{
  1838.                 $template = $twig->render('ZZ_front_end/carrello/carrello_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1839.                 break;
  1840.             }
  1841.             case "paginaFinalizzaCarrello":{
  1842.                 $template = $twig->render('ZZ_front_end/carrello/carrello_finalizza_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1843.                 break;
  1844.             }
  1845.             case "paginaHomeShop":{
  1846.                 $template = $twig->render('ZZ_front_end/shop/shop_comune_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1847.                 break;
  1848.             }
  1849.             case "paginaDettaglioArticolo":{
  1850.                 $template = $twig->render('ZZ_front_end/shop/dettaglio_prodotto/shop_comune_dettaglio_prodotto_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1851.                 break;
  1852.             }
  1853.             case "paginaDettaglioOrdine":{
  1854.                 $template = $twig->render('ZZ_front_end/ordini/dettaglio_ordine_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1855.                 break;
  1856.             }
  1857.             case "mailNuovoOrdine":{
  1858.                 $template = $twig->render('email/ordini/nuovo_ordine_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1859.                 break;
  1860.             }
  1861.             case "mailUtenteNuovoInserimento":{
  1862.                 $template = $twig->render('email/registrazione/nuovo_inserimento_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1863.                 break;
  1864.             }
  1865.             case "mailCambioStatoPagamento":{
  1866.                 $template = $twig->render('email/ordini/cambiato_stato_pagamento_ordine_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1867.                 break;
  1868.             }
  1869.             case "mailOrdineEsportato":{
  1870.                 $template = $twig->render('email/ordini/ordine_esportato_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1871.                 break;
  1872.             }
  1873.             case "mailOrdinePagamentoRegistrato":{
  1874.                 $template = $twig->render('email/ordini/pagamento_ordine_registrato_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1875.                 break;
  1876.             }
  1877.             case "mailUtenteCambioMail":{
  1878.                 $template = $twig->render('email/utenti/cambio_mail_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1879.                 break;
  1880.             }
  1881.             case "mailUtenteCambioPassword":{
  1882.                 $template = $twig->render('email/utenti/cambio_password_dflt.html.twig', $valoriSupporto ? $valoriSupporto : array());
  1883.                 break;
  1884.             }
  1885.         }
  1886.         return $template;
  1887.     }
  1888.     public static function ElaboraValoriSpecialiInCodiceHTML($codiceHtml, $valoriSupporto, ServiziController $serviziController, PagineEComponenti $pagina, $ordineCasuale = false, LoggerInterface $logger = null){
  1889.         $dizionarioElementiTrovati = array();
  1890.         $dizionarioIdElementiTrovati = array(); //lista dei soli ID per il recupero nel database
  1891.         $listaId = array();
  1892.         $listaElementiTrovati = SubstringWithFind::TrovaTutteOccorrenzeInStringa($codiceHtml, '%%:', ':%%');
  1893.         foreach ($listaElementiTrovati as $item){ //Creo dizionaro con chiave azione e sotto tutti gli array dello stesso elemento
  1894.             $ritorno = RitornoValoriSpecialiDaSostituire::OttieniDaElementoTag($item, $logger);
  1895.             if (!array_key_exists($ritorno->azione, $dizionarioElementiTrovati)){
  1896.                 $dizionarioElementiTrovati[$ritorno->azione] = array();
  1897.                 $dizionarioIdElementiTrovati[$ritorno->azione] = array();
  1898.             }
  1899.             array_push($dizionarioElementiTrovati[$ritorno->azione], $ritorno);
  1900.             array_push($dizionarioIdElementiTrovati[$ritorno->azione], $ritorno->idEntita);
  1901.             array_push($listaId, $ritorno->azione);
  1902.         }
  1903.         $recuperoDati = new RecuperoDati($serviziController->doctrine, $serviziController->impostazioni, $serviziController);
  1904.         foreach ($dizionarioElementiTrovati as $key => $value){
  1905.             //Cicli if con l'azione
  1906.             if ($key == 'Attributi') {
  1907.                 $attributiTrovati = array();
  1908.                 if($GLOBALS['ELB_VAL_SPEC_ID'][$key]){
  1909.                     $attributiTrovati = $GLOBALS['ELB_VAL_SPEC_ID'][$key];
  1910.                 }else{
  1911.                     $attributiTrovati = $recuperoDati->caricaAttributiDaDB($dizionarioIdElementiTrovati[$key], $serviziController->locale);
  1912.                     $GLOBALS['ELB_VAL_SPEC_ID'][$key] = $attributiTrovati;
  1913.                 }
  1914.                 $dizionarioConIdComeChiaveEEntita = $recuperoDati->creaArrayAssociativoConChiaveId($attributiTrovati);
  1915.                 /** @var RitornoValoriSpecialiDaSostituire $itm */
  1916.                 foreach ($value as $itm) {
  1917.                     if (array_key_exists($itm->idEntita, $dizionarioConIdComeChiaveEEntita)) { // verifico che l'entita con id Ã¨ stata trovata nel db
  1918.                         /** @var Attributi $entitaCollegataDb */
  1919.                         $entitaCollegataDb = $dizionarioConIdComeChiaveEEntita[$itm->idEntita];
  1920.                         $valoreDecodicia = Templating::ritornaValoreDaPercorsoValoriSpeciali($entitaCollegataDb, $itm->percorsoDecodifica);
  1921.                         $codiceHtml = str_replace($itm->elementoTagOriginale, $valoreDecodicia, $codiceHtml); //Sostituisco il tag con il corrispondente valore decodificato
  1922.                     } else {
  1923.                         $codiceHtml = str_replace($itm->elementoTagOriginale, 'Errore decodifica valore speciale', $codiceHtml);
  1924.                     }
  1925.                 }
  1926.             }else if ($key == 'RecuperoPercorsoDb'){
  1927.                 /** @var RitornoValoriSpecialiDaSostituire $itm */
  1928.                 foreach ($value as $itm) {
  1929.                     $entitaCollegataDb = $valoriSupporto[Templating::ottieniElementoDaUtilizzareInBaseATipoPagina($pagina->getTipoPagina(), $ordineCasuale)];
  1930.                     $valoreDecodicia = Templating::ritornaValoreDaPercorsoValoriSpeciali($entitaCollegataDb, $itm->percorsoDecodifica);
  1931.                     if ($valoreDecodicia !== false){
  1932.                         $codiceHtml = str_replace($itm->elementoTagOriginale, $valoreDecodicia, $codiceHtml); //Sostituisco il tag con il corrispondente valore decodificato
  1933.                     }else{
  1934.                         $codiceHtml = str_replace($itm->elementoTagOriginale, 'Errore decodifica valore speciale- Percorso: ' . $itm->percorsoDecodifica, $codiceHtml);
  1935.                     }
  1936.                 }
  1937.             }else if ($key == 'Dizionario'){
  1938.                 /** @var RitornoValoriSpecialiDaSostituire $itm */
  1939.                 foreach ($value as $itm) {
  1940.                     $traduzione = $serviziController->translating->OttieniElementoDizionario($itm->identificativo, $itm->famiglia)->valoreUscita;
  1941.                     if ($traduzione !== false){
  1942.                         $codiceHtml = str_replace($itm->elementoTagOriginale, $traduzione, $codiceHtml); //Sostituisco il tag con il corrispondente valore decodificato
  1943.                     }else{
  1944.                         $codiceHtml = str_replace($itm->elementoTagOriginale, 'Errore elemento dizionario non trovato: ' . $itm->identificativo, $codiceHtml);
  1945.                     }
  1946.                 }
  1947.             }
  1948.         }
  1949.         return $codiceHtml;
  1950.     }
  1951.     public static function ElaboraTagSostituzionePercorso($codiceHtml, $valoriSupporto, ServiziController $serviziController, LoggerInterface $logger = null){
  1952.         $ritorno = $codiceHtml;
  1953.         $listaElementiTrovati = SubstringWithFind::TrovaTutteOccorrenzeInStringa($codiceHtml, '%££%', '%££%');
  1954.         foreach ($listaElementiTrovati as $item){
  1955.             $itemElaborato = str_replace('%££%', '', $item);//%££%couponForm.children._token.vars.value%££%
  1956.             $percorso = explode('.', $itemElaborato);
  1957.             $colonnaDaPrendere = array_pop($percorso);
  1958.             $valore = self::ritornaValoreDaPercorso($valoriSupporto, $percorso, $colonnaDaPrendere, null);
  1959.             $ritorno = str_replace($item, $valore, $ritorno);
  1960.             if($logger)
  1961.                 $logger->debug('Item: ' . $item . '\nItem elaborato: ' . $itemElaborato . '\nPercorso: ' . print_r($percorso, true) . '\nColonna: ' . $colonnaDaPrendere . '\nValore: ' . $valore );
  1962.         }
  1963.         return $ritorno;
  1964.     }
  1965.     public static function ElaboraTagSostituzioneEntita($codiceHtml, $valoriSupporto, ServiziController $serviziController, LoggerInterface $logger = null)
  1966.     {
  1967.         $ritorno = $codiceHtml;
  1968.         $listaElementiTrovati = SubstringWithFind::TrovaTutteOccorrenzeInStringa($codiceHtml, Costanti::LYT_DELIMITATORE_ENTITA, Costanti::LYT_DELIMITATORE_ENTITA);
  1969.         foreach ($listaElementiTrovati as $item) {
  1970.             $itemElaborato = str_replace(Costanti::LYT_DELIMITATORE_ENTITA, '', $item);//$ENT$select££App:AssociazioneSpedizioniClienti.spedizione.descrizione+ +consegna.descrizione$ENT$
  1971.             $elementoIniziale = '';
  1972.             if (strpos($itemElaborato, '££') !== false) { //Vuol dire che contiene il carattere Â£Â£ e quindi devo verificare cosa fare
  1973.                 $arr = explode('££', $itemElaborato);
  1974.                 $elementoIniziale = $arr[0];
  1975.                 $itemElaborato = $arr[1];
  1976.             } else { //Non Ã¨ presente il tag iniziale
  1977.             }
  1978.             //App:AssociazioneSpedizioniClienti.spedizione.descrizione+ +consegna.descrizione
  1979.             $esplosoPrimo = explode('.', $itemElaborato);
  1980.             $entita = $esplosoPrimo[0];
  1981.             $itemElaborato = str_replace($entita . '.', '', $itemElaborato);
  1982.             //spedizione.descrizione+ +consegna.descrizione
  1983.             if (strpos($itemElaborato, '+') !== false)
  1984.                 $esplodoCompoenenti = explode('+', $itemElaborato);
  1985.             else
  1986.                 $esplodoCompoenenti = array($itemElaborato);
  1987.             $stringaRitorno = '';
  1988.             switch ($entita) {
  1989.                 case 'AppBundle:AssociazioneSpedizioniClienti':
  1990.                 case 'App:AssociazioneSpedizioniClienti':
  1991.                 {
  1992.                     $assSped = $serviziController->recuperoDati->RitornaAssociazioneSpedizioneClienti(null);//Se null viene preso in automatico l'attuale
  1993.                     $stringaRitorno .= self::elaboraPercorsoPerDatoDaEntita($assSped, $esplodoCompoenenti, $logger, '');
  1994.                     break;
  1995.                 }
  1996.                 case 'AppBundle:Pagamenti':
  1997.                 case 'App:Pagamenti':
  1998.                 {
  1999.                     $pagamenti = $serviziController->recuperoDati->RitornaPagamenti();
  2000.                     $idSelezionato = '';
  2001.                     if(array_key_exists(Costanti::ID_PAGAMENTO_SELEZIONATO, $valoriSupporto))
  2002.                         $idSelezionato = $valoriSupporto[Costanti::ID_PAGAMENTO_SELEZIONATO];
  2003.                     $stringaRitorno .= self::elaboraPercorsoPerDatoDaEntita($pagamenti, $esplodoCompoenenti, $logger, $idSelezionato);
  2004.                     break;
  2005.                 }
  2006.                 case 'AppBundle:ModalitaSpedizione':
  2007.                 case 'App:ModalitaSpedizione':
  2008.                 {
  2009.                     $spedizione = $serviziController->recuperoDati->RitornaModalitaSpedizione();
  2010.                     $idSelezionato = '';
  2011.                     if(array_key_exists(Costanti::ID_MODALITA_SPEDIZIONE_SELEZIONATA, $valoriSupporto))
  2012.                         $idSelezionato = $valoriSupporto[Costanti::ID_MODALITA_SPEDIZIONE_SELEZIONATA];
  2013.                     $stringaRitorno .= self::elaboraPercorsoPerDatoDaEntita($spedizione, $esplodoCompoenenti, $logger, $idSelezionato);
  2014.                     break;
  2015.                 }
  2016.                 case 'AppBundle:ModalitaPagamento':
  2017.                 case 'App:ModalitaPagamento':
  2018.                 {
  2019.                     $pagamenti = $serviziController->recuperoDati->RitornaModalitaPagamento();
  2020.                     $idSelezionato = '';
  2021.                     if(array_key_exists(Costanti::ID_MODALITA_PAGAMENTO_SELEZIONATA, $valoriSupporto))
  2022.                         $idSelezionato = $valoriSupporto[Costanti::ID_MODALITA_PAGAMENTO_SELEZIONATA];
  2023.                     $stringaRitorno .= self::elaboraPercorsoPerDatoDaEntita($pagamenti, $esplodoCompoenenti, $logger, $idSelezionato);
  2024.                     break;
  2025.                 }
  2026.                 case 'AppBundle:Destinazioni':
  2027.                 case 'App:Destinazioni':
  2028.                 {
  2029.                     $destinazioni = array();
  2030.                     if(array_key_exists(Costanti::IO_DESTINAZIONI, $valoriSupporto)){
  2031.                         foreach ($valoriSupporto[Costanti::IO_DESTINAZIONI] as $d){
  2032.                             array_push($destinazioni, Destinazioni::CreaDaConversioneEntity($d));
  2033.                         }
  2034.                     }
  2035.                     $utente = $serviziController->OttieniUtenteCorrente();
  2036.                     if ($utente && count($destinazioni) <= 0) {
  2037.                         $destinazioni = $serviziController->recuperoDati->RitornaDestinazioni($utente);
  2038.                     }
  2039.                     if(count($destinazioni) > 0) {
  2040.                         $idSelezionato = '';
  2041.                         if (array_key_exists(Costanti::ID_DESTINAZIONE_SELEZIONATA, $valoriSupporto))
  2042.                             $idSelezionato = $valoriSupporto[Costanti::ID_DESTINAZIONE_SELEZIONATA];
  2043.                         $stringaRitorno .= self::elaboraPercorsoPerDatoDaEntita($destinazioni, $esplodoCompoenenti, $logger, $idSelezionato, true);
  2044.                     }
  2045.                     break;
  2046.                 }
  2047.                 case 'AppBundle:Nazioni':
  2048.                 case 'App:Nazioni':
  2049.                 {
  2050.                     $nazioni = $serviziController->recuperoDati->RitornaNazioni();
  2051.                     $idSelezionato = '';
  2052.                     if(array_key_exists(Costanti::ID_NAZIONE_SELEZIONATA, $valoriSupporto))
  2053.                         $idSelezionato = $valoriSupporto[Costanti::ID_NAZIONE_SELEZIONATA];
  2054.                     $stringaRitorno .= self::elaboraPercorsoPerDatoDaEntita($nazioni, $esplodoCompoenenti, $logger, $idSelezionato);
  2055.                     break;
  2056.                 }
  2057.             }
  2058.             $ritorno = str_replace($item, $stringaRitorno, $ritorno);
  2059.         }
  2060.         return $ritorno;
  2061.     }
  2062.     /**
  2063.      * @param $entita
  2064.      * @param $componentiPercorso
  2065.      * @param null|LoggerInterface $logger
  2066.      * @param $selezionato string
  2067.      * @return string
  2068.      */
  2069.     public static function elaboraPercorsoPerDatoDaEntita($entita, $componentiPercorso, $logger = null, $idSelezionato = '', $aggiungiOpzioneVuota = false)
  2070.     {
  2071.         $stringaRitorno = '';
  2072.         foreach ($entita as $pag){
  2073.             $testoElaboratoPercorso = '';
  2074.             if($aggiungiOpzioneVuota){
  2075.                 $stringaRitorno .= ('<option value=""></option>');
  2076.             }
  2077.             foreach ($componentiPercorso as $percorso) {
  2078.                 //$->notice('Percorso: ' . $percorso);
  2079.                 if(strpos($percorso, '\'') === false){
  2080.                     if(strpos($percorso, '.') !== false){
  2081.                         $percorsoSplittato = explode('.', $percorso);
  2082.                         $colonnaDaPrendere = array_pop($percorsoSplittato);
  2083.                         //$->notice('Percorso: ' . $percorso . ' --- ColonnaDaPrendere: ' . $colonnaDaPrendere . ' --- PercorsoSplittato: ' . print_r($percorsoSplittato));
  2084.                     }else{
  2085.                         $percorsoSplittato = array();
  2086.                         $colonnaDaPrendere = $percorso;
  2087.                     }
  2088.                     $testoElaboratoPercorso .= self::ritornaValoreDaPercorso($pag, $percorsoSplittato, $colonnaDaPrendere);
  2089.                 }else{
  2090.                     $testoElaboratoPercorso .= str_replace('\'', '', $percorso);
  2091.                 }
  2092.             }
  2093.             $stringaRitorno .= ('<option value="' . $pag->id . '"' . ($pag->id == $idSelezionato ? ' selected' : '') . '>' . $testoElaboratoPercorso . '</option>');
  2094.         }
  2095.         return $stringaRitorno;
  2096.     }
  2097.     /**
  2098.      * @param $layout
  2099.      * @return array
  2100.      */
  2101.     public static function RitornaArrayFinaleInBaseAlLayout($layout){
  2102.         $ritorno = array();
  2103.         switch ($layout){
  2104.             case "paginaCarrello":{
  2105.                 $formCoupon = GJS_FormPreimpostato::Crea(
  2106.                     Costanti::CC_RADICE_FORM,
  2107.                     Costanti::CC_RADICE_FORM,
  2108.                     '%££%' . Costanti::CC_RADICE_FORM . '.vars.action%££%',
  2109.                     'couponForm',
  2110.                     'Coupon form',
  2111.                     '%££%' . Costanti::CC_RADICE_FORM . '.vars.method%££%',
  2112.                     true
  2113.                 );
  2114.                 $formModificaPagamentoSpedizione = GJS_FormPreimpostato::Crea(
  2115.                     Costanti::MPSC_RADICE_FORM,
  2116.                     Costanti::MPSC_RADICE_FORM,
  2117.                     '%££%' . Costanti::MPSC_RADICE_FORM . '.vars.action%££%',
  2118.                     Costanti::MPSC_RADICE_FORM,
  2119.                     'Modifica spedizione pagamento form',
  2120.                     '%££%' . Costanti::MPSC_RADICE_FORM . '.vars.method%££%',
  2121.                     true
  2122.                 );
  2123.                 $ritorno['Coupon form'] = array(
  2124.                     'label' => 'Coupon form',
  2125.                     'content' => array(
  2126.                         'type' => 'form-preimpostato',
  2127.                         'components' => self::RitornaElementiCouponForm(Costanti::CC_RADICE_FORM),
  2128.                         'configurazioneJson' => $formCoupon->ConvertiJsonJavascript()
  2129.                     ),
  2130.                     'category' => 'Form necessari',
  2131.                     'attributes' => array(
  2132.                         'class' => 'fa fa-forumbee'
  2133.                     )
  2134.                 );
  2135.                 $ritorno['Modifica spedizione pagamento form'] = array(
  2136.                     'label' => 'Modifica spedizione pagamento form',
  2137.                     'content' => array(
  2138.                         'type' => 'form-preimpostato',
  2139.                         'components' => self::RitornaElementiModificaSpedizionePagamentoInCarrello(Costanti::MPSC_RADICE_FORM),
  2140.                         'configurazioneJson' => $formModificaPagamentoSpedizione->ConvertiJsonJavascript()
  2141.                     ),
  2142.                     'category' => 'Form necessari',
  2143.                     'attributes' => array(
  2144.                         'class' => 'fa fa-forumbee'
  2145.                     )
  2146.                 );
  2147.                 break;
  2148.             }
  2149.             case "paginaFinalizzaCarrello":{
  2150.                 $formCheckout = GJS_FormPreimpostato::Crea(
  2151.                     Costanti::IO_RADICE_FORM,
  2152.                     Costanti::IO_RADICE_FORM,
  2153.                     '%££%' . Costanti::IO_RADICE_FORM . '.vars.action%££%',
  2154.                     'checkoutCarrello',
  2155.                     'checkoutCarrello',
  2156.                     '%££%' . Costanti::IO_RADICE_FORM . '.vars.method%££%',
  2157.                     true
  2158.                 );
  2159.                 $ritorno['Checkout'] = array(
  2160.                     'label' => 'Checkout',
  2161.                     'content' => array(
  2162.                         'type' => 'form-preimpostato',
  2163.                         'components' => self::RitornaElementiInvioOrdine(Costanti::IO_RADICE_FORM, true),
  2164.                         'configurazioneJson' => $formCheckout->ConvertiJsonJavascript()
  2165.                     ),
  2166.                     'category' => 'Form necessari',
  2167.                     'attributes' => array(
  2168.                         'class' => 'fa fa-forumbee'
  2169.                     )
  2170.                 );
  2171.                 break;
  2172.             }
  2173.             case "paginaGestioneUtente":{
  2174.                 $formCambioPassword = GJS_FormPreimpostato::Crea(
  2175.                     Costanti::CP_RADICE_FORM,
  2176.                     Costanti::CP_RADICE_FORM,
  2177.                     '%££%' . Costanti::CP_RADICE_FORM . '.vars.action%££%',
  2178.                     'cambiaPassword',
  2179.                     'Cambia password',
  2180.                     '%££%' . Costanti::CP_RADICE_FORM . '.vars.method%££%',
  2181.                     true
  2182.                 );
  2183.                 $formRegistrazioneUtente = GJS_FormPreimpostato::Crea(
  2184.                     Costanti::RU_RADICE_FORM,
  2185.                     Costanti::RU_RADICE_FORM,
  2186.                     '%££' . Costanti::RU_RADICE_FORM . '.vars.action%££%',
  2187.                     "registrazioneUtente",
  2188.                     "Registrazione utente",
  2189.                 '%££%' . Costanti::RU_RADICE_FORM . '%££%',
  2190.                     true
  2191.                 );
  2192.                 $formCambioMail = GJS_FormPreimpostato::Crea(
  2193.                     Costanti::CM_RADICE_FORM,
  2194.                     Costanti::CM_RADICE_FORM,
  2195.                     '%££%' . Costanti::CM_RADICE_FORM . '.vars.action%££%',
  2196.                     'cambiaMail',
  2197.                     'Cambia Mail',
  2198.                     '%££%' . Costanti::CM_RADICE_FORM . '.vars.method%££%',
  2199.                     true
  2200.                 );
  2201.                 $ritorno['Cambia password'] = array(
  2202.                     'label' => 'Cambia password',
  2203.                     'content' => array(
  2204.                         'type' => 'form-preimpostato',
  2205.                         'components' => self::RitornaElementiCambiaPassword(Costanti::CP_RADICE_FORM),
  2206.                         'configurazioneJson' => $formCambioPassword->ConvertiJsonJavascript()
  2207.                     ),
  2208.                     'category' => 'Form necessari',
  2209.                     'attributes' => array(
  2210.                         'class' => 'fa fa-forumbee'
  2211.                     )
  2212.                 );
  2213.                 $ritorno['Registrazione utente'] = array(
  2214.                     'label' => 'Registrazione utente',
  2215.                     'content' => array(
  2216.                         'type' => 'form-preimpostato',
  2217.                         'components' => self::RitornaElementiRegistrazioneUtentePerEditorJSON(Costanti::CP_RADICE_FORM),
  2218.                         'configurazioneJson' => $formRegistrazioneUtente->ConvertiJsonJavascript()
  2219.                     ),
  2220.                     'category' => 'Form necessari',
  2221.                     'attributes' => array(
  2222.                         'class' => 'fa fa-forumbee'
  2223.                     )
  2224.                 );
  2225.                 $ritorno['Cambia mail'] = array(
  2226.                     'label' => 'Cambia mail',
  2227.                     'content' => array(
  2228.                         'type' => 'form-preimpostato',
  2229.                         'components' => self::RitornaElementiCambiaMail(Costanti::CP_RADICE_FORM),
  2230.                         'configurazioneJson' => $formCambioMail->ConvertiJsonJavascript()
  2231.                     ),
  2232.                     'category' => 'Form necessari',
  2233.                     'attributes' => array(
  2234.                         'class' => 'fa fa-forumbee'
  2235.                     )
  2236.                 );
  2237.                 break;
  2238.             }
  2239.             case "paginaDettaglioArticolo":{
  2240.                 $formOrdinazione = GJS_FormPreimpostato::Crea(
  2241.                     'aggiungi-carrello-form',
  2242.                     'aggiungiCarrelloForm',
  2243.                     '/shopCM/cart/add/%££%' . Costanti::T_MAPPA_IDENTIFICATA . '.id%££%',
  2244.                     'ordinazioneArticolo',
  2245.                     'Ordinazione articolo',
  2246.                     'GET',
  2247.                     false,
  2248.                     array(),
  2249.                     array(),
  2250.                     array('form-ordinazione-articolo')
  2251.                 );
  2252.                 $ritorno['Ordinazione articolo'] = array(
  2253.                     'label' => 'Ordinazione articolo',
  2254.                     'content' => array(
  2255.                         'type' => 'form-preimpostato',
  2256.                         'components' => self::RitornaElementiOrdinazioneArticolo(),
  2257.                         'configurazioneJson' => $formOrdinazione->ConvertiJsonJavascript()
  2258.                     ),
  2259.                     'category' => 'Form necessari',
  2260.                     'attributes' => array(
  2261.                         'class' => 'fa fa-forumbee'
  2262.                     )
  2263.                 );
  2264.                 break;
  2265.             }
  2266.         }
  2267.         return $ritorno;
  2268.     }
  2269.     public static function RitornaElementiOrdinazioneArticolo(){
  2270.         return array(
  2271.             GJS_Components::CreaInput(
  2272.                 'qta',
  2273.                 'qta',
  2274.                 'input',
  2275.                 'number',
  2276.                 array('form-control'),
  2277.                 array()
  2278.             ),
  2279.             GJS_Components::CreaInput(
  2280.                 'id-mappa',
  2281.                 'id-mappa',
  2282.                 'input',
  2283.                 'hidden',
  2284.                 array(),
  2285.                 array(
  2286.                     'value' => '%££' . Costanti::T_MAPPA_IDENTIFICATA . '.id%££%'
  2287.                 )
  2288.             ),
  2289.             GJS_Components::CreaInput(
  2290.                 'disponibilita',
  2291.                 'disponibilita',
  2292.                 'input',
  2293.                 'hidden',
  2294.                 array(),
  2295.                 array(
  2296.                     'value' => '%££%' . Costanti::T_MAPPA_IDENTIFICATA . '.disponibile%££%'
  2297.                 )
  2298.             ),
  2299.             GJS_Components::CreaInput(
  2300.                 'id-variante',
  2301.                 'id-variante',
  2302.                 'input',
  2303.                 'hidden',
  2304.                 array(),
  2305.                 array(
  2306.                     'value' => '%%ID-VARIANTE%%'
  2307.                 )
  2308.             ),
  2309.             GJS_Components::CreaButton(
  2310.                 'btn-submit',
  2311.                 'btn-submit',
  2312.                 'submit',
  2313.                 array('btn', 'btn-success'),
  2314.                 array(),
  2315.                 array(),
  2316.                 'home_shop_ordina_btn',
  2317.                 'home_shop'
  2318.             )
  2319.         );
  2320.     }
  2321.     public static function RitornaElementiCambiaMail($radice = 'form'){
  2322.         return array(
  2323.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::CM_NUOVA_MAIL . ']', '', 'modifica_utente_cambia_nuova_mail', 'modifica_utente'),
  2324.             GJS_Components::CreaInput(
  2325.                 $radice . '[' . Costanti::CM_NUOVA_MAIL . ']',
  2326.                 $radice . ($radice != '' ? '_' : '') . Costanti::CM_NUOVA_MAIL,
  2327.                 'input',
  2328.                 'email',
  2329.                 array('form-control'),
  2330.                 array('style' => array(
  2331.                     'padding-left' => '5px',
  2332.                     'padding-right' => '5px')
  2333.                 )
  2334.             ),
  2335.             GJS_Components::CreaInput(
  2336.                 $radice . '[' . Costanti::FORM_TOKEN . ']',
  2337.                 $radice . ($radice != '' ? '_' : '') . Costanti::FORM_TOKEN,
  2338.                 'input',
  2339.                 'hidden',
  2340.                 array(),
  2341.                 array('value' => '%££%' . Costanti::RU_RADICE_FORM . '.children._token.vars.value%££%')
  2342.             ),
  2343.             GJS_Components::CreaButton(
  2344.                 $radice . '[' . Costanti::CM_APPLICA . ']',
  2345.                 $radice . ($radice != '' ? '_' : '') . Costanti::CM_APPLICA,
  2346.                 'submit',
  2347.                 array('form-inline', 'btn', 'btn-large', 'btn-success'),
  2348.                 array(),
  2349.                 array(),
  2350.                 'modifica_utente_cambia_mail_applica_btn',
  2351.                 'modifica_utente'
  2352.             )
  2353.         );
  2354.     }
  2355.     public static function RitornaElementiCambiaPassword($radice = 'form'){
  2356.         return array(
  2357.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::CP_PASSWORD_CORRENTE . ']', '', 'modifica_utente_password_corrente', 'modifica_utente'),
  2358.             GJS_Components::CreaInput(
  2359.                 $radice . '[' . Costanti::CP_PASSWORD_CORRENTE . ']',
  2360.                 $radice . ($radice != '' ? '_' : '') . Costanti::CP_PASSWORD_CORRENTE,
  2361.                 'input',
  2362.                 'password',
  2363.                 array('form-control'),
  2364.                 array('style' => array(
  2365.                     'padding-left' => '5px',
  2366.                     'padding-right' => '5px')
  2367.                 )
  2368.             ),
  2369.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::CP_PASSWORD_NUOVA . ']', '', 'modifica_utente_nuova_password', 'modifica_utente'),
  2370.             GJS_Components::CreaInput(
  2371.                 $radice . '[' . Costanti::CP_PASSWORD_NUOVA . ']',
  2372.                 $radice . ($radice != '' ? '_' : '') . Costanti::CP_PASSWORD_NUOVA,
  2373.                 'input',
  2374.                 'password',
  2375.                 array('form-control'),
  2376.                 array('style' => array(
  2377.                     'padding-left' => '5px',
  2378.                     'padding-right' => '5px')
  2379.                 )
  2380.             ),
  2381.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::CP_PASSWORD_NUOVA_RIPETI . ']', '', 'modifica_utente_ripeti_password', 'modifica_utente'),
  2382.             GJS_Components::CreaInput(
  2383.                 $radice . '[' . Costanti::CP_PASSWORD_NUOVA_RIPETI . ']',
  2384.                 $radice . ($radice != '' ? '_' : '') . Costanti::CP_PASSWORD_NUOVA_RIPETI,
  2385.                 'input',
  2386.                 'password',
  2387.                 array('form-control'),
  2388.                 array('style' => array(
  2389.                     'padding-left' => '5px',
  2390.                     'padding-right' => '5px')
  2391.                 )
  2392.             ),
  2393.             GJS_Components::CreaInput(
  2394.                 $radice . '[' . Costanti::FORM_TOKEN . ']',
  2395.                 $radice . ($radice != '' ? '_' : '') . Costanti::FORM_TOKEN,
  2396.                 'input',
  2397.                 'hidden',
  2398.                 array(),
  2399.                 array('value' => '%££%' . Costanti::RU_RADICE_FORM . '.children._token.vars.value%££%')
  2400.             ),
  2401.             GJS_Components::CreaButton(
  2402.                 $radice . '[' . Costanti::CP_CONFERMA . ']',
  2403.                 $radice . ($radice != '' ? '_' : '') . Costanti::CP_CONFERMA,
  2404.                 'submit',
  2405.                 array('form-inline', 'btn', 'btn-large', 'btn-success'),
  2406.                 array(),
  2407.                 array(),
  2408.                 'modifica_utente_cambia_password_btn',
  2409.                 'modifica_utente'
  2410.             )
  2411.         );
  2412.     }
  2413.     /**
  2414.      * @param string $radice
  2415.      * @return array
  2416.      */
  2417.     public static function RitornaElementiCouponForm($radice = 'form'){
  2418.         return array(
  2419.             GJS_Components::CreaInput(
  2420.                 $radice . '[' . Costanti::CC_CODICE_COUPON . ']',
  2421.                 $radice . ($radice != '' ? '_' : '') . Costanti::CC_CODICE_COUPON,
  2422.                 'input',
  2423.                 'text',
  2424.                 array('form-control'),
  2425.                 array('style' => array(
  2426.                     'padding-left' => '5px',
  2427.                     'padding-right' => '5px')
  2428.                 )
  2429.             ),
  2430.             GJS_Components::CreaButton(
  2431.                 $radice . '[' . Costanti::CC_APPLICA . ']',
  2432.                 $radice . ($radice != '' ? '_' : '') . Costanti::CC_APPLICA,
  2433.                 'submit',
  2434.                 array('form-inline', 'btn', 'btn-sm', 'btn-success'),
  2435.                 array('style' => array(
  2436.                     'margin-top' => '5px'
  2437.                 ))
  2438.             ),
  2439.             GJS_Components::CreaInput(
  2440.                 $radice . '[' . Costanti::FORM_TOKEN . ']',
  2441.                 $radice . ($radice != '' ? '_' : '') . Costanti::FORM_TOKEN,
  2442.                 'input',
  2443.                 'hidden',
  2444.                 array(),
  2445.                 array('value' => '%££%' . $radice . '.children._token.vars.value%££%')
  2446.             )
  2447.         );
  2448.     }
  2449.     /**
  2450.      * @param string $radice
  2451.      * @return array
  2452.      */
  2453.     public static function RitornaElementiModificaSpedizionePagamentoInCarrello($radice = Costanti::MPSC_RADICE_FORM){
  2454.         return array(
  2455.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_MODALITA_SPEDIZIONE . ']', '', 'carrello_modalita_spedizione', 'carrello'),
  2456.             GJS_Components::CreaSelect(
  2457.                 $radice . '[' . Costanti::IO_MODALITA_SPEDIZIONE . ']',
  2458.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_MODALITA_SPEDIZIONE,
  2459.                 Costanti::LYT_DELIMITATORE_ENTITA . 'App:ModalitaSpedizione.modalitaSpedizioneInLingua.testoDescrittivo' . Costanti::LYT_DELIMITATORE_ENTITA,
  2460.                 array('form-control'),
  2461.                 array('style' => array(
  2462.                     'padding-left' => '5px',
  2463.                     'padding-right' => '5px')
  2464.                 )
  2465.             ),
  2466.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_MODALITA_PAGAMENTO . ']', '', 'carrello_modalita_pagamento', 'carrello'),
  2467.             GJS_Components::CreaSelect(
  2468.                 $radice . '[' . Costanti::IO_MODALITA_PAGAMENTO . ']',
  2469.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_MODALITA_PAGAMENTO,
  2470.                 Costanti::LYT_DELIMITATORE_ENTITA . 'App:ModalitaPagamento.modalitaPagamentoInLingua.nome' . Costanti::LYT_DELIMITATORE_ENTITA,
  2471.                 array('form-control'),
  2472.                 array('style' => array(
  2473.                     'padding-left' => '5px',
  2474.                     'padding-right' => '5px')
  2475.                 )
  2476.             ),
  2477.             GJS_Components::CreaButton(
  2478.                 $radice . '[' . Costanti::MPSC_AGGIORNA_ORDINE . ']',
  2479.                 $radice . ($radice != '' ? '_' : '') . Costanti::MPSC_AGGIORNA_ORDINE,
  2480.                 'submit',
  2481.                 array('btn', 'btn-success'),
  2482.                 array('style' => array(
  2483.                     'padding-left' => '5px',
  2484.                     'padding-right' => '5px')
  2485.                 ),
  2486.                 array(
  2487.                     'content' => 'carrello_aggiorna',
  2488.                 ),
  2489.                 'carrello_aggiorna',
  2490.                 'carrello'
  2491.             ),
  2492.             GJS_Components::CreaInput(
  2493.                 $radice . '[' . Costanti::FORM_TOKEN . ']',
  2494.                 $radice . ($radice != '' ? '_' : '') . Costanti::FORM_TOKEN,
  2495.                 'input',
  2496.                 'hidden',
  2497.                 array(),
  2498.                 array('value' => '%££%' . $radice . '.children._token.vars.value%££%')
  2499.             )
  2500.         );
  2501.     }
  2502.     public static function RitornaElementiInvioOrdine($radice = 'form', $ancheRegistrazioneUtente = false){
  2503.         $ritorno = array();
  2504.         if($ancheRegistrazioneUtente){
  2505.             $ritorno = array_merge($ritorno, self::RitornaElementiRegistrazioneUtentePerEditorJSON($radice, true));
  2506.         }
  2507.         array_push($ritorno,
  2508.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_RIFERIMENTO_ORDINE . ']', '', 'carrello_riferimento_ordine', 'carrello'),
  2509.             GJS_Components::CreaInput(
  2510.                 $radice . '[' . Costanti::IO_RIFERIMENTO_ORDINE . ']',
  2511.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_RIFERIMENTO_ORDINE,
  2512.                 'input',
  2513.                 'text',
  2514.                 array('form-control'),
  2515.                 array('style' => array(
  2516.                     'padding-left' => '5px',
  2517.                     'padding-right' => '5px')
  2518.                 )
  2519.             ),
  2520.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_MODALITA_SPEDIZIONE . ']', '', 'carrello_modalita_spedizione', 'carrello'),
  2521.             GJS_Components::CreaSelect(
  2522.                 $radice . '[' . Costanti::IO_MODALITA_SPEDIZIONE . ']',
  2523.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_MODALITA_SPEDIZIONE,
  2524.                 Costanti::LYT_DELIMITATORE_ENTITA . 'App:ModalitaSpedizione.modalitaSpedizioneInLingua.testoDescrittivo' . Costanti::LYT_DELIMITATORE_ENTITA,
  2525.                 array('form-control'),
  2526.                 array('style' => array(
  2527.                     'padding-left' => '5px',
  2528.                     'padding-right' => '5px')
  2529.                 )
  2530.             ),
  2531.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_MODALITA_PAGAMENTO . ']', '', 'carrello_modalita_pagamento', 'carrello'),
  2532.             GJS_Components::CreaSelect(
  2533.                 $radice . '[' . Costanti::IO_MODALITA_PAGAMENTO . ']',
  2534.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_MODALITA_PAGAMENTO,
  2535.                 Costanti::LYT_DELIMITATORE_ENTITA . 'App:ModalitaPagamento.modalitaPagamentoInLingua.nome' . Costanti::LYT_DELIMITATORE_ENTITA,
  2536.                 array('form-control'),
  2537.                 array('style' => array(
  2538.                     'padding-left' => '5px',
  2539.                     'padding-right' => '5px')
  2540.                 )
  2541.             ),
  2542.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_NOTE . ']', '', 'carrello_note', 'carrello'),
  2543.             GJS_Components::CreaInput(
  2544.                 $radice . '[' . Costanti::IO_NOTE . ']',
  2545.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_NOTE,
  2546.                 'textarea',
  2547.                 'textarea',
  2548.                 array('form-control'),
  2549.                 array('style' => array(
  2550.                     'padding-left' => '5px',
  2551.                     'padding-right' => '5px')
  2552.                 )
  2553.             ),
  2554.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_NOTE_AZIENDALI . ']', '', 'carrello_note_aziendali', 'carrello'),
  2555.             GJS_Components::CreaInput(
  2556.                 $radice . '[' . Costanti::IO_NOTE_AZIENDALI . ']',
  2557.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_NOTE_AZIENDALI,
  2558.                 'textarea',
  2559.                 'textarea',
  2560.                 array('form-control'),
  2561.                 array('style' => array(
  2562.                     'padding-left' => '5px',
  2563.                     'padding-right' => '5px')
  2564.                 )
  2565.             ),
  2566.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_DATA_SPEDIZIONE_RITIRO . ']', '', 'carrello_data_spedizione_ritiro_richiesta', 'carrello'),
  2567.             GJS_Components::CreaInput(
  2568.                 $radice . '[' . Costanti::IO_DATA_SPEDIZIONE_RITIRO . ']',
  2569.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_DATA_SPEDIZIONE_RITIRO,
  2570.                 'input',
  2571.                 'text',
  2572.                 array('form-control', 'input-data'),
  2573.                 array('style' => array(
  2574.                     'padding-left' => '5px',
  2575.                     'padding-right' => '5px')
  2576.                 ),
  2577.                 array('autocomplete' => 'off')
  2578.             ),
  2579.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_SPEDIZIONE_CONSEGNA . ']', '', 'carrello_modalita_spedizione', 'carrello'),
  2580.             GJS_Components::CreaSelect(
  2581.                 $radice . '[' . Costanti::IO_SPEDIZIONE_CONSEGNA . ']',
  2582.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_SPEDIZIONE_CONSEGNA,
  2583.                 Costanti::LYT_DELIMITATORE_ENTITA . 'App:AssociazioneSpedizioniClienti.spedizione.descrizione+\' \'+consegna.descrizione' . Costanti::LYT_DELIMITATORE_ENTITA,
  2584.                 array('form-control'),
  2585.                 array('style' => array(
  2586.                     'padding-left' => '5px',
  2587.                     'padding-right' => '5px')
  2588.                 )
  2589.             ),
  2590.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_PAGAMENTO . ']', '', 'carrello_modalita_pagamento', 'carrello'),
  2591.             GJS_Components::CreaSelect(
  2592.                 $radice . '[' . Costanti::IO_PAGAMENTO . ']',
  2593.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_PAGAMENTO,
  2594.                 Costanti::LYT_DELIMITATORE_ENTITA . 'App:Pagamenti.descrizione' . Costanti::LYT_DELIMITATORE_ENTITA,
  2595.                 array('form-control'),
  2596.                 array('style' => array(
  2597.                     'padding-left' => '5px',
  2598.                     'padding-right' => '5px')
  2599.                 )
  2600.             ),
  2601.             GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::IO_DESTINAZIONI . ']', '', 'carrello_destinazioni', 'carrello'),
  2602.             GJS_Components::CreaSelect(
  2603.                 $radice . '[' . Costanti::IO_DESTINAZIONI . ']',
  2604.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_DESTINAZIONI,
  2605.                 Costanti::LYT_DELIMITATORE_ENTITA . 'App:Destinazioni.ragioneSociale+\' - \'+indirizzo+\' - \'+citta' . Costanti::LYT_DELIMITATORE_ENTITA,
  2606.                 array('form-control'),
  2607.                 array('style' => array(
  2608.                     'padding-left' => '5px',
  2609.                     'padding-right' => '5px')
  2610.                 )
  2611.             ),
  2612.             GJS_Components::CreaButton(
  2613.                 $radice . '[' . Costanti::IO_INVIO_ORDINE . ']',
  2614.                 $radice . ($radice != '' ? '_' : '') . Costanti::IO_INVIO_ORDINE,
  2615.                 'submit',
  2616.                 array('btn', 'btn-success'),
  2617.                 array('style' => array(
  2618.                     'padding-left' => '5px',
  2619.                     'padding-right' => '5px')
  2620.                 ),
  2621.                 array(
  2622.                     'content' => 'carrello_completa_btn',
  2623.                 ),
  2624.                 'carrello_completa_btn',
  2625.                 'carrello'
  2626.             )
  2627.         );
  2628.         if(!$ancheRegistrazioneUtente){
  2629.             array_push($ritorno, GJS_Components::CreaInput(
  2630.                 $radice . '[' . Costanti::FORM_TOKEN . ']',
  2631.                 $radice . ($radice != '' ? '_' : '') . Costanti::FORM_TOKEN,
  2632.                 'input',
  2633.                 'hidden',
  2634.                 array(),
  2635.                 array('value' => '%££%' . Costanti::RU_RADICE_FORM . '.children._token.vars.value%££%')
  2636.             ));
  2637.         }
  2638.         return $ritorno;
  2639.     }
  2640.     /**
  2641.      * @param string $radice
  2642.      * @param false $daCheckoutCarrello
  2643.      * @return array
  2644.      */
  2645.     public static function RitornaElementiRegistrazioneUtentePerEditorJSON($radice = 'form', $daCheckoutCarrello = false)
  2646.     {
  2647.         $ritorno = GJS_Components::CreaRadio(
  2648.             $radice . '[' . Costanti::RU_AZIENDA_O_PRIVATO . ']',
  2649.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_AZIENDA_O_PRIVATO,
  2650.             array(
  2651.                 'azienda' => GJS_Components::CreaElementoDizionario(
  2652.                     $radice . '[' . Costanti::RU_AZIENDA_O_PRIVATO . ']',
  2653.                     '',
  2654.                     'dati_utente_azienda',
  2655.                     'dati_utente'
  2656.                 ),
  2657.                 'privato' => GJS_Components::CreaElementoDizionario(
  2658.                     $radice . '[' . Costanti::RU_AZIENDA_O_PRIVATO . ']',
  2659.                     '',
  2660.                     'dati_utente_privato',
  2661.                     'dati_utente'
  2662.                 )
  2663.             )
  2664.         );
  2665.         array_push($ritorno,
  2666.         GJS_Components::CreaInput(
  2667.             $radice . '[' . Costanti::FORM_TOKEN . ']',
  2668.             $radice . ($radice != '' ? '_' : '') . Costanti::FORM_TOKEN,
  2669.             'input',
  2670.             'hidden',
  2671.             array(),
  2672.             array('value' => '%££%' . Costanti::RU_RADICE_FORM . '.children._token.vars.value%££%')
  2673.         ),
  2674.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_RAGIONE_SOCIALE . ']', '', 'dati_utente_ragione_sociale', 'dati_utente'),
  2675.         GJS_Components::CreaInput(
  2676.             $radice . '[' . Costanti::RU_RAGIONE_SOCIALE . ']',
  2677.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_RAGIONE_SOCIALE,
  2678.             'input',
  2679.             'text',
  2680.             array('form-control', 'input-sm'),
  2681.             array('style' => array(
  2682.                 'padding-left' => '5px',
  2683.                 'padding-right' => '5px')
  2684.             )
  2685.         ),
  2686.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_NOME . ']', '', 'dati_utente_nome', 'dati_utente'),
  2687.         GJS_Components::CreaInput(
  2688.             $radice . '[' . Costanti::RU_NOME . ']',
  2689.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_NOME,
  2690.             'input',
  2691.             'text',
  2692.             array('form-control'),
  2693.             array('style' => array(
  2694.                 'padding-left' => '5px',
  2695.                 'padding-right' => '5px')
  2696.             )
  2697.         ),
  2698.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_COGNOME . ']', '', 'dati_utente_cognome', 'dati_utente'),
  2699.         GJS_Components::CreaInput(
  2700.             $radice . '[' . Costanti::RU_COGNOME . ']',
  2701.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_COGNOME,
  2702.             'input',
  2703.             'text',
  2704.             array('form-control'),
  2705.             array('style' => array(
  2706.                 'padding-left' => '5px',
  2707.                 'padding-right' => '5px')
  2708.             )
  2709.         ),
  2710.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_CODICE_FISCALE . ']', '', 'dati_utente_codice_fiscale', 'dati_utente'),
  2711.         GJS_Components::CreaInput(
  2712.             $radice . '[' . Costanti::RU_CODICE_FISCALE . ']',
  2713.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_CODICE_FISCALE,
  2714.             'input',
  2715.             'text',
  2716.             array('form-control'),
  2717.             array('style' => array(
  2718.                 'padding-left' => '5px',
  2719.                 'padding-right' => '5px')
  2720.             )
  2721.         ),
  2722.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_PARTITA_IVA . ']', '', 'dati_utente_partita_iva', 'dati_utente'),
  2723.         GJS_Components::CreaInput(
  2724.             $radice . '[' . Costanti::RU_PARTITA_IVA . ']',
  2725.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_PARTITA_IVA,
  2726.             'input',
  2727.             'text',
  2728.             array('form-control'),
  2729.             array('style' => array(
  2730.                 'padding-left' => '5px',
  2731.                 'padding-right' => '5px')
  2732.             )
  2733.         ),
  2734.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_INDIRIZZO . ']', '', 'dati_utente_indirizzo', 'dati_utente'),
  2735.         GJS_Components::CreaInput(
  2736.             $radice . '[' . Costanti::RU_INDIRIZZO . ']',
  2737.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_INDIRIZZO,
  2738.             'input',
  2739.             'text',
  2740.             array('form-control'),
  2741.             array('style' => array(
  2742.                 'padding-left' => '5px',
  2743.                 'padding-right' => '5px')
  2744.             )
  2745.         ),
  2746.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_CITTA . ']', '', 'dati_utente_citta', 'dati_utente'),
  2747.         GJS_Components::CreaInput(
  2748.             $radice . '[' . Costanti::RU_CITTA . ']',
  2749.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_CITTA,
  2750.             'input',
  2751.             'text',
  2752.             array('form-control'),
  2753.             array('style' => array(
  2754.                 'padding-left' => '5px',
  2755.                 'padding-right' => '5px')
  2756.             )
  2757.         ),
  2758.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_PROVINCIA . ']', '', 'dati_utente_provincia', 'dati_utente'),
  2759.         GJS_Components::CreaInput(
  2760.             $radice . '[' . Costanti::RU_PROVINCIA . ']',
  2761.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_PROVINCIA,
  2762.             'input',
  2763.             'text',
  2764.             array('form-control'),
  2765.             array('style' => array(
  2766.                 'padding-left' => '5px',
  2767.                 'padding-right' => '5px')
  2768.             )
  2769.         ),
  2770.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_CAP . ']', '', 'dati_utente_cap', 'dati_utente'),
  2771.         GJS_Components::CreaInput(
  2772.             $radice . '[' . Costanti::RU_CAP . ']',
  2773.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_CAP,
  2774.             'input',
  2775.             'text',
  2776.             array('form-control'),
  2777.             array('style' => array(
  2778.                 'padding-left' => '5px',
  2779.                 'padding-right' => '5px')
  2780.             )
  2781.         ),
  2782.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_STATO . ']', '', 'dati_utente_nazione', 'dati_utente'),
  2783.         GJS_Components::CreaSelect(
  2784.             $radice . '[' . Costanti::RU_STATO . ']',
  2785.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_STATO,
  2786.             Costanti::LYT_DELIMITATORE_ENTITA . 'App:Nazioni.descrizione' . Costanti::LYT_DELIMITATORE_ENTITA,
  2787.             array('form-control'),
  2788.             array('style' => array(
  2789.                 'padding-left' => '5px',
  2790.                 'padding-right' => '5px')
  2791.             )
  2792.         ),
  2793.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_TELEFONO . ']', '', 'dati_utente_cellulare', 'dati_utente'),
  2794.         GJS_Components::CreaInput(
  2795.             $radice . '[' . Costanti::RU_TELEFONO . ']',
  2796.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_TELEFONO,
  2797.             'input',
  2798.             'tel',
  2799.             array('form-control'),
  2800.             array('style' => array(
  2801.                 'padding-left' => '5px',
  2802.                 'padding-right' => '5px')
  2803.             )
  2804.         ),
  2805.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_FAX . ']', '', 'dati_utente_fax', 'dati_utente'),
  2806.         GJS_Components::CreaInput(
  2807.             $radice . '[' . Costanti::RU_FAX . ']',
  2808.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_FAX,
  2809.             'input',
  2810.             'tel',
  2811.             array('form-control'),
  2812.             array('style' => array(
  2813.                 'padding-left' => '5px',
  2814.                 'padding-right' => '5px')
  2815.             )
  2816.         ),
  2817.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_INDIRIZZO_MAIL . ']', '', 'dati_utente_email', 'dati_utente'),
  2818.         GJS_Components::CreaInput(
  2819.             $radice . '[' . Costanti::RU_INDIRIZZO_MAIL . ']',
  2820.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_INDIRIZZO_MAIL,
  2821.             'input',
  2822.             'email',
  2823.             array('form-control'),
  2824.             array('style' => array(
  2825.                 'padding-left' => '5px',
  2826.                 'padding-right' => '5px')
  2827.             )
  2828.         ),
  2829.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_INDIRIZZO_PEC . ']', '', 'dati_utente_indirizzo_pec', 'dati_utente'),
  2830.         GJS_Components::CreaInput(
  2831.             $radice . '[' . Costanti::RU_INDIRIZZO_PEC . ']',
  2832.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_INDIRIZZO_PEC,
  2833.             'input',
  2834.             'email',
  2835.             array('form-control'),
  2836.             array('style' => array(
  2837.                 'padding-left' => '5px',
  2838.                 'padding-right' => '5px')
  2839.             )
  2840.         ),
  2841.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_CODICE_DESTINATARIO_FATTURAZIONE_ELETTRONICA . ']', '', 'dati_utente_codice_destinatario_fattura_elettronica', 'dati_utente'),
  2842.         GJS_Components::CreaInput(
  2843.             $radice . '[' . Costanti::RU_CODICE_DESTINATARIO_FATTURAZIONE_ELETTRONICA . ']',
  2844.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_CODICE_DESTINATARIO_FATTURAZIONE_ELETTRONICA,
  2845.             'input',
  2846.             'text',
  2847.             array('form-control'),
  2848.             array('style' => array(
  2849.                 'padding-left' => '5px',
  2850.                 'padding-right' => '5px')
  2851.             )
  2852.         ),
  2853.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DESTINAZIONE_DIVERSA . ']', '', 'carrello_rdu_destinazione_diversa', 'carrello'),
  2854.         GJS_Components::CreaCheckbox(
  2855.             $radice . '[' . Costanti::RU_DESTINAZIONE_DIVERSA . ']',
  2856.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DESTINAZIONE_DIVERSA,
  2857.             array('form-control'),
  2858.             array('style' => array(
  2859.                 'padding-left' => '5px',
  2860.                 'padding-right' => '5px')
  2861.             )
  2862.         ),
  2863.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DD_RAGIONE_SOCIALE . ']', '', 'dati_utente_destinazione_ragione_sociale', 'dati_utente'),
  2864.         GJS_Components::CreaInput(
  2865.             $radice . '[' . Costanti::RU_DD_RAGIONE_SOCIALE . ']',
  2866.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DD_RAGIONE_SOCIALE,
  2867.             'input',
  2868.             'text',
  2869.             array('form-control'),
  2870.             array('style' => array(
  2871.                 'padding-left' => '5px',
  2872.                 'padding-right' => '5px')
  2873.             )
  2874.         ),
  2875.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DD_INDIRIZZO . ']', '', 'dati_utente_destinazione_indirizzo', 'dati_utente'),
  2876.         GJS_Components::CreaInput(
  2877.             $radice . '[' . Costanti::RU_DD_INDIRIZZO . ']',
  2878.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DD_INDIRIZZO,
  2879.             'input',
  2880.             'text',
  2881.             array('form-control'),
  2882.             array('style' => array(
  2883.                 'padding-left' => '5px',
  2884.                 'padding-right' => '5px')
  2885.             )
  2886.         ),
  2887.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DD_CITTA . ']', '', 'dati_utente_destinazione_citta', 'dati_utente'),
  2888.         GJS_Components::CreaInput(
  2889.             $radice . '[' . Costanti::RU_DD_CITTA . ']',
  2890.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DD_CITTA,
  2891.             'input',
  2892.             'text',
  2893.             array('form-control'),
  2894.             array('style' => array(
  2895.                 'padding-left' => '5px',
  2896.                 'padding-right' => '5px')
  2897.             )
  2898.         ),
  2899.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DD_PROVINCIA . ']', '', 'dati_utente_destinazione_provincia', 'dati_utente'),
  2900.         GJS_Components::CreaInput(
  2901.             $radice . '[' . Costanti::RU_DD_PROVINCIA . ']',
  2902.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DD_PROVINCIA,
  2903.             'input',
  2904.             'text',
  2905.             array('form-control'),
  2906.             array('style' => array(
  2907.                 'padding-left' => '5px',
  2908.                 'padding-right' => '5px')
  2909.             )
  2910.         ),
  2911.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DD_CAP . ']', '', 'dati_utente_destinazione_cap', 'dati_utente'),
  2912.         GJS_Components::CreaInput(
  2913.             $radice . '[' . Costanti::RU_DD_CAP . ']',
  2914.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DD_CAP,
  2915.             'input',
  2916.             'text',
  2917.             array('form-control'),
  2918.             array('style' => array(
  2919.                 'padding-left' => '5px',
  2920.                 'padding-right' => '5px')
  2921.             )
  2922.         ),
  2923.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DD_TELEFONO . ']', '', 'dati_utente_destinazione_telefono', 'dati_utente'),
  2924.         GJS_Components::CreaInput(
  2925.             $radice . '[' . Costanti::RU_DD_TELEFONO . ']',
  2926.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DD_TELEFONO,
  2927.             'input',
  2928.             'text',
  2929.             array('form-control'),
  2930.             array('style' => array(
  2931.                 'padding-left' => '5px',
  2932.                 'padding-right' => '5px')
  2933.             )
  2934.         ),
  2935.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DD_STATO . ']', '', 'dati_utente_destinazione_nazione', 'dati_utente'),
  2936.         GJS_Components::CreaSelect(
  2937.             $radice . '[' . Costanti::RU_DD_STATO . ']',
  2938.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DD_STATO,
  2939.             Costanti::LYT_DELIMITATORE_ENTITA . 'App:Nazioni.descrizione' . Costanti::LYT_DELIMITATORE_ENTITA,
  2940.             array('form-control'),
  2941.             array('style' => array(
  2942.                 'padding-left' => '5px',
  2943.                 'padding-right' => '5px')
  2944.             )
  2945.         ),
  2946.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_DD_INDIRIZZO_MAIL . ']', '', 'dati_utente_destinazione_mail', 'dati_utente'),
  2947.         GJS_Components::CreaInput(
  2948.             $radice . '[' . Costanti::RU_DD_INDIRIZZO_MAIL . ']',
  2949.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_DD_INDIRIZZO_MAIL,
  2950.             'input',
  2951.             'email',
  2952.             array('form-control'),
  2953.             array('style' => array(
  2954.                 'padding-left' => '5px',
  2955.                 'padding-right' => '5px')
  2956.             )
  2957.         ),GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_USERNAME . ']', '', 'dati_utente_username', 'dati_utente'),
  2958.             GJS_Components::CreaInput(
  2959.                 $radice . '[' . Costanti::RU_USERNAME . ']',
  2960.                 $radice . ($radice != '' ? '_' : '') . Costanti::RU_USERNAME,
  2961.                 'input',
  2962.                 'text',
  2963.                 array('form-control'),
  2964.                 array('style' => array(
  2965.                     'padding-left' => '5px',
  2966.                     'padding-right' => '5px')
  2967.                 )
  2968.             ),
  2969.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_PASSWORD . ']', '', 'dati_utente_password', 'dati_utente'),
  2970.         GJS_Components::CreaInput(
  2971.             $radice . '[' . Costanti::RU_PASSWORD . ']',
  2972.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_PASSWORD,
  2973.             'input',
  2974.             'password',
  2975.             array('form-control'),
  2976.             array('style' => array(
  2977.                 'padding-left' => '5px',
  2978.                 'padding-right' => '5px')
  2979.             )
  2980.         ),
  2981.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_RIPETI_PASSWORD . ']', '', 'dati_utente_ripeti_password', 'dati_utente'),
  2982.         GJS_Components::CreaInput(
  2983.             $radice . '[' . Costanti::RU_RIPETI_PASSWORD . ']',
  2984.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_RIPETI_PASSWORD,
  2985.             'input',
  2986.             'password',
  2987.             array('form-control'),
  2988.             array(),
  2989.             array('style' => array(
  2990.                 'padding-left' => '5px',
  2991.                 'padding-right' => '5px')
  2992.             )
  2993.         ),
  2994.         GJS_Components::CreaElementoDizionario($radice . '[' . Costanti::RU_PRIVACY . ']', '', 'carrello_privacy_esprimo_il_consenso', 'carrello'),
  2995.         GJS_Components::CreaCheckbox(
  2996.             $radice . '[' . Costanti::RU_PRIVACY . ']',
  2997.             $radice . ($radice != '' ? '_' : '') . Costanti::RU_PRIVACY,
  2998.             array('form-control'),
  2999.             array(
  3000.                 'style' => array(
  3001.                     'padding-left' => '5px',
  3002.                     'padding-right' => '5px'),
  3003.             )
  3004.         ));
  3005.         if(!$daCheckoutCarrello) {
  3006.             array_push($ritorno,
  3007.                 GJS_Components::CreaButton(
  3008.                     $radice . '[' . Costanti::RU_REGISTRA . ']',
  3009.                     $radice . ($radice != '' ? '_' : '') . Costanti::RU_REGISTRA,
  3010.                     'submit',
  3011.                     array('btn', 'btn-success'),
  3012.                     array(),
  3013.                     array(
  3014.                         'btn-linkautomatico' => 'pfc_completa',
  3015.                         'content' => 'dati_utente_registra_btn',
  3016.                         'style' => array(
  3017.                             'padding-left' => '5px',
  3018.                             'padding-right' => '5px')
  3019.                     ),
  3020.                     'dati_utente_registra_btn',
  3021.                     'dati_utente'
  3022.                 ));
  3023.         }
  3024.         return $ritorno;
  3025.     }
  3026. }