<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PHONE>
	<REGISTRATION
		{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.display_name}"
		reg.{$row.line_number}.address="{$row.user_id}"
		reg.{$row.line_number}.label="{$row.display_name}"
		reg.{$row.line_number}.type="private"
		reg.{$row.line_number}.auth.userId="{$row.user_id}"
		reg.{$row.line_number}.auth.password="{$row.password}"
		reg.{$row.line_number}.lineKeys="{$line_key_value_{$row.line_number}}"
		{if isset($row.outbound_proxy)}reg.{$row.line_number}.outboundProxy.address = "{$row.outbound_proxy}"{/if}
		{if isset($row.sip_port)}reg.{$row.line_number}.outboundProxy.port="{$row.sip_port}"{else}reg.{$row.line_number}.outboundProxy.port="5060"{/if}

		{if $row.sip_transport == ''}reg.{$row.line_number}.outboundProxy.transport="TCPOnly"{/if}
		{if $row.sip_transport == 'tcp'}reg.{$row.line_number}.outboundProxy.transport="TCPOnly"{/if}
		{if $row.sip_transport == 'udp'}reg.{$row.line_number}.outboundProxy.transport="UDPOnly"{/if}
		{if $row.sip_transport == 'tls'}reg.{$row.line_number}.outboundProxy.transport="TLS" {/if}
		{if $row.sip_transport == 'dns srv'}reg.{$row.line_number}.outboundProxy.transport="DNSnaptr"{/if}

		reg.{$row.line_number}.server.1.address="{$row.server_address}"
		{if isset($row.sip_port)}reg.{$row.line_number}.server.1.port="{$row.sip_port}"{else}reg.{$row.line_number}.server.1.port="5060"{/if}

		{if $row.sip_transport == ''}reg.{$row.line_number}.server.1.transport="TCPOnly"{/if}
		{if $row.sip_transport == 'tcp'}reg.{$row.line_number}.server.1.transport="TCPOnly"{/if}
		{if $row.sip_transport == 'udp'}reg.{$row.line_number}.server.1.transport="UDPOnly"{/if}
		{if $row.sip_transport == 'tls'}reg.{$row.line_number}.server.1.transport="TLS" {/if}
		{if $row.sip_transport == 'dns srv'}reg.{$row.line_number}.server.1.transport="DNSnaptr"{/if}

		{if isset($row.register_expires)}reg.{$row.line_number}.server.1.expires="{$row.register_expires}"{else}reg.{$row.line_number}.server.1.expires="{$row.register_expires}"{/if}

		{/foreach}
	/>
	<DEVICE_SETTINGS
		device.set="1"
		device.sntp.serverName="pool.ntp.org"
		device.sntp.gmtOffset="{$polycom_gmt_offset}"
		{if isset($admin_password)}
		device.auth.localUserPassword.set="1" 
		device.auth.localUserPassword="{$admin_password}"
		{/if}
		{if isset($admin_password)}
		device.auth.localAdminPassword.set="1"
		device.auth.localAdminPassword="{$admin_password}"
		{/if}
		{if isset($dns_server_primary)}device.dns.serverAddress="{$dns_server_primary}"{/if}
		{if isset($dns_server_secondary)}device.dns.altSrvAddress="{$dns_server_secondary}"{/if}
	/>
	<SNTP
		tcpIpApp.sntp.resyncPeriod="86400"
		tcpIpApp.sntp.address="{$ntp_server_primary}"
		tcpIpApp.sntp.gmtOffset.overrideDHCP="0"
		tcpIpApp.sntp.gmtOffset="{$polycom_gmt_offset}"
		tcpIpApp.sntp.daylightSavings.enable="1"
		tcpIpApp.sntp.daylightSavings.fixedDayEnable="0"
		tcpIpApp.sntp.daylightSavings.start.month="{$daylight_savings_start_month}"
		tcpIpApp.sntp.daylightSavings.start.date="{$daylight_savings_start_day}"
		tcpIpApp.sntp.daylightSavings.start.time="{$daylight_savings_start_time}"
		tcpIpApp.sntp.daylightSavings.start.dayOfWeek="1"
		tcpIpApp.sntp.daylightSavings.start.dayOfWeek.lastInMonth="0"
		tcpIpApp.sntp.daylightSavings.stop.month="{$daylight_savings_stop_month}"
		tcpIpApp.sntp.daylightSavings.stop.date="{$daylight_savings_stop_day}"
		tcpIpApp.sntp.daylightSavings.stop.time="{$daylight_savings_stop_time}"
		tcpIpApp.sntp.daylightSavings.stop.dayOfWeek="0"
		tcpIpApp.sntp.daylightSavings.stop.dayOfWeek.lastInMonth="0"
	/>
	<DIALPLAN
		{if isset($polycom_digitmap)}dialplan.digitmap="{$polycom_digitmap}"{else}dialplan.digitmap=""{/if}
	/>
	<DEVICE_KEYS
		attendant.uri=""
		{if isset($polycom_remotecallerid_automata)}
			attendant.behaviors.display.remoteCallerID.automata="{$polycom_remotecallerid_automata}"
		{else}
			attendant.behaviors.display.remoteCallerID.automata="0"
		{/if}
		{if isset($polycom_remotecallerid_normal)}
			attendant.behaviors.display.remoteCallerID.normal="{$polycom_remotecallerid_normal}"
		{else}
			attendant.behaviors.display.remoteCallerID.normal="0"
		{/if}
		{if isset($polycom_spontaneouscallappearances_automata)}
			attendant.behaviors.display.spontaneousCallAppearances.automata="{$polycom_spontaneouscallappearances_automata}"
		{else}
			attendant.behaviors.display.spontaneousCallAppearances.automata="0"
		{/if}
		{if isset($polycom_spontaneouscallappearances_normal)}
			attendant.behaviors.display.spontaneousCallAppearances.normal="{$polycom_spontaneouscallappearances_normal}"
		{else}
			attendant.behaviors.display.spontaneousCallAppearances.normal="0"
		{/if}
		feature.enhancedFeatureKeys.enabled="1"
		{foreach $keys["line"] as $row}
			{if $row.device_key_type == "automata" || $row.device_key_type == "normal"}
				attendant.resourceList.{$row.device_key_id}.address="{$row.device_key_value}"
				attendant.resourceList.{$row.device_key_id}.callAddress=""
				attendant.resourceList.{$row.device_key_id}.label="{$row.device_key_label}"
				attendant.resourceList.{$row.device_key_id}.proceedingIsRecipient="0"
				attendant.resourceList.{$row.device_key_id}.type="{$row.device_key_type}"
			{else}
				{if $row.device_key_type != "line"}
					{if $row.device_key_type == "URL"}
						key.{$row.device_key_id}.function.prim="{$row.device_key_value}"
					{else}
						key.{$row.device_key_id}.function.prim="{$row.device_key_type}"
						key.{$row.device_key_id}.subPoint.prim="{$row.device_key_value}"
					{/if}
				{/if}
			{/if}
		{/foreach}
	/>
	<MULTICAST_PAGING
		ptt.pageMode.enable="1"
		ptt.pageMode.displayName="INTERCOM"
	/>
	<REMOTE_PACKET_CAPTURE
		diags.pcap.enabled="0"
		diags.pcap.remote.enabled="0"
	/>
	<GENERAL
		nat.keepalive.interval="30"
		voIpProt.SIP.specialEvent.checkSync.alwaysReboot="1"
		voIpProt.SIP.requestValidation.1.request="INVITE" 
		voIpProt.SIP.requestValidation.1.method="source"
		feature.broadsoftUcOne.enabled="0"
		voice.volume.persist.handset="1"
		voice.volume.persist.handsfree="1"
		feature.nonVolatileRingerVolume.enabled="1"
		{if $headset_mode != ''}up.handsfreeMode="1"
		up.headsetMode="{$headset_mode}"{/if}
		{if $analog_headset_option != ''}up.analogHeadsetOption="{$analog_headset_option}"{/if}
		{if isset($polycom_onetouchvoicemail)}
			up.oneTouchVoiceMail="{$polycom_onetouchvoicemail}"
			{else}
			up.oneTouchVoiceMail="0"
		{/if}

	/>
	<SOFT_KEYS
		softkey.1.label="VMTransfer"
		softkey.1.action="^*99$P1N4$$Trefer$"
		softkey.1.enable="1"
		softkey.1.use.active="1"
		efk.efkprompt.1.label="Voice Mail ID to transfer to:"
		efk.efkprompt.1.status="1"
		efk.efkprompt.1.type="numeric"
	/>
</PHONE>
