Пример #1
2
$where_2 = "where 1=1 ";
$where_3 = "where 1=1 ";
include "where_TIPO_MOV_BANCO_ID.php";
if ($tipo_reporte != "") {
    if ($tipo_reporte == "cuenta") {
        $criterios .= " Estado de cuenta <br>";
    }
    if ($tipo_reporte == "expedidos") {
        $criterios .= " Expedidos <br>";
    }
}
if ($CLIENTE_ID != "") {
    $where_1 .= " AND CLIENTE_ID='{$CLIENTE_ID}' ";
    $where_2 .= " AND 0 ";
    $where_3 .= " AND 0 ";
    $criterios .= " CLIENTE " . nombre_id('vta_c_clientes', 'CLIENTE_ID', $CLIENTE_ID, 'RAZON_SOCIAL') . " <br>";
}
include "where_CUENTA_ID.php";
if ($tipo_reporte == "expedidos") {
    $where_expedidos_ini = " or (TIPO_MOV_BANCO_ID=100 AND FECHA>='" . fecha_to_mysql($fecha_ini) . "' and ESTATUS_CHEQUE_ID=1) ";
    $where_expedidos_fin = " or (TIPO_MOV_BANCO_ID=100 AND FECHA<='" . fecha_to_mysql($fecha_fin) . "' and ESTATUS_CHEQUE_ID=1) ";
} else {
    $where_expedidos_fin = "";
    $where_expedidos_fin = "";
}
if ($fecha_ini != "") {
    $where_1 .= " and (\n\t\t\t\t\t\t\t\t(TIPO_MOV_BANCO_ID<>100 AND FECHA>='" . fecha_to_mysql($fecha_ini) . "') OR \n\t\t\t\t\t\t\t\t(TIPO_MOV_BANCO_ID=100 AND FECHA_COBRO>='" . fecha_to_mysql($fecha_ini) . "') \n\t\t\t\t\t\t\t\t{$where_expedidos_ini}\n\t\t\t\t\t\t\t   )";
    $where_2 .= " and FECHA>='" . fecha_to_mysql($fecha_ini) . "' ";
    $where_3 .= " and FECHA>='" . fecha_to_mysql($fecha_ini) . "' ";
    $criterios .= " Fecha inicio : {$fecha_ini} <br>";
}
			aux_1=filtro.toLowerCase()+"="+document.getElementsByName(filtro.toUpperCase())[0].value; 		    
			window.open('<?php 
        echo TEditorUrl . $agregar_al_url_2 . "&table=";
        ?>
'+tabla+'&busqueda_popup='+campo_padre+'&'+aux_1,'new'+ aux_date,'location=yes,resizable=yes,status=yes, scrollbars=yes'); 
		}
		</script>
      <?php 
    }
}
if ($table == "ban_p_bancos") {
    if ($tipo_mov_banco_id == "") {
        $tipo_mov_banco_id = $_GET["tipo_mov_banco_id"];
    }
    if ($tipo_mov_banco_id == "") {
        $tipo_mov_banco_id = nombre_id("ban_p_bancos", "MOVIMIENTO_ID", $_GET["edit"], "TIPO_MOV_BANCO_ID");
    }
    $agregar_al_url = "&tipo_mov_banco_id=" . $tipo_mov_banco_id;
    if ($FieldName == "CLIENTE_ID") {
        $agregar_al_url .= "&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'); 
Пример #3
0
 function displayHeader()
 {
     $headerfile = $this->getConfig('headerfile');
     if ($headerfile) {
         require $headerfile;
         return;
     }
     $table = $this->table;
     echo '<div class="TEmainbody" align="center">';
     if ($this->errors) {
         foreach ($this->errors as $e) {
             $aux_error = split(":", $e);
             if (strpos($aux_error[1], "Duplicate entry")) {
                 $aux_1 = split(" ", trim($aux_error[1]));
                 $NumberArray = count($aux_1);
                 $aux_2 = $aux_1[5];
                 $aux = TEgetPrimaryKeyOf($this->table);
                 $valor_duplicado = $aux_1[2];
                 $ElementDuplicate = (int) $aux_1[$NumberArray - 1];
                 $campo_duplicado = $aux[$ElementDuplicate];
                 $ArrayErrorTxt = split("'", trim($aux_error[1]));
                 $valor_duplicado = $ArrayErrorTxt[1];
                 if ($campo_duplicado != "") {
                     $RecordId = nombre_id($this->table, $campo_duplicado, str_replace("'", "", $valor_duplicado), $aux[1]);
                 }
                 $DuplicateErrorTxt = TEErrorDuplicateEntry . " ";
                 $url = new TableEditor_URL();
                 $url->removeQueryString('edit');
                 $url->removeQueryString('add');
                 $url->addQueryString('view', $RecordId);
                 $PopupUrl = $url->getURL(true);
                 $DuplicateErrorButton .= '<img src="' . TEImagesPath . 'TEActionView.gif" srcover="' . TEImagesPath . 'TEActionViewOver.gif" class="TEInputButton" ';
                 if (file_exists("" . TEditorPath . "TEPopupForm.php")) {
                     $DuplicateErrorButton .= 'onclick="TEWindowOpenPopup(\'' . $TEditorPath . 'TEPopupForm.php?table=' . $this->table . '&view=' . $RecordId . '&TEPopup=1\', \'DuplicateEntry\', \'500\', \'500\', \'0\', \'0\')" ';
                     $DuplicateErrorButton .= 'title="' . TEButtonAdd . '" alt="' . TEButtonAdd . '">&nbsp;';
                 } else {
                     $url = new TableEditor_URL();
                     $url->removeQueryString('edit');
                     $url->removeQueryString('add');
                     $url->addQueryString('view', $RecordId);
                     $PopupUrl = $url->getURL(true);
                     $DuplicateErrorButton .= 'onclick="TEWindowOpenPopup(\'' . $PopupUrl . '\', \'DuplicateEntry\', \'769\', \'400\', \'0\', \'1\')" title="' . TEButtonView . '" alt="' . TEButtonView . '">&nbsp;';
                 }
                 echo '<script language="javascript"> alert("ERROR: ' . $DuplicateErrorTxt . '\\n");</script><div class="TEditorError">ERROR: ' . $DuplicateErrorTxt . '<br>' . $DuplicateErrorButton . '</div>';
             } else {
                 echo '<script language="javascript"> alert("ERROR: ' . htmlspecialchars($e) . '"); </script><div class="TEditorError">ERROR: ' . htmlspecialchars($e) . '</div>';
             }
         }
     }
 }
Пример #4
0
    $where_2 .= " AND 0 ";
    $where_3 .= " AND 0 ";
    $criterios .= "TIPO DE SERVICIO: " . nombre_id('c_tipos_de_servicio', 'TIPO_SERVICIO_ID', $tipo_servicio, 'DESCRIPCION') . " <br>";
}
if ($sucursal != "") {
    $where_1 .= " AND SUCURSAL_ID='{$sucursal}' ";
    $where_2 .= " AND 0 ";
    $where_3 .= " AND 0 ";
    $criterios .= " SUCURSAL: " . nombre_id('c_sucursales', 'SUCURSAL_ID', $sucursal, 'NOMBRE') . " <br>";
    $sucXls .= substr(str_replace(" ", "", nombre_id('c_sucursales', 'SUCURSAL_ID', $sucursal, 'NOMBRE')), 0, 5);
}
if ($medico != "") {
    $where_1 .= " AND r.MEDICO_ID='{$medico}' AND r.RECEPCION_ID= r.RECEPCION_ID";
    $where_2 .= " AND 0 ";
    $where_3 .= " AND 0 ";
    $criterios .= " MEDICO: " . nombre_id('c_medicos', 'MEDICO_ID', $medico, 'TITULO') . " " . nombre_id('c_medicos', 'MEDICO_ID', $medico, 'NOMBRE') . " " . nombre_id('c_medicos', 'MEDICO_ID', $medico, 'APELLIDOS') . " <br>";
}
if ($fecha_ini != "") {
    $where_1 .= " and FECHA>='" . fecha_to_mysql($fecha_ini) . "' ";
    $where_2 .= " and FECHA>='" . fecha_to_mysql($fecha_ini) . "' ";
    $where_3 .= " and FECHA>='" . fecha_to_mysql($fecha_ini) . "' ";
    $criterios .= " Fecha inicio : {$fecha_ini} <br>";
    $fechaXls .= str_replace("/", "_", $fecha_ini);
}
if ($fecha_fin != "") {
    $where_1 .= " and FECHA<='" . fecha_to_mysql($fecha_fin) . "' ";
    $where_2 .= " and FECHA<='" . fecha_to_mysql($fecha_fin) . "' ";
    $where_3 .= " and FECHA<='" . fecha_to_mysql($fecha_fin) . "' ";
    $criterios .= " Fecha fin : {$fecha_fin} <br>";
    $fechaXls .= str_replace("/", "_", $fecha_fin);
}
<?php

$criterios = "<b>Criterios de búsqueda : </b><br>";
$where_1 = "where 1=1 ";
if ($sucursal != "") {
    $where_1 .= " AND SUCURSAL_ID='{$sucursal}' ";
    $where_2 .= " AND 0 ";
    $where_3 .= " AND 0 ";
    $criterios .= " SUCURSAL: " . nombre_id('c_sucursales', 'SUCURSAL_ID', $sucursal, 'NOMBRE') . " <br>";
}
if ($fecha_ini != "") {
    $where_1 .= " and FECHA>='" . fecha_to_mysql($fecha_ini) . "' ";
    $criterios .= " Fecha inicio : {$fecha_ini} <br>";
}
if ($fecha_fin != "") {
    $where_1 .= " and FECHA<='" . fecha_to_mysql($fecha_fin) . "' ";
    $criterios .= " Fecha fin : {$fecha_fin} <br>";
}
if (!$orderby) {
    $orderby = " order by RECEPCION_ID";
}
$campos = "\nRECEPCION_ID as FOLIO,\nDATE_FORMAT(a.FECHA, '%d/%m/%Y') as FECHA,\n(SELECT NOMBRE FROM c_clientes WHERE CLIENTE_ID = a.CLIENTE_ID) as EMPRESA,\nNOMBRE,\nAPELLIDOS,\nDATE_FORMAT(FECHA_NACIMIENTO, '%d/%m/%Y') as FECHA_NACIMIENTO\n";
$sql = "\nselect\n   {$campos}\n  from\n  p_recepcion a\n" . $where_1 . " " . $orderby;
//echo $sql;
if ($criterios == "<b>Criterios de búsqueda : </b>") {
    $criterios .= "Mostrando todos los registros";
}
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>";
}