<?php
 require('load_this/load_bigware_11.php');
 function go_set_searchselect_status($searchselect_id, $status) {
 if ($status == '1') {
 return go_db_query("update ".DB_TBL_SEARCHSELECT." set status = '1' where searchselect_id = '" . $searchselect_id . "'");
 } elseif ($status == '0') {
 return go_db_query("update ".DB_TBL_SEARCHSELECT." set status = '0' where searchselect_id = '" . $searchselect_id . "'");
 } else {
 return -1;
 }
 }
 switch ($_GET['action']) {
 case 'setflag':
 go_set_searchselect_status($_GET['id'], $_GET['flag']);
 go_forward(go_href_link(NAME_OF_FILE_SEARCHSELECT, '', 'NONSSL'));
 break;
 case 'insert':
 $searchtext = $_POST['searchtext'];
 $selectbox = $_POST['selectbox'];
 
 go_db_query("insert into ".DB_TBL_SEARCHSELECT." (`searchtext`,selectbox, status) values ('" . $_POST['searchtext'] . "', '" .$_POST['selectbox']. "' , '1')");
 go_forward(go_href_link(NAME_OF_FILE_SEARCHSELECT));
 break;
 case 'update':
 $searchtext = $_POST['searchtext'];
 $selectbox = $_POST['selectbox'];
 
 go_db_query("update ".DB_TBL_SEARCHSELECT." set `searchtext`='".$searchtext."',selectbox='".$selectbox."' where searchselect_id = '" . $_POST['searchselect_id'] . "'");
 go_forward(go_href_link(NAME_OF_FILE_SEARCHSELECT, '&sID=' . $searchselect_id));
 break;
 case 'deleteconfirm':
 $searchselect_id = go_db_producing_input($_GET['sID']);
 go_db_query("delete from ".DB_TBL_SEARCHSELECT." where searchselect_id = '" . go_db_input($searchselect_id) . "'");
 go_forward(go_href_link(NAME_OF_FILE_SEARCHSELECT));
 break;
 }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="load_this/style.css">
<script language="javascript" src="load_this/general.js"></script>
<script language="javascript" src="load_this/menu.js"></script>
<?php
 if ( ($_GET['action'] == 'new') || ($_GET['action'] == 'edit') ) {
?>
<link rel="stylesheet" type="text/css" href="includes/javascript/calendar.css">
<script language="JavaScript" src="includes/javascript/calendarcode.js"></script>
<?php
 }
?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="popupcalendar" class="text"></div>
<!-- header //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_9.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
 <td width="<?php echo FRAME_WIDTH; ?>" valign="top"></td>
<!-- body_text //-->
 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
 <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
 <td class="pageGeneralsign"><?php echo ABOVE_TITLE; ?></td>
 <td class="pageGeneralsign" align="right"><?php echo go_fetch_dividing_up('tranparentes.gif', ABOVE_PICTURE_WIDTH, ABOVE_PICTURE_HEIGHT); ?></td>
 </tr>
 </table></td>
 </tr>
