Changeset 18631 for branches/comu-ver2


Ignore:
Timestamp:
2010/05/05 20:11:17 (14 years ago)
Author:
Seasoft
Message:

#698(メルマガ配信に誤りがある) 改修

Location:
branches/comu-ver2/data
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/Smarty/templates/default/admin/mail/history.tpl

    r18254 r18631  
    2626<input type="hidden" name="mode" value="" /> 
    2727<div id="mail" class="contents-main"> 
    28   <table class="list center"> 
    29     <tr> 
    30       <th>配信開始時刻</th> 
    31       <th>配信終了時刻</th> 
    32       <th>Subject</th> 
    33       <th>プレビュー</th> 
    34       <th>配信条件</th> 
    35       <th>配信予定件数</th> 
    36       <th>配信件数</th> 
    37       <th>削除</th> 
    38     </tr> 
    39     <!--{section name=cnt loop=$arrDataList}--> 
    40     <tr> 
    41       <td><!--{$arrDataList[cnt].start_date|sfDispDBDate|escape}--></td> 
    42       <td><!--{$arrDataList[cnt].end_date|sfDispDBDate|escape}--></td> 
    43       <td class="left"><!--{$arrDataList[cnt].subject|escape}--></td> 
    44       <td><a href="./preview.php?send_id=<!--{$arrDataList[cnt].send_id|escape}-->" target="_blank">確認</a></td> 
    45       <td><a href="#" onclick="win03('./<!--{$smarty.const.DIR_INDEX_URL}-->?mode=query&amp;send_id=<!--{$arrDataList[cnt].send_id|escape}-->','query','720','420'); return false;">確認</a></td> 
    46       <td><!--{$arrDataList[cnt].send_count|escape}--></td> 
    47       <td><!--{$arrDataList[cnt].complete_count|escape}--></td> 
    48       <td><a href="<!--{$smarty.server.PHP_SELF|escape}-->?mode=delete&send_id=<!--{$arrDataList[cnt].send_id|escape}-->" onclick="return window.confirm('配信履歴を削除しても宜しいでしょうか');">削除</a></td> 
    49     </tr> 
    50     <!--{/section}--> 
    51   </table> 
     28    <table class="list center"> 
     29        <tr> 
     30            <th>配信開始時刻</th> 
     31            <th>配信終了時刻</th> 
     32            <th>Subject</th> 
     33            <th>プレビュー</th> 
     34            <th>配信条件</th> 
     35            <th>配信総数</th> 
     36            <th>配信済数</th> 
     37            <th>配信失敗数</th> 
     38            <th>未配信数</th> 
     39            <th>再試行</th> 
     40            <th>削除</th> 
     41        </tr> 
     42        <!--{section name=cnt loop=$arrDataList}--> 
     43        <tr> 
     44            <td><!--{$arrDataList[cnt].start_date|sfDispDBDate|escape}--></td> 
     45            <td><!--{$arrDataList[cnt].end_date|sfDispDBDate|escape}--></td> 
     46            <td class="left"><!--{$arrDataList[cnt].subject|escape}--></td> 
     47            <td><a href="./preview.php?send_id=<!--{$arrDataList[cnt].send_id|escape}-->" target="_blank">確認</a></td> 
     48            <td><a href="#" onclick="win03('./<!--{$smarty.const.DIR_INDEX_URL}-->?mode=query&amp;send_id=<!--{$arrDataList[cnt].send_id|escape}-->','query','720','420'); return false;">確認</a></td> 
     49            <td><!--{$arrDataList[cnt].count_all|escape}--></td> 
     50            <td><!--{$arrDataList[cnt].count_sent|escape}--></td> 
     51            <td style="<!--{if $arrDataList[cnt].count_error >= 1}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"> 
     52                <!--{$arrDataList[cnt].count_error|escape}--> 
     53            </td> 
     54            <td style="<!--{if $arrDataList[cnt].count_unsent >= 1}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"> 
     55                <!--{$arrDataList[cnt].count_unsent|escape}--> 
     56            </td> 
     57            <td> 
     58                <!--{if $arrDataList[cnt].count_error >= 1 || $arrDataList[cnt].count_unsent >= 1}--> 
     59                    <a href="sendmail.php?mode=now&amp;send_id=<!--{$arrDataList[cnt].send_id|escape}-->&amp;retry=yes" onclick="return window.confirm('未配信と配信失敗となった宛先に再送信を試みますか?');">実行</a> 
     60                <!--{/if}--> 
     61            </td> 
     62            <td><a href="?mode=delete&send_id=<!--{$arrDataList[cnt].send_id|escape}-->" onclick="return window.confirm('配信履歴を削除しても宜しいでしょうか');">削除</a></td> 
     63        </tr> 
     64        <!--{/section}--> 
     65    </table> 
    5266</div> 
    5367</form> 
  • branches/comu-ver2/data/class/pages/admin/mail/LC_Page_Admin_Mail.php

    r18630 r18631  
    6666        $this->arrMagazineTypeAll = $masterData->getMasterData("mtb_magazine_type"); 
    6767 
    68         //---- 検索用項目配列 
     68        // 検索用項目配列 
    6969        $this->arrHtmlmail = array( "" => "両方",  1 => "HTML", 2 => "TEXT" ); 
    7070 
    7171 
    72         //---- 配列内容専用項目の配列 
     72        // 配列内容専用項目の配列 
    7373        $this->arrRegistColumn = array( 
    7474              array(  "column" => "template_id",    "convert" => "n" ), 
     
    8383              ); 
    8484 
    85         //---- メルマガ会員種別 
     85        // メルマガ会員種別 
    8686        $this->arrCustomerType = array(1 => "会員", 
    8787                                       2 => "非会員", 
    88                                        //3 => "CSV登録" 
     88                                       // 3 => "CSV登録" 
    8989                                       ); 
    9090 
    91         //---- 検索項目 
     91        // 検索項目 
    9292        $this->arrSearchColumn = array( 
    9393             array(  "column" => "name",                "convert" => "aKV"), 
     
    149149    function process() { 
    150150 
    151         //---- ページ初期設定 
     151        // ページ初期設定 
    152152        $conn = new SC_DBConn(); 
    153153        $objView = new SC_AdminView(); 
     
    221221        case 'search': 
    222222        case 'back': 
    223             //-- 入力値コンバート 
     223            // 入力値コンバート 
    224224            $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn); 
    225225 
    226             //-- 入力エラーのチェック 
     226            // 入力エラーのチェック 
    227227            $this->arrErr = $this->lfErrorCheck($this->list_data); 
    228228 
    229             //-- 検索開始 
     229            // 検索開始 
    230230            if (empty($this->arrErr)) { 
    231231                $this->list_data['name'] = isset($this->list_data['name']) 
     
    234234                $this->arrHidden = $this->lfGetHidden($this->list_data); 
    235235 
    236                 //-- 検索データ取得 
     236                // 検索データ取得 
    237237                $objSelect = new SC_CustomerList($this->list_data, "magazine"); 
    238238                // 生成されたWHERE文を取得する 
     
    262262                $col = $objSelect->getMailMagazineColumn($this->lfGetIsMobile($_POST['mail_type'])); 
    263263                $this->arrResults = $objQuery->select($col, $from, $where, $arrval); 
    264                 //現在時刻の取得 
     264                // 現在時刻の取得 
    265265                $this->arrNowDate = $this->lfGetNowDate(); 
    266266            } 
     
    270270            */ 
    271271        case 'input': 
    272             //-- 入力値コンバート 
     272            // 入力値コンバート 
    273273            $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn); 
    274             //-- 入力エラーのチェック 
     274            // 入力エラーのチェック 
    275275            $this->arrErr = $this->lfErrorCheck($this->list_data); 
    276             //-- エラーなし 
     276            // エラーなし 
    277277            if (empty($this->arrErr)) { 
    278                 //-- 現在時刻の取得 
     278                // 現在時刻の取得 
    279279                $this->arrNowDate = $this->lfGetNowDate(); 
    280280                $this->arrHidden = $this->lfGetHidden($this->list_data); // hidden要素作成 
     
    286286            */ 
    287287        case 'template': 
    288             //-- 入力値コンバート 
     288            // 入力値コンバート 
    289289            $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn); 
    290290 
    291             //-- 時刻設定の取得 
     291            // 時刻設定の取得 
    292292            $this->arrNowDate['year'] = isset($_POST['send_year']) ? $_POST['send_year'] : ""; 
    293293            $this->arrNowDate['month'] = isset($_POST['send_month']) ? $_POST['send_month'] : ""; 
     
    296296            $this->arrNowDate['minutes'] = isset($_POST['send_minutes']) ? $_POST['send_minutes'] : ""; 
    297297 
    298             //-- 入力エラーのチェック 
     298            // 入力エラーのチェック 
    299299            $this->arrErr = $this->lfErrorCheck($this->list_data); 
    300300 
    301             //-- 検索開始 
     301            // 検索開始 
    302302            if (empty($this->arrErr)) { 
    303303                $this->list_data['name'] = isset($this->list_data['name']) ? SC_Utils_Ex::sfManualEscape($this->list_data['name']) : ""; 
     
    312312                } 
    313313 
    314                 //-- HTMLテンプレートを使用する場合は、HTMLソースを生成してBODYへ挿入 
     314                // HTMLテンプレートを使用する場合は、HTMLソースを生成してBODYへ挿入 
    315315                if ( $this->list_data["mail_method"] == 3) { 
    316316                    $objTemplate = new LC_HTMLtemplate; 
     
    318318                    $objSiteInfo = new SC_SiteInfo(); 
    319319                    $objTemplate->arrInfo = $objSiteInfo->data; 
    320                     //メール担当写真の表示 
     320                    // メール担当写真の表示 
    321321                    $objUpFile = new SC_UploadFile(IMAGE_TEMP_URL, IMAGE_SAVE_URL); 
    322322                    $objUpFile->addFile("メール担当写真", 'charge_image', array('jpg'), IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); 
     
    337337        case 'regist_back': 
    338338        case 'regist_complete': 
    339             //-- 入力値コンバート 
     339            // 入力値コンバート 
    340340            $this->arrCheckColumn = array_merge( $this->arrSearchColumn, $this->arrRegistColumn ); 
    341341            $this->list_data = $this->lfConvertParam($_POST, $this->arrCheckColumn); 
    342342 
    343             //現在時刻の取得 
     343            // 現在時刻の取得 
    344344            $this->arrNowDate = $this->lfGetNowDate(); 
    345345 
    346             //-- 入力エラーのチェック 
     346            // 入力エラーのチェック 
    347347            $this->arrErr = $this->lfErrorCheck($this->list_data, 1); 
    348348            $this->tpl_mainpage = 'mail/input.tpl'; 
    349349            $this->arrHidden = $this->lfGetHidden($this->list_data); // hidden要素作成 
    350350 
    351             //-- 検索開始 
     351            // 検索開始 
    352352            if (empty($this->arrErr)) { 
    353353                $this->list_data['name'] = 
     
    358358                    $this->tpl_mainpage = 'mail/input_confirm.tpl'; 
    359359                } else if( $_POST['mode'] == 'regist_complete' ){ 
    360                     $this->lfRegistData($conn, $this->list_data); 
    361                     if(MELMAGA_SEND == true) { 
    362                         if(MELMAGA_BATCH_MODE) { 
    363                             $this->sendRedirect($this->getLocation(URL_DIR . "admin/mail/history.php")); 
     360                    $sendId = $this->lfRegistData($conn, $this->list_data); 
     361                    if (MELMAGA_SEND) { 
     362                        if (MELMAGA_BATCH_MODE) { 
     363                            $this->sendRedirect($this->getLocation(URL_DIR . 'admin/mail/history.php')); 
    364364                        } else { 
    365                             $this->sendRedirect($this->getLocation(URL_DIR . "admin/mail/sendmail.php", array("mode" => "now"))); 
     365                            $this->sendRedirect($this->getLocation(URL_DIR . 'admin/mail/sendmail.php', array('mode' => 'now', 'send_id' => $sendId))); 
    366366                        } 
    367367                        exit; 
     
    389389        $this->arrCampaignList = $this->lfGetCampaignList($objQuery); 
    390390 
    391         //---- ページ表示 
     391        // ページ表示 
    392392        $objView->assignobj($this); 
    393393        $objView->display(MAIN_FRAME); 
     
    421421    } 
    422422 
    423     //現在時刻の取得(配信時間デフォルト値) 
     423    // 現在時刻の取得(配信時間デフォルト値) 
    424424    function lfGetNowDate(){ 
    425425        $nowdate = date("Y/n/j/G/i"); 
     
    451451    } 
    452452 
    453     // 配信内容と配信リストを書き込む 
     453    /** 
     454     * 配信内容と配信リストを書き込む 
     455     * 
     456     * @return string 登録した行の dtb_send_history.send_id の値 
     457     */ 
    454458    function lfRegistData(&$conn, $arrData){ 
    455459 
     
    461465 
    462466        $dtb_send_history = array(); 
    463         if(DB_TYPE=='pgsql'){ 
    464             $dtb_send_history["send_id"] = $objQuery->nextval('dtb_send_history', 'send_id'); 
    465         } 
    466467        $dtb_send_history["mail_method"] = $arrData['mail_method']; 
    467468        $dtb_send_history["subject"] = $arrData['subject']; 
     
    479480        $dtb_send_history["create_date"] = "now()"; 
    480481        $objQuery->insert("dtb_send_history", $dtb_send_history ); 
    481         if(DB_TYPE == "mysql"){ 
    482             $dtb_send_history["send_id"] = $objQuery->nextval('dtb_send_history','send_id'); 
    483         } 
     482 
     483        $sendId = $objQuery->currval('dtb_send_history', 'send_id'); 
     484 
    484485        if ( is_array( $search_data ) ){ 
    485486            foreach( $search_data as $line ){ 
    486487                $dtb_send_customer = array(); 
    487488                $dtb_send_customer["customer_id"] = $line["customer_id"]; 
    488                 $dtb_send_customer["send_id"] = $dtb_send_history["send_id"]; 
     489                $dtb_send_customer["send_id"] = $sendId; 
    489490                $dtb_send_customer["email"] = $line["email"]; 
    490  
    491491                $dtb_send_customer["name"] = $line["name01"] . " " . $line["name02"]; 
    492  
    493492                $conn->autoExecute("dtb_send_customer", $dtb_send_customer ); 
    494493            } 
    495494        } 
     495 
     496        return $sendId; 
    496497    } 
    497498 
     
    528529 
    529530 
    530     //---- HTMLテンプレートを使用する場合、データを取得する。 
     531    // HTMLテンプレートを使用する場合、データを取得する。 
    531532    function lfGetHtmlTemplateData($id) { 
    532533 
     
    559560                $result = $conn->getAll($sql, array($list_data["sub_product_id" .$j])); 
    560561                $list_data["sub"][$k][$l] = $result[0]; 
    561                 $list_data["sub"][$k]["data_exists"] = "OK";    //当該段にデータが1つ以上存在するフラグ 
     562                $list_data["sub"][$k]["data_exists"] = "OK";    // 当該段にデータが1つ以上存在するフラグ 
    562563            } 
    563564            $l ++; 
     
    566567    } 
    567568 
    568     //---  テンプレートの種類を返す 
     569    // テンプレートの種類を返す 
    569570    function lfGetTemplateMethod($conn, $templata_id){ 
    570571 
     
    574575    } 
    575576 
    576     //---  hidden要素出力用配列の作成 
     577    // hidden要素出力用配列の作成 
    577578    function lfGetHidden( $array ){ 
    578579        if ( is_array($array) ){ 
     
    590591    } 
    591592 
    592     //---- 取得文字列の変換 
     593    // 取得文字列の変換 
    593594    function lfConvertParam($array, $arrSearchColumn) { 
    594595 
     
    612613 
    613614 
    614     //---- 入力エラーチェック 
     615    // 入力エラーチェック 
    615616    function lfErrorCheck($array, $flag = '') { 
    616617 
     
    658659        $objErr->doFunc(array("キャンペーン", "campaign_id", INT_LEN), array("NUM_CHECK")); 
    659660 
    660         //購入金額(from) > 購入金額(to) の場合はエラーとする 
     661        // 購入金額(from) > 購入金額(to) の場合はエラーとする 
    661662        if ( (is_numeric($array["buy_total_from"]) && is_numeric($array["buy_total_to"]) ) && 
    662663             ($array["buy_total_from"] > $array["buy_total_to"]) ) { 
     
    689690        $sql = "SELECT template_id, subject, mail_method FROM dtb_mailmaga_template WHERE del_flg = 0 "; 
    690691        if ($_POST["htmlmail"] == 2 || $_POST['mail_type'] == 2) { 
    691             $sql .= " AND mail_method = 2 ";    //TEXT希望者へのTESTメールテンプレートリスト 
     692            $sql .= " AND mail_method = 2 ";    // TEXT希望者へのTESTメールテンプレートリスト 
    692693        } 
    693694        $sql .= " ORDER BY template_id DESC"; 
  • branches/comu-ver2/data/class/pages/admin/mail/LC_Page_Admin_Mail_History.php

    r18234 r18631  
    5858     */ 
    5959    function process() { 
    60         //---- ページ初期設定 
     60        // ページ初期設定 
    6161        $conn = new SC_DBConn(); 
    6262        $objView = new SC_AdminView(); 
     
    7272 
    7373        // 削除時 
    74         if (SC_Utils_Ex::sfCheckNumLength($_GET['send_id']) && ($_GET['mode']=='delete') ){ 
     74        if (SC_Utils_Ex::sfCheckNumLength($_GET['send_id']) && ($_GET['mode']=='delete')) { 
    7575 
    7676            $sql = "UPDATE dtb_send_history SET del_flg = 1 WHERE send_id = ?"; 
     
    7979            $this->reload(); 
    8080        } 
    81         $col = "*"; 
    8281        $from = "dtb_send_history"; 
    8382 
     
    102101        $objQuery->setorder($order); 
    103102 
     103        $col = "*"; 
     104        $col .= ",(SELECT COUNT(*) FROM dtb_send_customer WHERE dtb_send_customer.send_id = dtb_send_history.send_id) AS count_all"; 
     105        $col .= ",(SELECT COUNT(*) FROM dtb_send_customer WHERE dtb_send_customer.send_id = dtb_send_history.send_id AND send_flag = 1) AS count_sent"; 
     106        $col .= ",(SELECT COUNT(*) FROM dtb_send_customer WHERE dtb_send_customer.send_id = dtb_send_history.send_id AND send_flag = 2) AS count_error"; 
     107        $col .= ",(SELECT COUNT(*) FROM dtb_send_customer WHERE dtb_send_customer.send_id = dtb_send_history.send_id AND send_flag IS NULL) AS count_unsent"; 
     108 
    104109        // 検索結果の取得 
    105110        $this->arrDataList = $objQuery->select($col, $from, $where, $arrval); 
    106111 
    107         //---- ページ表示 
     112        // ページ表示 
    108113        $objView->assignobj($this); 
    109114        $objView->display(MAIN_FRAME); 
  • branches/comu-ver2/data/class/pages/admin/mail/LC_Page_Admin_Mail_Sendmail.php

    r18284 r18631  
    3434class LC_Page_Admin_Mail_Sendmail extends LC_Page { 
    3535     
    36     var $objMail; 
     36    var $objMail; 
    3737    // }}} 
    3838    // {{{ functions 
     
    4444     */ 
    4545    function init() { 
    46         // SC_SendMailの拡張 
    47         if(file_exists(MODULE_PATH . "mdl_speedmail/SC_SpeedMail.php")) { 
    48             require_once(MODULE_PATH . "mdl_speedmail/SC_SpeedMail.php"); 
    49             // SpeedMail対応 
    50             $this->objMail = new SC_SpeedMail(); 
    51         } else { 
    52             $this->objMail = new SC_SendMail_Ex(); 
    53         } 
    54          
     46        // SC_SendMailの拡張 
     47        if (file_exists(MODULE_PATH . "mdl_speedmail/SC_SpeedMail.php")) { 
     48            require_once(MODULE_PATH . "mdl_speedmail/SC_SpeedMail.php"); 
     49            // SpeedMail対応 
     50            $this->objMail = new SC_SpeedMail(); 
     51        } else { 
     52            $this->objMail = new SC_SendMail_Ex(); 
     53        } 
     54 
    5555        parent::init(); 
    5656    } 
     
    6363    function process() { 
    6464        $conn = new SC_DbConn(); 
     65        $objQuery = new SC_Query(); 
    6566        $objSite = new SC_SiteInfo($conn); 
    6667 
    67         if(MELMAGA_SEND != true) { 
     68        if (MELMAGA_SEND != true) { 
    6869            exit; 
    6970        } 
    7071 
    71         //リアルタイム配信モードがオンのとき 
    72         if($_GET['mode'] == 'now') { 
    73             //---- 未送信データを取得する 
    74             $time_data = $conn->getAll( "SELECT send_id FROM dtb_send_history  WHERE complete_count = 0 AND del_flg = 0 AND end_date IS NULL ORDER BY send_id ASC, start_date ASC" ); 
     72        $where = 'del_flg = 0'; 
     73        $sqlval = array(); 
     74        // リアルタイム配信モードがオンのとき 
     75        if ($_GET['mode'] == 'now') { 
     76            // 指定データを取得する 
     77            $where .= ' AND send_id = ?'; 
     78            $sqlval[] = $_GET['send_id']; 
     79            if ($_GET['retry'] != 'yes') { 
     80                $where .= ' AND complete_count = 0 AND end_date IS NULL'; 
     81            } 
    7582        } else { 
     83            $where .= ' AND end_date IS NULL'; 
    7684            // postgresql と mysql とでSQLをわける 
    7785            if (DB_TYPE == "pgsql") { 
    78                 $sql = "SELECT send_id FROM dtb_send_history  "; 
    79                 $sql.= "WHERE start_date  BETWEEN current_timestamp + '- 5 minutes' AND current_timestamp + '5 minutes' AND del_flg = 0  AND end_date IS NULL ORDER BY send_id ASC, start_date ASC"; 
    80             }else if (DB_TYPE == "mysql") { 
    81                 $sql = "SELECT send_id FROM dtb_send_history  "; 
    82                 $sql.= "WHERE start_date  BETWEEN date_add(now(),INTERVAL -5 minute) AND date_add(now(),INTERVAL 5 minute) AND del_flg = 0  AND end_date IS NULL ORDER BY send_id ASC, start_date ASC"; 
     86                $where .= "start_date BETWEEN current_timestamp + '- 5 minutes' AND current_timestamp + '5 minutes'"; 
     87            } else if (DB_TYPE == "mysql") { 
     88                $where .= "start_date BETWEEN date_add(now(),INTERVAL -5 minute) AND date_add(now(),INTERVAL 5 minute)"; 
    8389            } 
    84             //---- 30分毎にCronが送信時間データ確認 
    85             $time_data = $conn->getAll($sql); 
     90            // 30分毎にCronが送信時間データ確認 
    8691        } 
     92        $objQuery->setorder('send_id'); 
     93        $arrMailList = $objQuery->select('*', 'dtb_send_history', $where, $sqlval); 
     94        $objQuery->setorder(''); 
    8795 
    88         //未送信メルマガの数 
    89         $count = count($time_data); 
    90  
    91         //未送信メルマガがあれば送信処理を続ける。なければ中断する。 
    92         if( $count > 0 ){ 
    93             print("start sending <br />\n"); 
    94         } else { 
    95             print("not found <br />\n"); 
     96        // 未送信メルマガがあれば送信処理を続ける。なければ中断する。 
     97        if (empty($arrMailList)) { 
     98            echo "not found\n"; 
    9699            exit; 
    97100        } 
    98101 
    99         //---- メール送信準備 
    100         for( $i = 0; $i < $count; $i++ ) { 
     102        echo "start sending\n"; 
     103 
     104        // メール生成と送信 
     105        foreach ($arrMailList as $arrMail) { 
     106            $sendFlag = null; 
     107 
    101108            // 送信先リストの取得 
    102             $sql = "SELECT * FROM dtb_send_customer WHERE send_id = ? AND (send_flag = 2 OR send_flag IS NULL)"; 
    103             $list_data[] = $conn->getAll( $sql, array( $time_data[$i]["send_id"] ) ); 
    104             // 送信先データの取得 
    105             $sql = "SELECT * FROM dtb_send_history WHERE send_id = ?"; 
    106             $mail_data[] = $conn->getAll( $sql, array( $time_data[$i]["send_id"] ) ); 
    107         } 
     109            $arrDestinationList = $objQuery->select( 
     110                '*', 
     111                'dtb_send_customer', 
     112                'send_id = ? AND (send_flag = 2 OR send_flag IS NULL)', 
     113                array($arrMail["send_id"]) 
     114            ); 
    108115 
    109         //---- 送信結果フラグ用SQL 
    110         $sql_flag ="UPDATE dtb_send_customer SET send_flag = ? WHERE send_id = ? AND customer_id = ?"; 
     116            foreach ($arrDestinationList as $arrDestination) { 
    111117 
    112         //---- メール生成と送信 
    113         for( $i = 0; $i < $count; $i++ ) { 
    114             for( $j = 0; $j < count( $list_data[$i] ); $j ++ ) { 
    115                 $customerName = ""; 
    116                 $mailBody = ""; 
    117                 $sendFlag = ""; 
    118  
    119                 //-- 顧客名の変換 
    120                 $name = trim($list_data[$i][$j]["name"]); 
     118                // 顧客名の変換 
     119                $name = trim($arrDestination["name"]); 
    121120 
    122121                if ($name == "") { 
     
    125124 
    126125                $customerName = htmlspecialchars($name); 
    127                 $subjectBody = ereg_replace( "{name}", $customerName , $mail_data[$i][0]["subject"] ); 
    128                 $mailBody = ereg_replace( "{name}", $customerName ,  $mail_data[$i][0]["body"] ); 
     126                $subjectBody = ereg_replace("{name}", $customerName, $arrMail["subject"]); 
     127                $mailBody = ereg_replace("{name}", $customerName, $arrMail["body"]); 
    129128 
    130129                $this->objMail->setItem( 
    131                                                 $list_data[$i][$j]["email"] 
    132                                                ,$subjectBody 
    133                                                ,$mailBody 
    134                                                ,$objSite->data["email03"]                  // 送信元メールアドレス 
    135                                                ,$objSite->data["shop_name"]                // 送信元名 
    136                                                ,$objSite->data["email03"]                  // reply_to 
    137                                                ,$objSite->data["email04"]                  // return_path 
    138                                                ,$objSite->data["email04"]                  // errors_to 
    139                                     ); 
     130                    $arrDestination["email"], 
     131                    $subjectBody, 
     132                    $mailBody, 
     133                    $objSite->data["email03"],      // 送信元メールアドレス 
     134                    $objSite->data["shop_name"],    // 送信元名 
     135                    $objSite->data["email03"],      // reply_to 
     136                    $objSite->data["email04"],      // return_path 
     137                    $objSite->data["email04"]       // errors_to 
     138                ); 
    140139 
    141                 //-- テキストメール配信の場合 
    142                 if( $mail_data[$i][0]["mail_method"] == 2 ) { 
     140                // テキストメール配信の場合 
     141                if ($arrMail["mail_method"] == 2) { 
    143142                    $sendResut = $this->objMail->sendMail(); 
    144                 //-- HTMLメール配信の場合 
     143                // HTMLメール配信の場合 
    145144                } else { 
    146145                    $sendResut = $this->objMail->sendHtmlMail(); 
    147146                } 
    148147 
    149                 //-- 送信完了なら1、失敗なら-1をメール送信結果フラグとしてDBに挿入 
    150                 if( ! $sendResut ){ 
    151                     $sendFlag = "-1"; 
     148                // 送信完了なら1、失敗なら2をメール送信結果フラグとしてDBに挿入 
     149                if (!$sendResut) { 
     150                    $sendFlag = '2'; 
    152151                } else { 
    153                     $sendFlag = "1"; 
     152                    $sendFlag = '1'; 
    154153 
    155154                    // 完了を 1 増やす 
    156155                    $sql = "UPDATE dtb_send_history SET complete_count = complete_count + 1 WHERE send_id = ?"; 
    157                     $conn->query( $sql, array($mail_data[$i][0]["send_id"])); 
     156                    $conn->query($sql, array($arrMail["send_id"])); 
    158157                } 
    159                 $conn->query( $sql_flag, array( $sendFlag, $mail_data[$i][0]["send_id"], $list_data[$i][$j]["customer_id"] ) ); 
     158 
     159                // 送信結果フラグ 
     160                $sql ="UPDATE dtb_send_customer SET send_flag = ? WHERE send_id = ? AND customer_id = ?"; 
     161                $conn->query($sql, array($sendFlag, $arrMail["send_id"], $arrDestination["customer_id"])); 
    160162            } 
    161163 
    162             //--- メール全件送信完了後の処理 
     164            // メール全件送信完了後の処理 
    163165            $completeSql = "UPDATE dtb_send_history SET end_date = now() WHERE send_id = ?"; 
    164             $conn->query( $completeSql, array( $time_data[$i]["send_id"] ) ); 
     166            $conn->query($completeSql, array($arrMail["send_id"])); 
    165167 
    166             //--- 送信完了 報告メール 
    167             $compSubject =  date("Y年m月d日H時i分" . "  下記メールの配信が完了しました。" ); 
     168            // 送信完了 報告メール 
     169            $compSubject = date("Y年m月d日H時i分") . "  下記メールの配信が完了しました。"; 
    168170            // 管理者宛に変更 
    169171            $this->objMail->setTo($objSite->data["email03"]); 
    170172            $this->objMail->setSubject($compSubject); 
    171173 
    172             //-- テキストメール配信の場合 
    173             if( $mail_data[$i][0]["mail_method"] == 2 ) { 
     174            // テキストメール配信の場合 
     175            if ($arrMail["mail_method"] == 2 ) { 
    174176                $sendResut = $this->objMail->sendMail(); 
    175             //-- HTMLメール配信の場合 
     177            // HTMLメール配信の場合 
    176178            } else { 
    177179                $sendResut = $this->objMail->sendHtmlMail(); 
    178180            } 
    179181        } 
    180         if ($_GET['mode'] = "now") { 
    181             header("Location: " . URL_DIR . "admin/mail/history.php"); 
     182        if ($_GET['mode'] == 'now') { 
     183            $this->sendRedirect($this->getLocation(URL_DIR . 'admin/mail/history.php')); 
    182184        } 
    183185        echo "complete\n"; 
Note: See TracChangeset for help on using the changeset viewer.