# file: product.html # Copyright (c) 1996-2010 Cuesta Technologies, LLC # All rights reserved. # This document contains confidential and/or proprietary information # beloging to Cuesta Technologies, LLC. # Package: snp # # Purpose: # # Requires: # set pageID PG_5 cw source mysql.tcl if {![info exists cw_args(record)]} { cw redirect search$webPgExtn$nocache+prod@no force } else { set record $cw_args(record) ## 2015/7/29 Cindy: remove ' which cause the mysql error. regsub -all "\'" $record {} record } cw source $new_cw_templatePath/templateSetup.tcl #cw log 2 "record=$record" ### check sdb(List_Type_column) to decide the ### sdb(..._result_list) to be used # cw log 2 "sdb(List_Type_column) is $sdb(List_Type_column)-------" switch $sdb(List_Type_column) { new { set resultList new_result_list } offers { set resultList offers_result_list } exclusives { set resultList exclusives_result_list } spotlights { set resultList spotlights_result_list } default { set resultList search_result_list } } # Figure out the previous and next pages if {[info exists sdb($resultList)]} { set l $sdb($resultList) 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] #cw log 2 "data=$data" if {$data == 0 } { MysqlDisconnect cw redirect search$webPgExtn$nocache+prod@no force } DataStringToArray $data proArray $cw_tablepath cw stats PRODUCT "$proArray(Record_ID)\t$proArray(Title)" ###### 9.9.16 mes: urlTitle will be added to url on redirect set urlTitle $proArray(Title) set urlTitle [sub_percent $proArray(Title)] if { [VarCheck cw_args(Title)] == 0 && [VarCheck cw_args(bad_quant)]== 0 } { if {[info exists cw_args(s)] || [info exists cw_args(nocache)]} { cw redirect $pagename$webPgExtn$nocache+record@$proArray(Record_ID)+Title@$urlTitle force } elseif {[info exists env(QUERY_STRING)]} { ## first time enter the site cw redirect $pagename$webPgExtn$nocache+Title@$urlTitle+$env(QUERY_STRING) force } } if { [info exists sdb(bag)] && [string length $sdb(bag)] } { set baglist $sdb(bag) } else { set baglist {} } 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 conIDList {} set priceList {} set configList {} set cFieldList { GR_Level_Config Lexile_Level_Begin EI_Level_Config DRA_Level_Config EDL_Level_Config Word_Count_Config Discount_Config } set cHeaderList { "GRL Level" "Lexile®" "EIL Level" "DRA Level" "EDL Level" "Word Count" "Discount" } set noneList {N/A "" 0 0 N/A "" No} foreach item $cFieldList { set list($item) {} } set list(Lexile_Level_End) {} set colSpan 4 if {[string compare {{}} $proArray(Config_Sort_Order)] } { foreach cID $proArray(Config_Sort_Order) { set configdata [MysqlGrokRec $mysqlConfigTable Item_Number $cID] if { $configdata == 0} { continue } DataStringToArray $configdata conArray $cw_conf_tablepath lappend conIDList $cID lappend priceList $conArray(Price) ### added product title lappend configList $conArray(Configuration) set n 0 foreach item $cFieldList { set empty [lindex $noneList $n] lappend list($item) $conArray($item) if {[string match EI_Level_Config $item]} { cw log 2 "empty for $item: $empty" cw log 2 "conArray($item)=$conArray($item)" } if {[string match Lexile_Level_Begin $item]} { lappend list(Lexile_Level_End) $conArray(Lexile_Level_End) } set flag($item) [CheckEmptyValueList $list($item) $empty] if {$flag($item)} { incr colSpan } incr n } } if {[llength $conIDList]} { sql selectdb $mysqlcorreldb set SCflag 0 ## Juen 27 2005 Cindy: Use learnobject table which is small and fast foreach item $conIDList { set query "SELECT LOID FROM $mysqlLOtbl WHERE PLOID='$item';" set loList [sql $query] set lo($item) [llength $loList] if {$lo($item) > 0} { incr SCflag } } if {$SCflag} { incr colSpan set corrLink "See correlations for this product        " } sql selectdb $mysqlproddb set conHeader "" set m 0 foreach item $cFieldList { set header [lindex $cHeaderList $m] if {$flag($item)} { if {[regexp Discount $item]} { append conHeader "" } else { append conHeader "" } } incr m } append conHeader "" if {$SCflag} { append conHeader "" } append conHeader "" # set orderNowLink "Order Now! " set orderNowLink "" } } cw source $new_cw_templatePath/templateTop.tcl ######################## # Add your own code here ######################## puts -nonewline "
$proArray(Title)
Quantity" if {[info exists mark(qty)] && $mark(qty) == 1} { append conHeader "*" } append conHeader " Order Code Configuration" append conHeader [OpenPopWinHTML "dmessage$webPgExtn$nocache" " Eligible for
Trade
Discount
" 300 400 "scrollbars=Yes" output] append conHeader "
$headerPriceStandards Correlations
" if {[info exists proArray(Grade_Begin)] && ![string match "N/A" $proArray(Grade_Begin)]} { set gBegin $proArray(Grade_Begin) set gEnd $proArray(Grade_End) if {[string match $gBegin K]} { set gBegin 0 } elseif {[string match $gBegin PreK]} { set gBegin -1 } if {[string match $gEnd K]} { set gEnd 0 } elseif {[string match $gEnd PreK]} { set gEnd -1 } if {$gEnd > $gBegin} { set gradeString "Grades $proArray(Grade_Begin) to $proArray(Grade_End)" } elseif {$gEnd == $gBegin} { set gradeString "Grade $proArray(Grade_Begin)" } puts "" } else { puts "" } puts "
$corrLink $orderNowLink" #### Add Prev and Next Buttons if {([string match Product $proArray(Record_Type)] && [string length $proArray(Title)]) || [info exists prev] || [info exists next]} { puts "$Button_Prev $Button_Next" } puts -nonewline "
" set flagImg "" if {[lsearch $proArray(Special) New] > -1} { # append flagImg "  " ## New burst append flagImg "
NEW!

