'!Y!O!N!', 'REQ_BASE' => '!Y!O!N!', 'REQ_STRENGTH' => '!Y!N!', 'REQ_CARBONATION' => '!N!0!1!2!3!4!5!6!7!', 'REQ_COLOR' => '!N!1!2!3!A!B!C!D!', 'REQ_DESC' => '!N!O!Y!'); $SelFields['REQ_SWEETNESS']=($CatType == 'C' ? '!N!1!2!3!4!5!A!B!C!D!E!F!G!H!I!' : '!N!1!3!5!B!F!H!'); $NotEmpty=array('REQ_COMMENT', 'REQ_BASE', 'REQ_STRENGTH', 'REQ_SWEETNESS', 'REQ_CARBONATION', 'REQ_COLOR', 'REQ_DESC'); } else { $SelFields=array('REQ_COMMENT' => '!Y!O!N!', 'REQ_BASE' => '!Y!O!N!', 'REQ_STRENGTH' => '!Y!N!', 'REQ_CARBONATION' => '!N!0!1!2!3!4!5!6!7!'); $SelFields['REQ_SWEETNESS']=($Extended ? '!N!0!1!2!3!4!5!6!7!8!' : '!N!1!2!3!5!6!7!8!'); $NotEmpty=array('REQ_COMMENT', 'REQ_BASE', 'REQ_STRENGTH', 'REQ_SWEETNESS', 'REQ_CARBONATION'); } if (!$NoSubs) { $NotEmpty[]='CAT_DESC'; } else { if (empty($subcat['CAT_DESC'])) { $subcat['CAT_DESC']=$CatDesc; } } if ($cat_row['base'] == 'Y' || ($Comp_SG == '2015' && $CatType == 'C') || ($Comp_SG != '2015' && $CatType != 'B')) { $subcat['REQ_BASE']='N'; } if ($CatType == 'C') { $subcat['BASE']='N'; $subcat['REQ_STRENGTH']='N'; } foreach ($subcat as $tag => $tag_val) { if (!empty($tag_val) && array_key_exists($tag, $SelFields) && (strpos($SelFields[$tag], '!'.$tag_val.'!') === FALSE)) { $e_subcat[$tag.'_1']=TRUE; } if (in_array($tag, $NotEmpty) && empty($tag_val)) { $e_subcat[$tag.'_R']=TRUE; } } $query='select count(*) from style_sub where cat_desc="'.$subcat['CAT_DESC']; $query.='" and sg="'.$Comp_SG.'" and type_seq!="'.$TypeSeq.'" and cat!="'.$Cat.'" and sub_cat!="'.$SubCat.'"'; $cnt_res=mysqli_query($db, $query); $cnt_row=mysqli_fetch_row($cnt_res); if ($cnt_row[0] > 0) { $e_subcat['CAT_DESC_1']=TRUE; } if ($CatType == 'M' && $Comp_SG != '2015' && !$Extended) { if ($subcat['REQ_SWEETNESS'] == '0') { $subcat['REQ_SWEETNESS']='1'; } elseif ($subcat['REQ_SWEETNESS'] == '4') { $subcat['REQ_SWEETNESS']='3'; } } if (count($e_subcat) == 0) { if (!$Edit) { $query='insert into style_sub values(null, "'.$Comp_SG.'", "'.$TypeSeq.'", "'.$Cat.'", "'.$SubCat.'", '; $query.='"'.$subcat['CAT_DESC'].'", "'.$subcat['NOTE_NUM'].'", "'.$subcat['REQ_COMMENT'].'", '; $query.='"'.$subcat['REQ_BASE'].'", "'.$subcat['REQ_STRENGTH'].'", "'.$subcat['REQ_SWEETNESS'].'", '; $query.='"'.$subcat['REQ_CARBONATION'].'", "'.$subcat['REQ_COLOR'].'", "'.$subcat['REQ_DESC'].'", now())'; if (!mysqli_query($db, $query)) { $e_subcat['INSERT']=TRUE; } else { $query='insert into changelog values(null, null, "'.$Key.'", "style_sub", "A", "", "'.$Comp_SG.':'.$TypeSeq.':'.$Cat.':'.$SubCat.'", "", "")'; mysqli_query($db, $query); if (cntSubCat($TypeSeq, $Cat) == 1) { $query='select * from style_sub where sg="'.$Comp_SG.'" and type_seq="'.$TypeSeq.'" and cat="'.$Cat.'" and sub_cat=""'; $subcat_res=mysqli_query($db, $query); if (mysqli_num_rows($subcat_res) == 1) { $subcat_row=mysqli_fetch_assoc($subcat_res); foreach ($Map as $row) { $query='insert into changelog values(null, null, "'.$Key.'", "style_sub", "C", "'.$row.'", "'.$Comp_SG.':'.$TypeSeq.':'.$Cat.':", "'.$subcat_row[$row].'", "")'; mysqli_query($db, $query); } $query='delete from style_sub where sg="'.$Comp_SG.'" and type_seq="'.$TypeSeq.'" and cat="'.$Cat.'" and sub_cat=""'; if (mysqli_query($db, $query)) { $query='insert into changelog values(null, null, "'.$Key.'", "style_sub", "D", "", "'.$Comp_SG.':'.$TypeSeq.':'.$Cat.':", "", "")'; mysqli_query($db, $query); } } } } } else { $query='select * from style_sub where sg="'.$Comp_SG.'" and type_seq="'.$TypeSeq.'" and cat="'.$Cat.'" and sub_cat="'.$SubCat.'"'; $subcat_res=mysqli_query($db, $query); $subcat_row=mysqli_fetch_assoc($subcat_res); foreach ($Map as $tag => $row) { if ($subcat[$tag] != $o_subcat[$tag]) { if ($o_subcat[$tag] != $subcat_row[$row]) { $e_subcat[$tag.'_C']=TRUE; } } } if (count($e_subcat) == 0) { foreach ($Map as $tag => $row) { if ($subcat[$tag] != $o_subcat[$tag]) { $query='update style_sub set '.$row.'="'.$subcat[$tag].'" where sg="'.$Comp_SG.'" and type_seq="'.$TypeSeq.'" and cat="'.$Cat.'" and sub_cat="'.$SubCat.'"'; if (!mysqli_query($db, $query)) { $e_subcat['UPDATE']=TRUE; } else { $query='insert into changelog values(null, null, "'.$Key.'", "style_sub", "C", "'.$row.'", "'.$Comp_SG.':'.$TypeSeq.':'.$Cat.':'.$SubCat.'", "'.$o_subcat[$tag].'", "'.$subcat[$tag].'")'; mysqli_query($db, $query); } } } } } } ?>

Validating Sub-Category Information

'."\n"; if (count($e_subcat) != 0) { BuildHidden($subcat, TRUE); BuildHidden($o_subcat, TRUE, '_ORIG'); BuildHidden($e_subcat); } else { list($CatDesc, $SubCatDesc)=get_desc($TypeSeq, $Cat, $SubCat); echo '

'."\n"; echo 'Sub-Category '.disp_cat($TypeSeq, $Cat, $SubCat).' '.($Edit ? 'Updated' : 'Created')."\n"; echo '
'.$CatDesc.($NoSubs ? '' : '
'.$SubCatDesc)."\n"; echo '

'."\n"; echo ''."\n"; } echo ''."\n"; if (count($e_subcat) != 0 && !array_key_exists('RELOAD', $e_subcat) && !array_key_exists('LIST', $e_subcat)) { echo ''."\n"; } ?>