MRW.it Forum
  • Home
  • Forum
  • Fare Web
  • PHP

SELECT che popola in contemporanea un DIV e un'altra SELECT

  • Creatore Discussione Creatore Discussione claudiovis
  • Data di inizio Data di inizio 29 Ott 2015
C

claudiovis

Nuovo Utente
1 Ott 2015
12
0
0
  • 29 Ott 2015
  • #1
Ciao a tutti
tempo fa avevo usato un esempio di select concatenate per ottenere un elenco di punti vendita cercati da regioni/comuni/cap
scegli prima la regione ... poi il comune e quando scegli il CAP mostra i risultati.
ora avrei bisogno di mostrare i risultati alla scelta del comune ed eventualmente filtrarli col cap.

index.php
Codice:
<?php session_start();
session_unset();
session_destroy();

session_start();
$_SESSION["codice"] =  "$_GET[productName]";

?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<link href="screen.css" rel="stylesheet" type="text/css" />
<title>Cerca punto vendita</title>

	<script type="text/javascript">
	$(document).ready(function(){

		var scegli = '<option value="0">Scegli...</option>';
		var attendere = '<option value="0">Attendere...</option>';
		
		$("select#comuni").html(scegli);
		$("select#comuni").attr("disabled", "disabled");
		$("select#cap").html(scegli);
		$("select#cap").attr("disabled", "disabled");
		
		
		$("select#province").change(function(){
			var regione = $("select#province option:selected").attr('value');
			$("select#comuni").html(attendere);
			$("select#comuni").attr("disabled", "disabled");
			$("select#cap").html(scegli);
			$("select#cap").attr("disabled", "disabled");
			
			$.post("select.php", {provincia:regione}, function(data){
				$("select#comuni").removeAttr("disabled"); 
				$("select#comuni").html(data);	
			});
		});	
		
		$("select#comuni").change(function(){
			$("select#cap").attr("disabled", "disabled");
			$("select#cap").html(attendere);
			var provincia = $("select#comuni option:selected").attr('value');
			$.post("select.php", {city:provincia}, function(data){
				$("select#cap").removeAttr("disabled");
				$("select#cap").html(data);	
			});
		});	

		/*****/
		$("select#cap").change(function(){
			$("#puntiv").html(attendere);
			var pvend = $("select#cap option:selected").attr('value');
			$.post("select.php", {cap:pvend}, function(data){
				/*$("select#puntiv").removeAttr("disabled");*/
				$("#puntiv").html(data);	
			});
		});	
		/****/
	});
	
	</script>

<?php 
include_once 'select.class.php';
$opt = new SelectList();

?>
<body>
	<div id="pvcontainer">
	
	<h1>Cerca punto vendita</h1>
	<div class="row">
	 Cerca il punto vendita più vicino a te 
    </div>
    <p>&nbsp;</p>    <p>&nbsp;</p>
    <div style="clear:both"></div>
		<form action="?" id="myform">
      
        	<div class="sel">Seleziona una Provincia:<br />
			<select id="province">
				<?php echo $opt->ShowProvince(); ?>
			</select>
			</div>
		
			<div class="sel">Seleziona una Città:<br />
			<select id="comuni">
			<option>Scegli...</option>
			</select>
			</div>
		
			<div class="sel">Seleziona un cap:<br />
			<select id="cap" >
			<option>Scegli...</option>
			</select>
            </div>
