include "../inc/classes/SoundTest.php";
include "../inc/classes/Helpers.php";
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'sort') {
    $objSoundTest = new SoundTest();
    $objSoundTest->SortValues(substr($_REQUEST['action'], 1), substr($_REQUEST['action'], 0, 1));
    unset($objSoundTest);
} elseif (isset($_REQUEST['dragsort'])) {
    // handle drag sort ajax request:
    $objSoundTest = new SoundTest($_REQUEST['id']);
    $new_sort_order = $_REQUEST['idx'] * 10 + 5;
    if ($new_sort_order > $objSoundTest->SortOrder) {
        $new_sort_order += 10;
        // increasing sort order so must add another 10
    }
    $objSoundTest->SortOrder = $new_sort_order;
    $objSoundTest->update();
    echo "success";
    exit;
    // just exit since this is an ajax request
}
$objSound = new Sound($_REQUEST['sound']);
include "includes/pagetemplate.php";
function PageContent()
{
    global $objSound;
    ?>
    
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
        $obj->handleDropFileUploads($aDropFields[1], 'ImageUrl2');
        $obj->handleDropFileUploads($aDropFields[2], 'ImageUrl3');
        // redirect to listing list
        header("Location:soundtest_list.php?cat=" . $_REQUEST['cat'] . "&sound=" . $_REQUEST['sound']);
        exit;
    } else {
        // update
        $obj = new SoundTest($id);
        $obj->SoundTestDescription = $_REQUEST["sound_test_description"];
        $obj->SoundUrl1 = $_REQUEST["sound_url1"];
        $obj->SoundUrl2 = $_REQUEST["sound_url2"];
        $obj->SoundUrl3 = $_REQUEST["sound_url3"];
        $obj->Text1 = $_REQUEST["text1"];
        $obj->Text2 = $_REQUEST["text2"];
        $obj->Text3 = $_REQUEST["text3"];
        $obj->update();
        $obj->handleFileUploads();
        $obj->handleDropFileUploads($aDropFields[0], 'ImageUrl1');
        $obj->handleDropFileUploads($aDropFields[1], 'ImageUrl2');
        $obj->handleDropFileUploads($aDropFields[2], 'ImageUrl3');
        // redirect to listing list
        header("Location:soundtest_list.php?cat=" . $_REQUEST['cat'] . "&sound=" . $_REQUEST['sound']);
        exit;
    }
} else {
    if ($_REQUEST['mode'] == 'e') {
        //listing
        $objSoundTest = new SoundTest($id);
        $sound_id = $objSoundTest->SoundId;
        $sound_test_description = $objSoundTest->SoundTestDescription;
        $sound_url1 = $objSoundTest->SoundUrl1;