SET NAMES cp1250;
 UPDATE `operdoc` od, 
(SELECT dg.Value AS OWNER FROM `_db_globals` dg WHERE `Key` = 'OWNER') dg
SET
	od.KPR = 
	IF(od.grupa IN (0, 3), 7,	--	ST,SI = 7
	IF(od.grupa IN (1), 10,		--	ZT = 10
	IF(od.grupa IN (4), 		--	ZP ... (14) 
		IF(dg.Owner = 'ASEKURACJA', 41,
		IF(dg.Owner = 'AZO', 10,
		14)),
	od.KPR)))
WHERE
	od.KPR = 0
;
