hellofacteurV1/vues/compte_crea_abo_nouveau_flu...

67 lines
2.7 KiB
PHP
Executable File

<?php
/**
* Vue affichant le formulaire permettant de choisir à quel abonnement ajouté le hub correspondant un nouveau flux
* ou encore à en créer un nouveau
**/
$header_title=SITE_NOM." >> Vous abonner à un nouveau flux.";
$header_robots="noindex,follow";
$body_title=SITE_NOM." >> Vous abonner à ".htmlentities($nom_hub,ENT_QUOTES).".";
$ariane_items[0]["txt"]="<li><a href='".PAGE_REPERTOIRE_ACCUEIL."'>Les bonnes adresses du facteur.</a></li>";
$ariane_items[0]["form"]=false;
$ariane_items[0]["actif"]=false;
if(!empty($_SESSION["message"]))
{
$msg_infos[0]="<strong>".$_SESSION["message"]."</strong>";
$_SESSION["message"]="";
}
$msg_infos[1]="Vous vous apprêtez à vous abonner aux mises à jour de : <strong>".htmlentities($nom_hub,ENT_QUOTES)."</strong>.";
$form["nom"]="Nouvel abonnement.";
$form["champs"]="<form method='post' id='crea_abo_flux' action='".PAGE_ABO_CREA_HUB.$id_hub."' role='form'>";
if(!empty($liste_abo))
{
$form["champs"].="<div class='form-group'><label for='abo'>Je souhaite l'ajouter à l'abonnement suivant :</label>";
foreach ($abos as $abo_info)
$form["champs"].="<label class='checkbox-inline'><input type='radio' name='abo' value=\"".$abo_info["id_abonnement"]."\"> ".affiche_utf8(htmlentities($abo_info["designation"],ENT_QUOTES),UTF8_OK)."</label>";
$form["champs"].="</div>
<p class='help-block'><strong>- OU -</strong></p>";
}
$form["champs"].="<div class='form-group'>
<label for='nouvel_abo'>Je créer un nouvel abonnement :</label>
<input class='form-control' type='text' maxlength='".ABO_MAX_DESIGNATION."' name='nouvel_abo' id='nouvel_abo' value=\"".get_chaine_debut(htmlentities($nom_hub,ENT_QUOTES),ABO_MAX_DESIGNATION)."\">
</div>
<div id='msg_abo'></div>
<div class='form-group'>
<button type='submit' class='btn btn-success btn-lg'>Enregistrer.</button>
</div>
</fieldset></form>";
//le code pour ajax
ob_start();
?>
<script>
$(document).ready(function()
{
$('#crea_abo_flux').on('submit', function(e)
{
var $this=$(this);
var nouveau=$('#nouvel_abo').val();
var anciens=$("input[name=abo]:checked").val();
var ln=nouveau.length;
if((nouveau==='')&&(anciens===undefined))
{
e.preventDefault();
$('#msg_abo').html('<?php echo str_replace("'","\"",get_html_alerte_msg((array) ERREUR_UTILISA_CHAMPS_ABSENTS));?>');
}
else if ((anciens===undefined)&&(nouveau!=='')&&((ln<<?=ABO_MIN_DESIGNATION;?>)||(ln><?=ABO_MAX_DESIGNATION;?>)))
{
e.preventDefault();
$('#msg_abo').html('<?php echo str_replace(array("__MIN__","__MAX__","'"),array(ABO_MIN_DESIGNATION,ABO_MAX_DESIGNATION,"\""),get_html_alerte_msg((array) ERREUR_ABO_DESIGNATION_LONG));?>');
}
});
});
</script>
<?php
$footer_JS=ob_get_contents();
ob_end_clean();
require(TEMPLATE_REP."/page.php");