<?php


function TABLE_INSERTDB() {
global $error,$thiss,$MENU_INIT;
if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN][FUNCPERMEDIT][TABLE_INSERTDB],"W")) {  //EOF if($_SESSION[CURRENT_MENU]==A_PROBLEM)
 echo "<hr>f. TABLE_INSERTDB<hr>";
      if($_POST) {

         $ZAP_SQL_INSERT_F = "insert into ".$thiss->DETECT_TABLE_NAME." (ID,A_RECORD_UPDATE_DATE,A_RECORD_UPDATE_AUTHOR,A_RECORD_CREATE_DATE,A_RECORD_CREATE_AUTHOR";
         $ZAP_SQL_INSERT_V = ") values ('','".date(Y)."-".date(m)."-".date(d)."-".date(H).":".date(i)."','".$_SESSION[ADM_ACCOUNT]."','".date(Y)."-".date(m)."-".date(d)."-".date(H).":".date(i)."','".$_SESSION[ADM_ACCOUNT]."'";

	foreach ($_SESSION[$thiss->DETECT_TABLE_COLUMN][DESC] as $value) {
		if(($_SESSION[$thiss->DETECT_TABLE_COLUMN][WIEVID]==$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]) && (isset($_POST["$value"])) &&  (!($_POST["$value"]==$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][$value]))) {
			if(($_SESSION[$thiss->DETECT_TABLE_COLUMN][TYPESPECIAL][$value])) { 
				if(!function_exists($_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPESPECIAL'][$value])) SEF($_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPESPECIAL'][$value]);
				$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPESPECIAL'][$value]('POST_VERIFY', $_POST[$value]);
			}
		}
	}

       foreach ($_SESSION[$thiss->DETECT_TABLE_COLUMN][DESC] as $value) {
	if((isset($_POST["$value"])) && (strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN][PERMEDIT]["$value"],'C'))) { 
          $_SESSION[$thiss->DETECT_TABLE_COLUMN][EDIT_TEMPLATE][$value]=$_POST[$value]; 
          $_SESSION[$thiss->DETECT_TABLE_COLUMN][NEW_RECORD][$value]=$_POST[$value];
if($_SESSION[DEBUG])  "<br>\n F.TABLE_INSERTDB value= $value";
         $ZAP_SQL_INSERT_F = $ZAP_SQL_INSERT_F . ",$value";
         $ZAP_SQL_INSERT_V = $ZAP_SQL_INSERT_V . ",'". $_POST["$value"]. "'";      
	 }
       } //EOF foreach1
      } //EOF post
   if(!($error)) {
      $ZAP_SQL_INSERT = $ZAP_SQL_INSERT_F . $ZAP_SQL_INSERT_V . ");" ;
if($_SESSION[DEBUG])     echo "<hr>$ZAP_SQL_INSERT<hr>";
       ZAP_SQL_UPDATE($ZAP_SQL_INSERT); $RESULT=$_SESSION[MYSQL_UPDATE_NUM_ROWS] ;
      echo "PASSED($RESULT)<hr>";
   }
 } 

echo "<h2>AKTUALIZACJA DANYCH: ";
if($RESULT==2) echo "OK($RESULT)"; else { echo "ERROR($RESULT,$error)";
 }
echo "</h2>";
CREATE_MENUFUNC_NOTD_INIT($_SESSION[LAST_MENU],'POWROT DO ' . $_SESSION[LAST_MENU]);
echo " | ";
CREATE_MENUFUNC_NOTD_INIT($_SESSION[CURRENT_MENU],'POWROT DO ' . $_SESSION[CURRENT_MENU]);
if(!($RESULT==2)) {
 echo " | ";
 CREATE_MENUFUNC_INIT_2($_SESSION[CURRENT_MENU],'',RESTORE,'POWROT_I_POPRAWA_DANYCH') ;
 }

echo "<hr>";

 $MENU_INIT=MENU ;

}

?>