source: branches/dev/html/admin/basis/mail.php @ 13510

Revision 13510, 4.6 KB checked in by nakanishi, 17 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../require.php");
8
9class LC_Page {
10    var $arrSession;
11    var $tpl_mode;
12    function LC_Page() {
13        $this->tpl_mainpage = 'basis/mail_list.tpl';
14        $this->tpl_subnavi = 'basis/subnavi.tpl';
15        $this->tpl_mainno = 'basis';
16        $this->tpl_subno = 'mail';
17        $this->tpl_subtitle = '¥á¡¼¥ëÀßÄê';
18    }
19}
20
21$conn = new SC_DBConn();
22$objQuery = new SC_Query();
23$objPage = new LC_Page();
24$objView = new SC_AdminView();
25$objSess = new SC_Session();
26
27//ǧ¾Ú²ÄÈݤÎȽÄê
28sfIsSuccess($objSess);
29
30//------------------------------------------------------------------
31
32if (count($objPage->arrErr) == 0) {
33       
34        //-- ¸¡º÷¥Ç¡¼¥¿¼èÆÀ
35        $mail_list = $objQuery->getall("dtb_template");
36        print_r($mail_list);exit;
37       
38        // ɽ¼¨·ï¿ôÀßÄê
39        $page_rows = $objPage->arrForm['page_rows'];
40        if(is_numeric($page_rows)) {   
41            $page_max = $page_rows;
42        } else {
43            $page_max = SEARCH_PMAX;
44        }
45       
46        if ($objPage->arrForm['search_pageno'] == 0){
47            $objPage->arrForm['search_pageno'] = 1;
48        }
49       
50        $offset = $page_max * ($objPage->arrForm['search_pageno'] - 1);
51        $objSelect->setLimitOffset($page_max, $offset);     
52       
53        if ($_POST["mode"] == 'csv') {
54            $searchSql = $objSelect->getListCSV($arrColumnCSV);
55        }else{
56            $searchSql = $objSelect->getList();
57        }
58       
59        $objPage->search_data = $objQuery->conn->getAll($searchSql, $objSelect->arrVal);
60
61        // ¹Ô¿ô¤Î¼èÆÀ
62            $linemax = $objQuery->conn->getOne( $objSelect->getListCount(), $objSelect->arrVal);
63            $objPage->tpl_linemax = $linemax;               // ²¿·ï¤¬³ºÅö¤·¤Þ¤·¤¿¡£É½¼¨ÍÑ
64
65            // ¥Ú¡¼¥¸Á÷¤ê¤Î¼èÆÀ
66            $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnCustomerPage", NAVI_PMAX);
67            $startno = $objNavi->start_row;
68            $objPage->arrPagenavi = $objNavi->arrPagenavi;     
69        }
70
71
72//-----------------------------------------------------------------
73
74
75
76$objPage->arrMailTEMPLATE = $arrMAILTEMPLATE;
77
78if ( $_POST['mode'] == 'id_set'){
79    // ¥Æ¥ó¥×¥ì¡¼¥È¥×¥ë¥À¥¦¥óÊѹ¹»þ
80   
81    if ( sfCheckNumLength( $_POST['template_id']) ){
82        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
83        $result = $conn->getAll($sql, array($_POST['template_id']) );
84        if ( $result ){
85            $objPage->arrForm = $result[0];
86        } else {
87            $objPage->arrForm['template_id'] = $_POST['template_id'];
88        }
89    }
90   
91} elseif ( $_POST['mode'] == 'regist' && sfCheckNumLength( $_POST['template_id']) ){
92
93    // POST¥Ç¡¼¥¿¤Î°ú¤­·Ñ¤®
94    $objPage->arrForm = lfConvertParam($_POST);
95    $objPage->arrErr = fnErrorCheck($objPage->arrForm);
96   
97    if ( $objPage->arrErr ){
98        // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
99        $objPage->tpl_msg = "¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿";
100       
101    } else {
102        // Àµ¾ï
103        lfRegist($conn, $objPage->arrForm);
104       
105        // ´°Î»¥á¥Ã¥»¡¼¥¸
106        $objPage->tpl_onload = "window.alert('¥á¡¼¥ëÀßÄ꤬´°Î»¤·¤Þ¤·¤¿¡£¥Æ¥ó¥×¥ì¡¼¥È¤òÁªÂò¤·¤ÆÆâÍƤò¤´³Îǧ¤¯¤À¤µ¤¤¡£');";
107        unset($objPage->arrForm);
108    }
109}
110
111$objView->assignobj($objPage);
112$objView->display(MAIN_FRAME);
113
114//-----------------------------------------------------------------------------------------------------------------------------------
115
116function lfRegist( $conn, $data ){
117   
118    $data['creator_id'] = $_SESSION['member_id'];
119   
120    $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
121    $result = $conn->getAll($sql, array($_POST['template_id']) );
122    if ( $result ){
123        $sql_where = "template_id = ". addslashes($_POST['template_id']);
124        $conn->query("UPDATE dtb_mailtemplate SET template_id = ?, subject = ?,header = ?, footer = ?,creator_id = ?, update_date = now() WHERE ".$sql_where, $data);
125    }else{
126        $conn->query("INSERT INTO dtb_mailtemplate (template_id,subject,header,footer,creator_id,update_date,create_date) values ( ?,?,?,?,?,now(),now() )", $data);
127    }
128
129}
130
131
132function lfConvertParam($array) {
133   
134    $new_array["template_id"] = $array["template_id"];
135    $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV");
136    $new_array["header"] = mb_convert_kana($array["header"] ,"KV");
137    $new_array["footer"] = mb_convert_kana($array["footer"] ,"KV");
138   
139    return $new_array;
140}
141
142/* ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯ */
143function fnErrorCheck($array) {
144   
145    $objErr = new SC_CheckError($array);
146   
147    $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_id'), array("EXIST_CHECK"));
148    $objErr->doFunc(array("¥á¡¼¥ë¥¿¥¤¥È¥ë",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
149    $objErr->doFunc(array("¥Ø¥Ã¥À¡¼",'header',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
150    $objErr->doFunc(array("¥Õ¥Ã¥¿¡¼",'footer',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
151
152    return $objErr->arrErr;
153}
154
155?>
Note: See TracBrowser for help on using the repository browser.