source: temp/trunk/html/admin/mail/index.php @ 2721

Revision 2721, 11.3 KB checked in by kakinaka, 20 years ago (diff)

blank

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3require_once("../require.php");
4require_once("./inc_mailmagazine.php");
5
6class LC_Page {
7    var $arrSession;
8    var $arrHtmlmail;
9    var $arrNowDate;
10    function LC_Page() {
11        $this->tpl_mainpage = 'mail/index.tpl';
12        $this->tpl_mainno = 'mail';
13        $this->tpl_subnavi = 'mail/subnavi.tpl';
14        $this->tpl_subno = "index";
15        $this->tpl_pager = ROOT_DIR . 'data/Smarty/templates/admin/pager.tpl';
16        $this->tpl_subtitle = 'ÇÛ¿®ÆâÍÆÀßÄê';
17       
18        global $arrPref;
19        $this->arrPref = $arrPref;
20        global $arrJob;
21        $arrJob["ÉÔÌÀ"] = "ÉÔÌÀ";
22        $this->arrJob = $arrJob;
23        global $arrSex;     
24        $this->arrSex = $arrSex;
25        global $arrPageRows;
26        $this->arrPageRows = $arrPageRows;
27        // ¥Ú¡¼¥¸¥Ê¥ÓÍÑ
28        $this->tpl_pageno = $_POST['search_pageno'];
29        global $arrMAILMAGATYPE;
30        $this->arrMAILMAGATYPE = $arrMAILMAGATYPE;
31        $this->arrHtmlmail[''] = "¤¹¤Ù¤Æ";
32        $this->arrHtmlmail[1] = $arrMAILMAGATYPE[1];
33        $this->arrHtmlmail[2] = $arrMAILMAGATYPE[2];
34        global $arrCustomerType;
35        $this->arrCustomerType = $arrCustomerType;
36    }
37}
38
39class LC_HTMLtemplate {
40    var $list_data;
41}
42
43//---- ¥Ú¡¼¥¸½é´üÀßÄê
44$conn = new SC_DBConn();
45$objPage = new LC_Page();
46$objView = new SC_AdminView();
47$objDate = new SC_Date();
48$objPage->objDate = $objDate;
49$objPage->arrTemplate = getTemplateList($conn);
50
51$objSess = new SC_Session();
52
53// ǧ¾Ú²ÄÈݤÎȽÄê
54sfIsSuccess($objSess);
55
56/*
57    query:ÇÛ¿®ÍúÎò¡Ö³Îǧ¡×
58*/
59if ($_GET["mode"] == "query" && sfCheckNumLength($_GET["send_id"])) {
60    // Á÷¿®ÍúÎò¤è¤ê¡¢Á÷¿®¾ò·ï³Îǧ²èÌÌ
61    $sql = "SELECT search_data FROM dtb_send_history WHERE send_id = ?";
62    $result = $conn->getOne($sql, array($_GET["send_id"]));
63    $tpl_path = "mail/query.tpl";
64       
65    $list_data = unserialize($result);
66   
67    // À­Ê̤ÎÊÑ´¹
68    if (count($list_data['sex']) > 0) {
69        foreach($list_data['sex'] as $key => $val){
70            $list_data['sex'][$key] = $objPage->arrSex[$val];
71            $sex_disp .= $list_data['sex'][$key] . " ";
72        }
73        $list_data['sex_disp'] = $sex_disp;
74    }
75   
76    // ¿¦¶È¤ÎÊÑ´¹
77    if (count($list_data['job']) > 0) {
78        foreach($list_data['job'] as $key => $val){
79            $list_data['job'][$key] = $objPage->arrJob[$val];
80            $job_disp .= $list_data['job'][$key] . " ";
81        }
82        $list_data['job_disp'] = $job_disp;
83    }
84   
85    // ¥«¥Æ¥´¥êÊÑ´¹
86    $list_data['category_name'] = $objPage->arrCatList[$list_data['category_id'];
87   
88    $objPage->list_data = $list_data;
89    sfprintr($objPage->list_data);
90   
91    $objView->assignobj($objPage);
92    $objView->display($tpl_path);
93    exit;
94}
95
96if($_POST['mode'] == 'delete') {
97    $objQuery = new SC_Query();
98    $objQuery->delete("dtb_customer_mail", "email = ?", array($_POST['result_email']));
99}
100
101switch($_POST['mode']) {
102/*
103    search:¡Ö¸¡º÷¡×¥Ü¥¿¥ó
104    back:¸¡º÷·ë²Ì²èÌÌ¡ÖÌá¤ë¡×¥Ü¥¿¥ó
105*/
106case 'delete':
107case 'search':
108case 'back':
109    //-- ÆþÎÏÃÍ¥³¥ó¥Ð¡¼¥È
110    $objPage->list_data = lfConvertParam($_POST, $arrSearchColumn);
111   
112    //-- ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯
113    $objPage->arrErr = lfErrorCheck($objPage->list_data);
114
115    //-- ¸¡º÷³«»Ï
116    if (!is_array($objPage->arrErr)) {
117        $objPage->list_data['name'] = sfManualEscape($objPage->list_data['name']);
118        // hiddenÍ×ÁǺîÀ®
119        $objPage->arrHidden = lfGetHidden($objPage->list_data);
120
121        //-- ¸¡º÷¥Ç¡¼¥¿¼èÆÀ
122        $objSelect = new SC_CustomerList($objPage->list_data, "magazine");
123
124        // À¸À®¤µ¤ì¤¿WHEREʸ¤ò¼èÆÀ¤¹¤ë     
125        list($where, $arrval) = $objSelect->getWhere();
126        // ¡ÖWHERE¡×Éôʬ¤òºï½ü¤¹¤ë¡£
127        $where = ereg_replace("^WHERE", "", $where);
128
129        // ¸¡º÷·ë²Ì¤Î¼èÆÀ
130        $objQuery = new SC_Query();
131        $from = "dtb_customer_mail LEFT OUTER JOIN dtb_customer USING(email)";
132
133        // ¹Ô¿ô¤Î¼èÆÀ
134        $linemax = $objQuery->count($from, $where, $arrval);
135        $objPage->tpl_linemax = $linemax;               // ²¿·ï¤¬³ºÅö¤·¤Þ¤·¤¿¡£É½¼¨ÍÑ
136       
137        // ¥Ú¡¼¥¸Á÷¤ê¤Î¼èÆÀ
138        $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, SEARCH_PMAX, "fnResultPageNavi", NAVI_PMAX);
139        $objPage->arrPagenavi = $objNavi->arrPagenavi; 
140        $startno = $objNavi->start_row;
141
142        // ¼èÆÀÈϰϤλØÄê(³«»Ï¹ÔÈֹ桢¹Ô¿ô¤Î¥»¥Ã¥È)
143        $objQuery->setlimitoffset(SEARCH_PMAX, $startno);
144        // ɽ¼¨½ç½ø
145        $objQuery->setorder("customer_id DESC");
146        // ¸¡º÷·ë²Ì¤Î¼èÆÀ
147        $col = "customer_id,name01,name02,kana01,kana02,sex,email,tel01,tel02,tel03,pref,mail_flag";
148        $objPage->arrResults = $objQuery->select($col, $from, $where, $arrval);
149
150        //¸½ºß»þ¹ï¤Î¼èÆÀ
151        $objPage->arrNowDate = lfGetNowDate();
152    }
153    break;
154/*
155    input:¸¡º÷·ë²Ì²èÌÌ¡ÖÇÛ¿®ÆâÍÆÀßÄê¡×¥Ü¥¿¥ó
156*/
157case 'input':
158    //-- ÆþÎÏÃÍ¥³¥ó¥Ð¡¼¥È
159    $objPage->list_data = lfConvertParam($_POST, $arrSearchColumn);
160    //-- ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯
161    $objPage->arrErr = lfErrorCheck($objPage->list_data);
162    //-- ¥¨¥é¡¼¤Ê¤·
163    if (!is_array($objPage->arrErr)) {
164        //-- ¸½ºß»þ¹ï¤Î¼èÆÀ
165        $objPage->arrNowDate = lfGetNowDate();
166        $objPage->arrHidden = lfGetHidden($objPage->list_data); // hiddenÍ×ÁǺîÀ®
167        $objPage->tpl_mainpage = 'mail/input.tpl';
168    }
169    break;
170/*
171    template:¥Æ¥ó¥×¥ì¡¼¥ÈÁªÂò
172*/
173case 'template':
174    //-- ÆþÎÏÃÍ¥³¥ó¥Ð¡¼¥È
175    $objPage->list_data = lfConvertParam($_POST, $arrSearchColumn);
176   
177    //-- »þ¹ïÀßÄê¤Î¼èÆÀ
178    $objPage->arrNowDate['year'] = $_POST['send_year'];
179    $objPage->arrNowDate['month'] = $_POST['send_month'];
180    $objPage->arrNowDate['day'] = $_POST['send_day'];
181    $objPage->arrNowDate['hour'] = $_POST['send_hour'];
182    $objPage->arrNowDate['minutes'] = $_POST['send_minutes'];
183   
184    //-- ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯
185    $objPage->arrErr = lfErrorCheck($objPage->list_data);
186
187    //-- ¸¡º÷³«»Ï
188    if ( ! is_array($objPage->arrErr)) {
189        $objPage->list_data['name'] = sfManualEscape($objPage->list_data['name']);
190        $objPage->arrHidden = lfGetHidden($objPage->list_data); // hiddenÍ×ÁǺîÀ®
191   
192        $objPage->tpl_mainpage = 'mail/input.tpl';
193        $template_data = getTemplateData($conn, $_POST['template_id']);
194        if ( $template_data ){
195            foreach( $template_data as $key=>$val ){
196                $objPage->list_data[$key] = $val;
197            }
198        }
199
200        //-- HTML¥Æ¥ó¥×¥ì¡¼¥È¤ò»ÈÍѤ¹¤ë¾ì¹ç¤Ï¡¢HTML¥½¡¼¥¹¤òÀ¸À®¤·¤ÆBODY¤ØÁÞÆþ
201        if ( $objPage->list_data["mail_method"] == 3) {
202            $objTemplate = new LC_HTMLtemplate;
203            $objTemplate->list_data = lfGetHtmlTemplateData($_POST['template_id']);
204            $objSiteInfo = new SC_SiteInfo();
205            $objTemplate->arrInfo = $objSiteInfo->data;
206            //¥á¡¼¥ëôÅö¼Ì¿¿¤Îɽ¼¨
207            $objUpFile = new SC_UploadFile(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
208            $objUpFile->addFile("¥á¡¼¥ëôÅö¼Ì¿¿", 'charge_image', array('jpg'), IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
209            $objUpFile->setDBFileList($objTemplate->list_data);
210            $objTemplate->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
211            $objMakeTemplate = new SC_AdminView();
212            $objMakeTemplate->assignobj($objTemplate);     
213            $objPage->list_data["body"] = $objMakeTemplate->fetch("mail/html_template.tpl");
214        }
215    }
216    break;
217/*
218    regist_confirm:¡ÖÆþÎÏÆâÍÆ¤ò³Îǧ¡×
219    regist_back:¡Ö¥Æ¥ó¥×¥ì¡¼¥ÈÀßÄê²èÌ̤ØÌá¤ë¡×
220    regist_complete:¡ÖÅÐÏ¿¡×
221*/ 
222case 'regist_confirm':
223case 'regist_back':
224case 'regist_complete':
225    //-- ÆþÎÏÃÍ¥³¥ó¥Ð¡¼¥È
226    $arrCheckColumn = array_merge( $arrSearchColumn, $arrRegistColumn );
227    $objPage->list_data = lfConvertParam($_POST, $arrCheckColumn);
228   
229    //¸½ºß»þ¹ï¤Î¼èÆÀ
230    $objPage->arrNowDate = lfGetNowDate();
231
232    //-- ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯
233    $objPage->arrErr = lfErrorCheck($objPage->list_data, 1);
234    $objPage->tpl_mainpage = 'mail/input.tpl';
235    $objPage->arrHidden = lfGetHidden($objPage->list_data); // hiddenÍ×ÁǺîÀ®
236   
237    //-- ¸¡º÷³«»Ï
238    if ( ! is_array($objPage->arrErr)) {
239            $objPage->list_data['name'] = sfManualEscape($objPage->list_data['name']);
240        if ( $_POST['mode'] == 'regist_confirm'){
241            $objPage->tpl_mainpage = 'mail/input_confirm.tpl';
242        } else if( $_POST['mode'] == 'regist_complete' ){
243            lfRegistData($objPage->list_data);
244            header("Location: /admin/mail/sendmail.php?mode=now");
245            exit;           
246        }
247    }
248    break;
249default:
250    break;
251}
252
253// ÇÛ¿®»þ´Ö¤Îǯ¤ò¡¢¡Ö¸½ºßǯ¢·¸½ºßǯ¡Ü£±¡×¤ÎÈϰϤËÀßÄê
254for ($year=date("Y"); $year<=date("Y") + 1;$year++){
255    $arrYear[$year] = $year;
256}
257$objPage->arrYear = $arrYear;
258
259$objPage->arrCustomerOrderId = lfGetCustomerOrderId($_POST['buy_product_code']);
260
261$objPage->arrCatList = sfGetCategoryList();
262
263//----¡¡¥Ú¡¼¥¸É½¼¨
264$objView->assignobj($objPage);
265$objView->display(MAIN_FRAME);
266
267//-------------------------------------------------------------------------------------------------------------------------------
268
269// ¾¦ÉÊ¥³¡¼¥É¤Ç¸¡º÷¤µ¤ì¤¿¾ì¹ç¤Ë¥Ò¥Ã¥È¤·¤¿¼õÃíÈÖ¹æ¤ò¼èÆÀ¤¹¤ë¡£
270function lfGetCustomerOrderId($keyword) {
271    if($keyword != "") {
272        $col = "customer_id, order_id";
273        $from = "dtb_order LEFT JOIN dtb_order_detail USING(order_id)";
274        $where = "product_code LIKE ? AND delete = 0";
275        $val = sfManualEscape($keyword);
276        $arrVal[] = "%$val%";
277        $objQuery = new SC_Query();
278        $objQuery->setgroupby("customer_id, order_id");
279        $arrRet = $objQuery->select($col, $from, $where, $arrVal);
280        $arrCustomerOrderId = sfArrKeyValues($arrRet, "customer_id", "order_id");
281    }
282    return $arrCustomerOrderId;
283}
284
285function lfMakeCsvData( $send_id ){
286       
287    global $conn;
288
289    $arrTitle  = array(  'name01','email');
290               
291    $sql = "SELECT name01,email FROM dtb_send_customer WHERE send_id = ? ORDER BY email";
292    $result = $conn->getAll($sql, array($send_id) );
293   
294    if ( $result ){
295        $return = lfGetCSVData( $result, $arrTitle);
296    }
297    return $return;
298}
299
300//---- CSV½ÐÎÏÍѥǡ¼¥¿¼èÆÀ
301function lfGetCSVData( $array, $arrayIndex){   
302   
303    for ($i=0; $i<count($array); $i++){
304       
305        for ($j=0; $j<count($array[$i]); $j++ ){
306            if ( $j > 0 ) $return .= ",";
307            $return .= "\"";           
308            if ( $arrayIndex ){
309                $return .= mb_ereg_replace("<","¡ã",mb_ereg_replace( "\"","\"\"",$array[$i][$arrayIndex[$j]] )) ."\""; 
310            } else {
311                $return .= mb_ereg_replace("<","¡ã",mb_ereg_replace( "\"","\"\"",$array[$i][$j] )) ."\"";
312            }
313        }
314        $return .= "\n";           
315    }
316    return $return;
317}
318
319//¸½ºß»þ¹ï¤Î¼èÆÀ¡ÊÇÛ¿®»þ´Ö¥Ç¥Õ¥©¥ë¥ÈÃÍ¡Ë
320function lfGetNowDate(){
321    $nowdate = date("Y/n/j/G/i");
322    list($year, $month, $day, $hour, $minute) = split("[/]", $nowdate);
323    $arrNowDate = array( 'year' => $year, 'month' => $month, 'day' => $day, 'hour' => $hour, 'minutes' => $minute);
324    foreach ($arrNowDate as $key => $val){
325        switch ($key){
326            case 'minutes':
327            $val = ereg_replace('^[0]','', $val);
328            if ($val < 30){
329            $list_date[$key] = '30';
330            }else{
331            $list_date[$key] = '00';
332            }
333            break;
334            case 'year':
335            case 'month':
336            case 'day':
337            $list_date[$key] = $val;
338            break;
339        }
340    }
341        if ($arrNowDate['minutes'] < 30){
342            $list_date['hour'] = $hour;
343        }else{
344            $list_date['hour'] = $hour + 1;
345        }
346    return $list_date;
347}
348
349// ÇÛ¿®ÆâÍÆ¤ÈÇÛ¿®¥ê¥¹¥È¤ò½ñ¤­¹þ¤à
350function lfRegistData($arrData){
351   
352    global $conn;
353    global $arrSearchColumn;
354       
355    $objSelect = new SC_CustomerList( lfConvertParam($arrData, $arrSearchColumn), "magazine" );
356    $search_data = $conn->getAll($objSelect->getListMailMagazine(), $objSelect->arrVal);
357    $dataCnt = count($search_data);
358
359    $dtb_send_history = array();
360    $dtb_send_history["send_id"] = $conn->getOne("SELECT NEXTVAL('dtb_send_history_send_id_seq')");
361    $dtb_send_history["mail_method"] = $arrData['mail_method'];
362    $dtb_send_history["subject"] = $arrData['subject'];
363    $dtb_send_history["body"] = $arrData['body'];
364    $dtb_send_history["start_date"] = "now()";
365    $dtb_send_history["creator_id"] = $_SESSION['member_id'];
366    $dtb_send_history["send_count"] = $dataCnt;
367    $arrData['body'] = "";
368    $dtb_send_history["search_data"] = serialize($arrData);
369    $conn->autoExecute("dtb_send_history", $dtb_send_history );     
370   
371    if ( is_array( $search_data ) ){
372        foreach( $search_data as $line ){
373            $dtb_send_customer = array();
374            $dtb_send_customer["customer_id"] = $line["customer_id"];
375            $dtb_send_customer["send_id"] = $dtb_send_history["send_id"];
376            $dtb_send_customer["email"] = $line["email"];
377           
378            $dtb_send_customer["name"] = $line["name01"] . " " . $line["name02"];
379               
380            $conn->autoExecute("dtb_send_customer", $dtb_send_customer );                   
381        }   
382    }   
383}
384
385?>
Note: See TracBrowser for help on using the repository browser.