" } if {[regexp Updated $proArray(Special)]} { append flagImg "  " } if {[regexp "Customer Favorite" $proArray(Featured_Products)]} { append flagImg "
Customer Favorite
" } puts -nonewline "$flagImg

$proArray(Title)

$gradeString
 
" if {[info exists cw_args(bad_quant)] && [string match "yup" $cw_args(bad_quant)]} { puts "

Oops! Some important information is missing or incorrect.

$sdb(complaints)" } if {[llength $sdb($resultList)] == 1 && [string match $record $sdb($resultList)]} { puts " 
$sdb(searchcriteria) $sdb(searchcriteria2)   The database contains 1 item that matches your request.


" } ### 5/3/02 mpk per client ### itemimages table conditional if { [string length $proArray(Picture_File1)] || [string length $proArray(Picture_File3)] } { puts "
 
" ### 6/11/01 mes: link to zoompic should indicate which picture ### was clicked. For #1 link to #2; for #3 link to #4 if { [string length $proArray(Picture_File1)] } { #cw log 2 "Picture_File1:$proArray(Picture_File1)" # 8-30-01 mpk: add handling for jpeg or gif set filePict1 $cw_parts/itemimages/medium/$proArray(Picture_File1).jpg if {[file exists $filePict1]} { set pictFile1 $proArray(Picture_File1).jpg } else { set pictFile1 $proArray(Picture_File1).gif } #cw log 2 "pictFile1:$pictFile1" if {[string length $proArray(Picture_File2)]} { ## valign=absbottom is not a standard attribute for img tag #puts "
Click picture for sample pages." puts "
Click picture for sample pages." } else { #puts "" puts "" } } puts "
" #cw log 2 "proArray(Discounted)=$proArray(Discounted)" ### if no discount but sundance exclusive, show exclusive image ### if any config has discount, then show discount image ### else don't show image. if {![string length $proArray(Discounted)] && [regexp {Sundance Exclusives} $proArray(Special)]} { puts " 

" #### 3.2.18 mes: Discounted field must show "Discounted" } elseif {[string match "Discounted" $proArray(Discounted)]} { OpenPopWinHTML "dmessage$webPgExtn$nocache" "" 300 400 "scrollbars=Yes" } puts "

