Пример #1
0
function sendQuotePDF($id)
{
    global $CONFIG;
    global $_LANG;
    global $currency;
    $result = select_query("tblquotes", "", array("id" => $id));
    $data = mysql_fetch_array($result);
    $subject = html_entity_decode($data['subject']);
    $stage = $data['stage'];
    $datecreated = fromMySQLDate($data['datecreated']);
    $validuntil = fromMySQLDate($data['validuntil']);
    $userid = $data['userid'];
    $notes = html_entity_decode($data['customernotes']) . "\r\n";
    if ($userid) {
        $clientsdetails = getClientsDetails($userid);
        foreach ($clientsdetails as $k => $v) {
            $clientsdetails[$k] = html_entity_decode($v);
        }
    } else {
        $clientsdetails['firstname'] = html_entity_decode($data['firstname']);
        $clientsdetails['lastname'] = html_entity_decode($data['lastname']);
        $clientsdetails['companyname'] = html_entity_decode($data['companyname']);
        $clientsdetails['email'] = html_entity_decode($data['email']);
        $clientsdetails['address1'] = html_entity_decode($data['address1']);
        $clientsdetails['address2'] = html_entity_decode($data['address2']);
        $clientsdetails['city'] = html_entity_decode($data['city']);
        $clientsdetails['state'] = html_entity_decode($data['state']);
        $clientsdetails['postcode'] = html_entity_decode($data['postcode']);
        $clientsdetails['country'] = html_entity_decode($data['country']);
        $clientsdetails['phonenumber'] = html_entity_decode($data['phonenumber']);
    }
    $pdfdata = genQuotePDF($id);
    $sysurl = $CONFIG['SystemSSLURL'] ? $CONFIG['SystemSSLURL'] : $CONFIG['SystemURL'];
    $quote_link = "<a href=\"" . $sysurl . ("/viewquote.php?id=" . $id . "\">") . $sysurl . ("/viewquote.php?id=" . $id . "</a>");
    sendMessage("Quote Delivery with PDF", 1, array("emailquote" => true, "quote_number" => $id, "quote_subject" => $subject, "quote_date_created" => $datecreated, "quote_valid_until" => $validuntil, "client_id" => $userid, "client_first_name" => $clientsdetails['firstname'], "client_last_name" => $clientsdetails['lastname'], "client_company_name" => $clientsdetails['companyname'], "client_email" => $clientsdetails['email'], "client_address1" => $clientsdetails['address1'], "client_address2" => $clientsdetails['address2'], "client_city" => $clientsdetails['city'], "client_state" => $clientsdetails['state'], "client_postcode" => $clientsdetails['postcode'], "client_country" => $clientsdetails['country'], "client_phonenumber" => $clientsdetails['phonenumber'], "client_language" => $clientsdetails['language'], "quoteattachmentdata" => $pdfdata, "quote_link" => $quote_link));
    update_query("tblquotes", array("stage" => "Delivered"), array("id" => $id));
}
Пример #2
0
            } else {
                if ($type == "q") {
                    if (!$_SESSION['uid'] && !$_SESSION['adminid']) {
                        downloadLogin();
                    }
                    $result = select_query("tblquotes", "id,userid", array("id" => $id));
                    $data = mysql_fetch_array($result);
                    $id = $data['id'];
                    $userid = $data['userid'];
                    if ($userid != $_SESSION['uid'] && !$_SESSION['adminid']) {
                        exit("Permission Denied");
                    }
                    require ROOTDIR . "/includes/clientfunctions.php";
                    require ROOTDIR . "/includes/invoicefunctions.php";
                    require ROOTDIR . "/includes/quotefunctions.php";
                    $pdfdata = genQuotePDF($id);
                    header("Pragma: public");
                    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                    header("Cache-Control: must-revalidate, post-check=0, pre-check=0, private");
                    header("Cache-Control: private", false);
                    header("Content-Type: application/pdf");
                    header("Content-Disposition: " . ($viewpdf ? "inline" : "attachment") . "; filename=\"" . $_LANG['quotefilename'] . $id . ".pdf\"");
                    header("Content-Transfer-Encoding: binary");
                    echo $pdfdata;
                    exit;
                }
            }
        }
    }
}