# file: product.web # Copyright (c) 1996-2013 Cuesta Technologies, LLC # All rights reserved. # This document contains confidential and/or File Edit Options Buffers Tools Help proprietary information # beloging to Cuesta Technologies, LLC. # Package: sts # # Purpose: # # Requires: # set pageID PG_41 if {![info exists cw_args(record)]} { cw redirect search$webPgExtn$nocache+prod@no force } else { #cw log 2 "cw_args(record)=$cw_args(record)" regsub -all {[^a-zA-Z0-9_]} $cw_args(record) "" record #cw log 2 "record=$record" } cw source $cw_templatePath/templateSetup.tcl ############################################ MysqlConnectProdDB set data [MysqlGrokRec $mysqlProductTable Record_ID $record] #cw log 2 "record=$record; data=$data" DataStringToArray $data prod $cw_Ptablepath cw stats PRODUCT "$prod(Record_ID)\t$prod(Title)" ### 9.12.16 mes: also add first isbn to url ### 9.12.16 mes: get first non-empty ISBN ###===========#### need to do loop to get first isbn ### ex with isbn in 5th config: record@TF40460 ### ex with no isbn: record@TF142333 cw log 2 "prod(ISBN)=$prod(ISBN)" set isbnTag [lindex $prod(ISBN) 0] cw log 2 "llength prod(ISBN)=[llength $prod(ISBN)]" set num 0 while { $num < [llength $prod(ISBN)] } { if {![string length [lindex $prod(ISBN) $num]]} { incr num continue } else { set isbnTag [lindex $prod(ISBN) $num] break } } cw log 2 "isbnTag::$isbnTag" set urlIsbn $isbnTag ###### 9.9.16 mes: urlTitle will be added to url on redirect set urlTitle $prod(Title) set urlTitle [sub_percent $prod(Title)] cw log 2 "urlTitle====$urlTitle" ### 9.12.16 mes: ### changed cw_args(urlTitle) to cw_args(Title) ### added ISBN ### 9.13.16 mes: add condition of no isbn - don't want isbn arg on url ### only works if first time to product and no cw_args(Title) if {![string length $isbnTag] } { set isbnTagString "" } else { set isbnTagString "+ISBN@$isbnTag" } cw log 2 "isbnTagString=$isbnTagString" if { [VarCheck cw_args(Title)] == 0 } { ### 9.12.16 mes: had to add $cw_htdocs_url cuz redirect was not getting ### sessionized... just showing tcl code on the page ### 9.12.16 mes: if add force, don't need $cw_htdocs_url !!! # cw redirect $cw_htdocs_url/$pagename$webPgExtn$nocache+record@$prod(Record_ID)+urlTitle@$urlTitle # cw redirect $pagename$webPgExtn$nocache+record@$prod(Record_ID)+urlTitle@$urlTitle force cw redirect $pagename$webPgExtn$nocache+record@$prod(Record_ID)+Title@$urlTitle$isbnTagString force } set pTitle $prod(Title) # ### 5.15.13 mes: not using var "description" because it makes ### double quotes invisible ### not sure what problems we will see by doing this ### it cause the javascript onclick missing double quote and works incorrectly. ## 12/05/2014 Cindy: for incoming url: href="article.html?article@CCP100T", we need to ## replace .html with .web. ## for outgoing url: href="http://www.apcomparativegov.com/corandupdts.html" We should not ## replace .html with .web ## so we cannot just simple replace all .html with .web. #regsub -all {(html\?)} $prod(Description) "web$nocache+" description #regsub -all {(html)} $description "web$nocache" description set des $prod(Description) set newDes "" while {[regexp {" $des] set tmp1 [string range $des 0 [expr ($idx1 - 1)]] #cw log 2 "tmp1=$tmp1" set newDes $newDes$tmp1 ## save the xxx to tmp2 set tmp2 [string range $des [expr ($idx1 + 0)] [expr ($idx2 + 3)]] if {[regexp {http://} $tmp2]} { ## for outgoing url: href="http://www.apcomparativegov.com/corandupdts.html" no change } else { ## for incoming url: href="article.web?article@CCP100T", replace .html with .web regsub {(html\?)} $tmp2 "web$nocache+" tmp3 regsub {(html)} $tmp3 "web$nocache" tmp2 } #cw log 2 "tmp2=$tmp2" set newDes $newDes$tmp2 set des [string range $des [expr ($idx2 + 4)] end] } if {[string length $newDes]} { set description $newDes$des } else { set description $prod(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 } #cw log 2 "prod(Bundle)=$prod(Bundle)" ### Set order table set orderTB "" #cw log 2 "prod(Configs_Record_IDs)====$prod(Configs_Record_IDs)" if {[llength $prod(Configs_Record_IDs)] && [string compare {{}} $prod(Configs_Record_IDs)]} { set QtyList [MysqlGetListValue_In_Field $mysqlConfigTable $prod(Configs_Record_IDs) Record_ID Config_Qty] if {[regexp {[1-9]} $QtyList]} { set colNum 5 } else { set colNum 4 } set ii 0 append orderTB "

