<?php
# ID: 20
# Providers_create_module ver.1.0
# last modification 30.3.2010
# Formulář pro vytváření privideru
#
# 
if (IsSet($_POST['PC_SUBMIT']) ){
  include "build/db_connect.inc.php"  ;
   $query="INSERT INTO provider (Name,description)
                  VALUES(\"".$_POST['PC_NAME']."\",\"".$_POST['PC_DESCRIPTION']."\")";
          $result = mysql_query($query);
          
          if (!$result) {
            die('Data nelze vložit mezi providery:' . mysql_error());
          }   
  echo "Data o poskytelovately uloženy. ";
  echo "<a href=\"".selfURL()."\">Pokračovat</a>";



}else{ 
?>

<script language="JavaScript">
// soubor funkcí pro kontrolu hodnot formuláře na straně klienta
  function HideIt() {
        document.getElementById('required').style.visibility= "hidden";
        document.getElementById('requiredtext').style.visibility= "hidden";
  }
 
   
  function CheckEmptyField( theField, theMessage ) {
   if( theField.value=="" ) {
      theField.focus();
      if(document.getElementById) {
        document.getElementById('required').style.visibility= "visible";
        document.getElementById('requiredtext').style.visibility= "visible";
        document.getElementById('requiredtext').innerHTML= theMessage;
        setTimeout( "HideIt()",1500);
      } else {
          alert(theMessage);
      }
      return false;
   } else {
      return true;
   }
  }
  function Validate(theForm) {
      if( !CheckEmptyField(theForm.PC_NAME,"Zadejte prosím název providera!") ) return false;
      
  // uspech
  return true;
}
     <!-- <![CDATA[
      var MaxLengthLock = false;
      function MaxLengthCount(fieldObj,fieldMaxLength)
      {
        if (!MaxLengthLock)
        {
          MaxLengthLock = true;
          if (fieldObj.value.length > fieldMaxLength)
          {
            alert("Text je delší než " + fieldMaxLength + " znaků!");
            fieldObj.value = fieldObj.value.substring(0,fieldMaxLength);
          }
          var percentage = parseInt(100 - (( fieldMaxLength - fieldObj.value.length) * 100)/fieldMaxLength);
          document.getElementById(fieldObj.id + "_PBar").style.width = parseInt((parseInt(fieldObj.offsetWidth)*percentage)/100)+"px";
          MaxLengthLock = false;
        }
      }
      //]]> -->
 

</script>
<center>
 <div class="forms">
<h2>Vytvoření nového providera</h2><span class="backtoform"><a href="admin_page.php?NEXTFORM=19">Zpět</a> </span>
<fieldset>
  <legend>Informace</legend>
  
  <form name="form1" action="admin_page.php" onSubmit="return Validate(this);" method="post">
      <table>
        <tr>
          <td class="tablehead">Název: </td><td class="tableculombhead"><input type="text" name="PC_NAME" value="<?php if(IsSet($_POST['PC_NAME'])){echo $_POST['PC_NAME'];}?>" ></td>
        </tr>
        <tr>
          <td class="tablehead" colspan=2>Popis: </td>
        </tr>
        <tr>
          <td colspan=2 class="tableculombhead"><textarea name="PC_DESCRIPTION" id="PC_DESCRIPTION" accesskey="T" rows="6" cols="30" wrap="virtual"
            onpropertychange="MaxLengthCount(this,160);"
            onclick="MaxLengthCount(this,160);"
            onmousemove="MaxLengthCount(this,160);"
            onblur="MaxLengthCount(this,160);"
            onkeyup="MaxLengthCount(this,160);"
            onfocus="MaxLengthCount(this,160);"
            onchange="MaxLengthCount(this,160);"
            onafterupdate="MaxLengthCount(this,160);"></textarea>
          <div id="PC_DESCRIPTION_PBar" style="width:0px;height:10px;border:0;font-size:8px;overflow:hidden;background-color: #3399FF;"></div></td>
        </tr><tr>
        
        <input name="PC_SUBMIT" type="hidden" value="TRUE" >
        <td class="tablehead" colspan=2 style="text-align:center"><input type="reset" value="Storno"><input type="submit" value="Vytvoř"></td>
        </tr>
      </table>
  </form>
</fieldset> 

</div>
</center>
<script language="JavaScript"><!-------------
// Tuto funkci je mozno vlozit na konec hlavního dokumentu a ušetři její opakování
if(document.getElementById) {
  document.write('<img ID="required" STYLE="visibility:hidden; position:absolute; left:300; top:120" src="required.gif">');
  document.write('<p ID="requiredtext" STYLE="visibility:hidden; position:absolute; left:365; top:155" >abc</p>');
}

//-----------></script> 
<?php
}
?>