<?php
class wpda_pricing_table_theme_page{
	
	private $options;
	
	function __construct(){		
		$this->options=self::return_params_array();	
	}
	public static function get_theme_id_and_name(){
		global $wpdb;
		$query = "SELECT `id`,`name`,`default` FROM ".wpda_pricing_table_databese::$table_names['theme'];
		$rows=$wpdb->get_results($query,ARRAY_A);
		return $rows;
	}
	private function aaaa(&$test){
		$test++;
	}
	public static function return_params_array(){	
		return array(
			"theme_general"=>array(
				"heading_name"=>"General Settings",
				"params"=>array(
					"column_type"=>array(
						"title"=>"Column type",
						"description"=>"Select Column Type",				
						"function_name"=>"simple_select",
						"values"=>array("normal"=>"Normal","only_info"=>"Only Info"),
						"default_value"=>"normal",
					),
					"column_width"=>array(
						"title"=>"Column width",
						"description"=>"Type column width",				
						"function_name"=>"simple_input",
						"default_value"=>"220",
						"small_text"=>"px"
					),
					"column_min_width"=>array(
						"title"=>"Column minimum width",
						"description"=>"Type column minimum width",				
						"function_name"=>"simple_input",
						"default_value"=>"160",
						"small_text"=>"px"
					),
					"column_scale"=>array(
						"title"=>"Column scale",
						"description"=>"Column scale",				
						"function_name"=>"range_input",
						"small_text"=>"(%)",	
						"default_value"=>"0",
					),
					"column_bg_color"=>array(
						"title"=>"Background color",
						"description"=>"Type here title background color",				
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>"0"),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_outside_box_shadow"=>array(
						"title"=>"Column outside box shadow",
						"description"=>"Column outside box shadow",				
						"function_name"=>"simple_input",
						"placeholder"=>"5px 5px 10px #dddddd",
						"default_value"=>"",
					),
					"column_outside_border_type"=>array(
						"title"=>"Column outside border type",
						"description"=>"Select border type",				
						"function_name"=>"simple_select",
						"values"=>array("solid"=>"Solid","dotted"=>"Dotted","dashed"=>"Dashed","double"=>"Double","groove"=>"Groove","ridge"=>"Ridge","inset"=>"Inset","outset"=>"Outset"),
						"default_value"=>"solid",
					),
					"column_outside_border_width"=>array(
						"title"=>"Column outside border width",
						"description"=>"Type here the width of column outside border",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"1","right"=>"1","bottom"=>"1","left"=>"1"),
					),
					"column_outside_border_color"=>array(
						"title"=>"Column outside border color",
						"description"=>"Type here the width of column outside border color",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),
					"column_outside_border_radius"=>array(
						"title"=>"Column outside border radius",
						"description"=>"Type here column outside border radius",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"5","right"=>"0","bottom"=>"5","left"=>"0"),
					),
					"text_align"=>array(
						"title"=>"Text align",
						"description"=>"Select Text horizontal alignment for texts",				
						"function_name"=>"simple_select",
						"values"=>array("left"=>"Left","center"=>"Center","right"=>"Right"),
						"default_value"=>"center",
					),					
				)
			),
			"content_styling"=>array(
				"heading_name"=>"Content Styling",
				"params"=>array(					
					"column_title_bg_color"=>array(
						"title"=>"Title background color",
						"description"=>"Type here title background color",				
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>""),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_title_txt_color"=>array(
						"title"=>"Title text color",
						"description"=>"Type here title text color",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),
					"column_title_font_size"=>array(
						"title"=>"Title font size",
						"description"=>"Type here title font size",				
						"function_name"=>"simple_input",
						"default_value"=>"18",
						"small_text"=>"px"
					),
					"column_title_font_family"=>array(
						"title"=>"Title font family",
						"description"=>"Type here Title font family",				
						"function_name"=>"font_select",
						"values"=>wpda_pricing_table_library::fonts_select(),
						"default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
					),
					"column_title_padding"=>array(
						"title"=>"Title padding",
						"description"=>"Type here title padding",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"5","right"=>"0","bottom"=>"5","left"=>"0"),
					),
					"column_title_margin"=>array(
						"title"=>"Title margin",
						"description"=>"Type here title margin",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
					),
					"column_title_border_type"=>array(
						"title"=>"Title border type",
						"description"=>"Select title border type",				
						"function_name"=>"simple_select",
						"values"=>array("solid"=>"Solid","dotted"=>"Dotted","dashed"=>"Dashed","double"=>"Double","groove"=>"Groove","ridge"=>"Ridge","inset"=>"Inset","outset"=>"Outset"),
						"default_value"=>"solid",
					),
					"column_title_top_bottom_border_wdith"=>array(
						"title"=>"Title border width",
						"description"=>"Type here title border width",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","bottom"=>"0"),
						"default_value"=>array("top"=>"0","bottom"=>"0"),
					),
					"column_title_border_color"=>array(
						"title"=>"Title border color",
						"description"=>"Type here title border color",
						"default_value"=>"#cccccc",
						"function_name"=>"color_input",
					),
					"column_price_bg_color"=>array(
						"title"=>"Price background color",
						"description"=>"Type here price background color",
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>""),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_price_txt_color"=>array(
						"title"=>"Price text color",
						"description"=>"Type here price text color",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),
					"column_price_font_size"=>array(
						"title"=>"Price font size",
						"description"=>"Type here price font size",				
						"function_name"=>"simple_input",
						"default_value"=>"18",
						"small_text"=>"px"
					),
					"column_price_font_family"=>array(
						"title"=>"Price font family",
						"description"=>"Type here price font family",				
						"function_name"=>"font_select",
						"values"=>wpda_pricing_table_library::fonts_select(),
						"default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
					),
					"column_price_padding"=>array(
						"title"=>"Price padding",
						"description"=>"Type here price padding",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"5","right"=>"0","bottom"=>"5","left"=>"0"),
					),
					"column_price_margin"=>array(
						"title"=>"Price margin",
						"description"=>"Type here price margin",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
					),
					"column_price_border_type"=>array(
						"title"=>"Price border type",
						"description"=>"Select price border type",				
						"function_name"=>"simple_select",
						"values"=>array("solid"=>"Solid","dotted"=>"Dotted","dashed"=>"Dashed","double"=>"Double","groove"=>"Groove","ridge"=>"Ridge","inset"=>"Inset","outset"=>"Outset"),
						"default_value"=>"solid",
					),
					"column_price_top_bottom_border_wdith"=>array(
						"title"=>"Price border width",
						"description"=>"Type here price border width",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","bottom"=>"0"),
						"default_value"=>array("top"=>"0","bottom"=>"0"),
					),
					"column_price_border_color"=>array(
						"title"=>"Price border color",
						"description"=>"Type here price border color",
						"default_value"=>"#cccccc",
						"function_name"=>"color_input",
					),
					"column_feature_bg_color"=>array(
						"title"=>"Feature background color",
						"description"=>"Type here feature background color",
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>""),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_feature_odd_bg_color"=>array(
						"title"=>"Feature odd background color",
						"description"=>"Type here feature odd background color",
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>""),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_feature_txt_color"=>array(
						"title"=>"Feature text color",
						"description"=>"Type here feature text color",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),
					"column_feature_font_size"=>array(
						"title"=>"Feature font size",
						"description"=>"Type here feature font size",				
						"function_name"=>"simple_input",
						"default_value"=>"18",
						"small_text"=>"px"
					),
					"column_feature_font_family"=>array(
						"title"=>"Feature font family",
						"description"=>"Type here feature font family",				
						"function_name"=>"font_select",
						"values"=>wpda_pricing_table_library::fonts_select(),
						"default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
					),
					"column_feature_padding"=>array(
						"title"=>"Feature padding",
						"description"=>"Type here feature padding",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"5","right"=>"0","bottom"=>"5","left"=>"0"),
					),
					"column_feature_margin"=>array(
						"title"=>"Feature margin",
						"description"=>"Type here feature margin",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"0","right"=>"15","bottom"=>"0","left"=>"15"),
					),
					"column_feature_border_type"=>array(
						"title"=>"Feature border type",
						"description"=>"Select feature border type",				
						"function_name"=>"simple_select",
						"values"=>array("solid"=>"Solid","dotted"=>"Dotted","dashed"=>"Dashed","double"=>"Double","groove"=>"Groove","ridge"=>"Ridge","inset"=>"Inset","outset"=>"Outset"),
						"default_value"=>"solid",
					),
					"column_feature_top_bottom_border_wdith"=>array(
						"title"=>"Feature border width",
						"description"=>"Type here feature border width",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","bottom"=>"0"),
						"default_value"=>array("top"=>"5","bottom"=>"5"),
					),
					"column_feature_border_color"=>array(
						"title"=>"Feature border color",
						"description"=>"Type here feature border color",
						"default_value"=>"#cccccc",
						"function_name"=>"color_input",
					)
					
				),
			),
			"additional_text_styling"=>array(
				"heading_name"=>"Additional Text",
				"params"=>array(
				"column_aditional_text"=>array(
						"title"=>"Column top additional text",
						"description"=>"Type here additional text for showing at the top of the column. It can be the best price or favorite or other text",				
						"function_name"=>"simple_input",
						"default_value"=>"",
					),
					"column_aditional_text_position"=>array(
						"title"=>"Additional text position",
						"description"=>"Select the additional text position",				
						"function_name"=>"simple_select",
						"values"=>array("above_column"=>" Above the column","above_the_title"=>"Above the title","below_the_title"=>"Below the title","above_the_price"=>"Above the price","below_the_price"=>"Below the price"),
						"default_value"=>"center",
					),
					"column_additional_text_border_type"=>array(
						"title"=>"Column additional text border type",
						"description"=>"Select column additional text border type",				
						"function_name"=>"simple_select",
						"values"=>array("solid"=>"Solid","dotted"=>"Dotted","dashed"=>"Dashed","double"=>"Double","groove"=>"Groove","ridge"=>"Ridge","inset"=>"Inset","outset"=>"Outset"),
						"default_value"=>"solid",
					),
					"column_additional_text_border_width"=>array(
						"title"=>"Column additional text border width",
						"description"=>"Type here column additional text border width",				
						"function_name"=>"simple_input",
						"default_value"=>"1",
						"small_text"=>"px"
					),
					"column_additional_text_border_color"=>array(
						"title"=>"Column additional text border color",
						"description"=>"Type here column additional text border color",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),
					"column_additional_text_border_radius"=>array(
						"title"=>"Column additional text border radius",
						"description"=>"Type here column additional text border radius",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"5","right"=>"0","bottom"=>"5","left"=>"0"),
					),
					"column_additional_text_bg_color"=>array(
						"title"=>"Column additional text background color",
						"description"=>"Type here column additional text background color",
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>""),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_additional_text_color"=>array(
						"title"=>"Column additional text color",
						"description"=>"Type here column additional text color",
						"default_value"=>"#ffffff",
						"function_name"=>"color_input",
					),
					"column_additional_text_conteiner_width"=>array(
						"title"=>"Column additional text element width",
						"description"=>"Type here column additional text element width",
						"function_name"=>"simple_input",
						"default_value"=>"100",
						"small_text"=>"(%)"
					),
					"column_additional_text_conteiner_align"=>array(
						"title"=>"Column additional text element position",
						"description"=>"Type here column additional text element position",
						"function_name"=>"simple_select",
						"values"=>array("left"=>"Left","center"=>"Center","right"=>"Right"),
						"default_value"=>"center",
					),
					"column_additional_text_align"=>array(
						"title"=>"Column additional text position",
						"description"=>"Type here column additional text position",
						"function_name"=>"simple_select",
						"values"=>array("left"=>"Left","center"=>"Center","right"=>"Right"),
						"default_value"=>"center",
					),
					"column_additional_text_font_size"=>array(
						"title"=>"Column additional text font size",
						"description"=>"Type here column additional text font size",				
						"function_name"=>"simple_input",
						"default_value"=>"18",
						"small_text"=>"px"
					),
					"column_additional_text_font_family"=>array(
						"title"=>"Column additional text font family",
						"description"=>"Type here column additional text font family",				
						"function_name"=>"font_select",
						"values"=>wpda_pricing_table_library::fonts_select(),
						"default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
					),
					"column_additional_text_font_size"=>array(
						"title"=>"Column additional text font size",
						"description"=>"Type here column additional text font size",				
						"function_name"=>"simple_input",
						"default_value"=>"18",
						"small_text"=>"px"
					),
					"column_additional_text_distance_top_bottom"=>array(
						"title"=>"Column additional text distance from top and bottom",
						"description"=>"Type here column additional text distance from top and bottom",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","bottom"=>"0"),
						"default_value"=>array("top"=>"5","bottom"=>"5"),
					),
					"column_additional_text_padding"=>array(
						"title"=>"Column additional text padding",
						"description"=>"Type here column additional text padding",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"5","right"=>"0","bottom"=>"5","left"=>"0"),
					)
				)
			),
			"button_styling"=>array(
				"heading_name"=>"Button Styling",
				"params"=>array(	
					"column_button_bg_row_color"=>array(
						"title"=>"Button row background color",
						"description"=>"Type here button row background color",
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>""),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_button_row_padding"=>array(
						"title"=>"Button row padding",
						"description"=>"Type here button padding",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"5","right"=>"0","bottom"=>"5","left"=>"0"),
					),
					"column_button_row_margin"=>array(
						"title"=>"Button row margin",
						"description"=>"Type here button margin",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
					),
					"column_button_row_border_type"=>array(
						"title"=>"Button row border type",
						"description"=>"Select button border type",				
						"function_name"=>"simple_select",
						"values"=>array("solid"=>"Solid","dotted"=>"Dotted","dashed"=>"Dashed","double"=>"Double","groove"=>"Groove","ridge"=>"Ridge","inset"=>"Inset","outset"=>"Outset"),
						"default_value"=>"solid",
					),
					"column_button_row_top_bottom_border_wdith"=>array(
						"title"=>"Button row border width",
						"description"=>"Type here button border width",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","bottom"=>"0"),
						"default_value"=>array("top"=>"0","bottom"=>"0"),
					),
					"column_button_row_border_color"=>array(
						"title"=>"Button row border color",
						"description"=>"Type here button border color",
						"default_value"=>"#cccccc",
						"function_name"=>"color_input",
					),
					"column_button_themes"=>array(
						"title"=>"Button hover style",
						"description"=>"Select the button style",				
						"function_name"=>"simple_select",
						"values"=>array(
							"standart"=>"Standard",
							"Sliding_background"=>array(
								"type_1_from_left"=>"Slide from left",
								"type_1_from_right"=>"Slide from right",
								"type_1_from_top"=>"Slide from top",
								"type_1_from_bottom"=>"Slide from bottom",
								"type_1_from_middle"=>"Slide from middle",
							),
							"Loading_border_animation"=>array(
								"type_2_animation_border_bottom"=>"Border bottom",
								"type_2_animation_border_top"=>"Border top"
							),
							"Sliding_background_fixed_border"=>array(
								"type_3_animation_from_center_dioganal_right"=>"From center diagonal right",
								"type_3_animation_from_center_dioganal_left"=>"From center diagonal left",
								"type_3_animation_from_center_to_vertical"=>"From center to vertical",
								"type_3_animation_from_center_to_horizontal"=>"From center to horizontal",
								"type_3_animation_from_bottom_to_top"=>"From bottom to top",
								"type_3_animation_from_top_to_bottom"=>"From top to bottom",
								"type_3_animation_from_left_to_right"=>"From left to right",
								"type_3_animation_from_right_to_left"=>"From right to left",
								
							)
						),
						"default_value"=>"Standard",
					),
					"column_button_bg_color"=>array(
						"title"=>"Button background color",
						"description"=>"Type here button background color",
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>""),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_button_txt_color"=>array(
						"title"=>"Button text color",
						"description"=>"Type here button text color",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),
					"column_button_border_color"=>array(
						"title"=>"Button border color",
						"description"=>"Type here button border color",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),					
					"column_button_bg_color_hover"=>array(
						"title"=>"Button background color on hover",
						"description"=>"Type here button background color on hover",
						"function_name"=>"gradient_color_input",
						"values"=>array("color1"=>"","color2"=>"","gradient"=>""),
						"default_value"=>array("color1"=>"rgba(255,255,255,0)","color2"=>"rgba(255,255,255,0)","gradient"=>"none"),
					),
					"column_button_txt_color_hover"=>array(
						"title"=>"Button text color on hover",
						"description"=>"Type here button text color",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),
					"column_button_border_color_hover"=>array(
						"title"=>"Button border color on hover",
						"description"=>"Type here button border color on hover",
						"default_value"=>"#000000",
						"function_name"=>"color_input",
					),
					"column_button_border_type"=>array(
						"title"=>"Button border type",
						"description"=>"Select button border type",				
						"function_name"=>"simple_select",
						"values"=>array("solid"=>"Solid","dotted"=>"Dotted","dashed"=>"Dashed","double"=>"Double","groove"=>"Groove","ridge"=>"Ridge","inset"=>"Inset","outset"=>"Outset"),
						"default_value"=>"solid",
					),
					"column_button_border_width"=>array(
						"title"=>"Button border width",
						"description"=>"Type here button border width",				
						"function_name"=>"simple_input",
						"default_value"=>"5",
						"small_text"=>"px"
					),
					"column_button_border_radius"=>array(
						"title"=>"Button border radius",
						"description"=>"Type here button border radius",				
						"function_name"=>"simple_input",
						"default_value"=>"5",
						"small_text"=>"px"
					),
					"column_button_font_size"=>array(
						"title"=>"Button font size",
						"description"=>"Type here button font size",				
						"function_name"=>"simple_input",
						"default_value"=>"18",
						"small_text"=>"px"
					),
					"column_button_font_family"=>array(
						"title"=>"Button font family",
						"description"=>"Type here button font family",				
						"function_name"=>"font_select",
						"values"=>wpda_pricing_table_library::fonts_select(),
						"default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
					),					
					"column_button_padding"=>array(
						"title"=>"Button padding",
						"description"=>"Type here button padding",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"2","right"=>"5","bottom"=>"2","left"=>"5"),
					),					
					"column_button_margin"=>array(
						"title"=>"Button margin",
						"description"=>"Type here button margin",				
						"function_name"=>"padding_margin_input",
						"values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
						"default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
					)
				),
			),
			"animations"=>array(
				"heading_name"=>"Animation",
				"params"=>array(	
					"column_animation_type"=>array(
						"title"=>"Animation effect",
						"description"=>"Select the animation effect",				
						"function_name"=>"simple_select",
						"values"=>array(
							"none"=>"None",
							"random"=>"Random",
							"Attention_Seekers"=>array(
								"bounce"=>"Bounce",
								"flash"=>"Flash",
								"pulse"=>"Pulse",
								"rubberBand"=>"RubberBand",
								"shake"=>"Shake",
								"swing"=>"Swing",
								"tada"=>"Tada",
								"wobble"=>"Wobble",
							),		
							"Bouncing_Entrances"=>array(
								"bounceIn"=>"BounceIn",
								"bounceInDown"=>"BounceInDown",
								"bounceInLeft"=>"BounceInLeft",
								"bounceInRight"=>"BounceInRight",
								"bounceInUp"=>"BounceInUp",
							),						
							"Fading_Entrances"=>array(
								"fadeIn"=>"FadeIn",
								"fadeInDown"=>"FadeInDown",
								"fadeInDownBig"=>"FadeInDownBig",
								"fadeInLeft"=>"FadeInLeft",
								"fadeInLeftBig"=>"FadeInLeftBig",
								"fadeInRight"=>"FadeInRight",
								"fadeInRightBig"=>"FadeInRightBig",
								"fadeInUp"=>"FadeInUp",
								"fadeInUpBig"=>"FadeInUpBig",
							),
							"Flippers"=>array(
								"flip"=>"Flip",
								"flipInX"=>"FlipInX",
								"flipInY"=>"FlipInY",
							),
							"Lightspeed"=>array(
								"lightSpeedIn"=>"LightSpeedIn",
							),
							"Rotating_Entrances"=>array(
								"rotateIn"=>"RotateIn",
								"rotateInDownLeft"=>"RotateInDownLeft",
								"rotateInDownRight"=>"RotateInDownRight",
								"rotateInUpLeft"=>"RotateInUpLeft",
								"rotateInUpRight"=>"RotateInUpRight",
							),
							"Specials"=>array(
								"rollIn"=>"RollIn",
							),
							"Zoom_Entrances"=>array(
								"zoomIn"=>"ZoomIn",
								"zoomInDown"=>"ZoomInDown",
								"zoomInLeft"=>"ZoomInLeft",
								"zoomInRight"=>"ZoomInRight",
								"zoomInUp"=>"ZoomInUp",
							),
						),
						"default_value"=>"none",
					),
					"column_animation_delay"=>array(
						"title"=>"Animation delay",
						"description"=>"Type here the animation delay",				
						"function_name"=>"simple_input",
						"default_value"=>"100",
						"small_text"=>"(ms)"
					)
				),
			)			
		);
	}
	public static function get_default_values_array(){
		$array_of_returned=array();
		$options=self::return_params_array();
		foreach($options as $param_heading_key=>$param_heading_value){
			foreach($param_heading_value['params'] as $key=>$value){
				$array_of_returned[$key]=$value['default_value'];
			}
		}	
		return $array_of_returned;
	}
	public function controller_page(){
		global $wpdb;
		$task="default";
		$id=0;
		if(isset($_GET["task"])){
			$task=$_GET["task"];
		}
		if(isset($_GET["id"])){
			$id=$_GET["id"];
		}		
		switch($task){
		case 'add_wpda_pricing_table_themes':	
			$this->add_edit_theme($id);
			break;
			
		case 'add_edit_theme':	
			$this->add_edit_theme($id);
			break;
		case 'duplicate':	
			$this->duplicate_theme($id);
			$this->display_table_list_theme();	
			break;
		case 'save_theme':		
			if($id)	
				$this->update_theme($id);
			else
				$this->save_theme();
				
			$this->display_table_list_theme();	
			break;
			
			
		case 'update_theme':		
			if($id){
				$this->update_theme($id);
			}else{
				$this->save_theme();
				$_GET['id']=$wpdb->get_var("SELECT MAX(id) FROM ".wpda_pricing_table_databese::$table_names['theme']);
				$id=$_GET['id'];
			}
			$this->add_edit_theme($id);
			break;
		case 'set_default_theme':
			$this->set_default_theme($id);
			$this->display_table_list_theme();	
		break;
		case 'remove_theme':	
			$this->remove_theme($id);
			$this->display_table_list_theme();
			break;				
		default:
			$this->display_table_list_theme();
		}
	}
	
