Hi, i am working on a site with Scriptcase and i have a serious bug with Variables.
I have this SQL Query in an app
SELECT
MONTO,
SUCURSAL,
FECHA
FROM
dbo.VENTA_DIARIA_POR_LOCAL
WHERE [sqlWHERE]
You can notice that the query has a Variable named sqlWHERE.
In the other hand i have this Script on the onScriptInit Event.
if ([FLAG] <> 1) {
sc_reset_global ([sqlWHERE]);
[FLAG] = 1;
$DESDE = '01/01/2015';
$HASTA = '31/01/2015';
$SUCURSALES = '';
$FILTRO = '';
if (isset($_GET['BEGIN_DATE'])) {
$DESDE = $_GET['BEGIN_DATE'];
if (isset($_GET['END_DATE'])) {
$HASTA = $_GET['END_DATE'];
$FILTRO = "FECHA ENTRE $DESDE Y $HASTA";
}
} else {
$WHERE = "FECHA BETWEEN '$DESDE' AND '$HASTA'";
}
if (isset($_GET['sucursales'])) {
$SUCURSALES = $_GET['sucursales'];
}
if (empty($SUCURSALES)) {
$WHERE = " FECHA BETWEEN '$DESDE' AND '$HASTA'";
$FILTRO = "Fecha entre $DESDE y $HASTA";
} else {
$SUCURSALES = "'".str_replace(',', "','", $SUCURSALES)."'";
$WHERE = " FECHA BETWEEN '$DESDE' AND '$HASTA' AND SUCURSAL IN ($SUCURSALES)";
$FILTRO = "Fecha entre $DESDE y $HASTA y Sucursal est? incluida en ($SUCURSALES)";
}
[sqlWHERE] = $WHERE." AND EMPRESA = " .[usr_company];
echo '<table cellspacing="0" cellpadding="0" align="center" valign="top">';
echo '<tbody><tr><td>';
echo '<div class="scAppDivMoldura" style="font-family:Open Sans,Arial,sans-serif;font-size:12px;">';
echo $FILTRO;
echo [sqlWHERE];
echo '</div></td></tr></tbody></table>';
echo '<div style="heigth=10px;"> </div></tr></td></table>';
} ELSE {
[FLAG] = 0;
[sqlWHERE] = '1=1';
}
As you can see, the variable is Setted with some parameters received by Get Method and Printed on the screen.
Now, the problem is that the variable is passed to the SQL Query with old values. See this Screenshot where you can notice that the variable value printed on the screen deffers from the one that is passed to the SQL Query.
[ATTACH=CONFIG]n64817[/ATTACH]
This problem have me Stucked with the site, please i need an urgent solution for this.
Thank you very much in advance.
Regards,
Maximiliano