Completed
Branch EE5Update (bc64e6)
by
unknown
09:36 queued 05:38
created
4_7_0_stages/EE_DMS_4_7_0_Registration_Payments.dmsstage.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
         global $wpdb;
25 25
         $this->_pretty_name = esc_html__('Registration Payment Record Generation', 'event_espresso');
26 26
         // define tables
27
-        $this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
28
-        $this->_payment_table                       = $wpdb->prefix . 'esp_payment';
29
-        $this->_registration_table                  = $wpdb->prefix . 'esp_registration';
30
-        $this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
27
+        $this->_old_table = $wpdb->prefix.'esp_transaction';
28
+        $this->_payment_table                       = $wpdb->prefix.'esp_payment';
29
+        $this->_registration_table                  = $wpdb->prefix.'esp_registration';
30
+        $this->_registration_payment_table = $wpdb->prefix.'esp_registration_payment';
31 31
         // build SQL WHERE clauses
32 32
         $this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
33 33
         parent::__construct();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         /** @type WPDB $wpdb */
45 45
         global $wpdb;
46 46
         $TXN_ID = absint($transaction['TXN_ID']);
47
-        if (! $TXN_ID) {
47
+        if ( ! $TXN_ID) {
48 48
             $this->add_error(
49 49
                 sprintf(
50 50
                     esc_html__('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         $available_payment_amount = $payment->PAY_amount;
137 137
         foreach ($registrations as $REG_ID => $registration) {
138 138
             // nothing left, then we are done here?
139
-            if (! $available_payment_amount > 0) {
139
+            if ( ! $available_payment_amount > 0) {
140 140
                 break;
141 141
             }
142 142
             // ensure REG_final_price has a valid value, and skip if it turns out to be zero
143 143
             $registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
144
-            if (! $registration->REG_final_price > 0) {
144
+            if ( ! $registration->REG_final_price > 0) {
145 145
                 continue;
146 146
             }
147 147
             // because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             $registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
154 154
             // calculate amount owing, and skip if it turns out to be zero
155 155
             $owing = $registration->REG_final_price - $registration->REG_paid;
156
-            if (! $owing > 0) {
156
+            if ( ! $owing > 0) {
157 157
                 continue;
158 158
             }
159 159
             // don't allow payment amount to exceed the available payment amount, OR the amount owing
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
         global $wpdb;
186 186
         $success = $wpdb->insert(
187 187
             $this->_registration_payment_table,
188
-            array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
189
-            array( '%f' )   // data format
188
+            array('REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount,), // data
189
+            array('%f')   // data format
190 190
         );
191 191
         if ($success === false) {
192 192
             $this->add_error(
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
         global $wpdb;
217 217
         $success = $wpdb->update(
218 218
             $this->_registration_table,
219
-            array( 'REG_paid' => $REG_paid ),  // data
220
-            array( 'REG_ID' => $REG_ID ),  // where
221
-            array( '%f' ),   // data format
222
-            array( '%d' )  // where format
219
+            array('REG_paid' => $REG_paid), // data
220
+            array('REG_ID' => $REG_ID), // where
221
+            array('%f'), // data format
222
+            array('%d')  // where format
223 223
         );
224 224
         if ($success === false) {
225 225
             $this->add_error(
Please login to merge, or discard this patch.
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -11,225 +11,225 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_7_0_Registration_Payments extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_payment_table;
15
-
16
-    protected $_registration_table;
17
-
18
-    protected $_registration_payment_table;
19
-
20
-    public function __construct()
21
-    {
22
-        /** @type WPDB $wpdb */
23
-        global $wpdb;
24
-        $this->_pretty_name = esc_html__('Registration Payment Record Generation', 'event_espresso');
25
-        // define tables
26
-        $this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
27
-        $this->_payment_table                       = $wpdb->prefix . 'esp_payment';
28
-        $this->_registration_table                  = $wpdb->prefix . 'esp_registration';
29
-        $this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
30
-        // build SQL WHERE clauses
31
-        $this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
32
-        parent::__construct();
33
-    }
34
-
35
-
36
-
37
-    /**
38
-     * @param array $transaction
39
-     * @return void
40
-     */
41
-    protected function _migrate_old_row($transaction)
42
-    {
43
-        /** @type WPDB $wpdb */
44
-        global $wpdb;
45
-        $TXN_ID = absint($transaction['TXN_ID']);
46
-        if (! $TXN_ID) {
47
-            $this->add_error(
48
-                sprintf(
49
-                    esc_html__('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
50
-                    $TXN_ID,
51
-                    $wpdb->last_error
52
-                )
53
-            );
54
-            return;
55
-        }
56
-        // get all payments for the TXN
57
-        $payments = $this->_get_payments($TXN_ID);
58
-        if (empty($payments)) {
59
-            return;
60
-        }
61
-        // then the registrants
62
-        $registrations = $this->_get_registrations($TXN_ID);
63
-        if (empty($registrations)) {
64
-            return;
65
-        }
66
-        // now loop thru each payment and apply it to each of the registrations
67
-        foreach ($payments as $PAY_ID => $payment) {
68
-            if ($payment->STS_ID === 'PAP' && $payment->PAY_amount > 0) {
69
-                $this->_process_registration_payments($payment, $registrations);
70
-            }
71
-        }
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * _get_registrations
78
-     *
79
-     * @param int $TXN_ID
80
-     * @return array
81
-     */
82
-    protected function _get_registrations($TXN_ID)
83
-    {
84
-        /** @type WPDB $wpdb */
85
-        global $wpdb;
86
-        $SQL = "SELECT * FROM {$this->_registration_table} WHERE TXN_ID = %d AND STS_ID IN ( 'RPP', 'RAP' )";
87
-        return $wpdb->get_results($wpdb->prepare($SQL, $TXN_ID), OBJECT_K);
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * _get_payments
94
-     *
95
-     * @param int $TXN_ID
96
-     * @return array
97
-     */
98
-    protected function _get_payments($TXN_ID)
99
-    {
100
-        /** @type WPDB $wpdb */
101
-        global $wpdb;
102
-        return $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->_payment_table} WHERE TXN_ID = %d", $TXN_ID), OBJECT_K);
103
-    }
104
-
105
-
106
-
107
-    /**
108
-     * _get_possibly_updated_REG_paid
109
-     *
110
-     * @param int $REG_ID
111
-     * @return array
112
-     */
113
-    protected function _get_possibly_updated_REG_paid($REG_ID)
114
-    {
115
-        /** @type WPDB $wpdb */
116
-        global $wpdb;
117
-        return $wpdb->get_var($wpdb->prepare("SELECT REG_paid FROM {$this->_registration_table} WHERE REG_ID = %d", $REG_ID));
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * _process_registration_payments
124
-     *
125
-     * basically a copy of the "Sequential Registration Payment Application Strategy"  logic
126
-     * currently in EE_Payment_Processor::process_registration_payments()
127
-     *
128
-     * @param stdClass $payment
129
-     * @param array $registrations
130
-     * @return bool
131
-     */
132
-    protected function _process_registration_payments($payment, $registrations = array())
133
-    {
134
-        // how much is available to apply to registrations?
135
-        $available_payment_amount = $payment->PAY_amount;
136
-        foreach ($registrations as $REG_ID => $registration) {
137
-            // nothing left, then we are done here?
138
-            if (! $available_payment_amount > 0) {
139
-                break;
140
-            }
141
-            // ensure REG_final_price has a valid value, and skip if it turns out to be zero
142
-            $registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
143
-            if (! $registration->REG_final_price > 0) {
144
-                continue;
145
-            }
146
-            // because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
147
-            $possibly_updated_REG_paid = $this->_get_possibly_updated_REG_paid($REG_ID);
148
-            if (is_float($possibly_updated_REG_paid)) {
149
-                $registration->REG_paid = $possibly_updated_REG_paid;
150
-            }
151
-            // and ensure REG_paid has a valid value
152
-            $registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
153
-            // calculate amount owing, and skip if it turns out to be zero
154
-            $owing = $registration->REG_final_price - $registration->REG_paid;
155
-            if (! $owing > 0) {
156
-                continue;
157
-            }
158
-            // don't allow payment amount to exceed the available payment amount, OR the amount owing
159
-            $payment_amount = min($available_payment_amount, $owing);
160
-            // update $available_payment_amount
161
-            $available_payment_amount = $available_payment_amount - $payment_amount;
162
-            // add relation between registration and payment and set amount
163
-            if ($this->_insert_registration_payment($registration->REG_ID, $payment->PAY_ID, $payment_amount)) {
164
-                // calculate and set new REG_paid
165
-                $registration->REG_paid = $registration->REG_paid + $payment_amount;
166
-                $this->_update_registration_paid($registration->REG_ID, $registration->REG_paid);
167
-            }
168
-        }
169
-    }
170
-
171
-
172
-
173
-    /**
174
-     * _insert_registration_payment
175
-     *
176
-     * @param int $REG_ID
177
-     * @param int $PAY_ID
178
-     * @param float $PAY_amount
179
-     * @return bool
180
-     */
181
-    protected function _insert_registration_payment($REG_ID = 0, $PAY_ID = 0, $PAY_amount = 0.00)
182
-    {
183
-        /** @type WPDB $wpdb */
184
-        global $wpdb;
185
-        $success = $wpdb->insert(
186
-            $this->_registration_payment_table,
187
-            array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
188
-            array( '%f' )   // data format
189
-        );
190
-        if ($success === false) {
191
-            $this->add_error(
192
-                sprintf(
193
-                    esc_html__('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
194
-                    $REG_ID,
195
-                    $wpdb->last_error
196
-                )
197
-            );
198
-            return false;
199
-        }
200
-        return true;
201
-    }
202
-
203
-
204
-
205
-    /**
206
-     * _update_registration_paid
207
-     *
208
-     * @param int $REG_ID
209
-     * @param float $REG_paid
210
-     * @return bool
211
-     */
212
-    protected function _update_registration_paid($REG_ID = 0, $REG_paid = 0.00)
213
-    {
214
-        /** @type WPDB $wpdb */
215
-        global $wpdb;
216
-        $success = $wpdb->update(
217
-            $this->_registration_table,
218
-            array( 'REG_paid' => $REG_paid ),  // data
219
-            array( 'REG_ID' => $REG_ID ),  // where
220
-            array( '%f' ),   // data format
221
-            array( '%d' )  // where format
222
-        );
223
-        if ($success === false) {
224
-            $this->add_error(
225
-                sprintf(
226
-                    esc_html__('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
227
-                    $REG_ID,
228
-                    $wpdb->last_error
229
-                )
230
-            );
231
-            return false;
232
-        }
233
-        return true;
234
-    }
14
+	protected $_payment_table;
15
+
16
+	protected $_registration_table;
17
+
18
+	protected $_registration_payment_table;
19
+
20
+	public function __construct()
21
+	{
22
+		/** @type WPDB $wpdb */
23
+		global $wpdb;
24
+		$this->_pretty_name = esc_html__('Registration Payment Record Generation', 'event_espresso');
25
+		// define tables
26
+		$this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
27
+		$this->_payment_table                       = $wpdb->prefix . 'esp_payment';
28
+		$this->_registration_table                  = $wpdb->prefix . 'esp_registration';
29
+		$this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
30
+		// build SQL WHERE clauses
31
+		$this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
32
+		parent::__construct();
33
+	}
34
+
35
+
36
+
37
+	/**
38
+	 * @param array $transaction
39
+	 * @return void
40
+	 */
41
+	protected function _migrate_old_row($transaction)
42
+	{
43
+		/** @type WPDB $wpdb */
44
+		global $wpdb;
45
+		$TXN_ID = absint($transaction['TXN_ID']);
46
+		if (! $TXN_ID) {
47
+			$this->add_error(
48
+				sprintf(
49
+					esc_html__('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
50
+					$TXN_ID,
51
+					$wpdb->last_error
52
+				)
53
+			);
54
+			return;
55
+		}
56
+		// get all payments for the TXN
57
+		$payments = $this->_get_payments($TXN_ID);
58
+		if (empty($payments)) {
59
+			return;
60
+		}
61
+		// then the registrants
62
+		$registrations = $this->_get_registrations($TXN_ID);
63
+		if (empty($registrations)) {
64
+			return;
65
+		}
66
+		// now loop thru each payment and apply it to each of the registrations
67
+		foreach ($payments as $PAY_ID => $payment) {
68
+			if ($payment->STS_ID === 'PAP' && $payment->PAY_amount > 0) {
69
+				$this->_process_registration_payments($payment, $registrations);
70
+			}
71
+		}
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * _get_registrations
78
+	 *
79
+	 * @param int $TXN_ID
80
+	 * @return array
81
+	 */
82
+	protected function _get_registrations($TXN_ID)
83
+	{
84
+		/** @type WPDB $wpdb */
85
+		global $wpdb;
86
+		$SQL = "SELECT * FROM {$this->_registration_table} WHERE TXN_ID = %d AND STS_ID IN ( 'RPP', 'RAP' )";
87
+		return $wpdb->get_results($wpdb->prepare($SQL, $TXN_ID), OBJECT_K);
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * _get_payments
94
+	 *
95
+	 * @param int $TXN_ID
96
+	 * @return array
97
+	 */
98
+	protected function _get_payments($TXN_ID)
99
+	{
100
+		/** @type WPDB $wpdb */
101
+		global $wpdb;
102
+		return $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->_payment_table} WHERE TXN_ID = %d", $TXN_ID), OBJECT_K);
103
+	}
104
+
105
+
106
+
107
+	/**
108
+	 * _get_possibly_updated_REG_paid
109
+	 *
110
+	 * @param int $REG_ID
111
+	 * @return array
112
+	 */
113
+	protected function _get_possibly_updated_REG_paid($REG_ID)
114
+	{
115
+		/** @type WPDB $wpdb */
116
+		global $wpdb;
117
+		return $wpdb->get_var($wpdb->prepare("SELECT REG_paid FROM {$this->_registration_table} WHERE REG_ID = %d", $REG_ID));
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * _process_registration_payments
124
+	 *
125
+	 * basically a copy of the "Sequential Registration Payment Application Strategy"  logic
126
+	 * currently in EE_Payment_Processor::process_registration_payments()
127
+	 *
128
+	 * @param stdClass $payment
129
+	 * @param array $registrations
130
+	 * @return bool
131
+	 */
132
+	protected function _process_registration_payments($payment, $registrations = array())
133
+	{
134
+		// how much is available to apply to registrations?
135
+		$available_payment_amount = $payment->PAY_amount;
136
+		foreach ($registrations as $REG_ID => $registration) {
137
+			// nothing left, then we are done here?
138
+			if (! $available_payment_amount > 0) {
139
+				break;
140
+			}
141
+			// ensure REG_final_price has a valid value, and skip if it turns out to be zero
142
+			$registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
143
+			if (! $registration->REG_final_price > 0) {
144
+				continue;
145
+			}
146
+			// because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
147
+			$possibly_updated_REG_paid = $this->_get_possibly_updated_REG_paid($REG_ID);
148
+			if (is_float($possibly_updated_REG_paid)) {
149
+				$registration->REG_paid = $possibly_updated_REG_paid;
150
+			}
151
+			// and ensure REG_paid has a valid value
152
+			$registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
153
+			// calculate amount owing, and skip if it turns out to be zero
154
+			$owing = $registration->REG_final_price - $registration->REG_paid;
155
+			if (! $owing > 0) {
156
+				continue;
157
+			}
158
+			// don't allow payment amount to exceed the available payment amount, OR the amount owing
159
+			$payment_amount = min($available_payment_amount, $owing);
160
+			// update $available_payment_amount
161
+			$available_payment_amount = $available_payment_amount - $payment_amount;
162
+			// add relation between registration and payment and set amount
163
+			if ($this->_insert_registration_payment($registration->REG_ID, $payment->PAY_ID, $payment_amount)) {
164
+				// calculate and set new REG_paid
165
+				$registration->REG_paid = $registration->REG_paid + $payment_amount;
166
+				$this->_update_registration_paid($registration->REG_ID, $registration->REG_paid);
167
+			}
168
+		}
169
+	}
170
+
171
+
172
+
173
+	/**
174
+	 * _insert_registration_payment
175
+	 *
176
+	 * @param int $REG_ID
177
+	 * @param int $PAY_ID
178
+	 * @param float $PAY_amount
179
+	 * @return bool
180
+	 */
181
+	protected function _insert_registration_payment($REG_ID = 0, $PAY_ID = 0, $PAY_amount = 0.00)
182
+	{
183
+		/** @type WPDB $wpdb */
184
+		global $wpdb;
185
+		$success = $wpdb->insert(
186
+			$this->_registration_payment_table,
187
+			array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
188
+			array( '%f' )   // data format
189
+		);
190
+		if ($success === false) {
191
+			$this->add_error(
192
+				sprintf(
193
+					esc_html__('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
194
+					$REG_ID,
195
+					$wpdb->last_error
196
+				)
197
+			);
198
+			return false;
199
+		}
200
+		return true;
201
+	}
202
+
203
+
204
+
205
+	/**
206
+	 * _update_registration_paid
207
+	 *
208
+	 * @param int $REG_ID
209
+	 * @param float $REG_paid
210
+	 * @return bool
211
+	 */
212
+	protected function _update_registration_paid($REG_ID = 0, $REG_paid = 0.00)
213
+	{
214
+		/** @type WPDB $wpdb */
215
+		global $wpdb;
216
+		$success = $wpdb->update(
217
+			$this->_registration_table,
218
+			array( 'REG_paid' => $REG_paid ),  // data
219
+			array( 'REG_ID' => $REG_ID ),  // where
220
+			array( '%f' ),   // data format
221
+			array( '%d' )  // where format
222
+		);
223
+		if ($success === false) {
224
+			$this->add_error(
225
+				sprintf(
226
+					esc_html__('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
227
+					$REG_ID,
228
+					$wpdb->last_error
229
+				)
230
+			);
231
+			return false;
232
+		}
233
+		return true;
234
+	}
235 235
 }
Please login to merge, or discard this patch.
4_7_0_stages/EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price.dmsstage.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
         global $wpdb;
23 23
         $this->_pretty_name = esc_html__('Registration Final Price Tax Calculations', 'event_espresso');
24 24
         // define tables
25
-        $this->_old_table               = $wpdb->prefix . 'esp_registration';
26
-        $this->_ticket_table            = $wpdb->prefix . 'esp_ticket';
27
-        $this->_line_item_table     = $wpdb->prefix . 'esp_line_item';
25
+        $this->_old_table               = $wpdb->prefix.'esp_registration';
26
+        $this->_ticket_table            = $wpdb->prefix.'esp_ticket';
27
+        $this->_line_item_table = $wpdb->prefix.'esp_line_item';
28 28
         parent::__construct();
29 29
     }
30 30
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         /** @type WPDB $wpdb */
110 110
         global $wpdb;
111 111
         // ensure all required values are present
112
-        if (! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) {
112
+        if ( ! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) {
113 113
             $this->add_error(
114 114
                 sprintf(
115 115
                     esc_html__('Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', 'event_espresso'),
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         }
125 125
         // get tax subtotal
126 126
         $tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($row['LIN_ID']);
127
-        if (! $tax_subtotal_line_item_ID) {
127
+        if ( ! $tax_subtotal_line_item_ID) {
128 128
             $this->add_error(
129 129
                 sprintf(
130 130
                     esc_html__('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'),
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         if (is_array($taxes) && ! empty($taxes)) {
192 192
             $total_taxes = 0;
193 193
             foreach ($taxes as $tax) {
194
-                $total_taxes += $final_price * ( $tax->LIN_percent / 100 );
194
+                $total_taxes += $final_price * ($tax->LIN_percent / 100);
195 195
             }
196 196
             $final_price += $total_taxes;
197 197
             $this->_update_registration_final_price($REG_ID, $final_price);
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
         global $wpdb;
214 214
         $success = $wpdb->update(
215 215
             $this->_old_table,
216
-            array( 'REG_final_price' => $REG_final_price ),  // data
217
-            array( 'REG_ID' => $REG_ID ),  // where
218
-            array( '%f' ),   // data format
219
-            array( '%d' )  // where format
216
+            array('REG_final_price' => $REG_final_price), // data
217
+            array('REG_ID' => $REG_ID), // where
218
+            array('%f'), // data format
219
+            array('%d')  // where format
220 220
         );
221 221
         if ($success === false) {
222 222
             $this->add_error(
Please login to merge, or discard this patch.
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -11,73 +11,73 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_ticket_table;
15
-
16
-    protected $_line_item_table;
17
-
18
-    public function __construct()
19
-    {
20
-        /** @type WPDB $wpdb */
21
-        global $wpdb;
22
-        $this->_pretty_name = esc_html__('Registration Final Price Tax Calculations', 'event_espresso');
23
-        // define tables
24
-        $this->_old_table               = $wpdb->prefix . 'esp_registration';
25
-        $this->_ticket_table            = $wpdb->prefix . 'esp_ticket';
26
-        $this->_line_item_table     = $wpdb->prefix . 'esp_line_item';
27
-        parent::__construct();
28
-    }
29
-
30
-
31
-
32
-    /**
33
-     * @return string
34
-     */
35
-    protected function _get_rest_of_sql_for_query()
36
-    {
37
-        $SQL = "FROM {$this->_old_table} AS reg ";
38
-        $SQL .= "JOIN {$this->_ticket_table} as tkt ON reg.TKT_ID = tkt.TKT_ID ";
39
-        $SQL .= "JOIN {$this->_line_item_table} as line ON reg.TXN_ID = line.TXN_ID ";
40
-        $SQL .= "WHERE tkt.TKT_taxable = 1 ";
41
-        $SQL .= "AND line.LIN_code = 'total' ";
42
-        $SQL .= "AND reg.REG_final_price > 0 ";
43
-        return $SQL;
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * Counts the records to migrate; the public version may cache it
50
-     * @return int
51
-     */
52
-    public function _count_records_to_migrate()
53
-    {
54
-        /** @type WPDB $wpdb */
55
-        global $wpdb;
56
-        $SQL = "SELECT count( reg.REG_ID ) ";
57
-        $SQL .= $this->_get_rest_of_sql_for_query();
58
-        $count = $wpdb->get_var($SQL);
59
-        return $count;
60
-    }
61
-
62
-
63
-
64
-    /**
65
-     * Gets data for all registrations with taxable tickets in the esp_line_item table
66
-     * @global wpdb $wpdb
67
-     * @param int $limit
68
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
69
-     */
70
-    protected function _get_rows($limit)
71
-    {
72
-        /** @type WPDB $wpdb */
73
-        global $wpdb;
74
-        $start_at_record = $this->count_records_migrated();
75
-        $SQL = "SELECT reg.REG_ID,  reg.REG_final_price, line.LIN_ID ";
76
-        $SQL .= $this->_get_rest_of_sql_for_query();
77
-        $SQL .= $wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit);
78
-
79
-        // produces something like:
80
-        /*
14
+	protected $_ticket_table;
15
+
16
+	protected $_line_item_table;
17
+
18
+	public function __construct()
19
+	{
20
+		/** @type WPDB $wpdb */
21
+		global $wpdb;
22
+		$this->_pretty_name = esc_html__('Registration Final Price Tax Calculations', 'event_espresso');
23
+		// define tables
24
+		$this->_old_table               = $wpdb->prefix . 'esp_registration';
25
+		$this->_ticket_table            = $wpdb->prefix . 'esp_ticket';
26
+		$this->_line_item_table     = $wpdb->prefix . 'esp_line_item';
27
+		parent::__construct();
28
+	}
29
+
30
+
31
+
32
+	/**
33
+	 * @return string
34
+	 */
35
+	protected function _get_rest_of_sql_for_query()
36
+	{
37
+		$SQL = "FROM {$this->_old_table} AS reg ";
38
+		$SQL .= "JOIN {$this->_ticket_table} as tkt ON reg.TKT_ID = tkt.TKT_ID ";
39
+		$SQL .= "JOIN {$this->_line_item_table} as line ON reg.TXN_ID = line.TXN_ID ";
40
+		$SQL .= "WHERE tkt.TKT_taxable = 1 ";
41
+		$SQL .= "AND line.LIN_code = 'total' ";
42
+		$SQL .= "AND reg.REG_final_price > 0 ";
43
+		return $SQL;
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * Counts the records to migrate; the public version may cache it
50
+	 * @return int
51
+	 */
52
+	public function _count_records_to_migrate()
53
+	{
54
+		/** @type WPDB $wpdb */
55
+		global $wpdb;
56
+		$SQL = "SELECT count( reg.REG_ID ) ";
57
+		$SQL .= $this->_get_rest_of_sql_for_query();
58
+		$count = $wpdb->get_var($SQL);
59
+		return $count;
60
+	}
61
+
62
+
63
+
64
+	/**
65
+	 * Gets data for all registrations with taxable tickets in the esp_line_item table
66
+	 * @global wpdb $wpdb
67
+	 * @param int $limit
68
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
69
+	 */
70
+	protected function _get_rows($limit)
71
+	{
72
+		/** @type WPDB $wpdb */
73
+		global $wpdb;
74
+		$start_at_record = $this->count_records_migrated();
75
+		$SQL = "SELECT reg.REG_ID,  reg.REG_final_price, line.LIN_ID ";
76
+		$SQL .= $this->_get_rest_of_sql_for_query();
77
+		$SQL .= $wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit);
78
+
79
+		// produces something like:
80
+		/*
81 81
             SELECT
82 82
               reg.REG_ID,
83 83
               reg.REG_final_price,
@@ -94,137 +94,137 @@  discard block
 block discarded – undo
94 94
             LIMIT 1, 50
95 95
          */
96 96
 
97
-        return $wpdb->get_results($SQL, ARRAY_A);
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * @param array $row
104
-     * @return void
105
-     */
106
-    protected function _migrate_old_row($row)
107
-    {
108
-        /** @type WPDB $wpdb */
109
-        global $wpdb;
110
-        // ensure all required values are present
111
-        if (! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) {
112
-            $this->add_error(
113
-                sprintf(
114
-                    esc_html__('Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', 'event_espresso'),
115
-                    '<br />',
116
-                    isset($row['REG_ID']) ? $row['REG_ID'] : '',
117
-                    isset($row['REG_final_price']) ? $row['REG_final_price'] : '',
118
-                    isset($row['LIN_ID']) ? $row['LIN_ID'] : '',
119
-                    $wpdb->last_error
120
-                )
121
-            );
122
-            return;
123
-        }
124
-        // get tax subtotal
125
-        $tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($row['LIN_ID']);
126
-        if (! $tax_subtotal_line_item_ID) {
127
-            $this->add_error(
128
-                sprintf(
129
-                    esc_html__('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'),
130
-                    $wpdb->last_error
131
-                )
132
-            );
133
-            return;
134
-        }
135
-        // now get taxes
136
-        $taxes = $this->_get_tax_amounts($tax_subtotal_line_item_ID);
137
-        // apply taxes to registration final price
138
-        $this->_apply_taxes($row['REG_ID'], $row['REG_final_price'], $taxes);
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * _get_tax_subtotal
145
-     *
146
-     * @param int $LIN_ID
147
-     * @return int
148
-     */
149
-    protected function _get_line_item_ID_for_tax_subtotal($LIN_ID)
150
-    {
151
-        /** @type WPDB $wpdb */
152
-        global $wpdb;
153
-        $SQL = "SELECT LIN_ID ";
154
-        $SQL .= "FROM {$this->_line_item_table} ";
155
-        $SQL .= "WHERE LIN_parent = %d ";
156
-        $SQL .= "AND LIN_code = 'taxes'";
157
-        return $wpdb->get_var($wpdb->prepare($SQL, $LIN_ID));
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * _get_tax_subtotal
164
-     *
165
-     * @param int $LIN_ID
166
-     * @return array
167
-     */
168
-    protected function _get_tax_amounts($LIN_ID)
169
-    {
170
-        /** @type WPDB $wpdb */
171
-        global $wpdb;
172
-        $SQL = "SELECT LIN_percent ";
173
-        $SQL .= "FROM {$this->_line_item_table} ";
174
-        $SQL .= "WHERE LIN_parent = %d";
175
-        return $wpdb->get_results($wpdb->prepare($SQL, $LIN_ID), OBJECT_K);
176
-    }
177
-
178
-
179
-
180
-    /**
181
-     * _apply_taxes
182
-     *
183
-     * @param int $REG_ID
184
-     * @param float $final_price
185
-     * @param array $taxes
186
-     * @return void
187
-     */
188
-    protected function _apply_taxes($REG_ID = 0, $final_price = 0.00, $taxes = array())
189
-    {
190
-        if (is_array($taxes) && ! empty($taxes)) {
191
-            $total_taxes = 0;
192
-            foreach ($taxes as $tax) {
193
-                $total_taxes += $final_price * ( $tax->LIN_percent / 100 );
194
-            }
195
-            $final_price += $total_taxes;
196
-            $this->_update_registration_final_price($REG_ID, $final_price);
197
-        }
198
-    }
199
-
200
-
201
-
202
-    /**
203
-     * _update_registration_final_price
204
-     *
205
-     * @param int $REG_ID
206
-     * @param float $REG_final_price
207
-     * @return void
208
-     */
209
-    protected function _update_registration_final_price($REG_ID = 0, $REG_final_price = 0.00)
210
-    {
211
-        /** @type WPDB $wpdb */
212
-        global $wpdb;
213
-        $success = $wpdb->update(
214
-            $this->_old_table,
215
-            array( 'REG_final_price' => $REG_final_price ),  // data
216
-            array( 'REG_ID' => $REG_ID ),  // where
217
-            array( '%f' ),   // data format
218
-            array( '%d' )  // where format
219
-        );
220
-        if ($success === false) {
221
-            $this->add_error(
222
-                sprintf(
223
-                    esc_html__('Could not update registration final price value for registration ID=%1$d because "%2$s"', 'event_espresso'),
224
-                    $REG_ID,
225
-                    $wpdb->last_error
226
-                )
227
-            );
228
-        }
229
-    }
97
+		return $wpdb->get_results($SQL, ARRAY_A);
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * @param array $row
104
+	 * @return void
105
+	 */
106
+	protected function _migrate_old_row($row)
107
+	{
108
+		/** @type WPDB $wpdb */
109
+		global $wpdb;
110
+		// ensure all required values are present
111
+		if (! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) {
112
+			$this->add_error(
113
+				sprintf(
114
+					esc_html__('Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', 'event_espresso'),
115
+					'<br />',
116
+					isset($row['REG_ID']) ? $row['REG_ID'] : '',
117
+					isset($row['REG_final_price']) ? $row['REG_final_price'] : '',
118
+					isset($row['LIN_ID']) ? $row['LIN_ID'] : '',
119
+					$wpdb->last_error
120
+				)
121
+			);
122
+			return;
123
+		}
124
+		// get tax subtotal
125
+		$tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($row['LIN_ID']);
126
+		if (! $tax_subtotal_line_item_ID) {
127
+			$this->add_error(
128
+				sprintf(
129
+					esc_html__('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'),
130
+					$wpdb->last_error
131
+				)
132
+			);
133
+			return;
134
+		}
135
+		// now get taxes
136
+		$taxes = $this->_get_tax_amounts($tax_subtotal_line_item_ID);
137
+		// apply taxes to registration final price
138
+		$this->_apply_taxes($row['REG_ID'], $row['REG_final_price'], $taxes);
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * _get_tax_subtotal
145
+	 *
146
+	 * @param int $LIN_ID
147
+	 * @return int
148
+	 */
149
+	protected function _get_line_item_ID_for_tax_subtotal($LIN_ID)
150
+	{
151
+		/** @type WPDB $wpdb */
152
+		global $wpdb;
153
+		$SQL = "SELECT LIN_ID ";
154
+		$SQL .= "FROM {$this->_line_item_table} ";
155
+		$SQL .= "WHERE LIN_parent = %d ";
156
+		$SQL .= "AND LIN_code = 'taxes'";
157
+		return $wpdb->get_var($wpdb->prepare($SQL, $LIN_ID));
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * _get_tax_subtotal
164
+	 *
165
+	 * @param int $LIN_ID
166
+	 * @return array
167
+	 */
168
+	protected function _get_tax_amounts($LIN_ID)
169
+	{
170
+		/** @type WPDB $wpdb */
171
+		global $wpdb;
172
+		$SQL = "SELECT LIN_percent ";
173
+		$SQL .= "FROM {$this->_line_item_table} ";
174
+		$SQL .= "WHERE LIN_parent = %d";
175
+		return $wpdb->get_results($wpdb->prepare($SQL, $LIN_ID), OBJECT_K);
176
+	}
177
+
178
+
179
+
180
+	/**
181
+	 * _apply_taxes
182
+	 *
183
+	 * @param int $REG_ID
184
+	 * @param float $final_price
185
+	 * @param array $taxes
186
+	 * @return void
187
+	 */
188
+	protected function _apply_taxes($REG_ID = 0, $final_price = 0.00, $taxes = array())
189
+	{
190
+		if (is_array($taxes) && ! empty($taxes)) {
191
+			$total_taxes = 0;
192
+			foreach ($taxes as $tax) {
193
+				$total_taxes += $final_price * ( $tax->LIN_percent / 100 );
194
+			}
195
+			$final_price += $total_taxes;
196
+			$this->_update_registration_final_price($REG_ID, $final_price);
197
+		}
198
+	}
199
+
200
+
201
+
202
+	/**
203
+	 * _update_registration_final_price
204
+	 *
205
+	 * @param int $REG_ID
206
+	 * @param float $REG_final_price
207
+	 * @return void
208
+	 */
209
+	protected function _update_registration_final_price($REG_ID = 0, $REG_final_price = 0.00)
210
+	{
211
+		/** @type WPDB $wpdb */
212
+		global $wpdb;
213
+		$success = $wpdb->update(
214
+			$this->_old_table,
215
+			array( 'REG_final_price' => $REG_final_price ),  // data
216
+			array( 'REG_ID' => $REG_ID ),  // where
217
+			array( '%f' ),   // data format
218
+			array( '%d' )  // where format
219
+		);
220
+		if ($success === false) {
221
+			$this->add_error(
222
+				sprintf(
223
+					esc_html__('Could not update registration final price value for registration ID=%1$d because "%2$s"', 'event_espresso'),
224
+					$REG_ID,
225
+					$wpdb->last_error
226
+				)
227
+			);
228
+		}
229
+	}
230 230
 }
Please login to merge, or discard this patch.
4_2_0_stages/EE_DMS_4_2_0_datetime_fields.dmsstage.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -8,49 +8,49 @@
 block discarded – undo
8 8
 
9 9
 class EE_DMS_4_2_0_datetime_fields extends EE_Data_Migration_Script_Stage_Table
10 10
 {
11
-    public function __construct()
12
-    {
13
-        global $wpdb;
14
-        $this->_pretty_name = esc_html__("Datetime Fields", "event_espresso");
15
-        $this->_old_table = $wpdb->prefix . "esp_datetime";
16
-        parent::__construct();
17
-    }
11
+	public function __construct()
12
+	{
13
+		global $wpdb;
14
+		$this->_pretty_name = esc_html__("Datetime Fields", "event_espresso");
15
+		$this->_old_table = $wpdb->prefix . "esp_datetime";
16
+		parent::__construct();
17
+	}
18 18
 
19
-    protected function _migrate_old_row($old_row)
20
-    {
21
-        // foreach question_group_question entry with this QST_ID, we want to set its
22
-        // QSG_order equal to this question's QST_order
23
-        global $wpdb;
19
+	protected function _migrate_old_row($old_row)
20
+	{
21
+		// foreach question_group_question entry with this QST_ID, we want to set its
22
+		// QSG_order equal to this question's QST_order
23
+		global $wpdb;
24 24
 
25
-        $updated = $wpdb->update(
26
-            $this->_old_table,
27
-            array(
28
-                'DTT_name' => '',
29
-                'DTT_description' => '',
30
-            ),
31
-            array(
32
-                'DTT_ID' => $old_row['DTT_ID'],
33
-            ),
34
-            array(
35
-                '%s',// DTT_name,
36
-                '%s',// DTT_description
37
-            ),
38
-            array(
39
-                '%d',// DTT_ID
40
-            )
41
-        );
42
-        if (false === $updated) {
43
-            $this->add_error(
44
-                sprintf(
45
-                    esc_html__(
46
-                        "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d",
47
-                        'event_espresso'
48
-                    ),
49
-                    $this->_old_table,
50
-                    $old_row['QST_ID']
51
-                )
52
-            );
53
-        }
54
-        // nothing to map really
55
-    }
25
+		$updated = $wpdb->update(
26
+			$this->_old_table,
27
+			array(
28
+				'DTT_name' => '',
29
+				'DTT_description' => '',
30
+			),
31
+			array(
32
+				'DTT_ID' => $old_row['DTT_ID'],
33
+			),
34
+			array(
35
+				'%s',// DTT_name,
36
+				'%s',// DTT_description
37
+			),
38
+			array(
39
+				'%d',// DTT_ID
40
+			)
41
+		);
42
+		if (false === $updated) {
43
+			$this->add_error(
44
+				sprintf(
45
+					esc_html__(
46
+						"Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d",
47
+						'event_espresso'
48
+					),
49
+					$this->_old_table,
50
+					$old_row['QST_ID']
51
+				)
52
+			);
53
+		}
54
+		// nothing to map really
55
+	}
56 56
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     {
13 13
         global $wpdb;
14 14
         $this->_pretty_name = esc_html__("Datetime Fields", "event_espresso");
15
-        $this->_old_table = $wpdb->prefix . "esp_datetime";
15
+        $this->_old_table = $wpdb->prefix."esp_datetime";
16 16
         parent::__construct();
17 17
     }
18 18
 
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
                 'DTT_ID' => $old_row['DTT_ID'],
33 33
             ),
34 34
             array(
35
-                '%s',// DTT_name,
36
-                '%s',// DTT_description
35
+                '%s', // DTT_name,
36
+                '%s', // DTT_description
37 37
             ),
38 38
             array(
39
-                '%d',// DTT_ID
39
+                '%d', // DTT_ID
40 40
             )
41 41
         );
42 42
         if (false === $updated) {
Please login to merge, or discard this patch.
4_2_0_stages/EE_DMS_4_2_0_question_group_questions.dmsstage.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 
7 7
 class EE_DMS_4_2_0_question_group_questions extends EE_Data_Migration_Script_Stage_Table
8 8
 {
9
-    private $_qgq_table;
10
-    public function __construct()
11
-    {
12
-        global $wpdb;
13
-        $this->_pretty_name = esc_html__("Question Group Questions", "event_espresso");
14
-        $this->_old_table = $wpdb->prefix . "esp_question";
15
-        $this->_qgq_table = $wpdb->prefix . "esp_question_group_question";
16
-        parent::__construct();
17
-    }
18
-    protected function _migrate_old_row($old_row)
19
-    {
20
-        // foreach question_group_question entry with this QST_ID, we want to set its
21
-        // QSG_order equal to this question's QST_order
22
-        global $wpdb;
23
-        $updated = $wpdb->update(
24
-            $this->_qgq_table,
25
-            array('QGQ_order' => $old_row['QST_order']),
26
-            array('QST_ID' => $old_row['QST_ID']),
27
-            array('%d',// QGQ_order
28
-                    ),
29
-            array('%d',// QST_ID
30
-                    )
31
-        );
32
-        if (false === $updated) {
33
-            $this->add_error(
34
-                sprintf(
35
-                    esc_html__(
36
-                        "Error in updating table %s setting QGQ_order = %d where QST_ID = %d",
37
-                        'event_espresso'
38
-                    ),
39
-                    $this->_qgq_table,
40
-                    $old_row['QST_order'],
41
-                    $old_row['QST_ID']
42
-                )
43
-            );
44
-        }
45
-        // nothing to map really
46
-    }
9
+	private $_qgq_table;
10
+	public function __construct()
11
+	{
12
+		global $wpdb;
13
+		$this->_pretty_name = esc_html__("Question Group Questions", "event_espresso");
14
+		$this->_old_table = $wpdb->prefix . "esp_question";
15
+		$this->_qgq_table = $wpdb->prefix . "esp_question_group_question";
16
+		parent::__construct();
17
+	}
18
+	protected function _migrate_old_row($old_row)
19
+	{
20
+		// foreach question_group_question entry with this QST_ID, we want to set its
21
+		// QSG_order equal to this question's QST_order
22
+		global $wpdb;
23
+		$updated = $wpdb->update(
24
+			$this->_qgq_table,
25
+			array('QGQ_order' => $old_row['QST_order']),
26
+			array('QST_ID' => $old_row['QST_ID']),
27
+			array('%d',// QGQ_order
28
+					),
29
+			array('%d',// QST_ID
30
+					)
31
+		);
32
+		if (false === $updated) {
33
+			$this->add_error(
34
+				sprintf(
35
+					esc_html__(
36
+						"Error in updating table %s setting QGQ_order = %d where QST_ID = %d",
37
+						'event_espresso'
38
+					),
39
+					$this->_qgq_table,
40
+					$old_row['QST_order'],
41
+					$old_row['QST_ID']
42
+				)
43
+			);
44
+		}
45
+		// nothing to map really
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
     {
12 12
         global $wpdb;
13 13
         $this->_pretty_name = esc_html__("Question Group Questions", "event_espresso");
14
-        $this->_old_table = $wpdb->prefix . "esp_question";
15
-        $this->_qgq_table = $wpdb->prefix . "esp_question_group_question";
14
+        $this->_old_table = $wpdb->prefix."esp_question";
15
+        $this->_qgq_table = $wpdb->prefix."esp_question_group_question";
16 16
         parent::__construct();
17 17
     }
18 18
     protected function _migrate_old_row($old_row)
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
             $this->_qgq_table,
25 25
             array('QGQ_order' => $old_row['QST_order']),
26 26
             array('QST_ID' => $old_row['QST_ID']),
27
-            array('%d',// QGQ_order
27
+            array('%d', // QGQ_order
28 28
                     ),
29
-            array('%d',// QST_ID
29
+            array('%d', // QST_ID
30 30
                     )
31 31
         );
32 32
         if (false === $updated) {
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_question_types.dmsstage.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     {
26 26
         global $wpdb;
27 27
         $this->_pretty_name = esc_html__('Question Types', 'event_espresso');
28
-        $this->_old_table = $wpdb->prefix . 'esp_question';
28
+        $this->_old_table = $wpdb->prefix.'esp_question';
29 29
         $this->_question_type_conversions = array(
30 30
             'MULTIPLE'          => 'CHECKBOX',
31 31
             'SINGLE'                => 'RADIO_BTN'
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted
35 35
         // so we need to include both the migrated rows as well as the non-migrated rows
36 36
         $QST_types_to_count = array_merge(array_keys($this->_question_type_conversions), $this->_question_type_conversions);
37
-        $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')" ;
37
+        $this->_extra_where_sql = "WHERE QST_type IN ('".implode("', '", $QST_types_to_count)."')";
38 38
         parent::__construct();
39 39
     }
40 40
 
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
     protected function _migrate_old_row($question)
46 46
     {
47 47
         global $wpdb;
48
-        if ($question['QST_ID'] && isset($this->_question_type_conversions[ $question['QST_type'] ])) {
48
+        if ($question['QST_ID'] && isset($this->_question_type_conversions[$question['QST_type']])) {
49 49
             $success = $wpdb->update(
50 50
                 $this->_old_table,
51
-                array( 'QST_type' => $this->_question_type_conversions[ $question['QST_type'] ] ),  // data
52
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
53
-                array( '%s' ),   // data format
54
-                array( '%d' )  // where format
51
+                array('QST_type' => $this->_question_type_conversions[$question['QST_type']]), // data
52
+                array('QST_ID' => $question['QST_ID']), // where
53
+                array('%s'), // data format
54
+                array('%d')  // where format
55 55
             );
56
-            if (! $success) {
56
+            if ( ! $success) {
57 57
                 $this->add_error(
58 58
                     sprintf(
59 59
                         esc_html__('Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso'),
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,57 +11,57 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_question_types extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_question_type_conversions = array();
14
+	protected $_question_type_conversions = array();
15 15
 
16 16
 
17 17
 
18
-    /**
19
-     * Just initializes the status of the migration
20
-     *
21
-     * @return EE_DMS_4_6_0_question_types
22
-     */
23
-    public function __construct()
24
-    {
25
-        global $wpdb;
26
-        $this->_pretty_name = esc_html__('Question Types', 'event_espresso');
27
-        $this->_old_table = $wpdb->prefix . 'esp_question';
28
-        $this->_question_type_conversions = array(
29
-            'MULTIPLE'          => 'CHECKBOX',
30
-            'SINGLE'                => 'RADIO_BTN'
31
-        );
32
-        // when fetching rows, because we automatically use a limit and offset
33
-        // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted
34
-        // so we need to include both the migrated rows as well as the non-migrated rows
35
-        $QST_types_to_count = array_merge(array_keys($this->_question_type_conversions), $this->_question_type_conversions);
36
-        $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')" ;
37
-        parent::__construct();
38
-    }
18
+	/**
19
+	 * Just initializes the status of the migration
20
+	 *
21
+	 * @return EE_DMS_4_6_0_question_types
22
+	 */
23
+	public function __construct()
24
+	{
25
+		global $wpdb;
26
+		$this->_pretty_name = esc_html__('Question Types', 'event_espresso');
27
+		$this->_old_table = $wpdb->prefix . 'esp_question';
28
+		$this->_question_type_conversions = array(
29
+			'MULTIPLE'          => 'CHECKBOX',
30
+			'SINGLE'                => 'RADIO_BTN'
31
+		);
32
+		// when fetching rows, because we automatically use a limit and offset
33
+		// rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted
34
+		// so we need to include both the migrated rows as well as the non-migrated rows
35
+		$QST_types_to_count = array_merge(array_keys($this->_question_type_conversions), $this->_question_type_conversions);
36
+		$this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')" ;
37
+		parent::__construct();
38
+	}
39 39
 
40
-    /**
41
-     * @param array $question an associative array where keys are column names and values are their values.
42
-     * @return null
43
-     */
44
-    protected function _migrate_old_row($question)
45
-    {
46
-        global $wpdb;
47
-        if ($question['QST_ID'] && isset($this->_question_type_conversions[ $question['QST_type'] ])) {
48
-            $success = $wpdb->update(
49
-                $this->_old_table,
50
-                array( 'QST_type' => $this->_question_type_conversions[ $question['QST_type'] ] ),  // data
51
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
52
-                array( '%s' ),   // data format
53
-                array( '%d' )  // where format
54
-            );
55
-            if (! $success) {
56
-                $this->add_error(
57
-                    sprintf(
58
-                        esc_html__('Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso'),
59
-                        wp_json_encode($question['QST_type']),
60
-                        $question['QST_ID'],
61
-                        $wpdb->last_error
62
-                    )
63
-                );
64
-            }
65
-        }
66
-    }
40
+	/**
41
+	 * @param array $question an associative array where keys are column names and values are their values.
42
+	 * @return null
43
+	 */
44
+	protected function _migrate_old_row($question)
45
+	{
46
+		global $wpdb;
47
+		if ($question['QST_ID'] && isset($this->_question_type_conversions[ $question['QST_type'] ])) {
48
+			$success = $wpdb->update(
49
+				$this->_old_table,
50
+				array( 'QST_type' => $this->_question_type_conversions[ $question['QST_type'] ] ),  // data
51
+				array( 'QST_ID' => $question['QST_ID'] ),  // where
52
+				array( '%s' ),   // data format
53
+				array( '%d' )  // where format
54
+			);
55
+			if (! $success) {
56
+				$this->add_error(
57
+					sprintf(
58
+						esc_html__('Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso'),
59
+						wp_json_encode($question['QST_type']),
60
+						$question['QST_ID'],
61
+						$wpdb->last_error
62
+					)
63
+				);
64
+			}
65
+		}
66
+	}
67 67
 }
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_state_system_question.dmsstage.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     {
24 24
         global $wpdb;
25 25
         $this->_pretty_name = esc_html__('State - System Question', 'event_espresso');
26
-        $this->_old_table = $wpdb->prefix . 'esp_question';
26
+        $this->_old_table = $wpdb->prefix.'esp_question';
27 27
         $this->_extra_where_sql = "WHERE QST_system = 'state'";
28 28
         parent::__construct();
29 29
     }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
             global $wpdb;
42 42
             $success = $wpdb->update(
43 43
                 $this->_old_table,
44
-                array( 'QST_type' => 'STATE' ),  // data
45
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
46
-                array( '%s' ),   // data format
47
-                array( '%d' )  // where format
44
+                array('QST_type' => 'STATE'), // data
45
+                array('QST_ID' => $question['QST_ID']), // where
46
+                array('%s'), // data format
47
+                array('%d')  // where format
48 48
             );
49
-            if (! $success) {
49
+            if ( ! $success) {
50 50
                 $this->add_error(
51 51
                     sprintf(
52 52
                         esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -11,48 +11,48 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_state_system_question extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    /**
15
-     * Just initializes the status of the migration
16
-     *
17
-     * @return EE_DMS_4_6_0_state_system_question
18
-     */
19
-    public function __construct()
20
-    {
21
-        global $wpdb;
22
-        $this->_pretty_name = esc_html__('State - System Question', 'event_espresso');
23
-        $this->_old_table = $wpdb->prefix . 'esp_question';
24
-        $this->_extra_where_sql = "WHERE QST_system = 'state'";
25
-        parent::__construct();
26
-    }
14
+	/**
15
+	 * Just initializes the status of the migration
16
+	 *
17
+	 * @return EE_DMS_4_6_0_state_system_question
18
+	 */
19
+	public function __construct()
20
+	{
21
+		global $wpdb;
22
+		$this->_pretty_name = esc_html__('State - System Question', 'event_espresso');
23
+		$this->_old_table = $wpdb->prefix . 'esp_question';
24
+		$this->_extra_where_sql = "WHERE QST_system = 'state'";
25
+		parent::__construct();
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * updates the question with the new question type
32
-     * @param array $question an associative array where keys are column names and values are their values.
33
-     * @return null
34
-     */
35
-    protected function _migrate_old_row($question)
36
-    {
37
-        if ($question['QST_ID'] && $question['QST_system'] == 'state') {
38
-            global $wpdb;
39
-            $success = $wpdb->update(
40
-                $this->_old_table,
41
-                array( 'QST_type' => 'STATE' ),  // data
42
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
43
-                array( '%s' ),   // data format
44
-                array( '%d' )  // where format
45
-            );
46
-            if (! $success) {
47
-                $this->add_error(
48
-                    sprintf(
49
-                        esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
50
-                        wp_json_encode($question['QST_system']),
51
-                        $question['QST_ID'],
52
-                        $wpdb->last_error
53
-                    )
54
-                );
55
-            }
56
-        }
57
-    }
30
+	/**
31
+	 * updates the question with the new question type
32
+	 * @param array $question an associative array where keys are column names and values are their values.
33
+	 * @return null
34
+	 */
35
+	protected function _migrate_old_row($question)
36
+	{
37
+		if ($question['QST_ID'] && $question['QST_system'] == 'state') {
38
+			global $wpdb;
39
+			$success = $wpdb->update(
40
+				$this->_old_table,
41
+				array( 'QST_type' => 'STATE' ),  // data
42
+				array( 'QST_ID' => $question['QST_ID'] ),  // where
43
+				array( '%s' ),   // data format
44
+				array( '%d' )  // where format
45
+			);
46
+			if (! $success) {
47
+				$this->add_error(
48
+					sprintf(
49
+						esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
50
+						wp_json_encode($question['QST_system']),
51
+						$question['QST_ID'],
52
+						$wpdb->last_error
53
+					)
54
+				);
55
+			}
56
+		}
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_payments.dmsstage.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_payments extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_payment_method_table;
15
-    public function __construct()
16
-    {
17
-        global $wpdb;
18
-        $this->_old_table = $wpdb->prefix . 'esp_payment';
19
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
20
-        $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso');
21
-        parent::__construct();
22
-    }
23
-    protected function _migrate_old_row($payment_row)
24
-    {
25
-        global $wpdb;
26
-        // get the payment method's ID
27
-        $PMD_ID = apply_filters('FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', $this->_get_payment_method_id_by_gateway_name($payment_row['PAY_gateway'], $payment_row['PAY_method']));
28
-        if (! $PMD_ID) {
29
-            $this->add_error(sprintf(esc_html__('Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', 'event_espresso'), $payment_row['PAY_gateway'], $this->_json_encode($payment_row)));
30
-            $PMD_ID = 0;
31
-        }
32
-        $new_values = array(
33
-            'PMD_ID' => $PMD_ID,
34
-            'PAY_source' => ( $payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART' ) );
35
-        $wheres = array( 'PAY_ID' => $payment_row['PAY_ID'] );
36
-        $new_value_datatypes = array( '%d', '%s' );
37
-        $where_datatypes = array( '%d' );
38
-        $success = $wpdb->update(
39
-            $this->_old_table,
40
-            $new_values,
41
-            $wheres,
42
-            $new_value_datatypes,
43
-            $where_datatypes
44
-        );
45
-        if (! $success) {
46
-            $this->add_error(sprintf(esc_html__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_old_table, $this->_json_encode($wheres)));
47
-        }
48
-    }
49
-    /**
50
-     *
51
-     *  array(
14
+	protected $_payment_method_table;
15
+	public function __construct()
16
+	{
17
+		global $wpdb;
18
+		$this->_old_table = $wpdb->prefix . 'esp_payment';
19
+		$this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
20
+		$this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso');
21
+		parent::__construct();
22
+	}
23
+	protected function _migrate_old_row($payment_row)
24
+	{
25
+		global $wpdb;
26
+		// get the payment method's ID
27
+		$PMD_ID = apply_filters('FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', $this->_get_payment_method_id_by_gateway_name($payment_row['PAY_gateway'], $payment_row['PAY_method']));
28
+		if (! $PMD_ID) {
29
+			$this->add_error(sprintf(esc_html__('Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', 'event_espresso'), $payment_row['PAY_gateway'], $this->_json_encode($payment_row)));
30
+			$PMD_ID = 0;
31
+		}
32
+		$new_values = array(
33
+			'PMD_ID' => $PMD_ID,
34
+			'PAY_source' => ( $payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART' ) );
35
+		$wheres = array( 'PAY_ID' => $payment_row['PAY_ID'] );
36
+		$new_value_datatypes = array( '%d', '%s' );
37
+		$where_datatypes = array( '%d' );
38
+		$success = $wpdb->update(
39
+			$this->_old_table,
40
+			$new_values,
41
+			$wheres,
42
+			$new_value_datatypes,
43
+			$where_datatypes
44
+		);
45
+		if (! $success) {
46
+			$this->add_error(sprintf(esc_html__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_old_table, $this->_json_encode($wheres)));
47
+		}
48
+	}
49
+	/**
50
+	 *
51
+	 *  array(
52 52
             'PP' => esc_html__( 'PayPal', 'event_espresso' ),
53 53
             'CC' => esc_html__( 'Credit Card', 'event_espresso' ),
54 54
             'DB'=>  esc_html__("Debit Card", 'event_espresso'),
@@ -57,44 +57,44 @@  discard block
 block discarded – undo
57 57
             'BK'=>  esc_html__("Bank", 'event_espresso'),
58 58
             'IV'=>  esc_html__("Invoice", 'event_espresso'),
59 59
             'MO'=>  esc_html__("Money Order", 'event_espresso'),
60
-     * @global type $wpdb
61
-     * @param int $id
62
-     * @return string
63
-     */
64
-    protected function _get_payment_method_id_by_gateway_name($gateway_name, $old_pay_method_column)
65
-    {
66
-        global $wpdb;
67
-        // convert from old known PAY_method values to their corresponding
68
-        // PMD_type or default PMD_name
69
-        switch ($old_pay_method_column) {
70
-            case 'PP':
71
-                $pmd_type = 'Paypal_Standard';
72
-                break;
73
-            case 'CC':
74
-                $pmd_type = 'Credit_Card';
75
-                break;
76
-            case 'DB':
77
-                $pmd_type = 'Debit_Card';
78
-                break;
79
-            case 'CHQ':
80
-                $pmd_type = 'Check';
81
-                break;
82
-            case 'CSH':
83
-                $pmd_type = 'Cash';
84
-                break;
85
-            case 'BK':
86
-                $pmd_type = 'Bank';
87
-                break;
88
-            case 'IV':
89
-                $pmd_type = 'Invoice';
90
-                break;
91
-            case 'MO':
92
-                $pmd_type = 'Money_Order';
93
-                break;
94
-            default:
95
-                $pmd_type = $gateway_name;
96
-        }
97
-        $pmd_name = str_replace("_", " ", $pmd_type);
98
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name));
99
-    }
60
+	 * @global type $wpdb
61
+	 * @param int $id
62
+	 * @return string
63
+	 */
64
+	protected function _get_payment_method_id_by_gateway_name($gateway_name, $old_pay_method_column)
65
+	{
66
+		global $wpdb;
67
+		// convert from old known PAY_method values to their corresponding
68
+		// PMD_type or default PMD_name
69
+		switch ($old_pay_method_column) {
70
+			case 'PP':
71
+				$pmd_type = 'Paypal_Standard';
72
+				break;
73
+			case 'CC':
74
+				$pmd_type = 'Credit_Card';
75
+				break;
76
+			case 'DB':
77
+				$pmd_type = 'Debit_Card';
78
+				break;
79
+			case 'CHQ':
80
+				$pmd_type = 'Check';
81
+				break;
82
+			case 'CSH':
83
+				$pmd_type = 'Cash';
84
+				break;
85
+			case 'BK':
86
+				$pmd_type = 'Bank';
87
+				break;
88
+			case 'IV':
89
+				$pmd_type = 'Invoice';
90
+				break;
91
+			case 'MO':
92
+				$pmd_type = 'Money_Order';
93
+				break;
94
+			default:
95
+				$pmd_type = $gateway_name;
96
+		}
97
+		$pmd_name = str_replace("_", " ", $pmd_type);
98
+		return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name));
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
     public function __construct()
16 16
     {
17 17
         global $wpdb;
18
-        $this->_old_table = $wpdb->prefix . 'esp_payment';
19
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
18
+        $this->_old_table = $wpdb->prefix.'esp_payment';
19
+        $this->_payment_method_table = $wpdb->prefix.'esp_payment_method';
20 20
         $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso');
21 21
         parent::__construct();
22 22
     }
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
         global $wpdb;
26 26
         // get the payment method's ID
27 27
         $PMD_ID = apply_filters('FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', $this->_get_payment_method_id_by_gateway_name($payment_row['PAY_gateway'], $payment_row['PAY_method']));
28
-        if (! $PMD_ID) {
28
+        if ( ! $PMD_ID) {
29 29
             $this->add_error(sprintf(esc_html__('Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', 'event_espresso'), $payment_row['PAY_gateway'], $this->_json_encode($payment_row)));
30 30
             $PMD_ID = 0;
31 31
         }
32 32
         $new_values = array(
33 33
             'PMD_ID' => $PMD_ID,
34
-            'PAY_source' => ( $payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART' ) );
35
-        $wheres = array( 'PAY_ID' => $payment_row['PAY_ID'] );
36
-        $new_value_datatypes = array( '%d', '%s' );
37
-        $where_datatypes = array( '%d' );
34
+            'PAY_source' => ($payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART') );
35
+        $wheres = array('PAY_ID' => $payment_row['PAY_ID']);
36
+        $new_value_datatypes = array('%d', '%s');
37
+        $where_datatypes = array('%d');
38 38
         $success = $wpdb->update(
39 39
             $this->_old_table,
40 40
             $new_values,
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $new_value_datatypes,
43 43
             $where_datatypes
44 44
         );
45
-        if (! $success) {
45
+        if ( ! $success) {
46 46
             $this->add_error(sprintf(esc_html__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_old_table, $this->_json_encode($wheres)));
47 47
         }
48 48
     }
@@ -95,6 +95,6 @@  discard block
 block discarded – undo
95 95
                 $pmd_type = $gateway_name;
96 96
         }
97 97
         $pmd_name = str_replace("_", " ", $pmd_type);
98
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name));
98
+        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name));
99 99
     }
100 100
 }
Please login to merge, or discard this patch.
data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_transactions.dmsstage.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -11,51 +11,51 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_transaction_table;
15
-    protected $_payment_method_table;
16
-    public function __construct()
17
-    {
18
-        global $wpdb;
19
-        $this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
-        $this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
22
-        $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso');
23
-        $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24
-        parent::__construct();
25
-    }
26
-    protected function _migrate_old_row($extra_meta_row)
27
-    {
28
-        global $wpdb;
29
-        // get the payment method's ID
30
-        $PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']);
31
-        if (! $PMD_ID) {
32
-            $this->add_error(sprintf(esc_html__('Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso'), $extra_meta_row['EXM_value'], $this->_json_encode($extra_meta_row)));
33
-            return;
34
-        }
35
-        $new_values = array( 'PMD_ID' => $PMD_ID );
36
-        $wheres = array( 'TXN_ID' => $extra_meta_row['OBJ_ID'] );
37
-        $new_value_datatypes = array( '%d' );
38
-        $where_datatypes = array( '%d' );
39
-        $success = $wpdb->update(
40
-            $this->_transaction_table,
41
-            $new_values,
42
-            $wheres,
43
-            $new_value_datatypes,
44
-            $where_datatypes
45
-        );
46
-        if (! $success) {
47
-            $this->add_error(sprintf(esc_html__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_transaction_table, $this->_json_encode($wheres)));
48
-        }
49
-    }
50
-    /**
51
-     *
52
-     * @global type $wpdb
53
-     * @param int $id
54
-     * @return string
55
-     */
56
-    protected function _get_payment_method_id_by_gateway_name($gateway_name)
57
-    {
58
-        global $wpdb;
59
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
60
-    }
14
+	protected $_transaction_table;
15
+	protected $_payment_method_table;
16
+	public function __construct()
17
+	{
18
+		global $wpdb;
19
+		$this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
+		$this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
+		$this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
22
+		$this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso');
23
+		$this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24
+		parent::__construct();
25
+	}
26
+	protected function _migrate_old_row($extra_meta_row)
27
+	{
28
+		global $wpdb;
29
+		// get the payment method's ID
30
+		$PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']);
31
+		if (! $PMD_ID) {
32
+			$this->add_error(sprintf(esc_html__('Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso'), $extra_meta_row['EXM_value'], $this->_json_encode($extra_meta_row)));
33
+			return;
34
+		}
35
+		$new_values = array( 'PMD_ID' => $PMD_ID );
36
+		$wheres = array( 'TXN_ID' => $extra_meta_row['OBJ_ID'] );
37
+		$new_value_datatypes = array( '%d' );
38
+		$where_datatypes = array( '%d' );
39
+		$success = $wpdb->update(
40
+			$this->_transaction_table,
41
+			$new_values,
42
+			$wheres,
43
+			$new_value_datatypes,
44
+			$where_datatypes
45
+		);
46
+		if (! $success) {
47
+			$this->add_error(sprintf(esc_html__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_transaction_table, $this->_json_encode($wheres)));
48
+		}
49
+	}
50
+	/**
51
+	 *
52
+	 * @global type $wpdb
53
+	 * @param int $id
54
+	 * @return string
55
+	 */
56
+	protected function _get_payment_method_id_by_gateway_name($gateway_name)
57
+	{
58
+		global $wpdb;
59
+		return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
     public function __construct()
17 17
     {
18 18
         global $wpdb;
19
-        $this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
-        $this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
19
+        $this->_old_table = $wpdb->prefix.'esp_extra_meta';
20
+        $this->_transaction_table = $wpdb->prefix.'esp_transaction';
21
+        $this->_payment_method_table = $wpdb->prefix.'esp_payment_method';
22 22
         $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso');
23 23
         $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24 24
         parent::__construct();
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
         global $wpdb;
29 29
         // get the payment method's ID
30 30
         $PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']);
31
-        if (! $PMD_ID) {
31
+        if ( ! $PMD_ID) {
32 32
             $this->add_error(sprintf(esc_html__('Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso'), $extra_meta_row['EXM_value'], $this->_json_encode($extra_meta_row)));
33 33
             return;
34 34
         }
35
-        $new_values = array( 'PMD_ID' => $PMD_ID );
36
-        $wheres = array( 'TXN_ID' => $extra_meta_row['OBJ_ID'] );
37
-        $new_value_datatypes = array( '%d' );
38
-        $where_datatypes = array( '%d' );
35
+        $new_values = array('PMD_ID' => $PMD_ID);
36
+        $wheres = array('TXN_ID' => $extra_meta_row['OBJ_ID']);
37
+        $new_value_datatypes = array('%d');
38
+        $where_datatypes = array('%d');
39 39
         $success = $wpdb->update(
40 40
             $this->_transaction_table,
41 41
             $new_values,
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             $new_value_datatypes,
44 44
             $where_datatypes
45 45
         );
46
-        if (! $success) {
46
+        if ( ! $success) {
47 47
             $this->add_error(sprintf(esc_html__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_transaction_table, $this->_json_encode($wheres)));
48 48
         }
49 49
     }
@@ -56,6 +56,6 @@  discard block
 block discarded – undo
56 56
     protected function _get_payment_method_id_by_gateway_name($gateway_name)
57 57
     {
58 58
         global $wpdb;
59
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
59
+        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s", $gateway_name));
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_country_system_question.dmsstage.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     {
24 24
         global $wpdb;
25 25
         $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso');
26
-        $this->_old_table = $wpdb->prefix . 'esp_question';
26
+        $this->_old_table = $wpdb->prefix.'esp_question';
27 27
         $this->_extra_where_sql = "WHERE QST_system = 'country'";
28 28
         parent::__construct();
29 29
     }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
             global $wpdb;
42 42
             $success = $wpdb->update(
43 43
                 $this->_old_table,
44
-                array( 'QST_type' => 'COUNTRY' ),  // data
45
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
46
-                array( '%s' ),   // data format
47
-                array( '%d' )  // where format
44
+                array('QST_type' => 'COUNTRY'), // data
45
+                array('QST_ID' => $question['QST_ID']), // where
46
+                array('%s'), // data format
47
+                array('%d')  // where format
48 48
             );
49
-            if (! $success) {
49
+            if ( ! $success) {
50 50
                 $this->add_error(
51 51
                     sprintf(
52 52
                         esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -11,48 +11,48 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_country_system_question extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    /**
15
-     * Just initializes the status of the migration
16
-     *
17
-     * @return EE_DMS_4_6_0_country_system_question
18
-     */
19
-    public function __construct()
20
-    {
21
-        global $wpdb;
22
-        $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso');
23
-        $this->_old_table = $wpdb->prefix . 'esp_question';
24
-        $this->_extra_where_sql = "WHERE QST_system = 'country'";
25
-        parent::__construct();
26
-    }
14
+	/**
15
+	 * Just initializes the status of the migration
16
+	 *
17
+	 * @return EE_DMS_4_6_0_country_system_question
18
+	 */
19
+	public function __construct()
20
+	{
21
+		global $wpdb;
22
+		$this->_pretty_name = esc_html__('Country - System Question', 'event_espresso');
23
+		$this->_old_table = $wpdb->prefix . 'esp_question';
24
+		$this->_extra_where_sql = "WHERE QST_system = 'country'";
25
+		parent::__construct();
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * updates the question with the new question type
32
-     * @param array $question an associative array where keys are column names and values are their values.
33
-     * @return null
34
-     */
35
-    protected function _migrate_old_row($question)
36
-    {
37
-        if ($question['QST_ID'] && $question['QST_system'] == 'country') {
38
-            global $wpdb;
39
-            $success = $wpdb->update(
40
-                $this->_old_table,
41
-                array( 'QST_type' => 'COUNTRY' ),  // data
42
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
43
-                array( '%s' ),   // data format
44
-                array( '%d' )  // where format
45
-            );
46
-            if (! $success) {
47
-                $this->add_error(
48
-                    sprintf(
49
-                        esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
50
-                        wp_json_encode($question['QST_system']),
51
-                        $question['QST_ID'],
52
-                        $wpdb->last_error
53
-                    )
54
-                );
55
-            }
56
-        }
57
-    }
30
+	/**
31
+	 * updates the question with the new question type
32
+	 * @param array $question an associative array where keys are column names and values are their values.
33
+	 * @return null
34
+	 */
35
+	protected function _migrate_old_row($question)
36
+	{
37
+		if ($question['QST_ID'] && $question['QST_system'] == 'country') {
38
+			global $wpdb;
39
+			$success = $wpdb->update(
40
+				$this->_old_table,
41
+				array( 'QST_type' => 'COUNTRY' ),  // data
42
+				array( 'QST_ID' => $question['QST_ID'] ),  // where
43
+				array( '%s' ),   // data format
44
+				array( '%d' )  // where format
45
+			);
46
+			if (! $success) {
47
+				$this->add_error(
48
+					sprintf(
49
+						esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
50
+						wp_json_encode($question['QST_system']),
51
+						$question['QST_ID'],
52
+						$wpdb->last_error
53
+					)
54
+				);
55
+			}
56
+		}
57
+	}
58 58
 }
Please login to merge, or discard this patch.