<?php
$this->load->view('includes/header.php');
	echo '<font class="title">'.$menu_path.'</font>';
	echo '<br>';
	$this->fungsi->disp_sys_msg();
?>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="application/javascript">
$(document).on('click', '#createpo', function() {
//alert("test");
var type = $("#type").val();
var pp = $("#pp").val();
var id_vendor = $("#id_vendor").val();
var trans_sup = $("#trans_sup").val();
var harga_sup = $("#harga_sup").val();
var vol_coll = $("#vol_coll").val();
var id_ba = $("#id_ba").val();
var type = $("#type").val();
 $.ajax({url: "../sap/createpo.php",
                    data: {formData : $('#form_ba_sup').serialize()}, // Convert a form to a JSON string representation
                    type: 'post',                   
                    async: true,
                    beforeSend: function() {
                    },
					data: "pengirim="+type+"&pp="+pp+"&vendor="+id_vendor+"&hargasup="+harga_sup+"&transsup="+trans_sup+"&volcoll="+vol_coll+"&id_ba="+id_ba+"",
                    complete: function() {
                         $( "#msg" ).append( "" );
                    },
                    success: function (data) {
						  var json = $.parseJSON(data);
						  alert(json.msg);
						 
						  	$("#po").val(json.nopo);
						
						  // $( "#msg" ).append( "<strong>"+json.errmsg+"</strong><br><strong>No PO :"+json.nopo+"</strong>" );
                    },
                    error: function (request,error) {
                        // This callback function will trigger on unsuccessful action                
                        alert('Network error has occurred please try again!');
                    }
                });          	
});
</script>
</head>

<body>
<div id="wrapper">
	
	<!-- start page -->
    <div id="page">
        <form action="<?php echo $form_action ?>" method="POST" enctype="multipart/form-data" name="form1" id="form_ba_sup">
        
     <script type="text/JavaScript">

function MM_jumpMenu(targ,selObj,restore)
{
		eval(targ+".location='form_ba_sup.php?pengirim="+document.form1.pengirim.value+"&id_ba="+'<?php echo  $_GET['id_ba']; ?>'+"'");
	}

</script>

	  <table width="100%" border="0" align="center">
	    <tr>
	      <td colspan="2" align="center"> <div id="msg"></div></td>
        </tr>
	    <tr>
	      <td colspan="2" align="center"><font size="+2"><span class="primary">
	        <input name="id_ba" type="hidden" id="id_ba" value="<?php echo $id_ba; ?>" />
	      </span>Form Berita Acara<label for="textfield"></label>
	          <span class="primary"><strong><?php echo $row['id_ba']; ?></strong></span></font></td>
        </tr>
	    <tr>
	      <td width="182" align="right"> Tanggal :</td>
	      <td width="390"><input name="tgll" type="text" readonly="readonly" id="tgll" value="<?php 
