rec["当月着地見込み"] = int(float(v["cnt"]) * rec["先月同日比"] / 100) if rec["先月同日比"] != 0 else int(rec["当月累計売上"] * 30 / float((int(date.replace("-","")) % 100)))


label = [ "売上",
          "サブスクリプション売上",
          "従量売上",
          "当月累計売上",
          "先月同日比",
          "当月着地見込み",
          ]

d = []
d.append([rec["売上"], rec["サブスクリプション売上"], rec["従量売上"],
          rec["当月累計売上"], rec["先月同日比"], rec["当月着地見込み"]])

table_summary = html_table.table(label, d)

#スマ本Andorid
for key, value in sorted(params.items()):
     record = { "アプリ名" : key,
                "売上" : 0,
                "サブスクリプション売上" : 0,
                "従量売上" : 0,
                "新規ユーザー数" : 0,
                "DAU" : 0,
                "当月累計売上" : 0,
                "先月同日比" : 0,
                "当月着地見込み" : 0,
                }

#DAU
               data[v["book_id"]].setdefault("month_play", 0)
               data[v["book_id"]].setdefault("name", books[v["book_id"]]["name"])
               data[v["book_id"]].setdefault("release", books[v["book_id"]]["release"])
               data[v["book_id"]][uu] += int(v["uu"])
               data[v["book_id"]][play] += int(v["play_num"])



label = ["名称", "リリース日", 
         "今週のUU", "今週の再生回数", "今週の熱狂度", 
         "先週のUU", "先週の再生回数", "先週の熱狂度",
         "先月のUU", "先月の再生回数", "先月の熱狂度"]
d = []
for k, v in sorted(data.items(), key=lambda x:x[1]["current_uu"], reverse=True):
     c0 = float(v["current_play"]) / float(v["current_uu"]) if int(v["current_uu"]) != 0 else 0
     c1 = float(v["week_play"]) / float(v["week_uu"]) if int(v["week_uu"]) != 0 else 0
     c2 = float(v["month_play"]) / float(v["month_uu"]) if int(v["month_uu"]) != 0 else 0
     rec = [v["name"], v["release"], 
            str(v["current_uu"]), str(v["current_play"]), str(round(c0,1)),
            str(v["week_uu"]), str(v["week_play"]), str(round(c1,1)),
            str(v["month_uu"]), str(v["month_play"]), str(round(c2,1))]
     d.append(rec)

table = html_table.table(label, d)
title = u'ETV週間熱狂度レポート' + "( " + str(argvs[1]) + u"の週)" 
for to_addr in to_addrs:
    msg = mail_util.create_message_jp_html(from_addr, to_addr, title, table, 'UTF-8')
    mail_util.send_via_gmail(from_addr, to_addr, msg)