<div class="wrap wpcsr-content">
	<h1 class="wp-heading-inline"><?php esc_html_e('Shipment Country', '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 Country', 'wpcargo-shipment-rate' ); ?></h4>
				<form class="wpcsr-form add-country-form">
					<table class="form-table wpcsr_add_table">
						<tr>
							<th><label><?php esc_html_e('Country', 'wpcargo-shipment-rate' ); ?></label></th>
							<td><input type="text" name="wpcsr_country" id="wpcsr_country" class="wpcsr_detail wpcsr_country" value="" required="required" /></td>
						</tr>
						<tr>
							<th><label><?php esc_html_e('Slug', 'wpcargo-shipment-rate' ); ?></label></th>
							<td><input type="text" name="wpcsr_country_slug" id="wpcsr_country_slug" class="wpcsr_detail wpcsr_country_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 Country', 'wpcargo-shipment-rate' ); ?>" /></td>
						</tr>
					</table>
				</form>
			</div>
			<div class="wpcsr-form-section">
				<h4><?php esc_html_e('Import Country', '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 you file cannot be read by the system, based on your upload file delimiter.', 'wpcargo-shipment-rate' ); ?></p>
					<p>
					<input type="hidden" name="section" value="conutry" />
					<input type="submit" id="import_location" class="wpcsr_btn wpcsr_submit" value="<?php esc_html_e('Import Country', 'wpcargo-shipment-rate' ); ?>" />
					</p>
				</form>
				<?php
				$templatename_unique = "shipping-location-template.csv";
				$csv_file 		= fopen($templatename_unique, "w");
				$file_header 	= array( 
					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 Countries', 'wpcargo-shipment-rate' ); ?></h4>
				<a id="wpcsr-export-location" href="#" class="button button-primary button-large"><?php esc_html_e('Download Countries', 'wpcargo-shipment-rate' ); ?></a>
			</div>
		</div>
		<div class="column two-thirds">
			<div class="wpcsr-table-section wpcsr-location-table">
				<?php wpcsr_pagination( $pagelink, $page_count, $page ); ?>
				<table class="wpcsr-table location-table">
					<thead>
						<tr>
							<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-<?php echo $data->location_id;?>">
									<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>
										<a href="#" class="wpcsr-edit edit-location edit-btn" data-id="<?php echo $data->location_id;?>"><i class="far fa-edit"></i><?php esc_html_e('Edit', 'wpcargo-shipment-rate' ); ?></a>
										<a href="#" class="wpcsr-delete delete-location delete-btn" data-section="location" data-id="<?php echo $data->location_id;?>"><?php esc_html_e('Delete', 'wpcargo-shipment-rate' ); ?></a>
									</td>
								</tr>
							<?php endforeach;?>
						<?php endif; ?>
					</tbody>
				</table>
				<?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>