Optimised Company() Setup() Config() and changed method_directory into URL

This commit is contained in:
Deon George
2013-02-12 22:14:59 +11:00
parent 97d894d472
commit 288d974cfa
63 changed files with 422 additions and 346 deletions

View File

@@ -46,7 +46,7 @@ class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin {
ORM::factory('Invoice')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
'date_orig'=>array('label'=>'Date'),
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
'credit_amt'=>array('label'=>'Credits','class'=>'right'),
@@ -58,7 +58,7 @@ class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin {
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/invoice/view',
'form'=>URL::link('user','invoice/view'),
)),
));
}

View File

@@ -76,8 +76,8 @@ class Controller_Task_Invoice extends Controller_Task {
'DUE_DATE'=>$io->display('due_date'),
'FIRST_NAME'=>$io->account->first_name,
'INV_NUM'=>$io->refnum(),
'INV_URL'=>URL::site('user/invoice/view/'.$io->id,'http'),
'SITE_NAME'=>Company::name(),
'INV_URL'=>URL::site(URL::link('user','invoice/view/'.$io->id),'http'),
'SITE_NAME'=>Company::instance()->name(),
);
// @todo Record email log id if possible.
@@ -131,10 +131,10 @@ class Controller_Task_Invoice extends Controller_Task {
'EMAIL'=>Company::email(),
'FIRST_NAME'=>$io->account->first_name,
'INV_NUM'=>$io->refnum(),
'INV_URL'=>URL::site('user/invoice/view/'.$io->id,'http'),
'INV_URL'=>URL::site(URL::link('user','invoice/view/'.$io->id),'http'),
'LATE_FEE'=>'5.50', // @todo This should come from a config file.
'PAYMENTS_TABLE'=>$io->account->payment->list_recent_table(),
'SITE_NAME'=>Company::name(),
'SITE_NAME'=>Company::instance()->name(),
);
// @todo Record email log id if possible.
@@ -303,9 +303,9 @@ class Controller_Task_Invoice extends Controller_Task {
'FIRST_NAME'=>$io->account->first_name,
'HTML_INVOICE'=>$io->html(),
'INV_NUM'=>$io->refnum(),
'INV_URL'=>URL::site('user/invoice/view/'.$io->id,'http'),
'INV_URL_DOWNLOAD'=>URL::site(sprintf('user/invoice/download/%s?token=%s',$io->id,$token),'http'),
'SITE_NAME'=>Company::name(),
'INV_URL'=>URL::site(URL::link('user','invoice/view/'.$io->id),'http'),
'INV_URL_DOWNLOAD'=>URL::site(URL::link('user',sprintf('invoice/download/%s?token=%s',$io->id,$token)),'http'),
'SITE_NAME'=>Company::instance()->name(),
);
// @todo Record email log id if possible.

View File