echo date("d-m-Y H:i"); 
?>" /> </td>
        </tr>
		 
		<tr>
	      <td align="right">Pengirim:</td>
	      <td><label for="select"></label>
          	<select name="pengirim" id="type"  onChange="MM_jumpMenu('self',this,0)">
           					<option <?php if($_GET['pengirim']=='CABANG'){ echo "selected=selected";}?> value="CABANG">CABANG</option>
							<option  <?php if($_GET['pengirim']=='SUPPLIER'){ echo "selected=selected";}?> value="SUPPLIER">SUPPLIER</option>
                            <option  <?php if($_GET['pengirim']=='SUPPLIERPJK'){ echo "selected=selected";}?> value="SUPPLIERPJK">SUPPLIER PAJAK</option>
			</select>          </td>
        </tr>
       
        <?php if($_GET['pengirim']=='CABANG' || $_GET['pengirim']=='') 
		{
			
		?>
	    <tr>
	      <td align="right"><span class="primary">No. Surat Jalan : </span></td>
	      <td><span class="primary">
	        <input name="no_sj" readonly="readonly" type="text" />
	        <input type="button" name="choice" onclick="window.open('../popup_sj_ba','popuppage','width=600,height=500,scrollbar=yes,scrollbars=yes,top=100,left=100');" value="..." />
	        <input type="hidden" name="harga" id="harga" /><input type="hidden" name="matdoc" id="matdoc" />
	      </span></td>
        </tr>
		<tr>
	      <td align="right">Sewa Transport :</td>
	      <td><span class="primary">
	        <input name="sewa_trans" type="text" id="sewa_trans" />(Rp)
	      </span></td>
        </tr>
		<tr>
	      <td align="right">Transport WGI :</td>
	      <td><span class="primary">
	        <input name="wgi_trans" type="text" id="wgi_trans" />(Rp)
	      </span></td>
        </tr>
        <tr>
	      <td align="right">Type :</td>
	      <td><span class="primary">
	        <input name="tipe" type="text" id="tipe" />
	      </span></td>
        </tr>
        
        <? }
		elseif ($_GET['pengirim']=='SUPPLIER' ) 
		{ 
		
		?>
       <tr>
    <td width="182" height="26" align="right" class="primary"> ID Supplier : </td>
    <td width="390" class="primary"><input name="supp" readonly="readonly" type="text" value="<?php echo $_GET['supp']; ?>" size="5" /> 
      <label for="nama_supp"></label>
      <input type="text" name="nama_supp" id="nama_supp" value="<?php echo $_GET['nama_supp']; ?>"  readonly="readonly" />
      <input type=button name=choice onclick="window.open('../popup_supplier_pusat','popuppage','width=600,height=500,scrollbar=yes,scrollbars=yes,top=100,left=100');" value="..." /></td>
  </tr>
   <tr>
    <td width="182" height="26" align="right" class="primary"> No. SJ Supplier : </td>
    <td width="390" class="primary"><input name="sj_supp" type="text" value="<?php echo $_GET['sj_supp']; ?>" size="20" />    </td>
  </tr>
  <tr>
	      <td align="right">Type :</td>
	      <td width="390" class="primary"><select name="type" id="type"  >
                <option value="container">Container</option>
                <option  value="iso tank">Iso Tank</option>
                <option   value="truck">Truck </option>
              </select></td>
        </tr>
  <tr>
	      <td align="right">Harga Supplier :</td>
	      <td><span class="primary">
	        <input name="harga_sup" type="text" id="harga_sup"  readonly="readonly" value="<?php echo $_GET['harga_sup']; ?>" />(Rp)
	      </span></td>
        </tr>
		<tr>
	      <td align="right">Transport Supplier :</td>
	      <td><span class="primary">
	        <input name="trans_sup" type="text" id="trans_sup" value="<?php echo $_GET['trans_sup']; ?>"/>(Rp)
	      </span></td>
        </tr>
 <tr>
	      <td align="right">No PO :</td>
	      <td><span class="primary">
	        <input name="po" type="text" id="po" value="<?php echo $_GET['po']; ?>"/>(Supplier)
	      </span></td>
        </tr>
       <tr>
	      <td align="right">Vol Total :</td>
	      <td><span class="primary">
	        <input name="vol_total" type="text" id="vol_total" readonly='readonly' value="<?php echo $_GET['vol_total']; ?>"/>(Supplier)
	      </span></td>
        </tr>
        <tr>
	      <td align="right">Vol Sisa :</td>
	      <td><span class="primary">
	        <input name="vol_sisa" type="text" readonly='readonly' id="vol_sisa" value="<?php echo $_GET['vol_sisa']; ?>"/>(Supplier)
	      </span></td>
        </tr>
        <? }
		elseif ($_GET['pengirim']=='SUPPLIERPJK') 
		{ 
		
		?>
       <tr>
    <td width="182" height="26" align="right" class="primary"> ID Supplier : </td>
    <td width="390" class="primary"><input name="supp" readonly="readonly" type="text" value="<?php echo $_GET['supp']; ?>" size="5" /> 
      <label for="nama_supp"></label>
      <input type="text" name="nama_supp" id="nama_supp" value="<?php echo $_GET['nama_supp']; ?>"  readonly="readonly" />
      <input type=button name=choice onclick="window.open('../popup_supplier_pusat_ppn','popuppage','width=600,height=500,scrollbar=yes,scrollbars=yes,top=100,left=100');" value="..." /></td>
  </tr>
   <tr>
    <td width="182" height="26" align="right" class="primary"> No. SJ Supplier : </td>
    <td width="390" class="primary"><input name="sj_supp" type="text" value="<?php echo $_GET['sj_supp']; ?>" size="20" />    </td>
  </tr>
  <tr>
	      <td align="right">Type :</td>
	      <td width="390" class="primary"><select name="type" id="type"  >
                <option value="container">Container</option>
                <option  value="iso tank">Iso Tank</option>
                <option   value="truck">Truck </option>
              </select></td>
        </tr>
  <tr>
	      <td align="right">Harga Supplier :</td>
	      <td><span class="primary">
	        <input name="harga_sup" type="text" id="harga_sup" readonly="readonly" value="<?php echo $_GET['harga_sup']; ?>" />(Rp) (SEBELUM PAJAK)
	      </span></td>
        </tr>
        <tr>
	      <td align="right">PAJAK:</td>
	      <td><span class="primary">
	        <input name="ppn" type="text" id="ppn" readonly="readonly" value="<?php echo $_GET['ppn']; ?>"  />
	        (Rp) (PAJAK)
	      </span></td>
        </tr>
        <tr>
	      <td align="right">Harga Total :</td>
	      <td><span class="primary">
	        <input name="total" type="text" id="total" readonly="readonly" value="<?php echo $_GET['total']; ?>" />(Rp) (SESUDAH PAJAK)
	      </span></td>
        </tr>
		<tr>
	      <td align="right">Transport Supplier :</td>
	      <td><span class="primary">
	        <input name="trans_sup" type="text" id="trans_sup" value="<?php echo $_GET['trans_sup']; ?>"/>(Rp)
	      </span></td>
        </tr>
         <tr>
	      <td align="right">No PO :</td>
	      <td><span class="primary">
	        <input name="po" type="text" id="po"  value="<?php echo $_GET['po']; ?>"/>(Supplier Pajak)
	      </span></td>
        </tr>
<tr>
	      <td align="right">Vol Total :</td>
	      <td><span class="primary">
	        <input name="vol_total" type="text" id="vol_total" readonly='readonly' value="<?php echo $_GET['vol_total']; ?>"/>(Supplier Pajak)
	      </span></td>
        </tr>
        <tr>
	      <td align="right">Vol Sisa :</td>
	      <td><span class="primary">
	        <input name="vol_sisa" type="text" id="vol_sisa" readonly='readonly' value="<?php echo $_GET['vol_sisa']; ?>"/>(Supplier Pajak)
	      </span></td>
        </tr>
        <? } ?>
        <tr>
	      <td align="right"><span class="primary"> ID Vendor :
	        </p>
	        </span></td>
	     <td><span class="primary">
	        <input id="id_vendor" name="id_vendor" size="8" readonly="readonly" type="text" />
	        <input type="button" name="choice" onclick="window.open('/cis/sap/popup_dispven_cis.php','popuppage','width=600,height=500,scrollbar=yes,scrollbars=yes,top=100,left=100');" value="..." />
	     </span></td>
	      </tr>
		  <tr>
	      <td align="right"><span class="primary">Nama Vendor :
	        </p>
	        </span></td>
	     <td><span class="primary">
	        <input name="nama_vendor" size="40" readonly="readonly" type="text" />
	     </span></td>
	      </tr>
	    <tr>
	      <td align="right">No ISO :</td>
	      <td><span class="primary">
	        <input name="iso" type="text" id="iso" />
	      </span></td>
        </tr>
        <tr>
	      <td align="right">No Manifest :</td>
	      <td><span class="primary">
	        <input name="manifest" type="text" id="manifest" />
	      </span></td>
        </tr>
	    <tr>
	      <td align="right">Transporter :</td>
	      <td><span class="primary">
	        <input name="transporter" type="text" id="transporter" size="50" />
	      </span></td>
        </tr>
	    <tr>
	      <td align="right"><span class="primary">No. Polisi 1:
	        </p>
	        </span></td>
	      <td><span class="primary">
	        <input name="no_pol" type="text" />
	        </span></td>
	      </tr>
          <tr>
	      <td align="right"><span class="primary">No. Polisi 2:
	        </p>
	        </span></td>
	      <td>
	        <input name="no_pol2" type="text" /> 
	        *Khusus	ISO tank       </td>
	      </tr>
          <tr>
	      <td align="right"><span class="primary">Jumlah Vol :</span></td>
	      <td><span class="primary">
	        <input name="vol_coll" type="text" id="vol_coll" />
	      </span>Ltr</td>
        </tr>
	    <tr>
	      <td align="right">Jam Datang:</td>
	      <td><span class="primary">
	        <input name="jam_datang_coll" type="text" id="jam_datang_coll" />
	        </span></td>
	      </tr>
	    
	    <tr>
	      <td align="right"><span class="primary">Jam Diserahkan :</span></td>
	      <td><span class="primary">
	        <input name="jam_diserahkan_coll" type="text" id="jam_diserahkan_coll" />
	      </span></td>
        </tr>
	    <tr>
	      <td align="right"><span class="primary">Keterangan :</span></td>
	      <td><span class="primary">
	        <textarea name="note1_coll" cols="10" rows="3" id="note1_coll" > </textarea>
	        <input name="id_nu"  type="hidden" id="id_nu" value="<?php echo ($nu) ?>" />
	        <input name="id_cb" type="hidden" id="id_cb" value="<?php echo ($_SESSION[cabang])?>" />
	      </span></td>
        </tr>
	    <tr>
	      <td>&nbsp;</td>
	      <td><input type="submit" name="button" id="button" value="UPDATE">		  </td>
        </tr>
              </table>
      </form>
        
 <!-- start sidebars -->
		<!-- start content --><!-- end content -->
	  <div style="clear: both;">&nbsp;</div>
	</div>
	  <!-- end page -->
</div>