Current File : /home/karenpetzb/application/modules/backoffice/views/scripts/command/listdevis.phtml
<div class="table-box">
<div class="col-md-12 header-single-line">
	<div class="col-md-5 header-single no-space-top"><?php echo $this->titlePage; ?></div>
	<div class="col-md-7 no-space-top"><?php echo $this->render("alert.phtml"); ?></div>
</div>
<table class="display table" id="commandTable" width="100%">
	<thead>
		<tr>
			<th class="text-center">
				<form action="<?php echo $this->baseUrl; ?>/backoffice/command/archivedevis/" method="POST" id="archiveForm" >
					<div>
						<a class="btn btn-success" href="#" onclick="javascript:submitArchive();">Archiver</a>
					</div>
					<div>
						<input type="hidden" name="checkBoxValues" id="checkBoxValues" value="">
					</div>
				</form>
			</th>
			<th class="text-center">R�f�rence</th>
			<th class="no-wrap">Mode de reglement</th>
			<th class="no-wrap">Prix TTC</th>
			<th>Statut</th>
			<th class="text-center">Client</th>
			<th class="no-wrap">Date de la commande</th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<?php foreach($this->listcommand as $row) { ?> 
		<tr>
			<td class="text-center"><input type="checkbox"  class="bluecheckradios" name="archiveCommand" value="<?php echo $row->ID; ?>"></td>
			<td > <a class="btn btn-primary"  href="<?php echo $this->baseUrl; ?>/backoffice/command/edit/id/<?php echo $row->ID; ?>"><span class="glyphicon glyphicon-list-alt"></span>&nbsp;<?php echo $this->escape($row->REFERENCE);?></a></td>
			<td >
			<?php 
			switch ($row->USER_MODEPAIEMENT_TYPE) {
					case 1 : echo "Par ch�que"; break;
					case 2 : echo "Par virement"; break; 
					default :
						switch ($row->USER_MODEPAIEMENT) {
							case 1 : echo " Paiement en ligne"; break;
							case 2 : echo " Contre remboursement";break;
							case 3 : echo " Paiement diff�r� - 30 jours";break;
							case 4 : echo " Paiement diff�r� - 45 jours";break;
							case 5 : echo " Paiement diff�r� - 60 jours";break;
							case 6 : echo " A r�ception de la facture ";break;
						}
						break;
			} ?>
			</td>
			<td ><?php echo sprintf("%.2f",$this->escape($row->PRIXTOTALTTC)).'&nbsp;&#8364;';?></td>
			<td >
			<?php 
				switch ($this->escape($row->STATUT)) {
					case 1 : echo 'Commande - En attente'; break;
					case 2 : echo 'Commande - En livraison'; break;
					case 3 : echo 'Commande - Termin�e'; break;
					case 4 : echo 'Commande - En traitement'; break;
					case 10 : echo 'Devis - En attente'; break;
					case 11 : echo 'Devis - Termin�'; break;
				}
			?>
			</td>
			<td ><a class="btn btn-primary " href="<?php echo $this->baseUrl; ?>/backoffice/user/edit/id/<?php echo $row->IDUSER; ?>" ><span class="glyphicon glyphicon-user"></span>&nbsp;<?php echo $row->USER_NOM.' '.$row->USER_PRENOM;?></a></td>
			<td ><?php 
			$myDate = new Zend_Date(strtotime($row->DATESTART));
			$mois = array('','Jan.', 'F�v.', 'Mars', 'Avril', 'Mai', 'Juin', 'Juil.', 'Ao�t', 'Sept.', 'Oct.', 'Nov.', 'D�c.');
			$moisComplet = array('','Janvier', 'F�vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao�t', 'Septembre', 'Octobre', 'Novembre', 'D�cembre');
			echo $myDate->toString("dd").' '.$mois[(int)$myDate->toString('MM')].' '.$myDate->toString("YYYY");
				
			?></td>
			
			<td  class="text-center">
				<div class="btn-group">
		        	<a class="btn btn-success" href="<?php echo $this->baseUrl; ?>/backoffice/command/edit/id/<?php echo $row->ID; ?>"><span class="glyphicon glyphicon-edit"></span> Modifier</a>
					<button class="btn btn-danger btn-modal" data-toggle="ajaxModalDelete" data-linkok="<?php echo $this->baseUrl; ?>/backoffice/command/deldevis/id/<?php echo $row->ID; ?>" ><span class="glyphicon glyphicon-trash"></span> Supprimer</button>
				</div>
			</td>
		</tr>
		<?php } ?>
	</tbody>
</table>
<script>			
	$(document).ready(function() {
		initDataTable('commandTable', [[ 1, "asc" ]], [{ "orderable": false, "targets": 0}, { "orderable": false, "targets": -1, "width": "270px" }]); 	    
	});

	function submitArchive() {
		var elms = $("input[name=archiveCommand]:checked");
		$("#checkBoxValues").val("");
	 	
		var commandeValue = "devis";
		var data = "";
		var totalCommand = 0;
		elms.each(function( index ) {
			data += $(this).val()+",";
			totalCommand++;
		});
		
		if (totalCommand > 1) {
			commandeValue = "devis";
		}

	 	if (totalCommand > 0) {
			$("#ajaxModalArchive").remove();
		 	$("#checkBoxValues").val(data);
	        var $labelHeader = "Confirmation d'archivage", $labelBody = "Vous etes sur le point d'archiver "+totalCommand+" "+commandeValue+", voulez vous continuer ? ";
	        var $modal = $('<div id="ajaxModalArchive" class="modal fade" role="dialog" aria-labelledby="myModalLabel" ><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal">&times;</button><h4 class="modal-title">'+$labelHeader+'</h4></div><div class="modal-body">'+$labelBody+'</div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button><button type="button" class="btn btn-success" id="modalBtnDelete">Archiver</button></div></div></div></div>');
	        $('body').append($modal);
	        $('#ajaxModalArchive').modal({backdrop: 'static', keyboard: false});
	        $("#modalBtnDelete").on('click', function(e) {
	        	document.forms["archiveForm"].submit();
	        });
		}
	}
</script>
</div>