<?php
settings_fields('rtwwpcp_format_setting');
$rtwwpcp_get_setting = get_option('rtwwpcp_format_setting_opt');
$rtwwpcp_template_selected = isset( $rtwwpcp_get_setting[ 'pdf_format' ] ) ? $rtwwpcp_get_setting[ 'pdf_format' ] : '1';
$rtwwpcp_content_html_1 = '<table style="font-family: sans-serif; width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0">
	<tbody>
		<tr>
			<td style="padding: 50px 0px 50px 30px; width: 45%; text-align: center; vertical-align: top;"><img style="max-width: 100%; width: 350px; max-height: 260px; padding-bottom: 40px;" src="[product_img]" />
				<table style="font-family: sans-serif; width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td style="background-color: #ff9f00; color: #ffffff; float-right;text-align: center; padding 10px;line-height: 20px; height: 65px;"><a style="color: #ffffff; text-decoration: none; font-size: 24px;" href="[add_to_cart]">Add To Cart</a>
							</td>
						</tr>
					</tbody>
				</table>
			</td>
			<td style="text-align: left; padding: 50px 0px 50px 30px; width: 55%; vertical-align: top;">
				<table style="font-family: sans-serif; width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td style="font-size: 24px; font-weight: bold; color: #212121;">[product_name]
							</td>
						</tr>
						<tr>
							<td style="font-size: 16px; padding: 10px 0; color: #212121; font-weight: bold;"><span style="color: #fdcc0d; font-size: 20px;">★</span> <span style="color: #fdcc0d; font-size: 20px;">★</span> <span style="color: #fdcc0d; font-size: 20px;">★</span> <span style="color: #fdcc0d; font-size: 20px;">★</span> <span style="color: #fdcc0d; font-size: 20px;">★</span>
							</td>
						</tr>
						<tr>
							<td style="font-size: 20px; padding-top: 10px; font-weight: bold; color: #212121;">[product_price]
							</td>
						</tr>
						<tr id="rtwwpcp_cat_list">
							<td style="font-size: 20px; padding-top: 15px; color: #212121;">[product_category]
							</td>
						</tr>
						<tr id="rtwwpcp_variation_list">
							<td style="font-size: 20px; padding-top: 15px; color: #212121;">[variation]
							</td>
						</tr>
						<tr>
							<td style="padding-top: 20px; font-size: 16px; line-height: 26px; font-family: sans-serif;">[product_desc]
							</td>
						</tr>
					</tbody>
				</table>
			</td>
		</tr>
	</tbody>
</table>
<table style="font-family: sans-serif; width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0">
	<tbody>
		<tr>
			<td colspan="4" style="padding: 1px 35px 0 35px; background-color: #efefef;"></td>
		</tr>
		<tr>
			<td style="font-size: 16px; font-weight: bold; color: #212121; padding: 15px; text-align: center;" colspan="4">Products Image</td>
		</tr>
		<tr>
			<td style="width: 25%; padding: 15px; text-align: center;" width="25%"><img style="width: auto; max-width: 120px; max-height: 250px; padding-bottom: 15px;" src="[thumb_img_1]" /></td>
			<td style="width: 25%; padding: 15px; text-align: center;" width="25%"><img style="width: auto; max-width: 120px; max-height: 250px; padding-bottom: 15px;" src="[thumb_img_2]" /></td>
			<td style="width: 25%; padding: 15px; text-align: center;" width="25%"><img style="width: auto; max-width: 120px; max-height: 250px; padding-bottom: 15px;" src="[thumb_img_3]" /></td>
			<td style="width: 25%; padding: 15px; text-align: center;" width="25%"><img style="width: auto; max-width: 120px; max-height: 250px; padding-bottom: 15px;" src="[thumb_img_4]" /></td>
		</tr>
		<tr>
			<td colspan="4" style="padding: 1px 35px 0 35px; background-color: #efefef;"></td>
		</tr>
		<tr>
			<td style="padding: 20px 35px 0 35px; font-size: 16px; color: #212121; line-height: 26px; font-weight: bold;" colspan="4">Product Description</td>
		</tr>
		<tr>
			<td style="padding: 20px 35px; font-size: 14px; line-height: 26px;" colspan="4">[product_short_desc]</td>
		</tr>
	</tbody>
