Jump to content

Recommended Posts

Hi

I am using Zen-Cart to which I have made significant changes.  Two years ago I managed to change the Products Sort Order from Integer to Decimal(5,2) to store books such as 1, 1.5, 1.75, 2 etc.  Regrettably we had a major server issue and I also lost the new coding.  Having restored everything else whenever we enter a book series number such as 1.5 it only stores as 1.

To date the zen-Cart forums have been unable to offer a solution so I am reaching out to see if anyone else can advise me of how to get this working again please.

 

Thanks in advance

Owen

 

Link to comment
https://forums.phpfreaks.com/topic/309383-storing-decimal-places-in-a-database/
Share on other sites

Do you, by any chance, have any backups of the database? Perhaps you could look through those backups for what was changed before.

If you don't have any backups, are you using a third-party website host? If so, have you checked with them on any backups?

Hi Barand

Thank you for your reply.  I understand your comment!

I attach the structure screen shot and the php file that collects the data (obviously there are more in the background).

Kindest regards

Owen


 

<?php
/**
 * @package admin
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: collect_info.php 19330 2011-08-07 06:32:56Z drbyte $
 */

    if (!defined('IS_ADMIN_FLAG')) {
        die('Illegal Access');
    }
    
    $parameters = array('products_name' => '',
        'products_description' => '',
        'products_url' => '',
        'products_id' => '',
        'products_quantity' => '',
        'products_model' => '',
        'products_image' => '',
        'products_price' => '',
        'products_virtual' => DEFAULT_PRODUCT_PRODUCTS_VIRTUAL,
        'products_weight' => '',
        'products_date_added' => '',
        'products_last_modified' => '',
        'products_date_available' => '',
        'products_status' => '',
        'products_tax_class_id' => DEFAULT_PRODUCT_TAX_CLASS_ID,
        'manufacturers_id' => '',
        'products_quantity_order_min' => '',
        'products_quantity_order_units' => '',
        'products_priced_by_attribute' => '',
        'product_is_free' => '',
        'product_is_call' => '',
        'products_quantity_mixed' => '',
        'product_is_always_free_shipping' => DEFAULT_PRODUCT_PRODUCTS_IS_ALWAYS_FREE_SHIPPING,
        'products_qty_box_status' => PRODUCTS_QTY_BOX_STATUS,
        'products_quantity_order_max' => '0',
        'products_sort_order' => '',
        'products_discount_type' => '0',
        'products_discount_type_from' => '0',
        'products_price_sorter' => '0',
        'master_categories_id' => ''
    );

    $pInfo = new objectInfo($parameters);

    if (isset($_GET['pID']) && empty($_POST)) {
        $product = $db->Execute("select pd.products_name, pd.products_description, pd.products_url,
            p.products_id, p.products_quantity, p.products_model,
            p.products_image, p.products_price, p.products_virtual, p.products_weight,
            p.products_date_added, p.products_last_modified,
            date_format(p.products_date_available, '%Y-%m-%d') as
            products_date_available, p.products_status, p.products_tax_class_id,
            p.manufacturers_id,
            p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
            p.product_is_free, p.product_is_call, p.products_quantity_mixed,
            p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
            p.products_sort_order,
            p.products_discount_type, p.products_discount_type_from,
            p.products_price_sorter, p.master_categories_id
            from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
            where p.products_id = '" . (int)$_GET['pID'] . "'
            and p.products_id = pd.products_id
            and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");

        $pInfo->objectInfo($product->fields);
    } elseif (zen_not_null($_POST)) {
        $pInfo->objectInfo($_POST);
        $products_name = $_POST['products_name'];
        $products_description = $_POST['products_description'];
         $products_url = $_POST['products_url'];
    }

    $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));
    $manufacturers = $db->Execute("select manufacturers_id, manufacturers_name
                                   from " . TABLE_MANUFACTURERS . " order by manufacturers_name");

    while (!$manufacturers->EOF) {
        $manufacturers_array[] = array('id' => $manufacturers->fields['manufacturers_id'],
            'text' => $manufacturers->fields['manufacturers_name']);
        $manufacturers->MoveNext();
    }

    $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
    $tax_class = $db->Execute("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");

    while (!$tax_class->EOF) {
        $tax_class_array[] = array('id' => $tax_class->fields['tax_class_id'],
            'text' => $tax_class->fields['tax_class_title']);
        $tax_class->MoveNext();
    }

    $languages = zen_get_languages();

    if (!isset($pInfo->products_status)) $pInfo->products_status = '1';

    switch ($pInfo->products_status) {

        case '0': $in_status = false; $out_status = true; break;

        case '1':
            default: $in_status = true; $out_status = false;
            break;
    }

    // set to out of stock if categories_status is off and new product or existing products_status is off
    if (zen_get_categories_status($current_category_id) == '0' and $pInfo->products_status != '1') {
        $pInfo->products_status = 0;
        $in_status = false;
        $out_status = true;
    }

    // Virtual Products
    if (!isset($pInfo->products_virtual)) $pInfo->products_virtual = DEFAULT_PRODUCT_PRODUCTS_VIRTUAL;

    switch ($pInfo->products_virtual) {

        case '0': $is_virtual = false; $not_virtual = true; break;

        case '1': $is_virtual = true; $not_virtual = false; break;

          // *** LEAVE PRODUCT IS VIRTUAL AS NO ***
        default: $is_virtual = false; $not_virtual = true;
        // **************************************

    }

    // Always Free Shipping
    if (!isset($pInfo->product_is_always_free_shipping)) $pInfo->product_is_always_free_shipping = DEFAULT_PRODUCT_PRODUCTS_IS_ALWAYS_FREE_SHIPPING;

    switch ($pInfo->product_is_always_free_shipping) {

        case '0': $is_product_is_always_free_shipping = false; $not_product_is_always_free_shipping = true; $special_product_is_always_free_shipping = false; break;

        case '1': $is_product_is_always_free_shipping = true; $not_product_is_always_free_shipping = false; $special_product_is_always_free_shipping = false; break;

        case '2': $is_product_is_always_free_shipping = false; $not_product_is_always_free_shipping = false; $special_product_is_always_free_shipping = true; break;

          // *** LEAVE PRODUCT IS ALWAYS FREE SHIPPING AS NO ***
        default: $is_product_is_always_free_shipping = false; $not_product_is_always_free_shipping = true; $special_product_is_always_free_shipping = false; break;
        // ***************************************************

    }

    // products_qty_box_status shows
    if (!isset($pInfo->products_qty_box_status)) $pInfo->products_qty_box_status = PRODUCTS_QTY_BOX_STATUS;

    switch ($pInfo->products_qty_box_status) {

        case '0': $is_products_qty_box_status = false; $not_products_qty_box_status = true; break;

        case '1': $is_products_qty_box_status = true; $not_products_qty_box_status = false; break;

        // *** SET PRODUCT DISPLAY QTY BOX TO NO AS DEFAULT ***
        default: $is_products_qty_box_status = false; $not_products_qty_box_status = true;
        // ****************************************************
    }

    // Product is Priced by Attributes
    if (!isset($pInfo->products_priced_by_attribute)) $pInfo->products_priced_by_attribute = '0';

        switch ($pInfo->products_priced_by_attribute) {

            case '0': $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true; break;

            case '1': $is_products_priced_by_attribute = true; $not_products_priced_by_attribute = false; break;

            // *** LEAVE PRODUCT IS PRICED BY ATTRIBUTES AS NO ***
            default: $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true;
            // ***************************************************
    }

    // Product is Free
    if (!isset($pInfo->product_is_free)) $pInfo->product_is_free = '0';

    switch ($pInfo->product_is_free) {

        case '0': $in_product_is_free = false; $out_product_is_free = true; break;

        case '1': $in_product_is_free = true; $out_product_is_free = false; break;

        // *** SET TO PRODUCT IS FREE BY DEFAULT ***
        default: $in_product_is_free = true; $out_product_is_free = false;
        // *****************************************
    }

    // Product is Call for price
    if (!isset($pInfo->product_is_call)) $pInfo->product_is_call = '0';
    
    switch ($pInfo->product_is_call) {

        case '0': $in_product_is_call = false; $out_product_is_call = true; break;

        case '1': $in_product_is_call = true; $out_product_is_call = false; break;

          // *** LEAVE PRODUCT IS CALL FOR PRICE AS NO ***
        default: $in_product_is_call = false; $out_product_is_call = true;
        // *********************************************
    }

    // Products can be purchased with mixed attributes retail
    if (!isset($pInfo->products_quantity_mixed)) $pInfo->products_quantity_mixed = '0';
    
    switch ($pInfo->products_quantity_mixed) {

        case '0': $in_products_quantity_mixed = false; $out_products_quantity_mixed = true; break;

        case '1': $in_products_quantity_mixed = true; $out_products_quantity_mixed = false; break;

        // *** LEAVE PRODUCTS QUANTITY MIXED SET TO YES ***
        default: $in_products_quantity_mixed = true; $out_products_quantity_mixed = false;
        // ************************************************
    }

    // set image overwrite
    $on_overwrite = true;
    $off_overwrite = false;

    // set image delete
    $on_image_delete = false;
    $off_image_delete = true;
?>

<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
<script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script language="javascript"><!--
    var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
//--></script>
<script language="javascript"><!--
    var tax_rates = new Array();
    <?php
        for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) {
            if ($tax_class_array[$i]['id'] > 0) {
                echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . zen_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n";
            }
        }
    ?>

    function doRound(x, places) {
        return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
    }

    function getTaxRate() {
        var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex;
        var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value;

        if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
            return tax_rates[parameterVal];
        } else {
            return 0;
        }
    }

    function updateGross() {
        var taxRate = getTaxRate();
        var grossValue = document.forms["new_product"].products_price.value;

        if (taxRate > 0) {
            grossValue = grossValue * ((taxRate / 100) + 1);
        }

        document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
    }

    function updateNet() {
        var taxRate = getTaxRate();
        var netValue = document.forms["new_product"].products_price_gross.value;

        if (taxRate > 0) {
            netValue = netValue / ((taxRate / 100) + 1);
        }

        document.forms["new_product"].products_price.value = doRound(netValue, 4);
    }
