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

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