<?php

function IN7_MK_BAZA_DYSTRYBUCJI_EDIT() {
global $result,$thiss,$ARG1_VAL,$ARG1;
$EDITRECORD=$ARG1_VAL;
  if(($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['ID'])&&($ARG1!='EDIT'))    $EDITRECORD=$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['ID'] ;

  ZAP_SQL("select M_DIST_TYPE from IN7_MK_BAZA_DYSTRYBUCJI where ID='".$EDITRECORD."'");
   while ($res=mysql_fetch_array($result)) {
//      print_r($res);
	//Teraz sprawdzamy czy jest to projekt ktory zawiera __ znaki w typie, jezeli tak , to permujemy wszystkie kolumny regexem ktore maja taka kolumne (i perm W)...
        // a potem je znowu wylaczamy ich permy (READ)
   if((strstr($res['M_DIST_TYPE'],'__'))|| (1==1)) {
		echo "Wlaczamy superpermy<br>";
		list($TYP_PROJEKTU_FIND)=split('__',$res['M_DIST_TYPE']);
//		print_r($TYP_PROJEKTU_FIND);
//		echo "<hr>";		
		unset($COLUMNS_TO_UNHIDE);
		unset($COLUMNS_TO_HIDE);
	foreach($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT'] as $INDEX=>$NAME) {
		if(preg_match('/^'.$TYP_PROJEKTU_FIND."_/",$INDEX)) {
//  		 echo "I $INDEX name $NAME";
		  
		} else{ //tutaj chowamy
	  	   if(strstr($NAME,'H')) { 
			//echo "\n<br>chowamy :".$INDEX ;
		     $COLUMNS_TO_HIDE[$INDEX]=str_replace('R','',$NAME) ;
		     $COLUMNS_TO_UNHIDE[$INDEX]=$NAME;
		   }
		}

 	} //eof foreach

//	print_r($COLUMNS_TO_UNHIDE);

	foreach($COLUMNS_TO_HIDE as $INDEX=>$NAME) {
	       $_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT'][$INDEX]=$NAME ;
        }


   }   
  } //eof    if(strstr($res[M_DIST_TYPE],'__')) {

EDIT_TABLE_RECORD();

	foreach($COLUMNS_TO_UNHIDE as $INDEX=>$NAME) {
	       $_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT'][$INDEX]=$NAME ;
        }


} //eof function IN7_MK_BAZA_DYSTRYBUCJI_EDIT() {

