<?php
	global $wpcargo;
	$shipment_id 		= $shipment_detail->ID;
	$shipper_fields 	= wpc_cf_get_fields('shipper_info');
?>
<div id="shipper-info" class="wpcargo-row">
    <div class="wpcargo-col-md-4"></div>
	<?php if( empty( $options ) || !array_key_exists( 'wpc_cf_disable_shipper', $options ) ): ?>
    <div class="wpcargo-col-md-4 detail-section">
            <p id="shipper-header" class="header-title" style="text-align: center"><strong><?php echo apply_filters('result_shipper_address', __('Shipper Address', 'wpcargo-custom-field' )); ?></strong></p>
            <div class="shipper details" style="text-align: center">
			<?php
                if( !empty( $shipper_fields ) ){
                    foreach( $shipper_fields as $field){
						$field_key 		= get_post_meta($shipment_id, $field->field_key, TRUE);
						$field_label 	= stripslashes( $field->label );
						if( is_serialized($field_key) ){
							if( $field->field_type == 'url' ) {
								$url_key_unserialized = unserialize($field_key);
								if(is_array($url_key_unserialized)) {	
									$target_blank = !empty($url_key_unserialized[2]) ? 'target="_blank"' :'';
									echo '<p><span class="label">'.$field_label.' : </span>'.'<a href="'.$url_key_unserialized[1].'" '.$target_blank.' >'.$url_key_unserialized[0].'</a>'.'</p>';
								}
							} else {
								$field_key = maybe_unserialize($field_key);
								$field_key = array_filter( array_map('trim', $field_key ) );
								$field_key = implode(", ", $field_key);
								echo '<p><span class="label">'.$field_label.' : </span>'.$field_key.'</p>';
							}
						}
						elseif( $field->field_type == 'file' ){
							echo '<div class="wpcargo-col-4">';
							echo '<p class="label">'.$field_label.'</p>';
							$explode_data = explode(",", $field_key);
							if(is_array($explode_data)){
								foreach(array_filter($explode_data) as $get_file){
									echo '<div class="file-wrap">';
										?><a href="<?php
										echo wp_get_attachment_url($get_file);
										?>"><?php
										echo wp_get_attachment_image($get_file, 'thumbnail', TRUE);
										?></a>
										<?php
										
									echo '</div>';
								}
							}
							echo '</div>';
						}						
						else{
							echo '<p><span class="label">'.$field_label.' : </span>'.$field_key.'</p>';
						}
                    }
                }
            ?>
            </div>
    </div>
	<?php endif; ?>

    <div class="wpcargo-col-md-4"></div>

    <div class="clear-line"></div>
</div>
