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

# Contains all sub routines (functions) to edit store files with
# editors not found elsewhere.
#
# Files Edited:
#
# productPage (ppinc) Layout Templates - determines how products are layed out, and CSS/JS framework dependent.
#
# Order Forms - gateway specific by name, CSS/JS framework dependent.
#
# Headers and Footers for categories based on category name - each recognized category can have it's own header and/or footer.
#
# Product Option files - while there is a creator for simple options, advanced/complex ones need more editing control.
#
# Email Templates - controls the information within emails sent to store admin and to customers.
#
# Verify Page Templates - page shown after filling out order form so a customer can verify their info is correct.
#
# Thank You Page Templates - Last page in a checkout session after a successful payment and handoff from payment gateway.
#
# Order Viewing Templates - For use in dislaying HTML presentations of order data such as invoices, packing slips, etc. Files starting with "mgr" are used in manager areas.
#
# Store Home Pages - For use in dislaying HTML presentation on the very first page of the store. 2 files are included: .pl file with settings for the home page, and .inc for the HTML content. Must have 'homepage' in the file name.
#
#
# Files not edited:
#
# All template Files including:
# manifest, template store and manager language files, widgets, JS, CSS,
# homezone, main headers & footers for checkout and store (aka wrappers)
#
#
# Product Pages - those linked to with page=namehere.html in a link / URL
# see static HTML page editor for product pages
#
# Cartlink Pages - those linked to with cartlink=namehere.html in a link / URL
# see static HTML page editor for cartlink (menu link capable) pages

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

@cms_edit_array = ( ppinc, orderform, catwrapper, options, emailplates,
    thankstables, verifytables, orderview
);

{
    local ($modname) = 'Content_Management_file_editor';
    register_extension( $modname, 'Store File Editor', $versions{$modname} );
    register_menu( 'saveNewCMSpage', 'write_NewCMS_Store_File',
        $modname, 'Write CMS Edited Store File' );
    register_menu( 'saveHomePage', 'write_HomePage_Files',
        $modname, 'Write Edited Store Home Page Files' );
    register_menu( 'display_cms_file_editor_screen', 'display_cms_file_editor_screen',
        $modname, 'Display CMS Page to Edit' );
    register_menu( 'selectCMSpagetoEdit', 'display_cms_file_editor_screen',
        $modname, 'Submit and Display CMS Page to Edit' );
    register_menu( 'selectHomePagetoEdit', 'display_storehome_editor_screen',
        $modname, 'Submit and Display Home Page to Edit' );

    register_menu( 'select_all_cms_files_screen','select_all_cms_files_screen',
        $modname, 'Select CMS Page to Edit' );
    add_merchtools_settings_choice(
        'File Editor Misc', 'File Editor - Misc Templates &amp; Files',
        'select_all_cms_files_screen'
    );
    register_menu( 'edit_diff_cms_file', 'select_all_cms_files_screen',
        $modname, 'Edit a different CMS file link' );
    register_menu( 'selectCMSpagetoDelete', 'delete_cmsFileEditor_file',
        $modname, 'Delete - Selected CMS Editor File' );
    register_menu( 'selectCMSbackuptoRestore', 'restore_cmsFileEditor_file',
        $modname, 'Restore - Selected CMS Editor Backup or Master File' );
    register_menu( 'selectCMSpagetoCopy', 'perform_selectCMSpagetoCopy',
        $modname, 'CopySubmit Button for Display CMS Page to Edit' );
}

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

sub write_NewCMS_Store_File {

    my $new_store_file = $in{'changed_store_file'};
    my ( $old_cms_file_name_location, $new_cms_file_name_location ) = q{};
    my $temp_time = time();
    $in{'new_cms_file_name_location'} =~ /([\w\-\=\+\/\.]+)/;
    $new_cms_file_name_location = "$1";
    $in{'originalFileLocation'} =~ /([\w\-\=\+\/\.]+)/;
    $old_cms_file_name_location = "$1";
    $new_store_file =~ s/text2area/textarea/ig;
    $new_store_file =~ s/\[nbsp\]/\&nbsp\;/ig;
    $new_store_file =~ s/\r//g;           # removes ^M

    # first, create backup of file being edited, if store admin requests it each change submit
    if ( ( $in{'make_backup'} eq 'yes' ) && ( $old_cms_file_name_location eq $new_cms_file_name_location ) ) {
        my $newbackupfile = $old_cms_file_name_location;
        $newbackupfile =~ s/\.inc$//i;
        $newbackupfile =~ s/\.tpl$//i;
        $newbackupfile =~ s/\.html$//i;
        $newbackupfile =~ s/\.pl$//i;
        $newbackupfile =~ s/\.$//i;
        $newbackupfile .= '_time_' . $temp_time . '.backup';
        copy( $old_cms_file_name_location, $newbackupfile );
    }

    open( NEWCMSSTOREFILE, '>', "$new_cms_file_name_location" );
    print NEWCMSSTOREFILE $new_store_file;
    close(NEWCMSSTOREFILE);
    $in{'new_cms_file_updated'} = 'yes';
    display_cms_file_editor_screen();
}

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

sub write_HomePage_Files {

    my $myfile = q{};
    my $temp_time = time();
    my $clean_file = $in{'hp_file_to_save'};
    $clean_file =~ s/\.s?html?$/\.pl/i; # just in case .htm or html is used
    $clean_file =~ /([\w\-\_\+]+)(\.pl)/i; # untaint
    $clean_file = "$1$2";
    my $file_name = "$1";
    if ( $file_name !~ /homepage/ ) {
        $mgr_success_message = qq|Oops: Not a valid Store Home Page! we didn't recognize the file name $clean_file|;
        $in{'system_edit_success'} = '1';
        &select_all_cms_files_screen();
        exit;
    }
    my $content_file_name = $file_name . '.inc';
    my $temp2backup = "$sc_html_dir/homepage/$sc_lang_path" . "/$clean_file";
    my $newbackupfile = "$sc_html_dir/homepage/$sc_lang_path" . "/$file_name" . '_time_' . $temp_time . '.backup';
    my $content2backup = "$sc_html_dir/homepage/$sc_lang_path" . "/$content_file_name";
    my $contentbackupfile = "$sc_html_dir/homepage/$sc_lang_path" . "/$file_name" . '_contentINC_time_' . $temp_time . '.backup';

    # first, create backup of the specified Home Page files, if store admin requests it each change submit
    if ( $in{'make_backup'} eq 'yes' ) {
        copy( $temp2backup, $newbackupfile );
        copy( $content2backup, $contentbackupfile );
    }

    $myfile .= qq~\$sc_page_title = qq|$in{'sc_page_title'}|;\n~;
    $myfile .= qq~\$sc_page_meta_description = qq|$in{'sc_page_meta_description'}|;\n~;
    $myfile .= qq~\$sc_page_meta_keywords = qq|$in{'sc_page_meta_keywords'}|;\n~;
    $myfile .= qq~\$sc_page_is_active = \'yes\';\n~;
    $in{'sc_page_content'} =~ s/\[\[textarea\]\]/textarea/ig;
    $in{'sc_page_content'} =~ s/\[\[formtag\]\]/form/ig;
    $in{'sc_page_content'} =~ s/\[nbsp\]/\&nbsp\;/ig;

    $in{'sc_page_content'} =~ s/\r//g; # removes ^M
    $myfile .= q~$sc_page_content = '';\n~;
    $myfile .= qq~1;\n~;

    # update the Home Page variables file
    open( NEWCLFILE, '>', "$temp2backup" );
    print NEWCLFILE $myfile;
    close( NEWCLFILE );

    # update the Home Page contents file
    open( NEWCLCFILE, '>', "$content2backup" );
    print NEWCLCFILE $in{'sc_page_content'};
    close( NEWCLCFILE );

    $mgr_success_message = qq|Success: $temp2backup and $content2backup were both updated and saved|;
    &display_storehome_editor_screen();
}

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

sub perform_selectCMSpagetoCopy {

    my ( $temp_file_to_copy, $copy_target, $error_type, $filenameX_swap ) = q{};
    my $x = "File::Copy qw(copy);";

    foreach my $cms_edit_array (@cms_edit_array) {
        my $filenameX = 'cmsfile2edit_' . "$cms_edit_array";
        if ( $in{"$filenameX"} ) {
            $temp_file_to_copy = $in{"$filenameX"};
            $filenameX_swap = $filenameX;
        }
    }

    $temp_file_to_copy =~ /([\w\-\_\+\.\/]+)/i; # untaint
    $temp_file_to_copy = "$1";

    $copy_target = $in{"categoryForFileName"};
    $copy_target =~ /([\w\-\_\+\.\/]+)/i; # untaint
    $copy_target = "$1";

    if ( $in{'cms_editor_file_type'} eq 'prodcathead' ) {
        $copy_target = $sc_prod_cat_templates_dir . '/header-' . $copy_target . '.tpl';
        $in{'new_cms_file_name_location'} = $copy_target;
    }
    elsif ( $in{'cms_editor_file_type'} eq 'prodcatfoot' ) {
        $copy_target = $sc_prod_cat_templates_dir . '/footer-' . $copy_target . '.tpl';
        $in{'new_cms_file_name_location'} = $copy_target;
    }
    elsif ( $in{'cms_editor_file_type'} eq 'ppinc' ) {
        $copy_target = $sc_product_layouts_dir . '/' . $copy_target . '.inc';
        $in{'new_cms_file_name_location'} = $copy_target;
    }
    else {
        $error_type = 1;
    }

    eval("use $x"); # use in non-fatal way
    if ($@) {
        # just in case we can't use it, but it is a core perl module
        $mgr_success_message =  qq|Error:: $result &amp; $@|;
    }
    elsif ( !($error_type) ) {
        copy( $temp_file_to_copy, $copy_target );

        if ( -e $copy_target ) {
            $mgr_success_message = qq|Success: $temp_file_to_copy was copied to: $copy_target|;
            $in{"$filenameX_swap"} = $copy_target;
        }
        else {
            # new file does not exist - hopefully it didn't before now as well.
            $mgr_success_message = qq|Oops: Something went wrong! $temp_file_to_copy was not copied to: $copy_target|;
        }

    }
    else {
        $mgr_success_message = qq|Oops: Something went wrong! we didn't recognize $copy_target|;
    }

    &display_cms_file_editor_screen();
}

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

