<?php
/* 
 * Mise à jour d'un agent client
 */

if (isset($_POST['majButton'])) {
    header('Location: http://'.$_POST['id_client'].'/webservices/majAgent.php');
    exit();
}

include('adminBroker.class.php');
include 'includes/functions.php';
define('INI_SERVER', '../serveur/config/clients.ini');

function printConfig($aConfig) {
    $select = '<select name="id_client" id="id_client">';
    foreach ($aConfig as $partConfig => $configTab) {
        $select .= '<option value="'.$configTab['ip_agent'].'">'.$partConfig.'</option>';
    }
    $select .= '</select>';
    return $select;
}

$adminBroker = new adminBroker();
$tabConfigServeur = $adminBroker->readConfig(INI_SERVER);
ksort($tabConfigServeur);
$select = printConfig($tabConfigServeur);

echo headerPage('Mise à jour d\'un agent SIGB client');
?>

<div class="blocMenu">
  <p>
      <form action="#" method="post">
          Client : <?php echo $select; ?> <span class="help" <?php echo readHelp('updatorClient') ?>>&nbsp;</span><br /><br />
          <input id="majButton" name="majButton" type="submit" value="Mettre à jour" onclick="javascript:if (confirm('Mettre à jour le client '+document.getElementById('id_client').options[document.getElementById('id_client').selectedIndex].text+' ?')) {this.style.display='none';document.getElementById('resultMajAgent').className='loading';document.getElementById('resultMajAgent').innerHTML='&nbsp;';} else return false;" />
      </form>
  </p>
  <p id="resultMajAgent"></p>
</div>

<?php
echo footerPage();
?>
