<?php

settings_fields('rtwwpcp_watermark_setting');

$rtwwpcp_get_setting = get_option('rtwwpcp_watermark_setting_opt'); 

?>

<table class="wp-list-table form-table rtwwpcp-table">

	<tr>

		<th class="descr"><?php esc_html_e('Watermark Text', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

		<td class="descr_2">

			<input type="checkbox" id="rtwwpcfp_wtrmrk"

			name="rtwwpcp_watermark_setting_opt[enable_text_watermark]" value='1'

			<?php if(isset($rtwwpcp_get_setting['enable_text_watermark'])) { echo esc_html('checked = "checked"'); } ?> />

			<div class="descr"><?php esc_html_e('Check it if you want to show Watermark text.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

		</td>

	</tr>

</table>

<table id="rtwwpcp_text_add_watermark"

class="wp-list-table form-table rtwwpcp-table <?php if(!isset($rtwwpcp_get_setting['enable_text_watermark'])) { echo esc_attr('rtwwpcf_hide_wtrmrk'); } ?>">

<tr>

	<th class="descr"><?php esc_html_e('Watermark Font', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

	<td>

		<select name="rtwwpcp_watermark_setting_opt[watermark_font]">

			<?php

			foreach ( $rtwwpcp_fonts as $rtwwpcp_key => $rtwwpcp_value ) 

			{

				?>

				<option value="<?php echo esc_attr($rtwwpcp_value);?>" <?php echo esc_html(isset( $rtwwpcp_get_setting['watermark_font'] ) && $rtwwpcp_get_setting['watermark_font'] == $rtwwpcp_value ? 'selected="selected"' : '');?>><?php echo esc_html($rtwwpcp_key);?></option>

				<?php

			}

			?>

		</select>

		<div class="descr"><?php esc_html_e('Choose the font family of Watermark text.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

	</td>

</tr>

<tr>

	<th class="descr"><?php esc_html_e('Watermark Rotation', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

	<td>

		<input type="text" name="rtwwpcp_watermark_setting_opt[watermark_rotation]"

		value="<?php echo esc_attr((isset ( $rtwwpcp_get_setting['watermark_rotation'] )) ? $rtwwpcp_get_setting['watermark_rotation'] : '45'); ?>" />

		<div class="descr"><?php esc_html_e('Enter your required rotation(in degree) for Watermark text.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

	</td>

</tr>

<tr>

	<th class="descr"><?php esc_html_e('Watermark Text:', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

	<td class="descr_2">

		<textarea name="rtwwpcp_watermark_setting_opt[watermark_text]" rows="4" cols="35"><?php if( isset($rtwwpcp_get_setting['watermark_text'])) { echo esc_html($rtwwpcp_get_setting['watermark_text']); } ?>

	</textarea>

	<div class="descr"><?php esc_html_e('Enter Watermark Text which you want to show on pdf.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

</td>

</tr>

<tr>

	<th class="descr"><?php esc_html_e('Text Transparency', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

	<td class="descr_2">

		<input type="text" name="rtwwpcp_watermark_setting_opt[watermark_text_trans]"

		value="<?php echo esc_attr( isset ( $rtwwpcp_get_setting['watermark_text_trans'] ) ? $rtwwpcp_get_setting['watermark_text_trans'] : ''); ?>" />

		<div class="descr"><?php esc_html_e('Enter the text Transparency of Watermark.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

	</td>

</tr>

</table>



<table class="wp-list-table form-table rtwwpcp-table">

	<tr>

		<th class="descr"><?php esc_html_e('Watermark Image', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

		<td class="descr_2">

			<input type="checkbox" id="rtwwpcfp_imgwtrmk"

			name="rtwwpcp_watermark_setting_opt[enable_image_watermark]" value='1'

			<?php if(( isset($rtwwpcp_get_setting['enable_image_watermark']))) { echo esc_html('checked = "checked"'); } ?> />

			<div class="descr"><?php esc_html_e('Check it if you want to show Watermark image.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

		</td>

	</tr>

</table>

<table id="rtwwpcp_add_watermark_image" class="wp-list-table form-table rtwwpcp-table <?php if(!isset($rtwwpcp_get_setting['enable_image_watermark']))   { echo esc_attr('rtwwpcf_hide_img_wtrmrk'); } ?>">

	<tr>

		<th class="descr"><?php esc_html_e('Image Transparency', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

		<td class="descr_2">

			<input type="text" name="rtwwpcp_watermark_setting_opt[watermark_image_trans]"

			value="<?php echo esc_attr( isset ( $rtwwpcp_get_setting['watermark_image_trans'] ) ? $rtwwpcp_get_setting['watermark_image_trans'] : ''); ?>" />

			<div class="descr"><?php esc_html_e('Enter the image Transparency of Watermark.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

		</td>

	</tr>

	<tr>

		<th class="descr"><?php esc_html_e('Watermark Image:', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

		<td>

			<?php $src_watermark = isset($rtwwpcp_get_setting['rtwwpcp_watermark_img_url'] ) ? $rtwwpcp_get_setting['rtwwpcp_watermark_img_url'] : '';?>

			<?php if($src_watermark != ''){ ?>

				<div id="rtwwpcp_watermark_img_backgrnd">

					<img id="rtwwpcp_watermark_img" src="<?php echo esc_url($src_watermark); ?>" />

				</div>

			<?php } ?>

			<div id="rtwwpcp_wtrmrk_img" >

				<input type="hidden" id="rtwwpcp_watermark_img_url"

				name="rtwwpcp_watermark_setting_opt[rtwwpcp_watermark_img_url]"

				value="<?php echo esc_attr($src_watermark); ?>" />

				<button type="button" class="rtwwpcp_watermark_img_upload button"><?php esc_html_e( 'Upload/Add image', 'rtwwpcp-woocommerce-pdf-catalog-pro'); ?></button><br>

				<?php if($src_watermark != ''){ ?>

					<button type="button" class="rtwwpcp_watermark_remove_img button"><?php esc_html_e( 'Remove image', 'rtwwpcp-woocommerce-pdf-catalog-pro'); ?></button>

				<?php } ?>

			</div>

			<div class="descr"><?php esc_html_e('Choose your Watermark Image which you want to show on pdf.', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

		</td>

	</tr>

	<?php $rtwwpcp_watermark_size=array('D'=>'Original size of image','P'=>'Resize to fit the full page size, keeping aspect ratio','F'=>'Resize to fit the print-area (frame) respecting current page margins, keeping aspect ratio','INT'=>'Resize to full page size minus a margin set by this integer, keeping aspect ratio','array'=>'Specify Width and Height');?>

	<tr>

		<th class="descr"><?php esc_html_e('Image Dimension', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

		<td>

			<select name="rtwwpcp_watermark_setting_opt[watermark_img_dim]" id="rtwwpcp_doc-add-watermark-image-dimen-select"><?php

			foreach ( $rtwwpcp_watermark_size as $rtwwpcp_key => $rtwwpcp_value ) 

			{

				?>

				<option value="<?php echo esc_attr($rtwwpcp_key);?>" <?php echo (isset( $rtwwpcp_get_setting['watermark_img_dim'] ) && $rtwwpcp_get_setting['watermark_img_dim'] == $rtwwpcp_key ? esc_html('selected="selected"') : '');?>><?php esc_html_e($rtwwpcp_value);?></option>

				<?php

			}

			?>  

		</select>

		<div class="descr"><?php esc_html_e('Choose the dimension of Watermark Image', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

	</td>

</tr>

<tr>

	<td colspan="2" id="rtwwpcp_add_watermark_image_dimension"

	class="<?php if($rtwwpcp_get_setting['watermark_img_dim']=='array' && $rtwwpcp_get_setting['enable_image_watermark']==1) {echo ''; } else {echo 'display_none';} ?>">

	<table>

		<tr>

			<th class="descr"><?php esc_html_e('Image Width', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

			<td class="descr_2">

				<input type="text" name="rtwwpcp_watermark_setting_opt[water_img_dim_width]"

				value="<?php echo esc_attr(( isset ( $rtwwpcp_get_setting['water_img_dim_width'] ) ? $rtwwpcp_get_setting['water_img_dim_width'] : '')); ?>" />

				<div class="descr"><?php esc_html_e('Set the Width of Watermark Image', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

			</td>

		</tr>

		<tr>

			<th class="descr"><?php esc_html_e('Image Height', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

			<td class="descr_2">

				<input type="text" name="rtwwpcp_watermark_setting_opt[water_img_dim_height]"

				value="<?php echo esc_attr(( isset ( $rtwwpcp_get_setting['water_img_dim_height'] ) ? $rtwwpcp_get_setting['water_img_dim_height'] : '')); ?>" />

				<div class="descr"><?php esc_html_e('Set the Height of Watermark Image', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></div>

			</td>

		</tr>

	</table>

</td>

</tr>

<tr>

	<td colspan="2" id="rtwwpcp_add_watermark_image_dimen_integer"

	class="<?php if($rtwwpcp_get_setting['watermark_img_dim']=='INT' && $rtwwpcp_get_setting['enable_image_watermark']==1): echo '';else: echo esc_html('display_none');endif;?>">

	<table>

		<tr>

			<th class="descr"><?php esc_html_e('Integer Value', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

			<td class="descr_2"><input type="text" name="rtwwpcp_watermark_setting_opt[water_img_dim_int]"

				value="<?php echo esc_attr(( isset ( $rtwwpcp_get_setting['water_img_dim_int'] ) ? $rtwwpcp_get_setting['water_img_dim_int'] : '')); ?>" />

			</td>

		</tr>

	</table>

</td>

</tr>

<?php $rtwwpcp_watermark_position=array('P'=>'Centred on the whole page area','F'=>'Centred on the page print-area (frame) respecting page margins','arrays'=>'Specify a position');

?>

<tr>

	<th class="descr"><?php esc_html_e('Image Position', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

	<td>

		<select name="rtwwpcp_watermark_setting_opt[watermark_img_pos]" id="rtwwpcp_doc-add-watermark-image-pos-select"><?php

		foreach ( $rtwwpcp_watermark_position as $rtwwpcp_key => $rtwwpcp_value ) 

		{

			?>

			<option value="<?php echo esc_attr($rtwwpcp_key);?>" <?php echo esc_html(isset( $rtwwpcp_get_setting['watermark_img_pos'] ) && $rtwwpcp_get_setting['watermark_img_pos'] == $rtwwpcp_key ? 'selected="selected"' : '');?>><?php  esc_html_e($rtwwpcp_value);?></option>

			<?php

		}	

		?>  </select>

	</td>

</tr>

<tr>

	<td colspan="2">

		<table id="rtwwpcp_add_watermark_image_pos"

		class="<?php if($rtwwpcp_get_setting['watermark_img_pos']=='arrays' && $rtwwpcp_get_setting['enable_image_watermark']==1) {echo '';}else {echo 'display_none';}?>">

		<tr>

			<th class="descr"><?php esc_html_e('Horizontal Position', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

			<td class="descr_2"><input type="text" name="rtwwpcp_watermark_setting_opt[watermark_img_pos_x]" value="<?php echo esc_attr(( isset ( $rtwwpcp_get_setting['watermark_img_pos_x'] ) ? $rtwwpcp_get_setting['watermark_img_pos_x'] : '')); ?>" />

			</td>

		</tr>

		<tr>

			<th class="descr"><?php esc_html_e('Vertical Position', 'rtwwpcp-woocommerce-pdf-catalog-pro');?></th>

			<td class="descr_2"><input type="text" name="rtwwpcp_watermark_setting_opt[watermark_img_pos_y]"

				value="<?php echo esc_attr(( isset ( $rtwwpcp_get_setting['watermark_img_pos_y'] ) ? $rtwwpcp_get_setting['watermark_img_pos_y'] : '')); ?>" />

			</td>

		</tr>

	</table>

</td>

</tr> 

</table>