$versions{'product_edit-ext_lib.pl'} = '06.6.00.0001';

# Contains all sub routines (functions) to display and edit products in Database
# as well as product deletion from DB.

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

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

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

{
    local ($modname) = 'product_edit';
    register_extension( $modname, 'Product DB Edit', $versions{$modname} );
    register_menu(
        'display_screen', 'display_catalog_screen',
        $modname,  'Display Product DB Catalog'
    );
    register_menu( 'edit_screen', 'edit_product_screen', $modname,
        "Edit Product" );
    register_menu( 'skip_edit_screen', 'edit_product_screen', $modname,
        'BASE -- needed if editing products' );
    register_menu(
        'delete_screen', 'delete_product_screen',
        $modname, 'Delete Product Screen'
    );
    register_menu( 'EditProduct', 'action_edit_product', $modname,
        'Edit Product Form' );
    register_menu( 'SubmitEditProduct', 'action_submit_edit_product', $modname,
        'Write Edited Product' );
    register_menu(
        'DeleteProduct', 'action_delete_product',
        $modname,  'Delete a product'
    );
}

# set defaults
if ( $mc_max_items_per_page eq '' ) {    # Used when listing items in a category
    $mc_max_items_per_page = 100;
}
#edit item/show category
if ( $mc_put_edit_helper_at_top eq '' ) {
    $mc_put_edit_helper_at_top = 'yes';
}
#edit item/show category
if ( $mc_put_edit_helper_at_bot eq '' ) {
    $mc_put_edit_helper_at_bot = 'no';
}

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

sub display_categories {

    local ($link_to) = @_;
    my $maxcols = 3;
    my $items = 0;
    local ( %category_list, %db_ele );

    print <<ENDOFTEXT;
<div class="col-md-6 col-lg-6 col-sm-offset-0 col-md-offset-3 col-lg-offset-3">
        <form action="manager.cgi" method="post"><input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
        <input type="hidden" name="$link_to" value="yes">
        <input type="hidden" name="category" value="_ALL_">
        <button class="btn btn-primary btn-lg btn-block">Display All Items in All Categories</button>
        </form><br><br>
  </div>
</div>
ENDOFTEXT

    $element_id = $db{'product'};
    get_mgr_prod_db_element( $element_id, *db_ele );

    foreach $sku ( keys %db_ele ) {
        $category = $db_ele{$sku};
        $category_list{$category}++;
    }

    foreach $category ( sort( keys(%category_list) ) ) {
        $items++;
        if ( $items == 1 ) {
            print "<div class='row'>\n";
        }
        print <<ENDOFTEXT;
<div class="col-md-4 col-lg-4">
    <form action="manager.cgi" method="post"><input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
    <input type="hidden" name="category" value="$category">
    <input type="hidden" name="$link_to" value="yes">
    <button class="btn btn-info btn-block">$category ($category_list{$category})</button>
    </form><br>
</div>
ENDOFTEXT

        if ( $items == $maxcols ) {
            $items = 0;
            print "</div>\n";
        }

    } # End of foreach $category

    if ( $items > 0 ) {
        $items = 0;
        print "</div>\n";
    }

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

}

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

sub display_items_in_category {

    local ( $button, $col_header, $link, $return_link ) = @_;
    local ($items) = 0;
    local ( $first, $last );
    local ( %category_list, %db_ele );
    local ( $product_id, $found_it, @db_row, $raw_data );

    # Get every element's product category
    $element_id = $db{'product'};
    get_mgr_prod_db_element( $element_id, *db_ele );
    $first = $in{'first'};
    if ( ( $first + 0 ) lt 1 ) { $first = 1; }
    $last  = $first - 1 + $mc_max_items_per_page;
    $table_text = q{};
    foreach $sku ( sort( keys %db_ele ) ) {
        $category = $db_ele{$sku};

        if ($sku) {

            if ( $in{'category'} eq '_ALL_' || $in{'category'} eq $category ) {

                if ( $items <= $last ) {
                    $found_it =
                      get_prod_db_row( $sku, *db_row, *raw_data, 'no' );
                }
                else {
                    $raw_data = q{};
                    @db_row   = ();
                }
                $price = $db_row[ $db{'price'} ];
                $name  = $db_row[ $db{'name'} ];

                $subcats        = q{};
                $subcats_thingy = q{};

                if ( $sc_use_database_subcats =~ /yes/i ) {
                    $subcats = $db_row[ $db{"$sc_subcat_index_field"} ];
                    $subcats =~ s/::/, /g;
                    if ( $subcats eq '' ) { $subcats = '&nbsp;';}
                    $subcats_thingy = qq~
  <td align="left">$subcats</td>
~;
                }

                #($sku, $category, $price, $short_description, $image,
                # $long_description, $options) = split(/\|/,$_);

                $items++;
                if ( ( $items >= $first ) && ( $items <= $last ) ) {
                    $table_text .= qq~
<tr>
  <td class="mgr-center"><button class="btn btn-primary" name="$link\WhichProduct" value="$sku">$sku</button>
  </td>
  <td class="mgr-center">$category</td>
  <td align="left">$name</td>
    $subcats_thingy
  <td class="mgr-center">$price</td>
</tr>
~;
                }
            }  # end if ( $in{'category'} eq '_ALL_' || $in{'category'} eq $category )

        } # end if ($sku)

    }   # End of foreach

    if ( $items < $last ) { $last = $items; }
    $link_info =
"manager.cgi?mgr_seshun=$in{'mgr_seshun'}&${return_link}=yes&category=$in{'category'}";
    $nav_info = "Found $items items, showing $first to $last.";
    $nav_info .= "&nbsp;&nbsp;&nbsp;";
    if ( $first > 1 ) {
        $newfirst = $first - $mc_max_items_per_page;
        $nav_info .= "<a href='$link_info&first=$newfirst'>Previous</a>";
        $nav_info .= "&nbsp;&nbsp;&nbsp;";

        # $link_info

    }
    if ( $items > $last ) {
        $newfirst = $last + 1;
        $nav_info .= "<a href='$link_info&first=$newfirst'>Next</a>";
        $nav_info .= "&nbsp;&nbsp;&nbsp;";
    }

    print <<ENDOFTEXT;
<p class="mgr-center">$nav_info<br></p>
ENDOFTEXT

    $subcats_header = q{};
    if ( $sc_use_database_subcats =~ /yes/i ) {
        $subcats_header = qq~<td class="mgr-center" bgcolor="#FFCC00"><b>Sub Categories</b></td>~;
    }

    print <<ENDOFTEXT;
<form action="manager.cgi" method="post"><input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<input type="hidden" name=$link\Product value="$button">
<input type="hidden" name=category value=$in{'category'}>
<input type="hidden" name="first" value="$in{'first'}">
<div class="table-responsive">
<table class="table table-condensed table-hover table-bordered">
  <tr>
  <td class="mgr-center" bgcolor="#FFCC00">$col_header</td>
  <td class="mgr-center" bgcolor="#FFCC00"><b>Category</b></td>
  <td class="mgr-center" bgcolor="#FFCC00"><b>Description</b></td>
$subcats_header
  <td class="mgr-center" bgcolor="#FFCC00"><b>Price</b></td>
  </tr>
$table_text
ENDOFTEXT

    if ( $items <= 0 ) {
        print <<ENDOFTEXT;
  <tr>
  <td colspan=5><font face=arial size=2>
        <center><a href="manager.cgi?mgr_seshun=$in{'mgr_seshun'}&edit_screen=yes&">Click here</a> to display the categories in your catalog/database.
  </center></font>
  </td>
  </tr>
ENDOFTEXT
    }
    print <<ENDOFTEXT;
</table>
</div>
<p class="mgr-center"><br>$nav_info</p>
</form>
ENDOFTEXT

}

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

