9, 'ESTYLE_VAL' => 4, 'EKIND_VAL' => 1, 'EHEAD' => 1); foreach ($Len as $tag => $maxlen) { if (array_key_exists($tag, $_POST) && !empty($_POST[$tag])) { $LenChk=chk_str($_POST[$tag], $maxlen); switch ($tag) { case 'EHEAD': $EHEAD=(in_array($LenChk, array('Y', 'N')) ? $LenChk : 'N'); break; case 'EKIND_VAL': if (in_array($ETYPE, array('ADDR', 'CONFLICTS', 'PREFS'))) { $EKIND=(in_array($LenChk, array('B', 'J', 'S', 'A')) ? $LenChk : 'A'); } else { $EKIND=''; } break; case 'ESTYLE_VAL': if (in_array($ETYPE, array('ENTRY', 'BREWER'))) { $ESTYLE=(in_array($LenChk, array('CHS', 'HCCP')) ? $LenChk : 'HCCP'); } else { $ESTYLE=''; } break; case 'ETYPE': $ETYPE=(in_array($LenChk, array('ENTRY', 'BREWER', 'CONFLICTS', 'ADDR', 'PREFS', 'RESULT', 'BOS')) ? $LenChk : 'ADDR'); break; } } } // // Get Preferences // function get_prefs($Brewer, $IsLikes) { global $db; $Res=''; $query='select * from style_prefs where brewer="'.$Brewer.'" and rank '.($IsLikes ? '>' : '<').'0'; $pref_res=mysqli_query($db, $query); while ($pref_row=mysqli_fetch_assoc($pref_res)) { $query='select count(*) from style where sg="'.$Comp_SG.'" and type_seq="'.$pref_row['type_seq'].'" and cat="'.$pref_row['cat'].'"'; $style_res=mysqli_query($db, $query); $style_row=mysqli_fetch_row($style_res); if ($style_row[0] == 0) { continue; } $Res.=(!empty($Res) ? ',' : '').disp_cat($pref_row['type_seq'], $pref_row['cat'], $pref_row['sub_cat'], TRUE); } return $Res; } // ?> 0) { $Comment.='Style Desc: '.$entry_row['style_desc'].' '; } if (strlen($entry_row['strength']) > 0) { $Comment.=disp_strength($entry_row['strength'], $entry_row['type_seq'], $entry_row['cat']).' '; } $Comment.=str_replace('"', '""', str_replace("\r\n", ' ', $entry_row['comment'])); $Comment=substr($Comment,0,255); while (substr($Comment,-1) == '"') { $Comment=substr($Comment,0,-1); } $Line.=$Comment."\t"; $Line.=(strlen($entry_row['sweetness']) > 0 ? disp_sweetness($entry_row['sweetness'], get_type($entry_row['type_seq'])) : '')."\t"; $Line.=(strlen($entry_row['carbonation']) > 0 ? disp_carbonation($entry_row['carbonation'], $entry_row['type_seq']) : ''); $Line.="\r\n"; } else { $Line=$entry_row['brewer']."\t\t".$entry_row['entry']."\t"; $Line.=disp_cat($entry_row['type_seq'], $entry_row['cat'], $entry_row['sub_cat'], TRUE, FALSE)."\t"; $Comment=''; if (!empty($entry_row['base_cat'])) { $Comment.='Base Style: '.$entry_row['base_cat'].$entry_row['base_sub_cat'].' '; } if (strlen($entry_row['style_desc']) > 0) { $Comment.='Style Desc: '.$entry_row['style_desc'].' '; } if (strlen($entry_row['strength']) > 0) { $Comment.=disp_strength($entry_row['strength'], $entry_row['type_seq'], $entry_row['cat']).' '; } if (strlen($entry_row['sweetness']) > 0) { $Comment.=disp_sweetness($entry_row['sweetness'], $entry_row['type_seq']).' '; } if (strlen($entry_row['carbonation']) > 0) { $Comment.=disp_carbonation($entry_row['carbonation'], $entry_row['type_seq']).' '; } $Comment.=str_replace('"', '""', $entry_row['comment']); $Comment=substr($Comment,0,255); while (substr($Comment,-1) == '"') { $Comment=substr($Comment,0,-1); } $Line.='"'.$Comment.'"'."\t\t\t\t\t\t"; $Line.="\r\n"; } fwrite($exports, $Line); } break; case 'BREWER': if ($EHEAD == 'Y') { if ($ESTYLE == 'HCCP') { $Line="First Name\tLast Name\tAddress\tCity\tState\tZip Code\tCountry\tPhone\tBrewer\t"; $Line.="Email Address\tJudge ID\tJudge Rank\tClub\tLikes\tDislikes\r\n"; } else { $Line="Brewer\tFirst Name\tLast Name\tAdditional Brewers\tAddress 1\tCity\tState\t"; $Line.="Zip Code\tEmail Address\tPhone Number\tBrew Club\r\n"; } fwrite($exports, $Line); } $JS_PREF=get_ctrl('JS-LD'); $query='select * from brewer where brewer_type="I" or brewer_type="G" order by brewer'; $brew_res=mysqli_query($db, $query); while ($brew_row=mysqli_fetch_assoc($brew_res)) { if ($brew_row['assist'] == 'N' && cntEntry($brew_row['brewer']) < 1) { continue; } if ($ESTYLE == 'HCCP') { $Line=($brew_row['brewer_type'] != 'G' ? $brew_row['fname']."\t".$brew_row['lname'] : 'Group:'."\t".$brew_row['groupname'])."\t"; $Line.=$brew_row['addr1']."\t".$brew_row['city']."\t"; $Line.=$brew_row['state']."\t".$brew_row['zip']."\tUSA\t".$brew_row['phone1']."\t".$brew_row['brewer']."\t"; $Line.=$brew_row['email']."\t".(strlen($brew_row['bjcpid']) > 0 ? $brew_row['bjcpid'] : '')."\t\t"; $Line.=($brew_row['brewclub'] == 'None' ? '' : $brew_row['brewclub'])."\t"; if (!in_array($brew_row['assist'], array('J', 'S')) || $JS_PREF != 'Y') { $Line.="\t\t"; } else { $Line.=get_prefs($brew_row['brewer'], TRUE)."\t".get_prefs($brew_row['brewer'], FALSE)."\t"; } $Line.="\r\n"; } else { $Line=$brew_row['brewer']."\t".($brew_row['brewer_type'] != 'G' ? $brew_row['fname']."\t".$brew_row['lname'] : 'Group:'."\t".$brew_row['groupname'])."\t\t"; $Line.=$brew_row['addr1']."\t".$brew_row['city']."\t".$brew_row['state']."\t".$brew_row['zip']."\t"; $Line.=$brew_row['email']."\t".$brew_row['phone1']."\t"; $Line.=($brew_row['brewclub'] == 'None' ? '' : $brew_row['brewclub'])."\t\t\t".AmtPaid($brew_row['brewer'])."\t\t\t"; $Line.="\r\n"; } fwrite($exports, $Line); } break; case 'ADDR': if ($EHEAD == 'Y') { $Line="Number\tAddress\tName\tAssist\tHardcopy\r\n"; fwrite($exports, $Line); } $query='select brewer, brewer_type, fname, lname, groupname, email, assist, hardcopy from brewer '; if ($EKIND == 'J' || $EKIND == 'S') { $query.='where brewer_type="'.$EKIND.'" or assist="'.$EKIND.'" '; } $query.='order by brewer'; $result_res=mysqli_query($db, $query); while ($result_row=mysqli_fetch_assoc($result_res)) { if ($EKIND == 'B' && in_array($result_row['brewer_type'], array('I', 'G')) && cntEntry($result_row['brewer']) < 1) { continue; } $Line=$result_row['brewer']."\t".$result_row['email']."\t"; $Line.=($result_row['brewer_type'] == 'G' ? $result_row['groupname'] : $result_row['fname'].(strlen($result_row['fname']) > 0 ? ' ' : '').$result_row['lname'])."\t"; $Line.=$result_row['assist']."\t".$result_row['hardcopy']; $Line.="\r\n"; fwrite($exports, $Line); } break; case 'CONFLICTS': if ($EKIND == 'J' || $EKIND == 'S') { $where='b.assist="'.$EKIND.'" '; } elseif ($EKIND == 'B') { $where='b.brewer_type in ("I", "J", "S") and (b.assist = "J" or b.assist = "S")'; } else { $where='b.assist = "J" or b.assist = "S"'; } $query='select count(*) as cnt from entry as e, brewer as b '; $query.='where ('.$where.') and b.brewer=e.brewer and e.removed != "Y" group by b.brewer order by cnt desc'; $cnt_res=mysqli_query($db, $query); $cnt_row=mysqli_fetch_row($cnt_res); $MaxStyle=$cnt_row[0]; if ($EHEAD == 'Y') { $Line="Number\tAssist\tName\tEmail"; for ($lop=1; $lop<=$MaxStyle; $lop++) { $Line.="\tStyle"; } $Line.="\r\n"; fwrite($exports, $Line); } $query='select distinct b.brewer as brewer, b.brewer_type as brewer_type, b.assist as assist, '; $query.='b.fname as fname, b.lname as lname, b.email as email '; $query.='from entry e left join brewer b on (e.brewer=b.brewer and ('.$where.')) where e.removed!="Y"'; $query.='order by b.brewer'; $result_res=mysqli_query($db, $query); while ($result_row=mysqli_fetch_assoc($result_res)) { $Line=$result_row['brewer']."\t"; $Line.=disp_assist($result_row['assist'])."\t"; $Line.=$result_row['fname'].(strlen($result_row['fname']) > 0 ? ' ' : '').$result_row['lname']."\t"; $Line.=$result_row['email']."\t"; $query='select distinct cat, sub_cat from entry where brewer="'.$result_row['brewer'].'" order by cat, sub_cat'; $entry_res=mysqli_query($db, $query); while ($entry_row = mysqli_fetch_assoc($entry_res)) { $Line.="\t".($entry_row['cat']<10 ? '0' : '').$entry_row['cat'].$entry_row['sub_cat']; } $Line.="\r\n"; fwrite($exports, $Line); } break; case 'PREFS': $prefs=array(); if ($EHEAD == 'Y') { $Line="Number\tAssist\tName\tEmail\tPref 1\tPref 2\tPref 3\tDislike 1\tDislike 2\tDislike 3\r\n"; fwrite($exports, $Line); } $query='select distinct s.brewer as brewer, b.brewer_type as brewer_type, b.assist as assist, '; $query.='b.fname as fname, b.lname as lname, b.email as email '; $query.='from style_prefs s left join brewer b on (s.brewer=b.brewer) where '; if ($EKIND == 'J' || $EKIND == 'S') { $query.='b.assist="'.$EKIND.'" '; } elseif ($EKIND == 'B') { $query.='b.brewer_type in ("I", "J", "S") and (b.assist = "J" or b.assist = "S")'; } else { $query.='b.assist = "J" or b.assist = "S"'; } $query.='order by s.brewer'; $result_res=mysqli_query($db, $query); while ($result_row=mysqli_fetch_assoc($result_res)) { $prefs=array(); $query='select * from style_prefs where brewer="'.$result_row['brewer'].'"'; $prefs_res=mysqli_query($db, $query); while ($prefs_row = mysqli_fetch_assoc($prefs_res)) { $prefs[$prefs_row['rank']]=array($pref_row['type_seq'], $prefs_row['cat'], $prefs_row['sub_cat']); } $Line=$result_row['brewer']."\t"; $Line.=disp_assist($result_row['assist'])."\t"; $Line.=$result_row['fname'].(strlen($result_row['fname']) > 0 ? ' ' : '').$result_row['lname']."\t"; $Line.=$result_row['email']."\t"; foreach (array(1, 2, 3, -1, -2, -3) as $indx) { if (!empty($prefs[$indx][0])) { $Line.=disp_cat($prefs[$indx][0], $prefs[$indx][1], $prefs[$indx][2], TRUE); } $Line.="\t"; } $Line.="\r\n"; fwrite($exports, $Line); unset($prefs); } break; case 'RESULT': if ($EHEAD == 'Y') { $Line="Name\tPlace\tCat-SubCat\tBrew Club\r\n"; fwrite($exports, $Line); } $query='select b.brewer_type, b.fname, b.lname, b.groupname, e.place, e.cat, e.sub_cat, b.brewclub, e.flight '; $query.='from entry e, brewer b where e.removed != "Y" and e.place is not null and e.place >= 1 '; $query.='and e.place <= 3 and e.brewer=b.brewer order by e.flight, e.place'; $result_res=mysqli_query($db, $query); while ($result_row=mysqli_fetch_row($result_res)) { $Line=($result_row[0] == 'G' ? $result_row[3] : $result_row[1].(strlen($result_row[1]) > 0 ? ' ' : '').$result_row[2])."\t"; $Line.=$result_row[4]."\t".($result_row[5]<10 ? '0' : '').$result_row[5].$result_row[6]."\t"; $Line.=($result_row[7] == 'None' ? '' : $result_row[7]); $Line.="\r\n"; fwrite($exports, $Line); } break; case 'BOS': if ($EHEAD == 'Y') { $Line="Name\tBOS Place\tCat-SubCat\tBrew Club\r\n"; fwrite($exports, $Line); } $query='select b.brewer_type, b.fname, b.lname, b.groupname, e.bos_place, e.cat, e.sub_cat, b.brewclub '; $query.='from entry e, brewer b where e.removed != "Y" and e.bos_place is not null '; $query.='and e.bos_place >= 1 and e.bos_place <= 3 and e.brewer=b.brewer order by e.bos_place'; $bos_res=mysqli_query($db, $query); while ($bos_row=mysqli_fetch_row($bos_res)) { $Line=($bos_row[0] == 'I' ? $bos_row[1].(strlen($bos_row[1]) > 0 ? ' ' : '').$bos_row[2] : $bos_row[3])."\t"; $Line.=$bos_row[4]."\t".($bos_row[5]<10 ? '0' : '').$bos_row[5].$bos_row[6]."\t"; $Line.=($bos_row[7] == 'None' ? '' : $bos_row[7]); $Line.="\r\n"; fwrite($exports, $Line); } break; } fclose($exports); $query='insert into changelog values(null, null, "'.$Key.'", "'.$table.'", "E", "'.$ETYPE.'", "'.$Desc.'", "'.$exp_name.'.txt", "'.(!empty($ESTYLE) ? $ESTYLE : '').'")'; mysqli_query($db, $query); ?>

Export Files


Download/View Information

Click on Link to View Information
Right-Click Link and select Save As to Download Information


Select Another File to Export