[flag type=write table=country] [flag type=write table=userdb] [flag type=write table=access] [flag type=write table=variable] [flag type=write table=area] [flag type=write table=cat] [value name=site_created set=1 hide=1] [set ui_checklist]1[/set] @_UI_STD_HEAD_@  
[if value sampleproducts] [and value products =~ /\.xls$/i] [import-fields convert="xls" add=1 dir=backup file="upload/[value products]" move=1 multiple="1" quiet="2" table="products" ] [/if] [if value sampleorders] [flag type=write table=userdb] [flag type=write table=transactions] [flag type=write table=orderline] [import-fields convert=xls add=1 dir=backup file="upload/sampledata.xls" move=1 multiple=1 quiet=2 table=userdb ] [/if] [if value sampleproducts] [perl tables="area cat products"] my $go_page = 'index'; $CGI->{mv_nextpage} = '@@MV_PAGE@@'; my $ptab = 'products' or return "no area source table"; my $pdb = $Db{$ptab} or return "area source table bad"; my $adb = $Db{area} or return "no area table"; my $cdb = $Db{cat} or return "no cat table"; my $acol = 'prod_group'; my $ccol = 'category'; if(! $acol and ! $ccol ) { return "no column to populate either"; } my $selector = ''; my $selcode = ''; my %area_defaults = ( name => undef, which_page => 'all', sort => '05', sel => 'left', display_type => 'name', ); my %catmap; my %cat_defaults = ( link_type => 'simple', sort => '05', display_type => 'name' ); $adb->query('delete from area'); $cdb->query('delete from cat'); if($acol) { $adb->config('AUTO_NUMBER', '1000') if ! $adb->config('_Auto_number'); return "area column $acol doesn't exist" unless $pdb->column_exists($acol); my $ary = $pdb->query("select distinct $acol from $ptab order by $acol") or return "area column query failed"; for(@$ary) { my ($area) = (@$_); my $key = $adb->set_row(''); return "no autonumbering available" if ! $key; $catmap{$area} = $key; for(keys %area_defaults) { $adb->set_field($key, $_, $area_defaults{$_} || $area); } } } my %catdone; if($ccol) { $cdb->config('AUTO_NUMBER', '1000') if ! $cdb->config('_Auto_number'); return "cat column $ccol doesn't exist" unless $pdb->column_exists($ccol); my $ary = $pdb->query("select $acol, $ccol from $ptab order by $ccol") or return "cat column query failed"; for(@$ary) { my ($area, $cat) = (@$_); next if $catdone{$cat}++; my $key = $cdb->set_row(''); return "no cat autonumbering available" if ! $key; $cat_defaults{name} = $cat; $cat_defaults{sel} = $catmap{$area}; $cat_defaults{selector} = "$ccol=$cat"; for(keys %cat_defaults) { Log("setting col=$_ key=$key = $cat_defaults{$_}"); $cdb->set_field($key, $_, $cat_defaults{$_}); } } } my $out = $Tag->uneval( { ref => \%catmap } ); $out =~ s/,/,\n/g; #return '' . $Tag->uneval( { ref => \%catmap } ) . "</XMP"; return "<P>Categories built.</P>"; [/perl] [/if] <P>[if type=explicit compare="[reconfig]"] Catalog activated with new values. [/if]</P> <P> Your catalog is now operational for testing. </P> <blockquote> <LARGE><A HREF="[area index]" target="_new">Preview</A></LARGE> </blockquote> You may need to click your browsers Reload button several times to see the changes. </blockquote> @_UI_STD_FOOTER_@