
### LEADER

## LDR 05 - n - new
marc_leader('05','n');

## LDR 06 - a - language material 
marc_leader('06','a');

## LDR 07 - Bibliographic level 
marc_leader('07','s');

## LDR 17 - Encoding level ; 7 - minimal level, u - unknown
marc_leader('17','u');

## LDR 18 - i - isbd 
marc_leader('18','i');

### 008 - All materials
marc_fixed('008','00', '090512');	# 00-05 - Date entered on file

## za 008 06 treba i lookup u tablicu u kojoj postoji podatak o tome jel tekuci casopis ili nije?
## c - Continuing resource currently published
## d - Continuing resource ceased publication

marc_fixed('008','06','|');		# 06 - Type of date/Publication status, s = single know date, | = no attempt to code
marc_fixed('008','07','||||');
marc_fixed('008','11','||||');
marc_fixed('008','15','xx ');
					# 18-34 - Material specific coded elements 
					# 35-37 - Language
marc_fixed('008','38','|');		# 38 - Modified record
marc_fixed('008','39','d');		# 39 - Cataloging source

### 008 - Continuing resources

marc_fixed('008','18', '|');	# 18 - Frequency - ovo treba popuniti iz polja 326
marc_fixed('008','19', '|');	# 19 - Regularity
				# 20 - Undefined, ontains a blank (#) or fill character (|)

marc_fixed('008','21', 'p');	# 21 - Type of continuing resource

				# 22 - Form of original item - blank
				# 23 - Form of item
				# 24 - Nature of entire work
				# 25-27 - Nature of contents
				# 28 - Government publication
				# 29 - Conference publication
				# 30-32 - Undefined
				# 33 - Original alphabet or script of title
				# 34 - Entry convention
marc_fixed('008','22', ' ');
marc_fixed('008','23', ' ');
marc_fixed('008','24', '|');
marc_fixed('008','25', '|||');
marc_fixed('008','28', ' ');
marc_fixed('008','29', ' ');
marc_fixed('008','33', '|');
marc_fixed('008','34', '|');

### 022

marc('022','a',
	rec('F')
);

### 035$a

if ( rec('B') ) {
	marc('035','a',
		join_with(' ',
			'HR-ZaFF',
			join_with('',
				suffix('P',
					lc( rec('A') )
				),
				rec('B')
			),
		)
	);
}

### 040
# za sve je isti
# treba utvrditi točnu oznaku za ustanovu

marc('040','a',
	'HR FFZG'
);

marc('040','b',
	'hrv'
);

marc('040','c',
	'HR-ZaFF'
);

marc('040','e',
	'ppiak'
);


#_debug(3);

## iz nsk
#if ( rec('11') ) {
#marc('210','a',
#	lookup(
#	 	sub { rec('531','a') },
# 		'nsk','bbaza',
# 		sub { rec('011','a') },
# 		sub { rec('11') },
# 	) 
#);
#}

# ### 222 indikatori
# # drugi indikator prema članu
# 
# marc_indicators('222',' ','0');
# 
# ### 222 - Key title
# # pronaći prikadan izvor podataka - nsk baza, issn baze
# 
# marc('222','a',
# 	rec('530')
# );
# 
# # iz nsk:
# #if ( rec('11') ) {
# #marc('222','a',
# #	lookup(
# #	 	sub { rec('530','a') },
# # 		'nsk','bbaza',
# # 		sub { rec('011','a') },
# # 		sub { rec('11') },
# # 	) 
# #);
# #}

### 245 indikatori
# generiraju se prema članu, trebalo bi možda i prema jeziku (jezika nema uvijek). 
# potrebna naknadna kontrola

marc_indicators('245', 0, 0);

if ( 	( rec('E') =~ m/^Die /) || 
	( rec('E') =~ m/^Das /) || 
	( rec('E') =~ m/^Der /) || 
	( rec('E') =~ m/^Les /) || 
	( rec('E') =~ m/^The /) ) {
		marc_indicators('245', 0, 4);

} 

