<template>
  <strong
    style="
      display: inline-block;
      width: 100%;
      font-size: 10pt;
      margin-bottom: 10px;
      text-align: center;
    ">
    MİLLİ PİYANGO İDARESİ GENEL MÜDÜRLÜĞÜ
    <br />
    Bahisler ve Oyunlar Dairesi Başkanlığına
  </strong>
  <br />
  <div style="display: inline-block; width: 100%; font-size: 10pt">
    Şirketimizce/Kuruluşumuzca
    <strong>{{ piyangoStore.lotteryData.amacpiyango }}</strong>
    düzenlemek üzere, aşağıda belirtilen koşullarda piyango düzenlemek üzere gerekli iznin
    verilmesi hususunda bilgilerinizi ve gereğini arz ederiz.
    <br />
  </div>
  <strong style="font-size: 10pt; margin-bottom: 10px">
    PİYANGO İLE İLGİLİ BİLGİLER
  </strong>
  <br />
  <strong style="font-size: 10pt; margin-bottom: 10px">
    PİYANGO ID: {{ piyangoStore.lotteryData.piyangoId }}
  </strong>
  <br />
  <table
    cellspacing="0"
    class="table-no-line"
    data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayoutNoLine'}">
    <tbody>
      <tr>
        <td colspan="2">
          <strong style="font-size: 10pt; margin-bottom: 10px">
            1- Piyangoyu Düzenleyenin
          </strong>
        </td>
      </tr>
    </tbody>
  </table>
  <template v-if="loaded">
    <table
      cellspacing="0"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayout'}"
      style="margin-bottom: 10px; font-size: 10pt">
      <tbody>
        <template v-if="piyangoStore.duzenleyenData.basvuruTipId === 18">
          <tr>
            <td colspan="2">
              <strong>Adı/Soyadı:</strong>
              {{
                piyangoStore.duzenleyenData.unvan ||
                piyangoStore.duzenleyenData.gercekAdi +
                  ' ' +
                  piyangoStore.duzenleyenData.gercekSoyadi
              }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>Ticari Ünvanı:</strong>
              {{
                piyangoStore.duzenleyenData.unvan ||
                piyangoStore.duzenleyenData.gercekTicariUnvan
              }}
            </td>
          </tr>
        </template>
        <template v-if="piyangoStore.duzenleyenData.basvuruTipId === 21">
          <tr>
            <td colspan="2">
              <strong>Ünvanı:</strong>
              {{
                piyangoStore.duzenleyenData.unvan ||
                piyangoStore.duzenleyenData.tuzelUnvan
              }}
            </td>
          </tr>
        </template>

        <template v-if="piyangoStore.duzenleyenData.basvuruTipId === 22">
          <tr>
            <td colspan="2">
              <strong>Ünvanı:</strong>
              {{
                piyangoStore.duzenleyenData.unvan ||
                piyangoStore.duzenleyenData.dernekUnvan
              }}
            </td>
          </tr>
        </template>

        <template v-if="piyangoStore.duzenleyenData.basvuruTipId === 26">
          <tr>
            <td colspan="2">
              <strong>Ünvanı:</strong>
              {{
                piyangoStore.duzenleyenData.unvan || piyangoStore.duzenleyenData.kamuUnvan
              }}
            </td>
          </tr>
        </template>

        <tr>
          <td colspan="2">
            <strong>Adresi:</strong>
            {{ piyangoStore.duzenleyenData.adres }}
          </td>
        </tr>

        <template v-if="piyangoStore.duzenleyenData.basvuruTipId === 18">
          <tr>
            <td colspan="2">
              <strong>Bağlı Bulunduğu Oda Kayıt No/ Ticaret Sicil No:</strong>
              {{ piyangoStore.duzenleyenData.gercekOdaKayitNo }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>Bağlı Bulunduğu Vergi Dairesi/Numarası:</strong>
              {{ piyangoStore.duzenleyenData.gercekVergiDairesi }} /
              {{ piyangoStore.duzenleyenData.gercekVergiNo }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>TCKN:</strong>
              {{ piyangoStore.duzenleyenData.gercekTCKN }}
            </td>
          </tr>
        </template>

        <template v-if="piyangoStore.duzenleyenData.basvuruTipId === 21">
          <tr>
            <td colspan="2">
              <strong>Ticaret Sicil No:</strong>
              {{ piyangoStore.duzenleyenData.tuzelSicilNo }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>Bağlı Bulunduğu Vergi Dairesi/Numarası:</strong>
              {{ piyangoStore.duzenleyenData.tuzelVergiDairesi }} /
              {{ piyangoStore.duzenleyenData.tuzelVergiNo }}
            </td>
          </tr>
        </template>

        <template v-if="piyangoStore.duzenleyenData.basvuruTipId === 22">
          <tr>
            <td colspan="2">
              <strong>Sicil No:</strong>
              {{ piyangoStore.duzenleyenData.dernekSicilNo }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>Bağlı Bulunduğu Vergi Dairesi/Numarası:</strong>
              {{ piyangoStore.duzenleyenData.dernekVergiDairesi }} /
              {{ piyangoStore.duzenleyenData.dernekVergiNo }}
            </td>
          </tr>
        </template>
        <template v-if="piyangoStore.duzenleyenData.basvuruTipId === 26">
          <tr>
            <td colspan="2">
              <strong>Sicil No:</strong>
              {{ piyangoStore.duzenleyenData.kamuSicilNo }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>Bağlı Bulunduğu Vergi Dairesi/Numarası:</strong>
              {{ piyangoStore.duzenleyenData.kamuVergiDairesi }} /
              {{ piyangoStore.duzenleyenData.kamuVergiNo }}
            </td>
          </tr>
        </template>

        <tr>
          <td colspan="2">
            <strong>İrtibat Kurulacak Kişi Adı Soyadı:</strong>
            {{ customerIrtibatStore.customerIrtibatForm.firstName }}
            {{ customerIrtibatStore.customerIrtibatForm.lastName }}
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <strong>İrtibat Telefon Numarası:</strong>
            {{ customerIrtibatStore.customerIrtibatForm.phone }}
          </td>
        </tr>
      </tbody>
    </table>

    <template v-if="piyangoStore.lotteryData.baglisirketId !== null">
      <table
        cellspacing="0"
        class="table-no-line"
        data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayoutNoLine'}"
        style="font-size: 10pt">
        <tbody>
          <tr>
            <td colspan="2">
              <strong class="title" style="font-size: 10pt; margin-bottom: 10px">
                Piyangoyu Yürütenin:
              </strong>
            </td>
          </tr>
        </tbody>
      </table>
      <table
        cellspacing="0"
        data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayout'}"
        style="font-size: 10pt">
        <tbody>
          <tr>
            <td colspan="2">
              <strong>Ünvanı:</strong>
              {{ piyangoStore.araciUyeData.sirketUnvan }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>Adresi:</strong>
              {{ piyangoStore.araciUyeData.adres }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>Bağlı Bulunduğu Vergi Dairesi/Numarası:</strong>
              {{ piyangoStore.araciUyeData.sirketVergiDairesi }} /
              {{ piyangoStore.araciUyeData.sirketVergiNo }}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <strong>Ticaret Sicil No:</strong>
              {{ piyangoStore.araciUyeData.sirketSicilNo }}
            </td>
          </tr>
        </tbody>
      </table>
    </template>

    <table
      cellspacing="0"
      class="table-no-line"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayoutNoLine'}"
      style="font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong class="title" style="font-size: 10pt; margin-bottom: 10px">
              2- Kampanyanın:
            </strong>
          </td>
        </tr>
      </tbody>
    </table>
    <table
      cellspacing="0"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayout'}"
      style="margin-bottom: 10px; font-size: 10pt">
      <tbody>
        <tr>
          <td>
            <strong>Kampanya Başlangıç Tarihi ve Saati:</strong>
            <br />
            {{
              dateStore.dateFormat({
                date: piyangoStore.lotteryData.baslangicTarihi,
                pattern: 'dd-mm-yy-t'
              })
            }}
          </td>
          <td>
            <strong>Kampanya Bitiş Tarihi ve Saati:</strong>
            <br />
            {{
              dateStore.dateFormat({
                date: piyangoStore.lotteryData.bitisTarihi,
                pattern: 'dd-mm-yy-t'
              })
            }}
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <strong>Kapsadığı Yerler:</strong>
            {{
              piyangoStore.lotteryData.kampsamIlStrList.length ===
              globalDataStore.ilList.length
                ? 'Türkiye Geneli'
                : piyangoStore.lotterySelectedProvience
            }}
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      class="table-no-line"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayoutNoLine'}"
      style="font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong class="title" style="font-size: 10pt; margin-bottom: 10px">
              3-Çekilişe katılma şekil ve şartları:
            </strong>
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayout'}"
      style="margin-bottom: 10px; font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            {{ piyangoStore.lotteryData.cekilisSartveSekilleri }}
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <strong>Katılımcı Listesinin İçeriği ve Hazırlanma Şekli:</strong>
            {{ piyangoStore.lotteryData.katilimListesi }}
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      class="table-no-line"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayoutNoLine'}"
      style="font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong class="title" style="font-size: 10pt; margin-bottom: 10px">
              4-Çekilişin;
            </strong>
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayout'}"
      style="margin-bottom: 10px; font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong>Tarihi ve saati:</strong>
            {{
              dateStore.dateFormat({
                date: piyangoStore.lotteryData.cekilisTarihi,
                pattern: 'dd-mm-yy-t'
              })
            }}
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <strong>Açık adresi:</strong>
            {{
              piyangoStore.lotteryData.adres +
              ' ' +
              piyangoStore.lotteryData.il +
              ' ' +
              piyangoStore.lotteryData.ilce
            }}
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <strong>Ne şekilde yapılacağı:</strong>
            {{ piyangoStore.lotteryData.cekilisYontemi }}
            <div
              style="margin-top: 16px"
              v-if="piyangoStore.lotteryData.cekilisYontemiId === 1">
              <span v-for="txt in piyangoDataStore.fizikselTicariMessage">
                {{ txt }}
                <br />
              </span>
            </div>
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      class="table-no-line"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayoutNoLine'}"
      style="font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong class="title" style="font-size: 10pt; margin-bottom: 10px">
              5-Çekiliş sonuçlarının ilan edileceği gazetenin:
            </strong>
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayout'}"
      style="margin-bottom: 10px; font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong>Adı:</strong>
            {{ piyangoStore.lotteryData.ilanEdilecekGazete }}
          </td>
        </tr>
        <tr>
          <td>
            <strong>Tarihi:</strong>
            {{
              dateStore.dateFormat({
                date: piyangoStore.lotteryData.ilantarihi,
                pattern: 'dd-mm-yy'
              })
            }}
          </td>
          <td></td>
        </tr>
        <tr v-if="piyangoMecraStore.piyangoAllMecraData.length > 0">
          <td colspan="2">
            Ayrıca, çekiliş sonuçları
            <strong>
              <template v-for="(mecra, i) in piyangoMecraStore.piyangoAllMecraData">
                {{ mecra.mecraAdi
                }}{{ i !== piyangoMecraStore.piyangoAllMecraData.length - 1 ? ', ' : '' }}
              </template>
            </strong>
            {{
              piyangoMecraStore.piyangoAllMecraData.length > 1
                ? 'mecralarında'
                : 'mecrasında'
            }}
            ilan edilecektir.
          </td>
        </tr>
        <tr>
          <td colspan="2">
            Çekilişten sonra asil ve yedek talihlilerin adreslerine aynı anda taahhütlü
            posta kanalıyla tebligat yapılacaktır.
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayout'}"
      style="margin-bottom: 10px; font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong>6-Asil talihlilerin son başvuru tarihi:</strong>
            {{
              dateStore.dateFormat({
                date: piyangoStore.lotteryData.asilSonBasvuruTarihi,
                pattern: 'dd-mm-yy'
              })
            }}
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <strong>Yedek talihlilerin son başvuru tarihi:</strong>
            {{
              dateStore.dateFormat({
                date: piyangoStore.lotteryData.yedekSonBasvuruTarihi,
                pattern: 'dd-mm-yy'
              })
            }}
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <strong>İkramiyelerin son teslim edilme/kullanma tarihleri:</strong>
            {{
              dateStore.dateFormat({
                date: piyangoStore.lotteryData.ikramiyeTeslimTarihi,
                pattern: 'dd-mm-yy'
              })
            }}
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      class="table-no-line"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayoutNoLine'}"
      style="font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong class="title" style="font-size: 10pt; margin-bottom: 10px">
              7-Diğer hususlar:
            </strong>
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayout'}"
      style="margin-bottom: 10px; font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <div>
              <span v-for="txt in digerHususlar">
                {{ txt }}
                <br />
              </span>
            </div>
            <div style="margin-top: 16px">
              <span v-for="txt in piyangoDataStore.digerHusularTexts">
                {{ txt }}
                <br />
              </span>
            </div>
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      class="table-no-line"
      data-pdfmake="{'widths': [ '50%', '50%'],'layout':'pdfTableLayoutNoLine'}"
      style="font-size: 10pt">
      <tbody>
        <tr>
          <td colspan="2">
            <strong class="title" style="font-size: 10pt; margin-bottom: 10px">
              8-Piyangoya konu ikramiyeler:
            </strong>
          </td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      data-pdfmake="{'widths': ['10%', '30%', '15%', '15%', '15%', '15%'],'layout': 'pdfTableLayout'}"
      style="margin-bottom: 10px; font-size: 10pt"
      v-if="piyangoIkramiyeStore.piyangoAllIkramiyeData.length > 0">
      <tbody>
        <tr>
          <td><strong>Sıra No</strong></td>
          <td><strong>Cinsi, Markası, Modeli</strong></td>
          <td><strong>Birim Değeri (KDV+ÖTV Dahil)</strong></td>
          <td>
            <strong>Asil Talihli Adedi</strong>
          </td>
          <td><strong>Toplam Değer</strong></td>
          <td><strong>Yedek Talihli Adedi</strong></td>
        </tr>
        <template v-for="(item, i) in piyangoIkramiyeStore.piyangoAllIkramiyeData">
          <tr>
            <td>{{ i + 1 }}</td>
            <td>{{ `${item.cinsi}, ${item.marka}, ${item.model}` }}</td>
            <td>
              {{
                item.paraBirimi !== null
                  ? `${globalStore.toTrLocale(item.birimFiyat)} ${
                      item.paraBirimi.paraBirimiSembol
                    }`
                  : globalStore.toTrLocale(item.birimFiyat)
              }}
            </td>
            <td>{{ item.asilTalihliAdedi }}</td>
            <td>
              {{
                item.paraBirimi !== null
                  ? `${globalStore.toTrLocale(item.toplamDeger)} ${
                      item.paraBirimi.paraBirimiSembol
                    }`
                  : globalStore.toTrLocale(item.toplamDeger)
              }}
            </td>
            <td>
              {{ item.yedekTalihliAdedi }}
            </td>
          </tr>
        </template>
        <tr>
          <td colspan="3" style="text-align: right"><strong>TOPLAM:</strong></td>
          <td>{{ piyangoIkramiyeStore.piyangoAllIkramiyeTotals.asilTalihliAdedi }}</td>
          <td>
            {{
              `${globalStore.toTrLocale(
                piyangoIkramiyeStore.piyangoAllIkramiyeTotals.toplamDeger
              )} ${piyangoIkramiyeStore.piyangoAllIkramiyeParaBirimi}`
            }}
          </td>
          <td>{{ piyangoIkramiyeStore.piyangoAllIkramiyeTotals.yedekTalihliAdedi }}</td>
        </tr>
      </tbody>
    </table>

    <table
      cellspacing="0"
      class="table-no-line"
      data-pdfmake="{'widths': [ '50%', '30%','20%'],'layout':'pdfTableLayoutNoLine'}"
      style="margin-bottom: 10px; font-size: 10pt">
      <tbody>
        <tr>
          <td>
            <strong>İrtibat Tel. No:</strong>
            {{ piyangoContactStore.contactData.telefonNumarasi }}
          </td>
          <td></td>
          <td>
            Tarih:{{
              dateStore.dateFormat({
                date: new Date(),
                pattern: 'dd-mm-yy',
                splitDate: '/'
              })
            }}
          </td>
        </tr>
        <tr>
          <td>
            <strong>İrtibat Faks No:</strong>
            {{ piyangoContactStore.contactData.faksNumarasi }}
          </td>
          <td></td>
          <td>İMZA/KAŞE</td>
        </tr>
        <tr>
          <td>
            <strong>İrtibat Kurulacak İlgilinin Adı/Soyadı:</strong>
            {{ piyangoContactStore.contactData.adSoyad }}
          </td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td></td>
        </tr>
      </tbody>
    </table>
  </template>
</template>
<script setup lang="ts">
  import { ref, onBeforeMount, computed } from 'vue'
  import { useGlobalStore } from '@/stores/globalStore'
  const globalStore = useGlobalStore()
  import { useDataStore } from '@/stores/dataStore'
  const dataStore = useDataStore()
  import { useGlobalDataStore } from '@/stores/globalDataStore'
  const globalDataStore = useGlobalDataStore()
  import { useDateStore } from '@/stores/dateStore'
  const dateStore = useDateStore()
  import { usePiyangoStore } from '../../stores/piyangoStore'
  const piyangoStore = usePiyangoStore()
  import { usePiyangoContactStore } from '../../stores/piyangoContactStore'
  const piyangoContactStore = usePiyangoContactStore()
  import { usePiyangoMecraStore } from '../../stores/piyangoMecraStore'
  const piyangoMecraStore = usePiyangoMecraStore()
  import { usePiyangoMecraService } from '../../service/piyangoMecraService'
  const piyangoMecraService = usePiyangoMecraService()
  import { usePiyangoIkramiyeStore } from '../../stores/piyangoIkramiyeStore'
  const piyangoIkramiyeStore = usePiyangoIkramiyeStore()
  import { usePiyangoIkramiyeService } from '../../service/piyangoIkramiyeService'
  const piyangoIkramiyeService = usePiyangoIkramiyeService()
  import { useCustomerIrtibatStore } from '@/module/uyeler/stores/customerIrtibatStore'
  const customerIrtibatStore = useCustomerIrtibatStore()
  import { useCustomerIrtibatService } from '@/module/uyeler/service/customerIrtibatService'
  const customerIrtibatService = useCustomerIrtibatService()
  import { usePiyangoDataStore } from '../../stores/piyangoDataStore'
  const piyangoDataStore = usePiyangoDataStore()

  const loaded = ref(false)

  const digerHususlar = computed<string[]>(() => {
    return piyangoStore.lotteryData.digerHususlar.split('\n')
  })

  onBeforeMount(async () => {
    await piyangoMecraService.GetAllMecralar()
    await customerIrtibatService.GetIrtibat(piyangoStore.duzenleyenData.id)
    await piyangoIkramiyeService.GetAllIkramiyeler()

    await dataStore.GetIlList()

    setTimeout(() => {
      loaded.value = true
    }, 30)
  })
</script>
