<?php
	$ic = 'item-edit-input'; //input class.
	require('inc/data.item.icons.php'); //icon data constants
	require('inc/data.item.skills.php'); //item skill requirement constants
	$exclude_debug_fieldlist = [
		'icon','id','name','item_type','description',
		'lore' ,'lore_equip' ,'stacklore' ,'temporary' ,
		'artifact' ,'notrade' ,'nodestroy' ,'show_name',
		'crafted','attuneable','heirloom','nozone','norepair',
		'good_only','evil_only','novalue','ornate','etheral',
		'appearance_only','reforged','refined','usable',
		'collectable','tier','count','weight','slots',
		'skill_id_req2','display_charges','harvest','unlocked',
		'max_charges','skill_min','flags_16384','flags_32768',
		'flags2_256', 'set_name','soe_item_id','soe_item_crc',
		'recommended_level','adventure_default_level','stack_count',
		'sell_price', 'sell_status_amount','adornment_slot1',
		'adornment_slot2','adornment_slot3','adornment_slot4',
		'adornment_slot5','adornment_slot6','offers_quest_id',
		'soe_autoquest_id','part_of_quest_id','lua_script',
		'quest_unknown','adornment_description','skill_id_req',
		'tradeskill_default_level','adventure_classes',
		'tradeskill_classes'
	];
	
?>
<div class="col-xl-12">
	<div class="row">
		<!-- Item Icon Edit -->
		<div class="col-xs-4 col-sm-3 col-md-3 col-lg-3 col-xl-2 text-center">
			<div class="edit-item-ico-ctn">
				<img class="edit-item-ico vm" src="img/eq2/items/<?php echo $item['icon']; ?>.png"/>
				<br/>
				<small><strong>Icon ID</strong>: <?php echo $item['icon']; ?></small>
			</div>
			<button class="btn btn-xs btn-default btn-block ico-picker-btn">
				<i class="fad fa-eye-dropper color-info-500"></i> Icon Picker
			</button>
		</div>
		<!-- End: Item Icon Edit -->
		
		<!-- Item Basic Details -->
		<div class="col-xs-8 col-sm-9 col-md-9 col-lg-9 col-xl-10">
			<div class="row">
				<div class="col-sm-12 col-xl-7">
					<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'name','value'=>$item['name'],'id'=>$item['id'],'title'=>'Name','icon'=>'fad fa-tag','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Enter item name ...']); ?>
				</div>
				<div class="col-sm-12 col-xl-5">
					<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'set_name','value'=>$item['set_name'],'id'=>$item['id'],'title'=>'Set Name','icon'=>'fad fa-tags','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Enter a set name...']); ?>
				</div>
				<div class="col-sm-6 col-xl-6">
					<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'icon','value'=>$item['icon'],'id'=>$item['id'],'title'=>'Icon ID','icon'=>'fad fa-images','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Enter icon id ...', 'type'=>'number']); ?>
				</div>
				<div class="col-sm-6 col-xl-6">
					<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'item_type','value'=>$item['item_type'],'id'=>$item['id'],'title'=>'Item Type','icon'=>'fad fa-disease','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>NULL, 'field_type'=>'select', 'options'=>$itemCategories]); ?>
				</div>
			</div>
		</div>
		<!-- End: Item Basic Details -->
	</div>
</div>
<!-- Description Row -->
<div class="col-xl-12">
	<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'description','value'=>$item['description'],'id'=>$item['id'],'title'=>'Description','icon'=>'fad fa-file-signature','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Enter an item description ...', 'field_type'=>'textarea']); ?>
</div>
<!-- End: Description Row -->



