$versions{'basic_options_editor-ext_lib.pl'} = '06.6.00.0000';

# Contains sub routines (functions) to build very very basic product
# option files in form selector format.  Advanced functions need to be
# done manually or via a file editor covering product option files.

#######################################################################
#
# AgoraCart and all associated files, except where noted, are
# Copyright 2001 to Present jointly by K-Factor Technologies, Inc.
# and by C E Mayo (aka Mister Ed) at AgoraCart.com & K-Factor.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This copyright notice may not be removed or altered in any way.
#
#######################################################################

{
    local ($modname) = 'basic_options_editor';
    register_extension( $modname, 'Basic Option File Manager',
        $versions{$modname} );
    add_merchtools_settings_choice(
        'Basic Option Files',
        ' Basic Option Files ',
        'change_basic_options_screen'
    );
    register_menu( 'EditOptionsFile', 'display_basic_options_screen',
        $modname, 'Select Option File' );
    register_menu(
        'BasicOptionsSettings', 'write_basic_options_settings',
        $modname,   'Write Basic Option Files Settings'
    );
    register_menu( 'change_basic_options_screen', 'display_options_screen',
        $modname, 'Display Basic Option File Settings' );
}

#######################################################################

sub write_basic_options_settings {

    local ($myset)   = q{};
    local ($optfile) = q{};
    $optfile2 = q{};
    local ($optfile3) = q{};
    local ($class_string) = q{};

    require_supporting_libraries( __FILE__, __LINE__,
        "$sc_hedfut_templates_dir/$sc_headerTemplateRoot/$sc_hedfut_template_manifest" );

    if ( $mgr_template_framework =~ /^boot3$|^boot4$/ ) {
        $class_string = q|class="form-control"|;
    }

    $optfile = "$in{'optionfilename'}.html";
    $optfile =~ /([\w\-\=\+\/]+)\.(\w+)/;
    $optfile = "$1.$2";
    $optfile =~ s/^\/+//;
    $optfile2 = ( split( /\./, $optfile ) )[0];
    if ( $optfile2 eq "" ) { $optfile2 = "$optfile"; }
    $optfile3    = 'html';
    $optfile   = "$optfile2.$optfile3";
    $sc_optfile2edit = "$optfile2";

    open( NEW, ">$sc_options_directory_path/$optfile" );
    $counter = 1;

    print NEW qq|
<table>
<tr><td><p>\n
|;
    if ( $in{'OptionA1'} ) {
        print NEW
"<b>$in{'OptionA'}</b> <select $class_string name= \"option|$counter|\[\[PRODUCT_ID\]\]\">\n<option value=''></option>\n";
        if ( $in{'OptionA1d'} ) { $OptionA1d = " \(\+ \$$in{'OptionA1d'}\)"; }
        print NEW
"<option value=\"$in{'OptionA1'}|$in{'OptionA1d'}\">$in{'OptionA1'}$OptionA1d</option>\n";
        if ( $in{'OptionA2'} ) {
            if ( $in{'OptionA2d'} ) {
                $OptionA2d = " \(\+ \$$in{'OptionA2d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA2'}|$in{'OptionA2d'}\">$in{'OptionA2'}$OptionA2d</option>\n";
        }
        if ( $in{'OptionA3'} ) {
            if ( $in{'OptionA3d'} ) {
                $OptionA3d = " \(\+ \$$in{'OptionA3d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA3'}|$in{'OptionA3d'}\">$in{'OptionA3'}$OptionA3d</option>\n";
        }
        if ( $in{'OptionA4'} ) {
            if ( $in{'OptionA4d'} ) {
                $OptionA4d = " \(\+ \$$in{'OptionA4d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA4'}|$in{'OptionA4d'}\">$in{'OptionA4'}$OptionA4d</option>\n";
        }
        if ( $in{'OptionA5'} ) {
            if ( $in{'OptionA5d'} ) {
                $OptionA5d = " \(\+ \$$in{'OptionA5d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA5'}|$in{'OptionA5d'}\">$in{'OptionA5'}$OptionA5d</option>\n";
        }
        if ( $in{'OptionA6'} ) {
            if ( $in{'OptionA6d'} ) {
                $OptionA6d = " \(\+ \$$in{'OptionA6d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA6'}|$in{'OptionA6d'}\">$in{'OptionA6'}$OptionA6d</option>\n";
        }
        if ( $in{'OptionA7'} ) {
            if ( $in{'OptionA7d'} ) {
                $OptionA7d = " \(\+ \$$in{'OptionA7d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA7'}|$in{'OptionA7d'}\">$in{'OptionA7'}$OptionA7d</option>\n";
        }
        if ( $in{'OptionA8'} ) {
            if ( $in{'OptionA8d'} ) {
                $OptionA8d = " \(\+ \$$in{'OptionA8d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA8'}|$in{'OptionA8d'}\">$in{'OptionA8'}$OptionA8d</option>\n";
        }
        if ( $in{'OptionA9'} ) {
            if ( $in{'OptionA9d'} ) {
                $OptionA9d = " \(\+ \$$in{'OptionA9d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA9'}|$in{'OptionA9d'}\">$in{'OptionA9'}$OptionA9d</option>\n";
        }
        if ( $in{'OptionA10'} ) {
            if ( $in{'OptionA10d'} ) {
                $OptionA10d = " \(\+ \$$in{'OptionA10d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA10'}|$in{'OptionA10d'}\">$in{'OptionA10'}$OptionA10d</option>\n";
        }
        if ( $in{'OptionA11'} ) {
            if ( $in{'OptionA11d'} ) {
                $OptionA12d = " \(\+ \$$in{'OptionA11d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA11'}|$in{'OptionA11d'}\">$in{'OptionA11'}$OptionA11d</option>\n";
        }
        if ( $in{'OptionA12'} ) {
            if ( $in{'OptionA12d'} ) {
                $OptionA12d = " \(\+ \$$in{'OptionA12d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA12'}|$in{'OptionA12d'}\">$in{'OptionA12'}$OptionA12d</option>\n";
        }
        if ( $in{'OptionA13'} ) {
            if ( $in{'OptionA13d'} ) {
                $OptionA13d = " \(\+ \$$in{'OptionA13d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA13'}|$in{'OptionA13d'}\">$in{'OptionA13'}$OptionA13d</option>\n";
        }
        if ( $in{'OptionA14'} ) {
            if ( $in{'OptionA14d'} ) {
                $OptionA14d = " \(\+ \$$in{'OptionA14d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA14'}|$in{'OptionA14d'}\">$in{'OptionA14'}$OptionA14d</option>\n";
        }
        if ( $in{'OptionA15'} ) {
            if ( $in{'OptionA15d'} ) {
                $OptionA15d = " \(\+ \$$in{'OptionA1d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionA15'}|$in{'OptionA15d'}\">$in{'OptionA15'}$OptionA15d</option>\n";
        }
        $counter++;
        print NEW "</select></p></td></tr>\n";
    }
    if ( $in{'OptionB1'} ) {
        print NEW
"<tr><td><b>$in{'OptionB'}</b> <select $class_string name= \"option|$counter|\[\[PRODUCT_ID\]\]\">\n<option value=''></option>\n";
        if ( $in{'OptionB1d'} ) { $OptionB1d = " \(\+ \$$in{'OptionB1d'}\)"; }
        print NEW
"<option value=\"$in{'OptionB1'}|$in{'OptionB1d'}\">$in{'OptionB1'}$OptionB1d</option>\n";
        if ( $in{'OptionB2'} ) {
            if ( $in{'OptionB2d'} ) {
                $OptionB2d = " \(\+ \$$in{'OptionB2d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB2'}|$in{'OptionB2d'}\">$in{'OptionB2'}$OptionB2d</option>\n";
        }
        if ( $in{'OptionB3'} ) {
            if ( $in{'OptionB3d'} ) {
                $OptionB3d = " \(\+ \$$in{'OptionB3d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB3'}|$in{'OptionB3d'}\">$in{'OptionB3'}$OptionB3d</option>\n";
        }
        if ( $in{'OptionB4'} ) {
            if ( $in{'OptionB4d'} ) {
                $OptionB4d = " \(\+ \$$in{'OptionB4d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB4'}|$in{'OptionB4d'}\">$in{'OptionB4'}$OptionB4d</option>\n";
        }
        if ( $in{'OptionB5'} ) {
            if ( $in{'OptionB5d'} ) {
                $OptionB5d = " \(\+ \$$in{'OptionB5d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB5'}|$in{'OptionB5d'}\">$in{'OptionB5'}$OptionB5d</option>\n";
        }
        if ( $in{'OptionB6'} ) {
            if ( $in{'OptionB6d'} ) {
                $OptionB6d = " \(\+ \$$in{'OptionB6d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB6'}|$in{'OptionB6d'}\">$in{'OptionB6'}$OptionB6d</option>\n";
        }
        if ( $in{'OptionB7'} ) {
            if ( $in{'OptionB7d'} ) {
                $OptionB7d = " \(\+ \$$in{'OptionB7d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB7'}|$in{'OptionB7d'}\">$in{'OptionB7'}$OptionB7d</option>\n";
        }
        if ( $in{'OptionB8'} ) {
            if ( $in{'OptionB8d'} ) {
                $OptionB8d = " \(\+ \$$in{'OptionB8d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB8'}|$in{'OptionB8d'}\">$in{'OptionB8'}$OptionB8d</option>\n";
        }
        if ( $in{'OptionB9'} ) {
            if ( $in{'OptionB9d'} ) {
                $OptionB9d = " \(\+ \$$in{'OptionB9d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB9'}|$in{'OptionB9d'}\">$in{'OptionB9'}$OptionB9d</option>\n";
        }
        if ( $in{'OptionB10'} ) {
            if ( $in{'OptionB10d'} ) {
                $OptionB10d = " \(\+ \$$in{'OptionB10d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB10'}|$in{'OptionB10d'}\">$in{'OptionB10'}$OptionB10d</option>\n";
        }
        if ( $in{'OptionB11'} ) {
            if ( $in{'OptionB11d'} ) {
                $OptionB11d = " \(\+ \$$in{'OptionB11d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB11'}|$in{'OptionB11d'}\">$in{'OptionB11'}$OptionB11d</option>\n";
        }
        if ( $in{'OptionB12'} ) {
            if ( $in{'OptionB12d'} ) {
                $OptionB12d = " \(\+ \$$in{'OptionB12d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB12'}|$in{'OptionB12d'}\">$in{'OptionB12'}$OptionB12d</option>\n";
        }
        if ( $in{'OptionB13'} ) {
            if ( $in{'OptionB13d'} ) {
                $OptionB1d = " \(\+ \$$in{'OptionB13d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB13'}|$in{'OptionB13d'}\">$in{'OptionB13'}$OptionB13d</option>\n";
        }
        if ( $in{'OptionB14'} ) {
            if ( $in{'OptionB14d'} ) {
                $OptionB14d = " \(\+ \$$in{'OptionB14d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB14'}|$in{'OptionB14d'}\">$in{'OptionB14'}$OptionB14d</option>\n";
        }
        if ( $in{'OptionB15'} ) {
            if ( $in{'OptionB15d'} ) {
                $OptionB15d = " \(\+ \$$in{'OptionB15d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionB15'}|$in{'OptionB15d'}\">$in{'OptionB15'}$OptionB15d</option>\n";
        }
        $counter++;
        print NEW "</select><p></td></tr>\n";
    }
    if ( $in{'OptionC1'} ) {
        print NEW
"<tr><td><b>$in{'OptionC'}</b> <select $class_string name= \"option|$counter|\[\[PRODUCT_ID\]\]\">\n<option value=''></option>\n";
        if ( $in{'OptionC1d'} ) { $OptionC1d = " \(\+ \$$in{'OptionC1d'}\)"; }
        print NEW
"<option value=\"$in{'OptionC1'}|$in{'OptionC1d'}\">$in{'OptionC1'}$OptionC1d</option>\n";
        if ( $in{'OptionC2'} ) {
            if ( $in{'OptionC2d'} ) {
                $OptionC2d = " \(\+ \$$in{'OptionC2d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC2'}|$in{'OptionC2d'}\">$in{'OptionC2'}$OptionC2d</option>\n";
        }
        if ( $in{'OptionC3'} ) {
            if ( $in{'OptionC3d'} ) {
                $OptionC3d = " \(\+ \$$in{'OptionC3d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC3'}|$in{'OptionC3d'}\">$in{'OptionC3'}$OptionC3d</option>\n";
        }
        if ( $in{'OptionC4'} ) {
            if ( $in{'OptionC4d'} ) {
                $OptionC4d = " \(\+ \$$in{'OptionC4d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC4'}|$in{'OptionC4d'}\">$in{'OptionC4'}$OptionC4d</option>\n";
        }
        if ( $in{'OptionC5'} ) {
            if ( $in{'OptionC5d'} ) {
                $OptionC5d = " \(\+ \$$in{'OptionC5d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC5'}|$in{'OptionC5d'}\">$in{'OptionC5'}$OptionC5d</option>\n";
        }
        if ( $in{'OptionC6'} ) {
            if ( $in{'OptionC6d'} ) {
                $OptionC6d = " \(\+ \$$in{'OptionC6d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC6'}|$in{'OptionC6d'}\">$in{'OptionC6'}$OptionC6d</option>\n";
        }
        if ( $in{'OptionC7'} ) {
            if ( $in{'OptionC7d'} ) {
                $OptionC7d = " \(\+ \$$in{'OptionC7d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC7'}|$in{'OptionC7d'}\">$in{'OptionC7'}$OptionC7d</option>\n";
        }
        if ( $in{'OptionC8'} ) {
            if ( $in{'OptionC8d'} ) {
                $OptionC8d = " \(\+ \$$in{'OptionC8d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC8'}|$in{'OptionC8d'}\">$in{'OptionC8'}$OptionC8d</option>\n";
        }
        if ( $in{'OptionC9'} ) {
            if ( $in{'OptionC9d'} ) {
                $OptionC9d = " \(\+ \$$in{'OptionC9d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC9'}|$in{'OptionC9d'}\">$in{'OptionC9'}$OptionC9d</option>\n";
        }
        if ( $in{'OptionC10'} ) {
            if ( $in{'OptionC10d'} ) {
                $OptionC10d = " \(\+ \$$in{'OptionC10d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC10'}|$in{'OptionC10d'}\">$in{'OptionC10'}$OptionC10d</option>\n";
        }
        if ( $in{'OptionC11'} ) {
            if ( $in{'OptionC11d'} ) {
                $OptionC11d = " \(\+ \$$in{'OptionC11d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC11'}|$in{'OptionC11d'}\">$in{'OptionC11'}$OptionC11d</option>\n";
        }
        if ( $in{'OptionC12'} ) {
            if ( $in{'OptionC12d'} ) {
                $OptionC12d = " \(\+ \$$in{'OptionC12d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC12'}|$in{'OptionC12d'}\">$in{'OptionC12'}$OptionC12d</option>\n";
        }
        if ( $in{'OptionC13'} ) {
            if ( $in{'OptionC13d'} ) {
                $OptionC13d = " \(\+ \$$in{'OptionC13d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC13'}|$in{'OptionC13d'}\">$in{'OptionC13'}$OptionC13d</option>\n";
        }
        if ( $in{'OptionC14'} ) {
            if ( $in{'OptionC14d'} ) {
                $OptionC14d = " \(\+ \$$in{'OptionC14d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC14'}|$in{'OptionC14d'}\">$in{'OptionC14'}$OptionC14d</option>\n";
        }
        if ( $in{'OptionC15'} ) {
            if ( $in{'OptionC15d'} ) {
                $OptionC1d = " \(\+ \$$in{'OptionC15d'}\)";
            }
            print NEW
"<option value=\"$in{'OptionC15'}|$in{'OptionC15d'}\">$in{'OptionC15'}$OptionC15d</option>\n";
        }
        $counter++;
        print NEW "<\/select></p></td></tr>\n";
    }
    print NEW qq|</table>\n|;

    close(NEWFILE);

    $myset .= "$optfile|";
    $myset .= "$in{'OptionA'}|";
    $myset .= "$in{'OptionA1'}|";
    $myset .= "$in{'OptionA1d'}|";
    $myset .= "$in{'OptionA2'}|";
    $myset .= "$in{'OptionA2d'}|";
    $myset .= "$in{'OptionA3'}|";
    $myset .= "$in{'OptionA3d'}|";
    $myset .= "$in{'OptionA4'}|";
    $myset .= "$in{'OptionA4d'}|";
    $myset .= "$in{'OptionA5'}|";
    $myset .= "$in{'OptionA5d'}|";
    $myset .= "$in{'OptionA6'}|";
    $myset .= "$in{'OptionA6d'}|";
    $myset .= "$in{'OptionA7'}|";
    $myset .= "$in{'OptionA7d'}|";
    $myset .= "$in{'OptionA8'}|";
    $myset .= "$in{'OptionA8d'}|";
    $myset .= "$in{'OptionA9'}|";
    $myset .= "$in{'OptionA9d'}|";
    $myset .= "$in{'OptionA10'}|";
    $myset .= "$in{'OptionA10d'}|";
    $myset .= "$in{'OptionA11'}|";
    $myset .= "$in{'OptionA11d'}|";
    $myset .= "$in{'OptionA12'}|";
    $myset .= "$in{'OptionA12d'}|";
    $myset .= "$in{'OptionA13'}|";
    $myset .= "$in{'OptionA13d'}|";
    $myset .= "$in{'OptionA14'}|";
    $myset .= "$in{'OptionA14d'}|";
    $myset .= "$in{'OptionA15'}|";
    $myset .= "$in{'OptionA15d'}|";
    $myset .= "$in{'OptionB'}|";
    $myset .= "$in{'OptionB1'}|";
    $myset .= "$in{'OptionB1d'}|";
    $myset .= "$in{'OptionB2'}|";
    $myset .= "$in{'OptionB2d'}|";
    $myset .= "$in{'OptionB3'}|";
    $myset .= "$in{'OptionB3d'}|";
    $myset .= "$in{'OptionB4'}|";
    $myset .= "$in{'OptionB4d'}|";
    $myset .= "$in{'OptionB5'}|";
    $myset .= "$in{'OptionB5d'}|";
    $myset .= "$in{'OptionB6'}|";
    $myset .= "$in{'OptionB6d'}|";
    $myset .= "$in{'OptionB7'}|";
    $myset .= "$in{'OptionB7d'}|";
    $myset .= "$in{'OptionB8'}|";
    $myset .= "$in{'OptionB8d'}|";
    $myset .= "$in{'OptionB9'}|";
    $myset .= "$in{'OptionB9d'}|";
    $myset .= "$in{'OptionB10'}|";
    $myset .= "$in{'OptionB10d'}|";
    $myset .= "$in{'OptionB11'}|";
    $myset .= "$in{'OptionB11d'}|";
    $myset .= "$in{'OptionB12'}|";
    $myset .= "$in{'OptionB12d'}|";
    $myset .= "$in{'OptionB13'}|";
    $myset .= "$in{'OptionB13d'}|";
    $myset .= "$in{'OptionB14'}|";
    $myset .= "$in{'OptionB14d'}|";
    $myset .= "$in{'OptionB15'}|";
    $myset .= "$in{'OptionB15d'}|";
    $myset .= "$in{'OptionC'}|";
    $myset .= "$in{'OptionC1'}|";
    $myset .= "$in{'OptionC1d'}|";
    $myset .= "$in{'OptionC2'}|";
    $myset .= "$in{'OptionC2d'}|";
    $myset .= "$in{'OptionC3'}|";
    $myset .= "$in{'OptionC3d'}|";
    $myset .= "$in{'OptionC4'}|";
    $myset .= "$in{'OptionC4d'}|";
    $myset .= "$in{'OptionC5'}|";
    $myset .= "$in{'OptionC5d'}|";
    $myset .= "$in{'OptionC6'}|";
    $myset .= "$in{'OptionC6d'}|";
    $myset .= "$in{'OptionC7'}|";
    $myset .= "$in{'OptionC7d'}|";
    $myset .= "$in{'OptionC8'}|";
    $myset .= "$in{'OptionC8d'}|";
    $myset .= "$in{'OptionC9'}|";
    $myset .= "$in{'OptionC9d'}|";
    $myset .= "$in{'OptionC10'}|";
    $myset .= "$in{'OptionC10d'}|";
    $myset .= "$in{'OptionC11'}|";
    $myset .= "$in{'OptionC11d'}|";
    $myset .= "$in{'OptionC12'}|";
    $myset .= "$in{'OptionC12d'}|";
    $myset .= "$in{'OptionC13'}|";
    $myset .= "$in{'OptionC13d'}|";
    $myset .= "$in{'OptionC14'}|";
    $myset .= "$in{'OptionC14d'}|";
    $myset .= "$in{'OptionC15'}|";
    $myset .= "$in{'OptionC15d'}|";

    update_option_file_settings( '$optfile2', $myset );

    display_basic_options_screen();

}

#######################################################################

sub display_basic_options_screen {

    local ($filename) = "$mgrdir/";
    print &$manager_page_header( 'Basic Options', '', '', '', '' );

    if ( $in{'sc_optfile2edit'} ) {
        $sc_optfile2edit = "$in{'sc_optfile2edit'}";
    }
    if ( $sc_optfile2edit ) {
        $optext4      = "pl";
        $optfilename4 = "$mgrdir/options/$sc_optfile2edit.$optext4";
        open( DATA, "$optfilename4" );
        @indata = <DATA>;
        close(DATA);
        foreach $entries (@indata) {
            (
                $optfilename, $OptionA,    $OptionA1,   $OptionA1d,
                $OptionA2,    $OptionA2d,  $OptionA3,   $OptionA3d,
                $OptionA4,    $OptionA4d,  $OptionA5,   $OptionA5d,
                $OptionA6,    $OptionA6d,  $OptionA7,   $OptionA7d,
                $OptionA8,    $OptionA8d,  $OptionA9,   $OptionA9d,
                $OptionA10,   $OptionA10d, $OptionA11,  $OptionA11d,
                $OptionA12,   $OptionA12d, $OptionA13,  $OptionA13d,
                $OptionA14,   $OptionA14d, $OptionA15,  $OptionA15d,
                $OptionB,     $OptionB1,   $OptionB1d,  $OptionB2,
                $OptionB2d,   $OptionB3,   $OptionB3d,  $OptionB4,
                $OptionB4d,   $OptionB5,   $OptionB5d,  $OptionB6,
                $OptionB6d,   $OptionB7,   $OptionB7d,  $OptionB8,
                $OptionB8d,   $OptionB9,   $OptionB9d,  $OptionB10,
                $OptionB10d,  $OptionB11,  $OptionB11d, $OptionB12,
                $OptionB12d,  $OptionB13,  $OptionB13d, $OptionB14,
                $OptionB14d,  $OptionB15,  $OptionB15d, $OptionC,
                $OptionC1,    $OptionC1d,  $OptionC2,   $OptionC2d,
                $OptionC3,    $OptionC3d,  $OptionC4,   $OptionC4d,
                $OptionC5,    $OptionC5d,  $OptionC6,   $OptionC6d,
                $OptionC7,    $OptionC7d,  $OptionC8,   $OptionC8d,
                $OptionC9,    $OptionC9d,  $OptionC10,  $OptionC10d,
                $OptionC11,   $OptionC11d, $OptionC12,  $OptionC12d,
                $OptionC13,   $OptionC13d, $OptionC14,  $OptionC14d,
                $OptionC15,   $OptionC15d
            ) = split( /\|/, $entries );
        }
    }

    print <<ENDOFTEXT;
<h1 class='mgr-page-title'>Basic Option File Creator / Manager</h1>
<p><br></p>

<p class="well">This area allows you to create very simple option files to include in your products. You can create an option file that will contain up to 3 drop-down option boxes with up to 15 options per box.
<br><br>An .HTML file will be created in the <i>$sc_options_directory_path</i> sub-directory as well as a data file in the store manager's options directory so that you may be able to update the file you created with this manager at a later date.<br><br>
<b>Tips:</b><br>
- In Option Name, for formatting, add an : and a space afterwards.<br>
- In the pricing for each individual option, if there is no price or price increase, leave blank.<br>
- Once the option file has been created, go to the product in the database and select the option file you created from the dropdown list and save.  Repeat for every product that needs this option file.</p>
<p><br></p>

ENDOFTEXT

    if ( $in{'system_edit_success'} ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-success">
        <h4 class="text-primary mgr-center">Option File has been successfully updated.</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    print qq~
<form action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<div class="table-responsive col-xs-12 col-sm-12">
<table class="table table-striped table-bordered table-condensed">
   <tr>
   <td>
   <p align="right"><b>File Name:</font></b></td>
   <td colspan="4"><b><input type="text" name="optionfilename" size="26" value="$optfilename">
   </font>
   </b><font color="#FF0000" size="2" face="Arial">- filename.html</font></td>
   </tr>
   <tr>
   <td colspan="6"><b>&nbsp;</font></b></td>
   </tr>
   </center>
   <tr>
   <td colspan="6" bgcolor="#0000ff" align=center><font face="Arial" size="2" color=white><b>Top / First Option Box - Option 1</b></font></td>
</tr>
   <tr>
   <td colspan="6" align=center>
   <p><b>Option Name:</b></font>&nbsp;&nbsp;
 <b><input type="text" name="OptionA" size="26" value="$OptionA"></b>
   </td>
</tr>
   <tr>
   <td bgcolor="#E0E5FF" align=center><b>Enter Option Name and Price</b></td>
   <td bgcolor="#E0E5FF"></td>
   <td bgcolor="#E0E5FF" align=center><b>Enter Option Name and Price</b></td>
   <td bgcolor="#E0E5FF"></td>
   <td bgcolor="#E0E5FF" align=center><b>Enter Option Name and Price</b></td>
   </tr>
   <tr>
   <td>
   <b>
   1.<input type="text" name="OptionA1" size="17" value="$OptionA1">\$<input type="text" name="OptionA1d" size="7" value="$OptionA1d"></b></td>
   <td></td>
   <td>
   <b>2.<input type="text" name="OptionA2" size="17" value="$OptionA2">\$<input type="text" name="OptionA2d" size="7" value="$OptionA2d"></b></td>
   <td></td>
   <td>
   <b>
   3.<input type="text" name="OptionA3" size="17" value="$OptionA3">\$<input type="text" name="OptionA3d" size="7" value="$OptionA3d"></b></td>
   </tr>
   <tr>
   <td>
   <b>
   4.<input type="text" name="OptionA4" size="17" value="$OptionA4">\$<input type="text" name="OptionA4d" size="7"  value="$OptionA4d"></b></td>
   <td></td>
   <td>
   <b>
   5.<input type="text" name="OptionA5" size="17" value="$OptionA5">\$<input type="text" name="OptionA5d" size="7" value="$OptionA5d"></b></td>
   <td></td>
   <td>
   <b>
   6.<input type="text" name="OptionA6" size="17" value="$OptionA6">\$<input type="text" name="OptionA6d" size="7" value="$OptionA6d"></b>
   </td>
   </tr>
   <tr>
   <td>
   <b>7.<input type="text" name="OptionA7" size="17" value="$OptionA7">\$<input type="text" name="OptionA7d" size="7" value="$OptionA7d"></b>
   </td>
   <td></td>
   <td>
   <b>
   8.<input type="text" name="OptionA8" size="17" value="$OptionA8">\$<input type="text" name="OptionA8d" size="7" value="$OptionA8d"></b>
   </td>
   <td></td>
   <td>
   <b>
   9.<input type="text" name="OptionA9" size="17" value="$OptionA9">\$<input type="text" name="OptionA9d" size="7" value="$OptionA9d"></b>
   </td>
   </tr>
   <tr>
   <td>
   <b>10.<input type="text" name="OptionA10" size="16" value="$OptionA10">\$<input type="text" name="OptionA10d" size="7" value="$OptionA10d"></b>
   </td>
   <td></td>
   <td>
   <b>
   11.<input type="text" name="OptionA11" size="16" value="$OptionA11">\$<input type="text" name="OptionA11d" size="7" value="$OptionA11d"></b>
   </td>
   <td></td>
   <td>
   <b>
   12.<input type="text" name="OptionA12" size="16" value="$OptionA12">\$<input type="text" name="OptionA12d" size="7" value="$OptionA12d"></b>
   </td>
   </tr>
   <tr>
   <td>
   <b>13.<input type="text" name="OptionA13" size="16" value="$OptionA13">\$<input type="text" name="OptionA13d" size="7" value="$OptionA13d"></b>
   </td>
   <td></td>
   <td>
   <b>
   14.<input type="text" name="OptionA14" size="16" value="$OptionA14">\$<input type="text" name="OptionA14d" size="7" value="$OptionA14d"></b>
   </td>
   <td></td>
   <td>
   <b>
   15.<input type="text" name="OptionA15" size="16" value="$OptionA15">\$<input type="text" name="OptionA15d" size="7" value="$OptionA15d"></b>
   </td>
   </tr>
  <tr>
   <td colspan="6"><b>&nbsp;</b></td>
   </tr>
   </center>
   <tr>
   <td colspan="6" bgcolor="#0000ff" align=center><font face="Arial" size="2" color=white><b>Middle / Second Option Box - Option 2</b></font></td>
</tr>
   <tr>
   <td colspan="6" align=center>
   <p><b>Option Name:</b></font>&nbsp;&nbsp;
 <b><input type="text" name="OptionB" size="26" value="$OptionB"></b>
   </td>
</tr>
   <tr>
   <td bgcolor="#E0E5FF" align=center><b>Enter Option Name and Price</b></td>
   <td bgcolor="#E0E5FF"></td>
   <td bgcolor="#E0E5FF" align=center><b>Enter Option Name and Price</b></td>
   <td bgcolor="#E0E5FF"></td>
   <td bgcolor="#E0E5FF" align=center><b>Enter Option Name and Price</b></td>
   </tr>
   <tr>
   <td>
   <b>
   1.<input type="text" name="OptionB1" size="17" value="$OptionB1">\$<input type="text" name="OptionB1d" size="7" value="$OptionB1d"></b></td>
   <td></td>
   <td>
   <b>
   2.<input type="text" name="OptionB2" size="17" value="$OptionB2">\$<input type="text" name="OptionB2d" size="7" value="$OptionB2d"></b></td>
   <td></td>
   <td>
   <b>
   3.<input type="text" name="OptionB3" size="17" value="$OptionB3">\$<input type="text" name="OptionB3d" size="7" value="$OptionB3d"></b></td>
   </tr>
   <tr>
   <td>
   <b>
   4.<input type="text" name="OptionB4" size="17" value="$OptionB4">\$<input type="text" name="OptionB4d" size="7" value="$OptionB4d"></b></td>
   <td></td>
   <td>
   <b>
   5.<input type="text" name="OptionB5" size="17" value="$OptionB5">\$<input type="text" name="OptionB5d" size="7" value="$OptionB5d"></b></td>
   <td></td>
   <td>
   <b>
   6.<input type="text" name="OptionB6" size="17" value="$OptionB6">\$<input type="text" name="OptionB6d" size="7" value="$OptionB6d"></b>
   </td>
   </tr>
   <tr>
   <td>
   <b>7.<input type="text" name="OptionB7" size="17" value="$OptionB7">\$<input type="text" name="OptionB7d" size="7" value="$OptionB7d"></b>
   </td>
   <td></td>
   <td>
   <b>8.<input type="text" name="OptionB8" size="17" value="$OptionB8">\$<input type="text" name="OptionB8d" size="7" value="$OptionB8d"></b>
   </td>
   <td></td>
   <td>
   <b>9.<input type="text" name="OptionB9" size="17" value="$OptionB9">\$<input type="text" name="OptionB9d" size="7" value="$OptionB9d"></b>
   </td>
   </tr>
  <tr>
   <td>
   <b>10.<input type="text" name="OptionB10" size="16" value="$OptionB10">\$<input type="text" name="OptionB10d" size="7" value="$OptionB10d"></b>
   </td>
   <td></td>
   <td>
   <b>11.<input type="text" name="OptionB11" size="16" value="$OptionB11">\$<input type="text" name="OptionB11d" size="7" value="$OptionB11d"></b>
   </td>
   <td></td>
   <td>
   <b>12.<input type="text" name="OptionB12" size="16" value="$OptionB12">\$<input type="text" name="OptionB12d" size="7" value="$OptionB12d"></b>
   </td>
   </tr>
  <tr>
   <td>
   <b>13.<input type="text" name="OptionB13" size="16" value="$OptionB13">\$<input type="text" name="OptionB13d" size="7" value="$OptionB13d"></b>
   </td>
   <td></td>
   <td>
   <b>14.<input type="text" name="OptionB14" size="16" value="$OptionB14">\$<input type="text" name="OptionB14d" size="7" value="$OptionB14d"></b>
   </td>
   <td></td>
   <td>
   <b>15.<input type="text" name="OptionB15" size="16" value="$OptionB15">\$<input type="text" name="OptionB15d" size="7" value="$OptionB15d"></b>
   </td>
   </tr>

   <tr>
   <td colspan="6"><b>&nbsp;</b></td>
   </tr>
   </center>
   <tr>
   <td colspan="6" bgcolor="#0000ff" align=center><font face="Arial" size="2" color=white><b>Bottom / Third Option Box - Option 3</b></font></td>
</tr>
   <tr>
   <td colspan="6" align=center>
   <p><b>Option Name:</b></font>&nbsp;&nbsp;
 <b><input type="text" name="OptionC" size="26" value="$OptionC"></b>
   </td>
</tr>
   <tr>
   <td bgcolor="#E0E5FF" align=center>
   <b>
   Enter Option Name and Price</b></td>
   <td bgcolor="#E0E5FF"></td>
   <td bgcolor="#E0E5FF" align=center><b>Enter Option Name and Price</font></b></td>
   <td bgcolor="#E0E5FF"></td>
   <td bgcolor="#E0E5FF" align=center><b>Enter Option Name and Price</b></td>
   </tr>
  <tr>
   <td>
   <b>
   1.<input type="text" name="OptionC1" size="17" value="$OptionC1">\$<input type="text" name="OptionC1d" size="7" value="$OptionC1d"></b></td>
   <td></td>
   <td>
   <b>
   2.<input type="text" name="OptionC2" size="17" value="$OptionC2">\$<input type="text" name="OptionC2d" size="7" value="$OptionC2d"></b></td>
   <td></td>
   <td>
   <b>
   3.<input type="text" name="OptionC3" size="17" value="$OptionC3">\$<input type="text" name="OptionC3d" size="7" value="$OptionC3d"></b></td>
   </tr>
   <tr>
   <td>
   <b>
   4.<input type="text" name="OptionC4" size="17" value="$OptionC4">\$<input type="text" name="OptionC4d" size="7" value="$OptionC4d"></b></td>
   <td></td>
   <td>
   <b>
   5.<input type="text" name="OptionC5" size="17" value="$OptionC5">\$<input type="text" name="OptionC5d" size="7" value="$OptionC5d"></b></td>
   <td></td>
   <td>
   <b>
   6.<input type="text" name="OptionC6" size="17" value="$OptionC6">\$<input type="text" name="OptionC6d" size="7" value="$OptionC6d"></b>
   </td>
   </tr>
   <tr>
   <td>
   <b>7.<input type="text" name="OptionC7" size="17" value="$OptionC7">\$<input type="text" name="OptionC7d" size="7" value="$OptionC7d"></b>
   </td>
   <td></td>
   <td>
   <b>8.<input type="text" name="OptionC8" size="17" value="$OptionC8">\$<input type="text" name="OptionC8d" size="7" value="$OptionC8d"></b>
   </td>
   <td></td>
   <td>
   <b>9.<input type="text" name="OptionC9" size="17" value="$OptionC9">\$<input type="text" name="OptionC9d" size="7" value="$OptionC9d"></b>
   </td>
   </tr>
 <tr>
   <td>
   <b>10.<input type="text" name="OptionC10" size="16" value="$OptionC10">\$<input type="text" name="OptionC10d" size="7" value="$OptionC10d"></b>
   </td>
   <td></td>
   <td>
   <b>11.<input type="text" name="OptionC11" size="16" value="$OptionC11">\$<input type="text" name="OptionC11d" size="7" value="$OptionC11d"></b>
   </td>
   <td></td>
   <td>
   <b>12.<input type="text" name="OptionC12" size="16" value="$OptionC12">\$<input type="text" name="OptionC12d" size="7" value="$OptionC12d"></b>
   </td>
   </tr>
 <tr>
   <td>
   <b>13.<input type="text" name="OptionC13" size="16" value="$OptionC13">\$<input type="text" name="OptionC13d" size="7" value="$OptionC13d"></b>
   </td>
   <td></td>
   <td>
   <b>14.<input type="text" name="OptionC14" size="16" value="$OptionC14">\$<input type="text" name="OptionC14d" size="7" value="$OptionC14d"></b>
   </td>
   <td></td>
   <td>
   <b>15.<input type="text" name="OptionC15" size="16" value="$OptionC15">\$<input type="text" name="OptionC15d" size="7" value="$OptionC15d"></b>
   </td>
   </tr>
</table>
</div>
<p><br></p>

<input type="hidden" name="system_edit_success" value="yes">
<button name="BasicOptionsSettings" class="btn btn-primary btn-lg btn-block mgr-center" value="Submit">Submit Option File Changes</button>

</form>
<div class="row col-sm-12"><p><br><br><br></p></div>
~;

    print &$manager_page_footer;
}

#######################################################################

sub display_options_screen {

    print &$manager_page_header( 'Basic Options', '', '', '', '' );
    $sc_optfile2edit = q{};
    $optlist     = q{};
    $optlist     = "<option value=''>Create New Option File</option>\n";

    opendir( OPTDIR, "$mgrdir/options" ) || die("Cannot open Directory!");
    @optnames2 = readdir(OPTDIR);
    my @sorted = sort { lc($a) cmp lc($b) } @optnames2;
    for $optnames2 (@sorted) {
        $optname2       = ( split( /\./, $optnames2 ) )[0];
        $opt_extension2 = ( split( /\./, $optnames2 ) )[1];
        if ( $opt_extension2 eq "pl" ) {
            $optlist .= "<option value='$optname2'>$optname2</option>\n";
        }
    }
    close(OPTDIR);

    print qq~
<h2 class='mgr-page-title'>Select Basic Option File to Edit</h2>
<p><br></p>

<p class="well">This manager allows you to create very simple option files to include in your products within the Add and Edit product screens. You will only be able to edit option files you can previously created with this manager. Advanced option files need to be edited manually or with a store manager file editor that handles all option files.</p>
<p><br></p>

<form action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">

<div align="center">
<p><b>Select file you wish to edit</b>: <select name='sc_optfile2edit'>$optlist</select>
<button name="EditOptionsFile" class="btn btn-primary btn-sm" value="Submit">Submit Option File Changes</button></p>
</div>

</form>
<p><br><br><br></p>

~;

    print &$manager_page_footer;
}

#######################################################################

sub update_option_file_settings {

    local ( $item, $stuff ) = @_;
    $option_file_settings{$item} = $stuff;
    local ($opt_settings) = "$mgrdir/options/$optfile2.pl";
    local ( $item, $zitem );

    get_file_lock("$opt_settings.lockfile");
    open( OPTFILE, ">$opt_settings" ) || my_die("Can't Open $opt_settings");
    foreach $zitem ( sort( keys %option_file_settings ) ) {
        $item = $zitem;
        print( OPTFILE $option_file_settings{$zitem} );
    }
    close(OPTFILE);
    release_file_lock("$opt_settings.lockfile");

}

#######################################################################

1;
