Пример #1
0
        }
    }
    $smarty->assign('country', $country_t);
}
//if load states button is press process the states
if (isset($_POST['loadcounty'])) {
    $county = new County();
    $filename = $_POST['filename'];
    $county->delete_by_country($countrycode);
    $file = SITE_ROOT . "/counties/" . $filename;
    $file = fopen($file, "r");
    while (($data = fgetcsv($file, 8000, ",")) !== FALSE) {
        $county = new County();
        $county->countrycode = $countrycode;
        $county->code = trim($data[0]);
        $county->var_name = $county->mod_write_check(trim($data[1]));
        $county->name = trim($data[1]);
        $county->statecode = trim($data[2]);
        $save = $county->save();
    }
    fclose($file);
    $message = "<div class='success'>County codes loaded from " . $filename . " </div>";
    $session->message($message);
    redirect_to($_SERVER['PHP_SELF']);
}
//delete all the countys from list
if (isset($_POST['deletecounty'])) {
    global $db, $database;
    $county = new County();
    $county->delete_by_country($countrycode);
    /* We should remove the county definition from counties, cities and zips tables also for this country */