/**
     * 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;
        }
    }
 /**
  * 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 get data history display text
  * @param object $obj
  * @param boolean $link
  * @param boolean $user_history
  * @return array $ret_array
  */
 public function get_data_history_display_text($obj, $link = false, $user_history = false)
 {
     $row1 = '<strong>' . $obj->firstname . ' ' . $obj->lastname . '</strong> ' . _('on ') . '<i>' . i18nDate::i18n_long_time(TimeZoneUtil::convert_to_user_timezone($obj->date_modified, true)) . '</i>';
     switch ($obj->action) {
         case 'add':
             if ($user_history === true) {
                 $row2 = _('Added') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Added the record');
             }
             break;
         case 'delete':
             if ($user_history === true) {
                 $row2 = _('Deleted') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Deleted the record');
             }
             break;
         case 'edit':
             if ($user_history === true) {
                 $row2 = _('Updated') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Updated the record');
             }
             break;
         case 'value_changes':
             $do_crm_fields = new CRMFields();
             $do_crm_fields->getId($obj->idfields);
             if ($do_crm_fields->getNumRows() > 0) {
                 $field_label = $do_crm_fields->field_label;
                 $old_value = $obj->old_value;
                 $new_value = $obj->new_value;
                 if ($do_crm_fields->field_type == 9) {
                     $old_value = FieldType9::display_value($old_value);
                     $new_value = FieldType9::display_value($new_value);
                 }
                 if ($user_history === true) {
                     $row2 = _('Changed value in') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule) . ' , ' . $field_label . ' :: ' . $old_value . ' >>> ' . $new_value;
                 } else {
                     $row2 = _('Changed') . ' ' . $field_label . ' :: ' . $old_value . ' >>> ' . $new_value;
                 }
             }
             $do_crm_fields->free();
             break;
     }
     if ($obj->user_avatar != '') {
         $avatar_path = $GLOBALS['AVATAR_DISPLAY_PATH'];
         $thumb = $avatar_path . '/ths_' . $obj->user_avatar . '.' . $obj->file_extension;
     }
     if ($link === true) {
         $detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->idmodule]["name"], "detail", $obj->id_referrer);
         $row2 .= '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $detail_url . '">' . $GLOBALS['SITE_URL'] . $detail_url . '</a>';
     }
     $ret_array = array("avatar" => $thumb, "row1" => $row1, "row2" => $row2);
     return $ret_array;
 }
 public static function display_value($value)
 {
     $value = TimeZoneUtil::convert_to_user_timezone($value, true);
     $val = explode(" ", $value);
     $date = parent::display_value($val[0]);
     $time = i18nDate::i18n_time($val[1]);
     return $date . ' ' . $time;
 }
Exemple #5
0
echo _('Transaction Type');
?>
</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>
Exemple #6
0
            }
            $event_url = SITE_URL . NavigationControl::getNavigationLink("Calendar", "detail", $do_calendar->idevents);
            $reminder_time = strtotime("- {$d} days - {$h} hours - {$m} minutes ", strtotime($start_date_time));
            if (strtotime($now) >= $reminder_time) {
                foreach ($email_to_array as $key => $val) {
                    if ($key == 0) {
                        foreach ($val as $additional_emailids) {
                            $email_data = array("firstname" => "Hi", "event_type" => $do_calendar->event_type, "start_time" => FieldType10::display_value($start_time), "start_date" => FieldType9::display_value($start_date), "CRM_NAME" => CRM_NAME, "event_url" => $event_url, "subject" => $do_calendar->subject);
                            $emailer->IsSendmail();
                            $emailer->setEmailTemplate($email_template);
                            $emailer->mergeArray($email_data);
                            $emailer->AddAddress($val["email"], $val["firstname"] . ' ' . $val["lastname"]);
                            $emailer->send();
                            echo "Email Sent to " . $val["email"] . "\n";
                        }
                    } else {
                        $email_data = array("firstname" => $val["firstname"], "event_type" => $do_calendar->event_type, "start_time" => FieldType10::display_value($start_time), "start_date" => FieldType9::display_value($start_date), "CRM_NAME" => CRM_NAME, "event_url" => $event_url, "subject" => $do_calendar->subject);
                        $emailer->IsSendmail();
                        $emailer->setEmailTemplate($email_template);
                        $emailer->mergeArray($email_data);
                        $emailer->AddAddress($val["email"], $val["firstname"] . ' ' . $val["lastname"]);
                        $emailer->send();
                        echo "Email Sent to " . $val["email"] . "\n";
                    }
                }
                $qry = "\r\n\t\t\t\tupdate \r\n                `events_reminder` \r\n                set `reminder_send` = 1 \r\n                where `idevents_reminder` = " . $do_event_reminder->idevents_reminder . " limit 1";
                $GLOBALS['conn']->getDbConnection()->executeQuery($qry);
            }
        }
    }
}
					echo '<br />';
				} elseif ($recurrent_events_pattern["repeat_monthly_opts"] == 2) {
					echo $recurrent_events_pattern["repeat_monthly_opts_week_freq"].' '.$recurrent_events_pattern["repeat_monthly_opts_week_weekdays"];
					echo '<br />';
				}
			}
			if ($recurrent_events_pattern["repeat_end_opts"] == 1) {
				echo _('Ends after');
				echo '&nbsp;';
				echo $recurrent_events_pattern["repeat_end_num_occurence"];
				echo '&nbsp;';
				echo _('occurrences');
			} elseif ($recurrent_events_pattern["repeat_end_opts"] == 2) {
				echo _('Ends on');
				echo '&nbsp;';
				echo FieldType9::display_value($recurrent_events_pattern["repeat_end_date"]);
			}
		}
	}
	?>
</div>
<div class="box_content">
	<?php
    echo '<b>'._('Alert').'</b><br />';
    if (false === $reminder) {
		echo _('Event alert is not set');
    } else {
		if (is_array($reminder) && count($reminder) > 0) {
			echo _('Send alert ');
			echo '<br />';
			echo $reminder["days"].'&nbsp;'._('day(s)');