//--></script>

<?php
    //  echo $type_admin_handler;
    echo zen_draw_form('new_product', $type_admin_handler , 'cPath=' . $cPath . (isset($_GET['product_type']) ? '&product_type=' . $_GET['product_type'] : '') . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . '&action=new_product_preview' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ( (isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '') . ( (isset($_POST['search']) && !empty($_POST['search']) && empty($_GET['search'])) ? '&search=' . $_POST['search'] : ''), 'post', 'enctype="multipart/form-data"');
 ?>
 
 <table border="0" width="100%" cellspacing="0" cellpadding="2">
    <tr>
        <td>
            <table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, zen_output_generated_category_path($current_category_id)); ?></td>
                    <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
                </tr>
            </table>
        </td>
    </tr>

    <tr>
        <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '1'); ?></td>
     </tr>

    <tr>
        <td class="main" align="right"><?php echo zen_draw_hidden_field('products_date_added', (zen_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . zen_image_submit('button_preview.gif', IMAGE_PREVIEW) . '  <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ( (isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '') . ( (isset($_POST['search']) && !empty($_POST['search']) && empty($_GET['search'])) ? '&search=' . $_POST['search'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
    </tr>

    <tr>
        <td>
            <table border="0" cellspacing="0" cellpadding="2">

                <?php
                    // show when product is linked
                    if (zen_get_product_is_linked($_GET['pID']) == 'true' and $_GET['pID'] > 0) {
                ?>
                        <tr>
                            <td class="main"><?php echo TEXT_MASTER_CATEGORIES_ID; ?></td>
                            <td class="main">
                                <?php
                                    // echo zen_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id);
                                    echo zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '  ';
                                    echo zen_draw_pull_down_menu('master_category', zen_get_master_categories_pulldown($_GET['pID']), $pInfo->master_categories_id); ?>
                            </td>
                        </tr>

                    <?php
                    } else {
                    ?>

                        <tr>
                            <td class="main"><?php echo TEXT_MASTER_CATEGORIES_ID; ?></td>
                            <td class="main"><?php echo TEXT_INFO_ID . ($_GET['pID'] > 0 ? $pInfo->master_categories_id  . ' ' . zen_get_category_name($pInfo->master_categories_id, $_SESSION['languages_id']) : $current_category_id  . ' ' . zen_get_category_name($current_category_id, $_SESSION['languages_id'])); ?></td>
                        </tr>

                    <?php 
                    }
                    ?>

                <tr>
                    <td colspan="2" class="main"><?php echo TEXT_INFO_MASTER_CATEGORIES_ID; ?></td>
                </tr>

                <tr>
                    <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '100%', '2'); ?></td>
                </tr>

                <?php
                    // hidden fields not changeable on products page
                    echo zen_draw_hidden_field('master_categories_id', $pInfo->master_categories_id);

                    echo zen_draw_hidden_field('products_discount_type', $pInfo->products_discount_type);
                    echo zen_draw_hidden_field('products_discount_type_from', $pInfo->products_discount_type_from);
                    echo zen_draw_hidden_field('products_price_sorter', $pInfo->products_price_sorter);

                    // *** ADD ADDITIONAL HIDDEN FIELDS ***
                    echo zen_draw_hidden_field('product_is_free', '1');  // product is always free
                    echo zen_draw_hidden_field('product_is_call', '0');  // product call for price is always no
                    echo zen_draw_hidden_field('products_priced_by_attribute', '0'); // products priced by attribute is always no
                    echo zen_draw_hidden_field('products_tax_class_id', '0'); // products tax class is always --none--
                    echo zen_draw_hidden_field('products_price', '0'); // products price is always zero
                    echo zen_draw_hidden_field('products_virtual', '0'); // products virtual is always no
                    echo zen_draw_hidden_field('product_is_always_free_shipping', '0'); // product is always free shipping is always no
                    echo zen_draw_hidden_field('products_qty_box_status', '0'); // always set display quantity box to no
                    echo zen_draw_hidden_field('products_quantity_order_min', '1'); // always set minimum quantity to 1
                    echo zen_draw_hidden_field('products_quantity_order_max', '0'); // always set maxiumum quantity to 0
                    echo zen_draw_hidden_field('products_quantity_order_units', '1'); // always set order units to 1
                    echo zen_draw_hidden_field('products_quantity_mixed', '1'); // always set products mixed quantities to YES
                    echo zen_draw_hidden_field('products_quantity', '1'); // always set products quantity to 1
                    echo zen_draw_hidden_field('products_model', ''); // products model will always be null as not used
                    echo zen_draw_hidden_field('products_url', ''); // products yrl will always be blank
                    echo zen_draw_hidden_field('products_weight', '0'); // products weight will always be zero
                    echo zen_draw_hidden_field('products_sort_order', '0'); // products sort order will always be zero
                    echo zen_draw_hidden_field('products_data_available', NULL); // not going to use this field

                ?>

                <tr>
                    <td colspan="2" class="main" align="center"><?php echo (zen_get_categories_status($current_category_id) == '0' ? TEXT_CATEGORIES_STATUS_INFO_OFF : '') . ($out_status == true ? ' ' . TEXT_PRODUCTS_STATUS_INFO_OFF : ''); ?></td>
                </tr>

                <tr>
                    <td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td>
                    <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('products_status', '1', $in_status) . ' ' . TEXT_PRODUCT_AVAILABLE . ' ' . zen_draw_radio_field('products_status', '0', $out_status) . ' ' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td>
                </tr>

                <tr>
                    <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                </tr>

                <tr>
                    <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                </tr>
                    
                <tr>
                    <td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>
                    <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td>
                </tr>

                <tr>
                    <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                </tr>

 <!-- Products model is never used so will always be null so no need to display the field -->
          <tr><td class="main"><?php echo TEXT_PRODUCTS_MODEL; ?></td><td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_model', htmlspecialchars(stripslashes($pInfo->products_model), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS, 'products_model')); ?></td></tr> 
          
          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>

<!-- products sort order will always be zero so no need to display the field -->
          <tr>
            <td class="main"><?php echo TEXT_PRODUCTS_SORT_ORDER; ?></td>
            <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_sort_order', $pInfo->products_sort_order); ?></td>
          </tr>


<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
          <tr>
            <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td>
            <td class="main"><?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_input_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(isset($products_name[$languages[$i]['id']]) ? stripslashes($products_name[$languages[$i]['id']]) : zen_get_products_name($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS_DESCRIPTION, 'products_name')); ?></td>
          </tr>
<?php
    }
