pour_une_election_et_un_poste"; // GET - POST if (isset ($_GET['validation'])){ $validation=$_GET['validation']; }else{ $validation=0; } if (isset ($_POST['scrutin'])){ $scrutin=$_POST['scrutin']; }else{ $scrutin=0; } if (isset ($_POST['scrutinsolde'])){ $scrutinsolde=$_POST['scrutinsolde']; }else{ $scrutinsolde=0; } if (isset ($_POST['poste'])){ $poste=$_POST['poste']; }else{ $poste=0; } if (isset ($_POST['candidat'])){ $candidat=$_POST['candidat']; }else{ $candidat=0; } echo "\n
\n"; if($validation==0){ $validation=1; echo ""; echo ""; echo ""; // choix scrutin $sql="select scrutin,libelle from ".DB_PREFIXE."scrutin where solde is true"; $res = $f -> db -> query($sql); $f->isDatabaseError($res); echo ""; // choix scrutin $sql="select scrutin,libelle from ".DB_PREFIXE."scrutin where solde is false"; $res = $f -> db -> query($sql); $f->isDatabaseError($res); echo ""; // choix poste $sql="select poste,poste from ".DB_PREFIXE."poste where nature ='affectation'"; $res = $f -> db -> query($sql); $f->isDatabaseError($res); echo ""; // choix candidat $sql="select candidat,nom,candidat.scrutin as scrutin from ".DB_PREFIXE."candidat inner join ".DB_PREFIXE."scrutin on candidat.scrutin=scrutin.scrutin where solde is true order by nom"; $res = $f -> db -> query($sql); $f->isDatabaseError($res); echo ""; echo ""; echo "
"._("transfert")." "._("des")." "._("affectations")."
"._("selectionnez")." "._("un")." "._("scrutin")." "._("solde")."
"._("selectionnez")." "._("un")." "._("scrutin")." "._("encours")."
"._("selectionnez")." "._("un")." "._("poste")."
"._("selectionnez")." "._("un")." "._("candidat")."

"; echo ""; echo "  "._("attention")."   "._("decision")." = ".$f->collectivite['decision']."  !"; echo ""; echo "
"; }else{ // validation = 1 echo "
"; // verification existence echo "
"._("traitement").""; $sql = "select count(affectation) from ".DB_PREFIXE."affectation where scrutin ='". $scrutin."' and poste ='".$poste."' and decision is true"; if($candidat!='T') $sql.=" and where candidat='".$candidat."'"; $nb = $f -> db -> getOne($sql); if(!is_numeric($nb)) $nb=0; echo "
  "._("il_existe")." ".$nb." ".$poste." "._("pour")." ".$scrutin." "._("candidat")." ".$candidat." "._("avec")." "._("decision")." = "._("oui")."
"; // selection $sql = "select affectation.elu,bureau,periode,candidat,nom,prenom from ".DB_PREFIXE."affectation inner join ".DB_PREFIXE."elu on elu.elu=affectation.elu where scrutin ='". $scrutinsolde."' and affectation.poste ='".$poste."' and decision is true"; echo ""; echo ""; if($candidat!='T') $sql.=" and candidat='".$candidat."'"; $res = $f -> db -> query($sql); $f->isDatabaseError($res); while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ $affectation = $f -> db -> nextId(DB_PREFIXE.'affectation'); if($f->collectivite["decision"]=='Oui') $decision = 'TRUE'; else $decision = 'FALSE'; if($candidat!='T') $sql="insert into ".DB_PREFIXE."affectation (affectation,scrutin,decision,periode,poste,bureau,candidat,note,elu) values('".$affectation."','".$scrutin."',".$decision.",'".$row['periode']."','".$poste."','". $row['bureau']."','".$row['candidat']."','transfert ".$scrutinsolde. "','".$row['elu']."')"; else $sql="insert into ".DB_PREFIXE."affectation (affectation,scrutin,decision,periode,poste,bureau,note,elu) values('".$affectation."','".$scrutin."',".$decision.",'".$row['periode']."','".$poste."','". $row['bureau']."','transfert ".$scrutinsolde. "','".$row['elu']."')"; $res1 = $f -> db -> query($sql); $f->isDatabaseError($res1); echo ""; } echo "
"._("transfert")." "._("affectation")."
"; echo "
  ".$row['elu']." ".$row['nom']." ".$row['prenom']."  ".$row['bureau'].' '. $row['periode']."
"; echo "
"; echo "
"; echo "
"; } echo "
"; ?>