<div style="clear:both"></div>
            <div id="puntiv">
            
            </div>
		</div>
        <style>
			button.hov:hover{ background:#d4721b;border:1px solid #d4721b;}
			</style>
           
	</form>

  <div >
</body>

select.php
Codice:
<?php session_start();

include_once  'select.class.php';
$opt = new SelectList();

if(isset($_POST['provincia']))
{	
	echo $opt->ShowComuni();
	die;
}

if(isset($_POST['city']))
{

	echo $opt->ShowCap();
	die;
}
if(isset($_POST['cap']))
{
	echo $opt->ShowPuntivendita();
	die;
}


?>

select.class.php
Codice:
<?php

if(!isset($_SESSION)){
    session_start();
}

class SelectList
{
	
	protected $conn;
	
		public function __construct()
		{
			$this->DbConnect();
		}
	
		protected function DbConnect()
		{
			include "db_config.php";
			
			$this->conn = mysql_connect($host,$user,$password) OR die("Impossibile connettersi al database");
			mysql_select_db($db,$this->conn) OR die("Impossibile selezionare il database $db");
			
			return TRUE;
		}
		
		public function ShowProvince()
		{
			$sql = "SELECT DISTINCT provincia FROM prodotto_p_vendita ";
			$res = mysql_query($sql,$this->conn);
			$regioni = '<option value="0">scegli...</option>';
			
				while($row = mysql_fetch_array($res))
				{
					$regioni .= '<option value="' . $row['provincia']  .'">'. utf8_encode($row['provincia']) .'</option>';
				}
				
			return $regioni;
		}
		
		public function ShowComuni()
		{
			
			$sql = "SELECT DISTINCT city FROM prodotto_p_vendita WHERE provincia='$_POST[provincia]'";
			$res = mysql_query($sql,$this->conn);
			$province = '<option value="0">scegli...</option>';
			
				while($row = mysql_fetch_array($res))
				{
					$province .= '<option value="' . $row['city'] . '">'. utf8_encode($row['city']) . '</option>';
				}
				
			return $province;
		}
		
		public function ShowCap()
		{
			$sql = "SELECT DISTINCT cap FROM prodotto_p_vendita WHERE city='$_POST[city]'";		
			$res = mysql_query($sql,$this->conn);	
			$comuni = '<option value="0">scegli...</option>';
			
				while($row = mysql_fetch_array($res))
				{
					$comuni .= '<option value="' . $row['cap'] . '">' . $row['cap'] .'</option>';
					
				}
					return $comuni;
						}
		
		
	

		public function ShowPuntivendita()
		
			{
			
			$test = $_SESSION['codice'] ;				
			$sql = "SELECT  distinct t1.name, t1.address, t1.phoneno,ifnull(( select  t2.famiglia FROM prodotto_p_vendita as t2 
          where t2.cap='$_POST[cap]' and t2.name=t1.name and t2.address=t1.address and t2.phoneno=t1.phoneno and t2.famiglia='$test' LIMIT 1),'') as descriptionart
          
FROM prodotto_p_vendita as t1 WHERE t1.cap='$_POST[cap]' order BY name, descriptionart";
			$res = mysql_query($sql,$this->conn);
			$puntiv = '<p>PUNTI VENDITA:</p><div class="rowtop"><div class="col1">Nome</div><div class="col2">Indirizzo</div><div class="col3">Telefono</div><div class="col4"></div></div>';
			
				while($row = mysql_fetch_array($res))
				{
			
				$puntiv .=  '<div class="row"><div class="col1">' .$row['name'] . '</div><div class="col2">' . $row['address'] . '</div><div class="col3">' . utf8_encode($row['phoneno']) .'</div><div class="col4">'. $row['descriptionart'] .'</div></div>';
				
				}
			return $puntiv;
		

		}
		
		/*******/
		
}



?>

questi erano i file di origine ... ora le mie modifiche:

se modifico index.php con
Codice:
$("select#comuni").change(function(){
			$("select#cap").attr("disabled", "disabled");
			$("select#cap").html(attendere);
			var provincia = $("select#comuni option:selected").attr('value');
			$.post("select.php", {city:provincia}, function(data){
				$("select#cap").removeAttr("disabled");
				$("select#cap").html(data);	
			});
			$("#puntiv").html(attendere);
			var pvend = $("select#comuni option:selected").attr('value');
			$.post("select.php", {city:pvend}, function(data){
				/*$("#puntiv").removeAttr("disabled");*/
				$("#puntiv").html(data);	
			});
		});

e in class.php aggiungo
Codice:
if(isset($_POST['city']))
{
	echo $opt->ShowPuntivendita1();
	echo $opt->ShowCap();
	die;
}
e in select.class.php aggiungo
Codice:
public function ShowPuntivendita1()
		{
			
			$test = $_SESSION['codice'] ;				
			$sql1 = "SELECT  distinct t1.name, t1.address, t1.phoneno,ifnull(( select  t2.famiglia FROM prodotto_p_vendita as t2 
          where t2.city='$_POST[city]' and t2.name=t1.name and t2.address=t1.address and t2.phoneno=t1.phoneno and t2.famiglia='$test' LIMIT 1),'') as descriptionart
          