?>

          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>

          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>

<script language="javascript"><!--
updateGross();
//--></script>
<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
          <tr>
            <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td>
            <td colspan="2"><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="main" width="25" valign="top"><?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>
                <td class="main" width="100%"><?php echo zen_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '100%', '30', htmlspecialchars((isset($products_description[$languages[$i]['id']])) ? stripslashes($products_description[$languages[$i]['id']]) : zen_get_products_description($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE)); //,'id="'.'products_description' . $languages[$i]['id'] . '"'); ?></td>
              </tr>
            </table></td>
          </tr>
<?php
    }
?>
          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>



          
          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>


<?php


    // ***** WE NEED TO FORCE ALL BOOK IMAGES INTO THE BOOK COVERS FOLDER ***** //

  $dir = @dir(DIR_FS_CATALOG_IMAGES);

//  $dir_info[] = array('id' => '', 'text' => "Main Directory");  
//  embed the data here

  $dir_info[] = array('id' => 'Book_Covers/', 'text' => "Book_Covers");

//  and remove the search for other folders
//  while ($file = $dir->read()) {
//    if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
//      $dir_info[] = array('id' => $file . '/', 'text' => $file);
//    }
//  }

  
  $dir->close();

    // ***** BOOK COVERS FOLDER FORCED ***** //
  
  
  sort($dir_info);

    //  and just be doubly sure that the correct categories folder is set here
