-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdetails.php
308 lines (280 loc) · 15.9 KB
/
details.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* This is a store module for PyroCMS
*
* @author pyrocms-store Team - Jaap Jolman - Kevin Meier - Rudolph Arthur Hernandez - Gary Hussey
* @website http://www.odin-ict.nl/
* @package pyrocms-store
* @subpackage Store Module
**/
class Module_Store extends Module {
public $version = '0.1';
public function info()
{
return array(
'name' => array(
'en' => 'Online Store',
'nl' => 'Online Webwinkel',
'de' => 'Online Store'
),
'description' => array(
'en' => 'This is a PyroCMS Store module.',
'nl' => 'Dit is een webwinkel module voor PyroCMS',
'de' => 'Dies ist ein Online-Shop fur PyroCMS'
),
'frontend' => TRUE,
'backend' => TRUE,
'skip_xss' => TRUE,
'menu' => 'content',
'author' => 'Jaap Jolman - Kevin Meier - Rudolph Arthur Hernandez - Gary Hussey',
'roles' => array(
'admin_module'
),
'sections' => array(
'store' => array(
'name' => 'store_menu_store',
'uri' => 'admin/store'
),
'categories' => array(
'name' => 'store_menu_categories',
'uri' => 'admin/store/categories',
'shortcuts' => array(
array(
'name' => 'store_shortcut_add_category',
'uri' => 'admin/store/categories/add',
'class' => 'add'
),
),
),
'products' => array(
'name' => 'store_menu_products',
'uri' => 'admin/store/products',
'shortcuts' => array(
array(
'name' => 'store_shortcut_add_product',
'uri' => 'admin/store/products/add',
'class' => 'add'
),
),
),
),
);
}
public function install()
{
$this->db->query("
CREATE TABLE IF NOT EXISTS `core_stores` (
`store_id` INT NOT NULL AUTO_INCREMENT ,
`core_sites_id` INT(5) NOT NULL ,
PRIMARY KEY (`store_id`, `core_sites_id`) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_settings') . "` (
`settings_id` INT NOT NULL AUTO_INCREMENT ,
`slug` VARCHAR(255) NOT NULL ,
`type` VARCHAR(255) NOT NULL ,
`value` TEXT NOT NULL ,
`options` VARCHAR(255) NOT NULL ,
`tab` VARCHAR(255) NOT NULL ,
`is_required` ENUM('1','0') NOT NULL ,
`gui` ENUM('1','0') NOT NULL ,
`order` INT NOT NULL ,
PRIMARY KEY (`settings_id`) )
ENGINE = InnoDB;");
$this->db->query("INSERT INTO `core_stores` (store_id, core_sites_id) VALUES (null,(SELECT `id` FROM `core_sites` WHERE ref='" . $this->site_ref . "'));");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (NULL, 'store_id', 'text', LAST_INSERT_ID(), '', 'general', '1', '0', 0);");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'name', 'text', '', '', 'general', '1', '1', '1');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'email', 'text', '', '', 'general', '1', '1', '2');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'additional_emails', 'text', '', '', 'general', '1', '1', '3');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'currency', 'dropdown', '', '1=EUR|2=USD', 'general', '1', '1', '4');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'item_per_page', 'text', '', '', 'general', '1', '1', '5');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'show_with_tax', 'radio', '', '', 'general', '1', '1', '6');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'display_stock', 'radio', '', '', 'general', '1', '1', '7');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'allow_comments', 'radio', '', '', 'general', '1', '1', '8');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'new_order_mail_alert', 'radio', '', '', 'general', '1', '1', '9');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'active', 'radio', '', '', 'general', '1', '1', '10');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'is_default', 'radio', '', '', 'general', '1', '1', '11');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'paypal_enabled', 'radio', '0', '', 'payment-gateways', '1', '1', '12');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'paypal_account', 'text', '', '', 'payment-gateways', '1', '1', '13');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'paypal_developer_mode', 'radio', '1', '', 'payment-gateways', '1', '1', '14');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'authorize_enabled', 'radio', '0', '', 'payment-gateways', '1', '1', '15');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'authorize_account', 'text', '', '', 'payment-gateways', '1', '1', '16');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'authorize_secret', 'text', '', '', 'payment-gateways', '1', '1', '17');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'authorize_developer_mode', 'radio', '1', '', 'payment-gateways', '1', '1', '18');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'twoco_enabled', 'radio', '0', '', 'payment-gateways', '1', '1', '19');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'twoco_account', 'text', '', '', 'payment-gateways', '1', '1', '20');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'twoco_developer_mode', 'radio', '1', '', 'payment-gateways', '1', '1', '21');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'terms_and_conditions', 'wysiwyg|simple', '', '', 'extra', '1', '1', '22');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'privacy_policy', 'textarea', '', '', 'extra', '1', '1', '23');");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_settings') . "` (`settings_id`, `slug`, `type`, `value`, `options`, `tab`, `is_required`, `gui`, `order`) VALUES (null, 'delivery_information', 'textarea', '', '', 'extra', '1', '1', '24');");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_currency') . "` (
`currency_id` INT NOT NULL AUTO_INCREMENT ,
`currency_symbol` VARCHAR(45) NULL ,
`currency_name` VARCHAR(100) NULL ,
PRIMARY KEY (`currency_id`) )
ENGINE = InnoDB;");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_currency') . "` (currency_id, currency_symbol, currency_name) VALUES (null, '€', 'EUR') ");
$this->db->query("INSERT INTO `" . $this->db->dbprefix('store_currency') . "` (currency_id, currency_symbol, currency_name) VALUES (null, '$', 'USD') ");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_users_addresses') . "` (
`users_id` SMALLINT(5) UNSIGNED NOT NULL ,
`addresses_users_id` INT NOT NULL AUTO_INCREMENT ,
`firstname` VARCHAR(100) NULL ,
`lastname` VARCHAR(100) NULL ,
`email` VARCHAR(100) NULL ,
`telephone` VARCHAR(45) NULL ,
`newsletter` ENUM('1','0') NULL ,
`shipping` ENUM('1','0') NULL ,
`payment` ENUM('1','0') NULL ,
`address1` VARCHAR(100) NOT NULL ,
`address2` VARCHAR(100) NULL ,
`organisation` VARCHAR(100) NULL ,
`city` VARCHAR(100) NULL ,
`postal_code` VARCHAR(8) NULL ,
`country` VARCHAR(100) NULL ,
`state` VARCHAR(100) NULL ,
PRIMARY KEY (`addresses_users_id`, `users_id`) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_products') . "` (
`products_id` INT NOT NULL AUTO_INCREMENT ,
`categories_id` INT NOT NULL ,
`attributes_id` INT NOT NULL ,
`name` VARCHAR(100) NOT NULL ,
`slug` VARCHAR(100) NOT NULL ,
`meta_description` TEXT NULL ,
`meta_keywords` TEXT NULL ,
`html` LONGTEXT NULL ,
`price` FLOAT NULL ,
`stock` INT NULL ,
`limited` INT NULL ,
`limited_used` INT NULL ,
`discount` FLOAT NULL ,
`images_id` VARCHAR(50) NULL ,
`thumbnail_id` VARCHAR(50) NULL ,
`allow_comments` ENUM('1','0') NULL ,
PRIMARY KEY (`products_id`, `categories_id`) ,
UNIQUE INDEX `name_UNIQUE` (`name` ASC) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_categories') . "` (
`categories_id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(50) NOT NULL ,
`slug` VARCHAR(50) NOT NULL ,
`html` LONGTEXT NULL ,
`parent_id` INT NULL ,
`images_id` VARCHAR(50) NULL ,
`thumbnail_id` VARCHAR(50) NULL ,
PRIMARY KEY (`categories_id`) ,
UNIQUE INDEX `name_UNIQUE` (`name` ASC) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_attributes') . "` (
`attributes_id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(50) NOT NULL ,
`html` LONGTEXT NULL ,
PRIMARY KEY (`attributes_id`) ,
UNIQUE INDEX `name_UNIQUE` (`name` ASC) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_tags') . "` (
`tags_id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(50) NULL ,
PRIMARY KEY (`tags_id`) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_products_has_tags') . "` (
`products_id` INT NOT NULL ,
`categories_id` INT NOT NULL ,
`tags_id` INT NOT NULL ,
PRIMARY KEY (`products_id`, `categories_id`, `tags_id`) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_order_addresses') . "` (
`addresses_orders_id` INT NOT NULL AUTO_INCREMENT ,
`firstname` VARCHAR(100) NULL ,
`lastname` VARCHAR(100) NULL ,
`email` VARCHAR(100) NULL ,
`telephone` VARCHAR(45) NULL ,
`newsletter` ENUM('1','0') NULL ,
`shipping` ENUM('1','0') NULL ,
`payment` ENUM('1','0') NULL ,
`address1` VARCHAR(255) NOT NULL ,
`address2` VARCHAR(255) NULL ,
`organisation` VARCHAR(100) NULL ,
`city` VARCHAR(100) NULL ,
`postal_code` VARCHAR(8) NULL ,
`country` VARCHAR(100) NULL ,
`state` VARCHAR(100) NULL ,
PRIMARY KEY (`addresses_orders_id`) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_orders') . "` (
`orders_id` INT NOT NULL AUTO_INCREMENT ,
`users_id` SMALLINT(5) UNSIGNED NOT NULL ,
`invoice_nr` VARCHAR(80) NULL ,
`ip_address` VARCHAR(20) NULL ,
`telefone` VARCHAR(45) NULL ,
`status` INT NULL ,
`comments` LONGTEXT NULL ,
`date_added` DATETIME NULL ,
`date_modified` DATETIME NULL ,
`payment_address` INT NOT NULL ,
`payment_method` VARCHAR(45) NULL ,
`shipping_address` INT NOT NULL ,
`shipping_method` VARCHAR(45) NULL ,
`tax` FLOAT NULL ,
`shipping_cost` FLOAT NULL ,
PRIMARY KEY (`orders_id`, `users_id`, `payment_address`, `shipping_address`) )
ENGINE = InnoDB;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('store_orders_has_store_products') . "` (
`orders_id` INT NOT NULL ,
`users_id` SMALLINT(5) UNSIGNED NOT NULL ,
`products_id` INT NOT NULL ,
`categories_id` INT NOT NULL ,
`number` INT NULL ,
PRIMARY KEY (`orders_id`, `users_id`, `products_id`, `categories_id`) )
ENGINE = InnoDB;");
if(is_dir('uploads/store') OR @mkdir('uploads/store',0777,TRUE))
{
// make upload folders for admin images and stuff
if ( (is_dir('uploads/store/products') OR @mkdir('uploads/store/products',0777,TRUE) ) &&
(is_dir('uploads/store/categories') OR @mkdir('uploads/store/categories',0777,TRUE) )) {
return TRUE;
}
}
}
public function uninstall()
{
$this->db->query("DELETE FROM `core_stores` WHERE store_id=(SELECT `value` FROM `" . $this->db->dbprefix('store_settings') . "` WHERE slug='store_id');");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_settings') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_currency') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_users_addresses') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_categories') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_attributes') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_products') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_tags') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_products_has_tags') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_orders') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_order_addresses') . "`;");
$this->db->query("DROP TABLE IF EXISTS `" . $this->db->dbprefix('store_orders_has_store_products') . "`;");
$this->db->delete('settings', array('module' => 'store'));
{
return TRUE;
}
}
public function upgrade($old_version)
{
// Your Upgrade Logic
return TRUE;
}
public function help()
{
// Return a string containing help info
// You could include a file and return it here.
return "No documentation has been added for this module.<br />Contact the module developer for assistance.";
}
}
/* End of file details.php */