FROM prodotto_p_vendita as t1 WHERE t1.city='$_POST[city]' order BY name, descriptionart";
			$res1 = mysql_query($sql1,$this->conn);
			$puntiv = '<p>PUNTI VENDITA:</p><div class="rowtop"><div class="col1">Nome</div><div class="col2">Indirizzo</div><div class="col3">Telefono</div><div class="col4"></div></div>';
			
				while($row1 = mysql_fetch_array($res1))
				{
			
				$puntiv .=  '<div class="row"><div class="col1">' .$row1['name'] . '</div><div class="col2">' . $row1['address'] . '</div><div class="col3">' . utf8_encode($row1['phoneno']) .'</div><div class="col4">'. $row1['descriptionart'] .'</div></div>';
				
				}
			return $puntiv;
		}

ottengo che alla scelta del comune mi popola correttamente la select dei CAP
e mi popola anche i puntivendita... ma mostra anche i cap dentro il div dei puntivendita... come posso eliminarli?

spero di essermi spiegato...
..grazie a chi vorrà aiutarmi a capire
 
Ultima modifica: 29 Ott 2015
C

claudiovis

Nuovo Utente
1 Ott 2015
12
0
0
  • 30 Ott 2015
  • #2
tante visite... e nesusna risposta.

quindi le possibilità sono due.

o è particolarmente complicato :crying: .... oppure ho scritto troppa roba e ci si rompe a leggere tutto!!
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 30 Ott 2015
  • #3
claudiovis ha scritto:
tante visite... e nesusna risposta.

quindi le possibilità sono due.

o è particolarmente complicato :crying: .... oppure ho scritto troppa roba e ci si rompe a leggere tutto!!
Clicca per allargare...

no nessuna delle due,
per essere sicuro del suggerimento, ho eseguito il codice che hai postato ma ... è necessario creare l'ambiente di prova
il solo codice non basta,
nel frattempo ho scaricato la tabella dei comuni ma è necessario ... tempo
ciao
 
C

claudiovis

Nuovo Utente
1 Ott 2015
12
0
0
  • 30 Ott 2015
  • #4
marino51 ha scritto:
no nessuna delle due,
per essere sicuro del suggerimento, ho eseguito il codice che hai postato ma ... è necessario creare l'ambiente di prova
il solo codice non basta,
nel frattempo ho scaricato la tabella dei comuni ma è necessario ... tempo
ciao
Clicca per allargare...

hai ragione... scusami!!:fonzie:
...aspetto con ansia qualche test
grazie
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 30 Ott 2015
  • #5
dal codice, capisco che
scegli la provincia,
poi il comune
quindi rifinisci la ricerca con il cap, credo, nel caso di città con + cap
visualizzando i punti vendita

vorresti cambiare l'ordine con,
scelta della provincia,
scelta del comune
visualizzazione punti vendita e valorizzazione select CAP
per rifinire se necessario con CAP (già valorizzato)

ho modificato index.php con la nuova chiamata ajax
PHP:
		$("select#comuni").change(function(){
			alert('select#comuni');
			$("select#cap").attr("disabled", "disabled");
			$("select#cap").html(attendere);
			var provincia = $("select#comuni option:selected").attr('value');
			$.post("select.php", {city:provincia}, function(data){
				$("select#cap").removeAttr("disabled");
				$("select#cap").html(data);
			});
			$.post("select.php", {MYCITY:provincia}, function(data){
				/*$("select#puntiv").removeAttr("disabled");*/
				$("#puntiv").html(data);
			});
		});

di conseguenza ho modificato select.php aggiungendo,
PHP:
if(isset($_POST['MYCITY']))
{
	echo $opt->ShowPuntivenditaCITY();
	die;
}

e quindi la modifica di select.class.php aggiungendo,
PHP:
public function ShowPuntivenditaCITY()
	{
........ qui il codice che seleziona i punti vendita per comune
	}