<div class="col-xl-12">
	<div class="row">
		<!-- Stats & Reqs Panel -->
		<div class="col-xs-7 col-sm-7 col-md-7 col-lg-7 col-xl-7">
			<!-- Requisites -->
			<div id="itemeditor-reqs" class="panel">
				<div class="panel-hdr">
					<h4 class="mb-0 color-secondary"><i class="fas fa-badge-check color-warning-900"></i>&nbsp;Requisites</h4>
				</div> 
				<div class="panel-container show" style="">
					<div class="panel-content">
						<div class="row">
							<div class="col-xs-12 col-sm-12 col-md-12 col-lg-8 col-xl-8">
								<?php
									$_skillsReq = get_skills($_itemSkills['req'],true);
									echo build_edit_input(['key'=>'id','table'=>'items','field'=>'skill_id_req','value'=>$item['skill_id_req'],'id'=>$item['id'],'title'=>'Skill Req.','icon'=>'fas fa-shield-cross color-success-700','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>'Primary skill requirement.','placeholder'=>NULL, 'field_type'=>'select', 'options'=>$_skillsReq]);
									$_skillsReq = NULL; // Clear memory usage.
								?>
							</div>
							<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4 col-xl-4">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'skill_min','value'=>$item['skill_min'],'id'=>$item['id'],'title'=>'Min. Skill','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>'The minimum skill required.','placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
								<?php
									$_skillsReq2 = get_skills($_itemSkills['req2'],true);
									echo build_edit_input(['key'=>'id','table'=>'items','field'=>'skill_id_req2','value'=>$item['skill_id_req2'],'id'=>$item['id'],'title'=>'Skill Req.','icon'=>'fas fa-bow-arrow color-info-700','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>'Secondary skill requirement for this item.','placeholder'=>NULL, 'field_type'=>'select', 'options'=>$_skillsReq2]);
									$_skillsReq2 = NULL; // Clear memory usage.
								?>
							</div>
							
							<div class="col-xl-12"><h1><hr></hr></h1></div>

							<div class="col-xs-12 col-sm-12 col-md-7 col-lg-7 col-xl-6">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'adventure_default_level','value'=>$item['adventure_default_level'],'id'=>$item['id'],'title'=>'Adventure Level','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>'Default Adventure Level.','placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xs-12 col-sm-12 col-md-5 col-lg-5 col-xl-6">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'recommended_level','value'=>$item['recommended_level'],'id'=>$item['id'],'title'=>'Rec. Level','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>'Recommended player level.','placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xs-12 col-sm-12 col-md-5 col-lg-5 col-xl-6">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'tradeskill_default_level','value'=>$item['tradeskill_default_level'],'id'=>$item['id'],'title'=>'Tradeskill Level','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>'Default Tradeskill Level','placeholder'=>'0','type'=>'number']); ?>
							</div>
							
							
							
						</div>
					</div>
				</div>
			</div>
			<!-- End: Requisites -->
		
			<!-- Stats -->
			<div id="itemeditor-props" class="panel">
				<div class="panel-hdr">
					<h4 class="mb-0 color-secondary"><i class="fas fa-book-spells color-primary-500"></i>&nbsp;Stats</h4>
				</div>
				<div class="panel-container show" style="">
					<div class="panel-content">
						<div class="row">
							<p>Item Stats</p>
							<div class="col-xl-12"><h1><hr></hr></h1></div>
							
							<div class="col-xl-5">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'sell_price','value'=>$item['sell_price'],'id'=>$item['id'],'title'=>'Sell Price','icon'=>'fas fa-toilet-paper color-success-700','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>'Merchant sell price.','placeholder'=>'0','type'=>'number']); ?>
							</div>
							
							<div class="col-xl-7">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'sell_status_amount','value'=>$item['sell_status_amount'],'id'=>$item['id'],'title'=>'Sell Status Amt.','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>'Sell status amount. Whatever that means...','placeholder'=>'0','type'=>'number']); ?>
							</div>
							
							<div class="col-xl-12"><h1><hr></hr></h1></div>
							<div class="col-xl-6">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'tier','value'=>$item['tier'],'id'=>$item['id'],'title'=>'Tier','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xl-6">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'count','value'=>$item['count'],'id'=>$item['id'],'title'=>'Count','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Count - whatever that means...','type'=>'number']); ?>
							</div>
							<div class="col-xl-6">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'weight','value'=>$item['weight'],'id'=>$item['id'],'title'=>'Weight','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xl-6">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'stack_count','value'=>$item['stack_count'],'id'=>$item['id'],'title'=>'Stack Count','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Stack count (int)','type'=>'number']); ?>
							</div>
							<div class="col-xl-6">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'slots','value'=>$item['slots'],'id'=>$item['id'],'title'=>'Slots','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Slots (int)','type'=>'number']); ?>
							</div>

							<div class="col-xl-12"><h4 class="mb-0">Adornment Slots<hr class="mb-2 mt-1"></hr></h4></div>
							
							<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-4">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'adornment_slot1','value'=>$item['adornment_slot1'],'id'=>$item['id'],'title'=>'Slot 1','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>NULL,'placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-4">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'adornment_slot2','value'=>$item['adornment_slot2'],'id'=>$item['id'],'title'=>'Slot 2','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>NULL,'placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-4">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'adornment_slot3','value'=>$item['adornment_slot3'],'id'=>$item['id'],'title'=>'Slot 3','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>NULL,'placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-4">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'adornment_slot4','value'=>$item['adornment_slot4'],'id'=>$item['id'],'title'=>'Slot 4','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>NULL,'placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-4">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'adornment_slot5','value'=>$item['adornment_slot5'],'id'=>$item['id'],'title'=>'Slot 5','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>NULL,'placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-4">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'adornment_slot6','value'=>$item['adornment_slot6'],'id'=>$item['id'],'title'=>'Slot 6','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>NULL,'placeholder'=>'0','type'=>'number']); ?>
							</div>
							<div class="col-xl-12">
								<?php echo build_edit_input(['key'=>'id','table'=>'items','field'=>'adornment_description','value'=>$item['adornment_description'],'id'=>$item['id'],'title'=>'Adornment Description','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Enter an adornment description ...', 'field_type'=>'textarea']); ?>
							</div>
						</div>
					</div>	<!-- fas fa-toilet-paper, fas fa-book-spells -->
				</div>
			</div>
		</div>



		<!-- Right Slim Column -->
		<div class="col-xs-5 col-sm-5 col-md-5 col-lg-5 col-xl-5">
			<!-- Flags Panel -->
			<div id="itemeditor-props" class="panel">
				<div class="panel-hdr">
					<h4 class="mb-0 color-secondary"><i class="fas fa-flag color-danger-700"></i>&nbsp;Flags</h4>
				</div>
				<div class="panel-container show" style="">
					<div class="panel-content">
						<div class="row">
							<?php
								$_switches = [
									'lore'				=> ['title'=>'Lore',			'ico'=>''],
									'lore_equip'		=> ['title'=>'Lore Equip',		'ico'=>''],
									'stacklore'			=> ['title'=>'Stack Lore',		'ico'=>''],
									'temporary'			=> ['title'=>'Temporary',		'ico'=>''],
									'artifact'			=> ['title'=>'Artifact',		'ico'=>''],
									'notrade'			=> ['title'=>'Untradable',		'ico'=>''],
									'nodestroy'			=> ['title'=>'Indestructible',	'ico'=>''],
									'show_name'			=> ['title'=>'Show Name',		'ico'=>''],
									'crafted'			=> ['title'=>'Crafted',			'ico'=>''],
									'attuneable'		=> ['title'=>'Attuneable',		'ico'=>''],
									'heirloom'			=> ['title'=>'Heirloom',		'ico'=>''],
									'nozone'			=> ['title'=>'No Zone',			'ico'=>''],
									'norepair'			=> ['title'=>'No Repair',		'ico'=>''],
									'good_only'			=> ['title'=>'Good Only',		'ico'=>''],
									'evil_only'			=> ['title'=>'Evil Only',		'ico'=>''],
									'novalue'			=> ['title'=>'No Value',		'ico'=>''],
									'ornate'			=> ['title'=>'Ornate',			'ico'=>''],
									'etheral'			=> ['title'=>'Etheral',			'ico'=>''],
									'appearance_only'	=> ['title'=>'Appearance Only',	'ico'=>''],
									'reforged'			=> ['title'=>'Reforged',		'ico'=>''],
									'refined'			=> ['title'=>'Refined',			'ico'=>''],
									'usable'			=> ['title'=>'Usable',			'ico'=>''],
									'harvest'			=> ['title'=>'Harvest',			'ico'=>''],
									'collectable'		=> ['title'=>'Collectable',		'ico'=>''],
									'unlocked'			=> ['title'=>'Unlocked',		'ico'=>'']
				
								];
								foreach($_switches as $k => $v) {
									echo '
									<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
										'.build_edit_input(['key'=>'id','table'=>'items','field'=>$k,'value'=>$item[$k],'icon'=>$v['ico'],'title'=>$v['title'],'id'=>$item['id'],'show-label'=>true,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>NULL, 'field_type'=>'switch']).'
									</div>';
								}
							?>
						</div>
					</div>	<!-- fas fa-toilet-paper, fas fa-book-spells -->
				</div>
			</div>
			<!-- End: Flags Panel -->
			
			
			<!-- Spell Effects Panel -->
			<div id="itemeditor-fx" class="panel">
				<div class="panel-hdr">
					<h4 class="mb-0 color-secondary"><i class="fad fa-flask-potion color-info-700"></i>&nbsp;Effects</h4>
				</div>
				<div class="panel-container show" style="">
					<div class="panel-content">
						<div class="row">
							<div class="col-xl-12">
								<?php
									echo build_edit_input(['key'=>'id','table'=>'items','field'=>'max_charges','value'=>$item['max_charges'],'id'=>$item['id'],'title'=>'Max Charges','icon'=>NULL,'show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Number of charges for the clickable item effect.','type'=>'number']);
									
									echo build_edit_input(['key'=>'id','table'=>'items','field'=>'display_charges','value'=>$item['display_charges'],'icon'=>NULL,'title'=>'Show Charges','id'=>$item['id'],'show-label'=>true,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>NULL, 'field_type'=>'switch']);
								?>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- End: Spell Effects Panel -->
		</div>
		<!-- End: Right Slim Column -->
		
		
		<?php
		$_unknownFields = [
			'flags_16384','flags_32768','flags2_256','soe_item_id','soe_item_crc',
			'offers_quest_id','soe_autoquest_id','part_of_quest_id','quest_unknown',
			'tradeskill_classes','adventure_classes'
		];
		?>
		<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
			<!-- Unknown Columns Panel -->
			<div id="itemeditor-unknown" class="panel">
				<div class="panel-hdr">
					<h4 class="mb-0 color-secondary"><i class="fad fa-map-marker-question color-primary-700"></i>&nbsp;Unknown Fields</h4>
				</div>
				<div class="panel-container show" style="">
					<div class="panel-content">
						<div class="row">
							<?php
								foreach($_unknownFields as $f) {
									echo '<div class="col-xl-4">
									'.build_edit_input(['key'=>'id','table'=>'items','field'=>$f,'value'=>$item[$f],'id'=>$item['id'],'title'=>$f,'icon'=>'fad fa-tag','show-label'=>false,'class'=>$ic,'aria'=>false,'desc'=>false,'placeholder'=>'Enter item name ...']).'
									</div>';
								}
							?>
						</div>
					</div>
				</div>
			</div>
			<!-- End: Unknown Columns Panel -->
		</div>
		
		
		
	</div> <!-- Row -->
</div> <!-- Col -->
	