//      $default_directory = substr( $pInfo->products_image, 0,strpos( $pInfo->products_image, '/')+1);

    $default_directory = 'Book_Covers/';

?>

          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
          </tr>

          <tr>
            <td class="main" colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td>
                <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_file_field('products_image') . ' ' . ($pInfo->products_image !='' ? TEXT_IMAGE_CURRENT . $pInfo->products_image : TEXT_IMAGE_CURRENT . ' ' . NONE) . zen_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td>
                <td valign = "center" class="main"><?php echo TEXT_PRODUCTS_IMAGE_DIR; ?> <?php echo zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory); ?></td>
                          </tr>
              <tr>
                <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15'); ?></td>
                <td class="main" valign="top"><?php echo TEXT_IMAGES_DELETE . ' ' . zen_draw_radio_field('image_delete', '0', $off_image_delete) . ' ' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('image_delete', '1', $on_image_delete) . ' ' . TABLE_HEADING_YES; ?></td>
                    </tr>

              <tr>
                <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15'); ?></td>
                <td colspan="3" class="main" valign="top"><?php echo TEXT_IMAGES_OVERWRITE  . ' ' . zen_draw_radio_field('overwrite', '0', $off_overwrite) . ' ' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('overwrite', '1', $on_overwrite) . ' ' . TABLE_HEADING_YES; ?>
                  <?php echo '<br />' . TEXT_PRODUCTS_IMAGE_MANUAL . ' ' . zen_draw_input_field('products_image_manual'); ?></td>
              </tr>
            </table></td>
          </tr>

          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
          </tr>

