<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CWR</title>
<!--
<style>
  .pesan{
  display: none;
  position: fixed;
  border: 1px solid blue;
  width: 200px;
  height: 100px;
  top: 300px;
  left: 700px;
  padding: 35px 10px;
  background-color: lightskyblue;
  text-align: center;
  font-size:16px; 
  font-weight:bold;
 }
 </style>
 -->

<link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.min.css" rel="stylesheet"></link>

</head>

<body>
<div class="wrapper">	
<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Create CWR
      </h1>
      <!--
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Examples</a></li>
        <li class="active">User profile</li>
      </ol>
      -->
    </section>

    <!-- Main content -->
    <section class="content">

      <div class="row">
        <div class="col-md-3" style="padding-left:7.5px; padding-right:7.5px;">

          <!-- Profile Image -->
          <div class="box box-primary">
            <div class="box-body box-profile">
              <img class="profile-user-img img-responsive img-circle" src="dist/img/tiktok-128x129.png" alt="User profile picture">

              <h3 class="profile-username text-center">Tiktok</h3>

              <p class="text-muted text-center">Common Work Registration</p>
			  <!--
              <ul class="list-group list-group-unbordered">
                <li class="list-group-item">
                  <b>Followers</b> <a class="pull-right">1,322</a>
                </li>
                <li class="list-group-item">
                  <b>Following</b> <a class="pull-right">543</a>
                </li>
                <li class="list-group-item">
                  <b>Friends</b> <a class="pull-right">13,287</a>
                </li>
              </ul>

              <a href="#" class="btn btn-primary btn-block"><b>Follow</b></a>
              -->
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->


          <!-- About Me Box -->
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">Create CWR</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <strong><i class="fa fa-download margin-r-5"></i> Form Metadata</strong>

              <p class="text-muted">
                <!--<a href="download.php?nama_file=Contoh_MetaData_XMLSpotify_20190418.xls" class="btn btn-primary btn-block"><b>Download</b></a>-->
                <a href="pages/metadata/download.php?nama_file=Contoh_MetaData_CWR_Tiktok.xls" class="btn btn-primary btn-block"><b>Download</b></a>
              </p>

              <hr>

              <strong><i class="fa fa-database margin-r-5"></i> Empty Database</strong>

         	  <p class="text-muted">
             <a href="pages/tiktok/aksi_empty.php?del=delete" onclick="javascript: return confirm('Anda yakin kosongkan database ?')" class="btn btn-danger btn-block">
                	<b>Empty</b>
                </a>
              </p>

              <hr>

              <strong><i class="fa fa-upload margin-r-5"></i> Upload Metadata</strong>

              <p>
                <form method="post" action="pages/tiktok/aksi_upload_metadata_cwr_tiktok_1.php" enctype="multipart/form-data">
                <div class="form-group">
                  	<input type="file" name="filemetadata" id="exampleInputFile">
 					<br>

				  	<label>Submitter Number (CISAC)</label>
					<input type="text" class="form-control" value="1005548098" disabled>
					<input type="hidden" name="submitternumber" class="form-control" value="1005548098">
					<br>

					<label>Type and ID Sender (CISAC)</label>
					<div class="row">
						<div class="col-sm-4">
							<!--<input type="text" class="form-control" placeholder="2 digit (01)" style="width:87px;" disabled>-->
							<!--<input type="text" class="form-control" placeholder="01" style="width:87px;" disabled>
							<input type="hidden" name="sendertype" class="form-control" value="01">-->
							<input type="text" class="form-control" placeholder="PB" style="width:87px;" disabled>
							<input type="hidden" name="sendertype" class="form-control" value="PB">
						</div>
						<div class="col-sm-8">
							<!--<input type="text" class="form-control" placeholder="9 digit (005548098)" style="width:140px; margin-left:5px;" disabled>-->
							<input type="text" class="form-control" placeholder="005548098" style="width:140px; margin-left:5px;" disabled>
							<input type="hidden" name="senderid" class="form-control" value="005548098">
						</div>
					</div>
					<br>

					<label>Sender Name (CISAC)</label>
					<input type="text" class="form-control" value="PUSTAKA JEKA PUBLISHING" disabled>
					<input type="hidden" name="sendername" class="form-control" value="PUSTAKA JEKA PUBLISHING">

                </div>
                <div class="box-footer">
                	<button type="submit" name="submit" value="submit" class="btn btn-success btn-block">Submit</button>
              	</div>
                </form>
              </p>

              <hr>

              <strong><i class="fa fa-exchange margin-r-5"></i> Get CWR</strong>

              <p>
              	<form action="pages/tiktok/1_cwr.php" method="post" enctype="multipart/form-data">
              		<div class="form-group">
                		<!--<label>Minimal</label>-->
                		<!--
						<select name="status_cwr" class="form-control select2" style="width: 100%;">
                  			<option>- Choose -</option>
                            <option value="createCWR">Create CWR</option>
                		</select>
						-->
						
 						<input type="text" name="sequence" class="form-control" placeholder="4 digit no urut kirim (contoh : 0001)">
 						<input type="hidden" name="status_cwr" value="createCWR" class="form-control">
              		</div>
                		<button type="submit" name="submit" value="submit" class="btn btn-warning btn-block">Process</button>
              	</form>  
              </p>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
       
       
        <!-- /.col -->
        <div class="col-md-9" style="padding-left:7.5px; padding-right:7.5px;">
          <div class="nav-tabs-custom">
          
          <?php
		  /* 
			//menampilkan pesan jika ada pesan
  			if (isset($_SESSION['pesan']) && $_SESSION['pesan'] <> '') {
     		echo '<div class="pesan">'.$_SESSION['pesan'].'</div>';
  			}

  			//mengatur session pesan menjadi kosong
  			$_SESSION['pesan'] = '';
			*/
		  ?>
          
            <ul class="nav nav-tabs">
              <li class="active"><a href="#activity" data-toggle="tab">CWR</a></li>
              <li><a href="#hdr" data-toggle="tab">hdr</a></li>
              <li><a href="#nwr" data-toggle="tab">nwr</a></li>
              <li><a href="#spu" data-toggle="tab">spu</a></li>
              <li><a href="#swr" data-toggle="tab">swr</a></li>
			  <li><a href="#pwr" data-toggle="tab">pwr</a></li>
            </ul>
            <div class="tab-content">
              <div class="active tab-pane" id="activity">
				<table class="table table-bordered table-striped" id="data_cwr_tiktok">
            		<thead>
                  		<tr>
                        	<th><center>No</center></th>
                        	<th><center>Sequence</center></th>
							<th><center>File Name</center></th>
                        	<th><center>Download</center></th>
                  		</tr>
            		</thead>
            		<tbody>
                  	<?php
						$download = mysql_query("SELECT no_id, sequence, name_file, status_download FROM ttk_file WHERE status_download = '1' ORDER BY no_id");
						$cek = mysql_num_rows($download);
						
						if($cek > 0)
						{
							$c=1;
							while($row=mysql_fetch_array($download))
							{
                  	?>
                  				<tr>
                        			<td align="center"><?php echo $c;?></td>
									<td align="center"><?=$row['sequence'];?></td>
                                    <td align="center"><?=$row['name_file'];?></td>
                        			<td align="center">
          								<a href="pages/tiktok/<?='hasilGenerate'.'/'.$row['name_file'];?>" class="btn btn-primary btn-block" download>
          								Download
          								</a>
                                    </td>
                  				</tr>

                  	<?php 
								
							$c++;
							}
						}
					?>

            		</tbody>
      			</table>
              </div>
              
              
              
              <!-- /.tab-pane -->
              <div class="tab-pane" id="hdr">
              	<table class="table table-bordered table-striped" id="data_hdr_tiktok">
            		<thead>
                  		<tr>
                        	<th><center>No</center></th>
                            <th><center>Sender ID</center></th>
                        	<th><center>Sender Name</center></th>
                        	<th><center>Creation Date</center></th>
                  		</tr>
            		</thead>
            		<tbody>
                  	<?php
						$hdr = mysql_query("SELECT * FROM ttk_hdr ORDER BY record_type");
						$cek_hdr = mysql_num_rows($hdr);
						
						if($cek_hdr > 0)
						{
							$c=1;
							while($row=mysql_fetch_array($hdr))
							{
                  	?>
                  				<tr>
                        			<td align="center"><?php echo $c;?></td>
                                    <td align="center"><?=$row['sender_id'];?></td>
                        			<td><?=$row['sender_name'];?></td>
                        			<td><?=$row['creation_date'];?></td>
                  				</tr>

                  	<?php 
							$c++;
							}
						}
					?>

            		</tbody>
      			</table>
              </div>
              <!-- /.tab-pane -->



              <div class="tab-pane" id="nwr">
              	<table class="table table-bordered table-striped" id="data_nwr_tiktok">
            		<thead>
                  		<tr>
                        	<th><center>No</center></th>
                            <th><center>Work Title</center></th>
                            <th><center>Submitter Work Number</center></th>
                        	<th><center>ISWC</center></th>
                  		</tr>
            		</thead>
            		<tbody>
                  	<?php
						$nwr = mysql_query("SELECT * FROM ttk_nwr ORDER BY transaction_sequence");
						$cek_nwr = mysql_num_rows($nwr);
						
						if($cek_nwr > 0)
						{
							$c=1;
							while($row=mysql_fetch_array($nwr))
							{
                  	?>
                  				<tr>
                        			<td align="center"><?php echo $c;?></td>
                                    <td align="center"><?=$row['work_title'];?></td>
                                    <td align="center"><?=$row['submitter_work_number'];?></td>
                        			<td><?=$row['iswc'];?></td>
                  				</tr>

                  	<?php 
							$c++;
							}
						}
					?>

            		</tbody>
      			</table>
              </div>
              <!-- /.tab-pane -->
              
              
              
              <div class="tab-pane" id="spu">
              	<table class="table table-bordered table-striped" id="data_spu_tiktok">
            		<thead>
                  		<tr>
                        	<th><center>No</center></th>
                            <th><center>Interested Party Number</center></th>
                            <th><center>Publisher Name</center></th>
                        	<th><center>Publisher IPI Name Number</center></th>
                            <th><center>PR Affiliation Society</center></th>
							<th><center>PR Share</center></th>
                            <th><center>MR Share</center></th>
                            <th><center>SR Share</center></th>
                  		</tr>
            		</thead>
            		<tbody>
                  	<?php
						$spu = mysql_query("SELECT * FROM ttk_spu ORDER BY transaction_sequence");
						$cek_spu = mysql_num_rows($spu);
						
						if($cek_spu > 0)
						{
							$c=1;
							while($row=mysql_fetch_array($spu))
							{
                  	?>
                                <tr>
                        			<td align="center"><?php echo $c;?></td>
                                    <td align="center"><?=$row['interested_party_number'];?></td>
                                    <td align="center"><?=$row['publisher_name'];?></td>
                        			<td><?=$row['publisher_ipi_name_number'];?></td>
                                    <td align="center"><?=$row['pr_affiliation_society'];?></td>
									<td><?=$row['pr_ownership_share'];?></td>
                                    <td><?=$row['mr_ownership_share'];?></td>
                                    <td><?=$row['sr_ownership_share'];?></td>
                  				</tr>

                  	<?php 
								
							$c++;
							}
						}
					?>

            		</tbody>
      			</table>
              </div>
              <!-- /.tab-pane -->
              
              
              
              <div class="tab-pane" id="swr">
              	<table class="table table-bordered table-striped" id="data_swr_tiktok">
            		<thead>
                  		<tr>
                        	<th><center>No</center></th>
                            <th><center>Interested Party Number</center></th>
                            <th><center>Writer</center></th>
                        	<th><center>Writer IPI Name Number</center></th>
                            <th><center>PR Affiliation Society</center></th>
                            <th><center>PR Share</center></th>
							<th><center>MR Share</center></th>
                            <th><center>SR Share</center></th>
                  		</tr>
            		</thead>
            		<tbody>
                  	<?php
						$swr = mysql_query("SELECT * FROM ttk_swr ORDER BY transaction_sequence");
						$cek_swr = mysql_num_rows($swr);
						
						if($cek_swr > 0)
						{
							$c=1;
							while($row=mysql_fetch_array($swr))
							{
                  	?>
                                <tr>
                        			<td align="center"><?php echo $c;?></td>
                                    <td align="center"><?=$row['interested_party_number'];?></td>
                                    <td align="center"><?=$row['writer_last_name'].' '.$row['writer_first_name'];?></td>
                        			<td><?=$row['writer_ipi_name_number'];?></td>
                                    <td align="center"><?=$row['pr_affiliation_society'];?></td>
                                    <td><?=$row['pr_ownership_share'];?></td>
									<td><?=$row['mr_ownership_share'];?></td>
                                    <td><?=$row['sr_ownership_share'];?></td>
                  				</tr>

                  	<?php 
								
							$c++;
							}
						}
					?>

            		</tbody>
      			</table>
              </div>
              <!-- /.tab-pane -->
              
			  
			  <div class="tab-pane" id="pwr">
              	<table class="table table-bordered table-striped" id="data_pwr_tiktok">
            		<thead>
                  		<tr>
                        	<th><center>No</center></th>
                            <th><center>Publisher Interested Party Number</center></th>
                            <th><center>Publisher Name</center></th>
                        	<th><center>Writer Interested Party Number</center></th>
                  		</tr>
            		</thead>
            		<tbody>
                  	<?php
						$pwr = mysql_query("SELECT * FROM ttk_pwr ORDER BY transaction_sequence");
						$cek_pwr = mysql_num_rows($pwr);
						
						if($cek_pwr > 0)
						{
							$c=1;
							while($row=mysql_fetch_array($pwr))
							{
                  	?>
                  				<tr>
                        			<td align="center"><?php echo $c;?></td>
                                    <td align="center"><?=$row['publisher_interested_party_number'];?></td>
                                    <td align="center"><?=$row['publisher_name'];?></td>
                        			<td><?=$row['writer_interested_party_number'];?></td>
                  				</tr>

                  	<?php 
							$c++;
							}
						}
					?>

            		</tbody>
      			</table>
              </div>
              <!-- /.tab-pane -->

              
            </div>
            <!-- /.tab-content -->
          </div>
          <!-- /.nav-tabs-custom -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->

    </section>
    <!-- /.content -->
  </div>
