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

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