Completed
Pull Request — Gutenberg/master (#499)
by Darren
53:58 queued 39:33
created
Paypal_Standard/templates/paypal_standard_intro.template.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@
 block discarded – undo
3 3
 // if this is decaf, which is put on WordPress.org, we need to inform users that
4 4
 // we just put an affiliate link there. See https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/ section 12
5 5
 if (apply_filters('FHEE__ee_show_affiliate_links', true)) {
6
-    $closing_tag .= esc_html__(' (affiliate link)', 'event_espresso');
6
+	$closing_tag .= esc_html__(' (affiliate link)', 'event_espresso');
7 7
 }
8 8
 printf(
9
-    esc_html__(
10
-        'PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.',
11
-        'event_espresso'
12
-    ),
13
-    '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">',
14
-    $closing_tag
9
+	esc_html__(
10
+		'PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.',
11
+		'event_espresso'
12
+	),
13
+	'<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">',
14
+	$closing_tag
15 15
 );
Please login to merge, or discard this patch.
payment_methods/Check/EE_PMT_Check.pm.php 2 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -13,121 +13,121 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @param null $pm_instance
18
-     * @return EE_PMT_Check
19
-     */
20
-    public function __construct($pm_instance = null)
21
-    {
22
-        $this->_pretty_name = __("Check", 'event_espresso');
23
-        $this->_default_description = __('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
24
-        parent::__construct($pm_instance);
25
-        $this->_default_button_url = $this->file_url().'lib'.DS.'check-logo.png';
26
-    }
16
+	/**
17
+	 * @param null $pm_instance
18
+	 * @return EE_PMT_Check
19
+	 */
20
+	public function __construct($pm_instance = null)
21
+	{
22
+		$this->_pretty_name = __("Check", 'event_espresso');
23
+		$this->_default_description = __('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
24
+		parent::__construct($pm_instance);
25
+		$this->_default_button_url = $this->file_url().'lib'.DS.'check-logo.png';
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * Creates the billing form for this payment method type
32
-     * @param \EE_Transaction $transaction
33
-     * @return NULL
34
-     */
35
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
36
-    {
37
-        return null;
38
-    }
30
+	/**
31
+	 * Creates the billing form for this payment method type
32
+	 * @param \EE_Transaction $transaction
33
+	 * @return NULL
34
+	 */
35
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
36
+	{
37
+		return null;
38
+	}
39 39
 
40 40
 
41 41
 
42
-    /**
43
-     * Overrides parent to dynamically set some defaults, but only when the form is requested
44
-     * @return EE_Form_Section_Proper
45
-     */
46
-    public function generate_new_settings_form()
47
-    {
48
-        if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
49
-            $organization = EE_Registry::instance()->CFG->organization;
50
-            $organization_name = $organization->get_pretty('name');
51
-            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
52
-            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
53
-            $default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
54
-            $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
55
-            $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
56
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
57
-            $default_address .=  $state ? $state->name() . '<br />' : '';
58
-            $default_address .= $country ? $country->name(). '<br />' : '';
59
-            $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
60
-        } else {
61
-            $default_address = 'unknown';
62
-            $organization_name = 'unknown';
63
-        }
64
-            return new EE_Payment_Method_Form(array(
65
-            'extra_meta_inputs'=>array(
66
-                'check_title'=> new EE_Text_Input(array(
67
-                    'html_label_text'=>  sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()),
68
-                    'default'=>  __("Check/Money Order Payments", 'event_espresso'),
69
-                )),
70
-                'payment_instructions'=>new EE_Text_Area_Input(array(
71
-                    'html_label_text'=>  sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
72
-                    'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
73
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
74
-                )),
75
-                'payable_to'=>new EE_Text_Input(array(
76
-                    'html_label_text'=>  sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
77
-                    'default'=>$organization_name
78
-                )),
79
-                'address_to_send_payment'=>new EE_Text_Area_Input(array(
80
-                    'html_label_text'=>  sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
81
-                    'default'=>$default_address,
82
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
83
-                )),
84
-            ),
85
-            'exclude'=>array('PMD_debug_mode')
86
-            ));
87
-    }
42
+	/**
43
+	 * Overrides parent to dynamically set some defaults, but only when the form is requested
44
+	 * @return EE_Form_Section_Proper
45
+	 */
46
+	public function generate_new_settings_form()
47
+	{
48
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
49
+			$organization = EE_Registry::instance()->CFG->organization;
50
+			$organization_name = $organization->get_pretty('name');
51
+			$default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
52
+			$default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
53
+			$default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
54
+			$default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
55
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
56
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
57
+			$default_address .=  $state ? $state->name() . '<br />' : '';
58
+			$default_address .= $country ? $country->name(). '<br />' : '';
59
+			$default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
60
+		} else {
61
+			$default_address = 'unknown';
62
+			$organization_name = 'unknown';
63
+		}
64
+			return new EE_Payment_Method_Form(array(
65
+			'extra_meta_inputs'=>array(
66
+				'check_title'=> new EE_Text_Input(array(
67
+					'html_label_text'=>  sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()),
68
+					'default'=>  __("Check/Money Order Payments", 'event_espresso'),
69
+				)),
70
+				'payment_instructions'=>new EE_Text_Area_Input(array(
71
+					'html_label_text'=>  sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
72
+					'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
73
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
74
+				)),
75
+				'payable_to'=>new EE_Text_Input(array(
76
+					'html_label_text'=>  sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
77
+					'default'=>$organization_name
78
+				)),
79
+				'address_to_send_payment'=>new EE_Text_Area_Input(array(
80
+					'html_label_text'=>  sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
81
+					'default'=>$default_address,
82
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
83
+				)),
84
+			),
85
+			'exclude'=>array('PMD_debug_mode')
86
+			));
87
+	}
88 88
 
89 89
 
90 90
 
91
-    /**
92
-     * Adds the help tab
93
-     * @see EE_PMT_Base::help_tabs_config()
94
-     * @return array
95
-     */
96
-    public function help_tabs_config()
97
-    {
98
-        return array(
99
-            $this->get_help_tab_name() => array(
100
-                        'title' => __('Check Settings', 'event_espresso'),
101
-                        'filename' => 'payment_methods_overview_check'
102
-                        ),
103
-        );
104
-    }
91
+	/**
92
+	 * Adds the help tab
93
+	 * @see EE_PMT_Base::help_tabs_config()
94
+	 * @return array
95
+	 */
96
+	public function help_tabs_config()
97
+	{
98
+		return array(
99
+			$this->get_help_tab_name() => array(
100
+						'title' => __('Check Settings', 'event_espresso'),
101
+						'filename' => 'payment_methods_overview_check'
102
+						),
103
+		);
104
+	}
105 105
 
106 106
 
107 107
 
108
-    /**
109
-     * For adding any html output ab ove the payment overview.
110
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
111
-     * Other gateways may want to override this, such as offline gateways.
112
-     * @return string
113
-     */
114
-    public function payment_overview_content(EE_Payment $payment)
115
-    {
116
-        $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
117
-        $template_vars = array_merge(
118
-            array(
119
-                            'payment_method'=>$this->_pm_instance,
120
-                            'payment'=>$payment,
121
-                            'check_title'=>'',
122
-                            'payment_instructions'=>'',
123
-                            'payable_to'=>'',
124
-                            'address_to_send_payment'=>'',
125
-                            ),
126
-            $extra_meta_for_payment_method
127
-        );
128
-        return EEH_Template::locate_template(
129
-            'payment_methods' . DS . 'Check'. DS . 'templates'.DS.'check_payment_details_content.template.php',
130
-            $template_vars
131
-        );
132
-    }
108
+	/**
109
+	 * For adding any html output ab ove the payment overview.
110
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
111
+	 * Other gateways may want to override this, such as offline gateways.
112
+	 * @return string
113
+	 */
114
+	public function payment_overview_content(EE_Payment $payment)
115
+	{
116
+		$extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
117
+		$template_vars = array_merge(
118
+			array(
119
+							'payment_method'=>$this->_pm_instance,
120
+							'payment'=>$payment,
121
+							'check_title'=>'',
122
+							'payment_instructions'=>'',
123
+							'payable_to'=>'',
124
+							'address_to_send_payment'=>'',
125
+							),
126
+			$extra_meta_for_payment_method
127
+		);
128
+		return EEH_Template::locate_template(
129
+			'payment_methods' . DS . 'Check'. DS . 'templates'.DS.'check_payment_details_content.template.php',
130
+			$template_vars
131
+		);
132
+	}
133 133
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
49 49
             $organization = EE_Registry::instance()->CFG->organization;
50 50
             $organization_name = $organization->get_pretty('name');
51
-            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
52
-            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
51
+            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1').'<br />' : '';
52
+            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2').'<br />' : '';
53 53
             $default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
54
-            $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
54
+            $default_address .= ($organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
55 55
             $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
56
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
57
-            $default_address .=  $state ? $state->name() . '<br />' : '';
58
-            $default_address .= $country ? $country->name(). '<br />' : '';
56
+            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO);
57
+            $default_address .= $state ? $state->name().'<br />' : '';
58
+            $default_address .= $country ? $country->name().'<br />' : '';
59 59
             $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
60 60
         } else {
61 61
             $default_address = 'unknown';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 'payment_instructions'=>new EE_Text_Area_Input(array(
71 71
                     'html_label_text'=>  sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
72 72
                     'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
73
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
73
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
74 74
                 )),
75 75
                 'payable_to'=>new EE_Text_Input(array(
76 76
                     'html_label_text'=>  sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 'address_to_send_payment'=>new EE_Text_Area_Input(array(
80 80
                     'html_label_text'=>  sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
81 81
                     'default'=>$default_address,
82
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                 )),
84 84
             ),
85 85
             'exclude'=>array('PMD_debug_mode')
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $extra_meta_for_payment_method
127 127
         );
128 128
         return EEH_Template::locate_template(
129
-            'payment_methods' . DS . 'Check'. DS . 'templates'.DS.'check_payment_details_content.template.php',
129
+            'payment_methods'.DS.'Check'.DS.'templates'.DS.'check_payment_details_content.template.php',
130 130
             $template_vars
131 131
         );
132 132
     }
Please login to merge, or discard this patch.
payment_methods/Check/templates/check_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php esc_html_e(
2
-    'Check is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a check.',
3
-    'event_espresso'
2
+	'Check is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a check.',
3
+	'event_espresso'
4 4
 );
Please login to merge, or discard this patch.
payment_methods/Admin_Only/EE_PMT_Admin_Only.pm.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -16,38 +16,38 @@
 block discarded – undo
16 16
 
17 17
 
18 18
 
19
-    /**
20
-     *
21
-     * @param EE_Payment_Method $pm_instance
22
-     * @return EE_PMT_Admin_Only
23
-     */
24
-    public function __construct($pm_instance = null)
25
-    {
26
-        $this->_pretty_name = __("Admin Only", 'event_espresso');
27
-        $this->_default_button_url = '';
28
-        parent::__construct($pm_instance);
29
-    }
30
-
31
-
32
-
33
-    /**
34
-     * Creates the billing form for this payment method type
35
-     * @param \EE_Transaction $transaction
36
-     * @return NULL
37
-     */
38
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
39
-    {
40
-        return null;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * Gets the form for all the settings related to this payment method type
47
-     * @return EE_Payment_Method_Form
48
-     */
49
-    public function generate_new_settings_form()
50
-    {
51
-        return new EE_Payment_Method_Form();
52
-    }
19
+	/**
20
+	 *
21
+	 * @param EE_Payment_Method $pm_instance
22
+	 * @return EE_PMT_Admin_Only
23
+	 */
24
+	public function __construct($pm_instance = null)
25
+	{
26
+		$this->_pretty_name = __("Admin Only", 'event_espresso');
27
+		$this->_default_button_url = '';
28
+		parent::__construct($pm_instance);
29
+	}
30
+
31
+
32
+
33
+	/**
34
+	 * Creates the billing form for this payment method type
35
+	 * @param \EE_Transaction $transaction
36
+	 * @return NULL
37
+	 */
38
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
39
+	{
40
+		return null;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * Gets the form for all the settings related to this payment method type
47
+	 * @return EE_Payment_Method_Form
48
+	 */
49
+	public function generate_new_settings_form()
50
+	{
51
+		return new EE_Payment_Method_Form();
52
+	}
53 53
 }
Please login to merge, or discard this patch.
payment_methods/Bank/EE_PMT_Bank.pm.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -14,99 +14,99 @@
 block discarded – undo
14 14
 
15 15
 
16 16
 
17
-    /**
18
-     *
19
-     * @param EE_Payment_Method $pm_instance
20
-     * @return EE_PMT_Bank
21
-     */
22
-    public function __construct($pm_instance = null)
23
-    {
24
-        $this->_pretty_name = __("Bank", 'event_espresso');
25
-        parent::__construct($pm_instance);
26
-        $this->_default_button_url = $this->file_url().'lib'.DS.'bank-logo.png';
27
-        $this->_default_description = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso');
28
-    }
29
-
30
-
31
-
32
-    /**
33
-     * Creates the billing form for this payment method type
34
-     * @param \EE_Transaction $transaction
35
-     * @return NULL
36
-     */
37
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
38
-    {
39
-        return null;
40
-    }
41
-
42
-
43
-
44
-    /**
45
-     * Gets the form for all the settings related to this payment method type
46
-     * @return EE_Payment_Method_Form
47
-     */
48
-    public function generate_new_settings_form()
49
-    {
50
-        return new EE_Payment_Method_Form(array(
51
-            'extra_meta_inputs'=>array(
52
-                'page_title'=>new EE_Text_Input(array(
53
-                    'html_label_text'=>  sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()),
54
-                    'default'=>  __("Electronic Funds Transfers", 'event_espresso')
55
-                )),
56
-                'payment_instructions'=>new EE_Text_Area_Input(array(
57
-                    'html_label_text'=>  sprintf(__("Payment Instructions %s", "event_espresso"), $this->get_help_tab_link()),
58
-                    'html_help_text' => __('Provide instructions on how registrants can send the bank draft payment. Eg, mention your account name, bank account number, bank name, bank routing code, and bank address, etc.', 'event_espresso'),
59
-                    'default'=> sprintf(
60
-                        __('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'),
61
-                        "\n"
62
-                    ),
63
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
64
-                )),
65
-            ),
66
-            'exclude'=>array('PMD_debug_mode')
67
-        ));
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * Adds the help tab
74
-     * @see EE_PMT_Base::help_tabs_config()
75
-     * @return array
76
-     */
77
-    public function help_tabs_config()
78
-    {
79
-        return array(
80
-            $this->get_help_tab_name() => array(
81
-                        'title' => __('Bank Draft Settings', 'event_espresso'),
82
-                        'filename' => 'payment_methods_overview_bank_draft'
83
-                        ),
84
-        );
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * For adding any html output ab ove the payment overview.
91
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
92
-     * Other gateways may want to override this, such as offline gateways.
93
-     * @return string
94
-     */
95
-    public function payment_overview_content(EE_Payment $payment)
96
-    {
97
-        $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
98
-        $template_vars = array_merge(
99
-            array(
100
-                            'payment_method'=>$this->_pm_instance,
101
-                            'payment'=>$payment,
102
-                            'page_title'=>'',
103
-                            'payment_instructions'=>'',
104
-                            ),
105
-            $extra_meta_for_payment_method
106
-        );
107
-        return EEH_Template::locate_template(
108
-            'payment_methods' . DS . 'Bank'. DS . 'templates' . DS . 'bank_payment_details_content.template.php',
109
-            $template_vars
110
-        );
111
-    }
17
+	/**
18
+	 *
19
+	 * @param EE_Payment_Method $pm_instance
20
+	 * @return EE_PMT_Bank
21
+	 */
22
+	public function __construct($pm_instance = null)
23
+	{
24
+		$this->_pretty_name = __("Bank", 'event_espresso');
25
+		parent::__construct($pm_instance);
26
+		$this->_default_button_url = $this->file_url().'lib'.DS.'bank-logo.png';
27
+		$this->_default_description = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso');
28
+	}
29
+
30
+
31
+
32
+	/**
33
+	 * Creates the billing form for this payment method type
34
+	 * @param \EE_Transaction $transaction
35
+	 * @return NULL
36
+	 */
37
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
38
+	{
39
+		return null;
40
+	}
41
+
42
+
43
+
44
+	/**
45
+	 * Gets the form for all the settings related to this payment method type
46
+	 * @return EE_Payment_Method_Form
47
+	 */
48
+	public function generate_new_settings_form()
49
+	{
50
+		return new EE_Payment_Method_Form(array(
51
+			'extra_meta_inputs'=>array(
52
+				'page_title'=>new EE_Text_Input(array(
53
+					'html_label_text'=>  sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()),
54
+					'default'=>  __("Electronic Funds Transfers", 'event_espresso')
55
+				)),
56
+				'payment_instructions'=>new EE_Text_Area_Input(array(
57
+					'html_label_text'=>  sprintf(__("Payment Instructions %s", "event_espresso"), $this->get_help_tab_link()),
58
+					'html_help_text' => __('Provide instructions on how registrants can send the bank draft payment. Eg, mention your account name, bank account number, bank name, bank routing code, and bank address, etc.', 'event_espresso'),
59
+					'default'=> sprintf(
60
+						__('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'),
61
+						"\n"
62
+					),
63
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
64
+				)),
65
+			),
66
+			'exclude'=>array('PMD_debug_mode')
67
+		));
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * Adds the help tab
74
+	 * @see EE_PMT_Base::help_tabs_config()
75
+	 * @return array
76
+	 */
77
+	public function help_tabs_config()
78
+	{
79
+		return array(
80
+			$this->get_help_tab_name() => array(
81
+						'title' => __('Bank Draft Settings', 'event_espresso'),
82
+						'filename' => 'payment_methods_overview_bank_draft'
83
+						),
84
+		);
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * For adding any html output ab ove the payment overview.
91
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
92
+	 * Other gateways may want to override this, such as offline gateways.
93
+	 * @return string
94
+	 */
95
+	public function payment_overview_content(EE_Payment $payment)
96
+	{
97
+		$extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
98
+		$template_vars = array_merge(
99
+			array(
100
+							'payment_method'=>$this->_pm_instance,
101
+							'payment'=>$payment,
102
+							'page_title'=>'',
103
+							'payment_instructions'=>'',
104
+							),
105
+			$extra_meta_for_payment_method
106
+		);
107
+		return EEH_Template::locate_template(
108
+			'payment_methods' . DS . 'Bank'. DS . 'templates' . DS . 'bank_payment_details_content.template.php',
109
+			$template_vars
110
+		);
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                         __('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'),
61 61
                         "\n"
62 62
                     ),
63
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
63
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
64 64
                 )),
65 65
             ),