/*############  Save function  ################*/
	
	private function save_theme(){
		global $wpdb;
		if(count($_POST)==0)
			return;		
		$params_array=array();
		if(isset($_POST['name'])){
			$name=sanitize_text_field($_POST['name']);
		}else{
			$name="theme";
		}
		
		$params_array=array('name'=>sanitize_text_field($name));
		foreach($this->options as $param_heading_key=>$param_heading_value){
			foreach($param_heading_value['params'] as $key=>$value){
				if(isset($_POST[$key])){
					if(is_array($_POST[$key])){
						$params_array[$key]=$_POST[$key];
					}else{
						if($key=='column_aditional_text'){
							$params_array[$key]=htmlspecialchars(stripslashes($_POST[$key]));
						}else{
							$params_array[$key]=stripslashes($_POST[$key]);
						}
					}
				}else{
					$params_array[$key]=$value['default_value'];
				}
			}
		}	
		
		$save_or_no=$wpdb->insert( wpda_pricing_table_databese::$table_names['theme'], 
			array( 
				'name' => $name,
				'option_value' => json_encode($params_array),
			), 
			array( 
				'%s', 
				'%s',
			) 
		);
		if($save_or_no){
			?><div class="updated"><p><strong>Item Saved</strong></p></div><?php
		}
		else{
			?><div id="message" class="error"><p>Error please reinstall plugin</p></div> <?php
		}
	}
	
