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

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