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

Revision 4608, 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            exit;           
252        }
253    }
254    break;
255default:
256    break;
257}
258
259// ÇÛ¿®»þ´Ö¤Îǯ¤ò¡¢¡Ö¸½ºßǯ¢·¸½ºßǯ¡Ü£±¡×¤ÎÈϰϤËÀßÄê
260for ($year=date("Y"); $year<=date("Y") + 1;$year++){
261    $arrYear[$year] = $year;
262}
263$objPage->arrYear = $arrYear;
264
265$objPage->arrCustomerOrderId = lfGetCustomerOrderId($_POST['buy_product_code']);
266
267$objPage->arrCatList = sfGetCategoryList();
268
269//----¡¡¥Ú¡¼¥¸É½¼¨
270$objView->assignobj($objPage);
271$objView->display(MAIN_FRAME);
272
273//-------------------------------------------------------------------------------------------------------------------------------
274
275// ¾¦ÉÊ¥³¡¼¥É¤Ç¸¡º÷¤µ¤ì¤¿¾ì¹ç¤Ë¥Ò¥Ã¥È¤·¤¿¼õÃíÈÖ¹æ¤ò¼èÆÀ¤¹¤ë¡£
276function lfGetCustomerOrderId($keyword) {
277    if($keyword != "") {
278        $col = "customer_id, order_id";
279        $from = "dtb_order LEFT JOIN dtb_order_detail USING(order_id)";
280        $where = "product_code LIKE ? AND del_flg = 0";
281        $val = sfManualEscape($keyword);
282        $arrVal[] = "%$val%";
283        $objQuery = new SC_Query();
284        $objQuery->setgroupby("customer_id, order_id");
285        $arrRet = $objQuery->select($col, $from, $where, $arrVal);
286        $arrCustomerOrderId = sfArrKeyValues($arrRet, "customer_id", "order_id");
287    }
288    return $arrCustomerOrderId;
289}
290
291function lfMakeCsvData( $send_id ){
292       
293    global $conn;
294
295    $arrTitle  = array(  'name01','email');
296               
297    $sql = "SELECT name01,email FROM dtb_send_customer WHERE send_id = ? ORDER BY email";
298    $result = $conn->getAll($sql, array($send_id) );
299   
300    if ( $result ){
301        $return = lfGetCSVData( $result, $arrTitle);
302    }
303    return $return;
304}
305
306//---- CSV½ÐÎÏÍѥǡ¼¥¿¼èÆÀ
307function lfGetCSVData( $array, $arrayIndex){   
308   
309    for ($i=0; $i<count($array); $i++){
310       
311        for ($j=0; $j<count($array[$i]); $j++ ){
312            if ( $j > 0 ) $return .= ",";
313            $return .= "\"";           
314            if ( $arrayIndex ){
315                $return .= mb_ereg_replace("<","¡ã",mb_ereg_replace( "\"","\"\"",$array[$i][$arrayIndex[$j]] )) ."\""; 
316            } else {
317                $return .= mb_ereg_replace("<","¡ã",mb_ereg_replace( "\"","\"\"",$array[$i][$j] )) ."\"";
318            }
319        }
320        $return .= "\n";           
321    }
322    return $return;
323}
324
325//¸½ºß»þ¹ï¤Î¼èÆÀ¡ÊÇÛ¿®»þ´Ö¥Ç¥Õ¥©¥ë¥ÈÃÍ¡Ë
326function lfGetNowDate(){
327    $nowdate = date("Y/n/j/G/i");
328    list($year, $month, $day, $hour, $minute) = split("[/]", $nowdate);
329    $arrNowDate = array( 'year' => $year, 'month' => $month, 'day' => $day, 'hour' => $hour, 'minutes' => $minute);
330    foreach ($arrNowDate as $key => $val){
331        switch ($key){
332            case 'minutes':
333            $val = ereg_replace('^[0]','', $val);
334            if ($val < 30){
335            $list_date[$key] = '30';
336            }else{
337            $list_date[$key] = '00';
338            }
339            break;
340            case 'year':
341            case 'month':
342            case 'day':
343            $list_date[$key] = $val;
344            break;
345        }
346    }
347        if ($arrNowDate['minutes'] < 30){
348            $list_date['hour'] = $hour;
349        }else{
350            $list_date['hour'] = $hour + 1;
351        }
352    return $list_date;
353}
354
355// ÇÛ¿®ÆâÍÆ¤ÈÇÛ¿®¥ê¥¹¥È¤ò½ñ¤­¹þ¤à
356function lfRegistData($arrData){
357   
358    global $conn;
359    global $arrSearchColumn;
360       
361    $objSelect = new SC_CustomerList( lfConvertParam($arrData, $arrSearchColumn), "magazine" );
362    $search_data = $conn->getAll($objSelect->getListMailMagazine(), $objSelect->arrVal);
363    $dataCnt = count($search_data);
364   
365    $dtb_send_history = array();
366    $dtb_send_history["send_id"] = $conn->getOne("SELECT NEXTVAL('dtb_send_history_send_id_seq')");
367    $dtb_send_history["mail_method"] = $arrData['mail_method'];
368    $dtb_send_history["subject"] = $arrData['subject'];
369    $dtb_send_history["body"] = $arrData['body'];
370    $dtb_send_history["start_date"] = "now()";
371    $dtb_send_history["creator_id"] = $_SESSION['member_id'];
372    $dtb_send_history["send_count"] = $dataCnt;
373    $arrData['body'] = "";
374    $dtb_send_history["search_data"] = serialize($arrData);
375    $conn->autoExecute("dtb_send_history", $dtb_send_history );     
376   
377    if ( is_array( $search_data ) ){
378        foreach( $search_data as $line ){
379            $dtb_send_customer = array();
380            $dtb_send_customer["customer_id"] = $line["customer_id"];
381            $dtb_send_customer["send_id"] = $dtb_send_history["send_id"];
382            $dtb_send_customer["email"] = $line["email"];
383           
384            $dtb_send_customer["name"] = $line["name01"] . " " . $line["name02"];
385               
386            $conn->autoExecute("dtb_send_customer", $dtb_send_customer );                   
387        }   
388    }   
389}
390
391?>
Note: See TracBrowser for help on using the repository browser.