<?php
session_name("AUTHENUSER");
session_start();
$USERNAME = $_SESSION['SES_USERNAME'];
if(!session_name("AUTHENUSER"))
	{
?>
						<script language="javascript">
						 alert("Waktu Login telah habis.Silahkan Login Kembali");
						document.location="index.php";
						</script>
<?php
	}
if(!$USERNAME)
	{
?>
						<script language="javascript">
						 alert("Harap Login Dahulu.");
						document.location="index.php";
						</script>
<?php
	}
	?>
	<?php include "common/config.php";
	include "include/head.php"; ?>
       <?php
	$act  = $_REQUEST['act'];
	$id_customer  = $_REQUEST['id_customer'];
	if($act == 3)
	{
		$delete = mysql_query("update tbl_customer set status_customer = 2,user_update  = '$USERNAME' where id_customer='$id_customer'");
		if($delete)
		{
				?>
				<script language="javascript">
                alert("Delete Customer Success");
                document.location="master_customer.php";
                </script>
				<?php
			}
			else
			{
				?>
				<script language="javascript">
                alert("Delete Customer Failed");
                document.location="master_customer.php";
                </script>
				<?php	
			}
	}
	?>
    
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-th"></i> Master Customer</h1>
</div>

<ol class="breadcrumb">
  <li><a href="add_customer.php">Add Customer</a></li>
<!--  <li><a href="#">Bread</a></li>
  <li><a href="#">Crumbs</a></li>
  <li class="active">Example</li>-->
</ol>
   <div class="main-content">
            <div class="widget">
              <h3 class="section-title first-title"><i class="icon-table"></i> Listing Customer</h3>
              <div class="widget-content-white glossed">
                <div class="padded">
                <table class="table table-striped table-bordered table-hover">
                  <thead>
                    <tr>
                     <th>Kode Customer</th>
                            <th>Nama Customer</th>
                            <th>Nama Kota</th>
                           <th>Telepon</th>
                           <th>Handphone</th>
                            <th>Email</th>
                            <th>Nomor Rekening</th>
                             <th>Details</th>
                    </tr>
                  </thead>
                  <tbody>
                     <?php
						$sql = mysql_query("select * from tbl_customer a
						inner join tbl_kota b on a.id_kota = b.id_kota
						 where status_customer = 1");
						while($fetch = mysql_fetch_array($sql))
						{
								$id_customer = $fetch['id_customer'];
					?>
                        <tr class="gradeX">
                          <td><?php echo $fetch['kode_customer'];?></td>
                            <td><?php echo $fetch['nama_customer'];?></td>
                            <td><?php echo $fetch['nama_kota'];?></td>
                            <td><?php echo $fetch['telepon'];?></td>
                            <td><?php echo $fetch['handphone'];?></td>
                            <td><?php echo $fetch['email'];?></td>
                            <td><?php echo $fetch['nomorrekening'];?></td>
                            <td class="actions aligncenter"><a href="edit_customer.php?id_customer=<?php echo $id_customer; ?>" class="btn btn-default btn-xs"><i class="icon-pencil"></i> edit</a> &nbsp; <a href="master_customer.php?act=3&id_customer=<?php echo $id_customer; ?>" class="btn btn-default btn-xs"><i class="icon-remove"></i> delete</a>&nbsp; <a href="histori_customer.php?act=3&id_customer=<?php echo $id_customer; ?>" class="btn btn-default btn-xs"><i class="icon-shopping-cart"></i> history</a></td>
                        </tr>
                        <?php
						}
						?>
                  </tbody>
                </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</div>       

<?php include "include/foot.php"; ?>
<script src='assets/js/for_pages/dashboard.js'></script>
</body>

</html>