<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
       
<!-- Products url will always be blank so no need to display the field          
          <tr>
            <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br /><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>
            <td class="main"><?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_input_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(isset($products_url[$languages[$i]['id']]) ? $products_url[$languages[$i]['id']] : zen_get_products_url($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS_DESCRIPTION, 'products_url')); ?></td>
          </tr>
-->


<?php
    }
?>
          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>

<!-- Products weight will always be zero so no need to display the field
          <tr>
            <td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
            <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
          </tr>
-->

          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>

        </table></td>
      </tr>
      <tr>
        <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="main" align="right"><?php echo zen_draw_hidden_field('products_date_added', (zen_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . ( (isset($_GET['search']) && !empty($_GET['search'])) ? zen_draw_hidden_field('search', $_GET['search']) : '') . ( (isset($_POST['search']) && !empty($_POST['search']) && empty($_GET['search'])) ? zen_draw_hidden_field('search', $_POST['search']) : '') . zen_image_submit('button_preview.gif', IMAGE_PREVIEW) . '  <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ( (isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '') . ( (isset($_POST['search']) && !empty($_POST['search']) && empty($_GET['search'])) ? '&search=' . $_POST['search'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
      </tr>
    </table></form>

Structure.PNG

52 minutes ago, OwenB said:

whenever we enter a book series number such as 1.5 it only stores as 1.

I see no such field in the table. What's the table like that contains the field you are having the problem with.

FYI - next time you post code, use the code <> button in the tool bar

Does this help?

<?php
/**
 * @package admin
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: html_output.php 19356 2011-08-22 05:22:42Z drbyte $
 */

////
// The HTML href link wrapper function
  function zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true) {
    global $request_type, $session_started, $http_domain, $https_domain;
    if ($page == '') {
      die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>Function used:<br><br>zen_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
    }

    if ($connection == 'NONSSL') {
      $link = HTTP_SERVER . DIR_WS_ADMIN;
    } elseif ($connection == 'SSL') {
      if (ENABLE_SSL_ADMIN == 'true') {
        $link = HTTPS_SERVER . DIR_WS_HTTPS_ADMIN;
      } else {
        $link = HTTP_SERVER . DIR_WS_ADMIN;
      }
    } else {
      die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>zen_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
    }
    if (!strstr($page, '.php')) $page .= '.php';
    if ($parameters == '') {
      $link = $link . $page;
      $separator = '?';
    } else {
      $link = $link . $page . '?' . $parameters;
      $separator = '&';
    }

    while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
    if ( ($add_session_id == true) && ($session_started == true) ) {
      if (defined('SID') && zen_not_null(SID)) {
        $sid = SID;
      } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL_ADMIN == 'true') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
//die($connection);
        if ($http_domain != $https_domain) {
          $sid = zen_session_name() . '=' . zen_session_id();
        }
      }
    }

    if (isset($sid)) {
      $link .= $separator . $sid;
    }

    return $link;
  }

  function zen_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL') {
    if ($connection == 'NONSSL') {
      $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;
    } elseif ($connection == 'SSL') {
      if (ENABLE_SSL_CATALOG == 'true') {
        $link = HTTPS_CATALOG_SERVER . DIR_WS_HTTPS_CATALOG;
      } else {
        $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;
      }
    } else {
      die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>zen_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
    }
    if ($parameters == '') {
      $link .= 'index.php?main_page='. $page;
    } else {
      $link .= 'index.php?main_page='. $page . "&" . zen_output_string($parameters);
    }

    while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

    return $link;
  }

