<div class="wrap wpcsr-content">
	<h1 class="wp-heading-inline"><?php esc_html_e('Shipment Delivery Types', 'wpcargo-shipment-rate' ); ?></h1>
	<p><?php esc_html_e('These options will allow you to categorize your shipment rates according to delivery type.', 'wpcargo-shipment-rate' ); ?></p>
	<div class="column-wrap">
		<div class="column one-third">
			<div class="wpcsr-form-section">
			<h4><?php esc_html_e('Add a new Delivery Type', 'wpcargo-shipment-rate' ); ?></h4>
				<form id="add-delivery-form" class="wpcsr-form">
					<table class="form-table wpcsr_add_table">
						<tr>
							<th><label><?php esc_html_e('Delivery Title', 'wpcargo-shipment-rate' ); ?></label></th>
							<td><input type="text" name="wpcsr_delivery" id="wpcsr_delivery" class="wpcsr_detail wpcsr_delivery" value="" required="required" /></td>
						</tr>
						<tr>
							<th><label><?php esc_html_e('Description', 'wpcargo-shipment-rate' ); ?></label></th>
							<td>
								<textarea name="wpcsr_delivery_description" id="wpcsr_delivery_description" class="wpcsr_detail wpcsr_delivery_description" cols="30" rows="10"></textarea>
							</td>
						</tr>
						<tr>
							<td></td>
							<td><input type="submit" id="wpcsr_submit_delivery" class="wpcsr_btn wpcsr_submit" value="<?php esc_html_e('Add Delivery Type', 'wpcargo-shipment-rate' ); ?>" /></td>
						</tr>
					</table>
				</form>
			</div>
			<div class="wpcsr-form-section">
				<h4><?php esc_html_e('Import delivery', 'wpcargo-shipment-rate' ); ?></h4>
				<p><a href="#" id="download-deliverycsv-template"><?php esc_html_e('Download', 'wpcargo-shipment-rate' ); ?></a> <?php esc_html_e('.csv import template.', 'wpcargo-shipment-rate' ); ?></p>
				<form id="import-delivery-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="delivery_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="delivery" />
					<input type="submit" id="import_delivery" class="wpcsr_btn wpcsr_submit" value="<?php esc_html_e('Import delivery', 'wpcargo-shipment-rate' ); ?>" />
					</p>
				</form>
				<?php
				$templatename_unique = "shipping-delivery-template.csv";
				$csv_file 		= fopen($templatename_unique, "w");
				$file_header 	= array( 
					wpcsr_delivery_id_label(),
					wpcsr_name_label(), 
					wpcsr_delivery_desc_label()
				);
				fputcsv( $csv_file, $file_header );
				fclose($csv_file);
				?>
				<script>
				jQuery(document).ready(function($) {
					$('#download-deliverycsv-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 Delivery', 'wpcargo-shipment-rate' ); ?></h4>
				<a id="wpcsr-export-delivery" href="#" class="button button-primary button-large"><?php esc_html_e('Download deliveries', 'wpcargo-shipment-rate' ); ?></a>
			</div>
		</div>
		<div class="column two-thirds">
			<div class="wpcsr-table-section wpcsr-delivery-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="delivery" class="wpcsrate-bulk-delete delete-btn button button-medium"><?php esc_html_e('Delete', 'wpcargo-shipment-rate' ); ?></a>
				<table class="wpcsr-table delivery-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('Label', 'wpcargo-shipment-rate' ); ?></th>
							<th class="tbl-head"><?php esc_html_e('Description', 'wpcargo-shipment-rate' ); ?></th>
							<th class="tbl-head"><?php esc_html_e('Actions', 'wpcargo-shipment-rate' ); ?></th>
						</tr>
					</thead>
					<tbody>
						<?php if( !empty( $wpcsr_delivery ) ): ?>
							<?php foreach($wpcsr_delivery as $data):?>
								<tr class="tbl-data tbl-data-<?php echo $data->id;?>">
									<td><input type="checkbox" class="bulk_id" name="rate_bulk_action[]" value="<?php echo $data->id;?>"></td>
									<td class="id"><?php echo $data->id;?></td>
									<td class="title"><?php echo $data->title;?></td>
									<td class="description"><?php echo $data->description;?></td>
									<td>
										<span class="dashicons dashicons-edit wpcsr-edit edit-delivery" data-section="delivery" data-id="<?php echo $data->id;?>"></span>
										<span class="dashicons dashicons-trash wpcsr-delete" data-section="delivery" data-id="<?php echo $data->id;?>" ></span>
									</td>
								</tr>
							<?php endforeach;?>
						<?php endif; ?>
					</tbody>
				</table>
				<a href="#" data-section="delivery" 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="delivery-edit" class="modal">
	<div class="modal-content">
		<div class="modal-title">
			<p><?php esc_html_e('Edit Delivery', 'wpcargo-shipment-rate' ); ?>
			<span class="close-btn">&times;</span></p>
		</div>
		<div class="modal-body">
			<form id="update-delivery" class="wpcsr-form edit-delivery-form">
			</form>
		</div>
	</div>
</div>