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

Revision 13514, 4.7 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        $sql = "SELECT * FROM dtb_templates";
36        $mail_list = $objQuery->query($sql);
37        print_r($mail_list["result"]);exit;
38       
39        // ɽ¼¨·ï¿ôÀßÄê
40        $page_rows = $objPage->arrForm['page_rows'];
41        if(is_numeric($page_rows)) {   
42            $page_max = $page_rows;
43        } else {
44            $page_max = SEARCH_PMAX;
45        }
46       
47        if ($objPage->arrForm['search_pageno'] == 0){
48            $objPage->arrForm['search_pageno'] = 1;
49        }
50       
51        $offset = $page_max * ($objPage->arrForm['search_pageno'] - 1);
52        $objSelect->setLimitOffset($page_max, $offset);     
53       
54        if ($_POST["mode"] == 'csv') {
55            $searchSql = $objSelect->getListCSV($arrColumnCSV);
56        }else{
57            $searchSql = $objSelect->getList();
58        }
59       
60        $objPage->search_data = $objQuery->conn->getAll($searchSql, $objSelect->arrVal);
61
62        // ¹Ô¿ô¤Î¼èÆÀ
63            $linemax = $objQuery->conn->getOne( $objSelect->getListCount(), $objSelect->arrVal);
64            $objPage->tpl_linemax = $linemax;               // ²¿·ï¤¬³ºÅö¤·¤Þ¤·¤¿¡£É½¼¨ÍÑ
65
66            // ¥Ú¡¼¥¸Á÷¤ê¤Î¼èÆÀ
67            $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnCustomerPage", NAVI_PMAX);
68            $startno = $objNavi->start_row;
69            $objPage->arrPagenavi = $objNavi->arrPagenavi;     
70        }
71
72
73//-----------------------------------------------------------------
74
75
76
77$objPage->arrMailTEMPLATE = $arrMAILTEMPLATE;
78
79if ( $_POST['mode'] == 'id_set'){
80    // ¥Æ¥ó¥×¥ì¡¼¥È¥×¥ë¥À¥¦¥óÊѹ¹»þ
81   
82    if ( sfCheckNumLength( $_POST['template_id']) ){
83        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
84        $result = $conn->getAll($sql, array($_POST['template_id']) );
85        if ( $result ){
86            $objPage->arrForm = $result[0];
87        } else {
88            $objPage->arrForm['template_id'] = $_POST['template_id'];
89        }
90    }
91   
92} elseif ( $_POST['mode'] == 'regist' && sfCheckNumLength( $_POST['template_id']) ){
93
94    // POST¥Ç¡¼¥¿¤Î°ú¤­·Ñ¤®
95    $objPage->arrForm = lfConvertParam($_POST);
96    $objPage->arrErr = fnErrorCheck($objPage->arrForm);
97   
98    if ( $objPage->arrErr ){
99        // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
100        $objPage->tpl_msg = "¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿";
101       
102    } else {
103        // Àµ¾ï
104        lfRegist($conn, $objPage->arrForm);
105       
106        // ´°Î»¥á¥Ã¥»¡¼¥¸
107        $objPage->tpl_onload = "window.alert('¥á¡¼¥ëÀßÄ꤬´°Î»¤·¤Þ¤·¤¿¡£¥Æ¥ó¥×¥ì¡¼¥È¤òÁªÂò¤·¤ÆÆâÍƤò¤´³Îǧ¤¯¤À¤µ¤¤¡£');";
108        unset($objPage->arrForm);
109    }
110}
111
112$objView->assignobj($objPage);
113$objView->display(MAIN_FRAME);
114
115//-----------------------------------------------------------------------------------------------------------------------------------
116
117function lfRegist( $conn, $data ){
118   
119    $data['creator_id'] = $_SESSION['member_id'];
120   
121    $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
122    $result = $conn->getAll($sql, array($_POST['template_id']) );
123    if ( $result ){
124        $sql_where = "template_id = ". addslashes($_POST['template_id']);
125        $conn->query("UPDATE dtb_mailtemplate SET template_id = ?, subject = ?,header = ?, footer = ?,creator_id = ?, update_date = now() WHERE ".$sql_where, $data);
126    }else{
127        $conn->query("INSERT INTO dtb_mailtemplate (template_id,subject,header,footer,creator_id,update_date,create_date) values ( ?,?,?,?,?,now(),now() )", $data);
128    }
129
130}
131
132
133function lfConvertParam($array) {
134   
135    $new_array["template_id"] = $array["template_id"];
136    $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV");
137    $new_array["header"] = mb_convert_kana($array["header"] ,"KV");
138    $new_array["footer"] = mb_convert_kana($array["footer"] ,"KV");
139   
140    return $new_array;
141}
142
143/* ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯ */
144function fnErrorCheck($array) {
145   
146    $objErr = new SC_CheckError($array);
147   
148    $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_id'), array("EXIST_CHECK"));
149    $objErr->doFunc(array("¥á¡¼¥ë¥¿¥¤¥È¥ë",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
150    $objErr->doFunc(array("¥Ø¥Ã¥À¡¼",'header',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
151    $objErr->doFunc(array("¥Õ¥Ã¥¿¡¼",'footer',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
152
153    return $objErr->arrErr;
154}
155
156?>
Note: See TracBrowser for help on using the repository browser.