66 66
             'exclude'=>array('PMD_debug_mode')
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             $extra_meta_for_payment_method
106 106
         );
107 107
         return EEH_Template::locate_template(
108
-            'payment_methods' . DS . 'Bank'. DS . 'templates' . DS . 'bank_payment_details_content.template.php',
108
+            'payment_methods'.DS.'Bank'.DS.'templates'.DS.'bank_payment_details_content.template.php',
109 109
             $template_vars
110 110
         );
111 111
     }
Please login to merge, or discard this patch.
payment_methods/Bank/templates/bank_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php esc_html_e(
2
-    'Bank is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a bank transfer.',
3
-    'event_espresso'
2
+	'Bank is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a bank transfer.',
3
+	'event_espresso'
4 4
 );
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Pricing_Admin_Page.core.php 2 patches
Indentation   +1412 added lines, -1412 removed lines patch added patch discarded remove patch
@@ -12,1420 +12,1420 @@
 block discarded – undo
12 12
 class Pricing_Admin_Page extends EE_Admin_Page
13 13
 {
14 14
 
15
-    /**
16
-     *    constructor
17
-     *
18
-     * @Constructor
19
-     * @access public
20
-     * @param bool $routing
21
-     * @return Pricing_Admin_Page
22
-     */
23
-    public function __construct($routing = true)
24
-    {
25
-        parent::__construct($routing);
26
-    }
27
-
28
-
29
-    protected function _init_page_props()
30
-    {
31
-        $this->page_slug = PRICING_PG_SLUG;
32
-        $this->page_label = PRICING_LABEL;
33
-        $this->_admin_base_url = PRICING_ADMIN_URL;
34
-        $this->_admin_base_path = PRICING_ADMIN;
35
-    }
36
-
37
-
38
-    protected function _ajax_hooks()
39
-    {
40
-        add_action('wp_ajax_espresso_update_prices_order', array($this, 'update_price_order'));
41
-    }
42
-
43
-
44
-    protected function _define_page_props()
45
-    {
46
-        $this->_admin_page_title = PRICING_LABEL;
47
-        $this->_labels = array(
48
-            'buttons' => array(
49
-                'add'         => __('Add New Default Price', 'event_espresso'),
50
-                'edit'        => __('Edit Default Price', 'event_espresso'),
51
-                'delete'      => __('Delete Default Price', 'event_espresso'),
52
-                'add_type'    => __('Add New Default Price Type', 'event_espresso'),
53
-                'edit_type'   => __('Edit Price Type', 'event_espresso'),
54
-                'delete_type' => __('Delete Price Type', 'event_espresso'),
55
-            ),
56
-        );
57
-    }
58
-
59
-
60
-    /**
61
-     *        an array for storing request actions and their corresponding methods
62
-     *
63
-     * @access private
64
-     * @return void
65
-     */
66
-    protected function _set_page_routes()
67
-    {
68
-        $prc_id = ! empty($this->_req_data['PRC_ID']) && ! is_array($this->_req_data['PRC_ID'])
69
-            ? $this->_req_data['PRC_ID'] : 0;
70
-        $prt_id = ! empty($this->_req_data['PRT_ID']) && ! is_array($this->_req_data['PRT_ID'])
71
-            ? $this->_req_data['PRT_ID'] : 0;
72
-        $this->_page_routes = array(
73
-            'default'                     => array(
74
-                'func'       => '_price_overview_list_table',
75
-                'capability' => 'ee_read_default_prices',
76
-            ),
77
-            'add_new_price'               => array(
78
-                'func'       => '_edit_price_details',
79
-                'args'       => array('new_price' => true),
80
-                'capability' => 'ee_edit_default_prices',
81
-            ),
82
-            'edit_price'                  => array(
83
-                'func'       => '_edit_price_details',
84
-                'args'       => array('new_price' => false),
85
-                'capability' => 'ee_edit_default_price',
86
-                'obj_id'     => $prc_id,
87
-            ),
88
-            'insert_price'                => array(
89
-                'func'       => '_insert_or_update_price',
90
-                'args'       => array('new_price' => true),
91
-                'noheader'   => true,
92
-                'capability' => 'ee_edit_default_prices',
93
-            ),
94
-            'update_price'                => array(
95
-                'func'       => '_insert_or_update_price',
96
-                'args'       => array('new_price' => false),
97
-                'noheader'   => true,
98
-                'capability' => 'ee_edit_default_price',
99
-                'obj_id'     => $prc_id,
100
-            ),
101
-            'trash_price'                 => array(
102
-                'func'       => '_trash_or_restore_price',
103
-                'args'       => array('trash' => true),
104
-                'noheader'   => true,
105
-                'capability' => 'ee_delete_default_price',
106
-                'obj_id'     => $prc_id,
107
-            ),
108
-            'restore_price'               => array(
109
-                'func'       => '_trash_or_restore_price',
110
-                'args'       => array('trash' => false),
111
-                'noheader'   => true,
112
-                'capability' => 'ee_delete_default_price',
113
-                'obj_id'     => $prc_id,
114
-            ),
115
-            'delete_price'                => array(
116
-                'func'       => '_delete_price',
117
-                'noheader'   => true,
118
-                'capability' => 'ee_delete_default_price',
119
-                'obj_id'     => $prc_id,
120
-            ),
121
-            'espresso_update_price_order' => array(
122
-                'func'       => 'update_price_order',
123
-                'noheader'   => true,
124
-                'capability' => 'ee_edit_default_prices',
125
-            ),
126
-            // price types
127
-            'price_types'                 => array(
128
-                'func'       => '_price_types_overview_list_table',
129
-                'capability' => 'ee_read_default_price_types',
130
-            ),
131
-            'add_new_price_type'          => array(
132
-                'func'       => '_edit_price_type_details',
133
-                'capability' => 'ee_edit_default_price_types',
134
-            ),
135
-            'edit_price_type'             => array(
136
-                'func'       => '_edit_price_type_details',
137
-                'capability' => 'ee_edit_default_price_type',
138
-                'obj_id'     => $prt_id,
139
-            ),
140
-            'insert_price_type'           => array(
141
-                'func'       => '_insert_or_update_price_type',
142
-                'args'       => array('new_price_type' => true),
143
-                'noheader'   => true,
144
-                'capability' => 'ee_edit_default_price_types',
145
-            ),
146
-            'update_price_type'           => array(
147
-                'func'       => '_insert_or_update_price_type',
148
-                'args'       => array('new_price_type' => false),
149
-                'noheader'   => true,
150
-                'capability' => 'ee_edit_default_price_type',
151
-                'obj_id'     => $prt_id,
152
-            ),
153
-            'trash_price_type'            => array(
154
-                'func'       => '_trash_or_restore_price_type',
155
-                'args'       => array('trash' => true),
156
-                'noheader'   => true,
157
-                'capability' => 'ee_delete_default_price_type',
158
-                'obj_id'     => $prt_id,
159
-            ),
160
-            'restore_price_type'          => array(
161
-                'func'       => '_trash_or_restore_price_type',
162
-                'args'       => array('trash' => false),
163
-                'noheader'   => true,
164
-                'capability' => 'ee_delete_default_price_type',
165
-                'obj_id'     => $prt_id,
166
-            ),
167
-            'delete_price_type'           => array(
168
-                'func'       => '_delete_price_type',
169
-                'noheader'   => true,
170
-                'capability' => 'ee_delete_default_price_type',
171
-                'obj_id'     => $prt_id,
172
-            ),
173
-            'tax_settings'                => array(
174
-                'func'       => '_tax_settings',
175
-                'capability' => 'manage_options',
176
-            ),
177
-            'update_tax_settings'         => array(
178
-                'func'       => '_update_tax_settings',
179
-                'capability' => 'manage_options',
180
-                'noheader'   => true,
181
-            ),
182
-        );
183
-    }
184
-
185
-
186
-    protected function _set_page_config()
187
-    {
188
-
189
-        $this->_page_config = array(
190
-            'default'            => array(
191
-                'nav'           => array(
192
-                    'label' => __('Default Pricing', 'event_espresso'),
193
-                    'order' => 10,
194
-                ),
195
-                'list_table'    => 'Prices_List_Table',
196
-                'help_tabs'     => array(
197
-                    'pricing_default_pricing_help_tab'                           => array(
198
-                        'title'    => __('Default Pricing', 'event_espresso'),
199
-                        'filename' => 'pricing_default_pricing',
200
-                    ),
201
-                    'pricing_default_pricing_table_column_headings_help_tab'     => array(
202
-                        'title'    => __('Default Pricing Table Column Headings', 'event_espresso'),
203
-                        'filename' => 'pricing_default_pricing_table_column_headings',
204
-                    ),
205
-                    'pricing_default_pricing_views_bulk_actions_search_help_tab' => array(
206
-                        'title'    => __('Default Pricing Views & Bulk Actions & Search', 'event_espresso'),
207
-                        'filename' => 'pricing_default_pricing_views_bulk_actions_search',
208
-                    ),
209
-                ),
210
-                'help_tour'     => array('Pricing_Default_Prices_Help_Tour'),
211
-                'require_nonce' => false,
212
-            ),
213
-            'add_new_price'      => array(
214
-                'nav'           => array(
215
-                    'label'      => __('Add New Default Price', 'event_espresso'),
216
-                    'order'      => 20,
217
-                    'persistent' => false,
218
-                ),
219
-                'help_tabs'     => array(
220
-                    'add_new_default_price_help_tab' => array(
221
-                        'title'    => __('Add New Default Price', 'event_espresso'),
222
-                        'filename' => 'pricing_add_new_default_price',
223
-                    ),
224
-                ),
225
-                'help_tour'     => array('Pricing_Add_New_Default_Price_Help_Tour'),
226
-                'metaboxes'     => array('_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes'),
227
-                'require_nonce' => false,
228
-            ),
229
-            'edit_price'         => array(
230
-                'nav'           => array(
231
-                    'label'      => __('Edit Default Price', 'event_espresso'),
232
-                    'order'      => 20,
233
-                    'url'        => isset($this->_req_data['id']) ? add_query_arg(
234
-                        array('id' => $this->_req_data['id']),
235
-                        $this->_current_page_view_url
236
-                    ) : $this->_admin_base_url,
237
-                    'persistent' => false,
238
-                ),
239
-                'metaboxes'     => array('_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes'),
240
-                'help_tabs'     => array(
241
-                    'edit_default_price_help_tab' => array(
242
-                        'title'    => __('Edit Default Price', 'event_espresso'),
243
-                        'filename' => 'pricing_edit_default_price',
244
-                    ),
245
-                ),
246
-                'help_tour'     => array('Pricing_Edit_Default_Price_Help_Tour'),
247
-                'require_nonce' => false,
248
-            ),
249
-            'price_types'        => array(
250
-                'nav'           => array(
251
-                    'label' => __('Price Types', 'event_espresso'),
252
-                    'order' => 30,
253
-                ),
254
-                'list_table'    => 'Price_Types_List_Table',
255
-                'help_tabs'     => array(
256
-                    'pricing_price_types_help_tab'                           => array(
257
-                        'title'    => __('Price Types', 'event_espresso'),
258
-                        'filename' => 'pricing_price_types',
259
-                    ),
260
-                    'pricing_price_types_table_column_headings_help_tab'     => array(
261
-                        'title'    => __('Price Types Table Column Headings', 'event_espresso'),
262
-                        'filename' => 'pricing_price_types_table_column_headings',
263
-                    ),
264
-                    'pricing_price_types_views_bulk_actions_search_help_tab' => array(
265
-                        'title'    => __('Price Types Views & Bulk Actions & Search', 'event_espresso'),
266
-                        'filename' => 'pricing_price_types_views_bulk_actions_search',
267
-                    ),
268
-                ),
269
-                'help_tour'     => array('Pricing_Price_Types_Default_Help_Tour'),
270
-                'metaboxes'     => array('_espresso_news_post_box', '_espresso_links_post_box'),
271
-                'require_nonce' => false,
272
-            ),
273
-            'add_new_price_type' => array(
274
-                'nav'           => array(
275
-                    'label'      => __('Add New Price Type', 'event_espresso'),
276
-                    'order'      => 40,
277
-                    'persistent' => false,
278
-                ),
279
-                'help_tabs'     => array(
280
-                    'add_new_price_type_help_tab' => array(
281
-                        'title'    => __('Add New Price Type', 'event_espresso'),
282
-                        'filename' => 'pricing_add_new_price_type',
283
-                    ),
284
-                ),
285
-                'help_tour'     => array('Pricing_Add_New_Price_Type_Help_Tour'),
286
-                'metaboxes'     => array(
287
-                    '_publish_post_box',
288
-                    '_espresso_news_post_box',
289
-                    '_price_type_details_meta_boxes',
290
-                ),
291
-                'require_nonce' => false,
292
-            ),
293
-            'edit_price_type'    => array(
294
-                'nav'       => array(
295
-                    'label'      => __('Edit Price Type', 'event_espresso'),
296
-                    'order'      => 40,
297
-                    'persistent' => false,
298
-                ),
299
-                'help_tabs' => array(
300
-                    'edit_price_type_help_tab' => array(
301
-                        'title'    => __('Edit Price Type', 'event_espresso'),
302
-                        'filename' => 'pricing_edit_price_type',
303
-                    ),
304
-                ),
305
-                'help_tour' => array('Pricing_Edit_Price_Type_Help_Tour'),
306
-                'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes'),
307
-
308
-                'require_nonce' => false,
309
-            ),
310
-            'tax_settings'       => array(
311
-                'nav'           => array(
312
-                    'label' => esc_html__('Tax Settings', 'event_espresso'),
313
-                    'order' => 40,
314
-                ),
315
-                'labels'        => array(
316
-                    'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'),
317
-                ),
318
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
319
-                // 'help_tabs'     => array(
320
-                //     'registration_form_reg_form_settings_help_tab' => array(
321
-                //         'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
322
-                //         'filename' => 'registration_form_reg_form_settings'
323
-                //     ),
324
-                // ),
325
-                // 'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
326
-                'require_nonce' => true,
327
-            ),
328
-        );
329
-    }
330
-
331
-
332
-    protected function _add_screen_options()
333
-    {
334
-        // todo
335
-    }
336
-
337
-
338
-    protected function _add_screen_options_default()
339
-    {
340
-        $this->_per_page_screen_option();
341
-    }
342
-
343
-
344
-    protected function _add_screen_options_price_types()
345
-    {
346
-        $page_title = $this->_admin_page_title;
347
-        $this->_admin_page_title = __('Price Types', 'event_espresso');
348
-        $this->_per_page_screen_option();
349
-        $this->_admin_page_title = $page_title;
350
-    }
351
-
352
-
353
-    protected function _add_feature_pointers()
354
-    {
355
-    }
356
-
357
-
358
-    public function load_scripts_styles()
359
-    {
360
-        // styles
361
-        wp_enqueue_style('espresso-ui-theme');
362
-        wp_register_style(
363
-            'espresso_PRICING',
364
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
365
-            array(),
366
-            EVENT_ESPRESSO_VERSION
367
-        );
368
-        wp_enqueue_style('espresso_PRICING');
369
-
370
-        // scripts
371
-        wp_enqueue_script('ee_admin_js');
372
-        wp_enqueue_script('jquery-ui-position');
373
-        wp_enqueue_script('jquery-ui-widget');
374
-        // wp_enqueue_script('jquery-ui-dialog');
375
-        // wp_enqueue_script('jquery-ui-draggable');
376
-        // wp_enqueue_script('jquery-ui-datepicker');
377
-        wp_register_script(
378
-            'espresso_PRICING',
379
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
380
-            array('jquery'),
381
-            EVENT_ESPRESSO_VERSION,
382
-            true
383
-        );
384
-        wp_enqueue_script('espresso_PRICING');
385
-    }
386
-
387
-
388
-    public function load_scripts_styles_default()
389
-    {
390
-        wp_enqueue_script('espresso_ajax_table_sorting');
391
-    }
392
-
393
-
394
-    public function admin_footer_scripts()
395
-    {
396
-    }
397
-
398
-    public function admin_init()
399
-    {
400
-    }
401
-
402
-    public function admin_notices()
403
-    {
404
-    }
405
-
406
-
407
-    protected function _set_list_table_views_default()
408
-    {
409
-        $this->_views = array(
410
-            'all' => array(
411
-                'slug'        => 'all',
412
-                'label'       => __('View All Default Pricing', 'event_espresso'),
413
-                'count'       => 0,
414
-                'bulk_action' => array(
415
-                    'trash_price' => __('Move to Trash', 'event_espresso'),
416
-                ),
417
-            ),
418
-        );
419
-
420
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
421
-            $this->_views['trashed'] = array(
422
-                'slug'        => 'trashed',
423
-                'label'       => __('Trash', 'event_espresso'),
424
-                'count'       => 0,
425
-                'bulk_action' => array(
426
-                    'restore_price' => __('Restore from Trash', 'event_espresso'),
427
-                    'delete_price'  => __('Delete Permanently', 'event_espresso'),
428
-                ),
429
-            );
430
-        }
431
-    }
432
-
433
-
434
-    protected function _set_list_table_views_price_types()
435
-    {
436
-        $this->_views = array(
437
-            'all' => array(
438
-                'slug'        => 'all',
439
-                'label'       => __('All', 'event_espresso'),
440
-                'count'       => 0,
441
-                'bulk_action' => array(
442
-                    'trash_price_type' => __('Move to Trash', 'event_espresso'),
443
-                ),
444
-            ),
445
-        );
446
-
447
-        if (EE_Registry::instance()->CAP->current_user_can(
448
-            'ee_delete_default_price_types',
449
-            'pricing_trash_price_type'
450
-        )) {
451
-            $this->_views['trashed'] = array(
452
-                'slug'        => 'trashed',
453
-                'label'       => __('Trash', 'event_espresso'),
454
-                'count'       => 0,
455
-                'bulk_action' => array(
456
-                    'restore_price_type' => __('Restore from Trash', 'event_espresso'),
457
-                    'delete_price_type'  => __('Delete Permanently', 'event_espresso'),
458
-                ),
459
-            );
460
-        }
461
-    }
462
-
463
-
464
-    /**
465
-     *        generates HTML for main Prices Admin page
466
-     *
467
-     * @access protected
468
-     * @return void
469
-     */
470
-    protected function _price_overview_list_table()
471
-    {
472
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
473
-            'add_new_price',
474
-            'add',
475
-            array(),
476
-            'add-new-h2'
477
-        );
478
-        $this->admin_page_title .= $this->_learn_more_about_pricing_link();
479
-        $this->_search_btn_label = __('Default Prices', 'event_espresso');
480
-        $this->display_admin_list_table_page_with_no_sidebar();
481
-    }
482
-
483
-
484
-    /**
485
-     *    retrieve data for Prices List table
486
-     *
487
-     * @access public
488
-     * @param  int     $per_page how many prices displayed per page
489
-     * @param  boolean $count    return the count or objects
490
-     * @param  boolean $trashed  whether the current view is of the trash can - eww yuck!
491
-     * @return mixed (int|array)  int = count || array of price objects
492
-     */
493
-    public function get_prices_overview_data($per_page = 10, $count = false, $trashed = false)
494
-    {
495
-
496
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
497
-        // start with an empty array
498
-        $event_pricing = array();
499
-
500
-        require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
501
-        require_once(EE_MODELS . 'EEM_Price.model.php');
502
-        // $PRC = EEM_Price::instance();
503
-
504
-        $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby'];
505
-        $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
506
-            : 'ASC';
507
-
508
-        switch ($this->_req_data['orderby']) {
509
-            case 'name':
510
-                $orderby = array('PRC_name' => $order);
511
-                break;
512
-            case 'type':
513
-                $orderby = array('Price_Type.PRT_name' => $order);
514
-                break;
515
-            case 'amount':
516
-                $orderby = array('PRC_amount' => $order);
517
-                break;
518
-            default:
519
-                $orderby = array('PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order);
520
-        }
521
-
522
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
523
-            ? $this->_req_data['paged'] : 1;
524
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
525
-            ? $this->_req_data['perpage'] : $per_page;
526
-
527
-        $_where = array(
528
-            'PRC_is_default' => 1,
529
-            'PRC_deleted'    => $trashed,
530
-        );
531
-
532
-        $offset = ($current_page - 1) * $per_page;
533
-        $limit = array($offset, $per_page);
534
-
535
-        if (isset($this->_req_data['s'])) {
536
-            $sstr = '%' . $this->_req_data['s'] . '%';
537
-            $_where['OR'] = array(
538
-                'PRC_name'            => array('LIKE', $sstr),
539
-                'PRC_desc'            => array('LIKE', $sstr),
540
-                'PRC_amount'          => array('LIKE', $sstr),
541
-                'Price_Type.PRT_name' => array('LIKE', $sstr),
542
-            );
543
-        }
544
-
545
-        $query_params = array(
546
-            $_where,
547
-            'order_by' => $orderby,
548
-            'limit'    => $limit,
549
-            'group_by' => 'PRC_ID',
550
-        );
551
-
552
-        if ($count) {
553
-            return $trashed ? EEM_Price::instance()->count(array($_where))
554
-                : EEM_Price::instance()->count_deleted_and_undeleted(array($_where));
555
-        } else {
556
-            return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
557
-        }
558
-    }
559
-
560
-
561
-    /**
562
-     *        _price_details
563
-     *
564
-     * @access protected
565
-     * @return void
566
-     */
567
-    protected function _edit_price_details()
568
-    {
569
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
570
-        // grab price ID
571
-        $PRC_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id'])
572
-            : false;
573
-        // change page title based on request action
574
-        switch ($this->_req_action) {
575
-            case 'add_new_price':
576
-                $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso');
577
-                break;
578
-            case 'edit_price':
579
-                $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso');
580
-                break;
581
-            default:
582
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
583
-        }
584
-        // add PRC_ID to title if editing
585
-        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
586
-
587
-        // get prices
588
-        require_once(EE_MODELS . 'EEM_Price.model.php');
589
-        $PRC = EEM_Price::instance();
590
-
591
-        if ($PRC_ID) {
592
-            $price = $PRC->get_one_by_ID($PRC_ID);
593
-            $additional_hidden_fields = array(
594
-                'PRC_ID' => array('type' => 'hidden', 'value' => $PRC_ID),
595
-            );
596
-            $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
597
-        } else {
598
-            $price = $PRC->get_new_price();
599
-            $this->_set_add_edit_form_tags('insert_price');
600
-        }
601
-
602
-        $this->_template_args['PRC_ID'] = $PRC_ID;
603
-        $this->_template_args['price'] = $price;
604
-
605
-        // get price types
606
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
607
-        $PRT = EEM_Price_Type::instance();
608
-        $price_types = $PRT->get_all(array(array('PBT_ID' => array('!=', 1))));
609
-        $price_type_names = array();
610
-        if (empty($price_types)) {
611
-            $msg = __(
612
-                'You have no price types defined. Please add a price type before adding a price.',
613
-                'event_espresso'
614
-            );
615
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
616
-            exit();
617
-        } else {
618
-            foreach ($price_types as $type) {
619
-                // if ($type->is_global()) {
620
-                $price_type_names[] = array('id' => $type->ID(), 'text' => $type->name());
621
-            // }
622
-            }
623
-        }
624
-
625
-        $this->_template_args['price_types'] = $price_type_names;
626
-        $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
627
-
628
-        $this->_set_publish_post_box_vars('id', $PRC_ID);
629
-        // the details template wrapper
630
-        $this->display_admin_page_with_sidebar();
631
-    }
632
-
633
-
634
-    /**
635
-     *        declare price details page metaboxes
636
-     *
637
-     * @access protected
638
-     * @return void
639
-     */
640
-    protected function _price_details_meta_boxes()
641
-    {
642
-        add_meta_box(
643
-            'edit-price-details-mbox',
644
-            __('Default Price Details', 'event_espresso'),
645
-            array($this, '_edit_price_details_meta_box'),
646
-            $this->wp_page_slug,
647
-            'normal',
648
-            'high'
649
-        );
650
-    }
651
-
652
-
653
-    /**
654
-     *        _edit_price_details_meta_box
655
-     *
656
-     * @access public
657
-     * @return void
658
-     */
659
-    public function _edit_price_details_meta_box()
660
-    {
661
-        echo EEH_Template::display_template(
662
-            PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
663
-            $this->_template_args,
664
-            true
665
-        );
666
-    }
667
-
668
-
669
-    /**
670
-     *        set_price_column_values
671
-     *
672
-     * @access protected
673
-     * @return array
674
-     */
675
-    protected function set_price_column_values()
676
-    {
677
-
678
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
679
-
680
-        $set_column_values = array(
681
-            'PRT_ID'         => absint($this->_req_data['PRT_ID']),
682
-            'PRC_amount'     => $this->_req_data['PRC_amount'],
683
-            'PRC_name'       => $this->_req_data['PRC_name'],
684
-            'PRC_desc'       => $this->_req_data['PRC_desc'],
685
-            'PRC_is_default' => 1,
686
-            'PRC_overrides'  => null,
687
-            'PRC_order'      => 0,
688
-            'PRC_deleted'    => 0,
689
-            'PRC_parent'     => 0,
690
-        );
691
-        return $set_column_values;
692
-    }
693
-
694
-
695
-    /**
696
-     *        insert_or_update_price
697
-     *
698
-     * @param boolean $insert - whether to insert or update
699
-     * @access protected
700
-     * @return void
701
-     */
702
-    protected function _insert_or_update_price($insert = false)
703
-    {
704
-
705
-        // echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
706
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
707
-
708
-        require_once(EE_MODELS . 'EEM_Price.model.php');
709
-        $PRC = EEM_Price::instance();
710
-
711
-        // why be so pessimistic ???  : (
712
-        $success = 0;
713
-
714
-        $set_column_values = $this->set_price_column_values();
715
-        // is this a new Price ?
716
-        if ($insert) {
717
-            // run the insert
718
-            if ($PRC_ID = $PRC->insert($set_column_values)) {
719
-                // make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
720
-                $PR = EEM_price::instance()->get_one_by_ID($PRC_ID);
721
-                if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
722
-                    $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
723
-                    $ticket->_add_relation_to($PR, 'Price');
724
-                    $ticket->save();
725
-                }
726
-                $success = 1;
727
-            } else {
728
-                $PRC_ID = false;
729
-                $success = 0;
730
-            }
731
-            $action_desc = 'created';
732
-        } else {
733
-            $PRC_ID = absint($this->_req_data['PRC_ID']);
734
-            // run the update
735
-            $where_cols_n_values = array('PRC_ID' => $PRC_ID);
736
-            if ($PRC->update($set_column_values, array($where_cols_n_values))) {
737
-                $success = 1;
738
-            }
739
-
740
-            $PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
741
-            if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
742
-                // if this is $PRC_ID == 1, then we need to update the default ticket attached to this price so the TKT_price value is updated.
743
-                if ($PRC_ID === 1) {
744
-                    $ticket = $PR->get_first_related('Ticket');
745
-                    if ($ticket) {
746
-                        $ticket->set('TKT_price', $PR->get('PRC_amount'));
747
-                        $ticket->set('TKT_name', $PR->get('PRC_name'));
748
-                        $ticket->set('TKT_description', $PR->get('PRC_desc'));
749
-                        $ticket->save();
750
-                    }
751
-                } else {
752
-                    // we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
753
-                    $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
754
-                    $ticket->_add_relation_to($PRC_ID, 'Price');
755
-                    $ticket->save();
756
-                }
757
-            }
758
-
759
-            $action_desc = 'updated';
760
-        }
761
-
762
-        $query_args = array('action' => 'edit_price', 'id' => $PRC_ID);
763
-
764
-        $this->_redirect_after_action($success, 'Prices', $action_desc, $query_args);
765
-    }
766
-
767
-
768
-    /**
769
-     *        _trash_or_restore_price
770
-     *
771
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
772
-     * @access protected
773
-     * @return void
774
-     */
775
-    protected function _trash_or_restore_price($trash = true)
776
-    {
777
-
778
-        // echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
779
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
780
-
781
-        require_once(EE_MODELS . 'EEM_Price.model.php');
782
-        $PRC = EEM_Price::instance();
783
-
784
-        $success = 1;
785
-        $PRC_deleted = $trash ? true : false;
786
-
787
-        // get base ticket for updating
788
-        $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
789
-        // Checkboxes
790
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
791
-            // if array has more than one element than success message should be plural
792
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
793
-            // cycle thru checkboxes
794
-            while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) {
795
-                if (! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), absint($PRC_ID))) {
796
-                    $success = 0;
797
-                } else {
798
-                    $PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
799
-                    if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
800
-                        // if trashing then remove relations to base default ticket.  If restoring then add back to base default ticket
801
-                        if ($PRC_deleted) {
802
-                            $ticket->_remove_relation_to($PRC_ID, 'Price');
803
-                        } else {
804
-                            $ticket->_add_relation_to($PRC_ID, 'Price');
805
-                        }
806
-                        $ticket->save();
807
-                    }
808
-                }
809
-            }
810
-        } else {
811
-            // grab single id and delete
812
-            $PRC_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
813
-            if (empty($PRC_ID) || ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), $PRC_ID)) {
814
-                $success = 0;
815
-            } else {
816
-                $PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
817
-                if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
818
-                    // if trashing then remove relations to base default ticket.  If restoring then add back to base default ticket
819
-                    if ($PRC_deleted) {
820
-                        $ticket->_remove_relation_to($PRC_ID, 'Price');
821
-                    } else {
822
-                        $ticket->_add_relation_to($PRC_ID, 'Price');
823
-                    }
824
-                    $ticket->save();
825
-                }
826
-            }
827
-        }
828
-        $query_args = array(
829
-            'action' => 'default',
830
-        );
831
-
832
-        if ($success) {
833
-            if ($trash) {
834
-                $msg = $success == 2
835
-                    ? __('The Prices have been trashed.', 'event_espresso')
836
-                    : __(
837
-                        'The Price has been trashed.',
838
-                        'event_espresso'
839
-                    );
840
-            } else {
841
-                $msg = $success == 2
842
-                    ? __('The Prices have been restored.', 'event_espresso')
843
-                    : __(
844
-                        'The Price has been restored.',
845
-                        'event_espresso'
846
-                    );
847
-            }
848
-
849
-            EE_Error::add_success($msg);
850
-        }
851
-
852
-        $this->_redirect_after_action(false, '', '', $query_args, true);
853
-    }
854
-
855
-
856
-    /**
857
-     *        _delete_price
858
-     *
859
-     * @access protected
860
-     * @return void
861
-     */
862
-    protected function _delete_price()
863
-    {
864
-
865
-        // echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
866
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
867
-
868
-        require_once(EE_MODELS . 'EEM_Price.model.php');
869
-        $PRC = EEM_Price::instance();
870
-
871
-        $success = 1;
872
-        // Checkboxes
873
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
874
-            // if array has more than one element than success message should be plural
875
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
876
-            // cycle thru bulk action checkboxes
877
-            while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) {
878
-                if (! $PRC->delete_permanently_by_ID(absint($PRC_ID))) {
879
-                    $success = 0;
880
-                }
881
-            }
882
-        } else {
883
-            // grab single id and delete
884
-            $PRC_ID = absint($this->_req_data['id']);
885
-            if (! $PRC->delete_permanently_by_ID($PRC_ID)) {
886
-                $success = 0;
887
-            }
888
-        }
889
-
890
-        $this->_redirect_after_action($success, 'Prices', 'deleted', array());
891
-    }
892
-
893
-
894
-    public function update_price_order()
895
-    {
896
-        $success = __('Price order was updated successfully.', 'event_espresso');
897
-
898
-        // grab our row IDs
899
-        $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) ? explode(
900
-            ',',
901
-            rtrim(
902
-                $this->_req_data['row_ids'],
903
-                ','
904
-            )
905
-        ) : false;
906
-
907
-        if (is_array($row_ids)) {
908
-            for ($i = 0; $i < count($row_ids); $i++) {
909
-                // Update the prices when re-ordering
910
-                $id = absint($row_ids[ $i ]);
911
-                if (EEM_Price::instance()->update(
912
-                    array('PRC_order' => $i + 1),
913
-                    array(array('PRC_ID' => $id))
914
-                ) === false) {
915
-                    $success = false;
916
-                }
917
-            }
918
-        } else {
919
-            $success = false;
920
-        }
921
-
922
-        $errors = ! $success ? __('An error occurred. The price order was not updated.', 'event_espresso') : false;
923
-
924
-        echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
925
-        die();
926
-    }
927
-
928
-
929
-
930
-
931
-
932
-
933
-    /**************************************************************************************************************************************************************
15
+	/**
16
+	 *    constructor
17
+	 *
18
+	 * @Constructor
19
+	 * @access public
20
+	 * @param bool $routing
21
+	 * @return Pricing_Admin_Page
22
+	 */
23
+	public function __construct($routing = true)
24
+	{
25
+		parent::__construct($routing);
26
+	}
27
+
28
+
29
+	protected function _init_page_props()
30
+	{
31
+		$this->page_slug = PRICING_PG_SLUG;
32
+		$this->page_label = PRICING_LABEL;
33
+		$this->_admin_base_url = PRICING_ADMIN_URL;
34
+		$this->_admin_base_path = PRICING_ADMIN;
35
+	}
36
+
37
+
38
+	protected function _ajax_hooks()
39
+	{
40
+		add_action('wp_ajax_espresso_update_prices_order', array($this, 'update_price_order'));
41
+	}
42
+
43
+
44
+	protected function _define_page_props()
45
+	{
46
+		$this->_admin_page_title = PRICING_LABEL;
47
+		$this->_labels = array(
48
+			'buttons' => array(
49
+				'add'         => __('Add New Default Price', 'event_espresso'),
50
+				'edit'        => __('Edit Default Price', 'event_espresso'),
51
+				'delete'      => __('Delete Default Price', 'event_espresso'),
52
+				'add_type'    => __('Add New Default Price Type', 'event_espresso'),
53
+				'edit_type'   => __('Edit Price Type', 'event_espresso'),
54
+				'delete_type' => __('Delete Price Type', 'event_espresso'),
55
+			),
56
+		);
57
+	}
58
+
59
+
60
+	/**
61
+	 *        an array for storing request actions and their corresponding methods
62
+	 *
63
+	 * @access private
64
+	 * @return void
65
+	 */
66
+	protected function _set_page_routes()
67
+	{
68
+		$prc_id = ! empty($this->_req_data['PRC_ID']) && ! is_array($this->_req_data['PRC_ID'])
69
+			? $this->_req_data['PRC_ID'] : 0;
70
+		$prt_id = ! empty($this->_req_data['PRT_ID']) && ! is_array($this->_req_data['PRT_ID'])
71
+			? $this->_req_data['PRT_ID'] : 0;
72
+		$this->_page_routes = array(
73
+			'default'                     => array(
74
+				'func'       => '_price_overview_list_table',
75
+				'capability' => 'ee_read_default_prices',
76
+			),
77
+			'add_new_price'               => array(
78
+				'func'       => '_edit_price_details',
79
+				'args'       => array('new_price' => true),
80
+				'capability' => 'ee_edit_default_prices',
81
+			),
82
+			'edit_price'                  => array(
83
+				'func'       => '_edit_price_details',
84
+				'args'       => array('new_price' => false),
85
+				'capability' => 'ee_edit_default_price',
86
+				'obj_id'     => $prc_id,
87
+			),
88
+			'insert_price'                => array(
89
+				'func'       => '_insert_or_update_price',
90
+				'args'       => array('new_price' => true),
91
+				'noheader'   => true,
92
+				'capability' => 'ee_edit_default_prices',
93
+			),
94
+			'update_price'                => array(
95
+				'func'       => '_insert_or_update_price',
96
+				'args'       => array('new_price' => false),
97
+				'noheader'   => true,
98
+				'capability' => 'ee_edit_default_price',
99
+				'obj_id'     => $prc_id,
100
+			),
101
+			'trash_price'                 => array(
102
+				'func'       => '_trash_or_restore_price',
103
+				'args'       => array('trash' => true),
104
+				'noheader'   => true,
105
+				'capability' => 'ee_delete_default_price',
106
+				'obj_id'     => $prc_id,
107
+			),
108
+			'restore_price'               => array(
109
+				'func'       => '_trash_or_restore_price',
110
+				'args'       => array('trash' => false),
111
+				'noheader'   => true,
112
+				'capability' => 'ee_delete_default_price',
113
+				'obj_id'     => $prc_id,
114
+			),
115
+			'delete_price'                => array(
116
+				'func'       => '_delete_price',
117
+				'noheader'   => true,
118
+				'capability' => 'ee_delete_default_price',
119
+				'obj_id'     => $prc_id,
120
+			),
121
+			'espresso_update_price_order' => array(
122
+				'func'       => 'update_price_order',
123
+				'noheader'   => true,
124
+				'capability' => 'ee_edit_default_prices',
125
+			),
126
+			// price types
127
+			'price_types'                 => array(
128
+				'func'       => '_price_types_overview_list_table',
129
+				'capability' => 'ee_read_default_price_types',
130
+			),
131
+			'add_new_price_type'          => array(
132
+				'func'       => '_edit_price_type_details',
133
+				'capability' => 'ee_edit_default_price_types',
134
+			),
135
+			'edit_price_type'             => array(
136
+				'func'       => '_edit_price_type_details',
137
+				'capability' => 'ee_edit_default_price_type',
138
+				'obj_id'     => $prt_id,
139
+			),
140
+			'insert_price_type'           => array(
141
+				'func'       => '_insert_or_update_price_type',
142
+				'args'       => array('new_price_type' => true),
143
+				'noheader'   => true,
144
+				'capability' => 'ee_edit_default_price_types',
145
+			),
146
+			'update_price_type'           => array(
147
+				'func'       => '_insert_or_update_price_type',
148
+				'args'       => array('new_price_type' => false),
149
+				'noheader'   => true,
150
+				'capability' => 'ee_edit_default_price_type',
151
+				'obj_id'     => $prt_id,
152
+			),
153
+			'trash_price_type'            => array(
154
+				'func'       => '_trash_or_restore_price_type',
155
+				'args'       => array('trash' => true),
156
+				'noheader'   => true,
157
+				'capability' => 'ee_delete_default_price_type',
158
+				'obj_id'     => $prt_id,
159
+			),
160
+			'restore_price_type'          => array(
161
+				'func'       => '_trash_or_restore_price_type',
162
+				'args'       => array('trash' => false),
163
+				'noheader'   => true,
164
+				'capability' => 'ee_delete_default_price_type',
165
+				'obj_id'     => $prt_id,
166
+			),
167
+			'delete_price_type'           => array(
168
+				'func'       => '_delete_price_type',
169
+				'noheader'   => true,
170
+				'capability' => 'ee_delete_default_price_type',
171
+				'obj_id'     => $prt_id,
172
+			),
173
+			'tax_settings'                => array(
174
+				'func'       => '_tax_settings',
175
+				'capability' => 'manage_options',
176
+			),
177
+			'update_tax_settings'         => array(
178
+				'func'       => '_update_tax_settings',
179
+				'capability' => 'manage_options',
180
+				'noheader'   => true,
181
+			),
182
+		);
183
+	}
184
+
185
+
186
+	protected function _set_page_config()
187
+	{
188
+
189
+		$this->_page_config = array(
190
+			'default'            => array(
191
+				'nav'           => array(
192
+					'label' => __('Default Pricing', 'event_espresso'),
193
+					'order' => 10,
194
+				),
195
+				'list_table'    => 'Prices_List_Table',
196
+				'help_tabs'     => array(
197
+					'pricing_default_pricing_help_tab'                           => array(
198
+						'title'    => __('Default Pricing', 'event_espresso'),
199
+						'filename' => 'pricing_default_pricing',
200
+					),
201
+					'pricing_default_pricing_table_column_headings_help_tab'     => array(
202
+						'title'    => __('Default Pricing Table Column Headings', 'event_espresso'),
203
+						'filename' => 'pricing_default_pricing_table_column_headings',
204
+					),
205
+					'pricing_default_pricing_views_bulk_actions_search_help_tab' => array(
206
+						'title'    => __('Default Pricing Views & Bulk Actions & Search', 'event_espresso'),
207
+						'filename' => 'pricing_default_pricing_views_bulk_actions_search',
208
+					),
209
+				),
210
+				'help_tour'     => array('Pricing_Default_Prices_Help_Tour'),
211
+				'require_nonce' => false,
212
+			),
213
+			'add_new_price'      => array(
214
+				'nav'           => array(
215
+					'label'      => __('Add New Default Price', 'event_espresso'),
216
+					'order'      => 20,
217
+					'persistent' => false,
218
+				),
219
+				'help_tabs'     => array(
220
+					'add_new_default_price_help_tab' => array(
221
+						'title'    => __('Add New Default Price', 'event_espresso'),
222
+						'filename' => 'pricing_add_new_default_price',
223
+					),
224
+				),
225
+				'help_tour'     => array('Pricing_Add_New_Default_Price_Help_Tour'),
226
+				'metaboxes'     => array('_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes'),
227
+				'require_nonce' => false,
228
+			),
229
+			'edit_price'         => array(
230
+				'nav'           => array(
231
+					'label'      => __('Edit Default Price', 'event_espresso'),
232
+					'order'      => 20,
233
+					'url'        => isset($this->_req_data['id']) ? add_query_arg(
234
+						array('id' => $this->_req_data['id']),
235
+						$this->_current_page_view_url
236
+					) : $this->_admin_base_url,
237
+					'persistent' => false,
238
+				),
239
+				'metaboxes'     => array('_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes'),
240
+				'help_tabs'     => array(
241
+					'edit_default_price_help_tab' => array(
242
+						'title'    => __('Edit Default Price', 'event_espresso'),
243
+						'filename' => 'pricing_edit_default_price',
244
+					),
245
+				),
246
+				'help_tour'     => array('Pricing_Edit_Default_Price_Help_Tour'),
247
+				'require_nonce' => false,
248
+			),
249
+			'price_types'        => array(
250
+				'nav'           => array(
251
+					'label' => __('Price Types', 'event_espresso'),
252
+					'order' => 30,
253
+				),
254
+				'list_table'    => 'Price_Types_List_Table',
255
+				'help_tabs'     => array(
256
+					'pricing_price_types_help_tab'                           => array(
257
+						'title'    => __('Price Types', 'event_espresso'),
258
+						'filename' => 'pricing_price_types',
259
+					),
260
+					'pricing_price_types_table_column_headings_help_tab'     => array(
261
+						'title'    => __('Price Types Table Column Headings', 'event_espresso'),
262
+						'filename' => 'pricing_price_types_table_column_headings',
263
+					),
264
+					'pricing_price_types_views_bulk_actions_search_help_tab' => array(
265
+						'title'    => __('Price Types Views & Bulk Actions & Search', 'event_espresso'),
266
+						'filename' => 'pricing_price_types_views_bulk_actions_search',
267
+					),
268
+				),
269
+				'help_tour'     => array('Pricing_Price_Types_Default_Help_Tour'),
270
+				'metaboxes'     => array('_espresso_news_post_box', '_espresso_links_post_box'),
271
+				'require_nonce' => false,
272
+			),
273
+			'add_new_price_type' => array(
274
+				'nav'           => array(
275
+					'label'      => __('Add New Price Type', 'event_espresso'),
276
+					'order'      => 40,
277
+					'persistent' => false,
278
+				),
279
+				'help_tabs'     => array(
280
+					'add_new_price_type_help_tab' => array(
281
+						'title'    => __('Add New Price Type', 'event_espresso'),
282
+						'filename' => 'pricing_add_new_price_type',
283
+					),
284
+				),
285
+				'help_tour'     => array('Pricing_Add_New_Price_Type_Help_Tour'),
286
+				'metaboxes'     => array(
287
+					'_publish_post_box',
288
+					'_espresso_news_post_box',
289
+					'_price_type_details_meta_boxes',
290
+				),
291
+				'require_nonce' => false,
292
+			),
293
+			'edit_price_type'    => array(
294
+				'nav'       => array(
295
+					'label'      => __('Edit Price Type', 'event_espresso'),
296
+					'order'      => 40,
297
+					'persistent' => false,
298
+				),
299
+				'help_tabs' => array(
300
+					'edit_price_type_help_tab' => array(
301
+						'title'    => __('Edit Price Type', 'event_espresso'),
302
+						'filename' => 'pricing_edit_price_type',
303
+					),
304
+				),
305
+				'help_tour' => array('Pricing_Edit_Price_Type_Help_Tour'),
306
+				'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes'),
307
+
308
+				'require_nonce' => false,
309
+			),
310
+			'tax_settings'       => array(
311
+				'nav'           => array(
312
+					'label' => esc_html__('Tax Settings', 'event_espresso'),
313
+					'order' => 40,
314
+				),
315
+				'labels'        => array(
316
+					'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'),
317
+				),
318
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
319
+				// 'help_tabs'     => array(
320
+				//     'registration_form_reg_form_settings_help_tab' => array(
321
+				//         'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
322
+				//         'filename' => 'registration_form_reg_form_settings'
323
+				//     ),
324
+				// ),
325
+				// 'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
326
+				'require_nonce' => true,
327
+			),
328
+		);
329
+	}
330
+
331
+
332
+	protected function _add_screen_options()
333
+	{
334
+		// todo
335
+	}
336
+
337
+
338
+	protected function _add_screen_options_default()
339
+	{
340
+		$this->_per_page_screen_option();
341
+	}
342
+
343
+
344
+	protected function _add_screen_options_price_types()
345
+	{
346
+		$page_title = $this->_admin_page_title;
347
+		$this->_admin_page_title = __('Price Types', 'event_espresso');
348
+		$this->_per_page_screen_option();
349
+		$this->_admin_page_title = $page_title;
350
+	}
351
+
352
+
353
+	protected function _add_feature_pointers()
354
+	{
355
+	}
356
+
357
+
358
+	public function load_scripts_styles()
359
+	{
360
+		// styles
361
+		wp_enqueue_style('espresso-ui-theme');
362
+		wp_register_style(
363
+			'espresso_PRICING',
364
+			PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
365
+			array(),
366
+			EVENT_ESPRESSO_VERSION
367
+		);
368
+		wp_enqueue_style('espresso_PRICING');
369
+
370
+		// scripts
371
+		wp_enqueue_script('ee_admin_js');
372
+		wp_enqueue_script('jquery-ui-position');
373
+		wp_enqueue_script('jquery-ui-widget');
374
+		// wp_enqueue_script('jquery-ui-dialog');
375
+		// wp_enqueue_script('jquery-ui-draggable');
376
+		// wp_enqueue_script('jquery-ui-datepicker');
377
+		wp_register_script(
378
+			'espresso_PRICING',
379
+			PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
380
+			array('jquery'),
381
+			EVENT_ESPRESSO_VERSION,
382
+			true
383
+		);
384
+		wp_enqueue_script('espresso_PRICING');
385
+	}
386
+
387
+
388
+	public function load_scripts_styles_default()
389
+	{
390
+		wp_enqueue_script('espresso_ajax_table_sorting');
391
+	}
392
+
393
+
394
+	public function admin_footer_scripts()
395
+	{
396
+	}
397
+
398
+	public function admin_init()
399
+	{
400
+	}
401
+
402
+	public function admin_notices()
403
+	{
404
+	}
405
+
406
+
407
+	protected function _set_list_table_views_default()
408
+	{
409
+		$this->_views = array(
410
+			'all' => array(
411
+				'slug'        => 'all',
412
+				'label'       => __('View All Default Pricing', 'event_espresso'),
413
+				'count'       => 0,
414
+				'bulk_action' => array(
415
+					'trash_price' => __('Move to Trash', 'event_espresso'),
416
+				),
417
+			),
418
+		);
419
+
420
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
421
+			$this->_views['trashed'] = array(
422
+				'slug'        => 'trashed',
423
+				'label'       => __('Trash', 'event_espresso'),
424
+				'count'       => 0,
425
+				'bulk_action' => array(
426
+					'restore_price' => __('Restore from Trash', 'event_espresso'),
427
+					'delete_price'  => __('Delete Permanently', 'event_espresso'),
428
+				),
429
+			);
430
+		}
431
+	}
432
+
433
+
434
+	protected function _set_list_table_views_price_types()
435
+	{
436
+		$this->_views = array(
437
+			'all' => array(
438
+				'slug'        => 'all',
439
+				'label'       => __('All', 'event_espresso'),
440
+				'count'       => 0,
441
+				'bulk_action' => array(
442
+					'trash_price_type' => __('Move to Trash', 'event_espresso'),
443
+				),
444
+			),
445
+		);
446
+
447
+		if (EE_Registry::instance()->CAP->current_user_can(
448
+			'ee_delete_default_price_types',
449
+			'pricing_trash_price_type'
450
+		)) {
451
+			$this->_views['trashed'] = array(
452
+				'slug'        => 'trashed',
453
+				'label'       => __('Trash', 'event_espresso'),
454
+				'count'       => 0,
455
+				'bulk_action' => array(
456
+					'restore_price_type' => __('Restore from Trash', 'event_espresso'),
457
+					'delete_price_type'  => __('Delete Permanently', 'event_espresso'),
458
+				),
459
+			);
460
+		}
461
+	}
462
+
463
+
464
+	/**
465
+	 *        generates HTML for main Prices Admin page
466
+	 *
467
+	 * @access protected
468
+	 * @return void
469
+	 */
470
+	protected function _price_overview_list_table()
471
+	{
472
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
473
+			'add_new_price',
474
+			'add',
475
+			array(),
476
+			'add-new-h2'
477
+		);
478
+		$this->admin_page_title .= $this->_learn_more_about_pricing_link();
479
+		$this->_search_btn_label = __('Default Prices', 'event_espresso');
480
+		$this->display_admin_list_table_page_with_no_sidebar();
481
+	}
482
+
483
+
484
+	/**
485
+	 *    retrieve data for Prices List table
486
+	 *
487
+	 * @access public
488
+	 * @param  int     $per_page how many prices displayed per page
489
+	 * @param  boolean $count    return the count or objects
490
+	 * @param  boolean $trashed  whether the current view is of the trash can - eww yuck!
491
+	 * @return mixed (int|array)  int = count || array of price objects
492
+	 */
493
+	public function get_prices_overview_data($per_page = 10, $count = false, $trashed = false)
494
+	{
495
+
496
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
497
+		// start with an empty array
498
+		$event_pricing = array();
499
+
500
+		require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
501
+		require_once(EE_MODELS . 'EEM_Price.model.php');
502
+		// $PRC = EEM_Price::instance();
503
+
504
+		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby'];
505
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
506
+			: 'ASC';
507
+
508
+		switch ($this->_req_data['orderby']) {
509
+			case 'name':
510
+				$orderby = array('PRC_name' => $order);
511
+				break;
512
+			case 'type':
513
+				$orderby = array('Price_Type.PRT_name' => $order);
514
+				break;
515
+			case 'amount':
516
+				$orderby = array('PRC_amount' => $order);
517
+				break;
518
+			default:
519
+				$orderby = array('PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order);
520
+		}
521
+
522
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
523
+			? $this->_req_data['paged'] : 1;
524
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
525
+			? $this->_req_data['perpage'] : $per_page;
526
+
527
+		$_where = array(
528
+			'PRC_is_default' => 1,
529
+			'PRC_deleted'    => $trashed,
530
+		);
531
+
532
+		$offset = ($current_page - 1) * $per_page;
533
+		$limit = array($offset, $per_page);
534
+
535
+		if (isset($this->_req_data['s'])) {
536
+			$sstr = '%' . $this->_req_data['s'] . '%';
537
+			$_where['OR'] = array(
538
+				'PRC_name'            => array('LIKE', $sstr),
539
+				'PRC_desc'            => array('LIKE', $sstr),
540
+				'PRC_amount'          => array('LIKE', $sstr),
541
+				'Price_Type.PRT_name' => array('LIKE', $sstr),
542
+			);
543
+		}
544
+
545
+		$query_params = array(
546
+			$_where,
547
+			'order_by' => $orderby,
548
+			'limit'    => $limit,
549
+			'group_by' => 'PRC_ID',
550
+		);
551
+
552
+		if ($count) {
553
+			return $trashed ? EEM_Price::instance()->count(array($_where))
554
+				: EEM_Price::instance()->count_deleted_and_undeleted(array($_where));
555
+		} else {
556
+			return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
557
+		}
558
+	}
559
+
560
+
561
+	/**
562
+	 *        _price_details
563
+	 *
564
+	 * @access protected
565
+	 * @return void
566
+	 */
567
+	protected function _edit_price_details()
568
+	{
569
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
570
+		// grab price ID
571
+		$PRC_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id'])
572
+			: false;
573
+		// change page title based on request action
574
+		switch ($this->_req_action) {
575
+			case 'add_new_price':
576
+				$this->_admin_page_title = esc_html__('Add New Price', 'event_espresso');
577
+				break;
578
+			case 'edit_price':
579
+				$this->_admin_page_title = esc_html__('Edit Price', 'event_espresso');
580
+				break;
581
+			default:
582
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
583
+		}
584
+		// add PRC_ID to title if editing
585
+		$this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
586
+
587
+		// get prices
588
+		require_once(EE_MODELS . 'EEM_Price.model.php');
589
+		$PRC = EEM_Price::instance();
590
+
591
+		if ($PRC_ID) {
592
+			$price = $PRC->get_one_by_ID($PRC_ID);
593
+			$additional_hidden_fields = array(
594
+				'PRC_ID' => array('type' => 'hidden', 'value' => $PRC_ID),
595
+			);
596
+			$this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
597
+		} else {
598
+			$price = $PRC->get_new_price();
599
+			$this->_set_add_edit_form_tags('insert_price');
600
+		}
601
+
602
+		$this->_template_args['PRC_ID'] = $PRC_ID;
603
+		$this->_template_args['price'] = $price;
604
+
605
+		// get price types
606
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
607
+		$PRT = EEM_Price_Type::instance();
608
+		$price_types = $PRT->get_all(array(array('PBT_ID' => array('!=', 1))));
609
+		$price_type_names = array();
610
+		if (empty($price_types)) {
611
+			$msg = __(
612
+				'You have no price types defined. Please add a price type before adding a price.',
613
+				'event_espresso'
614
+			);
615
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
616
+			exit();
617
+		} else {
618
+			foreach ($price_types as $type) {
619
+				// if ($type->is_global()) {
620
+				$price_type_names[] = array('id' => $type->ID(), 'text' => $type->name());
621
+			// }
622
+			}
623
+		}
624
+
625
+		$this->_template_args['price_types'] = $price_type_names;
626
+		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
627
+
628
+		$this->_set_publish_post_box_vars('id', $PRC_ID);
629
+		// the details template wrapper
630
+		$this->display_admin_page_with_sidebar();
631
+	}
632
+
633
+
634
+	/**
635
+	 *        declare price details page metaboxes
636
+	 *
637
+	 * @access protected
638
+	 * @return void
639
+	 */
640
+	protected function _price_details_meta_boxes()
641
+	{
642
+		add_meta_box(
643
+			'edit-price-details-mbox',
644
+			__('Default Price Details', 'event_espresso'),
645
+			array($this, '_edit_price_details_meta_box'),
646
+			$this->wp_page_slug,
647
+			'normal',
648
+			'high'
649
+		);
650
+	}
651
+
652
+
653
+	/**
654
+	 *        _edit_price_details_meta_box
655
+	 *
656
+	 * @access public
657
+	 * @return void
658
+	 */
659
+	public function _edit_price_details_meta_box()
660
+	{
661
+		echo EEH_Template::display_template(
662
+			PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
663
+			$this->_template_args,
664
+			true
665
+		);
666
+	}
667
+
668
+
669
+	/**
670
+	 *        set_price_column_values
671
+	 *
672
+	 * @access protected
673
+	 * @return array
674
+	 */
675
+	protected function set_price_column_values()
676
+	{
677
+
678
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
679
+
680
+		$set_column_values = array(
681
+			'PRT_ID'         => absint($this->_req_data['PRT_ID']),
682
+			'PRC_amount'     => $this->_req_data['PRC_amount'],
683
+			'PRC_name'       => $this->_req_data['PRC_name'],
684
+			'PRC_desc'       => $this->_req_data['PRC_desc'],
685
+			'PRC_is_default' => 1,
686
+			'PRC_overrides'  => null,
687
+			'PRC_order'      => 0,
688
+			'PRC_deleted'    => 0,
689
+			'PRC_parent'     => 0,
690
+		);
691
+		return $set_column_values;
692
+	}
693
+
694
+
695
+	/**
696
+	 *        insert_or_update_price
697
+	 *
698
+	 * @param boolean $insert - whether to insert or update
699
+	 * @access protected
700
+	 * @return void
701
+	 */
702
+	protected function _insert_or_update_price($insert = false)
703
+	{
704
+
705
+		// echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
706
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
707
+
708
+		require_once(EE_MODELS . 'EEM_Price.model.php');
709
+		$PRC = EEM_Price::instance();
710
+
711
+		// why be so pessimistic ???  : (
712
+		$success = 0;
713
+
714
+		$set_column_values = $this->set_price_column_values();
715
+		// is this a new Price ?
716
+		if ($insert) {
717
+			// run the insert
718
+			if ($PRC_ID = $PRC->insert($set_column_values)) {
719
+				// make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
720
+				$PR = EEM_price::instance()->get_one_by_ID($PRC_ID);
721
+				if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
722
+					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
723
+					$ticket->_add_relation_to($PR, 'Price');
724
+					$ticket->save();
725
+				}
726
+				$success = 1;
727
+			} else {
728
+				$PRC_ID = false;
729
+				$success = 0;
730
+			}
731
+			$action_desc = 'created';
732
+		} else {
733
+			$PRC_ID = absint($this->_req_data['PRC_ID']);
734
+			// run the update
735
+			$where_cols_n_values = array('PRC_ID' => $PRC_ID);
736
+			if ($PRC->update($set_column_values, array($where_cols_n_values))) {
737
+				$success = 1;
738
+			}
739
+
740
+			$PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
741
+			if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
742
+				// if this is $PRC_ID == 1, then we need to update the default ticket attached to this price so the TKT_price value is updated.
743
+				if ($PRC_ID === 1) {
744
+					$ticket = $PR->get_first_related('Ticket');
745
+					if ($ticket) {
746
+						$ticket->set('TKT_price', $PR->get('PRC_amount'));
747
+						$ticket->set('TKT_name', $PR->get('PRC_name'));
748
+						$ticket->set('TKT_description', $PR->get('PRC_desc'));
749
+						$ticket->save();
750
+					}
751
+				} else {
752
+					// we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
753
+					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
754
+					$ticket->_add_relation_to($PRC_ID, 'Price');
755
+					$ticket->save();
756
+				}
757
+			}
758
+
759
+			$action_desc = 'updated';
760
+		}
761
+
762
+		$query_args = array('action' => 'edit_price', 'id' => $PRC_ID);
763
+
764
+		$this->_redirect_after_action($success, 'Prices', $action_desc, $query_args);
765
+	}
766
+
767
+
768
+	/**
769
+	 *        _trash_or_restore_price
770
+	 *
771
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
772
+	 * @access protected
773
+	 * @return void
774
+	 */
775
+	protected function _trash_or_restore_price($trash = true)
776
+	{
777
+
778
+		// echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
779
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
780
+
781
+		require_once(EE_MODELS . 'EEM_Price.model.php');
782
+		$PRC = EEM_Price::instance();
783
+
784
+		$success = 1;
785
+		$PRC_deleted = $trash ? true : false;
786
+
787
+		// get base ticket for updating
788
+		$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
789
+		// Checkboxes
790
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
791
+			// if array has more than one element than success message should be plural
792
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
793
+			// cycle thru checkboxes
794
+			while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) {
795
+				if (! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), absint($PRC_ID))) {
796
+					$success = 0;
797
+				} else {
798
+					$PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
799
+					if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
800
+						// if trashing then remove relations to base default ticket.  If restoring then add back to base default ticket
801
+						if ($PRC_deleted) {
802
+							$ticket->_remove_relation_to($PRC_ID, 'Price');
803
+						} else {
804
+							$ticket->_add_relation_to($PRC_ID, 'Price');
805
+						}
806
+						$ticket->save();
807
+					}
808
+				}
809
+			}
810
+		} else {
811
+			// grab single id and delete
812
+			$PRC_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
813
+			if (empty($PRC_ID) || ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), $PRC_ID)) {
814
+				$success = 0;
815
+			} else {
816
+				$PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
817
+				if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
818
+					// if trashing then remove relations to base default ticket.  If restoring then add back to base default ticket
819
+					if ($PRC_deleted) {
820
+						$ticket->_remove_relation_to($PRC_ID, 'Price');
821
+					} else {
822
+						$ticket->_add_relation_to($PRC_ID, 'Price');
823
+					}
824
+					$ticket->save();
825
+				}
826
+			}
827
+		}
828
+		$query_args = array(
829
+			'action' => 'default',
830
+		);
831
+
832
+		if ($success) {
833
+			if ($trash) {
834
+				$msg = $success == 2
835
+					? __('The Prices have been trashed.', 'event_espresso')
836
+					: __(
837
+						'The Price has been trashed.',
838
+						'event_espresso'
839
+					);
840
+			} else {
841
+				$msg = $success == 2
842
+					? __('The Prices have been restored.', 'event_espresso')
843
+					: __(
844
+						'The Price has been restored.',
845
+						'event_espresso'
846
+					);
847
+			}
848
+
849
+			EE_Error::add_success($msg);
850
+		}
851
+
852
+		$this->_redirect_after_action(false, '', '', $query_args, true);
853
+	}
854
+
855
+
856
+	/**
857
+	 *        _delete_price
858
+	 *
859
+	 * @access protected
860
+	 * @return void
861
+	 */
862
+	protected function _delete_price()
863
+	{
864
+
865
+		// echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
866
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
867
+
868
+		require_once(EE_MODELS . 'EEM_Price.model.php');
869
+		$PRC = EEM_Price::instance();
870
+
871
+		$success = 1;
872
+		// Checkboxes
873
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
874
+			// if array has more than one element than success message should be plural
875
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
876
+			// cycle thru bulk action checkboxes
877
+			while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) {
878
+				if (! $PRC->delete_permanently_by_ID(absint($PRC_ID))) {
879
+					$success = 0;
880
+				}
881
+			}
882
+		} else {
883
+			// grab single id and delete
884
+			$PRC_ID = absint($this->_req_data['id']);
885
+			if (! $PRC->delete_permanently_by_ID($PRC_ID)) {
886
+				$success = 0;
887
+			}
888
+		}
889
+
890
+		$this->_redirect_after_action($success, 'Prices', 'deleted', array());
891
+	}
892
+
893
+
894
+	public function update_price_order()
895
+	{
896
+		$success = __('Price order was updated successfully.', 'event_espresso');
897
+
898
+		// grab our row IDs
899
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) ? explode(
900
+			',',
901
+			rtrim(
902
+				$this->_req_data['row_ids'],
903
+				','
904
+			)
905
+		) : false;
906
+
907
+		if (is_array($row_ids)) {
908
+			for ($i = 0; $i < count($row_ids); $i++) {
909
+				// Update the prices when re-ordering
910
+				$id = absint($row_ids[ $i ]);
911
+				if (EEM_Price::instance()->update(
912
+					array('PRC_order' => $i + 1),
913
+					array(array('PRC_ID' => $id))
914
+				) === false) {
915
+					$success = false;
916
+				}
917
+			}
918
+		} else {
919
+			$success = false;
920
+		}
921
+
922
+		$errors = ! $success ? __('An error occurred. The price order was not updated.', 'event_espresso') : false;
923
+
924
+		echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
925
+		die();
926
+	}
927
+
928
+
929
+
930
+
931
+
932
+
933
+	/**************************************************************************************************************************************************************
934 934
      ********************************************************************  TICKET PRICE TYPES  ******************************************************************
935 935
      **************************************************************************************************************************************************************/
