<?php
/*
 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 */
require_once("../require.php");

class LC_Page {
    var $arrSession;
    var $list_data;
    var $default_template;
    var $default_template_mobile;
    var $arrMagazineType;
    
    function LC_Page() {
        $this->tpl_mainpage = 'basis/template.tpl';
        $this->tpl_mainno = 'basis';
        $this->tpl_subnavi = 'basis/subnavi.tpl';
        $this->tpl_subno = 'mail';
        $this->tpl_subtitle = 'テンプレート設定';
    }
}

$conn = new SC_DBConn();
$objPage = new LC_Page();
$objView = new SC_AdminView();
$objSess = new SC_Session();

// 認証可否の判定
sfIsSuccess($objSess);

if ( $_GET['mode'] == "delete" && sfCheckNumLength($_GET['id'])===true ){
    
    // 登録削除
    $sql = "UPDATE dtb_mailtemplate SET del_flg = 1 WHERE template_id = ?";
    $conn->query($sql, array($_GET['id']));
    sfReload();
}

$sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = 0";
$default_template = $conn->getAll($sql);
$split_data = explode(".",$default_template[0]["create_date"]);
$default_template[0]["create_date"] = $split_data[0];    
$objPage->default_template = $default_template[0];

$sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = 1";
$default_template_mobile = $conn->getAll($sql);
$split_data = explode(".",$default_template_mobile[0]["create_date"]);
$default_template_mobile[0]["create_date"] = $split_data[0]; 
$objPage->default_template_mobile = $default_template_mobile[0];

$sql = "SELECT * FROM dtb_mailtemplate WHERE del_flg = 0 AND template_id >1 ORDER BY create_date ASC";
$list_data = $conn->getAll($sql);
$linemax = count($list_data);

for($i = 0;$i < count($list_data);$i++){
   $split_data = explode(".",$list_data[$i]["create_date"]);
   $list_data[$i]["create_date"] = $split_data[0];    
}

//print_r($list_data);
$objPage->list_data = $list_data;
$objPage->arrMagazineType = $arrMagazineTypeAll;

$objView->assignobj($objPage);
$objView->display(MAIN_FRAME);
?>