<?php
 if ( ($_GET['action'] == 'new') || ($_GET['action'] == 'edit') ) {
 $form_action = 'insert';
 
 $searchselectbox_query_raw = "select * from ".DB_TBL_SEARCHSELECTBOX." order by selectboxtext";
 $searchselectbox_query = go_db_query($searchselectbox_query_raw);
 $searchselectbox_array = "";
 while ($searchselectbox=go_db_fetch_array($searchselectbox_query)){
 $searchselectbox_array[] = array('id'=>$searchselectbox['searchselectbox_id'],'text'=>$searchselectbox['selectboxtext']);
 }
 
 if ( ($_GET['action'] == 'edit') && ($_GET['sID']) ) {
 $form_action = 'update';
 
 $searchselect_query = go_db_query("select `searchtext`,selectbox from ".DB_TBL_SEARCHSELECT." where searchselect_id = '" . $_GET['sID'] . "'");
 $searchselects = go_db_fetch_array($searchselect_query);
 
 
 
 $sInfo = new objectInfo($searchselects);
 } else {
 $sInfo = new objectInfo(array());
 
 }	
?>
 <tr><form name="new_feature" <?php echo 'action="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, go_get_all_get_parameter(array('action', 'info', 'sID')) . 'action=' . $form_action, 'NONSSL') . '"'; ?> method="post"><?php if ($form_action == 'update') echo go_fetch_hidden_field('searchselect_id', $_GET['sID']); ?>
 <td><br>
 
 
<table cellpadding="5" border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
 <td valign="top"> 
 
 
 
 <table border="0" cellspacing="0" cellpadding="2">
 <tr>
 <td class="main"><?php echo TEXT_SEARCHSELECT_LIMIT; ?>&nbsp;</td>
 <td class="main"><?php echo go_fetch_inputfeld('searchtext',$sInfo->searchtext,'size "6"');?></td>
 </tr>
 <tr>
 <td class="main"><?php echo TEXT_SEARCHSELECT_PROCENT; ?>&nbsp;</td>
 <td class="main"><?php echo go_fetch_pull_down_menu('selectbox', $searchselectbox_array, $sInfo->selectbox); ?></td>
 </tr>
 </table></td>
 </tr>
 <tr>
 <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
 <td class="main" align="right" valign="top"><br>
 <?php echo (($form_action == 'insert') ? go_picture_submit('button_insert.gif', IMAGE_INSERT) : go_picture_submit('button_update.gif', IMAGE_UPDATE)). 
 '&nbsp;&nbsp;&nbsp;<a href="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'sID=' . $_GET['sID']) . '">' . go_picture_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
 </tr>
 </table></td>
 </form></tr>
<?php
 } 
	else {
?>
 <tr>
 <td><table cellpadding="5" border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
 <td valign="top"><table border="0" cellpadding="5" cellspacing="1" style="border-collapse: collapse" width="100%" id="AutoNumber1">
 <tr class="tbUPCountData">
 <td class="tbUPDataInside"><?php echo TABLE_HEADING_SEARCHSELECT_LIMIT; ?></td>
 <td class="tbUPDataInside" align="right"><?php echo TABLE_HEADING_SEARCHSELECT_PRECENT; ?></td>
 <td class="tbUPDataInside" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>
 <td class="tbUPDataInside" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 </tr>
<?php
 $searchselect_query_raw = "select s.searchtext,sb.selectboxtext,s.status,s.searchselect_id from ".DB_TBL_SEARCHSELECT." s, ".DB_TBL_SEARCHSELECTBOX." sb where sb.searchselectbox_id=s.selectbox order by `searchtext`";
 $searchselect_split = new splitPageResults($_GET['page'], MAX_SHOW_SEARCH_RESULTS, $searchselect_query_raw, $searchselect_query_numrows);
 $searchselect_query = go_db_query($searchselect_query_raw);
 
	
 
 while ($searchselect = go_db_fetch_array($searchselect_query)) {
 if ( ((!$_GET['sID']) || ($_GET['sID'] == $searchselect['searchselect_id'])) && (!$sInfo) ) {
 /*$products_query = go_db_query(\"select products_picture from \" . DB_TBL_PRODUCTS . \" where products_id = '\" . $featured['products_id'] . \"'\");
        $products = go_db_fetch_array($products_query);
        $sInfo_array = array_merge($featured, $products);*/
         $sInfo = new objectInfo($searchselect);
 }
 if ( (is_object($sInfo)) && ($searchselect['searchselect_id'] == $sInfo->searchselect_id) ) {
 echo ' <tr class="tbCountDataSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'sID=' . $sInfo->searchselect_id . '&action=edit') . '\'">' . "\n";
 } else {
 echo ' <tr class="tbCountData" onmouseover="this.className=\'tbCountDataOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'tbCountData\'" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'sID=' . $searchselect['searchselect_id']) . '\'">' . "\n";
 }
?>
 <td class="TbInsideData"><?php echo $searchselect['searchtext']; ?></td>
 <td class="TbInsideData" align="right"><?php echo $searchselect['selectboxtext']; ?></td>
 <td class="TbInsideData" align="right">
<?php
 if ($searchselect['status'] == '1') {
 echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '&nbsp;&nbsp;<a href="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'action=setflag&flag=0&id=' . $searchselect['searchselect_id'], 'NONSSL') . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
 } else {
 echo '<a href="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'action=setflag&flag=1&id=' . $searchselect['searchselect_id'], 'NONSSL') . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>&nbsp;&nbsp;' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
 }
?></td>
 <td class="TbInsideData" align="right"><?php if ( (is_object($sInfo)) && ($searchselect['searchselect_id'] == $sInfo->searchselect_id) ) { echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'sID=' . $featured['featured_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 </tr>
<?php
 }
?>
 <tr>
 <td colspan="4"><table border="0" width="100%" cellpadding="0"cellspacing="2">
 <tr>
 <td class="smallText" valign="top"><?php echo $searchselect_split->display_count($searchselect_query_numrows, MAX_SHOW_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_FEATURED); ?></td>
 <td class="smallText" align="right"><?php echo $searchselect_split->display_links($searchselect_query_numrows, MAX_SHOW_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
 </tr>
<?php
 if (!$_GET['action']) {
?>
 <tr> 
 <td colspan="2" align="right"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'action=new') . '">' . go_picture_button('button_new_searchselect.gif', IMAGE_NEW_SEARCHSELECT) . '</a>'; ?></td>
 </tr>
<?php
 }
?>
 </table></td>
 </tr>
 </table></td>
<?php
 $heading = array();
 $contents = array();
 switch ($_GET['action']) {
 case 'delete':
 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_FEATURED . '</b>');
 $contents = array('form' => go_fetch_form('discount', NAME_OF_FILE_SEARCHSELECT, 'sID=' . $sInfo->searchselect_id . '&action=deleteconfirm'));
 $contents[] = array('text' => TEXT_INFO_SEARCHSELECT_INTRO);
 $contents[] = array('text' => '<br><b>' . $sInfo->searchtext . ', '.$sInfo->selectbox.' </b>');
 $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'sID=' . $sInfo->discount_id) . '">' . go_picture_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 break;
 default:
 if (is_object($sInfo)) {	
 $heading[] = array('text' => '<b>' . $sInfo->searchtext . ', '. $sInfo->selectbox.' </b>');
 $contents[] = array('align' => 'center', 'text' => '<a href="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'sID=' . $sInfo->searchselect_id . '&action=edit') . '">' . go_picture_button('button_change.gif', IMAGE_EDIT) . '</a> <a href="' . go_href_link(NAME_OF_FILE_SEARCHSELECT, 'sID=' . $sInfo->searchselect_id . '&action=delete') . '">' . go_picture_button('button_delete.gif', IMAGE_DELETE) . '</a>');
 }
 break;
 }
 if ( (go_not_null($heading)) && (go_not_null($contents)) ) {
 echo ' <td width="25%" valign="top">' . "\n";
 $box = new box;
 echo $box->infoBox($heading, $contents);
 echo ' </td>' . "\n";
 }
}
?>
 </tr>
 </table></td>
 </tr>
 </table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_6.php'); ?>