function buildDocumentModel()
 {
     global $app_strings;
     try {
         $model = parent::buildDocumentModel();
         $this->generateEntityModel($this->focus, 'SalesOrder', 'salesorder_', $model);
         $entity = new Potentials();
         if ($this->focusColumnValue('potential_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('potential_id'), 'Potentials');
         }
         $this->generateEntityModel($entity, 'Potentials', 'potential_', $model);
         $entity = new Quotes();
         if ($this->focusColumnValue('quote_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('quote_id'), 'Quotes');
         }
         $this->generateEntityModel($entity, 'Quotes', 'quote_', $model);
         $entity = new Contacts();
         if ($this->focusColumnValue('contact_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('contact_id'), 'Contacts');
         }
         $this->generateEntityModel($entity, 'Contacts', 'contact_', $model);
         $entity = new Accounts();
         if ($this->focusColumnValue('account_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('account_id'), 'Accounts');
         }
         $this->generateEntityModel($entity, 'Accounts', 'account_', $model);
         $this->generateUi10Models($model);
         $this->generateRelatedListModels($model);
         $model->set('salesorder_no', $this->focusColumnValue('salesorder_no'));
         return $model;
     } catch (Exception $e) {
         echo '<meta charset="utf-8" />';
         if ($e->getMessage() == $app_strings['LBL_RECORD_DELETE']) {
             echo $app_strings['LBL_RECORD_INCORRECT'];
             echo '<br><br>';
         } else {
             echo $e->getMessage();
             echo '<br><br>';
         }
         return null;
     }
 }
 /** Delete a quote
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     if ($this->_request->isPost()) {
         $id = (int) $this->_request->getPost('id');
         $del = $this->_request->getPost('del');
         if ($del == 'Yes' && $id > 0) {
             $where = 'id = ' . $id;
             $this->_quotes->delete($where);
             $this->getFlash()->addMessage('Quote/announcement deleted!');
         }
         $this->redirect(self::REDIRECT);
     } else {
         $id = (int) $this->_request->getParam('id');
         if ($id > 0) {
             $this->view->quote = $this->_quotes->fetchRow('id =' . $id);
         }
     }
 }
 /**
  * Function to get the value of the entity 
  * @param integer $value
  * @return string $retval
  */
 public static function get_value($value)
 {
     $retval = '';
     if ((int) $value > 0) {
         $object = new Quotes();
         $retrun_fields = $object->popup_selection_return_field;
         $retrun_field_list = explode(",", $retrun_fields);
         $object->query("select " . $retrun_fields . " from quotes where idquotes = ?", array($value));
         if ($object->getNumRows() > 0) {
             $object->next();
             $cnt_return_fields = 0;
             foreach ($retrun_field_list as $retrun_fields) {
                 if ($cnt_return_fields > 0) {
                     $retval .= ' ';
                 }
                 $retval .= $object->{$retrun_fields};
                 $cnt_return_fields++;
             }
         }
     }
     return $retval;
 }
Example #4
0
<?php

// To store current search
session_start();
require_once 'classes.php';
$Q = new Quotes();
include 'header.php';
$quotes = 0;
if ($_POST['submit']) {
    $search = $_POST['search'];
    $_SESSION['search'] = $search;
    if (!$search['prof'] == "") {
        echo "<p class='searchresult'>You searched for: <b>" . $search['prof'] . "</b> ";
        echo $search['exact'] ? "(exact) " : "(partial) ";
        if (!$search['rand']) {
            echo "and sorted by <b>" . $search['sort'] . "</b>.";
        } else {
            echo "and chose to be <b>rAnDoM</b>!";
        }
        if (intval($search['limit'])) {
            echo " Returning " . intval($search['limit']) . " results.</p>\n\n";
        } else {
            echo " Returning all results.</p>\n\n";
        }
    } else {
        echo "<p>You searched for nothing! Try again, noob</p>\n\n";
    }
    $quotes = $Q->getQuotes($search);
} else {
    $search = $_SESSION['search'];
    ?>
Example #5
0
$focus = CRMEntity::getInstance($currentModule);
$smarty = new vtigerCRM_Smarty();
$category = getParentTab($currentModule);
$record = vtlib_purify($_REQUEST['record']);
$isduplicate = vtlib_purify($_REQUEST['isDuplicate']);
//added to fix the issue4600
$searchurl = getBasic_Advance_SearchURL();
$smarty->assign("SEARCH", $searchurl);
//4600 ends
$currencyid = fetchCurrency($current_user->id);
$rate_symbol = getCurrencySymbolandCRate($currencyid);
$rate = $rate_symbol['rate'];
if (isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
    if (isset($_REQUEST['convertmode']) && $_REQUEST['convertmode'] == 'quotetoinvoice') {
        $quoteid = $record;
        $quote_focus = new Quotes();
        $quote_focus->id = $quoteid;
        $quote_focus->retrieve_entity_info($quoteid, 'Quotes');
        $focus = getConvertQuoteToInvoice($focus, $quote_focus, $quoteid);
        // Reset the value w.r.t Quote Selected
        $currencyid = $quote_focus->column_fields['currency_id'];
        $rate = $quote_focus->column_fields['conversion_rate'];
        //Added to display the Quote's associated vtiger_products -- when we create vtiger_invoice from Quotes DetailView
        $associated_prod = getAssociatedProducts("Quotes", $quote_focus);
        $txtTax = $quote_focus->column_fields['txtTax'] != '' ? $quote_focus->column_fields['txtTax'] : '0.000';
        $txtAdj = $quote_focus->column_fields['txtAdjustment'] != '' ? $quote_focus->column_fields['txtAdjustment'] : '0.000';
        $smarty->assign("CONVERT_MODE", vtlib_purify($_REQUEST['convertmode']));
        $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
        $smarty->assign("MODE", $quote_focus->mode);
        $smarty->assign("AVAILABLE_PRODUCTS", 'true');
    } elseif (isset($_REQUEST['convertmode']) && $_REQUEST['convertmode'] == 'sotoinvoice') {
Example #6
0
} else {
    if (isset($_REQUEST['convertmode']) && $_REQUEST['convertmode'] == 'update_quote_val') {
        //Updating the Select Quote Value in Create Mode
        foreach ($focus->column_fields as $fieldname => $val) {
            if (isset($_REQUEST[$fieldname])) {
                $value = $_REQUEST[$fieldname];
                $focus->column_fields[$fieldname] = $value;
            }
        }
        //Handling for dateformat in due_date vtiger_field
        if ($focus->column_fields['duedate'] != '') {
            $curr_due_date = $focus->column_fields['duedate'];
            $focus->column_fields['duedate'] = getValidDBInsertDateValue($curr_due_date);
        }
        $quoteid = $focus->column_fields['quote_id'];
        $quote_focus = new Quotes();
        $quote_focus->id = $quoteid;
        $quote_focus->retrieve_entity_info($quoteid, "Quotes");
        $focus = getConvertQuoteToSoObject($focus, $quote_focus, $quoteid);
        // Reset the value w.r.t Quote Selected
        $currencyid = $quote_focus->column_fields['currency_id'];
        $rate = $quote_focus->column_fields['conversion_rate'];
        //Added to display the Quotes's associated vtiger_products -- when we select Quote in New SO page
        if (isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') {
            $associated_prod = getAssociatedProducts("Quotes", $quote_focus, $focus->column_fields['quote_id']);
        }
        $smarty->assign("QUOTE_ID", $focus->column_fields['quote_id']);
        $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
        $smarty->assign("MODE", $quote_focus->mode);
        $smarty->assign("AVAILABLE_PRODUCTS", 'true');
    }
Example #7
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Quotes detail 
* @author Abhik Chakraborty
*/
$do_crmfields = new \CRMFields();
$do_block = new \Block();
$do_block->get_block_by_module($module_id);
$module_obj = new \Quotes();
$module_obj->getId($sqcrm_record_id);
$do_lineitems = new \Lineitems();
$do_lineitems->get_line_items($module_id, $sqcrm_record_id);
$lineitems = array();
if ($do_lineitems->getNumRows() > 0) {
    while ($do_lineitems->next()) {
        $lineitems[] = array("idlineitems" => $do_lineitems->idlineitems, "item_type" => $do_lineitems->item_type, "item_name" => $do_lineitems->item_name, "item_value" => $do_lineitems->item_value, "item_description" => $do_lineitems->item_description, "item_quantity" => $do_lineitems->item_quantity, "item_price" => $do_lineitems->item_price, "discount_type" => $do_lineitems->discount_type, "discount_value" => $do_lineitems->discount_value, "discounted_amount" => $do_lineitems->discounted_amount, "tax_values" => $do_lineitems->tax_values, "taxed_amount" => $do_lineitems->taxed_amount, "total_after_discount" => $do_lineitems->total_after_discount, "total_after_tax" => $do_lineitems->total_after_tax, "net_total" => $do_lineitems->net_total);
    }
}
//updates detail, just add and last updated
$do_crmentity = new \CRMEntity();
$update_history = $do_crmentity->get_last_updates($sqcrm_record_id, $module_id, $module_obj);
if (isset($_GET['ajaxreq']) && $_GET['ajaxreq'] == true) {
    require_once 'view/detail_view_entry.php';
} else {
    require_once 'view/detail_view.php';
}
Example #8
0
$focus = CRMEntity::getInstance($currentModule);
$smarty = new vtigerCRM_Smarty();
$category = getParentTab($currentModule);
$record = vtlib_purify($_REQUEST['record']);
$isduplicate = vtlib_purify($_REQUEST['isDuplicate']);
//added to fix the issue4600
$searchurl = getBasic_Advance_SearchURL();
$smarty->assign("SEARCH", $searchurl);
//4600 ends
$currencyid = fetchCurrency($current_user->id);
$rate_symbol = getCurrencySymbolandCRate($currencyid);
$rate = $rate_symbol['rate'];
if (isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
    if (isset($_REQUEST['convertmode']) && $_REQUEST['convertmode'] == 'quotetoissuecard') {
        $quoteid = $_REQUEST['record'];
        $quote_focus = new Quotes();
        $quote_focus->id = $quoteid;
        $quote_focus->retrieve_entity_info($quoteid, "Quotes");
        $focus->column_fields['description'] = $quote_focus->column_fields['description'];
        $focus->column_fields['currency_id'] = $quote_focus->column_fields['currency_id'];
        $focus->column_fields['conversion_rate'] = $quote_focus->column_fields['conversion_rate'];
        // Reset the value w.r.t Quote Selected
        $currencyid = $quote_focus->column_fields['currency_id'];
        $rate = $quote_focus->column_fields['conversion_rate'];
        //Added to display the Quote's associated vtiger_products -- when we create vtiger_invoice from Quotes DetailView
        $associated_prod = getAssociatedProducts("Quotes", $quote_focus);
        $txtTax = $quote_focus->column_fields['txtTax'] != '' ? $quote_focus->column_fields['txtTax'] : '0.000';
        $txtAdj = $quote_focus->column_fields['txtAdjustment'] != '' ? $quote_focus->column_fields['txtAdjustment'] : '0.000';
        $smarty->assign("CONVERT_MODE", vtlib_purify($_REQUEST['convertmode']));
        $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
        $smarty->assign("MODE", $quote_focus->mode);
Example #9
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Create sales order from quote 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
$do_block = new Block();
$do_block->get_block_by_module(14);
//-- get block information for sales order
$do_global_settings = new CRMGlobalSettings();
$inv_terms_cond = $do_global_settings->get_inventory_terms_condition();
$tems_condition = $inv_terms_cond["salesorder_terms_condition"];
$module_obj = new Quotes();
$module_obj->getId($sqcrm_record_id);
//-- get lineitems for quotes
$do_lineitems = new Lineitems();
$do_lineitems->get_line_items(13, $sqcrm_record_id);
//update the properties
$module_obj->terms_condition = $tems_condition;
$module_obj->so_billing_address = $module_obj->q_billing_address;
$module_obj->so_shipping_address = $module_obj->q_shipping_address;
$module_obj->so_billing_po_box = $module_obj->q_billing_po_box;
$module_obj->so_shipping_po_box = $module_obj->q_shipping_po_box;
$module_obj->so_billing_po_code = $module_obj->q_billing_po_code;
$module_obj->so_shipping_po_code = $module_obj->q_shipping_po_code;
$module_obj->so_billing_city = $module_obj->q_billing_city;
$module_obj->so_shipping_city = $module_obj->q_shipping_city;
$module_obj->so_billing_state = $module_obj->q_billing_state;
$module_obj->so_shipping_state = $module_obj->q_shipping_state;
Example #10
0
 * Contributor(s): ______________________________________.
 ********************************************************************************/
require_once 'Smarty_setup.php';
require_once "data/Tracker.php";
require_once 'modules/Quotes/Quotes.php';
require_once 'include/logging.php';
require_once 'include/ListView/ListView.php';
require_once 'include/utils/utils.php';
require_once 'modules/CustomView/CustomView.php';
global $app_strings, $list_max_entries_per_page, $currentModule, $theme;
$log = LoggerManager::getLogger('quote_list');
if (!isset($where)) {
    $where = "";
}
$url_string = '';
$focus = new Quotes();
// Initialize sort by fields
$focus->initSortbyField('Quotes');
// END
$smarty = new vtigerCRM_Smarty();
$other_text = array();
if (!$_SESSION['lvs'][$currentModule]) {
    unset($_SESSION['lvs']);
    $modObj = new ListViewSession();
    $modObj->sorder = $sorder;
    $modObj->sortby = $order_by;
    $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
}
if ($_REQUEST['errormsg'] != '') {
    $errormsg = vtlib_purify($_REQUEST['errormsg']);
    $smarty->assign("ERROR", "The User does not have permission to Change/Delete " . $errormsg . " " . $currentModule);
Example #11
0
 * Contributor(s): ______________________________________.
 ********************************************************************************/
require_once 'Smarty_setup.php';
require_once "data/Tracker.php";
require_once 'modules/Quotes/Quotes.php';
require_once 'include/logging.php';
require_once 'include/ListView/ListView.php';
require_once 'include/utils/utils.php';
require_once 'modules/CustomView/CustomView.php';
global $app_strings, $list_max_entries_per_page, $currentModule, $theme;
$log = LoggerManager::getLogger('quote_list');
if (!isset($where)) {
    $where = "";
}
$url_string = '';
$focus = new Quotes();
// Initialize sort by fields
$focus->initSortbyField('Quotes');
// END
$smarty = new vtigerCRM_Smarty();
$other_text = array();
if (!$_SESSION['lvs'][$currentModule]) {
    unset($_SESSION['lvs']);
    $modObj = new ListViewSession();
    $modObj->sorder = $sorder;
    $modObj->sortby = $order_by;
    $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
}
if ($_REQUEST['errormsg'] != '') {
    $errormsg = vtlib_purify($_REQUEST['errormsg']);
    $smarty->assign("ERROR", "The User does not have permission to Change/Delete " . $errormsg . " " . $currentModule);
Example #12
0
/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
function smarty_block_quote($params, $content, &$smarty, &$repeat)
{
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "quote";
    }
    if (class_exists("Quotes")) {
        $quote = new Quotes();
        $quote_controller = new Quote();
    } else {
        uses("quote");
        $quote = new Quotes();
        $quote_controller = new Quote();
    }
    if (!empty($params['productid'])) {
        $conditions[] = "q.product_id='" . intval($params['productid']) . "'";
    }
    if (!empty($params['marketid'])) {
        $conditions[] = "q.market_id=" . $params['marketid'];
    }
    if (!empty($params['areaid'])) {
        $conditions[] = "q.area_id='" . $params['areaid'] . "'";
    }
    $orderby = null;
    if (isset($params['orderby'])) {
        $orderby = " ORDER BY " . trim($params['orderby']) . " ";
    } else {
        $orderby = " ORDER BY id DESC ";
    }
    $quote->setCondition($conditions);
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $quote->setLimitOffset($offset, $limit);
    $sql = "SELECT id,title,content,max_price,min_price,created FROM {$quote->table_prefix}quotes q " . $quote->getCondition() . "{$orderby}" . $quote->getLimitOffset();
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $quote->GetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        $url = $quote->getPermaLink($item['id'], 'market/quote.php');
        $item['url'] = $url;
        if (isset($params['titlelen'])) {
            $item['title'] = mb_substr(strip_tags($item['title']), 0, $params['titlelen']);
        }
        $item['pubdate'] = @date("m/d", $item['created']);
        $item['link'] = '<a title="' . $item['title'] . '" href="' . $url . '">' . $item['title'] . '</a>';
        $smarty->assign($params['name'], $item);
    } else {
        $repeat = false;
        reset($smarty->blockvars[$param_count]);
    }
    if (!is_null($content)) {
        print $content;
    }
    if (!$repeat) {
        $smarty->blockvars[$param_count] = array();
    }
}
Example #13
0
<?php

session_start();
require 'classes.php';
include 'header.php';
$update = new Quotes();
if ($_SESSION['loggedin']) {
    ?>

	<p>Fix troublesome quotes...</p>
	<form method="post" action="fix.php">
	Search for a bad quote by prof: <input type="text" name="search" value="<?php 
    echo $_POST['search'] ? $_POST['search'] : "";
    ?>
" />
	<br />Term <select name="term"><option>Spring</option><option>Fall</option><option>Winter</option></select> 
	<input type="text" name="syear" value="<?php 
    echo $_POST['syear'] ? $_POST['syear'] : "";
    ?>
" />
	<br /><input type="submit" name="submit" value="Search" />

<?php 
    if ($_POST['submit']) {
        // Need to search by term/year too
        // Need new search/better. search should accept "stuff?stuff?" or something
        $quotes = $update->getQuotes($_POST['search']);
        echo "<table><tr><th>Quote</th><th>Prof</th><th>Course</th><th>Term/Year</th></tr>\n";
        foreach ($quotes as $quote) {
            echo "<tr><td><input type='text' name='quote[]' value=\"" . $quote['quote'] . "\" /></td>";
            echo "<td><input type='text' name='prof[]' value='" . $quote['prof'] . "' /></td>";
Example #14
0
/**
 * Function to generate Quote pdf
 */
function get_quote_pdf()
{
    require_once 'include/tcpdf/pdf.php';
    require_once 'include/tcpdf/pdfconfig.php';
    require_once 'include/database/PearDatabase.php';
    require_once 'modules/Quotes/Quotes.php';
    global $adb, $app_strings, $current_user;
    // would you like and end page?  1 for yes 0 for no
    $endpage = "1";
    $focus = new Quotes();
    $focus->retrieve_entity_info($_REQUEST['record'], "Quotes");
    $focus->apply_field_security();
    $account_name = getAccountName($focus->column_fields[account_id]);
    $quote_no = $focus->column_fields[quote_no];
    if ($focus->column_fields["hdnTaxType"] == "individual") {
        $product_taxes = 'true';
    } else {
        $product_taxes = 'false';
    }
    $sql = "select currency_symbol from vtiger_currency_info where id=?";
    $result = $adb->pquery($sql, array($focus->column_fields['currency_id']));
    $currency_symbol = $adb->query_result($result, 0, 'currency_symbol');
    // **************** BEGIN POPULATE DATA ********************
    $account_id = $focus->column_fields[account_id];
    $quote_id = $_REQUEST['record'];
    // Quote Information
    $valid_till = $focus->column_fields["validtill"];
    $valid_till = getDisplayDate($valid_till);
    $bill_street = $focus->column_fields["bill_street"];
    $bill_city = $focus->column_fields["bill_city"];
    $bill_state = $focus->column_fields["bill_state"];
    $bill_code = $focus->column_fields["bill_code"];
    $bill_country = $focus->column_fields["bill_country"];
    $contact_name = getContactName($focus->column_fields["contact_id"]);
    $ship_street = $focus->column_fields["ship_street"];
    $ship_city = $focus->column_fields["ship_city"];
    $ship_state = $focus->column_fields["ship_state"];
    $ship_code = $focus->column_fields["ship_code"];
    $ship_country = $focus->column_fields["ship_country"];
    $conditions = from_html($focus->column_fields["terms_conditions"]);
    $description = from_html($focus->column_fields["description"]);
    $status = $focus->column_fields["quotestage"];
    // Company information
    $add_query = "select * from vtiger_organizationdetails";
    $result = $adb->pquery($add_query, array());
    $num_rows = $adb->num_rows($result);
    if ($num_rows > 0) {
        $org_name = $adb->query_result($result, 0, "organizationname");
        $org_address = $adb->query_result($result, 0, "address");
        $org_city = $adb->query_result($result, 0, "city");
        $org_state = $adb->query_result($result, 0, "state");
        $org_country = $adb->query_result($result, 0, "country");
        $org_code = $adb->query_result($result, 0, "code");
        $org_phone = $adb->query_result($result, 0, "phone");
        $org_fax = $adb->query_result($result, 0, "fax");
        $org_website = $adb->query_result($result, 0, "website");
        $logo_name = $adb->query_result($result, 0, "logoname");
    }
    //Population of Product Details - Starts
    //we can cut and paste the following lines in a file and include that file here is enough. For that we have to put a new common file. we will do this later
    //NOTE : Removed currency symbols and added with Grand Total text. it is enough to show the currency symbol in one place
    //we can also get the NetTotal, Final Discount Amount/Percent, Adjustment and GrandTotal from the array $associated_products[1]['final_details']
    //get the Associated Products for this Invoice
    $focus->id = $focus->column_fields["record_id"];
    $associated_products = getAssociatedProducts("Quotes", $focus);
    $num_products = count($associated_products);
    //This $final_details array will contain the final total, discount, Group Tax, S&H charge, S&H taxes and adjustment
    $final_details = $associated_products[1]['final_details'];
    //getting the Net Total
    $price_subtotal = number_format($final_details["hdnSubTotal"], 2, '.', ',');
    //Final discount amount/percentage
    $discount_amount = $final_details["discount_amount_final"];
    $discount_percent = $final_details["discount_percentage_final"];
    if ($discount_amount != "") {
        $price_discount = number_format($discount_amount, 2, '.', ',');
    } else {
        if ($discount_percent != "") {
            //This will be displayed near Discount label - used in include/fpdf/templates/body.php
            $final_price_discount_percent = "(" . number_format($discount_percent, 2, '.', ',') . " %)";
            $price_discount = number_format($discount_percent * $final_details["hdnSubTotal"] / 100, 2, '.', ',');
        } else {
            $price_discount = "0.00";
        }
    }
    //Adjustment
    $price_adjustment = number_format($final_details["adjustment"], 2, '.', ',');
    //Grand Total
    $price_total = number_format($final_details["grandTotal"], 2, '.', ',');
    //To calculate the group tax amount
    if ($final_details['taxtype'] == 'group') {
        $group_tax_total = $final_details['tax_totalamount'];
        $price_salestax = number_format($group_tax_total, 2, '.', ',');
        $group_total_tax_percent = '0.00';
        $group_tax_details = $final_details['taxes'];
        for ($i = 0; $i < count($group_tax_details); $i++) {
            $group_total_tax_percent = $group_total_tax_percent + $group_tax_details[$i]['percentage'];
        }
    }
    //S&H amount
    $sh_amount = $final_details['shipping_handling_charge'];
    $price_shipping = number_format($sh_amount, 2, '.', ',');
    //S&H taxes
    $sh_tax_details = $final_details['sh_taxes'];
    $sh_tax_percent = '0.00';
    for ($i = 0; $i < count($sh_tax_details); $i++) {
        $sh_tax_percent = $sh_tax_percent + $sh_tax_details[$i]['percentage'];
    }
    $sh_tax_amount = $final_details['shtax_totalamount'];
    $price_shipping_tax = number_format($sh_tax_amount, 2, '.', ',');
    $prod_line = array();
    $lines = 0;
    //This is to get all prodcut details as row basis
    for ($i = 1, $j = $i - 1; $i <= $num_products; $i++, $j++) {
        $product_name[$i] = $associated_products[$i]['productName' . $i];
        $subproduct_name[$i] = split("<br>", $associated_products[$i]['subprod_names' . $i]);
        //$prod_description[$i] = $associated_products[$i]['productDescription'.$i];
        $comment[$i] = $associated_products[$i]['comment' . $i];
        $product_id[$i] = $associated_products[$i]['hdnProductId' . $i];
        $qty[$i] = $associated_products[$i]['qty' . $i];
        $unit_price[$i] = number_format($associated_products[$i]['unitPrice' . $i], 2, '.', ',');
        $list_price[$i] = number_format($associated_products[$i]['listPrice' . $i], 2, '.', ',');
        $list_pricet[$i] = $associated_products[$i]['listPrice' . $i];
        $discount_total[$i] = $associated_products[$i]['discountTotal' . $i];
        //aded for 5.0.3 pdf changes
        $product_code[$i] = $associated_products[$i]['hdnProductcode' . $i];
        $taxable_total = $qty[$i] * $list_pricet[$i] - $discount_total[$i];
        $producttotal = $taxable_total;
        $total_taxes = '0.00';
        if ($focus->column_fields["hdnTaxType"] == "individual") {
            $total_tax_percent = '0.00';
            //This loop is to get all tax percentage and then calculate the total of all taxes
            for ($tax_count = 0; $tax_count < count($associated_products[$i]['taxes']); $tax_count++) {
                $tax_percent = $associated_products[$i]['taxes'][$tax_count]['percentage'];
                $total_tax_percent = $total_tax_percent + $tax_percent;
                $tax_amount = $taxable_total * $tax_percent / 100;
                $total_taxes = $total_taxes + $tax_amount;
            }
            $producttotal = $taxable_total + $total_taxes;
            $product_line[$j]["Tax"] = number_format($total_taxes, 2, '.', ',') . "\n ({$total_tax_percent} %) ";
            $price_salestax += $total_taxes;
        }
        $prod_total[$i] = number_format($producttotal, 2, '.', ',');
        $product_line[$j]["Product Code"] = $product_code[$i];
        $product_line[$j]["Qty"] = $qty[$i];
        $product_line[$j]["Price"] = $list_price[$i];
        $product_line[$j]["Discount"] = $discount_total[$i];
        $product_line[$j]["Total"] = $prod_total[$i];
        $lines++;
        $product_line[$j]["Product Name"] = decode_html($product_name[$i]);
        $prod_line[$j] = 1;
        for ($count = 0; $count < count($subproduct_name[$i]); $count++) {
            if ($lines % 12 != 0) {
                $product_line[$j]["Product Name"] .= "\n" . decode_html($subproduct_name[$i][$count]);
                $prod_line[$j]++;
            } else {
                $j++;
                $product_line[$j]["Product Name"] = decode_html($product_name[$i]);
                $product_line[$j]["Product Name"] .= "\n" . decode_html($subproduct_name[$i][$count]);
                $prod_line[$j] = 2;
                $lines++;
            }
            $lines++;
        }
        if ($comment[$i] != '') {
            $product_line[$j]["Product Name"] .= "\n" . decode_html($comment[$i]);
            $prod_line[$j]++;
            $lines++;
        }
    }
    $price_salestax = number_format($price_salestax, 2, '.', ',');
    //echo '<pre>Product Details ==>';print_r($product_line);echo '</pre>';
    //echo '<pre>';print_r($associated_products);echo '</pre>';
    //Population of Product Details - Ends
    // ************************ END POPULATE DATA ***************************8
    $page_num = '1';
    $pdf = new PDF('P', 'mm', 'A4');
    $pdf->Open();
    //	$num_pages=ceil(($num_products/$products_per_page));
    //STARTS - Placement of products in pages as per the lines count
    $lines_per_page = "12";
    $prod_cnt = 0;
    $num_pages = ceil($lines / $lines_per_page);
    $tmp = 0;
    for ($count = 0; $count < $num_pages; $count++) {
        for ($k = $tmp; $k < $j; $k++) {
            if ($prod_cnt != 12) {
                $products[$count][] = $k;
                $prod_cnt += $prod_line[$k];
            } else {
                $tmp = $k;
                $prod_cnt = 0;
                break;
            }
        }
    }
    //ENDS - Placement of products in pages as per the lines count
    $current_product = 0;
    for ($l = 0; $l < $num_pages; $l++) {
        $line = array();
        if ($num_pages == $page_num) {
            $lastpage = 1;
        }
        /*while($current_product != $page_num*$products_per_page)
        		{
        			$line[]=$product_line[$current_product];
        			$current_product++;
        		}/*/
        foreach ($products[$l] as $index => $key) {
            $line[] = $product_line[$key];
        }
        $pdf->AddPage();
        include "modules/Quotes/pdf_templates/header.php";
        include "include/tcpdf/templates/body.php";
        //if bottom > 145 then we skip the Description and T&C in every page and display only in lastpage
        //if you want to display the description and T&C in each page then set the display_desc_tc='true' and bottom <= 145 in pdfconfig.php
        if ($display_desc_tc == 'true') {
            if ($bottom <= 145) {
                include "modules/Quotes/pdf_templates/footer.php";
            }
        }
        $page_num++;
        if ($endpage && $lastpage) {
            $pdf->AddPage();
            include "modules/Quotes/pdf_templates/header.php";
            include "modules/Quotes/pdf_templates/lastpage/body.php";
            include "modules/Quotes/pdf_templates/lastpage/footer.php";
        }
    }
    return $pdf;
}
Example #15
0
<?php

/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2048 $
 */
define('CURSCRIPT', 'quote');
require "../libraries/common.inc.php";
require "../share.inc.php";
uses("quote");
$quote = new Quotes();
$condition = null;
$conditions = array();
$tpl_file = "market/quote";
$viewhelper->setTitle(L("price_quotes", "tpl"));
$viewhelper->setPosition(L("price_quotes", "tpl"), "market/quote.php");
if (isset($_GET['id'])) {
    $id = intval($_GET['id']);
}
if (isset($_GET['action'])) {
    $action = trim($_GET['action']);
    switch ($action) {
        case "data":
            if (!empty($_GET['type'])) {
                $type = trim($_GET['type']);
                if ($type == "price") {
                    $info = $pdb->GetRow("SELECT * FROM " . $tb_prefix . "productprices WHERE id=" . $id);
                    $time_limit = strtotime("-1 month");
                    if (!empty($info)) {
Example #16
0
$keywords = '';
$description = '';
include "/srv/athenace/lib/shared/common.php";
include "/srv/athenace/lib/intranet/common.php";
include "/srv/athenace/lib/shared/functions_form.php";
$fields = array("content", "custid", "price", "contactsid", "staffid", "notes");
foreach ($fields as $field) {
    if (!isset($_POST[$field])) {
        $_POST[$field] = '';
    }
}
// Check if we have Form Data to process
if (isset($_GET['go']) && $_GET['go'] == "y") {
    $logContent = "\n";
    // Insert into DB
    $quotesNew = new Quotes();
    $quotesNew->setCustid($_POST['custid']);
    $quotesNew->setIncept(time());
    $quotesNew->setContent($_POST['content']);
    $quotesNew->setPrice($_POST['price']);
    $quotesNew->setNotes($_POST['notes']);
    $quotesid = $quotesNew->insertIntoDB();
    $logresult = logEvent(1, $logContent);
    header("Location: /quotes/?id=" . $quotesid);
    exit;
}
// Define elements for the HTML Header include
$pagescript = array('/pub/js/jquery.js');
$pagestyle = array();
include "../tmpl/header.php";
?>
Example #17
0
    /**
     * Static function to display form for the field type
     * @param string $name
     * @param string $value
     * @param string $css
     * @return html for the form containing the field
     */
    public static function display_field($name, $value = '', $css = 'form-control input-sm')
    {
        $html = '';
        $display_val = '';
        if ((int) $value > 0) {
            $object = new Quotes();
            $retrun_fields = $object->popup_selection_return_field;
            $retrun_field_list = explode(",", $retrun_fields);
            $object->query("select " . $retrun_fields . " from `sales_order` where `idsales_order` = ?", array($value));
            if ($object->getNumRows() > 0) {
                $object->next();
                $cnt_return_fields = 0;
                foreach ($retrun_field_list as $retrun_fields) {
                    if ($cnt_return_fields > 0) {
                        $display_val .= ' ';
                    }
                    $display_val .= $object->{$retrun_fields};
                    $cnt_return_fields++;
                }
            }
        }
        $special_field = false;
        if (preg_match("/:::/", $name)) {
            $name_explode = explode(':::', $name);
            $name = 'sales_order_' . $name_explode[1];
            $special_field = true;
        }
        $html .= '<input type="text" class = "' . $css . '" name="sales_order_' . $name . '" id="sales_order_' . $name . '" value="' . $display_val . '" readonly>';
        $html .= '&nbsp;&nbsp;<a href="#"  id="select_' . $name . '"  class="btn btn-primary btn-mini"><i class="glyphicon glyphicon-plus-sign"></i></a>';
        $html .= '&nbsp;&nbsp;<a href="#" id="remove_' . $name . '" class="btn btn-primary btn-mini"><i class="glyphicon glyphicon-remove"></i></a>';
        $html .= '<input type="hidden" name="' . $name . '" id="' . $name . '" value="' . $value . '">';
        $html .= "\n" . '<script>';
        // add icon click function
        $html .= '$(\'#select_' . $name . '\').click(function(){ ';
        if ($special_field === true) {
            $html .= 'var href = \'/popups/listdata_popup_modal?m=SalesOrder&action=list&fielddisp=sales_order&special_field=yes&special_field_name=' . $name_explode[1] . '&fieldname=' . $name . '\';';
        } else {
            $html .= 'var href = \'/popups/listdata_popup_modal?m=SalesOrder&action=list&fielddisp=sales_order&fieldname=' . $name . '\';';
        }
        $html .= "\n" . ' 
		if (href.indexOf(\'#\') == 0) {
				$(href).modal(\'open\');
		} else {
			$.get(href, function(data) {
				//ugly heck to prevent the content getting append when opening the same modal multiple time
				$("#listdata_popup_selector").html(\'\'); 
				$("#listdata_popup_selector").attr("id","ugly_heck");
				$(\'<div class="modal fade" tabindex="-1" role="dialog" id="listdata_popup_selector">\' + data + \'</div>\').modal();
			}).success(function() { $(\'input:text:visible:first\').focus(); });
		}
		';
        $html .= "\n" . '});';
        // click function ends here
        // remove icon click function
        if ($special_field === true) {
            $html .= "\n" . '$(\'#remove_' . $name . '\').click( function(){
				$("#sales_order_' . $name . '").attr(\'value\',\'\');
				$("#' . $name . '").attr(\'value\',\'\');
				$("#' . $name_explode[1] . '").attr(\'value\',\'\');
			});';
        } else {
            $html .= "\n" . '$(\'#remove_' . $name . '\').click( function(){
				$("##sales_order_' . $name . '").attr(\'value\',\'\');
				$("#' . $name . '").attr(\'value\',\'\');
			});';
        }
        // remove icon click function ends here
        $html .= '</script>';
        if ($special_field === true) {
            return $html;
        } else {
            echo $html;
        }
    }
Example #18
0
<?php

session_start();
$i = 0;
// table stripeys
$pass = "******";
require 'classes.php';
$Q = new Quotes();
include 'header.php';
include 'parserfuncs.php';
?>

<form method="post" class="parser" action="parser.php">

<?php 
echo $_SESSION['loggedin'] ? "<p class='logout'>LOGGED IN <input type='submit' name='logout' value='logout' /></p>" : "<p>You haz no permissionz</p>";
if ($_SESSION['loggedin']) {
    ?>
	<a href="parser.php">Start Fresh</a> <a href="fix.php">Update quotes</a><br /><br />
	<select name="term">
		<?php 
    defTerm();
    ?>
	</select>
	<input type="text" name="year" <?php 
    echo $_POST['year'] ? "value=\"" . $_POST['year'] . "\"" : "value=\"" . date('Y') . "\"";
    ?>
 size="5">
	<input type="checkbox" name="style" value="new" <?php 
    echo $_POST['style'] ? "checked" : "";
    ?>
Example #19
0
 /**
  * @covers Geissler\CSL\Rendering\Quotes::render
  */
 public function testRender2()
 {
     $this->initElement('<text />');
     $this->assertEquals('Hello World', $this->object->render('Hello World'));
 }
Example #20
0
<?php

/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
require "../libraries/common.inc.php";
uses("quote", "quotetype");
require LIB_PATH . 'page.class.php';
require LIB_PATH . 'cache.class.php';
require "session_cp.inc.php";
include CACHE_PATH . "cache_typeoption.php";
$marketquotes = new Quotes();
$quotetype = new Quotetypes();
$cache = new Caches();
$page = new Pages();
$conditions = array();
setvar("Measuries", $_PB_CACHE['measuring']);
setvar("Monetaries", $_PB_CACHE['monetary']);
$tpl_file = "quote";
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    if (!empty($_GET['id'])) {
        $id = intval($_GET['id']);
    }
    if ($do == "search") {
        if (isset($_GET['q'])) {
            $conditions[] = "title like '%" . trim($_GET['q']) . "%'";
        }
Example #21
0
    /**
     * function to generate inventory (quote,invoice,sales order,purchase order) PDF
     * @param integer $idquotes
     * @param boolean $save
     * @see http://www.mpdf1.com/mpdf/index.php
     */
    public function generate_inventory_pdf($idrecord, $idmodule, $save = false)
    {
        include_once BASE_PATH . THIRD_PARTY_LIB_PATH . "/mpdf/mpdf.php";
        //echo BASE_PATH.THIRD_PARTY_LIB_PATH ;exit;
        $pdf = new \mPDF();
        $crm_global_settings = new \CRMGlobalSettings();
        if ($idmodule == 13) {
            $obj = new \Quotes();
            $obj->getId($idrecord);
            $prefix = $crm_global_settings->get_setting_data_by_name('quote_num_prefix');
            $inventory_type = _('QUOTE');
            $inv = 'q';
            $inv_number_fld = 'quote_number';
            $inv_date_fld = 'valid_till';
            $file_name = 'Quote_' . $prefix . $obj->quote_number . '.pdf';
            $inventory_number = _('Quote #');
        } elseif ($idmodule == 14) {
            $obj = new \SalesOrder();
            $obj->getId($idrecord);
            $prefix = $crm_global_settings->get_setting_data_by_name('salesorder_num_prefix');
            $inventory_type = _('SALES ORDER');
            $inv = 'so';
            $inv_number_fld = 'sales_order_number';
            $inv_date_fld = 'due_date';
            $file_name = 'SalesOrder_' . $prefix . $obj->sales_order_number . '.pdf';
            $inventory_number = _('Sales Order #');
        } elseif ($idmodule == 15) {
            $obj = new \Invoice();
            $obj->getId($idrecord);
            $prefix = $crm_global_settings->get_setting_data_by_name('invoice_num_prefix');
            $inventory_type = _('INVOICE');
            $inv = 'inv';
            $inv_number_fld = 'invoice_number';
            $inv_date_fld = 'due_date';
            $file_name = 'Invoice_' . $prefix . $obj->invoice_number . '.pdf';
            $inventory_number = _('Invoice #');
        } elseif ($idmodule == 16) {
            $obj = new \PurchaseOrder();
            $obj->getId($idrecord);
            $prefix = $crm_global_settings->get_setting_data_by_name('purchaseorder_num_prefix');
            $inventory_type = _('PURCHASE ORDER');
            $inv = 'po';
            $inv_number_fld = 'po_number';
            $inv_date_fld = 'due_date';
            $file_name = 'PurchaseOrder_' . $prefix . $obj->po_number . '.pdf';
            $inventory_number = _('Purchase Order #');
        }
        $inventory_logo = $crm_global_settings->get_setting_data_by_name('inventory_logo');
        $company_address = $crm_global_settings->get_setting_data_by_name('company_address');
        $do_lineitems = new \Lineitems();
        $do_lineitems->get_line_items($idmodule, $idrecord);
        $lineitems = array();
        if ($do_lineitems->getNumRows() > 0) {
            while ($do_lineitems->next()) {
                $lineitems[] = array("idlineitems" => $do_lineitems->idlineitems, "item_type" => $do_lineitems->item_type, "item_name" => $do_lineitems->item_name, "item_value" => $do_lineitems->item_value, "item_description" => $do_lineitems->item_description, "item_quantity" => $do_lineitems->item_quantity, "item_price" => $do_lineitems->item_price, "discount_type" => $do_lineitems->discount_type, "discount_value" => $do_lineitems->discount_value, "discounted_amount" => $do_lineitems->discounted_amount, "tax_values" => $do_lineitems->tax_values, "taxed_amount" => $do_lineitems->taxed_amount, "total_after_discount" => $do_lineitems->total_after_discount, "total_after_tax" => $do_lineitems->total_after_tax, "net_total" => $do_lineitems->net_total);
            }
        }
        $html = '';
        if (is_array($lineitems) && count($lineitems) > 0) {
            //--load the stylesheet
            $stylesheet = file_get_contents(BASE_PATH . '/themes/custom-css/inventory_export.css');
            $pdf->WriteHTML($stylesheet, 1);
            $html .= '
			<div>
				<div class="inv_wrapper">
					<h1 class="inv_heading">' . $inventory_type . '</h1>
					<div class="inv_address_wrapper">
						<p class="inv_address_section">
							<span class="inv_address_to_from">FROM:</span><br>
							' . nl2br($company_address) . '
						</p>
					</div>
					<div class="inv_company_address_wrapper">
						<img class="inv_company_address_logo" src="' . $GLOBALS['FILE_UPLOAD_DISPLAY_PATH'] . '/' . $inventory_logo . '">
					</div>
				</div>
				<div style="clear:both;"></div>
				<div class="inv_wrapper">
				<div class="inv_address_wrapper">
					<p class="inv_address_section">
						<span class="inv_address_to_from">To:</span><br>' . $this->generate_to_address($obj, $inv) . '
					</p>
				</div>
				<div class="inv_brief_section">
					<table class="inv_brief_section_table">
						<tr>
							<th class="inv_brief_section_table_heading">
								<span>' . $inventory_number . '</span>
							</th>
							<td class="inv_brief_section_table_content">
								<span>' . $prefix . $obj->{$inv_number_fld} . '</span>
							</td>
						</tr>
						<tr>
							<th class="inv_brief_section_table_heading">
								<span>Date</span>
							</th>
							<td class="inv_brief_section_table_content">
								<span>' . \FieldType9::display_value($obj->{$inv_date_fld}) . '</span>
							</td>
						</tr>
						<tr>
							<th class="inv_brief_section_table_heading">
								<span>Amount Due</span>
							</th>
							<td class="inv_brief_section_table_content">
								<span>' . \FieldType30::display_value($obj->grand_total) . '</span>
							</td>
						</tr>
					</table>
				</div>
			</div>
			<div style="clear:both;"></div>
			<br>
			';
            $html .= '
			<table class="inv_line_table">
				<thead>
					<tr>
						<th class="inv_line_table_header inv_line_table_header_width_30">
							<span>Item Name</span>
						</th>
						<th class="inv_line_table_header inv_line_table_header_width_10">
							<span>Qty</span>
						</th>
						<th class="inv_line_table_header inv_line_table_header_width_30">
							<span>Price</span>
						</th>
						<th class="inv_line_table_header inv_line_table_header_width_15">
							<span>Total</span>
						</th>
						<th class="inv_line_table_header inv_line_table_header_width_15">
							<span>Net Price</span>
						</th>
					</tr>
				</thead>
			';
            $html .= '<tbody>';
            foreach ($lineitems as $key => $items) {
                $line_discount = '';
                if ($items["discount_type"] == 'direct') {
                    $line_discount = _('Discount') . '-' . \FieldType30::display_value($items["discount_value"]);
                } elseif ($items["discount_type"] == 'percentage') {
                    $line_discount = _('Discount') . '-' . $items["discount_value"] . ' %';
                } else {
                    $line_discount = _('Discount') . '-' . _('no discount');
                }
                $line_tax = '';
                if ($items["tax_values"] != '') {
                    $line_tax = ' - ' . rtrim($items["tax_values"], ',');
                } else {
                    $line_tax = ' - no tax';
                }
                $html .= '
				<tr>
					<td class="inv_line_table_content inv_line_table_content_vertical_top">
						<div class="inv_line_table_content_block">
							' . $items["item_name"] . ' <br><br>
							' . nl2br($items["item_description"]) . '
						</div>
					</td>
					<td class="inv_line_table_content inv_line_table_content_vertical_top">
						<div class="inv_line_table_content_block">
							' . \FieldType16::display_value($items["item_quantity"]) . '
						</div>
					</td>
					<td class="inv_line_table_content">
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["item_price"]) . '
						</div>
						<div class="inv_line_table_content_block">
							' . $line_discount . '
						</div>
						<div class="inv_line_table_content_block">
							<b>Total after discount</b>
						</div>
						<div class="inv_line_table_content_block">
							<b>Tax </b> ' . $line_tax . '
						</div>
					</td>
					<td class="inv_line_table_content">
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["item_price"] * $items["item_quantity"]) . '
						</div>
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["discounted_amount"]) . '
						</div>
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["total_after_discount"]) . '
						</div>
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["taxed_amount"]) . '
						</div>
					</td>
					<td class="inv_line_table_content inv_line_table_content_vertical_top">
						' . \FieldType30::display_value($items["net_total"]) . '
					</td>
				</tr>';
            }
            $html .= '
			</tbody></table>';
            $net_discount = '';
            if ($obj->discount_type == 'percentage') {
                $net_discount = $obj->discount_value . ' %';
            } elseif ($obj->discount_type == 'direct') {
                $net_discount = FieldType30::display_value($obj->discount_value);
            } else {
                $net_discount = _('no discount');
            }
            $net_tax = '';
            if ($obj->tax_values != '') {
                $net_tax = rtrim($obj->tax_values, ',');
            }
            $ship_hand_tax = '';
            if ($obj->shipping_handling_tax_values != '') {
                $ship_hand_tax = rtrim($obj->shipping_handling_tax_values, ',');
            }
            $final_adj = '';
            if ($obj->final_adjustment_type == 'add') {
                $final_adj = '(+)';
            } elseif ($obj->final_adjustment_type == 'deduct') {
                $final_adj = '(-)';
            }
            $html .= '
			<div style="clear:both;"></div>
			<br>
			<div class="inv_grand_total_section">
				<table class="inv_grand_total_table">
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Net Total</b></span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->net_total) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Discount -</b> ' . $net_discount . '</span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->discounted_amount) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Tax -</b> ' . $net_tax . ' </span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->taxed_amount) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Shipping/Handling charges</b></span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->shipping_handling_charge) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Shipping/Handling Tax -</b>' . $ship_hand_tax . '</span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->shipping_handling_taxed_amount) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Final Adjustment</b>' . $final_adj . '</span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->final_adjustment_amount) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Grand Total</span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->grand_total) . '</span>
						</td>
					</tr>
				</table>
			</div>
			<div style="clear:both;"></div>
			<br>
			<h3 class="inv_terms_cond_section">
				<span>Terms & Condition</span>
			</h3>
			<div style="top:2px;">
				<p>
					' . nl2br($obj->terms_condition) . '
				</p>
			</div></div>';
        }
        if (true === $save) {
            $pdf->WriteHTML($html);
            $pdf->Output(OUTBOUND_PATH . '/' . $file_name, 'F');
            return $file_name;
        } else {
            $pdf->WriteHTML($html, 2);
            $pdf->Output($file_name, 'D');
            exit;
        }
    }
Example #22
0
include "/srv/athenace/lib/shared/common.php";
include "/srv/athenace/lib/intranet/common.php";
include "/srv/athenace/lib/shared/functions_form.php";
if (!is_numeric($_GET['id'])) {
    header("Location: /quotes/?id=notFound");
    exit;
}
if (isset($_GET['go']) && $_GET['go'] == "y") {
    $quotesDelete = new Quotes();
    $quotesDelete->setQuotesid($_GET['id']);
    $quotesDelete->deleteFromDB();
    header("Location: /quotes/?ItemDeleted=y");
    exit;
}
include "../tmpl/header.php";
$quotes = new Quotes();
// Load DB data into object
$quotes->setQuotesid($_GET['id']);
$quotes->loadQuotes();
$all = $quotes->getAll();
if (isset($all)) {
    ?>

<div class="panel panel-info">
	<div class="panel-heading">
		<strong>Viewing <?php 
    echo $quotes->getQuotesid();
    ?>
</strong>
	</div>
	<div class="panel-body">
Example #23
0
 /** Get the announcements from the model
  * @access public
  * @return array
  */
 public function direct()
 {
     $announcements = new Quotes();
     return $announcements->getAnnouncements();
 }
Example #24
0
include "/srv/athenace/lib/shared/common.php";
include "/srv/athenace/lib/intranet/common.php";
include "/srv/athenace/lib/shared/functions_form.php";
if (!is_numeric($_GET['id'])) {
    header("Location: /quotes/?id=notFound");
    exit;
}
# Set up HTML Form input error array
# Check if we have Form Data to process
if (isset($_GET['go']) && $_GET['go'] == "y") {
    if (empty($errors)) {
        if ($_POST['live'] != 1) {
            $_POST['live'] = 0;
        }
        # Update DB
        $quotesUpdate = new Quotes();
        $quotesUpdate->setQuotesid($_GET['id']);
        $quotesUpdate->setLive($_POST['live']);
        $quotesUpdate->updateDB();
        $logContent = 'Changed Quote Status to ' . $input['live'];
        $logresult = logEvent(5, $logContent);
        header("Location: /quotes/view.php?id=" . $_GET['id']);
        exit;
    }
}
# Define  elements for the HTML Header include
$pagetitle = "Edit Quote";
$pagescript = array("/pub/calpop/calendar_eu.js");
$pagestyle = array("/css/calendar.css");
include "../tmpl/header.php";
$sqltext = "SELECT * FROM quotes WHERE quotesid=?";
Example #25
0
function createpdffile($idnumber, $purpose = '', $path = '', $current_id = '')
{
    require_once 'include/tcpdf/tcpdf.php';
    require_once 'include/tcpdf/config/tcpdf_config.php';
    require_once 'modules/Quotes/Quotes.php';
    require_once 'include/database/PearDatabase.php';
    require_once 'include/utils/InventoryUtils.php';
    require_once 'include/utils/PDFutils.php';
    require_once 'test/contact/bank.php';
    global $FOOTER_PAGE, $default_font, $font_size_footer, $NUM_FACTURE_NAME, $pdf_strings, $quote_no, $footer_margin;
    global $org_name, $org_address, $org_city, $org_code, $org_country, $org_irs, $org_taxid, $org_phone, $org_fax, $org_website;
    global $ORG_POSITION, $VAR_PAGE, $VAR_OF;
    //bank information - content
    global $bank_name, $bank_street, $bank_city, $bank_zip, $bank_country, $bank_account, $bank_routing, $bank_iban, $bank_swift;
    //bank information - labels from language files
    global $ACCOUNT_NUMBER, $ROUTING_NUMBER, $SWIFT_NUMBER, $IBAN_NUMBER;
    global $columns, $logoradio, $logo_name, $footerradio, $pageradio;
    global $adb, $app_strings, $focus, $current_user;
    $module = 'Quotes';
    //get bank information
    $bank_name = $bank_array['bank_name'];
    $bank_street = $bank_array['bank_street'];
    $bank_city = $bank_array['bank_city'];
    $bank_zip = $bank_array['bank_zip'];
    $bank_country = $bank_array['bank_country'];
    $bank_account = $bank_array['bank_account'];
    $bank_routing = $bank_array['bank_routing'];
    $bank_iban = $bank_array['bank_iban'];
    $bank_swift = $bank_array['bank_swift'];
    //get tax information
    $org_taxid = $tax_array['org_taxid'];
    $org_irs = $tax_array['org_irs'];
    //get the stored configuration values
    $pdf_config_details = getAllPDFDetails('Quotes');
    //set font
    $default_font = getTCPDFFontsname($pdf_config_details[fontid]);
    if ($default_font == '') {
        $default_font = 'freesans';
    }
    $font_size_header = $pdf_config_details[fontsizeheader];
    $font_size_address = $pdf_config_details[fontsizeaddress];
    $font_size_body = $pdf_config_details[fontsizebody];
    $font_size_footer = $pdf_config_details[fontsizefooter];
    //select comma or dot as numberformat
    //European Format
    $decimal_precision = 2;
    $decimals_separator = ',';
    $thousands_separator = '.';
    //US Format
    //$decimal_precision = 2;
    //$decimals_separator = '.';
    //$thousands_separator = ',';
    //get users data
    //select language file
    if (file_exists("modules/Quotes/language/" . $pdf_config_details[pdflang] . ".lang.pdf.php")) {
        include "modules/Quotes/language/" . $pdf_config_details[pdflang] . ".lang.pdf.php";
        $language = strtoupper(substr($pdf_config_details[pdflang], -2, 2));
    } else {
        include "modules/Quotes/language/en_us.lang.pdf.php";
        $language = "EN";
    }
    //internal number
    $id = $idnumber;
    //retreiving the quote info
    $focus = new Quotes();
    $focus->retrieve_entity_info($id, "Quotes");
    $account_name = decode_html(getAccountName($focus->column_fields[account_id]));
    $quote_no = $focus->column_fields['quote_no'];
    $sql = "select vtiger_currency_info.currency_symbol from vtiger_currency_info where vtiger_currency_info.id= " . $focus->column_fields['currency_id'];
    $currency_symbol = $adb->query_result($adb->query($sql), 0, 'currency_symbol');
    //get the quote date set
    $date_to_display_array = array(str_replace("-", ".", getDisplayDate(date("Y-m-d"))));
    $date_created = getDisplayDate($focus->column_fields["createdtime"]);
    $date_array = explode(" ", $date_created);
    $date_to_display_array[1] = str_replace("-", ".", $date_array[0]);
    $date_modified = getDisplayDate($focus->column_fields["modifiedtime"]);
    $date_array = explode(" ", $date_modified);
    $date_to_display_array[2] = str_replace("-", ".", $date_array[0]);
    $date_to_display = $date_to_display_array[$pdf_config_details[dateused]];
    //number of lines after headline
    $space_headline = $pdf_config_details[space_headline];
    //display logo?
    $logoradio = $pdf_config_details[logoradio];
    //display summary?
    $summaryradio = $pdf_config_details[summaryradio];
    //display footer?
    $footerradio = $pdf_config_details[footerradio];
    //display footer page number?
    $pageradio = $pdf_config_details[pageradio];
    // get company information from settings
    $add_query = "select * from vtiger_organizationdetails";
    $result = $adb->query($add_query);
    $num_rows = $adb->num_rows($result);
    if ($num_rows > 0) {
        $org_name = $adb->query_result($result, 0, "organizationname");
        $org_address = $adb->query_result($result, 0, "address");
        $org_city = $adb->query_result($result, 0, "city");
        $org_state = $adb->query_result($result, 0, "state");
        $org_country = $adb->query_result($result, 0, "country");
        $org_code = $adb->query_result($result, 0, "code");
        $org_phone = $adb->query_result($result, 0, "phone");
        $org_fax = $adb->query_result($result, 0, "fax");
        $org_website = $adb->query_result($result, 0, "website");
        $logo_name = $adb->query_result($result, 0, "logoname");
    }
    //get owner information
    $recordOwnerArr = getRecordOwnerId($_REQUEST['record']);
    foreach ($recordOwnerArr as $type => $id) {
        $ownertype = $type;
        $ownerid = $id;
    }
    if ($ownertype == 'Users') {
        // get owner information for user
        $sql = "SELECT * FROM vtiger_users,vtiger_crmentity WHERE vtiger_users.id = vtiger_crmentity.smownerid AND vtiger_crmentity.crmid = '" . $_REQUEST['record'] . "'";
        $result = $adb->query($sql);
        $owner_lastname = $adb->query_result($result, 0, 'last_name');
        $owner_firstname = $adb->query_result($result, 0, 'first_name');
        $owner_id = $adb->query_result($result, 0, 'smownerid');
        $owner_phone = $adb->query_result($result, 0, 'phone_work');
        $owner_title = decode_html(trim($adb->query_result($result, 0, 'title')));
    } else {
        // get owner information for Groups
        $sql = "SELECT * FROM vtiger_groups,vtiger_crmentity WHERE vtiger_groups.groupid  = vtiger_crmentity.smownerid AND vtiger_crmentity.crmid = '" . $_REQUEST['record'] . "'";
        $result = $adb->query($sql);
        $owner_lastname = '';
        $owner_firstname = $adb->query_result($result, 0, 'groupname');
        $owner_id = $adb->query_result($result, 0, 'smownerid');
        $owner_phone = $org_phone;
        $owner_title = '';
    }
    //display owner?
    $owner = $pdf_config_details['owner'];
    //display owner phone#?
    $ownerphone = $pdf_config_details['ownerphone'];
    //to display at product description based on tax type
    $gproddetailarray = array($pdf_config_details[gprodname], $pdf_config_details[gproddes], $pdf_config_details[gprodcom]);
    $gproddetails = 0;
    foreach ($gproddetailarray as $key => $value) {
        if ($value == 'true') {
            if ($key == 0) {
                $gproddetails = $gproddetails + 1;
            } else {
                $gproddetails = $gproddetails + $key * 2;
            }
        }
    }
    $iproddetails = 0;
    $iproddetailarray = array($pdf_config_details[iprodname], $pdf_config_details[iproddes], $pdf_config_details[iprodcom]);
    foreach ($iproddetailarray as $key => $value) {
        if ($value == 'true') {
            if ($key == 0) {
                $iproddetails = $iproddetails + 1;
            } else {
                $iproddetails = $iproddetails + $key * 2;
            }
        }
    }
    // Quote Requisition Nummer
    $subject = $focus->column_fields[requisition_no];
    if ($focus->column_fields["hdnTaxType"] == "individual") {
        $product_taxes = 'true';
    } else {
        $product_taxes = 'false';
    }
    // **************** BEGIN POPULATE DATA ********************
    $account_id = $focus->column_fields[account_id];
    $largeArray = $focus;
    $quote_id = $id;
    $valid_till = $focus->column_fields["validtill"];
    $valid_till = getDisplayDate($valid_till);
    $valid_till = str_replace("-", ".", $valid_till);
    $bill_street = decode_html($focus->column_fields["bill_street"]);
    $bill_city = decode_html($focus->column_fields["bill_city"]);
    $bill_state = decode_html($focus->column_fields["bill_state"]);
    $bill_code = decode_html($focus->column_fields["bill_code"]);
    $bill_country = decode_html($focus->column_fields["bill_country"]);
    //format contact name
    $contact_name = decode_html(getContactforPDF($focus->column_fields["contact_id"]));
    //get department of contact or account, contact wins
    $contact_department = '';
    //get contact department
    if (trim($focus->column_fields["contact_id"]) != '') {
        $sql = "select * from vtiger_contactdetails where contactid=" . $focus->column_fields["contact_id"];
        $result = $adb->query($sql);
        $contact_department = decode_html(trim($adb->query_result($result, 0, "department")));
        $contact_firstname = decode_html(trim($adb->query_result($result, 0, "firstname")));
        $contact_lastname = decode_html(trim($adb->query_result($result, 0, "lastname")));
        $contact_salutation = decode_html(trim($adb->query_result($result, 0, "salutation")));
    }
    //get account department
    if ($contact_department == '') {
        $sql = "select * from vtiger_account where accountid=" . $account_id;
        $result = $adb->query($sql);
        $contact_department = decode_html(trim($adb->query_result($result, 0, "tickersymbol")));
    }
    $ship_street = $focus->column_fields["ship_street"];
    $ship_city = $focus->column_fields["ship_city"];
    $ship_state = $focus->column_fields["ship_state"];
    $ship_code = $focus->column_fields["ship_code"];
    $ship_country = $focus->column_fields["ship_country"];
    // condition field for last page
    $conditions = decode_html($focus->column_fields["terms_conditions"]);
    // description field for first page
    $description = decode_html($focus->column_fields["description"]);
    // ************************ BEGIN POPULATE DATA ***************************
    //get the Associated Products for this Quote
    $focus->id = $focus->column_fields["record_id"];
    $associated_products = getAssociatedProducts("Quotes", $focus);
    $num_products = count($associated_products);
    //This $final_details array will contain the final total, discount, Group Tax, S&H charge, S&H taxes and adjustment
    $final_details = $associated_products[1]['final_details'];
    //getting the Net Total
    $price_subtotal = $final_details["hdnSubTotal"];
    $price_subtotal_formated = number_format($price_subtotal, $decimal_precision, $decimals_separator, $thousands_separator);
    //Final discount amount/percentage
    $discount_amount = $final_details["discount_amount_final"];
    $discount_percent = $final_details["discount_percentage_final"];
    if ($discount_amount != "") {
        $price_discount = $discount_amount;
        $price_discount_formated = number_format($price_discount, $decimal_precision, $decimals_separator, $thousands_separator);
    } else {
        if ($discount_percent != "") {
            //This will be displayed near Discount label
            $final_price_discount_percent = "(" . number_format($discount_percent, $decimal_precision, $decimals_separator, $thousands_separator) . " %)";
            $price_discount = $discount_percent * $final_details["hdnSubTotal"] / 100;
            $price_discount_formated = number_format($price_discount, $decimal_precision, $decimals_separator, $thousands_separator);
        } else {
            $price_discount = "0.00";
        }
    }
    //Adjustment
    $price_adjustment = $final_details["adjustment"];
    $price_adjustment_formated = number_format($price_adjustment, $decimal_precision, $decimals_separator, $thousands_separator);
    //Grand Total
    $price_total = $final_details["grandTotal"];
    $price_total_formated = number_format($price_total, $decimal_precision, $decimals_separator, $thousands_separator);
    //To calculate the group tax amount
    if ($final_details['taxtype'] == 'group') {
        $group_tax_total = $final_details['tax_totalamount'];
        $price_salestax = $group_tax_total;
        $price_salestax_formated = number_format($price_salestax, $decimal_precision, $decimals_separator, $thousands_separator);
        $group_total_tax_percent = '0.00';
        $group_tax_details = $final_details['taxes'];
        for ($i = 0; $i < count($group_tax_details); $i++) {
            $group_total_tax_percent = $group_total_tax_percent + $group_tax_details[$i]['percentage'];
        }
    }
    //S&H amount
    $sh_amount = $final_details['shipping_handling_charge'];
    $price_shipping_formated = number_format($sh_amount, $decimal_precision, $decimals_separator, $thousands_separator);
    //S&H taxes
    $sh_tax_details = $final_details['sh_taxes'];
    $sh_tax_percent = '0.00';
    for ($i = 0; $i < count($sh_tax_details); $i++) {
        $sh_tax_percent = $sh_tax_percent + $sh_tax_details[$i]['percentage'];
    }
    $sh_tax_amount = $final_details['shtax_totalamount'];
    $price_shipping_tax = number_format($sh_tax_amount, $decimal_precision, $decimals_separator, $thousands_separator);
    //to calculate the individuel tax amounts included we should get all available taxes and then retrieve the corresponding tax values
    $tax_details = getAllTaxes('available');
    $numer_of_tax_types = count($tax_details);
    for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
        $taxtype_listings[taxname . $tax_count] = $tax_details[$tax_count]['taxname'];
        $taxtype_listings[percentage . $tax_count] = $tax_details[$tax_count]['percentage'];
        $taxtype_listings[value . $tax_count] = '0';
    }
    //This is to get all prodcut details as row basis
    for ($i = 1, $j = $i - 1; $i <= $num_products; $i++, $j++) {
        $product_code[$i] = $associated_products[$i]['hdnProductcode' . $i];
        $product_name[$i] = decode_html($associated_products[$i]['productName' . $i]);
        $prod_description[$i] = decode_html($associated_products[$i]['productDescription' . $i]);
        $qty[$i] = $associated_products[$i]['qty' . $i];
        $qty_formated[$i] = number_format($associated_products[$i]['qty' . $i], $decimal_precision, $decimals_separator, $thousands_separator);
        $comment[$i] = decode_html($associated_products[$i]['comment' . $i]);
        $unit_price[$i] = number_format($associated_products[$i]['unitPrice' . $i], $decimal_precision, $decimals_separator, $thousands_separator);
        $list_price[$i] = number_format($associated_products[$i]['listPrice' . $i], $decimal_precision, $decimals_separator, $thousands_separator);
        $list_pricet[$i] = $associated_products[$i]['listPrice' . $i];
        $discount_total[$i] = $associated_products[$i]['discountTotal' . $i];
        $discount_totalformated[$i] = number_format($associated_products[$i]['discountTotal' . $i], $decimal_precision, $decimals_separator, $thousands_separator);
        //added by crm-now
        $usageunit[$i] = $associated_products[$i]['usageunit' . $i];
        //look whether the entry already exists, if the translated string is available then the translated string other wise original string will be returned
        $usageunit[$i] = getTranslatedString($usageunit[$i], 'Products');
        $taxable_total = $qty[$i] * $list_pricet[$i] - $discount_total[$i];
        $producttotal = $taxable_total;
        $total_taxes = '0.00';
        if ($focus->column_fields["hdnTaxType"] == "individual") {
            $total_tax_percent = '0.00';
            //This loop is to get all tax percentage and then calculate the total of all taxes
            for ($tax_count = 0; $tax_count < count($associated_products[$i]['taxes']); $tax_count++) {
                $tax_percent = $associated_products[$i]['taxes'][$tax_count]['percentage'];
                $total_tax_percent = $total_tax_percent + $tax_percent;
                $tax_amount = $taxable_total * $tax_percent / 100;
                //calculate the tax amount for any available tax percentage
                $detected_tax = substr(array_search($total_tax_percent, $taxtype_listings), -1);
                $taxtype_listings[value . $detected_tax] = $taxtype_listings[value . $detected_tax] + $tax_amount;
                $total_taxes = $total_taxes + $tax_amount;
            }
            $producttotal = $taxable_total + $total_taxes;
            $product_line[$j][$pdf_strings['Tax']] = " ({$total_tax_percent} %) " . number_format($total_taxes, $decimal_precision, $decimals_separator, $thousands_separator);
            // combine product name, description and comment to one field based on settings
        }
        // combine product name, description and comment to one field based on settings
        if ($focus->column_fields["hdnTaxType"] == "individual") {
            $product_selection = $iproddetails;
        } else {
            $product_selection = $gproddetails;
        }
        switch ($product_selection) {
            case 1:
                $product_name_long[$i] = $product_name[$i];
                break;
            case 2:
                $product_name_long[$i] = $prod_description[$i];
                break;
            case 3:
                $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i];
                break;
            case 4:
                $product_name_long[$i] = $comment[$i];
                break;
            case 5:
                $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i];
                break;
            case 6:
                if ($prod_description[$i] != '') {
                    $product_name_long[$i] = $prod_description[$i] . "\n" . $comment[$i];
                } else {
                    $product_name_long[$i] = $comment[$i];
                }
                break;
            case 7:
                if ($prod_description[$i] != '') {
                    $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i] . "\n" . $comment[$i];
                } else {
                    $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i];
                }
                break;
            default:
                if ($prod_description[$i] != '') {
                    $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i] . "\n" . $comment[$i];
                } else {
                    $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i];
                }
                break;
        }
        $prod_total[$i] = number_format($producttotal, $decimal_precision, $decimals_separator, $thousands_separator);
        $product_line[$j][$pdf_strings['Position']] = $j + 1;
        $product_line[$j][$pdf_strings['OrderCode']] = $product_code[$i];
        $product_line[$j][$pdf_strings['Description']] = $product_name_long[$i];
        $product_line[$j][$pdf_strings['Qty']] = $qty_formated[$i];
        $product_line[$j][$pdf_strings['Unit']] = $usageunit[$i];
        $product_line[$j][$pdf_strings['UnitPrice']] = $list_price[$i];
        $product_line[$j][$pdf_strings['Discount']] = $discount_totalformated[$i];
        $product_line[$j][$pdf_strings['LineTotal']] = $prod_total[$i];
    }
    //Population of current date
    $addyear = strtotime("+0 year");
    if ($purpose == 'customerportal') {
        $dat_fmt = $owner_id->date_format == '' ? 'dd-mm-yyyy' : $owner_id->date_format;
    } else {
        $dat_fmt = $current_user->date_format == '' ? 'dd-mm-yyyy' : $current_user->date_format;
    }
    $date_issued = $dat_fmt == 'dd-mm-yyyy' ? date('d-m-Y', $addyear) : ($dat_fmt == 'mm-dd-yyyy' ? date('m-d-Y', $addyear) : ($dat_fmt == 'yyyy-mm-dd' ? date('Y-m-d', $addyear) : ''));
    // ************************ END POPULATE DATA ***************************
    //************************BEGIN PDF FORMATING**************************
    // Extend the TCPDF class to create custom Header and Footer
    class MYPDF extends TCPDF
    {
        //modifiy tcpdf class footer
        public function Footer()
        {
            //To make the function Footer() work properly
            $this->AliasNbPages();
            if (!isset($this->original_lMargin)) {
                $this->original_lMargin = $this->lMargin;
            }
            if (!isset($this->original_rMargin)) {
                $this->original_rMargin = $this->rMargin;
            }
            include "modules/Quotes/pdf_templates/footer.php";
        }
    }
    $page_num = '1';
    // create new PDF document
    //$pdf = new PDF( 'P', 'mm', 'A4' );
    $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
    // set font
    $pdf->SetFont($default_font, " ", $default_font_size);
    $pdf->setPrintHeader(0);
    //header switched off permanently
    // auto break on
    //$pdf->SetAutoPageBreak(true);
    // set footer fonts
    //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    //set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    // set pdf information
    $pdf->SetTitle($pdf_strings['FACTURE'] . ": " . $account_name);
    $pdf->SetAuthor($owner_firstname . " " . $owner_lastname . ", " . $org_name);
    $pdf->SetSubject($account_name);
    $pdf->SetCreator('PDF Creator from www.crm-now.com');
    //list product names as keywords
    $productlisting = implode(", ", $product_name);
    $pdf->SetKeywords($productlisting);
    //Disable automatic page break
    $pdf->SetAutoPageBreak(true, PDF_MARGIN_FOOTER);
    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    //set some language-dependent strings
    $pdf->setLanguageArray($l);
    //initialize document
    $pdf->AliasNbPages();
    //in reference to body.php -> if a new page must be added if the space available for summary is too small
    $new_page_started = false;
    $pdf->AddPage();
    $pdf->setImageScale(1.5);
    //$pdf->SetY(PDF_MARGIN_HEADER);
    include "modules/Quotes/pdf_templates/header.php";
    $pdf->SetFont($default_font, " ", $font_size_body);
    include "modules/Quotes/pdf_templates/body.php";
    // issue pdf
    if ($purpose == 'print') {
        $pdf->Output($pdf_strings['FACTURE'] . '_' . $date_issued . '.pdf', 'D');
        exit;
    } elseif ($purpose == 'send') {
        // send pdf with mail
        switch ($language) {
            case "EN":
                $pdf->Output('storage/Quote_' . $_REQUEST['record'] . '.pdf', 'F');
                //added file name to make it work in IE, also forces the download giving the user the option to save
                break;
            case "DE":
                $pdf->Output('storage/Angebot_' . $_REQUEST['record'] . '.pdf', 'F');
                //added file name to make it work in IE, also forces the download giving the user the option to save
                break;
        }
        return;
        exit;
    } elseif ($purpose == 'customerportal') {
        $pdf->Output($path . $current_id . "_Quotes.pdf", 'F');
    }
}
Example #26
0
    $rand = array_rand($num_array);
    $faq->column_fields["product_id"] = $product_ids[$i];
    $faq->column_fields["faqcategories"] = "General";
    $faq->column_fields["faqstatus"] = $status_array[$i];
    $faq->column_fields["question"] = $question_array[$i];
    $faq->column_fields["faq_answer"] = $answer_array[$i];
    $faq->save("Faq");
    $faq_ids[] = $faq->id;
}
//Populate Quote Data
$sub_array = array("Prod_Quote", "Cont_Quote", "SO_Quote", "PO_Quote", "Vendor_Quote");
$stage_array = array("Created", "Reviewed", "Delivered", "Accepted", "Rejected");
$carrier_array = array("FedEx", "UPS", "USPS", "DHL", "BlueDart");
$validtill_array = array("2007-09-21", "2007-10-29", "2007-12-11", "2007-03-29", "2007-06-18");
for ($i = 0; $i < 5; $i++) {
    $quote = new Quotes();
    $quote->column_fields["assigned_user_id"] = $assigned_user_id;
    $account_key = array_rand($account_ids);
    $quote->column_fields["account_id"] = $account_ids[$account_key];
    $op_key = array_rand($opportunity_ids);
    $quote->column_fields["potential_id"] = $opportunity_ids[$op_key];
    $contact_key = array_rand($contact_ids);
    $quote->column_fields["contact_id"] = $contact_ids[$contact_key];
    $rand = array_rand($num_array);
    $quote->column_fields["subject"] = $sub_array[$i];
    $quote->column_fields["quotestage"] = $stage_array[$i];
    $quote->column_fields["carrier"] = $carrier_array[$i];
    $quote->column_fields["validtill"] = $validtill_array[$i];
    $quote->column_fields["bill_street"] = $street_address_array[rand(0, $street_address_count - 1)];
    $quote->column_fields["bill_city"] = $city_array[rand(0, $city_array_count - 1)];
    $quote->column_fields["bill_state"] = "CA";
Example #27
0
 function display()
 {
     $focus = new Tour();
     $quotes = new Quotes();
     global $sugar_config, $mod_strings, $timedate;
     $ss = new Sugar_Smarty();
     $db = DBManagerFactory::getInstance();
     // ONLY LOAD A RECORD IF A RECORD ID IS GIVEN;
     // A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR
     $record = isset($_GET["record"]) ? htmlspecialchars($_GET["record"]) : '';
     $department = isset($_GET["department"]) ? htmlspecialchars($_GET["department"]) : '';
     $template = file_get_contents('modules/Quotes/tpls/export.tpl');
     $quotes->retrieve($record);
     $focus->retrieve($quotes->quotes_toufa8brstours_idb);
     $content = $quotes->cost_detail;
     $content = base64_decode($content);
     $content = json_decode($content);
     $template = str_replace('{SITE_URL}', $sugar_config['site_url'], $template);
     if (!empty($focus->picture)) {
         $img = "<br/><img src='" . $sugar_config['site_url'] . "/modules/images/" . $focus->picture . "' width='600'/><br/><br/>";
     } else {
         $img = "";
     }
     $html = '';
     if ($quotes->department == 'dos') {
         $html .= '<table cellpadding="0" cellspacing="0" border="0" class="content1" align="center">';
         $html .= '<tr><td>&nbsp;&nbsp; </td> </tr>';
         $html .= '<tr><td align="center"><i>' . $mod_strings['LBL_MOD_STRING_DOS_HEAD'] . '</i></td> </tr>';
         $html .= '<tr><td align="center" style="font-size: 24px; color: blue">' . $focus->name . '</td></tr>';
         $html .= '<tr><td align="justify">' . $focus->description . ' </tr>';
         $html .= '<tr>';
         $html .= '<tr><td class="tabDetailViewDL" align="center">' . $img . '</td></tr>';
         $html .= '</tr>';
         $html .= '</table>';
         if (!empty($focus->start_date)) {
             $start_date = $timedate->to_display($focus->start_date, $timedate->get_date_format($current_user), 'd/m/Y');
             //                                    $start_date = date('d/m/Y',strtotime());
         } else {
             $start_date = '';
         }
         $html .= '<table align="center">';
         $html .= '<tr>';
         $html .= '<td class="tabDetailViewDL" align="left"><p>Thời gian : ' . $focus->duration . ' <br/> Mã tour: ' . $focus->tour_code . ' <br/> Phương tiện : ' . $focus->transport2 . ' <br/> Khởi hành : ' . $start_date . '<br/></p></td>';
         $html .= '</tr>';
         $html .= '</table><br/>';
         $template = str_replace('{HEAD}', $html, $template);
         $html = '';
         $cost_detail = $content->dos_cost_detail;
         if (count($cost_detail) > 0) {
             $html .= '<div id="dos" align="center"><table width="100%" class="table_clone" border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse">';
             $html .= '<thead>';
             $html .= '<tr height="15">';
             $html .= '<td class="tdborder" rowspan="2" style="text-align:center">' . $mod_strings['LBL_DOS_TICKET_VN'] . '</td>';
             $html .= '<td class="tdborder" colspan="2" style="text-align:center">' . $mod_strings['LBL_DOS_TOUR_COST_VN'] . '</td>';
             $html .= '<td class="tdborder" colspan="2" style="text-align:center">' . $mod_strings['LBL_DOS_SURCHANGE_VN'] . '</td>';
             $html .= '</tr>';
             $html .= '<tr height="15">';
             $html .= '<td class="tdborder" style="text-align:center">' . $mod_strings['LBL_DOS_FARE_VN'] . '</td>';
             $html .= '<td class="tdborder" style="text-align:center">' . $mod_strings['LBL_DOS_FACILITY_COST_VN'] . '</td>';
             $html .= '<td class="tdborder" style="text-align:center">' . $mod_strings['LBL_DOS_SINGLE_ROM_VN'] . '</td>';
             $html .= '<td class="tdborder" style="text-align:center">' . $mod_strings['LBL_DOS_FOREIGN_VN'] . '</td>';
             $html .= '</tr>';
             $html .= '</thead>';
             $html .= '<tbody>';
             if (count($cost_detail) > 0) {
                 foreach ($cost_detail as $val) {
                     $html .= '<tr height="15">';
                     $html .= '<td class="tdborder" align="center">' . translate('quotes_dos_hotel_standard', '', $val->dos_hotel_standard) . '</td>';
                     $html .= '<td class="tdborder" align="center">' . number_format($val->ticket_cost, 0, '', '.') . '</td>';
                     $html .= '<td class="tdborder" align="center">' . number_format($val->facility_cost, 0, '', '.') . '</td>';
                     $html .= '<td class="tdborder" align="center">' . number_format($val->single_room, 0, '', '.') . '</td>';
                     $html .= '<td class="tdborder" align="center">' . number_format($val->foreign, 0, '', '.') . '</td>';
                     $html .= '</tr>';
                 }
             }
             $html .= '</tbody>';
             $html .= '</table> </div> ';
             $template = str_replace('{COST_DETAIL}', $html, $template);
         }
         $html = '';
         $html .= '<h3 align="center">GIÁ TOUR TRỌN GÓI CHO CÁC DỊCH VỤ:</h3>';
         $html .= '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
         $html .= '<tr>';
         $html .= '<td align="justify"><h2><u><b>I. GIÁ TRÊN BAO GỒM:</b></u></h2></td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify"><u><b>Vận chuyển:</b></u><br/>' . html_entity_decode(nl2br($quotes->transport)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify"><u><b>Khách sạn:</b></u><br/>' . html_entity_decode(nl2br($quotes->hotel)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify"><u><b>Hướng dẫn viên</b></u>: <br/> ' . html_entity_decode(nl2br($quotes->guide)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify"><u><b>Tham quan</b></u><br/>' . html_entity_decode(nl2br($quotes->room)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify"><u><b>Ăn uống</b></u>: ' . html_entity_decode(nl2br($quotes->food)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify"><u><b>Bảo hiểm</b></u>: <br/>' . html_entity_decode(nl2br($quotes->insurance)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify"><u><b>Khăn, nón, nước và quà tặng</b></u>: <br/>' . html_entity_decode(nl2br($quotes->other)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<tr>';
         $html .= '<td>&nbsp;</td>';
         $html .= '</tr>';
         $html .= '<td align="justify"><h2><u><b>II. GIÁ TRÊN KHÔNG BAO GỒM :</b></u></h2></td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify">' . html_entity_decode(nl2br($quotes->not_content)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify"><h2><u><b>III.GIÁ TOUR DÀNH CHO TRẺ EM</b></u> :</h2></td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify">' . html_entity_decode(nl2br($quotes->child_cost)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="center"><h2>THÔNG TIN HƯỚNG DẪN</h2></td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify">' . html_entity_decode(nl2br($quotes->surcharge)) . '</td>';
         $html .= '</tr>';
         $html .= '</table>';
         $html .= '<p align="center"> <br/> <b>CARNIVAL TOURS HÂN HẠNH PHỤC VỤ QUÝ KHÁCH</b> </p>';
         $template = str_replace('{DETAIL}', $html, $template);
     } elseif ($quotes->department == 'ib') {
         $html .= '<p align="center" style="font-size: 24px;">&nbsp;</p>';
         $html .= '<p align="center" style="font-size: 24px; color: blue">' . $focus->name . '</p>';
         $html .= '<table>';
         $html .= '<tr><td class="tabDetailViewDL" align="center">' . $img . '</td></tr>';
         $html .= '</table>';
         $html .= '<table align="center" cellpadding="0" cellspacing="0">';
         $html .= '<tr> <td>Duration : </td> <td>' . $focus->duration . '</td></tr>';
         $html .= '<tr> <td>Code tour : </td> <td>' . $focus->tour_code . '</td></tr>';
         if (!empty($focus->start_date)) {
             $start_date = $timedate->to_display($focus->start_date, $timedate->get_date_format($current_user), 'd/m/Y');
             //                                    $start_date = date('d/m/Y',strtotime());
         } else {
             $start_date = '';
         }
         $html .= '<tr> <td>Start : </td> <td>' . $start_date . '</td></tr>';
         $html .= '<tr> <td>Transport : </td> <td>' . $focus->transport2 . '</td></tr>';
         //                $html .= '<tr> <td>Depart from : </td> <td>'.$focus->.'</td></tr>';
         $html .= '</table><br />';
         $template = str_replace("{HEAD}", $html, $template);
         $html = '';
         $cost_detail_head = $content->cost_detail_head;
         $ib_cose_detai = $content->ib_cose_detai;
         $html .= '<div id="inbound">';
         $html .= '<table width="100%" border="1" class="table_clone" cellspacing="0" cellpadding="2" style="border-collapse:collapse">';
         $html .= '<thead>';
         $html .= '<tr height="15">';
         $html .= '<td colspan="7" style="text-align:center" class="tdborder"><strong>' . $mod_strings['LBL_IB_TABLE_TITLE'] . '</strong></td>';
         $html .= '</tr>';
         $html .= '<tr height="15">';
         $html .= '<td class="tdborder"><strong>' . $mod_strings['LBL_IB_GROUP_SIZE'] . '</strong></td>';
         $html .= '<td class="tdborder">' . $cost_detail_head->group_site1 . '</td>';
         $html .= '<td class="tdborder">' . $cost_detail_head->group_site2 . '</td>';
         $html .= '<td class="tdborder">' . $cost_detail_head->group_site3 . '</td>';
         $html .= '<td class="tdborder">' . $cost_detail_head->group_site4 . '</td>';
         $html .= '<td class="tdborder">' . $cost_detail_head->group_site5 . '</td>';
         $html .= '<td class="tdborder">' . $cost_detail_head->group_site6 . '</td>';
         $html .= '</tr>';
         $html .= '</thead>';
         $html .= '<tbody>';
         if (count($ib_cose_detai) > 0) {
             foreach ($ib_cose_detai as $val) {
                 $html .= '<tr height="15">';
                 $html .= '<td class="tdborder">' . translate('quotes_ib_hotel_standard', '', $val->ib_hotel_standard) . '</td>';
                 $html .= '<td class="tdborder">' . $val->group_site1_cost . '</td>';
                 $html .= '<td class="tdborder">' . $val->group_site2_cost . '</td>';
                 $html .= '<td class="tdborder">' . $val->group_site3_cost . '</td>';
                 $html .= '<td class="tdborder">' . $val->group_site4_cost . '</td>';
                 $html .= '<td class="tdborder">' . $val->group_site5_cost . '</td>';
                 $html .= '<td class="tdborder">' . $val->group_site6_cost . '</td>';
                 $html .= '</tr>';
             }
         }
         $html .= '</tbody>';
         $html .= '</table>';
         $html .= '</div>';
         $template = str_replace('{COST_DETAIL}', $html, $template);
         $html = '';
         $html .= '<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse">';
         $html .= '<tr bgcolor="#CCCCCC">';
         $html .= '<td align="center">' . $mod_strings['LBL_IB_INCLUDE'] . '</td>';
         $html .= '<td align="center">' . $mod_strings['LBL_IB_EXCLUDE'] . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="justify">' . html_entity_decode_utf8(nl2br($quotes->ib_include)) . '</td>';
         $html .= '<td align="justify">' . html_entity_decode_utf8(nl2br($quotes->not_content)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr bgcolor="#CCCCCC">';
         $html .= '<td colspan="2" align="center">' . $mod_strings['LBL_IB_EXPORT_HOTEL'] . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td colspan="2" align="justify">' . html_entity_decode_utf8(nl2br($quotes->hotel)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr bgcolor="#CCCCCC" align="justify">';
         $html .= '<td colspan="2" align="center">' . $mod_strings['LBL_IB_EXPORT_SURCHARGE'] . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td colspan="2" align="justify">' . html_entity_decode_utf8(nl2br($quotes->surcharge)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr bgcolor="#CCCCCC">';
         $html .= '<td colspan="2" align="center">' . $mod_strings['LBL_IB_EXPORT_CHILD_POLICY'] . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td colspan="2" align="justify">' . html_entity_decode_utf8(nl2br($quotes->child_cost)) . '</td>';
         $html .= '</tr>';
         $html .= '</table>';
         $html .= '<p> &nbsp;</p>';
         $html .= '<p align="center">CARNIVAL TOURS – WITH YOU ALL THE WAY!</p>';
         $template = str_replace('{DETAIL}', $html, $template);
     } elseif ($quotes->department == 'ob') {
         $html .= '<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse">';
         $html .= '<tr><td><br /><br /><br /></td> </tr>';
         $html .= '<tr>';
         $html .= '<td align="center">Chương trình du lịch</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="center"><p align="center" style="font-size: 24px; color: blue">' . $focus->name . '</p></td>';
         $html .= '</tr>';
         $html .= '<tr><td class="tabDetailViewDL" align="center">' . $img . '</td></tr>';
         $html .= '<tr>';
         $html .= '<td>';
         $html .= '<table align="center" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse">';
         $html .= '<tr>';
         $html .= '<td align="left">Thời gian : ' . $focus->duration . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="left">Tour Code : ' . $focus->tour_code . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         if (!empty($focus->start_date)) {
             $start_date = $timedate->to_display($focus->start_date, $timedate->get_date_format($current_user), 'd/m/Y');
             //                                    $start_date = date('d/m/Y',strtotime());
         } else {
             $start_date = '';
         }
         $html .= '<td align="left">Khởi hành : ' . $start_date . '</td>';
         $html .= '</tr>';
         $html .= '</table>';
         $html .= '</td>';
         $html .= '</tr>';
         $html .= '</table><br/>';
         $html .= '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse">';
         $html .= '<tr>';
         $html .= '<td> Lịch bay tham khảo </td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td> <br/>' . html_entity_decode_utf8(nl2br($quotes->flight_schedules)) . '</td>';
         $html .= '</tr>';
         $html .= '</table>';
         $template = str_replace("{HEAD}", $html, $template);
         $html = '';
         $ob_cost_detail = $content->ob_cost_detail;
         $html .= '<table width="100%" border="0" class="table_clone" cellspacing="0" cellpadding="2" style="border-collapse:collapse">';
         $html .= '<tr>';
         $html .= '<td align="center"><b>Giá: ' . $ob_cost_detail->price . ' ' . translate('currency_dom', '', $ob_cost_detail->currency) . ' + ' . $ob_cost_detail->tax . ' ' . translate('currency_dom', '', $ob_cost_detail->currency) . '(Thuế) = ' . $ob_cost_detail->total_price . ' ' . translate('currency_dom', '', $ob_cost_detail->currency) . ' </b></td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td align="center"><b>' . html_entity_decode_utf8(nl2br($ob_cost_detail->price_note)) . '</b></td>';
         $html .= '</tr>';
         $html .= '</table>';
         $template = str_replace('{COST_DETAIL}', $html, $template);
         $html = '';
         $html .= '<table cellspacing="0" cellpadding="0" border="0" style="border-collaspe:collapse" width="100%">';
         $html .= '<tr>';
         $html .= '<td> <u><b>' . $mod_strings['LBL_OB_INCLUDE_EXPORT'] . '</b></u><br/>' . html_entity_decode_utf8(nl2br($quotes->ib_include)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td><br/> <u><b>' . $mod_strings['LBL_OB_EXCLUDE_EXPORT'] . '</b></u><br/>' . html_entity_decode_utf8(nl2br($quotes->not_content)) . '</td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td><br/> <u><b>' . $mod_strings['LBL_OB_NOTE_EXPORT'] . '</b></u><br/>' . html_entity_decode_utf8(nl2br($quotes->ob_notes)) . '</td>';
         $html .= '</tr>';
         $html .= '</table>';
         $html .= '<p align="center"><font size="14pt">Carnival Tours Kính Chúc Quý Khách Một Chuyến Du Lịch Vui Vẻ. </p></p>';
         $template = str_replace('{DETAIL}', $html, $template);
     }
     $template = str_replace("{TOUR_PROGRAM_LINE_DETAIL}", html_entity_decode_utf8($focus->get_data_to_expor2word($focus->id)), $template);
     $size = strlen($template);
     $filename = $quotes->name . ".doc";
     ob_end_clean();
     header("Cache-Control: private");
     header("Content-Type: application/force-download;");
     header("Content-Disposition:attachment; filename=\"{$filename}\"");
     header("Content-length:{$size}");
     echo $template;
     ob_flush();
 }
Example #28
0
 function __construct($conx = NULL, $table_name = "")
 {
     parent::__construct($conx, $table_name);
 }