<div class="wrap wpcsr-content">
	<h1 class="wp-heading-inline"><?php esc_html_e('Shipment Locations', 'wpcargo-shipment-rate' ); ?></h1>
	<div class="column-wrap">
		<div class="column one-third">
			<div class="wpcsr-form-section">
			<h4><?php esc_html_e('Add a new location', 'wpcargo-shipment-rate' ); ?></h4>
				<form class="wpcsr-form add-location-form">
					<table class="form-table wpcsr_add_table">
						<tr>
							<th><label><?php esc_html_e('Location Name', 'wpcargo-shipment-rate' ); ?></label></th>
							<td><input type="text" name="wpcsr_location" id="wpcsr_location" class="wpcsr_detail wpcsr_location" value="" required="required" /></td>
						</tr>
						<tr>
							<th><label><?php esc_html_e('Slug', 'wpcargo-shipment-rate' ); ?></label></th>
							<td><input type="text" name="wpcsr_location_slug" id="wpcsr_location_slug" class="wpcsr_detail wpcsr_location_slug" value="" readonly="readonly" /></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="submit" id="wpcsr_submit_location" class="wpcsr_btn wpcsr_submit" value="<?php esc_html_e('Add Location', 'wpcargo-shipment-rate' ); ?>" /></td>
						</tr>
					</table>
				</form>
			</div>
			<div class="wpcsr-form-section">
				<h4><?php esc_html_e('Import Location', 'wpcargo-shipment-rate' ); ?></h4>
				<p><a href="#" id="download-locationcsv-template"><?php esc_html_e('Download', 'wpcargo-shipment-rate' ); ?></a> <?php esc_html_e('.csv import template.', 'wpcargo-shipment-rate' ); ?></p>
				<form id="import-location-form" class="wpcsr-form" method="post" enctype="multipart/form-data">
					<?php wp_nonce_field( 'wpc_import_ie_results_callback', 'wpc_ie_nonce' ); ?>
					<p><input type="file" name="shipment_file" id="location_file"/></p>
					<p><label for="compatibility"><?php esc_html_e('Delimiter', 'wpcargo-shipment-rate' ); ?></label><input id="compatibility" type="text" name="compatibility" value="," size="2"></p>
					<p class="description"><?php esc_html_e('Changed the delimiter if your file cannot be read by the system, based on your upload file delimiter.', 'wpcargo-shipment-rate' ); ?></p>
					<p>
					<input type="hidden" name="section" value="location" />
					<input type="submit" id="import_location" class="wpcsr_btn wpcsr_submit" value="<?php esc_html_e('Import Location', 'wpcargo-shipment-rate' ); ?>" />
					</p>
				</form>
				<?php
					$templatename_unique = "shipping-location-template.csv";
					$csv_file 		= fopen($templatename_unique, "w");
					$file_header 	= array( 
						wpcsr_location_id_label(),
						wpcsr_locations_label(), 
						wpcsr_slug_label(), 
					);
					fputcsv( $csv_file, $file_header );
					fclose($csv_file);
				?>
				<script>
					jQuery(document).ready(function($) {
						$('#download-locationcsv-template').on('click', function(e){
							e.preventDefault();
							window.location='<?php echo $templatename_unique; ?>';
						});
					});
				</script>
			</div>
			<div class="wpcsr-form-section">
				<h4><?php esc_html_e('Export Location', 'wpcargo-shipment-rate' ); ?></h4>
				<a id="wpcsr-export-location" href="#" class="button button-primary button-large"><?php esc_html_e('Download Locations', 'wpcargo-shipment-rate' ); ?></a>
			</div>
		</div>
		<div class="column two-thirds">
			<div class="wpcsr-table-section wpcsr-location-table">
				<div class="wpcsr-search-section">
					<input type="text" class="wpcsr-search-table">
					<input type="button" class="wpcsr-search-button" value="Search">
				</div>
				<?php wpcsr_pagination( $pagelink, $page_count, $page ); ?>
				<a href="#" data-section="location" class="wpcsrate-bulk-delete delete-btn button button-medium"><?php esc_html_e('Delete', 'wpcargo-shipment-rate' ); ?></a>
				<table class="wpcsr-table location-table">
					<thead>
						<tr>
							<th class="tbl-head bulk-action"><input id="checkall" type="checkbox"></th>
							<th class="tbl-head"><?php esc_html_e('ID', 'wpcargo-shipment-rate' ); ?></th>
							<th class="tbl-head"><?php esc_html_e('Location', 'wpcargo-shipment-rate' ); ?></th>
							<th class="tbl-head"><?php esc_html_e('Slug', 'wpcargo-shipment-rate' ); ?></th>
							<th class="tbl-head"><?php esc_html_e('Actions', 'wpcargo-shipment-rate' ); ?></th>
						</tr>
					</thead>
					<tbody>
						<?php if( !empty( $wpcsr_location ) ): ?>
							<?php foreach($wpcsr_location as $data):?>
								<tr class="tbl-data tbl-data-<?php echo $data->location_id;?>">
									<td><input type="checkbox" class="bulk_id" name="rate_bulk_action[]" value="<?php echo $data->location_id;?>"></td>
									<td class="wpcsr-td-id location"><?php echo $data->location_id;?></td>
									<td class="wpcsr-td-name location"><?php echo $data->location;?></td>
									<td class="wpcsr-td-slug location"><?php echo $data->location_slug;?></td>
									<td>
										<span class="dashicons dashicons-edit wpcsr-edit edit-location" data-section="location" data-id="<?php echo $data->location_id;?>"></span>
										<span class="dashicons dashicons-trash wpcsr-delete" data-section="location" data-id="<?php echo $data->location_id;?>" ></span>
									</td>
								</tr>
							<?php endforeach;?>
						<?php endif; ?>
					</tbody>
				</table>
				<a href="#" data-section="location" class="wpcsrate-bulk-delete delete-btn button button-medium"><?php esc_html_e('Delete', 'wpcargo-shipment-rate' ); ?></a>
				<?php wpcsr_pagination( $pagelink, $page_count, $page ); ?>
			</div>
		</div>
	</div>
</div>
<div id="location-edit" class="modal">
	<div class="modal-content">
		<div class="modal-title">
			<p><?php esc_html_e('Edit Location', 'wpcargo-shipment-rate' ); ?>
			<span class="close-btn">&times;</span></p>
		</div>
		<div class="modal-body">
			<form id="update-location" class="wpcsr-form edit-location-form">
			</form>
		</div>
	</div>
</div>