Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Parts Filter
- Bootstrapped by Tsimi - December 2015
- osCommerce, Open Source E-Commerce Solutions
- http://www.oscommerce.com
- Copyright (c) 2015 osCommerce
- Released under the GNU General Public License
- */
- require('includes/application_top.php');
- $printer_category_id = $_REQUEST['printer_category_id'];
- $parent_id = $_REQUEST['parent_id'];
- if(isset($_REQUEST['printer_category_id'])&&($_REQUEST['printer_category_id']!='')) {
- $vehcat_query = tep_db_query("SELECT * FROM ".TABLE_PRINTER_CATEGORY." WHERE printer_category_id = '".$_REQUEST['printer_category_id']."'");
- $vehcat_row = tep_db_fetch_array($vehcat_query);
- }
- $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
- // Ultimate SEO URLs v2.1
- // If the action will affect the cache entries
- if ( preg_match("(insert|update|setflag)", $action) ) include_once('includes/reset_seo_cache.php');
- if (tep_not_null($action)) {
- switch ($action) {
- case 'assign_products':
- $productids = "";
- // $mediacat_ref_no = "";
- // $mediacat_quantity = "";
- $selvalarray = array();
- $pagearray = array();
- $remproductarray = array();
- //$products_query_raw = 'select distinct p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id, p.products_mediacat_ref_no, p.products_mediacat_quantity from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd, '.TABLE_PRINTER_CATEGORY.' pc where p.products_id = pd.products_id and p.products_id = pc.printer_category_id and pd.language_id = "'.(int)$languages_id.'" and pc.printer_category_id = "'.(int)$printer_category_id.'" order by pd.products_id asc';
- // working original query
- $products_query_raw = 'select distinct p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd, '.TABLE_PRINTER_CATEGORY.' pc where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and pc.printer_category_id = "'.$printer_category_id.'" order by pd.products_name asc';
- $products_query = tep_db_query($products_query_raw);
- $products_split = new splitPageResults($_REQUEST['page'], MAX_DISPLAY_SEARCH_RESULTS, $products_query_raw, $products_query_numrows);
- $products_query = tep_db_query($products_query_raw);
- while ($products = tep_db_fetch_array($products_query)) {
- array_push($pagearray,$products['products_id']);
- }
- if(isset($HTTP_POST_VARS['productids'])) {
- foreach($HTTP_POST_VARS['productids'] as $val) {
- if($val!='') {
- array_push($selvalarray,$val);
- $productids .= $val.",";
- }
- }
- }
- foreach($pagearray as $val) {
- if(!in_array($val,$selvalarray)) {
- array_push($remproductarray,$val);
- }
- }
- $olderdata = $vehcat_row['productids'];
- $finaldata = "";
- if($olderdata!='') {
- $oldprodarray = explode(",",$olderdata);
- foreach($oldprodarray as $val) {
- if(!in_array($val,$remproductarray)) {
- if(!in_array($val,$selvalarray)) {
- array_push($selvalarray,$val);
- }
- }
- }
- $productids = "";
- foreach($selvalarray as $val) {
- $productids .= $val.",";
- }
- $finaldata = substr($productids,0,-1);
- } else {
- $finaldata = substr($productids,0,-1);
- }
- $update_sql_data = array('productids' => $finaldata);
- tep_db_perform(TABLE_PRINTER_CATEGORY, $update_sql_data, 'update', "printer_category_id = '" . (int)$printer_category_id . "'");
- tep_redirect(tep_href_link(FILENAME_PRINTER_PRODUCTS, 'parent_id=' . $parent_id.'&printer_category_id='.$printer_category_id.'&page='.$_REQUEST['page'] ));
- break;
- }
- }
- require(DIR_WS_INCLUDES . 'template_top.php');
- $vehcat_query = tep_db_query("SELECT * FROM ".TABLE_PRINTER_CATEGORY." WHERE printer_category_id = '".$_REQUEST['printer_category_id']."'");
- $vehcat_row = tep_db_fetch_array($vehcat_query);
- $prodidsarr = explode(",",$vehcat_row['productids']);
- require(DIR_WS_INCLUDES . 'functions/filter_test.php');
- ?>
- <div class="row">
- <div class="col-md-7">
- <h3><?php echo HEADING_TITLE." ".$vehcat_row['category_name']; ?></h3>
- </div>
- <div class="col-md-4 text-right">
- <?php echo tep_draw_form('printerfilter', FILENAME_PRINTER_PRODUCTS, 'action=assign_products&parent_id='.$parent_id.'&printer_category_id='.$printer_category_id.'&page='.$_REQUEST['page'], 'post');?>
- <?php echo tep_draw_button(IMAGE_GO_BACK, 'fa fa-chevron-left', tep_href_link(FILENAME_PRINTER_CATEGORY, 'printer_category_id='.$printer_category_id.'&parent_id=' . $parent_id), 'primary') . ' ' . tep_draw_button(IMAGE_BUTTON_SAVE, 'fa fa-floppy-o', null, null, null, 'btn-success'); ?>
- </div>
- </div>
- <div class="table-responsive">
- <table class="table table-condensed table-hover header">
- <thead><!-- table head-->
- <tr>
- <th><?php echo TABLE_HEADING_PRODUCT_ID; ?></th>
- <th><?php echo TABLE_HEADING_PRODUCT_MODEL;?></th>
- <th><?php echo TABLE_HEADING_PRODUCT_NAME;?></th>
- <th><?php echo TABLE_HEADING_PRODUCT_CATEGORY_NAME;?></th>
- <th><?php echo TABLE_HEADING_PRODUCT_SELECT;?></th>
- </tr>
- </thead>
- <tbody>
- <?php
- //$products_query_raw = 'select distinct p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id, p.products_mediacat_ref_no, p.products_mediacat_quantity from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by pd.products_id asc';
- $products_query_raw = 'select distinct p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by pd.products_id asc';
- $products_split = new splitPageResults($_REQUEST['page'], '70', $products_query_raw, $products_query_numrows);
- $products_query = tep_db_query($products_query_raw);
- while ($products = tep_db_fetch_array($products_query)) {
- if ( strpos( tep_get_product_path($products['products_id']), "_" ) == FALSE ) {
- $result = tep_get_category_name2( tep_get_product_path( $products['products_id'] ) );
- } else {
- $pieces = explode("_", tep_get_product_path($products['products_id']) );
- $categories_array = array();
- $categories_array = tep_get_categories( $categories_array, $pieces[0] );
- for ( $j = 0 ; $j < count($categories_array) ; $j++ ) {
- if ( $categories_array[ $j ]['id'] == $pieces[ count( $pieces ) - 1 ] ) {
- $result = $categories_array[ $j ][ 'text' ];
- break;
- }
- }
- }
- ?>
- <?php if(in_array($products['products_id'],$prodidsarr)) { ?>
- <tr bgcolor="#cccccc">
- <?php } else { ?>
- <tr>
- <?php } ?>
- <td class="col-md-1"><?php echo $products['products_id'];?></td>
- <td class="col-md-2"><?php echo $products['products_model'];?></td>
- <td class="col-md-2"><?php echo $products['products_name'];?></td>
- <td class="col-md-2"><?php echo $result; ?></td>
- <!--<td class="col-md-1"><input type="checkbox" name="productids[]" value="<?php echo $products['products_id'];?>" <?php if(in_array($products['products_id'],$prodidsarr)) echo 'checked';?> /></td> //-->
- <td class="col-md-1"><input type="checkbox" name="productids[]" value="<?php echo $products['products_id'];?>" <?php if(in_array($products['products_id'],$prodidsarr)) echo 'checked';?> /></td>
- <?php
- } // End of while
- ?>
- </tr>
- </tbody>
- </table>
- </div>
- <div class="row">
- <div class="col-xs-11 text-right">
- <?php echo tep_draw_button(IMAGE_GO_BACK, 'fa fa-chevron-left', tep_href_link(FILENAME_PRINTER_CATEGORY, 'printer_category_id='.$printer_category_id.'&parent_id=' . $parent_id), 'primary') . ' ' . tep_draw_button(IMAGE_BUTTON_SAVE, 'fa fa-floppy-o', null, null, null, 'btn-success'); ?>
- </div>
- </div>
- </form>
- <!-- body_eof //-->
- <?php
- require(DIR_WS_INCLUDES . 'template_bottom.php');
- require(DIR_WS_INCLUDES . 'application_bottom.php');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment