<?php
///////////////////////////////////////////////
///  PilotAwardsSystem v2.0 by php-mods.eu  ///
///            Author php-mods.eu           ///
///            Packed at 8/12/2019          ///
///     Copyright (c) 2019, php-mods.eu     ///
///////////////////////////////////////////////

?>
<h3>Edit Auto Award Setting</h3>
<form id="form" action="<?php echo adminaction('/awards/autoaward_edit/');?>" method="post">
    <table width="100%" border="0">
        <tr>
            <td width="60%">
                <table width="100%" border="0" id="mainTable">
                    <tr>
                        <td width="30%"><b>Type:</b></td>
                        <td width="70%">
                                    <?php foreach($autoAwardTypes as $type => $value) {
                                        if($type==$set->type) echo $value;
                                    } ?>
                            <input type="hidden" name="type" value="<?php echo $set->type; ?>" />
                        </td>
                    </tr>
                    <tr class="1 achievement" <?php if($set->type != 1) echo 'style="display: none"'; ?>>
                        <td><b>Achievement:</b><br/><i>Select the amount of hours required to issue this award.</i></td>
                        <td><input type="text" name="achieve_1" value="<?php echo $set->achieve; ?>" /></td>
                    </tr>
                    <tr class="2 achievement" <?php if($set->type != 2) echo 'style="display: none"'; ?>>
                        <td><b>Achievement:</b><br/><i>Select the amount of flights required to issue this award.</i></td>
                        <td><input type="text" name="achieve_2" value="<?php echo $set->achieve; ?>" /></td>
                    </tr>
                    <tr class="3 achievement" <?php if($set->type != 3) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the minimum and maximum landing required to issue this award. Values
                                should be set including minus.</i></td>
                        <td>Min: <input type="text" name="achieve_3" value="<?php echo $achieve[0]; ?>" style="width: 10%;"/> |
                            Max: <input type="text" name="achieve_3a" value="<?php echo $achieve[1]; ?>" style="width: 10%;"/>
                        </td>
                    </tr>
                    <tr class="4 achievement" <?php if($set->type != 4) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the amount of days of membership required to issue this award.</i>
                        </td>
                        <td><input type="text" name="achieve_4" value="<?php echo $achieve[0]; ?>" /> <input type="checkbox" name="achieve_4a" value="1" <?php if($achieve[1] == 1) echo 'checked'; ?> /> Weekdays Only
                        </td>
                    </tr>
                    <tr class="5 achievement" <?php if($set->type != 5) echo 'style="display: none"'; ?>>
                        <td><b>Achievement:</b><br/><i>Select the total distance flown required to issue this award.</i></td>
                        <td><input type="text" name="achieve_5" value="<?php echo $set->achieve; ?>" /> nm
                        </td>
                    </tr>
                    <tr class="6 achievement" <?php if($set->type != 6) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the total hours by airline flown required to issue this award.</i></td>
                        <td><input type="text" name="achieve_6" value="<?php echo $achieve[0]; ?>" /><br />
                            Airline: <select name="achieve_6a">
                                <?php if($airlines) {
                                    foreach($airlines as $airline) { ?>
                                        <option value="<?php echo $airline->code; ?>" <?php if($achieve[1] == $airline->code) echo 'selected'; ?>><?php echo $airline->code.' - '.$airline->name; ?></option>
                                    <?php }
                                } ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="7 achievement" <?php if($set->type != 7) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the total hours by aircraft type flown required to issue this award.</i></td>
                        <td><input type="text" name="achieve_7" value="<?php echo $achieve[0]; ?>" /><br />
                            Aircraft Type: <select name="achieve_7a">
                                <?php if($aircraft) {
                                    foreach($aircraft as $airc) { ?>
                                        <option value="<?php echo $airc->icao; ?>" <?php if($achieve[1] == $airc->icao) echo 'selected'; ?>><?php echo $airc->icao; ?></option>
                                    <?php }
                                } ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="8 achievement" <?php if($set->type != 8) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the total flights by airline flown required to issue this award.</i></td>
                        <td><input type="text" name="achieve_8" value="<?php echo $achieve[0]; ?>" /><br />
                            Airline: <select name="achieve_8a">
                                <?php if($airlines) {
                                    foreach($airlines as $airline) { ?>
                                        <option value="<?php echo $airline->code; ?>" <?php if($achieve[1] == $airline->code) echo 'selected'; ?>><?php echo $airline->code.' - '.$airline->name; ?></option>
                                    <?php }
                                } ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="9 achievement" <?php if($set->type != 9) echo 'style="display: none"'; ?>>

                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the total flights by aircraft type flown required to issue this award.</i></td>
                        <td><input type="text" name="achieve_9" value="<?php echo $achieve[0]; ?>" /><br />
                            Aircraft Type: <select name="achieve_9a">
                                <?php if($aircraft) {
                                    foreach($aircraft as $airc) { ?>
                                        <option value="<?php echo $airc->icao; ?>" <?php if($achieve[1] == $airc->icao) echo 'selected'; ?>><?php echo $airc->icao; ?></option>
                                    <?php }
                                } ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="10 achievement" <?php if($set->type != 10) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the total distance by airline flown required to issue this award.</i></td>
                        <td><input type="text" name="achieve_10" value="<?php echo $achieve[0]; ?>" /> nm<br />
                            Airline: <select name="achieve_10a">
                                <?php if($airlines) {
                                    foreach($airlines as $airline) { ?>
                                        <option value="<?php echo $airline->code; ?>" <?php if($achieve[1] == $airline->code) echo 'selected'; ?>><?php echo $airline->code.' - '.$airline->name; ?></option>
                                    <?php }
                                } ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="11 achievement" <?php if($set->type != 11) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the total distance by aircraft type flown required to issue this award.</i></td>
                        <td><input type="text" name="achieve_11" value="<?php echo $achieve[0]; ?>" /> nm<br />
                            Aircraft Type: <select name="achieve_11a">
                                <?php if($aircraft) {
                                    foreach($aircraft as $airc) { ?>
                                        <option value="<?php echo $airc->icao; ?>" <?php if($achieve[1] == $airc->icao) echo 'selected'; ?>><?php echo $airc->icao; ?></option>
                                    <?php }
                                } ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="12 achievement" <?php if($set->type != 12) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the minimum and maximum landing rate (by aircraft type) required to issue this award. Values
                                should be set including minus.</i></td>
                        <td>Min: <input type="text" name="achieve_12" value="<?php echo $achieve[0]; ?>" style="width: 10%;"/> |
                            Max: <input type="text" name="achieve_12a" value="<?php echo $achieve[1]; ?>" style="width: 10%;"/><br />
                            Aircraft Type: <select name="achieve_12b">
                                <?php if($aircraft) {
                                    foreach($aircraft as $airc) { ?>
                                        <option value="<?php echo $airc->icao; ?>" <?php if($achieve[2] == $airc->icao) echo 'selected'; ?>><?php echo $airc->icao; ?></option>
                                    <?php }
                                } ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="13 achievement" <?php if($set->type != 13) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the flights (by airport departed) required to issue this award.</i></td>
                        <td><input type="text" name="achieve_13" value="<?php echo $achieve[0]; ?>" /><br />
                            Airport ICAO: <input type="text" name="achieve_13a" value="<?php echo $achieve[1]; ?>" placeholder="Enter Airport ICAO" />
                        </td>
                    </tr>
                    <tr class="14 achievement" <?php if($set->type != 14) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the flights (by airport arrived) required to issue this award.</i></td>
                        <td><input type="text" name="achieve_14" value="<?php echo $achieve[0]; ?>" /><br />
                            Airport ICAO: <input type="text" name="achieve_14a" value="<?php echo $achieve[1]; ?>" placeholder="Enter Airport ICAO" />
                        </td>
                    </tr>
                    <tr class="15 achievement" <?php if($set->type != 15) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the hours (by airport departed) required to issue this award.</i></td>
                        <td><input type="text" name="achieve_15" value="<?php echo $achieve[0]; ?>" /><br />
                            Airport ICAO: <input type="text" name="achieve_15a" value="<?php echo $achieve[1]; ?>" placeholder="Enter Airport ICAO" />
                        </td>
                    </tr>
                    <tr class="16 achievement" <?php if($set->type != 16) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the hours (by airport arrived) required to issue this award.</i></td>
                        <td><input type="text" name="achieve_16" value="<?php echo $achieve[0]; ?>" /><br />
                            Airport ICAO: <input type="text" name="achieve_16a" value="<?php echo $achieve[1]; ?>" placeholder="Enter Airport ICAO" />
                        </td>
                    </tr>
                    <tr class="17 achievement" <?php if($set->type != 17) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the times flown a schedule required to issue this award.</i></td>
                        <td><input type="text" name="achieve_17" value="<?php echo $achieve[0]; ?>" /><br />
                            Schedule: <input type="text" name="achieve_17a" value="<?php echo $achieve[1]; ?>" placeholder="CODE" style="width: 15%" />
                            <input type="text" name="achieve_17b" value="<?php echo $achieve[2]; ?>" placeholder="FLIGHT NUMBER" style="width:15%" />
                        </td>
                    </tr>
                    <tr class="18 achievement" <?php if($set->type != 18) echo 'style="display: none"'; ?>>
                        <?php $achieve = explode('|', $set->achieve); ?>
                        <td><b>Achievement:</b><br/><i>Select the times flown (by acars) required to issue this award.</i></td>
                        <td><input type="text" name="achieve_18" value="<?php echo $achieve[0]; ?>" /><br />
                            ACARS: <select name="achieve_18a">
                                <?php if($acars) {
                                    foreach($acars as $acars) { ?>
                                        <option value="<?php echo $acars->source; ?>" <?php if($achieve[1] == $acars->source) {echo 'selected';} ?>><?php echo $acars->source; ?></option>
                                    <?php }
                                } ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="19 achievement" <?php if($set->type != 19) echo 'style="display: none"'; ?>>
                        <td><b>Achievement:</b><br/><i>Select the total money required to issue this award.</i></td>
                        <td><input type="text" name="achieve_19" value="<?php echo $set->achieve; ?>" /> <?php echo Config::Get('MONEY_UNIT'); ?></td>
                    </tr>
                    <tr class="20 achievement" <?php if($set->type != 20) echo 'style="display: none"'; ?>>
                        <td><b>Achievement:</b><br/><i>Select the total fuel burned required to issue this award.</i></td>
                        <td><input type="text" name="achieve_20" value="<?php echo $set->achieve; ?>" /> <?php echo Config::Get('LIQUID_UNIT_NAMES', Config::Get('LiquidUnit'))?></td>
                    </tr>
                    <tr class="21 achievement" <?php if($set->type != 21) echo 'style="display: none"'; ?>>
                        <td><b>Achievement:</b><br/><i>Select the flight long (by hours) required to issue this award.</i></td>
                        <td><input type="text" name="achieve_21" value="<?php echo $set->achieve; ?>" /></td>
                    </tr>
                    <tr class="22 achievement" <?php if($set->type != 22) echo 'style="display: none"'; ?>>
                        <td><b>Achievement:</b><br/><i>Select the flight long (by distance) required to issue this award.</i></td>
                        <td><input type="text" name="achieve_22" value="<?php echo $set->achieve; ?>" /> nm</td>
                    </tr>
                    <?php if($settings[5] != 0) { ?>
                        <tr class="23 achievement" <?php if($set->type != 23) echo 'style="display: none"'; ?>>
                            <td><b>Achievement:</b><br/><i>Select the forum posts required to issue this award.</i></td>
                            <td><input type="text" name="achieve_23" value="<?php echo $set->achieve; ?>" /></td>
                        </tr>
                    <?php } ?>
                    <?php if($settings[6] != 0) { ?>
                        <tr class="24 achievement" <?php if($set->type != 24) echo 'style="display: none"'; ?>>
                            <td><b>Achievement:</b><br/><i>Select the total screenshots submitted required to issue this award.</i></td>
                            <td><input type="text" name="achieve_24" value="<?php echo $set->achieve; ?>" />
                            </td>
                        </tr>
                    <?php } ?>
                    <?php if($settings[7] != 0) { ?>
                        <tr class="25 achievement" <?php if($set->type != 25) echo 'style="display: none"'; ?>>
                            <td><b>Achievement:</b><br/><i>Select the completed tour to issue this award.</i></td>
                            <td><select name="achieve_25">
                                    <?php if($tours) {
                                        foreach($tours as $tour) { ?>
                                            <option value="<?php echo $tour->id; ?>" <?php if($set->achieve == $tour->id) {echo 'selected';} ?>><?php echo $tour->title; ?></option>
                                        <?php } } ?>
                                </select>
                            </td>
                        </tr>
                        <tr class="26 achievement" <?php if($set->type != 25) echo 'style="display: none"'; ?>>
                            <td><b>Achievement:</b><br/><i>Select the total tours completed to issue this award.</i></td>
                            <td><input type="text" name="achieve_26" value="<?php echo $set->achieve; ?>" />
                            </td>
                        </tr>
                    <?php }?>
                    <tr>
                        <td><b>Award to Issue:</b></td>
                        <td><select name="awardid">
                                <?php foreach ($awards as $award) { ?>
                                    <option value="<?php echo $award->awardid; ?>" <?php if($set->awardid == $award->awardid) echo 'selected'; ?>><?php echo $award->name; ?></option>
                                <?php } ?>
                            </select></td>
                    </tr>
                    <tr>
                        <td><b>Comment:</b></td>
                        <td><textarea cols="50" id="comment" name="comment" rows="5"><?php echo $set->comment; ?></textarea></td>
                    </tr>
                    <tr>
                        <td><b>Auto Update:</b></td>
                        <td><input type="checkbox" name="auto" value="1" <?php if($set->auto == 1) echo 'checked'; ?> /></td>
                    </tr>
                    <tr>
                        <td align="center"><input type="hidden" name="id" value="<?php echo $set->id; ?>"/><br/><input type="submit"
                                                                                                                       name="submit"
                                                                                                                       value="Edit Setting"/>
                        </td>
                    </tr>
                </table>
            </td>
            <td width="40%" style="vertical-align: top;">
                <h3>Comment Variables</h3>
                <ul>
                    <li><b>{PILOT_FNAME}</b> - Pilot's first name</li>
                    <li><b>{PILOT_LNAME}</b> - Pilot's last name</li>
                    <li><b>{PILOT_ID}</b> - Insert the pilot's pilot id (VMA001)</li>
                    <li><b>{ACHIEVEMENT_1}</b> - Pilot's achievement <br />(ex Total Flights, Total Distance, Total Hours, Min Landing etc)</li>
                    <li><b>{ACHIEVEMENT_2}</b> - Pilot's achievement 2<br /> (ex Airline, Aircraft, ACARS System, Max Landing, Schedule Code)</li>
                    <li><b>{ACHIEVEMENT_3}</b> - Pilot's achievement 3<br /> (ex Max Landing, Schedule Flight Number, Aircraft for Landing Limits)</li>
                </ul>
            </td>
        </tr>
    </table>
    <script>
        $('#selectSetting').change(function () {
            $('#mainTable .achievement').hide();
            $('#mainTable .' + $(this).val()).fadeIn(1000);
        })
    </script>