forked from nurigo-world/xe-module-nstore_digital
/
nstore_digital.admin.view.php
653 lines (559 loc) · 19.2 KB
/
nstore_digital.admin.view.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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
<?php
/**
* vi:set sw=4 ts=4 noexpandtab fileencoding=utf-8:
* @class nstore_digitalAdminView
* @author NURIGO(contact@nurigo.net)
* @brief nstore_digitalAdminView
*/
class nstore_digitalAdminView extends nstore_digital
{
function init()
{
// module_srl이 있으면 미리 체크하여 존재하는 모듈이면 module_info 세팅
$module_srl = Context::get('module_srl');
if(!$module_srl && $this->module_srl)
{
$module_srl = $this->module_srl;
Context::set('module_srl', $module_srl);
}
$oModuleModel = &getModel('module');
// module_srl이 넘어오면 해당 모듈의 정보를 미리 구해 놓음
if($module_srl)
{
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if(!$module_info)
{
Context::set('module_srl','');
$this->act = 'list';
} else {
ModuleModel::syncModuleToSite($module_info);
$this->module_info = $module_info;
Context::set('module_info',$module_info);
}
}
if($module_info && !in_array($module_info->module, array('nstore','nstore_digital','elearning')))
{
return $this->stop("msg_invalid_request");
}
// epay plugin list
$oEpayModel = &getModel('epay');
$modules = $oEpayModel->getEpayList();
Context::set('epay_modules', $modules);
// set template file
$tpl_path = $this->module_path.'tpl';
$this->setTemplatePath($tpl_path);
Context::set('tpl_path', $tpl_path);
// module이 cympusadmin일때 관리자 레이아웃으로
if(Context::get('module')=='cympusadmin')
{
$classfile = _XE_PATH_.'modules/cympusadmin/cympusadmin.class.php';
if(file_exists($classfile))
{
require_once($classfile);
cympusadmin::init();
}
}
}
/**
* @brief Contructor
**/
function dispNstore_digitalAdminDashboard()
{
$output = executeQueryArray('nstore_digital.getOrderStat', $args);
if(!$output->toBool()) return $output;
$list = $output->data;
if(!is_array($list)) $list = array();
$stat_arr = array();
$keys = array_keys($this->order_status);
foreach ($keys as $key) {
$stat_arr[$key] = 0;
}
foreach ($list as $key=>$val) {
$stat_arr[$val->order_status] = $val->count;
}
Context::set('order_status', $this->getOrderStatus());
Context::set('orderstat', $stat_arr);
// get module srls
$module_srls = array();
$output = executeQueryArray('nproduct.getModInstList', $args);
if(!$output->toBool())
{
return $output;
}
$modinst_list = $output->data;
if(!is_array($modinst_list))
{
$modinst_list = array();
}
foreach ($modinst_list as $modinst)
{
$module_srls[] = $modinst->module_srl;
}
// newest comment
$oCommentModel = &getModel('comment');
$columnList = array('comment_srl', 'module_srl', 'document_srl', 'content', 'nick_name', 'member_srl');
$args->module_srl = $module_srls;
$args->list_count = 20;
$comment_list = $oCommentModel->getNewestCommentList($args, $columnList);
if(!is_array($comment_list))
{
$comment_list = array();
}
foreach($comment_list AS $key=>$value)
{
$value->content = strip_tags($value->content);
}
Context::set('comment_list', $comment_list);
unset($args, $comment_list, $columnList);
// newest review
$review_list = array();
require_once(_XE_PATH_.'modules/store_review/store_review.item.php');
$args->module_srl = $module_srls;
$output = executeQueryArray('nstore_digital.getNewestReviewList', $args);
if(!is_array($output->data))
{
$output->data = array();
}
foreach ($output->data as $key=>$val)
{
if(!$val->review_srl)
{
continue;
}
$oReview = new store_reviewItem();
$oReview->setAttribute($val);
$oReview->storeItem = new nproductItem($oReview->get('item_srl'));
debugprint($oReview->storeItem);
$review_list[$key] = $oReview;
}
Context::set('review_list', $review_list);
$this->getNewsFromAgency();
$this->setTemplateFile('dashboard');
}
function dispNstore_digitalAdminOrderManagement()
{
$oNstore_coreModel = &getModel('nstore_digital');
if(!Context::get('status'))
{
Context::set('status','1');
}
$args->order_status = Context::get('status');
$args->page = Context::get('page');
if(Context::get('search_key'))
{
$search_key = Context::get('search_key');
$search_value = Context::get('search_value');
if($search_key == 'nick_name' && $search_value == '비회원')
{
$search_key = 'member_srl';
$search_value = 0;
}
$args->{$search_key} = $search_value;
}
$output = executeQueryArray('nstore_digital.getOrderListByStatus', $args);
if(!$output->toBool()) return $output;
$order_list = $output->data;
if(!is_array($order_list)) $order_list = array();
Context::set('list', $order_list);
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_navigation', $output->page_navigation);
Context::set('order_status', $this->getOrderStatus());
Context::set('delivery_inquiry_urls', $this->delivery_inquiry_urls);
$this->setTemplateFile('ordermanagement');
}
function dispNstore_digitalAdminIndividualOrderManagement()
{
$oNstore_coreModel = &getModel('nstore_digital');
$oEpayModel = &getModel('epay');
$config = $oNstore_coreModel->getModuleConfig();
/*
$order_srl = Context::get('order_srl');
$order_info = $oNstore_coreModel->getOrderInfo($order_srl);
$payment_info = $oEpayModel->getTransactionByOrderSrl($order_srl);
Context::set('payment_info',$payment_info);
Context::set('order_info', $order_info);
*/
if(!Context::get('status'))
{
Context::set('status','1');
}
if(Context::get('search_key'))
{
$search_key = Context::get('search_key');
$search_value = Context::get('search_value');
if($search_key == 'nick_name' && $search_value == '비회원')
{
$search_key = 'member_srl';
$search_value = 0;
}
$args->{$search_key} = $search_value;
}
$args->order_status = Context::get('status');
$args->page = Context::get('page');
$output = executeQueryArray('nstore_digital.getPurchasedItemsByStatus', $args);
if(!$output->toBool()) return $output;
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_navigation', $output->page_navigation);
$order_list = $output->data;
if(!is_array($order_list)) $order_list = array();
foreach($order_list as $k => $v)
{
if(!$v)continue;
$item = new nproductItem($v, $config->currency, $config->as_sign, $config->decimals);
debugprint($item);
if ($item->option_srl)
{
$item->price += ($item->option_price);
}
$v->item = $item;
$vars->order_srl = $v->order_srl;
$output = executeQuery('nstore_digital.getOrderInfo', $vars);
if(!$output->toBool()) return $output;
$v->order_info = $output->data;
unset($vars);
}
Context::set('order_list', $order_list);
Context::set('order_status', $this->getOrderStatus());
Context::set('delivery_inquiry_urls', $this->delivery_inquiry_urls);
$this->setTemplateFile('individual_ordermanagement');
}
function dispNstore_digitalAdminPeriodManagement()
{
$oNstore_coreModel = &getModel('nstore_digital');
$oNproduct_Model = &getModel('nproduct');
if(!Context::get('status'))
{
Context::set('status','1');
}
$args = new Object();
$args->order_status = Context::get('status');
$args->page = Context::get('page');
if(Context::get('search_key'))
{
$search_key = Context::get('search_key');
$search_value = Context::get('search_value');
if($search_key == 'nick_name' && $search_value == '비회원')
{
$search_key = 'member_srl';
$search_value = 0;
}
$args->{$search_key} = $search_value;
}
$output = executeQueryArray('nstore_digital.getPeriodListByStatus', $args);
if(!$output->toBool()) return $output;
$order_list = $output->data;
if(!is_array($order_list)) $order_list = array();
foreach($order_list as $k => $v)
{
if($v->item_srl)
{
$output = $oNproduct_Model->getItemInfo($v->item_srl);
$v->item_name = $output->item_name;
}
}
Context::set('list', $order_list);
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_navigation', $output->page_navigation);
Context::set('order_status', $this->getOrderStatus());
$this->setTemplateFile('periodmanagement');
}
function dispNstore_digitalAdminOrderDetail()
{
$oNstore_coreModel = &getModel('nstore_digital');
$oEpayModel = &getModel('epay');
$config = $oNstore_coreModel->getModuleConfig();
$order_srl = Context::get('order_srl');
$order_info = $oNstore_coreModel->getOrderInfo($order_srl);
$payment_info = $oEpayModel->getTransactionByOrderSrl($order_srl);
Context::set('payment_info',$payment_info);
Context::set('order_info', $order_info);
Context::set('order_status', $this->getOrderStatus());
Context::set('payment_method', $this->getPaymentMethods());
Context::set('delivery_inquiry_urls', $this->delivery_inquiry_urls);
$this->setTemplateFile('orderdetail');
}
function dispNstore_digitalAdminOrderExcelDownload()
{
$args->order_status = Context::get('status');
$output = executeQueryArray('nstore_digital.getOrderItemsByStatus', $args);
if(!$output->toBool())
{
return $output;
}
Context::set('list', $output->data);
$this->setLayoutPath('./common/tpl');
$this->setLayoutFile('default_layout');
$this->setTemplateFile('excel_download');
header("Content-Type: Application/octet-stream;");
header("Content-Disposition: attachment; filename=\"ORDERITEMS-" . date('Ymd') . ".xls\"");
}
function dispNstore_digitalAdminItemListExcelDownload()
{
$oNstore_coreModel = &getModel('nstore_digital');
$oStoreView = &getView('nstore_digital');
$oStoreView->getCategoryTree($this->module_info->module_srl);
$category = Context::get('category');
$list_count = Context::get('disp_numb');
$sort_index = Context::get('sort_index');
$order_type = Context::get('order_type');
if(!$list_count)
{
$list_count = 30;
}
if(!$sort_index)
{
$sort_index = "item_srl";
}
if(!$order_type)
{
$order_type = 'asc';
}
if($category)
{
$category_info = $oNstore_coreModel->getCategoryInfo($category);
$args->module_srl = Context::get('module_srl');
$args->node_route = $category_info->node_route . $category_info->node_id . '.';
$args->page = Context::get('page');
$args->list_count = $list_count;
$args->sort_index = $sort_index;
$args->order_type = $order_type;
$output = executeQueryArray('nstore_digital.getItemsByNodeRoute', $args);
if(!$output->toBool())
{
return $output;
}
$item_list = $output->data;
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_navigation', $output->page_navigation);
}
else
{
$args->module_srl = Context::get('module_srl');
$args->page = Context::get('page');
$args->list_count = $list_count;
$args->sort_index = $sort_index;
$args->order_type = $order_type;
$output = executeQueryArray('nstore_digital.getItemsByNodeRoute', $args);
if(!$output->toBool())
{
return $output;
}
$item_list = $output->data;
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_navigation', $output->page_navigation);
}
if($item_list)
{
foreach ($item_list as $key=>$val) {
$item_list[$key] = new nproductItem($val);
}
}
Context::set('list', $item_list);
$this->setLayoutPath('./common/tpl');
$this->setLayoutFile('default_layout');
$this->setTemplateFile('itemlist_exceldown');
header("Content-Type: Application/octet-stream;");
header("Content-Disposition: attachment; filename=\"ITEMLIST-" . date('Ymd') . ".xls\"");
}
function dispNstore_digitalAdminReceipt()
{
$args->order_srl = Context::get('order_srl');
$output = executeQuery('nstore_digital.getOrderInfo', $args);
if(!$output->toBool())
{
return $output;
}
$order_info = $output->data;
Context::set('order_info', $order_info);
$this->setTemplateFile('receipt');
$this->setLayoutPath('./common/tpl');
$this->setLayoutFile('default_layout');
}
function dispNstore_digitalAdminOrderSheet()
{
$oNstore_digitalModel = &getModel('nstore_digital');
$order_srl = Context::get('order_srl');
$order_info = $oNstore_digitalModel->getOrderInfo($order_srl);
Context::set('order_info', $order_info);
$this->setTemplateFile('ordersheet');
$this->setLayoutPath('./common/tpl');
$this->setLayoutFile('default_layout');
}
function dispNstore_digitalAdminModInstList()
{
$args->sort_index = "module_srl";
$args->page = Context::get('page');
$args->list_count = 20;
$args->page_count = 10;
$args->s_module_category_srl = Context::get('module_category_srl');
$output = executeQueryArray('nstore_digital.getModInstList', $args);
$list = $output->data;
Context::set('list', $list);
$oModuleModel = &getModel('module');
$module_category = $oModuleModel->getModuleCategories();
Context::set('module_category', $module_category);
$this->setTemplateFile('modinstlist');
}
function dispNstore_digitalAdminConfig()
{
$oNstore_coreModel = &getModel('nstore_digital');
$oModuleModel = &getModel('module');
$config = $oNstore_coreModel->getModuleConfig();
Context::set('config',$config);
// list of skins for member module
$skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list', $skin_list);
$mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins");
Context::set('mskin_list', $mskin_list);
// 레이아웃 목록을 구해옴
$oLayoutModel = &getModel('layout');
$layout_list = $oLayoutModel->getLayoutList();
Context::set('layout_list', $layout_list);
$mobile_layout_list = $oLayoutModel->getLayoutList(0,"M");
Context::set('mlayout_list', $mobile_layout_list);
// epay plugin list
$oEpayModel = &getModel('epay');
$modules = $oEpayModel->getEpayList();
Context::set('epay_modules', $modules);
$oNcartModel = &getModel('ncart');
if($oNcartModel)
{
$ncart_insts = $oNcartModel->getModInstList();
Context::set('ncart_insts', $ncart_insts);
}
$this->setTemplateFile('config');
}
function dispNstore_digitalAdminInsertModInst()
{
$oNstore_coreModel = &getModel('nstore_digital');
// 스킨 목록을 구해옴
$oModuleModel = &getModel('module');
$skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list',$skin_list);
$mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins");
Context::set('mskin_list', $mskin_list);
// 레이아웃 목록을 구해옴
$oLayoutModel = &getModel('layout');
$layout_list = $oLayoutModel->getLayoutList();
Context::set('layout_list', $layout_list);
$mobile_layout_list = $oLayoutModel->getLayoutList(0,"M");
Context::set('mlayout_list', $mobile_layout_list);
// epay plugin list
$oEpayModel = &getModel('epay');
$modules = $oEpayModel->getEpayList();
Context::set('epay_modules', $modules);
$oEditorModel = &getModel('editor');
$config = $oEditorModel->getEditorConfig(0);
// 에디터 옵션 변수를 미리 설정
$option->skin = $config->editor_skin;
$option->content_style = $config->content_style;
$option->content_font = $config->content_font;
$option->content_font_size = $config->content_font_size;
$option->colorset = $config->sel_editor_colorset;
$option->allow_fileupload = true;
$option->enable_default_component = true;
$option->enable_component = true;
$option->disable_html = false;
$option->height = 200;
$option->enable_autosave = false;
$option->primary_key_name = 'module_srl';
$option->content_key_name = 'delivery_info';
$editor = $oEditorModel->getEditor($this->module_info->module_srl, $option);
Context::set('editor', $editor);
$module_category = $oModuleModel->getModuleCategories();
Context::set('module_category', $module_category);
$this->setTemplateFile('insertmodinst');
}
function dispNstore_digitalAdminAdditionSetup()
{
// content는 다른 모듈에서 call by reference로 받아오기에 미리 변수 선언만 해 놓음
$content = '';
$oEditorView = &getView('editor');
$oEditorView->triggerDispEditorAdditionSetup($content);
Context::set('setup_content', $content);
}
function dispNstore_digitalAdminMailSetup()
{
// content는 다른 모듈에서 call by reference로 받아오기에 미리 변수 선언만 해 놓음
$content = '';
$status = Context::get('status');
if(!$status) $status = '1';
$oAutomailModel = &getModel('automail');
if($oAutomailModel) $oAutomailModel->getSetup('nstore_digital', $status, $content);
Context::set('setup_content', $content);
$order_status = $this->getOrderStatus();
unset($order_status[0]);
Context::set('order_status', $order_status);
$this->setTemplateFile('additionsetup');
}
/**
* @brief 스킨 정보 보여줌
**/
function dispNstore_digitalAdminSkinInfo()
{
// 공통 모듈 권한 설정 페이지 호출
$oModuleAdminModel = &getAdminModel('module');
$skin_content = $oModuleAdminModel->getModuleSkinHTML($this->module_info->module_srl);
Context::set('skin_content', $skin_content);
$this->setTemplateFile('skininfo');
}
/**
* @brief 스킨 정보 보여줌
**/
function dispNstore_digitalAdminMobileSkinInfo()
{
// 공통 모듈 권한 설정 페이지 호출
$oModuleAdminModel = &getAdminModel('module');
$skin_content = $oModuleAdminModel->getModuleMobileSkinHTML($this->module_info->module_srl);
Context::set('skin_content', $skin_content);
$this->setTemplateFile('skininfo');
}
function getNewsFromAgency()
{
//Retrieve recent news and set them into context
$newest_news_url = sprintf("http://www.xeshoppingmall.com/?module=newsagency&act=getNewsagencyArticle&inst=notice&top=6&loc=%s", _XE_LOCATION_);
$cache_file = sprintf("%sfiles/cache/nstore_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_);
if(!file_exists($cache_file) || filemtime($cache_file)+ 60*60 < time())
{
// Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing textmessageistration page
// Ensure to access the textmessageistration page even though news cannot be displayed
FileHandler::writeFile($cache_file,'');
FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL'=>getFullUrl('')));
}
if(file_exists($cache_file))
{
$oXml = new XmlParser();
$buff = $oXml->parse(FileHandler::readFile($cache_file));
$item = $buff->zbxe_news->item;
if($item)
{
if(!is_array($item))
{
$item = array($item);
}
foreach($item as $key => $val) {
$obj = null;
$obj->title = $val->body;
$obj->date = $val->attrs->date;
$obj->url = $val->attrs->url;
$news[] = $obj;
}
Context::set('news', $news);
}
Context::set('released_version', $buff->zbxe_news->attrs->released_version);
Context::set('download_link', $buff->zbxe_news->attrs->download_link);
}
}
}
/* End of file nstore_digital.admin.view.php */
/* Location: ./modules/nstore_digital/nstore_digital.admin.view.php */