</table>';
$rtwwpcp_content_html_2 = '
<div>
	<div style="width: 50%; float: left; padding: 1%;">
		<div id="rtwwcpcp_img" style="width: 48%; float: left;"><img style="max-width: 100%; width: auto; padding: 5px; height: 200px;" src="[thumb_img_1]" /></div>
		<div id="rtwwcpcp_img" style="width: 48%; float: left;"><img style="max-width: 100%; width: auto; padding: 5px; height: 200px;" src="[thumb_img_2]" /></div>
		<div id="rtwwcpcp_img" style="width: 48%; float: left;"><img style="max-width: 100%; width: auto; padding: 5px; height: 200px;" src="[thumb_img_3]" /></div>
		<div id="rtwwcpcp_img" style="width: 48%; float: left;"><img style="max-width: 100%; width: auto; padding: 5px; height: 200px;" src="[thumb_img_4]" /></div>
	</div>
	<div style="width: 45%; float: left; padding: 1%;">
		<div style="font-family: sans-serif; width: 100%; border-collapse: collapse;">
			<div>
				<div style="font-size: 24px; font-weight: bold; color: #212121;">[product_name]</div>
			</div>
			<div>
				<div style="font-size: 17px; padding: 7px 0; color: #212121; font-weight: bold;"><span style="color: #fdcc0d; font-size: 20px;">★</span> <span style="color: #fdcc0d; font-size: 20px; verical-align: middle;">★</span> <span style="color: #fdcc0d; font-size: 20px;">★</span> <span style="color: #fdcc0d; font-size: 20px;">★</span> <span style="color: #fdcc0d; font-size: 20px;">★</span>
				</div>
			</div>
			<div style="font-size: 16px;">[product_price]</div>
			<div style="width: 100%; margin-top: 5px;">[product_category]</div>
			<div id="rtwwpcp_variation_list">
				<div style="padding-top: 10px;">[variation]</div>
			</div>
			<div>
				<div style="padding-top: 16px; font-size: 13px; line-height: 18px; font-family: sans-serif;">[product_short_desc]</div>
			</div>
			<div style="text-align: center; padding-top: 15px;">
				<div style="background-color: #d93c50; color: #ffffff; float-right;text-align: center; padding 10px; line-height: 45px; height: 45px; width: 200px;"><a style="color: #ffffff; text-decoration: none; font-size: 18px; font-weight: bold; letter-spacing: 2px; text-align: center;" href="[add_to_cart]">Add To Cart</a>
				</div>
			</div>
		</div>
	</div>
