function desliega_expedidos($sql)
{
    global $TOTALES, $direccion, $REPORTE_campos_hidden;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $campos_moneda = array('MONTO', 'ACUMULADO');
    //   $campos_hidden=array('ESTATUS_CHEQUE_ID', 'TIPO_MOV_BANCO_ID', 'FECHA_ORDENADA');
    $result = mysql_db_query(DB_NAME, $sql);
    if (mysql_error() != "") {
        echo "<br>" . $sql . "<br><font class='TEditorError'><br>";
        echo mysql_error() . "</font>";
        exit;
    }
    ?>
	 <table border="0" align="center" cellspacing="5" id="tblDefects"><?php 
    $conta_aux = 0;
    $acumulado = 0;
    $cuenta_anterior = "";
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if ($cuenta_anterior != $dato["CUENTA"] and $cuenta_anterior != "") {
            echo "<tr>";
            echo "<td class='TEsubtotales' colspan=15>";
            echo "Saldo " . formato_moneda($acumulado, 2);
            echo "</td>";
            echo "</tr>";
            $acumulado = 0;
            $conta_aux = 0;
        }
        $cuenta_anterior = $dato["CUENTA"];
        if ($conta == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                if (in_array($campo, $REPORTE_campos_hidden)) {
                    continue;
                }
                $img_ordenamiento = "";
                if ($orderby == $campo) {
                    if ($direccion == "ASC" or $direccion == "") {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_up.png>";
                    } else {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_down.png>";
                    }
                }
                //   echo "<th align=center><a href='javascript:reordena(\"$campo\")'><font style='font-size:11px'>".despiega_nombre_columna_reportes($campo)."</font></a> $img_ordenamiento</th>";
                echo "<th align=center><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font></th>";
            }
            echo "</tr>";
            $conta++;
        }
        $conta_aux++;
        if ($conta_aux == 1) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                if ($campo == "RAZON_SOCIAL") {
                    $aux_banco = consulta("select * from ban_c_cuentas where DESCRIPCION='" . $dato["CUENTA"] . "'");
                    //echo $dato["CUENTA"]."++";
                    $acumulado = $aux_banco["SALDO_INICIAL"];
                    $fecha_saldo_inicial = $_POST["fecha_ini"];
                    //					$fecha_saldo_inicial='2011-01-10';
                    $valor = BANCOS_saldo_cuenta_fecha($aux_banco["CUENTA_ID"], $fecha_saldo_inicial);
                    $acumulado = $valor;
                    echo "<td align=right><b>Saldo inicial</b></td><td align=right><b>" . formato_moneda($valor, 2) . "</b></td><td align=right><b>" . formato_moneda($valor, 2) . "</b></td>";
                } else {
                    echo "<td></td>";
                }
            }
            echo "</tr>";
            $conta++;
        }
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        //		if(($dato["ESTATUS_CHEQUE"]<>"Cancelado") and ($dato["ESTATUS_CHEQUE"]<>"Sin cobrar"))
        if ($dato["ESTATUS_CHEQUE"] != "Cobrado" and $dato["MOV"] == "Egreso x Cheque") {
            if ($_POST["tipo_reporte"] == "cuenta") {
                continue;
            }
            // echo $dato["ESTATUS_CHEQUE_ID"];
            //		  echo "++++".($_POST["tipo_reporte"]=="expedidos")."----".($dato["ESTATUS_CHEQUE"]=="Sin Cobrar")."_";
            if ($_POST["tipo_reporte"] == "expedidos" and $dato["ESTATUS_CHEQUE_ID"] == "1") {
                if ($dato["EN_GARANTIA"] != 1) {
                    $acumulado = $acumulado - $dato["MONTO"];
                }
                //  echo "-".$acumulado."+++".$dato["MONTO"];
            }
        } else {
            if ($dato["ACUMULADO"] < 100) {
                $acumulado = $acumulado + $dato["MONTO"];
            } else {
                $acumulado = $acumulado - $dato["MONTO"];
            }
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $valor = $dato[$aux];
            $campo = mysql_field_name($result, $aux);
            if (in_array($campo, $REPORTE_campos_hidden)) {
                continue;
            }
            if ($campo == "ACUMULADO") {
                $valor = $acumulado;
            }
            $TOTALES[$campo] = $TOTALES[mysql_field_name($result, $aux)] * 1 + $valor;
            //		       echo "<td nowrap align=right>";
            global $REPORTE_COLUMNA;
            $alineacion = "right";
            if ($REPORTE_COLUMNA[$campo]["ALINEACION"]) {
                $alineacion = $REPORTE_COLUMNA[$campo]["ALINEACION"];
            }
            $titulo = " title='" . $valor . "'";
            echo "<td nowrap align='{$alineacion}' {$titulo}>";
            if (in_array($campo, $campos_moneda)) {
                echo formato_moneda($valor, 2);
            } else {
                if ($REPORTE_COLUMNA[$campo]["SIZE"]) {
                    $size = $REPORTE_COLUMNA[$campo]["SIZE"];
                } else {
                    $size = 30;
                }
                if (strlen($valor) > $size) {
                    echo substr($valor, 0, $size) . "...";
                } else {
                    echo $valor;
                }
            }
            echo "</td>";
        }
        echo "</tr>";
    }
    echo "<tr>";
    echo "<td class='TEsubtotales' colspan=10>";
    echo "Saldo " . formato_moneda($acumulado, 2);
    echo "</td>";
    echo "</tr>";
    $TOTALES["REGISTROS"] = mysql_num_rows($result);
    echo "</table>";
}
예제 #2
0
$tbl_reg = array();
$n = 0;
while ($row = mysql_fetch_array($detalle)) {
    $codigo = $row['CLAVE'];
    $cantidad = $row['CANTIDAD'];
    $can = floor($cantidad);
    if ($can == $cantidad || $cantidad == 0) {
        $cantidad = formato_numero($cantidad, 0);
    }
    $desc = utf8_encode($row['DESCRIPCION']);
    $nserie = $row['SERIES'];
    $nserie_debajo = $row['SERIES_DEBAJO'];
    $precio_uni = $row['PRECIO'];
    $importe = $row['CANTIDAD'] * $precio_uni;
    $precio_uni = formato_moneda($precio_uni, 2);
    $importe = formato_moneda($importe, 2);
    //$series_debajo=$row['SERIES'];
    if ($nserie_debajo == "") {
        $tbl_reg[$n] = '<tr>	
					<td style="background:url(\'../images/remisiones/cuadro_left2.png\') left repeat-y">&nbsp;</td>
					<td align="center">' . $codigo . '</td>
					<td align="center">' . $cantidad . '</td>
					<td align="left">' . $desc . '</td>
					<td align="left">' . $nserie . '</td>
					<td align="right">' . $precio_uni . '</td>
					<td style="color:blue;" class="texto_solo" align="right">' . $importe . '</td>
				 </tr>';
    } else {
        $tbl_reg[$n] = '<tr>	
					<td style="background:url(\'../images/remisiones/cuadro_left2.png\') left repeat-y">&nbsp;</td>
					<td align="center">' . $codigo . '</td>
function depositos($sql)
{
    global $TOTALES, $direccion, $orderby;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    if (mysql_error() != "") {
        echo "<br>" . $sql . "<br><font class='TEditorError'><br>";
        echo mysql_error() . "</font>";
        exit;
    }
    ?>
	 <table border="0" align="center" cellspacing="5"><?php 
    $conta = 0;
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if ($conta == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                $img_ordenamiento = "";
                if ($orderby == $campo) {
                    if ($direccion == "ASC" or $direccion == "") {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_up.png>";
                    } else {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_down.png>";
                    }
                }
                echo "<th align=center><a href='javascript:reordena(\"{$campo}\")'><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font></a> {$img_ordenamiento}</th>";
            }
            echo "</tr>";
            $conta++;
        }
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $valor = $dato[$aux];
            $TOTALES[mysql_field_name($result, $aux)] = $TOTALES[mysql_field_name($result, $aux)] * 1 + $valor;
            $campo = mysql_field_name($result, $aux);
            include "reporteador_muestra campo.php";
        }
        echo "</tr>";
        echo "<tr><td  colspan=10>";
        $sql_pagos = "SELECT EGRESO_ID, PAGO from ban_p_bancos_egresos where MOVIMIENTO_ID=" . $dato["MOVIMIENTO_ID"];
        despliega_sql_completo($sql_pagos);
        echo "</tr><td>";
    }
    $TOTALES["REGISTROS"] = mysql_num_rows($result);
    global $campos_totales;
    //print_r($campos_totales)."+";print_r($TOTALES);
    echo '<tr>';
    foreach ($TOTALES as $campo => $valor) {
        echo "<td class='gran_total'>";
        if (in_array($campo, $campos_totales)) {
            echo despiega_nombre_columna_reportes($campo);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "</tr>";
    echo '<tr>';
    foreach ($TOTALES as $campo => $valor) {
        echo "<td class='gran_total'>";
        if (in_array($campo, $campos_totales)) {
            echo formato_moneda($valor, 2);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "</tr>";
    echo "</table>";
}
function despliega_sql_completo_ot($sql)
{
    global $TOTALES, $direccion, $orderby, $REPORTE_campos_hidden;
    //echo $sql;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    if (mysql_error() != "") {
        echo "<br>" . $sql . "<br><font class='TEditorError'><br>";
        echo mysql_error() . "</font>";
        exit;
    }
    ?>
	 <table border="0" align="center" cellspacing="5"><?php 
    $conta = 0;
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if (1) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                if (in_array($campo, $REPORTE_campos_hidden)) {
                    continue;
                }
                $img_ordenamiento = "";
                if ($orderby == $campo) {
                    if ($direccion == "ASC" or $direccion == "") {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_up.png>";
                    } else {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_down.png>";
                    }
                }
                echo "<th align=center><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font> {$img_ordenamiento}</th>";
            }
            echo "</tr>";
            //		$conta++;
        }
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $valor = $dato[$aux];
            $TOTALES[mysql_field_name($result, $aux)] = $TOTALES[mysql_field_name($result, $aux)] * 1 + $valor;
            $campo = mysql_field_name($result, $aux);
            if (in_array($campo, $REPORTE_campos_hidden)) {
                continue;
            }
            include "reporteador_muestra campo.php";
        }
        echo "</tr>";
        echo "<tr><td colspan=10><table>";
        $sql_anaisis = "select CONCEPTO_ID, CLAVE, DESCRIPCION from p_recepcion_partidas where RECEPCION_ID=" . $dato["FOLIO"];
        $result_analisis = mysql_db_query(DB_NAME, $sql_anaisis);
        while ($dato_analisis = mysql_fetch_array($result_analisis, MYSQL_BOTH)) {
            echo "<tr><td><b> - ";
            echo $dato_analisis["DESCRIPCION"];
            echo "</b></td><td></td></tr>";
            $sql_parametros = "select PARAMETRO, UNIDAD from c_analisis_parametros  where CONCEPTO_ID=" . $dato_analisis["CONCEPTO_ID"];
            //echo $sql_parametros;
            $result_parametros = mysql_db_query(DB_NAME, $sql_parametros);
            /*while ($dato_parametros=mysql_fetch_array($result_parametros, MYSQL_BOTH))
            	 {
            		 echo "<tr><td>";
            		 echo $dato_parametros["PARAMETRO"]; echo "</td><td>____________";
            		 echo $dato_parametros["UNIDAD"];
            		 echo "</td></tr>";
            	 }	*/
        }
        //		despliega_sql_completo_nuevo($sql_parametros,"MOVIMIENTO_ID");
        echo "</tr></table></td></tr>";
    }
    $TOTALES["REGISTROS"] = mysql_num_rows($result);
    global $campos_totales;
    echo '<tr>';
    foreach ($TOTALES as $campo => $valor) {
        if (in_array($campo, $REPORTE_campos_hidden)) {
            continue;
        }
        echo "<td class='gran_total'>";
        if (in_array($campo, $campos_totales)) {
            echo despiega_nombre_columna_reportes($campo);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "</tr>";
    echo '<tr>';
    foreach ($TOTALES as $campo => $valor) {
        if (in_array($campo, $REPORTE_campos_hidden)) {
            continue;
        }
        echo "<td class='gran_total'>";
        if (in_array($campo, $campos_totales)) {
            echo formato_moneda($valor, 2);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "</tr>";
    echo "</table>";
}
예제 #5
0
function reportes_facturas_ventas2($sql, $rollup_fields)
{
    global $TOTALES, $TIPO_REPORTE, $CLIENTE_ID, $USUARIO_ID, $direccion, $orderby;
    $TOTALES_MX = array();
    $TOTALES_USD = array();
    $TOTALES_MX_USD = array();
    $PARCIALES_MX = array();
    $PARCIALES_USD = array();
    $PARCIALES_MX_USD = array();
    $paciales_mx_mod = array();
    $parciales_usd_mod = array();
    $parciales_mx_usd_mod = array();
    $anterior_mod = array();
    $print_parcial = array();
    foreach ($rollup_fields as $value) {
        $anterior_mod[$value] = array();
        $parciales_mx_mod[$value] = array();
        $parciales_usd_mod[$value] = array();
        $parciales_mx_usd_mod[$value] = array();
    }
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    ?>
	 <table id="tblDefects" border="0" align="center" cellspacing="0">
<?php 
    $conta = 0;
    $campos_moneda = array('SUBTOTAL', 'IVA', 'TOTAL', 'UTILIDAD', 'COSTO');
    $campos_totales = array('SUBTOTAL', 'IVA', 'TOTAL', 'UTILIDAD', 'COSTO');
    $cliente_anterior = "";
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        //		if (
        //			(($cliente_anterior<>$dato["CLIENTE"]) AND ($TIPO_REPORTE=="cliente")) OR
        //			(($vendedor_anterior<>$dato["EJECUTIVO"]) AND ($TIPO_REPORTE=="vendedor"))
        //		   )
        foreach ($rollup_fields as $field) {
            if ($dato[$field] != $anterior_mod[$field] && $anterior_mod[$field] != "") {
                //imprime parciales
                echo "<tr class='subs'>";
                $conta2 = 0;
                $conta3 = 0;
                foreach ($parciales_mx_mod[$field] as $valor) {
                    echo "<td class='TEsubtotales'>";
                    $campo = mysql_field_name($result, $conta2);
                    if (in_array($campo, $campos_totales)) {
                        echo formato_moneda($valor, 2);
                    }
                    if ($campo == "FECHA") {
                        echo "Total MN (<b>" . $anterior_mod[$field] . "</b>)";
                    }
                    echo "</td>";
                    $conta2++;
                }
                echo "</tr>";
                echo "<tr>";
                $conta = 0;
                foreach ($parciales_usd_mod[$field] as $valor) {
                    echo "<td class='TEsubtotales'>";
                    $campo = mysql_field_name($result, $conta3);
                    if (in_array($campo, $campos_totales)) {
                        echo formato_moneda($valor, 2);
                    }
                    if ($campo == "FECHA") {
                        echo "Total USD (<b>" . $anterior_mod[$field] . "</b>)";
                    }
                    echo "</td>";
                    $conta3++;
                }
                echo "</tr>";
                echo "<tr>";
                $conta3 = 0;
                foreach ($parciales_mx_usd_mod[$field] as $valor) {
                    echo "<td class='TEsubtotales'>";
                    $campo = mysql_field_name($result, $conta3);
                    if (in_array($campo, $campos_totales)) {
                        echo formato_moneda($valor, 2);
                    }
                    if ($campo == "FECHA") {
                        echo "Gran Total MX";
                    }
                    echo "</td>";
                    $conta3++;
                }
                echo "</tr>";
                $parciales_mx_mod[$field] = array();
                $parciales_usd_mod[$field] = array();
                $parciales_mx_usd_mod[$field] = array();
            }
            //imprime parciales
        }
        //END FOR EACH
        //DATO ANTERIOR
        $cliente_anterior = $dato["CLIENTE"];
        $vendedor_anterior = $dato["EJECUTIVO"];
        foreach ($rollup_fields as $value) {
            $anterior_mod[$value] = $dato[$value];
        }
        if ($conta == 0) {
            //TITULOS
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                $img_ordenamiento = "";
                if ($orderby == $campo) {
                    if ($_POST['mode'] != "excel") {
                        if ($direccion == "ASC" or $direccion == "") {
                            $img_ordenamiento = "<img src=" . TEImagesPath . "arror_up.png>";
                        } else {
                            $img_ordenamiento = "<img src=" . TEImagesPath . "arror_down.png>";
                        }
                    }
                }
                echo "<th align=center><a href='javascript:reordena(\"{$campo}\")'><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font></a> {$img_ordenamiento}</th>";
            }
            echo "</tr>";
            $conta++;
        }
        //color de fondo
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        //empieza imprecion de fila
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $campo = mysql_field_name($result, $aux);
            //---modificado
            if (empty($_POST['nueva_paridad']) || $_POST['nueva_paridad'] <= 0 || !is_numeric($_POST['nueva_paridad'])) {
                //validacion
                $par = 1;
                //nueva paridad
            } else {
                $par = $_POST['nueva_paridad'];
            }
            //fin nueva paridad
            //si son dolares
            if ($_POST['tipo_moneda'] == 1 && ($campo == 'SUBTOTAL' || $campo == 'IVA' || $campo == 'TOTAL') && $dato[7] == 'USD') {
                $valor2 = $dato[$aux] * $par;
                //valor en pesos
                $valor = $dato[$aux];
                //val dolares
            } elseif ($_POST['tipo_moneda'] == 2 && ($campo == 'SUBTOTAL' || $campo == 'IVA' || $campo == 'TOTAL') && $dato[7] == 'MX') {
                $valor2 = $dato[$aux] / $par;
                //val pesos
                $valor = $dato[$aux];
                //val dolares
            } else {
                //si no se selecciono tipo de moneda
                $valor2 = $dato[$aux];
                $valor = $dato[$aux];
            }
            //----fin modificado
            //			 if ($campo=="UTILIDAD") $valor=$dato["TOTAL"]-$dato["COSTO"];
            //			 if (($campo=="DIAS_VENCIDOS") AND ($dato["ESTATUS"]<>"Activa")) $valor="";
            if ($dato["MONEDA"] == "MX") {
                $campo = mysql_field_name($result, $aux);
                foreach ($rollup_fields as $field) {
                    $parciales_mx_mod[$field][$campo] = $parciales_mx_mod[$field][$campo] * 1 + $valor;
                    $parciales_mx_usd[$field][$campo] = $parciales_mx_usd[$field][$campo] * 1 + $valor;
                }
                $PARCIALES_MX[mysql_field_name($result, $aux)] = $PARCIALES_MX[mysql_field_name($result, $aux)] * 1 + $valor;
                $TOTALES_MX[mysql_field_name($result, $aux)] = $TOTALES_MX[mysql_field_name($result, $aux)] * 1 + $valor;
                $PARCIALES_MX_USD[mysql_field_name($result, $aux)] = $PARCIALES_MX_USD[mysql_field_name($result, $aux)] + $valor;
                $TOTALES_MX_USD[mysql_field_name($result, $aux)] += $valor;
            }
            if ($dato["MONEDA"] == "USD") {
                $campo = mysql_field_name($result, $aux);
                foreach ($rollup_fields as $field) {
                    $parciales_usd_mod[$field][$campo] += $parciales_usd_mod[$field][$campo] * 1 + $valor;
                    $parciales_mx_usd[$field][$campo] += $valor * $dato["PARIDAD"];
                }
                $PARCIALES_USD[mysql_field_name($result, $aux)] = $PARCIALES_USD[mysql_field_name($result, $aux)] * 1 + $valor;
                $TOTALES_USD[mysql_field_name($result, $aux)] = $TOTALES_USD[mysql_field_name($result, $aux)] * 1 + $valor;
                $PARCIALES_MX_USD[mysql_field_name($result, $aux)] = $PARCIALES_MX_USD[mysql_field_name($result, $aux)] + $valor * $dato["PARIDAD"];
                $TOTALES_MX_USD[mysql_field_name($result, $aux)] += $valor * $dato["PARIDAD"];
            }
            //		       echo "<td align=right nowrap>";
            $titulo = " title='" . $valor . "'";
            global $REPORTE_COLUMNA;
            $alineacion = "right";
            if ($REPORTE_COLUMNA[$campo]["ALINEACION"]) {
                $alineacion = $REPORTE_COLUMNA[$campo]["ALINEACION"];
            }
            echo "<td align='{$alineacion}' {$titulo}>";
            if ($campo == "FACTURA") {
                $aux_factura = consulta("select FACTURA_ID FROM vta_p_facturas where FOLIO_FISCAL='" . $dato["FACTURA"] . "'");
                $lupita = $_POST['mode'] != "excel" ? "<img border=0 src='../images/samples_ico1.png'>" : "";
                echo "<a href='../admin/index.php?table=vta_p_facturas&edit=" . $aux_factura["FACTURA_ID"] . "' target=_new>{$lupita}</a>";
            }
            if ($valor < 0) {
                echo "<b>";
            }
            if ($campo == "MARGEN" and $dato["TOTAL"] != 0) {
                $margen_aux = $dato["UTILIDAD"] * 100 / $dato["SUBTOTAL"];
                $valor = formato_numero($margen_aux, 2);
                $margen[] = $valor;
            }
            //			   if(in_array($campo, $campos_moneda)) echo formato_moneda($valor,2); else echo $valor;
            if (in_array($campo, $campos_moneda)) {
                echo formato_moneda($valor, 2);
            } else {
                if ($_POST['mode'] != "excel" and strlen($valor) > 30) {
                    echo substr($valor, 0, 30) . "...";
                } else {
                    echo $valor;
                }
            }
            echo "</td>";
        }
        echo "</tr>";
    }
    //END WHILE
    //PARCIALES FINALES
    foreach ($rollup_fields as $field) {
        if ($dato[$field] != $anterior_mod[$field] && $anterior_mod[$field] != "") {
            //imprime parciales
            echo "<tr class='subs'>";
            $conta2 = 0;
            $conta3 = 0;
            foreach ($parciales_mx_mod[$field] as $valor) {
                echo "<td class='TEsubtotales'>";
                $campo = mysql_field_name($result, $conta2);
                if (in_array($campo, $campos_totales)) {
                    echo formato_moneda($valor, 2);
                }
                if ($campo == "FECHA") {
                    echo "Total MN (" . $anterior_mod[$field] . ")";
                }
                echo "</td>";
                $conta2++;
            }
            echo "</tr>";
            echo "<tr>";
            $conta = 0;
            foreach ($parciales_usd_mod[$field] as $valor) {
                echo "<td class='TEsubtotales'>";
                $campo = mysql_field_name($result, $conta3);
                if (in_array($campo, $campos_totales)) {
                    echo formato_moneda($valor, 2);
                }
                if ($campo == "FECHA") {
                    echo "Total USD (" . $anterior_mod[$field] . ")";
                }
                echo "</td>";
                $conta3++;
            }
            echo "</tr>";
            echo "<tr>";
            $conta3 = 0;
            foreach ($parciales_mx_usd_mod[$field] as $valor) {
                echo "<td class='TEsubtotales'>";
                $campo = mysql_field_name($result, $conta3);
                if (in_array($campo, $campos_totales)) {
                    echo formato_moneda($valor, 2);
                }
                if ($campo == "FECHA") {
                    echo "Gran Total MX (" . $anterior_mod[$field] . ")";
                }
                echo "</td>";
                $conta3++;
            }
            echo "</tr>";
            //
            $parciales_mx_mod[$field] = array();
            $parciales_usd_mod[$field] = array();
            $parciales_mx_usd_mod[$field] = array();
        }
        //imprime parciales
    }
    //END FOR EACH
    //PARCIALES FINALES
    /*
    		echo "<tr>";$conta2=0;$conta3=0;
    		foreach($PARCIALES_MX as $valor)
    		{
    			echo "<td class='TEsubtotales'>";$campo=mysql_field_name($result,$conta2); 
    			 if(in_array($campo, $campos_totales)) echo formato_moneda($valor,2);
    			 if($campo=="FECHA") echo "Total MN";
    			echo "</td>";$conta2++;
    		}
    		echo "</tr>";
    		echo "<tr>";$conta=0;
    		foreach($PARCIALES_USD as $valor)
    		{
    			echo "<td class='TEsubtotales'>";$campo=mysql_field_name($result,$conta3); 
    			 if(in_array($campo, $campos_totales)) echo formato_moneda($valor,2);
    			 if($campo=="FECHA") echo "Total USD";
    			echo "</td>";$conta3++;
    		}
    		echo "</tr>";			
    */
    ////////// GRAN TOTAL
    if (!$CLIENTE_ID and !$USUARIO_ID) {
        echo "<tr>";
        $conta = 0;
        foreach ($TOTALES_MX as $valor) {
            echo "<td class='gran_total'>";
            $campo = mysql_field_name($result, $conta);
            if (in_array($campo, $campos_totales)) {
                echo formato_moneda($valor, 2);
            }
            if ($campo == "FECHA") {
                echo "Gran Total MN";
            }
            echo "</td>";
            $conta++;
        }
        echo "</tr>";
        echo "<tr>";
        $conta = 0;
        foreach ($TOTALES_USD as $valor) {
            echo "<td class='gran_total'>";
            $campo = mysql_field_name($result, $conta);
            if (in_array($campo, $campos_totales)) {
                echo formato_moneda($valor, 2);
            }
            if ($campo == "FECHA") {
                echo "Gran Total USD";
            }
            echo "</td>";
            $conta++;
        }
        echo "</tr>";
        echo '<tr>';
        foreach ($TOTALES_MX_USD as $key => $valor) {
            echo "<td class='gran_total'>";
            #$campo=mysql_field_name($result,$conta);
            $campo = $key;
            if (in_array($campo, $campos_totales)) {
                echo formato_moneda($valor, 2);
            }
            if ($campo == "FECHA") {
                echo "Gran Total MX";
            }
            echo "</td>";
            $conta++;
        }
        echo "</tr>";
    }
    echo "</table>";
}
$alineacion = "right";
if ($REPORTE_COLUMNA[$campo]["ALINEACION"]) {
    $alineacion = $REPORTE_COLUMNA[$campo]["ALINEACION"];
}
$titulo = " title='" . $valor . "'";
echo "<td nowrap align='{$alineacion}' {$titulo}>";
if ($REPORTE_COLUMNA[$campo]["SIZE"]) {
    $size = $REPORTE_COLUMNA[$campo]["SIZE"];
} else {
    $size = 3000;
}
if (strlen($valor) > $size) {
    echo substr($valor, 0, $size) . "...";
} else {
    if ($REPORTE_COLUMNA[$campo]["FORMATO"] == "Moneda") {
        echo formato_moneda($valor, 2);
    } else {
        echo $valor;
    }
}
switch ($campo) {
    case "PROMESA_PAGO":
        if ($_POST['mode'] != "excel") {
            echo "<a href='../admin/?table=cob_p_gestion&add=1&no_menu=1&folio_fiscal=" . $dato["FACTURA"] . "' target=gestion_cobranza><img src=" . TEImagesPath . "LeftSubmenuCatalog.png border=0></a>";
        }
        break;
    case "PAGOS":
        if ($rep == "com1") {
            $sql_pagos = "select c.PAGO, b.MONEDA  from egr_p_egresos b, egr_p_egresos_facturas c where b.PROVEEDOR_ID=" . $dato["PROVEEDOR_ID"] . " and c.FACTURA='" . $dato["FACTURA"] . "' and\nb.EGRESO_ID=c.EGRESO_ID  ";
            despliega_sql_completo($sql_pagos);
            //echo $sql_pagos;
<?php

include "../config/config.php";
include $rep . "_reporteador_sql.php";
require_once "reporte_inicio.php";
require "reporteador_encabezado.php";
$reporte = new muestra_reporte();
$reporte->sql = $sql_bancos;
$reporte->campos_subtotales = array('SALDO', 'TOTAL_MN');
// Muestra totales de esta columna, separa cantidades en MX, USD y un global
$reporte->campos_MX = array('TOTAL_MN');
// Considera todas las cantidades en MX,  si no se pone esta considera totales en MX, totales en USD y total global
//  $reporte->campos_USD=array('TOTAL_USD');    // Considera todas las cantidades en USD, si no se pone esta considera totales en MX, totales en USD y total global
$reporte->despliega_reporte();
// Despliega el reporte
$x_cobrar = consulta($sql_x_cobrar);
$x_pagar = consulta($sql_x_pagar);
echo "<table width='800' align='center' border='0'><tr><th> Por cobrar </th><td class='gran_total'>";
echo formato_moneda($x_cobrar["POR_COBRAR_MN"], 2) . " MN";
echo "</td></tr><tr><th> Por pagar </th><td class='gran_total'>";
echo formato_moneda($x_pagar["POR_PAGAR_MN"], 2) . " MN";
echo "</td></tr></table>";
require_once "reporte_fin.php";
예제 #8
0
function despliega_sql_completo_proveedores_detalle($sql)
{
    global $TOTALES, $direccion, $orderby, $REPORTE_campos_hidden;
    $tot = 0;
    $prov = '';
    $nprov = '';
    $t = 0;
    $reg = false;
    $cc = 0;
    $c = 0;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    if (mysql_error() != "") {
        echo "<br>" . $sql . "<br><font class='TEditorError'><br>";
        echo mysql_error() . "</font>";
        exit;
    }
    ?>



	 <table border="0" align="center" cellspacing="5"><?php 
    $conta = 0;
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if ($conta == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                if (mysql_field_name($result, $aux) != 'PROVEEDOR_ID') {
                    if (in_array($campo, $REPORTE_campos_hidden)) {
                        continue;
                    }
                    $img_ordenamiento = "";
                    if ($orderby == $campo) {
                        if ($direccion == "ASC" or $direccion == "") {
                            $img_ordenamiento = "<img src=" . TEImagesPath . "arror_up.png>";
                        } else {
                            $img_ordenamiento = "<img src=" . TEImagesPath . "arror_down.png>";
                        }
                    }
                    echo "<th align=center><a href='javascript:reordena(\"{$campo}\")'><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font></a> {$img_ordenamiento}</th>";
                } else {
                    echo '<td></td>';
                }
            }
            echo "</tr>";
            $conta++;
        }
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $valor = $dato[$aux];
            $TOTALES[mysql_field_name($result, $aux)] = $TOTALES[mysql_field_name($result, $aux)] * 1 + $valor;
            $campo = mysql_field_name($result, $aux);
            if (mysql_field_name($result, $aux) != 'PROVEEDOR_ID') {
                if (in_array($campo, $REPORTE_campos_hidden)) {
                    continue;
                }
                include "reporteador_muestra campo.php";
            } else {
                echo '<td></td>';
            }
            if (mysql_field_name($result, $aux) == 'PROVEEDOR_ID' && $cc == 0) {
                $resul = mysql_query("select PROVEEDOR_ID FROM com_p_proveedores_facturas where PROVEEDOR_ID=" . $valor);
                $num = mysql_num_rows($resul);
                $cc = 1;
            }
            if (mysql_field_name($result, $aux) == 'TOTAL') {
                $tot += $valor;
                $t = $aux;
            }
            if ($c < $num - 1 && $aux == $i - 1) {
                $c++;
                $reg = false;
            } else {
                $reg = true;
            }
            if ($aux == $i - 1 && $reg == true) {
                echo '</tr><tr style="background:#CCC;>';
                for ($a = 0; $a < $i + 1; $a++) {
                    if ($a == $t + 1) {
                        echo '<td style="text-align:right;border:1px solid #999;">' . formato_moneda($tot, 2) . '</td>';
                    } else {
                        echo '<td style="border:1px solid #999;"></td>';
                    }
                }
                $tot = 0;
                $t = 0;
                $reg = false;
                $c = 0;
                $cc = 0;
            }
        }
        echo "</tr>";
    }
    $TOTALES["REGISTROS"] = mysql_num_rows($result);
    global $campos_totales;
    echo '<tr>';
    foreach ($TOTALES as $campo => $valor) {
        if (in_array($campo, $REPORTE_campos_hidden)) {
            continue;
        }
        echo "<td class='gran_total'>";
        if (in_array($campo, $campos_totales)) {
            echo despiega_nombre_columna_reportes($campo);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "</tr>";
    echo '<tr>';
    foreach ($TOTALES as $campo => $valor) {
        if (in_array($campo, $REPORTE_campos_hidden)) {
            continue;
        }
        echo "<td class='gran_total'>";
        if (in_array($campo, $campos_totales)) {
            echo formato_moneda($valor, 2);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "</tr>";
    echo "</table>";
}
function depositos_x_cuenta($sql, $REPORTE_campos_hidden = array("MOVIMIENTO_ID", "FECHA_ORDENADA", "TIPO_CONTA_2", "PARIDAD", "MONEDA", "TIPO_MOV_BANCO_ID", "ORDEN_MOVIMIENTO"), $campos_totales = array("MONTO", "SUB_MN", "IVA_MN", "PAGO_MN"))
{
    $z = 0;
    //echo $sql;
    global $TOTALES, $direccion, $orderby;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    if (mysql_error() != "") {
        echo "<br>" . $sql . "<br><font class='TEditorError'><br>";
        echo mysql_error() . "</font>";
        exit;
    }
    ?>
	 <table border="0" align="center" cellspacing="5"><?php 
    $conta = 0;
    $anterior = array();
    $TOTALES_CORTES = array();
    $campos_subtotales = array('MONTO', 'SUB_MN', 'IVA_MN', 'PAGO_MN');
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        $imprimir_subtotal = 0;
        if ($anterior["CUENTA"] != $dato["CUENTA"]) {
            $imprimir_subtotal = 1;
        }
        if ($imprimir_subtotal and $anterior["CUENTA"] != "") {
            //			echo "<tr><td></td><td>".$dato["CUENTA"]."</td></tr>";
            foreach ($TOTALES_CORTES as $campo => $valor) {
                if (in_array($campo, $REPORTE_campos_hidden)) {
                    continue;
                }
                echo "<td class='TEsubtotales'>";
                if (in_array($campo, $campos_subtotales)) {
                    echo formato_moneda($valor, 2);
                }
                echo "</td>";
            }
            //				echo "<td class='gran_total'></td><td class='gran_total'></td><td class='gran_total'>";
            echo "<td><table width=100%><tr><td class='TEsubtotales' width=100></td><td class='TEsubtotales' width=100></td>";
            echo "<td class='TEsubtotales' width=100>Sub MN<br>" . formato_moneda($TOTALES["SUB_MN"], 2) . "</td>";
            echo "<td class='TEsubtotales' width=100>IVA MN <br>" . formato_moneda($TOTALES["IVA_MN"], 2) . "</td>";
            echo "<td class='TEsubtotales' width=100>Pago MN <br>" . formato_moneda($TOTALES["PAGO_MN"], 2) . "</td>";
            echo "<td class='TEsubtotales' width=100>Pagos <br>" . formato_moneda($TOTALES["PAGOS"], 2) . "</td>";
            echo "<td class='TEsubtotales' width=100></td>";
            echo "</tr></table></td>";
            $TOTALES_CORTES = array();
            $TOTALES_GLOBALES["SUB_MN"] = $TOTALES_GLOBALES["SUB_MN"] * 1 + $TOTALES["SUB_MN"];
            $TOTALES_GLOBALES["IVA_MN"] = $TOTALES_GLOBALES["IVA_MN"] * 1 + $TOTALES["IVA_MN"];
            $TOTALES_GLOBALES["PAGO_MN"] = $TOTALES_GLOBALES["PAGO_MN"] * 1 + $TOTALES["PAGO_MN"];
            $TOTALES_GLOBALES["P"] = $TOTALES_GLOBALES["P"] * 1 + $TOTALES["P"];
            $TOTALES = array();
        }
        if ($imprimir_subtotal) {
            echo "<tr><td></td><td></td><td></td><td colspan=2><b>" . $dato["CUENTA"] . "</b></td></tr>";
        }
        $anterior["CUENTA"] = $dato["CUENTA"];
        // Titulos
        if ($conta == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                if (in_array($campo, $REPORTE_campos_hidden)) {
                    continue;
                }
                $img_ordenamiento = "";
                echo "<th align=center><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font> {$img_ordenamiento}</th>";
            }
            echo '</tr>';
            $conta++;
        }
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $valor = $dato[$aux];
            $TOTALES[mysql_field_name($result, $aux)] = $TOTALES[mysql_field_name($result, $aux)] * 1 + $valor;
            $TOTALES_CORTES[mysql_field_name($result, $aux)] = $TOTALES_CORTES[mysql_field_name($result, $aux)] * 1 + $valor;
            $TOTALES_GLOBALES[mysql_field_name($result, $aux)] = $TOTALES_GLOBALES[mysql_field_name($result, $aux)] * 1 + $valor;
            $campo = mysql_field_name($result, $aux);
            if (in_array($campo, $REPORTE_campos_hidden)) {
                continue;
            }
            include "reporteador_muestra campo.php";
        }
        //print_r();
        echo "<td>";
        if ($dato["TIPO_CONTA_2"] == 1) {
            $sql_pagos = "\n\t\t   SELECT \n\t\t   a.FOLIO_FISCAL, \n\t\t   DATE_FORMAT(b.FECHA, '%d/%m/%Y') as FECHA_FACTURA, \n\t\t   FORMAT((if(b.MONEDA='USD', PAGO*c.PARIDAD/1.16, PAGO/1.16)),2) AS SUB_MN,\n\t\t   FORMAT((if(b.MONEDA='USD', PAGO*c.PARIDAD*0.16/1.16, PAGO*0.16/1.16)), 2) AS IVA_MN,\n\t\t   FORMAT((if(b.MONEDA='USD', PAGO*c.PARIDAD, PAGO)),2) AS PAGO_MN,\n\t\t   FORMAT(\n\t\t\t   if\n\t\t\t   (\n\t\t\t     (SELECT MONEDA from ban_c_cuentas where CUENTA_ID=c.CUENTA_ID)='MX' , \n\t\t\t     (if(b.MONEDA='USD', PAGO*c.PARIDAD, PAGO)), \n\t\t\t\t (if(b.MONEDA='USD', PAGO*c.PARIDAD, PAGO))/c.PARIDAD\n\t\t\t   )\n\t\t   ,2) AS PAGOS,\n   \t\t   c.PARIDAD\n\t\t   from \n\t\t   ban_p_bancos_facturas a, vta_p_facturas b, ban_p_bancos c\n\t\t   where \n\t\t   a.MOVIMIENTO_ID=c.MOVIMIENTO_ID and\n\t\t   a.FOLIO_FISCAL=b.FOLIO_FISCAL AND\n\t\t   a.MOVIMIENTO_ID=" . $dato["MOVIMIENTO_ID"];
            //echo $sql_pagos;
        }
        if ($dato["TIPO_CONTA_2"] == 2) {
            $sql_pagos = "select '' AS FOLIO_FISCAL, '' AS FECHA_FACTURA, FORMAT(" . $dato["MONTO"] . ",2) AS SUB_MN, 0.00 AS IVA_MN, FORMAT(" . $dato["MONTO"] . ",2) AS PAGO_MN, FORMAT(" . $dato["MONTO"] . ",2) AS PAGOS, 1 AS PARIDAD";
        }
        if ($dato["TIPO_MOV_BANCO_ID"] == 3 || mysql_num_rows(mysql_query($sql_pagos)) == 0) {
            if ($dato["MONEDA"] == "USD") {
                $monto = $dato["MONTO"] * $dato["PARIDAD"];
            } else {
                $monto = $dato["MONTO"];
            }
            $monto = round($monto, 2);
            if ($dato["MONEDA"] == "USD") {
                $monto_usd = $dato["MONTO"];
            } else {
                $monto_usd = $dato["MONTO"] / $dato["PARIDAD"];
            }
            $monto = round($monto, 2);
            $sql_pagos = "select '' AS FOLIO_FISCAL, '' AS FECHA_FACTURA, FORMAT(" . $monto . ",2) AS SUB_MN, 0.00 AS IVA_MN, FORMAT(" . $monto . ",2) AS PAGO_MN, FORMAT(" . $monto_usd . ",2) AS PAGOS," . $dato["PARIDAD"] . " AS PARIDAD";
        }
        despliega_sql_completo2($sql_pagos, $z);
        if (mysql_num_rows(mysql_query($sql_pagos)) > 0) {
            $z++;
        }
        if ($dato["MONEDA"] == "USD") {
            $TOTALES_GLOBALES_USD = $TOTALES_GLOBALES_USD + $dato["MONTO"];
        } else {
            $TOTALES_GLOBALES_MX = $TOTALES_GLOBALES_MX + $dato["MONTO"];
        }
        echo "</td>";
        echo "</tr>";
    }
    foreach ($TOTALES_CORTES as $campo => $valor) {
        if (in_array($campo, $REPORTE_campos_hidden)) {
            continue;
        }
        echo "<td class='TEsubtotales'>";
        if (in_array($campo, $campos_subtotales)) {
            echo formato_moneda($valor, 2);
        }
        echo "</td>";
    }
    echo "<td><table width=100%><tr><td class='TEsubtotales' width=100></td><td class='TEsubtotales' width=100></td>";
    echo "<td class='TEsubtotales' width=100>" . formato_moneda($TOTALES["SUB_MN"], 2) . "</td>";
    echo "<td class='TEsubtotales' width=100>" . formato_moneda($TOTALES["IVA_MN"], 2) . "</td>";
    echo "<td class='TEsubtotales' width=100>" . formato_moneda($TOTALES["PAGO_MN"], 2) . "</td>";
    echo "<td class='TEsubtotales' width=100>" . formato_moneda($TOTALES["PAGOS"], 2) . "</td>";
    echo "<td class='TEsubtotales' width=100></td>";
    echo "</tr></table></td>";
    $TOTALES["REGISTROS"] = mysql_num_rows($result);
    //	$campos_subtotales=array("MONTO");
    //include('reporte_muestra_reporte_totales.php');
    echo "</table>";
    echo '<table align="center"><tr><TD width=300 class="gran_total"></TD>';
    foreach ($TOTALES_GLOBALES as $campo => $valor) {
        if (in_array($campo, $REPORTE_campos_hidden)) {
            continue;
        }
        //	    echo "<td class='gran_total'></td><td class='gran_total'></td><td class='gran_total'></td>";
        echo "<td class='gran_total' width='100'>";
        if (in_array($campo, $campos_subtotales) && $campo != "MONTO") {
            echo $campo . "<br>" . formato_moneda($TOTALES_GLOBALES[$campo] + $TOTALES[$campo], 2);
        }
        if ($campo == "MONTO") {
            echo "Total MX " . formato_moneda($TOTALES_GLOBALES_MX, 2) . "<BR> Total USD <br>" . formato_moneda($TOTALES_GLOBALES_USD, 2);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "<TD width=100 class='gran_total'></TD>";
    echo "</tr></table>";
}
function reportes_facturas_ventas_cobranza($sql)
{
    global $TOTALES, $CLIENTE_ID, $USUARIO_ID, $direccion, $orderby, $campos_totales;
    $TOTALES_MX = array();
    $TOTALES_USD = array();
    $TOTALES_MX_USD = array();
    $PARCIALES_MX = array();
    $PARCIALES_USD = array();
    $PARCIALES_MX_USD = array();
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    if ($_POST['mode'] == "excel") {
        $borde = "border=1 BORDERCOLOR=#dadada ";
    } else {
        $borde = "border=0";
    }
    ?>
	 <table <?php 
    echo $borde;
    ?>
 align="center" cellspacing="0">
<?php 
    $conta = 0;
    $conta_general = 0;
    $conta_cliente = 0;
    //	 $campos_totales=array('SUBTOTAL','IVA','TOTAL', 'UTILIDAD', 'PAGADO', 'SALDO');
    $cliente_anterior = "";
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if ($cliente_anterior != $dato["CLIENTE"]) {
            echo "<tr>";
            $conta3 = 0;
            foreach ($PARCIALES_MX_USD as $valor) {
                echo "<td class='TEsubtotales'>";
                $campo = mysql_field_name($result, $conta3);
                if (in_array($campo, $campos_totales)) {
                    echo formato_moneda($valor, 2);
                }
                if ($campo == "FECHA_VENCIMIENTO") {
                    echo "Gran Total MX";
                }
                echo "</td>";
                $conta3++;
                $conta_cliente = 0;
            }
            echo "</tr><tr><td colspan=10>&nbsp;</td></tr>";
            $PARCIALES_MX = array();
            $PARCIALES_USD = array();
            $PARCIALES_MX_USD = array();
        }
        $cliente_anterior = $dato["CLIENTE"];
        if ($conta_general == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                $img_ordenamiento = "";
                if ($orderby == $campo) {
                    if ($_POST['mode'] != "excel") {
                        if ($direccion == "ASC" or $direccion == "") {
                            $img_ordenamiento = "<img src=" . TEImagesPath . "arror_up.png>";
                        } else {
                            $img_ordenamiento = "<img src=" . TEImagesPath . "arror_down.png>";
                        }
                    }
                }
                echo "<th bgcolor='#dadada' align=center><a href='javascript:reordena(\"{$campo}\")'><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font></a> {$img_ordenamiento}</th>";
            }
            echo "</tr>";
            $conta++;
        }
        $conta_general++;
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        $conta_cliente++;
        for ($aux = 0; $aux < $i; $aux++) {
            $campo = mysql_field_name($result, $aux);
            $valor = $dato[$aux];
            if ($campo == "DIAS_VENCIDOS" and $dato["ESTATUS"] != "Activa") {
                $valor = "";
            }
            if ($dato["MONEDA"] == "MX") {
                $PARCIALES_MX[mysql_field_name($result, $aux)] = $PARCIALES_MX[mysql_field_name($result, $aux)] * 1 + $valor;
                $TOTALES_MX[mysql_field_name($result, $aux)] = $TOTALES_MX[mysql_field_name($result, $aux)] * 1 + $valor;
                $PARCIALES_MX_USD[mysql_field_name($result, $aux)] = $PARCIALES_MX_USD[mysql_field_name($result, $aux)] + $valor;
                $TOTALES_MX_USD[mysql_field_name($result, $aux)] += $valor;
            }
            if ($dato["MONEDA"] == "USD") {
                $PARCIALES_USD[mysql_field_name($result, $aux)] = $PARCIALES_USD[mysql_field_name($result, $aux)] * 1 + $valor;
                $TOTALES_USD[mysql_field_name($result, $aux)] = $TOTALES_USD[mysql_field_name($result, $aux)] * 1 + $valor;
                $PARCIALES_MX_USD[mysql_field_name($result, $aux)] = $PARCIALES_MX_USD[mysql_field_name($result, $aux)] + $valor * $dato["PARIDAD"];
                $TOTALES_MX_USD[mysql_field_name($result, $aux)] += $valor * $dato["PARIDAD"];
            }
            $no_repetir = array("CONTACTO", "TELEFONO", "EMAIL", "COMENTARIO");
            if ($conta_cliente > 1 and in_array($campo, $no_repetir)) {
                $valor = "";
            }
            include "reporteador_muestra campo.php";
        }
        echo "</tr>";
    }
    echo "<tr>";
    $conta3 = 0;
    foreach ($PARCIALES_MX_USD as $valor) {
        echo "<td class='TEsubtotales'>";
        $campo = mysql_field_name($result, $conta3);
        if (in_array($campo, $campos_totales)) {
            echo formato_moneda($valor, 2);
        }
        if ($campo == "FECHA_VENCIMIENTO") {
            echo "Gran Total MX";
        }
        echo "</td>";
        $conta3++;
        $conta_cliente = 0;
    }
    echo "</tr><tr><td colspan=10>&nbsp;</td></tr>";
    ////////// GRAN TOTAL
    if (!$CLIENTE_ID and !$USUARIO_ID) {
        echo "<tr>";
        $conta = 0;
        foreach ($TOTALES_MX as $valor) {
            echo "<td class='gran_total'>";
            $campo = mysql_field_name($result, $conta);
            if (in_array($campo, $campos_totales)) {
                echo formato_moneda($valor, 2);
            }
            if ($campo == "FECHA_VENCIMIENTO") {
                echo "Gran Total MN";
            }
            echo "</td>";
            $conta++;
        }
        echo "</tr>";
        echo "<tr>";
        $conta = 0;
        foreach ($TOTALES_USD as $valor) {
            echo "<td class='gran_total'>";
            $campo = mysql_field_name($result, $conta);
            if (in_array($campo, $campos_totales)) {
                echo formato_moneda($valor, 2);
            }
            if ($campo == "FECHA_VENCIMIENTO") {
                echo "Gran Total USD";
            }
            echo "</td>";
            $conta++;
        }
        echo "</tr>";
        echo '<tr>';
        foreach ($TOTALES_MX_USD as $key => $valor) {
            echo "<td class='gran_total'>";
            #$campo=mysql_field_name($result,$conta);
            $campo = $key;
            if (in_array($campo, $campos_totales)) {
                echo formato_moneda($valor, 2);
            }
            if ($campo == "FECHA_VENCIMIENTO") {
                echo "Gran Total MX";
            }
            echo "</td>";
            $conta++;
        }
        echo "</tr>";
    }
    echo "</table>";
}
function despliega_parteto($sql, $sql_parteto_total)
{
    global $TOTALES, $fecha_ini, $fecha_fin;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    $campos_moneda = array('TOTAL', 'UTILIDAD', 'COSTO');
    $campos_totales = array('TOTAL', 'UTILIDAD', 'COSTO', 'P_GLOBAL');
    $total_ventas = consulta($sql_parteto_total);
    $margen = array();
    $porcentaje = array();
    $TOTALES = array();
    ?>
	 <table border="0" align="center" cellspacing="0"><?php 
    $conta = 0;
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if ($TOTALES["P_GLOBAL"] >= 80) {
            continue;
        }
        if ($conta == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                echo "<th class='titulo_barra'>" . $campo . "</th>";
            }
            echo "<TH>FACTURAS</TH><TH>FAC PROMEDIO</TH></tr>";
            $conta++;
        }
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $campo = mysql_field_name($result, $aux);
            $valor = $dato[$aux];
            if ($campo == "MARGEN" and $dato["TOTAL"] != 0) {
                $valor = formato_numero($dato["UTILIDAD"] * 100 / $dato["TOTAL"], 2);
                $margen[] = $valor;
            }
            if ($campo == "P_GLOBAL" and $dato["TOTAL"] != 0) {
                $valor = formato_numero($dato["TOTAL"] * 100 / $total_ventas["TOTAL"], 2);
                $porcentaje[] = $valor;
            }
            $TOTALES[mysql_field_name($result, $aux)] = $TOTALES[mysql_field_name($result, $aux)] * 1 + $valor;
            $alineacion = "align='right'";
            if ($campo == "CLIENTE") {
                $alineacion = " align='left' ";
            }
            if ($campo == "CLIENTE_ID") {
                $alineacion = " align='center' ";
            }
            echo "<td " . $alineacion . ">";
            if (in_array($campo, $campos_moneda)) {
                echo formato_moneda($valor, 2);
            } else {
                echo $valor;
            }
            if ($campo == "MARGEN" or $campo == "P_GLOBAL") {
                echo " % ";
            }
            echo "</td>";
        }
        if ($dato["CLIENTE"]) {
            $cliente_id = nombre_id("vta_c_clientes", "RAZON_SOCIAL", $dato["CLIENTE"], "CLIENTE_ID");
            if ($fecha_ini != "") {
                $where_aux = " and FECHA>='" . fecha_to_mysql($fecha_ini) . "' ";
            }
            if ($fecha_fin != "") {
                $where_aux .= " and FECHA<='" . fecha_to_mysql($fecha_fin) . "' ";
            }
            $aux = consulta("select count(*) as CUANTAS, sum(MONTO) AS MONTO from vta_p_facturas where CLIENTE_ID=" . $dato["CLIENTE_ID"] . " AND ESTATUS_FACTURA_ID<>2 " . $where_aux);
            $promedio = $aux["MONTO"] / $aux["CUANTAS"];
        }
        $TOTAL_FACTURAS = $TOTAL_FACTURAS + $aux["CUANTAS"];
        echo "<td ALIGN=CENTER>" . $aux["CUANTAS"] . "</td>";
        echo "<td ALIGN=right>" . formato_moneda($promedio, 2) . "</td>";
        echo "</tr>";
    }
    echo "<tr>";
    $conta = 0;
    foreach ($TOTALES as $valor) {
        echo "<td class='gran_total'>";
        $campo = mysql_field_name($result, $conta);
        if (in_array($campo, $campos_totales)) {
            if (in_array($campo, $campos_moneda)) {
                echo formato_moneda($valor, 2);
            } else {
                echo formato_numero($valor, 2);
            }
        }
        if ($campo == "MARGEN") {
            echo formato_numero(array_sum($margen) / count($margen), 2);
        }
        echo "</td>";
        $conta++;
    }
    echo "<td class='gran_total'>" . $TOTAL_FACTURAS . "</td>";
    echo "</tr>";
    $TOTALES["REGISTROS"] = mysql_num_rows($result);
    echo "</table>";
}
    $valor = $dato[$aux];
    $campo_2 = mysql_field_name($result, $aux);
    echo "<td class='gran_total'>";
    if (in_array($campo_2, $campos_subtotales)) {
        echo " USD " . formato_moneda($TOTALES_USD[$campo_2], 2) . "</td>";
    }
    echo "</td>";
}
echo "</tr>";
echo "<tr>";
for ($aux = 0; $aux < $i; $aux++) {
    $valor = $dato[$aux];
    $campo_2 = mysql_field_name($result, $aux);
    echo "<td class='gran_total'>";
    if (in_array($campo_2, $campos_subtotales)) {
        echo " Global MX " . formato_moneda($TOTALES_MX_USD[$campo_2], 2) . "</td>";
    }
    echo "</td>";
}
echo "</tr>";
echo "<tr>";
for ($aux = 0; $aux < $i; $aux++) {
    $valor = $dato[$aux];
    $campo_2 = mysql_field_name($result, $aux);
    echo "<td class='gran_total'>";
    if (in_array($campo_2, $campos_subtotales)) {
        echo " Global USD " . formato_moneda($TOTALES_G_USD[$campo_2], 2) . "</td>";
    }
    echo "</td>";
}
echo "</tr>";
                 echo "Gran Total MX";
             }
             echo "</td>";
         }
         $conta3++;
     }
     echo "</tr>";
     echo "<tr>";
     $conta4 = 0;
     if (sizeof($parciales_G_usd_mod[$field]) > 0) {
         foreach ($parciales_G_usd_mod[$field] as $valor) {
             $campo = mysql_field_name($result, $conta4);
             if (!in_array($campo, $REPORTE_campos_hidden)) {
                 echo "<td class='TEsubtotales'>";
                 if (in_array($campo, $campos_subtotales)) {
                     echo "<b title='Subtotal USD'>G USD</b> " . formato_moneda($valor, 2);
                 }
                 if ($campo == "FECHA") {
                     echo "Gran Total USD";
                 }
                 echo "</td>";
             }
             $conta4++;
         }
     }
     echo "</tr>";
     $parciales_mx_mod[$field] = array();
     $parciales_usd_mod[$field] = array();
     $parciales_mx_usd_mod[$field] = array();
     $parciales_G_usd_mod[$field] = array();
 }
