Ejemplo n.º 1
0
function select_date ( $year_name, $month_name, $day_name, $min_year, $max_year, $selected_date = NULL )
{
	$selected = explode('-', $selected_date);

	$years = array_merge(array('Select Year'), range($min_year, $max_year));
	$months = indexed_array(array('Select Month', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'));
	$days = array_merge(array('Select Day'), range(1, 31));

	$year_options = options_for_select($years, $selected[0]);
	$month_options = options_for_select($months, $selected[1]);
	$day_options = options_for_select($days, $selected[2]);

	return "<select id='$year_name' name='$year_name'>$year_options</select>"
	     . "<select id='$month_name' name='$month_name'>$month_options</select>"
	     . "<select id='$day_name' name='$day_name'>$day_options</select>";
}
//query("TRUNCATE {$T('stationowner')}");
//query("TRUNCATE {$T('fuelprovider')}");
//query("TRUNCATE {$T('fuel')}");
query("TRUNCATE {$T('price')}");
$comuni = query_results("SELECT comune_ID, comune_uid FROM {$T('comune')}", 'Comune');
$comuni = indexed_array($comuni, 'comune_uid', 'comune_ID');
$provincie = query_results("SELECT provincia_ID, provincia_uid FROM {$T('provincia')}", 'Provincia');
$provincie = indexed_array($provincie, 'provincia_uid', 'provincia_ID');
$fuels = query_results("SELECT fuel_ID, fuel_uid FROM {$T('fuel')}", 'Fuel');
$fuels = indexed_array($fuels, 'fuel_uid', 'fuel_ID');
$stations = query_results("SELECT station_ID, station_miseID FROM {$T('station')}", 'Station');
$stations = indexed_array($stations, 'station_miseID', 'station_ID');
$stationowners = query_results("SELECT stationowner_ID, stationowner_uid FROM {$T('stationowner')}", 'Stationowner');
$stationowners = indexed_array($stationowners, 'stationowner_uid', 'stationowner_ID');
$fuelproviders = query_results("SELECT fuelprovider_ID, fuelprovider_uid FROM {$T('fuelprovider')}", 'Fuelprovider');
$fuelproviders = indexed_array($fuelproviders, 'fuelprovider_uid', 'fuelprovider_ID');
try {
    if (!isset($argv[1], $argv[2])) {
        throw new Exception(sprintf(_("Utilizzo: %s FILE_STAZIONI.csv PREZZI_ALLE_8.csv"), esc_html($argv[0])), 1);
    }
    define('FILENAME_STATIONS', $argv[1]);
    define('FILENAME_PRICES', $argv[2]);
    if (!file_exists(FILENAME_STATIONS)) {
        throw new Exception(_("File delle stazioni non trovato"), 2);
    }
    if (!($handle = fopen(FILENAME_STATIONS, 'r'))) {
        throw new Exception(_("Impossibile aprire il file delle stazioni"), 3);
    }
    // Waste first 2 lines
    fgetcsv($handle);
    fgetcsv($handle);