<?
					
						if ($prod=='BAYAR')
						{
						    $query = "SELECT * FROM produk where kode LIKE '$prod%' and (kode_area LIKE '%$area%' OR kode_area ='') order by kode asc";
						}
						elseif ($prod=='BANK')
						{
						    $query = "SELECT * FROM produk where kode_operator LIKE '$prod' order by kode asc";
						}
						else
						{
						    $query = "SELECT * FROM produk where kode_operator = '$prod' order by harga_jual asc";
						}
						$exe = mysqli_query($conn,$query);
						$no = 1;
						while($record = mysqli_fetch_array($exe)){
                       
							$kode_p = $record['kode'];
							$nominal = $record['nominal'].".000";
							$nama = $record['nama'];
                            $harga_tetap = $record['harga_tetap'];
							$harga_awal = $record['harga_jual'];
							$harga = $record['harga_jual'];
							$oprator = $record['kode_operator'];
							$gangguan = $record['gangguan'];
							$kosong = $record['kosong'];
							$catatan = $record['catatan'];
							$hitung=$harga+$markup;

							$query2 = "SELECT harga FROM harga_grup where kode_level='$kodelevel' and kode_produk='$kode_p'";
							$exe2 = mysqli_query($conn,$query2);
							$jumlah=mysqli_num_rows($exe2);
							if ($jumlah == 0)
                            {
                            	$harga=$harga;
                            	$hitung=$harga+$markup;
                            }
                            else{
							    while($record = mysqli_fetch_array($exe2)){
							     $harga = $record['harga'];
							     $hitung=$harga+$markup0; 
							    }
                            }
                            
							
                            $query3 = "SELECT * FROM markup_produk where kode_reseller='$user' and kode_produk='$kode_p'";
							$exe3 = mysqli_query($conn,$query3);
							$jumlah=mysqli_num_rows($exe3);
							if ($jumlah == 0)
                            {
                            	$harga=$harga;
                            }
                            else{
							    while($record = mysqli_fetch_array($exe3)){
							     $harga = $harga+$record['markup'];
								 $hitung=$harga;
							    }
                            }
                            
                            
							if ($harga_tetap==1)
							{
							    $hitung=$harga_awal;
							}
							$harga1=number_format($hitung,0,',','.');
						    $keterangan='';
						    
							if (empty($nama))
							{
							    $keterangan="Pulsa ";
							}
							else
							{
							    $nominal="";
							}

							if ($kosong == 0 && $gangguan == 0)
							{
								$status ='Open';
								echo "<tbody><tr><td><center>$kode_p</center></td><td><center>$keterangan$nominal$nama</center></td><td><center>$harga1</center></td><td><center><font style='color:blue;'>$status</font></center></td></tr></tbody>";	
							}
							else if ($kosong == 1 && $gangguan == 0)
							{
								$status ='Kosong';
								echo "<tbody><tr><td><center>$kode_p</center></td><td><center>$keterangan$nominal$nama</center></td><td><center>$harga1</center></td><td><center><font style='color:red;'>$status</font></center></td></tr></tbody>";
							}
							else if ($kosong == 0 && $gangguan == 1)
							{
								$status ='Gangguan';
								echo "<tbody><tr><td><center>$kode_p</center></td><td><center>$keterangan$nominal$nama</center></td><td><center>$harga1</center></td><td><center><font style='color:red;'>$status</font></center></td></tr></tbody>";
							}
							else 
							{
								$status ='Close';
								echo "<tbody><tr><td><center>$kode_p</center></td><td><center>$keterangan$nominal$nama</center></td><td><center>$harga1</center></td><td><center><font style='color:red;'>$status</font></center></td></tr></tbody>";
							}
							$no++;
						}
						?>