function desliega_iva1($sql, $campos_hidden = array())
{
    global $TOTALES, $direccion, $campos_totales;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $campos_moneda = array('MONTO', 'ACUMULADO');
    $result = mysql_db_query(DB_NAME, $sql);
    if (mysql_error() != "") {
        echo "<br>" . $sql . "<br><font class='TEditorError'><br>";
        echo mysql_error() . "</font>";
        exit;
    }
    ?>
	 <table border="0" align="center" cellspacing="5"><?php 
    $conta_aux = 0;
    $acumulado = 0;
    $cuenta_anterior = "";
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if ($cuenta_anterior != $dato["CUENTA"] and $cuenta_anterior != "") {
            echo '<tr>';
            foreach ($TOTALES as $campo => $valor) {
                echo "<td class='gran_total'>";
                if (in_array($campo, $campos_totales)) {
                    echo formato_moneda($valor, 2);
                }
                //echo $campo;
                echo "</td>";
            }
            unset($TOTALES);
            echo "</tr><tr><td>&nbsp;</td></tr>";
            $acumulado = 0;
            $conta_aux = 0;
        }
        $cuenta_anterior = $dato["CUENTA"];
        if ($conta == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                if (in_array($campo, $campos_hidden)) {
                    continue;
                }
                $img_ordenamiento = "";
                if ($orderby == $campo) {
                    if ($direccion == "ASC" or $direccion == "") {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_up.png>";
                    } else {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_down.png>";
                    }
                }
                echo "<th align=center><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font></th>";
            }
            echo "</tr>";
            $conta++;
        }
        $conta_aux++;
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $valor = $dato[$aux];
            $campo = mysql_field_name($result, $aux);
            if (in_array($campo, $campos_hidden)) {
                continue;
            }
            $TOTALES[$campo] = $TOTALES[mysql_field_name($result, $aux)] * 1 + $valor;
            $GRAN_TOTAL[$campo] = $GRAN_TOTAL[$campo] + $valor;
            global $REPORTE_COLUMNA;
            $alineacion = "right";
            if ($REPORTE_COLUMNA[$campo]["ALINEACION"]) {
                $alineacion = $REPORTE_COLUMNA[$campo]["ALINEACION"];
            }
            $titulo = " title='" . $valor . "'";
            echo "<td align='{$alineacion}' {$titulo}>";
            if ($REPORTE_COLUMNA[$campo]["SIZE"]) {
                $size = $REPORTE_COLUMNA[$campo]["SIZE"];
            } else {
                $size = 3000;
            }
            if (strlen($valor) > $size) {
                echo substr($valor, 0, $size) . "...";
            } else {
                if ($REPORTE_COLUMNA[$campo]["FORMATO"] == "Moneda") {
                    echo formato_moneda($valor, 2);
                } else {
                    echo $valor;
                }
            }
            echo "</td>";
        }
        echo "</tr>";
    }
    echo '<tr>';
    foreach ($TOTALES as $campo => $valor) {
        echo "<td class='gran_total'>";
        if (in_array($campo, $campos_totales)) {
            echo formato_moneda($valor, 2);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "</tr>";
    echo '<tr>';
    foreach ($GRAN_TOTAL as $campo => $valor) {
        echo "<td class='gran_total'>";
        if (in_array($campo, $campos_totales)) {
            echo formato_moneda($valor, 2);
        }
        //echo $campo;
        echo "</td>";
    }
    echo "</tr>";
    echo "</table>";
}
예제 #15
0
                    <td class="currency"> &nbsp;<?php 
echo formato_moneda($descuento, 2);
?>
</td>
                </tr>
                <tr>
                    <td class="contenido_bordedoble_subtotal" align="right"><strong>I.V.A.</strong>&nbsp;&nbsp;</td>
                    <td class="currency"> &nbsp;<?php 
echo formato_moneda($iva, 2);
?>
</td>
                </tr>
                <tr>
                    <td class="contenido_bordedoble_subtotal" align="right"><strong>TOTAL</strong>&nbsp;&nbsp;</td>
                    <td class="currency"> &nbsp;<?php 
echo formato_moneda($total, 2);
?>
</td>
                </tr>
          		<tr>
                    <td class="contenido_bordedoble_subtotal" style="background:url(../images/remisiones/cuadro_bottom.png) bottom repeat-x;">&nbsp;</td>
                  	<td style="background:url(../images/remisiones/cuadro_bottom.png) bottom repeat-x;">&nbsp;</td>
                </tr>               
            </table>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td height="100" valign="bottom">
            <table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr>
 <script language="javascript">
 function limpia_datos(){ 
 $("[id^=UB_D]").val('');
 }
 </script>
<?php 
if ($FieldName == "CLIENTE_ID" and $table != "_sample_vta_c_clientes") {
    echo "<a href='?&table=_sample_vta_c_clientes' target=_blank><img alt='Agregar clientes' border=0 width=20 src='" . TEImagesPath . 'categories.png' . "'></a>";
}
if ($FieldName == "PROVEEDOR_ID") {
    echo "<a href='?&table=com_c_proveedores' target=_blank><img alt='Agregar proveedores' border=0 width=20 src='" . TEImagesPath . 'categories.png' . "'></a>";
}
if ($table == "ndc_p_aplicadas") {
    if ($FieldName == "NOTA_CREDITO_ID" && $edit) {
        $aux = consulta("select * from ndc_p_notas_credito where NOTA_CREDITO_ID>=" . $FieldValue);
        echo "Total NC : " . formato_moneda($aux["TOTAL"], 2) . " Aplicado : " . formato_moneda($aux["APLICADO"], 2);
    }
    if ($FieldName == "CLIENTE_ID") {
        $agregar_al_url .= "&tipo=facturas&estatus_factura_id=1";
        echo "<a href=javascript:busqueda_popup('_sample_vta_p_facturas','cliente_id','" . $FieldName . "') title='Facturas activas'> <img border=0 width=20 src='" . TEImagesPath . 'facturas.png' . "'></a>";
        ?>
        <script language="javascript">
		date= new Date();	aux_date=date.getTime();		
		function busqueda_popup(tabla, filtro, campo_padre)
		{   
			aux_1=filtro.toLowerCase()+"="+document.getElementsByName(filtro.toUpperCase())[0].value; 		    
			window.open('<?php 
        echo TEditorUrl . $agregar_al_url . "&table=";
        ?>
'+tabla+'&busqueda_popup='+campo_padre+'&'+aux_1,'new'+ aux_date,'location=yes,resizable=yes,status=yes, scrollbars=yes'); 
		}
function poliza($sql, $sql3)
{
    global $TOTALES, $direccion, $orderby, $REPORTE_campos_hidden;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    if (mysql_error() != "") {
        echo "<br>" . $sql . "<br><font class='TEditorError'><br>";
        echo mysql_error() . "</font>";
        exit;
    }
    ?>
	 <table border="0" align="center" cellspacing="5"><?php 
    $conta = 0;
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if ($conta == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                if (in_array($campo, $REPORTE_campos_hidden)) {
                    continue;
                }
                $img_ordenamiento = "";
                if ($orderby == $campo) {
                    if ($direccion == "ASC" or $direccion == "") {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_up.png>";
                    } else {
                        $img_ordenamiento = "<img src=" . TEImagesPath . "arror_down.png>";
                    }
                }
                echo "<th align=center><a href='javascript:reordena(\"{$campo}\")'><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font></a> {$img_ordenamiento}</th>";
            }
            echo "</tr>";
            $conta++;
        }
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $valor = $dato[$aux];
            $TOTALES[mysql_field_name($result, $aux)] = $TOTALES[mysql_field_name($result, $aux)] * 1 + $valor;
            $campo = mysql_field_name($result, $aux);
            if (in_array($campo, $REPORTE_campos_hidden)) {
                continue;
            }
            include "reporteador_muestra campo.php";
        }
        echo "</tr>";
    }
    $TOTALES["REGISTROS"] = mysql_num_rows($result);
    global $campos_totales;
    /*echo '<tr>';
    		foreach($TOTALES as $campo => $valor)
    		{   if(in_array($campo, $REPORTE_campos_hidden)) continue;
    			echo "<td class='gran_total'>";
    			 if(in_array($campo, $campos_totales)) echo despiega_nombre_columna_reportes($campo); //echo $campo;
    			echo "</td>";
    		}
    		echo "</tr>";
    		echo '<tr>';
    		foreach($TOTALES as $campo => $valor)
    		{
    			if(in_array($campo, $REPORTE_campos_hidden)) continue;
    			echo "<td class='gran_total'>";
    			 if(in_array($campo, $campos_totales)) echo formato_moneda($valor,2); //echo $campo;
    			echo "</td>";
    		}
    		echo "</tr>";*/
    $res = mysql_query($sql3);
    $n = 1;
    while ($row = mysql_fetch_array($res)) {
        $n++;
        $d = 'D' . $n;
        echo '<tr> <td>' . $d . '</td> <td>' . $row['FECHA'] . '</td> <td> </td> <td>' . $row['DESCRIPCION'] . '</td> <td>DEPOSITOS DEL MES</td> <td>' . formato_moneda($row['MONTO'], 2) . '</td> <td> </td> </tr>';
        echo '<tr> <td>' . $d . '</td> <td>' . $row['FECHA'] . '</td> <td> </td> <td>IVA POR DEVENGAR</td> <td>DEPOSITOS DEL MES</td> <td>' . formato_moneda($row['IVA'], 2) . '</td> <td> </td> </tr>';
        $sql4 = "\nselect if(MONEDA='USD',PAGO*VALOR,PAGO)as PAGO, ban_p_bancos_facturas.FOLIO_FISCAL, RAZON_SOCIAL from ban_c_cuentas,gen_paridad, ban_p_bancos, ban_p_bancos_facturas, vta_c_clientes where 1=1 and ban_c_cuentas.CUENTA_ID=ban_p_bancos.CUENTA_ID and ban_p_bancos.FECHA = gen_paridad.FECHA and vta_c_clientes.CLIENTE_ID = ban_p_bancos.CLIENTE_ID and ban_p_bancos_facturas.MOVIMIENTO_ID = ban_p_bancos.MOVIMIENTO_ID and ban_p_bancos.MOVIMIENTO_ID = " . $row['MOVIMIENTO_ID'];
        $pagos = mysql_query($sql4);
        while ($row2 = mysql_fetch_array($pagos)) {
            echo '<tr> <td>' . $d . '</td> <td>' . $row['FECHA'] . '</td> <td>' . $row2['FOLIO_FISCAL'] . '</td> <td>' . $row2['RAZON_SOCIAL'] . '</td> <td>DEPOSITOS DEL MES</td> <td></td> <td>' . formato_moneda($row2['PAGO'], 2) . '</td> </tr>';
        }
        echo '<tr> <td>' . $d . '</td> <td>' . $row['FECHA'] . '</td> <td> </td> <td>IVA COBRADO</td> <td>DEPOSITOS DEL MES</td> <td></td> <td>' . formato_moneda($row['IVA'], 2) . '</td> </tr>';
    }
    echo "</table>";
}
        case "ban_p_bancos_egresos":
            if ($valor == "EGRESO_ID") {
                echo "";
                $aux = consulta("select * FROM egr_p_egresos where EGRESO_ID=" . $campo_dato);
                echo $aux["MONEDA"] . ", ";
                echo "Mt : " . formato_moneda($aux["MONTO"], 2);
                echo ", <B>IVA : </B>" . formato_moneda($aux["IVA"], 2);
                echo ", <B>R ISR : </B>" . formato_moneda($aux["RETENCION_ISR"], 2);
                echo ", <B>R IVA : </B>" . formato_moneda($aux["RETENCION_IVA"], 2);
                echo ", <B>Tot : </B>" . formato_moneda($aux["TOTAL"], 2);
                echo " <a href='../admin/index.php?table=egr_p_egresos&edit=" . $aux["EGRESO_ID"] . "' target=_new><img alt='Ver egreso' border=0 src='../images/samples_ico1.png'></a>";
                echo "";
            }
            break;
        case "egr_p_egresos_facturas":
            if ($valor == "FACTURA") {
                echo "";
                $aux = consulta("select * FROM com_p_proveedores_facturas where FACTURA='" . $campo_dato . "'");
                echo $aux["MONEDA"] . ", ";
                echo "Mt : " . formato_moneda($aux["MONTO"], 2);
                echo ", <B>IVA : </B>" . formato_moneda($aux["IVA"], 2);
                echo ", <B>R ISR : </B>" . formato_moneda($aux["RETENCION_ISR"], 2);
                echo ", <B>R IVA : </B>" . formato_moneda($aux["RETENCION_IVA"], 2);
                echo ", <B>Tot : </B>" . formato_moneda($aux["TOTAL"], 2);
                //	 echo "Tot : ".formato_moneda($aux["MONTO"],2);
                echo " <a href='../admin/index.php?table=com_p_proveedores_facturas&edit=" . $aux["PROVEEDOR_FACTURA_ID"] . "' target=_new><img alt='Ver factura' border=0 src='../images/samples_ico1.png'></a>";
                echo "";
            }
            break;
    }
}
예제 #19
0
function reportes_facturas2($sql)
{
    global $TOTALES, $TIPO_REPORTE, $CLIENTE_ID, $USUARIO_ID;
    $TOTALES_MX = array();
    $TOTALES_USD = array();
    $PARCIALES_MX = array();
    $PARCIALES_USD = array();
    $PARCIALES_MX_USD = array();
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $result = mysql_db_query(DB_NAME, $sql);
    ?>
	 <table border="0" align="center" cellspacing="0">
<?php 
    $conta = 0;
    $campos_moneda = array('SUBTOTAL', 'IVA', 'TOTAL', 'UTILIDAD', 'COSTO');
    $campos_totales = array('SUBTOTAL', 'IVA', 'TOTAL', 'UTILIDAD', 'COSTO');
    $cliente_anterior = "";
    while ($dato = mysql_fetch_array($result, MYSQL_BOTH)) {
        if ($cliente_anterior != $dato["CLIENTE"] and $TIPO_REPORTE == "cliente" or $vendedor_anterior != $dato["EJECUTIVO"] and $TIPO_REPORTE == "vendedor") {
            echo "<tr>";
            $conta2 = 0;
            $conta3 = 0;
            foreach ($PARCIALES_MX as $valor) {
                echo "<td class='TEsubtotales'>";
                $campo = mysql_field_name($result, $conta2);
                if (in_array($campo, $campos_totales)) {
                    echo formato_moneda($valor, 2);
                }
                if ($campo == "EJECUTIVO") {
                    echo "Total MN";
                }
                echo "</td>";
                $conta2++;
            }
            echo "</tr>";
            echo "<tr>";
            $conta = 0;
            foreach ($PARCIALES_USD as $valor) {
                echo "<td class='TEsubtotales'>";
                $campo = mysql_field_name($result, $conta3);
                if (in_array($campo, $campos_totales)) {
                    echo formato_moneda($valor, 2);
                }
                if ($campo == "EJECUTIVO") {
                    echo "Total USD";
                }
                echo "</td>";
                $conta3++;
            }
            echo "</tr>";
            echo "<tr>";
            $conta3 = 0;
            foreach ($PARCIALES_MX_USD as $valor) {
                echo "<td class='TEsubtotales'>";
                $campo = mysql_field_name($result, $conta3);
                if (in_array($campo, $campos_totales)) {
                    echo formato_moneda($valor, 2);
                }
                if ($campo == "EJECUTIVO") {
                    echo "Gran Total MX";
                }
                echo "</td>";
                $conta3++;
            }
            echo "</tr>";
            $PARCIALES_MX = array();
            $PARCIALES_USD = array();
            $PARCIALES_MX_USD = array();
        }
        $cliente_anterior = $dato["CLIENTE"];
        $vendedor_anterior = $dato["EJECUTIVO"];
        if ($conta == 0) {
            echo "<tr>";
            $i = count($dato) / 2;
            for ($aux = 0; $aux < $i; $aux++) {
                $campo = mysql_field_name($result, $aux);
                echo "<th align=center><a href='javascript:reordena(\"{$campo}\")'><font style='font-size:11px'>" . despiega_nombre_columna_reportes($campo) . "</font></a>++++</th>";
            }
            echo "</tr>";
            $conta++;
        }
        if ($conta == 2) {
            $conta = 1;
            $aux_f = " bgcolor=#f5f5f4";
        } else {
            $aux_f = "";
            $conta = 2;
        }
        echo "<tr {$aux_f}>";
        $i = count($dato) / 2;
        for ($aux = 0; $aux < $i; $aux++) {
            $campo = mysql_field_name($result, $aux);
            $valor = $dato[$aux];
            //			 if ($campo=="UTILIDAD") $valor=$dato["TOTAL"]-$dato["COSTO"];
            if ($campo == "DIAS_VENCIDOS" and $dato["ESTATUS"] != "Activa") {
                $valor = "";
            }
            if ($dato["MONEDA"] == "MX") {
                $PARCIALES_MX[mysql_field_name($result, $aux)] = $PARCIALES_MX[mysql_field_name($result, $aux)] * 1 + $valor;
                $TOTALES_MX[mysql_field_name($result, $aux)] = $TOTALES_MX[mysql_field_name($result, $aux)] * 1 + $valor;
                $PARCIALES_MX_USD[mysql_field_name($result, $aux)] = $PARCIALES_MX_USD[mysql_field_name($result, $aux)] + $valor;
            }
            if ($dato["MONEDA"] == "USD") {
                $PARCIALES_USD[mysql_field_name($result, $aux)] = $PARCIALES_USD[mysql_field_name($result, $aux)] * 1 + $valor;
                $TOTALES_USD[mysql_field_name($result, $aux)] = $TOTALES_USD[mysql_field_name($result, $aux)] * 1 + $valor;
                $PARCIALES_MX_USD[mysql_field_name($result, $aux)] = $PARCIALES_MX_USD[mysql_field_name($result, $aux)] + $valor * $dato["PARIDAD"];
            }
            echo "<td align=right>";
            if ($campo == "FACTURA") {
                $aux_factura = consulta("select FACTURA_ID FROM vta_p_facturas where FOLIO_FISCAL='" . $dato["FACTURA"] . "'");
                $lupita = $_POST['mode'] != "excel" ? "<img border=0 src='../images/samples_ico1.png'>" : "";
                echo "<a href='../admin/index.php?table=vta_p_facturas&edit=" . $aux_factura["FACTURA_ID"] . "' target=_new>{$lupita}</a>";
            }
            if ($valor < 0) {
                echo "<b>";
            }
            if (in_array($campo, $campos_moneda)) {
                echo formato_moneda($valor, 2);
            } else {
                echo $valor;
            }
            echo "</td>";
        }
        echo "</tr>";
    }
    echo "<tr>";
    $conta2 = 0;
    $conta3 = 0;
    foreach ($PARCIALES_MX as $valor) {
        echo "<td class='TEsubtotales'>";
        $campo = mysql_field_name($result, $conta2);
        if (in_array($campo, $campos_totales)) {
            echo formato_moneda($valor, 2);
        }
        if ($campo == "EJECUTIVO") {
            echo "Total MN";
        }
        echo "</td>";
        $conta2++;
    }
    echo "</tr>";
    echo "<tr>";
    $conta = 0;
    foreach ($PARCIALES_USD as $valor) {
        echo "<td class='TEsubtotales'>";
        $campo = mysql_field_name($result, $conta3);
        if (in_array($campo, $campos_totales)) {
            echo formato_moneda($valor, 2);
        }
        if ($campo == "EJECUTIVO") {
            echo "Total USD";
        }
        echo "</td>";
        $conta3++;
    }
    echo "</tr>";
    ////////// GRAN TOTAL
    if (!$CLIENTE_ID and !$USUARIO_ID) {
        echo "<tr>";
        $conta = 0;
        foreach ($TOTALES_MX as $valor) {
            echo "<td class='gran_total'>";
            $campo = mysql_field_name($result, $conta);
            if (in_array($campo, $campos_totales)) {
                echo formato_moneda($valor, 2);
            }
            if ($campo == "EJECUTIVO") {
                echo "Gran Total MN";
            }
            echo "</td>";
            $conta++;
        }
        echo "</tr>";
        echo "<tr>";
        $conta = 0;
        foreach ($TOTALES_USD as $valor) {
            echo "<td class='gran_total'>";
            $campo = mysql_field_name($result, $conta);
            if (in_array($campo, $campos_totales)) {
                echo formato_moneda($valor, 2);
            }
            if ($campo == "EJECUTIVO") {
                echo "Gran Total USD";
            }
            echo "</td>";
            $conta++;
        }
        echo "</tr>";
    }
    echo "</table>";
}