questa è la sequenza delle operazioni
[30-Oct-2015 22:46:16 Europe/Rome]
[30-Oct-2015 22:46:16 Europe/Rome] main : index
[30-Oct-2015 22:46:16 Europe/Rome] function ShowProvince
[30-Oct-2015 22:46:16 Europe/Rome] SELECT DISTINCT nomeProvincia as provincia, siglaProvincia FROM province
[30-Oct-2015 22:46:57 Europe/Rome]
[30-Oct-2015 22:46:57 Europe/Rome] main : select
[30-Oct-2015 22:46:57 Europe/Rome] function ShowComuni
[30-Oct-2015 22:46:57 Europe/Rome] SELECT DISTINCT Comune as city FROM comuni WHERE provincia='BG'
[30-Oct-2015 22:47:28 Europe/Rome]
[30-Oct-2015 22:47:28 Europe/Rome] main : select
[30-Oct-2015 22:47:28 Europe/Rome] function ShowCap
[30-Oct-2015 22:47:28 Europe/Rome] SELECT DISTINCT CAP as cap FROM comuni WHERE Comune='Azzano San Paolo'
[30-Oct-2015 22:47:28 Europe/Rome]
[30-Oct-2015 22:47:28 Europe/Rome] main : select
[30-Oct-2015 22:47:28 Europe/Rome] function ShowPuntivenditaCITY
[30-Oct-2015 22:47:28 Europe/Rome]
SELECT distinct 'nameI' as name, 'addressI' as address, 'phonenoI' as phoneno, 'famigliaI' as descriptionart union
SELECT distinct 'nameH' as name, 'addressH' as address, 'phonenoH' as phoneno, 'famigliaH' as descriptionart union
SELECT distinct 'nameG' as name, 'addressG' as address, 'phonenoG' as phoneno, 'famigliaG' as descriptionart union
SELECT distinct 'nameF' as name, 'addressF' as address, 'phonenoF' as phoneno, 'famigliaF' as descriptionart union
SELECT distinct 'nameE' as name, 'addressE' as address, 'phonenoE' as phoneno, 'famigliaE' as descriptionart union
SELECT distinct 'nameD' as name, 'addressD' as address, 'phonenoD' as phoneno, 'famigliaD' as descriptionart union
SELECT distinct 'nameC' as name, 'addressC' as address, 'phonenoC' as phoneno, 'famigliaC' as descriptionart union
SELECT distinct 'nameB' as name, 'addressB' as address, 'phonenoB' as phoneno, 'famigliaB' as descriptionart union
SELECT distinct 'nameA' as name, 'addressA' as address, 'phonenoA' as phoneno, 'famigliaA' as descriptionart
order BY name, descriptionart

[30-Oct-2015 22:48:02 Europe/Rome]
[30-Oct-2015 22:48:02 Europe/Rome] main : select
[30-Oct-2015 22:48:02 Europe/Rome] function ShowPuntivendita
[30-Oct-2015 22:48:02 Europe/Rome]
SELECT distinct 'name9' as name, 'address9' as address, 'phoneno9' as phoneno, 'famiglia9' as descriptionart union
SELECT distinct 'name8' as name, 'address8' as address, 'phoneno8' as phoneno, 'famiglia8' as descriptionart union
SELECT distinct 'name7' as name, 'address7' as address, 'phoneno7' as phoneno, 'famiglia7' as descriptionart union
SELECT distinct 'name6' as name, 'address6' as address, 'phoneno6' as phoneno, 'famiglia6' as descriptionart union
SELECT distinct 'name5' as name, 'address5' as address, 'phoneno5' as phoneno, 'famiglia5' as descriptionart union
SELECT distinct 'name4' as name, 'address4' as address, 'phoneno4' as phoneno, 'famiglia4' as descriptionart union
SELECT distinct 'name3' as name, 'address3' as address, 'phoneno3' as phoneno, 'famiglia3' as descriptionart union
SELECT distinct 'name2' as name, 'address2' as address, 'phoneno2' as phoneno, 'famiglia2' as descriptionart union
SELECT distinct 'name1' as name, 'address1' as address, 'phoneno1' as phoneno, 'famiglia1' as descriptionart
order BY name, descriptionart
Clicca per allargare...

questo è il risultato
inizio
scelgo la provincia
scelgo il comune, valorizzando cap e punti vendita
rifinitura con cap

è corretto ?
ciao
Marino

ps, non badare alle query un poco modificate ma uso mssql e pdo e non ho il db con le tue strutture
 
Ultima modifica: 30 Ott 2015
C

claudiovis

Nuovo Utente
1 Ott 2015
12
0
0
  • 2 Nov 2015
  • #6
