From: Steve Sutton Date: Thu, 11 Jul 2019 20:50:27 +0000 (-0400) Subject: Save WIP for billing revamp X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=2e9d30e7ebb5ce9a06d0757c7060e3f322f1014d;p=WP-Plugins%2Fglm-member-db-billing.git Save WIP for billing revamp Working on foundation 6 revamp for: Settings Invoice Types Notifications Reporting Invoicing --- diff --git a/models/admin/billing/invoiceTypes.php b/models/admin/billing/invoiceTypes.php new file mode 100644 index 0000000..b68c5d9 --- /dev/null +++ b/models/admin/billing/invoiceTypes.php @@ -0,0 +1,210 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Member Types data abstract +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataInvoiceTypes.php'; +require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberTypes.php'; + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'menuItemRedirect' + * + * If not false, provides a menu item the controller should + * execute after this one. Normally if this is used, there would also be a + * modelRedirect value supplied as well. + * + * 'modelRedirect' + * + * If not false, provides an action the controller should execute after + * this one. + * + * 'view' + * + * A suggested view name that the contoller should use instead of the + * default view for this model or false to indicate that the default view + * should be used. + * + * 'data' + * + * Data that the model is returning for use in merging with the view to + * produce output. + * + */ + public function modelAction ($actionData = false) + { + + $success = true; + $haveInvoiceTypes = false; + $invoiceTypes = false; + $error = false; + $enable_members = $this->config['settings']['enable_members']; + $memberTypes = false; + + // Enqueue GLMA Foundation + wp_enqueue_style( 'Foundation6', GLM_MEMBERS_PLUGIN_URL . '/css/foundation-6.min.css' ); + wp_enqueue_script( 'Foundation6', GLM_MEMBERS_PLUGIN_URL . '/js/foundation-6.min.js' ); + + // Check for region id + $id = 0; + if (isset($_REQUEST['id'])) { + $id = $_REQUEST['id']-0; + } + + // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + + // If there's an action option + if (isset($_REQUEST['option'])) { + + switch($_REQUEST['option']) { + + case 'addNew': + $this->insertEntry(); + break; + + case 'update': + if ($id > 0) { + $this->updateEntry($id); + } + break; + + case 'delete': + if ($id > 0) { + $this->deleteEntry($id, true); + } + break; + + } + + } + + // Get a current list of members + $invoiceTypes = $this->getList(); + + // echo '
$invoiceTypes: ' . print_r( $invoiceTypes, true ) . '
'; + + // If we have list entries - even if it's an empty list + $success = true; + $haveInvoiceTypes = false; + if ($invoiceTypes !== false) { + + $success = true; + + // If we have any entries + if (count($invoiceTypes) > 0) { + $haveInvoiceTypes = true; + } + } + + // Sort results by higherarchy (Parent/Child and Alpha) + $invoiceTypes = $this->sortParentChild($invoiceTypes); + // echo '
$invoiceTypes: ' . print_r( $invoiceTypes, true ) . '
'; + + // Get list of Member Types + $MemberType = new GlmDataMemberTypes( $this->wpdb, $this->config ); + $memberTypes = $MemberType->getList(); + // echo '
$memberTypes: ' . print_r( $memberTypes, true ) . '
'; + + + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + + + + // Compile template data + $templateData = array( + 'action' => $_REQUEST['glm_action'], + 'enable_members' => $enable_members, + 'haveInvoiceTypes' => $haveInvoiceTypes, + 'invoiceTypes' => $invoiceTypes, + 'recurrenceTypes' => $this->config['recurrence'], + 'memberTypes' => $memberTypes, + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/billing/invoiceTypes.html', + 'data' => $templateData + ); + + } + + +} diff --git a/models/admin/billing/notifications.php b/models/admin/billing/notifications.php new file mode 100644 index 0000000..394fbb4 --- /dev/null +++ b/models/admin/billing/notifications.php @@ -0,0 +1,318 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Member Types data abstract +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataNotificationTypes.php'; + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_billing_notifications extends GlmDataNotificationTypes +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'menuItemRedirect' + * + * If not false, provides a menu item the controller should + * execute after this one. Normally if this is used, there would also be a + * modelRedirect value supplied as well. + * + * 'modelRedirect' + * + * If not false, provides an action the controller should execute after + * this one. + * + * 'view' + * + * A suggested view name that the contoller should use instead of the + * default view for this model or false to indicate that the default view + * should be used. + * + * 'data' + * + * Data that the model is returning for use in merging with the view to + * produce output. + * + */ + public function modelAction ($actionData = false) + { + + $id = 0; + $option = 'list'; + $view = 'notifications'; + $success = true; + $notificationUpdated = false; + $notificationUpdateError = false; + $notificationAdded = false; + $notificationInsertError = false; + $haveNotificationTypes = false; + $notificationTypes = false; + $notification = false; + $error = false; + $enable_members = $this->config['settings']['enable_members']; + + // Enqueue GLMA Foundation + wp_enqueue_style( 'Foundation6', GLM_MEMBERS_PLUGIN_URL . '/css/foundation-6.min.css' ); + wp_enqueue_script( 'Foundation6', GLM_MEMBERS_PLUGIN_URL . '/js/foundation-6.min.js' ); + + // Check for region id + $id = 0; + if (isset($_REQUEST['id'])) { + $id = $_REQUEST['id']-0; + } + + // need to setup the fields for send_by_(date/action) + if ( isset( $_REQUEST['send_by'] ) ) { + switch ( $_REQUEST['send_by'] ) { + case 'date': + $_REQUEST['send_by_date'] = true; + $_REQUEST['send_by_action'] = false; + break; + case 'action': + $_REQUEST['send_by_action'] = true; + $_REQUEST['send_by_date'] = false; + break; + default: + $_REQUEST['send_by_action'] = false; + $_REQUEST['send_by_date'] = false; + break; + } + } + + // Get any provided option + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } + + switch( $option ) { + + case 'add': + /** + * add: + * + * This calls the dataAbstract newEntry method and sets up the + * edit for for creating a new notification_type. + */ + $notification = $this->newEntry(); + $view = 'editNotificationType'; + break; + + case 'insert': + /** + * insert: + * + * Calls the insertEntry method that stores the actual data for the data abstract class. + */ + $view = 'editNotificationType'; + $notification = $this->insertEntry(); + if ( $notification['status'] ) { + $notificationAdded = true; + $id = $notification['fieldData']['id']; + $notification = $this->editEntry( $id ); + } else { + $notificationInsertError = true; + } + break; + + case 'edit': + /** + * edit: + * + * Calls the editEntry method to setup the edit form for this record by id. + */ + $notification = $this->editEntry( $id ); + $view = 'editNotificationType'; + break; + + case 'update': + /** + * update: + * + * Calls the updateEntry method for the data abstract to save the edit data. + */ + if ($id > 0) { + $notification = $this->updateEntry($id); + if ( $notification['status'] ) { + $notificationUpdated = true; + $notification = $this->editEntry( $id ); + } else { + $notificationUpdateError = true; + } + $view = 'editNotificationType'; + } + + break; + + case 'delete': + /** + * delete: + * + * Calls the delete entry method of the dataabstract class. + * To delete the given entry by id. + */ + if ($id > 0) { + $this->deleteEntry($id, true); + } + case 'list': + default: + // Get a current list of members + $notificationTypes = $this->getList(); + break; + } + + + // If we have list entries - even if it's an empty list + $success = true; + $haveNotificationTypes = false; + if ($notificationTypes !== false) { + + $success = true; + + // If we have any entries + if (count($notificationTypes) > 0) { + $haveNotificationTypes = true; + } + } + + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + $mergeTagsBilling = array( + 'Name of Account', '{$account.name}', + 'Billing First Name', '{$account.fname}', + 'Billing Last Name', '{$account.lname}', + 'Billing Address Line 1', '{$account.addr1}', + 'Billing Address Line 2', '{$account.addr2}', + 'Billing City', '{$account.city}', + 'Billing State', '{$account.state}', + 'Billing Zip', '{$account.zip}', + 'Billing Email', '{$account.email}', + 'Billing Phone', '{$account.phone}', + 'Billing Company', '{$account.company}', + 'Billing Position', '{$account.position}', + 'Renewal Date', '{$account.renewal_date}', + 'Current Due Amount', '{$account.current_due}', + ); + $mergeTagsInvoice = array( + 'Invoice Amount', '{$data.amount}', + ); + $mergeTagsPayment = array( + 'Payment Amount', '{$data.payment}', + ); + $mergeTagsContact = array( + 'Contact First Name', '{$contact.fname}', + 'Contact Last Name', '{$contact.lname}', + 'Contact Address Line 1', '{$contact.addr1}', + 'Contact Address Line 2', '{$contact.addr2}', + 'Contact City', '{$contact.city}', + 'Contact State', '{$contact.state}', + 'Contact Zip', '{$contact.zip}', + 'Contact Company', '{$contact.company}', + 'Contact Position', '{$contact.position}', + 'Contact Email', '{$contact.email}', + 'Contact Office Phone', '{$contact.office_phone}', + 'Contact Mobile Phone', '{$contact.mobile_phone}', + ); + // Compile template data + $templateData = array( + 'notification_id' => $id, + 'action' => $_REQUEST['glm_action'], + 'enable_members' => $enable_members, + 'haveNotificationTypes' => $haveNotificationTypes, + 'notificationTypes' => $notificationTypes, + 'notification' => $notification, + 'notificationUpdated' => $notificationUpdated, + 'notificationUpdateError' => $notificationUpdateError, + 'notificationAdded' => $notificationAdded, + 'notificationInsertError' => $notificationInsertError, + 'send_date_period' => $this->config['send_date_period'], + 'send_date_when' => $this->config['send_date_when'], + 'send_action' => $this->config['send_action'], + 'mergeTagsBilling' => $mergeTagsBilling, + 'mergeTagsInvoice' => $mergeTagsInvoice, + 'mergeTagsPayment' => $mergeTagsPayment, + 'mergeTagsContact' => $mergeTagsContact, + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/billing/' . $view . '.html', + 'data' => $templateData + ); + + } + + +} diff --git a/setup/validActions.php b/setup/validActions.php index c46b080..9bc8f6f 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -88,16 +88,18 @@ $glmMembersBillingAddOnValidActions = array( 'notificationTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, ), 'billing' => array( - 'index' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'list' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'invoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'payments' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'accounts' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'invoicing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'reports' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'logs' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'contact' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'settings' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'index' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'list' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'invoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'payments' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'accounts' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'invoicing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'reports' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'logs' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'contact' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'settings' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'invoiceTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'notifications' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, ), 'member' => array( 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, diff --git a/views/admin/billing/accounts.html b/views/admin/billing/accounts.html index c5f12b0..75021ff 100644 --- a/views/admin/billing/accounts.html +++ b/views/admin/billing/accounts.html @@ -1,8 +1,8 @@ {include file='admin/billing/header.html'} -
+
-

Accounts

+

Accounts

Accounts Export
@@ -36,7 +36,7 @@ {foreach $accounts as $t} {$t.id} - + {if $settings.allow_employees} {if $t.boss.value}Yes{/if} {/if} @@ -47,7 +47,7 @@