936 936
 
937 937
 
938
-    /**
939
-     *        generates HTML for main Prices Admin page
940
-     *
941
-     * @access protected
942
-     * @return void
943
-     */
944
-    protected function _price_types_overview_list_table()
945
-    {
946
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
947
-            'add_new_price_type',
948
-            'add_type',
949
-            array(),
950
-            'add-new-h2'
951
-        );
952
-        $this->admin_page_title .= $this->_learn_more_about_pricing_link();
953
-        $this->_search_btn_label = __('Price Types', 'event_espresso');
954
-        $this->display_admin_list_table_page_with_no_sidebar();
955
-    }
956
-
957
-
958
-    /**
959
-     *    retrieve data for Price Types List table
960
-     *
961
-     * @access public
962
-     * @param  int     $per_page how many prices displayed per page
963
-     * @param  boolean $count    return the count or objects
964
-     * @param  boolean $trashed  whether the current view is of the trash can - eww yuck!
965
-     * @return mixed (int|array)  int = count || array of price objects
966
-     */
967
-    public function get_price_types_overview_data($per_page = 10, $count = false, $trashed = false)
968
-    {
969
-
970
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
971
-        // start with an empty array
972
-
973
-        require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
974
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
975
-
976
-        $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby'];
977
-        $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
978
-            : 'ASC';
979
-        switch ($this->_req_data['orderby']) {
980
-            case 'name':
981
-                $orderby = array('PRT_name' => $order);
982
-                break;
983
-            default:
984
-                $orderby = array('PRT_order' => $order);
985
-        }
986
-
987
-
988
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
989
-            ? $this->_req_data['paged'] : 1;
990
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
991
-            ? $this->_req_data['perpage'] : $per_page;
992
-
993
-        $offset = ($current_page - 1) * $per_page;
994
-        $limit = array($offset, $per_page);
995
-
996
-        $_where = array('PRT_deleted' => $trashed, 'PBT_ID' => array('!=', 1));
997
-
998
-        if (isset($this->_req_data['s'])) {
999
-            $sstr = '%' . $this->_req_data['s'] . '%';
1000
-            $_where['OR'] = array(
1001
-                'PRT_name' => array('LIKE', $sstr),
1002
-            );
1003
-        }
1004
-        $query_params = array(
1005
-            $_where,
1006
-            'order_by' => $orderby,
1007
-            'limit'    => $limit,
1008
-        );
1009
-        if ($count) {
1010
-            return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params);
1011
-        } else {
1012
-            return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
1013
-        }
1014
-
1015
-        // EEH_Debug_Tools::printr( $price_types, '$price_types  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1016
-    }
1017
-
1018
-
1019
-    /**
1020
-     *        _edit_price_type_details
1021
-     *
1022
-     * @access protected
1023
-     * @return void
1024
-     */
1025
-    protected function _edit_price_type_details()
1026
-    {
1027
-
1028
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1029
-
1030
-
1031
-        // grab price type ID
1032
-        $PRT_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id'])
1033
-            : false;
1034
-        // change page title based on request action
1035
-        switch ($this->_req_action) {
1036
-            case 'add_new_price_type':
1037
-                $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso');
1038
-                break;
1039
-            case 'edit_price_type':
1040
-                $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso');
1041
-                break;
1042
-            default:
1043
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
1044
-        }
1045
-        // add PRT_ID to title if editing
1046
-        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
1047
-
1048
-        if ($PRT_ID) {
1049
-            $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
1050
-            $additional_hidden_fields = array('PRT_ID' => array('type' => 'hidden', 'value' => $PRT_ID));
1051
-            $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
1052
-        } else {
1053
-            $price_type = EEM_Price_Type::instance()->get_new_price_type();
1054
-            $this->_set_add_edit_form_tags('insert_price_type');
1055
-        }
1056
-
1057
-        $this->_template_args['PRT_ID'] = $PRT_ID;
1058
-        $this->_template_args['price_type'] = $price_type;
1059
-
1060
-
1061
-        $base_types = EEM_Price_Type::instance()->get_base_types();
1062
-        $select_values = array();
1063
-        foreach ($base_types as $ref => $text) {
1064
-            if ($ref == EEM_Price_Type::base_type_base_price) {
1065
-                // do not allow creation of base_type_base_prices because that's a system only base type.
1066
-                continue;
1067
-            }
1068
-            $values[] = array('id' => $ref, 'text' => $text);
1069
-        }
1070
-
1071
-
1072
-        $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input(
1073
-            'base_type',
1074
-            $values,
1075
-            $price_type->base_type(),
1076
-            'id="price-type-base-type-slct"'
1077
-        );
1078
-        $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1079
-        $redirect_URL = add_query_arg(array('action' => 'price_types'), $this->_admin_base_url);
1080
-        $this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL);
1081
-        // the details template wrapper
1082
-        $this->display_admin_page_with_sidebar();
1083
-    }
1084
-
1085
-
1086
-    /**
1087
-     *        declare price type details page metaboxes
1088
-     *
1089
-     * @access protected
1090
-     * @return void
1091
-     */
1092
-    protected function _price_type_details_meta_boxes()
1093
-    {
1094
-        add_meta_box(
1095
-            'edit-price-details-mbox',
1096
-            __('Price Type Details', 'event_espresso'),
1097
-            array($this, '_edit_price_type_details_meta_box'),
1098
-            $this->wp_page_slug,
1099
-            'normal',
1100
-            'high'
1101
-        );
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     *        _edit_price_type_details_meta_box
1107
-     *
1108
-     * @access public
1109
-     * @return void
1110
-     */
1111
-    public function _edit_price_type_details_meta_box()
1112
-    {
1113
-        echo EEH_Template::display_template(
1114
-            PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1115
-            $this->_template_args,
1116
-            true
1117
-        );
1118
-    }
1119
-
1120
-
1121
-    /**
1122
-     *        set_price_type_column_values
1123
-     *
1124
-     * @access protected
1125
-     * @return void
1126
-     */
1127
-    protected function set_price_type_column_values()
1128
-    {
1129
-
1130
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1131
-
1132
-        $base_type = ! empty($this->_req_data['base_type']) ? $this->_req_data['base_type']
1133
-            : EEM_Price_Type::base_type_base_price;
1134
-
1135
-        switch ($base_type) {
1136
-            case EEM_Price_Type::base_type_base_price:
1137
-                $this->_req_data['PBT_ID'] = EEM_Price_Type::base_type_base_price;
1138
-                $this->_req_data['PRT_is_percent'] = 0;
1139
-                $this->_req_data['PRT_order'] = 0;
1140
-                break;
1141
-
1142
-            case EEM_Price_Type::base_type_discount:
1143
-                $this->_req_data['PBT_ID'] = EEM_Price_Type::base_type_discount;
1144
-                break;
1145
-
1146
-            case EEM_Price_Type::base_type_surcharge:
1147
-                $this->_req_data['PBT_ID'] = EEM_Price_Type::base_type_surcharge;
1148
-                break;
1149
-
1150
-            case EEM_Price_Type::base_type_tax:
1151
-                $this->_req_data['PBT_ID'] = EEM_Price_Type::base_type_tax;
1152
-                $this->_req_data['PRT_is_percent'] = 1;
1153
-                break;
1154
-        }/**/
1155
-
1156
-        $set_column_values = array(
1157
-            'PRT_name'       => $this->_req_data['PRT_name'],
1158
-            'PBT_ID'         => absint($this->_req_data['PBT_ID']),
1159
-            'PRT_is_percent' => absint($this->_req_data['PRT_is_percent']),
1160
-            'PRT_order'      => absint($this->_req_data['PRT_order']),
1161
-            'PRT_deleted'    => 0,
1162
-        );
1163
-
1164
-        return $set_column_values;
1165
-    }
1166
-
1167
-
1168
-    /**
1169
-     *        _insert_or_update_price_type
1170
-     *
1171
-     * @param boolean $new_price_type - whether to insert or update
1172
-     * @access protected
1173
-     * @return void
1174
-     */
1175
-    protected function _insert_or_update_price_type($new_price_type = false)
1176
-    {
1177
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1178
-
1179
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
1180
-        $PRT = EEM_Price_Type::instance();
1181
-
1182
-        // why be so pessimistic ???  : (
1183
-        $success = 0;
1184
-
1185
-        $set_column_values = $this->set_price_type_column_values();
1186
-        // is this a new Price ?
1187
-        if ($new_price_type) {
1188
-            // run the insert
1189
-            if ($PRT_ID = $PRT->insert($set_column_values)) {
1190
-                $success = 1;
1191
-            }
1192
-            $action_desc = 'created';
1193
-        } else {
1194
-            $PRT_ID = absint($this->_req_data['PRT_ID']);
1195
-            // run the update
1196
-            $where_cols_n_values = array('PRT_ID' => $PRT_ID);
1197
-            if ($PRT->update($set_column_values, array($where_cols_n_values))) {
1198
-                $success = 1;
1199
-            }
1200
-            $action_desc = 'updated';
1201
-        }
1202
-
1203
-        $query_args = array('action' => 'edit_price_type', 'id' => $PRT_ID);
1204
-        $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1205
-    }
1206
-
1207
-
1208
-    /**
1209
-     *        _trash_or_restore_price_type
1210
-     *
1211
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
1212
-     * @access protected
1213
-     * @return void
1214
-     */
1215
-    protected function _trash_or_restore_price_type($trash = true)
1216
-    {
1217
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1218
-
1219
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
1220
-        $PRT = EEM_Price_Type::instance();
1221
-
1222
-        $success = 1;
1223
-        $PRT_deleted = $trash ? true : false;
1224
-        // Checkboxes
1225
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1226
-            // if array has more than one element than success message should be plural
1227
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1228
-            $what = count($this->_req_data['checkbox']) > 1 ? 'Price Types' : 'Price Type';
1229
-            // cycle thru checkboxes
1230
-            while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) {
1231
-                if (! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) {
1232
-                    $success = 0;
1233
-                }
1234
-            }
1235
-        } else {
1236
-            // grab single id and delete
1237
-            $PRT_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
1238
-            if (empty($PRT_ID) || ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) {
1239
-                $success = 0;
1240
-            }
1241
-            $what = 'Price Type';
1242
-        }
1243
-
1244
-        $query_args = array('action' => 'price_types');
1245
-        if ($success) {
1246
-            if ($trash) {
1247
-                $msg = $success > 1
1248
-                    ? __('The Price Types have been trashed.', 'event_espresso')
1249
-                    : __(
1250
-                        'The Price Type has been trashed.',
1251
-                        'event_espresso'
1252
-                    );
1253
-            } else {
1254
-                $msg = $success > 1
1255
-                    ? __('The Price Types have been restored.', 'event_espresso')
1256
-                    : __(
1257
-                        'The Price Type has been restored.',
1258
-                        'event_espresso'
1259
-                    );
1260
-            }
1261
-            EE_Error::add_success($msg);
1262
-        }
1263
-
1264
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     *        _delete_price_type
1270
-     *
1271
-     * @access protected
1272
-     * @return void
1273
-     */
1274
-    protected function _delete_price_type()
1275
-    {
1276
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1277
-
1278
-        $PRT = EEM_Price_Type::instance();
1279
-
1280
-        $success = 1;
1281
-        // Checkboxes
1282
-        if (! empty($this->_req_data['checkbox'])) {
1283
-            // if array has more than one element than success message should be plural
1284
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1285
-            $what = $PRT->item_name($success);
1286
-            // cycle thru bulk action checkboxes
1287
-            while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) {
1288
-                if (! $PRT->delete_permanently_by_ID($PRT_ID)) {
1289
-                    $success = 0;
1290
-                }
1291
-            }
1292
-        }
1293
-
1294
-
1295
-        $query_args = array('action' => 'price_types');
1296
-        $this->_redirect_after_action($success, $what, 'deleted', $query_args);
1297
-    }
1298
-
1299
-
1300
-    /**
1301
-     *        _learn_more_about_pricing_link
1302
-     *
1303
-     * @access protected
1304
-     * @return string
1305
-     */
1306
-    protected function _learn_more_about_pricing_link()
1307
-    {
1308
-        return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __(
1309
-            'learn more about how pricing works',
1310
-            'event_espresso'
1311
-        ) . '</a>';
1312
-    }
1313
-
1314
-
1315
-    protected function _tax_settings()
1316
-    {
1317
-        $this->_set_add_edit_form_tags('update_tax_settings');
1318
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1319
-        $this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html();
1320
-        $this->display_admin_page_with_sidebar();
1321
-    }
1322
-
1323
-
1324
-    /**
1325
-     * @return \EE_Form_Section_Proper
1326
-     * @throws \EE_Error
1327
-     */
1328
-    protected function tax_settings_form()
1329
-    {
1330
-        return new EE_Form_Section_Proper(
1331
-            array(
1332
-                'name'            => 'tax_settings_form',
1333
-                'html_id'         => 'tax_settings_form',
1334
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1335
-                'subsections'     => apply_filters(
1336
-                    'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections',
1337
-                    array(
1338
-                        'tax_settings' => new EE_Form_Section_Proper(
1339
-                            array(
1340
-                                'name'            => 'tax_settings_tbl',
1341
-                                'html_id'         => 'tax_settings_tbl',
1342
-                                'html_class'      => 'form-table',
1343
-                                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1344
-                                'subsections'     => array(
1345
-                                    'prices_displayed_including_taxes' => new EE_Yes_No_Input(
1346
-                                        array(
1347
-                                            'html_label_text'         => __(
1348
-                                                "Show Prices With Taxes Included?",
1349
-                                                'event_espresso'
1350
-                                            ),
1351
-                                            'html_help_text'          => __(
1352
-                                                'Indicates whether or not to display prices with the taxes included',
1353
-                                                'event_espresso'
1354
-                                            ),
1355
-                                            'default'                 => isset(
1356
-                                                EE_Registry::instance()
1357
-                                                    ->CFG
1358
-                                                    ->tax_settings
1359
-                                                    ->prices_displayed_including_taxes
1360
-                                            )
1361
-                                                ? EE_Registry::instance()
1362
-                                                    ->CFG
1363
-                                                    ->tax_settings
1364
-                                                    ->prices_displayed_including_taxes
1365
-                                                : true,
1366
-                                            'display_html_label_text' => false,
1367
-                                        )
1368
-                                    ),
1369
-                                ),
1370
-                            )
1371
-                        ),
1372
-                    )
1373
-                ),
1374
-            )
1375
-        );
1376
-    }
1377
-
1378
-
1379
-    /**
1380
-     * _update_tax_settings
1381
-     *
1382
-     * @since 4.9.13
1383
-     * @return void
1384
-     */
1385
-    public function _update_tax_settings()
1386
-    {
1387
-        if (! isset(EE_Registry::instance()->CFG->tax_settings)) {
1388
-            EE_Registry::instance()->CFG->tax_settings = new EE_Tax_Config();
1389
-        }
1390
-        try {
1391
-            $tax_form = $this->tax_settings_form();
1392
-            // check for form submission
1393
-            if ($tax_form->was_submitted()) {
1394
-                // capture form data
1395
-                $tax_form->receive_form_submission();
1396
-                // validate form data
1397
-                if ($tax_form->is_valid()) {
1398
-                    // grab validated data from form
1399
-                    $valid_data = $tax_form->valid_data();
1400
-                    // set data on config
1401
-                    EE_Registry::instance()
1402
-                        ->CFG
1403
-                        ->tax_settings
1404
-                        ->prices_displayed_including_taxes
1405
-                        = $valid_data['tax_settings']['prices_displayed_including_taxes'];
1406
-                } else {
1407
-                    if ($tax_form->submission_error_message() !== '') {
1408
-                        EE_Error::add_error(
1409
-                            $tax_form->submission_error_message(),
1410
-                            __FILE__,
1411
-                            __FUNCTION__,
1412
-                            __LINE__
1413
-                        );
1414
-                    }
1415
-                }
1416
-            }
1417
-        } catch (EE_Error $e) {
1418
-            EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__);
1419
-        }
1420
-
1421
-        $what = 'Tax Settings';
1422
-        $success = $this->_update_espresso_configuration(
1423
-            $what,
1424
-            EE_Registry::instance()->CFG->tax_settings,
1425
-            __FILE__,
1426
-            __FUNCTION__,
1427
-            __LINE__
1428
-        );
1429
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'tax_settings'));
1430
-    }
938
+	/**
939
+	 *        generates HTML for main Prices Admin page
940
+	 *
941
+	 * @access protected
942
+	 * @return void
943
+	 */
944
+	protected function _price_types_overview_list_table()
945
+	{
946
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
947
+			'add_new_price_type',
948
+			'add_type',
949
+			array(),
950
+			'add-new-h2'
951
+		);
952
+		$this->admin_page_title .= $this->_learn_more_about_pricing_link();
953
+		$this->_search_btn_label = __('Price Types', 'event_espresso');
954
+		$this->display_admin_list_table_page_with_no_sidebar();
955
+	}
956
+
957
+
958
+	/**
959
+	 *    retrieve data for Price Types List table
960
+	 *
961
+	 * @access public
962
+	 * @param  int     $per_page how many prices displayed per page
963
+	 * @param  boolean $count    return the count or objects
964
+	 * @param  boolean $trashed  whether the current view is of the trash can - eww yuck!
965
+	 * @return mixed (int|array)  int = count || array of price objects
966
+	 */
967
+	public function get_price_types_overview_data($per_page = 10, $count = false, $trashed = false)
968
+	{
969
+
970
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
971
+		// start with an empty array
972
+
973
+		require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
974
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
975
+
976
+		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby'];
977
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
978
+			: 'ASC';
979
+		switch ($this->_req_data['orderby']) {
980
+			case 'name':
981
+				$orderby = array('PRT_name' => $order);
982
+				break;
983
+			default:
984
+				$orderby = array('PRT_order' => $order);
985
+		}
986
+
987
+
988
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
989
+			? $this->_req_data['paged'] : 1;
990
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
991
+			? $this->_req_data['perpage'] : $per_page;
992
+
993
+		$offset = ($current_page - 1) * $per_page;
994
+		$limit = array($offset, $per_page);
995
+
996
+		$_where = array('PRT_deleted' => $trashed, 'PBT_ID' => array('!=', 1));
997
+
998
+		if (isset($this->_req_data['s'])) {
999
+			$sstr = '%' . $this->_req_data['s'] . '%';
1000
+			$_where['OR'] = array(
1001
+				'PRT_name' => array('LIKE', $sstr),
1002
+			);
1003
+		}
1004
+		$query_params = array(
1005
+			$_where,
1006
+			'order_by' => $orderby,
1007
+			'limit'    => $limit,
1008
+		);
1009
+		if ($count) {
1010
+			return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params);
1011
+		} else {
1012
+			return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
1013
+		}
1014
+
1015
+		// EEH_Debug_Tools::printr( $price_types, '$price_types  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1016
+	}
1017
+
1018
+
1019
+	/**
1020
+	 *        _edit_price_type_details
1021
+	 *
1022
+	 * @access protected
1023
+	 * @return void
1024
+	 */
1025
+	protected function _edit_price_type_details()
1026
+	{
1027
+
1028
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1029
+
1030
+
1031
+		// grab price type ID
1032
+		$PRT_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id'])
1033
+			: false;
1034
+		// change page title based on request action
1035
+		switch ($this->_req_action) {
1036
+			case 'add_new_price_type':
1037
+				$this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso');
1038
+				break;
1039
+			case 'edit_price_type':
1040
+				$this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso');
1041
+				break;
1042
+			default:
1043
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
1044
+		}
1045
+		// add PRT_ID to title if editing
1046
+		$this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
1047
+
1048
+		if ($PRT_ID) {
1049
+			$price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
1050
+			$additional_hidden_fields = array('PRT_ID' => array('type' => 'hidden', 'value' => $PRT_ID));
1051
+			$this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
1052
+		} else {
1053
+			$price_type = EEM_Price_Type::instance()->get_new_price_type();
1054
+			$this->_set_add_edit_form_tags('insert_price_type');
1055
+		}
1056
+
1057
+		$this->_template_args['PRT_ID'] = $PRT_ID;
1058
+		$this->_template_args['price_type'] = $price_type;
1059
+
1060
+
1061
+		$base_types = EEM_Price_Type::instance()->get_base_types();
1062
+		$select_values = array();
1063
+		foreach ($base_types as $ref => $text) {
1064
+			if ($ref == EEM_Price_Type::base_type_base_price) {
1065
+				// do not allow creation of base_type_base_prices because that's a system only base type.
1066
+				continue;
1067
+			}
1068
+			$values[] = array('id' => $ref, 'text' => $text);
1069
+		}
1070
+
1071
+
1072
+		$this->_template_args['base_type_select'] = EEH_Form_Fields::select_input(
1073
+			'base_type',
1074
+			$values,
1075
+			$price_type->base_type(),
1076
+			'id="price-type-base-type-slct"'
1077
+		);
1078
+		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1079
+		$redirect_URL = add_query_arg(array('action' => 'price_types'), $this->_admin_base_url);
1080
+		$this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL);
1081
+		// the details template wrapper
1082
+		$this->display_admin_page_with_sidebar();
1083
+	}
1084
+
1085
+
1086
+	/**
1087
+	 *        declare price type details page metaboxes
1088
+	 *
1089
+	 * @access protected
1090
+	 * @return void
1091
+	 */
1092
+	protected function _price_type_details_meta_boxes()
1093
+	{
1094
+		add_meta_box(
1095
+			'edit-price-details-mbox',
1096
+			__('Price Type Details', 'event_espresso'),
1097
+			array($this, '_edit_price_type_details_meta_box'),
1098
+			$this->wp_page_slug,
1099
+			'normal',
1100
+			'high'
1101
+		);
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 *        _edit_price_type_details_meta_box
1107
+	 *
1108
+	 * @access public
1109
+	 * @return void
1110
+	 */
1111
+	public function _edit_price_type_details_meta_box()
1112
+	{
1113
+		echo EEH_Template::display_template(
1114
+			PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1115
+			$this->_template_args,
1116
+			true
1117
+		);
1118
+	}
1119
+
1120
+
1121
+	/**
1122
+	 *        set_price_type_column_values
1123
+	 *
1124
+	 * @access protected
1125
+	 * @return void
1126
+	 */
1127
+	protected function set_price_type_column_values()
1128
+	{
1129
+
1130
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1131
+
1132
+		$base_type = ! empty($this->_req_data['base_type']) ? $this->_req_data['base_type']
1133
+			: EEM_Price_Type::base_type_base_price;
1134
+
1135
+		switch ($base_type) {
1136
+			case EEM_Price_Type::base_type_base_price:
1137
+				$this->_req_data['PBT_ID'] = EEM_Price_Type::base_type_base_price;
1138
+				$this->_req_data['PRT_is_percent'] = 0;
1139
+				$this->_req_data['PRT_order'] = 0;
1140
+				break;
1141
+
1142
+			case EEM_Price_Type::base_type_discount:
1143
+				$this->_req_data['PBT_ID'] = EEM_Price_Type::base_type_discount;
1144
+				break;
1145
+
1146
+			case EEM_Price_Type::base_type_surcharge:
1147
+				$this->_req_data['PBT_ID'] = EEM_Price_Type::base_type_surcharge;
1148
+				break;
1149
+
1150
+			case EEM_Price_Type::base_type_tax:
1151
+				$this->_req_data['PBT_ID'] = EEM_Price_Type::base_type_tax;
1152
+				$this->_req_data['PRT_is_percent'] = 1;
1153
+				break;
1154
+		}/**/
1155
+
1156
+		$set_column_values = array(
1157
+			'PRT_name'       => $this->_req_data['PRT_name'],
1158
+			'PBT_ID'         => absint($this->_req_data['PBT_ID']),
1159
+			'PRT_is_percent' => absint($this->_req_data['PRT_is_percent']),
1160
+			'PRT_order'      => absint($this->_req_data['PRT_order']),
1161
+			'PRT_deleted'    => 0,
1162
+		);
1163
+
1164
+		return $set_column_values;
1165
+	}
1166
+
1167
+
1168
+	/**
1169
+	 *        _insert_or_update_price_type
1170
+	 *
1171
+	 * @param boolean $new_price_type - whether to insert or update
1172
+	 * @access protected
1173
+	 * @return void
1174
+	 */
1175
+	protected function _insert_or_update_price_type($new_price_type = false)
1176
+	{
1177
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1178
+
1179
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
1180
+		$PRT = EEM_Price_Type::instance();
1181
+
1182
+		// why be so pessimistic ???  : (
1183
+		$success = 0;
1184
+
1185
+		$set_column_values = $this->set_price_type_column_values();
1186
+		// is this a new Price ?
1187
+		if ($new_price_type) {
1188
+			// run the insert
1189
+			if ($PRT_ID = $PRT->insert($set_column_values)) {
1190
+				$success = 1;
1191
+			}
1192
+			$action_desc = 'created';
1193
+		} else {
1194
+			$PRT_ID = absint($this->_req_data['PRT_ID']);
1195
+			// run the update
1196
+			$where_cols_n_values = array('PRT_ID' => $PRT_ID);
1197
+			if ($PRT->update($set_column_values, array($where_cols_n_values))) {
1198
+				$success = 1;
1199
+			}
1200
+			$action_desc = 'updated';
1201
+		}
1202
+
1203
+		$query_args = array('action' => 'edit_price_type', 'id' => $PRT_ID);
1204
+		$this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1205
+	}
1206
+
1207
+
1208
+	/**
1209
+	 *        _trash_or_restore_price_type
1210
+	 *
1211
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
1212
+	 * @access protected
1213
+	 * @return void
1214
+	 */
1215
+	protected function _trash_or_restore_price_type($trash = true)
1216
+	{
1217
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1218
+
1219
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
1220
+		$PRT = EEM_Price_Type::instance();
1221
+
1222
+		$success = 1;
1223
+		$PRT_deleted = $trash ? true : false;
1224
+		// Checkboxes
1225
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1226
+			// if array has more than one element than success message should be plural
1227
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1228
+			$what = count($this->_req_data['checkbox']) > 1 ? 'Price Types' : 'Price Type';
1229
+			// cycle thru checkboxes
1230
+			while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) {
1231
+				if (! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) {
1232
+					$success = 0;
1233
+				}
1234
+			}
1235
+		} else {
1236
+			// grab single id and delete
1237
+			$PRT_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
1238
+			if (empty($PRT_ID) || ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) {
1239
+				$success = 0;
1240
+			}
1241
+			$what = 'Price Type';
1242
+		}
1243
+
1244
+		$query_args = array('action' => 'price_types');
1245
+		if ($success) {
1246
+			if ($trash) {
1247
+				$msg = $success > 1
1248
+					? __('The Price Types have been trashed.', 'event_espresso')
1249
+					: __(
1250
+						'The Price Type has been trashed.',
1251
+						'event_espresso'
1252
+					);
1253
+			} else {
1254
+				$msg = $success > 1
1255
+					? __('The Price Types have been restored.', 'event_espresso')
1256
+					: __(
1257
+						'The Price Type has been restored.',
1258
+						'event_espresso'
1259
+					);
1260
+			}
1261
+			EE_Error::add_success($msg);
1262
+		}
1263
+
1264
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 *        _delete_price_type
1270
+	 *
1271
+	 * @access protected
1272
+	 * @return void
1273
+	 */
1274
+	protected function _delete_price_type()
1275
+	{
1276
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1277
+
1278
+		$PRT = EEM_Price_Type::instance();
1279
+
1280
+		$success = 1;
1281
+		// Checkboxes
1282
+		if (! empty($this->_req_data['checkbox'])) {
1283
+			// if array has more than one element than success message should be plural
1284
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1285
+			$what = $PRT->item_name($success);
1286
+			// cycle thru bulk action checkboxes
1287
+			while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) {
1288
+				if (! $PRT->delete_permanently_by_ID($PRT_ID)) {
1289
+					$success = 0;
1290
+				}
1291
+			}
1292
+		}
1293
+
1294
+
1295
+		$query_args = array('action' => 'price_types');
1296
+		$this->_redirect_after_action($success, $what, 'deleted', $query_args);
1297
+	}
1298
+
1299
+
1300
+	/**
1301
+	 *        _learn_more_about_pricing_link
1302
+	 *
1303
+	 * @access protected
1304
+	 * @return string
1305
+	 */
1306
+	protected function _learn_more_about_pricing_link()
1307
+	{
1308
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __(
1309
+			'learn more about how pricing works',
1310
+			'event_espresso'
1311
+		) . '</a>';
1312
+	}
1313
+
1314
+
1315
+	protected function _tax_settings()
1316
+	{
1317
+		$this->_set_add_edit_form_tags('update_tax_settings');
1318
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1319
+		$this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html();
1320
+		$this->display_admin_page_with_sidebar();
1321
+	}
1322
+
1323
+
1324
+	/**
1325
+	 * @return \EE_Form_Section_Proper
1326
+	 * @throws \EE_Error
1327
+	 */
1328
+	protected function tax_settings_form()
1329
+	{
1330
+		return new EE_Form_Section_Proper(
1331
+			array(
1332
+				'name'            => 'tax_settings_form',
1333
+				'html_id'         => 'tax_settings_form',
1334
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1335
+				'subsections'     => apply_filters(
1336
+					'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections',
1337
+					array(
1338
+						'tax_settings' => new EE_Form_Section_Proper(
1339
+							array(
1340
+								'name'            => 'tax_settings_tbl',
1341
+								'html_id'         => 'tax_settings_tbl',
1342
+								'html_class'      => 'form-table',
1343
+								'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1344
+								'subsections'     => array(
1345
+									'prices_displayed_including_taxes' => new EE_Yes_No_Input(
1346
+										array(
1347
+											'html_label_text'         => __(
1348
+												"Show Prices With Taxes Included?",
1349
+												'event_espresso'
1350
+											),
1351
+											'html_help_text'          => __(
1352
+												'Indicates whether or not to display prices with the taxes included',
1353
+												'event_espresso'
1354
+											),
1355
+											'default'                 => isset(
1356
+												EE_Registry::instance()
1357
+													->CFG
1358
+													->tax_settings
1359
+													->prices_displayed_including_taxes
1360
+											)
1361
+												? EE_Registry::instance()
1362
+													->CFG
1363
+													->tax_settings
1364
+													->prices_displayed_including_taxes
1365
+												: true,
1366
+											'display_html_label_text' => false,
1367
+										)
1368
+									),
1369
+								),
1370
+							)
1371
+						),
1372
+					)
1373
+				),
1374
+			)
1375
+		);
1376
+	}
1377
+
1378
+
1379
+	/**
1380
+	 * _update_tax_settings
1381
+	 *
1382
+	 * @since 4.9.13
1383
+	 * @return void
1384
+	 */
1385
+	public function _update_tax_settings()
1386
+	{
1387
+		if (! isset(EE_Registry::instance()->CFG->tax_settings)) {
1388
+			EE_Registry::instance()->CFG->tax_settings = new EE_Tax_Config();
1389
+		}
1390
+		try {
1391
+			$tax_form = $this->tax_settings_form();
1392
+			// check for form submission
1393
+			if ($tax_form->was_submitted()) {
1394
+				// capture form data
1395
+				$tax_form->receive_form_submission();
1396
+				// validate form data
1397
+				if ($tax_form->is_valid()) {
1398
+					// grab validated data from form
1399
+					$valid_data = $tax_form->valid_data();
1400
+					// set data on config
1401
+					EE_Registry::instance()
1402
+						->CFG
1403
+						->tax_settings
1404
+						->prices_displayed_including_taxes
1405
+						= $valid_data['tax_settings']['prices_displayed_including_taxes'];
1406
+				} else {
1407
+					if ($tax_form->submission_error_message() !== '') {
1408
+						EE_Error::add_error(
1409
+							$tax_form->submission_error_message(),
1410
+							__FILE__,
1411
+							__FUNCTION__,
1412
+							__LINE__
1413
+						);
1414
+					}
1415
+				}
1416
+			}
1417
+		} catch (EE_Error $e) {
1418
+			EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__);
1419
+		}
1420
+
1421
+		$what = 'Tax Settings';
1422
+		$success = $this->_update_espresso_configuration(
1423
+			$what,
1424
+			EE_Registry::instance()->CFG->tax_settings,
1425
+			__FILE__,
1426
+			__FUNCTION__,
1427
+			__LINE__
1428
+		);
1429
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'tax_settings'));
1430
+	}
1431 1431
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
         wp_enqueue_style('espresso-ui-theme');
