Initial Commit of AgileBill Open Source
This commit is contained in:
109
modules/invoice/advance_notice.php
Normal file
109
modules/invoice/advance_notice.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Agileco community forums at http://forum.agileco.com/
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
*/
|
||||
|
||||
/**
|
||||
* Advance invoice e-mail notification class
|
||||
*/
|
||||
class advance_notice
|
||||
{
|
||||
var $advance_days=false;
|
||||
var $advance_days_service;
|
||||
|
||||
function task() {
|
||||
|
||||
$db=&DB();
|
||||
|
||||
/* get the max invoice days from the setup_invoice table */
|
||||
if(!$this->advance_days) {
|
||||
$setup = $db->Execute(sqlSelect($db,"setup_invoice","advance_notice","advance_notice>0 and advance_notice != '' and advance_notice is not null"));
|
||||
if(!$setup && !$setup->RecordCount()) return false;
|
||||
$this->advance_days = $setup->fields['advance_notice'];
|
||||
}
|
||||
|
||||
/* pre-billing days global setting */
|
||||
if(MAX_INV_GEN_PERIOD <= 0) $max_days = $max_date=1; else $max_days = MAX_INV_GEN_PERIOD;
|
||||
|
||||
/* pre-notification date for service */
|
||||
$this->advance_days_service = $this->advance_days + $max_days;
|
||||
$max_date = time()+($this->advance_days_service*86400);
|
||||
date("Y-m-d", $max_date);
|
||||
|
||||
$p=AGILE_DB_PREFIX; $s=DEFAULT_SITE;
|
||||
$ids=false;
|
||||
$account=false;
|
||||
$date=false;
|
||||
$invoice=false;
|
||||
$sql = "SELECT DISTINCT service.id as serviceId, account.id as accountId, invoice.id as invoiceId, from_unixtime(service.date_next_invoice,'%Y-%m-%d') as dayGroup
|
||||
FROM {$p}service as service
|
||||
JOIN {$p}account as account ON ( service.account_id=account.id and account.site_id={$s} )
|
||||
LEFT JOIN {$p}invoice as invoice ON ( service.invoice_id=invoice.id and invoice.site_id={$s} )
|
||||
WHERE service.site_id={$s}
|
||||
AND service.active = 1
|
||||
AND ( service.invoice_advance_notified IS NULL OR service.invoice_advance_notified = 0 )
|
||||
AND ( service.suspend_billing IS NULL OR service.suspend_billing = 0 )
|
||||
AND ( service.date_next_invoice > 0 AND service.date_next_invoice IS NOT NULL )
|
||||
AND
|
||||
((
|
||||
( account.invoice_advance_gen!='' OR account.invoice_advance_gen is not null ) AND service.date_next_invoice <= ((86400*(account.invoice_advance_gen+{$this->advance_days})) + (UNIX_TIMESTAMP(CURDATE())))
|
||||
) OR (
|
||||
( account.invoice_advance_gen='' OR account.invoice_advance_gen is null ) AND service.date_next_invoice <= {$max_date}
|
||||
))
|
||||
ORDER BY accountId, dayGroup, serviceId";
|
||||
$rs = $db->Execute($sql);
|
||||
if($rs === false) {global $C_debug; $C_debug->error('advance_notice.inc.php','task()', $sql . " \r\n\r\n " . @$db->ErrorMsg()); }
|
||||
if($rs && $rs->RecordCount()) {
|
||||
while(!$rs->EOF) {
|
||||
if( $ids && ($rs->fields['accountId'] != $account ) || ($rs->fields['dayGroup'] != $date) ) {
|
||||
$this->sendEmail($ids, $account, $date);
|
||||
$ids=false;
|
||||
}
|
||||
|
||||
// set the current account and date
|
||||
$account=$rs->fields['accountId'];
|
||||
$invoice=$rs->fields['invoiceId'];
|
||||
$date=$rs->fields['dayGroup'];
|
||||
|
||||
// add to id list
|
||||
if($ids) $ids.=",";
|
||||
$ids.=$rs->fields['serviceId'];
|
||||
$rs->MoveNext();
|
||||
}
|
||||
if($ids) $this->sendEmail($ids, $account, $date);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* send e-mail to user with pre-billing notice */
|
||||
function sendEmail($ids, $account, $date) {
|
||||
if (empty($account)) return;
|
||||
|
||||
//echo "<br> $account - $ids - $date";
|
||||
|
||||
/* send e-mail to user */
|
||||
include_once(PATH_MODULES.'email_template/email_template.inc.php');
|
||||
$mail = new email_template;
|
||||
$mail->send('invoice_pregen_notice', $account, $ids, DEFAULT_CURRENCY, $date);
|
||||
|
||||
/* update service.invoice_advance_notified=1 to stop future notifications */
|
||||
$db=&DB();
|
||||
$db->Execute("UPDATE ".AGILE_DB_PREFIX."service SET invoice_advance_notified=1 WHERE site_id=".DEFAULT_SITE." AND id in ($ids)");
|
||||
}
|
||||
}
|
||||
?>
|
13
modules/invoice/auth.inc.php
Normal file
13
modules/invoice/auth.inc.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$auth_methods = Array
|
||||
(
|
||||
Array ('module' => 'invoice', 'method' => 'user_search'),
|
||||
Array ('module' => 'invoice', 'method' => 'user_search_show'),
|
||||
Array ('module' => 'invoice', 'method' => 'user_view'),
|
||||
Array ('module' => 'invoice', 'method' => 'pdf'),
|
||||
Array ('module' => 'invoice', 'method' => 'checkoutnow'),
|
||||
Array ('module' => 'invoice', 'method' => 'checkout_multiple_preview'),
|
||||
Array ('module' => 'invoice', 'method' => 'custom_tracking'),
|
||||
Array ('module' => 'invoice', 'method' => 'has_unpaid'),
|
||||
);
|
||||
?>
|
4376
modules/invoice/invoice.inc.php
Normal file
4376
modules/invoice/invoice.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
182
modules/invoice/invoice_construct.xml
Normal file
182
modules/invoice/invoice_construct.xml
Normal file
@@ -0,0 +1,182 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<construct>
|
||||
<!-- define the module name -->
|
||||
<module>invoice</module>
|
||||
<!-- define the module table name -->
|
||||
<table>invoice</table>
|
||||
<!-- define the module dependancy(s) -->
|
||||
<dependancy/>
|
||||
<!-- define the DB cache in seconds -->
|
||||
<cache>0</cache>
|
||||
<!-- define the default order_by field for SQL queries -->
|
||||
<order_by>date_orig</order_by>
|
||||
<!-- define the methods -->
|
||||
<limit>25</limit>
|
||||
<!-- define database indexes -->
|
||||
<index>
|
||||
<orig>date_orig</orig>
|
||||
<last>date_last</last>
|
||||
<parent>parent_id</parent>
|
||||
<billing>billing_status</billing>
|
||||
<process>process_status</process>
|
||||
<suspend>suspend_billing</suspend>
|
||||
<refund>refund_status</refund>
|
||||
<account>account_id</account>
|
||||
<affiliate>affiliate_id</affiliate>
|
||||
<campaign>campaign_id</campaign>
|
||||
<reseller>reseller_id</reseller>
|
||||
<amount>total_amt</amount>
|
||||
<due_date>due_date</due_date>
|
||||
<checkout>checkout_plugin_id</checkout>
|
||||
<tax>tax_id</tax>
|
||||
</index>
|
||||
<!-- define the fields -->
|
||||
<field>
|
||||
<id>
|
||||
<type>I4</type>
|
||||
<unique>1</unique>
|
||||
<index>1</index>
|
||||
</id>
|
||||
<site_id>
|
||||
<type>I4</type>
|
||||
<index>1</index>
|
||||
</site_id>
|
||||
<date_orig>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</date_orig>
|
||||
<date_last>
|
||||
<type>I8</type>
|
||||
<convert>date-now</convert>
|
||||
</date_last>
|
||||
<parent_id>
|
||||
<type>I4</type>
|
||||
</parent_id>
|
||||
<type>
|
||||
<type>L</type>
|
||||
</type>
|
||||
<process_status>
|
||||
<type>L</type>
|
||||
</process_status>
|
||||
<billing_status>
|
||||
<type>L</type>
|
||||
</billing_status>
|
||||
<refund_status>
|
||||
<type>L</type>
|
||||
</refund_status>
|
||||
<suspend_billing>
|
||||
<type>L</type>
|
||||
</suspend_billing>
|
||||
<print_status>
|
||||
<type>L</type>
|
||||
</print_status>
|
||||
<account_id>
|
||||
<type>I8</type>
|
||||
<asso_table>account</asso_table>
|
||||
<asso_field>first_name,last_name</asso_field>
|
||||
</account_id>
|
||||
<account_billing_id>
|
||||
<type>I4</type>
|
||||
</account_billing_id>
|
||||
<affiliate_id>
|
||||
<type>C(32)</type>
|
||||
</affiliate_id>
|
||||
<campaign_id>
|
||||
<type>I4</type>
|
||||
</campaign_id>
|
||||
<custom_affiliate_status>
|
||||
<type>L</type>
|
||||
</custom_affiliate_status>
|
||||
<reseller_id>
|
||||
<type>C(32)</type>
|
||||
</reseller_id>
|
||||
<checkout_plugin_id>
|
||||
<type>I4</type>
|
||||
</checkout_plugin_id>
|
||||
<checkout_plugin_data>
|
||||
<type>C(255)</type>
|
||||
<convert>array</convert>
|
||||
</checkout_plugin_data>
|
||||
<tax_id>
|
||||
<type>I4</type>
|
||||
</tax_id>
|
||||
<tax_amt>
|
||||
<type>F</type>
|
||||
</tax_amt>
|
||||
<discount_arr>
|
||||
<type>C(255)</type>
|
||||
<convert>array</convert>
|
||||
</discount_arr>
|
||||
<discount_amt>
|
||||
<type>F</type>
|
||||
</discount_amt>
|
||||
<recur_amt>
|
||||
<type>F</type>
|
||||
</recur_amt>
|
||||
<total_amt>
|
||||
<type>F</type>
|
||||
</total_amt>
|
||||
<billed_amt>
|
||||
<type>F</type>
|
||||
</billed_amt>
|
||||
<billed_currency_id>
|
||||
<type>I4</type>
|
||||
</billed_currency_id>
|
||||
<actual_billed_amt>
|
||||
<type>F</type>
|
||||
</actual_billed_amt>
|
||||
<actual_billed_currency_id>
|
||||
<type>I4</type>
|
||||
</actual_billed_currency_id>
|
||||
<notice_count>
|
||||
<type>I4</type>
|
||||
</notice_count>
|
||||
<notice_max>
|
||||
<type>I4</type>
|
||||
</notice_max>
|
||||
<notice_next_date>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</notice_next_date>
|
||||
<grace_period>
|
||||
<type>I4</type>
|
||||
</grace_period>
|
||||
<due_date>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</due_date>
|
||||
<recur_arr>
|
||||
<type>X</type>
|
||||
</recur_arr>
|
||||
<notes>
|
||||
<type>X</type>
|
||||
</notes>
|
||||
<net_term_id>
|
||||
<type>L</type>
|
||||
</net_term_id>
|
||||
<net_term_date_last>
|
||||
<type>I8</type>
|
||||
</net_term_date_last>
|
||||
<net_term_intervals>
|
||||
<type>I4</type>
|
||||
</net_term_intervals>
|
||||
<ip>
|
||||
<type>C(32)</type>
|
||||
</ip>
|
||||
</field>
|
||||
<!-- define all the methods for this class, and the fields they have access to, if applicable. -->
|
||||
<method>
|
||||
<add>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date</add>
|
||||
<update>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</update>
|
||||
<delete>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date</delete>
|
||||
<view>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals,ip</view>
|
||||
<search>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals,ip</search>
|
||||
<export_excel>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_excel>
|
||||
<export_pdf>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_pdf>
|
||||
<export_xml>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_xml>
|
||||
<export_csv>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_csv>
|
||||
<export_tab>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_tab>
|
||||
</method>
|
||||
<!-- define the method triggers -->
|
||||
<trigger>0</trigger>
|
||||
</construct>
|
393
modules/invoice/invoice_fpdf.inc.php
Normal file
393
modules/invoice/invoice_fpdf.inc.php
Normal file
@@ -0,0 +1,393 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Agileco community forums at http://forum.agileco.com/
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
*/
|
||||
|
||||
require_once(PATH_INCLUDES.'pdf/fpdf.php');
|
||||
define('EURO', chr(128) );
|
||||
define('EURO_VAL', 6.55957 );
|
||||
|
||||
class INVOICE_FPDF extends FPDF
|
||||
{
|
||||
// private variables
|
||||
var $colonnes;
|
||||
var $format;
|
||||
var $angle=0;
|
||||
|
||||
// private functions
|
||||
function RoundedRect($x, $y, $w, $h, $r, $style = '')
|
||||
{
|
||||
$k = $this->k;
|
||||
$hp = $this->h;
|
||||
if($style=='F')
|
||||
$op='f';
|
||||
elseif($style=='FD' or $style=='DF')
|
||||
$op='B';
|
||||
else
|
||||
$op='S';
|
||||
$MyArc = 4/3 * (sqrt(2) - 1);
|
||||
$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
|
||||
$xc = $x+$w-$r ;
|
||||
$yc = $y+$r;
|
||||
$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));
|
||||
|
||||
$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
|
||||
$xc = $x+$w-$r ;
|
||||
$yc = $y+$h-$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
|
||||
$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
|
||||
$xc = $x+$r ;
|
||||
$yc = $y+$h-$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
|
||||
$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
|
||||
$xc = $x+$r ;
|
||||
$yc = $y+$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
|
||||
$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
|
||||
$this->_out($op);
|
||||
}
|
||||
|
||||
function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
|
||||
{
|
||||
$h = $this->h;
|
||||
$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
|
||||
$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
|
||||
}
|
||||
|
||||
function Rotate($angle,$x=-1,$y=-1)
|
||||
{
|
||||
if($x==-1)
|
||||
$x=$this->x;
|
||||
if($y==-1)
|
||||
$y=$this->y;
|
||||
if($this->angle!=0)
|
||||
$this->_out('Q');
|
||||
$this->angle=$angle;
|
||||
if($angle!=0)
|
||||
{
|
||||
$angle*=M_PI/180;
|
||||
$c=cos($angle);
|
||||
$s=sin($angle);
|
||||
$cx=$x*$this->k;
|
||||
$cy=($this->h-$y)*$this->k;
|
||||
$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
|
||||
}
|
||||
}
|
||||
|
||||
function _endpage()
|
||||
{
|
||||
if($this->angle!=0)
|
||||
{
|
||||
$this->angle=0;
|
||||
$this->_out('Q');
|
||||
}
|
||||
parent::_endpage();
|
||||
}
|
||||
|
||||
// public functions
|
||||
function sizeOfText( $texte, $largeur )
|
||||
{
|
||||
$index = 0;
|
||||
$nb_lines = 0;
|
||||
$loop = TRUE;
|
||||
while ( $loop )
|
||||
{
|
||||
$pos = strpos($texte, "\n");
|
||||
if (!$pos)
|
||||
{
|
||||
$loop = FALSE;
|
||||
$ligne = $texte;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ligne = substr( $texte, $index, $pos);
|
||||
$texte = substr( $texte, $pos+1 );
|
||||
}
|
||||
$length = floor( $this->GetStringWidth( $ligne ) );
|
||||
//$res = 1 + floor( $length / $largeur) ;
|
||||
$nb_lines += $res;
|
||||
}
|
||||
return $nb_lines;
|
||||
}
|
||||
|
||||
// Company
|
||||
function addCompany( $nom, $adresse )
|
||||
{
|
||||
$this->Image(PATH_THEMES.'default/images/invoice_logo.jpg',11,8,50);
|
||||
$x1 = 10;
|
||||
$y1 = 20;
|
||||
$this->SetXY( $x1, $y1 );
|
||||
$this->SetFont('Arial','B',12);
|
||||
$length = $this->GetStringWidth( $nom );
|
||||
$this->Cell( $length, 2, $nom);
|
||||
$this->SetXY( $x1, $y1 + 4 );
|
||||
$this->SetFont('Arial','',10);
|
||||
$length = $this->GetStringWidth( $adresse );
|
||||
$lignes = $this->sizeOfText( $adresse, $length) ;
|
||||
$this->MultiCell($length, 4, $adresse);
|
||||
}
|
||||
|
||||
function addDate( $date )
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = $this->w - 40;
|
||||
$r2 = $r1 + 30;
|
||||
$y1 = 8;
|
||||
$y2 = $y1 ;
|
||||
$mid = $y1 + ($y2 / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 3.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(10,5, $C_translate->translate('pdf_date','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+4 );
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->Cell(10,5,$date, 0,0, "C");
|
||||
}
|
||||
|
||||
function addPageNumber( $page )
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = $this->w - 59;
|
||||
$r2 = $r1 + 19;
|
||||
$y1 = 8;
|
||||
$y2 = $y1;
|
||||
$mid = $y1 + ($y2 / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 3.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(10,5, $C_translate->translate('pdf_page','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+4 );
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->Cell(10,5,$page, 0,0, "C");
|
||||
}
|
||||
|
||||
// Client address
|
||||
function addClient( $adresse )
|
||||
{
|
||||
$r1 = 140;
|
||||
$r2 = $r1 + 68;
|
||||
$y1 = 35;
|
||||
$this->SetXY( $r1, $y1);
|
||||
$this->MultiCell( 60, 4, $adresse);
|
||||
}
|
||||
|
||||
// Invoice number
|
||||
function addInvoiceNo($id)
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = 10;
|
||||
$r2 = $r1 + 60;
|
||||
$y1 = 65;
|
||||
$y2 = $y1+10;
|
||||
$mid = $y1 + (($y2-$y1) / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 20 , $y1+1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(40, 4, $C_translate->translate('pdf_invoice_number','invoice',''), 0, 0, "C");
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->SetXY( $r1 + 9 , $y1+5 );
|
||||
$this->Cell(40, 5, $id, '', '', "C");
|
||||
}
|
||||
|
||||
// Payment Status
|
||||
function addStatus( $mode )
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = 75;
|
||||
$r2 = $r1 + 60;
|
||||
$y1 = 65;
|
||||
$y2 = $y1+10;
|
||||
$mid = $y1 + (($y2-$y1) / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1+1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(10,4, $C_translate->translate('pdf_payment_status','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1 + 5 );
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->Cell(10,5,$mode, 0,0, "C");
|
||||
}
|
||||
|
||||
// Due date
|
||||
function addDueDate( $date )
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = 140;
|
||||
$r2 = $r1 + 60;
|
||||
$y1 = 65;
|
||||
$y2 = $y1+10;
|
||||
$mid = $y1 + (($y2-$y1) / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2 - $r1)/2 - 5 , $y1+1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(10,4, $C_translate->translate('pdf_date_due','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5 , $y1 + 5 );
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->Cell(10,5,$date, 0,0, "C");
|
||||
}
|
||||
|
||||
function addCols( $tab )
|
||||
{
|
||||
global $colonnes;
|
||||
|
||||
$r1 = 10;
|
||||
$r2 = $this->w - ($r1 * 2) ;
|
||||
$y1 = 80;
|
||||
$y2 = $this->h - 50 - $y1;
|
||||
$this->SetXY( $r1, $y1 );
|
||||
$this->Rect( $r1, $y1, $r2, $y2, "D");
|
||||
$this->Line( $r1, $y1+6, $r1+$r2, $y1+6);
|
||||
$colX = $r1;
|
||||
$colonnes = $tab;
|
||||
while ( list( $lib, $pos ) = each ($tab) )
|
||||
{
|
||||
$this->SetXY( $colX, $y1+2 );
|
||||
$this->Cell( $pos, 1, $lib, 0, 0, "C");
|
||||
$colX += $pos;
|
||||
$this->Line( $colX, $y1, $colX, $y1+$y2);
|
||||
}
|
||||
}
|
||||
|
||||
function addLineFormat( $tab )
|
||||
{
|
||||
global $format, $colonnes;
|
||||
|
||||
while ( list( $lib, $pos ) = each ($colonnes) )
|
||||
{
|
||||
if ( isset( $tab["$lib"] ) )
|
||||
$format[ $lib ] = $tab["$lib"];
|
||||
}
|
||||
}
|
||||
|
||||
function lineVert( $tab )
|
||||
{
|
||||
global $colonnes;
|
||||
|
||||
reset( $colonnes );
|
||||
$maxSize=0;
|
||||
while ( list( $lib, $pos ) = each ($colonnes) )
|
||||
{
|
||||
$texte = $tab[ $lib ];
|
||||
$longCell = $pos -2;
|
||||
$size = $this->sizeOfText( $texte, $longCell );
|
||||
if ($size > $maxSize)
|
||||
$maxSize = $size;
|
||||
}
|
||||
return $maxSize;
|
||||
}
|
||||
|
||||
function addLine( $ligne, $tab )
|
||||
{
|
||||
global $colonnes, $format;
|
||||
|
||||
$ordonnee = 10;
|
||||
$maxSize = $ligne;
|
||||
|
||||
reset( $colonnes );
|
||||
while ( list( $lib, $pos ) = each ($colonnes) )
|
||||
{
|
||||
$longCell = $pos -2;
|
||||
$texte = $tab[ $lib ];
|
||||
$length = $this->GetStringWidth( $texte );
|
||||
$tailleTexte = $this->sizeOfText( $texte, $length );
|
||||
$formText = $format[ $lib ];
|
||||
$this->SetXY( $ordonnee, $ligne-1);
|
||||
$this->MultiCell( $longCell, 4 , $texte, 0, $formText);
|
||||
if ( $maxSize < ($this->GetY() ) )
|
||||
$maxSize = $this->GetY() ;
|
||||
$ordonnee += $pos;
|
||||
}
|
||||
return ( $maxSize - $ligne );
|
||||
}
|
||||
|
||||
function addTotals($a, $b, $a_total, $a_paid, $a_due, $b_total, $b_paid, $b_due, $a_disc, $b_disc)
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = $this->w - 102;
|
||||
$r2 = $r1 + 92;
|
||||
$y1 = $this->h - 45;
|
||||
$y2 = $y1+25;
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
|
||||
$this->Line( $r1+20, $y1, $r1+20, $y2); // avant EUROS
|
||||
$this->Line( $r1+20, $y1+4, $r2, $y1+4); // Sous Euros & Francs
|
||||
$this->Line( $r1+55, $y1, $r1+55, $y2); // Entre Euros & Francs
|
||||
$this->SetFont( "Arial", "B", 8);
|
||||
$this->SetXY( $r1+30, $y1 );
|
||||
$this->Cell(15,4, $a, 0, 0, "C");
|
||||
$this->SetFont( "Arial", "", 8);
|
||||
$this->SetXY( $r1+65, $y1 );
|
||||
$this->Cell(15,4, $b, 0, 0, "C");
|
||||
$this->SetFont( "Arial", "B", 6);
|
||||
|
||||
$this->SetXY( $r1, $y1+5 );
|
||||
$this->Cell(20,4, $C_translate->translate('pdf_discounts','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1, $y1+10 );
|
||||
$this->Cell(20,4, $C_translate->translate('pdf_total','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1, $y1+15 );
|
||||
$this->Cell(20,4, $C_translate->translate('pdf_paid','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1, $y1+20 );
|
||||
$this->Cell(20,4, $C_translate->translate('pdf_due','invoice',''), 0, 0, "C");
|
||||
|
||||
$re = $this->w - 65;
|
||||
$rf = $this->w - 28;
|
||||
$y1 = $this->h - 40;
|
||||
|
||||
// A total
|
||||
$this->SetFont( "Arial", "", 8);
|
||||
$this->SetXY( $re, $y1+0 );
|
||||
$this->Cell( 17,4, $a_disc, '', '', 'R');
|
||||
$this->SetXY( $re, $y1+5 );
|
||||
$this->Cell( 17,4, $a_total, '', '', 'R');
|
||||
$this->SetXY( $re, $y1+10 );
|
||||
$this->Cell( 17,4, $a_paid, '', '', 'R');
|
||||
$this->SetXY( $re, $y1+15 );
|
||||
$this->Cell( 17,4, $a_due, '', '', 'R');
|
||||
$this->SetXY( $rf, $y1+5 );
|
||||
|
||||
// B Total
|
||||
if(!empty($b)) {
|
||||
$this->Cell( 17,4, $b_total, '', '', 'R');
|
||||
$this->SetXY( $rf, $y1+10 );
|
||||
$this->Cell( 17,4, $b_paid, '', '', 'R');
|
||||
$this->SetXY( $rf, $y1+14.8 );
|
||||
$this->Cell( 17,4, $b_due, '', '', 'R');
|
||||
}
|
||||
}
|
||||
|
||||
// watermark
|
||||
function addWatermark( $text )
|
||||
{
|
||||
$this->SetFont('Arial','B',50);
|
||||
$this->SetTextColor(203,203,203);
|
||||
$this->Rotate(0);
|
||||
$this->Text(10,50,$text);
|
||||
$this->Rotate(0);
|
||||
$this->SetTextColor(0,0,0);
|
||||
}
|
||||
}
|
||||
?>
|
65
modules/invoice/invoice_install.xml
Normal file
65
modules/invoice/invoice_install.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<install>
|
||||
<module_properties>
|
||||
<name>invoice</name>
|
||||
<parent>invoice</parent>
|
||||
<notes><![CDATA[This module controls the invoicing]]></notes>
|
||||
<menu_display>1</menu_display>
|
||||
</module_properties>
|
||||
<sql_inserts>
|
||||
<module_method>
|
||||
<add>
|
||||
<name>add</name>
|
||||
<menu_display>1</menu_display>
|
||||
</add>
|
||||
<update>
|
||||
<name>update</name>
|
||||
</update>
|
||||
<delete>
|
||||
<name>delete</name>
|
||||
</delete>
|
||||
<view>
|
||||
<name>view</name>
|
||||
<page><![CDATA[core:search&module=%%&_escape=1]]></page>
|
||||
<menu_display>1</menu_display>
|
||||
</view>
|
||||
<search>
|
||||
<name>search</name>
|
||||
<page><![CDATA[%%:search_form]]></page>
|
||||
<menu_display>1</menu_display>
|
||||
</search>
|
||||
<search_form>
|
||||
<name>search_form</name>
|
||||
</search_form>
|
||||
<search_show>
|
||||
<name>search_show</name>
|
||||
</search_show>
|
||||
<resend>
|
||||
<name>resend</name>
|
||||
</resend>
|
||||
<search_export>
|
||||
<name>search_export</name>
|
||||
</search_export>
|
||||
<approveinvoice>
|
||||
<name>approveinvoice</name>
|
||||
</approveinvoice>
|
||||
<voidinvoice>
|
||||
<name>voidinvoice</name>
|
||||
</voidinvoice>
|
||||
<performance>
|
||||
<name>performance</name>
|
||||
</performance>
|
||||
<refund>
|
||||
<name>refund</name>
|
||||
</refund>
|
||||
<reconcile>
|
||||
<name>reconcile</name>
|
||||
</reconcile>
|
||||
<autobill>
|
||||
<name>autobill</name>
|
||||
</autobill>
|
||||
<generatedomaininvoice>
|
||||
<name>generatedomaininvoice</name>
|
||||
</generatedomaininvoice>
|
||||
</module_method>
|
||||
</sql_inserts>
|
||||
</install>
|
93
modules/invoice/receipt_print.php
Normal file
93
modules/invoice/receipt_print.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Agileco community forums at http://forum.agileco.com/
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This module creates a printable pdf reciept on manual invoice reconciliation suitable for retail printing.
|
||||
* To enable, simply change "var $active=false;" to "var $active=true" below.
|
||||
* When an invoice is reconciled from the admin menu, a PDF will be displayed inline, and you can use the print
|
||||
* feature in the inline acrobat reader to print.
|
||||
*/
|
||||
|
||||
require_once(PATH_INCLUDES.'pdf/fpdf.php');
|
||||
|
||||
class receipt_print extends FPDF
|
||||
{
|
||||
var $active=false;
|
||||
var $save_path = '';
|
||||
|
||||
function add(&$invoiceRs, $payment_amt, $paid_amt) {
|
||||
|
||||
if(!$this->active) return false;
|
||||
|
||||
ob_start();
|
||||
|
||||
$this->AddPage();
|
||||
$this->SetFont('Arial','B',10);
|
||||
|
||||
$this->drawCompanyLogo();
|
||||
$this->drawCompanyAddress();
|
||||
|
||||
$this->SetXY(0,50);
|
||||
$this->Cell(50,10,"*** INVOICE# {$invoiceRs->fields['id']} ***");
|
||||
|
||||
$this->SetXY(0,60);
|
||||
$this->Cell(50,10,"DATE ".date("d/m/Y D H:i"));
|
||||
|
||||
$this->SetXY(0,70); $this->Cell(50,5,"INVOICE TOTAL: ");
|
||||
$this->SetXY(45,70); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt'],2));
|
||||
|
||||
$this->SetXY(0,75); $this->Cell(50,5,"PREV AMT DUE: " );
|
||||
$this->SetXY(45,75); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt']-$invoiceRs->fields['billed_amt'],2));
|
||||
|
||||
$this->SetXY(0,80); $this->Cell(50,5,"CURRENT PAYMENT: " );
|
||||
$this->SetXY(45,80); $this->Cell(50,5, $payment_amt);
|
||||
|
||||
$this->SetXY(0,85); $this->Cell(50,5,"PAID TO DATE: " );
|
||||
$this->SetXY(45,85); $this->Cell(50,5, number_format($paid_amt,2));
|
||||
|
||||
$this->SetXY(0,90); $this->Cell(50,5,"CURRENY AMT DUE: " );
|
||||
$this->SetXY(45,90); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt']-$paid_amt,2));
|
||||
|
||||
$this->SetXY(0,100); $this->Cell(50,5,"Thank You!" );
|
||||
|
||||
$this->Output();
|
||||
|
||||
ob_flush();
|
||||
}
|
||||
|
||||
|
||||
// draw the logo
|
||||
function drawCompanyLogo() {
|
||||
$width = 50;
|
||||
if(is_file(PATH_THEMES.'default/images/invoice_logo.jpg'))
|
||||
$this->Image(PATH_THEMES.'default/images/invoice_logo.jpg',0,0,$width);
|
||||
}
|
||||
|
||||
// draw the company address
|
||||
function drawCompanyAddress() {
|
||||
// add the company address on the payment stub (1)
|
||||
$this->SetFont('times','B', 10);
|
||||
$this->SetXY(0,30); $this->Cell(50,10, SITE_NAME);
|
||||
$this->SetXY(0,35); $this->Cell(50,10, SITE_ADDRESS);
|
||||
$this->SetXY(0,40); $this->Cell(50,10, SITE_CITY. ", ". SITE_STATE . " " . SITE_ZIP);
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user