if (	( rec('E') =~ m/^Un /) || 
	( rec('E') =~ m/^An /) ||
	( rec('E') =~ m/^La /) ||
	( rec('E') =~ m/^Le /) ||
	( rec('E') =~ m/^Il /) ) {
		marc_indicators('245', 0, 3);
} 

if (	( rec('E') =~ m/^A /) || 
	( rec('E') =~ m/^L'/) ) {
		marc_indicators('245', 0, 2);
} 

### 245

if ( rec('E') =~ m/:/ ) {
	marc('245','a',
		suffix(' :',
			regex('s/(^.*):.*/$1/',
				rec('E')
			)
		)
	);
	marc('245','b',
		regex('s/^.*: (.*)/$1/',
			rec('E')
		)
	);
} else {
	marc('245','a',
		rec('E')
	);
}

if ( rec('E') =~ m# / #  && rec('E') =~ m/[:=]/ ) {
	marc('299','a',
		regex('s/(^.*?[:=]) (.*\/) (.*)/$1/',
			rec('E')
		)
	);
	marc('299','b',
		regex('s/(^.*?[:=]) (.*\/) (.*)/$2/',
			rec('E')
		)
	);
	marc('299','c',
		regex('s/(^.*?[:=]) (.*\/) (.*)/$3/',
			rec('E')
		)
	);
		
} elsif ( rec('E') =~ m/ \/ /  && rec('E') !~ m/[:=]/ ) {
	marc('299','a',
		regex('s/(^.*?\/) (.*)/$1/',
			rec('E')
		)
	);
	marc('299','c',
		regex('s/(^.*?\/) (.*)/$2/',
			rec('E')
		)
	);
} elsif ( rec('E') !~ m/ \/ / && rec('E') =~ m/[:=]/ ) {
	marc('299','a',
		regex('s/(^.*?[:=]) (.*)/$1/',
			rec('E')
		)
	);
	marc('299','b',
		regex('s/(^.*?[:=]) (.*)/$2/',
			rec('E')
		)
	);

} else {	
	marc('299','a',
		rec('E')
	);
}

# ### 246 inikatori
# # prema jeziku - provjera
# 
# if ( 	( rec('200','a') =~ m/^Die /) || 
# 	( rec('200','a') =~ m/^Das /) || 
# 	( rec('200','a') =~ m/^The /) ) {
# 		marc_indicators('246', 0, 4);
# } else {
# 	marc_indicators('246', 0, 0);
# }
# 
# ### 246
# # povući podatke iz prikladnog izvora (nsk, issn)
# 
# marc('246','a',
# 	rec('532')
# );
# 
# ## iz nsk:
# #	marc('246','a',
# #		lookup(
# #			sub { rec('532','a') },
# #			'nsk','bbaza',
# #			sub { rec('011','a') },
# #			sub { rec('11') },
# #		)
# #	);
# 
# #_debug(0);
# 
# 
# ## 260 - izdavanje
# # provjeriti interpunkcije !!, u NSK nesto ne stima
# 
# marc_original_order('260','210');
# 
# ## lookup u NSK:
# # if ( rec('11') ) {
# # 	marc_repeatable_subfield('260','a',
# # 		lookup(
# # 			sub { rec('210','a') },
# # 			'nsk','bbaza',
# # 			sub { rec('011','a') },
# # 			sub { rec('11') },
# # 		) 
# # 	);
# # 	marc_repeatable_subfield('260','b',
# # 		lookup(
# # 			sub { rec('210','c') },
# # 			'nsk','bbaza',
# # 			sub { rec('011','a') },
# # 			sub { rec('11') },
# # 		) 
# # 	);
# # 	marc('260','c',
# # 		lookup(
# # 			sub { rec('210','d') },
# # 			'nsk','bbaza',
# # 			sub { rec('011','a') },
# # 			sub { rec('11') },
# # 		) 
# # 	);
# # } else {
# # 	marc_original_order('260', '210');
# # }
# 
# 
# ### 300
# 
# marc('300','a',
# 	suffix(
# 		( rec('215','a') && rec('215','c') )	?  ' : ' :
# 		( rec('215','a') && rec('215','d') )	?  ' ; ' :
# 		( rec('215','a') && rec('215','e') )    ?  ' + ' :
# 				   ' ',
# 			rec('215','a')
# 	)
# );
# 
# marc('300','b',
# 	suffix(
# 		( rec('215','c') && rec('215','d') )	?  ' ; ' :
# 		( rec('215','c') && rec('215','e') )   	?  ' + ' :
# 				 		       	   ' ',
# 			rec('215','c')
# 	)
# );
# 
# marc('300','c',
# 	suffix(
# 		rec('215','e') ? ' + ' :
# 				 ' ',
# 			rec('215','d')
# 	)
# );
# 
# marc('300','e',
# 	rec('215','e')
# );
# 
# ### 310 - current stated publication frequency
# # potrebno ujednačiti, koristi se i u polju 008
# 
# marc('310','a',
# 	rec('326')
# );
# 
# ### 321 - former frequency of either an item or an update to an item when a current frequency is contained in field 310
# 
# # marc('321','a',
# # 	ovo bi trebalo procitati iz NSK konvertiranih podataka
# #);
# 
# marc_indicators('362', 0, ' ');
# 
# ### 362
# #
# if ( rec('207','a') ) {
# 	marc('362','a',
# 		rec('207','a'),
# 	);
# } 
# 
# ## lookup iz nsk
# #else {
# #	if ( rec('11') ) {
# #		marc('362','a',
# #			lookup(
# #				sub { rec('207','a') },
# #				'nsk','bbaza',
# #				sub { first( rec('011','a') ) },
# #				sub { rec('11') },
# #			) 
# #		);
# #	}
# #}
# 
# ### 490 ind.
# 
# marc_indicators('490', '0', ' ');
# 
# ### 490
# 
# marc('490','a',
# 	join_with('. ',
# 		join_with(' / ',
# 			join_with(' : ',
# 				join_with(' = ',
# 					rec('225','a'),
# 					rec('225','d')
# 				),
# 				rec('225','e')
# 			),
# 			join_with(' ; ',
# 				rec('225','f'),
# 				rec('225','g')
# 			),
# 		),
# 		rec('225','h')
# 	)
# );
# 
# marc('490','v',
# 	rec('225','v')
# );
# 
# marc('490','x',
# 	rec('225','x')
# );
# 
# if ( rec('11') ) {
# 	marc('999','a',
# 		lookup(
# 			sub { rec('110','a'), },
# 			'nsk','bbaza',
# 			sub { rec('011','a') }, 
# 			sub { rec('11') } 
# 		)
# 	);
# }
# 
# 
# #marc('998','a',
# #	lookup(
# #		sub { rec('H') },
# #		'ffsf','xls',
# #		sub { rec('A') },
# #		sub { $id },
# #	),
# #);


### 500
# lookup
# 
# 
# marc('500','a',
# 	rec(''),
# );
#  
# 
# ### 534 - napomena o pretisku
# 
# marc('534','a',
# 	rec('324')
# );
# 
# ## potencijalno za izvući iz NSK
# #if ( rec('11') ) {
# #marc('546','a',
# #	lookup(
# # 		sub { rec('302','a') },
# # 		'nsk','bbaza',
# # 		sub { rec('011','a') },
# # 		sub { rec('11') },
# # 	) 
# #);
# #
# #marc('550','a',
# #	lookup(
# #	 	sub { rec('314','a') },
# # 		'nsk','bbaza',
# # 		sub { rec('011','a') },
# # 		sub { rec('11') },
# # 	) 
# #);
# #
# #marc('555','a',
# #	lookup(
# #	 	sub { rec('320','a') },
# # 		'nsk','bbaza',
# # 		sub { rec('011','a') },
# # 		sub { rec('11') },
# # 	) 
# #);
# #
# #
# ## marc('562','a',
# ##	lookup(
# ##	 	sub { rec('316','a') },
# ##		'nsk','bbaza',
# ## 		sub { rec('011','a') },
# ## 		sub { rec('11') },
# ## 	) 
# ## );
# #}


if ( rec('B') ) {
	marc('996','a',
		lc( rec('A') )
	);

	marc('996','b',
		'peri'
	);

	marc('996','c',
		rec('B')
	);
}

# 
# ### 653 indikatori
# marc_indicators('653', 0, ' ');
# 
# ### 653
# 
# marc('653','a',
# 	rec('610')
# );
# 
# # marc_indicators('655', ' ', 4);
# # marc('655','a',
# #	lookup(
# #	 	sub { rec('608','a') },
# #		'nsk','bbaza',
# # 		sub { rec('011','a') },
# # 		sub { rec('11') },
# # 	) 
# # );
# 
# 
# #_debug(2);
# 
# ### 700 indikatori
# 
# marc_indicators('700', 1, ' ');
# 
# ### 700
# 
# marc('700','a',
# 	rec('702','a'),
# );
# 
# marc('700','a',
# 	join_with(', ',
# 		rec('702','c'),
# 		rec('702','d')
# 	)
# );
# 
#  
# #_debug(0);
# 
# ### 710 indikatori
# 
# marc_indicators('710', '2', ' ');
# 
# ### 710
# marc('710','a',
# 	rec('710','a')
# );
# 
# ### 770 indikatori
# 
# marc_indicators('770', 0, ' ');
# 
# ### 770
# marc('770','t',
# 	rec('421','a'),
# );
# 
# ### 772 indikatori
# marc_indicators('772', 0, ' ');
# 
# ### 772
# marc('772','t',
# 	rec('422','a'),
# );
# 
# ### 773 indikatori
# 
# if ( rec('225','a') ) {
# 
# marc_indicators('773', 0, ' ');
# 
# ### 773
# ## da li je bitan redoslijed potpolja?
# 
# marc('773','w',
# 	lookup(
# 		sub { rec('000') },
# 		'ffsf','peri',
# 		sub { rec('200','a') },
# 		sub { 
# 			regex('s/ ; //g',
# 				rec('225','a')
# 			)
# 		},
# 	)
# );
# 
# }
# 
# 
# ### 777 indikatori
# 
# marc_indicators('777', 0, ' ');
# 
# ### 777
# 
# marc('777','t',
# 	rec('423','a'),
# );
# 
# ### 780 indikatori
# 
# marc_indicators('780', 0, 0);
# 
# ### 780
# marc('780','t',
# 	rec('430','a'),
# );
# 
# ### 785 indikatori
# 
# marc_indicators('785', 0, 0);
# 
# ### 785
# marc('785','t',
# 	rec('440','a'),
# );
# 
# ### 852
# 
# marc('852','j',
# 	join_with(' ',
# 		rec('990')
# 	)
# );
# 
# ### 876
# 
# marc('876','a',
# 	rec('991','a')
# );

marc('942','d',
	rec('C')
);



# 
# ### 992
# 
# marc('992','a',
# 	join_with(' ; ', 
# 		rec('992')
# 	)
# );
# 
# 
### polja za probu


#marc('998','a',
#	lookup(
#		sub { rec('200','a') },
#		'ffiz','peri',
#		sub { rec('200','a'), },
#		sub { rec('225','a'), }
#	)
#);

 
# marc('997','a',
# 	sort(
#  		lookup(
#  			sub { rec('001') },
#  			'nsk','bbaza',
#  			sub { rec('011','a') },
#  			sub { rec('11') },
#  		)
#  	)
# );
# 
# marc('998','a',
# 	sort(
#  		lookup(
#  			sub { rec('001') },
#  			'nsk','bbaza',
#  			sub { first(rec('200','a')) . first(rec('200','e')) },
#  			sub { rec('200','a') . rec('200','e') },
#  		)
#  	)
# );
# 
# marc('998','a',
# 	sort(
#  		lookup(
#  			sub { rec('001') },
#  			'nsk','bbaza',
#  			sub { first(rec('200','a')) },
#  			sub { rec('200','a') },
#  		)
#  	)
# );

