Originariamente inviato da xproj
questo codice è nell'index.php? e se si cosa c'è prima o dopo?
No, non è nell'index, è in una pagina interna. vedo di postarti l'intera pagina
Codice PHP:
class HTML_timecard {
function selectTimecard($option, $nome_options){
JHTML::_('behavior.calendar');
$nome_selected = JRequest::getInt('operatore', '', 'post');
$db =& JFactory::getDBO();
$query = "SELECT DISTINCT (operatore) FROM #__storico_attivita";
$db->setQuery($query);
$nomes = $db->loadAssocList();
$nome_options = "";
foreach ( $nomes as $v ) {
if ( $nome_selected == $v['operatore'] ) {
$selected = "selected='selected'";
} else {
$selected = '';
}
$nome_options .= "<option value='".$v['operatore']."' $selected >".$v['operatore']."</option>";
}
?>
<form name="form" action="index.php?option=com_timecard&task=showTimecard" method="post">
<label style="width:150px;">Scegli l'operatore:</label>
<select name="operatore">
<option>SELEZIONA</option>
<?php echo $nome_options;?>
</select>
<label>Scegli il periodo:</label>
<label>[b]DAL :[/b]</label> <input type="text" name="dalgiorno" id="dalgiorno" />
<input type="reset" class="button" value="..." onclick="return showCalendar('dalgiorno', '%Y-%m-%d');" />
<label>[b] AL :[/b]</label> <input type="text" name="algiorno" id="algiorno" />
<input type="reset" class="button" value=".." onclick="return showCalendar('algiorno', '%Y-%m-%d');" />
<input type="submit" class="button" name="periodo" value="VISUALIZZA" />
<input type="hidden" name="user" value="dalgiorno" />
<input type="hidden" name="operatore" value="<?php echo $v['operatore']; ?>" />
<input type="hidden" name="option" value="<?php echo $option?>" />
</p>
</form>
<?php var_dump($nome_options);?>
</p>
</p>
<?php
}
function showTimecard($rows, $option){
$operatore=$_POST['operatore'];
$dalgiorno=$_POST['dalgiorno'];
$algiorno=$_POST['algiorno'];
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__storico_attivita WHERE operatore='$operatore' AND giorno BETWEEN '$dalgiorno' AND '$algiorno'";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<table width="500px">......... tabella di visualizzazione elementi della query </table>