<?php
if (!defined('ABSPATH')) {
    exit;
}
?>
<table class="wt-pfd-mapping-tb wt-pfd-exporter-meta-mapping-tb" data-field-type="<?php echo esc_attr( $meta_mapping_screen_field_key ); ?>">
	<thead>
		<tr>
    		<th>
    			<?php 
    			$is_checked=(isset($meta_mapping_screen_field_val['checked']) && $meta_mapping_screen_field_val['checked']==1 ? 1 : 0);
    			$checked_attr=($is_checked==1 ? ' checked="checked"' : '');
    			?>
    			<input type="checkbox" name="" class="wt_pf_mapping_checkbox_main" <?php echo esc_attr( $checked_attr ); ?>>
    		</th>
    		<th width="35%"><?php esc_html_e('Column', 'webtoffee-product-feed');?></th>
    		<th><?php esc_html_e('Column name', 'webtoffee-product-feed');?></th>
                <th></th>
                <th></th>
    	</tr>
	</thead>
	<tbody>
		<?php
		$tr_count=0; 
		
		if(isset($meta_mapping_screen_field_val['fields']) && is_array($meta_mapping_screen_field_val['fields']) && count($meta_mapping_screen_field_val['fields'])>0)
		{
			foreach($meta_mapping_screen_field_val['fields'] as $key=>$val)
			{
				$val=is_array($val) ? $val : array($val, 0);
				$label=$val[0];

				if(isset($current_meta_step_form_data[$key])) /* forma data/template data available */
				{
					$val=(is_array($current_meta_step_form_data[$key]) ? $current_meta_step_form_data[$key] : array($current_meta_step_form_data[$key], 1));
				}else
				{
					$val[1]=$is_checked; //parent is checked
				}

				$selected_val = !empty($current_meta_step_form_data[$key][0]) ? $current_meta_step_form_data[$key][0] : $key;
				$wc_prod_attributes = Webtoffee_Product_Feed_Sync_Common_Helper::attribute_dropdown( $this->to_export, $selected_val);
				include "_export_mapping_tr_html.php";
				$tr_count++;
			}
		}

		if($tr_count==0)
		{
			?>
			<tr>
				<td colspan="3" style="text-align:center;">
					<?php esc_html_e('No fields found.', 'webtoffee-product-feed'); ?>
				</td>
			</tr>
			<?php
		}
		?>
	</tbody>
</table>   