<?php
if ($accounttype >= '0'){
	echo getPanel("warning","Error","This is disabled");
}
else{
?>
<div class="card-body">
Rewards can only be claimed once per person,<br>
KI Requires manual verification by GMs do not claim if you do not have the KI<br>
GMs Will verify any claims before rewards will be delivered.<br>
To reduce GM workload please do not claim if you havent met the requirements and if you have already claimed on one of your accounts
<br>
<strong>If you are selecting an ITEM you must use the ITEM ID you can get this from looking up the item and copying the ITEM ID</strong>
			<div class="table-responsive">
			<table class="table table-hover">
    <tr class="table-primary"> 
    <td><b>Campaign</td>
    <td><b>Level Required</td>
    <td><b>Rank Required</td>
    <td><b>Merits Required</td>
    <td><b>Campaign Required</td>
    <td><b>Item Required</td>
    <td><b>Key Item Required</td>
    <td><b>Item Reward</td>
    <td><b>Item Reward</td>
    <td><b>Item Reward</td>
    <td><b>Gil Reward</td>
    <td><b>End Date</td>
    <td><b>Claim</td>
    </tr>
<?php
$chars = getCharacterList($users['id']);
$date=date("Ymj");

foreach($campaigns as $camp) {
    $completed=0;
    $unable=0;
    $lreq="Incomplete";
    $nreq="Incomplete";
    $mreq="Incomplete";
    $vreq="Incomplete";
    $ireq="Incomplete";
    $kreq="";
	$new=$camp['new'];
	$existing=$camp['existing'];
	
    foreach($chars as $char) { 
	
	$created = strtotime($char['timecreated']);
    $charexisting = strtotime("+".$existing." day", $created);
    $charnew = strtotime("+".$new." day", $created);
		if($charexisting>time()&&$existing!=0){
			$unable=1;
			echo '<tr class="table-warning"><td colspan=13><strong>Character '.$char['charname'].' is not Eligible for Existing Player Campaign Yet.</strong></td></tr>';
		}
		if($charnew<=time()&&$new!=0){
			$unable=1;
			echo '<tr class="table-warning"><td colspan=13><strong>Character '.$char['charname'].' is no longer Eligible for New Player Campaign.</strong></td></tr>';
		}
        $var=getCharacterVar($char['charid'],$camp['var_granted']);
        if($var==2){
			$completed=2;
        }elseif($var==1){
			$completed=1;
        }
        $unablev=getCharacterVar($char['charid'],$camp['unable_var']);
        if($unablev==2){
			$unable=1;
        }elseif($unablev==1){
			$unable=1;
        }
        $unablev=getCharacterVar($char['charid'],$camp['unable_var2']);
        if($unablev==2){
			$unable=1;
        }elseif($unablev==1){
			$unable=1;
        }
		$lvlr=getCharacterMaxLevel($char['charid']);
        if($lvlr>=$camp['level_required']){
			$lreq="Completed";
        }
		$rankr=getCharacterMaxRank($char['charid']);
		if($rankr>=$camp['rank_required']){
			$nreq="Completed";
		}
        $meritr=getCharacterExp($char['charid']);
        if($meritr['merits']>=$camp['merits_required']){
            $mreq="Completed";
        }
        $varr=getCharacterVar($char['charid'],$camp['var_required']);
        if(($varr>=1 && $varr!='No Var') || $camp['var_required']==""){
            $vreq="Completed";
        }
        $itemr=getCharacterItem($char['charid'],$camp['item_required']);
        if($itemr>=1 || $camp['item_required']==""){
            $ireq="Completed";
        }
        if($camp['key_item_required']==""){
            $kreq="Completed";
        }
    }
	if($unable!=1){
		if($date>$camp['end'] || $lreq=="Incomplete" || $nreq=="Incomplete" || $mreq=="Incomplete" || $vreq=="Incomplete" || $ireq=="Incomplete"){
			echo '<tr class="table-danger"> ';
		}
		elseif($completed==1){
			echo '<tr class="table-warning"> ';
		}
		else{
			echo '<tr class="table-info"> ';
		}
		echo '
		<td>
		<form action="" method="post">'.$camp['name'].'</td>
		<td>'.$camp['level_required'].'<br> '.$lreq.'</td>
		<td>'.$camp['rank_required'].'<br>'.$nreq.'</td>
		<td>'.$camp['merits_required'].'<br> '.$mreq.'</td>
		<td>'.$camp['var_required'].'<br> '.$vreq.'</td>';
		if($camp['item_required']>=1){
			echo'<td>
			<a href="?p=items&id='.$camp['item_required'].'">
			<img src=http://static.ffxiah.com/images/icon/'.$camp['item_required'].'.png alt='.ucwords(str_replace('_',' ',getItemName($camp['item_required']))).' height=32 width=32>
			'.ucwords(str_replace('_',' ',getItemName($camp['item_required']))).'</a> <br> '.$ireq.'
			</td>';   
		}
		else{
			echo '<td>'.$ireq.'</td>';
		}
		echo'
		<td>'.$camp['key_item_required'].'<br> '.$kreq.'</td>';
		if($camp['item1']=='any'){
			if($completed==1){
					$item1=getCharacterVar($char['charid'],$camp['var_granted'].'item1');
			echo '<td><select name="item1" size="1">
		<option value="'.$item1.'">'.ucwords(str_replace('_',' ',getItemName($item1))).'</option></select></td>';
			}else{
		echo'<td><select name="item1" size="1">
		<option value="18991">Conqueror</option>
		<option value="18992">Glanzfaust</option>
		<option value="18993">Yagrush</option>
		<option value="18994">Laevateinn</option>
		<option value="18995">Murgleis</option>
		<option value="18996">Vajra</option>
		<option value="18997">Burtgang</option>
		<option value="18998">Liberator</option>
		<option value="18999">Aymur</option>
		<option value="19000">Carnwenhan</option>
		<option value="19001">Gastraphetes</option>
		<option value="19002">Kogarasumaru</option>
		<option value="19003">Nagi</option>
		<option value="19004">Ryunohige</option>
		<option value="19005">Nirvana</option>
		<option value="19006">Tizona</option>
		<option value="19007">Death Penalty</option>
		<option value="19008">Kenkonken</option>
		<option value="18989">Terpsichore</option>
		<option value="18990">Tupsimati</option>
		<option value="18264">Spharai</option>
		<option value="18270">Mandau</option>
		<option value="18276">Excalibur</option>
		<option value="18282">Ragnarok</option>
		<option value="18288">Guttler</option>
		<option value="18294">Bravura</option>
		<option value="18306">Apocalpyse</option>
		<option value="18300">Gungnir</option>
		<option value="18312">Kikoku</option>
		<option value="18318">Amanomurakumo</option>
		<option value="18324">Mjollnir</option>
		<option value="18330">Claustrum</option>
		<option value="18348">Yoichinoyumi</option>
		<option value="18336">Annihilator</option>
		<option value="18342">Gjallarhorn</option>
		<option value="15070">Aegis</option>
		<option value="15899">Velocious Belt</option>
		<option value="18852">Octave Club</option>
		<option value="13566">Defending Ring</option>
		<option value="13909">Blood Mask</option>
		<option value="14368">Blood Scale Mail</option>
		<option value="14059">Blood Finger Gauntlets</option>
		<option value="14281">Blood Cuisses</option>
		<option value="14161">Blood Greaves</option>
		<option value="13877">Zenith Crown +1</option>
		<option value="13788">Dalmatica +1</option>
		<option value="14007">Zenith Mitts +1</option>
		<option value="14248">Zenith Slacks +1</option>
		<option value="14124">Zenith Pumps +1</option>
		<option value="13935">Shura Zunari Kabuto +1</option>
		<option value="14388">Shura Togi +1</option>
		<option value="14822">Shura Kote +1</option>
		<option value="14304">Shura Haidate +1</option>
		<option value="14185">Shura Sune-ate +1</option>
		<option value="16116">Valkyrie\'s Hat</option>
		<option value="14576">Valkyrie\'s Coat</option>
		<option value="14998">Valkyrie\'s Cuffs</option>
		<option value="15658">Valkyrie\'s Trews</option>
		<option value="15743">Valkyrie\'s Clogs</option>
		<option value="13911">Kaiser Schaller</option>
		<option value="14370">Kaiser Cuirass</option>
		<option value="14061">Kaiser Handscuhs</option>
		<option value="14283">Kaiser Diechlings</option>
		<option value="14163">Kaiser Schuhs</option>
		<option value="13928">Hecatomb Cap +1</option>
		<option value="14379">Hecatomb Harness +1</option>
		<option value="14077">Hecatomb Mittens +1</option>
		<option value="14309">Hecatomb Subligar +1</option>
		<option value="14181">Hecatomb Leggings +1</option>
		<option value="16114">Valkyrie\'s Helm</option>
		<option value="14574">Valkyrie\'s Breastplate</option>
		<option value="14996">Valkyrie\'s Gauntlets</option>
		<option value="15656">Valkyrie\'s Cuishes</option>
		<option value="15741">Valkyrie\'s Sabatons</option>
		<option value="13924">Armada Celata</option>
		<option value="14371">Armada Hauberk</option>
		<option value="14816">Armada Mufflers</option>
		<option value="14296">Armada Breeches</option>
		<option value="14175">Armada Sollerets</option>
		<option value="19304">Sarissa</option>
		<option value="18603">Majestas</option>
		<option value="19159">Galatyn</option>
		<option value="17765">Concordia</option>
		<option value="19118">Machismo</option>
		<option value="12434">Genbu\'s Kabuto</option>
		<option value="12296">Genbu\'s Shield</option>
		<option value="12946">Suzaku\'s Sune-Ate</option>
		<option value="18043">Suzaku\'s Scythe</option>
		<option value="12818">Byakko\'s Haidate</option>
		<option value="18198">Byakko\'s Axe</option>
		<option value="12690">Seiryu\'s Kote</option>
		<option value="17659">Seiryu\'s Sword</option>
		<option value="16100">Morrigan\'s Coronal</option>
		<option value="14562">Morrigan\'s Robe</option>
		<option value="14977">Morrigan\'s Cuffs</option>
		<option value="15641">Morrigan\'s Slops</option>
		<option value="15727">Morrigan\'s Pigaches</option>
		<option value="16084">Ares Mask</option>
		<option value="14546">Ares Cuirass</option>
		<option value="14961">Ares Gauntlets</option>
		<option value="15625">Ares Flanchard</option>
		<option value="15711">Ares Sollerets</option>
		<option value="16088">Skadis Visor</option>
		<option value="14550">Skadis Curie</option>
		<option value="14965">Skadis Bazubands</option>
		<option value="15629">Skadis Chausses</option>
		<option value="15715">Skadis Jambeaux</option>
		<option value="16092">Usukane Somen</option>
		<option value="14554">Usukane Haramaki</option>
		<option value="14969">Usukane Gote</option>
		<option value="15633">Usukane Hizayoroi</option>
		<option value="15719">Usukane Sune-ate</option>
		<option value="16096">Marduks Tiara</option>
		<option value="14558">Marduks Jubbah</option>
		<option value="14973">Marduks Dastanas</option>
		<option value="15637">Marduks Shalwar</option>
		<option value="15723">Marduks Crackows</option>
		</select></td>';
			}
		}
		elseif($camp['item1']=='None'){
			echo '<td>None</td>';
		}
		else{
			echo'<td>
			<a href="?p=items&id='.$camp['item1'].'">
			<img src=http://static.ffxiah.com/images/icon/'.$camp['item1'].'.png alt='.ucwords(str_replace('_',' ',getItemName($camp['item1']))).' height=32 width=32>
			'.ucwords(str_replace('_',' ',getItemName($camp['item1']))).'</a>
			</td>';
		}
		if($camp['item2']=='any'){
		echo'<td><select name="item2" size="1">
                <option value="18991">Conqueror</option>
                <option value="18992">Glanzfaust</option>
                <option value="18993">Yagrush</option>
                <option value="18994">Laevateinn</option>
                <option value="18995">Murgleis</option>
                <option value="18996">Vajra</option>
                <option value="18997">Burtgang</option>
                <option value="18998">Liberator</option>
                <option value="18999">Aymur</option>
                <option value="19000">Carnwenhan</option>
                <option value="19001">Gastraphetes</option>
                <option value="19002">Kogarasumaru</option>
                <option value="19003">Nagi</option>
                <option value="19004">Ryunohige</option>
                <option value="19005">Nirvana</option>
                <option value="19006">Tizona</option>
                <option value="19007">Death Penalty</option>
                <option value="19008">Kenkonken</option>
                <option value="18989">Terpsichore</option>
                <option value="18990">Tupsimati</option>
                <option value="18264">Spharai</option>
                <option value="18270">Mandau</option>
                <option value="18276">Excalibur</option>
                <option value="18282">Ragnarok</option>
                <option value="18288">Guttler</option>
                <option value="18294">Bravura</option>
                <option value="18306">Apocalpyse</option>
                <option value="18300">Gungnir</option>
                <option value="18312">Kikoku</option>
                <option value="18318">Amanomurakumo</option>
                <option value="18324">Mjollnir</option>
                <option value="18330">Claustrum</option>
                <option value="18348">Yoichinoyumi</option>
                <option value="18336">Annihilator</option>
                <option value="18342">Gjallarhorn</option>
                <option value="15070">Aegis</option>
                <option value="15899">Velocious Belt</option>
                <option value="18852">Octave Club</option>
                <option value="13566">Defending Ring</option>
                <option value="13909">Blood Mask</option>
                <option value="14368">Blood Scale Mail</option>
                <option value="14059">Blood Finger Gauntlets</option>
                <option value="14281">Blood Cuisses</option>
                <option value="14161">Blood Greaves</option>
                <option value="13877">Zenith Crown +1</option>
                <option value="13788">Dalmatica +1</option>
                <option value="14007">Zenith Mitts +1</option>
                <option value="14248">Zenith Slacks +1</option>
                <option value="14124">Zenith Pumps +1</option>
                <option value="13935">Shura Zunari Kabuto +1</option>
                <option value="14388">Shura Togi +1</option>
                <option value="14822">Shura Kote +1</option>
                <option value="14304">Shura Haidate +1</option>
                <option value="14185">Shura Sune-ate +1</option>
                <option value="16116">Valkyrie\'s Hat</option>
                <option value="14576">Valkyrie\'s Coat</option>
                <option value="14998">Valkyrie\'s Cuffs</option>
                <option value="15658">Valkyrie\'s Trews</option>
                <option value="15743">Valkyrie\'s Clogs</option>
                <option value="13911">Kaiser Schaller</option>
                <option value="14370">Kaiser Cuirass</option>
                <option value="14061">Kaiser Handscuhs</option>
                <option value="14283">Kaiser Diechlings</option>
                <option value="14163">Kaiser Schuhs</option>
                <option value="13928">Hecatomb Cap +1</option>
                <option value="14379">Hecatomb Harness +1</option>
                <option value="14077">Hecatomb Mittens +1</option>
                <option value="14309">Hecatomb Subligar +1</option>
                <option value="14181">Hecatomb Leggings +1</option>
                <option value="16114">Valkyrie\'s Helm</option>
                <option value="14574">Valkyrie\'s Breastplate</option>
                <option value="14996">Valkyrie\'s Gauntlets</option>
                <option value="15656">Valkyrie\'s Cuishes</option>
                <option value="15741">Valkyrie\'s Sabatons</option>
                <option value="13924">Armada Celata</option>
                <option value="14371">Armada Hauberk</option>
                <option value="14816">Armada Mufflers</option>
                <option value="14296">Armada Breeches</option>
                <option value="14175">Armada Sollerets</option>
                <option value="19304">Sarissa</option>
                <option value="18603">Majestas</option>
                <option value="19159">Galatyn</option>
                <option value="17765">Concordia</option>
                <option value="19118">Machismo</option>
                <option value="12434">Genbu\'s Kabuto</option>
                <option value="12296">Genbu\'s Shield</option>
                <option value="12946">Suzaku\'s Sune-Ate</option>
                <option value="18043">Suzaku\'s Scythe</option>
                <option value="12818">Byakko\'s Haidate</option>
                <option value="18198">Byakko\'s Axe</option>
                <option value="12690">Seiryu\'s Kote</option>
                <option value="17659">Seiryu\'s Sword</option>
                <option value="16100">Morrigan\'s Coronal</option>
                <option value="14562">Morrigan\'s Robe</option>
                <option value="14977">Morrigan\'s Cuffs</option>
                <option value="15641">Morrigan\'s Slops</option>
                <option value="15727">Morrigan\'s Pigaches</option>
                <option value="16084">Ares Mask</option>
                <option value="14546">Ares Cuirass</option>
                <option value="14961">Ares Gauntlets</option>
                <option value="15625">Ares Flanchard</option>
                <option value="15711">Ares Sollerets</option>
                <option value="16088">Skadis Visor</option>
                <option value="14550">Skadis Curie</option>
                <option value="14965">Skadis Bazubands</option>
                <option value="15629">Skadis Chausses</option>
                <option value="15715">Skadis Jambeaux</option>
                <option value="16092">Usukane Somen</option>
                <option value="14554">Usukane Haramaki</option>
                <option value="14969">Usukane Gote</option>
                <option value="15633">Usukane Hizayoroi</option>
                <option value="15719">Usukane Sune-ate</option>
                <option value="16096">Marduks Tiara</option>
                <option value="14558">Marduks Jubbah</option>
                <option value="14973">Marduks Dastanas</option>
                <option value="15637">Marduks Shalwar</option>
                <option value="15723">Marduks Crackows</option>
		</select></td>';
		}
		elseif($camp['item2']=='None'){
			echo '<td>None</td>';
		}
		else{
			echo'<td>
			<a href="?p=items&id='.$camp['item2'].'">
			<img src=http://static.ffxiah.com/images/icon/'.$camp['item2'].'.png alt='.ucwords(str_replace('_',' ',getItemName($camp['item2']))).' height=32 width=32>
			'.ucwords(str_replace('_',' ',getItemName($camp['item2']))).'</a>
			</td>';
		}
		if($camp['item3']=='any'){
			echo'<td><input type="text" name="item3" placeholder="Enter Desired Items ID"></input></td>';
		}elseif($camp['item3']=='None'){
			echo '<td>None</td>';
		}
		else{
			echo'<td>
			<a href="?p=items&id='.$camp['item3'].'">
			<img src=http://static.ffxiah.com/images/icon/'.$camp['item3'].'.png alt='.ucwords(str_replace('_',' ',getItemName($camp['item3']))).' height=32 width=32>
			'.ucwords(str_replace('_',' ',getItemName($camp['item3']))).'</a>
			</td>';
		}
		echo '
		<td>'.$camp['gil'].'</td>
		<td>'.$camp['end'].'</td>'; 
		if($lreq=="Incomplete" || $nreq=="Incomplete" || $mreq=="Incomplete" || $vreq=="Incomplete" || $ireq=="Incomplete"){
			echo '<td>Unable to Claim</td>';
		}
		elseif($date>$camp['end']){
			echo '<td>Ended</td>';
		}
		elseif($completed==1){
			echo '<td>Claimed Waiting GM Verification</td>';
		}
		elseif($completed==2){
			echo '<td>Completed</td>';
		}
		else{
			echo '<td>
			<select class="form-select" name="char">';
			foreach($chars as $char) {
				echo '<option value="'.$char['charid'].'">'.$char['charname'].'</option>';
			}
			echo '
			</select> 
			<input type="hidden" name="camp" value="'.$camp['var_granted'].'">
			<input type="submit" value="Submit Claim"></input></form></td>';
		}
		echo '</tr>';
	}
}
}
?>
</table>
</div>
</div>
