partial #4276
This commit is contained in:
parent
bb18a2cb7a
commit
a46dfb46a8
22
db/migrate/000249_admin_payment_type_trackchange.sql
Normal file
22
db/migrate/000249_admin_payment_type_trackchange.sql
Normal file
@ -0,0 +1,22 @@
|
||||
CREATE TABLE `admin_payment_type_change_set` (
|
||||
`id_admin_payment_type_change_set` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_admin_payment_type` int(11) unsigned DEFAULT NULL,
|
||||
`timestamp` timestamp NULL DEFAULT NULL,
|
||||
`id_admin` int(11) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id_admin_payment_type_change_set`),
|
||||
KEY `id_admin_payment_type` (`id_admin_payment_type`),
|
||||
KEY `id_admin` (`id_admin`),
|
||||
CONSTRAINT `admin_payment_type_change_set_ibfk_1` FOREIGN KEY (`id_admin_payment_type`) REFERENCES `admin_payment_type` (`id_admin_payment_type`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `admin_payment_type_change_set_ibfk_2` FOREIGN KEY (`id_admin`) REFERENCES `admin` (`id_admin`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `admin_payment_type_change` (
|
||||
`id_admin_payment_type_change` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_admin_payment_type_change_set` int(11) unsigned DEFAULT NULL,
|
||||
`field` varchar(255) DEFAULT NULL,
|
||||
`old_value` varchar(255) DEFAULT NULL,
|
||||
`new_value` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_admin_payment_type_change`),
|
||||
KEY `id_admin_payment_type_change_set` (`id_admin_payment_type_change_set`),
|
||||
CONSTRAINT `admin_payment_type_change_ibfk_1` FOREIGN KEY (`id_admin_payment_type_change_set`) REFERENCES `admin_payment_type_change_set` (`id_admin_payment_type_change_set`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
22
db/migrate/000250_admin_pexcard_trackchange.sql
Normal file
22
db/migrate/000250_admin_pexcard_trackchange.sql
Normal file
@ -0,0 +1,22 @@
|
||||
CREATE TABLE `admin_pexcard_change_set` (
|
||||
`id_admin_pexcard_change_set` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_admin_pexcard` int(11) unsigned DEFAULT NULL,
|
||||
`timestamp` timestamp NULL DEFAULT NULL,
|
||||
`id_admin` int(11) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id_admin_pexcard_change_set`),
|
||||
KEY `id_admin_pexcard` (`id_admin_pexcard`),
|
||||
KEY `id_admin` (`id_admin`),
|
||||
CONSTRAINT `admin_pexcard_change_set_ibfk_1` FOREIGN KEY (`id_admin_pexcard`) REFERENCES `admin_pexcard` (`id_admin_pexcard`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `admin_pexcard_change_set_ibfk_2` FOREIGN KEY (`id_admin`) REFERENCES `admin` (`id_admin`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `admin_pexcard_change` (
|
||||
`id_admin_pexcard_change` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_admin_pexcard_change_set` int(11) unsigned DEFAULT NULL,
|
||||
`field` varchar(255) DEFAULT NULL,
|
||||
`old_value` varchar(255) DEFAULT NULL,
|
||||
`new_value` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_admin_pexcard_change`),
|
||||
KEY `id_admin_pexcard_change_set` (`id_admin_pexcard_change_set`),
|
||||
CONSTRAINT `admin_pexcard_change_ibfk_1` FOREIGN KEY (`id_admin_pexcard_change_set`) REFERENCES `admin_pexcard_change_set` (`id_admin_pexcard_change_set`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
110
include/controllers/default/cockpit2/api/pexcard/CardLog.php
Normal file
110
include/controllers/default/cockpit2/api/pexcard/CardLog.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
class Controller_api_PexCard_CardLog extends Crunchbutton_Controller_RestAccount {
|
||||
|
||||
public function init() {
|
||||
|
||||
if( !c::admin()->permission()->check( ['global', 'settlement', 'support-all', 'support-crud' ] ) ){
|
||||
$this->_error();
|
||||
}
|
||||
|
||||
$limit = $this->request()['limit'] ? c::db()->escape($this->request()['limit']) : 20;
|
||||
$search = $this->request()['search'] ? c::db()->escape($this->request()['search']) : '';
|
||||
$type = $this->request()['type'] ? c::db()->escape($this->request()['type']) : 'all';
|
||||
$status = $this->request()['status'] ? c::db()->escape($this->request()['status']) : 'all';
|
||||
$page = $this->request()['page'] ? c::db()->escape($this->request()['page']) : 1;
|
||||
|
||||
if ($page == 1) {
|
||||
$offset = '0';
|
||||
} else {
|
||||
$offset = ($page-1) * $limit;
|
||||
}
|
||||
|
||||
$q = '
|
||||
SELECT -WILD-
|
||||
FROM
|
||||
(SELECT
|
||||
s.name AS `staff_name`,
|
||||
a.name AS `admin_name`,
|
||||
aptcs.timestamp,
|
||||
NULL AS `card_serial`,
|
||||
new_value AS `value`,
|
||||
"using_pex" AS `type`
|
||||
FROM admin_payment_type_change_set aptcs
|
||||
INNER JOIN admin_payment_type_change aptc ON aptcs.id_admin_payment_type_change_set = aptc.id_admin_payment_type_change_set
|
||||
AND aptc.field = "using_pex"
|
||||
INNER JOIN admin_payment_type apt ON apt.id_admin_payment_type = aptcs.id_admin_payment_type
|
||||
INNER JOIN admin s ON s.id_admin = apt.id_admin
|
||||
INNER JOIN admin a ON a.id_admin = aptcs.id_admin
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
s.name AS `staff_name`,
|
||||
a.name AS `admin_name`,
|
||||
apcs.timestamp,
|
||||
ap.card_serial,
|
||||
new_value AS `value`,
|
||||
"card_assign" AS `type`
|
||||
FROM admin_pexcard_change_set apcs
|
||||
INNER JOIN admin_pexcard_change apc ON apcs.id_admin_pexcard_change_set = apc.id_admin_pexcard_change_set
|
||||
AND apc.field = "id_admin"
|
||||
INNER JOIN admin_pexcard ap ON ap.id_admin_pexcard = apcs.id_admin_pexcard
|
||||
INNER JOIN admin s ON s.id_admin = apc.new_value
|
||||
INNER JOIN admin a ON a.id_admin = apcs.id_admin ) log WHERE 1 = 1
|
||||
';
|
||||
|
||||
if ($type != 'all') {
|
||||
$q .= '
|
||||
AND log.type = "' . $type . '"
|
||||
';
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$q .= Crunchbutton_Query::search([
|
||||
'search' => stripslashes($search),
|
||||
'fields' => [
|
||||
'log.staff_name' => 'like',
|
||||
'log.admin_name' => 'like',
|
||||
'log.card_serial' => 'like'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// get the count
|
||||
$r = c::db()->get(str_replace('-WILD-','COUNT(*) c', $q));
|
||||
$count = intval( $r->_items[0]->c );
|
||||
|
||||
$q .= '
|
||||
ORDER BY log.timestamp DESC
|
||||
LIMIT '.$offset.', '.$limit . '
|
||||
';
|
||||
|
||||
// do the query
|
||||
$d = [];
|
||||
$r = c::db()->query(str_replace('-WILD-','*', $q));
|
||||
|
||||
while ($o = $r->fetch()) {
|
||||
$date = new DateTime($o->timestamp, new DateTimeZone(c::config()->timezone));;
|
||||
$o->date = $date->format( 'M jS Y g:i:s A T' );
|
||||
unset( $o->timestamp );
|
||||
$d[] = $o;
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'count' => intval($count),
|
||||
'pages' => ceil($count / $limit),
|
||||
'page' => $page,
|
||||
'results' => $d
|
||||
]);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
private function _error( $error = 'invalid request' ){
|
||||
echo json_encode( [ 'error' => $error ] );
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
@ -87,11 +87,8 @@ class Controller_api_PexCard_Log extends Crunchbutton_Controller_RestAccount {
|
||||
|
||||
|
||||
// get the count
|
||||
$count = 0;
|
||||
$r = c::db()->query(str_replace('-WILD-','COUNT(*) c', $q));
|
||||
while ($c = $r->fetch()) {
|
||||
$count++;
|
||||
}
|
||||
$r = c::db()->get(str_replace('-WILD-','COUNT(*) c', $q));
|
||||
$count = intval( $r->_items[0]->c );
|
||||
|
||||
$q .= '
|
||||
ORDER BY pa.id_pexcard_action DESC
|
||||
@ -102,6 +99,7 @@ class Controller_api_PexCard_Log extends Crunchbutton_Controller_RestAccount {
|
||||
$d = [];
|
||||
$r = c::db()->query(str_replace('-WILD-','
|
||||
pa.id_pexcard_action,
|
||||
pa.date,
|
||||
pa.status,
|
||||
a.name AS `driver`,
|
||||
a.login,
|
||||
@ -119,6 +117,8 @@ class Controller_api_PexCard_Log extends Crunchbutton_Controller_RestAccount {
|
||||
', $q));
|
||||
|
||||
while ($o = $r->fetch()) {
|
||||
$date = new DateTime($o->date, new DateTimeZone(c::config()->timezone));;
|
||||
$o->date = $date->format( 'M jS Y g:i:s A T' );
|
||||
$d[] = $o;
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,6 @@ class Controller_api_staff_payinfo extends Crunchbutton_Controller_RestAccount {
|
||||
|
||||
$payment_type->using_pex = ( intval( $this->request()[ 'using_pex' ] ) ? intval( $this->request()[ 'using_pex' ] ) : 0 );
|
||||
|
||||
|
||||
if( $this->request()[ 'using_pex_date_formatted' ] ){
|
||||
$payment_type->using_pex_date = ( new DateTime( $this->request()[ 'using_pex_date_formatted' ] ) )->format( 'Y-m-d H:i:s' );
|
||||
} else {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Cockpit_Admin_Pexcard extends Cana_Table {
|
||||
class Cockpit_Admin_Pexcard extends Cockpit_Admin_Pexcard_Trackchange {
|
||||
|
||||
const CONFIG_KEY_PEX_AMOUNT_TO_SHIFT_START = 'pex-amount-shift-start';
|
||||
const CONFIG_KEY_PEX_SHIFT_ENABLE = 'pex-card-funds-shift-enable';
|
||||
|
||||
18
include/library/Cockpit/Admin/Pexcard/Trackchange.php
Normal file
18
include/library/Cockpit/Admin/Pexcard/Trackchange.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class Cockpit_Admin_Pexcard_Trackchange extends Cana_Table {
|
||||
public function save() {
|
||||
if ($this->{$this->idVar()}) {
|
||||
$this->_changeSet = new Cockpit_Admin_Pexcard_Trackchange(Cana_Changeset::save($this));
|
||||
}
|
||||
parent::save();
|
||||
}
|
||||
|
||||
public function changeSet() {
|
||||
if (!isset($this->_changeSet)) {
|
||||
$sets = $this->changeSets();
|
||||
$this->_changeSet = array_pop($sets);
|
||||
}
|
||||
return $this->_changeSet;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Crunchbutton_Admin_Payment_Type extends Cana_Table {
|
||||
class Crunchbutton_Admin_Payment_Type extends Crunchbutton_Admin_Payment_Type_Trackchange {
|
||||
|
||||
const PAYMENT_METHOD_DEPOSIT = 'deposit';
|
||||
const PAYMENT_TYPE_HOURS = 'hours';
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class Crunchbutton_Admin_Payment_Type_Trackchange extends Cana_Table {
|
||||
public function save() {
|
||||
if ($this->{$this->idVar()}) {
|
||||
$this->_changeSet = new Crunchbutton_Admin_Payment_Type_Trackchange(Cana_Changeset::save($this));
|
||||
}
|
||||
parent::save();
|
||||
}
|
||||
|
||||
public function changeSet() {
|
||||
if (!isset($this->_changeSet)) {
|
||||
$sets = $this->changeSets();
|
||||
$this->_changeSet = array_pop($sets);
|
||||
}
|
||||
return $this->_changeSet;
|
||||
}
|
||||
}
|
||||
@ -13,7 +13,7 @@ class Crunchbutton_Pexcard_Action extends Cana_Table {
|
||||
const STATUS_DONE = 'done';
|
||||
const STATUS_ERROR = 'error';
|
||||
|
||||
const MAX_TRIES = 1;
|
||||
const MAX_TRIES = 3;
|
||||
|
||||
const TYPE_CREDIT = 'credit';
|
||||
const TYPE_DEBIT = 'debit';
|
||||
|
||||
@ -115,8 +115,6 @@ $permissionSupportView = c::admin()->permission()->check(['global','support-all'
|
||||
<br/>
|
||||
<a target="_blank" href="https://dashboard.balancedpayments.com/#/marketplaces/***REMOVED***/debits/<?php echo $order->txn ?>">Balanced transaction</a>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</td>
|
||||
<td nowrap="">
|
||||
<?php $date->setTimeZone( new DateTimeZone( c::config()->timezone ) ); ?>
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
<div class="box-content2 box-content-table">
|
||||
<table class="tb-zebra">
|
||||
<tr>
|
||||
<th>Changed by</th>
|
||||
<th>Staff</th>
|
||||
<th>Using pex</th>
|
||||
<th>Card Serial</th>
|
||||
<th>Type</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
<tr ng-repeat="l in logs track by $index" ng-attr-tabindex="{{$index+4}}" tab-select="/staff/{{l.login}}">
|
||||
<td>{{l.admin_name}}</td>
|
||||
<td>{{l.staff_name}}</td>
|
||||
<td class="tb-center">
|
||||
<span ng-if="l.type == 'using_pex'">
|
||||
<span ng-if="l.value">Yes</span>
|
||||
<span ng-if="!l.value">No</span>
|
||||
</span>
|
||||
<span ng-if="l.type != 'using_pex'">-</span>
|
||||
</td>
|
||||
<td>
|
||||
<span ng-if="l.card_serial">{{l.card_serial}}</span>
|
||||
<span ng-if="!l.card_serial">-</span>
|
||||
</td>
|
||||
<td>{{l.type}}</td>
|
||||
<td>{{l.date}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -4,6 +4,7 @@
|
||||
<th>#</th>
|
||||
<th>Driver</th>
|
||||
<th>Card Serial / Last Four</th>
|
||||
<th>Date</th>
|
||||
<th>Type</th>
|
||||
<th>Amount</th>
|
||||
<th class="tb-center">Order</th>
|
||||
@ -16,6 +17,7 @@
|
||||
<td><a href="/pexcard/log/{{l.id_pexcard_action}}">{{l.id_pexcard_action}}</a></td>
|
||||
<td><a href="/staff/{{l.login}}">{{l.driver}}</a></td>
|
||||
<td><a href="/pexcard/card/{{l.card_serial}}">{{l.card_serial}} / {{l.last_four}}</a></td>
|
||||
<td>{{l.date}}</td>
|
||||
<td>{{l.type}}</td>
|
||||
<td positive-or-negative-color="{{l.amount}}">${{l.amount | formatPrice}}</td>
|
||||
<td class="tb-center"><span ng-if="l.id_order"><i class="fa fa-check"></i></span></td>
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
<div class="top-pad"></div>
|
||||
|
||||
<div class="content-padding">
|
||||
<h1 class="title"><i class="fa fa-credit-card"></i>Pex Card: Card Activations Log<div class="title-loader" ng-if="loading"><i class="fa fa-refresh fa-spin"></i></div></h1>
|
||||
<div class="box-content2 box-content-table">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2"><i class="fa fa-search"></i> <input type="text" ng-model="query.search" id="search" tabindex="1"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<td>
|
||||
<select ng-model="query.type" name="searchType" tabindex="2">
|
||||
<option value="all">All</option>
|
||||
<option value="using_pex">Using pex</option>
|
||||
<option value="card_assign">Card Assignment</option>
|
||||
</select>
|
||||
</td>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="bar-loader bar-loader-search" ng-class="{'bar-loader-loading': loading}"></div>
|
||||
|
||||
<ng-include src="'assets/view/listview-pexcard-card-log.html'"></ng-include>
|
||||
<ng-include src="'assets/view/listview-paging.html'"></ng-include>
|
||||
</div>
|
||||
@ -7,6 +7,7 @@
|
||||
<tr><td><a href="/pexcard/card">Assign Pex Card to Driver</a></td></tr>
|
||||
<tr><td><a href="/pexcard/log">Transactions log</a></td></tr>
|
||||
<tr><td><a href="/pexcard/report">Pex Card Report</a></td></tr>
|
||||
<tr><td><a href="/pexcard/card/log">Card Activations Log</a></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -202,6 +202,11 @@ NGApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $l
|
||||
controller: 'PexCardLogCtrl',
|
||||
templateUrl: 'assets/view/pexcard-log.html'
|
||||
})
|
||||
.when('/pexcard/card/log', {
|
||||
action: 'pexcard',
|
||||
controller: 'PexCardCardLogCtrl',
|
||||
templateUrl: 'assets/view/pexcard-card-log.html'
|
||||
})
|
||||
.when('/pexcard/log/:id', {
|
||||
action: 'pexcard',
|
||||
controller: 'PexCardLogViewCtrl',
|
||||
|
||||
@ -177,7 +177,6 @@ NGApp.controller('PexCardLogCtrl', function ($scope, PexCardService, ViewListSer
|
||||
scope: $scope,
|
||||
watch: {
|
||||
search: '',
|
||||
type: 'all',
|
||||
status: 'all',
|
||||
type: 'all',
|
||||
_action: 'all'
|
||||
@ -190,3 +189,22 @@ NGApp.controller('PexCardLogCtrl', function ($scope, PexCardService, ViewListSer
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
NGApp.controller('PexCardCardLogCtrl', function ($scope, PexCardService, ViewListService) {
|
||||
|
||||
angular.extend( $scope, ViewListService );
|
||||
|
||||
$scope.view({
|
||||
scope: $scope,
|
||||
watch: {
|
||||
search: '',
|
||||
type: 'all',
|
||||
},
|
||||
update: function() {
|
||||
PexCardService.cardlog($scope.query, function(d) {
|
||||
$scope.logs = d.results;
|
||||
$scope.complete(d);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -247,10 +247,11 @@ NGApp.controller('StaffPayInfoCtrl', function( $scope, $filter, StaffPayInfoServ
|
||||
$scope.$watch( 'payInfo.using_pex', function( newValue, oldValue, scope ) {
|
||||
if( parseInt( $scope.payInfo.using_pex ) == 0 ){
|
||||
using_pex_date = $scope.payInfo.using_pex_date;
|
||||
$scope.payInfo.using_pex_date = new Date( '0000,00,00' );
|
||||
//
|
||||
$scope.payInfo.using_pex_date = '';
|
||||
} else {
|
||||
if( using_pex_date ){
|
||||
$scope.payInfo.using_pex_date = using_pex_date;
|
||||
if( !$scope.payInfo.using_pex_date ){
|
||||
$scope.payInfo.using_pex_date = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +263,7 @@ NGApp.controller('StaffPayInfoCtrl', function( $scope, $filter, StaffPayInfoServ
|
||||
$scope.submitted = true;
|
||||
return;
|
||||
}
|
||||
if( !isNaN( $scope.payInfo.using_pex_date.getTime() ) ){
|
||||
if( $scope.payInfo.using_pex_date && !isNaN( $scope.payInfo.using_pex_date.getTime() ) ){
|
||||
$scope.payInfo.using_pex_date_formatted = $filter( 'date' )( $scope.payInfo.using_pex_date, 'yyyy-MM-dd' )
|
||||
} else {
|
||||
$scope.payInfo.using_pex_date_formatted = null;
|
||||
|
||||
@ -12,6 +12,7 @@ NGApp.factory( 'PexCardService', function( $resource, $http, $routeParams ) {
|
||||
'pex_change_card_status' : { 'method': 'POST', params : { action: 'pexcard-change-card-status' } },
|
||||
'report' : { 'method': 'POST', params : { action: 'report' } },
|
||||
'logs' : { 'method': 'GET', params : { action: 'log' } },
|
||||
'cardlog' : { 'method': 'GET', params : { action: 'cardlog' } },
|
||||
'action' : { 'method': 'GET', params : { action: 'log' } }
|
||||
} );
|
||||
|
||||
@ -27,8 +28,6 @@ NGApp.factory( 'PexCardService', function( $resource, $http, $routeParams ) {
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
|
||||
service.driver_search = function( params, callback ){
|
||||
pexcard.driver_search( params, function( data ){
|
||||
callback( data );
|
||||
@ -71,6 +70,12 @@ NGApp.factory( 'PexCardService', function( $resource, $http, $routeParams ) {
|
||||
} );
|
||||
}
|
||||
|
||||
service.cardlog = function(params, callback) {
|
||||
pexcard.cardlog(params).$promise.then(function success(data, responseHeaders) {
|
||||
callback(data);
|
||||
});
|
||||
}
|
||||
|
||||
service.logs = function(params, callback) {
|
||||
pexcard.logs(params).$promise.then(function success(data, responseHeaders) {
|
||||
callback(data);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user