<thead>
	<tr>
		<th id="cod">
			COD
			<span class="glyphicon" aria-hidden="true"></span>
		</th>
		<th id="cum">
			CUM
			<span class="glyphicon" aria-hidden="true"></span>
		</th>
		<th id="nombre">
			<span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span>
			Nombre
		</th>
		<th id="forma_farmaceutica">
			<span class="glyphicon" aria-hidden="true"></span>
			Forma farmaceutica
		</th>
		<th id="concentracion">
			<span class="glyphicon" aria-hidden="true"></span>
			Concentración
		</th>
		<th id="unidad_de_medida">
			<span class="glyphicon" aria-hidden="true"></span>
			Unidad
		</th>
		<?php if(Auth::user()->id == 1 || Auth::user()->permisos['medicamentos'] != 'r'): ?>
			<td>Operaciones</td>
		<?php endif; ?>
	</tr>
</thead>
<tbody>
	<?php foreach($medicamentos as $medicamento): ?>
		<?php if($medicamento->deleted): ?>
			<tr class="danger">
		<?php else: ?>
			<tr>
		<?php endif; ?>
			<td><?php echo e($medicamento->cod); ?></td>
			<td><?php echo e($medicamento->cum); ?></td>
			<td><?php echo e($medicamento->nombre); ?></td>
			<td><?php echo e($medicamento->forma_farmaceutica); ?></td>
			<td><?php echo e($medicamento->concentracion); ?></td>
			<td><?php echo e($medicamento->unidad_de_medida); ?></td>
			
				<?php if($medicamento->deleted): ?>
					<?php if(Auth::user()->id == 1 || strstr(Auth::user()->permisos['medicamentos'], 'd')): ?>
						<td>
							<?php echo Form::open(['route'=>['medicamento.destroy', 'r'.$medicamento->id_medicamento], 'method'=>'DELETE']); ?>

								<?php echo Form::submit('Habilitar', ['class' => 'btn btn-success btn-xs']); ?>

							<?php echo Form::close(); ?>

						</td>
					<?php endif; ?>
				<?php else: ?>
					<?php if(Auth::user()->id == 1 || (strstr(Auth::user()->permisos['medicamentos'], 'd') && strstr(Auth::user()->permisos['medicamentos'], 'u'))): ?>
						<td>
							<?php echo Form::open(['route'=>['medicamento.destroy', $medicamento->id_medicamento], 'method'=>'DELETE']); ?>

								<?php echo link_to_route(
									'medicamento.edit',
									$title = 'Editar',
									$parameters = $medicamento->id_medicamento,
									$attributes = ['class'=>'btn btn-primary btn-xs'] 
								); ?>

								<?php echo Form::submit('Inhabilitar', ['class' => 'btn btn-danger btn-xs']); ?>

							<?php echo Form::close(); ?>

						</td>
					<?php endif; ?>
					<?php if(!strstr(Auth::user()->permisos['medicamentos'], 'd') && strstr(Auth::user()->permisos['medicamentos'], 'u')): ?>
						<td>
							<?php echo link_to_route(
								'medicamento.edit',
								$title = 'Editar',
								$parameters = $medicamento->id_medicamento,
								$attributes = ['class'=>'btn btn-primary btn-xs'] 
							); ?>

						</td>
					<?php endif; ?>
					<?php if(strstr(Auth::user()->permisos['medicamentos'], 'd') && !strstr(Auth::user()->permisos['medicamentos'], 'u')): ?>
						<td>
							<?php echo Form::open(['route'=>['medicamento.destroy', $medicamento->id_medicamento], 'method'=>'DELETE']); ?>

								<?php echo Form::submit('Inhabilitar', ['class' => 'btn btn-danger btn-xs']); ?>

							<?php echo Form::close(); ?>

						</td>
					<?php endif; ?>
				<?php endif; ?>
			</td>
		</tr>
	<?php endforeach; ?>
</tbody>