Fixes to OSB to work with KH 3.3

This commit is contained in:
Deon George
2012-11-10 10:13:57 +11:00
parent ea36639638
commit 6db02ae77d
238 changed files with 813 additions and 938 deletions

View File

@@ -43,7 +43,7 @@ class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('System Customer Invoices'),
'body'=>Table::display(
ORM::factory('invoice')->find_all(),
ORM::factory('Invoice')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),

View File

@@ -20,7 +20,7 @@ class Controller_Task_Invoice extends Controller_Task {
public function action_list() {
$mode = $this->request->param('id');
$i = ORM::factory('invoice');
$i = ORM::factory('Invoice');
$tm = 'list_'.$mode;
if (! method_exists($i,$tm))
@@ -59,9 +59,9 @@ class Controller_Task_Invoice extends Controller_Task {
public function action_remind_due() {
$action = array();
$key = 'remind_due';
$days = ORM::factory('invoice')->config('REMIND_DUE');
$days = ORM::factory('Invoice')->config('REMIND_DUE');
foreach (ORM::factory('invoice')->list_due(time()+86400*$days) as $io) {
foreach (ORM::factory('Invoice')->list_due(time()+86400*$days) as $io) {
// @todo Use another option to supress reminders
// If we have already sent a reminder, we'll skip to the next one.
if (($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again')) OR ($io->account->invoice_delivery != 1))
@@ -105,7 +105,7 @@ class Controller_Task_Invoice extends Controller_Task {
case 1:
case 2:
case 3:
$days = ORM::factory('invoice')->config('REMIND_OVERDUE_'.$notice);
$days = ORM::factory('Invoice')->config('REMIND_OVERDUE_'.$notice);
break;
default:
@@ -115,7 +115,7 @@ class Controller_Task_Invoice extends Controller_Task {
$key = 'remind_overdue_'.$notice;
foreach (ORM::factory('invoice')->list_overdue_billing(time()-86400*$days,FALSE) as $io) {
foreach (ORM::factory('Invoice')->list_overdue_billing(time()-86400*$days,FALSE) as $io) {
// @todo Use another option to supress reminders
// If we have already sent a reminder, we'll skip to the next one.
if (($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again')) OR ($io->account->invoice_delivery != 1))
@@ -154,7 +154,7 @@ class Controller_Task_Invoice extends Controller_Task {
*/
public function action_services() {
// Used to only process X invoices in a row.
$max = ORM::factory('invoice')->config('GEN_INV_MAX');
$max = ($x=Kohana::$config->load('debug')->invoice) ? $x : ORM::factory('Invoice')->config('GEN_INV_MAX');
// Our service next billing dates that need to be updated if this is successful.
$snd = array();
// Our charges that need to be updated if this is successful.
@@ -162,7 +162,7 @@ class Controller_Task_Invoice extends Controller_Task {
// If we are invoicing a specific service
$sid = is_null($this->request->param('id')) ? NULL : explode(':',$this->request->param('id'));
// Sort our service by account_id, then we can generate 1 invoice.
$svs = ORM::factory('service')->list_invoicesoon()->as_array();
$svs = ORM::factory('Service')->list_invoicesoon()->as_array();
Sort::MAsort($svs,'account_id,date_next_invoice');
$aid = $due = $io = NULL;
@@ -186,7 +186,7 @@ class Controller_Task_Invoice extends Controller_Task {
break;
// Start a new invoice.
$io = ORM::factory('invoice');
$io = ORM::factory('Invoice');
$io->due_date = $due = $io->min_due($so->date_next_invoice);
$io->account_id = $aid = $so->account_id;
$io->status = TRUE;
@@ -210,7 +210,7 @@ class Controller_Task_Invoice extends Controller_Task {
$snd[$so->id] = $pdata['end_time']+86400;
// Check if there are any charges
$c = ORM::factory('charge')
$c = ORM::factory('Charge')
->where('service_id','=',$so->id)
->where('status','=',0)
->where('sweep_type','=',6); // @todo This needs to be dynamic, not "6"
@@ -244,7 +244,7 @@ class Controller_Task_Invoice extends Controller_Task {
// Update our service next billing dates.
// @todo Catch any update errors
foreach ($snd as $sid=>$date) {
$so = ORM::factory('service',$sid);
$so = ORM::factory('Service',$sid);
$so->date_next_invoice = $date;
$so->save();
}
@@ -252,7 +252,7 @@ class Controller_Task_Invoice extends Controller_Task {
// Update any processed charges as such
// @todo Catch any update errors
foreach ($chgs as $cid) {
$co = ORM::factory('charge',$cid);
$co = ORM::factory('Charge',$cid);
$co->status=1;
$co->save();
}
@@ -262,7 +262,7 @@ class Controller_Task_Invoice extends Controller_Task {
public function action_send() {
// Used to only process X invoices in a row.
$max = ORM::factory('invoice')->config('EMAIL_INV_MAX');
$max = ORM::factory('Invoice')->config('EMAIL_INV_MAX');
$action = array();
$iid = $this->request->param('id');
@@ -272,7 +272,7 @@ class Controller_Task_Invoice extends Controller_Task {
list($iid,$x) = explode(':',$iid);
// Get our list of invoices to send
$i = $iid ? ORM::factory('invoice')->where('id','=',$iid) : ORM::factory('invoice')->list_tosend();
$i = $iid ? ORM::factory('Invoice')->where('id','=',$iid) : ORM::factory('Invoice')->list_tosend();
$key = 'send';
@@ -288,7 +288,7 @@ class Controller_Task_Invoice extends Controller_Task {
// Send our email
$et = Email_Template::instance('task_invoice_'.$key);
$token = ORM::factory('module_method_token')
$token = ORM::factory('Module_Method_Token')
->method(array('invoice','user_download'))
->account($io->account)
->expire(time()+86400*21)
@@ -324,7 +324,7 @@ class Controller_Task_Invoice extends Controller_Task {
public function action_audit_invoice_items() {
$output = '';
foreach (ORM::factory('invoice_item')->find_all() as $iio) {
foreach (ORM::factory('Invoice_Item')->find_all() as $iio) {
if ($iio->product_name AND $iio->product_id) {
if (md5(strtoupper($iio->product_name)) == md5(strtoupper($iio->product->name()))) {
$iio->product_name = NULL;

View File

@@ -49,7 +49,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
public function action_view() {
list($id,$output) = Table::page(__METHOD__);
$io = ORM::factory('invoice',$id);
$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()))) {
$this->template->content = 'Unauthorised or doesnt exist?';
@@ -123,7 +123,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
* Download an invoice
*/
public function action_download() {
$io = ORM::factory('invoice',$this->request->param('id'));
$io = ORM::factory('Invoice',$this->request->param('id'));
$this->response->body(Invoice::instance($io)->pdf()->Output(sprintf('%s.pdf',$io->refnum()),'D'));
$this->response->headers(array('Content-Type' => 'application/pdf'));

View File

@@ -87,14 +87,14 @@ SELECT i.id AS iid,i.due_date AS due FROM ab_invoice i,ab_invoice_item ii WHERE
// @todo Function Not Used
public static function balance($id) {
return ORM::factory('invoice',$id)->due();
return ORM::factory('Invoice',$id)->due();
}
/**
* Generate a PDF invoice
*/
public function pdf() {
$invoice_class = sprintf('invoice_tcpdf_%s',Kohana::config('invoice.driver'));
$invoice_class = sprintf('Invoice_TCPDF_%s',ucfirst(Kohana::$config->load('invoice')->driver));
$pdf = new $invoice_class($this->io);

View File

@@ -357,9 +357,9 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
// Calculate our rounding error
// @todo This shouldnt be required.
$subtotal = round($subtotal-$this->io->discount_amt,Kohana::config('config.currency_format'));
$subtotal = Currency::round($subtotal-$this->io->discount_amt);
if (round($this->io->subtotal(),Kohana::config('config.currency_format')) != $subtotal) {
if (Currency::round($this->io->subtotal()) != $subtotal) {
$this->SetFont('helvetica','',9);
$this->SetX($x);
$this->Cell(0,0,'Other');

View File

@@ -377,13 +377,13 @@ class Model_Invoice extends ORM_OSB {
$c = count($this->invoice_items);
$this->invoice_items[$c] = ORM::factory('invoice_item');
$this->invoice_items[$c] = ORM::factory('Invoice_Item');
return $this->invoice_items[$c];
}
public function min_due($date) {
return strtotime(date('Y-M-d',($date < time()) ? time()+ORM::factory('invoice')->config('DUE_DAYS_MIN')*86400 : $date));
return strtotime(date('Y-M-d',($date < time()) ? time()+ORM::factory('Invoice')->config('DUE_DAYS_MIN')*86400 : $date));
}
public function save(Validation $validation = NULL) {
@@ -577,7 +577,7 @@ class Model_Invoice extends ORM_OSB {
* @todo This should be optimised a little to return only invoices to send, instead of looking for them.
*/
public function list_tosend() {
return ORM::factory('invoice')->where_active()->where_open()->where('print_status','is',NULL)->or_where('print_status','!=',1)->where_close();
return ORM::factory('Invoice')->where_active()->where_open()->where('print_status','is',NULL)->or_where('print_status','!=',1)->where_close();
}
public function html() {

View File

@@ -169,7 +169,7 @@ class Model_Invoice_Item extends ORM_OSB {
// Need to save the discounts associated with the invoice_item
if ($this->saved()) {
$iito = ORM::factory('invoice_item_tax');
$iito = ORM::factory('Invoice_Item_Tax');
if ($this->subitems_loaded) {
foreach (array('tax') as $i)

View File

@@ -64,7 +64,7 @@
<table class="box-full" border="0">
<?php if ($items) { ?>
<?php foreach ($io->items_services($items) as $sid => $ito) { ?>
<?php $so = ORM::factory('service',$sid); ?>
<?php $so = ORM::factory('Service',$sid); ?>
<!-- Product Information -->
<tr class="head">
<td><?php echo $so->id(); ?></td>
@@ -122,7 +122,7 @@
</tr>
<?php
foreach ($io->tax_summary() as $tid => $amount) {
$m = ORM::factory('tax',$tid);
$m = ORM::factory('Tax',$tid);
?>
<tr>
<td>&nbsp;</td>

View File

@@ -189,7 +189,7 @@
<td class="head" colspan="4">Taxes Included:</td>
</tr>
<?php foreach ($io->tax_summary() as $tid => $amount) {
$m = ORM::factory('tax',$tid); ?>
$m = ORM::factory('Tax',$tid); ?>
<tr>
<td>&nbsp;</td>
<td><?php echo $m->description; ?></td>