# file: product.web # Copyright (c) 1996-2011 Cuesta Technologies, LLC # All rights reserved. # This document contains confidential and/or proprietary information # beloging to Cuesta Technologies, LLC. # Package: alt # # Purpose: # # Requires: # set pageID PG_25 cw source mysql.tcl if {![info exists cw_args(record)]} { cw redirect search$webPgExtn$nocache+prod@no force } else { set record $cw_args(record) } # Figure out the previous and next pages if {[info exists sdb(search_result_list)]} { set l $sdb(search_result_list) set i [lsearch $l $record] if {$i > 0} { set prev [lindex $l [expr $i-1]] } if {$i >= 0 && $i < [expr [llength $l] - 1]} { set next [lindex $l [expr $i+1]] } } # Define the Previous Button if {[info exists prev]} { set Button_Prev "Previous" } else { set Button_Prev "" } # Define the Next Button if {[info exists next]} { set Button_Next "Next" } else { set Button_Next "" } # fetch the product record from the product database ### connect to sql database MysqlConnectProdDB set data [MysqlGrokRec $mysqlProductTable Record_ID $record] DataStringToArray $data proArray $cw_tablepath cw stats PRODUCT "$proArray(Record_ID)\t$proArray(Title)" set pTitle $proArray(Title) # if {[string length $proArray(Description)] } { set description "$proArray(Description)" } else { set description "" } if {[info exists cw_args(bad_quant)] && [string match "yup" $cw_args(bad_quant)]} { ### user entered an invalid quantity, $sdb(complaints) comes from bag page. set mark(qty) 1 } set corrLink "" set orderNowLink "" set colSpan 4 set conHeader "" set configStr "" set SCflag 0 set midCell " " if {[string compare {{}} $proArray(Config_Sort_Order)] } { foreach cID $proArray(Config_Sort_Order) { if {[string length $cID] && [regexp {^([0-9])} $cID]} { set query "SELECT Record_ID FROM $mysqlCorreltbl WHERE Correlated_Items LIKE '%$cID%';" set correlList [sql $query] #cw log 2 "$cID correlation: $correlList" set lo($cID) [llength $correlList] if {$lo($cID) > 0} { incr SCflag } } } if {$SCflag} { incr colSpan set corrLink "See correlations for this product        " } set conHeader "" ### price 2 if {$SCflag} { append conHeader "" } append conHeader "" set orderNowLink "Order Now! " } if {[string compare {{}} $proArray(Config_Sort_Order)] } { cw log 2 "proArray(Config_Sort_Order)=$proArray(Config_Sort_Order)" set conFields {Title Item_Number ISBN Price Price_2 Price_Level_2 Record_ID} foreach cID $proArray(Config_Sort_Order) { if {[string length $cID] && [regexp {^([0-9])} $cID]} { set cdata [MysqlGrokRec $mysqlProductTable Item_Number $cID $conFields] if {$cdata==0} { ## Show text, not orderable append configStr "" } else { DataStringToArray $cdata conAry $cw_tablepath $conFields append configStr "" if {[string match $proArray(Item_Number) $conAry(Item_Number)]} { append configStr "" } else { append configStr "" } append configStr "" if {$lo($cID) > 0} { set scString "" } elseif {$SCflag} { set scString $midCell } else { set scString "" } append configStr "$scString" catch {unset conAry} } } else { ## Show text, not orderable append configStr "" } } } cw source $cw_templatePath/templateSetup.tcl cw source $cw_templatePath/templateTop.tcl ######################## # Add your own code here ######################## set flagImg "" if {[lsearch $proArray(Special) New] > -1} { append flagImg "  " } set filePict $cw_parts/itemimages/medium/$proArray(Item_Number)L.jpg if {[file exists $filePict]} { set pimgStr "\"$proArray(Title)\"" } else { #set pimgStr "Product Image Here" set pimgStr "" } cw log 2 "pimgStr=$pimgStr" set zoomPict $cw_parts/itemimages/large/$proArray(Item_Number)XL.jpg if {[file exists $zoomPict]} { #set linkStart "" set linkStart "" set url $itemimages/large/$proArray(Item_Number)XL.jpg set linkEnd "" ### client doesn't want this text #set subtitle "Click on the image to see the sample" } else { set url "" set linkStart "" set linkEnd "" set subtitle "" } if {[info exists cw_args(bad_quant)] && [string match "yup" $cw_args(bad_quant)]} { puts "

