Skip to content

Commit

Permalink
Merge pull request #131 from Blair2004/coupons_and_rewards
Browse files Browse the repository at this point in the history
Coupons and rewards
  • Loading branch information
nexopos committed Jan 28, 2021
2 parents 5ee94ca + 0c19b3d commit 922163a
Show file tree
Hide file tree
Showing 73 changed files with 3,234 additions and 364 deletions.
352 changes: 230 additions & 122 deletions app/Crud/CouponCrud.php

Large diffs are not rendered by default.

506 changes: 506 additions & 0 deletions app/Crud/CustomerCouponCrud.php

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions app/Crud/CustomerCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ public function getColumns() {
'owed_amount' => [
'label' => __( 'Owed Amount' )
],
'purchases_amount' => [
'label' => __( 'Purchase Amount' )
],
'gender' => [
'label' => __( 'Gender' )
],
Expand All @@ -482,8 +485,9 @@ public function getColumns() {
*/
public function setActions( $entry, $namespace )
{
$entry->owed_amount = ( string ) ns()->currency->define( $entry->owed_amount );
$entry->account_amount = ( string ) ns()->currency->define( $entry->account_amount );
$entry->owed_amount = ( string ) ns()->currency->define( $entry->owed_amount );
$entry->account_amount = ( string ) ns()->currency->define( $entry->account_amount );
$entry->purchases_amount = ( string ) ns()->currency->define( $entry->purchases_amount );

$entry->{'$actions'} = [
[
Expand All @@ -496,6 +500,16 @@ public function setActions( $entry, $namespace )
'namespace' => 'customers_orders',
'type' => 'GOTO',
'url' => ns()->url( 'dashboard/customers/' . $entry->id . '/orders' )
], [
'label' => __( 'Rewards' ),
'namespace' => 'customers_rewards',
'type' => 'GOTO',
'url' => ns()->url( 'dashboard/customers/' . $entry->id . '/rewards' )
], [
'label' => __( 'Coupons' ),
'namespace' => 'customers_rewards',
'type' => 'GOTO',
'url' => ns()->url( 'dashboard/customers/' . $entry->id . '/coupons' )
], [
'label' => __( 'Delete' ),
'namespace' => 'delete',
Expand Down Expand Up @@ -573,7 +587,9 @@ public function getLinks()
return [
'list' => ns()->url( '/dashboard/customers' ),
'create' => ns()->url( '/dashboard/customers/create' ),
'edit' => ns()->url( '/dashboard/customers/edit/{id}' )
'edit' => ns()->url( '/dashboard/customers/edit/{id}' ),
'post' => ns()->url( '/api/nexopos/v4/crud/ns.customers' ),
'put' => ns()->url( '/api/nexopos/v4/crud/ns.customers/{id}' ),
];
}

Expand Down
45 changes: 28 additions & 17 deletions app/Crud/CustomerGroupCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class CustomerGroupCrud extends CrudService
/**
* base route name
*/
protected $mainRoute = 'ns.customers-group.index';
protected $mainRoute = '/dashboard/customers/groups';

/**
* Define namespace
* @param string
*/
protected $namespace = 'ns.customers-group';
protected $namespace = 'ns.customers-groups';

/**
* Model Used
Expand All @@ -38,6 +38,14 @@ class CustomerGroupCrud extends CrudService
*/
public $relations = [
[ 'nexopos_users', 'nexopos_customers_groups.author', '=', 'nexopos_users.id' ],
'leftJoin' => [
[ 'nexopos_rewards_system as reward', 'reward.id', '=', 'nexopos_customers_groups.reward_system_id' ]
]
];

public $pick = [
'nexopos_users' => [ 'username' ],
'reward' => [ 'name' ]
];

/**
Expand Down Expand Up @@ -83,15 +91,15 @@ public function __construct()
public function getLabels()
{
return [
'list_title' => __( 'CustomerGroups List' ),
'list_description' => __( 'Display all customergroups.' ),
'no_entry' => __( 'No customergroups has been registered' ),
'create_new' => __( 'Add a new customergroup' ),
'create_title' => __( 'Create a new customergroup' ),
'create_description' => __( 'Register a new customergroup and save it.' ),
'edit_title' => __( 'Edit customergroup' ),
'edit_description' => __( 'Modify Customergroup.' ),
'back_to_list' => __( 'Return to CustomerGroups' ),
'list_title' => __( 'Customer Groups List' ),
'list_description' => __( 'Display all Customers Groups.' ),
'no_entry' => __( 'No Customers Groups has been registered' ),
'create_new' => __( 'Add a new Customers Group' ),
'create_title' => __( 'Create a new Customers Group' ),
'create_description' => __( 'Register a new Customers Group and save it.' ),
'edit_title' => __( 'Edit Customers Group' ),
'edit_description' => __( 'Modify Customers group.' ),
'back_to_list' => __( 'Return to Customers Groups' ),
];
}

Expand Down Expand Up @@ -230,7 +238,7 @@ public function canAccess( $fields )
* @return void
*/
public function beforeDelete( $namespace, $id ) {
if ( $namespace == 'ns.customers-group' ) {
if ( $namespace == 'ns.customers-groups' ) {
$this->allowedTo( 'delete' );
}
}
Expand Down Expand Up @@ -260,7 +268,7 @@ public function getColumns() {
'$direction' => '',
'$sort' => false,
],
'reward_system_id' => [
'reward_name' => [
'label' => __( 'Reward System' ),
'$direction' => '',
'$sort' => false,
Expand Down Expand Up @@ -296,13 +304,14 @@ public function setActions( $entry, $namespace )
'namespace' => 'delete',
'type' => 'DELETE',
'index' => 'id',
'url' => ns()->url( '/api/nexopos/v4/customers/groups/' . $entry->id ),
'url' => ns()->url( '/api/nexopos/v4/crud/ns.customers-groups/' . $entry->id ),
'confirm' => [
'message' => __( 'Would you like to delete this ?' ),
'title' => __( 'Delete a licence' )
]
]
];
$entry->reward_name = $entry->reward_name ?: __( 'N/A' );
$entry->{ '$checked' } = false;
$entry->{ '$toggled' } = false;
$entry->{ '$id' } = $entry->id;
Expand Down Expand Up @@ -359,9 +368,11 @@ public function bulkAction( Request $request )
public function getLinks()
{
return [
'list' => 'ns.customers-group.index',
'create' => 'ns.customers-group.index/create',
'edit' => 'ns.customers-group.index/edit/#'
'list' => ns()->url( 'dashboard/customers/groups' ),
'create' => ns()->url( 'dashboard/customers/groups/create' ),
'edit' => ns()->url( 'dashboard/customers/groups/edit' ),
'post' => ns()->url( 'api/nexopos/v4/crud/' . 'ns.customers-groups' ),
'put' => ns()->url( 'api/nexopos/v4/crud/' . 'ns.customers-groups/{id}' . '' ),
];
}

Expand Down
Loading

0 comments on commit 922163a

Please sign in to comment.