362 362
         wp_register_style(
363 363
             'espresso_PRICING',
364
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
364
+            PRICING_ASSETS_URL.'espresso_pricing_admin.css',
365 365
             array(),
366 366
             EVENT_ESPRESSO_VERSION
367 367
         );
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         // wp_enqueue_script('jquery-ui-datepicker');
377 377
         wp_register_script(
378 378
             'espresso_PRICING',
379
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
379
+            PRICING_ASSETS_URL.'espresso_pricing_admin.js',
380 380
             array('jquery'),
381 381
             EVENT_ESPRESSO_VERSION,
382 382
             true
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
      */
470 470
     protected function _price_overview_list_table()
471 471
     {
472
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
472
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
473 473
             'add_new_price',
474 474
             'add',
475 475
             array(),
@@ -497,8 +497,8 @@  discard block
 block discarded – undo
497 497
         // start with an empty array
498 498
         $event_pricing = array();
499 499
 
500
-        require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
501
-        require_once(EE_MODELS . 'EEM_Price.model.php');
500
+        require_once(PRICING_ADMIN.'Prices_List_Table.class.php');
501
+        require_once(EE_MODELS.'EEM_Price.model.php');
502 502
         // $PRC = EEM_Price::instance();
503 503
 
504 504
         $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby'];
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         $limit = array($offset, $per_page);
534 534
 
535 535
         if (isset($this->_req_data['s'])) {
536
-            $sstr = '%' . $this->_req_data['s'] . '%';
536
+            $sstr = '%'.$this->_req_data['s'].'%';
537 537
             $_where['OR'] = array(
538 538
                 'PRC_name'            => array('LIKE', $sstr),
539 539
                 'PRC_desc'            => array('LIKE', $sstr),
@@ -582,10 +582,10 @@  discard block
 block discarded – undo
582 582
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
583 583
         }
584 584
         // add PRC_ID to title if editing
585
-        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
585
+        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title.' # '.$PRC_ID : $this->_admin_page_title;
586 586
 
587 587
         // get prices
588
-        require_once(EE_MODELS . 'EEM_Price.model.php');
588
+        require_once(EE_MODELS.'EEM_Price.model.php');
589 589
         $PRC = EEM_Price::instance();
590 590
 
591 591
         if ($PRC_ID) {
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
         $this->_template_args['price'] = $price;
604 604
 
605 605
         // get price types
606
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
606
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
607 607
         $PRT = EEM_Price_Type::instance();
608 608
         $price_types = $PRT->get_all(array(array('PBT_ID' => array('!=', 1))));
609 609
         $price_type_names = array();
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
     public function _edit_price_details_meta_box()
660 660
     {
661 661
         echo EEH_Template::display_template(
662
-            PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
662
+            PRICING_TEMPLATE_PATH.'pricing_details_main_meta_box.template.php',
663 663
             $this->_template_args,
664 664
             true
665 665
         );
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
         // echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
706 706
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
707 707
 
708
-        require_once(EE_MODELS . 'EEM_Price.model.php');
708
+        require_once(EE_MODELS.'EEM_Price.model.php');
709 709
         $PRC = EEM_Price::instance();
710 710
 
711 711
         // why be so pessimistic ???  : (
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
         // echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
779 779
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
780 780
 
781
-        require_once(EE_MODELS . 'EEM_Price.model.php');
781
+        require_once(EE_MODELS.'EEM_Price.model.php');
782 782
         $PRC = EEM_Price::instance();
783 783
 
784 784
         $success = 1;
@@ -787,12 +787,12 @@  discard block
 block discarded – undo
787 787
         // get base ticket for updating
788 788
         $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
789 789
         // Checkboxes
790
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
790
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
791 791
             // if array has more than one element than success message should be plural
792 792
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
793 793
             // cycle thru checkboxes
794 794
             while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) {
795
-                if (! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), absint($PRC_ID))) {
795
+                if ( ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), absint($PRC_ID))) {
796 796
                     $success = 0;
797 797
                 } else {
798 798
                     $PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
@@ -865,24 +865,24 @@  discard block
 block discarded – undo
865 865
         // echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
866 866
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
867 867
 
868
-        require_once(EE_MODELS . 'EEM_Price.model.php');
868
+        require_once(EE_MODELS.'EEM_Price.model.php');
869 869
         $PRC = EEM_Price::instance();
870 870
 
871 871
         $success = 1;
872 872
         // Checkboxes
873
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
873
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
874 874
             // if array has more than one element than success message should be plural
875 875
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
876 876
             // cycle thru bulk action checkboxes
877 877
             while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) {
878
-                if (! $PRC->delete_permanently_by_ID(absint($PRC_ID))) {
878
+                if ( ! $PRC->delete_permanently_by_ID(absint($PRC_ID))) {
879 879
                     $success = 0;
880 880
                 }
881 881
             }
882 882
         } else {
883 883
             // grab single id and delete
884 884
             $PRC_ID = absint($this->_req_data['id']);
885
-            if (! $PRC->delete_permanently_by_ID($PRC_ID)) {
885
+            if ( ! $PRC->delete_permanently_by_ID($PRC_ID)) {
886 886
                 $success = 0;
887 887
             }
888 888
         }
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
         if (is_array($row_ids)) {
908 908
             for ($i = 0; $i < count($row_ids); $i++) {
909 909
                 // Update the prices when re-ordering
910
-                $id = absint($row_ids[ $i ]);
910
+                $id = absint($row_ids[$i]);
911 911
                 if (EEM_Price::instance()->update(
912 912
                     array('PRC_order' => $i + 1),
913 913
                     array(array('PRC_ID' => $id))
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
      */
944 944
     protected function _price_types_overview_list_table()
945 945
     {
946
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
946
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
947 947
             'add_new_price_type',
948 948
             'add_type',
949 949
             array(),
@@ -970,8 +970,8 @@  discard block
 block discarded – undo
970 970
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
971 971
         // start with an empty array
972 972
 
973
-        require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
974
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
973
+        require_once(PRICING_ADMIN.'Price_Types_List_Table.class.php');
974
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
975 975
 
976 976
         $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby'];
977 977
         $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
         $_where = array('PRT_deleted' => $trashed, 'PBT_ID' => array('!=', 1));
997 997
 
998 998
         if (isset($this->_req_data['s'])) {
999
-            $sstr = '%' . $this->_req_data['s'] . '%';
999
+            $sstr = '%'.$this->_req_data['s'].'%';
1000 1000
             $_where['OR'] = array(
1001 1001
                 'PRT_name' => array('LIKE', $sstr),
1002 1002
             );
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
1044 1044
         }
1045 1045
         // add PRT_ID to title if editing
1046
-        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
1046
+        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title.' # '.$PRT_ID : $this->_admin_page_title;
1047 1047
 
1048 1048
         if ($PRT_ID) {
1049 1049
             $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
     public function _edit_price_type_details_meta_box()
1112 1112
     {
1113 1113
         echo EEH_Template::display_template(
1114
-            PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1114
+            PRICING_TEMPLATE_PATH.'pricing_type_details_main_meta_box.template.php',
1115 1115
             $this->_template_args,
1116 1116
             true
1117 1117
         );
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
     {
1177 1177
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1178 1178
 
1179
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
1179
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
1180 1180
         $PRT = EEM_Price_Type::instance();
1181 1181
 
1182 1182
         // why be so pessimistic ???  : (
@@ -1216,19 +1216,19 @@  discard block
 block discarded – undo
1216 1216
     {
1217 1217
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1218 1218
 
1219
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
1219
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
1220 1220
         $PRT = EEM_Price_Type::instance();
1221 1221
 
1222 1222
         $success = 1;
1223 1223
         $PRT_deleted = $trash ? true : false;
1224 1224
         // Checkboxes
1225
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1225
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1226 1226
             // if array has more than one element than success message should be plural
1227 1227
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1228 1228
             $what = count($this->_req_data['checkbox']) > 1 ? 'Price Types' : 'Price Type';
1229 1229
             // cycle thru checkboxes
1230 1230
             while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) {
1231
-                if (! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) {
1231
+                if ( ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) {
1232 1232
                     $success = 0;
1233 1233
                 }
1234 1234
             }
@@ -1279,13 +1279,13 @@  discard block
 block discarded – undo
1279 1279
 
1280 1280
         $success = 1;
1281 1281
         // Checkboxes
1282
-        if (! empty($this->_req_data['checkbox'])) {
1282
+        if ( ! empty($this->_req_data['checkbox'])) {
1283 1283
             // if array has more than one element than success message should be plural
1284 1284
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1285 1285
             $what = $PRT->item_name($success);
1286 1286
             // cycle thru bulk action checkboxes
1287 1287
             while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) {
1288
-                if (! $PRT->delete_permanently_by_ID($PRT_ID)) {
1288
+                if ( ! $PRT->delete_permanently_by_ID($PRT_ID)) {
1289 1289
                     $success = 0;
1290 1290
                 }
1291 1291
             }
@@ -1305,10 +1305,10 @@  discard block
 block discarded – undo
1305 1305
      */
1306 1306
     protected function _learn_more_about_pricing_link()
1307 1307
     {
1308
-        return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __(
1308
+        return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__(
1309 1309
             'learn more about how pricing works',
1310 1310
             'event_espresso'
1311
-        ) . '</a>';
1311
+        ).'</a>';
1312 1312
     }
1313 1313
 
1314 1314
 
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
      */
1385 1385
     public function _update_tax_settings()
1386 1386
     {
1387
-        if (! isset(EE_Registry::instance()->CFG->tax_settings)) {
1387
+        if ( ! isset(EE_Registry::instance()->CFG->tax_settings)) {
1388 1388
             EE_Registry::instance()->CFG->tax_settings = new EE_Tax_Config();
1389 1389
         }
1390 1390
         try {
Please login to merge, or discard this patch.
new/pricing/templates/event_tickets_datetime_ticket_price_row.template.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,9 +33,12 @@  discard block
 block discarded – undo
33 33
             <input type="text" size="1" class="edit-price-PRC_amount ee-numeric"
34 34
                    name="prices_archive[<?php echo $tkt_row; ?>][<?php echo $PRC_order; ?>][PRC_amount]"
35 35
                    value="<?php echo $PRC_amount; ?>" disabled>
36
-        <?php else : ?>
36
+        <?php else {
37
+	: ?>
37 38
             <input type="text" size="1" class="edit-price-PRC_amount ee-numeric"
38
-                   name="<?php echo $edit_prices_name; ?>[<?php echo $tkt_row; ?>][<?php echo $PRC_order; ?>][PRC_amount]"
39
+                   name="<?php echo $edit_prices_name;
40
+}
41
+?>[<?php echo $tkt_row; ?>][<?php echo $PRC_order; ?>][PRC_amount]"
39 42
                    value="<?php echo $PRC_amount; ?>">
40 43
         <?php endif; ?>
41 44
     </td>
@@ -46,8 +49,11 @@  discard block
 block discarded – undo
46 49
     <td>
47 50
         <?php if ($disabled) : ?>
48 51
             <span class="ee-lock-icon"></span>
49
-        <?php else : ?>
50
-            <!-- <span class="gear-icon dashicons dashicons-admin-generic clickable" data-ticket-row="<?php echo $tkt_row; ?>" data-context="price" data-price-row="<?php echo $PRC_order; ?>"></span> -->
52
+        <?php else {
53
+	: ?>
54
+            <!-- <span class="gear-icon dashicons dashicons-admin-generic clickable" data-ticket-row="<?php echo $tkt_row;
55
+}
56
+?>" data-context="price" data-price-row="<?php echo $PRC_order; ?>"></span> -->
51 57
             <span class="trash-icon dashicons dashicons-post-trash clickable" data-ticket-row="<?php echo $tkt_row; ?>"
52 58
                   data-context="price" data-price-row="<?php echo $PRC_order; ?>"<?php echo $show_trash_icon; ?>></span>
53 59
             <button data-ticket-row="<?php echo $tkt_row; ?>" data-price-row="<?php echo $PRC_order; ?>"
Please login to merge, or discard this patch.
admin/new/pricing/templates/pricing_type_details_main_meta_box.template.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
             <td>
11 11
                 <?php echo $base_type_select; ?><br/>
12 12
                 <p class="description"><?php
13
-                    _e(
14
-                        'Choosing a basic type allows us to quickly configure a bunch of other options for you.<br/>All events need to have at least one Base Price type option.<br/>Discounts reduce the price of an event, Surcharges increase the price.<br/>Taxes are applied to the final total.',
15
-                        'event_espresso'
16
-                    ); ?></p>
13
+					_e(
14
+						'Choosing a basic type allows us to quickly configure a bunch of other options for you.<br/>All events need to have at least one Base Price type option.<br/>Discounts reduce the price of an event, Surcharges increase the price.<br/>Taxes are applied to the final total.',
15
+						'event_espresso'
16
+					); ?></p>
17 17
             </td>
18 18
         </tr>
19 19
 
@@ -44,20 +44,20 @@  discard block
 block discarded – undo
44 44
                     <?php _e('Fixed', 'event_espresso'); ?>
45 45
                 </label>
46 46
                 <p class="description"><?php
47
-                    _e(
48
-                        'Whether this Price Type will be applied as a percentage or applied as a set fixed amount.',
49
-                        'event_espresso'
50
-                    ); ?></p>
47
+					_e(
48
+						'Whether this Price Type will be applied as a percentage or applied as a set fixed amount.',
49
+						'event_espresso'
50
+					); ?></p>
51 51
                 <?php if ($price_type->base_type() == EEM_Price_Type::base_type_tax) :
52
-                    // base type is tax so let's just let the user know that taxes are always percentage.
53
-                    ?>
52
+					// base type is tax so let's just let the user know that taxes are always percentage.
53
+					?>
54 54
                     <p class="description" style="color:#E44064">
55 55
                         <?php
56
-                            _e(
57
-                                'The selected base type for this price type is "Tax".  Taxes are always assumed to be a percentage.  If you want to use a fixed value for a tax then please change the base type to a surcharge.',
58
-                                'event_espresso'
59
-                            );
60
-                        ?></p>
56
+							_e(
57
+								'The selected base type for this price type is "Tax".  Taxes are always assumed to be a percentage.  If you want to use a fixed value for a tax then please change the base type to a surcharge.',
58
+								'event_espresso'
59
+							);
60
+						?></p>
61 61
                 <?php endif; ?>
62 62
             </td>
63 63
         </tr>
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
                 <p class="description">
72 72
                     <?php _e('The order that Price Types are applied.', 'event_espresso'); ?></p>
73 73
                 <p class="description"><?php
74
-                    _e(
75
-                        'Price types are applied sequentially according to their Order, where higher ordered Price Types will affect lower ordered Price Types.<br/>Price types with equal Orders will be applied in parallel to whatever total precedes them and will not affect each other. Actual Prices will be set to "0" so that they are processed first. Taxes will be always be applied last but their order will still determine if they are applied in parallel or as compound taxes (one tax on top of the other).',
76
-                        'event_espresso'
77
-                    ); ?></p>
74
+					_e(
75
+						'Price types are applied sequentially according to their Order, where higher ordered Price Types will affect lower ordered Price Types.<br/>Price types with equal Orders will be applied in parallel to whatever total precedes them and will not affect each other. Actual Prices will be set to "0" so that they are processed first. Taxes will be always be applied last but their order will still determine if they are applied in parallel or as compound taxes (one tax on top of the other).',
76
+						'event_espresso'
77
+					); ?></p>
78 78
             </td>
79 79
         </tr>
80 80
 
Please login to merge, or discard this patch.