////
// The HTML image wrapper function
  function zen_image($src, $alt = '', $width = '', $height = '', $params = '') {
    $image = '<img src="' . $src . '" border="0" alt="' . $alt . '"';
    if ($alt) {
      $image .= ' title=" ' . $alt . ' "';
    }
    if ($width) {
      $image .= ' width="' . $width . '"';
    }
    if ($height) {
      $image .= ' height="' . $height . '"';
    }
    if ($params) {
      $image .= ' ' . $params;
    }
    $image .= '>';

    return $image;
  }

////
// The HTML form submit button wrapper function
// Outputs a button in the selected language
  function zen_image_submit($image, $alt = '', $parameters = '') {
    global $language;

    $image_submit = '<input type="image" src="' . zen_output_string(DIR_WS_LANGUAGES . $_SESSION['language'] . '/images/buttons/' . $image) . '" border="0" alt="' . zen_output_string($alt) . '"';

    if (zen_not_null($alt)) $image_submit .= ' title=" ' . zen_output_string($alt) . ' "';

    if (zen_not_null($parameters)) $image_submit .= ' ' . $parameters;

    $image_submit .= '>';

    return $image_submit;
  }

////
// Draw a 1 pixel black line
  function zen_black_line() {
    return zen_image(DIR_WS_IMAGES . 'pixel_black.gif', '', '100%', '1');
  }

////
// Output a separator either through whitespace, or with an image
  function zen_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
    return zen_image(DIR_WS_IMAGES . $image, '', $width, $height);
  }

////
// Output a function button in the selected language
  function zen_image_button($image, $alt = '', $params = '') {
    global $language;

    return zen_image(DIR_WS_LANGUAGES . $_SESSION['language'] . '/images/buttons/' . $image, $alt, '', '', $params);
  }

