                            <div class="row-fluid">
                                <div class="span12">

                                    <table class="table">
                                        <caption>Surtido asociado.</caption>
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>Clave</th>
                                                <th>Sutancia</th>
                                                <th>Descripción</th>
                                                <th>Presentación</th>
                                                <th style="text-align: right; ">Requerida</th>
                                                <th style="text-align: right; ">Surtida</th>
                                                <th>Lote</th>
                                                <th style="text-align: right; ">Inventario</th>
                                                <th style="text-align: center; ">Acción</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php 

                                            $n = 0;
                                            $req = 0;
                                            $sur = 0;
                                            $sur_max_total = 0;

                                            foreach ($query->result() as $d) {

                                            	if($d->inv == 0)
                                            	{
                                            		$color = ROJO_PASTEL;
                                            	}else
                                            	{
                                            		$color = null;
                                            	}

                                            ?>
                                            <tr style="background-color: <?php echo $color; ?>;">
                                                <td><?php echo $d->id; ?></td>
                                                <td><?php echo $d->cvearticulo; ?></td>
                                                <td><?php echo $d->susa; ?></td>
                                                <td><?php echo $d->descripcion; ?></td>
                                                <td><?php echo $d->pres; ?></td>
                                                <td style="text-align: right; font-size: x-large; "><?php echo number_format($d->req, 0); ?></td>
                                                <td style="text-align: right; font-size: x-large; "><?php echo number_format($d->sur, 0); ?></td>
                                                <td><?php echo $d->lote; ?></td>
                                                <td style="text-align: right; font-size: x-large; "><?php echo number_format($d->inv, 0); ?></td>
                                                <td style="text-align: center; "><?php echo anchor('movimiento/surtido_dinamico/' . $d->movimientoID . '/' .$n, 'Surtir'); ?></td>
                                            </tr>
                                            <?php

                                                $n++;
                                                $req = $req + $d->req;
                                                $sur = $sur + $d->sur;

                                                if($d->inv >= $d->req)
                                                {
                                                    $sur_max = $d->req;
                                                }else
                                                {
                                                    $sur_max = $d->inv;
                                                }

                                                $sur_max_total = $sur_max_total + $sur_max;

                                            }

                                            ?>
                                        </tbody>
                                        <tbody>
                                            <tr>
                                                <td colspan="5" style="text-align: right; ">Totales: </td>
                                                <td style="text-align: right; font-size: x-large; "><?php echo number_format($req, 0); ?></td>
                                                <td style="text-align: right; font-size: x-large; "><?php echo number_format($sur, 0); ?></td>
                                                <td colspan="3"></td>
                                            </tr>
                                            <?php

                                            $abasto = number_format(($sur / $req) * 100, 2);
                                            $abasto_max = number_format(($sur_max_total / $req) * 100, 2);

                                            ?>
                                            <tr>
                                                <td colspan="5" style="text-align: right; ">Abasto: </td>
                                                <td colspan="2" style="text-align: right; font-size: x-large; color: blue; "><?php echo $abasto; ?>%</td>
                                            </tr>
                                            <tr>
                                                <td colspan="5" style="text-align: right; ">Abasto maximo que podra alcanzar este pedido: </td>
                                                <td colspan="2" style="text-align: right; font-size: x-large; color: green; "><?php echo $abasto_max; ?>%</td>
                                            </tr>
                                        </tbody>
                                    </table>

                                </div>
                            </div>
