<?php
//session_save_path('/home/user/public_html/cgi-bin/tmp');
ob_start();
include "connect.php";

$kduser=$_SESSION['yuser'];

if (isset($_GET['id'])) {
	$nobukti=$_GET['id'];
	
//	$kd=$_GET['id'];
//	if ($kd=='NOR'){
//		if (isset($_SESSION['nb'])) {
//				$nobukti=$_SESSION['nb'];
//				$query1=mysql_query("SELECT custname,alamat,telp,'NOR' as statusbaru	 FROM customer_ikr 
//				WHERE nobukti='$nobukti';");
//				$data1=mysql_fetch_array($query1);										
//				$cn=$data1['custname'];
//				$al=$data1['alamat'];
//				$tl=$data1['telp'];
//				$st=$data1['statusbaru']; 
//				$_SESSION['nb']=null;
//			} else {	
//			$nobukti='baru';
//			}
			
		//nobukti,tgl,custno,custname,nik,propinsi,kota,kec,kel,alamat,typecust,telp,tgllahir    
			
			 
	
	} 	else {	
	$nobukti='baru';
	}
	$query=mysql_query("SELECT a.nobukti,a.tgl,a.kdslm,a.custno,a.cabang,a.lat,a.lng,a.newtype,
	IF(a.stat='0','Input',IF(a.stat='1','Assignment',IF(a.stat='2','Finish',IF(a.stat='4','Batal',IF(a.stat='5','Pending','Close'))))) AS kstat,ifnull(b.telp,f.telp) as telp,
	a.stat,ifnull(f.custname,b.custname) as custname,c.nmslm,g.nmslm as nmslm1,h.nmslm as nmslm2,ifnull(b.alamat1,f.alamat) as alamat1,
	b.statusbaru,ifnull(b.typecust,a.type) typecust,a.keterangan,a.jns,d.status,j.keterangan1 typelama,a.jns,
	f.custname as cust1,f.alamat as almt,a.alamat1 newalamat,a.telp newtelp,i.keterangan1,a.jaringan,if(a.jaringan='A','Analog','Digital') as kejar,
	f.nik,f.kdwil,w.nmwil,a.netto,a.iuran,a.stbid,a.serialnumber nosn ,a.odp ,a.formikr,a.bulan
	FROM jobheader a
						LEFT JOIN customer_ikr f ON a.nobukti=f.nobukti
						LEFT JOIN customer b ON a.custno=b.custno
						LEFT JOIN salesman c ON a.kdslm=c.kdslm
						LEFT JOIN salesman g ON a.kdslm1=g.kdslm
						LEFT JOIN salesman h ON a.kdslm2=h.kdslm
						left join wilayah w on f.kdwil=w.kdwil
						left join typecustomer i on a.newtype=i.typecust
						left join typecustomer j on a.type=j.typecust
						LEFT JOIN customer_status d ON a.jns=d.kode
						WHERE a.nobukti='$nobukti' ;");
	$data=mysql_fetch_array($query);
	
		$cn=$data['custname'];
		$al=$data['alamat1'];
		$tl=$data['telp'];
		$st=$data['jns'];
		$stat=$data['stat'];
		$nal=$data['newalamat'];
		$ntlp=$data['newtelp'];
		$_SESSION['slm']=$data['kdslm'];
$ktt=$data['keterangan1'];		
if ($data['keterangan1']=='') $ktt='Type Baru';
    
	
		
//}
//else {
//	$nobukti="baru";
//$ktt='Type Baru';
//}
$jabat1='6';
$jabat2='1';
$_SESSION['custno']=$nobukti;
$_SESSION['nobuk']=$nobukti;
//$_SESSION['jnst1']=$st;



?>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!doctype html>
<html>
    <head>
        <title>IBS</title>
        <link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
        <link rel="stylesheet" href="datatables/dataTables.bootstrap.css"/>
    
    <script language="JavaScript" type="text/JavaScript">
    window.history.forward();
    function noBack() { window.history.forward(); }
    
  function showSub()
  {
   if (document.anggota.jabatan.value == "1")
    {
     
     document.anggota.nopol.style.display = "none";
    }
   else if (document.anggota.jabatan.value == "2")
    {
     
     document.anggota.nopol.style.display = "none";
    }
	else if (document.anggota.jabatan.value == "3")
    {
     
     document.anggota.nopol.style.display = "none";
	 }
	else if (document.anggota.jabatan.value == "4")
    {
     document.anggota.nopol.style.display = "none";
    } 
	else if (document.anggota.jabatan.value == "5")
    {
     
     document.anggota.nopol.style.display = "none";
    }
	else if (document.anggota.jabatan.value == "6")
    {
     
     document.anggota.nopol.style.display = "none";
    }
	
   else
    {
     document.anggota.nopol.style.display = "block";
    // }
  }
  </script>
  
  <script language="JavaScript" type="text/JavaScript">

  function showSub1()
	{
   
    
	 if (document.anggota.jnst.value == "NOR")
    {
    document.anggota.cari.style.display = "none";	 
	document.anggota.editdata.style.display = "block";	 
	 }
	 else if (document.anggota.jnst.value == "NIP")
    {
    document.anggota.cari.style.display = "none";	 
	document.anggota.editdata.style.display = "block";	 
	 }
	 else if (document.anggota.jnst.value == "NFR")
    {
    document.anggota.cari.style.display = "none";	 
	document.anggota.editdata.style.display = "block";	 
	 }
     else if (document.anggota.jnst.value == "0")
    {
    document.anggota.cari.style.display = "none";	 
	document.anggota.editdata.style.display = "none";	 
	 }
	 else if (document.anggota.jnst.value == " ")
    {
    document.anggota.cari.style.display = "none";	 
	document.anggota.editdata.style.display = "none";	 
	 }
	 else if (document.anggota.jnst.value == null)
    {
    document.anggota.cari.style.display = "none";	 
	document.anggota.editdata.style.display = "none";	 
	 }
	 else
    {
     document.anggota.cari.style.display = "block";	 
	document.anggota.editdata.style.display = "none";	 
    }
  }
  
  </script>
  <style type="text/css">
.timbul {
	-moz-box-shadow:inset 0px 1px 0px 0px #fce2c1;
	-webkit-box-shadow:inset 0px 1px 0px 0px #fce2c1;
	box-shadow:inset 0px 1px 0px 0px #fce2c1;
	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #3a0cf0), color-stop(1, #176157) );
	background:-moz-linear-gradient( center top, #3a0cf0 5%, #176157 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3a0cf0', endColorstr='#176157');
	background-color:#3a0cf0;
	-webkit-border-top-left-radius:10px;
	-moz-border-radius-topleft:10px;
	border-top-left-radius:10px;
	-webkit-border-top-right-radius:10px;
	-moz-border-radius-topright:10px;
	border-top-right-radius:10px;
	-webkit-border-bottom-right-radius:10px;
	-moz-border-radius-bottomright:10px;
	border-bottom-right-radius:10px;
	-webkit-border-bottom-left-radius:10px;
	-moz-border-radius-bottomleft:10px;
	border-bottom-left-radius:10px;
	text-indent:0px;
	border:2px solid #ed5197;
	display:inline-block;
	color:#dcdeed;
	font-family:Arial Black;
	font-size:12px;
	font-weight:bold;
	font-style:normal;
	height:25px;
	line-height:25px;
	width:90px;
	text-decoration:none;
	text-align:center;
	text-shadow:0px 1px 0px #cc9f52;
}
.timbul:hover {
	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #176157), color-stop(1, #3a0cf0) );
	background:-moz-linear-gradient( center top, #176157 5%, #3a0cf0 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#176157', endColorstr='#3a0cf0');
	background-color:#176157;
}.timbul:active {
	position:relative;
	top:1px;
}</style>
 </head>
 
 <body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">      
	<div class="container">
		<div class="panel panel-success">
			<div class="panel-heading" >
				<div class="row">	
					<div class="col-md-3" class="panel-title">	
					<td align='left'  ><label>Surat Perintah Kerja IKR</label></td>
					</div>
					<?php if ($stat=='0')  { ?>
						<div class="col-md-2">	
							
							<td type="button" align='center' class="btn btn-warning"><a href='updatejob.php?id=<?php echo $nobukti;?>'><label class='timbul'>Posting</label></td>		
						</div>
					<?php }?> 
					<div class="col-md-2" >	
						<td type="button" align='center' class="btn btn-warning" ><a  href="listjob.php?id=<?php echo $data['kdslm'];?>"><label class='timbul'>Kembali</label></a></td>
					</div>	
				</div>
			</div>	
					<?php
					if ($data>1) {
						if ($stat=='0') {	?>	
							<div class="panel-body">
								<form action="simpanjobd.php"  method='POST' onsubmit="dummy(); return false">														
									<div class="form-group">				
										<div class="row">					
											<div class="col-md-2">					
											<input type='text' class="form-control" name='cabang' id=='cabang' style='float:left;' placeholder="Cabang" value="<?php echo $data['cabang'];?>" readonly />
											</div>
										<div class="col-md-2">					
											<input type='text' class="form-control" name='nobuk' id=='nobuk' style='float:left;' placeholder="No Bukti" value="<?php echo $data['nobukti'];?>" readonly />
										</div>
										
										<div class="col-md-1">
											<input type='text' class="form-control" name='status' id='status' style='float:left;' value="<?php echo $data['kstat'];?>" placeholder="Status" readonly />
											<input type='hidden' name='kodestat' id='kodestat'  value="<?php echo $data['stat'];?>"  />
										</div>
										<div class="col-md-3">
											<input class="form-control" name='jnst' id='jnst' onChange='showSub1()'  value="<?php echo $data['status'];?>" readonly />
											
										</div>										
									</div><p/>
				
									<div class="row">					
										
										<div class="col-md-2">
										<label>ID Pelanggan : </label>
											<input class="form-control" type="text"  name="custno" id="custno" placeholder="Kode Pelanggan" value="<?php echo $data['custno'];?>" readonly />
										</div>
									<div class="col-md-2">
									<label>Tanggal : </label>
											<input type='date' class="form-control" name='tgl' id='tgl' style='float:left;' placeholder="Tanggal Transaksi" value="<?php echo $data['tgl'];?>"/>
									</div>	
									<div class="col-md-2">
									<label>No. Formulir IKR : </label>
											<input class="form-control" type="text"  name="formikr" id="formikr" placeholder="Formulir IKR" value="<?php echo $data['formikr'];?>"  />
										</div>									
									</div>	<p/>	
									
									
									<div class="row">
										<div class="col-md-2">
											<label>NIK : </label><input pattern='.{16,}' maxlength='16' type="text" class="form-control" name="nik" id="nik" placeholder="NIK" value="<?php echo $data['nik'];?>" /><p/>
										</div>
										<div class="col-md-6">
										<label>Nama Pelanggan : </label>
											<input type="text"  class="form-control" name="custname" id="custname" placeholder="Nama Pelanggan" value="<?php echo $cn;?>"  />
										</div>
									</div>	
									<div class="row">					
										<div class="col-md-8">
											<label>Alamat Lengkap</label><input type="text" class="form-control" name="alamat" id="alamat" placeholder="Alamat lengkap" value="<?php echo $al;?>"  /><p/>
										</div>					
									</div>	
									<div class="row">
																	
									
										<div class="col-md-4">					
											<label>Area</label><select class="form-control" name='kdwil' id='kdwil' onChange='validasi()' required>
											<option value=""><?php echo $data['nmwil'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdwil,nmwil FROM wilayah ");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdwil'].'">'.$w['nmwil'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>
										<div class="col-md-4">
											<label>No. Hp :</label> <input type="number" class="form-control" name="telp1" id="telp1" placeholder="Telpon" value="<?php echo $ntlp;?>" /><p/>
									</div>	
										
									</div>
									
									<div class="row">	
												
									</div>									
									
									<div class="row">
										<div class="col-md-3">	
										<label>Teknisi</label>										
											<select class="form-control" name='kdslm' id='kdslm' onChange='validasi()' required>
											<option value=""><?php echo $data['nmslm'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>
										
																		
									
										<div class="col-md-3">					
										<label>Team Teknisi 1</label>
											<select class="form-control" name='kdslm1' id='kdslm1' >
											<option value=""><?php echo $data['nmslm1'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>										
									
										<div class="col-md-2">		
										<label>Team Teknisi 2</label>		
											<select class="form-control" name='kdslm2' id='kdslm2' >
											<option value=""><?php echo $data['nmslm2'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>	
									</div><p/>		
									
								
									<div class="row">	
										<div class="col-md-2">		
										<label>Jaringan ODP</label>		
											<select class="form-control" name='odp' id='odp' >
											<option value="" ><?php echo $data['odp'];?></option>
											<?php
											$tampil=mysql_query("SELECT odp,terpakai,port FROM masterodph where terpakai<port");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['odp'].'">'.$w['port'].'</option>';							
											} ?>
											</select> 
										</div>		
										<div class="col-md-3">		
										<label>STB ID :</label> 
										<input type="text" pattern='.{10,}' class="form-control" name="stbid" id="stbid" placeholder="No seri STB ID" value="<?php echo $data['stbid'];?>" /><p/>
									
										</div>	
										<div class="col-md-3">		
										<label>Serial Number :</label> 
										<input type="text" pattern='.{10,}' class="form-control" name="nosn" id="nosn" placeholder="No Serial Number" value="<?php echo $data['nosn'];?>" /><p/>
									
										</div>	
									</div><p/>	
									<div class="row">	
										<div class="col-md-3">	
			        	        	        <tr><td>
												<label>Jenis Paket :</label>
		                    			        <select name='type1' id='type1' class="form-control" placeholder='Type Baru'>
			                                    <option value='' ><?php echo $data['keterangan1']?></option>
			                                    <?php
			                                    $tampil1=mysql_query("SELECT kdharga,keterangan FROM kodeharga where jaringan='D'");
			                                    while($w1=mysql_fetch_array($tampil1))
			                                        {
			                                            echo '<option value="'.$w1['kdharga'].'">'.$w1['keterangan'].'</option>';        
			                                        }
			                                    ?>
			                                    </select>
                                            </td></tr>   
                				        </div>
										 
													
									<div class="col-md-2">
											<label>Biaya IKR Rp.: </label>
											<input min='0' type="text" class="form-control" name="harga" id="harga" placeholder="Biaya Pasang" value="<?php echo number_format($data['netto']);?>"></input><p/>
										</div>						
									<div class="col-md-2">
											<label>Token Rp.:</label> <input min='0' type="text" class="form-control" name="iuran" id="iuran"  value="<?php echo number_format($data['iuran']);?>" ></input><p/>
										</div>							
									<div class="col-md-1">
											<label>J.Bulan.:</label> <input min='20000' type="text" class="form-control" name="bulan" id="bulan" placeholder="Jumlah Bulan" value="<?php echo number_format($data['bulan']);?>" /><p/>
										</div>	
									</div>
									
									<div class="row">	
										<div class="col-md-8">	
											<label>Keterangan :</label> <textarea type="text" class="form-control" name="ket" id="ket" placeholder="Keterangan" value="<?php echo $data['keterangan'];?>"><?php echo $data['keterangan'];?></textarea>
										</div>
									</div>   
								</div>
					<?php } else {	?>
								
								<div class="panel-body">
								<form action="simpanjobd.php"  method='POST' onsubmit="dummy(); return false">														
									<div class="form-group">				
										<div class="row">					
											<div class="col-md-2">					
											<input type='text' class="form-control" name='cabang' id=='cabang' style='float:left;' placeholder="Cabang" value="<?php echo $data['cabang'];?>" readonly />
											</div>
										<div class="col-md-2">					
											<input type='text' class="form-control" name='nobuk' id=='nobuk' style='float:left;' placeholder="No Bukti" value="<?php echo $data['nobukti'];?>" readonly />
										</div>
										
										<div class="col-md-1">
											<input type='text' class="form-control" name='status' id='status' style='float:left;' value="<?php echo $data['kstat'];?>" placeholder="Status" readonly />
											<input type='hidden' name='kodestat' id='kodestat'  value="<?php echo $data['stat'];?>"  />
										</div>
										<div class="col-md-3">
											<input class="form-control" name='jnst' id='jnst' onChange='showSub1()'  value="<?php echo $data['status'];?>" readonly />
											
										</div>										
									</div><p/>
				
									<div class="row">					
										
										<div class="col-md-2">
										<label>ID Pelanggan : </label>
											<input class="form-control" type="text"  name="custno" id="custno" placeholder="Kode Pelanggan" value="<?php echo $data['custno'];?>" readonly />
										</div>
									<div class="col-md-2">
									<label>Tanggal : </label>
											<input type='date' class="form-control" name='tgl' id='tgl' style='float:left;' placeholder="Tanggal Transaksi" value="<?php echo $data['tgl'];?>" readonly />
									</div>	
									<div class="col-md-2">
									<label>No. Formulir IKR : </label>
											<input class="form-control" type="text"  name="formikr" id="formikr" placeholder="Formulir IKR" value="<?php echo $data['formikr'];?>"  readonly  />
										</div>									
									</div>	<p/>	
									
									
									<div class="row">
										<div class="col-md-2">
											<label>NIK : </label><input pattern='.{16,}' maxlength='16' type="text" class="form-control" name="nik" id="nik" placeholder="NIK" value="<?php echo $data['nik'];?>"  readonly /><p/>
										</div>
										<div class="col-md-6">
										<label>Nama Pelanggan : </label>
											<input type="text"  class="form-control" name="custname" id="custname" placeholder="Nama Pelanggan" value="<?php echo $cn;?>"  readonly  />
										</div>
									</div>	
									<div class="row">					
										<div class="col-md-8">
											<label>Alamat Lengkap</label><input type="text" class="form-control" name="alamat" id="alamat" placeholder="Alamat lengkap" value="<?php echo $al;?>"  readonly   /><p/>
										</div>					
									</div>	
									<div class="row">
																	
									
										<div class="col-md-4">					
											<label>Area</label><select class="form-control" name='kdwil' id='kdwil' onChange='validasi()' required  readonly >
											<option value=""><?php echo $data['nmwil'];?> </option>
											<?php
											$tampil=mysql_query("SELECT kdwil,nmwil FROM wilayah ");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdwil'].'">'.$w['nmwil'].'</option>';							
											} ?>
											
											</select> </td></tr>    
										</div>
										<div class="col-md-4">
											<label>No. Hp :</label> <input type="number" class="form-control" name="telp1" id="telp1" placeholder="Telpon" value="<?php echo $ntlp;?>"  readonly /><p/>
									</div>	
										
									</div>
									
									<div class="row">	
												
									</div>									
									
									<div class="row">
										<div class="col-md-3">	
										<label>Teknisi</label>										
											<select class="form-control" name='kdslm' id='kdslm' onChange='validasi()'  readonly required>
											<option value=""><?php echo $data['nmslm'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>
										
																		
									
										<div class="col-md-3">					
										<label>Team Teknisi 1</label>
											<select class="form-control" name='kdslm1' id='kdslm1'  readonly  >
											<option value=""><?php echo $data['nmslm1'];?></option>
											<?php 
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>										
									
										<div class="col-md-2">		
										<label>Team Teknisi 2</label>		
											<select class="form-control" name='kdslm2' id='kdslm2'  readonly  >
											<option value=""><?php echo $data['nmslm2'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>	
									</div><p/>		
									
								
									<div class="row">	
										<div class="col-md-2">		
										<label>Jaringan ODP</label>		
											<select class="form-control" name='odp' id='odp' readonly  >
											<option value="" ><?php echo $data['odp'];?></option>
											<?php
											$tampil=mysql_query("SELECT odp,terpakai,port FROM masterodph where terpakai<port");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['odp'].'">'.$w['port'].'</option>';							
											} ?>
											</select> 
										</div>		
										<div class="col-md-3">		
										<label>STB ID :</label> 
										<input type="text" pattern='.{10,}' class="form-control" name="stbid" id="stbid" placeholder="No seri STB ID" value="<?php echo $data['stbid'];?>" readonly  /><p/>
									
										</div>	
										<div class="col-md-3">		
										<label>Serial Number :</label> 
										<input type="text" pattern='.{10,}' class="form-control" name="nosn" id="nosn" placeholder="No Serial Number" value="<?php echo $data['nosn'];?>" readonly  /><p/>
									
										</div>	
									</div><p/>	
									<div class="row">	
										<div class="col-md-3">	
			        	        	        <tr><td>
												<label>Jenis Paket :</label>
		                    			        <select name='type1' id='type1' class="form-control" placeholder='Type Baru' readonly >
			                                    <option value='' ><?php echo $data['keterangan1']?></option>
			                                    <?php
			                                    $tampil1=mysql_query("SELECT kdharga,keterangan FROM kodeharga where jaringan='D'");
			                                    while($w1=mysql_fetch_array($tampil1))
			                                        {
			                                            echo '<option value="'.$w1['kdharga'].'">'.$w1['keterangan'].'</option>';        
			                                        }
			                                    ?>
			                                    </select>
                                            </td></tr>   
                				        </div>
										 
													
									<div class="col-md-2">
											<label>Biaya IKR Rp.: </label>
											<input min='0' type="text" class="form-control" name="harga" id="harga" placeholder="Biaya Pasang"  readonly value="<?php echo number_format($data['netto']);?>"></input><p/>
										</div>						
									<div class="col-md-2">
											<label>Token Rp.:</label> <input min='0' type="text" class="form-control" name="iuran" id="iuran"   readonly value="<?php echo number_format($data['iuran']);?>" ></input><p/>
										</div>							
									<div class="col-md-1">
											<label>J.Bulan.:</label> <input type="text" class="form-control" name="bulan" id="bulan" placeholder="Jumlah Bulan"  readonly value="<?php echo number_format($data['bulan']);?>" /><p/>
										</div>	
									</div>
									
									<div class="row">	
										<div class="col-md-8">	
											<label>Keterangan :</label> <textarea type="text" class="form-control" name="ket" id="ket" placeholder="Keterangan"  readonly value="<?php echo $data['keterangan'];?>"><?php echo $data['keterangan'];?></textarea>
										</div>
									</div>   
								</div>
								
								<?php if ($stat=='0') {?>
								<div class="row">	
								<input type="submit" value="Simpan" class="btn btn-warning" />			
										
								</div>
								<?php }?>
						</div>
					
					
					<?php } 
					} else {?>
					<div class="panel-body">
							<form action="simpanjobd.php"  method='POST' onsubmit="dummy(); return false">														
								<div class="form-group">				
									<div class="row">					
										<div class="col-md-2">					
											<input type='text' class="form-control" name='cabang' id=='cabang' style='float:left;' placeholder="Cabang" value="<?php echo $data['cabang'];?>" readonly />
										</div>
										<div class="col-md-2">					
											<input type='text' class="form-control" name='nobuk' id=='nobuk' style='float:left;' placeholder="No Bukti" value="<?php echo $data['nobukti'];?>" readonly />
										</div>
										
										<div class="col-md-1">
											<input type='text' class="form-control" name='status' id='status' style='float:left;' value="<?php echo $data['kstat'];?>" placeholder="Status" readonly />
											<input type='hidden' name='kodestat' id='kodestat'  value="<?php echo $data['stat'];?>"  />
										</div>
										<div class="col-md-3">
											<input class="form-control" name='jnst' id='jnst' onChange='showSub1()'  value="<?php echo $data['status'];?>" readonly />
											
										</div>										
									</div><p/>
				
									<div class="row">					
										
										<div class="col-md-2">
										<label>ID Pelanggan : </label>
											<input class="form-control" type="text"  name="custno" id="custno" placeholder="Kode Pelanggan" value="<?php echo $data['custno'];?>" readonly />
										</div>
									<div class="col-md-2">
									<label>Tanggal : </label>
											<input type='date' class="form-control" name='tgl' id='tgl' style='float:left;' placeholder="Tanggal Transaksi" value="<?php echo $data['tgl'];?>"/>
									</div>	
									<div class="col-md-2">
									<label>No. Formulir IKR : </label>
											<input class="form-control" type="text"  name="formikr" id="formikr" placeholder="Formulir IKR" value="<?php echo $data['noformulir'];?>"  />
										</div>									
									</div>	<p/>	
									
									
									<div class="row">
										<div class="col-md-2">
											<label>NIK : </label><input pattern='.{16,}' maxlength='16' type="text" class="form-control" name="nik" id="nik" placeholder="NIK" value="<?php echo $data['nik'];?>" /><p/>
										</div>
										<div class="col-md-6">
										<label>Nama Pelanggan : </label>
											<input type="text"  class="form-control" name="custname" id="custname" placeholder="Nama Pelanggan" value="<?php echo $cn;?>"  />
										</div>
									</div>	
									<div class="row">					
										<div class="col-md-8">
											<label>Alamat Lengkap</label><input type="text" class="form-control" name="alamat" id="alamat" placeholder="Alamat lengkap" value="<?php echo $al;?>"  /><p/>
										</div>					
									</div>	
									<div class="row">
																	
									
										<div class="col-md-4">					
											<label>Area</label><select class="form-control" name='kdwil' id='kdwil' onChange='validasi()' required>
											<option value=""><?php echo $data['nmwil'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdwil,nmwil FROM wilayah ");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdwil'].'">'.$w['nmwil'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>
										<div class="col-md-4">
											<label>No. Hp :</label> <input type="number" class="form-control" name="telp1" id="telp1" placeholder="Telpon" value="<?php echo $ntlp;?>" /><p/>
									</div>	
										
									</div>
									
									<div class="row">	
												
									</div>									
									
									<div class="row">
								
										<div class="col-md-3">	
										<label>Teknisi</label>										
											<select class="form-control" name='kdslm' id='kdslm' onChange='validasi()' required>
											<option value=""><?php echo $data['nmslm'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>
									
										<div class="col-md-3">					
										<label>Team Teknisi 1</label>
											<select class="form-control" name='kdslm1' id='kdslm1' >
											<option value=""><?php echo $data['nmslm1'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>										
									
										<div class="col-md-2">		
										<label>Team Teknisi 2</label>		
											<select class="form-control" name='kdslm2' id='kdslm2' >
											<option value=""><?php echo $data['nmslm2'];?></option>
											<?php
											$tampil=mysql_query("SELECT kdslm,nmslm FROM salesman where typeslm='TS20'");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['kdslm'].'">'.$w['nmslm'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>	
									</div><p/>		
									
								
									<div class="row">	
										<div class="col-md-2">		
										<label>Jaringan ODP</label>		
											<select class="form-control" name='odp' id='odp' >
											<option value="" ><?php echo $data['odp'];?></option>
											<?php
											$tampil=mysql_query("SELECT odp,terpakai,port FROM masterodph where terpakai<port");
											while($w=mysql_fetch_array($tampil)) {
											echo '<option value="'.$w['odp'].'">'.$w['port'].'</option>';							
											} ?>
											</select></td></tr>    
										</div>		
										<div class="col-md-3">		
										<label>STB ID :</label> 
										<input type="text" pattern='.{10,}' class="form-control" name="stbid" id="stbid" placeholder="No seri STB ID" value="<?php echo $data['stbid']?>" /><p/>
									
										</div>	
										<div class="col-md-3">		
										<label>Serial Number :</label> 
										<input type="text" pattern='.{10,}' class="form-control" name="nosnn" id="nosnn" placeholder="No Serial Number" value="<?php echo $data['nosn'];?>" /><p/>
									
										</div>	
									</div><p/>	
									<div class="row">	
										<div class="col-md-3">	
			        	        	        <tr><td>
												<label>Jenis Paket :</label>
		                    			        <select name='type1' id='type1' class="form-control" placeholder='Type Baru'>
			                                    <option value='' ><?php echo $data['keterangan1']?></option>
			                                    <?php
			                                    $tampil1=mysql_query("SELECT kdharga,keterangan FROM kodeharga where jaringan='D'");
			                                    while($w1=mysql_fetch_array($tampil1))
			                                        {
			                                            echo '<option value="'.$w1['kdharga'].'">'.$w1['keterangan'].'</option>';        
			                                        }
			                                    ?>
			                                    </select>
                                            </td></tr>   
                				        </div>
										
													
									<div class="col-md-2">
											<label>Biaya IKR Rp.: </label><input min='0' type="number" class="form-control" name="harga" id="harga" placeholder="Biaya Pasang" value="<?php echo number_format($data['netto']);?>" /><p/>
										</div>						
									<div class="col-md-2">
											<label>Token Rp.:</label> <input  min='0' type="number" class="form-control" name="iuran" id="iuran" placeholder="Nilai Token" value="<?php echo number_format($data['iuran']);?>" /><p/>
										</div>							
									<div class="col-md-1">
											<label>J.Bulan.:</label> <input min='0' type="number" class="form-control" name="bulan" id="bulan" placeholder="Jumlah Bulan" value="<?php echo number_format($data['bulan']);?>" /><p/>
										</div>	
									</div>
									
									<div class="row">	
										<div class="col-md-8">	
											<label>Keterangan :</label> <textarea type="text" class="form-control" name="ket" id="ket" placeholder="Keterangan" value="<?php echo $data['keterangan'];?>"><?php echo $data['keterangan'];?></textarea>
										</div>
									</div>   
								</div>            	
								<div class="row">	
								<input type="submit" value="Simpan" class="btn btn-warning" />			
										
								</div>
						</div>
					<?php } ?>
					
				<!-- <script type="text/javascript">
	                    function validasi() {
		                    var kdslm = document.getElementById("kdslm").value;
		                    if (kdslm != "" ){
			                return true;
		                    }else{
			                alert('Anda harus mengisi Kode Teksnisi !');
		                    }
	                    }
                </script>	-->	
						<script type="text/javascript">
	                    function validasi() {
		                    var kdslm = document.getElementById("kdslm").value;
		                    if (kdslm != "" ){
			                return true;
		                    }else{
			                alert('Anda harus mengisi Kode Teksnisi !');
		                        }
	                       }
                        </script>	
                        <script type="text/javascript">
	                    function validasi() {
		                    var kdslm = document.getElementById("odp").value;
		                    if (kdslm != "" ){
			                return true;
		                    }else{
			                alert('Anda harus mengisi Kode Odp !');
		                        }
	                       }
                        </script>	
						<script type="text/javascript">
	                    function validasi() {
		                    var kdslm = document.getElementById("stib").value;
		                    if (kdslm != "" ){
			                return true;
		                    }else{
			                alert('Anda harus mengisi Kode stib !');
		                        }
	                       }
                        </script>	
						<script type="text/javascript">
	                    function validasi() {
		                    var kdslm = document.getElementById("custname").value;
		                    if (kdslm != "" ){
			                return true;
		                    }else{
			                alert('Anda harus mengisi Nama Lengkap !');
		                        }
	                       }
                        </script>	
                        <script type="text/javascript">
	                    function validasi() {
		                    var kdslm = document.getElementById("formikr").value;
		                    if (kdslm != "" ){
			                return true;
		                    }else{
			                alert('Anda harus mengisi No Formulir IKR !');
		                        }
	                       }
                        </script>
                        
	
	<!-- sampai sini -->

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog" style="width:800px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">Data Pelanggan</h4>
                    </div>
                    <div class="modal-body">
                        <table id="lookup" class="table table-bordered table-hover table-striped">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Nama</th>
									<th>Type</th>
									<th>Alamat</th>
									<th>Jaringan</th>
									
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                //Data mentah yang ditampilkan ke tabel    
                                $query = mysql_query('SELECT a.custno as nim,a.custname as nama,a.typecust as ipk,b.keterangan1 kt1, a.alamat1 as jurusan,a.telp,a.cabang,a.statusbaru,if(a.jaringan="A","Analog","Digital") as jaringan FROM customer a
                                                      left join typecustomer b on a.typecust=b.typecust ;');
                                while ($data = mysql_fetch_array($query)) {
                                    ?>
                                    <tr class="pilih" 
									data-nim="<?php echo $data['nim']; ?>"
									data-nim1="<?php echo $data['nama']; ?>"
									data-nim2="<?php echo $data['jurusan']; ?>"
									data-nim3="<?php echo $data['telp']; ?>"
									data-nim4="<?php echo $data['cabang']; ?>"
									data-nim5="<?php echo $data['ipk']; ?>"
									data-nim7="<?php echo $data['kt1']; ?>"
									data-nim6="<?php echo $data['statusbaru']; ?>"
									data-nim8="<?php echo $data['jaringan']; ?>"
									>
                                        <td><?php echo $data['nim']; ?></td>
                                        <td><?php echo $data['nama']; ?></td>
										<td><?php echo $data['ipk']; ?></td>
										<td><?php echo $data['jurusan']; ?></td>		
										<td><?php echo $data['jaringan']; ?></td>		
                                    </tr>
                                    <?php
                                }
                                ?>
                            </tbody>
                        </table>  
                    </div>
                </div>
            </div>
        </div>
		
 <div class="modal fade" id="myModal1" role="dialog" >
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <label class="modal-title">Formulir data Pelanggan</label>
                </div>
                <div class="modal-body">
                    <div class="fetched-data"></div>
                </div>
            </div>
        </div>
    </div>

  <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  
  <script type="text/javascript">
    $(document).ready(function(){
        $('#myModal1').on('show.bs.modal', function (e) {
            var rowid = $(e.relatedTarget).data('id');
            //menggunakan fungsi ajax untuk pengambilan data
            $.ajax({
                type : 'post',
                url : 'detail.php',
                data :  'rowid='+ rowid,
                success : function(data){
                $('.fetched-data').html(data);//menampilkan data ke dalam modal
                }
            });
         });
    });
  </script>
		
        <script src="js/jquery-1.11.2.min.js"></script>
        <script src="bootstrap/js/bootstrap.js"></script>
        <script src="datatables/jquery.dataTables.js"></script>
        <script src="datatables/dataTables.bootstrap.js"></script>
        <script type="text/javascript">

//            jika dipilih, nim akan masuk ke input dan modal di tutup
            $(document).on('click', '.pilih', function (e) {
                document.getElementById("custno").value = $(this).attr('data-nim');
				document.getElementById("custname").value = $(this).attr('data-nim1');
				document.getElementById("alamat").value = $(this).attr('data-nim2');
				document.getElementById("telp").value = $(this).attr('data-nim3');
				document.getElementById("cabang1").value = $(this).attr('data-nim4');
				document.getElementById("typel").value = $(this).attr('data-nim7');
				document.getElementById("type").value = $(this).attr('data-nim5');
				document.getElementById("stat").value = $(this).attr('data-nim6');
				document.getElementById("jaringan").value = $(this).attr('data-nim8');
				
                $('#myModal').modal('hide');
            });
			
			
//            tabel lookup mahasiswa
            $(function () {
                $("#lookup").dataTable();
            });

            function dummy() {
                var nim = document.getElementById("nim").value;
                alert('Nomor Induk Mahasiswa ' + nim + ' berhasil tersimpan');
				
				var ket = document.getElementById("ket").value;
                alert('Keterangan ' + ket + ' berhasil tersimpan');
            }
        </script>
        

		
    </body>
</html>
