<!--
Author 		  : Tagor
Last update   : 23/7/2014
Desc          : view for list - customers
-->
	<div class="easyui-layout" data-options="fit:true,border:false">
		<div data-options="region:'north',border:false" style="height:30px">
			<form id="frm_tempo_save" method="POST" action="<?php echo base_url()?>list/customers/temporary_save" enctype="multipart/form-data">
				<input type="file" name="cust_file" id="cust_file" />
				<a href="javascript:void(0)" class="easyui-linkbutton" onclick="tempo_save()">Upload</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" onclick="how_import()">How to Import</a>
			</form>
		</div>
		<div id="form-body" data-options="region:'center',border:false">
			<!--div id="form-wrapper" class="easyui-panel"  style="width:1180%;height:548px;padding:5px;">
				<form id="fm_customer" name="fm_customer" method="post">
					<div>
						<table id="tt" class="easyui-datagrid" iconCls="icon-save" rownumbers="true" data-options="fit:false"  style="width:auto;">
							<thead>
								<tr>
									<th field="CustomerCode" width="150" align="left" halign="center" sortable="true">Customer No.</th>
									<th field="CustomerName" width="220" align="left" halign="center" sortable="true">Name</th>
									<th field="PhoneNumber" width="120" align="left" halign="center">Phone</th>
									<th field="ContactPerson" width="170" align="left"  halign="center">Contact</th>
									<th field="SalesLimit" width="120" align="right" halign="center" sortable="true" formatter="formatRp">Balance</th>
									<th field="CurrencyName" width="100" align="center" halign="center">Currency</th>
									<th field="TransStatus" width="100" align="center" halign="center">Status</th>
								</tr>
							</thead>
						</table>					
					</div>
				</form>
			</div>
			<div id="form-footer">
				<a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="<?php echo $menu_link?>/save_import">Save</a>
				<a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-cancel" onclick="">Cancel</a>
			</div-->
			<div id="CodeExist">
				Duplicate Customer Code :
				<div id="CodeExistChild" style="color:red;">text</div>
			</div>
			
			<div id="dialog-how-to-import" class="easyui-dialog" style="width:660px;height:550px;left:150px;top:50px;background-color:#F8F8F8;padding: 0 0px 0 0px" closed="true" data-options="modal:true,resizable:true,iconCls:'icon-save'">
				<div>
					<ul style="list-style:none;">
						<li>1.  Buka aplikasi <i>Accurate</i></li>
						<li>2.  Pilih menu <i>Customer</i></li>
						<li>3.  Pada Customer, pilih tombol <i>Print</i> </li>
						<li>4.  Setelah terbuka tab Customer List, pilih tombol <i>Modify</i></li>
						<li>5.  Pada pop up Report Format, pilih <i>Available Columns</i></li>
						<li>
							6.  Silahkan seleksi kolom pada daftar <i>Available Columns</i> dengan ketentuan :
							<ul style="list-style:none;">
								<li>Customer Name</li>
								<li>Address 1</li>
								<li>Address 2</li>
								<li>City</li>
								<li>Province</li>
								<li>Zip Code</li>
								<li>Country</li>
								<li>Phone</li>
								<li>Contact Name</li>
								<li>Fax</li>
								<li>Email</li>
								<li>Web Page</li>
								<li>Tax Number</li>
								<li>PKP No</li>
								<li>Notes</li>
								<li>Tax Type</li>
								<li>Credit Limit</li>
							</ul>
						</li>
						<li>7.  Masih pada pop up Report Format, pilih <i>Columns & Filters</i></li>
						<li>8.  Pilih Tab <i>Selected Columns & Filters</i></li>
						<li>9.  Centang semua <i>checkbox</i> selain Customer Type Name</li>
						<li>10. Masih pada pop up Report Format, pilih menu <i>Headers & Footers</i></li>
						<li>11. Hilangkan centang pada :
							<ul>
								<li><i>Company Name</i></li>
								<li><i>Report Title</i></li>
								<li><i>Subtitle</i></li>
								<li><i>Filtered By</i></li>
								<li><i>Column Title</i></li>
								<li><i>Show Report Header on each page</i></li>
								<li><i>Show Column Header on each page</i></li>
								<li><i>Show Report Footer</i></li>
							</ul>
						</li>
						<li>12. Masih pada pop up Report Format, pilih menu <i>Page Setup & Fonts</i></li>
						<li>13. Ubah Paper Size menjadi <i>Tabloid</i></li>
						<li>14. Klik tombol <i>OK</i></li>
						<li>15. Klik Tombol Export <i>Excel</i></li>
						<li>16. Pada pop up Export to excel (Page Range) pilih Radio Button <i>All</i></li>
						<li>17. Pada pop up Export to excel (Export Settings) hilangkan semua centang checkbox</li>
						<li>18. Centang Open Excel After Export</li>
						<li>19. Klik OK</li>
						<li>20. Pilih Destinasi penyimpanan</li>
						<li>21. Save</li>
						<li>22. Silahkan import data Customer</li>
					</ul>
				</div>
			</div>
			
		</div>
	</div>
	
	<script>
		function how_import(){
			$('#dialog-how-to-import').dialog('open');
		}
		
		/* function tempo_save(){
			$('#frm_tempo_save').submit();
		} */
		$(function(){
			$('#CodeExist').hide();
		});
		
		function tempo_save(){
			var fd = new FormData();    
			fd.append( 'cust_file', $('#cust_file')[0].files[0]);

			$.ajax({
				url: 'temporary_save',
				data: fd,
				processData: false,
				contentType: false,
				type: 'POST',
				dataType:'json',
				success: function(msg){
					if(msg.Code == 1){
						$.messager.alert('Info',msg.keterangan);
					}
					else if(msg.Code == 2){
						$.messager.alert('Info','<br /> Kode '+ msg.keterangan + ' sudah ada, <br /> silahkan rubah dan upload ulang semua data');
						$('#CodeExist').show();
						$('#CodeExistChild').text(msg.keterangan);
					}
					else{
						$('#CodeExist').hide();
						$.messager.alert('Info',msg.keterangan);
					}
				}
			});
		}
	</script>