function handle_submission($invoice_type_id)
{
    global $wpdb;
    $user_id = $_POST["user-id"];
    // if on other's behalf, get id of person
    if ($_POST["others_behalf"]) {
        $user_id = $wpdb->get_var($wpdb->prepare("SELECT `ID` FROM `wp_users` WHERE `user_email` = %s;", $_POST["email"]));
    }
    // send user's invoive (or simply the first if submitting for multiple people)
    $invoice_id = generateInvoice($user_id, $invoice_type_id);
    generatePDF($invoice_type_id, $invoice_id, $user_id);
    emailInvoice($invoice_type_id, $invoice_id, $user_id);
    /* Submit the rest of the invoices */
    $num_registering = $_POST["num_registering"];
    for ($i = 1; $i < $num_registering; $i++) {
        $email = "email" . $i;
        $user_id = $wpdb->get_var($wpdb->prepare("SELECT `ID` FROM `wp_users` WHERE `user_email` = %s;", $_POST[$email]));
        $invoice_id = generateInvoice($user_id, $invoice_type_id);
        generatePDF($invoice_type_id, $invoice_id, $user_id);
        emailInvoice($invoice_type_id, $invoice_id, $user_id);
    }
    // for: generate invoice for each user specified (can be multiple)
    // return if success
    return '<p class="cstem_im_form_success"> Form Submitted Successfully. You should receive an email shortly. </p>';
}
Пример #2
0
$setWarning = false;
// used to set missing options during export
if ($Module->isCurrentAction('BrowseSource')) {
    eZContentBrowse::browse(array('action_name' => 'ExportSourceBrowse', 'description_template' => 'design:content/browse_export.tpl', 'from_page' => '/pdf/edit/' . $pdfExport->attribute('id')), $Module);
} else {
    if ($Module->isCurrentAction('Export') && $inputValidated) {
        // remove the old file ( user may changed the filename )
        $originalPdfExport = eZPDFExport::fetch($Params['PDFExportID']);
        if ($originalPdfExport && $originalPdfExport->attribute('status') == eZPDFExport::CREATE_ONCE) {
            $filename = $originalPdfExport->attribute('filepath');
            if (file_exists($filename)) {
                unlink($filename);
            }
        }
        if ($pdfExport->attribute('status') == eZPDFExport::CREATE_ONCE) {
            generatePDF($pdfExport, $pdfExport->attribute('filepath'));
            $pdfExport->store(true);
            return $Module->redirect('pdf', 'list');
        } else {
            $pdfExport->store(true);
            return $Module->redirect('pdf', 'list');
        }
    } else {
        if ($Module->isCurrentAction('Discard')) {
            $pdfExport->remove();
            return $Module->redirect('pdf', 'list');
        }
    }
}
$tpl = eZTemplate::factory();
$tpl->setVariable('set_warning', $setWarning);
    $accountId = getAccountByUserId(getAuthUser()->userid)->ID;
    $transactions = getTransactionsByAccountId($accountId);
    $showDownload = "?download=1";
} else {
    //4.8.1
    if (isset($_GET['id']) && is_numeric((int) $_GET['id']) && (int) $_GET['id'] > 0) {
        $accountId = getAccountByUserId((int) $_GET['id'])->ID;
        $transactions = getTransactionsByAccountId($accountId);
        $showDownload = "?id=" . $_GET['id'] . "&download=1";
    } else {
        $transactions = getTransactions();
    }
}
if (isset($_GET['download'])) {
    $download = $_GET['download'];
    $pdf = generatePDF($accountId);
}
$users = getUsers();
// include header
$pageTitle = "View Transactions";
include "header.php";
?>

<div class="pull-left">
  <a class="pure-button pure-button-primary" href="create_transaction.php">New Transaction</a>
  <?php 
if ($showDownload !== "") {
    ?>
    <a class="pure-button pure-button-primary" href="view_transactions.php<?php 
    echo $showDownload;
    ?>
Пример #4
0
        you will see a save as option because of this headers.
        Alternatively, if you prefer to open for viewing,
        copy to your server ie copy($pdf, $destination), and use header("Location: pdf_link.php") to open
        */
        header("Content-Type: application/pdf");
        header("Cache-Control: no-cache");
        header("Accept-Ranges: none");
        header("Content-Disposition: attachment; filename=\"createdFile.pdf\"");
        echo $pdf;
    } catch (PdfcrowdException $why) {
        echo "PDF creation failed: " . $why . "\n";
    }
    return true;
}
if (isset($_GET['action']) == 'print') {
    generatePDF();
}
//visit http://pdfcrowd.com/web-html-to-pdf-php/ for more info
?>