/*############  Update theme ID function  ################*/
	
	private function update_theme($id){
		global $wpdb;
		if(count($_POST)==0)
			return;
		$params_array=array();
		if(isset($_POST['name'])){
			$name=sanitize_text_field($_POST['name']);
		}else{
			$name="theme";
		}
		$params_array=array('name'=>sanitize_text_field($name));
		foreach($this->options as $param_heading_key=>$param_heading_value){
			foreach($param_heading_value['params'] as $key=>$value){
				if(isset($_POST[$key])){
					if(is_array($_POST[$key])){
						$params_array[$key]=$_POST[$key];
					}else{
						if($key=='column_aditional_text'){
							$params_array[$key]=htmlspecialchars(stripslashes($_POST[$key]));
						}else{
							$params_array[$key]=stripslashes($_POST[$key]);
						}
					}
				}else{
					$params_array[$key]=$value['default_value'];
				}
			}
		}		
		$wpdb->update( wpda_pricing_table_databese::$table_names['theme'], 
			array( 
				'name' => $name,
				'option_value' => json_encode($params_array),
			), 
			array( 
				'id'=>$id 
			),
			array( 
				'%s', 
				'%s'
			),
			array( 
				'%d'
			)  
		);
		
		?><div class="updated"><p><strong>Item Saved</strong></p></div><?php
		
	}
	
	private function duplicate_theme($id){
		global $wpdb;
		if(!$id){
			?><div id="message" class="error"><p>incorect theme id</p></div> <?php
			return;
		}
		$theme_params = $wpdb->get_row('SELECT * FROM '.wpda_pricing_table_databese::$table_names['theme'].' WHERE id='.$id);
		$name = $theme_params->name;
		$save_or_no=$wpdb->insert( wpda_pricing_table_databese::$table_names['theme'], 
			array( 
				'name' => $name.'_copy',
				'option_value' => $theme_params->option_value,
			), 
			array( 
				'%s', 
				'%s',
			) 
		);
		if($save_or_no){
			?><div id="message" class="updated"><p>Theme duplicated</p></div> <?php
		}else{			
			?><div id="message" class="error"><p>Error</p></div> <?php
		
		}
		
	}
	private function copy_name($name){
		$name_length=strlen($name);
		$numer_before_copy='';
		for($i=0;$i<strlen($name);$i++){
			if(is_numeric($name[$name_length-1-$i])){
				$numer_before_copy.=$name[$name_length-1-$i];
			}else{
				$numer_before_copy=(int)$numer_before_copy;
				$numer_before_copy+=1;
				if($name[$name_length-1-$i]=='-')
					return substr($name,0,$name_length-$i).$numer_before_copy;
				else
					return substr($name,0,$name_length-$i).'-'.$numer_before_copy;
			}
		}
	}
	private function remove_theme($id){
		global $wpdb;
		$default_theme = $wpdb->get_var($wpdb->prepare('SELECT `default` FROM ' . wpda_pricing_table_databese::$table_names['theme'].' WHERE id="%d"', $id));
		if (!$default_theme) {
			$wpdb->query($wpdb->prepare('DELETE FROM ' . wpda_pricing_table_databese::$table_names['theme'].' WHERE id="%d"', $id));
		}
		else{
			?><div id="message" class="error"><p>You cannot remove default theme</p></div> <?php
		}
	}
	
	private function display_table_list_theme(){
		
		?>
        <style>
        .description_row:nth-child(odd){
			background-color: #f9f9f9;
		}
		
        </style>
        <script> var my_table_list=<?php echo $this->generete_jsone_list(); ?></script>
        <div class="wrap">
            <form method="post"  action="" id="admin_form" name="admin_form" ng-app="" ng-controller="customersController">
			<h2 class="wpda_pt_h2">Theme <a href="admin.php?page=wpda_pricing_table_themes&task=add_wpda_pricing_table_themes" class="add-new-h2">Add New</a> <a target="blank" href="<?php echo wpdevart_pricing_table_support_url; ?>" class="wpdevart_support">Have any Questions? Get quick support!</a></h2>            
   
            <div class="tablenav top" style="width:95%">  
                <input type="text" placeholder="Search" ng-change="filtering_table();" ng-model="searchText">            
                <div class="tablenav-pages"><span class="displaying-num">{{filtering_table().length}} items</span>
                <span ng-show="(numberOfPages()-1)>=1">
                    <span class="pagination-links"><a class="button first-page" ng-class="{disabled:(curPage < 1 )}" title="Go to the first page" ng-click="curPage=0;curect()">«</a>
                    <a class="button prev-page" title="Go to the previous page" ng-class="{disabled:(curPage < 1 )}" ng-click="curPage=curPage-1; curect()">‹</a>
                    <span class="paging-input"><span class="total-pages">{{curPage + 1}}</span> of <span class="total-pages">{{ numberOfPages() }}</span></span>
                    <a class="button next-page" title="Go to the next page" ng-class="{disabled:(curPage >= (numberOfPages() - 1))}" ng-click=" curPage=curPage+1; curect()">›</a>
                    <a class="button last-page" title="Go to the last page" ng-class="{disabled:(curPage >= (numberOfPages() - 1))}" ng-click="curPage=numberOfPages()-1;curect()">»</a></span></div>
                </span>
            </div>
            <table class="wp-list-table widefat fixed pages" style="width:95%">
                <thead>
                    <tr>
                        <th style="width: 100px;" id='oreder_by_id' data-ng-click="order_by='id'; reverse=!reverse; ordering($event,order_by,reverse);" class="manage-column sortable desc" scope="col"><a><span>ID</span><span class="sorting-indicator"></span></a></th>
                        <th data-ng-click="order_by='name'; reverse=!reverse; ordering($event,order_by,reverse)" class="manage-column sortable desc"><a><span>Name</span><span class="sorting-indicator"></span></a></th>
                        <th style="width:100px"><a>Default</span></a></th>
                        <th style="width:80px">Edit</th> 
						<th style="width:120px">Duplicate</th>						
                        <th  style="width:60px">Delete</th>
                    </tr>
                </thead>
                <tbody>
                 <tr ng-repeat="rows in names | filter:filtering_table" class="description_row">
					 <td>{{rows.id}}</td>
					 <td><a href="admin.php?page=wpda_pricing_table_themes&task=add_edit_theme&id={{rows.id}}">{{rows.name}}</a></td>
					 <td><a href="admin.php?page=wpda_pricing_table_themes&task=set_default_theme&id={{rows.id}}"><img src="<?php echo wpda_pricing_table_plugin_url.'includes/admin/images/default' ?>{{rows.default}}.png"></a></td>
					 <td><a href="admin.php?page=wpda_pricing_table_themes&task=add_edit_theme&id={{rows.id}}">Edit</a></td>
					  <td><a href="admin.php?page=wpda_pricing_table_themes&task=duplicate&id={{rows.id}}">Duplicate</a></td>
					 <td><a class="wpdevart_red" href="admin.php?page=wpda_pricing_table_themes&task=remove_theme&id={{rows.id}}">Delete</a></td>                               
                  </tr> 
                </tbody>
            </table>
        </form>
        </div>
    <script>

jQuery(document).ready(function(e) {
    jQuery('a.disabled').click(function(){return false});
	jQuery('form').on("keyup keypress", function(e) {
		var code = e.keyCode || e.which; 
		if (code  == 13) {               
			e.preventDefault();
			return false;
		}
	});
});
    function customersController($scope,$filter) {
		var orderBy = $filter('orderBy');
		$scope.previsu_search_result='';
		$scope.oredering=new Array();
		$scope.baza = my_table_list;
		$scope.curPage = 0;
		$scope.pageSize = 20;
		$scope.names=$scope.baza.slice( $scope.curPage* $scope.pageSize,( $scope.curPage+1)* $scope.pageSize)
		$scope.numberOfPages = function(){
		   return Math.ceil($scope.filtering_table().length / $scope.pageSize);
	   };
	   $scope.filtering_table=function(){
		   var new_searched_date_array=new Array;
		   new_searched_date_array=[];
		   angular.forEach($scope.baza,function(value,key){
			   var catched=0;
			   angular.forEach(value,function(value_loc,key_loc){
				   if((''+value_loc).indexOf($scope.searchText)!=-1 || $scope.searchText=='' || typeof($scope.searchText) == 'undefined')
					  catched=1;
			   })
			  if(catched)
				  new_searched_date_array.push(value);
		   })
		   if($scope.previsu_search_result != $scope.searchText){
			  
			  $scope.previsu_search_result=$scope.searchText;
			   $scope.ordering($scope.oredering[0],$scope.oredering[1], $scope.oredering[2]);
			   
		   }
		   if(new_searched_date_array.length<=$scope.pageSize)
		   		$scope.curPage = 0;
		   return new_searched_date_array;
	   }
	   $scope.curect=function(){
		   if( $scope.curPage<0){
				$scope.curPage=0;
		   }
		   if( $scope.curPage> $scope.numberOfPages()-1)
			   $scope.curPage=$scope.numberOfPages()-1;
		  $scope.names=$scope.filtering_table().slice( $scope.curPage* $scope.pageSize,( $scope.curPage+1)* $scope.pageSize)
	   }
		
		$scope.ordering=function($event,order_by,revers){
		   if( typeof($event) != 'undefined' && typeof($event.currentTarget) != 'undefined')
		   		element=$event.currentTarget;
			else
				element=jQuery();
		   
			if(revers)
			  indicator='asc'
			else
			  indicator='desc'
			 $scope.oredering[0]=$event;
			 $scope.oredering[1]=order_by;
			 $scope.oredering[2]=revers;
			jQuery(element).parent().find('.manage-column').removeClass('sortable desc asc sorted');
			jQuery(element).parent().find('.manage-column').not(element).addClass('sortable desc');
			jQuery(element).addClass('sorted '+indicator);		  
			$scope.names=orderBy($scope.filtering_table(),order_by,revers).slice( $scope.curPage* $scope.pageSize,( $scope.curPage+1)* $scope.pageSize)
		}
	}
    </script>
		<?php
		$this->generete_jsone_list();
	}
	private function generete_jsone_list(){
		global $wpdb;
		$query = "SELECT `id`,`name`,`default` FROM ".wpda_pricing_table_databese::$table_names['theme'];
		$rows=$wpdb->get_results($query);
		$json="[";
		$no_frst_storaket=1;
		foreach($rows as $row){
			$json.=(($no_frst_storaket) ? '' : ',' )."{";
			$no_frst_storaket=1;
			foreach($row as $key=>$value){
				if($key!='id'){
					$json.= "".(($no_frst_storaket) ? '' : ',' )."'".$key."':"."'".(($value)?preg_replace('/^\s+|\n|\r|\s+$/m', '',htmlspecialchars_decode(addslashes(strip_tags($value)))):'0')."'";				
				}
				else{					
					$json.= "".(($no_frst_storaket) ? '' : ',' )."'".$key."':".(($value)?htmlspecialchars_decode(addslashes($value)):'0'); 
				}
				
				$no_frst_storaket=0;
			 }			 
			 $json.="}";
		}
		$json.="]";
		return $json;
	}	
	public static function get_themes_by_ids($ids){
		global $wpdb;
		$ids_to_string=implode(",",$ids);
		$all_themes=array();
		$all_themes_info_from_db=$wpdb->get_results('SELECT * FROM '.wpda_pricing_table_databese::$table_names['theme'].' WHERE ID IN('.$ids_to_string.')');
		if($all_themes_info_from_db==null){
			return false;
		}
		foreach($all_themes_info_from_db as $theme_value){
			$all_themes[$theme_value->id]=json_decode($theme_value->option_value, true);
		}
		return $all_themes;
	}
	private function generete_theme_parametrs($id=0){
		global $wpdb;	
		$theme_params = NULL;
		$new_theme=1;
		if($id){
			$theme_params = $wpdb->get_row('SELECT * FROM '.wpda_pricing_table_databese::$table_names['theme'].' WHERE id='.$id);	
			$new_theme=0;
		}else{
			$theme_params = $wpdb->get_row('SELECT * FROM '.wpda_pricing_table_databese::$table_names['theme'].' WHERE `default`=1');	
			
		}
		if($theme_params==NULL){			
			foreach($this->options as $param_heading_key=>$param_heading_value){
				foreach($param_heading_value['params'] as $key=>$value){
					$this->options[$param_heading_key]['params'][$key]["value"]=$this->options[$param_heading_key]['params'][$key]["default_value"];
				}
			}
		}else{
			$databases_parametrs=json_decode($theme_params->option_value, true);
			foreach($this->options as $param_heading_key=>$param_heading_value){
				foreach($param_heading_value['params'] as $key=>$value){
					if(isset($databases_parametrs[$key])){
						$this->options[$param_heading_key]['params'][$key]["value"]=$databases_parametrs[$key];
					}else{
						$this->options[$param_heading_key]['params'][$key]["value"]=$this->options[$param_heading_key]['params'][$key]["default_value"];
					}
				}
			}
			if($new_theme){
				return "New Theme";
			}else{
				return $theme_params->name;
			}
		}
	}
	
	
	private function add_edit_theme($id=0){
		global $wpdb;
		$name=$this->generete_theme_parametrs($id);
		?>		         
		<form action="admin.php?page=wpda_pricing_table_themes<?php if($id) echo '&id='.$id; ?>" method="post" name="adminForm" class="top_description_table" id="adminForm">
            <div class="conteiner">
                <div class="header">
                    <span><h2 class="wpda_theme_title"><?php echo $id?"Edit":"Add" ?> Theme</h2></span>
                    <div class="header_action_buttons">
                        <span><input type="button" onclick="submitbutton('save_theme')" value="Save" class="button-primary action"> </span> 
                        <span><input type="button" onclick="submitbutton('update_theme')" value="Apply" class="button-primary action"> </span> 
                        <span><input type="button" onclick="window.location.href='admin.php?page=wpda_pricing_table_themes'" value="Cancel" class="button-secondary action"> </span> 
                    </div>
                </div>
                <div class="option_panel">            
                    <div class="parametr_name"></div>
                    <div class="all_options_panel">
                        <input type="text" class="theme_name" name="name" placeholder="Enter name here" value="<?php echo isset($name)?$name:'' ?>" >
                        <div class="wpda_theme_link_tabs">
							<?php
								echo "<ul>";
								foreach($this->options as $params_grup_name =>$params_group_value){ 
									echo '<li id="'.$params_grup_name.'_tab">'.$params_group_value['heading_name'].'</li>';
								}
								echo "</ul>";
							?>
						</div>
                        <table>
						<?php 
						foreach($this->options as $params_grup_name =>$params_group_value){ 
							wpda_pricing_table_library::create_table_heading($params_group_value['heading_name'],$params_grup_name);
							foreach($params_group_value['params'] as $param_name => $param_value){
								$args=array(
									"name"=>$param_name,
									"heading_name"=>$params_group_value['heading_name'],
									"heading_group"=>$params_grup_name,
								);
								$args=array_merge($args,$param_value);
								$function_name=$param_value['function_name'];
								wpda_pricing_table_library::$function_name($args);
							}
						}

						?>
					</table>
                    </div>
                </div>
            </div>
		</form>
		<?php

		 
	}
	private function set_default_theme($id){
		global $wpdb;
		$wpdb->update(wpda_pricing_table_databese::$table_names['theme'], array('default' => 0), array('default' => 1));
		$save = $wpdb->update(wpda_pricing_table_databese::$table_names['theme'], array('default' => 1), array('id' => $id));		
	}
	private function border_types(){
		$border_type[ 'dotted' ] = 'dotted';
		$border_type[ 'dashed' ] = 'dashed';
		$border_type[ 'solid' ] = 'solid';
		$border_type[ 'double' ] = 'double';
		$border_type[ 'groove' ] = 'groove';
		$border_type[ 'ridge' ] = 'ridge';
		$border_type[ 'inset' ] = 'inset';	
		$border_type[ 'outset' ] = 'outset';
		return $border_type;
	}
	private function fonts_options(){
		  $font_choices[ 'Arial,Helvetica Neue,Helvetica,sans-serif' ] = 'Arial *';
		  $font_choices[ 'Arial Black,Arial Bold,Arial,sans-serif' ] = 'Arial Black *';
		  $font_choices[ 'Arial Narrow,Arial,Helvetica Neue,Helvetica,sans-serif' ] = 'Arial Narrow *';
		  $font_choices[ 'Courier,Verdana,sans-serif' ] = 'Courier *';
		  $font_choices[ 'Georgia,Times New Roman,Times,serif' ] = 'Georgia *';
		  $font_choices[ 'Times New Roman,Times,Georgia,serif' ] = 'Times New Roman *';
		  $font_choices[ 'Trebuchet MS,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Arial,sans-serif' ] = 'Trebuchet MS *';
		  $font_choices[ 'Verdana,sans-serif' ] = 'Verdana *';
		  $font_choices[ 'American Typewriter,Georgia,serif' ] = 'American Typewriter';
		  $font_choices[ 'Andale Mono,Consolas,Monaco,Courier,Courier New,Verdana,sans-serif' ] = 'Andale Mono';
		  $font_choices[ 'Baskerville,Times New Roman,Times,serif' ] = 'Baskerville';
		  $font_choices[ 'Bookman Old Style,Georgia,Times New Roman,Times,serif' ] = 'Bookman Old Style';
		  $font_choices[ 'Calibri,Helvetica Neue,Helvetica,Arial,Verdana,sans-serif' ] = 'Calibri';
		  $font_choices[ 'Cambria,Georgia,Times New Roman,Times,serif' ] = 'Cambria';
		  $font_choices[ 'Candara,Verdana,sans-serif' ] = 'Candara';
		  $font_choices[ 'Century Gothic,Apple Gothic,Verdana,sans-serif' ] = 'Century Gothic';
		  $font_choices[ 'Century Schoolbook,Georgia,Times New Roman,Times,serif' ] = 'Century Schoolbook';
		  $font_choices[ 'Consolas,Andale Mono,Monaco,Courier,Courier New,Verdana,sans-serif' ] = 'Consolas';
		  $font_choices[ 'Constantia,Georgia,Times New Roman,Times,serif' ] = 'Constantia';
		  $font_choices[ 'Corbel,Lucida Grande,Lucida Sans Unicode,Arial,sans-serif' ] = 'Corbel';
		  $font_choices[ 'Franklin Gothic Medium,Arial,sans-serif' ] = 'Franklin Gothic Medium';
		  $font_choices[ 'Garamond,Hoefler Text,Times New Roman,Times,serif' ] = 'Garamond';
		  $font_choices[ 'Gill Sans MT,Gill Sans,Calibri,Trebuchet MS,sans-serif' ] = 'Gill Sans MT';
		  $font_choices[ 'Helvetica Neue,Helvetica,Arial,sans-serif' ] = 'Helvetica Neue';
		  $font_choices[ 'Hoefler Text,Garamond,Times New Roman,Times,sans-serif' ] = 'Hoefler Text';
		  $font_choices[ 'Lucida Bright,Cambria,Georgia,Times New Roman,Times,serif' ] = 'Lucida Bright';
		  $font_choices[ 'Lucida Grande,Lucida Sans,Lucida Sans Unicode,sans-serif' ] = 'Lucida Grande';
		  $font_choices[ 'Palatino Linotype,Palatino,Georgia,Times New Roman,Times,serif' ] = 'Palatino Linotype';
		  $font_choices[ 'Tahoma,Geneva,Verdana,sans-serif' ] = 'Tahoma';
		  $font_choices[ 'Rockwell, Arial Black, Arial Bold, Arial, sans-serif' ] = 'Rockwell';
		  $font_choices[ 'Segoe UI' ] = 'Segoe UI';
		  return $font_choices;
	}	
}


 ?>