/** * function to get the prospect lost to competitor by competitor name * @param string $where * @param integer $iduser * @param integer $date_filter_type * @param string $start_date * @param string $date_end * @return array */ public function get_prospect_lost_to_competitor($where = '', $iduser = 0, $date_filter_type = 15, $start_date = '', $end_date = '') { if ($where == '') { if ((int) $iduser == 0) { $iduser = $_SESSION["do_user"]->iduser; } $where = ''; $user_where = $this->get_report_where($iduser, 'p', 'ptg'); $date_where = $this->get_date_filter_where('p', 'expected_closing_date', $date_filter_type, $start_date = '', $end_date = ''); $where = $user_where . $date_where; } $qry = "\n\t\tselect p.competitor_name,sum(p.amount) as amount\n\t\tfrom potentials p\n\t\tleft join pot_to_grp_rel ptg on ptg.idpotentials = p.idpotentials\n\t\twhere p.deleted = 0\n\t\tand p.sales_stage = 'Close Lost'\n\t\tand p.lost_reason = 'Lost To Competitor'\n\t\t{$where}\n\t\tgroup by p.competitor_name\n\t\t"; $this->query($qry); $return_array = array(); $grand_total = 0.0; if ($this->getNumRows() > 0) { while ($this->next()) { $return_array[$this->competitor_name . ' - ' . FieldType30::display_value($this->amount)] = $this->amount; $grand_total += $this->amount; } } return array("data" => $return_array, "grand_total" => $grand_total); }
/** * event function to add the invoice payment * @param object $evctl */ public function eventAjaxAddInvoicePayment(EventControler $evctl) { $err = false; $error_code = 0; if (trim($evctl->payment_date) == '') { $err = true; $error_code = 1; } elseif (trim($evctl->ref_num) == '') { $err = true; $error_code = 2; } elseif ((int) FieldType30::convert_before_save(trim($evctl->amount)) == 0) { $err = true; $error_code = 3; } elseif (true === $this->is_payment_more_than_due($evctl->idinvoice, FieldType30::convert_before_save(trim($evctl->amount)))) { $err = true; $error_code = 4; } if (true === $err) { echo $error_code; } else { $payment_date = FieldType9::convert_before_save($evctl->payment_date); $payment_mode = $evctl->payment_mode; $amount = FieldType30::convert_before_save($evctl->amount); $ref_num = CommonUtils::purify_input($evctl->ref_num); $additional_note = CommonUtils::purify_input($evctl->additional_note); $idinvoice = (int) $evctl->idinvoice; // add to paymentlog $do_paymentlog = new Paymentlog(); $do_paymentlog->addNew(); $do_paymentlog->date_added = $payment_date; $do_paymentlog->amount = $amount; $do_paymentlog->ref_num = $ref_num; $do_paymentlog->idpayment_mode = $payment_mode; $do_paymentlog->add(); $idpaymentlog = $do_paymentlog->getInsertId(); // add to invoice payment $this->addNew(); $this->idinvoice = $idinvoice; $this->idpaymentlog = $idpaymentlog; $this->additional_note = $additional_note; $this->iduser = $_SESSION["do_user"]->iduser; $this->add(); $qry = "\n\t\t\tselect * from `payment_mode` where `idpayment_mode` = ?\n\t\t\t"; $stmt = $this->getDbConnection()->executeQuery($qry, array($evctl->payment_mode)); $data = $stmt->fetch(); $payment_mode_name = $data['mode_name']; $html = ''; $html .= '<tr>'; $html .= '<td>' . FieldType9::display_value($payment_date) . '</td>'; $html .= '<td>' . FieldType30::display_value($amount) . '</td>'; $html .= '<td>' . FieldType1::display_value($ref_num) . '</td>'; $html .= '<td>' . FieldType1::display_value($payment_mode_name) . '</td>'; $html .= '<td>' . _('charge') . '</td>'; $html .= '<td>' . nl2br($additional_note) . '</td>'; $html .= '</tr>'; $invoice_payments = new InvoicePayments(); $due_amount = FieldType30::display_value($invoice_payments->get_due_amount($idinvoice)); echo json_encode(array('html' => $html, 'due_amount' => $due_amount)); } }
/** * 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; } }
"/> </div> <br /> </form> </div> </div> </div> <div class="clear_float"></div> <div class="row-fluid"> <div class="span6"> <div class="datadisplay-outer"> <p><strong><?php echo _('Prospect Funnel By Stage and Amount'); ?> <?php echo $funnel_data_by_amount["grand_total"] > 0 ? _(' - Totalling ') . FieldType30::display_value($funnel_data_by_amount["grand_total"]) : ''; ?> </strong></p> <div id="c1"> </div> </div> </div> <div class="span6"> <div class="datadisplay-outer" > <p><strong><?php echo _('Prospect Funnel By Stage and Number'); ?> <?php echo $funnel_data_by_no["grand_total"] > 0 ? _(' - Totalling ') . $funnel_data_by_no["grand_total"] : ''; ?>
"/> </div> <br /> </form> </div> </div> </div> <div class="clear_float"></div> <div class="row"> <div class="col-md-12"> <div class="datadisplay-outer"> <p><strong><?php echo _('Prospect Lost to Competitor '); ?> <?php echo $prospect_lostto_competitor_by_name["grand_total"] > 0 ? _(' - Totalling ') . FieldType30::display_value($prospect_lostto_competitor_by_name["grand_total"]) : ''; ?> </strong></p> <div id="c1"> </div> </div> </div> </div> <div class="clear_float"></div> <div class="row"> <div class="col-md-12"> <div class="datadisplay-outer"> <div class="left_300" id=""> <p><strong><?php echo _('Detailed report'); ?>
?> </th> <th width="27%"><?php echo _('Note'); ?> </th> </tr> </thead> <tbody id="payment_details_tbody"> <?php if (count($payments) > 0) { foreach ($payments as $key => $val) { echo '<tr>'; echo '<td></td>'; echo '<td>' . FieldType9::display_value($val['date_added']) . '</td>'; echo '<td>' . FieldType30::display_value($val['amount']) . '</td>'; echo '<td>' . FieldType1::display_value($val['ref_num']) . '</td>'; echo '<td>' . FieldType1::display_value($val['mode_name']) . '</td>'; echo '<td>' . FieldType1::display_value($val['transaction_type']) . '</td>'; echo '<td>' . nl2br($val['additional_note']) . '</td>'; echo '</tr>'; } } ?> </tbody> </table> </div> </div> </div> </div> <hr class="form_hr">
"/> </div> <br /> </form> </div> </div> </div> <div class="clear_float"></div> <div class="row"> <div class="col-md-6"> <div class="datadisplay-outer"> <p><strong><?php echo _('Prospect Lost By Amount'); ?> <?php echo $prospect_lost_data_by_amount["grand_total"] > 0 ? _(' - Totalling ') . FieldType30::display_value($prospect_lost_data_by_amount["grand_total"]) : ''; ?> </strong></p> <div id="c1"> </div> </div> </div> <div class="col-md-6"> <div class="datadisplay-outer" > <p><strong><?php echo _('Prospect Lost By Number'); ?> <?php echo $prospect_lost_data_by_no["grand_total"] > 0 ? _(' - Totalling ') . $prospect_lost_data_by_no["grand_total"] : ''; ?>
<?php // Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt /** * @author Abhik Chakraborty */ $idmodule = (int) $_GET["idmodule"]; $sqcrm_record_id = (int) $_GET["sqrecord"]; $module_name = $modules_info[$idmodule]['name']; $do_module_object = new $module_name(); $do_invoice_payments = new InvoicePayments(); $payments = $do_invoice_payments->get_invoice_payments($sqcrm_record_id); $due_amount = FieldType30::display_value($do_invoice_payments->get_due_amount($sqcrm_record_id)); $payment_modes = $do_invoice_payments->get_payment_modes(); include_once 'view/plugin_view.php';
echo '(+)'; } elseif ($module_obj->final_adjustment_type == 'deduct') { echo '(-)'; } ?> </div> </td> <td width="20%"> <div style="height:30px;text-align:right;line-height:1.3;"> <?php echo FieldType30::display_value($module_obj->final_adjustment_amount); ?> </div> </td> </tr> <tr> <td width="80%" style="text-align: right;"> <div style="height:20px;text-align:right;line-height:1.3;"> <b><?php echo _('Grand Total');?></b> </div> </td> <td width="20%"> <div style="height:20px;text-align:right;line-height:1.3;"> <?php echo FieldType30::display_value($module_obj->grand_total); ?> </div> </td> </tr> </tbody> </table> <?php } ?> </div> <script src="/js/lineitem.js"></script>