
<?php 	if( $this->selectedSIPAccount !== null ) : ?>
<?php foreach($this->allProviderAccounts as $k1 => $mobile1 ) :

	if( $mobile1['SIP'] != 1 && $mobile1['SMS'] != "1" && $mobile1['Voicemail'] != "1" )
		continue;

		//dont process group again if already rendered
	if( array_key_exists('alreadyRendered',$this->allProviderAccounts[$k1]) && $this->allProviderAccounts[$k1]['alreadyRendered'] == true )
		continue;

	$groupNumber = $mobile1['PhoneNumber'];

?>

	<li style="display: none;">
		<div class="phone" isselectable="false" style="display: none;" nodrop="true">
			<a class="phone">
				<span class="label" id="MyMobile">Calls <b class="number"><?php echo $mobile1['PhoneNumber'] ?></b></span>
				<span class="unread" style="display: none;"><strong>0</strong></span>
				<script>
				$(function() {
				$("DIV.YesID").text("<?php echo preg_replace('/@.*/', '', $this->account) ?>");
				$("DIV.YesNumber").text("<?php echo str_replace('+6', '', $mobile1['PhoneNumber']) ?>");
				});
				</script>
			</a>
		</div>

	<!--	<ul style="display: block;"> -->
<?php
	//now render in groups of matching number
		foreach($this->allProviderAccounts as $k => $mobile) :
            if( $mobile['PhoneNumber'] != $groupNumber )
				continue;
			//dont render again if already rendered
			if( array_key_exists('alreadyRendered',$this->allProviderAccounts[$k]) && $this->allProviderAccounts[$k]['alreadyRendered'] == true )
				continue;
			$this->allProviderAccounts[$k]['alreadyRendered'] = true;

			$pid = $mobile['id'];
			$myId = $mobile['UserId'];
			$myDisplayName = $mobile['DisplayName'];
			$folders = array();
			if( $mobile["SMS"] == "1"  )
				$folders["SMS"] = "SMS";
			if( $mobile['Voicemail'] == "1" )
				$folders["Voicemail"] = "Voicemail";
			if( $mobile["SIP"] == "1" )
			{

				$folders["CDR"] = "Calls";
				$folders["SMS"] = "SMS";

			}
?>

<?php 			foreach( $this->SIPFolders as $folderName => $folderHuman ) : ?>
<?php 				if( $mobile['SIP'] == "1") : ?>
			<li class="serviceFolderGroup" pid="<?php echo $pid ?>">
				<div isSelectable="true" isMainFolder="true" nodrop="true">
					<a class="jsServiceProvider" href="<?php echo $this->appBaseUrl ?>/api/unify/ucdbget" pid="<?php echo $pid ?>" myid="<?php echo $myId ?>" mydisplayname="<?php echo $myDisplayName ?>" folder="<?php echo $folderName ?>" servicetype="SIP" servicename="<?php echo $mobile['Provider'] ?>">
						<span class="label <?php echo $folderName ?>"><?php echo $folderHuman ?></span>
						<span class="unread <?php echo "unread-" . $folderName ?>" style="display:none;"><strong>0</strong></span>
					</a>
				</div>
			</li>
<?php 				else : ?>
			<li class="serviceFolderGroup" pid="<?php echo $pid ?>">
				<div isSelectable="true" isMainFolder="true" nodrop="true">
					<a class="jsServiceProvider" href="<?php echo $this->appBaseUrl ?>/api/unify/ucdbget" pid="<?php echo $pid ?>" myid="<?php echo $myId ?>" mydisplayname="<?php echo $myDisplayName ?>" folder="<?php echo $folderName ?>" servicetype="SIP" servicename="<?php echo $mobile['Provider'] ?>">
						<span class="label <?php echo $folderName ?>"><?php echo $folderHuman ?></span>
						<span class="unread" id="unread-calls" style="display:none;"><strong>0</strong></span>
					</a>
				</div>
			</li>
<?php 				endif ?>
<?php 			endforeach ?>
<?php 		endforeach ?>

	</li>
<?php 	endforeach ?>
<?php 	endif //if( $this->selectedSIPAccount !== null ) ?>
