PHP list plugin $statusMsg appear only for one second and disappear

Status
Not open for further replies.

gnavarro

Member
Hi,

I have configured a PHP list plugin with the following code:

PHP:
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');

$count = 0;
foreach ($ids AS $id) {

$row = $model->getRow($id);
$tratamento = $row->fb_sessoes_fisioterapia___id_tratamento;
$dta_hora_sess_ = date_create($row->fb_sessoes_fisioterapia___dta_hora_sess);
$dta_hora_sess = date_format($dta_hora_sess_, 'd-m-Y H:i');
$email_clt = $row->fb_sessoes_fisioterapia___email_clt;
$email_colab = $row->fb_sessoes_fisioterapia___email_colab;
$colab = $row->fb_sessoes_fisioterapia___user_id_fisiot;
$cliente = $row->fb_sessoes_fisioterapia___user_id;
$estado = $row->fb_sessoes_fisioterapia___estado;

if ($estado !== "Agendada") {
$statusMsg  = "Apenas poder? cancelar sess?es que se encontrem agendadas.";
} else {
//EMAIL ADMIN

$mailer = JFactory::getMailer();
$config = JFactory::getConfig();

$sender = array(
    $config->get( 'mailfrom' ),
    $config->get( 'fromname' )
);
$mailer->setSender($sender);
$recipient_admin = 'info@fisiolar.pt';


$mailer->addRecipient($recipient_admin);

$body   = "Sess?o de ".$dta_hora_sess." para o tratamento ".$tratamento." cancelada pelo cliente ";
$mailer->setSubject("Sess?o de ".$dta_hora_sess." para o tratamento ".$tratamento." cancelada pelo cliente ");
$mailer->setBody($body);
$send = $mailer->Send();


//EMAIL COLAB

$mailer = JFactory::getMailer();
$config = JFactory::getConfig();

$sender_colab = array(
    $config->get( 'mailfrom' ),
    $config->get( 'fromname' )
);
$mailer->setSender($sender_colab);
$mailer->setFrom('colaboradores@fisiolar.pt', 'FisioLAR - Sa?de ao Domic?lio');
$recipient_colab = $email_colab;
$mailer->addRecipient($recipient_colab);

$body   = "Caro Colaborador,\n\nA sess?o de ".$dta_hora_sess." para o tratamento ".$tratamento." foi cancelada pelo cliente a partir da plataforma FisoLAR.\n\nAgradecemos que nos confirme a tomada de conhecimento deste cancelamento com uma resposta imediata a este email.\n\nCom os melhores cumprimentos,\n\nA Equipa da FisioLAR\nDepartamento de Apoio ao Colaborador\nFisioLAR- Sa?de ao Domic?lio";
$mailer->setSubject("Sess?o cancelada de ".$dta_hora_sess." para o tratamento ".$tratamento);
$mailer->setBody($body);
$send = $mailer->Send();


//EMAIL CLIENTE/RESP

$mailer = JFactory::getMailer();
$config = JFactory::getConfig();

$sender_clt = array(
    $config->get( 'mailfrom' ),
    $config->get( 'fromname' )
);
$mailer->setSender($sender_clt);
$recipient_clt = $email_clt;
$mailer->addRecipient($recipient_clt);

$body   = "Estimado(a) Cliente,\n\nConfirmamos o cancelamento da sess?o de ".$dta_hora_sess." para o tratamento ".$tratamento.". \n\nCaso o cancelamento tenha sido um equ?voco, agradecemos que responda agora a este email em conformidade com o sucedido de forma a se tomarem as necess?rias delig?ncias ao seu revertimento.\n\nCom os melhores cumprimentos,\n\nA Equipa da FisioLAR\nDepartamento de Apoio ao Cliente\nFisioLAR- Sa?de ao Domic?lio";
$mailer->setSubject("Sess?o de ".$dta_hora_sess." para o tratamento ".$tratamento." encontra-se cancelada");
$mailer->setBody($body);
$send = $mailer->Send();

$update = "UPDATE fb_sessoes_fisioterapia SET cancelada='1', motivo_canc='20', estado='Cancelada'  WHERE id=" . (int)$id;
$db->setQuery($update);
$db->query();


$statusMsg  = "Cancelamento efectuado com sucesso";
}

}

When I run the plugin everything is submitted as expected but the function $statusMsg='...' is showing the message (bootstrap green message) only for one second and closes by it self when should be the user closing it when clicking 'x'. Sometimes it disappears so fast that we did not tell the message exists.

___
You can test the message using the list filtered by the following url:

http://www.fisiolar.pt/index.php/pt...=0&fb_sessoes_fisioterapia___estado=Realizada

The function name is "Cancelar Sess?o"
___

Is this a known issue? Am I missing something on my config?
 
Last edited:
I don't see any rows displayed on that URL, when logging in as my usual username for your site. Even if I remove all of the filters I don't see any rows.

Let me know who I need to log in as to see some rows I can test with, or set it up so I see rows as my usual login.

-- hugh
 
Thanks Hugh,

Can I make any change in those lines of code to permit the messages and turn it more social again? ;)

Also the confirm("..."); function in the JS code is ruining the PHP when we click on cancel or close the modal window! Is this due to some kind of bug in Fabrik?
 
Last edited:
Thanks Hugh,

Can I make any change in those lines of code to permit the messages and turn it more social again? ;)

I'm assuming that's not critical code, as it just hides J! status messages, so yes, you could comment those three lines out. Although you might want to ask the authors why it does that.

Also the confirm("..."); function in the JS code is ruining the PHP when we click on cancel or close the modal window! Is this due to some kind of bug in Fabrik?

Your JS doesn't return a result. As the tooltip says "if you code returns false, the submit will be aborted". All you do is ...

Code:
confirm("...");

... which doesn't return a result. The confirm() is returning something, but you aren't then returning that, you are just ignoring it. So do ...

Code:
return confirm("...");

... which will return whatever value confirm() returns. Which will be false if they either hit cancel, or just close the dialog.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top