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

# Contains all sub routines (functions) for the store's shipping settings manager.

#######################################################################
#
# 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.
#
#######################################################################

$sc_custom_shipping_methodname_string = q{};
$sc_shipadminFedEx = "$mgrconfdir/ship_admin_FedEx.pl";
$sc_shipadminUSPS = "$mgrconfdir/ship_admin_USPS.pl";
$sc_shipadminfile = "$mgrconfdir/ship_admin.pl";

( $sc_show_UPS_XMLrate, $sc_show_FedEx, $sc_show_DHL ) = q{};

{
    local ($modname) = 'shipping_settings';
    register_extension( $modname, 'Shipping Library Settings',
        $versions{$modname} );
    add_settings_choice(
        'shipping settings',
        ' Shipping Settings & Logic ',
        'shipping_settings_screen'
    );
    register_menu( 'shipping_settings_screen', 'show_ship_settings_screen',
        $modname, 'Display Shipping Library Settings' );
    register_menu(
        'ChangeShipSettings', 'action_input_ship_settings',
        $modname,  'Write Shipping Library Settings'
    );
}

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

sub action_input_ship_settings {

    local ( $admin_email, $order_email, $cookieDomain, $cookiePath );
    local ($other_program_settings) = q{};
    local ( $i, $j, $shipmethod_count ) = 0;
    my (
        $temp_db_thingy,  $ups_xml_temp_thingy, $ups_temp_thingy,
        $usps_temp_thingy, $fedex_temp_thingy, $dhl_temp_thingy
    ) = q{};
    my ( $temp_origin_country_thingy, $myset, $myset2, $myset3, $myset4 ) = q{};
    my ( $myUSPS, $myFedEx ) = q{};

    if ( $in{'sc_alt_origin_db_counter2'} ) {
        $temp_db_thingy = $in{'sc_alt_origin_db_counter2'};
        if ( $temp_db_thingy =~ /User 20/i ) {
            $sc_alt_origin_db_counter = 26;
        }
        elsif ( $temp_db_thingy =~ /User 2/i ) {
            $sc_alt_origin_db_counter = 8;
        }
        elsif ( $temp_db_thingy =~ /User 3/i ) {
            $sc_alt_origin_db_counter = 9;
        }
        elsif ( $temp_db_thingy =~ /User 4/i ) {
            $sc_alt_origin_db_counter = 10;
        }
        elsif ( $temp_db_thingy =~ /User 5/i ) {
            $sc_alt_origin_db_counter = "11";
        }
        elsif ( $temp_db_thingy =~ /User 6/i ) {
            $sc_alt_origin_db_counter = 12;
        }
        elsif ( $temp_db_thingy =~ /User 7/i ) {
            $sc_alt_origin_db_counter = 13;
        }
        elsif ( $temp_db_thingy =~ /User 8/i ) {
            $sc_alt_origin_db_counter = 14;
        }
        elsif ( $temp_db_thingy =~ /User 9/i ) {
            $sc_alt_origin_db_counter = 15;
        }
        elsif ( $temp_db_thingy =~ /User 10/i ) {
            $sc_alt_origin_db_counter = 16;
        }
        elsif ( $temp_db_thingy =~ /User 11/i ) {
            $sc_alt_origin_db_counter = 17;
        }
        elsif ( $temp_db_thingy =~ /User 12/i ) {
            $sc_alt_origin_db_counter = 18;
        }
        elsif ( $temp_db_thingy =~ /User 13/i ) {
            $sc_alt_origin_db_counter = 19;
        }
        elsif ( $temp_db_thingy =~ /User 14/i ) {
            $sc_alt_origin_db_counter = 20;
        }
        elsif ( $temp_db_thingy =~ /User 15/i ) {
            $sc_alt_origin_db_counter = 21;
        }
        elsif ( $temp_db_thingy =~ /User 16/i ) {
            $sc_alt_origin_db_counter = 22;
        }
        elsif ( $temp_db_thingy =~ /User 17/i ) {
            $sc_alt_origin_db_counter = 23;
        }
        elsif ( $temp_db_thingy =~ /User 18/i ) {
            $sc_alt_origin_db_counter = 24;
        }
        elsif ( $temp_db_thingy =~ /User 19/i ) {
            $sc_alt_origin_db_counter = 25;
        }
        else {
            $sc_alt_origin_db_counter = q{};
        }
    }

    @values = param('shipping_enabled');
    foreach $value ( @values ) {
        if ( $shipmethod_count == 0 ) {
            $mc_enabled_shipping_methods .= "$value";
        }
        else {
            $mc_enabled_shipping_methods .= "|$value";
        }
        $myset2 .= "\$mc_ship_display{\"$value\"} = \"yes\";\n";
        $mc_ship_display{"$value"} = 'yes';
        $shipmethod_count++;
    }

    $myset2 .= "\$mc_enabled_shipping_methods = \"$mc_enabled_shipping_methods\";\n";

    $myset2 .= "\$sc_howmanycustomshippingmethods = \"$in{'sc_howmanycustomshippingmethods'}\";\n";
    $myset .= "\$sc_ship_thingy_p_id_indicator_enabled = \"$in{'sc_ship_thingy_p_id_indicator_enabled'}\";\n";
    $myset .= "\$sc_calculate_shipping_loop = \"$in{'sc_calculate_shipping_loop'}\";\n";
    $myset .= "\$sc_handling_charge = \"$in{'sc_handling_charge'}\";\n";
    $myset .= "\$sc_handling_charge_type = \"$in{'sc_handling_charge_type'}\";\n";
    $myset .= "\$sc_add_handling_cost_if_shipping_is_zero = \"$in{'sc_add_handling_cost_if_shipping_is_zero'}\";\n";
    $myset .= "\$sc_show_shipping_box_at_zero = \"$in{'sc_show_shipping_box_at_zero'}\";\n";
    $myset .= "\$sc_alt_origin_enabled = \"$in{'sc_alt_origin_enabled'}\";\n";

    # $myset .= "\$sc_alt_origin_db_counter = \"$sc_alt_origin_db_counter\";\n";
    $myset .= "\$sc_use_custom_shipping_logic = \"$in{'sc_use_custom_shipping_logic'}\";\n";
    $myset .= "\$sc_location_custom_shipping_logic = \"$in{'sc_location_custom_shipping_logic'}\";\n";
    $myset .= "\$sc_use_SBW2 = \"$in{'sc_use_SBW2'}\";\n";
    $myset .= "\$sc_num_shipping_codes = \"$in{'sc_num_shipping_codes'}\";\n";
    $myset .= "\@sc_shipping_logic = (";

    while ( $i <= $in{'sc_num_shipping_codes'} ) {
        $myrow = q{};
        if (  $in{ join( '_r', 'shipping_rate', $i ) } )
        {
            if ( $i > 0 ) { $myrow .= ',' }
            $myrow .= "\"$in{join('_r','shipping_code',$i)}|";
            $myrow .= "$in{join('_r','subtotal_price',$i)}|";
            $myrow .= "$in{join('_r','quantity',$i)}|";
            $myrow .= "$in{join('_r','measured_value',$i)}|";
            $myrow .= "$in{join('_r','shipping_rate',$i)}|";

            #check to make sure something is entered into the date column
            $myrow .= "$in{join('_r','exp_date',$i)}|";

            $myrow .= "$in{join('_r','comments',$i)}|";
            $myrow .= "$in{join('_r','p_indicator',$i)}|";
            $myrow .= "$in{join('_r','prod_valuetext',$i)}\"";
            $j++;
        }
        elsif ($in{ join( '_r', 'shipping_code', $i ) }
            || $in{ join( '_r', 'subtotal_price', $i ) }
            || $in{ join( '_r', 'quantity',       $i ) }
            || $in{ join( '_r', 'measured_value', $i ) }
            || $in{ join( '_r', 'shipping_rate',       $i ) }
            || $in{ join( '_r', 'exp_date',       $i ) }
            || $in{ join( '_r', 'comments',       $i ) }
            || $in{ join( '_r', 'p_indicator',       $i ) }
            || $in{ join( '_r', 'prod_valuetext',       $i ) } )
        {
            $warning_msg =
              q{One of your "Custom Shipping Logic - EZ Input" did not contain a <br>
                    <b>Shipping Rate</b> Entry. Therefore it was not added.};
        }
        $myset .= $myrow;
        $i++;
    }
    $myset .= ");\n";
    $sc_custom_shipping_logic = my_escape( $in{'sc_custom_shipping_logic'} );
    $myset .= "\$sc_custom_shipping_logic = qq`$sc_custom_shipping_logic`;\n";
    $myset .= "\$sc_use_SBW = \"$in{'sc_use_SBW'}\";\n";
    $myset .= "\$sc_use_socket = \"$in{'sc_use_socket'}\";\n";
    $myset .= "\$sc_dimensional_shipping_enabled = \"$in{'sc_dimensional_shipping_enabled'}\";\n";

    if ( ( $mc_ship_display{'UPS_XMLrate'} =~ /yes/i )
        || ( ( $in{'sc_use_UPS_XMLrate'} eq 'yes' ) && ( $mc_ship_display{'UPS_XMLrate'} ne '' ) ) ) {
        $myset .= &save_UPS_XMLrate_ship_settings();
    }
    else {
        $myset .= "\$sc_use_UPS = \"$in{'sc_use_UPS'}\";\n";
        $myset .= "\$sc_use_UPS_XMLrate = 'no';\n";
        $myset .= "\$sc_UPS_Origin_ZIP = \"$in{'sc_UPS_Origin_ZIP'}\";\n";
        $myset .= "\$sc_UPS_max_wt = \"$in{'sc_UPS_max_wt'}\";\n";
        $myset .= "\$sc_UPS_RateChart = \"$in{'sc_UPS_RateChart'}\";\n";
        $myset .= "\$sc_upsgroundres = \"$in{'sc_upsgroundres'}\";\n";
        $myset .= "\$sc_upsgroundcomm = \"$in{'sc_upsgroundcomm'}\";\n";
        $myset .= "\$sc_ups2da = \"$in{'sc_ups2da'}\";\n";
        $myset .= "\$sc_ups1da = \"$in{'sc_ups1da'}\";\n";
        $myset .= "\$sc_ups_non_xml_adjust = \"$in{'sc_ups_non_xml_adjust'}\";\n";
        $myset .= "\$sc_ups_non_xml_adjust_rate = \"$in{'sc_ups_non_xml_adjust_rate'}\";\n";
    }

    $myset .= "\$sc_use_USPS = \"$in{'sc_use_USPS'}\";\n";
    $myUSPS .= "\$sc_use_USPS = \"$in{'sc_use_USPS'}\";\n";
    if ( ( $mc_ship_display{'USPS'} eq 'yes' ) && ( $in{'sc_use_USPS'} eq 'yes' ) ) {
        $myUSPS .= "\$sc_USPS_max_wt = \"$in{'sc_USPS_max_wt'}\";\n";
        $myUSPS .= "\$sc_USPS_Origin_ZIP = \"$in{'sc_USPS_Origin_ZIP'}\";\n";
        $myUSPS .= "\$sc_USPS_use_API = \"$in{'sc_USPS_use_API'}\";\n";
        $myUSPS .= "\$sc_USPS_userid = \"$in{'sc_USPS_userid'}\";\n";
    }

    $sc_USPS_use_API = $in{'sc_USPS_use_API'};
    $myset .= "\$sc_USPS_max_wt = \"$in{'sc_USPS_max_wt'}\";\n";
    $myset .= "\$sc_USPS_Origin_ZIP = \"$in{'sc_USPS_Origin_ZIP'}\";\n";
    $myset .= "\$sc_USPS_use_API = \"$in{'sc_USPS_use_API'}\";\n";
    $myset .= "\$sc_USPS_userid = \"$in{'sc_USPS_userid'}\";\n";

    if ( $USPS_PackageType =~ /flat rate/i ) {
        $in{'sc_USPS_avg_package_length'} = q{};
        $in{'sc_USPS_avg_package_width'} = q{};
        $in{'sc_USPS_avg_package_height'} = q{};
        $in{'sc_USPS_avg_package_girth'} = q{};
    }

    $myset .= "\$sc_USPS_host_URL = \"$mc_USPS_production_URL\";\n";
    $myset .= "\$USPS_PackageType = \"$in{'USPS_PackageType'}\";\n";
    $myUSPS .= "\$USPS_PackageType = \"$in{'USPS_PackageType'}\";\n";
    $myset .= "\$sc_USPS_avg_package_length = \"$in{'sc_USPS_avg_package_length'}\";\n";
    $myUSPS .= "\$sc_USPS_avg_package_length = \"$in{'sc_USPS_avg_package_length'}\";\n";
    $myset .= "\$sc_USPS_avg_package_width = \"$in{'sc_USPS_avg_package_width'}\";\n";
    $myUSPS .= "\$sc_USPS_avg_package_width = \"$in{'sc_USPS_avg_package_width'}\";\n";
    $myset .= "\$sc_USPS_avg_package_height = \"$in{'sc_USPS_avg_package_height'}\";\n";
    $myUSPS .= "\$sc_USPS_avg_package_height = \"$in{'sc_USPS_avg_package_height'}\";\n";
    $myset .= "\$sc_USPS_avg_package_girth = \"$in{'sc_USPS_avg_package_girth'}\";\n";
    $myUSPS .= "\$sc_USPS_avg_package_girth = \"$in{'sc_USPS_avg_package_girth'}\";\n";
    $myset .= "\$USPS_insure_shipments = \"$in{'USPS_insure_shipments'}\";\n";
    $myUSPS .= "\$USPS_insure_shipments = \"$in{'USPS_insure_shipments'}\";\n";
    $myset .= "\$USPS_delivery_confirmation = \"$in{'USPS_delivery_confirmation'}\";\n";
    $myUSPS .= "\$USPS_delivery_confirmation = \"$in{'USPS_delivery_confirmation'}\";\n";
    $myset .= "\$USPS_signature_confirmation = \"$in{'USPS_signature_confirmation'}\";\n";
    if ( ( $mc_ship_display{'USPS'} eq 'yes' ) && ( $in{'sc_use_USPS'} eq 'yes' ) ) {
        $myUSPS .= "\$USPS_signature_confirmation = \"$in{'USPS_signature_confirmation'}\";\n";
        $myUSPS .= "\$sc_uspsfirstclass = \"$in{'sc_uspsfirstclass'}\";\n";
        $myUSPS .= "\$sc_uspsparcelpost = \"$in{'sc_uspsparcelpost'}\";\n";
        $myUSPS .= "\$sc_uspsprioritymail = \"$in{'sc_uspsprioritymail'}\";\n";
        $myUSPS .= "\$sc_uspsexpressmail = \"$in{'sc_uspsexpressmail'}\";\n";
        $myUSPS .= "\$sc_uspsfirstclasspackageintern = \"$in{'sc_uspsfirstclasspackageintern'}\";\n";
        $myUSPS .= "\$sc_uspspriorityintern = \"$in{'sc_uspspriorityintern'}\";\n";
        $myUSPS .= "\$sc_uspsexpressintern = \"$in{'sc_uspsexpressintern'}\";\n";
        $myUSPS .= "\$sc_uspsglobexpmail = \"$in{'sc_uspsglobexpmail'}\";\n";
    }


    if ( ( $mc_ship_display{'FedEx'} eq 'yes' ) || ( $in{'sc_use_FedEx'} =~ /yes/i ) ) {
        $myset  .= "\$sc_use_FedEx = \"$in{'sc_use_FedEx'}\";\n";
        $myFedEx .= "\$sc_use_FedEx = \"$in{'sc_use_FedEx'}\";\n";
        $myset  .= "\$sc_FedEx_use_API = \"$in{'sc_FedEx_use_API'}\";\n";
        $myFedEx .= "\$sc_FedEx_use_API = \"$in{'sc_FedEx_use_API'}\";\n";
        $sc_FedEx_use_API = $in{'sc_FedEx_use_API'};

        if ( $sc_FedEx_use_API eq 'Production' ) {
            $myset .= "\$sc_FedEx_server = \"$mc_FedEx_production_URL\";\n";
        }
        else {
            $myset .= "\$sc_FedEx_server = \"$mc_FedEx_sandbox_URL\";\n";
        }

        $myset .= "\$sc_FedEx_account_number = \"$in{'sc_FedEx_account_number'}\";\n";
        $myset .= "\$sc_FedEx_meter_number = \"$in{'sc_FedEx_meter_number'}\";\n";
        $myset .= "\$sc_FedEx_key = \"$in{'sc_FedEx_key'}\";\n";
        $myFedEx .= "\$sc_FedEx_key = \"$in{'sc_FedEx_key'}\";\n";
        $myset .= "\$sc_FedEx_password = \"$in{'sc_FedEx_password'}\";\n";
        $myFedEx .= "\$sc_FedEx_password = \"$in{'sc_FedEx_password'}\";\n";
        $myset .= "\$sc_FedEx_drop_off_type = \"$in{'sc_FedEx_drop_off_type'}\";\n";
        $myFedEx .= "\$sc_FedEx_drop_off_type = \"$in{'sc_FedEx_drop_off_type'}\";\n";
        $myset .= "\$sc_FedEx_packaging = \"$in{'sc_FedEx_packaging'}\";\n";
        $myFedEx .= "\$sc_FedEx_packaging = \"$in{'sc_FedEx_packaging'}\";\n";
        $myset .= "\$sc_FedEx_max_wt = \"$in{'sc_FedEx_max_wt'}\";\n";
        $myFedEx .= "\$sc_FedEx_max_wt = \"$in{'sc_FedEx_max_wt'}\";\n";
        $myset .= "\$sc_FedEx_weight_units = \"$in{'sc_FedEx_weight_units'}\";\n";
        $myFedEx .= "\$sc_FedEx_weight_units = \"$in{'sc_FedEx_weight_units'}\";\n";
        $myset .= "\$sc_FedEx_dimension_units = \"$in{'sc_FedEx_dimension_units'}\";\n";
        $myFedEx .= "\$sc_FedEx_dimension_units = \"$in{'sc_FedEx_dimension_units'}\";\n";
        $myset .= "\$sc_FedEx_avg_package_length = \"$in{'sc_FedEx_avg_package_length'}\";\n";
        $myFedEx .= "\$sc_FedEx_avg_package_length = \"$in{'sc_FedEx_avg_package_length'}\";\n";
        $myset .= "\$sc_FedEx_avg_package_width = \"$in{'sc_FedEx_avg_package_width'}\";\n";
        $myFedEx .= "\$sc_FedEx_avg_package_width = \"$in{'sc_FedEx_avg_package_width'}\";\n";
        $myset .= "\$sc_FedEx_avg_package_height = \"$in{'sc_FedEx_avg_package_height'}\";\n";
        $myFedEx .= "\$sc_FedEx_avg_package_height = \"$in{'sc_FedEx_avg_package_height'}\";\n";
        $myset .= "\$sc_FedEx_Origin_City = \"$in{'sc_FedEx_Origin_City'}\";\n";
        $myFedEx .= "\$sc_FedEx_Origin_City = \"$in{'sc_FedEx_Origin_City'}\";\n";
        $myset .= "\$sc_FedEx_Origin_ZIP = \"$in{'sc_FedEx_Origin_ZIP'}\";\n";
        $myFedEx .= "\$sc_FedEx_Origin_ZIP = \"$in{'sc_FedEx_Origin_ZIP'}\";\n";
        $myset .= "\$sc_FedEx_Origin_Stateprov = \"$in{'sc_FedEx_Origin_Stateprov'}\";\n";
        $myFedEx .= "\$sc_FedEx_Origin_Stateprov = \"$in{'sc_FedEx_Origin_Stateprov'}\";\n";
        $myset .= "\$sc_FedEx_Origin_Country = \"$in{'sc_FedEx_Origin_Country'}\";\n";
        $myFedEx .= "\$sc_FedEx_Origin_Country = \"$in{'sc_FedEx_Origin_Country'}\";\n";
        $myset .= "\$sc_FedEx_currency_code = \"$in{'sc_FedEx_currency_code'}\";\n";
        $myFedEx .= "\$sc_FedEx_currency_code = \"$in{'sc_FedEx_currency_code'}\";\n";
        $myset .= "\$sc_FedEx_residential = \"$in{'sc_FedEx_residential'}\";\n";
        if ( ( $mc_ship_display{'FedEx'} eq 'yes' ) && ( $in{'sc_use_FedEx'} =~ /yes/i ) ) {
            $myFedEx .= "\$sc_FedEx_account_number = \"$in{'sc_FedEx_account_number'}\";\n";
            $myFedEx .= "\$sc_FedEx_meter_number = \"$in{'sc_FedEx_meter_number'}\";\n";
            $myFedEx .= "\$sc_FedEx_residential = \"$in{'sc_FedEx_residential'}\";\n";
            $myFedEx .= "\$sc_FedEx_priority_overnight = \"$in{'sc_FedEx_priority_overnight'}\";\n";
            $myFedEx .= "\$sc_FedEx_standard_overnight = \"$in{'sc_FedEx_standard_overnight'}\";\n";
            #$myFedEx .= "\$sc_FedEx_first_overnight = \"$in{'sc_FedEx_first_overnight'}\";\n";
            $myFedEx .= "\$sc_FedEx_2_day = \"$in{'sc_FedEx_2_day'}\";\n";
            $myFedEx .= "\$sc_FedEx_express_saver = \"$in{'sc_FedEx_express_saver'}\";\n";
            $myFedEx .= "\$sc_FedEx_smart_post = \"$in{'sc_FedEx_smart_post'}\";\n";
            $myFedEx .= "\$sc_FedEx_freight = \"$in{'sc_FedEx_freight'}\";\n";
            $myFedEx .= "\$sc_FedEx_national_freight = \"$in{'sc_FedEx_national_freight'}\";\n";
            $myFedEx .= "\$sc_FedEx_international_ground = \"$in{'sc_FedEx_international_ground'}\";\n";
            $myFedEx .= "\$sc_FedEx_international_priority = \"$in{'sc_FedEx_international_priority'}\";\n";
            $myFedEx .= "\$sc_FedEx_international_economy = \"$in{'sc_FedEx_international_economy'}\";\n";
            $myFedEx .= "\$sc_FedEx_international_first = \"$in{'sc_FedEx_international_first'}\";\n";
            $myFedEx .= "\$sc_FedEx_1_day_freight = \"$in{'sc_FedEx_1_day_freight'}\";\n";
            $myFedEx .= "\$sc_FedEx_2_day_freight = \"$in{'sc_FedEx_2_day_freight'}\";\n";
            $myFedEx .= "\$sc_FedEx_3_day_freight = \"$in{'sc_FedEx_3_day_freight'}\";\n";
            $myFedEx .= "\$sc_FedEx_ground = \"$in{'sc_FedEx_ground'}\";\n";
            $myFedEx .= "\$sc_FedEx_ground_home_delivery = \"$in{'sc_FedEx_ground_home_delivery'}\";\n";
            $myFedEx .= "\$sc_FedEx_international_priority_freight = \"$in{'sc_FedEx_international_priority_freight'}\";\n";
            $myFedEx .= "\$sc_FedEx_international_economy_freight = \"$in{'sc_FedEx_international_economy_freight'}\";\n";
            $myFedEx .= "\$sc_FedEx_europe_first_international_priority = \"$in{'sc_FedEx_europe_first_international_priority'}\";\n";
        }
    }

    # DHL should be ready later.  Future plugin
    $dhl_temp_thingy = $in{'sc_use_DHL'};
    if ( ( $mc_ship_display{'DHL'} eq 'yes' ) || ( $dhl_temp_thingy =~ /yes/i ) )  {
        $myset .= "\$sc_use_DHL = \"$in{'sc_use_DHL'}\";\n";
        if ( $dhl_temp_thingy =~ /yes/i ) {

            # for future needs
        }
    }

    # build shipping method stuff for cut and paste box.
    $sc_shiptomethod_4forms = q{};

    $sc_howmanycustomshippingmethods = $in{'sc_howmanycustomshippingmethods'};
    my $howmanycustomshippingmethod_temp = '0';
    $myset3 = "\$sc_custom_shipping_methodname_string = \"";
    $myset4 = "\$sc_custom_shipping_methoddescrip_string = \"";
    if ( $sc_howmanycustomshippingmethods > 0 ) {
        while ( $howmanycustomshippingmethod_temp <
            $sc_howmanycustomshippingmethods )
        {
            my $custom_shipping_methodname2 = "sc_custom_shipping_methodname"
              . "$howmanycustomshippingmethod_temp";
            my $custom_shipping_methoddescrip2 =
                'sc_custom_shipping_methoddescrip'
              . "$howmanycustomshippingmethod_temp";

            $myset3 .= "$in{$custom_shipping_methodname2}|";
            $myset4 .= "$in{$custom_shipping_methoddescrip2}|";
            if ( $in{$custom_shipping_methodname2} ne "" ) {
                $sc_shiptomethod_4forms .=
                  qq~\n<option value="$in{$custom_shipping_methodname2}">
      $in{$custom_shipping_methoddescrip2}</option>~;
            }
            $howmanycustomshippingmethod_temp++;
        }
        $myset3 .= "\";\n";
        $myset4 .= "\";\n";
        $myset2 .= "$myset3";
        $myset2 .= "$myset4";
    }


    if ( $in{'sc_uspsfirstclass'} =~ /yes/i ) {
        $sc_shiptomethod_4forms .=
          qq~\n<option value="USPS First Class (First Class)">
USPS First Class (3-5 days)</option>~;
    }
    if ( $in{'sc_uspsparcelpost'} =~ /yes/i ) {
        $sc_shiptomethod_4forms .=
          qq~\n<option value="USPS Parcel Post (Parcel)">
USPS Parcel Post (5-14 days)</option>~;
    }
    if ( $in{'sc_uspsprioritymail'} =~ /yes/i ) {
        $sc_shiptomethod_4forms .=
          qq~\n<option value="USPS Priority Mail (Priority)">
USPS Priority Mail (3-7 days)</option>~;
    }
    if ( $in{'sc_uspsexpressmail'} =~ /yes/i ) {
        $sc_shiptomethod_4forms .=
          qq~\n<option value="USPS Express Mail (Express)">
USPS Express Mail (1-3 days)</option>~;
    }
    if ( $in{'sc_uspsfirstclasspackageintern'} =~ /yes/i ) {
        $sc_shiptomethod_4forms .=
          qq~\n<option value="USPS (First-Class Package International)">
First-Class Package International (varies by destination)</option>~;
    }
    if ( $in{'sc_uspspriorityintern'} =~ /yes/i ) {
        $sc_shiptomethod_4forms .=
          qq~\n<option value="USPS (Priority Mail International)">
Priority Mail International (6-10 business days to many major markets)</option>~;
    }
    if ( $in{'sc_uspsexpressintern'} =~ /yes/i ) {
        $sc_shiptomethod_4forms .=
          qq~\n<option value="USPS (Priority Mail Express International)">
Priority Mail Express International (3-5 business days to many major markets)</option>~;
    }
    if ( $in{'sc_uspsglobexpmail'} =~ /yes/i ) {
        $sc_shiptomethod_4forms .=
          qq~\n<option value="USPS (Global Express Guaranteed)">
Global Express Guaranteed (1-3 business days to many major markets)</option>~;
    }

    if ( $mc_ship_display{'UPS_XMLrate'} eq 'yes' ) {
        $sc_shiptomethod_4forms .= &update_form_shipdata_for_UPS_XMLrate();
    }
    else {

        if ( $in{'sc_upsgroundres'} =~ /yes/i ) {
            $sc_shiptomethod_4forms .=
qq~\n<option value="UPS Ground Residential(GNDRES)">UPS Ground Residential</option>~;
        }
        if ( $in{'sc_upsgroundcomm'} =~ /yes/i ) {
            $sc_shiptomethod_4forms .=
qq~\n<option value="UPS Ground Commercial (GNDCOM)">UPS Ground Commercial</option>~;
        }
        if ( $in{'sc_ups2da'} =~ /yes/i ) {
            $sc_shiptomethod_4forms .=
              qq~\n<option value="UPS 2nd Day (2DA)">UPS 2nd Day</option>~;
        }
        if ( $in{'sc_ups1da'} =~ /yes/i ) {
            $sc_shiptomethod_4forms .=
              qq~\n<option value="UPS Next Day (1DA)">UPS Next Day</option>~;
        }

    }

    # FedEx shipping cut and paste box methods
    $sc_shiptomethod_4forms .= qq~\n<option>FedEx Ground Home Delivery</option>~
      if ( $in{'sc_FedEx_ground_home_delivery'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx Standard Overnight</option>~
      if ( $in{'sc_FedEx_standard_overnight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx Priority Overnight</option>~
      if ( $in{'sc_FedEx_priority_overnight'} =~ /yes/i );

   # $sc_shiptomethod_4forms .= qq~\n<option>FedEx First Overnight</option>~
   #   if ( $in{'sc_FedEx_first_overnight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx 1-Day Freight</option>~
      if ( $in{'sc_FedEx_1_day_freight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx 2-Day</option>~
      if ( $in{'sc_FedEx_2_day'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx 2-Day Freight</option>~
      if ( $in{'sc_FedEx_2_day_freight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx 3-Day Freight</option>~
      if ( $in{'sc_FedEx_3_day_freight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>Europe First International</option>~
      if ( $in{'sc_FedEx_europe_first_international'} );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx Ground</option>~
      if ( $in{'sc_FedEx_ground'} =~ /yes/i );

    $sc_shiptomethod_4forms .=
      qq~\n<option>FedEx International Economy</option>~
      if ( $in{'sc_FedEx_international_economy'} =~ /yes/i );

    $sc_shiptomethod_4forms .=
      qq~\n<option>FedEx International Economy Freight</option>~
      if ( $in{'sc_FedEx_international_economy_freight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx International First</option>~
      if ( $in{'sc_FedEx_international_first'} =~ /yes/i );

    $sc_shiptomethod_4forms .=
      qq~\n<option>FedEx International Priority</option>~
      if ( $in{'sc_FedEx_international_priority'} =~ /yes/i );

    $sc_shiptomethod_4forms .=
      qq~\n<option>FedEx International Priority Freight</option>~
      if ( $in{'sc_FedEx_international_priority_freight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx Express Saver 3-day</option>~
      if ( $in{'sc_FedEx_express_saver'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx Smart Post</option>~
      if ( $in{'sc_FedEx_smart_post'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx Freight</option>~
      if ( $in{'sc_FedEx_freight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx National Freight</option>~
      if ( $in{'sc_FedEx_national_freight'} =~ /yes/i );

    $sc_shiptomethod_4forms .= qq~\n<option>FedEx International Ground</option>~
      if ( $in{'sc_FedEx_international_ground'} =~ /yes/i );

    $myset .=
"\$sc_override_shipmethods_4forms = qq~$in{'sc_override_shipmethods_4forms'}~;\n";
    $myset .= "\$sc_shiptostates_4forms = qq~$in{'sc_shiptostates_4forms'}~;\n";
    $myset .=
      "\$sc_shiptocountries_4forms = qq~$in{'sc_shiptocountries_4forms'}~;\n";

    if ( $in{'sc_override_shipmethods_4forms'} eq 'No' ) {
        $myset .=
          "\$sc_shiptomethod_4forms = qq~$in{'sc_shiptomethod_4forms'}~;\n";
    }
    else {
        $myset .= "\$sc_shiptomethod_4forms = qq~$sc_shiptomethod_4forms~;\n";
    }

    update_store_settings( 'shipping', $myset );    # main settings
    $myset = q{};
    $myset2 .= "\n1;\n";
    $myUSPS .= "\n1;\n";
    $myFedEx .= "\n1;\n";
    update_adminfile_settings( "$sc_shipadminfile", $myset2 );
    if ( ( $mc_ship_display{'FedEx'} eq 'yes' ) && ( $in{'sc_use_FedEx'} eq 'yes' ) ) {
        update_adminfile_settings( "$sc_shipadminFedEx", $myFedEx);
    }
    if ( ( $mc_ship_display{'USPS'} eq 'yes' ) && ( $in{'sc_use_USPS'} eq 'yes' ) ) {
        update_adminfile_settings( "$sc_shipadminUSPS", $myUSPS);
    }
    show_ship_settings_screen();
}

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

sub show_ship_settings_screen {

    print &$manager_page_header( 'Shipping Settings', '', '', '', '' );

    my $howmanycustomshippingmethod_temp = '0';
    my ( @shiplibs, $mylist_of_shipping_libs, $is_shipping_checked, $extra_shipmethod_message ) = '';
    $available_official_shiplibs{'Australia_Post_ship-lib.pl'} = 'no';
    $available_official_shiplibs{'Canada_Post_ship-lib.pl'} = 'no';
    $available_official_shiplibs{'Royal_Post_UK_ship-lib.pl'} = 'no';
    $available_official_shiplibs{'DHL_ship-lib.pl'} = 'no';
    $available_official_shiplibs{'FedEx_ship-lib.pl'} = 'yes';
    $available_official_shiplibs{'UPS_legacy_ship-lib.pl'} = 'yes';
    $available_official_shiplibs{'UPS_XMLrate_ship-lib.pl'} = 'yes';
    $available_official_shiplibs{'UPS_XMLshopntime_ship-lib.pl'} = 'no';
    $available_official_shiplibs{'UPS_XMLtrack_ship-lib.pl'} = 'no';
    $available_official_shiplibs{'USPS_ship-lib.pl'} = 'yes';

    #set some defaults
    if ( $sc_debug_mode eq '' ) {
        $sc_debug_mode = 'no';
    }

    if ( $sc_num_shipping_codes eq '' ) {
        $sc_num_shipping_codes = '10';
    }

    if ( $sc_path_of_images_directory ) {
        $URL_of_images_directory = $sc_path_of_images_directory;
    }

    if ( $sc_ship_thingy_p_id_indicator_enabled eq '' ) {
        $sc_ship_thingy_p_id_indicator_enabled = 'no';
    }

    if ( $sc_ups_non_xml_adjust_rate eq '' ) {
        $sc_ups_non_xml_adjust_rate = '1.06';
    }

    if ( $sc_ups_non_xml_adjust eq '' ) {
        $sc_ups_non_xml_adjust = 'yes';
    }

    if ( $sc_show_shipping_box_at_zero eq '' ) {
        $sc_show_shipping_box_at_zero = 'no';
    }

    require_supporting_libraries( __FILE__, __LINE__, "$sc_shipadminfile" );

    # check for files ending in _ship-lib.pl in the shipping library directory
    opendir( SHIP_LIBS, "$sc_shiplib_dir" );
    @shiplibs = sort( grep( /_ship-lib\.pl\b/i, readdir(SHIP_LIBS) ) );
    closedir(SHIP_LIBS);

    foreach $item (@shiplibs) {
        $value_name = $item;
        #print "\$item = $item<br>";
        $value_name =~ s/_ship-lib\.pl\b//i;
        $value_name_stripped = $value_name;
        $value_name_stripped =~ s/_/ /g;
        if ( $available_official_shiplibs{"$item"} ne 'no' ) {
            if ( $value_name =~ /UPS_Legacy/ ) {
                $is_shipping_checked = ' checked';
                $extra_shipmethod_message = '';
            }
            elsif ( $mc_enabled_shipping_methods =~ /$value_name/ ) {
                $is_shipping_checked = ' checked';
                $extra_shipmethod_message = '';
            }
            else {
                $is_shipping_checked = '';
                $extra_shipmethod_message = "<span style='padding-left: 16px;'></span><i>Enable &amp; Save to view tab</i>";
            }
            $mylist_of_shipping_libs .= qq{
<div class="col-sm-6" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="shipping_enabled" value="$value_name"$is_shipping_checked>
      </span>
      <label class="form-control">$value_name_stripped $extra_shipmethod_message</label>
    </div>
</div>\n
};
        }
        else {
            $mylist_of_shipping_libs .= qq{
<div class="col-sm-6" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="shipping_enabled" value="$value_name" disabled>
      </span>
      <label class="form-control"><s>$value_name_stripped </s><i></i></label>
    </div>
</div>\n
};
        }
    }

    if ( $sc_shiptostates_4forms eq '' ) {
        $sc_shiptostates_4forms = qq|
<option value="">---USA---</option>
<option>AK</option>
<option>AL</option>
<option>AR</option>
<option>AZ</option>
<option>CA</option>
<option>CO</option>
<option>CT</option>
<option>DC</option>
<option>DE</option>
<option>FL</option>
<option>GA</option>
<option>GU</option>
<option>HI</option>
<option>IA</option>
<option>ID</option>
<option>IL</option>
<option>IN</option>
<option>KS</option>
<option>KY</option>
<option>LA</option>
<option>MA</option>
<option>MD</option>
<option>ME</option>
<option>MI</option>
<option>MN</option>
<option>MO</option>
<option>MS</option>
<option>MT</option>
<option>NC</option>
<option>ND</option>
<option>NE</option>
<option>NH</option>
<option>NJ</option>
<option>NM</option>
<option>NV</option>
<option>NY</option>
<option>OH</option>
<option>OK</option>
<option>OR</option>
<option>PA</option>
<option>PR</option>
<option>RI</option>
<option>SC</option>
<option>SD</option>
<option>TN</option>
<option>TX</option>
<option>UT</option>
<option>VA</option>
<option>VI</option>
<option>VT</option>
<option>WA</option>
<option>WI</option>
<option>WV</option>
<option>WY</option>
<option value=""></option>
<option value="">--AUSTRALIA--</option>
<option value="ACT">ACT</option>
<option value="NSW">NSW</option>
<option value="NT">NT</option>
<option value="QLD">QLD</option>
<option value="SA">SA</option>
<option value="TAS">TAS</option>
<option value="VIC">VIC</option>
<option value="WA">WA</option>
<option value=""></option>
<option value="">--CANADA--</option>
<option value="AB">Alberta</option>
<option value="BC">British Columbia</option>
<option value="MB">Manitoba</option>
<option value="NB">New Brunswick</option>
<option value="NL">Newfoundland and Labrador</option>
<option value="NT">Northwest Territories</option>
<option value="NS">Nova Scotia</option>
<option value="NU">Nunavut</option>
<option value="ON">Ontario</option>
<option value="PE">Prince Edward Island</option>
<option value="QC">Quebec</option>
<option value="SK">Saskatchewan</option>
<option value="YT">Yukon</option>
<option value="">--UK / England--</option>
<option value="Aberdeen City">Aberdeen City</option>
<option value="Aberdeenshire">Aberdeenshire</option>
<option value="Angus">Angus</option>
<option value="Argyll & Bute">Argyll & Bute</option>
<option value="Bath & North East Somerset">Bath & North East Somerset</option>
<option value="Bedfordshire">Bedfordshire</option>
<option value="Berkshire">Berkshire</option>
<option value="Blaenau Gwent">Blaenau Gwent</option>
<option value="Bridgend">Bridgend</option>
<option value="Bristol">Bristol</option>
<option value="Buckinghamshire">Buckinghamshire</option>
<option value="Caerphilly ">Caerphilly </option>
<option value="Cambridgeshire">Cambridgeshire</option>
<option value="Cardiff">Cardiff</option>
<option value="Carmarthenshire">Carmarthenshire</option>
<option value="Ceredidgion">Ceredidgion</option>
<option value="Cheshire">Cheshire</option>
<option value="ClackMannanshire">ClackMannanshire</option>
<option value="Conwy">Conwy</option>
<option value="Cornwall">Cornwall</option>
<option value="Cumbria">Cumbria</option>
<option value="Denbighshire">Denbighshire</option>
<option value="Derbyshire">Derbyshire</option>
<option value="Devon">Devon</option>
<option value="Dorset">Dorset</option>
<option value="Dumfries & Galloway">Dumfries & Galloway</option>
<option value="Dundee City">Dundee City</option>
<option value="Durham">Durham</option>
<option value="East Ayrshire">East Ayrshire</option>
<option value="East Dunbartonshire">East Dunbartonshire</option>
<option value="East Lothian">East Lothian</option>
<option value="East Renfrewshire">East Renfrewshire</option>
<option value="East Riding of Yorkshire">East Riding of Yorkshire</option>
<option value="East Sussex">East Sussex</option>
<option value="Edinburgh">Edinburgh</option>
<option value="Essex">Essex</option>
<option value="Falkirk">Falkirk</option>
<option value="Fife">Fife</option>
<option value="Flintshire">Flintshire</option>
<option value="Glasgow">Glasgow</option>
<option value="Gloucestershire">Gloucestershire</option>
<option value="Greater Manchester">Greater Manchester</option>
<option value="Gwynedd">Gwynedd</option>
<option value="Hampshire">Hampshire</option>
<option value="Herefordshire">Herefordshire</option>
<option value="Hertfordshire">Hertfordshire</option>
<option value="Highlands">Highlands</option>
<option value="Inverclyde">Inverclyde</option>
<option value="Isle of Anglesey">Isle of Anglesey</option>
<option value="Kent">Kent</option>
<option value="Lancashire">Lancashire</option>
<option value="Leicestershire">Leicestershire</option>
<option value="Lincolnshire">Lincolnshire</option>
<option value="London">London</option>
<option value="Merseyside">Merseyside</option>
<option value="Merthyr Tydfil">Merthyr Tydfil</option>
<option value="Midlothian">Midlothian</option>
<option value="Monmouthshire">Monmouthshire</option>
<option value="Moray">Moray</option>
<option value="Neath Port Talbot">Neath Port Talbot</option>
<option value="Newport">Newport</option>
<option value="Norfolk">Norfolk</option>
<option value="North Ayrshire">North Ayrshire</option>
<option value="North Lanarkshire">North Lanarkshire</option>
<option value="North Somerset">North Somerset</option>
<option value="North Yorkshire">North Yorkshire</option>
<option value="Northamptonshire">Northamptonshire</option>
<option value="Northumberland">Northumberland</option>
<option value="Nottinghamshire">Nottinghamshire</option>
<option value="Orkney">Orkney</option>
<option value="Oxfordshire">Oxfordshire</option>
<option value="Pembrokeshire">Pembrokeshire</option>
<option value="Perth & Kinross">Perth & Kinross</option>
<option value="Powys">Powys</option>
<option value="Renfrewshire">Renfrewshire</option>
<option value="Rhondda Cynon Taff">Rhondda Cynon Taff</option>
<option value="Rutland">Rutland</option>
<option value="Scottish Borders">Scottish Borders</option>
<option value="Shetland">Shetland</option>
<option value="Shropshire">Shropshire</option>
<option value="Somerset">Somerset</option>
<option value="South Lanarkshire">South Lanarkshire</option>
<option value="South Yorkshire">South Yorkshire</option>
<option value="Staffordshire">Staffordshire</option>
<option value="Stirling">Stirling</option>
<option value="Suffolk">Suffolk</option>
<option value="Surrey">Surrey</option>
<option value="Swansea">Swansea</option>
<option value="Teesside">Teesside</option>
<option value="Torfaen">Torfaen</option>
<option value="Tyne & Wear">Tyne & Wear</option>
<option value="Vale of Glamorgan">Vale of Glamorgan</option>
<option value="Warwickshire">Warwickshire</option>
<option value="West Dunbartonshire">West Dunbartonshire</option>
<option value="West Lothian">West Lothian</option>
<option value="West Midlands">West Midlands</option>
<option value="West Sussex">West Sussex</option>
<option value="West Yorkshire">West Yorkshire</option>
<option value="Western Isles">Western Isles</option>
<option value="Wiltshire">Wiltshire</option>
<option value="Worcestershire">Worcestershire</option>
<option value="Wrexham">Wrexham</option>|;
    }

    if ( $sc_shiptocountries_4forms eq '' ) {
        $sc_shiptocountries_4forms = qq|
<option>United States</option>
<option>Australia</option>
<option>Canada</option>
<option>Ireland</option>
<option>Puerto Rico</option>
<option>Scotland</option>
<option>United Kingdom</option>
<option>Wales</option>
<option></option>
<option>American Samoa</option>
<option>Argentina</option>
<option>Austria</option>
<option>Belgium</option>
<option>Belize</option>
<option>Brazil</option>
<option>Bulgaria</option>
<option>Chile</option>
<option>Costa Rica</option>
<option>Cyprus</option>
<option>Denmark</option>
<option>Dominican Republic</option>
<option>Estonia</option>
<option>Finland</option>
<option>France</option>
<option>Germany</option>
<option>Greece</option>
<option>Guatemala</option>
<option>Hong Kong</option>
<option>Hungary</option>
<option>Israel</option>
<option>Italy</option>
<option>Jamaica</option>
<option>Japan</option>
<option>Latvia</option>
<option>Lithuania</option>
<option>Luxemborg</option>
<option>Malta</option>
<option>Mexico</option>
<option>Netherlands</option>
<option>New Zealand</option>
<option>Norway</option>
<option>Panama</option>
<option>Poland</option>
<option>Portugal</option>
<option>Slovakia</option>
<option>Slovenia</option>
<option>Spain</option>
<option>Sweden</option>
<option>Switzerland</option>
<option>Taiwan</option>
<option>Tonga</option>
<option>Virgin Islands (US)</option>|;
    }

    if ( $sc_shiptomethod_4forms eq '' ) {
        $sc_shiptomethod_4forms = qq|
<select name=Ecom_ShipTo_Method>
<option value="\$vform_Ecom_ShipTo_Method">\$vform_Ecom_ShipTo_Method2</option>
<option value="Local Delivery">
      Local Delivery</option>
<option value="Pickup">
      Pickup</option>
<option value="USPS Priority Mail (Priority)">
USPS Priority Mail (3-7 days)</option>
<option value="USPS (Priority Mail International)">
Priority Mail International (6-10 days)</option>
<option value="UPS Ground (GND)">UPS Ground (7-10 days)</option>
<option value="UPS Standard (STD)">UPS Standard to Canada Only (7-10 days)</option>
<option value="UPS 3 Day Select (3DS)">UPS 3 Day Select (3-4 days)</option>
<option value="UPS 2nd Day Air (2DA)">UPS 2nd Day Air</option>
</select>|;
    }


    print <<ENDOFTEXT;
<h1 class='mgr-page-title'><b>Shipping Settings &amp; Custom Logic</b></h1>
<p><br></p>
<p class="well">Use the tabs below to view each sub-section. You may change the settings within as many tabs/groups as needed, then press the <b><i>submit</i></b> button at the very bottom of the page after you are finished making any desired changes. Click on the <i class="fa fa-info-circle"></i> icon next to any setting for more information on the setting.</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">Shipping settings have been successfully updated.</h4>
    </div>
</div>
<p><br><br><br></p>
ENDOFTEXT

ENDOFTEXT
    }


    print <<ENDOFTEXT;

<ul class="nav nav-tabs" id="tabs3" role="tablist">
    <li role="presentation" class="active"><a href="#tabs-1" aria-controls="tabs-1" role="tab" data-toggle="tab">Main/Misc</a></li>
    <li role="presentation"><a href="#tabs-3" aria-controls="tabs-3" role="tab" data-toggle="tab">Toggle Shipping</a></li>
ENDOFTEXT
	if ( $mc_ship_display{'USPS'} eq 'yes' ) {
        print <<ENDOFTEXT;
        <li role="presentation"><a href="#tabs-4" aria-controls="tabs-4" role="tab" data-toggle="tab">USPS</a></li>
ENDOFTEXT
    }
    if ( ( $mc_ship_display{'UPS_legacy'} eq 'yes' ) || ( $mc_ship_display{'UPS_XMLrate'} eq 'yes' ) ) {
    print <<ENDOFTEXT;
        <li role="presentation"><a href="#tabs-5" aria-controls="tabs-5" role="tab" data-toggle="tab">UPS</a></li>
ENDOFTEXT
    }
	if ( $mc_ship_display{'FedEx'} eq 'yes' ) {
        print <<ENDOFTEXT;
        <li role="presentation"><a href="#tabs-6" aria-controls="tabs-6" role="tab" data-toggle="tab">FedEx</a></li>
ENDOFTEXT
    }
    print <<ENDOFTEXT;
    <li role="presentation"><a href="#tabs-2" aria-controls="tabs-2" role="tab" data-toggle="tab">Custom Logic</a></li>
    <li role="presentation"><a href="#tabs-7" aria-controls="tabs-7" role="tab" data-toggle="tab">States/Provinces</a></li>
    <li role="presentation"><a href="#tabs-8" aria-controls="tabs-8" role="tab" data-toggle="tab">Countries</a></li>
    <li role="presentation"><a href="#tabs-9" aria-controls="tabs-9" role="tab" data-toggle="tab">Your Shipping Methods</a></li>
</ul>

<form class="form-horizontal" action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<div class="tab-content">

<div class="tab-pane active" id="tabs-1">

<p><br></p>
<h2 class="mgr-page-title"><b>Main/Misc Shipping Settings</b></h2>
<p><br></p>

<p><b><b>In what loop</b> of calculate_final_values do you wish to calculate the shipping? &nbsp; <a data-toggle="collapse" href="#calcShippingLoop" aria-expanded="false" aria-controls="calcShippingLoop"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name="sc_calculate_shipping_loop">
<option>$sc_calculate_shipping_loop</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></p>
<div class="collapse" id="calcShippingLoop">
     <div class="well">
         <p>Check with your tax jurisdictions to see if shipping amounts are taxable.YES which allows you to create and use headers and/or footers for each individual category of products being viewed. Setting to NO disables this feature. </p>
         <p>Three (3) loops are performed on merchanidise totals so that fees/costs can be added to the subtotal or computations can be performed on the subtotal found during each loop. This allows you to add taxes, shipping and even take off discounts for a promotion code at the time of checkout. The 3 loops allow the different processes to be performed at different steps (loops) along the way, such as this <b>Example</b>: taking a discount off (loop 1), then computing a shipping cost based on the discounted subtotal of the order (loop 2), then taxing the discounted subtotal + shipping (loop 3).</p>
         <p>Discounts apply depending upon which loop the discount manager is set at. Double check those settings if shipping amounts are not to be discounted. Discounts should normally be computed a loop prior to shipping.</p>
         <p><b>Example</b>: If zero ( 0 ) is selected, shipping will never be calculated.</p>
         <p><b>Example</b>: If either 1 or 2 is selected, then the tax is based on the subtotal of merchandise + shipping. Discounts might applied depending upon which loop the discounts are applied to.</p>
         <p><b>Example</b>: If 3 is selected, then the tax is based on the pre-shipping subtotal -- any shipping amounts are added after taxes are computed and any shipping fees on the order are not taxed.</p>
     </div>
</div>
<p><hr></p>


<p><b>Handling Charge to be added to all orders: &nbsp; <a data-toggle="collapse" href="#handlingCharge" aria-expanded="false" aria-controls="handlingCharge"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="sc_handling_charge" type="text" size=6 maxlength="6" value="$sc_handling_charge"></p>
<div class="collapse" id="handlingCharge">
     <div class="well">
         <p>No currency symbol needed ( \$ ).</p>
         <p>Enter amount or percentage of order you wish to add to orders. <b>Example</b>: enter 2.75 for \$2.75 or for percntages enter 0.0635 for 6.35%</p>
         <p> Enter 0 if no handling charge is to be added to orders.</p>
     </div>
</div>
<p><br></p>

<p><b>Handling Charge Type: &nbsp; <a data-toggle="collapse" href="#handlingChargeType" aria-expanded="false" aria-controls="handlingChargeType"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name=sc_handling_charge_type>
<option>$sc_handling_charge_type</option>
<option>Flat Rate</option>
<option>Percentage</option>
</select></p>
<div class="collapse" id="handlingChargeType">
     <div class="well">
         <p>Default: Flat Rate is a single charge no matter the size of order.</p>
         <p>Percentage will charge a percentage of the total order as a handling fee.</p>
     </div>
</div>
<p><hr></p>

<p><b>Add handling Charge if shipping total is Zero?</b><span style="padding-left: 25px;"></span><select name="sc_add_handling_cost_if_shipping_is_zero">
<option>$sc_add_handling_cost_if_shipping_is_zero</option>
<option>yes</option>
<option>no</option>
</select></p>
<p><hr></p>

<p><b>Show alternate "free" text on shipping totals line if shipping total is Zero?</b><span style="padding-left: 25px;"></span><select name="sc_show_shipping_box_at_zero">
<option>$sc_show_shipping_box_at_zero</option>
<option>yes</option>
<option>no</option>
</select></p>
<p><hr></p>

<p><b>Enable Alternate Ship-From Origins? &nbsp; <a data-toggle="collapse" href="#altOriginsEnabled" aria-expanded="false" aria-controls="altOriginsEnabled"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name=sc_alt_origin_enabled>
<option>$sc_alt_origin_enabled</option>
<option>yes</option>
<option>no</option>
</select></p>
<div class="collapse" id="altOriginsEnabled">
     <div class="well">
         <p>Great for drop-shipped products and/or multiple shipping location shippers.</p>
         <p>If enabled (YES), extra fields show up in the "add products" and "edit products" screens.</p>
         <p>To use this ( in the "add product" or "edit product" screens ), first select a primary ship-from origin location for each shipping method your use (UPS, USPS, etc in their respective tabs in this manager). The recommended primary ship-from location should be where most of your products will be shipped from. Then using the "add" or "edit" product managers, change each individual product that ships from a different location by entering the alternate origination zipcode/postal-code and the related state/province for that ship-from origin.  No limit to locations/origination points.</p>
         <p> Using this method, there is No limit to locations/origination points.</p>
     </div>
</div>
<p><hr></p>

<p><b>Enable Dimensions in Product Database? &nbsp; <a data-toggle="collapse" href="#prodDimensEnabled" aria-expanded="false" aria-controls="prodDimensEnabled"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name=sc_dimensional_shipping_enabled>
<option>$sc_dimensional_shipping_enabled</option>
<option>yes</option>
<option>no</option>
</select></p>
<div class="collapse" id="prodDimensEnabled">
     <div class="well">
         <p>Great when you have products that ship in their own containers ( i.e.: separately from other items placed into a common shipping box ).</p>
         <p>If enabled (YES), extra fields show up in the "add products" and "edit products" screens.</p>
         <p>Only applicable for items rated and shipped via a real-time shipping methods (UPS, USPS, FedEx, DHL, etc).</p>
         <p>To use this feature ( in the "add product" or "edit product" screens ), enter individual product dimensions on the manager screens that allow you to edit or add products.</p>
         <p>If unsure, select NO</p>
     </div>
</div>
<p><br></p>

</div>

<!-- End of tab 1 -->


<div class="tab-pane" id="tabs-2">

<p><br></p>
<h2 class="mgr-page-title"><b>Custom Shipping Logic Settings</b></h2>
<p><br></p>

<p><b>Use the custom shipping logic? &nbsp; <a data-toggle="collapse" href="#useCustLogic" aria-expanded="false" aria-controls="useCustLogic"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name=sc_use_custom_shipping_logic>
<option>$sc_use_custom_shipping_logic</option>
<option>yes</option>
<option>no</option>
</select></p>
<div class="collapse" id="useCustLogic">
     <div class="well">
         <p>Custom Shipping Logic allows you to setup special rules for a great deal of situations, such as special shipping prices for categories, individual product items, in-store pickups, local delivery, and even overwrites on real-time shipment ratings.  The possibilities and combinations are almost limitless.</p>
         <p>If enabled (YES), you may still use the SBW module in the "real-time" tab of this manager -- perhaps some items are not appropriate for real-time shipment ratings and you desire to handle those items differently.</p>
         <p>If Custom logic and SBW are both set to "no" then the "shipping" field in the database is the shipping price of the individual items and added together for items in cart when customer checks out.</p>
     </div>
</div>
<p><hr></p>

<p><b>When to run custom shipping logic? &nbsp; <a data-toggle="collapse" href="#whenRunCustLogic" aria-expanded="false" aria-controls="whenRunCustLogic"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name=sc_location_custom_shipping_logic>
<option>$sc_location_custom_shipping_logic</option>
<option>before</option>
<option>after</option>
</select></p>
<div class="collapse" id="whenRunCustLogic">
     <div class="well">
         <p>Select BEFORE for default operations.</p>
         <p>Select when to run the custom shipping logic.</p>
         <p>If you need to alter shipping rates after real-time rates have been provided, then select AFTER.</p>
         <p>If using AFTER, there is a special variable to use that stores the value of realtime shipping costs that you can use in your shipping logic called \$SBW_shipping_price which allows you to alter or delete the costs of real time rates as you desire.</p>
     </div>
</div>
<p><hr></p>

<p><b>If using Custom Logic, is shipping measured by weight? &nbsp; <a data-toggle="collapse" href="#useCustLogicWeight" aria-expanded="false" aria-controls="useCustLogicWeight"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name=sc_use_SBW2>
<option>$sc_use_SBW2</option>
<option>yes</option>
<option>no</option>
</select></p>
<div class="collapse" id="useCustLogicWeight">
     <div class="well">
         <p>The shipping field in the product database can be either a price or a weight. This setting indicates how to treat the field value within custom shipping logic.</p>
         <p>YES turns the value into a weight.</p>
         <p>NO indicates the value is a shipping price.</p>
     </div>
</div>
<p><hr><br></p>

<h3 class="mgr-page-title"><b>Custom Shipping Methods</b></h3>
<p><br></p>

<p><b>How Many Custom Shipping Methods are Needed? &nbsp; <a data-toggle="collapse" href="#howManyShipMethods" aria-expanded="false" aria-controls="howManyShipMethods"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="sc_howmanycustomshippingmethods" type="number" size=3 maxlength="3" value="$sc_howmanycustomshippingmethods"></p>
<div class="collapse" id="howManyShipMethods">
     <div class="well">
         <p>Select the number of custom shipping method names you wish to use.</p>
         <p>The resulting names are placed in the shipping methods code you can place in your order forms along with any real-time options (UPS, USPS, FedEx, DHL, etc.) After saving any changes to the custom logic, see that tab in this manager for the resulting code you can copy, if needed.</p>
         <p>The custom shipping names can also be used in the custom shipping logic builder below. Must be manually entered there as well if you you wish to build any pricing for any custom shipping methods.</p>
         <p><b>Examples Names</b>: Local Delivery, Standard Delivery, Electronic Delivery, or any name you wish to use.</p>
         <p>The custom shipping method names can be the same or different from any real-time shipping method names. If real-time shipment method names are used, they may override the automated shipment rates, depending upon when the custom shipping logic is run, such as the AFTER setting above.</p>
     </div>
</div>
<p><br></p>

ENDOFTEXT

    if ( $sc_howmanycustomshippingmethods > 0 ) {
        while ( $howmanycustomshippingmethod_temp <
            $sc_howmanycustomshippingmethods )
        {
            my ($custom_shipping_methodname2) = q{};
            (
                $custom_shipping_methodname2,
                $sc_custom_shipping_methodname_string
            ) = split( /\|/, $sc_custom_shipping_methodname_string, 2 );
            (
                $custom_shipping_methoddescrip2,
                $sc_custom_shipping_methoddescrip_string
            ) = split( /\|/, $sc_custom_shipping_methoddescrip_string, 2 );
            my $custom_shipping_methodname = "sc_custom_shipping_methodname"
              . "$howmanycustomshippingmethod_temp";
            my $custom_shipping_methoddescrip =
                'sc_custom_shipping_methoddescrip'
              . "$howmanycustomshippingmethod_temp";

            print <<ENDOFTEXT;
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
<p><b>Method Name:</b><span style="padding-left: 25px;"></span><input name="$custom_shipping_methodname" type="text" maxlength="35" value="$custom_shipping_methodname2"></p></div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
<p><b>Name for Drop-down Lists:</b><span style="padding-left: 25px;"></span><input name="$custom_shipping_methoddescrip" type="text" maxlength="35" value="$custom_shipping_methoddescrip2"></p></div>
ENDOFTEXT
            $howmanycustomshippingmethod_temp++;
        }

    }
    else {

        print <<ENDOFTEXT;
<p>No Custom Shipping Methods Available.  Please select the number needed above. If none needed, leave blank or at 0.</p>
ENDOFTEXT

    }

    print <<ENDOFTEXT;
<p><br></p>

<h3 class="mgr-page-title"><b>Custom Shipping Logic - EZ Input</b></h3>
<p><br></p>

<p><b>Number of Shipping Logic Rows Available: &nbsp; <a data-toggle="collapse" href="#handlingCharge" aria-expanded="false" aria-controls="handlingCharge"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="sc_num_shipping_codes" type="number" size=3 maxlength="3" value="$sc_num_shipping_codes"></p>
<div class="collapse" id="handlingCharge">
     <div class="well">
         <p>If the number entered is less than the number of codes/lines entered below then any additional codes above this number will be lost!</p>
         <p>The actual custom shipping logic is created from the table entries below.</p>
         <p></p>
         <p></p>
         <p><b>Remember:</b> You may need to cut and paste the resulting shipping method names you wish to use from the code generated on the "Your Shipping Methods" tab after saving these settings (names are entered in the method and drop down list names above).</p>
         <p>See examples and more information at the <a href="http://www.agoracart.com/1community/documentation-v6.html" target="_blank">project documentation</a> for more help.</p>
     </div>
</div>
<p><br></p>

ENDOFTEXT
    display_custom_shipping_codes();
    print <<ENDOFTEXT;

<h3 class="mgr-page-title"><b>Custom Shipping Logic - Raw Code:</b></h3>
<p><br></p>

<p><textarea name="sc_custom_shipping_logic" class="form-control" rows="20" wrap="off">$sc_custom_shipping_logic</textarea></p>
<p><br></p>

</div>

<!-- End of tab 2 -->


<div class="tab-pane" id="tabs-3">

<p><br></p>
<h2 class="mgr-page-title"><b>Real-Time SBW (Ship By Weight) &amp; Ratings Selection</b></h2>
<p><br></p>

<p><b>Use the real-time SBW (Ship By Weight) module? &nbsp; <a data-toggle="collapse" href="#useSBWmod" aria-expanded="false" aria-controls="useSBWmod"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name=sc_use_SBW>
<option>$sc_use_SBW</option>
<option>yes</option>
<option>no</option>
</select></p>
<div class="collapse" id="useSBWmod">
     <div class="well">
         <p>This covers how the shipping field in each product within the database is treated for real-time shipping modules ( DHL/FedEx/UPS/USPS ).</p>
         <p>YES turns the value into a weight.</p>
         <p>If yes, then the "shipping" field in the product database is a shipping weight (instead of shipping price.)</p>
     </div>
</div>
<p><hr></p>

<p><b>Display Product ID number in box packing recommendations? &nbsp; <a data-toggle="collapse" href="#dispProdIDBoxPack" aria-expanded="false" aria-controls="dispProdIDBoxPack"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name="sc_ship_thingy_p_id_indicator_enabled">
<option>$sc_ship_thingy_p_id_indicator_enabled</option>
<option>yes</option>
<option>no</option>
</select></p>
<div class="collapse" id="dispProdIDBoxPack">
     <div class="well">
         <p>When a customer orders enough product to warrant additional boxes because they exceeded the maximum weight per box as set above, you can display the product database ID number in front of the product name of each product listed in the recommedation engine's suggested box packing or groups of items per each box -- which is a very rough guesstimate in nature.</p>
     </div>
</div>
<p><hr></p>

<p><b>Select all the shipping services you wish to display settings tabs for:</b><br>(NOTE: must save settings before they show in the tab section)</p>
<div class="row">
$mylist_of_shipping_libs
</div>



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

</div>

<!-- End of tab 3 -->

<div class="tab-pane" id="tabs-4">

<p><br></p>
<h2 class="mgr-page-title"><b>USPS - United States Postal Service</b></h2>
<p><br></p>
ENDOFTEXT

    if ( $mc_ship_display{'USPS'} eq 'yes' ) {
        &display_USPS_XML_settings_tab_content;
    }

print <<ENDOFTEXT;
<p><br></p>
</div>

<!-- End of tab 4 -->


<div class="tab-pane" id="tabs-5">
<p><br></p>
<h2 class="mgr-page-title"><b>UPS - United Parcel Service</b></h2>
<p><br></p>
ENDOFTEXT

    if ( $mc_ship_display{'UPS_XMLrate'} =~ /yes/i ) {
        # UPS XML also does Malaysia, Singapore, Thailand for origination

        # unused stuff for ratechart
        # <option value="OP_WEB">Oncall Air Pickup Web (arrange on the web)
        # <option value="OP_PHONE">Oncall Air Pickup Phone (arrange by phone)

        if ( $sc_ups_dimensionalunitmeasure eq '' ) {
            $sc_ups_dimensionalunitmeasure = 'IN';
        }
        if ( $sc_ups_customerclass eq '' ) { $sc_ups_customerclass = '04'; }

        &display_UPS_XMLrate_settings_tab_content; # displays UPS XML content of this tab.

    }
    elsif ( $mc_ship_display{'UPS_legacy'} eq 'yes' ) {
        print <<ENDOFTEXT;
<b>Note:</b> <small>This UPS module is generic and will not reflect rates that you receive with a UPS account. If your profit margins allow for a little variance and you do not ship outside of the US, this is an option to use. We have noticed that the rates are close to the combination of using the UPS customer counter pickup option and forcing shipments to be a residential address.  Fuel charges are not added, which can come into play for some deliveries. You can also add a buffer as a percentage to help offset any differences. Currently we set this to add 6% to the rate reported back. Adjust as needed below. Officially we recommend that you use the "members only" UPS XMLrate version for more accurate rating services as the continued availability of this rating service is unknown.</small><br><br>

<p><b>Enable UPS Legacy? &nbsp; <a data-toggle="collapse" href="#enableUPS" aria-expanded="false" aria-controls="enableUPS"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name="sc_use_UPS">
<option>$sc_use_UPS</option>
<option>yes</option>
<option>no</option>
</select></p>
<div class="collapse" id="enableUPS">
     <div class="well">
         <p>Allows you to enable or disable this shipping method without losing your previous settings.</p>
         <p>Selecting yes or no does not change shipping options listed on order forms.</p>
     </div>
</div>
<p><hr></p>

UPS ORIGIN ZIP: <input name="sc_UPS_Origin_ZIP" type="text" SIZE=5 maxlength="5"
value="$sc_UPS_Origin_ZIP"><br>
UPS Pickup Type: <select name="sc_UPS_RateChart">
   <option value="$sc_UPS_RateChart">$sc_UPS_RateChart</option>
   <option value="Daily Pickup">Daily Pickup
   <option value="On Call Air">On Call Air
   <option value="One Time Pickup">One Time Pickup
   <option value="Letter Center">Letter Center
   <option value="Customer Counter">Customer Counter
</select><br><br>

<br><b>Select Shipping Methods that you offer:</b><br>

UPS Ground Residential: <select name=sc_upsgroundres>
<option>$sc_upsgroundres</option>
<option>yes</option>
<option>no</option>
</select><br>

UPS Ground Commercial: <select name=sc_upsgroundcomm>
<option>$sc_upsgroundcomm</option>
<option>yes</option>
<option>no</option>
</select><br>

UPS 2nd Day: <select name=sc_ups2da>
<option>$sc_ups2da</option>
<option>yes</option>
<option>no</option>
</select><br>

UPS Next Day: <select name=sc_ups1da>
<option>$sc_ups1da</option>
<option>yes</option>
<option>no</option>
</select><br>
<br><hr><br>

Adjust UPS rates up or down from the quote?<br><small>will use percentage entered below to adjust the rate of shipping up or down.  Enable if the rates differ from what you actually pay for the shipment charges. Default is yes.</small> <select name=sc_ups_non_xml_adjust>
<option>$sc_ups_non_xml_adjust</option>
<option>yes</option>
<option>no</option>
</select>
Enter Percentage to adjust by:<br><small>Will be a percentage of the shipping cost.  Can be negative to deduct from the shippign cost. Max of 7 characters can be entered.</small><br> <input name="sc_ups_non_xml_adjust_rate" type="text" SIZE=7 maxlength="7"
value="$sc_ups_non_xml_adjust_rate"><br><br>
ENDOFTEXT
    }

print <<ENDOFTEXT;
<p><br></p>
</div>

<!-- End of tab 5 -->


<div class="tab-pane" id="tabs-6">

<p><br></p>
<h2 class="mgr-page-title"><b>FedEx - Federal Express</b></h2>
<p><br></p>

ENDOFTEXT

    if ( $mc_ship_display{'FedEx'} eq 'yes' ) {
        &display_FedEx_settings_tab_content;
    }


    print <<ENDOFTEXT;

<p><br></p>
</div>

<!-- End of tab 6 -->


<div class="tab-pane" id="tabs-7">

<p><br></p>
<h2 class="mgr-page-title"><b>Ship To State/Province Lists for Your Order Forms</b></h2>
<p><br></p>

<p class="well">Below are the states/provinces you allow shipments to, for use within your order forms.<br><br><b>NOTE:</b>  New order forms will use this output. If your order form does not automatically reflect any changes, your orderforms might be from an older version or the AgoraScript code was edited out manually and you must <b>Cut and paste</b> the code below and place it into your order forms manually with the states and provinces listed below:</p>
<p><br></p>

<p><textarea name="sc_shiptostates_4forms" class="form-control" rows="20" wrap="soft">$sc_shiptostates_4forms</textarea></p>
<p><br></p>
</div>

<!-- End of tab 7 -->


<div class="tab-pane" id="tabs-8">

<p><br></p>
<h2 class="mgr-page-title"><b>Ship To Country List for Your Order Forms</b></h2>
<p><br></p>

<p class="well">Below are the countries you allow shipment to, for use in your order forms. <br><br><b>NOTE:</b>  New order forms will use this output. If your order form does not automatically reflect any changes, your orderforms might be from an older version or the AgoraScript code was edited out manually and you must <b>Cut and paste</b> the code below and place it into your order forms manually with the country list below:</p>
<p><br></p>

<p><textarea name="sc_shiptocountries_4forms" class="form-control" rows="20" wrap="soft">$sc_shiptocountries_4forms</textarea></p>
<p><br></p>
</div>

<!-- End of tab 8 -->


<div class="tab-pane" id="tabs-9">

<p><br></p>
<h2 class="mgr-page-title"><b>Shipping Methods Code Pre-Built for Your Custom Order Forms</b></h2>
<p><br></p>

<p class="well">Below are the shipping options built for use within your enabled payment gateway order forms (enable/disable within the Payment Solutions Manager). Standard order forms will use the code below by default. To update the code below, please hit the submit button when ready and the code will be re-compiled from the realtime and custom options selected on the other tabs.<br><br><b>NOTE:</b>  If your order form does not automatically reflect any changes, your order forms might be from an older version or the AgoraScript code was removed manually and you must <b>Cut and paste</b> the code below (or replace the AgoraScript code) and place it into your order forms manually:</p>
<p><br></p>

<p><textarea name="sc_shiptomethod_4forms" class="form-control" rows="25" wrap="soft">$sc_shiptomethod_4forms</textarea></p>
<p><br></p>

</div>

<!-- End of tab 9 -->

<div class="row"><p><br><br></p></div>
</div><!-- End of tab content -->

<input type="hidden" name="system_edit_success" value="yes">
<input name="ChangeShipSettings" type="hidden" value="Submit">
<button class="btn btn-primary btn-lg mgr-center" style="display: block;">Submit Shipping Updates</button>
<div class="row col-sm-12"><p><br><br><br></p></div>
</form>
ENDOFTEXT

    print &$manager_page_footer;
}

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

sub display_custom_shipping_codes {
    local ( $shipping_code, $subtotal_price, $quantity, $measured_value,
        $shipping_rate, $exp_date, $blank_comments, $prod_indicator, $prod_value );

    print <<ENDOFTEXT;
<div class="table-responsive">
<table class="table table-striped table-bordered table-condensed">
    <tr>
      <td colspan=9 align=center><b>Custom Shipping Logic Rows</b><br>
      <a href="#" onClick="MyWindow=window.open('http://www.agoracart.com/1community/documentation-v6/62-managertips/58-shipping-logic-rows.html','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=1150,height=600'); return false;" target="_new">Click Here for notes on adding a new Custom Shipping Logic Row entry</a><br><br></td>
    </tr>
    <tr>
      <th align=center><b><small>Shipping Method</small></b></th>
      <th align=center><b><small>Subtotal Price</small></b></th>
      <th align=center><b><small>Quantity Ordered</small></b></th>
      <th align=center><b><small>Measured Value (weight)</small></b></th>
      <th align=center><b><small>Product Type</small></b></th>
      <th align=center><b><small>1 Category or Multi PIDs</small></b></th>
      <th align=center><b><small>Rate<br>( % or flat )</small></b></th>
      <th align=center><b><small>Valid Dates<br>(if any)</small></b></th>
    </tr>
ENDOFTEXT
    for ( $i = 0 ; $i <= $sc_num_shipping_codes ; $i++ ) {
        ( $shipping_code, $subtotal_price, $quantity, $measured_value,
            $shipping_rate, $exp_date, $blank_comments, $prod_indicator, $prod_value )
          = split( /\|/, $sc_shipping_logic[$i] );
    print <<ENDOFTEXT;
    <tr>
      <td align=center><small>
        <input name="shipping_code_r$i" type="text" size=23 maxlength="40" value="$shipping_code"></small></td>
      <td align=center><small>
        <input name="subtotal_price_r$i" type="text" size=5 maxlength="15" value="$subtotal_price"></small></td>
      <td align=center><small>
        <input name="quantity_r$i" type="text" size=5 maxlength="15" value="$quantity"></small></td>
      <td align=center><small>
        <input name="measured_value_r$i" type="text" size=5 maxlength="15" value="$measured_value"></small></td>
      <td align=center><small><select name="p_indicator_r$i">
        <option>$prod_indicator</option><option>Category</option><option>PID</option></select></small></td>
      <td align=center><small>
        <input name="prod_valuetext_r$i" type="text" size=8 maxlength="15" value="$prod_value"></small></td>
      <td align=center><small>
        <input name="shipping_rate_r$i" type="text" size=5 maxlength="15" value="$shipping_rate"></small></td>
      <td align=center><small>
        <input name="exp_date_r$i" type="text" size=11 maxlength="40" value="$exp_date"></small></td>
    </tr>
ENDOFTEXT
    }
    print <<ENDOFTEXT;
</table>
</div>
ENDOFTEXT
    close(CODES);
}

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

1;
