/** * Static function to display the data in detail view * @param string $value */ public static function display_value($value) { if ($value === null || $value == '') { $value = 0.0; } //-- handle empty and null values $do_global_settings = new CRMGlobalSettings(); $currency = $do_global_settings->get_setting_data_by_name('currency_setting'); $currency_data = json_decode($currency, true); $formated_val = number_format($value, $currency_data["decimal_point"], $currency_data["decimal_symbol"], $currency_data["thousand_seperator"]); if ($currency_data["currency_symbol_position"] == "left") { return $currency_data["currency_sysmbol"] . " " . $formated_val; } elseif ($currency_data["currency_symbol_position"] == "right") { return $formated_val . " " . $currency_data["currency_sysmbol"]; } }
<?php // Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt /** * Home page prospect pipeline by sales stage graph * @author Abhik Chakraborty */ include_once(BASE_PATH.'/widgets/ProspectPipeline/ProspectPipeline.class.php') ; $prospect_pipeline = new ProspectPipeline() ; $data_3 = $prospect_pipeline->get_prospect_pipeline_by_sales_stage_graph(); $crm_global_settings = new CRMGlobalSettings(); $currency = $crm_global_settings->get_setting_data_by_name('currency_setting'); $currency_data = json_decode($currency,true); ?> <script src="/js/plugins/jqplot/plugins/jqplot.barRenderer.min.js"></script> <script src="/js/plugins/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script> <script src="/js/plugins/jqplot/plugins/jqplot.pointLabels.min.js"></script> <script type="text/javascript" src="/js/jquery/plugins/accounting.js"></script> <script type="text/javascript"> $(document).ready(function() { var currency_symbol = '<?php echo $currency_data["currency_sysmbol"] ;?>'; var decimal_point = '<?php echo $currency_data["decimal_point"] ;?>'; var decimal_symbol = '<?php echo $currency_data["decimal_symbol"] ;?>'; var thousand_seperator = '<?php echo $currency_data["thousand_seperator"] ;?>'; var currency_symbol_position = '<?php echo $currency_data["currency_symbol_position"] ;?>'; tickFormatter = function(format,val) { var formatted_amt = accounting.formatMoney(val, "", decimal_point, thousand_seperator, decimal_symbol); if (currency_symbol_position == 'left') { formatted_amt = currency_symbol+' '+formatted_amt; } else if (currency_symbol_position == 'right') {
/** * event function to send sales order by email * @param object $evctl */ public function sendSalesOrderWithEmail(EventControler $evctl) { $record_id = $evctl->idsales_order; $sales_order_email = $evctl->sales_order_email; $crm_global_settings = new CRMGlobalSettings(); $inventory_prefixes = $crm_global_settings->get_inventory_prefixes(); $company_address = $crm_global_settings->get_setting_data_by_name('company_address'); $export_inventory = new ExportInventoryData(); if ((int) $record_id > 0) { if (is_array($sales_order_email) && count($sales_order_email) > 0) { $email_template = new EmailTemplate("send_sales_order_email"); $emailer = new SQEmailer(); $pdf_filename = $export_inventory->generate_inventory_pdf((int) $record_id, 14, true); foreach ($sales_order_email as $key => $val) { $val_exploded = explode(':::', $val); $to_email = $val_exploded[0]; $name = $val_exploded[1]; $name_explode = explode('::', $name); $email_data = array("sales_order_number" => $inventory_prefixes["salesorder_num_prefix"] . $record_id, "company_name" => CRM_NAME, "firstname" => array_key_exists(0, $name_explode) ? $name_explode[0] : '', "lastname" => array_key_exists(1, $name_explode) ? $name_explode[1] : '', "company_address" => nl2br($company_address)); $to_name = (array_key_exists(0, $name_explode) ? $name_explode[0] : '') . ' ' . (array_key_exists(1, $name_explode) ? $name_explode[1] : ''); $emailer->IsSendmail(); $emailer->setEmailTemplate($email_template); $emailer->mergeArray($email_data); $emailer->AddAddress($to_email, $to_name); $emailer->AddAttachment(OUTBOUND_PATH . '/' . $pdf_filename); $emailer->send(); $_SESSION["do_crm_messages"]->set_message('success', _('Email has been sent !')); $next_page = NavigationControl::getNavigationLink($evctl->module, "detail"); $dis = new Display($next_page); $dis->addParam("sqrecord", $record_id); $evctl->setDisplayNext($dis); } } else { $_SESSION["do_crm_messages"]->set_message('error', _('Operation failed! No email id specified.')); $next_page = NavigationControl::getNavigationLink($evctl->module, "detail"); $dis = new Display($next_page); $dis->addParam("sqrecord", $record_id); $evctl->setDisplayNext($dis); } } else { $_SESSION["do_crm_messages"]->set_message('error', _('Operation failed! No record id specified.')); $next_page = NavigationControl::getNavigationLink($evctl->module, "detail"); $dis = new Display($next_page); $dis->addParam("sqrecord", $record_id); $evctl->setDisplayNext($dis); } }
/** * 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; } }
<?php // Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt /** * Inventory settigs page * @author Abhik Chakraborty */ $crm_global_settings = new CRMGlobalSettings(); $inventory_prefixes = $crm_global_settings->get_inventory_prefixes(); $inventory_terms_cond = $crm_global_settings->get_inventory_terms_condition(); //$inventory_logo = $crm_global_settings->get_inventory_logo(); $inventory_logo = $crm_global_settings->get_setting_data_by_name('inventory_logo'); $company_address = $crm_global_settings->get_setting_data_by_name('company_address'); require_once 'view/inventory_settings_view.php';