diff --git a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml
index 019ab596a1..6b332cfd4e 100644
--- a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml
+++ b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml
@@ -3592,8 +3592,7 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 -->
{$start_id = 23000}
-{foreach $keys as $row}
-{if $row.device_key_category == "expansion"}
+{foreach $keys["expansion"] as $row}
{$key_id = $row.device_key_id - 1}
{$type_id = $start_id + ($key_id * 5)}
{$line_id = ($start_id + 1) + ($key_id * 5)}
@@ -3615,7 +3614,6 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 -->
{$row.device_key_line}
{$row.device_key_label}
{$row.device_key_value}
-{/if}
{/foreach}
diff --git a/resources/templates/provision/mitel/5324/MN_{$mac}.cfg b/resources/templates/provision/mitel/5324/MN_{$mac}.cfg
index 5166f30fbf..170dfa1acd 100644
--- a/resources/templates/provision/mitel/5324/MN_{$mac}.cfg
+++ b/resources/templates/provision/mitel/5324/MN_{$mac}.cfg
@@ -267,7 +267,7 @@
0
0
-{foreach $keys as $row}
+{foreach $keys["line"] as $row}
{if $row.device_key_line == "1"}{$feature = "6"}{$user_id = $user_id_1}{/if}
{if $row.device_key_line == "2"}{$feature = "7"}{$user_id = $user_id_2}{/if}
{if $row.device_key_line == "3"}{$feature = "8"}{$user_id = $user_id_3}{/if}
diff --git a/resources/templates/provision/mitel/5330/MN_{$mac}.cfg b/resources/templates/provision/mitel/5330/MN_{$mac}.cfg
index 7e52978c0d..8eeefce6ea 100644
--- a/resources/templates/provision/mitel/5330/MN_{$mac}.cfg
+++ b/resources/templates/provision/mitel/5330/MN_{$mac}.cfg
@@ -267,7 +267,7 @@
0
0
-{foreach $keys as $row}
+{foreach $keys["line"] as $row}
{if $row.device_key_line == "1"}{$feature = "6"}{$user_id = $user_id_1}{/if}
{if $row.device_key_line == "2"}{$feature = "7"}{$user_id = $user_id_2}{/if}
{if $row.device_key_line == "3"}{$feature = "8"}{$user_id = $user_id_3}{/if}
diff --git a/resources/templates/provision/mitel/5340/MN_{$mac}.cfg b/resources/templates/provision/mitel/5340/MN_{$mac}.cfg
index 5166f30fbf..170dfa1acd 100644
--- a/resources/templates/provision/mitel/5340/MN_{$mac}.cfg
+++ b/resources/templates/provision/mitel/5340/MN_{$mac}.cfg
@@ -267,7 +267,7 @@
0
0
-{foreach $keys as $row}
+{foreach $keys["line"] as $row}
{if $row.device_key_line == "1"}{$feature = "6"}{$user_id = $user_id_1}{/if}
{if $row.device_key_line == "2"}{$feature = "7"}{$user_id = $user_id_2}{/if}
{if $row.device_key_line == "3"}{$feature = "8"}{$user_id = $user_id_3}{/if}
diff --git a/resources/templates/provision/snom/3xx/{$mac}.xml b/resources/templates/provision/snom/3xx/{$mac}.xml
index 4bf3c626b6..0e22bce81a 100644
--- a/resources/templates/provision/snom/3xx/{$mac}.xml
+++ b/resources/templates/provision/snom/3xx/{$mac}.xml
@@ -85,19 +85,19 @@
g722,pcmu,pcma,gsm,g726-32,aal2-g726-32,g723,g729,telephone-event
-{foreach $keys as $row}
+{foreach $keys["line"] as $row}
{if $row.device_key_line == ""}
- {if $row.device_key_category == "line"}
- {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
- {else}
- line
- {/if}
+ {if $row.device_key_type == "line"}
+ line
+ {else}
+ {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
+ {/if}
{else}
- {if $row.device_key_category == "line"}
- {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
- {else}
- line
- {/if}
+ {if $row.device_key_type == "line"}
+ line
+ {else}
+ {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
+ {/if}
{/if}
{/foreach}
diff --git a/resources/templates/provision/snom/7xx/{$mac}.xml b/resources/templates/provision/snom/7xx/{$mac}.xml
index 41b64a3b7f..e30fd75bed 100644
--- a/resources/templates/provision/snom/7xx/{$mac}.xml
+++ b/resources/templates/provision/snom/7xx/{$mac}.xml
@@ -90,19 +90,9 @@
g722,pcmu,pcma,gsm,g726-32,aal2-g726-32,g723,g729,telephone-event
-{foreach $keys as $row}
+{foreach $keys["line"] as $row}
{if $row.device_key_line == ""}
- {if $row.device_key_category == "line"}
{$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
- {else}
- line
- {/if}
-{else}
- {if $row.device_key_category == "line"}
- {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
- {else}
- line
- {/if}
{/if}
{/foreach}
diff --git a/resources/templates/provision/snom/8xx/{$mac}.xml b/resources/templates/provision/snom/8xx/{$mac}.xml
index 4bf3c626b6..0e22bce81a 100644
--- a/resources/templates/provision/snom/8xx/{$mac}.xml
+++ b/resources/templates/provision/snom/8xx/{$mac}.xml
@@ -85,19 +85,19 @@
g722,pcmu,pcma,gsm,g726-32,aal2-g726-32,g723,g729,telephone-event
-{foreach $keys as $row}
+{foreach $keys["line"] as $row}
{if $row.device_key_line == ""}
- {if $row.device_key_category == "line"}
- {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
- {else}
- line
- {/if}
+ {if $row.device_key_type == "line"}
+ line
+ {else}
+ {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
+ {/if}
{else}
- {if $row.device_key_category == "line"}
- {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
- {else}
- line
- {/if}
+ {if $row.device_key_type == "line"}
+ line
+ {else}
+ {$row.device_key_type} {$row.device_key_value} {$row.device_key_extension}
+ {/if}
{/if}
{/foreach}