Originariamente inviato da satifal
Qui manca un ;
Codice PHP:
...
$data_in = substr($data_ini, 4, 4)."-".substr($data_ini, 2, 2)."-".substr($data_ini, 0, 2)." 00:00:00"
...
Il ; non mancava sull'originale
Ho provato solo con il codice postato e mi funziona quindi provo a postare il codice completo delle 3 pagine:
fatturare.php
Codice PHP:
<?php // Controllo accesso
session_start();
if (!isset($_SESSION['utente'])){
header('location:index.php?errore=non_autenticato');
exit;}
$utente=$_SESSION['utente'];
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Rimorchi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" media="all" href="skins/aqua/theme.css" title="Aqua" />
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript" src="calendar-it.js"></script>
<script type="text/javascript">
/////CALENDARIO/////
var oldLink = null;
function setActiveStyleSheet(link, title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
if (oldLink) oldLink.style.fontWeight = 'normal';
oldLink = link;
link.style.fontWeight = 'bold';
return false;
}
// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
cal.sel.value = date; // just update the date in the input field.
if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
cal.callCloseHandler();
}
function closeHandler(cal) {
cal.hide(); // hide the calendar
// cal.destroy();
_dynarch_popupCalendar = null;
}
function showCalendar(id, format, showsTime, showsOtherMonths) {
var el = document.getElementById(id);
if (_dynarch_popupCalendar != null) {
// we already have some calendar created
_dynarch_popupCalendar.hide(); // so we hide it first.
} else {
// first-time call, create the calendar.
var cal = new Calendar(1, null, selected, closeHandler);
// uncomment the following line to hide the week numbers
// cal.weekNumbers = false;
if (typeof showsTime == "string") {
cal.showsTime = true;
cal.time24 = (showsTime == "24");
}
if (showsOtherMonths) {
cal.showsOtherMonths = true;
}
_dynarch_popupCalendar = cal; // remember it in the global var
cal.setRange(1900, 2070); // min/max year allowed.
cal.create();
}
_dynarch_popupCalendar.setDateFormat(format); // set the specified date format
_dynarch_popupCalendar.parseDate(el.value); // try to parse the text in field
_dynarch_popupCalendar.sel = el; // inform it what input field we use
_dynarch_popupCalendar.showAtElement(el.nextSibling, "Br"); // show the calendar
return false;
}
var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;
function isDisabled(date) {
var today = new Date();
return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}
function flatSelected(cal, date) {
var el = document.getElementById("preview");
el.innerHTML = date;
}
function showFlatCalendar() {
var parent = document.getElementById("display");
var cal = new Calendar(0, null, flatSelected);
cal.weekNumbers = false;
cal.setDisabledHandler(isDisabled);
cal.setDateFormat("%A, %B %e");
cal.create(parent);
cal.show();
}
/////CALENDARIO/////
function controlla(){
var data_inizio = document.getElementById('data_inizio');
var data_fine = document.getElementById('data_fine');
if(data_inizio.value == ""){
alert("CAMPO DATA INIZIALE NON COMPILATO")
return false;
}
else if (data_fine.value == "")
{
alert("CAMPO DATA FINALE NON COMPILATO")
return false;
}
return true;
}
</script>
</head>
<body>
<?php
////////INIZIO database////////
require("connessione_database.php");
////////FINE database////////
$dataatt = date("dmY", time());
$data_inizio_mese = strftime ("%d%m%Y",mktime (0,0,0,date(substr($dataatt,2,2))-1,1,date(substr($dataatt,4,4))));
$data_fine_mese = strftime ("%d%m%Y",mktime (23,59,59,date(substr($dataatt,2,2)),0,date(substr($dataatt,4,4))));
?>
<table width="1000" border="0" align="center" style="background-repeat:no-repeat">
<tr>
<td height="82" colspan="4"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><span class="Stile20">DA FATTURARE </span></td>
<td colspan="2" align="right" valign="top"><span class="Stile19"><?php echo "$utente";//codice utente?></span></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
<tr>
<td width="243" height="52" align="center" valign="top"><form name="indietro" method="post" action="fatture.php">
<input type="image" name="indietro" class="Stile14" value="INDIETRO" src="imm/bottone_indietro_0.gif" onmouseout="this.src='imm/bottone_indietro_0.gif'" onmouseover="this.src='imm/bottone_indietro_1.gif'" onMouseDown="this.src='imm/bottone_indietro_2.gif'">
</form></td>
<td width="243" height="52" align="left" valign="top"><form name="indietro" method="post" action="menu.php">
<input type="image" name="menu" class="Stile14" value="MENU" src="imm/bottone_menu_0.gif" onMouseOut="this.src='imm/bottone_menu_0.gif'" onMouseOver="this.src='imm/bottone_menu_1.gif'" onMouseDown="this.src='imm/bottone_menu_2.gif'">
</form></td>
<td width="250"></td>
<td width="246"></td>
</tr>
<tr>
<td height="66" colspan="2"><form name="form1" method="post" onSubmit="return controlla()" action="fatturare1.php">
<table width="447" border="0">
<tr>
<td colspan="2" class="Stile20">PERIODO DA FATTURARE</td>
</tr>
<tr>
<td width="70" class="Stile20">DAL</td>
<td width="367"><input id="data_inizio" type="text" name="data_inizio" class="Stile13" value="<?php echo $data_inizio_mese;?>"><input type="reset" class="Stile14" value="..." onClick="return showCalendar('data_inizio', '%d%m%Y');"></td>
</tr>
<tr>
<td class="Stile20">AL </td>
<td><input id="data_fine" name="data_fine" type="text" class="Stile13" value="<?php echo $data_fine_mese;?>"><input type="reset" class="Stile14" value="..." onClick="return showCalendar('data_fine', '%d%m%Y');"></td>
</tr>
<tr>
<td></td>
<td><input type="image" name="ok" class="Stile14" value="OK" src="imm/bottone_ok_0.gif" onmouseout="this.src='imm/bottone_ok_0.gif'" onmouseover="this.src='imm/bottone_ok_1.gif'" onMouseDown="this.src='imm/bottone_ok_2.gif'"></td>
</tr>
</table>
</form></td>
<td height="66" colspan="2"></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
</table>
</body>
</html>
<?php //mysql_free_result($risultato); ?>
fatturare1.php
Codice PHP:
<?php // Controllo accesso
session_start();
if (!isset($_SESSION['utente'])){
header('location:index.php?errore=non_autenticato');
exit;}
$utente=$_SESSION['utente'];
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Rimorchi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
////////INIZIO database////////
require("connessione_database.php");
////////FINE database////////
$data_ini = $_POST['data_inizio'];
$data_fin = $_POST['data_fine'];
$data_in = substr($data_ini, 4, 4)."-".substr($data_ini, 2, 2)."-".substr($data_ini, 0, 2)." 00:00:00";
$data_fi = substr($data_fin, 4, 4)."-".substr($data_fin, 2, 2)."-".substr($data_fin, 0, 2)." 23:59:59";
$_SESSION['data_inS'] = $data_in;
$_SESSION['data_fiS'] = $data_fi;
$risultato = mysql_query ("(SELECT codice_cliente_motrice AS codice FROM storico_client WHERE (codice_storico = 'MOTRICE' OR codice_storico = 'SOLO_MOTRICE' OR codice_storico = 'AUTOBUS') AND codice_cliente_motrice IS NOT NULL AND codice_cliente_motrice!='' AND targa_motrice_ing!='RALLA' AND num_fattura = '0' AND pagato = '0' AND importo_sosta!='0.00' AND data_uscTS > '$data_in' AND data_uscTS < '$data_fi') UNION (SELECT codice_cliente_rimorchio AS codice FROM storico_client WHERE (codice_storico = 'RIMORCHIO_MOTRICE' OR codice_storico = 'RIMORCHIO_RALLA' OR codice_storico = 'CARICO_ECCEZIONALE_MOTRICE' OR codice_storico = 'CARICO_ECCEZIONALE_RALLA') AND codice_cliente_rimorchio IS NOT NULL AND codice_cliente_rimorchio!='' AND targa_rimorchio!='RALLA' AND num_fattura = '0' AND pagato = '0' AND importo_sosta!='0.00' AND data_uscTS > '$data_in' AND data_uscTS < '$data_fi') UNION (SELECT codice_cliente_rimorchio AS codice FROM storico_client WHERE (codice_storico = 'ABBONAMENTO' ) AND targa_rimorchio!='RALLA' AND num_fattura = '0' AND pagato = '0' AND importo_sosta!='0.00' AND data_uscTS > '$data_in' AND data_uscTS < '$data_fi') ORDER BY codice");
$righe = mysql_num_rows($risultato);
$risultato1 = mysql_query ("SELECT * FROM info");
$righe1 = mysql_num_rows($risultato1);
if ($righe1 > 0){
$riga1 = mysql_fetch_row($risultato1);
$ultima_fattura = $riga1[1];
$intestazioner1 = $riga1[3];
$intestazioner2 = $riga1[4];
$intestazioner3 = $riga1[5];
$intestazioner4 = $riga1[6];
$intestazioner5 = $riga1[7];
$intestazioner6 = $riga1[8];
$iva = $riga1[9];
}
$num_fattura_iniziale = $ultima_fattura+1;
?>
<table width="1000" border="0" align="center" style="background-repeat:no-repeat">
<tr>
<td height="82" colspan="4"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><span class="Stile20">DA FATTURARE </span></td>
<td colspan="2" align="right" valign="top"><span class="Stile19"><?php echo "$utente";//codice utente?></span></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
<tr>
<td colspan="4"><form name="form" method="post" action="fatturare2.php"><table width="992" border="0">
<tr>
<td class="Stile20">NUMERO FATTURA INIZIALE </td>
</tr>
<tr>
<td class="Stile20"><input id="num_fattura_iniziale" type="text" name="num_fattura_iniziale" class="Stile13" value="<?php echo $num_fattura_iniziale;?>"></td>
</tr>
<tr>
<td class="Stile20">LISTA CLIENTI DA FATTURARE</span></td>
</tr>
<?php if ($righe > 0) {
for ($i=0; $i<$righe; $i++){
$riga = mysql_fetch_row($risultato);
?>
<tr>
<td colspan="2" class="Stile20 Stile21">
<input type="checkbox" name="<?php echo "codice_clienteL[$i]";?>" value="<?php echo "$riga[0]";?>" checked="checked">
<?php echo html_entity_decode($riga[0]);
?> </td>
</tr>
<?php
}
} else{?>
<tr>
<td colspan="2" class="Stile20 Stile21 Stile22">NIENTE DA FATTURARE</td>
</tr>
<?php } ?>
<tr>
<td colspan="2" class="Stile15"><?php if ($righe > 0) {?><input type="image" name="ok2" class="Stile14" value="OK" src="imm/bottone_ok_0.gif" onmouseout="this.src='imm/bottone_ok_0.gif'" onmouseover="this.src='imm/bottone_ok_1.gif'" onMouseDown="this.src='imm/bottone_ok_2.gif'"><?php } else {echo "";}?></td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
</table>
</body>
</html>
<?php
//echo $data_in.$data_fi."
".$_SESSION['data_inS'].$_SESSION['data_fiS'];
mysql_free_result($risultato); ?>
fatturare2.php
Codice PHP:
<?php // Controllo accesso
session_start();
if (!isset($_SESSION['utente'])){
header('location:index.php?errore=non_autenticato');
exit;}
$utente=$_SESSION['utente'];
////////INIZIO database////////
require("connessione_database.php");
////////FINE database////////
echo $data_in.$data_fi.$_SESSION['data_inS'].$_SESSION['data_fiS'];
$_SESSION['codice_clienteLS'] = $_POST['codice_clienteL'];
$_SESSION['num_fattura_inizialeS'] = $_POST['num_fattura_iniziale'];
header("location:fatturare3.php");
?>
su fatturare2.php non lo stampa correttamente...