////
// javascript to dynamically update the states/provinces list when the country is changed
// TABLES: zones
  function zen_js_zone_list($country, $form, $field) {
    global $db;
    $countries = $db->Execute("select distinct zone_country_id
                               from " . TABLE_ZONES . "
                               order by zone_country_id");

    $num_country = 1;
    $output_string = '';
    while (!$countries->EOF) {
      if ($num_country == 1) {
        $output_string .= '  if (' . $country . ' == "' . $countries->fields['zone_country_id'] . '") {' . "\n";
      } else {
        $output_string .= '  } else if (' . $country . ' == "' . $countries->fields['zone_country_id'] . '") {' . "\n";
      }

      $states = $db->Execute("select zone_name, zone_id
                              from " . TABLE_ZONES . "
                              where zone_country_id = '" . $countries->fields['zone_country_id'] . "'
                              order by zone_name");


      $num_state = 1;
      while (!$states->EOF) {
        if ($num_state == '1') $output_string .= '    ' . $form . '.' . $field . '.options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n";
        $output_string .= '    ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $states->fields['zone_name'] . '", "' . $states->fields['zone_id'] . '");' . "\n";
        $num_state++;
        $states->MoveNext();
      }
      $num_country++;
      $countries->MoveNext();
    }
    $output_string .= '  } else {' . "\n" .
                      '    ' . $form . '.' . $field . '.options[0] = new Option("' . TYPE_BELOW . '", "");' . "\n" .
                      '  }' . "\n";

    return $output_string;
  }

////
// Output a form
  function zen_draw_form($name, $action, $parameters = '', $method = 'post', $params = '', $usessl = 'false') {
    $form = '<form name="' . zen_output_string($name) . '" action="';
    if (zen_not_null($parameters)) {
      if ($usessl) {
        $form .= zen_href_link($action, $parameters, 'NONSSL');
      } else {
        $form .= zen_href_link($action, $parameters, 'NONSSL');
      }
    } else {
      if ($usessl) {
        $form .= zen_href_link($action, '', 'NONSSL');
      } else {
        $form .= zen_href_link($action, '', 'NONSSL');
      }
    }
    $form .= '" method="' . zen_output_string($method) . '"';
    if (zen_not_null($params)) {
      $form .= ' ' . $params;
    }
    $form .= '>';
    if (strtolower($method) == 'post') $form .= '<input type="hidden" name="securityToken" value="' . $_SESSION['securityToken'] . '" />';
    return $form;
  }

////
// Output a form input field
  function zen_draw_input_field($name, $value = '~*~*#', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) {
    $field = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"';

    if ( $value == '~*~*#' && (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
      $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
    } elseif ($value != '~*~*#' && zen_not_null($value)) {
      $field .= ' value="' . zen_output_string($value) . '"';
    }

    if (zen_not_null($parameters)) $field .= ' ' . $parameters;

    $field .= ' />';

    return $field;
  }

////
// Output a form password field
  function zen_draw_password_field($name, $value = '', $required = false) {
    $field = zen_draw_input_field($name, $value, 'maxlength="40"', $required, 'password', false);

    return $field;
  }

////
// Output a form filefield
  function zen_draw_file_field($name, $required = false) {
    $field = zen_draw_input_field($name, '', ' size="50" ', $required, 'file');

    return $field;
  }

////
// Output a selection field - alias function for zen_draw_checkbox_field() and zen_draw_radio_field()
  function zen_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '', $parameters = '') {
    $selection = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"';

    if (zen_not_null($value)) $selection .= ' value="' . zen_output_string($value) . '"';

    if ( ($checked == true) || (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ($GLOBALS[$name] == 'on')) || (isset($value) && isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && (stripslashes($GLOBALS[$name]) == $value)) || (zen_not_null($value) && zen_not_null($compare) && ($value == $compare)) ) {
      $selection .= ' checked="checked"';
    }

    if (zen_not_null($parameters)) $selection .= ' ' . $parameters;

    $selection .= ' />';

    return $selection;
  }

////
// Output a form checkbox field
  function zen_draw_checkbox_field($name, $value = '', $checked = false, $compare = '', $parameters = '') {
    return zen_draw_selection_field($name, 'checkbox', $value, $checked, $compare, $parameters);
  }

////
// Output a form radio field
  function zen_draw_radio_field($name, $value = '', $checked = false, $compare = '', $parameters = '') {
    return zen_draw_selection_field($name, 'radio', $value, $checked, $compare, $parameters);
  }

////
// Output a form textarea field
  function zen_draw_textarea_field($name, $wrap, $width, $height, $text = '~*~*#', $parameters = '', $reinsert_value = true) {
    $field = '<textarea name="' . zen_output_string($name) . '" wrap="' . zen_output_string($wrap) . '" cols="' . zen_output_string($width) . '" rows="' . zen_output_string($height) . '"';

    if (zen_not_null($parameters)) $field .= ' ' . $parameters;

    $field .= '>';

    if ($text == '~*~*#' && (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
      $field .= stripslashes($GLOBALS[$name]);
      $field = str_replace('&gt;', '>', $field);
    } elseif ($text != '~*~*#' && zen_not_null($text)) {
      $field = str_replace('&gt;', '>', $field);
      $field .= $text;
    }

    $field .= '</textarea>';

    return $field;
  }

////
// Output a form hidden field
  function zen_draw_hidden_field($name, $value = '', $parameters = '') {
    $field = '<input type="hidden" name="' . zen_output_string($name) . '"';

    if (zen_not_null($value)) {
      $field .= ' value="' . zen_output_string($value) . '"';
    } elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) {
      $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
    }

    if (zen_not_null($parameters)) $field .= ' ' . $parameters;

    $field .= ' />';

    return $field;
  }

////
// Output a form pull down menu
  function zen_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
//    $field = '<select name="' . zen_output_string($name) . '"';
    $field = '<select rel="dropdown" name="' . zen_output_string($name) . '"';

    if (zen_not_null($parameters)) $field .= ' ' . $parameters;

    $field .= '>' . "\n";

    if (empty($default) && isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) ) $default = stripslashes($GLOBALS[$name]);

    for ($i=0, $n=sizeof($values); $i<$n; $i++) {
      $field .= '<option value="' . zen_output_string($values[$i]['id']) . '"';
      if ($default == $values[$i]['id']) {
        $field .= ' selected="selected"';
      }

      $field .= '>' . zen_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>' . "\n";
    }
    $field .= '</select>' . "\n";

    if ($required == true) $field .= TEXT_FIELD_REQUIRED;

    return $field;
  }
