<div style="height:40px;">
</div>
 <h1>Upload File BC 41 Scrap</h1>
   <form method="post" action="" id="upload_file_bc41_scrap_new">
	  <label for="userfile_bc41_scrap_new">Customer</label>
	  <select name="cust_code_bc41_scrap_new" id="cust_code_bc41_scrap_new">
			<?php 
				foreach($cust_code as $data){
					echo "<option value='". $data-> suppno."'>".$data-> suppname."</option>";
				}
			?>
	  </select>
	  <br>
      <label for="userfile_bc41_scrap_new">File</label>
      <input type="file" name="userfile_bc41_scrap_new" id="userfile_bc41_scrap_new" size="40" />
      <input type="submit" name="submit" id="submit" value="Upload" />
   </form>
   <hr>
   <h2>Files</h2>
   <div id="files_bc41_scrap_new" style="font-weight:bold;font-size:17px;"></div>
   
<script type="text/javascript">
    
    $(document).ready(function(){
	
		function refresh_files()
		{
		   $.get('<?php echo base_url().'loaderfiles/masterdata/'; ?>')
		   .success(function (data){
			  $('#files_bc41_scrap_new').html(data);
		   });
		};
	
		$('#userfile_bc41_scrap_new').live('change', function(){
			$('#files_bc41_scrap_new').html('<p>'+ $('#userfile_bc41_scrap_new').val() +'</p>'); 
		});
		
		jQuery.extend({
			handleError: function( s, xhr, status, e ) {
			// If a local callback was specified, fire it
				if ( s.error )
					s.error( xhr, status, e );
				// If we have some XML response text (e.g. from an AJAX call) then log it in the console
				else if(xhr.responseText)
					console.log(xhr.responseText);
			}
		});
		
		$(function() {
			$('#upload_file_bc41_scrap_new').submit(function(e) {
				e.preventDefault();
				$.ajaxFileUpload({
				 url         :'./pasi_uploadmd/ct_uploadbc41_scrap_new/upload_file_bc41_scrap_new/',
				 secureuri      :false,
				 fileElementId  :'userfile_bc41_scrap_new',
				 dataType    : 'json',
				 data        : {
					'userfile_bc41_scrap_new'  : $('#userfile_bc41_scrap_new').val(),
					'cust_code_bc41_scrap_new' : $('#cust_code_bc41_scrap_new').val()
				 },
				 success  : function (data, status)
				 {
					 alert(data.des);
					if(data.sts == '00') {
						$('#frmuploadbc41_scrap_newdialog').dialog("destroy"); 
						$(".frmuploadbc41_scrap_newdialog_cl").remove(); 
						$("body").append('<div id="frmuploadbc41_scrap_newdialog" title="UPLOAD FILE BC 41" class="frmuploadbc41_scrap_newdialog_cl"></div>'); 
						
						jQuery("#tbluploadbc41_scrap_new").trigger('reloadGrid');
					}
					
				 }
		  });
		  return false;
		   });
		});


	});
		  	
</script>



	
	