<script>
	$('#name_page_cat').html('{ADMIN_LABEL}');
</script>
<h1>{ADMIN_LABEL}</h1>
<div class="dynContent">
	<div class="groupItem <?php if($_POST['admin_type_post'] == "create_cat") { echo "opened"; } else { echo "closed"; } ?>">
		<h2>{ADD_CAT_LABEL}</h2>
		<ul>
			<li>
				<h3>{ADD_CAT_LABEL}</h3>
				<p>{ADD_CAT_TEXT_LABEL}</p>
				<br />
				<form action="" method="POST">
					<table>
						<tbody>
							<tr>
								<th>{CAT_NAME_LABEL} :</th>
								<th><input type="text" name="name_cat" /></th>
							</tr>
							<tr>
								<th>{CAT_TYPE_LABEL} :</th>
								<th>
									<select name="type_cat">
										<option value="DC">{MONEY_NAME}</option>
										<option value="MD">{SECOND_MONEY_NAME}</option>
									</select>
								</th>
							</tr>
							<tr>
							  <th><input type="submit" value="{CREATE_LABEL}" /></th>
							  <th>&nbsp;</th>
							</tr>
						</tbody>
					</table>
					
					
					
					<input type="hidden" name="admin_type_post" value="create_cat" />
					
				
				</form>
				<p><?php echo SendAdminAction('create_cat'); ?></p>
			</li>
			
		</ul>
		<div class="groupItemEnd">
		</div>
	</div>
	<div class="groupItem <?php if($_POST['admin_type_post'] == "modify_cat" or $_GET['delete_cat']) { echo "opened"; } else { echo "closed"; } ?>">
		<h2>{MODIFY_CAT_LABEL}</h2>
		<ul>
			<script type="text/javascript">
					function GetCatById(id){
						if(id == ""){
							id = 0;
						}
						$.ajax({
							'url': './ajax/get_modify_cat/'+ id + '/',
							'success': function(data, request, status) { 
								$('#form_modify_cat_result').html(data);
								$('#form_modify_cat_result').show();
							}
							});
					}
				</script>
			<li>
				<h3>{MODIFY_CAT_LABEL}</h3>
				<p>{MODIFY_CAT_TEXT_LABEL}</p>
				<br />
				<p><?php echo SendAdminAction('modify_cat'); 
					
				?></p>
				<form action="" method="POST" onsubmit="GetCatById(this.type_cat.value); return false;">
					<table>
						<tbody>
							<tr>
								<th>{CATEGORIE_LABEL} :</th>
								<th>
									<select name="type_cat" id="type_cat">
										<?php echo DisplayListSelectCat(); ?>
									</select>
								</th>
							</tr>
							<tr>
							  <th><input type="submit" value="{MODIFY_LABEL}" /></th>
							 
							</tr>
						</tbody>
					</table>
					
				</form>
				<hr>
				<div id="form_modify_cat_result" style="display:none;">
					
				</div>
			</li>
		</ul>
		<div class="groupItemEnd">
		</div>
	</div>
	<div class="groupItem <?php if($_POST['admin_type_post'] == "create_item") { echo "opened"; } else { echo "closed"; } ?>">
		<h2>{ADD_ITEM_LABEL}</h2>
		<ul>
			
			<li>
				<h3>{ADD_ITEM_LABEL}</h3>
				<p>{ADD_ITEM_TEXT_LABEL}</p>
				<br />
				<script type="text/javascript">
					function GetItemInfo(vnum){
						if(vnum == ""){
							vnum = 0;
						}
						$.ajax({
							'url': './ajax/get_create_item/'+ vnum + '/',
							'success': function(data, request, status) { 
								$('#form_create_item_result').html(data);
								$('#form_create_item_result').show();
							}
							});
					}
				</script>
				<form action="" method="POST" onsubmit="GetItemInfo(this.vnum_item_create.value); return false;">
				<table>
					<tbody>
						<tr>
							<th>{VNUM_LABEL} :</th>
							<th><input type="text" name="vnum_item_create" id="vnum_item_create" /></th>
						</tr>
						<tr>
						  <th><input type="submit" value="{ADD_LABEL}" /></th>
						  <th>&nbsp;</th>
						</tr>
					</tbody>
				</table>
					
					
					<p><?php echo SendAdminAction('create_item'); ?></p>
				</form>
				
				<hr>
				<div id="form_create_item_result" style="display:none;">
					
				</div>
				
			</li>
		</ul>
		<div class="groupItemEnd">
		</div>
	</div>
	<div class="groupItem <?php if($_POST['admin_type_post'] == "modify_item") { echo "opened"; } else { echo "closed"; } ?>">
		<h2>{MODIFY_ITEM_LABEL}</h2>
		<ul>
			
			<li>
				<h3>{MODIFY_ITEM_LABEL}</h3>
				<p>{MODIFY_ITEM_TEXT_LABEL}</p>
				<br />
				<p><?php echo SendAdminAction('modify_item'); ?></p>
				<form action="" onsubmit="GetItemInfoModify(this.item_id.value); return false;" method="POST">
					<table>
						<tbody>
							<tr>
								<th>{ITEM_LABEL} :</th>
								<th>
									<select name="item_id">
										<?php echo DisplayListItem(); ?>
									</select>
								</th>
							</tr>
							<tr>
							  <th><input type="submit" value="{MODIFY_LABEL}" /></th>
							</tr>
						</tbody>
					</table>
										
				</form>
				<script type="text/javascript">
					function GetItemInfoModify(id){
						if(id == ""){
							id = 0;
						}
						$.ajax({
							'url': './ajax/get_modify_item/'+ id + '/',
							'success': function(data, request, status) { 
								$('#form_modify_item_result').html(data);
								$('#form_modify_item_result').show();
							}
							});
					}
				</script>
				<hr>
				<div id="form_modify_item_result" style="display:none;">
					
				</div>
			</li>
		</ul>
		<div class="groupItemEnd">
		</div>
	</div>
</div>


<script>
$(document).ready(function() {
	$('.groupItem').find('h2').click(function() {
		$(this).closest('.groupItem').toggleClass('opened closed');
	});
});
</script>