Added Bulk Payments
This commit is contained in:
parent
f0c1f8800e
commit
8d53924988
@ -59,8 +59,8 @@ class Config extends lnApp_Config {
|
|||||||
return Company::name();
|
return Company::name();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function siteid() {
|
public static function siteid($format=FALSE) {
|
||||||
return Config::instance()->loadsite()->so->id;
|
return $format ? sprintf('%02s',Config::instance()->loadsite()->so->id) : Config::instance()->loadsite()->so->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sitemode() {
|
public static function sitemode() {
|
||||||
|
@ -45,7 +45,7 @@ class Model_Account extends Model_Auth_UserDefault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function accnum() {
|
public function accnum() {
|
||||||
return sprintf('%02s-%04s',Config::siteid(),$this->id);
|
return sprintf('%s-%04s',Config::siteid(TRUE),$this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function title($name) {
|
public function title($name) {
|
||||||
|
@ -67,7 +67,7 @@ class ORM extends Kohana_ORM {
|
|||||||
$value = $this->__get($column);
|
$value = $this->__get($column);
|
||||||
|
|
||||||
// If some of our fields need to be formated for display purposes.
|
// If some of our fields need to be formated for display purposes.
|
||||||
if ($this->_loaded AND ! $this->_formated AND $this->_display_filters)
|
if (! $this->_formated AND $this->_display_filters)
|
||||||
$this->_format();
|
$this->_format();
|
||||||
|
|
||||||
if (isset($this->_object_formated[$column]))
|
if (isset($this->_object_formated[$column]))
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
||||||
protected $secure_actions = array(
|
protected $secure_actions = array(
|
||||||
'add'=>TRUE,
|
'add'=>TRUE,
|
||||||
|
'addbulk'=>TRUE,
|
||||||
'list'=>TRUE,
|
'list'=>TRUE,
|
||||||
'view'=>TRUE,
|
'view'=>TRUE,
|
||||||
'autocomplete'=>FALSE,
|
'autocomplete'=>FALSE,
|
||||||
@ -203,5 +204,38 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
|||||||
'body'=>$this->add_view($id,$output),
|
'body'=>$this->add_view($id,$output),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function action_addbulk() {
|
||||||
|
$supported = array(
|
||||||
|
'ezypay'=>'Ezypay',
|
||||||
|
);
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
if ($_POST AND isset($_POST['payer'])) {
|
||||||
|
$c = sprintf('payment_bulk_%s',$_POST['payer']);
|
||||||
|
$o = new $c();
|
||||||
|
|
||||||
|
if (! $_FILES) {
|
||||||
|
$output .= $o->form();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$output .= $o->process();
|
||||||
|
}
|
||||||
|
|
||||||
|
// We dont know what sort of payment type yet
|
||||||
|
} else {
|
||||||
|
$output .= Form::open();
|
||||||
|
$output .= Form::select('payer',$supported);
|
||||||
|
$output .= Form::submit('submit','submit',array('class'=>'form_button'));
|
||||||
|
$output .= Form::close();
|
||||||
|
}
|
||||||
|
|
||||||
|
Block::add(array(
|
||||||
|
'title'=>_('Bulk Payments Received'),
|
||||||
|
'body'=>$output,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
104
modules/payment/classes/payment/bulk/ezypay.php
Normal file
104
modules/payment/classes/payment/bulk/ezypay.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is for processing Ezypay payments.
|
||||||
|
*
|
||||||
|
* @package Payment/Ezypay
|
||||||
|
* @subpackage System
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Open Source Billing
|
||||||
|
* @license http://dev.osbill.net/license.html
|
||||||
|
*/
|
||||||
|
class Payment_Bulk_Ezypay {
|
||||||
|
public function form() {
|
||||||
|
$return = '';
|
||||||
|
|
||||||
|
$return .= Form::open(NULL,array('enctype'=>'multipart/form-data'));
|
||||||
|
$return .= Form::hidden('payer',$_POST['payer']);
|
||||||
|
$return .= View::factory('payment/admin/addbulk/ezypay');
|
||||||
|
$return .= Form::submit('submit','submit',array('class'=>'form_button'));
|
||||||
|
$return .= Form::close();
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process() {
|
||||||
|
$payments = array();
|
||||||
|
|
||||||
|
// Process payment
|
||||||
|
$file = file_get_contents($_FILES['payment']['tmp_name']);
|
||||||
|
$file = explode("\r\n",$file);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach ($file as $line) {
|
||||||
|
// Line 0 is our header
|
||||||
|
if ($i++ == 0 OR ! trim($line))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Trim our whitespace on the end of the line.
|
||||||
|
$line = preg_replace("/\s+$/",'',$line);
|
||||||
|
$array = explode("\t",$line);
|
||||||
|
|
||||||
|
// Field 4 has our account reference
|
||||||
|
if (preg_match('/^'.Config::siteid(TRUE).'-/',$array[4]) AND $array[10] == 'Cleared') {
|
||||||
|
$aid = preg_replace('/^'.Config::siteid(TRUE).'-/','',$array[4]);
|
||||||
|
|
||||||
|
$po = ORM::factory('payment');
|
||||||
|
$po->account_id = $aid;
|
||||||
|
$po->total_amt = $array[7];
|
||||||
|
$po->notes = $array[2].':'.$array[3];
|
||||||
|
$po->date_payment = strtotime(str_replace('/','-',$array[8]));
|
||||||
|
|
||||||
|
$payments[$array[3]] = $po;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = file_get_contents($_FILES['transaction']['tmp_name']);
|
||||||
|
$file = explode("\r\n",$file);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach ($file as $line) {
|
||||||
|
// Line 0 is our header
|
||||||
|
if ($i++ == 0 OR ! trim($line))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Trim our whitespace on the end of the line.
|
||||||
|
$line = preg_replace("/\s+$/",'',$line);
|
||||||
|
$array = explode("\t",$line);
|
||||||
|
|
||||||
|
// Our commission fees
|
||||||
|
// @todo This should be in a config file
|
||||||
|
if (in_array($array[9],array(1,15)))
|
||||||
|
$payments[$array[3]]->fees_amt = (float)$array[7];
|
||||||
|
|
||||||
|
// @todo Hack - since the reports dont show how the payment was made.
|
||||||
|
// @todo Put this in a config file, in the mean time.
|
||||||
|
if ($array[7] == 1.05)
|
||||||
|
$payments[$array[3]]->checkout_plugin_id = 2;
|
||||||
|
else
|
||||||
|
$payments[$array[3]]->checkout_plugin_id = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = '';
|
||||||
|
$return .= View::Factory('payment/admin/addbulk/ezypay/head');
|
||||||
|
|
||||||
|
$total = $fees = 0;
|
||||||
|
foreach ($payments as $po) {
|
||||||
|
$po->save();
|
||||||
|
|
||||||
|
$total += $po->total_amt;
|
||||||
|
$fees += $po->fees_amt;
|
||||||
|
|
||||||
|
$return .= View::Factory('payment/admin/addbulk/ezypay/body')
|
||||||
|
->set('o',$po);
|
||||||
|
}
|
||||||
|
|
||||||
|
$return .= View::Factory('payment/admin/addbulk/ezypay/foot')
|
||||||
|
->set('total',$total)
|
||||||
|
->set('fees',$fees);;
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
13
modules/payment/views/payment/admin/addbulk/ezypay.php
Normal file
13
modules/payment/views/payment/admin/addbulk/ezypay.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">Ezypay Payment</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Payment File (BillDetails)</td>
|
||||||
|
<td><?php echo Form::file('payment'); ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Transaction File (AddItems)</td>
|
||||||
|
<td><?php echo Form::file('transaction'); ?></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
@ -0,0 +1,7 @@
|
|||||||
|
<tr>
|
||||||
|
<td><?php echo $o->display('id'); ?></td>
|
||||||
|
<td><?php echo $o->display('date_payment'); ?></td>
|
||||||
|
<td><?php echo $o->display('total_amt'); ?></td>
|
||||||
|
<td><?php echo $o->display('fees_amt'); ?></td>
|
||||||
|
<td><?php echo $o->display('notes'); ?></td>
|
||||||
|
</tr>
|
@ -0,0 +1,6 @@
|
|||||||
|
<tr class="head">
|
||||||
|
<td colspan="2"> </td>
|
||||||
|
<td><?php echo $total; ?></td>
|
||||||
|
<td><?php echo $fees; ?></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
@ -0,0 +1,8 @@
|
|||||||
|
<table>
|
||||||
|
<tr class="head">
|
||||||
|
<td>Payment ID</td>
|
||||||
|
<td>Date Payment</td>
|
||||||
|
<td>Amount</td>
|
||||||
|
<td>Fees</td>
|
||||||
|
<td>Transaction ID</td>
|
||||||
|
</tr>
|
Reference in New Issue
Block a user