<?php
  $Type = $_GET['type'];

  $File = "../graphconf/bar{$Type}.inc";

  if(!empty($_POST['Change']))
  {
    $Height    = $_POST['height'];
    $Width     = $_POST['width'];
    $ColorMode = $_POST['colormode'];
    $BarColor     = $_POST['barcolor'];
    if($BarColor[0] != '#') $BarColor = '#'.$BarColor;
    if(!ereg("#[A-Fa-f0-9]+", $BarColor))
      $Errors[] = $Err_NoHex;
    if(empty($Errors))
    {
      $Str = "<?php\n";
	    $Str .= "\$Height = {$Height};\n";
	    $Str .= "\$Width = {$Width};\n";
      $Str .= "\$BarColor = '{$BarColor}';\n";
      $Str .= "\$ColorMode = '{$ColorMode}';\n";
      $Str .= "?>";
	    SaveStringInFile($File, $Str, 'w');
	    Refresh("graphic_jpgraph_bars&type={$Type}");
    }
  }
  include_once($File);
  $OptStr = "<option value=50>50<option value=100>100<option value=150>150<option value=200>200<option value=250>250<option value=300>300<option value=350>350<option value=400>400<option value=450>450<option value=500>500<option value=550>550<option value=600>600<option value=650>650<option value=700>700<option value=750>750<option value=800>800<option value=850>850<option value=900>900<option value=950>950<option value=1000>1000";
  $Heading = "{$Heading_Bars} $Type";
  print "<h5>{$Heading}</h5>";
  print "<form method=post action=''>";
  ShowErrors($Errors, '75%', 'VeryMiniField');
  print "<fieldset class=VeryMiniField align=center>";
    print "<table class=General align=center border=0 cellspacing=0 cellpadding=0 width=75%>";
      print "<tr>";
        print "<td>{$Cpt_jpgraph_width}</td>";
        print "<td>";
          print "<select name=width>";
            $Tmp = str_replace("<option value={$Width}>{$Width}", "<option value={$Width} selected>{$Width}", $OptStr);
            print $Tmp;
          print "</select>";
        print "</td>";
      print "</tr>";
      print "<tr>";
        print "<td>{$Cpt_jpgraph_height}</td>";
        print "<td>";
          print "<select name=height>";
            $Tmp = str_replace("<option value={$Height}>{$Height}", "<option value={$Height} selected>{$Height}", $OptStr);
            print $Tmp;
          print "</select>";
        print "</td>";
      print "</tr>";
      print "<tr>";
        print "<td>{$Cpt_jpgraph_colormode}</td>";
        print "<td>";
          print "<select name=colormode>";
            if($ColorMode == 'onecolor')
              print "<option selected value = onecolor>{$Opt_unicolor}";
            else
              print "<option value = onecolor>{$Opt_unicolor}";
            if($ColorMode == 'manycolors')
              print "<option selected value = manycolors>{$Opt_multicolor}";
            else
              print "<option value = manycolors>многоцветный";
            if($ColorMode == 'transparent')
              print "<option selected value = transparent>{$Opt_transparent}";
            else
              print "<option value = transparent>{$Opt_transparent}";
          print "</select>";
        print "</td>";
      print "</tr>";
      print "<tr>";
        print "<td>{$Cpt_jpgraph_color}</td>";
        print "<td><input type=text name=barcolor value='{$BarColor}' size=7 maxlength=7></td>";
      print "</tr>";
      print "<tr><td align=center colspan=2><input class = ButtonSettings type=Submit name=Change value='{$Button_Change}'></td></tr>";
    print "</table>";
  print "</fieldset>";
  print "</form>";
?>