Site/Module setup work and auto_format fixes

This commit is contained in:
Deon George
2012-01-02 12:35:47 +11:00
parent 407eed04c9
commit a464d73f9a
19 changed files with 138 additions and 26 deletions

View File

@@ -24,7 +24,7 @@ class Model_Host_Server extends ORMOSB {
return $po->manage_button($u,$p,$d);
}
public function config() {
public function prov_plugin_data() {
if (! $this->provision_plugin_data)
throw new Kohana_Exception('No plugin configuration data');

View File

@@ -95,7 +95,7 @@ class Plesk {
}
private function server_command(XML $xml) {
$hs = $this->hso->config();
$hs = $this->hso->prov_plugin_data();
$request = Request::factory(sprintf('%s/%s',$this->hso->manage_url,$this->path))
->method('POST');

View File

@@ -17,8 +17,18 @@
class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'list'=>TRUE,
'setup'=>TRUE,
);
public function action_setup() {
$this->setup(array(
'GEN_DAYS'=>_('Generate Invoices this many days in advance of the due date'),
'GEN_SOON_DAYS'=>_('Days before GEN_DAYS to list invoices that will be generated'),
'TAX_ID'=>_('TAX ID shown on invoices'),
'TAX_ID_NAME'=>_('TAX ID name shown on invoices'),
));
}
/**
* Show a list of invoices
*/

View File

@@ -42,7 +42,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$this->SetFont('helvetica','',10);
$this->SetXY($x,$y); $this->Cell(0,0,Company::taxid()); $y += 6;
$this->SetXY($x,$y); $this->Cell(0,0,Company::street()); $y += 4;
$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;
$y += 2;
@@ -92,7 +92,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$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,Company::street(', ')); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,sprintf('%s, %s %s',Company::city(),Company::state(),Company::pcode())); $y += 4;
// Previous Due
@@ -122,7 +122,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
else
$name = $this->io->account->name();
$this->SetXY($x,$y); $this->Cell(0,0,html_entity_decode($name,ENT_NOQUOTES)); $y += 5;
$this->SetXY($x,$y); $this->Cell(0,0,html_entity_decode($name,ENT_NOQUOTES)); $y += 5;
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s %s ',$this->io->account->address1,$this->io->account->address2)); $y += 5;
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$this->io->account->city,$this->io->account->state,$this->io->account->zip)); $y += 5;
}

View File

@@ -525,7 +525,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('Services to Invoice'),
'body'=>Table::display(
ORM::factory('service')->list_invoicesoon(),
ORM::factory('service')->list_invoicesoon(ORM::factory('invoice')->config('GEN_SOON_DAYS')),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),

View File

@@ -147,14 +147,13 @@ class Model_Service extends ORMOSB {
/**
* List services that need to be billed.
*
* @param $days int Additional number of days to add to the query, above the module config.
*/
public function list_invoicesoon() {
// @todo This needs to be configurable
$days = 35;
public function list_invoicesoon($days=0) {
return $this->_list_active()
->where_open()->where('suspend_billing','IS',NULL)->or_where('suspend_billing','=','0')->where_close()
->where('date_next_invoice','<',time()+$days*86400)
->where('date_next_invoice','<',time()+(ORM::factory('invoice')->config('GEN_DAYS')+$days)*86400)
->find_all();
}

View File

@@ -60,19 +60,19 @@ class Model_Task extends ORMOSB {
$this->date_run = time();
$this->running = 0;
$this->running_host = NULL;
$this->save();
$tlo->result = 0;
$tlo->message = $r->body();
}
catch (Exception $e) {
$tlo->result = $e->getCode();
$tlo->message = $e->getMessage();
$tlo->message = Kohana_Exception::text($e);
$this->running = 0;
$this->running_host = NULL;
$this->save();
$this->running = 1;
$this->running_host = 'ERROR';
}
$this->save();
}
if ($this->log)