Oops! Some important information is missing or incorrect.

[join $sdb(complaints) "
"]
" } if {[llength $sdb(search_result_list)] == 1 && [string match $record $sdb(search_result_list)]} { puts " 

Quantity" if {[info exists mark(qty)] && $mark(qty) == 1} { append conHeader "*" } append conHeader " Item \# ISBN Title PriceCorrelations
$cID
" append configStr [cw_text $cID {} 3 {} 3 return] append configStr "$conAry(Item_Number) $conAry(ISBN)$conAry(Title)$conAry(Title)[dollarstring $conAry(Price)]" #### price 2 ### if { [string length $conAry(Price_2)] && [string length $conAry(Price_Level_2)]} { append configStr " ([dollarstring $conAry(Price_2)] / $conAry(Price_Level_2)+)" } append configStr "View Standards Correlation
$cID
$midCell
$sdb(searchcriteria) $sdb(searchcriteria2)The database contains 1 item that matches your request.

" } puts -nonewline "" if {[string length $proArray(Super_Title)]} { puts "" } puts "
$proArray(Super_Title)" } if {[string length $proArray(Sub_Title)]} { puts " - $proArray(Sub_Title)
$Button_Prev$proArray(Title) $flagImg$Button_Next

" if {[file exists $zoomPict]} { OpenPopWinHTML $url $pimgStr 840 600 } else { puts $pimgStr } #puts "$linkStart$pimgStr$linkEnd" ### client doesn't want subtitle #puts "$subtitle" puts "

" ############### bullet head and bullets ############### if {[string length $proArray(Bullet_Head)]} { puts "" } puts "
$description
$proArray(Bullet_Head)
    " foreach bul $proArray(Bullets) { puts "
  • $bul
  • " } puts "
" if {[string length $proArray(Item_Number)]} { puts " Item: $proArray(Item_Number) " } if {[string length $proArray(ISBN)]} { puts " ISBN: $proArray(ISBN) " } puts "" set lineStart "$midCell" } ################### Reading Level ############################### if {[string length $proArray(Reading_Level_Begin)] && [string compare "N/A" $proArray(Reading_Level_Begin)]} { if {[string match $proArray(Reading_Level_Begin) $proArray(Reading_Level_End)]} { set gradeString "$proArray(Reading_Level_Begin)" } else { set gradeString "$proArray(Reading_Level_Begin) to $proArray(Reading_Level_End)" } puts "${lineStart}Reading Level:$midCell" } if {[string length $proArray(GR_Level_Begin)] && [string compare "N/A" $proArray(GR_Level_Begin)]} { if {[string match $proArray(GR_Level_Begin) $proArray(GR_Level_End)]} { set grString "$proArray(GR_Level_Begin)" } else { set grString "$proArray(GR_Level_Begin) to $proArray(GR_Level_End)" } puts "${lineStart}Guided Reading Level:$midCell" } if {[string length $proArray(DRA_Level_Begin)] && [string compare "N/A" $proArray(DRA_Level_Begin)] && [string compare "0" $proArray(DRA_Level_Begin)] } { if {[string match $proArray(DRA_Level_Begin) $proArray(DRA_Level_End)]} { set draString "$proArray(DRA_Level_Begin)" } else { set draString "$proArray(DRA_Level_Begin) to $proArray(DRA_Level_End)" } puts "${lineStart}DRA Level:$midCell" } #################### Language ######################### if {[string compare {{}} $proArray(Language)]} { ### client does not want to display language if only English set language [join $proArray(Language) ", "] if {[string compare "English" $language]} { puts "${lineStart}Language:$midCell" } } #################### Literary Levels ################# if {[string compare {{}} $proArray(Literary_Levels)]} { puts "${lineStart}Literary Levels:$midCell" } #################### Literacy Stages ################# if {[string compare {{}} $proArray(Literacy_Stages)]} { puts "${lineStart}Literacy Stages:$midCell" } ################### Subject ########################## if {[string compare {{}} $proArray(Subject)]} { puts "${lineStart}Subject:$midCell" } ################### Math_Strand ########################## if {[string compare {{}} $proArray(Math_Strand)]} { puts "${lineStart}Math Strand:$midCell" } ################### Science_Strand ########################## if {[string compare {{}} $proArray(Science_Strand)]} { puts "${lineStart}Science Strand:$midCell" } ################### Social_Studies_Strand ########################## if {[string compare {{}} $proArray(Social_Studies_Strand)]} { puts "${lineStart}Social Studies Strand:$midCell" } ################### Reading_Language_Arts_Topics ########################## if {[string compare {{}} $proArray(Reading_Language_Arts_Topics)]} { puts "${lineStart}Reading/Language Arts Topics:$midCell" } ################### Five_Elements_Reading ########################## if {[string compare {{}} $proArray(Five_Elements_Reading)]} { puts "${lineStart}Five Elements of Reading:$midCell" } puts "
" ################### Grade Level ############################### if {[string length $proArray(Grade_Begin)] && [string compare "N/A" $proArray(Grade_Begin)]} { if {[string match $proArray(Grade_Begin) $proArray(Grade_End)]} { set gradeString "$proArray(Grade_Begin)" } else { set gradeString "$proArray(Grade_Begin) to $proArray(Grade_End)" } puts "${lineStart}Grade Level:$gradeString
$gradeString
$grString
$draString
$language
[join $proArray(Literary_Levels) ", "]
[join $proArray(Literacy_Stages) ", "]
[join $proArray(Subject) ", "]
[join $proArray(Math_Strand) ", "]
[join $proArray(Science_Strand) ", "]
[join $proArray(Social_Studies_Strand) ", "]
[join $proArray(Reading_Language_Arts_Topics) ", "]
[join $proArray(Five_Elements_Reading) ", "]

" ################## Config table ################################ if {[string compare {{}} $proArray(Config_Sort_Order)] } { puts " $conHeader$configStr

" } ############################## Parent and Children ############## if { [string length $proArray(Parent_Record_ID)] > 2 } { foreach parent $proArray(Parent_Record_ID) { set pFields {Title} set pdata [MysqlGrokRec $mysqlProductTable Record_ID $parent $pFields] DataStringToArray $pdata preAry $cw_tablepath $pFields append pLinkStr "$preAry(Title)
" } puts "This product is part of the series:
$pLinkStr

" } set children [sql "SELECT Record_ID FROM $mysqlProductTable WHERE Parent_Record_ID LIKE '%$record%' ORDER BY Title_Sort;"] if {[llength $children]} { set chiFields {Item_Number Title Title_Sort Description GR_Level_Begin GR_Level_End Grade_Begin Grade_End DRA_Level_Begin DRA_Level_End Reading_Level_Begin Reading_Level_End} puts "Titles in this series:

" set numcells 1 foreach child $children { set chiData [MysqlGrokRec $mysqlProductTable Record_ID $child $chiFields] DataStringToArray $chiData chiAry $cw_tablepath $chiFields set chiLinkStr "$chiAry(Title)" ### set and limit description to $desCharNum chars ### set desCharNum 1000 set description "$chiAry(Description)" if {[string length $desCharNum]} { set description [TruncateSentence $description $desCharNum] } if {[string length $description]} { set descStr "$description" } else { set descStr "" } ### grade level if {[string length $chiAry(Grade_Begin)]} { set grade "
Grade: $chiAry(Grade_Begin)" if {[string compare $chiAry(Grade_Begin) $chiAry(Grade_End)] &&[string length $chiAry(Grade_End)]} { append grade " - $chiAry(Grade_End)" } } else { set grade " " } ### DRA level if {[string length $chiAry(DRA_Level_Begin)]} { set dralevel "
DRA Level: $chiAry(DRA_Level_Begin)" if {[string compare $chiAry(DRA_Level_Begin) $chiAry(DRA_Level_End)] &&[string length $chiAry(DRA_Level_End)]} { append dralevel " - $chiAry(DRA_Level_End)" } } else { set dralevel " " } ### GR level if {[string length $chiAry(GR_Level_Begin)]} { set grlevel "
GR Level: $chiAry(GR_Level_Begin)" if {[string compare $chiAry(GR_Level_Begin) $chiAry(GR_Level_End)] &&[string length $chiAry(GR_Level_End)]} { append grlevel " - $chiAry(GR_Level_End)" } } else { set grlevel " " } ### reading level if {[string length $chiAry(Reading_Level_Begin)]} { set reading "
Reading Level: $chiAry(Reading_Level_Begin)" if {[string compare $chiAry(Reading_Level_Begin) $chiAry(Reading_Level_End)] &&[string length $chiAry(Reading_Level_End)]} { append reading " - $chiAry(Reading_Level_End)" } } else { set reading " " } ### small image set tempFile $cw_parts/itemimages/small/$chiAry(Item_Number).jpg if {[file exists $tempFile]} { regsub -all {\"} $description {} altDescr #cw log 2 "altDescr: $altDescr" set simgStr "\"$altDescr\"" } else { set simgStr " " } puts "
" if { $numcells == 4 } { puts "" set numcells 0 } incr numcells } puts "
$simgStr
$chiLinkStr

" } ##################### Related records ############################## if {[string length $proArray(Related_Records)]} { set relFields {Record_ID Item_Number Title Description GR_Level_Begin GR_Level_End Grade_Begin Grade_End DRA_Level_Begin DRA_Level_End Reading_Level_Begin Reading_Level_End} puts "Related Products:

" set numcells 0 foreach rel $proArray(Related_Records) { set relData [MysqlGrokRec $mysqlProductTable Item_Number $rel $relFields] DataStringToArray $relData relAry $cw_tablepath $relFields set relLinkStr "$relAry(Title)" ### set and limit description to $desCharNum chars ### set desCharNum 1000 set description "$relAry(Description)" if {[string length $desCharNum]} { set description [TruncateSentence $description $desCharNum] } if {[string length $description]} { set descStr "$description" } else { set descStr "" } #cw log 2 "descStr: $descStr" ### small image set tempFile $cw_parts/itemimages/small/$rel.jpg if {[file exists $tempFile]} { regsub -all {\"} $description {} altDescr set rimgStr "\"$altDescr\"" } else { set rimgStr " " } #cw log 2 "rimgStr: $imgStr" ### grade level if {[string length $relAry(Grade_Begin)]} { set grade "
Grade: $relAry(Grade_Begin)" if {[string compare $relAry(Grade_Begin) $relAry(Grade_End)] &&[string length $relAry(Grade_End)]} { append grade " - $relAry(Grade_End)" } } else { set grade " " } ### DRA level if {[string length $relAry(DRA_Level_Begin)]} { set dralevel "
DRA Level: $relAry(DRA_Level_Begin)" if {[string compare $relAry(DRA_Level_Begin) $relAry(DRA_Level_End)] &&[string length $relAry(DRA_Level_End)]} { append dralevel " - $relAry(DRA_Level_End)" } } else { set dralevel " " } ### GR level if {[string length $relAry(GR_Level_Begin)]} { set grlevel "
GR Level: $relAry(GR_Level_Begin)" if {[string compare $relAry(GR_Level_Begin) $relAry(GR_Level_End)] &&[string length $relAry(GR_Level_End)]} { append grlevel " - $relAry(GR_Level_End)" } } else { set grlevel " " } ### reading level if {[string length $relAry(Reading_Level_Begin)]} { set reading "
Reading Level: $relAry(Reading_Level_Begin)" if {[string compare $relAry(Reading_Level_Begin) $relAry(Reading_Level_End)] &&[string length $relAry(Reading_Level_End)]} { append reading " - $relAry(Reading_Level_End)" } } else { set reading " " } #cw log 2 "relLinkStr:$relLinkStr" #puts "
" #puts "" puts "" incr numcells if { $numcells == 4 } { puts "" set numcells 0 } } puts "
$rimgStr$relLinkStr
$descStr$grade$dralevel$grlevel$reading
 $relLinkStr
$rimgStr
$relLinkStr

" } MysqlDisconnect puts "$Button_Prev    $Button_Next

" catch {unset proArray} cw source $cw_templatePath/templateBottom.tcl