<?php
// [tm-quick-servicebox]
if( !function_exists('themetechmount_sc_quickservice_contentbox') ){
function themetechmount_sc_quickservice_contentbox( $atts, $content=NULL ){
	
	$return = '';
	
	if( function_exists('vc_map') ){ 
	
	global $tm_vc_custom_element_quickservice_box;
	$options_list = themetechmount_create_options_list($tm_vc_custom_element_quickservice_box);
	
	extract( shortcode_atts(
		$options_list
	, $atts ) );
	

		
		
				
		// Starting wrapper of the whole arear
		$return .= themetechmount_box_wrapper( 'start', 'quickservicebox', get_defined_vars() );
		
		// Heading element
		$return .= themetechmount_vc_element_heading( get_defined_vars() );
	
		// Getting $args for WP_Query
		$args = themetechmount_get_query_args( 'quickservicebox', get_defined_vars() );
	
		if( !empty($quickservice_content) ){
		
			$static_boxes = (array) vc_param_group_parse_atts( $quickservice_content );

				
				$return .= '<div class="row multi-columns-row themetechmount-boxes-row-wrapper">';
				foreach( $static_boxes as $tm_box ){
					$quickservice_desc  = ( !empty($tm_box['quickservice_boxcontent']) ) ? '<div class="tm-servicebox-description">'.$tm_box['quickservice_boxcontent'].'</div>' : '' ;
					
					$quickservice_boxnumber  = ( !empty($tm_box['quickservice_boxnumber']) ) ? '<div class="tm-servicebox-number">'.$tm_box['quickservice_boxnumber'].'</div>' : '' ;
					
					$tm_box['quickservice_boxlink']=( !empty($tm_box['quickservice_boxlink']) ) ? $tm_box['quickservice_boxlink'] : '';
					
					// Builing URL array
					$url =  themetechmount_vc_build_link($tm_box['quickservice_boxlink']);
						
		
					$tm_bicon= do_shortcode('[tm-icon type="' . $tm_box['i_type'] . '" icon_linecons="' . $tm_box['i_icon_linecons'] . '" icon_themify="' . $tm_box['i_icon_themify'] . '" icon_fontawesome="' . $tm_box['i_icon_fontawesome'] . '" icon_kw_anomica="' . $tm_box['i_icon_kw_anomica'] . '" ]');
					
										
					$quickservice_boxtitle      = ( !empty($tm_box['quickservice_boxtitle']) ) ? '<div class="tm-box-title"><h4>'.$tm_box['quickservice_boxtitle'].'</h4></div>' : '' ;
				
					$quickservice_buttontitle      = ( !empty($tm_box['quickservice_buttontitle']) ) ? '<div class="tm-box-Button-link">'.$tm_box['quickservice_buttontitle'].'</div>' : '' ;
							
					if ( strlen( $tm_box['quickservice_boxlink'] ) > 0 && strlen( $url['url'] ) > 0 ) {
						
						$quickservice_buttontitle      = ( !empty($tm_box['quickservice_buttontitle']) ) ? '<div class="tm-box-Button-link"><a class="tm_element-link" href="' . esc_attr( $url['url'] ) . '" title="' . esc_attr( $url['title'] ) . '" target="' . ( strlen( $url['target'] ) > 0 ? esc_attr( $url['target'] ) : '_self' ) . '">'.$tm_box['quickservice_buttontitle'].'</a></div>' : '' ;
		
					}
		
					
					$return .= themetechmount_column_div('start', $column );
						$return .= '
						<div class="tm-quickservices-box-wrapper tm-shadow-box">
							<div class="tm-quickservice-content" >
							  <div class="tm-servicebox-icon-wrapper">
							    '.$tm_bicon.'
							    '.$quickservice_boxnumber.'
							  </div>
							  <div class="tm-servicebox-details">
								'.$quickservice_boxtitle.'
								'.$quickservice_desc.'
								'.$quickservice_buttontitle.'
							  </div>
							</div>
						</div>
						';
					$return .= themetechmount_column_div('end', $column );
				} // end foreach
				$return .= '</div>';
				
			} // end if
			
		$return .= themetechmount_box_wrapper( 'end', 'static', get_defined_vars() );
		
		/* Restore original Post Data */
		wp_reset_postdata();
	
} else {
		$return .= '<!-- Visual Composer plugin not installed. Please install it to make this shortcode work. -->';
	}

	return $return;	
	
}
}
add_shortcode( 'tm-quick-servicebox', 'themetechmount_sc_quickservice_contentbox' );