mitico!! :tifoso:
funziona alla perfezione!
grazie mille!!
 
C

claudiovis

Nuovo Utente
1 Ott 2015
12
0
0
  • 17 Nov 2015
  • #7
Ciao @marino51
posso farti un'altra domanda?
se volessi che mi mostrasse i risultati al click su un bottone e non all' onChange della select come dovrei fare?

...magari che si possa inviare alla scelta del comune ed eventualmente poi alla rifinitura tramite cap

sarebbe da rifare da capo?
grazie mille
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 18 Nov 2015
  • #8
ho postato una risposta ma si è persa ..nell'etere, quindi rispondo ancora (sperando di non leggere 2 volte)
credo sia fattibile inserendo il bottone e agendo su "onclick", non ho il codice disponibile in questo momento ma questa sera provo a verificare
non dovrebbe essere necessario rifare tutto ma solo collocare le azioni nel punto giusto
ciao
Marino
 
C

claudiovis

Nuovo Utente
1 Ott 2015
12
0
0
  • 18 Nov 2015
  • #9
marino51 ha scritto:
ho postato una risposta ma si è persa ..nell'etere, quindi rispondo ancora (sperando di non leggere 2 volte)
credo sia fattibile inserendo il bottone e agendo su "onclick", non ho il codice disponibile in questo momento ma questa sera provo a verificare
non dovrebbe essere necessario rifare tutto ma solo collocare le azioni nel punto giusto
ciao
Marino
Clicca per allargare...

ciao, alla fine son riuscito ad utilizzare un altro metodo e a tracciare gli eventi all' onChange delle select
ma se hai un esempio (senza impegno) può servirmi ad imparare come modificarlo in caso di bisogno.
grazie mille per la disponibilità
 
C

claudiovis

Nuovo Utente
1 Ott 2015
12
0
0
  • 10 Feb 2016
  • #10
provo a riattaccarmi a questo post
... mi hanno chiesto di poter stampare (pdf o stampante) i risultati della ricerca.

inizio a cercare ma ...è complicato? ...ci posso riuscire? :book:
se avete consigli, tutorial, o altre risorse facili da aggiungere

0
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 10 Feb 2016
  • #11
ho trovato relativamente facile l'uso della classe FPDF,
FPDF permette la generazione di report anche abbastanza complessi,
da 1 pagina a diverse decine di pagine,
da una lista semplice, ad una lista con all'interno composizioni diverse, con anche un numero di colonne diverse

nel sito FPDF ci sono una buona quantità di script per varie necessità

ciao
Marino

ps, un semplicissimo esempio (tagliato per il suo contenuto)
 
C

claudiovis

Nuovo Utente
1 Ott 2015
12
0
0
  • 11 Feb 2016
  • #12
ma dove devo andare a fare le mie prove?

in ogni select che mostra i risultati?
in un file a parte ?
nell'index?

il procedimanto dovrebbe essere che

faccio le mie select (due o tre)
vedo i miei risultati ... a livello di comune o più filtrati a livello di cap

dopo se voglio salvarmi i risultati,
clicco su un bottone e mi viene generato il pdf di quei risultati che già vedo.
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 11 Feb 2016
  • #13
faccio le mie select (due o tre)
vedo i miei risultati ... a livello di comune o più filtrati a livello di cap

dopo se voglio salvarmi i risultati,
clicco su un bottone e mi viene generato il pdf di quei risultati che già vedo.
Clicca per allargare...
si proprio così, se i tuoi risultati sono in un'array .....

impiego meno tempo a postare un esempio e l'estensione della classe fpdf che uso,

credo sia intuitivo modificare l'esempio ed includerlo nella tua applicazione

ho lasciato nell'esensione tutti i metodi "CellFit", anche se non tutti usati,
un testo che deborda l'ampiezza assegnata, viene "costretto" nella sua colonna

nell'estensione ho commentato l'arrotondamento e la conversione delle date, perchè utilizzano delle funzioni,
si potranno riattivare sostituendo le mie funzioni

l'estensione andrebbe modificata solo nella parte che gestisce le specificità dei report,
altre modifiche potrebbero annullare "buone" funzionalità

gli elementi di "$header" indicano quante colonne devono essere incluse nel report oltre al loro nome
la query deve restituire le colonne nell'ordine riportato in "$header"

