This topic is locked
[SOLVED]

 Page don´t reload or redirect

10/6/2011 11:27:38 AM
PHPRunner General questions
S
sribeiro_gmr author

Hi,
My goal is to refresh/reload the current page after sending a mail and updating two tables when the custom button in the list view page is pressed.
Put the following code in custom button's events :

  • On server :

    global $dal;

    $dal_TableName = $dal->Table("litigios");

    $body="";

    foreach(@$keys as $keyblock)

    {

    $arr=explode("&",refine($keyblock["LIT_ID"]));

    if(count($arr)<1)

    continue;

    $arr2=array();

    $arr2["LIT_ID"]=urldecode(@$arr[0]);

    $where = KeyWhere($arr2);

    $rstmp = $dal_TableName->Query($where,"");

    $datatmp=db_fetch_array($rstmp );

    $body .= "------------------------------------------------------------\n";

    $body .= "ID: " . $datatmp['LIT_ID'] . "\n";

    $body .= "Loja: " . $datatmp['LIT_LOJA'] . "\n";

    $body .= "Data: " . $datatmp['LIT_DATA'] . "\n";

    $body .= "Tipo: " . $datatmp['LIT_TIP'] . "\n";

    $body .= "Contacto: " . $datatmp['LIT_CONTACTO'] . "\n";

    $body .= "E-Mail: " . $datatmp['LIT_MAIL'] . "\n------------------------------------------------------------\n";

    }
    // send the email

    $email="sribeiro@cooplecnorte.pt";

    $subject="Novo(s) Litígio(s)";

    $arr = runner_mail(array('to' => $email, 'subject' => $subject,

    'body' => $body));

    $result["txt"] = "Litigio(s) Enviado(s).";
    // if error happened print a message on the web page

    if (!$arr["mailed"])

    {

    $errmsg = "Erro:
    ";

    $errmsg.= "Ficheiro: " . $arr["errors"][0]["file"] . "
    ";

    $errmsg.= "Linha: " . $arr["errors"][0]["line"] . "
    ";

    $errmsg.= "Descrição: " . $arr["errors"][0]["description"] . "
    ";

    $result["txt"] = $errmsg;

    }
    global $dal;

    for ($i=0; $i<count($keys); $i++)

    {

    $sql = "Update litigios set LIT_ESTADO=1 where LIT_ID="

    . $keys[$i]["LIT_ID"];

    CustomQuery($sql);

    }
    global $dal;

    for ($i=0; $i<count($keys); $i++)

    {

    $sql = "Update vloja set LIT_ESTADO=1 where LIT_IDL="

    . $keys[$i]["LIT_ID"];

    CustomQuery($sql);

    }
    Mail is sent, tables are updated.
    How can i refresh/reload the list view after those two actions ?
    Many thanks.
    Sérgio

C
cgphp 10/6/2011

In the "Client after" section of the custom button enter this code:

location.href = "pagename_list.php";
S
sribeiro_gmr author 10/6/2011



In the "Client after" section of the custom button enter this code:

location.href = "pagename_list.php";



Hi Cristian,
Followed your instructions.

It's not working (however the mail is still sent and the tables updated).
Cheers.
Sérgio

C
cgphp 10/6/2011

Do you get some error from firebug ?

S
sribeiro_gmr author 10/6/2011



Do you get some error from firebug ?


No, no error.

C
cgphp 10/6/2011

Is there some other code in the "Client after" section ?

S
sribeiro_gmr author 10/6/2011



Is there some other code in the "Client after" section ?


No.

C
cgphp 10/6/2011

Please, post the link to the demo of your app.

S
sribeiro_gmr author 10/6/2011



Please, post the link to the demo of your app.


http://demo.asprunner.net/sribeiro_gmr_hotmail_com/litigios/login.php
user : sribeiro - password : martine1602

menu : Inserir / Enviar Litigios
Select a record and click the "Enviar Litígio(s)" button.

C
cgphp 10/6/2011

Redirect works fine on the demo.

S
sribeiro_gmr author 10/6/2011



Redirect works fine on the demo.


You're right.

Tried from another workstation on my local webserver and it worked too.

Cleaned up the i.e. history from my pc and it's working now.
Thanks for the time spent.
Sérgio