sub DisplayRequestedProduct
{
    print <<ENDOFTEXT;


<tr width="500">
<td width=125>
$sku
</td>
<td width=125>
$category
</td>
<td width=125>
$short_description
</td>
<td width=125>
$price
</td>
</tr>

ENDOFTEXT

}

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

sub edit_item_form {
    return edit_item_form_new();
}

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

sub edit_item_form_new {
    local ( $form, $msg, $imgup ) = q{};
    my ( $dimension_row, $alternate_origin_row ) = q{};
    local $mc_GD_module_status = 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 GD Perl Module is installed</h4>
            <p class="text-primary">No errors found - images uploading and resizing from the product add and edit screens should work properly.</p>
        </div>
    </div>
|;

    # check for GD in non-fatal way
    eval("use GD;");
    $err_code = q{};
    $err_code = $@;
    if ($err_code) {  # GD module error of some kind
        $mc_GD_module_status = 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-danger">
                <h4 class="text-danger mgr-center">The GD Perl Module is not installed</h4>
                <p class="text-danger">images uploaded on product add and edit screens will not be resized unless GD is installed on your server or hosting account. Store will still operate without this feature.</p>
            </div>
        </div>
|;
    }

    if ( $mc_file_upload_ok =~ /yes/ ) {  # allow images to be uploaded
           $imgup = qq~<p><hr></p>
<p><b>Image Uploads: &nbsp; <a data-toggle="collapse" href="#prodImageUp" aria-expanded="false" aria-controls="prodImageUp"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span></p>
<p><b>PRIMARY PRODUCT IMAGE:</b> <input type="file" name="upfile1" size="30"></p>
<p><br></p>
<p><b>ADDITIONAL IMAGES:</b></p>
<p>image #2: <input type="file" name="upfile2" size="30"></p>
<p>image #3: <input type="file" name="upfile3" size="30"></p>
<p>image #4: <input type="file" name="upfile4" size="30"></p>
<p>image #5: <input type="file" name="upfile5" size="30"></p>
<div class="collapse" id="prodImageUp">
    <div class="well">
        <p>Upload .GIF, .JPG and .PNG format Image File(s)</p>
        <p>The <b>Primary Product Image:</b> is resized to catalog and thumbnail sizes as set in the main/core settings. Image names are also automagically placed in the thumbnail (user 1 field) and the image fields on new or updated uploads using the Primary Product Image box. Images uploaded from this box are placed in a sub-directory named <b><i>$mc_images_dir/$sku</i></b></p>
        <p><b>Additional Images:</b> images uploaded via these boxes are placed in the <b><i>$mc_images_dir</i></b> sub-directory of the store, and are NOT resized for thumbnails and catalogs images.</p>
    </div>
</div>\n~;
    }

    if ( $sc_alt_origin_enabled =~ /yes/ ) {  # allow alternate origins
        $alternate_origin_row =
qq~<p><hr></p>
<p><b>Alternate Shipping Origin: &nbsp; <a data-toggle="collapse" href="#altOrigin" aria-expanded="false" aria-controls="altOrigin"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span>Zip/Postal Code: <input type=text name="alt_origin_postalcode" size="12" value="$alt_origin_postalcode"><span style="padding-left: 25px;"></span>
State/Province: <input type=text name="alt_origin_stateprov" size="3" value="$alt_origin_stateprov"></p>
<div class="collapse" id="altOrigin">
    <div class="well">
        <p>Alternate shipping origins are enabled and available for this product.</p>
        <p>If this product is shipped from a different location than the original location within your shipping settings, then please enter the Zip/Postal Code and the State/Province this product is shipping from.</p>
        <p><b>If not needed, leave blank</b>.</p>
    </div>
</div>\n~;
    }

    if ( $sc_dimensional_shipping_enabled =~ /yes/ ) {  # allow dimensions per box
        $dimension_row =
qq~<p><hr></p>
<p><b>Shipping Box Dimensions: &nbsp; <a data-toggle="collapse" href="#shipDims" aria-expanded="false" aria-controls="shipDims"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span>Box Type: <select name="boxtype">
<option>$boxtype</option>
<option value="02">02 - UPS Your Packaging</option>
<option value="03">03 - UPS Tube (38" Long, posters &amp; prints)</option>
<option value="21">21 - UPS Express Box (largest is 18x13x3)</option>
<option value="25">25 - UPS 10 KG Box (about 22lbs max, Worldwide Express only) </option>
<option value="24">24 - UPS 25 KG Box (about 55lbs max, Worldwide Express only) </option>
<option value="RECTANGULAR">USPS Your Packaging - Rectangular</option>
<option value="NONRECTANGULAR">USPS Your Packaging - Non-Rectangular</option>
<option value="LG FLAT RATE BOX">Large USPS Flat Rate Box 12" x 12" x 5.5" - Priority Mail Only</option>
<option value="MD FLAT RATE BOX">Med USPS Flat Rate Box 13.63" x11.9" x3.38" -Priority Mail Only</option>
<option value="MD FLAT RATE BOX">Medium USPS Flat Rate Box 11" x 8.5" x 5.5" - Priority Mail Only</option>
<option value="SM FLAT RATE BOX">Small USPS Flat Rate Box 8.63" x5.38" x1.63" -Priority Mail Only</option>
<option value="PADDED FLAT RATE ENVELOPE">USPS Flat Rate Envelope - Priority Mail Only</option>
<option value="FLAT RATE ENVELOPE">USPS Flat Rate Envelope - Priority Mail Only</option>
<option value='FEDEXENVELOPE'>FedEx Envelope</option>
<option value='FEDEXPAK'>FedEx Pak</option>
<option value='FEDEXBOX'>FedEx Box</option>
<option value='FEDEXTUBE'>FedEx Tube</option>
<option value='FEDEX10KGBOX'>FedEx 10kg Box</option>
<option value='FEDEX25KGBOX'>FedEx 25kg Box</option>
<option value='YOURPACKAGING'>FedEx - Your Packaging</option>
<option value='RECTANGULARPACKAGING'>Your Packaging (rectagular for any shipper)</option>
<option value="">None</option>
</select></p>
<p>Length: <input type=text name="length" size="3" value=$length> &nbsp;&nbsp;
Width: <input type=text name="width" size="3" value=$width> &nbsp;&nbsp;
Height: <input type=text name="height" size="3" value=$height> &nbsp;&nbsp;
Girth: <input type=text name="girth" size="3" value=$girth></p>
<div class="collapse" id="shipDims">
    <div class="well">
        <p>Shipping Dimensions are enabled and available for this product.</p>
        <p>Enter the length, width, height of the box.</p>
        <p>If using a non-rectangular package AND NOT using a shipper supplied container, enter in the girth of the widest point perpendicular to the length of the package.</p>
        <p>Select the packaging "Box" type as well.</p>
        <p>If you use more than one shipping company for real-time quotes, do not select anything other than "your packaging".</p>
        <p><b>If this product is to be boxed with other items, leave these fields blank</b> -- it will use defaults from the real-time shipping settings instead.</p>
    </div>
</div>\n~;
    }

    $form = &$manager_page_header( "Edit Product: $sku", '', '', '', '' );

    $form .= <<ENDOFTEXT;
<h1 class='mgr-page-title'><b>Edit Product: $sku $short_description</b></h1>
<p><br></p>

<p class="well">Use the least amount of text as possible in each field.  Shorten names a much as possible. The shorter and/or less text you use, the faster and more efficient your store will run. <b>Remember all entries are case sensitive</b> and will cause errors if even one character is wrong in case ( capitals or small caps ). Use the tabs below to view each sub-section. You may change the settings within as many tabs/groups as needed, then press the <b><i>submit</i></b> button at the very bottom of the page after you are finished making any desired changes. Click on the <i class="fa fa-info-circle"></i> icon next to any setting for more information on the setting.</p>
<p><br></p>

<form action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<input type="hidden" name="first" value="$in{'first'}">
<input type="hidden" name="ProductEditSku" value="$sku">
<button class="btn btn-sm btn-success pull-right" name="skip_edit_screen" value="Skip This Record - Done">Skip This Record - Cancel</button>
</form>
<p><br><br></p>

<ul class="nav nav-tabs" id="tabs4" role="tablist">
    <li role="presentation" class="active"><a href="#tabs-1" aria-controls="tabs-1" role="tab" data-toggle="tab">Product Info</a></li>
    <li role="presentation"><a href="#tabs-2" aria-controls="tabs-2" role="tab" data-toggle="tab">Images</a></li>
    <li role="presentation"><a href="#tabs-3" aria-controls="tabs-3" role="tab" data-toggle="tab">Shipping</a></li>
    <li role="presentation"><a href="#tabs-4" aria-controls="tabs-4" role="tab" data-toggle="tab">User Fields</a></li>
    <li role="presentation"><a href="#tabs-5" aria-controls="tabs-5" role="tab" data-toggle="tab">Misc</a></li>
ENDOFTEXT

    if ( $mgr_gm_product_feed_installed eq 'yes' && $mgr_gm_product_tab ) {
        $form .= <<ENDOFTEXT;
    <li role="presentation"><a href="#tabs-6" aria-controls="tabs-6" role="tab" data-toggle="tab">$mgr_gm_product_tab</a></li>
ENDOFTEXT
    }

    $form .= <<ENDOFTEXT;
</ul>

<form class="form-horizontal" action="manager.cgi" method="post" enctype="multipart/form-data">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<div class="tab-content">
<div class="tab-pane active" id="tabs-1">

<p><br></p>

<h2 class="mgr-page-title"><b>Product Info - Main Details</b></h2>
<p><br></p>

<p><b>Product ID # $sku &nbsp; <a data-toggle="collapse" href="#sku" aria-expanded="false" aria-controls="sku"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="new_sku" type="text" size="18" maxlength="20" value="$sku"></p>
<div class="collapse" id="sku">
     <div class="well">
         <p>20 characters max.</p>
         <p>Do not use spaces, dashes (a word separator in store URLS that replace spaces in names) nor meta characters (\$,#,%,&amp;,\@,*,',",-,<,>,?,/, etc).</p>
         <p>Changing the ID # will save this edit as a new product record automagically.</p>
     </div>
</div>
<p><hr></p>


<p><b>Category: &nbsp; <a data-toggle="collapse" href="#category" aria-expanded="false" aria-controls="category"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="category" type="text" maxlength="50" class="form-control" value="$category"></p>
<div class="collapse" id="category">
     <div class="well">
         <p>Spaces &amp; underscores okay. 50 characters max.</p>
         <p>Do not use dashes (a word separator in store URLS that replace spaces in names) nor meta characters (\$,#,%,&amp;,\@,*,',",-,<,>,?,/,etc).</p>
         <p>Changing the category name to something not used previously will create a new category automagically.</p>
     </div>
</div>
<p><hr></p>

<p><b>Product Name: &nbsp; <a data-toggle="collapse" href="#productName" aria-expanded="false" aria-controls="productName"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="name" type="text" maxlength="70" class="form-control" value="$short_description"></p>
<div class="collapse" id="productName">
     <div class="well">
         <p>4 to 8 words and Spaces okay. 70 characters max.</p>
         <p>Do not use quote marks, dashes (a word separator in store URLS that replace spaces in names), underscores (makes linked words a single word in search engines) nor meta characters (\$,#,%,&amp;,\@,*,',",-,<,>,?,/,etc).</p>
         <p>Best practice is to spellout or abbreviate words for measurements like "inches or in" or "feet or ft" instead of using quote marks.</p>
     </div>
</div>
<p><hr></p>

<p><b>Price: &nbsp; <a data-toggle="collapse" href="#productPrice" aria-expanded="false" aria-controls="productPrice"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="price" type="text" maxlength="12" size="8" value="$price"></p>
<div class="collapse" id="productPrice">
     <div class="well">
         <p>Do not enter currency symbol</p>
     </div>
</div>
<p><hr></p>

<p><b>Specials Price: &nbsp; <a data-toggle="collapse" href="#SpecialsPrice" aria-expanded="false" aria-controls="SpecialsPrice"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="SpecialsPrice" type="text" maxlength="12" size="8" value="$SpecialsPrice"></p>
<div class="collapse" id="SpecialsPrice">
     <div class="well">
         <p>This field requires an add-on or custom code to use.</p>
         <p>This is a sales price for special promotions</p>
         <p>Do not enter currency symbol</p>
     </div>
</div>
<p><hr></p>

<p><b>Wholesale Price: &nbsp; <a data-toggle="collapse" href="#WholesalePrice" aria-expanded="false" aria-controls="WholesalePrice"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="WholesalePrice" type="text" maxlength="12" size="8" value="$WholesalePrice"></p>
<div class="collapse" id="WholesalePrice">
     <div class="well">
         <p>This field requires an add-on or custom code to use.</p>
         <p>This is a discounted price for those that are your wholesalers or resellers.</p>
         <p>Do not enter currency symbol</p>
     </div>
</div>
<p><hr></p>

<p><b>COGS (cost of goods sold): &nbsp; <a data-toggle="collapse" href="#COGSitem" aria-expanded="false" aria-controls="COGSitem"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="COGSitem" type="text" maxlength="12" size="8" value="$cogs_db_item"></p>
<div class="collapse" id="COGSitem">
     <div class="well">
         <p>This field requires an add-on or custom code to use.</p>
         <p>This is a the actual/estimated/guesstimated COGS (cost of goods sold) current for items in inventory and/or sold.</p>
         <p>Do not enter currency symbol</p>
     </div>
</div>
<p><hr></p>

<p><b>Option File: &nbsp; <a data-toggle="collapse" href="#productOption" aria-expanded="false" aria-controls="productOption"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name="option_file" size="1"><option>$options</option>
$options_file_list
</select></p>
<div class="collapse" id="productOption">
     <div class="well">
         <p>Choose from the list of files in the options directory, found inside the <b><i>$sc_options_directory_path</i></b> sub-directory of the store.</p>
         <p><b>Option Files</b> can be created in a text editor. You can also use the "Basic Options Manager" that will help you create simple options in for use in your products ( see Content Management Managers for Link, if installed ).</p>
     </div>
</div>
<p><hr></p>

<p><b>Product Description: &nbsp; <a data-toggle="collapse" href="#productDescription" aria-expanded="false" aria-controls="productDescription"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><textarea name="description" rows="10" class="form-control" wrap="soft">$long_description</textarea></p>
<div class="collapse" id="productDescription">
     <div class="well">
         <p>Enter the Text &amp; HTML describing the product.</p>
     </div>
</div>

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

<!-- End of tab 1 -->


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

<p><br></p>

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

$mc_GD_module_status
<div class="row col-xs-12 col-sm-12"><p><br></p></div>

<p><b>Image File: &nbsp; <a data-toggle="collapse" href="#prodImage" aria-expanded="false" aria-controls="prodImage"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="image" type="text" class="form-control" maxlength="90"
 value="$image"></p>
<div class="collapse" id="prodImage">
     <div class="well">
         <p>Use image name format of: name.gif</p>
         <p>Image formats supported: .gif, .jpg, .png</p>
         <p>90 max characters. Case Sensitive, names must match! Do not enter path to image location.</p>
         <p>use image name format of: name.gif (or .jpg / .png)</p>
     </div>
</div>

$imgup

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

<!-- End of tab 2 -->


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

<p><br></p>

<h2 class="mgr-page-title"><b>Shipping Info</b></h2>
<p><br></p>

<p><b>Shipping Price or Weight: &nbsp; <a data-toggle="collapse" href="#shipWeightPrice" aria-expanded="false" aria-controls="shipWeightPrice"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="shipping_price" type="text" size="8" maxlength="12" value="$shipping_price"></p>
<div class="collapse" id="shipWeightPrice">
     <div class="well">
         <p>This field becomes a "weight" value only if using SBW module in shipping manager. Example: 2.50 becomes 2.5 pounds if SBW is enabled.</p>
         <p>This value is an additional shipping cost value if SBW is not used. Example: 2.50 becomes \$2.50 in shipping charges if SBW is not enabled in the shipping manager.</p>
         <p>Do not enter anything but the shipping price or weight in numerical form.</p>
         <p>Leave completely blank if no price or weight needed for this product.</p>
     </div>
</div>

$alternate_origin_row
$dimension_row

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

<!-- End of tab 3 -->


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

<p><br></p>

<h2 class="mgr-page-title"><b>Database User Fields</b></h2>
<p><br></p>

<p class="well">Change userfield titles displayed in Add Product and Edit Product screens <a href=manager.cgi?mgr_seshun=$in{'mgr_seshun'}&rename_userfields_screen=yes> here</a>.<br>
<b>sub categories</b>:  if using sub categories, indicate sub category name in a userfield that is open ( make sure this is setup in the main store settings/setups screen ).  If you need more than one sub category for the product, separate sub-category names with two colons ( :: ).  Spaces and the "greater than arrow" (>) are acceptable in sub-category names, but <b>do not use</b> underscores, dashes or other meta characters (\$,#,%,&amp;,\@,*,',",_,-,<,?,/,etc).<br>
<b>User Field #1</b> is reserved for thumbnail images by default, but may be used for other items if thumbnail images are not used.<br>
<b>User fields 2+</b> are searchable content in store searches.</p>
<p><br></p>

<p><b>Thumbnail Image: &nbsp; <a data-toggle="collapse" href="#thumbNailImage" aria-expanded="false" aria-controls="thumbNailImage"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input
value='$userDefinedOne' name="userDefinedOne" class="form-control" maxlength="256"></p>
<div class="collapse" id="thumbNailImage">
     <div class="well">
         <p>This is the image used in the cart contents displayed ( view cart, checkout, etc ).  Leave blank if not using images in cart contents layout ( see cart layout manager ).</p>
         <p>If using this image, use <b>[[img]]</b> in front of the image name for auto-built images for the image displayed ( example: [[img]]small_imagename.jpg ).</p>
         <p>Use small images, no larger than approx 40-70 pixels in width and/or height, or your cart contents displays will look really terrible and skew your layouts. If you entered an image (now or previously) in the "Main Product Image Only" box, the thumbnail image will be created and resized automatically for you and the box populated with the correct name and default location.</p>
     </div>
</div>
<p><hr></p>

<p><b>$user2:</b><span style="padding-left: 25px;"></span><input
value='$userDefinedTwo' name="userDefinedTwo" class="form-control" maxlength="256"></p>
<p><hr></p>

<p><b>$user3:</b><span style="padding-left: 25px;"></span><input
value='$userDefinedThree' name="userDefinedThree" class="form-control" maxlength="256"></p>
<p><hr></p>

<p><b>$user4:</b><span style="padding-left: 25px;"></span><input
value='$userDefinedFour' name="userDefinedFour" class="form-control" maxlength="256"></p>
<p><hr></p>

<p><b>$user5:</b><span style="padding-left: 25px;"></span><input
value='$userDefinedFive' name="userDefinedFive" class="form-control" maxlength="256"></p>
<p><hr></p>

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


<!-- End of tab 4 -->


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

<p><br></p>

<h2 class="mgr-page-title"><b>Misc Fields</b></h2>
<p><br></p>

<p class="well">All of the fields below require an add-on or custom code to utilize. If you are not using specific add-ons or custom code to use these fields, you can skip filling them out.</p>
<p><br></p>

<p><b>Inventory: &nbsp; <a data-toggle="collapse" href="#Inventory" aria-expanded="false" aria-controls="Inventory"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="Inventory" type="number" maxlength="12" size="8" value="$Inventory"></p>
<div class="collapse" id="Inventory">
     <div class="well">
         <p>This field requires an add-on or custom code to use, such as the Inventory Manager add-on</p>
         <p>Enter the numbers of all items, in all option types. At this time, inventory management cannot track individual option configurations, only a main sku (item or database ID)</p>
     </div>
</div>
<p><hr></p>

<p><b>Is This Item Taxable? &nbsp; <a data-toggle="collapse" href="#IsTaxable" aria-expanded="false" aria-controls="IsTaxable"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><select name="IsTaxable">
<option>$IsTaxable</option>
<option>yes</option>
<option>no</option>
</select></p>
<div class="collapse" id="IsTaxable">
     <div class="well">
         <p>This field requires an add-on or custom code to use.</p>
         <p>YES is assumed in most add-ons. Set to NO to disable sales taxes on this item.</p>
     </div>
</div>
<p><br></p>

<p><b>Tax Type ID: &nbsp; <a data-toggle="collapse" href="#TaxTypeID" aria-expanded="false" aria-controls="TaxTypeID"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="TaxTypeID" type="text" maxlength="12" size="8" value="$TaxTypeID"></p>
<div class="collapse" id="TaxTypeID">
     <div class="well">
         <p>This field requires an add-on or custom code to use.</p>
         <p>If your tax addon or custom tax code needs to indicate a item code for taxing purposes, enter it here.</p>
     </div>
</div>
<p><br></p>

<p><b>Tax Rate Adjustment For This Item: &nbsp; <a data-toggle="collapse" href="#SpecialTaxRateAdjust" aria-expanded="false" aria-controls="SpecialTaxRateAdjust"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="SpecialTaxRateAdjust" type="text" maxlength="12" size="8" value="$SpecialTaxRateAdjust"></p>
<div class="collapse" id="SpecialTaxRateAdjust">
     <div class="well">
         <p>This field requires an add-on or custom code to use.</p>
         <p>If your tax addon or custom tax code can adjust the tax on individual items, enter the rate adjustment here.</p>
     </div>
</div>
<p><hr></p>

<p><b>Shipping Rate Adjustment For This Item: &nbsp; <a data-toggle="collapse" href="#ShipRateAdjust" aria-expanded="false" aria-controls="ShipRateAdjust"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span><input name="ShipRateAdjust" type="text" maxlength="12" size="8" value="$ShipRateAdjust"></p>
<div class="collapse" id="ShipRateAdjust">
     <div class="well">
         <p>This field requires an add-on or custom code to use.</p>
         <p>If your shipment rating addon or custom shipping code can adjust the shipping on individual items, enter the rate adjustment here.</p>
     </div>
</div>


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

<!-- End of tab 5 -->


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

<p><br></p>
$mgr_gm_product_tab_content
<p><br></p>
</div>

<!-- End of tab 6 -->


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

<input type="hidden" name=save_category value="$category">
<input type="hidden" name="ProductEditSku" value="$sku">
<input type="hidden" name="first" value="$in{'first'}">
<input name="SubmitEditProduct" value="Submit Edit" type="hidden">
<button class="btn btn-primary btn-lg btn-block">Submit Product Edits</button>
<p><br><br><br></p>

</form>
ENDOFTEXT

    $form .= &$manager_page_footer;

    return $form;
}

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

sub edit_product_screen {

    local ( $message, $page_title, @categories, $cat_str, $inx );
    local ( $helper, $helper_top, $helper_bot );

    print &$manager_page_header( 'Edit Product', '', '', '', '' );

    if ( $in{'skip_edit_screen'} ) {
        $edit_error_message = "Item Record # $in{'ProductEditSku'} Skipped.";
        $in{'ProductEditSku'} = q{};
        if ( $in{'save_category'} ) {
            $in{'category'} = $in{'save_category'};
        }
    }

    if ( $in{'category'} ) {
        $page_title = qq|Edit a Product from: $in{'category'}|;
        $message =
qq~Click a button for the individual Product ID number under the "Item # to Edit" column to make changes to an individual product listing in your catalog that is within the <b>$in{'category'} </b>category.<br><br><a href="manager.cgi?mgr_seshun=$in{'mgr_seshun'}&edit_screen=yes&">Click here</a> to display the categories in your catalog/database.~;
    }
    else {
        $message = "Click on the catagory buttons below to select a specific product category to display -- displays all products assigned to that selected category.";
        $page_title = 'Select Product Category to Edit';
    }

    @categories = get_prod_db_category_list();
    $cat_str  = q{};
    foreach $inx (@categories) {
        $cat_str .= "<option>$inx</option>\n";
    }

    if ( ( $mc_put_edit_helper_at_top =~ /yes/i ) || ( $mc_put_edit_helper_at_bot =~ /yes/i ) )
    {
        $helper = qq~
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-5 mgr-center">
<form class="form-inline" action="manager.cgi" method="post"><input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<button class="btn btn-primary btn-sm">Edit Item --></button>
<input type=text name="EditWhichProduct" size=12>
<input type="hidden" name="category" value="$in{'category'}">
<input type="hidden" name="EditProduct" value="Edit">
<input name="Helper" type="hidden" value="submit">
</form>
</div>
<div class="col-xs-12 col-sm-12 col-md-7 mgr-center">
<form class="form-inline" action="manager.cgi" method="post"><input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<button class="btn btn-primary btn-sm">Show Category --></button>
<input type="hidden" name="edit_screen" value="yes">
<select name=category>$cat_str</select>
</form>
</div>
</div>
~;
    }

    if ( $mc_put_edit_helper_at_top =~ /yes/i ) {
        $helper_top = $helper . '<p><hr></p>';
    }
    if ( $mc_put_edit_helper_at_bot =~ /yes/i ) {
        $helper_bot = $helper;
    }

    print <<ENDOFTEXT;
<h1 class='mgr-page-title'><b>$page_title</b></h1>
<p><br></p>

<p class="well">$message</p>
$helper_top
ENDOFTEXT

    if ( $in{'ProductEditSku'} ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-success">
        <h4 class="text-primary mgr-center">Product ID \# $in{'ProductEditSku'} successfully edited!</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    if ( $edit_error_message ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-warning">
        <h4 class="text-primary mgr-center">$edit_error_message</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    if ( $conv_result ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-warning">
        <h4 class="text-primary mgr-center">$conv_result</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    if ( $in{'category'} ) {
        display_items_in_category( 'Edit', '<b>Item # to Edit</b>',
            'Edit', 'edit_screen' );
    }
    else {
        display_categories('edit_screen');
    }

    print <<ENDOFTEXT;
$helper_bot
<p><br><br><br></p>
ENDOFTEXT
    print &$manager_page_footer;
}

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

sub delete_product_screen {
    local ( $message, $my_script, $my_body_tag );
    my $page_title = 'Select Product Category to Delete From';

    $my_body_tag = $mc_standard_body_tag;
    if ( $in{'category'} ) {
        $my_body_tag .= '';
    }

    $my_script = qq~
~;

    print &$manager_page_header( 'Delete Product', $my_script, $my_body_tag, '', '' );

    if ( $in{'category'} ) {
        $message = qq|

<!-- Modal -->
<div class="modal fade" id="deletePageModal" tabindex="-1" role="dialog" aria-labelledby="deletePageLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                 <h4 class="modal-title" id="deletePageLabel"><font color='red'>WARNING!</font></h4>

            </div>
            <div class="modal-body">
                <h4>Clicking an <b>Item ID to Delete</b> button will IMMEDIATELY remove that product from your catalog.</h4>
                <h4><font color='red'>You've been warned!</font></h4>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
<!-- End Modal -->

<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-danger">
<h4 class="text-primary mgr-center">WARNING: Clicking an <b>'Item # to Delete'</b> button will IMMEDIATELY remove that product from your catalog.<br><b>You've been warned!</b></h4>
<p><a href="manager.cgi?mgr_seshun=$in{'mgr_seshun'}&delete_screen=yes">Click here</a> to display the categories in your catalog.</p>
</div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
|;
        $page_title = 'Press Product Item # Button to Delete';
    }
    else {
        $message = '<p class="well">Click below to select the category to display.<p>
<p><br></p>';
    }

    print <<ENDOFTEXT;
<h1 class='mgr-page-title'><b>$page_title</b></h1>
<p onload="loadDeletePage()"><br></p>

$message


ENDOFTEXT

    if ( $in{'DeleteWhichProduct'} ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-success">
<h4 class="text-primary mgr-center">Product ID \# $in{'DeleteWhichProduct'} successfully deleted</h4>
</div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    if ( $in{'category'} ) {
        display_items_in_category(
            "Delete", "<B><font color='red'>Item # to Delete</font></B>",
            "Delete", "delete_screen"
        );
    }
    else {
        display_categories('delete_screen');
    }

    print <<ENDOFTEXT;
<p><br><br><br></p>
ENDOFTEXT
    print &$manager_page_footer;

}

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

sub display_perform_edit_screen {
    $options_file_list = make_file_option_list( "$sc_options_directory_path", '' );
    print edit_item_form();
}

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

sub display_catalog_screen {
    $in{'category'} = q{};
    edit_product_screen();
}

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

sub action_edit_product {

    local (
        $sku,               $category,        $price,
        $short_description, $image,           $long_description,
        $shipping_price,    $userDefinedOne,  $userDefinedTwo,
        $userDefinedThree,  $userDefinedFour, $userDefinedFive,
        $SpecialsPrice, $cogs_db_item, $WholesalePrice, $Inventory,
        $IsTaxable, $TaxTypeID, $SpecialTaxRateAdjust, $ShipRateAdjust,
        $options
    );
    local ( $boxindicator, $length, $width, $height, $girth, $boxtype,
        $alt_origin_postalcode, $alt_origin_stateprov );
    local ( $product_id, $found_it, @db_row, $raw_data );

    $found_it =
      get_prod_db_row( $in{'EditWhichProduct'}, *db_row, *raw_data, 'no' );

    (
        $sku,               $category,        $price,
        $short_description, $image,           $long_description,
        $shipping_price,    $userDefinedOne,  $userDefinedTwo,
        $userDefinedThree,  $userDefinedFour, $userDefinedFive,
        $SpecialsPrice, $cogs_db_item, $WholesalePrice, $Inventory,
        $IsTaxable, $TaxTypeID, $SpecialTaxRateAdjust, $ShipRateAdjust,
        $options
    ) = split( /\|/, $raw_data );

    if (   ( $sc_alt_origin_enabled =~ /yes/i )
        || ( $sc_dimensional_shipping_enabled =~ /yes/i ) )
    {
        $found_it_ship =
          get_prod_shipping_dimensions_in_db_row_for_edit( $in{'EditWhichProduct'} );
        (
            $junk, $boxindicator, $length, $width, $height, $girth, $boxtype,
            $alt_origin_postalcode, $alt_origin_stateprov
        ) = split( /\|/, $found_it_ship );
    }

    chomp($options);

    if ( $sku ne $in{'EditWhichProduct'} ) {
        if ($found_it) {
            $long_description =
                "Error, expected sku of $in{'EditWhichProduct'}, "
              . "found $sku instead!";
        }
        $sku = $in{'EditWhichProduct'};
    }

    $options =~ s/%%OPTION%%//g;
    $image   =~ s/.*\[\[URLofImages\]\]\///g;
    $image   =~ s/.png.*/.png/g;
    $image   =~ s/.gif.*/.gif/g;
    $image   =~ s/.jpg.*/.jpg/g;
    ( $image, $junkjunkjunk ) = split( /\"/, $image, 2 );    # safety net

    display_perform_edit_screen();

}

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

sub action_submit_edit_product {
    local (
        $sku,               $category,        $price,
        $short_description, $image,           $long_description,
        $shipping_price,    $userDefinedOne,  $userDefinedTwo,
        $userDefinedThree,  $userDefinedFour, $userDefinedFive,
        $SpecialsPrice, $cogs_db_item, $WholesalePrice, $Inventory,
        $IsTaxable, $TaxTypeID, $SpecialTaxRateAdjust, $ShipRateAdjust,
        $options
    );
    local ($temp);
    my ($boxindicator);

    $formatted_description = $in{'description'};
    $formatted_description =~ s/\r/ /g;
    $formatted_description =~ s/\t/ /g;
    $formatted_description =~ s/\n/ /g;
    $formatted_description =~ s/\s+/ /g;

    $in{'name'} =~ s/\"//g;
    $in{'name'} =~ s/\'//g;
    $in{'name'} =~ s/\`//g;
    my_escape( $in{'name'} );

    if ( $in{'option_file'} ) {
        if ( -e "$sc_options_directory_path/$in{'option_file'}" ) {
            $formatted_option_file = "%%OPTION%%$in{'option_file'}";
        }
        else {
            $formatted_option_file = "%%OPTION%%blank.html";
        }
    }

    else {
        $formatted_option_file = "%%OPTION%%blank.html";
    }

    # NO Multiple BLANKS ALLOWED!  No tabs, newlines or carriage returns
    $in{'category'} =~ s/\s+/ /g;
    my @arrayThing = ( name, category, userDefinedOne, userDefinedTwo,
        userDefinedThree, userDefinedFour, userDefinedFive
    );
    foreach $arrayThing (@arrayThing) {
        $in{$arrayThing} =~ s/\s+/ /g;
        $in{$arrayThing} =~ s/\r//g;
        $in{$arrayThing} =~ s/\t//g;
        $in{$arrayThing} =~ s/\n//g;
    }

    # NO BLANKS OR WHITESPACE ALLOWED!
    my @arrayThing2 =
      ( new_sku, ProductEditSku, price, shipping_price, image, alt_origin_postalcode,
        alt_origin_stateprov, height, width, length, girth
      );
    foreach $arrayThing2 (@arrayThing2) {
        $in{$arrayThing2} =~ s/\s+//g;
    }

    $image = $in{'image'};
    if ( $image eq '' ) {
        $image = 'notavailable.gif';
    }
    $formatted_image = create_image_string($image);

    if ( $in{'category'} eq '' ) {
        $in{'category'} = '*Nameless*';
    }

    if ( $mc_product_image_thumb_holder ) {
        $in{'userDefinedOne'} = $mc_product_image_thumb_holder;
    }

    $raw_line =
        "$in{'ProductEditSku'}|$in{'category'}|$in{'price'}|$in{'name'}"
      . "|$formatted_image|$formatted_description|$in{'shipping_price'}"
      . "|$in{'userDefinedOne'}|$in{'userDefinedTwo'}|$in{'userDefinedThree'}"
      . "|$in{'userDefinedFour'}|$in{'userDefinedFive'}|$in{'SpecialsPrice'}"
      . "|$in{'COGSitem'}|$in{'WholesalePrice'}|$in{'Inventory'}|$in{'IsTaxable'}"
      . "|$in{'TaxTypeID'}|$in{'SpecialTaxRateAdjust'}|$in{'ShipRateAdjust'}|$formatted_option_file";

    if ( substr( $in{'new_sku'}, length( $in{'new_sku'} ) - 1, 1 ) eq '*' ) {
        $temp = substr( $in{'new_sku'}, 0, length( $in{'new_sku'} ) - 1 );
        if ( ( $in{'new_sku'} eq "*" ) || ( $temp ne $in{'ProductEditSku'} ) ) {
            if ( $temp ) {    #test if it is there first ...
                $found_it = check_db_with_product_id( $temp, *db_row );
                if ($found_it) {
                    $in{'new_sku'} = get_next_prod_key();
                }
                else {
                    $in{'new_sku'} = $temp;
                }
            }
            else {
                $in{'new_sku'} = get_next_prod_key();
            }
        }
        else {
            $in{'new_sku'} = $temp;
        }
    }

    if ( ( $in{'new_sku'} eq '' ) || ( $in{'new_sku'} eq $in{'ProductEditSku'} ) ) {
        $result =
          put_prod_db_raw_line( $in{'ProductEditSku'}, $raw_line, 'no' );
    }
    else {    # new product
        $found_it = check_db_with_product_id( $in{'new_sku'}, *db_row );
        if ($found_it) {
            $in{'ProductEditSku'} = q{};
            $edit_error_message =
                "Sorry, that item ("
              . $in{'new_sku'}
              . ") is already in the database.";
            $edit_error_message .= "&nbsp; Hit browser BACK BUTTON to re-edit.";
        }
        else {
            $in{'ProductEditSku'} = $in{'new_sku'};
            $formatted_image = create_image_string($image);
            $edit_error_message = "(NOTE: That item was ADDED to the database)";
            $raw_line =
                "$in{'ProductEditSku'}|$in{'category'}|$in{'price'}|$in{'name'}"
              . "|$formatted_image|$formatted_description|$in{'shipping_price'}"
              . "|$in{'userDefinedOne'}|$in{'userDefinedTwo'}|$in{'userDefinedThree'}"
              . "|$in{'userDefinedFour'}|$in{'userDefinedFive'}"
              . "|$in{'SpecialsPrice'}|$in{'COGSitem'}|$in{'WholesalePrice'}|$in{'Inventory'}"
              . "|$in{'IsTaxable'}|$in{'TaxTypeID'}|$in{'SpecialTaxRateAdjust'}|$in{'ShipRateAdjust'}|$formatted_option_file";
            add_new_record_to_prod_db($raw_line);

        }
    }

    if (   ( $sc_alt_origin_enabled =~ /yes/i )
        || ( $sc_dimensional_shipping_enabled =~ /yes/i ) )
    {
        if (   ( $in{'length'} )
            && ( $in{'width'} )
            && ( $in{'height'} ) )
        {
            $boxindicator = 'yes';
        }

        # NO BLANKS OR WHITESPACE ALLOWED!
        my @arrayThing3 =
          ( alt_origin_postalcode, alt_origin_stateprov, height, width, length,
            girth
          );
        foreach $arrayThing3 (@arrayThing3) {
            $in{$arrayThing3} =~ s/\s+//g;
        }

        my $raw_line2 =
            "$in{'ProductEditSku'}|$boxindicator|$in{'length'}|$in{'width'}"
          . "|$in{'height'}|$in{'girth'}|$in{'boxtype'}|$in{'alt_origin_postalcode'}"
          . "|$in{'alt_origin_stateprov'}";
        my $result2 = put_prod_dimensions_raw_line( $in{'ProductEditSku'}, $raw_line2 );
    }

    category_list_builder_for_store();
    edit_product_screen();

}

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

sub action_delete_product {

    del_prod_from_db( $in{'DeleteWhichProduct'} );

    # delete image sub-directory for P_ID
    # added by Mister Ed - January 2011
    $in{'DeleteWhichProduct'} =~ /([\w\-\/\.\:]+)/;
    my $tempdir = "$1";
    `rm -Rf $mc_images_dir/$tempdir`;

    category_list_builder_for_store();
    delete_product_screen();

}

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

1;
