<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php
  require('load_this/load_bigware_11.php');
	
    
  if ($_GET['action']) {
    switch ($_GET['action']) {
      case 'update':
			
	    if (strlen($attendees_group_name) == "" || $attendees_group_discount ==  "" || $attendees_group_discount ==  0) {
      $error = true;
      $messageStack->add(TYPE_IN_GROUPS_NAME_ERROR);
    } else {						
        $attendees_groups_id = go_db_producing_input($_GET['cID']);
        $attendees_groups_name = go_db_producing_input($_POST['attendees_group_name']);
        $attendees_groups_discount = go_db_producing_input($_POST['attendees_group_discount']);
				$color_bar = go_db_producing_input($_POST['color_bar']);
				$group_tax = go_db_producing_input($_POST['group_tax']); 
        if ($_POST['payment_unallowed']) {
		  while(list($key, $val) = each($_POST['payment_unallowed'])) {
		    if ($val == true) { $group_payment_unallowed .= $val.','; }
		  }
		  $group_payment_unallowed = substr($group_payment_unallowed,0,strlen($group_payment_unallowed)-1);
		  } 
        go_db_query("update " . DB_TBL_ATTENDEES_GROUPS . " set attendees_group_name='" . $attendees_groups_name . "', attendees_group_discount=" . $attendees_group_discount . ", color_bar='" . $color_bar ."', group_payment_unallowed='". $group_payment_unallowed ."', group_tax = '". $group_tax ."' where attendees_group_id = " . go_db_input($attendees_groups_id) );
        go_forward(go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID', 'action')) . 'cID=' . $attendees_group_id));
        }
        break;
        
      case 'deleteconfirm':
        $group_id = go_db_producing_input($_GET['cID']);
        go_db_query("delete from " . DB_TBL_GROUPS_TO_CATEGORIES . " where attendees_group_id= " . $group_id);
        go_db_query("delete from " . DB_TBL_ATTENDEES_GROUPS . " where attendees_group_id= " . $group_id);
        
        $attendees_id_query = go_db_query("select attendees_id from " . DB_TBL_ATTENDEES . " where attendees_group_id=" . $group_id);
        while($attendees_id = go_db_fetch_array($attendees_id_query)) {
            go_db_query("UPDATE " . DB_TBL_ATTENDEES . " set attendees_group_id=1 where attendees_id=" . $attendees_id['attendees_id']);
        }
        
        go_forward(go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID', 'action')))); 
        break;
        
      case 'newconfirm' :
	    if (strlen($attendees_group_name) == "" || $attendees_group_discount ==  "" || $attendees_group_discount ==  0) {
      $error = true;
      $messageStack->add(TYPE_IN_GROUPS_NAME_ERROR);
    } else {				
				$attendees_group_name = go_db_producing_input($_POST['attendees_group_name']);
        $attendees_group_discount = go_db_producing_input($_POST['attendees_group_discount']);
				
				$color_bar = go_db_producing_input($_POST['color_bar']);
				$group_tax = go_db_producing_input($_POST['group_tax']); 
          
				
        go_db_query("insert into " . DB_TBL_ATTENDEES_GROUPS . " set attendees_group_name = '" . $attendees_group_name . "',attendees_group_discount = '" . $attendees_group_discount . "', color_bar='" . $color_bar ."', group_tax = '". $group_tax ."' ");
        go_forward(go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action'))));
				}
        break;
      case 'newdiscountconfirm':
	    if ($_POST['discount'] == "" || $_POST['discount'] == 0) {
      $error = true;
      $messageStack->add(TYPE_IN_GROUPS_NAME_ERROR_ZERO);
    } else {				
        $group_id = go_db_producing_input($_POST['cID']);
        $new_category_discount = go_db_producing_input($_POST['discount']);
        $new_category_id = go_db_producing_input($_POST['categories_id']);
        $check_query = go_db_query('select * from ' . DB_TBL_GROUPS_TO_CATEGORIES . ' where categories_id=' . $new_category_id . ' and attendees_group_id=' . $group_id);
        $check = go_db_fetch_array($check_query);
        if($check == null) {
            $query_insert = "insert into " . DB_TBL_GROUPS_TO_CATEGORIES . " (attendees_group_id, categories_id, discount) VALUES (" . $group_id ."," . $new_category_id ."," . $new_category_discount .")"; 
            go_db_query($query_insert);
        }
        go_forward(go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action','cID')) . '&action=change&cID=' . $group_id));
				}
				
        break;
        
      case 'deletediscount':
        $group_id = go_db_producing_input($_GET['cID']);
        $category_id = go_db_producing_input($_GET['catID']);				
        $delete_query = "delete from " . DB_TBL_GROUPS_TO_CATEGORIES . " where attendees_group_id= " . $group_id . " and categories_id= " . $category_id;
        go_db_query($delete_query);
				go_forward(go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action')) . '&action=change&cID=' . $group_id));
        break;
        
      case 'updatediscount':
	    if ($_POST['upddiscount'] == "" || $_POST['upddiscount'] == 0 ) {
      $error = true;
      $messageStack->add(TYPE_IN_GROUPS_NAME_ERROR_ZERO);
    } else {				
        $group_id = go_db_producing_input($_GET['cID']);
        $new_discount = go_db_producing_input($_POST['upddiscount']);
        $category_id = go_db_producing_input($_POST['catID']);
        $query = "update " . DB_TBL_GROUPS_TO_CATEGORIES . " set discount=" . $new_discount ." where attendees_group_id = " . $group_id . " and categories_id = " . $category_id;
        go_db_query($query);
        go_forward(go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action')) . '&action=change&cID=' . $group_id));
				}
        break;
     
		  case 'updateallprice':
        $groups_id = go_db_producing_input($_GET['cID']); 
				$pricek_array = go_db_query("select p.items_price, p.items_id, p.items_percentage, pc.categories_id from ". DB_TBL_ITEMS ." p, ". DB_TBL_ITEMS_TO_CATEGORIES ." pc WHERE pc.items_id = p.items_id  ");
				while ($pricek_values = go_db_fetch_array($pricek_array)) { 
				$attendees_group_query = go_db_query("select distinct attendees_group_id, attendees_group_name, attendees_group_discount from ". DB_TBL_ATTENDEES_GROUPS ." where attendees_group_id = '" . $groups_id . "' ");
    		$attendees_group = go_db_fetch_array($attendees_group_query);
		 		if (go_db_num_rows($attendees_group_query) > 0) {
     			 $characteristics_query = go_db_query("select attendees_group_id, items_id, attendees_group_price, items_price from " . DB_TBL_ITEMS_GROUPS . " where attendees_group_id = '" . $groups_id . "'AND items_id = '". $pricek_values['items_id'] . "'");
     			 $characteristics = go_db_fetch_array($characteristics_query); 
		 			 $query_discount = go_db_query("select discount from " . DB_TBL_GROUPS_TO_CATEGORIES . " where attendees_group_id = " . $groups_id ." AND categories_id = ". $pricek_values['categories_id'] . ""); 
					 $query_discount_result = go_db_fetch_array($query_discount);
		 		if (is_null($query_discount_result['discount'])) {
		 			 $ricarico = $attendees_group['attendees_group_discount'];
		 			 } else {
		 			 $ricarico = $query_discount_result['discount'];
		 			 }       
			    } 
				$pricek = $pricek_values['items_price']; 
    				if ($pricek > 0){			 
    					 if (B2B == 'true') {	
    		 			 		if ($ricarico > 0) $newprice = $pricek+($pricek/100)*$ricarico;
    		 					if ($ricarico == 0) $newprice = $pricek;
     			  }
    	  		if (B2B == 'false') {
    	   			 if ($ricarico > 0) $newprice = $pricek-($pricek/100)*$ricarico;
    		 			 if ($ricarico == 0) $newprice = $pricek;
     			  }
	 			} else {
	  		$newprice = 0;
	 			}  
				if ($characteristics['attendees_group_id'] == NULL ) { 
				go_db_query("INSERT INTO "  . DB_TBL_ITEMS_GROUPS . " (attendees_group_id, attendees_group_price, items_id, items_price) values (". $groups_id . ", " . $newprice . ", " . $pricek_values['items_id'] . ", " . $pricek . ")");  				
				} else {
				go_db_query("UPDATE "  . DB_TBL_ITEMS_GROUPS . " SET attendees_group_price=". $newprice ." WHERE attendees_group_id=". $groups_id ." AND items_id=". $pricek_values['items_id'] ."");
				}
				$count_update++;
				$item_updated[$id] = 'updated';				
				}
				$count_item = array_count_values($item_updated);
    		if ($count_item['updated'] > 0) $messageStack->add($count_item['updated'].' '.TEXT_ITEMS_UPDATED . " $count_update " . TEXT_QTY_UPDATED, 'success');
				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/menu.js"></script>
<script language="javascript" src="load_this/general.js"></script>
<script language="Javascript" src="load_this/colorpicker.js"></script>
<?php ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<!-- 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">
<?php
if ($_GET['action'] == 'change') {  
    $attendees_group_query = go_db_query("select * FROM " . DB_TBL_ATTENDEES_GROUPS . " c  where c.attendees_group_id = '" . $_GET['cID'] . "' ORDER BY c.attendees_group_id");
    $attendees_group = go_db_fetch_array($attendees_group_query);
    $cInfo = new objectInfo($attendees_group);  
  $payments_unallowed = explode (",",$cInfo->group_payment_unallowed);
  $module_directory = FOLDER_ABSOLUT_CATALOG_MODULES . 'payment/';
  $module_key = 'CONSTITUENT_PAYMENT_INSTALLED';
  $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
  $directory_array = array();
  if ($dir = @dir($module_directory)) {
    while ($file = $dir->read()) {
      if (!is_dir($module_directory . $file)) {
        if (substr($file, strrpos($file, '.')) == $file_extension) {
          $directory_array[] = $file;
        }
      }
    }
    sort($directory_array);
    $dir->close();
  }
	
	 if (!isset($cInfo->group_tax)) $cInfo->group_tax = 'true';
   switch ($cInfo->group_tax) {
      case 'false': $group_tax_inc = false; $group_tax_ex = true; break;
      case 'true':
      default: $group_tax_inc = true; $group_tax_ex = false;
    } 
?>
      <tr>
        <td>
        <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('pixel_trans.gif', ABOVE_IMAGE_WIDTH, ABOVE_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
 

      <tr><?php echo go_fetch_form('attendees_group', NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action')) . 'action=update', 'post', 'onSubmit="return check_form();"'); ?>
        <td class="formAreaTitle"><?php echo CATEGORY_PERSONAL; ?></td>
      </tr>
      <tr>
        <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td class="main"><?php echo TYPE_IN_GROUPS_NAME; ?></td>
            <td class="main"><?php echo go_fetch_inputfeld('attendees_group_name', $cInfo->attendees_group_name, 'maxlength="32"', false); ?></td>
          </tr>
          <tr>
            <td class="main"><?php echo TYPE_IN_DEFAULT_DISCOUNT; ?></td>
            <td class="main"><?php echo go_fetch_inputfeld('attendees_group_discount', $cInfo->attendees_group_discount, 'maxlength="5" size=5', false); ?></td>
          </tr>
			<tr>
			<td class="main"><?php echo TYPE_IN_COLOR_BAR; ?></td>
			 <td>
	<table width="50%" id="colortd" align="left" bgcolor="<?php echo $cInfo->color_bar;?>">
              <tr>                                                                                 
                <td align="center" >
          <!-- flooble.com Color Picker start -->
	          <input id="pick1064797275field" size="12" class="inputframe"
		  onChange="cp.relateColor(this.value);" title="onclick" name="color_bar" value="<?php echo $cInfo->color_bar;?>">
		  <a href="javascript:void(0)" onclick="cp.pickColor();" id="pick1064797275"
		  style="border: 1px solid #000000; font-family:Verdana; font-size:10px;
		  text-decoration: none;">&nbsp;&nbsp;&nbsp;</a>
		  <script language="javascript">
			var cp = new ColorPicker( 'cp', 'pick1064797275', '#ffffff' );
		  </script>
	        <!-- flooble Color Picker end-->               
                </td>
              </tr>
            </table>
			 </td>
			</tr>
<!-- BOF GROUP PAYMENT UNALLOWED -->
<tr>    
<td class="main"><?php echo TYPE_IN_GROUP_PAYMENT_UNALLOWED; ?></td>
<td>
	 <table cellspacing="0" cellpadding="0" border="0" align="right">
	  <tr>
	   <td class="formArea">
	    <table border="0" cellspacing="0" cellpadding="2">
		  <tr class="tbUPCountData">
		    <td align="center" class="tbUPDataInside">*</td>
			  <td class="tbUPDataInside"><?php echo TYPE_IN_PAYMENT_UNALLOWED; ?></td>
      </tr>
<?php
  $module_active = explode (";",CONSTITUENT_PAYMENT_INSTALLED);
  $installed_modules = array();
  for ($i = 0, $n = sizeof($directory_array); $i < $n; $i++) {
    $file = $directory_array[$i];
    if (in_array ($directory_array[$i], $module_active)) {
     include(FOLDER_ABSOLUT_CATALOG_LANGUAGES . $language . '/' . FOLDER_RELATIV_LANG_MODULES_IN_LANG . 'payment/' . $file);
     include($module_directory . $file);
     $class = substr($file, 0, strrpos($file, '.'));
     if (go_class_exists($class)) {
       $module = new $class;
       if ($module->check() > 0) {
         $installed_modules[] = $file;
    }
	  }
?>
	<td class="TbInsideData">
<?php echo go_fetch_checkbox_field('payment_unallowed[' . $i . ']', $module->code , (in_array ($module->code, $payments_unallowed)) ?  1 : 0); ?></td>
    <td class="TbInsideData"><?php echo $module->title; ?></td>
  </tr>
<?php
  if ($_POST['payment_unallowed'][$i]) {
   $_POST['group_payment_unallowed'] .= $_POST['payment_unallowed'][$i] . ',';
   }
  } 
 }
?>
	</table>
	
	
	</td>
	</tr>
	</table>
          <tr>
            <td class="main"><?php echo TYPE_IN_GROUP_TAX; ?></td>
            <td class="main">
<?php echo go_fetch_radio_field('group_tax', 'true', $group_tax_inc) . '&nbsp;' . TEXT_GROUP_TAX_INC . '&nbsp;' . go_fetch_radio_field('group_tax', 'false', $group_tax_ex). '&nbsp;' . TEXT_GROUP_TAX_EX; ?>
            </td>
          </tr>
</td>
</tr>
<!-- EOF GROUP PAYMENT UNALLOWED -->				
				
				
	</table>
	</td>
				
      </tr>			
			
      <tr>
        <td class="TbInsideData">
				* <?php echo TYPE_IN_PAYMENT_UNALLOWED_EXPLAIN; ?><br>
				<?php echo go_fetch_dividing_up('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td align="right" class="main"><?php echo go_picture_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action','cID'))) .'">' . go_picture_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
      </tr>
      </form>

      </table>
      

      
      </td>
      </tr>			

<?php
  } else if($_GET['action'] == 'newdiscount') {
?>
      <tr>
        <td><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('pixel_trans.gif', ABOVE_IMAGE_WIDTH, ABOVE_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      
<?php
  } else if($_GET['action'] == 'new') {
   ?>
      <tr>
        <td><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('pixel_trans.gif', ABOVE_IMAGE_WIDTH, ABOVE_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr><?php echo go_fetch_form('attendees', NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action')) . 'action=newconfirm', 'post', 'onSubmit="return check_form();"'); ?>
        <td class="formAreaTitle"><?php echo CATEGORY_PERSONAL; ?></td>
      </tr>
      <tr>
        <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td class="main"><?php echo TYPE_IN_GROUPS_NAME; ?></td>
            <td class="main"><?php echo go_fetch_inputfeld('attendees_group_name', '', 'maxlength="32"', true) . '&nbsp;' . (go_not_null(TYPE_IN_FIRST_NAME_TEXT) ? '<span class="inputRequirement"></span>': ''); ?></td>
          </tr>
          <tr>
            <td class="main"><?php echo TYPE_IN_DEFAULT_DISCOUNT; ?></td>
            <td class="main"><?php echo go_fetch_inputfeld('attendees_group_discount', '', 'maxlength="5" size=5', true); ?></td>
          </tr>
			<tr>
			<td class="main"><?php echo TYPE_IN_COLOR_BAR; ?></td>
			 <td>
				    <table width="50%" id="colortd" align="left" bgcolor="#ffffff">
              <tr>                                                                                 
                <td align="center" >
          
	          <input id="pick1064797275field" size="12" class="inputframe"
		  onChange="cp.relateColor(this.value);" title="onclick" name="color_bar" value="<?php echo $cInfo->color_bar;?>">
		  <a href="javascript:void(0)" onclick="cp.pickColor();" id="pick1064797275"
		  style="border: 1px solid #000000; font-family:Verdana; font-size:10px;
		  text-decoration: none;">&nbsp;&nbsp;&nbsp;</a>
		  <script language="javascript">
			var cp = new ColorPicker( 'cp', 'pick1064797275', '#ffffff' );
		  </script>
	                    
                </td>
              </tr>
            </table>
			 </td>
			</tr>
<?php  ?>
          <tr>
            <td class="main"><?php echo TYPE_IN_GROUP_TAX; ?></td>
            <td class="main">
<?php echo go_fetch_radio_field('group_tax', '1', $group_tax_inc) . '&nbsp;' . TEXT_GROUP_TAX_INC . '&nbsp;' . go_fetch_radio_field('group_tax', '0', $group_tax_ex). '&nbsp;' . TEXT_GROUP_TAX_EX; ?>
            </td>
          </tr>
					
					
					
        </table></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td align="right" class="main"><?php echo go_picture_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action','cID'))) .'">' . go_picture_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
      </tr>        
      
      </table></td>
      </tr>
      
      </form>
<?php 
  } else {
?>
      <tr>
        <td><table cellpadding="5" border="0" width="100%" cellspacing="0" cellpadding="0"> 
          <tr><?php echo go_fetch_form('search', NAME_OF_FILE_ATTENDEES_GROUPS, '', 'get'); ?>
            <td class="pageGeneralsign"><?php echo ABOVE_TITLE; ?></td>
            <td class="pageGeneralsign" align="right"><?php echo go_fetch_dividing_up('pixel_trans.gif', 1, ABOVE_IMAGE_HEIGHT); ?></td>
            <td class="smallText" align="right"><?php echo ABOVE_TITLE_SEARCH . ' ' . go_fetch_inputfeld('search'); ?></td>
          </form></tr>
        </table></td>
      </tr>
      <tr>
          <?php
          switch ($listing) {
              case "id-asc":
              $order = "g.attendees_group_id";
              break;
              case "group":
              $order = "g.attendees_group_name";
              break;
              case "group-desc":
              $order = "g.attendees_group_name DESC";
              break;
              case "discount":
              $order = "g.attendees_group_discount";
              break;
              case "discount-desc":
              $order = "g.attendees_group_discount DESC";
              break;
              default:
              $order = "g.attendees_group_id DESC";
          }
          ?>
             <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 DB_TBL_ABOVE_NAME; ?>&nbsp;</td>
                <td></td>
								<td class="tbUPDataInside" align="right">								
                <?php echo DB_TBL_ABOVE_DISCOUNT; ?>&nbsp;</td>
                
								
                <td class="tbUPDataInside" align="right"><?php echo DB_TBL_ABOVE_ACTION; ?>&nbsp;</td>
              </tr>
<?php
    $search = '';
    if ( ($_GET['search']) && (go_not_null($_GET['search'])) ) {
      $keywords = go_db_input(go_db_producing_input($_GET['search']));
      $search = "where g.attendees_group_name like '%" . $keywords . "%'";
    }
    $attendees_group_query_raw = "select * from " . DB_TBL_ATTENDEES_GROUPS . " g  " . $search . " order by $order";
    $attendees_group_split = new splitPageResults($_GET['page'], MAX_SHOW_SEARCH_RESULTS, $attendees_group_query_raw, $attendees_group_query_numrows);
    $attendees_group_query = go_db_query($attendees_group_query_raw);
    while ($attendees_group = go_db_fetch_array($attendees_group_query)) {
      $info_query = go_db_query("select attendees_info_date_member_created as date_member_created, attendees_info_date_member_last_modified as date_member_last_modified, attendees_info_date_of_last_logon as date_last_logon, attendees_info_number_of_logons as number_of_logons from " . DB_TBL_ATTENDEES_INFO . " where attendees_info_id = '" . $attendees_group['attendees_group_id'] . "'");
      $info = go_db_fetch_array($info_query);
      if (((!$_GET['cID']) || (@$_GET['cID'] == $attendees_group['attendees_group_id'])) && (!$cInfo)) {
        $group_discount_query = go_db_query("select c.categories_name, g.discount, c.language_id from " . DB_TBL_CATEGORIES_DESCRIPTION . " c, " . DB_TBL_GROUPS_TO_CATEGORIES . " g where g.attendees_group_id = '" . $attendees_group['attendees_group_id'] . "' and g.categories_id=c.categories_id and c.language_id = " . $languages_id . " order by c.categories_name");   
        $cInfo = new objectInfo($attendees_group);//$cInfo_array);
      }
      if ( (is_object($cInfo)) && ($attendees_group['attendees_group_id'] == $cInfo->attendees_group_id) ) {
        echo '<tr class="tbCountDataSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID', 'action')) . 'cID=' . $cInfo->attendees_group_id . '&action=change') . '\'">' . "\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_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID')) . 'cID=' . $attendees_group['attendees_group_id']) . '\'">' . "\n";
      }
?>
                <td class="TbInsideData"><?php echo $attendees_group['attendees_group_name']; ?></td>
								<td  bgcolor="<?php echo $attendees_group['color_bar']; ?>" width="5"></td>
                <td class="TbInsideData" align="right"><?php echo $attendees_group['attendees_group_discount']; ?>%</td>
                <td class="TbInsideData" align="right"><?php if ( (is_object($cInfo)) && ($attendees_group['attendees_group_id'] == $cInfo->attendees_group_id) ) { echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID')) . 'cID=' . $attendees_group['attendees_group_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%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php echo $attendees_group_split->display_count($attendees_group_query_numrows, MAX_SHOW_SEARCH_RESULTS, $_GET['page'], TEXT_SHOW_NUMBER_OF_ATTENDEES); ?></td>
                    <td class="smallText" align="right"><?php echo $attendees_group_split->display_links($attendees_group_query_numrows, MAX_SHOW_SEARCH_RESULTS, MAXIMUM_SHOW_PAGE_LINKS, $_GET['page'], go_get_all_get_parameter(array('page', 'info', 'x', 'y', 'cID'))); ?></td>
                  </tr>
<?php
    if (go_not_null($_GET['search'])) {
?>
                  <tr>
                    <td align="right" colspan="2"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS) . '">' . go_picture_button('button_reset.gif', IMAGE_RESET) . '</a>'; ?></td>
                  </tr>
<?php
    }
?>
                </table></td>
              </tr>
            </table></td>
<?php
  $heading = array();
  $contents = array();
  switch ($_GET['action']) {
    case 'confirm':
        if ($_GET['cID'] != 1) {
            $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_DELETE_ATTENDEE . '</b>');
            $contents = array('form' => go_fetch_form('attendees_group', NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID', 'action')) . 'cID=' . $cInfo->attendees_group_id . '&action=deleteconfirm'));
            $contents[] = array('text' => TEXT_DELETE_INTRO . '<br><br><b>' . $cInfo->attendees_group_name . ' </b>');
            if ($cInfo->number_of_reviews > 0) $contents[] = array('text' => '<br>' . go_fetch_checkbox_field('delete_reviews', 'on', true) . ' ' . sprintf(TEXT_DELETE_REVIEWS, $cInfo->number_of_reviews));
            $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID', 'action')) . 'cID=' . $cInfo->attendees_group_id) . '">' . go_picture_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
        } else {
            $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_DELETE_ATTENDEE . '</b>');
            $contents[] = array('text' => TEXT_IMPOSSIBLE_DELETE .'<br><br><b>' . $cInfo->attendees_group_name . ' </b>');
        }
      break;
    default:
      if (is_object($cInfo)) {
        $heading[] = array('text' => '<b>' . $cInfo->attendees_group_name . ' </b>');
        $contents[] = array('align' => 'center', 'text' => '<a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID', 'action')) . 'cID=' . $cInfo->attendees_group_id . '&action=change') . '">' . go_picture_button('button_change.gif', IMAGE_CHANGE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID', 'action')) . 'cID=' . $cInfo->attendees_group_id . '&action=confirm') . '">' . go_picture_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('cID', 'action')) . '&action=new') . '">' . go_picture_button('button_new_group.gif', IMAGE_NEW_GROUP) . '</a> <a href="' . go_href_link(NAME_OF_FILE_ATTENDEES_GROUPS, go_get_all_get_parameter(array('action', 'cID')) .'cID=' . $cInfo->attendees_group_id . '&action=updateallprice') . '">' . go_picture_button('button_updateallprice.gif', IMAGE_UPDATEALLPRICE) . '</a>');
        
				if ($cInfo->group_tax == 'false'){ 
				 $show_gr_tax = TEXT_GROUP_TAX_EX;
				 } else {
				 $show_gr_tax = TEXT_GROUP_TAX_INC;
				 }
        
				$contents[] = array('text' => '' . TYPE_IN_GROUP_TAX . ' : ' . $show_gr_tax . '' );				
				
				
				$contents[] = array('text' => '' . TEXT_CATEGORIES . '' );
        while($group_discount = go_db_fetch_array($group_discount_query)) {
            $contents[] = array('text' => ''. $group_discount['categories_name'] .' : ' . $group_discount['discount'] . '%');
        }
      }
      break;
  }
  if ( (go_not_null($heading)) && (go_not_null($contents)) ) {
    echo '            <td width="25%" valign="top">' . "\n";
    $frame = new frame;
    echo $frame->infoBox($heading, $contents);
    echo '            </td>' . "\n";
  }
?>
          </tr>
        </table></td>
      </tr>
<?php
  }
?>
  </td>
<!-- body_text_eof //--> 
  </tr> 
</table> 
<!-- body_eof //--> 
<!-- footer //--> 
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?> 
<!-- footer_eof //--> 
<br> 
</body> 
</html> 
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_6.php'); ?>
