leon        01/11/01 12:45:01

  Modified:    freetrade2/modules/database/mysql department
               freetrade2/modules/screen admin_departments admin_item item
               freetrade2/modules/utility standard_library
  Log:
  fixed up department bugs
  
  Revision  Changes    Path
  1.10      +63 -55    freetrade/freetrade2/modules/database/mysql/department
  
  Index: department
  ===================================================================
  RCS file: /home/cvs/freetrade/freetrade2/modules/database/mysql/department,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- department        2001/10/31 18:33:09     1.9
  +++ department        2001/11/01 20:44:59     1.10
  @@ -6,7 +6,7 @@
        ** Author: Leon Atkinson
        ** Email: [EMAIL PROTECTED]
        ** CVS Author: $Author: leon $
  -     ** Last Revised: $Date: 2001/10/31 18:33:09 $
  +     ** Last Revised: $Date: 2001/11/01 20:44:59 $
        **
        */
   
  @@ -177,77 +177,85 @@
   
   
        /*
  -     ** Function: departmentOptions
  -     ** Input: 
  -     ** Output: 
  -     ** Description:
  +     ** Function: getDepartmentParents
  +     ** Input: INTEGER root, INTEGER leve, ARRAY REF selected, BOOLEAN
  +     ** Output: ARRAY
  +     ** Description: This function returns an array suitable for the
  +     ** selectField function.  Note that selected is passed by reference
  +     ** in order to mitigate filling up the stack.  We'll be careful to
  +     ** read from this array only, no changing values.
        */
  -     function departmentOptions($root, $level, $selected, $multiple=TRUE)
  +     function getDepartmentParents(&$selected, $root=0, $level=1)
        {
                global $DatabaseLink;
   
  -     
  -             $Query = "SELECT ID, Name ";
  -             $Query .= "FROM department ";
  -             $Query .= "WHERE Parent=$root ORDER BY DisplayPrecedence";
  -             $DatabaseResult = mysql_query($Query, $DatabaseLink);
  -             while($DatabaseRow = mysql_fetch_row($DatabaseResult))
  +             $r = array();
  +
  +             //Add 'imaginary' department 0, the root of all departments
  +             if($root==0)
                {
  -                     $department_ID = $DatabaseRow[0];
  -                     $department_Name = $DatabaseRow[1];
  -     
  -                     $r .= "<option value=\"$department_ID\"";
  -                     
  -                     if( (is_array($selected) && 
  -                             isset($selected[$department_ID]) &&
  -                             ($selected[$department_ID])) || 
  -                             ($department_ID == $selected))
  +                     if(is_array($selected) AND in_array(0, $selected))
                        {
  -                                                     
  -                             $r .= " selected";
  +                             $sel = TRUE;
                        }
  -                     
  -                     $r .= ">";
  -                     
  -                     for($index=0; $index < $level; $index++)
  +                     elseif($selected == 0)
                        {
  -                             $r .= "&nbsp;&nbsp;";
  +                             $sel = TRUE;
                        }
  -                     
  -                     $r .= "$department_Name</option>\n";
  -                     
  -                     $r .= departmentOptions($department_ID, $level+1, $selected);
  -                     
  -                     
  -                     
  +                     else
  +                     {
  +                             $sel = FALSE;
  +                     }
  +
  +                     array_push($r, array(0, 'Root', $sel));
                }
  -                             
  -             return($r);
  -     }
   
  -     /*
  -     ** Function: departmentSelector
  -     ** Input: 
  -     ** Output: 
  -     ** Description:
  -     */
  -     function departmentSelector($name, $selected=0, $multiple=TRUE, $size=5)
  -     {
  -             $r = "<select name=\"$name\"";
  -             if($multiple)
  +     
  +             $Query = "SELECT ID, Name " .
  +                     "FROM department " .
  +                     "WHERE Parent=$root " .
  +                     "ORDER BY DisplayPrecedence, Name ";
  +
  +             if(!($DatabaseResult = mysql_query($Query, $DatabaseLink)))
                {
  -                     $r .= " multiple";
  +                     addToLog("Couldn't get departments! " . 
  +                             $Query . mysql_errno() . ": " . mysql_error(),
  +                             LOG_EMERGENCY, __FILE__, __LINE__);
  +                     return(FALSE);
                }
  -             $r .= " size=\"$size\"";
  -             $r .= ">\n";
   
  -             $r .= departmentOptions(0, 0, $selected);
  -             
  -             $r .= "</select>\n";
  +             while($Row = mysql_fetch_object($DatabaseResult))
  +             {
  +                     //selected can be an array or a single value
  +                     if(is_array($selected) AND in_array($Row->ID, $selected))
  +                     {
  +                             $sel = TRUE;
  +                     }
  +                     elseif($selected == $Row->ID)
  +                     {
  +                             $sel = TRUE;
  +                     }
  +                     else
  +                     {
  +                             $sel = FALSE;
  +                     }
                
  +                     //add this department to array
  +                     array_push($r, array(
  +                             $Row->ID, 
  +                             str_repeat('&nbsp;&nbsp;', $level) . $Row->Name, 
  +                             $sel));
  +                     
  +                     //add any children
  +                     $c = getDepartmentParents($selected, $Row->ID, $level+1);
  +                     if(count($c))
  +                     {
  +                             $r = array_merge($r, $c);
  +                     }
  +             }
  +                             
                return($r);
        }
  -
   
   
   
  
  
  
  1.7       +5 -7      freetrade/freetrade2/modules/screen/admin_departments
  
  Index: admin_departments
  ===================================================================
  RCS file: /home/cvs/freetrade/freetrade2/modules/screen/admin_departments,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- admin_departments 2000/11/08 00:54:35     1.6
  +++ admin_departments 2001/11/01 20:45:00     1.7
  @@ -11,7 +11,7 @@
        ** Author: Shannon -jj Behrens
        ** Email: [EMAIL PROTECTED]
        ** CVS Author: $Author: leon $
  -     ** Last Revised: $Date: 2000/11/08 00:54:35 $
  +     ** Last Revised: $Date: 2001/11/01 20:45:00 $
        ** Copyright (c) 1999 Working Dogs.  All rights reserved.
        **
        ** Input: possibly $department, $expandDepartments
  @@ -105,17 +105,15 @@
                */
                
                //Name
  -             printEditRow(L_ADMINDEPARTMENTS_NAME, "inputName", 
  -                     prepareText($d["Name"]));
  +             printEditRow(L_ADMINDEPARTMENTS_NAME, "inputName", $d["Name"]);
        
                //Parent
                printTableRow(L_ADMINDEPARTMENTS_PARENT, 
  -                     departmentSelector("inputParent", $d["Parent"], FALSE), 
  +                     selectField("inputParent", 
getDepartmentParents($d["Parent"])), 
                        FALSE);
        
                //Graphic
  -             printEditRow(L_ADMINDEPARTMENTS_GRAPHIC, "inputGraphic", 
  -                     prepareText($d["Graphic"]));
  +             printEditRow(L_ADMINDEPARTMENTS_GRAPHIC, "inputGraphic", 
$d["Graphic"]);
        
                //Description
                printTableRow(L_ADMINDEPARTMENTS_DESCRIPTION, 
  @@ -124,7 +122,7 @@
        
                //Display Precedence
                printEditRow(L_ADMINDEPARTMENTS_DISPLAYPRECEDENCE, 
"inputDisplayPrecedence", 
  -                     prepareText($d["DisplayPrecedence"]), 2);
  +                     $d["DisplayPrecedence"], 2);
        
                //Submit Button
                printSubmit(L_ADMINDEPARTMENTS_UPDATEDEPARTMENT, 
L_ADMINDEPARTMENTS_RESET);
  
  
  
  1.9       +6 -11     freetrade/freetrade2/modules/screen/admin_item
  
  Index: admin_item
  ===================================================================
  RCS file: /home/cvs/freetrade/freetrade2/modules/screen/admin_item,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- admin_item        2000/11/08 00:54:36     1.8
  +++ admin_item        2001/11/01 20:45:00     1.9
  @@ -3,26 +3,19 @@
        ** File: admin_item
        ** Description: Everything (hopefully) the admin ever wanted for
        **   administrating items (including access to the skus).
  -     ** Version: $Revision: 1.8 $
  +     ** Version: $Revision: 1.9 $
        ** Created: 04/08/1999
        ** Author: Leon Atkinson, Shannon -jj Behrens
        ** Email: [EMAIL PROTECTED], [EMAIL PROTECTED]
        ** CVS Author: $Author: leon $
  -     ** Last Revised: $Date: 2000/11/08 00:54:36 $
  +     ** Last Revised: $Date: 2001/11/01 20:45:00 $
        **
        ** Copyright (c) 1999 Working Dogs.  All rights reserved.
        */
   
  -     //Need DepartmentSelector
        include_once(DATABASE_MODULE . "department");
  -
  -     //Need getItemInfo
        include_once(DATABASE_MODULE . "item");
  -
        include_once(DATABASE_MODULE . "relationship");
  -
  -
  -     //Need box
        include_once(MODULE . "utility/box");
   
   
  @@ -94,8 +87,10 @@
   
        //Department
        printTableRow(L_ADMINITEM_DEPARTMENT, 
  -             departmentSelector("inputDepartment[]", $i["Department"], 
  -                     ITEMS_IN_MULTIPLE_DEPARTMENTS), 
  +             selectField(
  +                     "inputDepartment[]", 
  +                     getDepartmentParents($i["Department"]),
  +                     0, 5, ITEMS_IN_MULTIPLE_DEPARTMENTS), 
                FALSE);
   
        //Description
  
  
  
  1.11      +4 -3      freetrade/freetrade2/modules/screen/item
  
  Index: item
  ===================================================================
  RCS file: /home/cvs/freetrade/freetrade2/modules/screen/item,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- item      2001/10/27 00:07:19     1.10
  +++ item      2001/11/01 20:45:00     1.11
  @@ -3,12 +3,12 @@
        /*
        ** File: item
        ** Description: show details about an item
  -     ** Version: $Revision: 1.10 $
  +     ** Version: $Revision: 1.11 $
        ** Created: 04/22/1999
        ** Author: Leon Atkinson, Shannon -jj Behrens,
        ** Email: [EMAIL PROTECTED], [EMAIL PROTECTED]
        ** CVS Author: $Author: leon $
  -     ** Last Revised: $Date: 2001/10/27 00:07:19 $
  +     ** Last Revised: $Date: 2001/11/01 20:45:00 $
        */
   
        //get attribute functions
  @@ -141,7 +141,8 @@
                //set price
                $price = formatMoney($sku["SalePrice"]);
                
  -             if($sku["SalePrice"] != $sku["ListPrice"])
  +             if(($sku["ListPrice"] > 0.00) AND 
  +                     ($sku["SalePrice"] < $sku["ListPrice"]))
                {
                        $price .= "<br>\nNormally " . formatMoney($sku["ListPrice"]);
                }
  
  
  
  1.25      +15 -5     freetrade/freetrade2/modules/utility/standard_library
  
  Index: standard_library
  ===================================================================
  RCS file: /home/cvs/freetrade/freetrade2/modules/utility/standard_library,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- standard_library  2001/10/31 18:33:10     1.24
  +++ standard_library  2001/11/01 20:45:01     1.25
  @@ -6,12 +6,12 @@
        ** 75% of all page views.  Most of these functions were in global_settings
        ** at one time.
        **
  -     ** Version: $Revision: 1.24 $
  +     ** Version: $Revision: 1.25 $
        ** Created: 10/4/99
        ** Author: Leon Atkinson
        ** Email: [EMAIL PROTECTED]
        ** CVS Author: $Author: leon $
  -     ** Last Revised: $Date: 2001/10/31 18:33:10 $
  +     ** Last Revised: $Date: 2001/11/01 20:45:01 $
        */
   
   
  @@ -100,7 +100,7 @@
                                else
                                {
                                        //Adds something like "&item=123"
  -                                     $get .= $getSeparator . "$key=" . 
prepareText($val);
  +                                     $get .= $getSeparator . "$key=" . 
prepareText(rawurlencode($val));
                                        $getSeparator = '&amp;';
                                }
                        }
  @@ -850,9 +850,19 @@
   
   
   
  -     function selectField($name, $data, $breaks=0)
  +     function selectField($name, $data, $breaks=0, $size=1, $multiple=FALSE)
        {
  -             $tag = "<select name=\"$name\">\n";
  +             $size = (integer)$size;
  +             $tag = "<select name=\"$name\"";
  +             if($size > 1)
  +             {
  +                     $tag .= " size=\"$size\"";
  +             }
  +             if($multiple)
  +             {
  +                     $tag .= " multiple=\"multiple\"";
  +             }
  +             $tag .= ">\n";
        
                foreach($data as $option)
                {
  
  
  
_______________________________________________
FreeTrade-dev mailing list
[EMAIL PROTECTED]
http://share.whichever.com/mailman/listinfo/freetrade-dev


Reply via email to