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

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