" if {$colNum == 5} { append orderTB "" } append orderTB "" foreach item $prod(Configs_Record_IDs) { set cdata [MysqlGrokRec $mysqlConfigTable Record_ID $item] #cw log 2 "item=$item" if {$cdata != 0} { DataStringToArray $cdata config $cw_Ctablepath set price $config(Price_A_Calc) set ordercode $config(Catalog_Number) #cw log 2 "config(Price_A_Calc)=$config(Price_A_Calc)" if {[string length $prod(Discount)]} { #set price [expr ($price * $prod(Discount))] #set priceStr "[dollarstring $price]-[expr $prod(Discount)*100]%off" #set priceStr "[dollarstring $price] - [expr $prod(Discount)*100]%off" set priceStr "[dollarstring $price] - 50% off" ### 2.20.14: mes: SSS does not want red discount to show # set priceStr "[dollarstring $price]" } else { set priceStr [dollarstring $price] } if {[expr ($ii % 2) == 0]} { set clsStr "" } else { set clsStr "class=bg" } append orderTB "" if {$colNum ==5} { if {$config(Config_Qty) > 0} { append orderTB "" } else { append orderTB "" } } append orderTB "" } incr ii } append orderTB "
QuantityOrder CodeISBNMedia/ContentPrice5 or more Price
" if {[string compare Bundle $prod(Bundle)]||$ii == 0 } { append orderTB [cw_text $ordercode {} 3 {} 3 return] } append orderTB " " if {[string compare Bundle $prod(Bundle)]||$ii == 0 } { ### 5.15.15 mes: using sdb(clientCode) as extention, per client ### set sdb(clientCode) in catalog_setup.tcl append orderTB "$ordercode\-$sdb(clientCode)" } append orderTB " $config(ISBN) $config(Media_Text) $priceStr[dollarstring $config(Price_B_Calc)] ($config(Config_Qty) or more)