////
// Hide form elements
  function zen_hide_session_id() {
    global $session_started;

    if ( ($session_started == true) && defined('SID') && zen_not_null(SID) ) {
      return zen_draw_hidden_field(zen_session_name(), zen_session_id());
    }
  }
?>

 

I'd be happy to change systems if we can find something that I can migrate in excess of 23,000 books to!

We don't have customer logins because it is an annual membership controlled by Sitelok.

All we need is:

Admin Add categories and sub-categories

Admin Add Books in the right sort order

User can browse categories and sub-categories then select a book and download either a MOBI or EPUB version or the entire serries

Just not experienced enough in PHP to write it from scratch

Thanks for taking the time to respond guys - it is really appreciated.

Whilst I look for an alternative system (as Zen-Cart cannot help and I did have it working once) I am going to install a 'dirty' patch and use the products price field as the sort order as we do not use the price field anyway.

Thanks again

Owen

Changing the column will not necesarily solve your problem. There is nothing in the table structure (a decimal(15,2) column) that would round 1.5 to 1, so my guess is somewhere in your code is rounding it to an integer value.

8 minutes ago, ginerjm said:

Just an odd thought.  A "sort order" field being defined as a decimal field seems wrong.  A simple field, char or integer, for sorting would make more sense.

It used to be an integer until we realised that we needed point 5 interim books and did somehow manage to get that working.  I'm trying to avoid using 100 for Book one and 150 for book 1.5 if possible but certainly a solution (we could divide that number by 100 to display in the user front end.  Will take a look ... thanks

10 minutes ago, Barand said:

Changing the column will not necesarily solve your problem. There is nothing in the table structure (a decimal(15,2) column) that would round 1.5 to 1, so my guess is somewhere in your code is rounding it to an integer value.

Thanks will take a deeper look into that

10 minutes ago, OwenB said:

It used to be an integer until we realised that we needed point 5 interim books and did somehow manage to get that working.  I'm trying to avoid using 100 for Book one and 150 for book 1.5 if possible but certainly a solution (we could divide that number by 100 to display in the user front end.  Will take a look ... thanks

Changed it to char and 1.75 returns as 1 so guessing Barand is correct - I need to find where this field is changed to an integer

OK, there could be multiple changes needed. SO, I would start by running a test. Edit a record in the DB (change a value of 1 to 1.5) and does that record correctly sort between 1's and 2's on the pages where it is to be sorted? If yes, then you only need to solve the problem of where that value is INSERTed/UPDATed in the database. I don't see any such queries in the code you have provided. Look for any code with queries that do INSERT or UPDATE for and which include the sort field. My guess is you will see something similar to the process I see used in the above queries

where p.products_id = '" . (int)$_GET['pID'] . "'

But, of course this would be for the sort field. Change "(int)" to "(float)" in those instances. That may be all that is needed. If not, we would want to trace back to where the variable used for that field may be modified before being used in the query.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.