</div>
<table style="font-family: sans-serif; width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0">
	<tbody>
		<tr>
			<td style="padding: 1px 35px 0 35px; background-color: #efefef;" colspan="4"></td>
		</tr>
		<tr>
			<td style="padding: 20px 35px 0 35px; font-size: 16px; color: #212121; line-height: 26px; font-weight: bold;" colspan="4">Product Description</td>
		</tr>
		<tr>
			<td style="padding: 20px 35px; font-size: 13px; line-height: 18px;" colspan="4">[product_desc]</td>
		</tr>
		<tr>
			<td style="padding: 1px 35px 0 35px; background-color: #efefef;" colspan="4"> </td>
		</tr>
		<tr id="rtwwpcp_similar_prod">
			<td style="font-size: 18px; font-weight: bold; color: #212121; padding: 15px; text-align: center;" colspan="4">Similar Products</td>
		</tr>
		<tr id="relate_prod_tr">
			<td style="width: 25%; padding: 15px; text-align: center;" width="25%">
				<table id="rtwwpcp_relat_prod" style="font-family: sans-serif; width: 180px; border-collapse: collapse;" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td><img style="width: auto; max-width: 180px; height: 200px;" src="[relate_img_1]" /></td>
						</tr>
						<tr id="rtwwpcp_relat_prod_tr">
							<td style="font-size: 16px; font-weight: normal; padding-top: 10px; padding-bottom: 10px;">[relate_prod_1]</td>
						</tr>
						<tr>
							<td id="rtwwpcp_add_to_cart" style="font-size: 16px; font-weight: normal; background-color: #d93c50; height: 30px;"><a style="color: #ffffff; text-decoration: none;" href="[add_to_cart_1]">Buy Now</a></td>
						</tr>
					</tbody>
				</table>
			</td>
			<td style="width: 25%; padding: 15px; text-align: center;" width="25%">
				<table id="rtwwpcp_relat_prod" style="font-family: sans-serif; width: 180px; border-collapse: collapse;" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td><img style="width: auto; max-width: 180px; height: 200px;" src="[relate_img_2]" /></td>
						</tr>
						<tr id="rtwwpcp_relat_prod_tr">
							<td style="font-size: 16px; font-weight: normal; padding-top: 10px; padding-bottom: 10px;">[relate_prod_2]</td>
						</tr>
						<tr>
							<td id="rtwwpcp_add_to_cart" style="font-size: 16px; font-weight: normal; background-color: #d93c50; height: 30px;"><a style="color: #ffffff; text-decoration: none;" href="[add_to_cart_2]">Buy Now</a></td>
						</tr>
					</tbody>
				</table>
			</td>
			<td style="width: 25%; padding: 15px; text-align: center;" width="25%">
				<table id="rtwwpcp_relat_prod" style="font-family: sans-serif; width: 180px; border-collapse: collapse;" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td><img style="width: auto; max-width: 180px; height: 200px;" src="[relate_img_3]" /></td>
						</tr>
						<tr id="rtwwpcp_relat_prod_tr">
							<td style="font-size: 16px; font-weight: normal; padding-top: 10px; padding-bottom: 10px;">[relate_prod_3]</td>
						</tr>
						<tr>
							<td id="rtwwpcp_add_to_cart" style="font-size: 16px; font-weight: normal; background-color: #d93c50; height: 30px;"><a style="color: #ffffff; text-decoration: none;" href="[add_to_cart_3]">Buy Now</a></td>
						</tr>
					</tbody>
				</table>
			</td>
			<td style="width: 25%; padding: 15px; text-align: center;" width="25%">
				<table id="rtwwpcp_relat_prod" style="font-family: sans-serif; width: 180px; border-collapse: collapse;" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td><img style="width: auto; max-width: 180px; height: 200px;" src="[relate_img_4]" /></td>
						</tr>
						<tr id="rtwwpcp_relat_prod_tr">
							<td style="font-size: 16px; font-weight: normal; padding-top: 10px; padding-bottom: 10px;">[relate_prod_4]</td>
						</tr>
						<tr>
							<td id="rtwwpcp_add_to_cart" style="font-size: 16px; font-weight: normal; background-color: #d93c50; height: 30px;"><a style="color: #ffffff; text-decoration: none;" href="[add_to_cart_4]">Buy Now</a></td>
						</tr>
					</tbody>
				</table>
			</td>
		</tr>
	</tbody>
</table>';

$rtwwpcp_content_html_3 = '
<div style="width: 100%;">
	<div id="rtwwpcp_relat_prod" style="border: 1px solid; width: 25%; float: left;">
		<div style="width: 300px; height: 200px;">
			<img class="alignnone size-medium wp-image-51" style="width: 100%; height: 100%;" src="[product_img]" alt="" />
		</div>
		<div style="width: 100%;">
			<div style="float: left; width: 70%;">
				<h3>[product_name]</h3>
			</div>
			<div style="float: right;">
				<p>[product_price]</p>
			</div>
		</div>
		<div style="text-align:center;">
			<button style="color: #ffffff; text-decoration: none;">[add_to_cart]</button>
		</div>
	</div>
</div>';
$rtwwpcp_content_html_4 = '
<div style="padding: 10px; font-family: sans-serif;">
	<h2 style="text-align: center; text-transform: uppercase;"><span style="border-bottom: 2px solid black;">Product Catalog</span></h2>
	<div>
		<table id="rtwwpcp_prod_table" style="border-collapse: collapse; font-family: sans-serif;">
			<thead>
				<tr>
					<th style="border-bottom: 1px solid black; background-color: #45ae9e; padding: 8px; color: white;">Product Image</th>
					<th style="border-bottom: 1px solid black; background-color: #45ae9e; color: white; padding: 8px;">Name</th>
					<th style="border-bottom: 1px solid black; background-color: #45ae9e; color: white; padding: 8px;">SKU</th>
					<th style="text-align: center; border-bottom: 1px solid black; background-color: #45ae9e; color: white; padding: 8px;">Short Description</th>
					<th style="border-bottom: 1px solid black; background-color: #45ae9e; padding: 8px; color: white;">Categories</th>
					<th style="border-bottom: 1px solid black; background-color: #45ae9e; padding: 8px; color: white;">Attributes</th>
					<th style="border-bottom: 1px solid black; background-color: #45ae9e; padding: 8px; color: white;">Price</th>
					<th style="border-bottom: 1px solid black; background-color: #45ae9e; padding: 8px; color: white;">Buy</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td style="border-left: 1px solid #ddd; border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 8px 10px;"><img style="width: 100px; height: 100px;" src="[product_img]" /></td>
					<td style="border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 8px 10px;">[produt_name]</td>
					<td style="border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 8px 10px;">[product_sku]</td>
					<td style="text-align: center; border-right: 1px solid #ddd; border-bottom: 1px solid #ddd;">[product_short_desc]</td>
					<td style="border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 8px 10px;">
						<table id="rtwwpcp_prod_cat">
							<tbody>
								<tr>
									<td style="background-color: #656dff; color: white; padding: 5px;">[product_category]</td>
								</tr>
							</tbody>
						</table>
					</td>
					<td style="border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 8px 10px;">
						<div style="text-transform: capitalize;"><b>Color:</b>red</div>
						<div><b>Size:</b><span style="text-transform: uppercase;">S,M,L,XL,XXL</span></div>
					</td>
					<td style="border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 8px 10px;">[product_price]</td>
					<td style="border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 8px 10px;">
						<table>
							<tbody>
								<tr>
									<td style="width: 150px; background-color: #ff7c52; padding: 10px 8px; text-align: center; font-size: 16px;">
										<a style="color: white; text-decoration: none; text-align: center; font-size: 16px;" href="[add_to_cart]"><b>Add to cart</b></a>
									</td>
								</tr>
							</tbody>
						</table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</div>';