sub display_cms_file_editor_screen {

    print &$manager_page_header( 'Content Management - Store File Editor', '', '', '', '' );

    my ( $file_type_message, $temp_file_to_edit ) = q{};
    local $cms_editor_file_type = $in{'cms_editor_file_type'};

    # debug
    # print "\$in{'new_cms_file_updated'} = $in{'new_cms_file_updated'} <br>";
    # print "\$in{'new_cms_file_name_location'} = $in{'new_cms_file_name_location'} <br>";

    if ( $in{'new_cms_file_updated'} ne 'yes' ) {
        foreach $cms_edit_array (@cms_edit_array) {
            my $filenameX = 'cmsfile2edit_' . "$cms_edit_array";
            if ( $in{"$filenameX"} ) {
                $temp_file_to_edit = $in{"$filenameX"};
                $in{"$filenameX"} = q{};
            }
        }
    }
    else {
        $in{'new_cms_file_name_location'} =~ /([\w\-\=\+\/\.]+)/;
        $temp_file_to_edit = "$1";
    }

    $in{'new_cms_file_name_location'} = q{};

    open( CMSSTOREFILE, "<$temp_file_to_edit" );    # || die ('Could not find file') ;
    my $full_store_file;
    while (<CMSSTOREFILE>) {
        $full_store_file .= $_;
    }
    close(CMSSTOREFILE);

    $full_store_file =~ s/textarea/text2area/ig;
    $full_store_file =~ s/\&nbsp\;/\[nbsp\]/ig;

    if ( $in{'cms_editor_file_type'} eq 'ppinc' ) {
        $file_type_message = <<ENDOFTEXT;
    <p>Product Page Layouts, aka ppinc files, are files with names starting with <b>productPage</b> and ending in <b>.inc</b> (include) that control the number of products to show per row per each screen size the product/results page is being viewed on, as well as the positioning of options, images, and other attributes for each product item being displayed on the page.</p>
    <p>Select the name of the orderform you wish to edit or copy. The template name starts with <b>productPage</b> and ends with <b>.inc</b>.</p>
    <p>The default layout template is named: productPage.inc</p>
    <p>Custom / Special ppinc: Files names with a dash followed by more characters (called the ppinc name) are special or custom productPage layout templates. These special/custom versions are called by adding <i>&amp;ppinc=name</i> to the URL when you want the layout to be used. The <b>Name</b> used in the URL is the part of the file name that is between the dash (-) and the .inc in the complete file name ( example: productPage-namehere.inc ).  Search and Search2 (productPage-search.inc and productPage-search2.inc) are only two that are required.</p>
    <p>Category Name based ppinc: You can save a ppinc file as a category name and it will automatically be used when that category is displayed. The category name must be exactly as found in the database (case, capitalization, spaces, etc). Use underscore characters (_) for spaces in the category name. Make sure to keep the .inc at the end of the file name. For example, if you have a category called "Cell Phone", you would rename and save the file as "Cell_Phone.inc".</p>
ENDOFTEXT
    }
    elsif ( $in{'cms_editor_file_type'} eq 'orderform' ) {
        $file_type_message = <<ENDOFTEXT;
    <p>The orderform name starts with the gateway's name.</p>
    <p>Each order form is specifically tailored for its payment gateway, so if copying to another gateway, make sure to change the agorascript sections to match those of the new gateway.</p>
    <p>Edits / changes to order forms will only be viewable in active gateways (must be enabled in the Payment Gateway manager).</p>
ENDOFTEXT
    }
    elsif ( $in{'cms_editor_file_type'} eq 'prodcathead' ) {
        $file_type_message = <<ENDOFTEXT;
    <p>Files for product categories must be saved as <b>header-</b> and then the name of the category to be automagically used, along with the ending .tpl file extension (.tpl is short for template). Use underscores (_) for blank spaces in the category name.</p>
    <p>File name format would look like: header-Category_Name_Here.tpl</p>
    <p><i>Custom Product Category Template Headers are located in the "$sc_prod_cat_templates_dir" sub-directory of your store.</i></p>

ENDOFTEXT
    }
    elsif ( $in{'cms_editor_file_type'} eq 'prodcatfoot' ) {
        $file_type_message = <<ENDOFTEXT;
    <p>Files for product categories must be saved as <b>footer-</b> and then the name of the category to be automagically used, along with the ending .tpl file extension (.tpl is short for template). Use underscores (_) for blank spaces in the category name.</p>
    <p>File name format would look like: footer-Category_Name_Here.tpl</p>
    <p><i>Custom Product Category Template Footers are located in the "$sc_prod_cat_templates_dir" sub-directory of your store.</i></p>

ENDOFTEXT
    }
    elsif ( $in{'cms_editor_file_type'} eq 'prodoptions' ) {
        $file_type_message = <<ENDOFTEXT;
        <p>Product Option Files allow you to add choices or options to each product in the database.</p>
        <p>Option files can be reused in many products. They can also be nested and added together (advanced feature).</p>
        <p>If you need simple options that are drowpdown lists to select from, you can use the <b>Basic/Simple Options Editor</b>.</p>
        <p>If you want to use advanced option types, such as variable options, discounted options, and nested options, this is the place to create and edit those types of option files.</i></p>
        <p>Option files can be found in the "$sc_options_directory_path" sub-directory of your store.</p>
ENDOFTEXT
    }
    elsif ( $in{'cms_editor_file_type'} eq 'emailplates' ) {
        $file_type_message = <<ENDOFTEXT;
        <p>Email Templates allow you to change the information emailed to the admin and the customer.</p>
        <p>Email Templates can be found in the "$sc_emailPlates_dir" sub-directory of your store.</p>
ENDOFTEXT
    }
    elsif ( $in{'cms_editor_file_type'} eq 'verifytables' ) {
        $file_type_message = <<ENDOFTEXT;
        <p>Verify Page Templates allow you to change the information shown during checkout after order form has ben filled out - the the verify page.</p>
        <p>Verify Page Templates can be found in the "$sc_cartverifyplates_dir" sub-directory of your store.</p>
ENDOFTEXT
    }
    elsif ( $in{'cms_editor_file_type'} eq 'thankstables' ) {
        $file_type_message = <<ENDOFTEXT;
        <p>Thank You Page Templates allow you to change the information shown after a successful payment - when returned to the store/cart from the payment gateway (at the end of the checkout process).</p>
        <p>Thank You Page Templates can be found in the "$sc_thankyouplates_dir" sub-directory of your store.</p>
ENDOFTEXT
    }
    elsif ( $in{'cms_editor_file_type'} eq 'orderview' ) {
        $file_type_message = <<ENDOFTEXT;
        <p>Order Viewing Templates allow you to change the information displayed in HTML formats for things like picking slips, invoices, etc.</p>
        <p>Files starting with <b>mgr</b> are used inside manager functions.</p>
        <p>Order Viewing Templates can be found in the "$sc_orderViewing_dir" sub-directory of your store.</p>
ENDOFTEXT
    }

    print <<ENDOFTEXT;
<h1 class='mgr-page-title'>File Editor / Copier</h1>
<p><br></p>

<div class="well">
    <p>You are currently working with the store file located at:<br><em>$temp_file_to_edit</em></p>
    <p>Feel free to do any edits using this interface; or you may download the file via FTP, make changes manually and then upload the file via FTP (in text or ASCII mode).</p>
    <p class="text-center"><a href="manager.cgi?edit_diff_cms_file=yes&mgr_seshun=$in{'mgr_seshun'}"><b>Edit / Copy a Different File</b></a></p>
</div>
<p><br></p>

ENDOFTEXT



    if ( $in{'system_edit_success'} ) {
        print qq|
<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">The File has been Successfully Saved</h4>
    </div>
</div>
<p><br><br><br><br><br></p>
|;
}

if ( $mgr_success_message ) {
    print qq|
<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">$mgr_success_message</h4>
</div>
</div>
<p><br><br><br><br><br></p>
|;
}

    print <<ENDOFTEXT;

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

<div class="checkbox">
    <label>
        <input type="checkbox" name="make_backup" value="yes" aria-label="make_backup"> <b>Create backup</b> of existing file before saving changes? <i>(recommended only when massive changes made and you are not changing the name of the file).</i>
    </label>
</div>
<p><hr></p>

<p><b>Save as (location and file name here): &nbsp; <a data-toggle="collapse" href="#saveFileName" aria-expanded="false" aria-controls="saveFileName"><i class="fa fa-info-circle"></i></a></b><input name="new_cms_file_name_location" type="text" class="form-control" value="$temp_file_to_edit" maxlength="110" required></p>
<div class="collapse" id="saveFileName">
     <div class="well">
         $file_type_message
         <p>Edit function: save the file without changing anything in this form field.</p>
         <p>Copy function: rename the file to be saved (while keeping the same location).</p>
         <p>Location of file is relative to where agora.cgi resides, so do not change the path unless you know what you are doing. The path is the portion up to the last forward slash ( / ) before the actual file name.</p>
         <p>Do not enter single or double quotes, nor any other meta-characters ( <i>non-alphanumeric characters and those that you would use the "shift key" plus a key to type</i> such as \$,\#,\%,&amp;,\@,*,',",<,>,?, etc ).</p>
     </div>
 </div>
<p><br></p>

<p><textarea name="changed_store_file" class="form-control" rows="40" wrap="off">$full_store_file</textarea></p>
<p><br><br></p>

<p><br></p>

<input type="hidden" name="originalFileLocation" value="$temp_file_to_edit">
<input type="hidden" name="cms_editor_file_type" value="$cms_editor_file_type">
<input type="hidden" name="system_edit_success" value="yes">
<input type="hidden" name="saveNewCMSpage" value="Submit">
<button class="btn btn-primary btn-lg mgr-center" style="display: block;">Save File</button>

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

    print &$manager_page_footer;
}

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

sub display_storehome_editor_screen {

    print &$manager_page_header( 'Content Management - Store HomePage File Editor', '', '', '', '' );

    my ( $file_type_message, $temp_file_to_edit ) = q{};

    my $clean_file = $in{'hp_file_to_save'};
    $clean_file =~ /([\w\-\_\+]+)(\.pl)/i; # untaint
    $clean_file = "$1$2";
    my $file_name = "$1";
    if ( $file_name !~ /homepage/ ) {
        $mgr_success_message = qq|Oops: Not a valid Store Home Page! we didn't recognize the file name $clean_file|;
        $in{'system_edit_success'} = '1';
        &select_all_cms_files_screen();
        exit;
    }
    my $temp_homepage_location = "$sc_html_dir/homepage/$sc_lang_path" . "/$clean_file";
    my $temp_homepage_contents_location = "$sc_html_dir/homepage/$sc_lang_path" . "/$file_name.inc";
    my $page_tokens_list = &build_sample_token_list_for_page_editor_screens();
    $page_tokens_list .= '[nbsp] = &amp;nbsp; (a space)';
    require_supporting_libraries( __FILE__, __LINE__, "$temp_homepage_location" );

    if ( $sc_page_content eq '' ) {
        open( MYFILE, "$temp_homepage_contents_location" );
        read( MYFILE, $sc_page_content, 256000 );
        close(MYFILE);
    }

    # defaults enforced if missing
    if ( $sc_page_is_active eq '' ) {
        $sc_page_is_active = 'yes';
    }
    if ( $clrobot_noarchive_checked eq '' ) {
        $clrobot_noarchive_checked = 'checked';
    }
    if ( $clrobot_noimageindex_checked eq '' ) {
        $clrobot_noimageindex_checked = 'checked';
    }
    $sc_page_content =~ s/\<textarea/\<\[\[textarea\]\]/ig;
    $sc_page_content =~ s/\<\/textarea/\<\/\[\[textarea\]\]/ig;
    $sc_page_content =~ s/\<form/\<\[\[formtag\]\]/ig;
    $sc_page_content =~ s/\<\/form/\<\/\[\[formtag\]\]/ig;
    $sc_page_content =~ s/\&nbsp\;/\[nbsp\]/ig;


    $file_type_message = <<ENDOFTEXT;

ENDOFTEXT


    print <<ENDOFTEXT;
<h1 class='mgr-page-title'>Store Homepage Editor</h1>
<p><br></p>

<div class="well">
    <p>Home page templates allow you to change the meta tag info for the store's main page, aka the store home page.</p>
    <p>By default, the store home page template uses tokens to show all the home page widgets selected in the homepage (ZoneHome) widget manager. Widgets are edited in each individual store template.</p>
    <p>You can add more elements &amp; information to the page but it is recommended that you make custom home page widgets instead.</p>
    <p>You are currently working with the store's home page files located at:<br><em>$temp_homepage_location</em><br><em>$temp_homepage_contents_location</em></p>
    <p>Feel free to do any edits using this interface; or you may download the file via FTP, make changes manually and then upload the file via FTP (in text or ASCII mode).</p>
    <p class="text-center"><a href="manager.cgi?edit_diff_cms_file=yes&mgr_seshun=$in{'mgr_seshun'}"><b>Edit / Copy a Different File</b></a></p>
</div>
<p><br></p>

ENDOFTEXT



    if ( $in{'system_edit_success'} ) {
        print qq|
<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">The Selected Home Page has been Successfully Saved</h4>
    </div>
</div>
<p><br><br><br><br><br></p>
|;
}

if ( $mgr_success_message ) {
    print qq|
<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">$mgr_success_message</h4>
</div>
</div>
<p><br><br><br><br><br></p>
|;
}

    print <<ENDOFTEXT;

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

<div class="checkbox">
    <label>
        <input type="checkbox" name="make_backup" value="yes" aria-label="make_backup"> <b>Create backup</b> of existing file before saving changes? <i>(recommended only when massive changes made and you are not changing the name of the file).</i>
    </label>
</div>
<p><hr></p>

<p><b>Page Title: &nbsp; <a data-toggle="collapse" href="#pageTitle" aria-expanded="false" aria-controls="pageTitle"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="sc_page_title" type="text" class="form-control" maxlength="145" value="$sc_page_title"></p>
<div class="collapse" id="pageTitle">
    <div class="well">
          <p>This is the page title that shows in specific browser areas such as tabs or other areas. Also the default bookmark name used by most browsers.</p>
          <p>Do not use these special metacharacters (\$,%,&,\@) nor double quotes.</p>
    </div>
</div>
<p><hr></p>


<p><b>Description Metatag: &nbsp; <a data-toggle="collapse" href="#descriptionMeta" aria-expanded="false" aria-controls="descriptionMeta"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="sc_page_meta_description" type="text" class="form-control" maxlength="145" value="$sc_page_meta_description"></p>
<div class="collapse" id="descriptionMeta">
    <div class="well">
          <p>This is the description you wish to use for this page.</p>
          <p>Do not use these special metacharacters (\$,%,&,\@) nor double quotes.</p>
    </div>
</div>
<p><hr></p>

<p><b>Keywords Metatag: &nbsp; <a data-toggle="collapse" href="#keywordsMeta" aria-expanded="false" aria-controls="keywordsMeta"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="sc_page_meta_keywords" type="text" class="form-control" maxlength="145" value="$sc_page_meta_keywords"></p>
<div class="collapse" id="keywordsMeta">
    <div class="well">
          <p>This is the list of keywords you wish to use for this page. Separate each word or phrase with a comma.</p>
          <p>Do not use these special metacharacters (\$,%,&,\@) nor double quotes.</p>
    </div>
</div>
<p><hr></p>

<p><b>Home Page HTML Content: &nbsp; <a data-toggle="collapse" href="#HPcontent" aria-expanded="false" aria-controls="HPcontent"><i class="fa fa-info-circle"></i></a></b></p>
<div class="collapse" id="HPcontent">
  <div class="well">
  <p>This is the main content for the HTML page content. HTML code is accepted. Agorascript can be added here as well. If you need to add javascript, usually it should be placed in the your template's JS file.</p>
  <p>Your store template headers and footers will be automagically wrapped around this content.</p>
  <p>You only need to include content that is between the <b>body</b> tags, excluding any AgoraCart header or footer tokens: [[StoreHeader]] or %%StoreHeader%%</p>
  <p>DO NOT INCLUDE THE FOLLOWING HTML ELEMENTS:
        <ul>
            <li>Store Header or Footer tokens: [[StoreHeader]] or %%StoreHeader%% - otherwise you will get duplicate headers/footers.</li>
            <li>header/footer/head HTML tags: and contents in those areas.</li>
            <li>meta tags</li>
            <li>body HTML tags</li>
            <li>Javascript script calls, unless specific to the homepage. If the scripts are already in your template headers or footers, then they are already present and used.</li>
        </ul>
  </p>
  <p>USE THE FOLLOWING TOKENS FOR FORM ELEMENTS IF YOU ARE INCLUDING A NESTED FORM:
        <ul>
            <li>[[textarea]] - for the textarea tag's word for both the opening and closing tags. Example would change from: &lt;/textarea&gt; to &lt;/[[textarea]]&gt; for the closing tag.</li>
            <li>[[formtag]] - for the form tag's word for both the opening and closing tags. Example would change from: &lt;/form&gt; to &lt;/[[formtag]]&gt; for the closing tag.</li>
        </ul>
  </p>
  </div>
</div>

$page_tokens_list
<p><textarea name="sc_page_content" class="form-control" rows="40" wrap="off">$sc_page_content</textarea></p>
<p><br><br></p>

<p><br></p>

<input type="hidden" name="system_edit_success" value="yes">
<input type="hidden" name="saveHomePage" value="Submit">
<button class="btn btn-primary btn-lg mgr-center" style="display: block;">Save Home Page</button>

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

    print &$manager_page_footer;
}

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

sub delete_cmsFileEditor_file {

    local ( $temp_file_to_delete, $temp_hp_inc_file_to_delete ) = q{};

    push ( @cms_edit_array, 'homepage' );

    foreach my $cms_edit_array (@cms_edit_array) {
        my $filenameX = 'cmsfile2delete_' . "$cms_edit_array";
        if ( $in{"$filenameX"} ) {
            $temp_file_to_delete = $in{"$filenameX"};
        }
    }

    $temp_file_to_delete =~ /([\w\-\_\+\.\/]+)/i; # untaint
    $temp_file_to_delete = "$1";

    if ( $in{'cms_editor_file_type'} eq 'homepage' ) {
        $temp_hp_inc_file_to_delete = $temp_file_to_delete;
        $temp_hp_inc_file_to_delete =~ s/\.pl$/\.inc/;
        $temp_hp_inc_file_to_delete =~ s/_time_/_contentINC_time_/;
    }

    if ( $in{'double_check_delete_checked'} eq 'yes') {
        unlink $temp_file_to_delete;
        if ( ( $in{'cms_editor_file_type'} eq 'homepage' ) && ( -e $temp_hp_inc_file_to_delete ) ) {
            unlink $temp_hp_inc_file_to_delete;
        }
        $mgr_success_message = qq|$temp_file_to_delete has been successfully deleted|;
    }
    else {
        $mgr_success_message = qq|$temp_file_to_delete deletion failed|;
    }

    # set so we get some sort of confirmation on next screen
    $in{'system_edit_success'} = 1;

    select_all_cms_files_screen();

}

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

sub restore_cmsFileEditor_file {

    my ( $temp_file_to_restore, $restore_target, $restore_hp_inc_target, $temp_inc_file_to_restore, $error_type ) = q{};
    my $x = "File::Copy qw(copy);";

    push ( @cms_edit_array, 'homepage' );

    foreach my $cms_edit_array (@cms_edit_array) {
        my $filenameX = 'cmsfile2restore_' . "$cms_edit_array";
        if ( $in{"$filenameX"} ) {
            $temp_file_to_restore = $in{"$filenameX"};
        }
    }

    $temp_file_to_restore =~ /([\w\-\_\+\.\/]+)/i; # untaint
    $temp_file_to_restore = "$1";
    $restore_target = $temp_file_to_restore;

    if ( $restore_target =~ /Master\.inc$/ ) {
        $restore_target =~ s/Master\.inc$/\.inc/i;
    }
    elsif ( $restore_target =~ /_time_/ ) {
        ( $restore_target, $junk ) = split( /_time_/, $restore_target, 2 );
        if ( ( $in{'cms_editor_file_type'} eq 'ppinc' ) || ( $in{'cms_editor_file_type'} eq 'emailplates' ) || ( $in{'cms_editor_file_type'} eq 'verifytables' ) || ( $in{'cms_editor_file_type'} eq 'thankstables' ) ) {
            $restore_target .= '.inc';
        }
        elsif ( ( $in{'cms_editor_file_type'} eq 'prodcathead' ) || ( $in{'cms_editor_file_type'} eq 'prodcatfoot' ) ) {
            $restore_target .= '.tpl';
        }
        elsif ( ( $in{'cms_editor_file_type'} eq 'orderform' ) || ( $in{'cms_editor_file_type'} eq 'orderview' ) ) {
            $restore_target .= '.html';
        }
        elsif ( $in{'cms_editor_file_type'} eq 'options' ) {
            $restore_target .= '.pl';
        }
        elsif ( $in{'cms_editor_file_type'} eq 'homepage' ) {
            $restore_target .= '.pl';
            $restore_hp_inc_target = $restore_target;
            $restore_hp_inc_target =~ s/\.pl$/\.inc/;
            $temp_inc_file_to_restore = $temp_file_to_restore;
            $temp_inc_file_to_restore =~ s/_time_/_contentINC_time_/;
        }
        else {
            $error_type = 1;
        }
    }

    eval("use $x"); # use in non-fatal way
    if ($@) {
        # just in case we can't use it, but it is a core perl module
        $mgr_success_message =  qq|Error:: $result &amp; $@|;
    }
    elsif ( !($error_type) ) {
        copy( $temp_file_to_restore, $restore_target );
        if ( ( $in{'cms_editor_file_type'} eq 'homepage' ) && ( -e $temp_inc_file_to_restore ) ) {
            copy( $temp_inc_file_to_restore, $restore_hp_inc_target );
        }

        if ( -e $restore_target ) {
            $mgr_success_message = qq|Success: $temp_file_to_restore was Restored to: $restore_target|;
        }
        else {
            # new file does not exist - hopefully it didn't before now as well.
            $mgr_success_message = qq|Oops: Something went wrong! $temp_file_to_restore was not restored to: $restore_target|;
        }

    }
    else {
        $mgr_success_message = qq|Oops: Something went wrong! we didn't recognize $restore_target|;
    }

    # set so we get some sort of confirmation on next screen
    $in{'system_edit_success'} = 1;

    select_all_cms_files_screen();

}

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

sub select_all_cms_files_screen {

    my (
        $zfile, $cat_str, $orderformdir, $orderformdirbackup, $orderformdirdelete,
        $ppinctemplatesdir, $ppinctemplatesdir_default, $ppinctorestore, $ppinctodelete,
        $templateheaders, $templatefooters, $backupheaders, $backupfooters,
        $prodoptions, $prodoptionsall, $prodoptionsbackups,
        $emailtemplates, $emailtemplatesall, $emailtemplatesbackups,
        $verifytables, $verifytablesbackups, $verifytablesdelete,
        $thankstables, $thankstablesbackups, $thankstablesdelete,
        $orderviewing, $orderviewingbackups, $orderviewingdelete, $ppinctocopy,
        $homepages, $backuphomepages, $deleteHomePageBackups
    ) = q{};
    my (@myfiles, @sorted);

    local ( %db_ele, %category_list, %subcatarray );

    # incase the current template overrides the $sc_product_layouts_dir variable
    require_supporting_libraries( __FILE__, __LINE__, "$sc_template_widgets_file" );

    $sc_categorylist_only = '1';
    get_prod_db_element( $db{"product"}, *db_ele );
    foreach my $sku ( keys %db_ele ) {
        my $category = $db_ele{$sku};
        $category_list{$category} = 1;


    }
    @categories = sort( keys %category_list );
    foreach my $inx (@categories) {
        my $catname = $inx;
        $catname =~ s/\s+/_/g;
        $cat_str .= qq|<option value="$catname">$inx</option>\n|;

        if ( ( $sc_use_database_subcats =~ /yes/i ) && ( $sc_categorylist_only ne '1' ) )  {
            %subcatarray = %{ $db_ele{$inx} };
            for my $subcat ( sort keys %subcatarray ) {
                my $subcat2 = $subcat;
                $subcat2 =~ s/ \> /-grthan-/g;
                $subcat2 =~ s/\s+/-/g;
                $cat_str .= qq|<option value="$subcat2">&nbsp;&nbsp;&nbsp;subcat: $subcat</option>\n|;
            }
        }
    }
    $sc_categorylist_only = q{};


    # read order forms sub-dir
    opendir( DIRTOREAD, "$sc_form_dir_path" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;
    foreach $zfile (@myfiles) {
        if ( ( ( $zfile =~ /\.htm$/i ) || ( $zfile =~ /\.html$/i ) ) && ( !( $zfile =~ /index\.htm/i ) ) ) {
            $orderformdir .= qq~<option value="$sc_form_dir_path/$zfile">$zfile</option>\n~;
            my ( $gatename, $junk ) = split(/\-orderform/, $zfile, 2 );
            if ( !( $mc_mgr_gateways_enabled =~ /$gatename/ ) && ( !( $zfile =~ /^combo\-orderform\.html$/i ) ) && ( !( $zfile =~ /^Donation/i && $zfile =~ /\-orderform\.html$/i ) ) ) {
                $orderformdirdelete .= qq~<option value="$sc_form_dir_path/$zfile">$zfile</option>\n~;
            }
        }
        if ( ( ( $zfile =~ /\.backup$/i ) || ( $zfile =~ /orderform$/i ) ) && ( $zfile =~ /_time_/i ) ) {
            $orderformdirbackup .= qq~<option value="$sc_form_dir_path/$zfile">$zfile</option>\n~;
            $orderformdirdelete .= qq~<option value="$sc_form_dir_path/$zfile">$zfile</option>\n~;
        }
    }

    # read PPINC sub-dir
    opendir( DIRTOREAD, "$sc_product_layouts_dir" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;
    foreach $zfile (@myfiles) {
        if ( ( $zfile =~ /\.inc$/i ) && ( ( $zfile =~ /^productPage/i ) || ( $zfile =~ /^donationproductPage/i ) ) && ( $zfile !~ /Master\.inc$/i ) ) {
            $ppinctemplatesdir .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            $ppinctocopy .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            if ( ( $zfile !~ /search\.inc$/i ) && ( $zfile !~ /search2\.inc$/i ) && ( $zfile !~ /^productPage\.inc$/i ) && ( $zfile !~ /^donationproductPage\.inc$/i ) ) {
                $ppinctodelete .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            }
        }
        elsif ( ( $zfile =~ /Master\.inc$/i ) && ( $zfile =~ /productPage/i ) ) {
            $ppinctemplatesdir_default .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            $ppinctorestore .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            $ppinctocopy .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
        }
        elsif ( ( $zfile =~ /\.inc$/i ) && ( ( $zfile !~ /$sc_lang_path\.inc/i )
            && ( $zfile !~ /$sc_lang_path\-mgr\_lang\.inc/i )
            && ( $zfile !~ /template\_homezone\.inc/i )
            && ( $zfile !~ /template\_manifest\.inc/i )
            && ( $zfile !~ /template\_widgets\.inc/i )
            ) ) {
            $ppinctemplatesdir .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            $ppinctocopy .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            $ppinctodelete .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
        }
        elsif ( ( $zfile =~ /_time_/i ) && ( $zfile =~ /^productPage/i ) && ( $zfile =~ /\.backup$/i ) ) {
            $ppinctodelete .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            $ppinctorestore .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
        }
    }

    # read PPINC default sub-dir; only if template is controlling the ppinc location variable.
    if ( $sc_product_layouts_dir ne $sc_product_layouts_dir_standard ) {

        opendir( DIRTOREAD, "$sc_product_layouts_dir_standard" );
        @myfiles = readdir(DIRTOREAD);
        closedir(DIRTOREAD);
        @sorted = sort { lc($a) cmp lc($b) } @myfiles;
        @myfiles = @sorted;
        foreach $zfile (@myfiles) {
            if ( ( $zfile =~ /\.inc$/i ) && ( $zfile =~ /^productPage/i ) && ( $zfile !~ /Master\.inc$/i ) ) {
                $ppinctemplatesdir_default .=
                  qq~<option value="$sc_product_layouts_dir_standard/$zfile">$zfile</option>\n~;
            }
            elsif ( ( $zfile =~ /Master\.inc$/i ) && ( $zfile =~ /^productPage/i ) ) {
                $ppinctemplatesdir_default .=
                  qq~<option value="$sc_product_layouts_dir_standard/$zfile">$zfile</option>\n~;
                  $ppinctorestore .= qq~<option value="$sc_product_layouts_dir_standard/$zfile">$zfile</option>\n~;
            }
            elsif ( $zfile =~ /\.inc$/i ) {
                $ppinctemplatesdir_default  .=
                  qq~<option value="$sc_product_layouts_dir_standard/$zfile">$zfile</option>\n~;
            }
            elsif ( ( $zfile =~ /_time_/i ) && ( $zfile =~ /^productPage/i ) && ( $zfile =~ /\.backup$/i ) ) {
                $ppinctodelete .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
                $ppinctorestore .= qq~<option value="$sc_product_layouts_dir/$zfile">$zfile</option>\n~;
            }
        }

    }


    # read options sub-dir
    opendir( DIRTOREAD, "$sc_options_directory_path" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;
    foreach $zfile (@myfiles) {
        if ( ( ( $zfile =~ /\.htm$/i ) || ( $zfile =~ /\.html$/i ) ) && ( !( $zfile =~ /^index\.htm/i ) && ( !( $zfile =~ /^blank\.htm/i ) ) ) ) {
            $prodoptions .= qq~<option value="$sc_options_directory_path/$zfile">$zfile</option>\n~;
            $prodoptionsall .= qq~<option value="$sc_options_directory_path/$zfile">$zfile</option>\n~;
        }
        elsif ( $zfile =~ /\.backup$/i ) {
            $prodoptionsbackups .= qq~<option value="$sc_options_directory_path/$zfile">$zfile</option>\n~;
            $prodoptionsall .= qq~<option value="$sc_options_directory_path/$zfile">$zfile</option>\n~;
        }
    }

    # Read current template directory for custom product category headers and footers
    opendir( DIRTOREAD, "$sc_prod_cat_templates_dir" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;

    foreach $zfile (@myfiles) {
        if ( ( $zfile =~ /\.tpl$/i ) && ( $zfile =~ /^header-/i ) ) {
            $templateheaders .= qq~<option value="$sc_prod_cat_templates_dir/$zfile">$zfile</option>\n~;
        }
        elsif ( ( $zfile =~ /\.tpl$/i ) && ( $zfile =~ /^footer-/i ) ) {
            $templatefooters .= qq~<option value="$sc_prod_cat_templates_dir/$zfile">$zfile</option>\n~;
        }
        elsif ( ( $zfile =~ /\.backup$/i ) && ( $zfile =~ /^footer-/i ) ) {
            $backupfooters = qq~<option value="$sc_prod_cat_templates_dir/$zfile">$zfile</option>\n~;
        }
        elsif ( ( $zfile =~ /\.backup$/i ) && ( $zfile =~ /^header-/i ) ) {
            $backupheaders = qq~<option value="$sc_prod_cat_templates_dir/$zfile">$zfile</option>\n~;
        }
    }


    # Read current home page directory
    opendir( DIRTOREAD, "$sc_html_dir/homepage/$sc_lang_path" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;
    foreach $zfile (@myfiles) {
        if ( $zfile =~ /homepage\.pl$/i ) {
            $homepages .= qq~<option value="$sc_html_dir/homepage/$sc_lang_path/$zfile">$zfile</option>\n~;
        }
        elsif ( ( $zfile =~ /\.backup$/i ) && ( $zfile =~ /homepage_time_/ ) ) {
            $backuphomepages .= qq~<option value="$sc_html_dir/homepage/$sc_lang_path/$zfile">$zfile</option>\n~;
            $deleteHomePageBackups .= qq~<option value="$sc_html_dir/homepage/$sc_lang_path/$zfile">$zfile</option>\n~;
        }
    }


    # read emailPlates sub-dir
    opendir( DIRTOREAD, "$sc_emailPlates_dir" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;
    foreach $zfile (@myfiles) {
        if ( $zfile =~ /\.inc$/i ) {
            $emailtemplates .= qq~<option value="$sc_emailPlates_dir/$zfile">$zfile</option>\n~;

            if ( $zfile !~ /_default01\.inc$/i ) {
                $emailtemplatesall .= qq~<option value="$sc_emailPlates_dir/$zfile">$zfile</option>\n~;
            }

        }
        if ( $zfile =~ /\.backup$/i ) {
            $emailtemplatesbackups .= qq~<option value="$sc_emailPlates_dir/$zfile">$zfile</option>\n~;
        }
    }

    # read verify page templates sub-dir
    opendir( DIRTOREAD, "$sc_cartverifyplates_dir" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;
    foreach $zfile (@myfiles) {
        if ( ( $zfile =~ /\.inc$/i ) && ( $zfile =~ /^verifyTable/i ) ) {
            $verifytables .= qq~<option value="$sc_cartverifyplates_dir/$zfile">$zfile</option>\n~;
            # screen for gatway specific Files
            if ( ( $zfile !~ /PayPalBasic\.inc$/i ) && ( $zfile !~ /PayPalIPN\.inc$/i ) && ( $zfile !~ /Offline\.inc$/i ) && ( $zfile !~ /standard.inc$/i ) && ( $zfile !~ /basic1\.inc$/i ) ) {
                $verifytablesdelete .= qq~<option value="$sc_cartverifyplates_dir/$zfile">$zfile</option>\n~;
            }
        }
        elsif ( ( $zfile =~ /\.backup$/i ) && ( $zfile =~ /^verifyTable/i ) ) {
            $verifytablesbackups .= qq~<option value="$sc_cartverifyplates_dir/$zfile">$zfile</option>\n~;
            $verifytablesdelete .= qq~<option value="$sc_cartverifyplates_dir/$zfile">$zfile</option>\n~;
        }
    }

    # read thankyou page templates sub-dir
    opendir( DIRTOREAD, "$sc_thankyouplates_dir" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;
    foreach $zfile (@myfiles) {
        if ( ( $zfile =~ /\.inc$/i ) && ( $zfile =~ /^thanksTable/i ) ) {
            $thankstables .= qq~<option value="$sc_thankyouplates_dir/$zfile">$zfile</option>\n~;
            if ( ( $zfile !~ /PayPalBasic\.inc$/i ) && ( $zfile !~ /PayPalIPN\.inc$/i ) && ( $zfile !~ /Offline\.inc$/i ) && ( $zfile !~ /basicbarebones\.inc$/i ) && ( $zfile !~ /basic1\.inc$/i ) ) {
                $thankstablesdelete .= qq~<option value="$sc_thankyouplates_dir/$zfile">$zfile</option>\n~;
            }

        }
        elsif ( ( $zfile =~ /\.backup$/i ) && ( $zfile =~ /^thanksTable/i ) ) {
            $thankstablesbackups .= qq~<option value="$sc_thankyouplates_dir/$zfile">$zfile</option>\n~;
            $thankstablesdelete .= qq~<option value="$sc_thankyouplates_dir/$zfile">$zfile</option>\n~;
        }
    }

    # read order viewing sub-dir - invoices, packing slips, etc
    opendir( DIRTOREAD, "$sc_orderViewing_dir" );
    @myfiles = readdir(DIRTOREAD);
    closedir(DIRTOREAD);
    @sorted = sort { lc($a) cmp lc($b) } @myfiles;
    @myfiles = @sorted;
    foreach $zfile (@myfiles) {
        if ( ( $zfile =~ /\.html$/i ) && ( $zfile !~ /^index\.html$/i ) ) {
            $orderviewing .= qq~<option value="$sc_orderViewing_dir/$zfile">$zfile</option>\n~;
            if ( ( $zfile !~ /^mgrinvoiceTemplate\.html$/i ) && ( $zfile !~ /^mgrinvoiceTemplate\-all\.html$/i ) && ( $zfile !~ /^mgrpackingslipTemplate\.html$/i ) && ( $zfile !~ /^mgrpackingslipTemplate\-all\.html$/i ) ) {
                $orderviewingdelete .= qq~<option value="$sc_orderViewing_dir/$zfile">$zfile</option>\n~;
            }

        }
        elsif ( ( $zfile =~ /\.backup$/i ) && ( $zfile =~ /_time_/i ) ) {
            $orderviewingbackups .= qq~<option value="$sc_orderViewing_dir/$zfile">$zfile</option>\n~;
            $orderviewingdelete .= qq~<option value="$sc_orderViewing_dir/$zfile">$zfile</option>\n~;
        }
    }


    # Start to output mgr screen page

    print &$manager_page_header( 'Select Store File / Template to Edit or Copy', '', '', '', '' );

    print <<ENDOFTEXT;

<h1 class='mgr-page-title'>Store File Editor / Manager</h1>
<p><br></p>

<p class="well">Use the tabs below to select the file type you wish to edit, copy or delete.</p>
<p><br></p>

ENDOFTEXT

    if ( $in{'system_edit_success'} ) {
        print qq|
<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">$mgr_success_message</h4>
    </div>
</div>
<p><br><br><br><br><br></p>
|;
    }

    print <<ENDOFTEXT;


<ul class="nav nav-tabs" id="tabs2" role="tablist">
    <li role="presentation" class="active"><a href="#tabs-1" aria-controls="tabs-1" role="tab" data-toggle="tab">Order Forms</a></li>
    <li role="presentation"><a href="#tabs-6" aria-controls="tabs-6" role="tab" data-toggle="tab">Product Option Files</a></li>
    <li role="presentation"><a href="#tabs-3" aria-controls="tabs-3" role="tab" data-toggle="tab">productPage Layouts - PPINC</a></li>
    <li role="presentation"><a href="#tabs-4" aria-controls="tabs-4" role="tab" data-toggle="tab">Custom Headers</a></li>
    <li role="presentation"><a href="#tabs-5" aria-controls="tabs-5" role="tab" data-toggle="tab">Custom Footers</a></li>
    <li role="presentation"><a href="#tabs-8" aria-controls="tabs-8" role="tab" data-toggle="tab">Email Templates</a></li>
    <li role="presentation"><a href="#tabs-9" aria-controls="tabs-9" role="tab" data-toggle="tab">Verify Page Templates</a></li>
    <li role="presentation"><a href="#tabs-10" aria-controls="tabs-10" role="tab" data-toggle="tab">Thankyou Page Templates</a></li>
    <li role="presentation"><a href="#tabs-11" aria-controls="tabs-11" role="tab" data-toggle="tab">Store Home Page</a></li>
    <li role="presentation"><a href="#tabs-13" aria-controls="tabs-13" role="tab" data-toggle="tab">Invoice / Packing Slip</a></li>
</ul>


<div class="tab-content">

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

<p><br></p>
<h2 class="mgr-page-title"><b>Order Forms</b></h2>
<p><br></p>

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

<div class="well">
    <p>These are the actual order forms used at checkout, each unique to the payment gateway it serves.</p>
    <p><i>The order forms are found in the "$sc_form_dir_path" sub-directory of your store.</i></p>
    <p>If you accidentally deleted a required order form or portion of a form for any of your active gateways, you can re-install the default order form via the payment gateway upgrader inside the Upgrade Manager. From inside the <b>Store Settings</b> area, click on the <b>Ugrade Your Store Software</b> button to access the manager.</p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy Payment Gateway Order Forms</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

<p><b>Select file to Edit / Copy: &nbsp; <a data-toggle="collapse" href="#gatewayOrderForms" aria-expanded="false" aria-controls="gatewayOrderForms"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_orderform">
<option></option>
$orderformdir
</select></p>
<div class="collapse" id="gatewayOrderForms">
    <div class="well">
        <p>Select the name of the order form you wish to edit or copy. The orderform name starts with the gateway's name.</p>
        <p>Changes to order forms will only be viewable / reachable for active gateways.</p>
        <p>Edit function: you can edit the selected order form on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected order form on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="orderform">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit/Copy Selected Order Form</button>
</form>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete Related Payment Gateway Order Files</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>


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

<p><b>Select file to delete &nbsp; <a data-toggle="collapse" href="#gatewayOrderFormsDelete" aria-expanded="false" aria-controls="gatewayOrderFormsDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_orderform">
<option></option>
$orderformdirdelete
</select></p>
<div class="collapse" id="gatewayOrderFormsDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete. All files start with the gateway's name.</p>
        <p>Once deleted, order forms can be restored from backups (if any) or re-installed from the payment gateway screen of the <b>Upgrade Your Store Software</b> manager.</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Order Form File</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore a Payment Gateway Order Form</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>


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

<p><b>Select backup to restore: &nbsp; <a data-toggle="collapse" href="#gatewayOrderFormBackups" aria-expanded="false" aria-controls="gatewayOrderFormBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_orderform">
<option></option>
$orderformdirbackup
</select></p>
<div class="collapse" id="gatewayOrderFormBackups">
    <div class="well">
        <p>Select the name of the order form backup you wish to restore. The backup for the orderform name starts with the gateway's name.</p>
        <p>The restore will completely overwrite the existing order form and any changes made to it.</p>
        <p>If no backup files are listed, that means none were created when you did previous edits</p>
        <p>No backups are created in this process. You can re-install a gateway's order form from the payment gateway screen of the: upgrade store software manager.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="orderform">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Order Form Backup</button>
</form>
<p><br><br></p>

</div>


<!-- End of tab 1 -->


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

<p><br></p>
<h2 class="mgr-page-title"><b>Product Page Layouts - PPINC</b></h2>
<p><br></p>

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

<div class="well">
    <p>Product Page Layouts, aka <b>ppinc</b> files, are files with names starting with <b>productPage</b> and ending in <b>.inc</b> (aka include file) that control the how products are shown for each screen size in the product category or search results pages, including the positioning of options, images, and other attributes for each product item being displayed on the page. </p>
    <p><i>Product Page Layouts your currently selected template uses are found in the "$sc_product_layouts_dir" sub-directory of your store.</i></p>
ENDOFTEXT

if ( $sc_product_layouts_dir ne $sc_product_layouts_dir_standard ) {
print <<ENDOFTEXT;
    <p><i>Your currently selected template controls the location of Product Page Layouts, but the default Product Page Layouts for your CSS/JS platform can also be found in the "$sc_product_layouts_dir_standard" sub-directory of your store. However these files are not used by your currently selected template and are available for your reference only.</i></p>
ENDOFTEXT
}

print <<ENDOFTEXT;
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy productPage (ppinc) Layout Templates</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

<p><b>Select file to Edit/Copy: &nbsp; <a data-toggle="collapse" href="#ppincFiles" aria-expanded="false" aria-controls="ppincFiles"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_ppinc">
<option></option>
$ppinctemplatesdir
ENDOFTEXT

if ( ( $ppinctemplatesdir_default ) && ( $sc_product_layouts_dir ne $sc_product_layouts_dir_standard ) ) {
    print <<ENDOFTEXT;
<option></option>
<option></option>
<option value=''>DEFAULT PPINCs - Not Used by Your Template</option>
<option></option>
$ppinctemplatesdir_default
ENDOFTEXT
}

print <<ENDOFTEXT;
</select></p>
<div class="collapse" id="ppincFiles">
    <div class="well">
        <p>Product Page Layouts, aka ppinc files, are files with names starting with <b>productPage</b> and ending in <b>.inc</b> (include) that control the number of products to show per row per each screen size the product/results page is being viewed on, as well as the positioning of options, images, and other attributes for each product item being displayed on the page.</p>
        <p>Select the name of the orderform you wish to edit or copy. The template name starts with <b>productPage</b> and ends with <b>.inc</b>.</p>
        <p>The default layout template is named: productPage.inc</p>
        <p>Custom / Special ppinc: Files names with a dash followed by more characters (called the ppinc name) are special or custom productPage layout templates. These special/custom versions are called by adding <i>&amp;ppinc=name</i> to the URL when you want the layout to be used. The <b>Name</b> used in the URL is the part of the file name that is between the dash (-) and the .inc in the complete file name.  Search and Search2 (productPage-search.inc and productPage-search2.inc) are only two that are required.</p>
        <p>Edit function: you can edit the selected productPage layout template on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected productPage layout template on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>

ENDOFTEXT

if ( $sc_product_layouts_dir ne $sc_product_layouts_dir_standard ) {
    print <<ENDOFTEXT;
<input name="PPINCnotDefault" type="hidden" value="yes">
ENDOFTEXT
}

print <<ENDOFTEXT;
<input type="hidden" name="cms_editor_file_type" value="ppinc">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit/Copy Selected PPINC File</button>
</form>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Copy / Add Custom Category Header</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

<form class="form-horizontal" action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<p><b>Copy / Add a Category Name Based PPINC File: &nbsp; <a data-toggle="collapse" href="#copyppinc" aria-expanded="false" aria-controls="copyppinc"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_ppinc" required>
    <option></option>
    $ppinctocopy
ENDOFTEXT

    if ( $sc_product_layouts_dir ne $sc_product_layouts_dir_standard ) {
        print <<ENDOFTEXT;
        <option></option>
        <option></option>
        <option value=''>DEFAULT PPINCs - Not Used by Your Template</option>
        <option></option>
        $ppinctemplatesdir_default
ENDOFTEXT
    }

    print <<ENDOFTEXT;
    </select>
<div class="collapse" id="copyppinc">
    <div class="well">
        <p>Select the name of the PPINC File you wish to copy. Then select the product category you wish to apply it to.</p>
        <p>Once it is copied, you may edit it.
    </div>
</div>
<p><b>Choose Product Category Name:</b> <span style="padding-left: 25px;"></span><select name="categoryForFileName" required>
    <option></option>
    $cat_str
</select></p>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="ppinc">
<input type="hidden" name="selectCMSpagetoCopy" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Copy Selected PPINC File</button>
</form>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete productPage (ppinc) Related Files</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to delete: &nbsp; <a data-toggle="collapse" href="#ppincDelete" aria-expanded="false" aria-controls="ppincDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_ppinc">
<option></option>
$ppinctodelete
</select></p>
<div class="collapse" id="ppincDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete. All files start with the gateway's name.</p>
        <p>If deleted, productPage Layout Templates can be re-created by pasting code from downloaded copies (from AgoraCart.com, etc) or custom copies into a productPage fle text area while in editing/copying mode and then saving it as the missing/desired ppinc file.</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected PPINC Related File</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore a productPage (ppinc) Layout Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to restore: &nbsp; <a data-toggle="collapse" href="#ppincBackups" aria-expanded="false" aria-controls="ppincBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_ppinc">
<option></option>
$ppinctorestore
</select></p>
<div class="collapse" id="ppincBackups">
    <div class="well">
        <p>Select the name of the productPage you wish to restore.</p>
        <p>Master files are original / default copies of the productPage layout template file which are updated when the store software is updated, so it is always the latest version of the default layout template for the CSS/JS framework.</p>
        <p>The restore will completely overwrite the existing productPage and any changes made to it.</p>
        <p>No backups are created in this process.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="ppinc">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected productPage (ppinc)</button>
</form>
<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>Custom Template Header Files</b></h2>
<p><br></p>

<div class="well">
    <p>Custom Template Headers allow you to change the header portion of the main store template (aka wrapper) for a specific category or static HTML page.</p>
    <p>Files must be saved as <b>header-</b> and then the name of the category (or other unique name for a static HTML page), along with the ending .tpl file extension (.tpl is short for template). Use underscores (_) for blank spaces in the category name.</p>
    <p>File name format would look like: header-Category_Name_Here.tpl</p>
    <p><i>Custom Template Headers are located in the "$sc_prod_cat_templates_dir" sub-directory of your store.</i></p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy Custom Template Header</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>
ENDOFTEXT

if ( $templateheaders ) {
    print <<ENDOFTEXT;
<form class="form-horizontal" action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<p><b>Edit / Copy a custom header: &nbsp; <a data-toggle="collapse" href="#customProductHeaders" aria-expanded="false" aria-controls="customProductHeaders"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_catwrapper">
    <option></option>
    $templateheaders
    </select></p>
<div class="collapse" id="customProductHeaders">
    <div class="well">
        <p>Select the name of the custom header template you wish to edit.</p>
        <p>Edit function: you can edit the selected header template on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected header template on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="prodcathead">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit/Copy Selected Custom Header</button>
</form>
ENDOFTEXT

}
else {
    print <<ENDOFTEXT;
<p><b>Sorry no custom headers exist yet. If you desire to create one, please copy your main store header to a recognized product category found in your product database or to a new name if a static HTML page.</b></p>
ENDOFTEXT
}

    print <<ENDOFTEXT;

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Copy / Add Custom Product Category Header</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

<form class="form-horizontal" action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<p><b>Copy / Add a Custom Product Category Header: &nbsp; <a data-toggle="collapse" href="#copyHeaders" aria-expanded="false" aria-controls="copyHeaders"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_catwrapper" required>
    <option></option>
    $templateheaders
    <option></option>
    <option value="$sc_store_header_file">Current Main Store Header</option>
    </select>
<div class="collapse" id="copyHeaders">
    <div class="well">
        <p>Select the name of the custom header template you wish to copy. Then select the product category you wish to apply it to.</p>
        <p>Once it is copied, you may edit it.
    </div>
</div>
<p><b>Choose Product Category Name:</b> <span style="padding-left: 25px;"></span><select name="categoryForFileName" required>
    <option></option>
    $cat_str
</select></p>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="prodcathead">
<input type="hidden" name="selectCMSpagetoCopy" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Copy Selected Custom Header File</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete a Custom Template Header</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to delete: &nbsp; <a data-toggle="collapse" href="#headerDelete" aria-expanded="false" aria-controls="headerDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_catwrapper">
<option></option>
$templateheaders
$backupheaders
</select></p>
<div class="collapse" id="headerDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete.</p>
        <p>If deleted, a custom header can be restored from a backup (if one exists - save the file with a backup option selected).</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="cms_editor_file_type" value="prodcathead">
<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Custom Header File</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore a Custom Template Header File</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to restore: &nbsp; <a data-toggle="collapse" href="#headerBackups" aria-expanded="false" aria-controls="headerBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_catwrapper">
<option></option>
$backupheaders
</select></p>
<div class="collapse" id="headerBackups">
    <div class="well">
        <p>Select the name of the Custom Header you wish to restore.</p>
        <p>The restore will completely overwrite the existing Custom Header and any changes made to it.</p>
        <p>No backups are created in this process.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="prodcathead">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Custom Header File</button>
</form>

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

</div>

<!-- End of tab 4 -->


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

<p><br></p>
<h2 class="mgr-page-title"><b>Custom Product Category Footer Files</b></h2>
<p><br></p>

<div class="well">
    <p>Custom Template Footers allow you to change the footer portion of the main store template (aka wrapper) for a specific category or specific static HTML page.</p>
    <p>Files for custom footers must be saved as <b>footer-</b> and then the name of the product category (exactly) or another name if a static HTML page , along with the ending .tpl file extension (.tpl is short for template). Use underscores (_) for blank spaces in the category name.</p>
    <p>File name format would look like: footer-Category_Name_Here.tpl</p>
    <p><i>Custom Template Footers are located in the "$sc_prod_cat_templates_dir" sub-directory of your store.</i></p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy Custom Footer</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>
ENDOFTEXT



if ( $templatefooters ) {
    print <<ENDOFTEXT;
<form class="form-horizontal" action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">

<p><b>Edit / Copy a custom product category footer: &nbsp; <a data-toggle="collapse" href="#customProductFooters" aria-expanded="false" aria-controls="customProductFooters"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_catwrapper">
    <option></option>
    $templatefooters
    </select></p>
<div class="collapse" id="customProductFooters">
    <div class="well">
        <p>Select the name of the custom footer template you wish to edit or copy.</p>
        <p>Edit function: you can edit the selected product footer template on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected product footer template on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="prodcatfoot">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit Selected Custom Footer File</button>
</form>
ENDOFTEXT

}
else {
    print <<ENDOFTEXT;
<p><b>Sorry no custom footers exist yet. If you desire to create one, please copy your main store footer to a recognized product category found in your product database.</b></p>
ENDOFTEXT
}

    print <<ENDOFTEXT;
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Copy / Add Custom Product Category Footer</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

<form class="form-horizontal" action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<p><b>Copy / Add a Custom Product Category Footer: &nbsp; <a data-toggle="collapse" href="#copyFooters" aria-expanded="false" aria-controls="copyFooters"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_catwrapper" required>
    <option></option>
    $templatefooters
    <option></option>
    <option value="$sc_store_footer_file">Current Main Store Footer</option>
    </select>
<div class="collapse" id="copyFooters">
    <div class="well">
        <p>Select the name of the custom footer template you wish to copy. Then select the product category you wish to apply it to.</p>
        <p>Once it is copied, you may edit it.
    </div>
</div>
<p><b>Choose Product Category Name:</b> <span style="padding-left: 25px;"></span><select name="categoryForFileName" required>
    <option></option>
    $cat_str
</select></p>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="prodcatfoot">
<input type="hidden" name="selectCMSpagetoCopy" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Copy Selected Custom Footer</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete a Custom Footer</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to delete: &nbsp; <a data-toggle="collapse" href="#footerDelete" aria-expanded="false" aria-controls="footerDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_catwrapper">
<option></option>
$templatefooters
$backupfooters
</select></p>
<div class="collapse" id="footerDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete.</p>
        <p>If deleted, a custom footer can be restored from a backup (if one exists - save the file with a backup option selected).</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="cms_editor_file_type" value="prodcatfoot">
<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Custom Footer File</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore a Custom Footer File</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to restore: &nbsp; <a data-toggle="collapse" href="#footerBackups" aria-expanded="false" aria-controls="footerBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_catwrapper">
<option></option>
$backupfooters
</select></p>
<div class="collapse" id="footerBackups">
    <div class="well">
        <p>Select the name of the Custom Footer you wish to restore.</p>
        <p>The restore will completely overwrite the existing Custom Footer file with the same base name and any changes made to it.</p>
        <p>No backups are created in this process.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="prodcatfoot">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Custom Footer</button>
</form>


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

</div>

<!-- End of tab 5 -->


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

<p><br></p>
<h2 class="mgr-page-title"><b>Product Option Files</b></h2>
<p><br></p>

<div class="well">
    <p>Product Option Files allow you to add choices or options to each product in the database.</p>
    <p>Option files can be reused in many products. They can also be nested and added together (advanced feature).</p>
    <p>If you need simple options that are drowpdown lists to select from, you can use the <b>Basic/Simple Options Editor</b>.</p>
    <p>If you want to use advanced option types, such as variable options, discounted options, and nested options, this is the place to create and edit those types of option files.</i></p>
    <p>Option files can be found in the "$sc_options_directory_path" sub-directory of your store.</p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy Product Option Files</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Edit / Copy a Products Option File: &nbsp; <a data-toggle="collapse" href="#editProdOptions" aria-expanded="false" aria-controls="editProdOptions"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_options">
    <option></option>
    $prodoptions
    </select></p>
<div class="collapse" id="editProdOptions">
    <div class="well">
        <p>Select the name of the product options file you wish to edit or copy.</p>
        <p>Edit function: you can edit the selected product options file on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected product options file on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="prodoptions">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit / Copy Selected Product Options File</button>
</form>



<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete a Product Options File</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to delete: &nbsp; <a data-toggle="collapse" href="#optionsDelete" aria-expanded="false" aria-controls="optionsDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_options">
<option></option>
$prodoptionsall
</select></p>
<div class="collapse" id="optionsDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete.</p>
        <p>If deleted, a Product Options File can be restored from a backup (if one exists - save the file with a backup option selected).</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="cms_editor_file_type" value="prodoptions">
<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Product Options File</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore a Product Options File</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to restore: &nbsp; <a data-toggle="collapse" href="#prodopBackups" aria-expanded="false" aria-controls="prodopBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_options">
<option></option>
$prodoptionsbackups
</select></p>
<div class="collapse" id="prodopBackups">
    <div class="well">
        <p>Select the name of the Product Options File you wish to restore.</p>
        <p>The restore will completely overwrite the existing Product Options File and any changes made to it.</p>
        <p>No backups are created in this process.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="prodoptions">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Product Options File</button>
</form>

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


</div>


<!-- End of tab 6 -->


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

<p><br></p>
<h2 class="mgr-page-title"><b>Email Templates</b></h2>
<p><br></p>

<div class="well">
    <p>Email Templates allow you to change the information emailed to the admin and the customer.</p>
    <p>Email Templates can be found in the "$sc_emailPlates_dir" sub-directory of your store.</p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy Email Template Files</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Edit / Copy a Email Template: &nbsp; <a data-toggle="collapse" href="#editEmailPlates" aria-expanded="false" aria-controls="editEmailPlates"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_emailplates">
    <option></option>
    $emailtemplates
    </select></p>
<div class="collapse" id="editEmailPlates">
    <div class="well">
        <p>Select the name of the Email Template you wish to edit or copy.</p>
        <p>Edit function: you can edit the selected Email Template on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected Email Template on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="emailplates">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit / Copy Selected Email Template</button>
</form>



<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete an Email Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to delete: &nbsp; <a data-toggle="collapse" href="#emailDelete" aria-expanded="false" aria-controls="emailDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_emailplates">
<option></option>
$emailtemplatesall
</select></p>
<div class="collapse" id="emailDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete.</p>
        <p>If deleted, a Email Template can be restored from a backup (if one exists - save the file with a backup option selected).</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="cms_editor_file_type" value="emailplates">
<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Email Template</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore an Email Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to restore: &nbsp; <a data-toggle="collapse" href="#emailBackups" aria-expanded="false" aria-controls="emailBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_emailplates">
<option></option>
$emailtemplatesbackups
</select></p>
<div class="collapse" id="emailBackups">
    <div class="well">
        <p>Select the name of the Email Template you wish to restore.</p>
        <p>The restore will completely overwrite the existing Email Template and any changes made to it.</p>
        <p>No backups are created in this process.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="emailplates">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Email Template</button>
</form>

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


	   </div>

<!-- End of tab 8 -->


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

<p><br></p>
<h2 class="mgr-page-title"><b>Verify Page Templates</b></h2>
<p><br></p>

<div class="well">
    <p>Verify Page Templates allow you to change the information shown during checkout after order form has ben filled out - the the verify page.</p>
    <p>Verify Page Templates can be found in the "$sc_cartverifyplates_dir" sub-directory of your store.</p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy a Verify Page Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Edit / Copy a Verify Page Template: &nbsp; <a data-toggle="collapse" href="#editVerify" aria-expanded="false" aria-controls="editVerify"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_verifytables">
    <option></option>
    $verifytables
    </select></p>
<div class="collapse" id="editVerify">
    <div class="well">
        <p>Select the name of the Verify Page Template you wish to edit or copy.</p>
        <p>Edit function: you can edit the selected Verify Page Template on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected Verify Page Template on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="verifytables">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit / Copy Selected Verify Page Template</button>
</form>



<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete a Verify Page Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to delete: &nbsp; <a data-toggle="collapse" href="#verifyDelete" aria-expanded="false" aria-controls="verifyDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_verifytables">
<option></option>
$verifytablesdelete
</select></p>
<div class="collapse" id="verifyDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete.</p>
        <p>If deleted, a Verify Page Template can be restored from a backup (if one exists - save the file with a backup option selected).</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="cms_editor_file_type" value="verifytables">
<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Verify Page Template</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore a Verify Page Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to restore: &nbsp; <a data-toggle="collapse" href="#verifyBackups" aria-expanded="false" aria-controls="verifyBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_verifytables">
<option></option>
$verifytablesbackups
</select></p>
<div class="collapse" id="verifyBackups">
    <div class="well">
        <p>Select the name of the Verify Page Template you wish to restore.</p>
        <p>The restore will completely overwrite the existing Verify Page Template and any changes made to it.</p>
        <p>No backups are created in this process.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="verifytables">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Verify Page Template</button>
</form>

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



	   </div>


<!-- End of tab 9 -->


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

<p><br></p>
<h2 class="mgr-page-title"><b>Thank You Page Templates</b></h2>
<p><br></p>

<div class="well">
    <p>Thank You Page Templates allow you to change the information shown after a successful payment - when returned to the store/cart from the payment gateway (at the end of the checkout process).</p>
    <p>Thank You Page Templates can be found in the "$sc_thankyouplates_dir" sub-directory of your store.</p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy a Thank You Page Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Edit / Copy a Thank You Page Template: &nbsp; <a data-toggle="collapse" href="#editThanks" aria-expanded="false" aria-controls="editThanks"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_thankstables">
    <option></option>
    $thankstables
    </select></p>
<div class="collapse" id="editThanks">
    <div class="well">
        <p>Select the name of the Thank You Page Template you wish to edit or copy.</p>
        <p>Edit function: you can edit the selected Thank You Page Template on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected Thank You Page Template on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="thankstables">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit / Copy Selected Thank You Page Template</button>
</form>



<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete a Thank You Page Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to delete: &nbsp; <a data-toggle="collapse" href="#thanksDelete" aria-expanded="false" aria-controls="thanksDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_thankstables">
<option></option>
$thankstablesdelete
</select></p>
<div class="collapse" id="thanksDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete.</p>
        <p>If deleted, a Thank You Page Template can be restored from a backup (if one exists - save the file with a backup option selected).</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="cms_editor_file_type" value="thankstables">
<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Thank You Page Template</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore a Thank You Page Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to restore: &nbsp; <a data-toggle="collapse" href="#thanksBackups" aria-expanded="false" aria-controls="thanksBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_thankstables">
<option></option>
$thankstablesbackups
</select></p>
<div class="collapse" id="thanksBackups">
    <div class="well">
        <p>Select the name of the Thank You Page Template you wish to restore.</p>
        <p>The restore will completely overwrite the existing Thank You Page Template and any changes made to it.</p>
        <p>No backups are created in this process.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="thankstables">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Thank You Page Template</button>
</form>

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



	</div>


<!-- End of tab 10 -->


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

<p><br></p>
<h2 class="mgr-page-title"><b>Store Home Pages</b></h2>
<p><br></p>

<div class="well">
<p>Home page templates allow you to change the meta tag info for the store's main page, aka the store home page.</p>
<p>By default, the store home page template uses tokens to show all the home page widgets selected in the homepage (ZoneHome) widget manager. Widgets are edited in each individual store template.</p>
<p>You can add more elements &amp; information to the page but it is recommended that you make custom home page widgets instead</p>
<p>Store Home Pages can be found in the "$sc_html_dir/homepage/$sc_lang_path" sub-directory of your store.</p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit a Store Home Page</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Edit a Store Home Page: &nbsp; <a data-toggle="collapse" href="#editHomePage" aria-expanded="false" aria-controls="editHomePage"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="hp_file_to_save">
<option></option>
$homepages
</select></p>
<div class="collapse" id="editHomePage">
<div class="well">
<p>Select the name of the Store Home Page you wish to edit or copy.</p>
<p>Edit function: you can edit the selected Store Home Page on the next screen and then save it.</p>
</div>
</div>
<p><br></p>

<input type="hidden" name="selectHomePagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit Selected Store Home Page</button>
</form>



<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore a Store Home Page</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select Home Page to restore: &nbsp; <a data-toggle="collapse" href="#homepageBackups" aria-expanded="false" aria-controls="homepageBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_homepage">
<option></option>
$backuphomepages
</select></p>
<div class="collapse" id="homepageBackups">
<div class="well">
<p>Select the name of the Store Home Page backup you wish to restore.</p>
<p>The restore will completely overwrite the existing Store Home Page and any changes made to it.</p>
<p>No backups are created in this process.</p>
</div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="homepage">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Store Home Page Backup</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete a Store Home Page backup</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select backup file to delete: &nbsp; <a data-toggle="collapse" href="#homepageDelete" aria-expanded="false" aria-controls="homepageDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_homepage">
<option></option>
$deleteHomePageBackups
</select></p>
<div class="collapse" id="homepageDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete.</p>
        <p>If deleted, a Home Page can be restored from a backup (if one exists - save the file with a backup option selected).</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS BACKUP FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="cms_editor_file_type" value="homepage">
<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Home Page Backup</button>
</form>


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

</div>


<!-- End of tab 11 -->


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

<p><br></p>
<h2 class="mgr-page-title"><b>Order Viewing Templates</b></h2>
<p><br></p>

<div class="well">
    <p>Order Viewing Templates allow you to change the information displayed in HTML formats for things like picking slips, invoices, etc.</p>
    <p>Files starting with <b>mgr</b> are used inside manager functions.</p>
    <p>Order Viewing Templates can be found in the "$sc_orderViewing_dir" sub-directory of your store.</p>
</div>

<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Edit / Copy an Order Viewing Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Edit / Copy an Order Viewing Template: &nbsp; <a data-toggle="collapse" href="#editov" aria-expanded="false" aria-controls="editov"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2edit_orderview">
    <option></option>
    $orderviewing
    </select></p>
<div class="collapse" id="editov">
    <div class="well">
        <p>Select the name of the Order Viewing Template you wish to edit or copy.</p>
        <p>Edit function: you can edit the selected Order Viewing Template on the next screen and then save it without changing the name.</p>
        <p>Copy function: you can edit the selected Order Viewing Template on the next screen and save it to a copy / file by changing the name of the file to be saved.</p>
    </div>
</div>
<p><br></p>

<input type="hidden" name="cms_editor_file_type" value="orderview">
<input type="hidden" name="selectCMSpagetoEdit" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Edit / Copy Selected Order Viewing Template</button>
</form>



<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Delete an Order Viewing Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to delete: &nbsp; <a data-toggle="collapse" href="#ovDelete" aria-expanded="false" aria-controls="ovDelete"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2delete_orderview">
<option></option>
$orderviewingdelete
</select></p>
<div class="collapse" id="ovDelete">
    <div class="well">
        <p>Select the name of the file you wish to delete.</p>
        <p>If deleted, a Order Viewing Template can be restored from a backup (if one exists - save the file with a backup option selected).</p>
        <p>Backups cannot be restored if deleted.</p>
    </div>
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-bottom: 10px;">
    <div class="input-group">
      <span class="input-group-addon">
        <input type="checkbox" name="double_check_delete_checked" value="yes" required>
      </span>
      <label class="form-control"><b>ARE YOU SURE YOU WANT TO PERMANENTLY DELETE THIS FILE?</b></label>
    </div>
</div>
<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br></p>

<input type="hidden" name="cms_editor_file_type" value="orderview">
<input type="hidden" name="selectCMSpagetoDelete" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Delete Selected Order Viewing Template</button>
</form>


<p class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><br><br></p>
<div><span class="divider"></span></div>
<h2 class="mgr-page-title"><b>Restore an Order Viewing Template</b></h2>
<div><span class="divider2"></span></div>
<div><span class="divider"></span></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><p><br><br></p></div>

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

<p><b>Select file to restore: &nbsp; <a data-toggle="collapse" href="#ovBackups" aria-expanded="false" aria-controls="ovBackups"><i class="fa fa-info-circle"></i></a></b> <span style="padding-left: 25px;"></span><select name="cmsfile2restore_orderview">
<option></option>
$orderviewingbackups
</select></p>
<div class="collapse" id="ovBackups">
    <div class="well">
        <p>Select the name of the Order Viewing Template you wish to restore.</p>
        <p>The restore will completely overwrite the existing Order Viewing Template and any changes made to it.</p>
        <p>No backups are created in this process.</p>
    </div>
</div>
<p><br></p>
<input type="hidden" name="cms_editor_file_type" value="orderview">
<input type="hidden" name="selectCMSbackuptoRestore" value="Submit">
<button class="btn btn-primary mgr-center" style="display: block;">Restore Selected Order Viewing Template</button>
</form>

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


    </div>


<!-- End of tab 13 -->


</div>
<br><br><br>
ENDOFTEXT
    print &$manager_page_footer;
}
#######################################################################################
1;
