<!DOCTYPE html>

<?php 
	session_start();
	@ob_start();
	include "../../config/koneksi.php";
	include "../../config/fungsi_rupiah.php";
	include "../../config/fungsi_indotgl.php";
	include "../head.php";

	
	if ($_SESSION['nama'] == ''){
		header('Location:index.php');
	}
	else{
?>
<html>

  <body class="hold-transition skin-blue sidebar-mini layout-boxed">
    <div class="wrapper">
		<?php include "../header.php";?>
      
		<?php include "../menu.php";?>
      

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            C R M
            <small>Customer Relationship Management</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="data.php">C R M</a></li>
            <li class="active"><a href="data.php"><u>Update CRM</u></a></li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12">
              
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">List PENJUALAN CS</h3><br><br>
				  Follow 1 : Info Customer ID dan resi pengiriman <br>
				  Follow 2 : Tanya Barang sudah diterima? <br>
				  Follow 3 : Minta Feedback / Testimoni <br>
				  Follow 4 : Ajak menggunakan Voucher <br>
				  Follow 5 : Tanya Produk sudah habis dan ajak untuk repeat order?<br><br>
				  
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th>No Ord</th>
                        <th>Date / Customer</th>
						<th>Telp</th>
                        <th>Total (Rp)</th>
						<th>Follow 1</th>
						<th>Follow 2</th>
						<th>Follow 3</th>
						<th>Follow 4</th>
						<th>Follow 5</th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
						$user = $_SESSION['nama'];
						$cek = mysql_query("Select * from jualcs order by billno desc");
						while ($r=mysql_fetch_array($cek)){	
							$ord = $r['billno'];
							$tgl = tgl_ind($r['billdate']);

							$noord = str_pad($ord, 4, "0", STR_PAD_LEFT);

							$supp = mysql_result(mysql_query("select nama from customer where id = $r[cust]"),0);
							$telp = mysql_result(mysql_query("select hp from customer where id = $r[cust]"),0);
							$tot = mysql_result(mysql_query("select sum(qty * harga) from jualcsdetail where billno = $ord"),0);
							$tot2 = format_rupiah($tot);
							if($r['status'] == 'D'){
								$warna = "class='label label-danger'";
							}else{
								$warna = "class='label label-success'";
							}
							
							if($r['status'] == 'V'){
								$valid = "<span class='fa fa-thumbs-o-up'></span>";
							}else{
								$valid = "";
							}
							
							if($r['fol1'] == 'N'){
								$fol1 = "<h2><i class='fa  fa-close text-danger'></i></h2>";
							}else{
								$fol1 = "<h2><i class='fa  fa-check text-success'></i></h2>";
							}
							
							if($r['fol2'] == 'N'){
								$fol2 = "<h2><i class='fa  fa-close text-danger'></i></h2>";
							}else{
								$fol2 = "<h2><i class='fa  fa-check text-success'></i></h2>";
							}
							
							if($r['fol3'] == 'N'){
								$fol3 = "<h2><i class='fa  fa-close text-danger'></i></h2>";
							}else{
								$fol3 = "<h2><i class='fa  fa-check text-success'></i></h2>";
							}
							
							if($r['fol4'] == 'N'){
								$fol4 = "<h2><i class='fa  fa-close text-danger'></i></h2>";
							}else{
								$fol4 = "<h2><i class='fa  fa-check text-success'></i></h2>";
							}
							
							if($r['fol5'] == 'N'){
								$fol5 = "<h2><i class='fa  fa-close text-danger'></i></h2>";
							}else{
								$fol5 = "<h2><i class='fa  fa-check text-success'></i></h2>";
							}
							
							echo "<tr>
									<td><a href='view.php?id=$ord'><span $warna><span class='fa fa-eye'> </span></span>&nbsp;&nbsp;$noord  <br>$r[web] </a><br>$valid</td>
									<td>$tgl<br>  $supp</td>
									<td>$telp</td>
									<td>$tot2</td>
									<td align = center>$fol1  &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=ap1&id=$ord'><i class='fa  fa-thumbs-o-up'></i></a> &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=uap1&id=$ord'><i class='fa  fa-thumbs-o-down'></i></a></td>
									<td align = center>$fol2 &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=ap2&id=$ord'><i class='fa  fa-thumbs-o-up'></i></a> &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=uap2&id=$ord'><i class='fa  fa-thumbs-o-down'></i></a></td>
									<td align = center>$fol3 &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=ap3&id=$ord'><i class='fa  fa-thumbs-o-up'></i></a> &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=uap3&id=$ord'><i class='fa  fa-thumbs-o-down'></i></a></td>
									<td align = center>$fol4 &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=ap4&id=$ord'><i class='fa  fa-thumbs-o-up'></i></a> &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=uap4&id=$ord'><i class='fa  fa-thumbs-o-down'></i></a></td>
									<td align = center>$fol5 &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=ap5&id=$ord'><i class='fa  fa-thumbs-o-up'></i></a> &nbsp;&nbsp;<a href='aksisales.php?module=sales&act=uap5&id=$ord'><i class='fa  fa-thumbs-o-down'></i></a></td>
								  </tr>";
						}
					?>
                        
                     
                    </tbody>
                    <tfoot>
                      <tr>
                        <th>No Order</th>
                        <th>Date / Customer</th>
						<th>Telp</th>
                        <th>Total</th>
						<th>Follow 1</th>
						<th>Follow 2</th>
						<th>Follow 3</th>
						<th>Follow 4</th>
						<th>Follow 5</th>
                      </tr>
                    </tfoot>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
		
		<!-- Modal form-->
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                  <div class="modal-dialog ">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4 class="modal-title" id="myModalLabel"></h4>
                      </div>
                      <div class="modal-body" id="modal-bodyku">
                      </div>
                      <div class="modal-footer" id="modal-footerq">
                      </div>
                    </div>
                  </div>
                </div>
                <!-- end of modal ------------------------------>
		
		
      </div><!-- /.content-wrapper -->
		<?php include "../footer.php";?>
		

      <!-- Control Sidebar -->
      <aside class="control-sidebar control-sidebar-dark">

        <!-- Tab panes -->
        <div class="tab-content">
          <!-- Home tab content -->
          <div class="tab-pane" id="control-sidebar-home-tab">

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

        </div>
      </aside><!-- /.control-sidebar -->
      <!-- Add the sidebar's background. This div must be placed
           immediately after the control sidebar -->
      <div class="control-sidebar-bg"></div>
    </div><!-- ./wrapper -->
	
	<script language="javascript">
	 function open_container(id)
	 {
	 var size='standart';
	 var content = '<form role="form" method=POST action="aksisales.php?module=sales&act=validasi&id='+id+'" ><div class="form-group"><label for="exampleInputFile">Yakin Validasi Nota '+id+'</label></div><button type="submit" class="btn btn-default">Submit</button></form>';
	 var title = 'Validasi';
	 var footer = '<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>';
	 setModalBox(title,content,footer,size);
	 $('#myModal').modal('show');
	 }
	 function setModalBox(title,content,footer,$size)
	 {
	 document.getElementById('modal-bodyku').innerHTML=content;
	 document.getElementById('myModalLabel').innerHTML=title;
	 document.getElementById('modal-footerq').innerHTML=footer;
	 if($size == 'large')
	 {
	 $('#myModal').attr('class', 'modal fade bs-example-modal-lg')
		  .attr('aria-labelledby','myLargeModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog modal-lg');
	 }
	 if($size == 'standart')
	 {
	 $('#myModal').attr('class', 'modal fade')
		  .attr('aria-labelledby','myModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog');
	 }
	 if($size == 'small')
	 {
	 $('#myModal').attr('class', 'modal fade bs-example-modal-sm')
		  .attr('aria-labelledby','mySmallModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog modal-sm');
	 }
	 }
 </script>

    <!-- jQuery 2.1.4 -->
    <script src="../../plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="../../bootstrap/js/bootstrap.min.js"></script>
    <!-- DataTables -->
    <script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="../../plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="../../plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="../../plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="../../dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="../../dist/js/demo.js"></script>
    <!-- page script -->
    <script>
      $(function () {
        $("#example2").DataTable();
        $('#example1').DataTable({
          "paging": false,
          "lengthChange": true,
          "searching": true,
          "ordering": true,
		  "order": [[ 0, "desc" ]],
          "info": true,
          "autoWidth": false
        });
      });
    </script>
	
  </body>
</html>
<?php 
	}
?>