<!--add-->
<?php if(!isset($salida)):?>
<div class="form-group" id="multiple-salida-producto-info">
	<div class="col-sm-2">
		<label>SKU</label>
		<div class="input-group">
			<input type="text"  id="multiple-salida-producto-sku" class="form-control frame-control frame-producto-sku">
			<input type="hidden" id="multiple-salida-producto-id" class="frame-control frame-producto-id">
			<input type="hidden" id="multiple-salida-presentacion-id" class="frame-control frame-presentacion-id">
			<input type="hidden" id="multiple-salida-unidades-representativas" class="frame-control frame-unidades-representativas">
			<span class="input-group-btn">
				<button type="button" id="multiple-salida-producto-buscar" class="btn btn-primary"><i class="fa fa-search"></i></button>
			</span>
		</div>
	</div>
	<div class="col-sm-4">
		<label>Descripci&oacute;n</label>
		<input type="text" id="multiple-salida-producto-desc" class="form-control frame-control frame-producto-desc" readonly>
	</div>
	<div class="col-sm-2">
		<label>Cantidad</label>
		<input type="text" id="multiple-salida-producto-cant" class="form-control frame-control frame-producto-cant">
	</div>
	<div class="col-sm-2">
		<label>Costo</label>
		<input type="text" class="form-control frame-control frame-producto-costo-ultimo">
	</div>
	<div class="col-sm-2">
		<button type="button" id="multiple-salida-producto-agregar" class="btn btn-info btn-md m-t-md frame-producto-add-btn">Agregar</button>
	</div>
</div>
<?php endif;?>
<!--table header-->
<div class="row">
	<table class="table table-hover" style="margin:0px;">
		<thead>
			<tr>
				<th style="width:15%">SKU</th>
				<th style="width:45%">Nombre</th>
				<th style="width:10%">Cant.</th>
				<th style="width:10%">Costo.</th>
				<th style="width:10%">Total.</th>
				<th style="width:10%">Quitar</th>
			</tr>
		</thead>
	</table>
</div
<!--tabla body-->
<div class="row">
	<div id="multiple-salida-productos-wrapper">
		<table class="table table-hover" id="multiple-salida-productos-table">
			<tbody>
			<?php if(isset($salida)):if(count($productos)>0):foreach($productos as $producto):?>
				<tr>
					<td class='table-sku' data-value='<?php echo $producto->sku;?>'><?php echo $producto->sku;?></td>
					<td class='table-desc' data-value='<?php echo $producto->desc;?>'><?php echo $producto->desc;?></td>
					<td class='table-cant' data-value='<?php echo $producto->cant;?>'><?php echo $producto->cant;?></td>
					<td class='table-costo' data-value='<?php echo $producto->costo;?>'><?php echo $producto->costo;?></td>
					<td class='table-total' data-value='<?php echo $producto->cant*$producto->costo;?>'><?php echo $producto->cant*$producto->costo;?></td>
					<td class='table-del'></td>
				</tr>
			<?php endforeach;endif;endif;?>
			</tbody>
		</table>
	</div>
</div>
<!--totales-->
<div class="row">
	<div class="col-sm-8">
		<h3 class="m-lg transacction-item-counter">Items en la salida: <b>0</b></h3>
	</div>
	<div class="col-sm-4">
		<table class="table" id="multiple-salida-totales-wrapper">
			<tbody>			
			</tbody>
		</table>
	</div>
</div>
<!--totales-->
<?php if(!isset($salida)):?>
<div class="form-group" style="margin:0; text-align:center;">
	<button type="button" class="btn btn-danger btn-rounded" onclick="Custombox.close();">Cancelar</button>
	<button type="button" class="btn btn-primary btn-rounded" onclick="salidas.guardarSalidaMultiple(event);" id="guardar-entradas">Registrar salida</button>
</div>
<?php endif;?>
<script>
	var toolsMultiple = new Transaccionestools('<?php echo base_url();?>');
	toolsMultiple.setProductFrame($("#multiple-salida-producto-info"));
	toolsMultiple.setProductTable($("#multiple-salida-productos-wrapper > table"));
	toolsMultiple.setTotalTable($("#multiple-salida-totales-wrapper"));
	toolsMultiple.SetTotalsProfile('sumas,total','sumas',true);
	 $('#multiple-salida-productos-wrapper').slimScroll({
		height: '200px'
	}); 
	$('#multiple-salida-producto-buscar').click(function(e){
		e.preventDefault();
		Custombox.open({
			target:'<?php echo base_url("productos/buscarproductos");?>?field=multiple-salida-producto-sku&enter=true', 
			effect: 'fadein',
		});
	});
	$("#multiple-salida-producto-sku").keypress(function(e) {
		if(e.which == 13) {
			e.preventDefault();
			toolsMultiple.getProductInfoBySKU('descripcion,costo_ultimo',$(this).val(),$("#multiple-salida-producto-cant"));
		}
	});
	$("#multiple-salida-producto-agregar").click(function(e){
		toolsMultiple.addProductToTable('data:.frame-producto-id@data-id,data:.frame-presentacion-id@data-pre,data:.frame-unidades-representativas@data-uequiv,field:.frame-producto-sku@table-sku,field:.frame-producto-desc@table-desc,field:.frame-producto-cant@table-cant,field:.frame-producto-costo-ultimo@table-costo,operation:.frame-producto-cant|*|.frame-producto-costo-ultimo@table-total,command:remove@table-del');
	});
	$("#multiple-salida-productos-wrapper").on('click','table tr td.table-del',function(){
		var tr = $(this).closest('tr');
		toolsMultiple.removeProductToTable($(tr));
	});
</script>