tutto funziona con la versione 1.7 di fpdf (che puoi scaricare dal sito fpdf.org

ciao
Marino

ps,
non mi interessano opinioni riguardanti variabili passate alla classe con "global"
chi ha di meglio é libero di postare il suo contributo


script di prova
PHP:
<?php

// gestione del db (giusto per far capire)
$sql = "SELECT tab_cod,tab_ele,tab_descr_1"
     . " FROM tabelle ORDER BY tab_cod,tab_ele";

// array con i dati selezionati, le colonne devono essere nell'ordine di presentazione del report
$data = $db->queryS($sql);



$swN = "RTAB"; // identificativo del report

require_once 'includes/Class_PDF.php';

$title = 'Lista delle tabelle di riferimento'; // titolo del report

$header[] = 'tabella';   // titolo delle colonne
$header[] = 'elemento';
$header[] = 'referenza';

$CellWidth = array(20,20,200); // ampiezza delle colonne
$CellRound = array( 0, 0,  0); // cifra su cui applicare arrotondamento, 99 = data


$HeaderCntrl = true;  // non modificare
$PageBreak   = true;  // non modificare
$fill        = false; // non modificare

$pdf = new PDF('L', 'mm', 'A4'); // landscape, misure in mm, formato A4

$pdf->SetAuthor("MG project");
$pdf->SetCreator("marino");
$pdf->SetSubject("tabelle");
$pdf->SetTitle($title);

$pdf->SetMargins(10,10,10);

$pdf->SetDrawColor(0,153,255);
$pdf->SetLineWidth(.4);
$pdf->AliasNbPages();

$pdf->AddPage();
$pdf->BodyTable();

$OPpdffile = $_SESSION['OPreportfolder'] . "\\" . $_SESSION['OPreportname'];

$pdf->Output("$OPpdffile", 'F');
?>


script Class_PDF.php
PHP:
<?php

require "FPDF/fpdf.php";

class PDF extends FPDF {

  //Cell with horizontal scaling if text is too wide
  function CellFit($CellWidth, $HeaderCntrl=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $scale=false, $force=true) {
    $str_width=$this->GetStringWidth($txt);

    //Calculate ratio to fit cell
    if($CellWidth==0) $CellWidth = $this->w-$this->rMargin-$this->x;
    $mg = $CellWidth-$this->cMargin*2;			// <------------- divisione zero
    if ($str_width == 0) $str_width = $mg;		// <------------- divisione zero
    $ratio = ($CellWidth-$this->cMargin*2)/$str_width;
    $fit = ($ratio < 1 || ($ratio > 1 && $force));
    if ($fit) {
      if ($scale) {
        //Calculate horizontal scaling
        $horiz_scale=$ratio*100.0;
        //Set horizontal scaling
        $this->_out(sprintf('BT %.2F Tz ET',$horiz_scale));
      } else {
        //Calculate character spacing in points
        $char_space=($CellWidth-$this->cMargin*2-$str_width)/max($this->MBGetStringLength($txt)-1,1)*$this->k;
        //Set character spacing
        $this->_out(sprintf('BT %.2F Tc ET',$char_space));
      }
      //Override user alignment (since text will fill up cell)
      $align='';
    }
    //Pass on to Cell method
    $this->Cell($CellWidth,$HeaderCntrl,$txt,$border,$ln,$align,$fill,$link);
    //Reset character spacing/horizontal scaling
    if ($fit) $this->_out('BT '.($scale ? '100 Tz' : '0 Tc').' ET');
  }
  //Cell with horizontal scaling only if necessary
  function CellFitScale($CellWidth, $HeaderCntrl=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') {
    $this->CellFit($CellWidth,$HeaderCntrl,$txt,$border,$ln,$align,$fill,$link,true,false);
  }
  //Cell with horizontal scaling always
  function CellFitScaleForce($CellWidth, $HeaderCntrl=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') {
    $this->CellFit($CellWidth,$HeaderCntrl,$txt,$border,$ln,$align,$fill,$link,true,true);
  }
  //Cell with character spacing only if necessary
  function CellFitSpace($CellWidth, $HeaderCntrl=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') {
    $this->CellFit($CellWidth,$HeaderCntrl,$txt,$border,$ln,$align,$fill,$link,false,false);
  }
  //Cell with character spacing always (Same as calling CellFit directly)
  function CellFitSpaceForce($CellWidth, $HeaderCntrl=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') {
    $this->CellFit($CellWidth,$HeaderCntrl,$txt,$border,$ln,$align,$fill,$link,false,true);
  }
  //Patch to also work with CJK double-byte text
  function MBGetStringLength($s) {
    if($this->CurrentFont['type']=='Type0') {
      $len = 0;
      $nbbytes = strlen($s);
      for ($i = 0; $i < $nbbytes; $i++) {
        if (ord($s[$i])<128) $len++;
        else {
          $len++;
          $i++;
      } }
      return $len;
    } else return strlen($s);
  }



  function Header() {
    global $HeaderCntrl,$CellWidth,$CellWidthSum,$title,$header;

    // TITLE
    $this->SetTextColor(0);
    $this->SetFont('Helvetica','B',16);
    $this->Cell(120,10,$title,0,1,'L');

    // HEADER
    //Colors, bold font
    $this->SetFillColor(0,153,255);
    $this->SetTextColor(255);
    $this->SetFont('Helvetica','B',10);

    for($i=0;$i<count($header);$i++)
      $this->Cell($CellWidth[$i],6,$header[$i],1,0,'C',1);
    $this->Ln();

    // SETTINGS FOR BODY and FOOTER PRINTING
    $CellWidthSum = array_sum($CellWidth);
    $HeaderCntrl = true;
  }

  function BodyTable() {
    global $swN,$HeaderCntrl,$CellWidth,$CellRound,$title,$header,$fill,$data;

    //now spool out the data from the $data array
    $PrevVal0 = "";
    $PrevVal1 = "";

    $ColCounter = count($header);
    foreach($data as $row) {

      $this->Cell(0,6,' ',0,0,'L'); // Check Page Break by empty cell
      $this->Ln(0);

      if ($HeaderCntrl) {
        $fill = false;
        $this->SetFillColor(178,178,178);
        $this->SetTextColor(0);
        $this->SetFont('');
      }

      for($i=0;$i<$ColCounter;$i++) {
        $valore = $row[$i];
        $textalign = "C";

//      if ( $CellRound[$i] == 99 )	$valore = dateUTCtoTZ($valore);
//      else
//        if ( $CellRound[$i] > 0 ) {	$valore = nf($valore, $CellRound[$i]);
//                                      $textalign = "R";                      }

        switch ($swN) {  // QUI SI POSSONO CONTROLLARE SPECIFICITA' DEI REPORT

          case "rep1":
            if (!$HeaderCntrl and $PrevVal0 == $row[0] and $i < 3) $valore = " ";
            break;

          case "rep2":
            if (!$HeaderCntrl and $PrevVal0 == $row[0]) {
              if ($i == 0) $valore = " ";
              if ($PrevVal1 == $row[1] and $i < 3) $valore = " ";
            }
            break;

          case "RTAB":
            if ($i == 2) $textalign = "L";
            break;
        }
        $this->CellFitScale($CellWidth[$i],6,$valore,'LR',0,$textalign,$fill);
      }
      $this->Ln();

      // flips from true to false and vise versa
      $fill =! $fill;

      $PrevVal0 = $row[0];
      $PrevVal1 = $row[1];
      $HeaderCntrl = false;
    }
  }

  function Footer() {
    global $CellWidthSum;

    $this->Cell($CellWidthSum,0,'','T');

    $this->SetY(-10);
    $this->SetFont('Helvetica','I',8);
    $this->Cell(0,0,'report di marino',0,0,'L');
    $this->Ln(0);
    $this->Cell(0,0,'Page '.$this->PageNo().'/{nb}',0,0,'C');
    $this->Ln(0);
    $this->Cell(0,0,date('e - l, F jS, Y - H:i:s'),0,0,'R');
  }
}
?>
 
Devi accedere o registrarti per poter rispondere.

Discussioni simili

S
Il metodo $.getJSON() e <select> che non si popola di dati per query troppo grandey
  • SAC07PA
  • 24 Apr 2017
  • Ajax
Risposte
0
Visite
1K
Ajax 24 Apr 2017
SAC07PA
S
L
Select Dinamiche...da txt?
  • lucign0l0
  • 17 Feb 2021
  • PHP
Risposte
3
Visite
1K
PHP 18 Feb 2021
marino51
R
Select concatenata che non funziona la seconda volta
  • _Rosy_
  • 29 Nov 2020
  • Ajax
Risposte
3
Visite
3K
Ajax 29 Nov 2020
WmbertSea
[PHP] 2 SELECT DINAMICHE
  • eraclio666
  • 9 Nov 2017
  • PHP
Risposte
8
Visite
3K
PHP 10 Nov 2017
marino51
T
PHP+MYSQL: una select che cerchi un campo vuoto
  • theseo
  • 27 Set 2017
  • PHP
Risposte
7
Visite
5K
PHP 29 Set 2017
theseo
T
G
[Javascript] select dinamiche
  • greghph27
  • 26 Lug 2017
  • Javascript
Risposte
0
Visite
3K
Javascript 26 Lug 2017
greghph27
G
T
[Javascript] un form con select dinamica che funzioni da menù...
  • theseo
  • 22 Feb 2017
  • Javascript
Risposte
2
Visite
3K
Javascript 22 Feb 2017
theseo
T
H
[PHP] Select dinamiche : regioni province comuni
  • hantos
  • 16 Nov 2016
  • PHP
Risposte
2
Visite
4K
PHP 17 Nov 2016
criric
H
select dinamiche php mysql
  • hantos
  • 9 Nov 2016
  • PHP
Risposte
4
Visite
5K
PHP 20 Dic 2017
franco5566
F
[PHP] form con select che non invia dati se con apostrofo
  • asevenx
  • 8 Ago 2016
  • PHP
Risposte
4
Visite
4K
PHP 10 Ago 2016
borgo italia
H
problema con select dinamiche e javascript
  • HyperX
  • 4 Set 2015
  • Javascript
Risposte
0
Visite
2K
Javascript 4 Set 2015
HyperX
H
W
Select dinamiche
  • WottaFacca
  • 30 Mar 2015
  • PHP
Risposte
3
Visite
2K
PHP 31 Mar 2015
WottaFacca
W
P
due select che non vanno d'accordo fra di loro
  • paperinik4
  • 20 Ott 2014
  • PHP
Risposte
4
Visite
1K
PHP 22 Ott 2014
paperinik4
P
P
la select che dovrebbe apaprire appare dopo l'inserimento di un record
  • paperinik4
  • 14 Ott 2014
  • PHP
Risposte
0
Visite
1K
PHP 14 Ott 2014
paperinik4
P
S
Salvare dei dati in una determinata tabella in base al select che l'utente seleziona
  • Soulfearor
  • 16 Set 2014
  • PHP
Risposte
8
Visite
3K
PHP 18 Set 2014
Altutto
A
  • Bloccata
Select dinamiche : regioni province comuni
  • criric
  • 16 Ago 2013
  • Snippet PHP
  • 2
Risposte
28
Visite
31K
Snippet PHP 26 Feb 2019
Max 1
S
Select dinamiche concatenate
  • sent89
  • 30 Mag 2013
  • Ajax
Risposte
8
Visite
6K
Ajax 27 Set 2013
criric
L
menu select che visualizza le cartelle di una cartella
  • luigi777
  • 17 Apr 2013
  • PHP
Risposte
16
Visite
2K
PHP 19 Apr 2013
luigi777
L
F
Problema select dinamiche con php e jquery
  • felix80
  • 17 Lug 2012
  • jQuery
Risposte
1
Visite
3K
jQuery 20 Lug 2012
criric
D
funzione AJAX che ricarica dei campi select
  • donadioema
  • 5 Nov 2010
  • Ajax
Risposte
3
Visite
2K
Ajax 14 Gen 2011
alessandro1997
Condividi:
Facebook X (Twitter) LinkedIn WhatsApp e-mail Condividi Link
  • Home
  • Forum
  • Fare Web
  • PHP
  • Italiano
  • Termini e condizioni d'uso del sito
  • Policy Privacy
  • Aiuto
  • Home
Community platform by XenForo® © 2010-2024 XenForo Ltd. | Traduzione a cura di XenForo Italia
Menu
Accedi

Registrati

  • Home
  • Forum
    • Nuovi Messaggi
    • Cerca...
  • Novità
    • Featured content
    • Nuovi Messaggi
    • Ultime Attività
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?