<?php
foreach ($query->result() as $row) {
     $paquetes = 0;
     $paquetesPiezas = 0;
     $paquetesTotal = 0;
     $paquetesAbasto = 0;
     
	if($row->tiporequerimiento == 1)
	{
		$recetas = $row->cuenta;
		$recetasPiezas = $row->cansur;
		$recetasTotal = $row->total;
		$recetasAbasto = $row->abasto;
	}elseif($row->tiporequerimiento == 2)
	{
		//$colectivos = $row->cuenta;
		//$colectivosPiezas = $row->cansur;
		//$colectivosTotal = $row->total;
		//$colectivosAbasto = $row->abasto;
	}elseif($row->tiporequerimiento == 3)
	{
		$paquetes = $row->cuenta;
		$paquetesPiezas = $row->cansur;
		$paquetesTotal = $row->total;
		$paquetesAbasto = $row->abasto;
	}
}



?>
					<!-- Folios y Desplazamiento -->

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

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

									<div class="infobox infobox-blue">
										<div class="infobox-icon">
											<i class="icon-user"></i>
										</div>

										<div class="infobox-data">
											<span class="infobox-data-number" id="recetas"><?php echo number_format($recetas, 0); ?></span>
											<div class="infobox-content">Recetas capturadas</div>
										</div>

									</div>

									<div class="infobox infobox-red">
										<div class="infobox-icon">
											<i class="icon-group"></i>
										</div>

								{{-- 		<div class="infobox-data">
											<span class="infobox-data-number" id="colectivos"><?php //echo number_format($colectivos, 0); ?></span>
											<div class="infobox-content">Colectivos capturados</div>
										</div> --}}

									</div>

									<div class="infobox infobox-green">
										<div class="infobox-icon">
											<i class="icon-shopping-cart"></i>
										</div>

										<div class="infobox-data">
											<span class="infobox-data-number" id="paquetes"><?php echo number_format($paquetes, 0); ?></span>
											<div class="infobox-content">Paquetes capturados</div>
										</div>
									</div>


									<div class="infobox infobox-blue">
										<div class="infobox-icon">
											<i class="icon-user"></i>
										</div>

										<div class="infobox-data">
											<span class="infobox-data-number" id="recetasPiezas"><?php echo number_format($recetasPiezas, 0); ?></span>
											<div class="infobox-content">Desp. recetas</div>
										</div>

									</div>

									<div class="infobox infobox-red">
										<div class="infobox-icon">
											<i class="icon-group"></i>
										</div>

									{{-- 	<div class="infobox-data">
											<span class="infobox-data-number" id="colectivosPiezas"><?php //echo number_format($colectivosPiezas, 0); ?></span>
											<div class="infobox-content">Desp. colectivos</div>
										</div> --}}

									</div>

									<div class="infobox infobox-green">
										<div class="infobox-icon">
											<i class="icon-shopping-cart"></i>
										</div>

										<div class="infobox-data">
											<span class="infobox-data-number" id="paquetesPiezas"><?php echo number_format($paquetesPiezas, 0); ?></span>
											<div class="infobox-content">Desp. paquetes</div>
										</div>
									</div>

									<div class="space-6"></div>

								</div>
							</div>
						</div>
					</div>

                            <div class="row-fluid">
                                <div class="span6">
                                
                                	<div id="graficaRecetas" style="height: 500px; "></div>
                                
                                </div>
                                <div class="span6">
                                
                                	<div id="graficaDesplazamiento" style="height: 500px; "></div>
                                
                                </div>

                            </div>



                     <!-- Abasto y Dinero -->





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

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

									<div class="infobox infobox-blue">
										<div class="infobox-icon">
											<i class="icon-user"></i>
										</div>

										<div class="infobox-data">
											<span class="infobox-data-number" id="recetasTotal"><?php echo number_format($recetasTotal, 2); ?></span>
											<div class="infobox-content">Total Recetas</div>
										</div>

									</div>

									<div class="infobox infobox-red">
										<div class="infobox-icon">
											<i class="icon-group"></i>
										</div>

										<div class="infobox-data">
{{-- 											<span class="infobox-data-number" id="colectivosTotal"><?php //echo number_format($colectivosTotal, 2); ?></span>
											<div class="infobox-content">Total Colectivos</div>
										</div> --}}

									</div>

									<div class="infobox infobox-green">
										<div class="infobox-icon">
											<i class="icon-shopping-cart"></i>
										</div>

										<div class="infobox-data">
											<span class="infobox-data-number" id="paquetesTotal"><?php echo number_format($paquetesTotal, 2); ?></span>
											<div class="infobox-content">Total Paquetes</div>
										</div>
									</div>


									<div class="infobox infobox-blue">
										<div class="infobox-icon">
											<i class="icon-user"></i>
										</div>

										<div class="infobox-data">
											<span class="infobox-data-number" id="recetasAbasto"><?php echo number_format($recetasAbasto, 2); ?></span>
											<div class="infobox-content">Abasto recetas</div>
										</div>

									</div>

									<div class="infobox infobox-red">
										<div class="infobox-icon">
											<i class="icon-group"></i>
										</div>

										<div class="infobox-data">
{{-- 											<span class="infobox-data-number" id="colectivosAbasto"><?php //echo number_format($colectivosAbasto, 2); ?></span>
											<div class="infobox-content">Abasto colectivos</div>
										</div> --}}

									</div>

									<div class="infobox infobox-green">
										<div class="infobox-icon">
											<i class="icon-shopping-cart"></i>
										</div>

										<div class="infobox-data">
											<span class="infobox-data-number" id="paquetesAbasto"><?php echo number_format($paquetesAbasto, 2); ?></span>
											<div class="infobox-content">Abasto paquetes</div>
										</div>
									</div>

									<div class="space-6"></div>

								</div>
							</div>
						</div>
					</div>

                            <div class="row-fluid">
                                <div class="span6">
                                
                                	<div id="graficaTotal" style="height: 500px; "></div>
                                
                                </div>
                                <div class="span6">
                                
                                	<div id="graficaAbasto" style="height: 500px; "></div>
                                
                                </div>
                            </div>

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

                    		<h3 class="header purple">Venta Mensual Registrada</h3>

                    		<table class="table table-hover">
                    			<thead>
                    				<tr>
                    					<th>Año</th>
                    					<th>Mes</th>
                    					<th style="text-align: right; ">Requeridas</th>
                    					<th style="text-align: right; ">Surtidas</th>
                    					<th style="text-align: center; " colspan="2">Abasto</th>
                    					<th style="text-align: right; ">Importe</th>
                    					<th style="text-align: right; ">IVA Producto</th>
                    					<th style="text-align: right; ">Servicio</th>
                    					<th style="text-align: right; ">IVA Servicio</th>
                    					<th style="text-align: right; ">Subtotal</th>
                    					<th style="text-align: right; ">Tendencia</th>
                    				</tr>
                    			</thead>
                    			<tbody>
                    				<?php 

                    				
                    				$canreq = 0;
                    				$cansur = 0;
									$importe = 0;
									$iva_producto = 0;
									$servicio = 0;
									$iva_servicio = 0;
									$subtotal = 0;
									$subtotal_anterior = 0;
									$abasto_anterior = 0;

                    				foreach ($mensual->result() as $m) {

                    					$abasto = ($m->cansur / $m->canreq) * 100;

                    					$por = number_format((($m->subtotal  - $subtotal_anterior) / ($subtotal_anterior == 0 ? 1 : $subtotal_anterior)) * 100, 2);
                    					$aba = number_format((($abasto  - $abasto_anterior) / ($abasto_anterior == 0 ? 1 : $abasto_anterior)) * 100, 2);

                    					if($subtotal_anterior == 0)
                    					{
                    						$flecha = null;
                    					}elseif($m->subtotal  > $subtotal_anterior)
                    					{
                    						$flecha = '<div class="stat stat-success green">'.$por.'% <i class="icon-arrow-up"></i></div>';
                    					}else

                    					{
                    						$flecha = '<div class="stat stat-warning red">'.$por.'% <i class="icon-arrow-down"></i></div>';
                    					}

                    					if($abasto_anterior == 0)
                    					{
                    						$aba_ten = null;
                    					}elseif($abasto > $abasto_anterior)
                    					{
                    						$aba_ten = '<div class="stat stat-success green">'.$aba.'% <i class="icon-arrow-up"></i></div>';
                    					}else
                    					{
                    						$aba_ten = '<div class="stat stat-warning red">'.$aba.'% <i class="icon-arrow-down"></i></div>';
                    					}
                    					
                    					

                    				?>
                    				<tr>
                    					<td><?php echo $m->anio; ?></td>
                    					<td><?php echo $m->mes; ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->canreq, 0); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->cansur, 0); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($abasto, 2); ?>%</td>
                    					<td style="text-align: right; "><?php echo $aba_ten; ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->importe, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->iva_producto, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->servicio, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->iva_servicio, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->subtotal, 2); ?></td>
                    					<td style="text-align: right; "><?php echo $flecha; ?></td>
                    				</tr>
                    				<?php

                    				$canreq = $canreq + $m->canreq;
                    				$cansur = $cansur + $m->cansur;
                    				$importe = $importe + $m->importe;
                    				$iva_producto = $iva_producto + $m->iva_producto;
                    				$servicio = $servicio + $m->servicio;
                    				$iva_servicio = $iva_servicio + $m->iva_servicio;
                    				$subtotal = $subtotal + $m->subtotal;

                    				$subtotal_anterior = $m->subtotal;
                    				$abasto_anterior = $abasto;

                    				} 

                    				?>
                    			</tbody>
                    			<tfoot>
                    				<tr>
                    					<td colspan="2">Totales: </td>
                    					<td style="text-align: right; "><?php echo number_format($canreq, 0); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($cansur, 0); ?></td>
                    					<td colspan="2"></td>
                    					<td style="text-align: right; "><?php echo number_format($importe, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($iva_producto, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($servicio, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($iva_servicio, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($subtotal, 2); ?></td>
                    				</tr>
                    			</tfoot>
                    		</table>
                    		
                    	</div>
                    </div>


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

                    		<h3 class="header purple">Venta Semanal Registrada</h3>

                    		<table class="table table-hover">
                    			<thead>
                    				<tr>
                    					<th>Año</th>
                    					<th>Mes</th>
                    					<th>Semana</th>
                    					<th style="text-align: right; ">Requeridas</th>
                    					<th style="text-align: right; ">Surtidas</th>
                    					<th style="text-align: center; " colspan="2">Abasto</th>
                    					<th style="text-align: right; ">Importe</th>
                    					<th style="text-align: right; ">IVA Producto</th>
                    					<th style="text-align: right; ">Servicio</th>
                    					<th style="text-align: right; ">IVA Servicio</th>
                    					<th style="text-align: right; ">Subtotal</th>
                    					<th style="text-align: right; ">Tendencia</th>
                    				</tr>
                    			</thead>
                    			<tbody>
                    				<?php 

                    				
                    				$canreq = 0;
                    				$cansur = 0;
									$importe = 0;
									$iva_producto = 0;
									$servicio = 0;
									$iva_servicio = 0;
									$subtotal = 0;
									$subtotal_anterior = 0;
									$abasto_anterior = 0;

                    				foreach ($semanal->result() as $m) {

                    					$abasto = ($m->cansur / $m->canreq) * 100;

                    					$por = number_format((($m->subtotal  - $subtotal_anterior) / ($subtotal_anterior == 0 ? 1 : $subtotal_anterior) ) * 100, 2);
                    					$aba = number_format((($abasto  - $abasto_anterior) / ($abasto_anterior == 0 ? 1 : $abasto_anterior)) * 100, 2);

                    					if($subtotal_anterior == 0)
                    					{
                    						$flecha = null;
                    					}elseif($m->subtotal  > $subtotal_anterior)
                    					{
                    						$flecha = '<div class="stat stat-success green">'.$por.'% <i class="icon-arrow-up"></i></div>';
                    					}else

                    					{
                    						$flecha = '<div class="stat stat-warning red">'.$por.'% <i class="icon-arrow-down"></i></div>';
                    					}

                    					if($abasto_anterior == 0)
                    					{
                    						$aba_ten = null;
                    					}elseif($abasto > $abasto_anterior)
                    					{
                    						$aba_ten = '<div class="stat stat-success green">'.$aba.'% <i class="icon-arrow-up"></i></div>';
                    					}else
                    					{
                    						$aba_ten = '<div class="stat stat-warning red">'.$aba.'% <i class="icon-arrow-down"></i></div>';
                    					}
                    					
                    					

                    				?>
                    				<tr>
                    					<td><?php echo $m->anio; ?></td>
                    					<td><?php echo $m->mes; ?></td>
                    					<td><?php echo $m->semana; ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->canreq, 0); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->cansur, 0); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($abasto, 2); ?>%</td>
                    					<td style="text-align: right; "><?php echo $aba_ten; ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->importe, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->iva_producto, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->servicio, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->iva_servicio, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($m->subtotal, 2); ?></td>
                    					<td style="text-align: right; "><?php echo $flecha; ?></td>
                    				</tr>
                    				<?php

                    				$canreq = $canreq + $m->canreq;
                    				$cansur = $cansur + $m->cansur;
                    				$importe = $importe + $m->importe;
                    				$iva_producto = $iva_producto + $m->iva_producto;
                    				$servicio = $servicio + $m->servicio;
                    				$iva_servicio = $iva_servicio + $m->iva_servicio;
                    				$subtotal = $subtotal + $m->subtotal;

                    				$subtotal_anterior = $m->subtotal;
                    				$abasto_anterior = $abasto;

                    				} 

                    				?>
                    			</tbody>
                    			<tfoot>
                    				<tr>
                    					<td colspan="3">Totales: </td>
                    					<td style="text-align: right; "><?php echo number_format($canreq, 0); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($cansur, 0); ?></td>
                    					<td colspan="2"></td>
                    					<td style="text-align: right; "><?php echo number_format($importe, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($iva_producto, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($servicio, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($iva_servicio, 2); ?></td>
                    					<td style="text-align: right; "><?php echo number_format($subtotal, 2); ?></td>
                    				</tr>
                    			</tfoot>
                    		</table>
                    		
                    	</div>
                    </div>

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

                              <h3 class="header purple">Venta por articulo, Clasificación ABC basados en el volumen de ventas</h3>

                              <table class="table table-hover">
                                   <thead>
                                        <tr>
                                             <th>#</th>
                                             <th>ID</th>
                                             <th>Clave corto</th>
                                             <th>Clave SSA</th>
                                             <th>Sustancia Activa</th>
                                             <th>Descripción</th>
                                             <th>Presentación</th>
                                             <th>Suministro</th>
                                             <th style="text-align: right; ">Precio</th>
                                             <th style="text-align: right; ">Cantidad Requerida</th>
                                             <th style="text-align: right; ">Cantidad Surtida</th>
                                             <th style="text-align: right; ">Subtotal</th>
                                             <th style="text-align: right; ">%</th>
                                             <th style="text-align: right; ">% Acumulado</th>
                                        </tr>
                                   </thead>
                                   <tbody>
                                        <?php 

                                        $i = 1;
                                        $canreq = 0;
                                        $cansur = 0;
                                        $subtotal = 0;
                                        $por_acumulado = 0;
                                        

                                        foreach ($articulos->result() as $m) {

                                             $por = ($m->subtotal / $total) * 100;
                                             $por_acumulado = $por_acumulado + $por;

                                             if($por_acumulado <= 80)
                                             {
                                                  $color = VERDE_PASTEL;
                                             }elseif($por_acumulado > 80 && $por_acumulado <= 95)
                                             {
                                                  $color = AMBAR_PASTEL;
                                             }elseif($por_acumulado > 95)
                                             {
                                                  $color = ROJO_PASTEL;
                                             }

                                             

                                        ?>
                                        <tr style="background-color: <?php echo $color; ?>;">
                                             <td><?php echo $i; ?></td>
                                             <td><?php echo $m->id; ?></td>
                                             <td><?php echo $m->cvearticulo; ?></td>
                                             <td><?php echo $m->clave; ?></td>
                                             <td><?php echo $m->susa; ?></td>
                                             <td><?php echo $m->descripcion; ?></td>
                                             <td><?php echo $m->pres; ?></td>
                                             <td><?php echo $m->suministro; ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->precio, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->canreq, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->cansur, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->subtotal, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($por, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($por_acumulado, 2); ?></td>
                                        </tr>
                                        <?php

                                        $canreq = $canreq + $m->canreq;
                                        $cansur = $cansur + $m->cansur;
                                        $subtotal = $subtotal + $m->subtotal;
                                        $i++;

                                        } 

                                        ?>
                                   </tbody>
                                   <tfoot>
                                        <tr>
                                             <td colspan="9">Totales: </td>
                                             <td style="text-align: right; "><?php echo number_format($canreq, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($cansur, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($subtotal, 2); ?></td>
                                        </tr>
                                   </tfoot>
                              </table>
                              
                         </div>
                    </div>

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

                              <h3 class="header purple">Venta por Farmacias, Clasificación ABC basados en el volumen de ventas</h3>

                              <table class="table table-hover">
                                   <thead>
                                        <tr>
                                             <th>#</th>
                                             <th>Jurisdicción</th>
                                             <th># Sucursal</th>
                                             <th>Sucursal</th>
                                             <th style="text-align: right; ">Cantidad Requerida</th>
                                             <th style="text-align: right; ">Cantidad Surtida</th>
                                             <th style="text-align: right; ">Subtotal</th>
                                             <th style="text-align: right; ">%</th>
                                             <th style="text-align: right; ">% Acumulado</th>
                                        </tr>
                                   </thead>
                                   <tbody>
                                        <?php 

                                        $i = 1;
                                        $canreq = 0;
                                        $cansur = 0;
                                        $subtotal = 0;
                                        $por_acumulado = 0;
                                        

                                        foreach ($farmacias->result() as $m) {

                                             $por = ($m->subtotal / $totalFarmacias) * 100;
                                             $por_acumulado = $por_acumulado + $por;

                                             if($por_acumulado <= 80)
                                             {
                                                  $color = VERDE_PASTEL;
                                             }elseif($por_acumulado > 80 && $por_acumulado <= 95)
                                             {
                                                  $color = AMBAR_PASTEL;
                                             }elseif($por_acumulado > 95)
                                             {
                                                  $color = ROJO_PASTEL;
                                             }

                                             

                                        ?>
                                        <tr style="background-color: <?php echo $color; ?>;">
                                             <td><?php echo $i; ?></td>
                                             <td><?php echo $m->jurisdiccion; ?></td>
                                             <td><?php echo $m->clvsucursal; ?></td>
                                             <td><?php echo $m->descsucursal; ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->canreq, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->cansur, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->subtotal, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($por, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($por_acumulado, 2); ?></td>
                                        </tr>
                                        <?php

                                        $canreq = $canreq + $m->canreq;
                                        $cansur = $cansur + $m->cansur;
                                        $subtotal = $subtotal + $m->subtotal;
                                        $i++;

                                        } 

                                        ?>
                                   </tbody>
                                   <tfoot>
                                        <tr>
                                             <td colspan="4">Totales: </td>
                                             <td style="text-align: right; "><?php echo number_format($canreq, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($cansur, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($subtotal, 2); ?></td>
                                        </tr>
                                   </tfoot>
                              </table>
                              
                         </div>
                    </div>

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

                              <h3 class="header purple">Venta por Jurisdicciones, Clasificación ABC basados en el volumen de ventas</h3>

                              <table class="table table-hover">
                                   <thead>
                                        <tr>
                                             <th>#</th>
                                             <th>Jurisdicción</th>
                                             <th># Sucursal</th>
                                             <th>Sucursal</th>
                                             <th style="text-align: right; ">Cantidad Requerida</th>
                                             <th style="text-align: right; ">Cantidad Surtida</th>
                                             <th style="text-align: right; ">Subtotal</th>
                                             <th style="text-align: right; ">%</th>
                                             <th style="text-align: right; ">% Acumulado</th>
                                        </tr>
                                   </thead>
                                   <tbody>
                                        <?php 

                                        $i = 1;
                                        $canreq = 0;
                                        $cansur = 0;
                                        $subtotal = 0;
                                        $por_acumulado = 0;
                                        

                                        foreach ($juris->result() as $m) {

                                             $por = ($m->subtotal / $totalJuris) * 100;
                                             $por_acumulado = $por_acumulado + $por;

                                             if($por_acumulado <= 80)
                                             {
                                                  $color = VERDE_PASTEL;
                                             }elseif($por_acumulado > 80 && $por_acumulado <= 95)
                                             {
                                                  $color = AMBAR_PASTEL;
                                             }elseif($por_acumulado > 95)
                                             {
                                                  $color = ROJO_PASTEL;
                                             }

                                             

                                        ?>
                                        <tr style="background-color: <?php echo $color; ?>;">
                                             <td><?php echo $i; ?></td>
                                             <td><?php echo $m->jurisdiccion; ?></td>
                                             <td><?php echo $m->clvsucursal; ?></td>
                                             <td><?php echo $m->descsucursal; ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->canreq, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->cansur, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->subtotal, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($por, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($por_acumulado, 2); ?></td>
                                        </tr>
                                        <?php

                                        $canreq = $canreq + $m->canreq;
                                        $cansur = $cansur + $m->cansur;
                                        $subtotal = $subtotal + $m->subtotal;
                                        $i++;

                                        } 

                                        ?>
                                   </tbody>
                                   <tfoot>
                                        <tr>
                                             <td colspan="4">Totales: </td>
                                             <td style="text-align: right; "><?php echo number_format($canreq, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($cansur, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($subtotal, 2); ?></td>
                                        </tr>
                                   </tfoot>
                              </table>
                              
                         </div>
                    </div>

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

                              <h3 class="header purple">Venta por Paquetes, Clasificación ABC basados en el volumen de ventas</h3>

                              <table class="table table-hover">
                                   <thead>
                                        <tr>
                                             <th>#</th>
                                             <th>Jurisdicción</th>
                                             <th># Sucursal</th>
                                             <th>Sucursal</th>
                                             <th style="text-align: right; ">Cantidad Requerida</th>
                                             <th style="text-align: right; ">Cantidad Surtida</th>
                                             <th style="text-align: right; ">Subtotal</th>
                                             <th style="text-align: right; ">%</th>
                                             <th style="text-align: right; ">% Acumulado</th>
                                        </tr>
                                   </thead>
                                   <tbody>
                                        <?php 

                                        $i = 1;
                                        $canreq = 0;
                                        $cansur = 0;
                                        $subtotal = 0;
                                        $por_acumulado = 0;


                                        foreach ($paqueteslist->result() as $m) {

                                             $por = ($m->subtotal / $totalPaquetes) * 100;
                                             $por_acumulado = $por_acumulado + $por;

                                             if($por_acumulado <= 80)
                                             {
                                                  $color = VERDE_PASTEL;
                                             }elseif($por_acumulado > 80 && $por_acumulado <= 95)
                                             {
                                                  $color = AMBAR_PASTEL;
                                             }elseif($por_acumulado > 95)
                                             {
                                                  $color = ROJO_PASTEL;
                                             }

                                             

                                        ?>
                                        <tr style="background-color: <?php echo $color; ?>;">
                                             <td><?php echo $i; ?></td>
                                             <td><?php echo $m->jurisdiccion; ?></td>
                                             <td><?php echo $m->clvsucursal; ?></td>
                                             <td><?php echo $m->descsucursal; ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->canreq, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->cansur, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($m->subtotal, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($por, 2); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($por_acumulado, 2); ?></td>
                                        </tr>
                                        <?php

                                        $canreq = $canreq + $m->canreq;
                                        $cansur = $cansur + $m->cansur;
                                        $subtotal = $subtotal + $m->subtotal;
                                        $i++;

                                        } 

                                        ?>
                                   </tbody>
                                   <tfoot>
                                        <tr>
                                             <td colspan="4">Totales: </td>
                                             <td style="text-align: right; "><?php echo number_format($canreq, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($cansur, 0); ?></td>
                                             <td style="text-align: right; "><?php echo number_format($subtotal, 2); ?></td>
                                        </tr>
                                   </tfoot>
                              </table>
                              
                         </div>
                    </div>
