<?php echo View::factory('pages/session'); ?>
<div id="users-contain" class="ui-widget">
<h2>Informations sur le compte </h2>	

Votre Solde actuel <h2><?php echo number_format(session::instance()->get('solde'), 2, ',', ' '); ?> DA</h2>
  <h1>Mes commandes:<?php echo session::instance()->get('nom_utilisateur'); ?></h1>
  <table id="users" class="ui-widget ui-widget-content">
    <thead>
      <tr class="ui-widget-header ">
        <th>N°</th>
        <th>Date</th>
        <th>Montant</th>
         <th></th>
          <th></th>
      </tr>
    </thead>
    <tbody>
           
      	<?php
	
	   $nbArticles=count($commandes);
	   if ($nbArticles <= 0){
	   echo '<tr><td colspan="5"><center>'.htmlspecialchars('Aucune commande etablie').'</center> </ td></tr>';}
	   else
	   {
	        foreach ($commandes as $commande) : 
			
	         echo '<tr >';
			 echo "<td>".htmlspecialchars( $commande['id_commande'])."</ td>";
	         echo "<td>".htmlspecialchars( $commande['date_commande'])."</ td>";
	         echo "<td style=\"text-align:right\">".number_format($commande['montant'], 2, ',', ' ').' DA'."</td>";
	        
			echo '<td ><strong><a id="'.$commande['id_commande'].'" name="'.$commande['montant'].'" date_c="'.$commande['date_commande'].'" Onclick="DetailsCommande('.$commande['montant'].')" class="create-user">Details</a></td>';
			 if ($commande['synchrone']==0){ echo '<td ><strong><a  Onclick="SupprimerCommande('.$commande['id_commande'].')" id="create-user">Supprimer</a></td>';}
			
	         echo "</tr>";
			 endforeach;
	      }
 
	
	?>
    </tbody>
  </table>
  
  <script type="text/javascript"> 
   function ClicBouton(sender){
          
        var quantite=document.getElementsByName(sender)[0].value;
		var id=document.getElementsByName(sender)[0].id;
       
		document.location.href="<?php echo URL::base() ?>page/modifierarticle/" +id+"/"+quantite ;
   } 
   
   function SupprimerCommande(sender){
          if (confirm('Vous etes sure de vouloir supprimer la commande ?')){ 
              
		document.location.href="<?php echo URL::base() ?>gestioncommandes/supprimercommande/" +sender ;
		}
   } 
   
   function DetailsCommande(sender){
      var date_commande=document.getElementsByName(sender)[0].date_c;
	 		var id=document.getElementsByName(sender)[0].id;
		document.location.href="<?php echo URL::base() ?>gestioncommandes/detailscommande/" +id+"/"+date_commande+"/"+sender ;
		   } 
</script>
</div>

