Skip to content

Commit

Permalink
refaktoring cisel stlpcov db na nazvy, uprava podpory alternativneho …
Browse files Browse the repository at this point in the history
…emailu pre hlasovaci preukaz
  • Loading branch information
scholtz committed Dec 22, 2015
1 parent dd90cd3 commit 36a742a
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 25 deletions.
40 changes: 24 additions & 16 deletions js/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function nastavOkres(){
var kraj = $("#addressslovakia-kraj").val();
var okres = $("#addressslovakia-okres").val();
for (var key in election.cities[kraj][okres]) {
options.append($("<option />").val(key).text(election.cities[kraj][okres][key][10]));
options.append($("<option />").val(key).text(election.cities[kraj][okres][key][App.C2N_NAZOV_OBCE]));
}
nastavObec();
if(!iOSversion()){
Expand All @@ -118,7 +118,7 @@ function getObec(){
var o = election.cities;

if (ico && o[kraj] && o[kraj][okres] && o[kraj][okres][ico]) {
return o[kraj][okres][ico][10];
return o[kraj][okres][ico][App.C2N_NAZOV_OBCE];
}
return "Nepodarilo sa načítať obec";
}
Expand All @@ -136,32 +136,40 @@ function nastavObec(obec) {

if (o[kraj] && o[kraj][okres] && o[kraj][okres][ico]) {
var data = o[kraj][okres][ico];
adresa = data[0] + "\n";
if (data[1] != "") {
adresa += data[1] + "\n";
adresa = data[App.C2N_TYP_URADU] + "\n";
if (data[App.C2N_TYP_URADU_RIADOK2] != "") {
adresa += data[App.C2N_TYP_URADU_RIADOK2] + "\n";
}
if (data[2] != "" || data[3] != "") {
if (data[2]) {
adresa += data[2] + " ";
if (data[App.C2N_ADRESA_URADU_ULICA] != "" || data[App.C2N_ADRESA_URADU_CISLO_DOMU] != "") {
if (data[App.C2N_ADRESA_URADU_ULICA]) {
adresa += data[App.C2N_ADRESA_URADU_ULICA] + " ";
}
if (data[3]) {
adresa += data[3];
if (data[App.C2N_ADRESA_URADU_CISLO_DOMU]) {
adresa += data[App.C2N_ADRESA_URADU_CISLO_DOMU];
}
adresa += "\n";
}
adresa += data[4] + " " + data[5] + "\n" + data[6].replace(/;/i, "\n");



var email = data[App.C2N_EMAIL];

if((App.request_form == "ziadostOPreukazPostou" || App.request_form =="ziadostOPreukaPreSplnomocnenca") && data[App.C2N_ALT_EMAIL_PRE_PREUKAZ].indexOf("@") != -1){
email = data[App.C2N_ALT_EMAIL_PRE_PREUKAZ];
}

adresa += data[App.C2N_ADRESA_URADU_PSC] + " " + data[App.C2N_ADRESA_URADU_MESTO] + "\n" + email.replace(/;/i, "\n");


if(App.request_form == 'volbaPostouBezTrvalehoPobytu'){
$("#adresa").val("Ministerstvo vnútra Slovenskej republiky\nodbor volieb, referenda a politických strán\nDrieňová 22\n826 86 Bratislava 29\nSLOVAK REPUBLIC");
$("#sendto").html("[email protected]");
$("#phone").html("");
$("#phonetext").hide();
}else{
$("#adresa").val(adresa);
$("#sendto").html(data[6]);
if(data[8] != ""){
$("#phone").html(data[7] + " / " + data[8]);
$("#sendto").html(email);
if(data[App.C2N_TELEFON] != ""){
$("#phone").html(data[App.C2N_TEL_PREDVOLBA] + " / " + data[App.C2N_TELEFON]);
$("#phonetext").show();
}else{
$("#phone").html("");
Expand All @@ -175,7 +183,7 @@ function nastavObec(obec) {
$("#sendemail").show();
$("#noemail").hide();
}
if(data[11] == "1"){
if(data[App.C2N_POTVRDENE_UDAJE] == "1"){
$("#emailpotvrdeny").show();
}else{
$("#emailpotvrdeny").hide();
Expand Down
18 changes: 18 additions & 0 deletions js/cities.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 55 additions & 9 deletions spracuj.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,37 @@
$chybneemaily = "";
file_put_contents("corrections.csv",file_get_contents("http://volby.digital/corrections.csv"));

$overene = array();
$overenePostou = array();
$overenePreukaz = array();
if (($handle = fopen("corrections.csv", "r")) !== FALSE) {
$i = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {$i++;
if($data[0]){
$overene[trim($data[0])] = trim($data[1]);
$emails = explode(";",$data[1]);
foreach($emails as $k=>$v){
$emails[$k] = $em = trim($v);
if(!$em){unset($emails[$k]);continue;}
if(!Validate::check("email",$em)){
echo "!!! OVERENY EMAIL NIE JE VALIDNY! ".$em."\n";
unset($emails[$k]);
}
}

$overenePostou[trim($data[0])] = implode(";",$emails);


if(isset($data[4]) && $data[4]){
$emails = explode(";",$data[4]);
foreach($emails as $k=>$v){
$emails[$k] = $em = trim($v);
if(!$em){unset($emails[$k]);continue;}
if(!Validate::check("email",$em)){
echo "!!! OVERENY EMAIL NIE JE VALIDNY! ".$em."\n";
unset($emails[$k]);
}
}
$overenePreukaz[trim($data[0])] = implode(";",$emails);
}
}else{
$tocheck[$data[1]] = $data[1];
//echo "Potvrdeny email nema overovatela: ".$data[1]."\n";
Expand Down Expand Up @@ -60,21 +85,25 @@
}
}else{
$name = Texts::clear($data[$n2k["obec"]]);
$potvrdeny = "";
$potvrdenyPostou = "";
$potvrdenyPreukaz = "";
$emaily = explode(";",$data[$n2k["email"]]);
foreach($emaily as $k=>$email){
$emaily[$k] = $email = trim($email);
if(isset($bounce[$email])){unset($emaily[$k]); continue;}
if(!$email) {unset($emaily[$k]); continue;}
$csv.='"'.$email.'","'.str_replace('"','""',$data[$n2k["obec"]]).'"'."\n";

if(isset($overene[$email])){
$potvrdeny = $overene[$email];
if(isset($overenePostou[$email])){
$potvrdenyPostou = $overenePostou[$email];
}
if(isset($overenePreukaz[$email])){
$potvrdenyPreukaz = $overenePreukaz[$email];
}
}
$data[$n2k["email"]] = implode(";",$emaily);

if(!$potvrdeny){
if(!$potvrdenyPostou){

$e = get_relevant_emails( $data[$n2k["email"]], $name );
if($e){
Expand All @@ -86,12 +115,12 @@
}
}
}else{
$e = $potvrdeny;
$e = $potvrdenyPostou;
$potvrdenych ++;
}
//if( $e ) echo $name,":\t",$e,'<br>';//for debug

$out[$data[$n2k["kraj"]]][$data[$n2k["okres"]]][$name] = "['".$data[$n2k["urad"]]."','','".$data[$n2k["ulica"]]."','".$data[$n2k["cislo"]]."','".$data[$n2k["psc"]]."','".$data[$n2k["posta"]]."','".$e."','".$data[$n2k["predvolba"]]."','".$data[$n2k["telefon"]]."','".$data[$n2k["mobil"]]."','".$data[$n2k["obec"]]."','".($potvrdeny?1:0)."']";
$out[$data[$n2k["kraj"]]][$data[$n2k["okres"]]][$name] = "['".$data[$n2k["urad"]]."','','".$data[$n2k["ulica"]]."','".$data[$n2k["cislo"]]."','".$data[$n2k["psc"]]."','".$data[$n2k["posta"]]."','".$e."','".$data[$n2k["predvolba"]]."','".$data[$n2k["telefon"]]."','".$data[$n2k["mobil"]]."','".$data[$n2k["obec"]]."','".($potvrdenyPostou?1:0)."','".$potvrdenyPreukaz."']";

$data[$n2k["pocetobyvatelov"]] = str_replace(" ","",$data[$n2k["pocetobyvatelov"]]);

Expand Down Expand Up @@ -434,7 +463,24 @@ function okres2okresname($name){
// "o" variable saves characters so the file is not as huge as with the regular keys
// "election" exports array in a variable so it\'s accessible inside of another files
'.$ret."\n\n\n".$pscout."\n\n".'})();';
// column mapping
election.C2N_TYP_URADU = 0;
election.C2N_TYP_URADU_RIADOK2 = 1;
election.C2N_ADRESA_URADU_ULICA = 2;
election.C2N_ADRESA_URADU_CISLO_DOMU = 3;
election.C2N_ADRESA_URADU_PSC = 4;
election.C2N_ADRESA_URADU_MESTO = 5;
election.C2N_EMAIL = 6;
election.C2N_TEL_PREDVOLBA = 7;
election.C2N_TELEFON = 8;
election.C2N_MOBIL = 9;
election.C2N_NAZOV_OBCE = 10;
election.C2N_POTVRDENE_UDAJE = 11;
election.C2N_ALT_EMAIL_PRE_PREUKAZ = 12;
// data
'.$ret."\n\n
// data for zip to city link\n\n".$pscout."\n\n".'})();';

var_dump(file_put_contents("cities.js",$ret));

Expand Down

0 comments on commit 36a742a

Please sign in to comment.