PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.6.7
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.6.7
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / modules / accounting / includes / classes / class-settings.php

class-settings.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.6.7, at modules/accounting/includes/classes/class-settings.php

191 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WeDevs\ERP\Accounting\Includes\Classes;
4
5 use WeDevs\ERP\Framework\ERP_Settings_Page;
6
7 /**
8 * General class
9 */
10 class Settings extends ERP_Settings_Page {
11 public function __construct() {
12 $this->id = 'erp-ac';
13 $this->label = __( 'Accounting', 'erp' );
14 $this->single_option = true;
15 $this->sections = $this->get_sections();
16
17 add_action( 'erp_admin_field_acct_opening_balance', [ $this, 'acct_opening_balance' ] );
18 }
19
20 /**
21 * Get sections
22 *
23 * @return array
24 */
25 public function get_sections() {
26 $sections = [
27 'customers' => __( 'Customers', 'erp' ),
28 'currency_option' => __( 'Currency Settings', 'erp' ),
29 'opening_balance' => __( 'Financial Years', 'erp' ),
30 ];
31
32 return apply_filters( 'erp_get_sections_' . $this->id, $sections );
33 }
34
35 /**
36 * Get sections fields
37 *
38 * @return array
39 */
40 public function get_section_fields( $section = '' ) {
41 $symbol = erp_acct_get_currency_symbol();
42
43 $fields['customers'] = [
44 [ 'title' => __( '', 'erp' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ],
45
46 [
47 'title' => __( 'Customer Settings', 'erp' ),
48 'type' => 'title',
49 'desc' => __( 'Settings for Accounting customers.', 'erp' ),
50 'id' => 'customer_settings',
51 ],
52
53 [
54 'title' => __( 'Auto Import', 'erp' ),
55 'id' => 'customer_auto_import',
56 'type' => 'select',
57 'desc' => __( 'Allow to auto import new crm user as accounting customer.', 'erp' ),
58 'options' => [ 1 => __( 'On', 'erp' ), 0 => __( 'Off', 'erp' ) ],
59 'default' => 0,
60 ],
61
62 [
63 'title' => __( 'Import User\'s From', 'erp' ),
64 'id' => 'crm_user_type',
65 'type' => 'multicheck',
66 'desc' => __( 'Selected user type are considered to auto import.', 'erp' ),
67 'options' => [ 'contact' => __( 'Contact', 'erp' ), 'company' => __( 'Company', 'erp' ) ],
68 'default' => [],
69 ],
70
71 [
72 'type' => 'sectionend',
73 'id' => 'script_styling_options',
74 ],
75 ];
76
77 $fields['currency_option'] = [
78 [
79 'title' => '',
80 'type' => 'title',
81 'desc' => '',
82 'id' => 'general_options',
83 ],
84
85 [
86 'title' => __( 'Currency Position', 'erp' ),
87 'id' => 'erp_ac_currency_position',
88 'type' => 'select',
89 'class' => 'erp-select2',
90 'options' => [
91 'left' => sprintf( '%1$s (%2$s99.99)', __( 'Left', 'erp' ), $symbol ),
92 'right' => sprintf( '%1$s (99.99%2$s)', __( 'Right', 'erp' ), $symbol ),
93 'left_space' => sprintf( '%1$s (%2$s 99.99)', __( 'Left with space', 'erp' ), $symbol ),
94 'right_space' => sprintf( '%1$s (99.99 %2$s)', __( 'Right with space', 'erp' ), $symbol ),
95 ],
96 ],
97
98 [
99 'title' => __( 'Thousand Separator', 'erp' ),
100 'type' => 'text',
101 'id' => 'erp_ac_th_separator',
102 'default' => ',',
103 ],
104
105 [
106 'title' => __( 'Decimal Separator', 'erp' ),
107 'id' => 'erp_ac_de_separator',
108 'type' => 'text',
109 'default' => '.',
110 ],
111
112 // array(
113 // 'title' => __( 'Number of Decimals', 'erp' ),
114 // 'type' => 'text',
115 // 'id' => 'erp_ac_nm_decimal',
116 // 'default' => 2
117 // ),
118
119 [
120 'type' => 'sectionend',
121 'id' => 'script_styling_options',
122 ],
123 ]; // End currency options settings
124
125 $fields['opening_balance'] = [
126 [
127 'title' => __( 'Financial Years', 'erp' ),
128 'type' => 'title',
129 'desc' => '',
130 'id' => 'erp_acct_ob_options',
131 ],
132 [
133 'type' => 'acct_opening_balance',
134 'id' => 'erp_ac_ob_years',
135 ],
136 [
137 'type' => 'sectionend',
138 'id' => 'script_styling_options',
139 ],
140 ]; // End opening balance settings
141
142 $section = false === $section ? $fields['checkout'] : isset( $fields[ $section ] ) ? $fields[ $section ] : [];
143
144 return apply_filters( 'erp_ac_settings_section_fields_' . $this->id, $section );
145 }
146
147 /**
148 * Get sections fields
149 *
150 * @return array
151 */
152 public function get_settings() {
153 $fields = [
154 [
155 'title' => __( 'Accounting Settings', 'erp' ),
156 'type' => 'title',
157 'desc' => '',
158 'id' => 'general_options',
159 ],
160
161 [
162 'title' => __( 'Home Currency', 'erp' ),
163 'id' => 'base_currency',
164 'desc' => __( 'The base currency of the system.', 'erp' ),
165 'type' => 'select',
166 'options' => erp_get_currencies(),
167 ],
168
169 [
170 'type' => 'sectionend',
171 'id' => 'script_styling_options',
172 ],
173 ]; // End general settings
174
175 return apply_filters( 'erp_ac_settings_general', $fields );
176 }
177
178 /**
179 * Render Financial Years settings page
180 */
181 public function acct_opening_balance() {
182 global $wpdb;
183
184 $rows = $wpdb->get_results( "SELECT id, name, start_date, end_date FROM {$wpdb->prefix}erp_acct_financial_years", ARRAY_A );
185
186 require_once ERP_ACCOUNTING_VIEWS . '/settings/opening-balance.php';
187 }
188 }
189
190 return new Settings();
191