#1 (permalink)  
Alt 16.07.2005, 03:24
 
Registriert seit: 24.06.2005
Beiträge: 3
Standard

I was tired in typing sort order values for atributes, so i wrote this small usefull something

It does two things :

1. disables/enables all inputs and selects in rows with unchecked/checked checkbox
2. when You are enabling some row - it counts nr of checked checkboxes, and autofills sort order filed with incremented nr.


at the end of admin/includes/general.js paste this function :

Code:
function enable_row(row_nr,total_rows) {

curr_sortorder = eval('"sortorder" + row_nr');
curr_model = eval('"model" + row_nr');
curr_stock = eval('"stock" + row_nr');
curr_weight = eval('"weight" + row_nr');

curr_weight_prefix = eval('"weight_prefix" + row_nr');
curr_value_prefix = eval('"value_prefix" + row_nr');
curr_value_price = eval('"value_price" + row_nr');

next_order=-1;
rows = total_rows + 1;
for(i=1;i<rows;i++) {
  checkbox = eval('"checkbox"+i');
    if(document.getElementById(checkbox).checked==true) {
    next_order += 1;
  }
}

if (document.getElementById(curr_sortorder).disabled==true) {
  document.getElementById(curr_sortorder).disabled=false;
  document.getElementById(curr_sortorder).value = next_order;
  document.getElementById(curr_model).disabled=false;
  document.getElementById(curr_stock).disabled=false;
  document.getElementById(curr_weight).disabled=false;
  document.getElementById(curr_weight_prefix).disabled=false;
  document.getElementById(curr_value_prefix).disabled=false;
  document.getElementById(curr_value_price).disabled=false;
  }
else {
  document.getElementById(curr_sortorder).disabled=true;
  document.getElementById(curr_sortorder).value = '';
  document.getElementById(curr_model).disabled=true;
  document.getElementById(curr_stock).disabled=true;
  document.getElementById(curr_weight).disabled=true;
  document.getElementById(curr_weight_prefix).disabled=true;
  document.getElementById(curr_value_prefix).disabled=true;
  document.getElementById(curr_value_price).disabled=true;
  }
}

in admin/new_attributes_include.php

1. find this :

Code:
     if ($isSelected) {
      $CHECKED = ' CHECKED';
     } else {
      $CHECKED = '';
     }

replace with this

Code:
     if ($isSelected) {
      $CHECKED = ' CHECKED';
      $DISABLED = '';
     } else {
      $CHECKED = '';
      $DISABLED= ' disabled';
     }



find this :
Code:
// Print the Current Value Name
      echo "<TR class=\"" . $rowClass . "\">";
      echo "<TD class=\"main\">";
      echo "<input type=\"checkbox\" name=\"optionValues[]\" value=\"" . $current_value_id . "\"" . $CHECKED . ">" . $current_value_name . "";
      echo "</TD>";
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_sortorder\" value=\"" . $sortorder . "\" size=\"4\"></TD>";
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_model\" value=\"" . $attribute_value_model . "\" size=\"15\"></TD>";
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_stock\" value=\"" . $attribute_value_stock . "\" size=\"4\"></TD>";
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_weight\" value=\"" . $attribute_value_weight . "\" size=\"10\"></TD>";
      echo "<TD class=\"main\" align=\"left\"><SELECT name=\"" . $current_value_id . "_weight_prefix\"><OPTION value=\"+\"" . $posCheck_weight . ">+<OPTION value=\"-\"" . $negCheck_weight . ">-</SELECT></TD>";

replace with this :

Code:
  // Print the Current Value Name
      echo "<TR class=\"" . $rowClass . "\">";
      echo "<TD class=\"main\">";
      echo "<input type=\"checkbox\" name=\"optionValues[]\" value=\"" . $current_value_id . "\"" . $CHECKED . " id=\"checkbox" . $i . "\" OnClick=\"enable_row('" . $i . "'," . $matches2 .")\">" . $current_value_name . "";
      echo "</TD>";
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_sortorder\" value=\"" . $sortorder . "\" size=\"4\" id=\"sortorder" . $i . "\"" . $DISABLED . "></TD>";
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_model\" value=\"" . $attribute_value_model . "\" size=\"15\" id=\"model" . $i . "\"" . $DISABLED . "></TD>";
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_stock\" value=\"" . $attribute_value_stock . "\" size=\"4\" id=\"stock" . $i . "\"" . $DISABLED . "></TD>";
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_weight\" value=\"" . $attribute_value_weight . "\" size=\"10\" id=\"weight" . $i . "\"" . $DISABLED . "></TD>";
      echo "<TD class=\"main\" align=\"left\"><SELECT name=\"" . $current_value_id . "_weight_prefix\" id=\"weight_prefix" . $i . "\"" . $DISABLED . "><OPTION value=\"+\"" . $posCheck_weight . ">+<OPTION value=\"-\"" . $negCheck_weight . ">-</SELECT></TD>";

find this :
Code:
 echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_price\" value=\"" . $attribute_value_price_calculate . "\" size=\"10\">";
 // brutto Admin

replace with this :
Code:
      echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_price\" value=\"" . $attribute_value_price_calculate . "\" size=\"10\" id=\"value_price" . $i . "\" " . $DISABLED . ">";
      // brutto Admin

find this :

Code:
      echo "</TD>";

       echo "<TD class=\"main\" align=\"left\"><SELECT name=\"" . $current_value_id . "_prefix\"> <OPTION value=\"+\"" . $posCheck . ">+<OPTION value=\"-\"" . $negCheck . ">-</SELECT></TD>";

replace with this :

Code:
      echo "</TD>";

       echo "<TD class=\"main\" align=\"left\"><SELECT name=\"" . $current_value_id . "_prefix\" id=\"value_prefix" . $i . "\" " . $DISABLED . "> <OPTION value=\"+\"" . $posCheck . ">+<OPTION value=\"-\"" . $negCheck . ">-</SELECT></TD>";

if You are useing downloadeble products, You need to change also inputs for those products and add those inputs in js function.


Hope it will be usefull. I also write some Attribute manager , and Product Options improvemnts (groups of attributes asigned for certain category/categories etc, etc)...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Wong this Post!
Mit Zitat antworten
Antwort

Lesezeichen

Stichworte
atribute, auto, order, sort

Themen-Optionen
Ansicht

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are aus
Pingbacks are aus
Refbacks are aus



Alle Zeitangaben in WEZ +1. Es ist jetzt 05:05 Uhr.

Copyright © 2011 xt:Commerce GmbH / xt:Commerce International Ltd. - All Rights Reserved

xt:Commerce is a SafeCharge brand