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

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