ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/option_values.php
Go to the documentation of this file.
00001 <?php
00009 ?>
00010 <?php
00011   require('includes/application_top.php');
00012 
00013   // verify option values exist
00014   $chk_option_values = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id='" . (int)$_SESSION['languages_id'] . "' limit 1");
00015   if ($chk_option_values->RecordCount() < 1) {
00016     $messageStack->add_session(ERROR_DEFINE_OPTION_VALUES, 'caution');
00017     zen_redirect(zen_href_link(FILENAME_OPTIONS_VALUES_MANAGER));
00018   }
00019 
00020   require(DIR_WS_CLASSES . 'currencies.php');
00021   $currencies = new currencies();
00022 
00023   switch($_GET['action']) {
00024     case ('update_sort_order'):
00025       foreach($_POST['options_values_new_sort_order'] as $id => $new_sort_order) {
00026         $row++;
00027 
00028         $db->Execute("UPDATE " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_sort_order= " . (int)$_POST['options_values_new_sort_order'][$id] . " where products_options_values_id=" . (int)$id);
00029       }
00030       $messageStack->add_session(SUCCESS_OPTION_VALUES_SORT_ORDER . ' ' . zen_options_name($_GET['options_id']), 'success');
00031       $_GET['action']='';
00032       zen_redirect(zen_href_link(FILENAME_PRODUCTS_OPTIONS_VALUES));
00033       break;
00034 // update by product
00035     case ('update_product'):
00036       $messageStack->add_session(SUCCESS_PRODUCT_UPDATE_SORT . $_POST['products_update_id'] . ' ' . zen_get_products_name($_POST['products_update_id'], $_SESSION['languages_id']), 'success');
00037       zen_update_attributes_products_option_values_sort_order($_POST['products_update_id']);
00038       $action='';
00039       zen_redirect(zen_href_link(FILENAME_PRODUCTS_OPTIONS_VALUES));
00040       break;
00041 // update by category
00042     case ('update_categories_attributes'):
00043       $all_products_attributes= $db->Execute("select ptoc.products_id, pa.products_attributes_id from " .
00044       TABLE_PRODUCTS_TO_CATEGORIES . " ptoc, " .
00045       TABLE_PRODUCTS_ATTRIBUTES . " pa " . "
00046       where ptoc.categories_id = '" . (int)$_POST['categories_update_id'] . "' and
00047       pa.products_id = ptoc.products_id"
00048       );
00049       while (!$all_products_attributes->EOF) {
00050         $count++;
00051         $product_id_updated .= ' - ' . $all_products_attributes->fields['products_id'] . ':' . $all_products_attributes->fields['products_attributes_id'];
00052         zen_update_attributes_products_option_values_sort_order($all_products_attributes->fields['products_id']);
00053         $all_products_attributes->MoveNext();
00054       }
00055       $messageStack->add_session(SUCCESS_CATEGORIES_UPDATE_SORT . (int)$_POST['categories_update_id'] . ' ' . zen_get_category_name($_POST['categories_update_id'], $_SESSION['languages_id']), 'success');
00056       $action='';
00057       zen_redirect(zen_href_link(FILENAME_PRODUCTS_OPTIONS_VALUES));
00058       break;
00059 // update all products in catalog
00060     case ('update_all_products_attributes_sort_order'):
00061       if (isset($_POST['confirm']) && $_POST['confirm'] == 'y')
00062       {
00063         $all_products_attributes= $db->Execute("select p.products_id, pa.products_attributes_id from " .
00064         TABLE_PRODUCTS . " p, " .
00065         TABLE_PRODUCTS_ATTRIBUTES . " pa " . "
00066         where p.products_id= pa.products_id"
00067         );
00068         while (!$all_products_attributes->EOF) {
00069           $count++;
00070           zen_update_attributes_products_option_values_sort_order($all_products_attributes->fields['products_id']);
00071           $all_products_attributes->MoveNext();
00072         }
00073       }
00074       $messageStack->add_session(SUCCESS_PRODUCT_UPDATE_SORT_ALL, 'success');
00075       $action='';
00076       zen_redirect(zen_href_link(FILENAME_PRODUCTS_OPTIONS_VALUES));
00077       break;
00078   } // switch
00079 ?>
00080 <!doctsype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00081 <html <?php echo HTML_PARAMS; ?>>
00082 <head>
00083 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00084 <title><?php echo TITLE; ?></title>
00085 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00086 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00087 <script language="javascript" src="includes/menu.js"></script>
00088 <script language="javascript" src="includes/general.js"></script>
00089 <script type="text/javascript">
00090   <!--
00091   function init()
00092   {
00093     cssjsmenu('navbar');
00094     if (document.getElementById)
00095     {
00096       var kill = document.getElementById('hoverJS');
00097       kill.disabled = true;
00098     }
00099   }
00100   // -->
00101 </script>
00102 </head>
00103 <body onload="init()" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
00104 <!-- header //-->
00105 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00106 <!-- header_eof //-->
00107 
00108 <!-- body //-->
00109 <table border="0" width="100%" cellspacing="2" cellpadding="2">
00110   <tr>
00111 <!-- body_text //-->
00112     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00113       <tr>
00114         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00115           <tr>
00116             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00117             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00118           </tr>
00119         </table></td>
00120       </tr>
00121       <tr>
00122         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00123 <?php
00124 if ($_GET['options_id']=='') {
00125 ?>
00126   <table border="1" cellspacing="1" cellpadding="2" bordercolor="gray">
00127     <tr class="dataTableHeadingRow">
00128       <td colspan="3" align="center" class="dataTableHeadingContent"><?php echo TEXT_UPDATE_OPTION_VALUES; ?></td>
00129     </tr>
00130     <tr class="dataTableHeadingRow">
00131 <?php echo zen_draw_form('quick_jump', FILENAME_PRODUCTS_OPTIONS_VALUES, '', 'get'); ?>
00132       <td class="dataTableHeadingContent"> <?php echo TEXT_SELECT_OPTION; ?> </td>
00133       <td class="dataTableHeadingContent">&nbsp;<select name="options_id">
00134 <?php
00135         $options_values = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$_SESSION['languages_id'] . "' and products_options_name !='' and products_options_type !='" . (int)PRODUCTS_OPTIONS_TYPE_TEXT . "' and products_options_type !='" . (int)PRODUCTS_OPTIONS_TYPE_FILE . "' order by products_options_name");
00136         while(!$options_values->EOF) {
00137             echo "\n" . '<option name="' . $options_values->fields['products_options_name'] . '" value="' . $options_values->fields['products_options_id'] . '">' . $options_values->fields['products_options_name'] . '</option>';
00138             $options_values->MoveNext();
00139         }
00140 ?>
00141       </select>&nbsp;</td>
00142       <td align="center" class="dataTableHeadingContent">&nbsp;<?php echo zen_image_submit('button_edit.gif', IMAGE_EDIT); ?>&nbsp;</td>
00143       </form>
00144     </tr>
00145   </table>
00146 <?php
00147 } else {
00148 ?>
00149   <table border="1" cellspacing="3" cellpadding="2" bordercolor="gray">
00150     <tr class="dataTableHeadingRow">
00151       <td colspan="3" class="dataTableHeadingContent" align="center"><?php echo TEXT_EDIT_OPTION_NAME; ?> <?php echo zen_options_name($_GET['options_id']); ?></td>
00152     </tr>
00153 <?php // echo zen_draw_form('update', zen_href_link(FILENAME_PRODUCTS_OPTIONS_VALUES, 'action=update_sort_order&options_id=' . $_GET['options_id'], 'NONSSL'), '', 'post'); ?>
00154 <?php echo zen_draw_form('update', FILENAME_PRODUCTS_OPTIONS_VALUES, 'action=update_sort_order&options_id=' . $_GET['options_id'], 'post'); ?>
00155 <?php
00156     echo '    <tr class="dataTableHeadingRow"><td class="dataTableHeadingContent">Option ID</td><td class="dataTableHeadingContent">Option Value Name</td><td class="dataTableHeadingContent">Sort Order</td></tr><tr>';
00157 
00158     $row = $db->Execute("SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " povtpo WHERE povtpo.products_options_values_id = pov.products_options_values_id and povtpo.products_options_id='" . (int)$_GET['options_id'] . "' and pov.language_id = '" . (int)$_SESSION['languages_id'] . "' ORDER BY pov.products_options_values_sort_order, pov.products_options_values_id");
00159 
00160     if (!$row->EOF) {
00161        $option_values_exist = true;
00162         while (!$row->EOF) {
00163             echo '      <td align="right" class="dataTableContent">' . $row->fields["products_options_values_id"] . '</td>' . "\n";
00164             echo '      <td class="dataTableContent">' . $row->fields["products_options_values_name"] . '</td>' . "\n";
00165             echo '      <td class="dataTableContent" align="center">' . "<input type=\"text\" name=\"options_values_new_sort_order[".$row->fields['products_options_values_id']."]\" value={$row->fields['products_options_values_sort_order']} size=\"4\">" . '</td>' . "\n";
00166             echo '    </tr>' . "\n";
00167           $row->MoveNext();
00168         }
00169 //        while($row = mysql_fetch_array($result));
00170     } else {
00171        $option_values_exist = false;
00172        echo '      <td colspan="3" height="50" align="center" valign="middle" class="dataTableContent">' . TEXT_NO_OPTION_VALUE . zen_options_name($_GET['options_id']) . '</td>' . "\n";
00173     }
00174 ?>
00175     <tr class="dataTableHeadingRow">
00176       <?php
00177         if ($option_values_exist == true) {
00178       ?>
00179       <td colspan="2" height="50" align="center" valign="middle" class="dataTableHeadingContent">
00180         <input type="submit" value="<?php echo TEXT_UPDATE_SUBMIT; ?>">
00181       </td>
00182       <?php
00183         }
00184       ?>
00185       <td colspan="<?php echo ($option_values_exist == true ? '1' : '3'); ?>"height="50" align="center" valign="middle" class="dataTableHeadingContent"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_OPTIONS_VALUES) . '">'; ?><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a></td>
00186     </tr>
00187   </form>
00188   </table>
00189 <?php
00190 } // which table
00191 ?>
00192 <?php
00194 // BOF: Update by Product, Category or All products
00195 // only show when not updating Option Value Sort Order
00196 if (empty($_GET['options_id'])) {
00197 
00198 // select from all product with attributes
00199 ?>
00200       <tr>
00201         <td colspan="2" class="main" align="left"><br /><?php echo TEXT_UPDATE_SORT_ORDERS_OPTIONS; ?></td>
00202       </tr>
00203 
00204       <tr>
00205         <td colspan="2" class="main" align="left"><br /><?php echo TEXT_UPDATE_SORT_ORDERS_OPTIONS_PRODUCTS; ?></td>
00206       </tr>
00207       <tr><form name="update_product_attributes" <?php echo 'action="' . zen_href_link(FILENAME_PRODUCTS_OPTIONS_VALUES, 'action=update_product') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('products_update_id', $_GET['products_update_id']); ?><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
00208         <td colspan="2"><table border="0" cellspacing="0" cellpadding="2">
00209           <tr>
00210             <td class="main"><?php echo zen_draw_products_pull_down_attributes('products_update_id'); ?></td>
00211             <td class="main" align="right" valign="top"><?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
00212           </tr>
00213         </table></td>
00214       </form></tr>
00215 
00216 <?php
00217 // select from all categories with products with attributes
00218 ?>
00219       <tr>
00220         <td colspan="2" class="main" align="left"><br /><?php echo TEXT_UPDATE_SORT_ORDERS_OPTIONS_CATEGORIES; ?></td>
00221       </tr>
00222       <tr><form name="update_categories_attributes" <?php echo 'action="' . zen_href_link(FILENAME_PRODUCTS_OPTIONS_VALUES, 'action=update_categories_attributes') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('categories_update_id', $_GET['categories_update_id']); ?><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
00223         <td colspan="2"><table border="0" cellspacing="0" cellpadding="2">
00224           <tr>
00225             <td class="main" align="left" valign="top"><?php echo zen_draw_products_pull_down_categories_attributes('categories_update_id'); ?></td>
00226             <td class="main" align="right" valign="middle"><?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
00227           </tr>
00228         </table></td>
00229       </form></tr>
00230 
00231 <?php
00232 // select the catalog and update all products with attributes
00233 ?>
00234       <tr>
00235         <td colspan="2"><br /><table border="0" cellspacing="0" cellpadding="2">
00236           <tr>
00237             <td class="main" align="left" valign="top"><?php echo TEXT_INFO_ATTRIBUTES_FEATURES_UPDATES; ?></td>
00238             <td><?php echo zen_draw_form('update_all_sort', FILENAME_PRODUCTS_OPTIONS_VALUES, 'action=update_all_products_attributes_sort_order')?><?php echo zen_draw_hidden_field('confirm', 'y'); ?> <?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE); ?></form></td>
00239           </tr>
00240         </table></td>
00241       </tr>
00242 <?php
00243 }
00244 // EOF: Update by Product, Category or All products
00246 ?>
00247 
00248         </table></td>
00249       </tr>
00250 
00251     </table></td>
00252 <!-- body_text_eof //-->
00253 
00254   </tr>
00255 </table>
00256 <!-- body_eof //-->
00257 
00258 <!-- footer //-->
00259 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
00260 <!-- footer_eof //-->
00261 </body>
00262 </html>
00263 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations