From: Steve Sutton Date: Wed, 10 Jul 2019 20:50:59 +0000 (-0400) Subject: Move setting form into the billing X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=4cf8e93c430ff3fa0ce54dac5f78158143e4f0eb;p=WP-Plugins%2Fglm-member-db-billing.git Move setting form into the billing Too many issues with using forms in a loaded reveal. Just moving it right into billing side. --- diff --git a/models/admin/billing/settings.php b/models/admin/billing/settings.php new file mode 100644 index 0000000..cfb6758 --- /dev/null +++ b/models/admin/billing/settings.php @@ -0,0 +1,242 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release billing.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Management Events data abstract +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataSettings.php'; + +/** + * GlmMembersAdmin_settings_billing + * + * PHP version 5 + * + * @category Model + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmMembersAdmin_billing_settings extends GlmDataBillingSettings +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * dbh Postgres database connection + * + * @var mixed + * @access public + */ + public $dbh; + /** + * settings used for the schema and tablenames + * + * @var mixed + * @access public + */ + public $settings = array(); + + public $ajaxSide = false; + /** + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * '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. + * + * @wpdb object WordPress database object + * + * @return array Array containing status, suggested view, and any data + */ + 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( $this->wpdb, $this->config ); + + } + + /** + * modelAction + * + * @param bool $actionData + * @access public + * @return void + */ + public function modelAction($actionData = false) + { + + $option = false; + $settings_updated = false; + $settings_update_error = false; + $billing_settings = false; + $option2 = false; + $enable_members = $this->config['settings']['enable_members']; + + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } + + // 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' ); + + switch ($option) { + + case 'settings': + + default: + + // Make sure option is set if default + $option = 'settings'; + + // Determine if current user can edit configurations + if (!current_user_can('glm_members_members')) { + return array( + 'status' => false, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => array( + 'reason' => 'User does not have rights to make configuration changes.' + ) + ); + } + + // Check for submission option + $option2 = ''; + if (isset($_REQUEST['option2'])) { + $option2 = $_REQUEST['option2']; + } + + switch($option2) { + + // Update the settings and redisplay the form + case 'submit': + + $_REQUEST['member_types_requiring_billing'] = ''; + // Combine the member types needing billing + if ( isset( $_REQUEST['member_types_requiring_billing_option'] ) ) { + $_REQUEST['member_types_requiring_billing'] = serialize( $_REQUEST['member_types_requiring_billing_option'] ); + } + // Combine the member types that are free + $_REQUEST['member_types_free'] = ''; + if ( isset( $_REQUEST['member_types_free_option'] ) ) { + $_REQUEST['member_types_free'] = serialize( $_REQUEST['member_types_free_option'] ); + } + + // Update the billing settings settings + $billing_settings = $this->updateEntry(1); + if ($billing_settings['status']) { + $settings_updated = true; + } else { + $settings_update_error = true; + } + + break; + + // Default is to get the current settings and display the form + default: + + // Try to get the first (should be only) entry for general settings. + $billing_settings = $this->editEntry(1); + // echo '
$billing_settings: ' . print_r( $billing_settings, true ) . '
'; + + break; + + } + + break; + + } + + // Get list of member types + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberTypes.php'; + $memberTypeData = new GlmDataMemberTypes( $this->wpdb, $this->config ); + $memberTypes = $memberTypeData->getList(); + + // Get the entry for member_types_requiring_billing + // Setup for the edit form + $member_types_requring_billing_selected = $billing_settings['fieldData']['member_types_requiring_billing']; + if ( $member_types_requring_billing_selected ) { + $member_types_requring_billing_selected = unserialize( $member_types_requring_billing_selected ); + } else { + $member_types_requring_billing_selected = array(); + } + $member_types_free_selected = $billing_settings['fieldData']['member_types_free']; + if ( $member_types_free_selected ) { + $member_types_free_selected = unserialize( $member_types_free_selected ); + } else { + $member_types_free_selected = array(); + } + + $view = 'settings'; + + // Compile template data + $template_data = array( + 'action' => $_REQUEST['glm_action'], + 'enable_members' => $enable_members, + 'option' => $option, + 'settingsUpdated' => $settings_updated, + 'settingsUpdateError' => $settings_update_error, + 'billingSettings' => $billing_settings, + 'renewal_month_opts' => range( 1, 12, 1 ), + 'renewal_day_opts' => range( 1, 31, 1 ), + 'member_types' => $memberTypes, + 'selectedMTRB' => $member_types_requring_billing_selected, + 'selectedMTFREE' => $member_types_free_selected, + 'pluginAssetsUrl' => GLM_MEMBERS_BILLING_PLUGIN_URL . 'assets', + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => true, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/billing/' . $view . '.html', + 'data' => $template_data + ); + + + } + + +} + diff --git a/setup/validActions.php b/setup/validActions.php index bcb70b4..c46b080 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -97,6 +97,7 @@ $glmMembersBillingAddOnValidActions = array( 'reports' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, 'logs' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, 'contact' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'settings' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, ), 'member' => array( 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, diff --git a/views/admin/billing/header.html b/views/admin/billing/header.html index 14fb7b6..e71c16e 100644 --- a/views/admin/billing/header.html +++ b/views/admin/billing/header.html @@ -24,7 +24,9 @@ Reports {/if} -
  • Settings
  • +
  • + Settings +
  • +{include file='admin/footer.html'} diff --git a/views/admin/settings/billing.html b/views/admin/settings/billing.html index 374c040..b0c1fe0 100644 --- a/views/admin/settings/billing.html +++ b/views/admin/settings/billing.html @@ -2,420 +2,422 @@ {include file='admin/settings/subHeader.html'} - - - - - - - - + +
    - {if $settingsUpdated}

    Settings Updated

    {/if} - {if $settingsUpdateError}Settings Update Error{/if} -

    Billing Settings

    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +
    Invoice Settings
    Company Logo - {if $billingSettings.fieldData.company_logo} - - Delete Image
    - {$billingSettings.fieldData.company_logo}
    - {/if} - New image: -
    Best logo size: No larger than (400px x 200px). Must be jpeg,gif or png.
    - {if $billingSettings.fieldFail.company_logo}

    {$billingSettings.fieldFail.company_logo}{/if} -

    - Width of PDF Logo
    - Must be a number -
    - - {if $billingSettings.fieldFail.company_logo_width}

    {$billingSettings.fieldFail.company_logo_width}

    {/if}
    -
    Invoice Options
    Company Name - - {if $billingSettings.fieldFail.company_name}

    {$billingSettings.fieldFail.company_name}

    {/if}
    -
    Company Name 2 - - {if $billingSettings.fieldFail.company_name2}

    {$billingSettings.fieldFail.company_name2}

    {/if}
    -
    Company Address 1 - - {if $billingSettings.fieldFail.company_addr1}

    {$billingSettings.fieldFail.company_addr1}

    {/if}
    -
    Company Address 2 - - {if $billingSettings.fieldFail.company_addr2}

    {$billingSettings.fieldFail.company_addr2}

    {/if}
    -
    Company City - - {if $billingSettings.fieldFail.company_city}

    {$billingSettings.fieldFail.company_city}

    {/if}
    -
    Company State - + + + + + - -
    + {if $settingsUpdated}

    Settings Updated

    {/if} + {if $settingsUpdateError}Settings Update Error{/if} +

    Billing Settings

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Invoice Settings
    Company Logo + {if $billingSettings.fieldData.company_logo} + + Delete Image
    + {$billingSettings.fieldData.company_logo}
    + {/if} + New image: +
    Best logo size: No larger than (400px x 200px). Must be jpeg,gif or png.
    + {if $billingSettings.fieldFail.company_logo}

    {$billingSettings.fieldFail.company_logo}{/if} +

    + Width of PDF Logo
    + Must be a number +
    + + {if $billingSettings.fieldFail.company_logo_width}

    {$billingSettings.fieldFail.company_logo_width}

    {/if}
    +
    Invoice Options
    Company Name + + {if $billingSettings.fieldFail.company_name}

    {$billingSettings.fieldFail.company_name}

    {/if}
    +
    Company Name 2 + + {if $billingSettings.fieldFail.company_name2}

    {$billingSettings.fieldFail.company_name2}

    {/if}
    +
    Company Address 1 + + {if $billingSettings.fieldFail.company_addr1}

    {$billingSettings.fieldFail.company_addr1}

    {/if}
    +
    Company Address 2 + + {if $billingSettings.fieldFail.company_addr2}

    {$billingSettings.fieldFail.company_addr2}

    {/if}
    +
    Company City + + {if $billingSettings.fieldFail.company_city}

    {$billingSettings.fieldFail.company_city}

    {/if}
    +
    Company State + + {if $billingSettings.fieldFail.company_state}

    {$billingSettings.fieldFail.company_state}

    {/if}
    +
    Company Zip + + {if $billingSettings.fieldFail.company_zip}

    {$billingSettings.fieldFail.company_zip}

    {/if}
    +
    Company Phone + + {if $billingSettings.fieldFail.company_phone}

    {$billingSettings.fieldFail.company_phone}

    {/if}
    +
    Company Email + + {if $billingSettings.fieldFail.company_email}

    {$billingSettings.fieldFail.company_email}

    {/if}
    +
    Company URL + + {if $billingSettings.fieldFail.company_url}

    {$billingSettings.fieldFail.company_url}

    {/if}
    +
    Payment Terms + + {if $billingSettings.fieldFail.payment_terms}

    {$billingSettings.fieldFail.payment_terms}

    {/if}
    +
    Receipt Text + {wp_editor( + $billingSettings.fieldData.receipt_text|escape:quotes, + 'receipt_text', + json_decode('{ + "media_buttons": false, + "quicktags": false, + "textarea_name": "receipt_text", + "editor_height": 200 + }', true) + )} + {if $billingSettings.fieldFail.receipt_text}

    {$billingSettings.fieldFail.receipt_text}

    {/if}
    +
    + + + Shown Account # +
    + + + Shown invoice # +
    + + + Enable Account Number +
    + + + Require Account Number +
    + + + Require Unique Account Numbers +
    Billing Options
    + + + Allow Membership Choice When renewing +
    + + + Allow Employees +
    + + + Use member types in Invoice Types +
    + + + Enable Quickbooks +
    + + + Enable Members billing tab (for members) +
    + + + Require Billing Fields +
    + + + Enable Invoice Methods +
    + + + Enable Billing Counties +
    + + + Enable Billing Contact Name (Don't use for Square Payments) +
    + + + All Members renewal same day each year +
    + + + Create PDF Invoices +
    + Renewal Date Each Year + +
    + Month + - {if $billingSettings.fieldFail.company_state}

    {$billingSettings.fieldFail.company_state}

    {/if}
    -
    Company Zip - - {if $billingSettings.fieldFail.company_zip}

    {$billingSettings.fieldFail.company_zip}

    {/if}
    -
    Company Phone - - {if $billingSettings.fieldFail.company_phone}

    {$billingSettings.fieldFail.company_phone}

    {/if}
    -
    Company Email - - {if $billingSettings.fieldFail.company_email}

    {$billingSettings.fieldFail.company_email}

    {/if}
    -
    Company URL - - {if $billingSettings.fieldFail.company_url}

    {$billingSettings.fieldFail.company_url}

    {/if}
    -
    Payment Terms - - {if $billingSettings.fieldFail.payment_terms}

    {$billingSettings.fieldFail.payment_terms}

    {/if}
    -
    Receipt Text - {wp_editor( - $billingSettings.fieldData.receipt_text|escape:quotes, - 'receipt_text', - json_decode('{ - "media_buttons": false, - "quicktags": false, - "textarea_name": "receipt_text", - "editor_height": 200 - }', true) - )} - {if $billingSettings.fieldFail.receipt_text}

    {$billingSettings.fieldFail.receipt_text}

    {/if}
    -
    - - - Shown Account # -
    - - - Shown invoice # -
    - - - Enable Account Number -
    - - - Require Account Number -
    - - - Require Unique Account Numbers -
    Billing Options
    - - - Allow Membership Choice When renewing -
    - - - Allow Employees -
    - - - Use member types in Invoice Types -
    - - - Enable Quickbooks -
    - - - Enable Members billing tab (for members) -
    - - - Require Billing Fields -
    - - - Enable Invoice Methods -
    - - - Enable Billing Counties -
    - - - Enable Billing Contact Name -
    - - - All Members renewal same day each year -
    - - - Create PDF Invoices -
    - Renewal Date Each Year - -
    - Month - - {if $billingSettings.fieldFail.renewal_month}

    {$billingSettings.fieldFail.renewal_month}

    {/if} -
    -
    - Day - - {if $billingSettings.fieldFail.renewal_day}

    {$billingSettings.fieldFail.renewal_day}

    {/if} -
    -
    - Member Types that require Billing Account - - + {foreach $renewal_day_opts as $opt} + {/foreach} -
    - Member Types that are Free - - -
    - Days Before Renewal Date
    - to Allow Membership Renewal
    - Must be a number -
    - - {if $billingSettings.fieldFail.days_before_renewal}

    {$billingSettings.fieldFail.days_before_renewal}

    {/if}
    -
    - Days After Renewal Date
    - Membership Expires
    - Must be a number -
    - - {if $billingSettings.fieldFail.days_after_expired}

    {$billingSettings.fieldFail.days_after_expired}

    {/if}
    -
    - - -
    - - + {if $billingSettings.fieldFail.renewal_day}

    {$billingSettings.fieldFail.renewal_day}

    {/if} + +
    + Member Types that require Billing Account + + +
    + Member Types that are Free + + +
    + Days Before Renewal Date
    + to Allow Membership Renewal
    + Must be a number +
    + + {if $billingSettings.fieldFail.days_before_renewal}

    {$billingSettings.fieldFail.days_before_renewal}

    {/if}
    +
    + Days After Renewal Date
    + Membership Expires
    + Must be a number +
    + + {if $billingSettings.fieldFail.days_after_expired}

    {$billingSettings.fieldFail.days_after_expired}

    {/if}
    +
    + + +
    + + + {include file='admin/footer.html'} diff --git a/views/admin/settings/billingAjax.html b/views/admin/settings/billingAjax.html deleted file mode 100644 index 0c3587f..0000000 --- a/views/admin/settings/billingAjax.html +++ /dev/null @@ -1,151 +0,0 @@ - - -
    -
    -

    Main Settings

    - -
    -
    - -
    - Invoice Information - - {$data = $billingSettings} - - {* Company Name *} - {$ui = [ - 'value' => $data.fieldData.company_name, - 'field' => 'company_name', - 'label' => 'Company Name', - 'required' => $data.fieldRequired.company_name, - 'errorText' => 'Company Name is Required', - 'dataError' => '$data.fieldError.company_name' - ]} - {include file='ui/f6/text.html'} - - {* Company Name 2 *} - {$ui = [ - 'value' => $data.fieldData.company_name2, - 'field' => 'company_name2', - 'label' => 'Company Name 2', - 'required' => $data.fieldRequired.company_name2, - 'errorText' => 'Company Name 2 is Required', - 'dataError' => '$data.fieldError.company_name2' - ]} - {include file='ui/f6/text.html'} - - {* Company Address 1 *} - {$ui = [ - 'value' => $data.fieldData.company_add1, - 'field' => 'company_add1', - 'label' => 'Company Address 1', - 'required' => $data.fieldRequired.company_add1, - 'errorText' => 'Company Address 1 is Required', - 'dataError' => '$data.fieldError.company_add1' - ]} - {include file='ui/f6/text.html'} - - {* Company Address 2 *} - {$ui = [ - 'value' => $data.fieldData.company_addr2, - 'field' => 'company_addr2', - 'label' => 'Company Address 2', - 'required' => $data.fieldRequired.company_addr2, - 'errorText' => 'Company Address 2 is Required', - 'dataError' => '$data.fieldError.company_addr2' - ]} - {include file='ui/f6/text.html'} - - {* Company City *} - {$ui = [ - 'value' => $data.fieldData.company_city, - 'field' => 'company_city', - 'label' => 'Company City', - 'required' => $data.fieldRequired.company_city, - 'errorText' => 'Company City is Required', - 'dataError' => '$data.fieldError.company_city' - ]} - {include file='ui/f6/text.html'} - - {* Company State *} - {$ui = [ - 'value' => $data.fieldData.company_state.value, - 'field' => 'company_state', - 'label' => 'Company State', - 'list' => $data.fieldData.company_state.list, - 'l_label' => 'name', - 'l_value' => 'value', - 'l_blank' => true, - 'required' => $data.fieldRequired.company_state, - 'errorText' => 'Company State is Required', - 'dataError' => '$data.fieldError.company_state' - ]} - {include file='ui/f6/select.html'} - - {* Company Zip *} - {$ui = [ - 'value' => $data.fieldData.company_zip, - 'field' => 'company_zip', - 'label' => 'Company Zip', - 'required' => $data.fieldRequired.company_zip, - 'errorText' => 'Company Zip is Required', - 'dataError' => '$data.fieldError.company_zip' - ]} - {include file='ui/f6/text.html'} - - {* Company Phone *} - {$ui = [ - 'value' => $data.fieldData.company_phone, - 'field' => 'company_phone', - 'label' => 'Company Phone', - 'required' => $data.fieldRequired.company_phone, - 'errorText' => 'Company Phone is Required', - 'dataError' => '$data.fieldError.company_phone' - ]} - {include file='ui/f6/text.html'} - - {* Company Email *} - {$ui = [ - 'value' => $data.fieldData.company_email, - 'field' => 'company_email', - 'label' => 'Company Email', - 'required' => $data.fieldRequired.company_email, - 'errorText' => 'Company Email is Required', - 'dataError' => '$data.fieldError.company_email' - ]} - {include file='ui/f6/text.html'} - - {* Company URL *} - {$ui = [ - 'value' => $data.fieldData.company_url, - 'field' => 'company_url', - 'label' => 'Company URL', - 'required' => $data.fieldRequired.company_url, - 'errorText' => 'Company URL is Required', - 'dataError' => '$data.fieldError.company_url' - ]} - {include file='ui/f6/text.html'} - -
    -
    -
    - - -
    -
    -

    Payment Types

    -
    -
    -

    Notifications

    -
    -
    - -