<?

	global $sess;

	if (($sess->isLoged("Wykl")) || ($sess->isLoged("Oper"))) {
		$changes=0;
		$zaj_id = $sess->get(w_zajecia);
		foreach ($sess->get(W_Pgrupy) as $key => $value){
			if ($_POST[$key]=="on") {
				if ($value[2]!='T') {
					$q=new CQuery("UPDATE
										XP_PROWADZACY_GRUP
									SET operator='T'
									WHERE (gr_nr='$key' and zaj_cyk_id='$zaj_id');");
				}
			} else
				if ($value[2]=='T') {
					$q = new CQuery();
					$q->query("UPDATE
										XP_PROWADZACY_GRUP
									SET operator='N'
									WHERE (gr_nr='$key' and zaj_cyk_id='$zaj_id');");
				}
		}

		$q = new CQuery("SELECT gr_nr, operator
			FROM 	XP_PROWADZACY_GRUP
			WHERE 	(zaj_cyk_id='$zaj_id');");

		if ($q->num_rows()) {
			while ($arr = $q->fetch_array()) {
				$grupa = $sess->getTab(W_Pgrupy, $arr[gr_nr]);
				if ($arr[operator] != $grupa[2]) $changes++;
				$grupa[2]=$arr[operator];
				$sess->setTab(W_Pgrupy, $arr["gr_nr"], $grupa);
			}
		}

		$przedmiot=$sess->get("w_przedmiot_id");
		$sess->set("w_changes", $changes);
	}
?>
