Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('error_log', './tmp/my-errors.log');
- class jaguar
- {
- //The pen and paper app runs custom scripts on events.
- //The events are defined in this class.
- function addEventHandlers (RequestContext $ctx)
- {
- error_log (__METHOD__);
- $jaguar = new GenerateJaguarhandler();
- $ctx->addEventHandler (FileGeneratedEvent::PDF, $jaguar, "satoreData");
- }
- }
- class GenerateJaguarhandler
- {
- /*
- Push form fields in to MYSQL DB
- */
- public function storeData (FileGeneratedEvent $event)
- {
- error_log(__METHOD__);
- //Mail to test before the data is added.
- $subject = 'hello ';
- $headers = "From: ".$from."\r\n";
- //$headers .= "Content-type: text/html\r\n";
- $message = 'before';
- mail($to, $subject, $message, $headers);
- //data vars
- $title="";
- $first_name="";
- $subject="";
- $address1="";
- $city="";
- $postcode="";
- $telephone="";
- $email="";
- $box1="";
- $box2="";
- $box3="";
- $box4="";
- $box5="";
- $box6="";
- //db vars
- $hostname = "www.celticinternet.com";
- $db = "dppjag";
- $dbusername = "root";
- $dbpassword = "elfy060cinet1308";
- //set connection and select db
- $connection = mysql_connect($hostname, $dbusername, $dbpassword);
- $dummy = mysql_select_db($db, $connection);
- //set the document page.
- $page = $event->document->pages[0];
- //If field has value add it to variable to be added to db.
- if ($page->fields["Title"]->value) {
- $title = $page->fields["Title"]->value;
- }//end if
- if ($page->fields["First_Name"]->value) {
- $first_name = $page->fields["First_Name"]->value;
- }//endif
- if ($page->fields["Surname"]->value) {
- $surname = $page->fields["Surname"]->value;
- }//endif
- if ($page->fields["Address1"]->value) {
- $address1 = $page->fields["Address1"]->value;
- }//endif
- if ($page->fields["City"]->value) {
- $city = $page->fields["City"]->value;
- }//endif
- if ($page->fields["Postcode"]->value) {
- $postcode = $page->fields["Postcode"]->value;
- }//endif
- if ($page->fields["Telephone"]->value) {
- $telephone = $page->fields["Telephone"]->value;
- }//endif
- if ($page->fields["Email"]->value) {
- $email = $page->fields["Email"]->value;
- }//endif
- if ($page->fields["New-XJ"]->value == 'true' ) {
- $box1 = '1';
- }else{
- $box1 ='0';
- }//endif
- if ($page->fields["XF"]->value == 'true') {
- $box2 = '1';
- }else{
- $box2 ='0';
- }//endif
- if ($page->fields["XK"]->value == 'true') {
- $box3 = '1';
- }else{
- $box3 ='0';
- }//endif
- if ($page->fields["S-Type"]->value == 'true') {
- $box4 = '1';
- }else{
- $box4 ='0';
- }//endif
- if ($page->fields["XJ"]->value == 'true') {
- $box5 = '1';
- }else{
- $box5 ='0';
- }//endif
- if ($page->fields["X-Type"]->value == 'true') {
- $box6 = '1';
- }else{
- $box6 ='0';
- }//endif
- //Insert into db statement
- $querystring = "INSERT INTO details (title, first_name, surname, address1, city, postcode, telephone, email, box1, box2, box3, box4, box5, box6)
- VALUES ('$title','$first_name','$surname','$address1','$city','$postcode','$telephone','$email','$box1' ,'$box2' ,'$box3' ,'$box4' ,'$box5' ,'$box6')";
- //Run Query
- $query = mysql_query($querystring) or die();
- //Make sure connection is closed.
- mysql_close($connection);
- //Send an email to show the script is run this far.
- $subject = 'hello ';
- $headers = "From: ".$from."\r\n";
- //$headers .= "Content-type: text/html\r\n";
- $message = 'After';
- mail($to, $subject, $message, $headers);
- }//end onGeneratePDF
- }//end class
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement