<!DOCTYPE html>

<?php 
	session_start();
	@ob_start();
	include "../../config/koneksi.php";
	include "../../config/fungsi_rupiah.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>
            Tambah Data Prospek
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Iklan</a></li>
            <li class="active">Tambah Data Prospek</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12">
				<div class="box">

                <div class="box-body">
					<div class="col-md-12">
					  <!-- Horizontal Form -->
					  <div class="box box-info">
						<div class="box-header with-border">
						  <h3 class="box-title">Item Prospek</h3>
						</div><!-- /.box-header -->
					<form id='demoForm' name=form method=POST action='aksicust.php?module=cust&act=addprospek' class='form-horizontal'>
					<div class="col-xs-12">
						<div class=" col-md-5">
							<div class="form-group">
								<label>Iklan</label>
									<select name="iklan"  class="form-control select2">
										<?php
											$iddno = $_SESSION['idm'];
											$cek = mysql_query("Select * from iklan where cs = $iddno order by id desc");
											while ($r=mysql_fetch_array($cek)){	
												$sales = mysql_result(mysql_query("select userid from admins where pk = (select sales from iklan where id = $r[id])"),0);
												$namacs = mysql_result(mysql_query("select userid from admins where pk = (select cs from iklan where id = $r[id])"),0);
												$cat = mysql_result(mysql_query("select category from iklancat where pk = (select category from iklan where id = $r[id])"),0);
												$produk = mysql_result(mysql_query("select produk from produk where id = (select produk from iklan where id = $r[id])"),0);
												$kasir = $_SESSION['nama'];
												if ($namacs == $kasir){
													echo"<option value = $r[id]> $namacs # $sales # $cat # $r[nama] # $produk</option>";
												}
											}	
										?>
									</select>
							</div>
						</div>
								
						<div class=" col-md-2">
							<div class="form-group">
								<label for="date">Status</label>
								<div class="input-group">
								  <select name = "status" class="form-control select2">
									<option value = "Tanya Tanya">Tanya Tanya</option>
									<option value = "Totalan">Totalan</option>
									<option value = "Belanja">Belanja</option>
									<option value = "Close">Close</option>
								  </select>
								</div><!-- /.input group -->
							</div><!-- /.form group -->
						</div>
					
						 <div class=" col-md-2">
							<div class="form-group">
								<label for="date">Nama</label>
								<div class="input-group">
								  <input type="text" class="form-control pull-right" name="nama" placeholder="Nama" required>
								</div><!-- /.input group -->
							</div><!-- /.form group -->
						 </div>
							 
							 
						<div class=" col-md-2">
							<div class="form-group">
								<label for="date">Keterangan</label>
								<div class="input-group">
								  <input type="text" class="form-control pull-right" name="ket" placeholder="Keterangan" required>
								</div><!-- /.input group -->
							</div><!-- /.form group -->
						 </div>
						 
						 <div class="col-md-1">
							<div class="form-group">
								<label for="date"></label>
								<div class="input-group">
									<button class="btn btn-lg btn-primary" type="submit" tabindex="3" name="addtocart">+</button>
								</div>
							</div>	
						</div>
							
					</div>
					</form>

							

							<div class="col-xs-12">
							  <div class="table-responsive">
								<table class="table no-margin">
								  <thead>
									<tr>
									  <th>Iklan</th>
									  <th>Status</th>
									  <th>Nama</th>
									  <th>Keterangan</th>
									</tr>
								  </thead>
								  <tbody>
									<?php
										$user = $_SESSION['nama'];
										$cek = mysql_query("Select * from tmpprospek where kasir = '$user' order by id desc");

										while ($r=mysql_fetch_array($cek)){	
											$id = $r['id'];
											$nama = mysql_result(mysql_query("select nama from iklan where id = $id"),0);
											$sales = mysql_result(mysql_query("select userid from admins where pk = (select sales from iklan where id = $id)"),0);
											$namacs = mysql_result(mysql_query("select userid from admins where pk = (select cs from iklan where id = $id)"),0);
											$cat = mysql_result(mysql_query("select category from iklancat where pk = (select category from iklan where id = $id)"),0);
											$produk = mysql_result(mysql_query("select produk from produk where id = (select produk from iklan where id = $id)"),0);
											echo "<tr>
												  <td><a href = 'aksicust.php?module=cust&act=delitemprospek&id=$id'><i class = 'fa fa-times' style='font-size:24px;color:red'></i></a>&nbsp; $namacs # $sales # $cat # $nama<br>$produk</td>
												  <td>$r[status]</td>
												  <td>$r[nama]</td>
												  <td>$r[keterangan]</td>
												</tr>";
										}
									?>
									
								  </tbody>
								</table>
							  </div><!-- /.table-responsive -->
							</div><!-- /.box-body -->
							<div class="box-footer clearfix">
							</div>		

								
								
					<div class="box box-info">
								<div class="box-header with-border">
								  <h3 class="box-title">Prospek Info</h3>
								</div><!-- /.box-header -->
							<!-- form start -->
						<?php echo"
						<form id='demoForm' name=form method=POST action='aksicust.php?module=cust&act=addallprospek' class='form-horizontal'>"; ?>
						  <div class="box-body">
								
								<div class="form-group">
									<label>Tanggal Prospek</label>
									<div class="input-group">
									  <div class="input-group-addon">
										<i class="fa fa-calendar"></i>
									  </div><!--
									  <input name ="antar" type="text" class="form-control" data-inputmask="'alias': 'dd/mm/yyyy'"  data-mask>
									 -->
									 <?php
										$dt1 = date("d-m-Y");
										if($_SESSION['nama'] == 'KTR2' ){
											echo"<input type='text' class='form-control' name = 'sls' value='$dt1' >";
										}else{
											echo"<input type='text' class='form-control' name = 'sls' value='$dt1' disabled>";
										}
										
									?>
									</div><!-- /.input group -->
								</div>
							  
							
								<button type="submit" class="btn btn-info">Tambah Data</button>
							
						</form>
					</div>		
							
							


							
							
						  </div><!-- /.box-body -->
						<?php echo"  
						</form>";?>
					  </div><!-- /.box -->

					  
					 </div><!-- /.box -->
					
                </div><!-- /.box-body -->
              </div><!-- /.box -->
             
            </div><!-- /.box -->
          </div><!-- /.col -->
        </section><!-- /.content -->
      </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 -->

    <!-- 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 () {
        $("#example1").DataTable();
        $('#example2').DataTable({
          "paging": true,
          "lengthChange": false,
          "searching": false,
          "ordering": true,
          "info": true,
          "autoWidth": false
        });
      });
    </script>
  </body>
</html>
<?php 
	}
?>