package WebGUI::Wobject::Product; #------------------------------------------------------------------- # WebGUI is Copyright 2001-2002 Plain Black LLC. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- use strict; use Tie::CPHash; use WebGUI::Attachment; use WebGUI::HTMLForm; use WebGUI::Icon; use WebGUI::International; use WebGUI::Privilege; use WebGUI::Session; use WebGUI::SQL; use WebGUI::URL; use WebGUI::Wobject; our @ISA = qw(WebGUI::Wobject); our $namespace = "Product"; our $name = WebGUI::International::get(1,$namespace); #------------------------------------------------------------------- sub _fileProperty { my ($filename, $f, $labelId, $name); $name = shift; $labelId = shift; $filename = shift; $f = WebGUI::HTMLForm->new; if ($filename ne "") { $f->readOnly(''. WebGUI::International::get(391).'',WebGUI::International::get($labelId,$namespace)); } else { $f->file($name,WebGUI::International::get($labelId,$namespace)); } return $f->printRowsOnly; } #------------------------------------------------------------------- sub _layoutStandard { my ($output, %data, $sth, $rows, $file, @column, $i, $seperator); tie %data, 'Tie::CPHash'; $output = $_[0]->displayTitle; $output .= '
| ';
$output .= $_[0]->description;
$output .= ''.WebGUI::International::get(10,$namespace).': '.$_[0]->get("price").' ' if ($_[0]->get("price") ne ""); $output .= ''.WebGUI::International::get(11,$namespace).': '.$_[0]->get("productNumber") if ($_[0]->get("productNumber") ne ""); $output .= ' ';
if ($_[0]->get("brochure")) {
$file = WebGUI::Attachment->new($_[0]->get("brochure"),$_[0]->get("wobjectId"));
$output .= ' | ';
if ($_[0]->get("image1")) {
$file = WebGUI::Attachment->new($_[0]->get("image1"),$_[0]->get("wobjectId"));
$output .= ' ';
}
if ($_[0]->get("image2")) {
$file = WebGUI::Attachment->new($_[0]->get("image2"),$_[0]->get("wobjectId"));
$output .= ' ';
}
if ($_[0]->get("image3")) {
$file = WebGUI::Attachment->new($_[0]->get("image3"),$_[0]->get("wobjectId"));
$output .= ' '; } $output .= ' |
| ';
$column[$i] .= ' '.WebGUI::International::get(30,$namespace).' ';
if ($session{var}{adminOn}) {
$column[$i] .= ''.WebGUI::International::get(34,$namespace).'';
}
}
while (%data = $sth->hash) {
if ($session{var}{adminOn}) {
$column[$i] .= deleteIcon('func=deleteFeature&wid='.$_[0]->get("wobjectId").'&fid='.$data{productFeatureId})
.editIcon('func=editFeature&wid='.$_[0]->get("wobjectId").'&fid='.$data{productFeatureId})
.moveUpIcon('func=moveFeatureUp&wid='.$_[0]->get("wobjectId").'&fid='.$data{productFeatureId})
.moveDownIcon('func=moveFeatureDown&wid='.$_[0]->get("wobjectId").'&fid='.$data{productFeatureId});
}
$column[$i] .= '·'.$data{feature}.''; } if ($rows > 0 || $session{var}{adminOn}) { $column[$i] .= ' | ';
$i++;
}
$sth->finish;
$sth = WebGUI::SQL->read("select name,value,units,productSpecificationId from Product_specification
where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
$rows = $sth->rows;
if ($rows > 0 || $session{var}{adminOn}) {
$column[$i] = '';
$column[$i] .= ' '.WebGUI::International::get(31,$namespace).' ';
if ($session{var}{adminOn}) {
$column[$i] .= ''.WebGUI::International::get(35,$namespace).'';
}
}
while (%data = $sth->hash) {
if ($session{var}{adminOn}) {
$column[$i] .= deleteIcon('func=deleteSpecification&wid='.$_[0]->get("wobjectId").'&sid='.$data{productSpecificationId})
.editIcon('func=editSpecification&wid='.$_[0]->get("wobjectId").'&sid='.$data{productSpecificationId})
.moveUpIcon('func=moveSpecificationUp&wid='.$_[0]->get("wobjectId").'&sid='.$data{productSpecificationId})
.moveDownIcon('func=moveSpecificationDown&wid='.$_[0]->get("wobjectId").'&sid='.$data{productSpecificationId});
}
$column[$i] .= '·'.$data{name}.': '.$data{value}.' '.$data{units}.''; } if ($rows > 0 || $session{var}{adminOn}) { $column[$i] .= ' | ';
$i++;
}
$sth->finish;
$sth = WebGUI::SQL->read("select wobject.title,page.urlizedTitle,Product_accessory.accessoryWobjectId from Product_accessory,wobject,page
where Product_accessory.wobjectId=".$_[0]->get("wobjectId")."
and Product_accessory.accessoryWobjectId=wobject.wobjectId and wobject.pageId=page.pageId order by Product_accessory.sequenceNumber");
$rows = $sth->rows;
if ($rows > 0 || $session{var}{adminOn}) {
$column[$i] = '';
$column[$i] .= ' '.WebGUI::International::get(32,$namespace).' ';
if ($session{var}{adminOn}) {
$column[$i] .= ''.WebGUI::International::get(36,$namespace).'';
}
}
while (%data = $sth->hash) {
if ($session{var}{adminOn}) {
$column[$i] .= deleteIcon('func=deleteAccessory&wid='.$_[0]->get("wobjectId").'&aid='.$data{accessoryWobjectId})
.moveUpIcon('func=moveAccessoryUp&wid='.$_[0]->get("wobjectId").'&aid='.$data{accessoryWobjectId})
.moveDownIcon('func=moveAccessoryDown&wid='.$_[0]->get("wobjectId").'&aid='.$data{accessoryWobjectId});
}
$column[$i] .= '·'.$data{title}.''; } if ($rows > 0 || $session{var}{adminOn}) { $column[$i] .= ' | ';
$i++;
}
$sth->finish;
$sth = WebGUI::SQL->read("select wobject.title,page.urlizedTitle,Product_related.relatedWobjectId from Product_related,wobject,page
where Product_related.wobjectId=".$_[0]->get("wobjectId")."
and Product_related.relatedWobjectId=wobject.wobjectId and wobject.pageId=page.pageId order by Product_related.sequenceNumber");
$rows = $sth->rows;
if ($rows > 0 || $session{var}{adminOn}) {
$column[$i] = '';
$column[$i] .= '';
if ($session{var}{adminOn}) {
$column[$i] .= ''.WebGUI::International::get(37,$namespace).'';
}
}
while (%data = $sth->hash) {
if ($session{var}{adminOn}) {
$column[$i] .= deleteIcon('func=deleteRelated&wid='.$_[0]->get("wobjectId").'&rid='.$data{relatedWobjectId})
.moveUpIcon('func=moveRelatedUp&wid='.$_[0]->get("wobjectId").'&rid='.$data{relatedWobjectId})
.moveDownIcon('func=moveRelatedDown&wid='.$_[0]->get("wobjectId").'&rid='.$data{relatedWobjectId});
}
$column[$i] .= '·'.$data{title}.' '; } if ($rows > 0 || $session{var}{adminOn}) { $column[$i] .= ' | ';
$i++;
}
$sth->finish;
$seperator = '
'; $output .= '
'; return $output; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteAccessoryConfirm { if (WebGUI::Privilege::canEditPage()) { WebGUI::SQL->write("delete from Product_accessory where wobjectId=$session{form}{wid} and accessoryWobjectId=$session{form}{aid}"); _reorderAccessories($_[0]->get("wobjectId")); return ""; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteFeature { my ($output); if (WebGUI::Privilege::canEditPage()) { $output = ''; $output .= '
'; return $output; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteFeatureConfirm { if (WebGUI::Privilege::canEditPage()) { WebGUI::SQL->write("delete from Product_feature where productFeatureId=$session{form}{fid}"); _reorderFeatures($_[0]->get("wobjectId")); return ""; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteFile { my ($output); if (WebGUI::Privilege::canEditPage()) { $output = ''; $output .= '
'; return $output; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteFileConfirm { if (WebGUI::Privilege::canEditPage()) { $_[0]->set({$session{form}{file}=>''}); return ""; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteRelated { my ($output); if (WebGUI::Privilege::canEditPage()) { $output = ''; $output .= '
'; return $output; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteRelatedConfirm { if (WebGUI::Privilege::canEditPage()) { WebGUI::SQL->write("delete from Product_related where wobjectId=$session{form}{wid} and relatedWobjectId=$session{form}{rid}"); _reorderRelated($_[0]->get("wobjectId")); return ""; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteSpecification { my ($output); if (WebGUI::Privilege::canEditPage()) { $output = ''; $output .= '
'; return $output; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteSpecificationConfirm { if (WebGUI::Privilege::canEditPage()) { WebGUI::SQL->write("delete from Product_specification where productSpecificationId=$session{form}{sid}"); _reorderSpecifications($_[0]->get("wobjectId")); return ""; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_edit { my ($f, $output, $proceed); if (WebGUI::Privilege::canEditPage()) { $output = helpIcon(1,$namespace); $output .= '