diff --git a/application/classes/Controller/Admin/Welcome.php b/application/classes/Controller/Admin/Welcome.php index fc0df636..70da6455 100644 --- a/application/classes/Controller/Admin/Welcome.php +++ b/application/classes/Controller/Admin/Welcome.php @@ -105,6 +105,7 @@ class Controller_Admin_Welcome extends Controller_Welcome { )); // We are a site administrator + $output = ''; if ($this->ao->rtm_id == NULL) { $rtmo = ORM::factory('RTM',array('account_id','=',$this->ao->id))->find(); @@ -116,7 +117,7 @@ class Controller_Admin_Welcome extends Controller_Welcome { ->set('o',$rtmo); } else { - $rtmo = ORM::factory('RTM',$this->ao->rmt_id); + $rtmo = ORM::factory('RTM',$this->ao->rtm_id); } if ($output) diff --git a/application/classes/Controller/TemplateDefault/User.php b/application/classes/Controller/TemplateDefault/User.php index 1fad17cb..3983d57d 100644 --- a/application/classes/Controller/TemplateDefault/User.php +++ b/application/classes/Controller/TemplateDefault/User.php @@ -10,14 +10,5 @@ * @license http://dev.osbill.net/license.html */ class Controller_TemplateDefault_User extends Controller_TemplateDefault { - public function after() { - SystemMessage::add(array( - 'title'=>'Retire this class extension', - 'type'=>'info', - 'body'=>__METHOD__, - )); - - return parent::after(); - } } ?> diff --git a/application/classes/Model/RTM.php b/application/classes/Model/RTM.php index 0f84c051..635ee2b1 100644 --- a/application/classes/Model/RTM.php +++ b/application/classes/Model/RTM.php @@ -36,7 +36,7 @@ class Model_RTM extends ORM_OSB { } public function customers_direct() { - return $this->customer->where_active()->find_all(); + return $this->customer->find_all(); } } ?> diff --git a/application/classes/Task/Account/Complete.php b/application/classes/Task/Account/Complete.php new file mode 100644 index 00000000..0a5f89fc --- /dev/null +++ b/application/classes/Task/Account/Complete.php @@ -0,0 +1,33 @@ +where_active(); + + foreach ($o->find_all() as $ao) { + if (count($ao->invoice->where_unprocessed()->find_all()) == 0 AND count($ao->service->where_active()->find_all()) == 0) + // @todo Cant update status=0, problem with sessions in CLI + echo $ao->id.','; + + $ao->save(); + + if ($ao->saved()) + $c++; + } + + printf('%s services updated',$c); + } +} +?> diff --git a/modules/adsl/classes/Model/ADSL/Plan.php b/modules/adsl/classes/Model/ADSL/Plan.php index ca77f8d4..01d120bd 100644 --- a/modules/adsl/classes/Model/ADSL/Plan.php +++ b/modules/adsl/classes/Model/ADSL/Plan.php @@ -13,7 +13,7 @@ class Model_ADSL_Plan extends ORM_OSB { // Relationships // @todo This model should probably be joined with product_plugin_adsl protected $_belongs_to = array( - 'adsl_supplier_plan'=>array(), + 'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan'), ); protected $_display_filters = array( diff --git a/modules/adsl/classes/Model/ADSL/Supplier.php b/modules/adsl/classes/Model/ADSL/Supplier.php index b549b320..abb7e83c 100644 --- a/modules/adsl/classes/Model/ADSL/Supplier.php +++ b/modules/adsl/classes/Model/ADSL/Supplier.php @@ -9,10 +9,10 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Adsl_Supplier extends ORM_OSB { +class Model_ADSL_Supplier extends ORM_OSB { // Relationships protected $_has_many = array( - 'adsl_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'), + 'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'), ); protected $_updated_column = FALSE; diff --git a/modules/adsl/classes/Model/ADSL/Supplier/Plan.php b/modules/adsl/classes/Model/ADSL/Supplier/Plan.php index f22de340..b60861e3 100644 --- a/modules/adsl/classes/Model/ADSL/Supplier/Plan.php +++ b/modules/adsl/classes/Model/ADSL/Supplier/Plan.php @@ -9,13 +9,13 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Adsl_Supplier_Plan extends ORM_OSB { +class Model_ADSL_Supplier_Plan extends ORM_OSB { // Relationships protected $_has_many = array( - 'adsl_plan'=>array('far_key'=>'id'), + 'adsl_plan'=>array('model'=>'ADSL_Plan','far_key'=>'id'), ); protected $_belongs_to = array( - 'adsl_supplier'=>array('foreign_key'=>'supplier_id'), + 'adsl_supplier'=>array('model'=>'ADSL_Supplier','foreign_key'=>'supplier_id'), ); /** diff --git a/modules/adsl/classes/Model/Product/Plugin/Adsl.php b/modules/adsl/classes/Model/Product/Plugin/Adsl.php index 006a9a92..0d4bc8b6 100644 --- a/modules/adsl/classes/Model/Product/Plugin/Adsl.php +++ b/modules/adsl/classes/Model/Product/Plugin/Adsl.php @@ -13,7 +13,7 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin { protected $_table_name = 'adsl_plan'; protected $_belongs_to = array( - 'adsl_supplier_plan'=>array(), + 'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan'), ); protected $_display_filters = array( diff --git a/modules/adsl/classes/Service/Traffic/Adsl.php b/modules/adsl/classes/Service/Traffic/Adsl.php index 260d1993..2e93be28 100644 --- a/modules/adsl/classes/Service/Traffic/Adsl.php +++ b/modules/adsl/classes/Service/Traffic/Adsl.php @@ -33,7 +33,7 @@ class Service_Traffic_Adsl { // Our DB record must be the suffix of this class name $supplier = preg_replace('/^'.get_parent_class($this).'_/','',get_class($this)); - $so = ORM::factory('Adsl_Supplier') + $so = ORM::factory('ADSL_Supplier') ->where('name','=',$supplier) ->find(); diff --git a/modules/cart/classes/Controller/Cart.php b/modules/cart/classes/Controller/Cart.php index 5dff9205..24820d1e 100644 --- a/modules/cart/classes/Controller/Cart.php +++ b/modules/cart/classes/Controller/Cart.php @@ -10,6 +10,8 @@ * @license http://dev.osbill.net/license.html */ class Controller_Cart extends Controller_TemplateDefault { + protected $auth_required = FALSE; + /** * List the cart contents */ diff --git a/modules/checkout/classes/Checkout/Plugin/Paypal.php b/modules/checkout/classes/Checkout/Plugin/Paypal.php index cea00c61..2c5ac346 100644 --- a/modules/checkout/classes/Checkout/Plugin/Paypal.php +++ b/modules/checkout/classes/Checkout/Plugin/Paypal.php @@ -69,7 +69,7 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { return _('Thank you!'); if (! $debug_mode) { - $request = Request::factory(sprintf('https://%s/cgi-bin/webscr',$cno->data['test_ipn'] ? $this->url_test : $this->url_prod)) + $request = Request::factory(sprintf('https://%s/cgi-bin/webscr',isset($cno->data['test_ipn']) ? $this->url_test : $this->url_prod)) ->method('POST'); $request->client()->options(Arr::merge($this->curlopts,array( @@ -84,7 +84,6 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { // Verify that the IPN is for us. // @todo This should be in the DB. if ($cno->data['business'] == 'deon_1260578114_biz@graytech.net.au') { - switch ($cno->data['payment_status']) { case 'Completed': // Our cart items total. diff --git a/modules/checkout/classes/Controller/Checkout.php b/modules/checkout/classes/Controller/Checkout.php index 33dbbf3c..014a8ae4 100644 --- a/modules/checkout/classes/Controller/Checkout.php +++ b/modules/checkout/classes/Controller/Checkout.php @@ -59,7 +59,7 @@ class Controller_Checkout extends Controller_TemplateDefault { $test_id = FALSE; $co = ORM::factory('Checkout',$this->request->param('id')); - if ((! $co->loaded() OR ! Request::current()->post()) AND ! $test_id=Kohana::$config->load('debug')->checkout_notify) + if ((! $co->loaded() OR ! Request::current()->post()) AND ! ($test_id=Kohana::$config->load('debug')->checkout_notify)) throw HTTP_Exception::factory(404,'Payment not found!'); $this->auto_render = FALSE; diff --git a/modules/export/classes/Export/Quicken.php b/modules/export/classes/Export/Quicken.php index c192f76b..93e71edc 100644 --- a/modules/export/classes/Export/Quicken.php +++ b/modules/export/classes/Export/Quicken.php @@ -175,14 +175,14 @@ class Export_Quicken extends Export { $qpo->MEMO = sprintf('Payment for invoice(s) %s (%s)',implode(':',$invoice_ids),$po->checkout->name); // @todo Accounts/Payment should be configurable - switch ($po->checkout->checkout_plugin) { + switch ($po->checkout->plugin) { // @todo this is direct debit - case 'MANUAL': + case 'DD_EZYPAY': $qpo->PAYMETH = 'DirectDebit'; $qpo->ACCNT = 'Ezypay'; break; - case 'REMIT_CHECK': + case 'REMIT_CHEQUE': $qpo->PAYMETH = 'Cheque'; $qpo->ACCNT = 'Undeposited Funds'; break; @@ -192,7 +192,7 @@ class Export_Quicken extends Export { $qpo->ACCNT = 'Bendigo Bank'; break; - case 'PAYPAL': + case 'PAYPAL_CART': $qpo->PAYMETH = 'Paypal'; $qpo->ACCNT = 'Paypal'; break; diff --git a/modules/host/classes/Host/Plugin/Cpanel.php b/modules/host/classes/Host/Plugin/Cpanel.php new file mode 100644 index 00000000..9068e698 --- /dev/null +++ b/modules/host/classes/Host/Plugin/Cpanel.php @@ -0,0 +1,81 @@ +_object; + } + public function unserialize($s) { + $this->_object = XML::factory(NULL,NULL,$s); + } + + public function __get($index) { +echo __METHOD__;die(); + } + + public function admin_update() { +echo __METHOD__;die(); + } + + public function manage_button(Model_Service_Plugin_Host $spho,$t) { + return $this->render_button($t,$spho->service_id,$spho->username_value(),substr(md5($spho->password_value()),0,8)); + } + public function admin_manage_button(Model_Host_Server $hso,$t) { + return $this->render_button($t,$hso->id,substr(md5($hso->manage_username),0,8),substr(md5($hso->manage_password),0,8)); + } + + protected function render_button($t,$sid,$u,$p) { + $debug = FALSE; + $output = ''; + + $output .= Form::open( + $debug ? 'debug/site' : sprintf('%s/%s',$this->hso->manage_url,$this->url), + array('target'=>'w24','method'=>'post','id'=>sprintf('id_%s_%s',$sid,$t)) + ); + $output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t))); + $output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t))); + $output .= Form::close(); + $output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$sid,$t))); + + return $output; + } + + protected function init() { +echo __METHOD__;die(); + } + + protected function server_command(XML $xml) { +echo __METHOD__;die(); + } + + public function loaded() { + return $this->_loaded; + } + + private function render(XML $xml) { +echo __METHOD__;die(); + } +} +?> diff --git a/modules/host/classes/Host/Plugin/Cpanel/11.php b/modules/host/classes/Host/Plugin/Cpanel/11.php new file mode 100644 index 00000000..12311125 --- /dev/null +++ b/modules/host/classes/Host/Plugin/Cpanel/11.php @@ -0,0 +1,100 @@ + diff --git a/modules/invoice/classes/Task/Invoice/Complete.php b/modules/invoice/classes/Task/Invoice/Complete.php index 17f77c60..c5fd705b 100644 --- a/modules/invoice/classes/Task/Invoice/Complete.php +++ b/modules/invoice/classes/Task/Invoice/Complete.php @@ -14,7 +14,6 @@ class Task_Invoice_Complete extends Task { $c = 0; $o = ORM::factory('Invoice') - ->where_active() ->where_unprocessed(); foreach ($o->find_all() as $io) { diff --git a/modules/payment/classes/Model/Payment.php b/modules/payment/classes/Model/Payment.php index 85e64307..9df00880 100644 --- a/modules/payment/classes/Model/Payment.php +++ b/modules/payment/classes/Model/Payment.php @@ -51,9 +51,6 @@ class Model_Payment extends ORM_OSB { * @param $inv number, to allocate payment to an invoice */ public function add_item($invnum) { - if ($this->loaded() and ! $this->payment_items) - throw new Kohana_Exception('Need to load payment_items?'); - // Find our id, if it exists foreach ($this->payment_items as $pio) if ($pio->invoice_id == $invnum) @@ -156,6 +153,7 @@ class Model_Payment extends ORM_OSB { /** LIST FUNCTIONS **/ public function list_unapplied() { + return array(); $pi = array(); // @todo database suffix needs to be dynamically calculated diff --git a/modules/product/classes/Model/Product.php b/modules/product/classes/Model/Product.php index 44f59fcf..a77bf99a 100644 --- a/modules/product/classes/Model/Product.php +++ b/modules/product/classes/Model/Product.php @@ -181,7 +181,7 @@ class Model_Product extends ORM_OSB { */ public function availPriceGroups() { // @todo This needs to be worked out dynamically - return array(0,2); + return array(0,1); } /** diff --git a/modules/service/classes/Controller/Admin/Service.php b/modules/service/classes/Controller/Admin/Service.php index 1bce8947..c9441b32 100644 --- a/modules/service/classes/Controller/Admin/Service.php +++ b/modules/service/classes/Controller/Admin/Service.php @@ -496,7 +496,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { public function action_listadslbilling() { $id = $this->request->param('id'); - $aso = ORM::factory('Adsl_Supplier',$id); + $aso = ORM::factory('ADSL_Supplier',$id); // Process upload // @todo This should be separated out by supplier in case each supplier has a different format @@ -616,37 +616,61 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { if (! $start && preg_match('/^Item ID,/',$line)) { $start = true; continue; + // Items end after "Subtotal" } elseif ($start && ! $end && preg_match('/^Subtotal:,/',$line)) { $end = true; continue; + // If we havent started or not ended, continue } elseif (! $start || $end) { continue; } - // @todo This is to workaround SEP2012 CSV invoice which had extra columns. - if (count(explode(',',$line)) == 9) - list($id,$ref,$unknown,$unknown,$unknown,$linedata,$q,$cost,$total) = explode(',',$line); - elseif (count(explode(',',$line)) == 10) - list($id,$ref,$unknown,$unknown,$unknown,$unknown,$linedata,$q,$cost,$total) = explode(',',$line); - else - list($id,$ref,$unknown,$linedata,$q,$cost,$total) = explode(',',$line); + $record = explode(',',$line); - // Extract the phone number from the $linedata - @list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$linedata))); + // 1 = Item ID (ignore) + // 2 = Reference ID (ignore - its not useful for us) + // 3 = Category (always appears blank) + // 4 = Item Description (has our service number, rental and excess charges description) + // 0nnnnnnnnn - Monthly Internet Charge On Plan XXXXX For billing period (dd/mm/yyyy - dd/mm/yyyy) (7 FIELDED LINES) + // 0nnnnnnnnn - Excess usage charges for March 2013 (8 FIELDED LINES) + // 5 = Quantity + // Always 1 for Plan Fees + // 0nnnnnnnnn@graytech.net.au Excess Usage y GB (for excess charges) + // 6 = Unit Price + // Always 1 for Excess Usage (probably quantity) + // 7 = Total Price + // Unit price for Excess Usage + // 8 = Total Price for Excess Usage - // If the description says Monthly Charge, we know its the monthly fee. - if (preg_match('/^Monthly Charge/',$description)) - $result[$service]['cost'] = preg_replace('/\$/','',$total); - // If the description says VISP credit, we know this is commission. - elseif (preg_match('/^VISP Credit/',$description)) - $result[$service]['credit'] = preg_replace('/\$/','',$total); - // If the description says Excess, we know this is excess charges. - elseif (preg_match('/^Excess usage/',$description)) - $result[$service]['excess'] = preg_replace('/\$/','',$total); - else - $result[$service]['info'] = $line; + if (! count($record) >= 7) + throw Kohana_Exception('Format of CSV file changed? (:record)',array(':record'=>$record)); + + + if (preg_match('/Monthly Internet Charge On Plan /',$record[3])) { + list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3]))); + $result[$service]['cost'] = str_replace('$','',$record[6]); + + } elseif (preg_match('/VISP Credit/',$record[3])) { + list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3]))); + $result[$service]['credit'] = str_replace('$','',$record[6]); + + } elseif (preg_match('/Excess usage charges for /',$record[3])) { + list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3]))); + $result[$service]['excess'] = str_replace('$','',$record[7]); + + // Ignore Payment For Invoice lines + } elseif (preg_match('/Payment For Invoice:/',$record[3])) { + + } else { + try { + list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3]))); + $result[$service]['info'] = $line; + } catch (Exception $e) { + $result['000']['info'] = $line; + } + } } return $result; diff --git a/modules/service/classes/Controller/Task/Service.php b/modules/service/classes/Controller/Task/Service.php index 5e0922b6..a70a5380 100644 --- a/modules/service/classes/Controller/Task/Service.php +++ b/modules/service/classes/Controller/Task/Service.php @@ -11,7 +11,7 @@ */ class Controller_Task_Service extends Controller_Task { private function _traffic_suppliers($active=FALSE) { - $suppliers = ORM::factory('Adsl_Supplier'); + $suppliers = ORM::factory('ADSL_Supplier'); return $active ? $suppliers->list_active() : $suppliers->find_all(); } diff --git a/modules/ssl/classes/Model/Service/Plugin/Ssl.php b/modules/ssl/classes/Model/Service/Plugin/Ssl.php index 661a2bc9..bcb5fd4b 100644 --- a/modules/ssl/classes/Model/Service/Plugin/Ssl.php +++ b/modules/ssl/classes/Model/Service/Plugin/Ssl.php @@ -132,13 +132,13 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin { } public function renew() { - $d = SSL::details($this->cert); + $d = SSL::instance($this->cert); $ssl_conf = Kohana::$config->load('ssl'); // @todo change this so an admin can force this. $force = TRUE; // If our certificate is not old enough skip - if ($d['validTo_time_t'] > time()+$ssl_conf['min_renew_days']*86400 AND ! $force) + if ($d->get_valid_to() > time()+$ssl_conf['min_renew_days']*86400 AND ! $force) return FALSE; $res = openssl_csr_sign($this->csr,$this->SSL_CA->sign_cert,$this->SSL_CA->sign_pk,$this->service->product->plugin()->days,array( diff --git a/modules/ssl/classes/Task/SSL/Renew.php b/modules/ssl/classes/Task/Ssl/Renew.php similarity index 100% rename from modules/ssl/classes/Task/SSL/Renew.php rename to modules/ssl/classes/Task/Ssl/Renew.php