$max     = (isset($_POST['max']))       ? Clean::entier($_POST['max'])      : 0 ;  // Nombre d'étapes à effectuer
$pack    = 10 ;  // Nombre de mails envoyés à chaque étape

// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Préparation d'une lettre d'informations avant envoi
// ////////////////////////////////////////////////////////////////////////////////////////////////////

if( ($action=='envoyer') && $titre && $contenu && $nb_bases )
{
  // Mémoriser en session le nb d'envoi / le titre / le contenu de la lettre d'informations
  $_SESSION['tmp']['nombre']  = $nb_bases ;
  $_SESSION['tmp']['titre']   = $titre ;
  $_SESSION['tmp']['contenu'] = $contenu ;
  // Mémoriser en session les données des contacts concernés par la lettre
  $_SESSION['tmp']['infos'] = array();
  $DB_TAB = DB_WEBMESTRE_WEBMESTRE::DB_lister_contacts_cibles( implode(',',$tab_base_id) );
  foreach($DB_TAB as $DB_ROW)
  {
    $_SESSION['tmp']['infos'][] = array(
      'base_id'          => $DB_ROW['contact_id'] ,
      'contact_nom'      => $DB_ROW['contact_nom'] ,
      'contact_prenom'   => $DB_ROW['contact_prenom'] ,
      'contact_courriel' => $DB_ROW['contact_courriel'] ,
    );
  }
  // Retour
  $max = 1 + floor($nb_bases/$pack) + 1 ; // La dernière étape consistera uniquement à vider la session temporaire
  exit('ok-'.$max);
}

// ////////////////////////////////////////////////////////////////////////////////////////////////////