@@ -27,7 +27,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
$this->ao->invoice->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
'date_orig'=>array('label'=>'Date Issued'),
'due_date'=>array('label'=>'Date Due'),
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
@@ -38,7 +38,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/invoice/view',
'form'=>URL::link('user','invoice/view'),
)),
));
}
@@ -51,7 +51,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
$io = ORM::factory('Invoice',$id);
if (! $io->loaded() OR (! Auth::instance()->authorised($io->account_id,$io->affiliate_id) AND ! in_array($this->ao->affiliate->id,$io->service_affiliates()))) {
if (! $io->loaded() AND ! in_array($this->ao->affiliate->id,$io->service_affiliates())) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;

View File

@@ -22,6 +22,8 @@ require_once('includes/tcpdf/tcpdf.php');
abstract class Invoice_TCPDF extends TCPDF {
// Our invoice object
protected $io;
// Our company object
protected $co;
protected $billToCompany = true;
protected $itemsSummaryMax = 16;
@@ -48,11 +50,12 @@ abstract class Invoice_TCPDF extends TCPDF {
parent::__construct();
$this->io = $io;
$this->co = Company::instance();
// Set up the invoice
$this->SetCreator('Open Source Billing');
$this->SetAuthor(Company::name());
$this->SetTitle(sprintf('%s Invoice',Company::name()));
$this->SetAuthor($this->co->name());
$this->SetTitle(sprintf('%s Invoice',$this->co->name()));
$this->SetSubject(sprintf('Invoice #%06s',$this->io->id()));
$this->SetKeywords($this->io->id());
$this->SetAutoPageBreak(TRUE,25);

View File

@@ -23,7 +23,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
public function drawCompanyLogo() {
$x = 9; $y = 7;
$size = 25;
$logo = Config::logo_file();
$logo = $this->co->logo_file();
if (is_file($logo))
$this->Image($logo,$x,$y,$size);
@@ -37,17 +37,17 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$x = 40; $y = 7;
$this->SetFont('helvetica','B',10);
$this->SetXY($x,$y); $this->Cell(0,0,Company::name()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,$this->co->name()); $y += 4;
$this->SetFont('helvetica','',10);
$this->SetXY($x,$y); $this->Cell(0,0,Company::taxid()); $y += 6;
$this->SetXY($x,$y); $this->Cell(0,0,$this->co->taxid()); $y += 6;
$this->SetXY($x,$y); $this->Cell(0,0,Company::street(', ')); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',Company::city(),Company::state(),Company::pcode())); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,$this->co->street(', ')); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$this->co->city(),$this->co->state(),$this->co->pcode())); $y += 4;
$y += 2;
$this->SetXY($x,$y); $this->Cell(0,0,'Phone:'); $this->SetXY($x+16,$y); $this->Cell(0,0,Company::phone()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,'Fax:'); $this->SetXY($x+16,$y); $this->Cell(0,0,Company::fax()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,'Phone:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$this->co->phone()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,'Fax:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$this->co->fax()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,'Web:'); $this->SetXY($x+16,$y); $this->addHtmlLink(URL::base(TRUE,TRUE),URL::base(TRUE,TRUE)); $y += 4;
}
@@ -65,7 +65,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$this->SetFont('helvetica','',8);
$this->SetXY($x,$y); $this->Cell(0,0,_('Please return this portion with your cheque or money order')); $y +=3;
$this->SetXY($x,$y); $this->Cell(0,0,_('made payable to').' '.Company::name());
$this->SetXY($x,$y); $this->Cell(0,0,_('made payable to').' '.$this->co->name());
// Due Date
$x = 110; $y = 200;
@@ -91,9 +91,9 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
// Company Address
$y = 216;
$this->SetFont('helvetica','',10);
$this->SetXY(18,$y); $this->Cell(0,0,Company::name()); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,Company::street(', ')); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,sprintf('%s, %s %s',Company::city(),Company::state(),Company::pcode())); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,$this->co->name()); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,$this->co->street(', ')); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,sprintf('%s, %s %s',$this->co->city(),$this->co->state(),$this->co->pcode())); $y += 4;
// Previous Due
$y = 215;

View File

@@ -4,8 +4,8 @@
<td style="vertical-align: top">
<table class="company_details" border="0">
<tr>
<td class="logo"><?php echo Config::logo(); ?></td>
<td class="address"><span class="company_name"><?php echo Company::name(); ?></span><br/><?php echo Company::address(); ?><br/><?php echo Company::contacts(); ?></td>
<td class="logo"><?php echo Company::instance()->logo(); ?></td>
<td class="address"><span class="company_name"><?php echo Company::instance()->name(); ?></span><br/><?php echo Company::instance()->address(); ?><br/><?php echo Company::instance()->contacts(); ?></td>
</tr>
</table>
</td>

View File

@@ -4,14 +4,14 @@
<td style="vertical-align: top">
<table class="company_details" border="0">
<tr>
<td class="logo"><?php echo Config::logo(); ?></td>
<td class="logo"><?php echo Company::instance()->logo(); ?></td>
<td class="address">
<span class="company_name"><?php echo Company::name(); ?></span><br/>
<?php echo Company::taxid(); ?><br/>
<span class="company_name"><?php echo Company::instance()->name(); ?></span><br/>
<?php echo Company::instance()->taxid(); ?><br/>
<br/>
<?php echo Company::address(); ?><br/>
<?php echo Company::instance()->address(); ?><br/>
<br/>
<?php echo Company::contacts(); ?>
<?php echo Company::instance()->contacts(); ?>
</td>
</tr>
</table>
@@ -85,7 +85,7 @@
$lp = $ito->product_id; ?>
<!-- Service Information -->
<tr class="head">
<td><?php echo HTML::anchor('/user/service/view/'.$ito->service_id,$ito->service->id()); ?></td>
<td><?php echo HTML::anchor(URL::link('user','service/view/'.$ito->service_id),$ito->service->id()); ?></td>
<td colspan="5"><?php printf('%s - %s',$ito->product->name(),$ito->service->name()); ?> (<?php echo $ito->product_id; ?>)</td>
<td class="right"><?php echo ($i++==0 ? Currency::display($io->items_service_total($ito->service_id)) : '&nbsp;');?></td>
</tr>
@@ -213,6 +213,6 @@
</td>
</tr>
<tr>
<td><?php echo HTML::anchor('user/invoice/download/'.$io->id,'Download detailed invoice'); ?></td>
<td><?php echo HTML::anchor(URL::link('user','invoice/download/'.$io->id),'Download detailed invoice'); ?></td>
</tr>
</table>