From b74fdc930f8aec9a06ed64af8125363bed26b338 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 25 Aug 2016 13:14:08 +1000 Subject: [PATCH] Ensure site_id is included in ORM::add(), fixed payment revendering, start product category work --- application/classes/DB.php | 2 +- .../classes/Database/Query/Builder/Insert.php | 23 +++++++ application/classes/URL.php | 8 +-- .../classes/Controller/Admin/Payment.php | 57 +---------------- .../payment/views/payment/admin/add_edit.php | 61 ++++++++++++------- modules/product/classes/Model/Product.php | 1 + .../product/views/product/category/list.php | 12 ++++ 7 files changed, 82 insertions(+), 82 deletions(-) create mode 100644 application/classes/Database/Query/Builder/Insert.php create mode 100644 modules/product/views/product/category/list.php diff --git a/application/classes/DB.php b/application/classes/DB.php index 2e885b4b..3f9f5d8b 100644 --- a/application/classes/DB.php +++ b/application/classes/DB.php @@ -11,7 +11,7 @@ */ class DB extends Kohana_DB { // Add the site_id to the delete query - public static function delete($table = NULL) + final public static function delete($table = NULL) { $db = new Database_Query_Builder_Delete($table); diff --git a/application/classes/Database/Query/Builder/Insert.php b/application/classes/Database/Query/Builder/Insert.php new file mode 100644 index 00000000..527c7dbe --- /dev/null +++ b/application/classes/Database/Query/Builder/Insert.php @@ -0,0 +1,23 @@ +_columns = Arr::Merge($this->_columns,['site_id']); + + foreach ($this->_values as $k=>$v) + $this->_values[$k] = Arr::Merge($this->_values[$k],[Site::id()]); + + return parent::compile($db); + } +} +?> diff --git a/application/classes/URL.php b/application/classes/URL.php index 431c101b..785290f9 100644 --- a/application/classes/URL.php +++ b/application/classes/URL.php @@ -23,19 +23,19 @@ class URL extends lnApp_URL { foreach (array_reverse(self::$method_directory) as $k=>$v) switch ($k) { - case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'icon-globe'); + case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'fa-globe'); break; case 'affiliate': - case 'reseller': $result[$k] = array('name'=>'Reseller','icon'=>'icon-th-list'); + case 'reseller': $result[$k] = array('name'=>'Reseller','icon'=>'fa-dashboard'); break; case 'user': if (is_object(Auth::instance()->get_user())) - $result[$k] = array('name'=>Auth::instance()->get_user()->name(),'icon'=>'icon-user'); + $result[$k] = array('name'=>Auth::instance()->get_user()->name(),'icon'=>'fa-user'); break; - default: $result[$k] = array('name'=>$k,'icon'=>'icon-question-sign'); + default: $result[$k] = array('name'=>$k,'icon'=>'fa-question'); } return $result; diff --git a/modules/payment/classes/Controller/Admin/Payment.php b/modules/payment/classes/Controller/Admin/Payment.php index 94d03e65..5ed96955 100644 --- a/modules/payment/classes/Controller/Admin/Payment.php +++ b/modules/payment/classes/Controller/Admin/Payment.php @@ -95,7 +95,7 @@ class Controller_Admin_Payment extends Controller_Payment { private function add_edit($id=NULL,$output='') { $po = ORM::factory('Payment',$id); - $this->meta->title = 'Payment: '.$po->refnum(TRUE); + $this->meta->title = $po->loaded() ? 'Payment: '.$po->refnum(TRUE) : 'A|Payment Add'; if ($this->request->post()) { $po->values($this->request->post()); @@ -113,61 +113,6 @@ class Controller_Admin_Payment extends Controller_Payment { $this->save($po); } - Script::factory() - ->type('file') - ->data('media/theme/bootstrap/js/bootstrap.datepicker.js'); - - Style::factory() - ->type('file') - ->data('media/theme/bootstrap/css/bootstrap.datepicker.css'); - - Script::factory() - ->type('stdin') - ->data(' -$(document).ready(function() { - $("#date_payment_label").datepicker({ - autoclose : true, - todayHighlight: true, - endDate : new Date(), - format : "dd-mm-yyyy", - todayBtn : true, - }).on("hide",function(ev) { - $("input[name=date_payment]").val(ev.date.valueOf()/1000); - }); - - $("input[name=account_id_label]").typeahead({ - minLength: 2, - source: function (query,process) { - search("'.URL::link('admin','payment/ajaxlist').'",query,process); - }, - - matcher: function () { return true; }, - - updater: function (item) { - $("input[name=account_id]").val(users[item]); - - // Send the request and update sub category dropdown - $.ajax({ - type: "GET", - data: "key="+users[item], - dataType: "html", - cache: false, - url: "'.URL::link('admin','payment/ajaxitemlist',TRUE).'", - timeout: 2000, - error: function(x) { - alert("Failed to submit"); - }, - success: function(data) { - $("div[id=items]").empty().append(data); - } - }); - - return item; - }, - }); -}); - '); - if ($po->loaded()) Script::factory() ->type('stdin') diff --git a/modules/payment/views/payment/admin/add_edit.php b/modules/payment/views/payment/admin/add_edit.php index 492f0004..c9944e47 100644 --- a/modules/payment/views/payment/admin/add_edit.php +++ b/modules/payment/views/payment/admin/add_edit.php @@ -2,30 +2,49 @@
Payment Details - -
- - -
- date_payment); ?> +set('data',['field'=>'date_payment','value'=>$o->date_payment ? $o->date_payment : time(),'text'=>'Date Charge','enddate'=>'new Date()']); + echo View::factory('field/select')->set('data',['field'=>'checkout_id','value'=>ORM::factory('Checkout')->list_select(TRUE),'text'=>'Payment Method','default'=>$o->checkout_id,'class'=>'col-md-2']); + echo View::factory('field/money')->set('data',['field'=>'total_amt','value'=>$o->total_amt,'text'=>'Total','class'=>'col-md-2']); + echo View::factory('field/money')->set('data',['field'=>'fees_amt','value'=>$o->fees_amt,'text'=>'Fees','class'=>'col-md-2']); + echo View::factory('field/account')->set('data',['field'=>'account_id','value'=>$o->account_id,'text'=>'Account','name'=>$o->account_id ? sprintf('%s: %s',$o->account->refnum(),$o->account->name()) : '','ajaxurl'=>URL::link('admin','payment/ajaxlist')]); + echo View::factory('field/text')->set('data',['field'=>'notes','value'=>$o->notes,'text'=>'Notes','class'=>'col-md-5']); +?> - list_select(),$o->checkout_id,array('label'=>'Payment Method','required')); ?> - total_amt,array('label'=>'Amount','placeholder'=>'Total','help-block'=>sprintf('Credits: %s, Balance: %s',$o->credit(),$o->total()))); ?> - fees_amt,array('label'=>'Fees','placeholder'=>'Fees')); ?> - account->name(),array('label'=>'Account','placeholder'=>'Account','data-provide'=>'typeahead')); ?> - account_id); ?> - notes,array('label'=>'Notes','placeholder'=>'Any notes about this payment?')); ?> +
+
+ Invoice Details + +
-
- Invoice Details - -
-
- -
- - +
+
+ +type('stdin') + ->data(' +$(document).ready(function() { + $("input[name=account_id]").change(function(){ + // Send the request and update sub category dropdown + $.ajax({ + type: "POST", + data: "key="+$(this).val(), + dataType: "html", + cache: false, + url: "'.URL::link('admin','payment/ajaxitemlist',TRUE).'", + timeout: 2000, + error: function(x) { + alert("Failed to submit"); + }, + success: function(data) { + $("div[id=items]").empty().append(data); + } + }); + }); +});'); +?> diff --git a/modules/product/classes/Model/Product.php b/modules/product/classes/Model/Product.php index ee4224c8..6dbfaaf4 100644 --- a/modules/product/classes/Model/Product.php +++ b/modules/product/classes/Model/Product.php @@ -14,6 +14,7 @@ */ class Model_Product extends ORM { protected $_has_many = array( + 'product_cat'=>array('through'=>'pivot_product_cat'), 'invoice'=>array('through'=>'invoice_item'), 'service'=>array('far_key'=>'id'), 'translate'=>array('model'=>'Product_Translate','far_key'=>'id'), diff --git a/modules/product/views/product/category/list.php b/modules/product/views/product/category/list.php new file mode 100644 index 00000000..04ad0c6f --- /dev/null +++ b/modules/product/views/product/category/list.php @@ -0,0 +1,12 @@ + +page_items(50) + ->data($o) + ->columns(array( + 'id'=>'ID', + 'name(TRUE)'=>'Name', + )) + ->prepend(array( + 'id'=>array('url'=>URL::link('admin','product_category/edit/')), + )); +?>