?>
<table class="wp-list-table form-table rtwwpcp-table">
	<tbody>
		<tr>
			<th><h3><?php esc_html_e('PDF Catalog Templates', 'rtwwpcp-woocommerce-pdf-catalog-pro'); ?>
		</th>
		<td>
			<select class="rtwwpcp_template_select" name="rtwwpcp_format_setting_opt[pdf_format]">
				<option value="1" <?php echo isset( $rtwwpcp_get_setting['pdf_format'] ) && $rtwwpcp_get_setting['pdf_format'] == '1' ? esc_html('selected="selected"') : '';?>><?php esc_html_e('Template 1', 'rtwwpcp-woocommerce-pdf-catalog-pro'); ?></option>
				<option value="2" <?php echo isset( $rtwwpcp_get_setting['pdf_format'] ) && $rtwwpcp_get_setting['pdf_format'] == '2' ? esc_html('selected="selected"') : '';?>><?php esc_html_e('Template 2', 'rtwwpcp-woocommerce-pdf-catalog-pro'); ?></option>
				<option value="3" <?php echo isset( $rtwwpcp_get_setting['pdf_format'] ) && $rtwwpcp_get_setting['pdf_format'] == '3' ? esc_html('selected="selected"') : '';?>><?php esc_html_e('Template 3', 'rtwwpcp-woocommerce-pdf-catalog-pro'); ?></option>
				<option value="4" <?php echo isset( $rtwwpcp_get_setting['pdf_format'] ) && $rtwwpcp_get_setting['pdf_format'] == '4' ? esc_html('selected="selected"') : '';?>><?php esc_html_e('Template 4', 'rtwwpcp-woocommerce-pdf-catalog-pro'); ?></option>
			</select>
			<div class="descr"><?php esc_html_e('Select any one of these template for your PDF Catalog layout.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>	
		</td>
	</tr>
	<tr class="rtwwpcp_template_1 <?php if( $rtwwpcp_template_selected != '1' ){ echo 'rtwwpcp_hide_template'; } ?>">
		<th><h3><?php esc_html_e('PDF Layout','rtwwpcp-woocommerce-pdf-catalog-pro'); ?></h3></th>
		<td>
			<?php
			if ( !empty($rtwwpcp_get_setting['pdf_format_1'])) 
			{
				$rtwwpcp_cntnt = $rtwwpcp_get_setting['pdf_format_1'] ;
			}
			else
			{
				$rtwwpcp_cntnt = $rtwwpcp_content_html_1;
			}
			$rtwwpcp_cntnt = html_entity_decode( $rtwwpcp_cntnt );
			$rtwwpcp_cntnt = stripslashes( $rtwwpcp_cntnt );
			$rtwwpcp_setting = array(
				'wpautop' => false,
				'media_buttons' => true,
				'textarea_name' => 'rtwwpcp_format_setting_opt[pdf_format_1]',
				'textarea_rows' => 40,
				'textarea_cols' => 30,
			);
			wp_editor($rtwwpcp_cntnt, 'rtwwpcp_pdf_flipbook_html_1' , $rtwwpcp_setting );
			?>
		</td>
	</tr>
	<tr class="rtwwpcp_template_2 <?php if( $rtwwpcp_template_selected != '2' ){ echo 'rtwwpcp_hide_template'; } ?>">
		<th><h3><?php esc_html_e('PDF Layout','rtwwpcp-woocommerce-pdf-catalog-pro'); ?></h3></th>
		<td>
			<?php
			if ( !empty($rtwwpcp_get_setting['pdf_format_2'])) 
			{
				$rtwwpcp_cntnt = $rtwwpcp_get_setting['pdf_format_2'] ;
			}
			else
			{
				$rtwwpcp_cntnt = $rtwwpcp_content_html_2;
			}
			$rtwwpcp_cntnt = html_entity_decode( $rtwwpcp_cntnt );
			$rtwwpcp_cntnt = stripslashes( $rtwwpcp_cntnt );
			$rtwwpcp_setting = array(
				'wpautop' => false,
				'media_buttons' => true,
				'textarea_name' => 'rtwwpcp_format_setting_opt[pdf_format_2]',
				'textarea_rows' => 40,
				'textarea_cols' => 30,
			);
			wp_editor($rtwwpcp_cntnt, 'rtwwpcp_pdf_flipbook_html_2' , $rtwwpcp_setting );
			?>
		</td>
	</tr>
	<tr class="rtwwpcp_template_3 <?php if( $rtwwpcp_template_selected != '3' ){ echo 'rtwwpcp_hide_template'; } ?>">
		<th><h3><?php esc_html_e('PDF Layout','rtwwpcp-woocommerce-pdf-catalog-pro'); ?></h3></th>
		<td>
			<p style="font-style: italic; color: red;"><?php esc_html_e('This template work only for PDF catalog. ( Not category catalog )','rtwwpcp-woocommerce-pdf-catalog-pro'); ?></p>
			<?php
			if ( !empty($rtwwpcp_get_setting['pdf_format_3'])) 
			{
				$rtwwpcp_cntnt = $rtwwpcp_get_setting['pdf_format_3'] ;
			}
			else
			{
				$rtwwpcp_cntnt = $rtwwpcp_content_html_3;
			}
			$rtwwpcp_cntnt = html_entity_decode( $rtwwpcp_cntnt );
			$rtwwpcp_cntnt = stripslashes( $rtwwpcp_cntnt );
			$rtwwpcp_setting = array(
				'wpautop' => false,
				'media_buttons' => true,
				'textarea_name' => 'rtwwpcp_format_setting_opt[pdf_format_3]',
				'textarea_rows' => 40,
				'textarea_cols' => 30,
			);
			wp_editor($rtwwpcp_cntnt, 'rtwwpcp_pdf_flipbook_html_3' , $rtwwpcp_setting );
			?>
		</td>
	</tr>
	<tr class="rtwwpcp_template_4 <?php if( $rtwwpcp_template_selected != '4' ){ echo 'rtwwpcp_hide_template'; } ?>">
		<th><h3><?php esc_html_e('PDF Layout','rtwwpcp-woocommerce-pdf-catalog-pro'); ?></h3></th>
		<td>
			<p style="font-style: italic; color: red;"><?php esc_html_e('This template work only for PDF catalog. ( Not category catalog )','rtwwpcp-woocommerce-pdf-catalog-pro'); ?></p>
			<?php
			if ( !empty($rtwwpcp_get_setting['pdf_format_4'])) 
			{
				$rtwwpcp_cntnt = $rtwwpcp_get_setting['pdf_format_4'] ;
			}
			else
			{
				$rtwwpcp_cntnt = $rtwwpcp_content_html_4;
			}
			$rtwwpcp_cntnt = html_entity_decode( $rtwwpcp_cntnt );
			$rtwwpcp_cntnt = stripslashes( $rtwwpcp_cntnt );
			$rtwwpcp_setting = array(
				'wpautop' => false,
				'media_buttons' => true,
				'textarea_name' => 'rtwwpcp_format_setting_opt[pdf_format_4]',
				'textarea_rows' => 40,
				'textarea_cols' => 30,
			);
			wp_editor($rtwwpcp_cntnt, 'rtwwpcp_pdf_flipbook_html_4' , $rtwwpcp_setting );
			?>
		</td>
	</tr>
</tbody>
</table>