#!/usr/bin/perl
########## ########## ########## ########## ##########
#  check_express.cgi(campaign)
#  MARS FLAG Corporation.
#  M.Nishida write
#  Update 2019.02.20
########## ########## ########## ########## ##########
use Encode;
require '../../lib/common.pl';

########## ########## ########## ########## ##########
# Define Data
########## ########## ########## ########## ##########
$CHECK_TMPL    = '../../tmpl/campaign_express_check.tmpl';
$LOG_PATH      = '../../data/campaign.txt';
@ITEM_SORT = ('last_name', 'first_name', 'company', '00N10000001rUhD', 'phone', 'email', '00N10000001dcWi', 'agree');

########## ########## ########## ########## ##########
# Main Source
########## ########## ########## ########## ##########
%in = &ReceiveData();  # CGIデータ取得
%out = %in;

foreach $item (@ITEM_SORT){
  $out{$item} =~ s/"/”/g;
  $out{$item} =~ s/</＜/g;
  $out{$item} =~ s/>/＞/g;
  $out{$item} =~ s/&/＆/g;
}

$out{'view_text'} = $out{'00N10000001dcWi'};
$out{'view_text'} =~ s/\x0D\x0A/<br \/>/g;
$out{'view_text'} =~ s/\x0D/<br \/>/g;
$out{'view_text'} =~ s/\x0A/<br \/>/g;

# ロギング
($sec, $min, $hour, $day, $month, $year) = localtime(time);
$date = sprintf("%04d.%02d.%02d %02d:%02d:%02d", $year+1900, $month+1, $day, $hour, $min, $sec);
$line = "$date\t$in{'last_name'}\t$in{'first_name'}\t$in{'company'}\t$in{'00N10000001rUhD'}\t$in{'phone'}\t$in{'email'}\t$out{'00N10000001dcWi'}\t";
&WriteLog($LOG_PATH, $line);

&PrintPage($CHECK_TMPL, %out);  # 確認ページを表示

exit;