" if {[string length $proArray(Picture_File3)]} { ### Metesh: check if file exists set filePict3 $cw_parts/itemimages/medium/$proArray(Picture_File3).jpg if {[file exists $filePict3]} { set pictFile3 $proArray(Picture_File3).jpg } else { set pictFile3 $proArray(Picture_File3).gif } #cw log 2 "pictFile3 : $pictFile3" if {[string length $proArray(Picture_File4)]} { puts "
Click picture for enlarged view." } else { puts "" } } puts "
" } ## end IF for itemimage table puts "

" if {[info exists proArray(Author)] && [string length $proArray(Author)]} { puts -nonewline "Author: $proArray(Author)

" } # if {[string length $proArray(Description)] } { set description "$proArray(Description)

" } else { set description "" } ## May 7 2002 Cindy: Since description field may contain ## html tags, we need to avoid using puts command. #puts "$description" $description ### 5.13.18 mes: added Award if {[string compare {{}} $proArray(Award)] } { puts -nonewline "Awards: [join $proArray(Award) "; "]

" } if { [string length $proArray(Series_Record_ID)] && [string compare {{}} $proArray(Series_Record_ID)] } { #set seriesTitleList [lindex [MysqlGetListValue_In_Field $mysqlProductTable $proArray(Series_Record_ID) Record_ID Title] 0] set seriesTitleList [MysqlGetListValue_In_Field $mysqlProductTable $proArray(Series_Record_ID) Record_ID Title {} 100 Yes] if {[llength $proArray(Series_Record_ID)] == 1} { set stitle [lindex [lindex $seriesTitleList 0] 0] set sLinkStr "$stitle" } else { set tid 0 set linkList {} foreach sid $proArray(Series_Record_ID) { set stitle [lindex $seriesTitleList $tid] set stitle [lindex $stitle 0 ] if {[string length $sid] && [string length $stitle]} { lappend linkList "$stitle" } incr tid } set tempStr [join $linkList "

  • "] set sLinkStr "
    • $tempStr
    " } puts "Learn more about: $sLinkStr

    " } if {[string compare {{}} $proArray(Related_Product_Lines)]} { ## Lists of products need to be sorted by the "Title_Alpha" field. if {[llength $proArray(Related_Product_Lines)] > 1} { #cw log 2 "sort proArray(Related_Product_Lines) by Title_Alpha!!!!" set recordList [MysqlSortListByColumn $mysqlProductTable Record_ID $proArray(Related_Product_Lines) Title_Alpha] set titleList [MysqlGetListValue_In_Field $mysqlProductTable $recordList Record_ID Title] set specialList [MysqlGetListValue_In_Field $mysqlProductTable $recordList Record_ID Special] } else { set recordList [lindex $proArray(Related_Product_Lines) 0] set queryString "SELECT Title, Special FROM $mysqlProductTable WHERE Record_ID='$recordList';" #cw log 2 "queryString=$queryString" set myRes [sql $queryString] set titleList [lindex $myRes 0] set specialList [lindex $myRes 1] #cw log 2 "titleList=$titleList; specialList=$specialList" } #cw log 2 "recordList=$recordList" if {[llength $titleList]} { puts "

    Teacher resources are available for this title in the following product lines:

      " set i 0 #cw log 2 "titleList=$titleList" foreach item $recordList { set myTitle [lindex $titleList $i] if {[string length $myTitle]} { set special [lindex $specialList $i] set speImg "" if {[regexp New $special]} { append speImg " " } if {[regexp Updated $special]} { append speImg " " } puts "
    • $myTitle$speImg" } incr i } puts "
    " } } ## Table of products available in this series set data [MysqlGrokRec $mysqlSeriesTable Record_ID $record] DataStringToArray $data relArray $cw_related_tablepath set childList $relArray(Child_Record_IDs) if {[llength $childList]} { #set selectedDisplayFields {Title Set_Designation Content_Area EI_Level_Begin EI_Level_End GR_Level_Begin GR_Level_End DRA_Level_Begin DRA_Level_End EDL_Level_Begin EDL_Level_End} ## 2006/6/29 Cindy: remove Set_Designation, added Content_Area. ## 2018.06.07 mes: rename some and reorder fields set selectedDisplayFields { Title Content_Area Grade_Begin Grade_End Reading_Level GR_Level_Begin GR_Level_End LX_Level_Begin LX_Level_End EI_Level_Begin EI_Level_End DRA_Level_Begin DRA_Level_End EDL_Level_Begin EDL_Level_End Page_Count Word_Count } set sortOrderList [MysqlGetListValue_In_Field $mysqlProductTable $childList Record_ID Sort_Order] if {[string length [lindex $sortOrderList 0]]} { set recordList [MysqlSortListByColumn $mysqlProductTable Record_ID $childList Sort_Order] ## following code just for testing #set sortOrderList [MysqlGetListValue_In_Field $mysqlProductTable $recordList Record_ID Sort_Order] #cw log 2 "After sorted: sortOrderList: $sortOrderList" } else { set recordList [MysqlSortListByColumn $mysqlProductTable Record_ID $childList Title_Alpha] } cw log 2 "recordList after sorted:$recordList" puts "" set displayFields {} cw log 2 "selectedDisplayFields===$selectedDisplayFields" foreach item $selectedDisplayFields { set tableAry($item) [MysqlGetListValue_In_Field $mysqlProductTable $recordList Record_ID $item] # Gayathri June 19 2002 changing N/A to blank regsub -all "N/A" $tableAry($item) "\{\}" tableAry($item) if {![CheckEmptyValueList $tableAry($item) N/A]} { continue } elseif {[string match Title $item]} { set header "Titles in this Series" } elseif {[string match EI_Level_Begin $item]} { set header "Early Intv Level" } elseif {[string match EI_Level_End $item]} { continue } elseif {[string match RR_Level_Begin $item]} { set header "Early Intervention Level" } elseif {[string match RR_Level_End $item]} { continue } elseif {[string match GR_Level_Begin $item]} { set header "Guided Rdg Level" } elseif {[string match GR_Level_End $item]} { continue } elseif {[string match DRA_Level_Begin $item]} { set header "Dev Rdg Assmt" } elseif {[string match DRA_Level_End $item]} { continue } elseif {[string match EDL_Level_Begin $item]} { set header "Spanish EDL" } elseif {[string match EDL_Level_End $item]} { continue } elseif {[string match LX_Level_Begin $item]} { set header "Lexile®" } elseif {[string match LX_Level_End $item]} { continue } elseif {[string match Interest_Begin $item]} { set header "Interest Level" } elseif {[string match Interest_End $item]} { continue ### added: } elseif {[string match "Grade_Begin" $item]} { set header "Grade/Interest Level" } elseif {[string match "Grade_End" $item]} { continue } else { regsub -all _ $item " " header } lappend displayFields $item puts "" cw log 2 "header==$header" } puts "" set i 0 cw log 2 "displayFields: $displayFields" foreach item $recordList { set specialList [MysqlGetListValue_In_Field $mysqlProductTable $item Record_ID Special] if {[string length [lindex $tableAry(Title) $i]]} { puts "" foreach cell $displayFields { set cellValue [lindex [lindex $tableAry($cell) $i] 0] set pre "" } puts "" } incr i } catch {unset tabelAry} puts "
    $header
    " if {[string match Title $cell]} { # set cTitle [lindex $cellValue 0] set cTitle [lindex $tableAry($cell) $i] ### 6.7.2018 mes: Title was being truncated to the first word ### Need to convert the Title list to a string set cTitle [join $cTitle " "] puts "$cTitle" if {[regexp New $specialList]} { puts " " } if {[regexp Updated $specialList]} { puts " " } } elseif {[string match EI_Level_Begin $cell] && [string length $cellValue]} { puts "$pre$cellValue" if {[string compare $cellValue [lindex $tableAry(EI_Level_End) $i]]} { puts " - [lindex $tableAry(EI_Level_End) $i]" } } elseif {[string match RR_Level_Begin $cell] && [string length $cellValue]} \ { puts "$pre$cellValue" if {[string compare $cellValue [lindex $tableAry(RR_Level_End) $i]]} { puts " - [lindex $tableAry(RR_Level_End) $i]" } } elseif {[string match GR_Level_Begin $cell] && [string length $cellValue]} { puts "$pre$cellValue" if {[string compare $cellValue [lindex $tableAry(GR_Level_End) $i]]} { puts " - [lindex $tableAry(GR_Level_End) $i]" } } elseif {[string match DRA_Level_Begin $cell] && [string length $cellValue]} { puts "$pre$cellValue" if {[string compare $cellValue [lindex $tableAry(DRA_Level_End) $i]]} { puts "- [lindex $tableAry(DRA_Level_End) $i]" } } elseif {[string match EDL_Level_Begin $cell] && [string length $cellValue]} { puts "$pre$cellValue" if {[string compare $cellValue [lindex $tableAry(EDL_Level_End) $i]]} { puts "- [lindex $tableAry(EDL_Level_End) $i]" } } elseif {[string match LX_Level_Begin $cell] && [string length $cellValue] && [string compare 0 $cellValue]} { puts "$pre${cellValue}L" if {[string compare $cellValue [lindex $tableAry(LX_Level_End) $i]]} { puts "- [lindex $tableAry(LX_Level_End) $i]L" } } elseif {[string match Interest_Begin $cell] && [string length $cellValue]} { puts "$pre${cellValue}" if {[string compare $cellValue [lindex $tableAry(Interest_End) $i]]} { puts " - [lindex $tableAry(Interest_End) $i]" } } elseif {[string match Grade_Begin $cell] && [string length $cellValue]} { puts "$pre${cellValue}" if {[string compare $cellValue [lindex $tableAry(Grade_End) $i]]} { puts " - [lindex $tableAry(Grade_End) $i]" } } elseif {[string length $cellValue] && [string compare 0 $cellValue]} { puts "$pre${cellValue}" # cw log 2 "What is cellValue--> $cellValue" } else { puts "$pre " } puts "

    " } if {[llength $conIDList]} { puts "   $conHeader" set i 0 set ii 0 foreach code $conIDList { if {[expr $ii % 2]} { set colorTD $cdb(colorTDBg2) } else { set colorTD $cdb(colorTDBg1) } set config [lindex $configList $i] set price [lindex $priceList $i] set discountable No foreach item $cFieldList { if { $flag($item) == 1 } { set value [lindex $list($item) $i] if {[regexp Discount $item]} { if {[regexp -nocase discount $value]} { set value Yes } else { set value No } set discountable $value } elseif {[string match N/A $value] || [string match {{}} $value] || [string match 0 $value]} { set value " " } if {[string match Lexile_Level_Begin $item]} { set lxend [lindex $list(Lexile_Level_End) $i] set show($item) "${value}" if {[string compare " " $value]} { append show($item) "L" } if {[string length $lxend] && $value != $lxend && [string compare 0 $lxend]} { append show($item) " - ${lxend}L" # append show($item) " - ${lxend}" } append show($item) "" } else { set show($item) "$value" } } else { set show($item) "" } } if {$lo($code) > 0} { set scString "Correlate" } elseif {$SCflag} { set scString " " } else { set scString "" } ### build rows puts "" if {$code != {} && $config != {} && $price != {} } { puts "" cw_text $code "" 3 "" 3 cw_hidden $code\_discount $discountable puts " $cdb(itemNumberPrefix)$code $config" foreach item $cFieldList { puts $show($item) } puts "[dollarstring $price] $scString " } else { lappend badrecords $code puts "Bad Data $code $config" foreach item $cFieldList { puts $show($item) } if {$price == {} } { puts " " } else { puts "[dollarstring $price]" } puts "$scString" } incr i incr ii } puts " " } if {[string compare {{}} $proArray(Related_Records)]} { ## Lists of products need to be sorted by the "Title_Alpha" field. set recordList [MysqlSortListByColumn $mysqlProductTable Record_ID $proArray(Related_Records) Title_Alpha] set titleList [MysqlGetListValue_In_Field $mysqlProductTable $recordList Record_ID Title] set specialList [MysqlGetListValue_In_Field $mysqlProductTable $recordList Record_ID Special] if {[llength $titleList]} { puts "

    Other products you might be interested in:

      " set i 0 foreach item $recordList { ## Gayathri Mon Sep 9 16:51:26 PDT 2002 ## need to do this because the specialList have the "{{{ }}}" ## around each of the values set tempspecial [lindex [lindex $specialList $i] 0] set flagImg "" if {[regexp New $tempspecial]} { append flagImg " " } if {[regexp Updated $tempspecial]} { append flagImg " " } set title [lindex [lindex $titleList $i] 0] if {[string length $title]} { puts "
    • $title$flagImg" } incr i } puts "
    " } } MysqlDisconnect puts "$Button_Prev $Button_Next
  • " catch {unset proArray} cw source $new_cw_templatePath/templateBottom.tcl