Hi.
I New in PHPMaker 2020, and sory my english.
I have many PDF´s list in grid.
I Need create a modal window and get 2 parameters… Name and E-mail… and send to select registrs/pdfs in previos Grid to e-mail get in ModalWindowI try this way…I create a button in Page_Load:
function Page_Load()
{
$this->CustomActions[“starb”] = new ListAction(“starb”, " Enviar ", IsLoggedIn(), ACTION_POSTBACK,ACTION_MULTIPLE, “Enviar agora ?”,“fa fa-star ew-icon”);
}I don´t now make this part…
I like to click in starb button then open a Modal Window, get a e-mail and name destination… and ajust with destination in EMail_Sender()My Code:
Row_CustomAction($action, $row)
// Return FALSE to abort
if ($action == "starb")
{
if ($row["ArquivoPDF"]!="")
{
$Email = new Email;
$Email->replaceSender("robo@kaldiris.com.br","RoboK");
//==== I like use data input in ModalWindow before =====
$Email->AddRecipient("grego@laclaw.com.br");
$Email->Subject = "LINK ID - ".$row["id"];
$Email->Content = $row["Nome"];
// Attachment...
$FilePath = "anexos/" ;
$FileName = $row["ArquivoPDF"];
$FileFull = $FilePath . $FileName;
$FileContent = "application/pdf";
$Email->addAttachment($FileFull);
// Send...
$bEmailSent = $Email->Send();
var_dump($bEmailSent);
//$this->setSuccessMessage($bEmailSent);
$this->setSuccessMessage("OK, E-mail Env.: " .$row["id"]);
}
else
{
$this->setFailureMessage("Reg. sem Anexo : ".$row["id"]);
}
}
return TRUE;
}Anybody have an exemple or tip to create this ?Thanks.
kaldiris
Unfortunately, “Row_CustomAction” server event does not support to display Modal dialog window. You need to write the email address inside “Row_CustomAction” event.
The code “new ListAction()” only adds a link for custom action, it does not let you add onclick event to open a modal window. You may use ListOptions_Load and ListOptions_Rendered to add your link with onclick event to open a Modal dialog: https://getbootstrap.com/docs/4.3/components/modal/#live-demo
and add “click” event to your button to post back or use Ajax to add your action, see the topic “Lookup Table” > “Ajax by API and Client Scripts” in the help file.
I try to create a modal, but i have sucess with javascript and cookie.
In global code, 2 functions… read and put cookie content
function getCookie(cname) {
var name = cname + “=”;
var ca = document.cookie.split(‘;’);
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ’ ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return “”;
}
function setEmail(){
// ok - janela pedindo e-mail…
var emailcook = getCookie(“pdfmail”);
var email = prompt(“E-Mail Destino:”,emailcook);
if (email == null || email == “”) {
destemail = “default@e-mail.com.br”;
} else {
destemail = email;
}
document.cookie = escape(‘pdfmail’)+“=” + escape(destemail)+“; path=/”;
return “”;
}Create button in Page_render call setmail function and put in cookie.And i use Row_Custom to send with cookie e-mail… $maildest = $_COOKIE[“pdfmail”];Is possible to get a modal window with javascript ? Or with Bootstrap ?
I put bootstrap code in CustomTemplateFooter… the same form in example on site bootstrap.
Create Button in Page_render call javascript function…
In Global e-mail create function SetEmail and use:
… var CPemailValue = getCookie(“pdfmail”); // Get data from cookie…
… document.getElementById(“pdf-email”).value = CPemailValue; // Put data in form field…
… $(‘#exampleModal’).modal(‘show’); // Open Modal Bootstrap Window…
… $(‘#exampleModal’).on(‘hidden.bs.modal’, function (e) // When close the window, cod return to this function…
… {
… var emailValue = document.getElementById(“pdf-email”).value; // Get data from field form…
… document.cookie = escape(‘pdfmail’)+“=” + (emailValue)+“; path=/”; // Put new data in cookie.
… });
And send e-mail for select lines in grid have attachment defined, in Row_custonAction
… $maildest = $_COOKIE[“pdfmail”]; // Get destini e-mail from cookie
… $Email->AddRecipient($maildest,$mailnome); // Set e-mail and name to…
… Attach file in Email…
… $FilePath = “anexos/” ;
… $FileName = $row[“ArquivoPDF”];
… $FileFull = $FilePath . $FileName;
… $Email->addAttachment($FileFull);
… $bEmailSent = $Email->Send(); Send SucessfullMan… 4 days to make this… but i study a lot, and learning many things.
Thanks a lot!