<!DOCTYPE html>
<html lang="fr">

<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
Пример #5
0
<?php

include "includes.php";
#include ("html/head.php");
#$serials_for_print=$db->query('SELECT `finish_number` FROM {numbers} WHERE `print_id`=?', array($_GET['print_id']))->assoc();
#foreach($serials_for_print as $serial){
#    print $serial['finish_number'];
#    print ('<br>');
#}
generatePDF($_GET['print_id'], $_GET['print_type']);
Пример #6
0
    if (!isset($settings['message'])) {
        $settings['message'] = LANG_FORM_CCPC_ADMIN_MAILER_DEFAULT_MESSAGE;
    }
    $getArray = array('evaluationType' => $_GET['evaluationType'], 'service' => $_POST['service'], 'FILTER' => array('date' => array('min' => $_POST['debutStage'], 'max' => $_POST['finStage']), 'promotion' => $_POST['promotion']));
    // Tableau contenant les équivalents texte codé => variable
    $textCode = array('%DATEDEBUT%' => date('d/m/Y', $_POST['debutStage']), '%DATEFIN%' => date('d/m/Y', $_POST['finStage']), '%PROMOTION%' => $promotionData['nom'], '%URL%' => getPageUrl('evalView', $getArray), '%MAILCONTACT%' => CONTACT_STAGE_MAIL);
    // On remplace les codes %CODE% par les variables correspondante
    foreach ($textCode as $key => $value) {
        // Pour l'objet
        $settings['object'] = str_replace($key, $value, $settings['object']);
        // Pour le message
        $settings['message'] = str_replace($key, $value, $settings['message']);
    }
    // Pièce jointe
    // On génère le PDF
    $pdfPath = generatePDF(getEvaluationCCPCFullData($_POST['service'], $_POST['promotion'], $_POST['debutStage'], $_POST['finStage'], TRUE), FALSE, TRUE)['pdfPath'];
    if (!file_exists(PLUGIN_PATH . 'attachments/' . $_POST['codeCampagne'] . ' - ' . basename($pdfPath)) || !is_file(PLUGIN_PATH . 'attachments/' . $_POST['codeCampagne'] . ' - ' . basename($pdfPath))) {
        copy($pdfPath, PLUGIN_PATH . 'attachments/' . $_POST['codeCampagne'] . ' - ' . basename($pdfPath));
    }
    $attachments = array('Evaluations.pdf' => array('path' => PLUGIN_PATH . 'attachments/' . $_POST['codeCampagne'] . ' - ' . basename($pdfPath), 'url' => ROOT . 'evaluations/ccpc/attachments/' . $_POST['codeCampagne'] . ' - ' . basename($pdfPath)));
    // Destinataire
    $chefId = getServiceInfo($_POST['service'])['chef']['id'];
    // On crée le mail
    addMailCampagne($_POST['codeCampagne'], $title, $chefId, $settings['object'], $settings['message'], $attachments);
    exit;
} else {
    if ($action == 'setMail') {
        // On enregistre les données du formulaire après les avoir sérialisé dans la table typeevaluation pour le module correspondant
        if (isset($_POST['object']) && htmLawed($_POST['object']) && isset($_POST['message']) && htmLawed($_POST['message'])) {
            $res = $db->prepare('UPDATE typeevaluation SET settings = :settings WHERE id = :id');
            $res->execute(array('id' => $evaluationTypeData['id'], 'settings' => serialize($_POST)));
function generateInvoice($invoice_type_id, $invoice_no_user)
{
    global $wpdb;
    $user_id = $_POST["user-id"];
    $invoice_no = $invoice_no_user;
    if ($_POST["others_behalf"]) {
        $user_email = $_POST["email"];
        $user_id = $wpdb->get_var($wpdb->prepare("SELECT `ID` FROM `wp_users` WHERE `user_email` = %s;", $user_email));
        $invoice_no = $wpdb->get_var($wpdb->prepare("SELECT `invoice_no` FROM wp_invoice_table WHERE invoice_type_id = %d AND user_id = %d", $invoice_type_id, $user_id));
    }
    // if on other's behalf, get id of person
    if ($invoice_no) {
        $lastid = $invoice_no;
    } else {
        // insert(table, data, format)
        $wpdb->insert('wp_invoice_table', array('invoice_type_id' => $invoice_type_id, 'user_id' => $user_id, 'total' => 0), array('%d', '%d', '%d'));
        $lastid = $wpdb->insert_id;
    }
    // else: insert into database
    $total;
    // gets sum of costs from data below
    // get all fields from form
    $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM `wp_invoice_info` WHERE `invoice_type_id` = %d ORDER BY `field_order`;", $invoice_type_id));
    foreach ($results as $row) {
        if ($_POST[$row->field_name] == "" && $row->field_type != "textbox") {
            if ($row->field_type == "dropdown" || $row->field_type == "checkbox" || $row->field_type == "radio" || $row->field_type == "textarea") {
                // needed to check if field was inputted already
                $row_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM `wp_invoice_data` WHERE `field_name` = %s AND `invoice_no` = %d;", $row->field_name, $lastid));
                if ($row_data) {
                    continue;
                } else {
                    if ($invoice_no) {
                        $wpdb->query($wpdb->prepare("UPDATE `wp_invoice_data` SET `field_value` = %s, `field_cost` = %f WHERE `invoice_no` = %d AND `field_name` = %s", $fieldvalue, $fieldcost, $invoice_no, $fieldname));
                    } else {
                        $wpdb->insert('wp_invoice_data', array('invoice_no' => $lastid, 'field_name' => $row->field_name, 'field_value' => "", 'field_cost' => 0), array('%d', '%s', '%s', '%f'));
                    }
                    // else: insert into database
                }
            }
            // if: it's a field type to store
        } elseif ($row->field_type == "dropdown" || $row->field_type == "checkbox" || $row->field_type == "textarea" || $row->field_type == "radio" || $row->field_type == "textbox" || $row->field_type == "textboxHidden") {
            $fieldname = $row->field_name;
            $fieldvalue = $_POST[$fieldname];
            $fieldcost = 0;
            $attributesArray = unserialize($row->attributes);
            /* textboxes can have price ranges, so get the right price and put in $fieldcost */
            if ($row->field_type == "textbox") {
                $fieldcost = textboxFieldCost($attributesArray, $fieldvalue);
            } elseif ($row->field_type == "dropdown" || $row->field_type == "radio") {
                if ($row->field_value == $fieldvalue) {
                    $invoice_date = $wpdb->get_var($wpdb->prepare("SELECT `invoice_creation_date` FROM `wp_invoice_table` WHERE `invoice_no` = %d;", $lastid));
                    if ($attributesArray["trigger_date"]) {
                        $invoice_date = strtotime($invoice_date);
                        $invoice_date = strtotime(date("Y-m-d", $invoice_date));
                        $trigger_date = strtotime($attributesArray["trigger_date"]);
                        if ($invoice_date >= $trigger_date) {
                            $fieldcost = $attributesArray["after_price"];
                        } else {
                            $fieldcost = $attributesArray["before_price"];
                        }
                    } else {
                        $fieldcost = $attributesArray[0];
                    }
                } else {
                    continue;
                }
                // don't insert into wp_invoice_data until we get the right field (avoid incorrect inserts of wrong prices). Also, skip repeats
            }
            // if radio, checkbox, dropdown
            $total += $fieldcost;
            if ($row->field_type == "checkbox") {
                $fieldcost = $wpdb->get_var($wpdb->prepare("SELECT `field_cost` FROM `wp_invoice_data` WHERE `invoice_no` = %d AND `field_name` = %s", $invoice_no, $fieldname));
                if (in_array($row->field_value, $fieldvalue)) {
                    $fieldcost += $attributesArray[0];
                } else {
                    continue;
                }
            }
            // if: checkbox
            /* Special Hidden fields that need to be filled (school_id, etc.) */
            if ($row->field_type == "textboxHidden") {
                if ($field_name == "school_id") {
                    //$user_id = $_POST['user-id'];
                    $single = true;
                    $key = 'wp_school_id';
                    $fieldvalue = get_user_meta($user_id, $key, $single);
                }
                // if: school_id
            }
            // if: textboxHidden
            if ($row->field_type == "checkbox") {
                $fieldvalue = implode(", ", $fieldvalue);
            }
            if ($invoice_no) {
                $wpdb->query($wpdb->prepare("UPDATE `wp_invoice_data` SET `field_value` = %s, `field_cost` = %f WHERE `invoice_no` = %d AND `field_name` = %s", $fieldvalue, $fieldcost, $invoice_no, $fieldname));
            } else {
                // insert(table, data, format)
                $wpdb->insert('wp_invoice_data', array('invoice_no' => $lastid, 'field_name' => $fieldname, 'field_value' => $fieldvalue, 'field_cost' => $fieldcost), array('%d', '%s', '%s', '%f'));
            }
            // else: insert into database
        }
        // if: input needs to go in database
    }
    // for: loop through form
    /* Update wp_invoice_table with total */
    $wpdb->query($wpdb->prepare("UPDATE `wp_invoice_table` SET `total` = %f WHERE `invoice_no` = %d;", $total, $lastid));
    generatePDF($invoice_type_id, $lastid);
}
Пример #8
0
 /**
  * Uses htmldoc to generate a pdf file from the provided html. returns the pdf as text. 
  * @param unknown_type $timestamp
  * @param unknown_type $html
  * @return string
  */
 public function generatePDF($html)
 {
     return generatePDF($html);
 }
 public function handle_submission($invoice_type_id)
 {
     $this->invoice_id = generateInvoice($invoice_type_id, $this->user_id, $this->form_fields);
     generatePDF($invoice_type_id, $this->invoice_id, $this->user_id);
     emailQuote($invoice_type_id, $this->invoice_id, $this->user_id);
 }
Пример #10
0
                }
            }
        }
        ?>
					</div>
					
					<?php 
        /**
        						Bouton de téléchargement
        					**/
        if (isset($_GET['download'])) {
            if ($_GET['download'] == 'csv') {
                downloadFILE(generateCSV($evaluationData, TRUE)['csvPath'], $evaluationData['service']['FullName'] . '.csv');
            } else {
                if ($_GET['download'] == 'pdf') {
                    downloadFILE(generatePDF($evaluationData, TRUE, TRUE)['pdfPath'], $evaluationData['service']['FullName'] . '.pdf');
                }
            }
        }
        /**
        						Masquage du service
        					**/
        if (isset($_GET['hideService']) && $_SESSION['rang'] >= 3) {
            unset($_GET['hideService']);
            if ($evaluationData['service']['hide'] == 1) {
                $setHideValue = 0;
            } else {
                $setHideValue = 1;
            }
            $sql = 'UPDATE eval_ccpc_resultats SET hide = ' . $setHideValue . ' WHERE service = ?';
            $res = $db->prepare($sql);
Пример #11
0
 				Contenue des messages à envoyer
 			**/
 $erreur = array();
 $_SESSION['sendMail']['settings']['objet'] = htmLawed($_POST['titre']);
 $_SESSION['sendMail']['settings']['message'] = htmLawed($_POST['message']);
 /*
 	Pièces jointes
 */
 $allowedJoin = $allowedDownloadAction;
 unset($allowedJoin['all']);
 $allowedJoin['none'] = FALSE;
 // Pour le PDF
 if (isset($_POST['pdfJoin']) && isset($allowedJoin[$_POST['pdfJoin']]) && ($_POST['pdfJoin'] == 'none' || $allowedJoin[$_POST['pdfJoin']]['type'] == 'PDF')) {
     if ($_POST['pdfJoin'] != 'none') {
         foreach ($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']] as $serviceDetected) {
             $_SESSION['sendMail']['settings']['pdf'] = generatePDF(getEvaluationCCPCFullData($serviceDetected['service']['id'], $serviceDetected['promotion'], $_GET['dateDebut'], $_GET['dateFin'], $allowedJoin[$_POST['pdfJoin']]['moderation']), $allowedJoin[$_POST['pdfJoin']]['comment'], TRUE)['pdfPath'];
         }
     }
 } else {
     $erreur['LANG_ERROR_CCPC_UNKNOWN'] = TRUE;
 }
 // Pour le CSV
 if (isset($_POST['csvJoin']) && isset($allowedJoin[$_POST['csvJoin']]) && ($_POST['csvJoin'] == 'none' || $allowedJoin[$_POST['csvJoin']]['type'] == 'CSV')) {
     if ($_POST['csvJoin'] != 'none') {
         foreach ($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']] as $serviceDetected) {
             $_SESSION['sendMail']['settings']['csv'] = generateCSV(getEvaluationCCPCFullData($serviceDetected['service']['id'], $serviceDetected['promotion'], $_GET['dateDebut'], $_GET['dateFin'], $allowedJoin[$_POST['csvJoin']]['moderation']), TRUE)['csvPath'];
         }
     }
 } else {
     $erreur['LANG_ERROR_CCPC_UNKNOWN'] = TRUE;
 }