function createInvoice($salesorder_id)
{
    require_once 'include/utils/utils.php';
    require_once 'modules/SalesOrder/SalesOrder.php';
    require_once 'modules/Invoice/Invoice.php';
    require_once 'modules/Users/Users.php';
    global $log, $adb;
    global $current_user;
    // Payment duration in days
    $payment_duration_values = array('net 01 day' => '1', 'net 05 days' => '5', 'net 07 days' => '7', 'net 10 days' => '10', 'net 15 days' => '15', 'net 30 days' => '30', 'net 45 days' => '45', 'net 60 days' => '60');
    if (!$current_user) {
        $current_user = Users::getActiveAdminUser();
    }
    $so_focus = new SalesOrder();
    $so_focus->id = $salesorder_id;
    $so_focus->retrieve_entity_info($salesorder_id, "SalesOrder");
    foreach ($so_focus->column_fields as $fieldname => $value) {
        $so_focus->column_fields[$fieldname] = decode_html($value);
    }
    $focus = new Invoice();
    // This will only fill in the basic columns from SO to Invoice and also Update the SO id in new Invoice
    $focus = getConvertSoToInvoice($focus, $so_focus, $salesorder_id);
    // Pick up the Payment due date based on the Configuration in SO
    $payment_duration = $so_focus->column_fields['payment_duration'];
    $due_duration = $payment_duration_values[trim(strtolower($payment_duration))];
    $durationinsec = mktime(0, 0, 0, date('m'), date('d') + $due_duration, date('Y'));
    // Cleanup focus object, to duplicate the Invoice.
    $focus->id = '';
    $focus->mode = '';
    $focus->column_fields['invoicestatus'] = $so_focus->column_fields['invoicestatus'];
    $focus->column_fields['invoicedate'] = date('Y-m-d');
    $focus->column_fields['duedate'] = date('Y-m-d', $durationinsec);
    // Additional SO fields to copy -> Invoice field name mapped to equivalent SO field name
    $invoice_so_fields = array('txtAdjustment' => 'txtAdjustment', 'hdnSubTotal' => 'hdnSubTotal', 'hdnGrandTotal' => 'hdnGrandTotal', 'hdnTaxType' => 'hdnTaxType', 'hdnDiscountPercent' => 'hdnDiscountPercent', 'hdnDiscountAmount' => 'hdnDiscountAmount', 'hdnS_H_Amount' => 'hdnS_H_Amount', 'assigned_user_id' => 'assigned_user_id', 'currency_id' => 'currency_id', 'conversion_rate' => 'conversion_rate');
    foreach ($invoice_so_fields as $invoice_field => $so_field) {
        $focus->column_fields[$invoice_field] = $so_focus->column_fields[$so_field];
    }
    $focus->_salesorderid = $salesorder_id;
    $focus->_recurring_mode = 'recurringinvoice_from_so';
    $focus->save("Invoice");
}
 function buildDocumentModel()
 {
     global $app_strings;
     try {
         $model = parent::buildDocumentModel();
         $this->generateEntityModel($this->focus, 'Consignment', 'consignment_', $model);
         $entity = new SalesOrder();
         if ($this->focusColumnValue('salesorder_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('salesorder_id'), 'SalesOrder');
         }
         $this->generateEntityModel($entity, 'SalesOrder', 'salesorder_', $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('consignment_no', $this->focusColumnValue('consignment_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;
     }
 }
Пример #3
0
 public function run()
 {
     $this->render('StoreCase', array('actives' => Product::model()->actives, 'income' => SalesOrder::model()->overallTotal, 'expenses' => DeliveryOrder::model()->overallTotal, 'currency' => Yii::app()->params['currency']));
 }
Пример #4
0
 function insertSalesOrder($salesorderinf)
 {
     global $log;
     $log->debug("Entering into function insertSalesOrder()");
     global $adb;
     global $current_user;
     $focus = new SalesOrder();
     foreach ($salesorderinf as $key => $val) {
         $focus->column_fields[$key] = $val;
     }
     $focus->save("SalesOrder");
     //file_put_contents("D:\\abcde.txt",$salesorderinf['duedate']);
     $log->debug("Exit function insertSalesOrder()");
     return $focus->id;
 }
Пример #5
0
require_once 'include/utils/utils.php';
require_once 'modules/CustomView/CustomView.php';
require_once 'include/database/Postgres8.php';
global $app_strings, $mod_strings, $list_max_entries_per_page, $currentModule, $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty = new vtigerCRM_Smarty();
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'SalesOrder');
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
$focus = new SalesOrder();
// Initialize sort by fields
$focus->initSortbyField('SalesOrder');
// END
$other_text = array();
$url_string = '';
// assigning http url string
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']);
Пример #6
0
 /**
  * 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 SalesOrder();
         $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) {
                     $retval .= ' ';
                 }
                 $retval .= $object->{$retrun_fields};
                 $cnt_return_fields++;
             }
         }
     }
     return $retval;
 }
Пример #7
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/SalesOrder/SalesOrder.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, $SalesOrder_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 $VAR40_NAME, $VAR3_NAME, $VAR4_NAME, $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 = 'SalesOrder';
    //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('SalesOrder');
    //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 number format
    //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/SalesOrder/language/" . $pdf_config_details[pdflang] . ".lang.pdf.php")) {
        include "modules/SalesOrder/language/" . $pdf_config_details[pdflang] . ".lang.pdf.php";
        $language = strtoupper(substr($pdf_config_details[pdflang], -2, 2));
    } else {
        include "modules/SalesOrder/language/en_us.lang.pdf.php";
        $language = "EN";
    }
    //internal number
    $id = $idnumber;
    //retreiving the salesorder info
    $focus = new SalesOrder();
    $focus->retrieve_entity_info($_REQUEST['record'], "SalesOrder");
    $account_name = decode_html(getAccountName($focus->column_fields['account_id']));
    $SalesOrder_no = $focus->column_fields['salesorder_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 SO 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 customer sign?
    $clientid = $pdf_config_details['clientid'];
    //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;
            }
        }
    }
    // SO Requisition Nummer
    $requisition_no = $focus->column_fields['vtiger_purchaseorder'];
    // CustomerMark
    $customermark = $focus->column_fields['customerno'];
    if ($focus->column_fields['hdnTaxType'] == 'individual') {
        $product_taxes = 'true';
    } else {
        $product_taxes = 'false';
    }
    // **************** BEGIN POPULATE DATA ********************
    $account_id = $focus->column_fields[account_id];
    $so_id = $_REQUEST['record'];
    if ($focus->column_fields["quote_id"] != '') {
        $quote_name = getQuoteName($focus->column_fields["quote_id"]);
    } else {
        $quote_name = '';
    }
    $po_name = $focus->column_fields["vtiger_purchaseorder"];
    $subject = $focus->column_fields["subject"];
    $delivery_date = $focus->column_fields["duedate"];
    $delivery_date = str_replace("-", ".", getDisplayDate($delivery_date));
    $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 Sales Order
    $focus->id = $focus->column_fields["record_id"];
    $associated_products = getAssociatedProducts("SalesOrder", $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");
    $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/SalesOrder/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/SalesOrder/pdf_templates/header.php";
    $pdf->SetFont($default_font, " ", $font_size_body);
    include "modules/SalesOrder/pdf_templates/body.php";
    // issue pdf
    if ($purpose == 'print') {
        $pdf->Output($pdf_strings['FACTURE'] . '_' . $date_issued . '.pdf', 'D');
    } elseif ($purpose == 'send') {
        // send pdf with mail
        switch ($language) {
            case "EN":
                $pdf->Output('storage/SalesOrder_' . $_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/Bestellung_' . $_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;
}
Пример #8
0
} else {
    if (isset($_REQUEST['convertmode']) && $_REQUEST['convertmode'] == 'update_so_val') {
        //Updating the Selected SO 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 invoicedate vtiger_field
        if ($focus->column_fields['invoicedate'] != '') {
            $curr_due_date = $focus->column_fields['invoicedate'];
            $focus->column_fields['invoicedate'] = DateTimeField::convertToDBFormat($curr_due_date);
        }
        $soid = $focus->column_fields['salesorder_id'];
        $so_focus = new SalesOrder();
        $so_focus->id = $soid;
        $so_focus->retrieve_entity_info($soid, "SalesOrder");
        $focus = getConvertSoToInvoice($focus, $so_focus, $soid);
        // Reset the value w.r.t SalesOrder Selected
        $currencyid = $so_focus->column_fields['currency_id'];
        $rate = $so_focus->column_fields['conversion_rate'];
        //Added to display the SO's associated products -- when we select SO in New Invoice page
        if (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') {
            $associated_prod = getAssociatedProducts("SalesOrder", $so_focus, $focus->column_fields['salesorder_id']);
        }
        $smarty->assign("SALESORDER_ID", $focus->column_fields['salesorder_id']);
        $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
        $smarty->assign("MODE", $so_focus->mode);
        $smarty->assign("AVAILABLE_PRODUCTS", 'true');
    } elseif (isset($_REQUEST['convertmode']) && $_REQUEST['convertmode'] == 'potentoinvoice') {
function createInvoice($salesorder_id)
{
    require_once 'include/utils/utils.php';
    require_once 'modules/SalesOrder/SalesOrder.php';
    require_once 'modules/Invoice/Invoice.php';
    require_once 'modules/Accounts/Accounts.php';
    require_once 'modules/Users/Users.php';
    global $log, $adb;
    global $current_user;
    // Payment duration in days
    $payment_duration_values = array('net 01 day' => '1', 'net 05 days' => '5', 'net 07 days' => '7', 'net 10 days' => '10', 'net 15 days' => '15', 'net 30 days' => '30', 'net 45 days' => '45', 'net 60 days' => '60');
    if (!$current_user) {
        $current_user = Users::getActiveAdminUser();
    }
    //End if
    $so_focus = new SalesOrder();
    $so_focus->id = $salesorder_id;
    $so_focus->retrieve_entity_info($salesorder_id, "SalesOrder");
    //SalesOrderのデータ抽出
    foreach ($so_focus->column_fields as $fieldname => $value) {
        #	print $fieldname . " : " . $value. "<br />";
        $so_focus->column_fields[$fieldname] = decode_html($value);
    }
    //End foreach
    $account_id = $so_focus->column_fields[account_id];
    /** ▼ ** 顧客情報呼び出し ****/
    $ac_focus = new Accounts();
    $ac_focus->id = $account_id;
    #	print "アカウントID : ".$account_id."<br />";
    $ac_focus->retrieve_entity_info($account_id, "Accounts");
    foreach ($ac_focus->column_fields as $fieldname => $value) {
        $ac_focus->column_fields[$fieldname] = decode_html($value);
    }
    //End foreach
    /** ▲ ** 顧客情報呼び出し ****/
    $strPayDay = $ac_focus->column_fields[payday];
    $focus = new Invoice();
    // This will only fill in the basic columns from SO to Invoice and also Update the SO id in new Invoice
    $focus = getConvertSoToInvoice($focus, $so_focus, $salesorder_id);
    switch ($strPayDay) {
        case '翌々月10日(40日)':
            $durationinsec = date('Y-m', strtotime('+2 month' . $_POST[first_date])) . "-10";
            break;
        case '翌々月15日(45日)':
            $durationinsec = date('Y-m', strtotime('+2 month' . $_POST[first_date])) . "-15";
            break;
        case '翌々月末日(60日)':
            $durationinsec = date('Y-m-t', strtotime('+2 month' . $_POST[first_date]));
            break;
        case '3ヶ月後10日(100日)':
            $durationinsec = date('Y-m', strtotime('+3 month' . $_POST[first_date])) . "-10";
            break;
        case '翌月10日':
            $durationinsec = date('Y-m', strtotime('+1 month' . $_POST[first_date])) . "-10";
            break;
        case '翌月15日':
            $durationinsec = date('Y-m', strtotime('+1 month' . $_POST[first_date])) . "-15";
            break;
        case '翌月20日':
            $durationinsec = date('Y-m', strtotime('+1 month' . $_POST[first_date])) . "-20";
            break;
        case '翌月末(30日)':
            $durationinsec = date('Y-m-t', strtotime($_POST[first_date] . ' +1 month'));
            break;
    }
    //End switch
    // Pick up the Payment due date based on the Configuration in SO
    #	$payment_duration = $so_focus->column_fields['payment_duration'];
    #	$due_duration = $payment_duration_values[trim(strtolower($payment_duration))];
    #	$durationinsec = mktime(0,0,0,date('m'),date('d')+$due_duration,date('Y'));
    // Cleanup focus object, to duplicate the Invoice.
    $focus->id = '';
    $focus->mode = '';
    #	$focus->column_fields['invoicestatus'] = $so_focus->column_fields['invoicestatus'];
    $focus->column_fields['invoicestatus'] = "自動作成";
    $focus->column_fields['closing_week'] = $so_focus->column_fields['closing_week'];
    $focus->column_fields['invoicedate'] = date('Y-m-t', strtotime($_POST[first_date]));
    #	$focus->column_fields['duedate'] = date('Y-m-d', $durationinsec);
    if (preg_match('@\\-12\\-31@', $durationinsec)) {
        $focus->column_fields['duedate'] = '2015-12-28';
    } else {
        $focus->column_fields['duedate'] = $durationinsec;
    }
    //End if
    #	print "<p>受注実績番号 : ".$so_focus->column_fields['salesorder_no']."</p>";
    $focus->column_fields['salesorder_no'] = $so_focus->column_fields['salesorder_no'];
    #受注実績番号
    $focus->column_fields['salesamount'] = $so_focus->column_fields['salesamount'];
    #売上
    $focus->column_fields['amount'] = $so_focus->column_fields['amount'];
    #粗利
    if (preg_match('@\\((.*?)分\\)|((.*?)分)@', $so_focus->column_fields['description'])) {
        $focus->column_fields['description'] = $so_focus->column_fields['description'];
    } else {
        $focus->column_fields['description'] = "";
    }
    //End if
    $focus->column_fields['outcome'] = "固定";
    // Additional SO fields to copy -> Invoice field name mapped to equivalent SO field name
    $invoice_so_fields = array('txtAdjustment' => 'txtAdjustment', 'hdnSubTotal' => 'hdnSubTotal', 'hdnGrandTotal' => 'hdnGrandTotal', 'hdnTaxType' => 'hdnTaxType', 'hdnDiscountPercent' => 'hdnDiscountPercent', 'hdnDiscountAmount' => 'hdnDiscountAmount', 'hdnS_H_Amount' => 'hdnS_H_Amount', 'assigned_user_id' => 'assigned_user_id', 'currency_id' => 'currency_id', 'conversion_rate' => 'conversion_rate', 'division' => 'division', 'pre_tax_total' => 'pre_tax_total', 'balance' => 'hdnGrandTotal', 'margin_rate' => 'margin_rate');
    #	foreach($invoice_so_fields as $invoice_field => $so_field) {
    #		print $so_field." : ".$so_focus->column_fields[$so_field]."<br />";
    #	}//End foreach
    foreach ($invoice_so_fields as $invoice_field => $so_field) {
        $focus->column_fields[$invoice_field] = $so_focus->column_fields[$so_field];
    }
    //End foreach
    $focus->_salesorderid = $salesorder_id;
    $focus->_recurring_mode = 'recurringinvoice_from_so';
    $focus->save("Invoice");
}
Пример #10
0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *
 ********************************************************************************/
require_once 'include/CRMSmarty.php';
require_once 'modules/SalesOrder/SalesOrder.php';
//Redirecting Header for single page layout
require_once 'user_privileges/default_module_view.php';
global $singlepane_view;
if ($singlepane_view == 'true' && $_REQUEST['action'] == 'CallRelatedList') {
    header("Location:index.php?action=DetailView&module=" . $_REQUEST['module'] . "&record=" . $_REQUEST['record'] . "&parenttab=" . $_REQUEST['parenttab']);
} else {
    $focus = new SalesOrder();
    $currentmodule = $_REQUEST['module'];
    $RECORD = $_REQUEST['record'];
    if (isset($_REQUEST['record']) && isset($_REQUEST['record'])) {
        $focus->retrieve_entity_info($_REQUEST['record'], "SalesOrder");
        $focus->id = $_REQUEST['record'];
        $focus->name = $focus->column_fields['subject'];
        $log->debug("id is " . $focus->id);
        $log->debug("name is " . $focus->name);
    }
    global $mod_strings;
    global $app_strings, $currentModule;
    global $theme;
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $smarty = new CRMSmarty();
Пример #11
0
/**
 * Create SalesOrder entity
 * 
 * @param array $input_array    input data for salesorder
 */
function create_salesorder($input_array)
{
    require_once 'modules/SalesOrder/SalesOrder.php';
    global $adb, $log;
    $adb->println("Inside customer portal function create_salesorder");
    $adb->println($input_array);
    // Input parameters
    $id = $input_array['id'];
    $sessionid = $input_array['sessionid'];
    $title = $input_array['title'];
    $module = $input_array['module'];
    $salesorderid = $input_array['salesorderid'];
    $product_ids = explode('_', $input_array['product_ids']);
    global $current_user;
    $current_user->id = getPortalUserid();
    if (!validateSession($id, $sessionid)) {
        return null;
    }
    $user_editable_state = 'Created';
    $order = new SalesOrder();
    if ($salesorderid > 0) {
        $order->retrieve_entity_info($salesorderid, 'SalesOrder');
        if (strcmp($user_editable_state, $order->column_fields['sostatus']) != 0) {
            return null;
        }
        $order->mode = 'edit';
        $order->id = $salesorderid;
    } else {
        $account_id = get_account_id_by_contact_id($id);
        $order->column_fields['assigned_user_id'] = $current_user->id;
        $order->column_fields['account_id'] = $account_id;
        $order->column_fields['contact_id'] = $id;
        $order->column_fields['currency_id'] = 1;
        $order->column_fields['sostatus'] = $user_editable_state;
        $shipads = get_table_record_fields_values('vtiger_accountshipads', 'accountaddressid', $account_id);
        $order->column_fields['ship_city'] = $shipads['ship_city'];
        $order->column_fields['ship_street'] = $shipads['ship_street'];
        $order->column_fields['ship_code'] = $shipads['ship_code'];
        $order->column_fields['ship_state'] = $shipads['ship_state'];
        $order->column_fields['ship_country'] = $shipads['ship_country'];
        $order->column_fields['ship_pobox'] = $shipads['ship_pobox'];
        $billads = get_table_record_fields_values('vtiger_accountbillads', 'accountaddressid', $account_id);
        $order->column_fields['bill_city'] = $billads['bill_city'];
        $order->column_fields['bill_street'] = $billads['bill_street'];
        $order->column_fields['bill_code'] = $billads['bill_code'];
        $order->column_fields['bill_state'] = $billads['bill_state'];
        $order->column_fields['bill_country'] = $billads['bill_country'];
        $order->column_fields['bill_pobox'] = $billads['bill_pobox'];
        $_REQUEST['discount_type_final'] = "amount";
        $_REQUEST['discount_amount_final'] = 0;
        $_REQUEST['discount_type_final'] = "amount";
        $_REQUEST['discount_amount_final'] = 0;
        $_REQUEST['taxtype'] = 'group';
        $_REQUEST['shipping_handling_charge'] = 0;
    }
    $order->column_fields['subject'] = $title;
    $i = 1;
    $prices = get_products_prices();
    $total = 0.0;
    foreach ($product_ids as $ix => $current_id) {
        if (!empty($current_id)) {
            $product_info = explode('#', $current_id);
            $product_id = $product_info[0];
            $product_qty = $product_info[1];
            $_REQUEST['hdnProductId' . $i] = $product_id;
            $_REQUEST['qty' . $i] = (int) $product_qty;
            $price = $prices[$product_id];
            $_REQUEST['listPrice' . $i] = $price;
            $_REQUEST['discount_type' . $i] = "amount";
            $_REQUEST['discount_amount' . $i] = $discount;
            $total += $price * $product_qty;
            $i++;
        }
    }
    $_REQUEST['totalProductCount'] = $i - 1;
    $_REQUEST['subtotal'] = $total;
    $_REQUEST['total'] = $total;
    $order->save("SalesOrder");
    if ($order->id > 0) {
        $record_array[0]['new_salesorder']['salesorderid'] = $order->id;
        $adb->println("SalesOrder from Portal is saved with id => " . $order->id);
        return $record_array;
    } else {
        $adb->println("There may be error in saving the salesorder.");
        return null;
    }
    $log->debug("Exiting customerportal function create_salesorder");
}
Пример #12
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* SalesOrder detail 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
$do_block = new Block();
$do_block->get_block_by_module($module_id);
$module_obj = new SalesOrder();
$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';
}
Пример #13
0
/**
 * Function to generate SalesOrder pdf
 */
function get_so_pdf()
{
    require_once 'include/tcpdf/pdf.php';
    require_once 'include/tcpdf/pdfconfig.php';
    require_once 'include/database/PearDatabase.php';
    require_once 'modules/SalesOrder/SalesOrder.php';
    global $adb, $app_strings, $current_user;
    // would you like and end page?  1 for yes 0 for no
    $endpage = "1";
    $id = $_REQUEST['record'];
    //retreiving the vtiger_invoice info
    $focus = new SalesOrder();
    $focus->retrieve_entity_info($_REQUEST['record'], "SalesOrder");
    $focus->apply_field_security();
    $account_name = getAccountName($focus->column_fields[account_id]);
    $so_no = $focus->column_fields[salesorder_no];
    $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 ********************
    // populate data
    if ($focus->column_fields["quote_id"] != '') {
        $quote_name = getQuoteName($focus->column_fields["quote_id"]);
    } else {
        $quote_name = '';
    }
    $po_name = $focus->column_fields["purchaseorder"];
    $subject = $focus->column_fields["subject"];
    $valid_till = $focus->column_fields["duedate"];
    $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["sostatus"];
    // 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("SalesOrder", $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/SalesOrder/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/SalesOrder/pdf_templates/footer.php";
            }
        }
        $page_num++;
        if ($endpage && $lastpage) {
            $pdf->AddPage();
            include "modules/SalesOrder/pdf_templates/header.php";
            include "modules/SalesOrder/pdf_templates/lastpage/body.php";
            include "modules/SalesOrder/pdf_templates/lastpage/footer.php";
        }
    }
    return $pdf;
}
Пример #14
0
/*********************************************************************************
 * $Header$
 * Description:  TODO To be written.
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
require_once 'include/CRMSmarty.php';
require_once 'data/Tracker.php';
require_once 'modules/SalesOrder/SalesOrder.php';
require_once 'include/CustomFieldUtil.php';
require_once 'include/database/PearDatabase.php';
require_once 'include/utils/utils.php';
require_once 'user_privileges/default_module_view.php';
global $mod_strings, $app_strings, $theme, $currentModule, $singlepane_view;
$focus = new SalesOrder();
if (isset($_REQUEST['record']) && isset($_REQUEST['record'])) {
    $focus->retrieve_entity_info($_REQUEST['record'], "SalesOrder");
    $focus->id = $_REQUEST['record'];
    $focus->name = $focus->column_fields['subject'];
}
if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
    $focus->id = "";
}
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
require_once $theme_path . 'layout_utils.php';
$log->info("SalesOrder detail view");
$smarty = new CRMSmarty();
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
Пример #15
0
<?php

require_once 'modules/SalesOrder/SalesOrder.php';
require_once 'include/utils/utils.php';
$rel_focus = new SalesOrder();
global $adb, $current_user;
global $currentModule;
$type = $_REQUEST["type"];
$record = $_REQUEST["record"];
if (!$type || $type == '') {
    echo '';
    die;
}
$infohtml = '<table class="dvtContentSpace" style="border-top: 1px solid rgb(222, 222, 222);" width="100%" border="0">
<tbody><tr><td style="padding:5px;">';
if ($type == 'ProductsInfo') {
    $infohtml .= '<table style="background-color: rgb(234, 234, 234);" class="small" width="100%" border="0" cellpadding="3" cellspacing="1">


      <tr style="height: 20px;">

        <td class="lvtCol2"  nowrap>产品编号</td>

        <td class="lvtCol2" nowrap>产品名称</td>

        <td class="lvtCol2" nowrap>购买数量</td>

        <td class="lvtCol2" nowrap>价格</td>
		
		 <td class="lvtCol2" nowrap>库存量</td>
Пример #16
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;
        }
    }
Пример #17
0
    $_REQUEST['discount_amount_final'] = $discount_amount_final = '10';
    $_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
    $_REQUEST['adjustmenttype'] = '+';
    $_REQUEST['adjustment'] = $adjustment = '10';
    $_REQUEST['total'] = $subtotal - $discount_amount_final + $shipping_handling_charge + $adjustment;
    //Upto this added to set the request values which will be used to save the inventory product details
    //Now call the saveInventoryProductDetails function
    saveInventoryProductDetails($quote, 'Quotes');
}
//Populate SalesOrder Data
$subj_array = array("SO_vtiger", "SO_zoho", "SO_vtiger5usrp", "SO_vt100usrpk", "SO_vendtl");
$status_array = array("Created", "Delivered", "Approved", "Cancelled", "Created");
$carrier_array = array("FedEx", "UPS", "USPS", "DHL", "BlueDart");
$duedate_array = array("2007-04-21", "2007-05-29", "2007-08-11", "2007-09-09", "2007-02-28");
for ($i = 0; $i < 5; $i++) {
    $so = new SalesOrder();
    $so->column_fields["assigned_user_id"] = $assigned_user_id;
    $account_key = array_rand($account_ids);
    $so->column_fields["account_id"] = $account_ids[$account_key];
    $quote_key = array_rand($quote_ids);
    $so->column_fields["quote_id"] = $quote_ids[$quote_key];
    $contact_key = array_rand($contact_ids);
    $so->column_fields["contact_id"] = $contact_ids[$contact_key];
    $rand = array_rand($num_array);
    $so->column_fields["subject"] = $subj_array[$i];
    $so->column_fields["sostatus"] = $status_array[$i];
    $so->column_fields["hdnGrandTotal"] = $sototal_array[$i];
    $so->column_fields["carrier"] = $carrier_array[$i];
    $so->column_fields["duedate"] = $duedate_array[$i];
    $so->column_fields["bill_street"] = $street_address_array[rand(0, $street_address_count - 1)];
    $so->column_fields["bill_city"] = $city_array[rand(0, $city_array_count - 1)];
Пример #18
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* SalesOrder edit 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
$do_block = new Block();
$do_block->get_block_by_module($module_id);
$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 SalesOrder();
$module_obj->getId($sqcrm_record_id);
$do_lineitems = new Lineitems();
$do_lineitems->get_line_items($module_id, $sqcrm_record_id);
$do_products = new Products();
$lineitems = array();
if ($do_lineitems->getNumRows() > 0) {
    while ($do_lineitems->next()) {
        $product_available_tax = '';
        if ($do_lineitems->item_type == 'product') {
            $product_available_tax = $do_products->get_products_tax($do_lineitems->item_value);
        }
        $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, "product_available_tax" => $product_available_tax, "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);
    }
}
//print_r($lineitems);
if (isset($_GET["return_page"]) && $_GET["return_page"] != '') {
    $return = $_GET["return_page"];
Пример #19
0
 public function process()
 {
     $myTax = $this->getTaxRulesForCountry();
     $mySO = new SalesOrder();
     $mySO->process($myTax);
 }
Пример #20
0
require_once 'include/utils/utils.php';
require_once 'modules/CustomView/CustomView.php';
require_once 'include/database/Postgres8.php';
global $app_strings, $mod_strings, $list_max_entries_per_page, $currentModule, $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty = new vtigerCRM_Smarty();
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'SalesOrder');
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
$focus = new SalesOrder();
// Initialize sort by fields
$focus->initSortbyField('SalesOrder');
// END
$other_text = array();
$url_string = '';
// assigning http url string
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']);
Пример #21
0
} else {
    $return_action = "index";
}
if (isset($_REQUEST['return_id'])) {
    $return_id = $_REQUEST['return_id'];
} else {
    if (isset($_REQUEST['record'])) {
        $return_id = $_REQUEST['record'];
    }
}
if (isset($_REQUEST['return_viewname'])) {
    $return_viewname = $_REQUEST['return_viewname'];
}
$log->debug("Inside Sales Order EditView");
$category = getParentTab();
$focus = new SalesOrder();
$smarty = new CRMSmarty();
if (isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
    $focus->id = $_REQUEST['record'];
    $focus->mode = 'edit';
    $focus->retrieve_entity_info($_REQUEST['record'], "SalesOrder");
    $focus->name = $focus->column_fields['subject'];
}
if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
    $SO_associated_prod = $focus->getAssociatedProducts();
    $focus->id = "";
    $focus->mode = '';
    $focus->column_fields['subject'] = "";
}
if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Accounts') {
    $account_id = $_REQUEST['return_id'];