# file: search.html # Copyright (c) 1996-2001 Cuesta Technologies, LLC # All rights reserved. # This document contains confidential and/or proprietary information # beloging to Cuesta Technologies, LLC. # Package: snp # # Purpose: quick search form: search for Config_Sort_Order and # Keywords (and Title, Configuration_Text, Description, # Author_Last_Name) # # search page: search for Title (and Configuration_Text) Author # Keywords (and Description) Product_Line Study_Area Topic Media # GR_Level_Begin_Code GR_Level_End_Code RR_Level_Begin_Code # RR_Level_End_Code RR_Level Grade_Begin_Code Grade_End_Code # Interest_Begin_Code Interest_End_Code LX_Level_Begin LX_Level_End # August 22, 2001 cindy: Change per sdp request: # 1) Delete the Keyword search option from the Advanced Search page # 2) Change the Title search option to search the 4 fields: Title, # Description, Keywords, and Configuration_text. # # Dec 20, 2006: change Author to Author_Last_Name # # Requires: # set pageID PG_4 cw source mysql.tcl ### Do cw state for Grade_Begin and Grade_End in Check_Grade_Range proc. ### Do cw state for Interest_Begin and Interest_End in Check_Interest_Range proc. ### set recordedFields for STATS set recordedFields {Title Author_Last_Name Keywords Product_Line Study_Area Topic Media Order_Code Config_Sort_Order ISBN Featured_Products Award Topic_Social_Studies Topic_Science Topic_Math} set allSearch 0 ## For quick search and Title/Keyword/Item search and Advance search. set searchList {Title Description Configuration_Text Keywords Author_Last_Name Config_Sort_Order} ### DO search if come from search page or form template or from URL. ###if {[info exists cw_val(submit)] || ([info exists cw_args(where)] && [string match template $cw_args(where)])} {} ### we cann't use [info exists cw_val(submit)] when search from URL. if {[info exists cw_val] || ([info exists cw_args(where)] && [string match template $cw_args(where)])} { set listcriteria "" ## List of fileds that need to do tlob search (word And word) set tlobFieldList "" ## List of fileds that are mult fileds. set multFieldList "" ## extra query string for some special search pass to MySQLRecordSearch proc. set appendQueryString "" set sdb(search_result_list) "" set sdb(searchcriteria) "" set omitlist {EDL_Level_Begin_Code EDL_Level_End_Code DRA_Level_Begin_Code DRA_Level_End_Code Interest_Begin_Code Interest_End_Code GR_Level_Begin_Code GR_Level_End_Code RR_Level_Begin_Code RR_Level_End_Code LX_Level_Begin LX_Level_End Title} set substitutepairs { {Config_Sort_Order "Item Number"} {Media "Format/Media"}} ### check the input data and do complain ### marked_complain Title isonechar "Please enter more than one character for title search." #marked_complain Description isonechar "Please enter more than one character for description search." #marked_complain Features isonechar "Please enter more than one character for features search." #marked_complain Review isonechar "Please enter more than one character for review search." #marked_complain Order_Code isonechar "Please enter more than one character for Item Number search." #marked_complain Keywords isonechar "Please enter more than one character for keyword search." if {![info exists cw_args(where)]} { ### check if the search criteria is input if come from search page set input 0 foreach var $recordedFields { if { [info exists cw_vals($var)] && ![string match $cw_vals($var) {{}}]} { incr input } } if {[info exists cw_val(Interest_Begin_Code)] && [info exists cw_val(Interest_End_Code)]} { if {[string compare 9 $cw_val(Interest_Begin_Code)] || [string compare 22 $cw_val(Interest_End_Code)]} { incr input set checkInterest yes } if {$cw_vals(Interest_Begin_Code) > $cw_vals(Interest_End_Code)} { set mark(interest) 1 lappend complaints "Please specify a valid Interest range (from was greater than to)." } } if {[info exists cw_val(GR_Level_Begin_Code)] && [info exists cw_val(GR_Level_End_Code)]} { if {[string compare 1 $cw_val(GR_Level_Begin_Code)] || [string compare [lindex $cdb(GR_Range_Number) end] $cw_val(GR_Level_End_Code)]} { incr input set checkGR yes } if {$cw_vals(GR_Level_Begin_Code) > $cw_vals(GR_Level_End_Code)} { set mark(GRlevel) 1 lappend complaints "Please specify a valid Guided Reading Level range (from was greater than to)." } } if {[info exists cw_val(RR_Level_Begin_Code)] && [info exists cw_val(RR_Level_End_Code)]} { if {[string compare 1 $cw_val(RR_Level_Begin_Code)] || [string compare 30 $cw_val(RR_Level_End_Code)]} { incr input set checkRR yes } if {$cw_vals(RR_Level_Begin_Code) > $cw_vals(RR_Level_End_Code)} { set mark(RRlevel) 1 lappend complaints "Please specify a valid Early Intervention Level range (from was greater than to)." } } if {[info exists cw_val(DRA_Level_Begin_Code)] && [info exists cw_val(DRA_Level_End_Code)]} { if {[string compare 1 $cw_val(DRA_Level_Begin_Code)] || [string compare 44 $cw_val(DRA_Level_End_Code)]} { incr input set checkDRA yes } if {$cw_vals(DRA_Level_Begin_Code) > $cw_vals(DRA_Level_End_Code)} { set mark(DRA) 1 lappend complaints "Please specify a valid Developmental Reading Assessment Level range (from was greater than to)." } } if {[info exists cw_val(EDL_Level_Begin_Code)] && [info exists cw_val(EDL_Level_End_Code)]} { if {[string compare 1 $cw_val(EDL_Level_Begin_Code)] || [string compare 38 $cw_val(EDL_Level_End_Code)]} { incr input set checkEDL yes } if {$cw_vals(EDL_Level_Begin_Code) > $cw_vals(EDL_Level_End_Code)} { set mark(EDL) 1 lappend complaints "Please specify a valid EDL Level range (from was greater than to)." } } if {[info exists cw_val(LX_Level_Begin)] && [string length $cw_val(LX_Level_Begin)] && (![info exists cw_val(LX_Level_End)] || ![string length $cw_val(LX_Level_End)])} { incr input set mark(lexile) 1 lappend complaints "Please specify a to Lexile level." } elseif {(![info exists cw_val(LX_Level_Begin)]|| ! [string length $cw_val(LX_Level_Begin)]) && [info exists cw_val(LX_Level_End)] && [string length $cw_val(LX_Level_End)]} { incr input set mark(lexile) 1 lappend complaints "Please specify a from Lexile level." } elseif {[info exists cw_val(LX_Level_Begin)] && [string length $cw_val(LX_Level_Begin)] && [info exists cw_val(LX_Level_End)] && [string length $cw_val(LX_Level_End)]} { incr input if {![regexp {^[0-9]+$} $cw_val(LX_Level_Begin)] || ![regexp {^[0-9]+$} $cw_val(LX_Level_End)]} { set mark(lexile) 1 lappend complaints "Please specify the valid numbers as Lexile levels." } elseif {$cw_vals(LX_Level_Begin) > $cw_vals(LX_Level_End)} { set mark(lexile) 1 lappend complaints "Please specify a valid Lexile range (from was greater than to)." } else { set checkLexile yes } } if { $input == 0 } { lappend complaints "Please enter some search criteria." } } else { ### come from quick search form. if {![info exists cw_val(quicksearch)] || ![string length $cw_val(quicksearch)] } { cw log 2 "NO INPUT FROM QUICK SEARCH" lappend complaints "Please enter some search criteria." } else { set cw_val(quicksearch) [string trim $cw_val(quicksearch)] } } if {[llength $complaints] == 0 } { if {[info exists cw_args(where)] && [string match template $cw_args(where)]} { ### Do search for template quick search form. set psearchableList "" set listcriteria [GetSearchCriteria $psearchableList $substitutepairs] ## Generate special query string for Config_Sort_Order append listcriteria "
Item Number / Keyword: $cw_val(quicksearch)" ## set tlobFieldList GetColumnList $cw_tablepath } else { ### Do search if come from search page cw stats SEARCHPAGE search ## create product search list based on product_table.t and cw_vals. set psearchableList [GetSearchableList $cw_tablepath $omitlist] ### Generate search criteria #cw log 2 "multFieldList:$multFieldList" set listcriteria [GetSearchCriteria $psearchableList $substitutepairs] if {[info exists cw_val(Title)] && [string length $cw_val(Title)]} { set cw_val(Title) [string trim $cw_val(Title)] append listcriteria "
Title/Keyword/Item #: $cw_val(Title)" } } MysqlCleancw_val set morethanpairs {} set lessthanpairs {} ## Step 1: Connect to the mysql server MysqlConnectProdDB if {[info exists cw_args(where)] && [string match template $cw_args(where)]} { ### Do search for template quick search form. cw stats QUICKSEARCH $cw_val(quicksearch) set titleORList {} foreach item $searchList { if {[string match Config_Sort_Order $item]} { ### May 18 2001 cindy: remove "\" and all other non numeric and "-" characters. #regsub -all {[^0-9\-]} $cw_val(quicksearch) {} code1 ### March 23 , 2018 Cindy: Cannot find items like 35033-E6 regsub $cdb(itemNumberPrefix) $cw_val(quicksearch) {} code1 cw log 2 "quick search: code1=$code1" if {[string length $code1]} { lappend titleORList "$item LIKE '%$code1%'" } } elseif {[lsearch $tlobFieldList $item] > -1 } { lappend titleORList [CreateAndSearchQuery $item $cw_val(quicksearch)] } else { lappend titleORList "$item LIKE '%$cw_val(quicksearch)%'" } } set titleString "([join $titleORList " OR "])" set appendQueryString [SetAppendQueryString $appendQueryString $titleString] #cw log 2 "appendQueryString: $appendQueryString" } else { ### Do search if come from search page cw stats SEARCHPAGE search if {[info exists cw_val(Title)] && [string length $cw_val(Title)]} { ## Generate special query string for Title field. set titleORList {} foreach item $searchList { if {[string match Config_Sort_Order $item]} { #regsub -all {[^0-9\-]} $cw_val(Title) {} code1 regsub $cdb(itemNumberPrefix) $cw_val(Title) {} code1 cw log 2 "Search Page: code1=$code1" if {[string length $code1]} { lappend titleORList "$item LIKE '%$code1%'" } } elseif {[lsearch $tlobFieldList $item] > -1 } { lappend titleORList [CreateAndSearchQuery $item $cw_val(Title)] } else { lappend titleORList "$item LIKE '%$cw_val(Title)%'" } } set titleString "([join $titleORList " OR "])" set appendQueryString [SetAppendQueryString $appendQueryString $titleString] } #cw log 2 "appendQueryString: $appendQueryString" if {[info exists checkInterest]} { set intbegin [mapelement $cw_vals(Interest_Begin_Code) $cdb(Interest_Range_Number) $cdb(Interest_Range)] set intend [mapelement $cw_vals(Interest_End_Code) $cdb(Interest_Range_Number) $cdb(Interest_Range)] cw stats PF-INTEREST_BEGIN $intbegin cw stats PF-INTEREST_END $intend lappend morethanpairs {Interest_End_Code Interest_Begin_Code} lappend lessthanpairs {Interest_Begin_Code Interest_End_Code} lappend psearchableList Interest_Begin_Code Interest_End_Code append listcriteria "
Interest Level: $intbegin - $intend
" } if {[info exists checkgrade]} { set gradebegin [mapelement $cw_vals(Grade_Begin_Code) $cdb(Grade_Range_Number) $cdb(Grade_Range)] set gradeend [mapelement $cw_vals(Grade_End_Code) $cdb(Grade_Range_Number) $cdb(Grade_Range)] cw stats PF-GRADE_BEGIN $gradebegin cw stats PF-GRADE_END $gradeend ##Grade_Begin_Code >= $cw_val(Grade_End_Code) ##Grade_End_Code >= $cw_val(Grade_Start_Code) lappend morethanpairs {Grade_End_Code Grade_Begin_Code } lappend lessthanpairs {Grade_Begin_Code Grade_End_Code} lappend psearchableList Grade_Begin_Code Grade_End_Code append listcriteria "
Grade Level: $gradebegin - $gradeend
" } if {[info exists checkGR]} { set GRBegin [mapelement $cw_val(GR_Level_Begin_Code) $cdb(GR_Range_Number) $cdb(Guided_Reading_Range)] set GREnd [mapelement $cw_val(GR_Level_End_Code) $cdb(GR_Range_Number) $cdb(Guided_Reading_Range)] cw stats PF-GR_BEGIN $GRBegin cw stats PF-GR_END $GREnd ##GR_Level_Begin_Code >= $cw_val(GR_Level_End_Code) ##GR_Level_End_Code >= $cw_val(GR_Level_Start_Code) lappend morethanpairs {GR_Level_End_Code GR_Level_Begin_Code} lappend lessthanpairs {GR_Level_Begin_Code GR_Level_End_Code} lappend psearchableList GR_Level_Begin_Code GR_Level_End_Code append listcriteria "
Guided Reading Level: $GRBegin-$GREnd
" } if {[info exists checkRR]} { cw stats PF-RR_BEGIN $cw_val(RR_Level_Begin_Code) cw stats PF-RR_END $cw_val(RR_Level_End_Code) lappend morethanpairs {RR_Level_End_Code RR_Level_Begin_Code} lappend lessthanpairs {RR_Level_Begin_Code RR_Level_End_Code} lappend psearchableList RR_Level_Begin_Code RR_Level_End_Code append listcriteria "
Early Intervention Level: $cw_val(RR_Level_Begin_Code) - $cw_val(RR_Level_End_Code)
" } if {[info exists checkDRA]} { cw stats PF-DRA_BEGIN $cw_val(DRA_Level_Begin_Code) cw stats PF-DRA_END $cw_val(DRA_Level_End_Code) lappend morethanpairs {DRA_Level_End_Code DRA_Level_Begin_Code} lappend lessthanpairs {DRA_Level_Begin_Code DRA_Level_End_Code} lappend psearchableList DRA_Level_Begin_Code DRA_Level_End_Code append listcriteria "
Developmental Reading Assessment Level: $cw_val(DRA_Level_Begin_Code) - $cw_val(DRA_Level_End_Code)
" } if {[info exists checkEDL]} { cw stats PF-EDL_BEGIN $cw_val(EDL_Level_Begin_Code) cw stats PF-EDL_END $cw_val(EDL_Level_End_Code) lappend morethanpairs {EDL_Level_End_Code EDL_Level_Begin_Code} lappend lessthanpairs {EDL_Level_Begin_Code EDL_Level_End_Code} lappend psearchableList EDL_Level_Begin_Code EDL_Level_End_Code append listcriteria "
EDL Level (For Products in Spanish): $cw_val(EDL_Level_Begin_Code) - $cw_val(EDL_Level_End_Code)
" } if {[info exists checkLexile]} { cw stats PF-LX_LEVEL_BEGIN $cw_val(LX_Level_Begin) cw stats PF-LX_LEVEL_END $cw_val(LX_Level_End) lappend morethanpairs {LX_Level_End LX_Level_Begin} lappend lessthanpairs {LX_Level_Begin LX_Level_End} lappend psearchableList LX_Level_Begin LX_Level_End append listcriteria "
Lexile Level: $cw_val(LX_Level_Begin) - $cw_val(LX_Level_End)
" } if {[info exists cw_val(ISBN)] && [string length $cw_val(ISBN)]} { ## Generate special query string for ISBN field. set ISBNsearchList {TB10_digit_ISBN TB13_digit_ISBN} set isbnORList {} regsub -all {[^0-9]} $cw_val(ISBN) {} isbn foreach item $ISBNsearchList { if {[lsearch $tlobFieldList $item] > -1 } { lappend isbnORList [CreateAndSearchQuery $item $isbn] } else { lappend isbnORList "$item LIKE '%$isbn%'" } } set isbnString "([join $isbnORList " OR "])" set appendQueryString [SetAppendQueryString $appendQueryString $isbnString] append listcriteria "
ISBN: $cw_val(ISBN)
" } } set appendQueryString_orig $appendQueryString set appendQueryString [SetAppendQueryString $appendQueryString "Results_List='Show'"] set results [MysqlRecordSearch $mysqlProductTable $psearchableList Record_ID Title_Alpha {} {} $morethanpairs $lessthanpairs $appendQueryString] ##Added the HTML end tags to search criteria append listcriteria [GetSearchCriteriaEnd] ## Disconnect the mysql server MysqlDisconnect cw log 2 "sdb(MYSQLqueryString): $sdb(MYSQLqueryString)" DoStats $recordedFields set sdb(search_result_list) $results set sdb(searchcriteria) $listcriteria if {[llength $results]} { if {[info exists cw_val(List_Limit)]} { set sdb(listLimit) $cw_val(List_Limit) } if {[info exists cw_val(List_Type)]} { set sdb(List_Type) $cw_val(List_Type) } else { set sdb(List_Type) "Title & Description" } #cw redirect list$webPgExtn$nocache+curList@0+frompage@search cw redirect resltable$webPgExtn$nocache+curList@0+frompage@search } else { set noresult 1 } } } cw source $new_cw_templatePath/templateSetup.tcl cw source $new_cw_templatePath/templateTop.tcl ######################## # Add your own code here ######################## if {[info exists cw_args(prod)] && [string match no $cw_args(prod)]} { puts "That product is no longer available. Please use the search page to find products that meet your needs." } if {[info exists noresult] && [string match 1 $noresult]} { puts "There are no items that meet your selected criteria. Please try again.
" } #### search form #### puts "
" ### All searches should be restricted to products based on ### the Catalog field and the Catalog_ID value:
Display Search Results Using: #cw_radios2 List_Type {"Title Only" "Title, Description"} 2 {} {} "Title Only" $sdb(List_Type) cw_radios2 List_Type {"Title Only" "Title & Description"} 2 {} {} "Title & Description"
Limit Search Results To cw_popup List_Limit {10 25 50} {} {} {} {25} Items Per Page
Title/Keyword/Item #: complain_mark Title * cw_text Title {} 30
ISBN: complain_mark ISBN * cw_text ISBN {} 30 (For Trade Paperback searches only.)
basic_form_buttons Search {Clear Changes}
if {[llength $cdb(Product_Line)]} { puts " " }
For the following search categories, your search will include all levels and areas if you do not change the beginning or ending levels or select any values.
Programs:  " cw_popupE Product_Line $cdb(Product_Line) {All} puts "
Grade/Interest Level: From:  complain_mark interest * if {![info exists cw_vals(Interest_Begin_Code)] || [llength $cw_vals(Interest_Begin_Code)] == 0} { set interestbegin "[lindex $cdb(Interest_Range_Number) 0]" } else { set interestbegin $cw_vals(Interest_Begin_Code) } cw_popup2 Interest_Begin_Code $cdb(Interest_Range_Number) $cdb(Interest_Range) $interestbegin To:  complain_mark Interest * if {![info exists cw_vals(Interest_End_Code)] || [llength $cw_vals(Interest_End_Code)] == 0} { set interestend [lindex $cdb(Interest_Range_Number) end] } else { set interestend $cw_vals(Interest_End_Code) } cw_popup2 Interest_End_Code $cdb(Interest_Range_Number) $cdb(Interest_Range) $interestend
Guided Reading Level: From:  complain_mark GRlevel * if {![info exists cw_vals(GR_Level_Begin_Code)] || [llength $cw_vals(GR_Level_Begin_Code)] == 0} { set GRbegin "[lindex $cdb(GR_Range_Number) 1]" } else { set GRbegin $cw_vals(GR_Level_Begin_Code) } cw_popup2 GR_Level_Begin_Code [lrange $cdb(GR_Range_Number) 1 end] [lrange $cdb(Guided_Reading_Range) 1 end] $GRbegin To:  complain_mark GRlevel * if {![info exists cw_vals(GR_Level_End_Code)] || [llength $cw_vals(GR_Level_End_Code)] == 0} { set GRend "[lindex $cdb(GR_Range_Number) end]" } else { set GRend $cw_vals(GR_Level_End_Code) } cw_popup2 GR_Level_End_Code [lrange $cdb(GR_Range_Number) 1 end] [lrange $cdb(Guided_Reading_Range) 1 end] $GRend
Early Intervention Level: From:  complain_mark RRlevel * if {![info exists cw_vals(RR_Level_Begin_Code)] || [llength $cw_vals(RR_Level_Begin_Code)] == 0} { set RRbegin "[lindex $cdb(RR_Range_Number) 1]" } else { set RRbegin $cw_vals(RR_Level_Begin_Code) } cw_popup2 RR_Level_Begin_Code [lrange $cdb(RR_Range_Number) 1 end] [lrange $cdb(Reading_Recovery_Range) 1 end] $RRbegin To:  complain_mark RRlevel * if {![info exists cw_vals(RR_Level_End_Code)] || [llength $cw_vals(RR_Level_End_Code)] == 0} { set RRend "[lindex $cdb(RR_Range_Number) end]" } else { set RRend $cw_vals(RR_Level_End_Code) } cw_popup2 RR_Level_End_Code [lrange $cdb(RR_Range_Number) 1 end] [lrange $cdb(Reading_Recovery_Range) 1 end] $RRend
Developmental Reading Assessment Level: From:  complain_mark DRA * if {![info exists cw_vals(DRA_Level_Begin_Code)] || [llength $cw_vals(DRA_Level_Begin_Code)] == 0} { set DRAbegin "[lindex $cdb(DRA_Range_Number) 0]" cw log 2 "DRAbegin==$DRAbegin" } else { set DRAbegin $cw_vals(DRA_Level_Begin_Code) } cw_popupE DRA_Level_Begin_Code $cdb(DRA_Range_Number) Select... {} {} {} {} $DRAbegin To:  complain_mark DRA * if {![info exists cw_vals(DRA_Level_End_Code)] || [llength $cw_vals(DRA_Level_End_Code)] == 0} { set DRAend [lindex $cdb(DRA_Range_Number) end] cw log 2 "DRAend==$DRAend" } else { set DRAend $cw_vals(DRA_Level_End_Code) } cw_popupE DRA_Level_End_Code $cdb(DRA_Range_Number) Select... {} {} {} {} $DRAend
EDL Level (For Products in Spanish): From:  complain_mark EDL * if {![info exists cw_vals(EDL_Level_Begin_Code)] || [llength $cw_vals(EDL_Level_Begin_Code)] == 0} { set EDLbegin "[lindex $cdb(SpanishEDL_Range_Number) 0]" } else { set EDLbegin $cw_vals(EDL_Level_Begin_Code) } cw_popupE EDL_Level_Begin_Code $cdb(SpanishEDL_Range_Number) Select... {} {} {} {} $EDLbegin To:  complain_mark EDL * if {![info exists cw_vals(EDL_Level_End_Code)] || [llength $cw_vals(EDL_Level_End_Code)] == 0} { set EDLend [lindex $cdb(SpanishEDL_Range_Number) end] } else { set EDLend $cw_vals(EDL_Level_End_Code) } cw_popupE EDL_Level_End_Code $cdb(SpanishEDL_Range_Number) Select... {} {} {} {} $EDLend
Lexile®: From:  complain_mark lexile * cw_text LX_Level_Begin {} 5 L To:  complain_mark lexile * cw_text LX_Level_End {} 5 L
basic_form_buttons Search {Clear Changes}
"
Featured Products : (Your search will include all featured products if you do not select one.)
cw_checkboxes Featured_Products $cdb(Featured_Products) 3 {} {}
ELA Focus Areas: (Your search will include all study areas if you do not select one.)
cw_checkboxes Study_Area $cdb(Study_Area) 3 {} {} puts "
Nonfiction Curriculum Area Topics
  Science:
" cw_checkboxes Topic_Science $cdb(Topic_Science) 3 {} {} puts "
  Social Studies:
" cw_checkboxes Topic_Social_Studies $cdb(Topic_Social_Studies) 3 {} {} puts "
  Math:
" cw_checkboxes Topic_Math $cdb(Topic_Math) 3 {} {} puts "
Fiction Genres and Types: (Your search will include all fiction genres and types if you do not select one.)
cw_checkboxes Topic $cdb(Topic) 3 {} {}
Formats: (Your search will include all formats if you do not select one.)
cw_checkboxes Media $cdb(Media) 3 {} {}
basic_form_buttons Search {Clear Changes}
cw source $new_cw_templatePath/templateBottom.tcl