<?php
    require_once 'common/database.php';

  $data =  array();
  $id_paket = $_GET['id'];
  $kuota = GetKuota($id_paket);

  $tiket_terpakai = jumlahTiketterpakai($id_paket);
  $tiket_tersisa = $kuota - $tiket_terpakai;

  $degree_tersisa = 360;
  $banding = $tiket_terpakai/$kuota;
  $degree = $banding * $degree_tersisa;
  $percent = round(($banding)*100,2);

  $myImage = ImageCreate(150,150);
  $white = ImageColorAllocate($myImage,245,245,245);
  $red = ImageColorAllocate($myImage,255,0,0);
  $blue = ImageColorAllocate($myImage,0,0,255);

  if($degree != 0){
      ImageFilledArc($myImage,75,75,120,120,0,$degree_tersisa,$red,IMG_ARC_PIE);
      ImageFilledArc($myImage,75,75,120,120,0,$degree,$blue,IMG_ARC_PIE);
  }
  else if($degree == 0){
    ImageFilledArc($myImage,75,75,120,120,0,$degree_tersisa,$red,IMG_ARC_PIE);
  }

  ImagePng($myImage,"images/png.png");
  ImageDestroy($myImage);

  $tersisa = ImageCreate(20,20);
  $red1 = ImageColorAllocate($tersisa,255,0,0);
  ImagePng($tersisa,"images/tersisa.png");
  ImageDestroy($tersisa);

  $terpakai = ImageCreate(20,20);
  $blue1 = ImageColorAllocate($terpakai,0,0,255);
  ImagePng($terpakai,"images/terpakai.png");
  ImageDestroy($terpakai);

?>
 <table>
    <tr>
        <td colspan="2"><img src='images/png.png' ></td>
    </tr>
    <tr style="color:black;">
       <td ><h3 style="color:red;"><strong>Tersisa = <?= $tiket_tersisa; ?>&nbsp(<?= 100 - $percent ?>%)</strong></h3></td>
       <td><h3 style="color:blue;"><strong>Terpakai = <?= $tiket_terpakai; ?>&nbsp(<?= $percent ?>%)</strong></h3></td>
    </tr>
 </table>
