Example #1
0
function genQuotePDF($id)
{
    global $whmcs;
    global $CONFIG;
    global $_LANG;
    global $currency;
    $companyname = html_entity_decode($CONFIG['CompanyName']);
    $companyurl = $CONFIG['Domain'];
    $companyaddress = html_entity_decode($CONFIG['InvoicePayTo']);
    $companyaddress = explode("\r\n", $companyaddress);
    $quotenumber = $id;
    $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'];
    $proposal = $data['proposal'] ? html_entity_decode($data['proposal']) . "\r\n" : "";
    $notes = $data['customernotes'] ? html_entity_decode($data['customernotes']) . "\r\n" : "";
    $currency = getCurrency($userid, $data['currency']);
    if ($userid) {
        getUsersLang($userid);
        $stage = getQuoteStageLang($stage);
        $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']);
    }
    $taxlevel1 = getTaxRate(1, $clientsdetails['state'], $clientsdetails['country']);
    $taxlevel2 = getTaxRate(2, $clientsdetails['state'], $clientsdetails['country']);
    require ROOTDIR . "/includes/countries.php";
    $clientsdetails['country'] = $countries[$clientsdetails['country']];
    $subtotal = formatCurrency($data['subtotal']);
    $tax1 = formatCurrency($data['tax1']);
    $tax2 = formatCurrency($data['tax2']);
    $total = formatCurrency($data['total']);
    $lineitems = array();
    $result = select_query("tblquoteitems", "", array("quoteid" => $id), "id", "ASC");
    while ($data = mysql_fetch_array($result)) {
        $line_id = $data['id'];
        $line_desc = $data['description'];
        $line_qty = $data['quantity'];
        $line_unitprice = $data['unitprice'];
        $line_discount = $data['discount'];
        $line_taxable = $data['taxable'];
        $line_total = format_as_currency($line_qty * $line_unitprice * (1 - $line_discount / 100));
        $lineitems[] = array("id" => $line_id, "description" => htmlspecialchars(html_entity_decode($line_desc, ENT_QUOTES)), "qty" => $line_qty, "unitprice" => $line_unitprice, "discount" => $line_discount, "taxable" => $line_taxable, "total" => formatCurrency($line_total));
    }
    $tplvars = array();
    $tplvars['companyname'] = $companyname;
    $tplvars['companyurl'] = $companyurl;
    $tplvars['companyaddress'] = $companyaddress;
    $tplvars['paymentmethod'] = $paymentmethod;
    $tplvars['quotenumber'] = $quotenumber;
    $tplvars['subject'] = $subject;
    $tplvars['stage'] = $stage;
    $tplvars['datecreated'] = $datecreated;
    $tplvars['validuntil'] = $validuntil;
    $tplvars['userid'] = $userid;
    $tplvars['clientsdetails'] = $clientsdetails;
    $tplvars['proposal'] = $proposal;
    $tplvars['notes'] = $notes;
    $tplvars['taxlevel1'] = $taxlevel1;
    $tplvars['taxlevel2'] = $taxlevel2;
    $tplvars['subtotal'] = $subtotal;
    $tplvars['tax1'] = $tax1;
    $tplvars['tax2'] = $tax2;
    $tplvars['total'] = $total;
    foreach ($tplvars as $k => $v) {
        $tplvars[$k] = html_entity_decode($v, ENT_QUOTES);
    }
    $tplvars['lineitems'] = $lineitems;
    $invoice = new WHMCS_Invoice();
    $invoice->pdfCreate($_LANG['quotenumber'] . $id);
    $invoice->pdfAddPage("quotepdf.tpl", $tplvars);
    $pdfdata = $invoice->pdfOutput();
    getUsersLang("");
    return $pdfdata;
}
Example #2
0
     $result = select_query("tblquotes", "COUNT(*)", array("userid" => $client->getID()));
     $data = mysql_fetch_array($result);
     $numitems = $data[0];
     list($orderby, $sort, $limit) = clientAreaTableInit("quote", "id", "DESC", $numitems);
     if (!in_array($orderby, array("id", "date", "duedate", "total", "stage"))) {
         $orderby = "validuntil";
     }
     $smartyvalues['orderby'] = $orderby;
     $smartyvalues['sort'] = strtolower($sort);
     $quotes = array();
     $result = select_query("tblquotes", "", array("userid" => $client->getID(), "stage" => array("sqltype" => "NEQ", "value" => "Draft")), $orderby, $sort, $limit);
     while ($data = mysql_fetch_assoc($result)) {
         $data['datecreated'] = fromMySQLDate($data['datecreated'], 0, 1);
         $data['validuntil'] = fromMySQLDate($data['validuntil'], 0, 1);
         $data['lastmodified'] = fromMySQLDate($data['lastmodified'], 0, 1);
         $data['stage'] = getQuoteStageLang($data['stage']);
         $quotes[] = $data;
     }
     $smartyvalues['quotes'] = $quotes;
     $smartyvalues = array_merge($smartyvalues, clientAreaTablePageNav($numitems));
 } else {
     if ($action == "bulkdomain") {
         checkContactPermission("managedomains");
         $ca->setTemplate("bulkdomainmanagement");
         $domainids = "";
         foreach ($domids as $domid) {
             $domainids .= (int) $domid . ",";
         }
         $domainids = substr($domainids, 0, 0 - 1);
         $queryfilter = "userid=" . (int) $client->getID() . (" AND id IN (" . $domainids . ")");
         $domains = $domainids = $errors = array();