<?php
/**
 * Clase FN para CrPlanillaPeriodoFN
 *
 * @package    
 * @subpackage CrPlanillaPeriodoFN
 * @author     Willy
 * @version    SVN:: CrPlanillaPeriodoFN.class.php,v 1.1 2014-03-11 18:51:07 william.taype Exp $
 */
class CrPlanillaPeriodoFN extends BaseCrPlanillaPeriodoFN
{
	
	public function montoTotal()
  {
    try
    {
      $where = $this->buildConsult();

      $con = Conexion::getConexion();
      $sql = "SELECT  sum(totalIngresos) as TotalIngresos, sum(totalDescuentos) as TotalDescuentos, sum(TotalAportes) as TotalAportes, sum(Neto) as TotalNeto FROM cr_planilla_periodo WHERE 1 ".$where;
      //echo $sql;
        $oLink = method_exists($con, 'getResource')?$con->getResource():$con;
        $result = mysql_query($sql, $oLink);
      $num_rows = mysql_num_rows($result);
      if($num_rows>0){
      	$i=1;
        while ($o_valor = mysql_fetch_object($result)) {
          $a_montos[$i]['TotalIngresos'] 	= $o_valor->TotalIngresos;
          $a_montos[$i]['TotalDescuentos'] 	= $o_valor->TotalDescuentos;
          $a_montos[$i]['TotalAportes'] 	= $o_valor->TotalAportes;
          $a_montos[$i]['TotalNeto'] 		= $o_valor->TotalNeto;
         
        }
      }
      
      return $a_montos;
    }catch ( Exception $o_Error ){
      throw new Exception($o_Error->getMessage().' en '.$o_Error->getFile().' linea '.$o_Error->getLine());
    }
  }
}