" } ### Set related records rrStr string set rrStr "" set rrList {} if {[string length $prod(Subcategory_Code_And_Text)] && [string compare {{}} $prod(Subcategory_Code_And_Text)]} { set subCatStrList {} foreach item $prod(Subcategory_Code_And_Text) { regsub -all ' $item {\\'} item lappend subCatStrList "Subcategory_Code_And_Text LIKE '%{$item}%'" } set subCatquery [join $subCatStrList " OR "] # if {[string match SSSS $sdb(catalog_id)]} { ## 9.5.14 The SSSS site is supposed to have all items regardless of Featured Site. # set relquery "SELECT Record_ID FROM ${mysqlProductTable} WHERE ($subCatquery) AND Record_ID !='$record' ORDER BY New, Title_Alpha" # } else { ## Only products where Featured_Site value matches clone code should appear on the clone site. # set relquery "SELECT Record_ID FROM ${mysqlProductTable} WHERE ($subCatquery) AND Record_ID !='$record' AND Featured_Site LIKE '%$sdb(catalog_id)%' ORDER BY New, Title_Alpha" # } ## 09/09/2015: For all sites, only products where Featured_Site value matches clone code should appear on the clone site. #set relquery "SELECT Record_ID FROM ${mysqlProductTable} WHERE ($subCatquery) AND Record_ID !='$record' AND Featured_Site LIKE '%$sdb(catalog_id)%' ORDER BY New, Title_Alpha" set relquery "SELECT Record_ID FROM ${mysqlProductTable} WHERE ($subCatquery) AND Record_ID !='$record' AND Include_On_Site LIKE '%$sdb(catalog_id)%' ORDER BY New, Title_Alpha" #cw log 2 "relquery=$relquery" set rrList [sql $relquery] #cw log 2 "rrList=[llength $rrList]" } ############### if {[string length $prod(Series_Record_ID)]} { set query "select Title from ${mysqlProductTable} where Record_ID='$prod(Series_Record_ID)';" set tmp [sql $query] set seriesTitle [lindex [lindex $tmp 0] 0] if {![string length $seriesTitle]} { set seriesTitle "This series record is missing." } } ############### products in this Series ################### if { [string match SC1 $prod(Record_Type)]} { set chiquery "SELECT Record_ID, Title FROM ${mysqlProductTable} WHERE Series_Record_ID='$record' ORDER BY Title_Alpha" set chiresult [sql $chiquery] set itemrecs {} set itemtitles {} foreach item $chiresult { lappend itemrecs [lindex $item 0] lappend itemtitles [lindex $item 1] } set limit [llength $itemrecs] #cw log 2 "chiresult=$chiresult" } MysqlDisconnect if {[llength $rrList] > 4} { set rrList [lrange $rrList 0 3] } if {[llength $rrList]} { set rrStr "

Related Titles

" append rrStr [ListProducts $rrList product {} print] } #cw log 2 "rrStr: $rrStr" cw source $cw_templatePath/templateTop.tcl ######################## # Add your own code here ######################## puts "
" 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) "
"]
" } ### set picture file ### set itemImg medium/$prod(Picture_File).jpg ### 9.12.16 mes: if you want full product image url for outside urls: ### set mediumImgUrl "$env(SERVER_URL)$itemimages/$prod(Picture_File)" ###### Note:itemimages from cw.conf should be: /dev/parts/itemimages cw log 2 "itemimages from cw.conf: $itemimages" cw log 2 "cw_parts===$cw_parts" if {[file exists $cw_parts/itemimages/$itemImg]} { set mediumImg "\"$prod(Title)\"" } else { set mediumImg "\"No" } ### set icons set iconAlign "align=middle" set newicon "" if {[string match New $prod(New)]} { set newicon "

\"New\"
" } set neicon "" if {[regexp {New Edition} $prod(Featured)]} { set neicon "
\"New
" } set tagline "" if {[string length $prod(Tagline)]} { set tagline "$prod(Tagline)" } set subtitle "" if {[string length $prod(Subtitle)]} { set subtitle "

$prod(Subtitle)

" } set myurl "$cw_htdocs_url/$pagename.web?record@$prod(Record_ID)" puts "
$newicon$neicon
$mediumImg$tagline

$prod(Title)

$subtitle " $description if { [string match SC1 $prod(Record_Type)]} { set outputstring "
" append outputstring "Titles in this series:
    " set i 0 while {$i < $limit} { set rid [lindex $itemrecs $i] set rtitle [lindex $itemtitles $i] if {$rid!={} && $rtitle!={}} { set printoutputstring 1 append outputstring "
  • $rtitle" } incr i } append outputstring "
" puts "
$outputstring" } elseif { [info exists prod(Series_Record_ID)] && [string length $prod(Series_Record_ID)]} { #cw log 2 "prod(Series_Record_ID)=$prod(Series_Record_ID)" puts "
This Title is part of the Series: $seriesTitle

" } puts "$orderTB$rrStr

" cw source $cw_templatePath/templateBottom.tcl