<!-- Script PHP/MYSQL of management of classifieds ads developed by Script PAG. Script PAG all rights reserved. Use under license. http://www.script-pag.com -->
<div class="internal-body">

	<p class="header-internal-body"><?php echo $language_adm['page_add_opts_info']; ?></p>
	
	<div class="body-internal-body form">
		
		<?php
		
			if(!empty($error) && $error == 1) echo '<p class="error">'. $language_adm['page_add_opts_error'] .'</p>';
			
			if(isset($_GET['succes']) && $_GET['succes'] == 1)
			{
				if($_GET['succes'] == 1)
				echo '<p class="succes">'. $language_adm['page_add_opts_su'] .'</p>';
			}
		?>
	
		<form method="post" action="cat_opts.php?act=13&amp;menu=5">
			<div>
			
				<div class="flex-container div-form first-child">
					<p class="title"><?php echo $language_adm['page_disc_cat']; ?></p>
					<div><input type="hidden" name="valid" value="1" /><?php if(is_array($cache_cat)) display_adm_cat($id_cat, 'select_cat'); ?></div>
				</div>
				
				<div id="get_opts" class="last-child">
					
					<?php
						
					foreach($cache_cat as $v)
					{
						if($v['id_cat'] == $id_cat)
						{
							$checked_price = '';
							$checked_digital[] = array();
							$checked_data[] = array();
							$checked_check[] = array();
							
							foreach($cache_search_price as $price)
							{
								if($price['id_cat'] == $id_cat)
								$checked_price = $price['id_cat_opt'];
							}
		
							foreach($cache_search_digital as $digital)
							{
								if($digital['id_cat'] == $id_cat)
								$checked_digital[] = $digital['id_cat_opt'];
							}
							
							foreach($cache_search_data as $data)
							{
								if($data['id_cat'] == $id_cat)
								$checked_data[] = $data['id_cat_opt'];
							}
							
							foreach($cache_search_check as $check)
							{
								if($check['id_cat'] == $id_cat)
								$checked_check[] = $check['id_cat_opt'];
							}
							
							if(is_array($cache_cat_opts))
							{
								foreach($cache_cat_opts as $row)
								{
									$type_cat_opt = (int) $row['type_cat_opt'];
								 
									if($type_cat_opt == 4)
									{
										?>
										<div class="flex-container div-form">
											<label class="title" class="title" for="opts_price"><?php echo $language_adm['page_add_opts_price_none']; ?></label>
											<div class="label">
												<input type="radio" id="opts_price" name="opts_price" value="0" <?php echo 'checked'; ?> />
												<label for="opts_price"></label>
											</div>
										</div>
										<?php
											
										break;
									}
								}
							}
							if(is_array($cache_cat_opts))
							{
								$i = 1;
								
								foreach($cache_cat_opts as $row)
								{
									$id_cat_opt = (int) $row['id_cat_opt'];
									$type_cat_opt = (int) $row['type_cat_opt'];
								 
									if($type_cat_opt == 4)
									{
										?>
										<div class="flex-container div-form">
											<label class="title" for="<?php echo $id_cat_opt; ?>"><?php echo $language_adm['page_add_opts_info4'] .' <b>'. $i .'</b>'; ?></label>
											<div class="label">
												<input type="radio" id="<?php echo $id_cat_opt; ?>" name="opts_price" value="<?php echo $id_cat_opt; ?>" <?php if(!empty($checked_price) && $checked_price == $id_cat_opt) echo 'checked'; ?> />
												<label for="<?php echo $id_cat_opt; ?>"></label>
											</div>
										</div>
										<?php
											
										$i++;
									}
								}
							}
							if(is_array($cache_cat_opts))
							{
								foreach($cache_cat_opts as $row)
								{
									$id_cat_opt = (int) $row['id_cat_opt'];
									$type_cat_opt = (int) $row['type_cat_opt'];
									$comment = $row['comment'];
								 
									if($type_cat_opt == 1)
									{
										foreach($cache_lang as $v)
										{
											$code_lang = stripslashes(htmlspecialchars($v['code_lang'], ENT_QUOTES));
											$name_cat_opt_lang = (isset($row['name_cat_opt_'. $code_lang])) ? stripslashes(htmlspecialchars($row['name_cat_opt_'. $code_lang], ENT_QUOTES)) : '';
											$position = (int) $v['position'];
											$active = (int) $v['active'];
											
											if($position != 1)
											continue;
											
											if($active == 1 && !empty($name_cat_opt_lang))
											{
											?>
											<div class="flex-container div-form">
												<label class="title" for="<?php echo $id_cat_opt; ?>"><?php echo $language_adm['page_add_opts_info1'] .' <b>'. $name_cat_opt_lang .'</b>'; if(!empty($comment)) echo ' - '. $comment; ?></label>
												<div class="label">
													<input type="checkbox" id="<?php echo $id_cat_opt; ?>" name="opts_digital[]" value="<?php echo $id_cat_opt; ?>" <?php if(in_array($id_cat_opt, $checked_digital)) echo 'checked'; ?> />
													<label for="<?php echo $id_cat_opt; ?>"></label>
												</div>
											</div>
											<?php
											}
											
											if($position == 1)
											break;
										}
									}
								}
							}
							if(is_array($cache_cat_opts))
							{
								foreach($cache_cat_opts as $row)
								{
									$id_cat_opt = (int) $row['id_cat_opt'];
									$child_cat_opt = (int) $row['child_cat_opt'];
									$type_cat_opt = (int) $row['type_cat_opt'];
									$comment = $row['comment'];
								 
									if($type_cat_opt == 2)
									{
										foreach($cache_lang as $v)
										{
											$code_lang = stripslashes(htmlspecialchars($v['code_lang'], ENT_QUOTES));
											$name_cat_opt_lang = (isset($row['name_cat_opt_'. $code_lang])) ? stripslashes(htmlspecialchars($row['name_cat_opt_'. $code_lang], ENT_QUOTES)) : '';
											$position = (int) $v['position'];
											$active = (int) $v['active'];
											
											if($position != 1)
											continue;
											
											if($active == 1 && !empty($name_cat_opt_lang) && $child_cat_opt == 0)
											{
											?>
											<div class="flex-container div-form">
												<label class="title" for="<?php echo $id_cat_opt; ?>"><?php echo $language_adm['page_add_opts_info2'] .' <b>'. $name_cat_opt_lang .'</b>'; if(!empty($comment)) echo ' - '. $comment; ?></label>
												<div class="label">
													<input type="checkbox" id="<?php echo $id_cat_opt; ?>" name="opts_data[]" value="<?php echo $id_cat_opt; ?>" <?php if(in_array($id_cat_opt, $checked_data)) echo 'checked'; ?> />
													<label for="<?php echo $id_cat_opt; ?>"></label>
												</div>
											</div>
											<?php
											}
											
											if($position == 1)
											break;
										}
									}
								}
							}
							if(is_array($cache_cat_opts))
							{
								foreach($cache_cat_opts as $row)
								{
									$id_cat_opt = (int) $row['id_cat_opt'];
									$type_cat_opt = (int) $row['type_cat_opt'];
									$comment = $row['comment'];
								 
									if($type_cat_opt == 3)
									{
										foreach($cache_lang as $v)
										{
											$code_lang = stripslashes(htmlspecialchars($v['code_lang'], ENT_QUOTES));
											$name_cat_opt_lang = (isset($row['name_cat_opt_'. $code_lang])) ? stripslashes(htmlspecialchars($row['name_cat_opt_'. $code_lang], ENT_QUOTES)) : '';
											$position = (int) $v['position'];
											$active = (int) $v['active'];
											
											if($position != 1)
											continue;
											
											if($active == 1 && !empty($name_cat_opt_lang))
											{
											?>
											<div class="flex-container div-form">
												<label class="title" for="<?php echo $id_cat_opt; ?>"><?php echo $language_adm['page_add_opts_info3'] .' <b>'. $name_cat_opt_lang .'</b>'; if(!empty($comment)) echo ' - '. $comment; ?></label>
												<div class="label">
													<input type="checkbox" id="<?php echo $id_cat_opt; ?>" name="opts_checkbox[]" value="<?php echo $id_cat_opt; ?>" <?php if(in_array($id_cat_opt, $checked_check)) echo 'checked'; ?> />
													<label for="<?php echo $id_cat_opt; ?>"></label>
												</div>
											</div>
											<?php
											}
											
											if($position == 1)
											break;
										}
									}
								}
							}
							
							break;
						}
					}
					
					?>
		
				</div>
				
			</div>
			
			<div class="input-submit"><input type="submit" value="<?php echo $language_adm['bt_link_submit']; ?>" /></div>
			
		</form>
		
	</div>
</div>