<!-- /.content-wrapper -->
</div>


<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.min.js"></script>

<!-- Javascript Datatable -->
<script type="text/javascript">
  $(document).ready(function(){
    $('#data_cwr_tiktok').DataTable();
  });
  
  $(document).ready(function(){
    $('#data_hdr_tiktok').DataTable();
  });
  
  $(document).ready(function(){
    $('#data_nwr_tiktok').DataTable();
  });
  
  $(document).ready(function(){
    $('#data_spu_tiktok').DataTable();
  });
  
  $(document).ready(function(){
    $('#data_swr_tiktok').DataTable();
  });

  $(document).ready(function(){
    $('#data_pwr_tiktok').DataTable();
  });
</script>

<!--
<script>
	//angka 500 dibawah ini artinya pesan akan muncul dalam 0,5 detik setelah document ready
  	$(document).ready(function(){setTimeout(function(){$(".pesan").fadeIn('slow');}, 500);});
	//angka 6000 dibawah ini artinya pesan akan hilang dalam 3 detik setelah muncul
    setTimeout(function(){$(".pesan").fadeOut('slow');}, 6000);
</script>
-->

<!-- jika ada session sukses maka tampilkan sweet alert dengan pesan yang telah di set di dalam session sukses  -->
<?php if(@$_SESSION['sukses']){ ?>
        <script>
            swal("Good job!", "<?php echo $_SESSION['sukses']; ?>", "success");
        </script>
    <!-- jangan lupa untuk menambahkan unset agar sweet alert tidak muncul lagi saat di refresh -->
    <?php unset($_SESSION['sukses']); }elseif(@$_SESSION['gagal']){ ?>
    
    <?php  ?>
        <script>
            swal("Proses Gagal!", "<?php echo $_SESSION['gagal']; ?>", "error");
        </script>
    <!-- jangan lupa untuk menambahkan unset agar sweet alert tidak muncul lagi saat di refresh -->
    <?php unset($_SESSION['gagal']); } ?>

</body>
</html>