<?php 
/**
 * Ahead WebSoft Technologies Pvt Ltd.
 * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
 * @license    https://www.socialengine.com/policies
*/
?>	
<?php
$viewer_id = $this->viewer->getIdentity();
if(!empty($viewer_id)){
	$levels = Engine_Api::_()->getApi('settings', 'core')->getSetting('invite.allowlevels', 'a:4:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"3";i:3;s:1:"4";}');
	$levelsvalue = unserialize($levels);
}

?>
<div class="pulse_mobile_menu_content_header">
	<h2><?php echo $this->translate("Dashboard")?></h2>
	<?php if(empty($viewer_id)){ ?>
		<a href="javascript:void(0)" id="header_mobile_profile_menu_close"><i class="icon_cross"></i></a>
	<?php } ?>
</div>

<div class="pulse_mobile_menu_profile pulse_mobile_menu_content_inner pt-0">
	<?php if(engine_in_array('miniMenu',$this->options)) { ?>
		<?php if(empty($viewer_id)){ ?>
			<div class="pulse_mobile_menu_btns mb-3 d-flex gap-3">
				<div class="flex-fill">
					<a href="<?php echo $this->url(array(), 'user_login', true); ?>" class="w-100 btn _login"><span><?php echo $this->translate("Sign In")?></span></a>
				</div>
				<div class="flex-fill">
					<a href="<?php echo $this->url(array(), 'user_signup', true); ?>" class="w-100 btn _signup d-flex"><span><?php echo $this->translate("Sign Up")?></span></a>
				</div>
			</div>
		<?php } ?>

		<?php if(!empty($viewer_id)){ ?>
			<div class="pulse_mobile_menu_profile_user_section d-flex align-items-center gap-3">
				<div class="pulse_mobile_menu_profile_user_thumb">
					<a href="<?php echo $this->viewer->getHref(); ?>">
						<?php echo Zend_Registry::get('Zend_View')->itemBackgroundPhoto($this->viewer, 'thumb.icon'); ?></i>
					</a>
				</div>
				<div class="pulse_mobile_menu_profile_user_info flex-fill">
					<p class="_name font_bold mb-1">
						<a href="<?php echo $this->viewer->getHref(); ?>"><?php echo $this->viewer->getTitle(); ?></a>
					</p>
					<p class="_edit font_small m-0"><a href="<?php echo $this->url(array('controller' => 'edit', 'action' => 'profile', 'id' => $viewer_id), 'user_extended', true); ?>" class="d-inline-flex gap-2 font_color"><i class="icon_edit"></i><span><?php echo $this->translate("Edit Profile")?></span></a></p>
				</div>
				
				<?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('core.general.recent.login', 1) && isset($_COOKIE['user_login_users'])){ ?>
					<div data-class="notifications_donotclose" class="pulse_mobile_menu_profile_user_switcher core_minimenu_switchuser core_minimenu_icon switch_user_pulldown " id="switch_user_pulldown"> 
						<a id="switch_account" class="btn-icon btn btn-alt" data-class="notifications_donotclose" href="javascript:void(0);" onclick="showRecentloginPopup('mobile_core_switch_user');" title="<?php echo $this->translate("Switch Account"); ?>">
							<i data-class="notifications_donotclose" id="switch_account_i" class="m-0 center_item fi fi-rr-angle-down"></i>
						</a>
						<div id="mobile_core_switch_user" class="core_switch_account_pulldown" style="display:none;">
							<div class="core_switch_account_pulldown_header">
								<p class="_heading"><?php echo $this->translate("Switch Account"); ?></p>
								<p class="font_small"><?php echo $this->translate("You can switch your accounts from below or log into another account."); ?></p>
							</div>
							<div class="core_switch_account_list">
								<?php $recent_login = Zend_Json::decode($_COOKIE['user_login_users']); ?>
								<?php if(engine_count($recent_login) > 0){ ?>
									<?php foreach($recent_login as $users){ ?>
										<?php $userArray = explode("_", $users);
											$user = Engine_Api::_()->getItem('user', $userArray[0]); ?>
										<?php if($viewer_id == $user->getIdentity()){ continue; ?><?php } ?>
										<?php if($user && isset($user->user_id)){ ?>
											<div id="core_recent_login_<?php echo $user->getIdentity(); ?>" class="core_switch_account_list_item d-flex  align-items-center"> 
												<a <?php if($viewer_id == $user->getIdentity()){ ?> class="recent_login_disable" <?php } else{ ?> onclick="loginAsUser('<?php echo $user->user_id ?>','<?php echo $userArray[1] ?>', 0);"  <?php } ?> href="javascript:;" >
													<div class="members_tab_item d-flex align-items-center">
														<div class="_img"> <?php echo $this->itemBackgroundPhoto($user, 'thumb.icon'); ?> </div>
														<div class="_cont">
															<span class="_name"><?php echo $user->getTitle(); ?></span>
															<?php $notificationCount = Engine_Api::_()->getDbtable('notifications', 'activity')->hasNotifications($user); ?>
															<?php if($notificationCount > 0){ ?>
																<span class="_notification font_small font_color_light"><?php echo $this->translate(array('%s notification', '%s notifications', $notificationCount),$notificationCount); ?></span>
															<?php } ?>
														</div>
													</div>
												</a>
												<?php if($viewer_id != $user->getIdentity()){ ?>
													<a href="javascript:void(0);" onclick="removeRecentUser('<?php echo $user->getIdentity(); ?>', 'recent_login_remove');" class="close-btn"  data-bs-toggle="modal" data-bs-target="#recent_login_remove"><i class="fa fa-times"></i></a>
												<?php } ?>
											</div>
										<?php } ?>
									<?php } ?>
								<?php } ?>
								<div class="sep"><span></span></div>
								<div class="core_switch_account_list_item login_other mt-0"> 
									<a href="<?php echo $this->baseUrl()."/user/auth/poplogin?user_id=newuseradd&type=".true;  ?>" >
										<div class="members_tab_item d-flex align-items-center">
											<div class="_img d-flex align-items-center justify-content-center"><i class="fa fa-plus"></i></div>
											<div class="_cont"> <span class="_name add_user"><?php echo $this->translate("Log into another account"); ?></span> </div>
										</div>
									</a> 
								</div>
							</div>
						</div>
					</div>
				<?php } ?>
			</div>
		<?php } ?>

		<div class="pulse_mobile_menu_profile_section mt-3">
			<ul>
				<?php if( !empty($viewer_id)) { ?>
					<?php if(Engine_Api::_()->getDbtable('gateways', 'payment')->getEnabledWalletGateway() && Engine_Api::_()->getDbtable('gateways', 'payment')->getEnabledGatewayCount() > 0) { ?>
						<li class="pulse_mobile_menu_profile_link_item">
							<a href="<?php echo $this->url(array("module" => "payment", "controller" => "settings", "action" => "wallet"), 'default', true); ?>" class=" pulse_mobile_menu_profile_link_item_inner">
								<div class="_icon">
									<img src="application/modules/Pulse/externals/images/menu-icons/wallet.png" alt="<?php echo $this->translate("Wallet"); ?>" alt="" height="30" width="30" />
								</div>
								<div class="_info">
									<p class="_title m-0 font_bold"><?php echo $this->translate("Wallet"); ?></p>
								</div>
								<div class="_right">
									<p class="m-0">
										<span class="font_color"><?php echo Engine_Api::_()->payment()->getCurrencyPrice($this->viewer()->wallet_amount,'','',''); ?></span>
									</p>
								</div>
							</a>
						</li>
					<?php } ?>

					<?php if(Engine_Api::_()->getDbtable('modules', 'core')->isModuleEnabled('sescredit')) { ?>
						<?php $credit = Engine_Api::_()->getDbTable('credits','sescredit')->getTotalCreditValue(array('point_type' => 'total_credit')); ?>
						<li class="pulse_mobile_menu_profile_link_item">
							<a href="<?php echo $this->url(array("action" => "manage"), 'sescredit_general', true); ?>" class="pulse_mobile_menu_profile_link_item_inner">
								<div class="_icon">
									<img src="application/modules/Pulse/externals/images/menu-icons/credits.png" alt="<?php echo $this->translate("Credit Points"); ?>" alt="" height="30" width="30" />
								</div>
								<div class="_info">
									<p class="_title m-0 font_bold"><?php echo $this->translate("Credit Points"); ?></p>
								</div>
								<div class="_right">
									<p class="m-0 d-flex gap-2">
										<i class="_coin"></i>
										<span class="font_color"><?php echo $credit; ?></span>
									</p>
								</div>
							</a>
						</li>
					<?php } ?>

					<?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('savecollection.enabled', 1)) { ?>
						<li class="pulse_mobile_menu_profile_link_item">
							<a href="<?php echo $this->url(array("module" => "core", "controller" => "savecollection", "action" => "index"), 'default', true); ?>" class="pulse_mobile_menu_profile_link_item_inner">
								<div class="_icon">
									<img src="application/modules/Core/externals/images/dashboard/saved.png" alt="<?php echo $this->translate("Credit Points"); ?>" alt="" height="30" width="30" />
								</div>
								<div class="_info">
									<p class="_title m-0 font_bold"><?php echo $this->translate("Saved Items"); ?></p>
								</div>
							</a>
						</li>
					<?php } ?>
					
					<?php if(Engine_Api::_()->getDbtable('gateways', 'payment')->getEnabledGatewayCount() > 0 && Engine_Api::_()->getDbtable('packages', 'payment')->getEnabledAfterSignupPackageCount() > 0 && Engine_Api::_()->getDbtable('subscriptions', 'payment')->memberCurrentSubscription()) { ?>
						<li class="pulse_mobile_menu_profile_link_item">
							<a href="<?php echo $this->url(array("module" => "payment", "controller" => "settings", "action" => "index"), 'default', true); ?>" class="pulse_mobile_menu_profile_link_item_inner">
								<div class="_icon">
									<img src="application/modules/Pulse/externals/images/menu-icons/subscription.png" alt="<?php echo $this->translate("Membership Subscription"); ?>" alt="" height="30" width="30" />
								</div>
								<div class="_info">
									<p class="_title m-0 font_bold"><?php echo $this->translate("Membership Subscription"); ?></p>
								</div>
							</a>
						</li>
					<?php } ?>
				<?php } ?>

				<?php if(engine_count($this->currencies) > 1 || Engine_Api::_()->getApi('settings', 'core')->getSetting('enableglocation', 0) == 1 || 1 !== engine_count($this->languageNameList)) { ?>

					<?php if(engine_count($this->languageNameList) > 1) { ?>
						<?php $language = ''; ?>
						<?php if(!empty($_COOKIE['en4_language'])) { ?>
							<?php $language = strtoupper($_COOKIE['en4_language']); ?>
						<?php } ?>
						<li class="pulse_mobile_menu_profile_link_item">
							<a href="javascript:;" class="pulse_mobile_menu_profile_link_item_inner language_btn show_icons" data-bs-toggle="modal" data-bs-target="#language_modal" >
								<div class="_icon">
									<img src="application/modules/Pulse/externals/images/menu-icons/language.png" alt="<?php echo $this->translate("Language"); ?>" alt="" height="30" width="30" />
								</div>
								<div class="_info">
									<p class="_title m-0 font_bold"><?php echo $this->translate("Language"); ?></p>
								</div>
								<div class="_right">
									<p class="m-0 d-flex gap-2">
										<span class="font_color"><?php echo $language; ?></span>
										<i class="_arrow fi fi-rr-angle-small-right"></i>
									</p>
								</div>
							</a>
						</li>
					<?php } ?>

					<?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('enableglocation', 0) == 1) { ?>
						<li class="pulse_mobile_menu_profile_link_item">
							<?php $location = ''; ?>
							<?php if(!empty($_COOKIE['location_countryshortname']) && $_COOKIE['location_countryshortname'] != 'undefined') { ?>
								<?php $location = strtoupper($_COOKIE['location_countryshortname']); ?>
							<?php } ?>
							<a href="javascript:;" class="pulse_mobile_menu_profile_link_item_inner language_btn show_icons" data-bs-toggle="modal" data-bs-target="#language_modal" >
								<div class="_icon">
									<img src="application/modules/Pulse/externals/images/menu-icons/location.png" alt="<?php echo $this->translate("Location"); ?>" alt="" height="30" width="30" />
								</div>
								<div class="_info">
									<p class="_title m-0 font_bold"><?php echo $this->translate("Location"); ?></p>
								</div>
								<div class="_right">
									<p class="m-0 d-flex gap-2">
										<span class="font_color"><?php echo $location; ?></span>
										<i class="_arrow fi fi-rr-angle-small-right"></i>
									</p>
								</div>
							</a>
						</li>
					<?php } ?>

					<?php if(engine_count($this->currencies) > 1 && Engine_Api::_()->payment()->getCurrentCurrency())  { ?>
						<li class="pulse_mobile_menu_profile_link_item">
							<a href="javascript:;" class="pulse_mobile_menu_profile_link_item_inner language_btn show_icons" data-bs-toggle="modal" data-bs-target="#language_modal" >
								<div class="_icon">
									<img src="application/modules/Pulse/externals/images/menu-icons/currency.png" alt="<?php echo $this->translate("Currency"); ?>" alt="" height="30" width="30" />
								</div>
								<div class="_info">
									<p class="_title m-0 font_bold"><?php echo $this->translate("Currency"); ?></p>
								</div>
								<div class="_right">
									<p class="m-0 d-flex gap-2">
										<span class="font_color"><?php echo Engine_Api::_()->payment()->getCurrentCurrency(); ?></span>
										<i class="_arrow fi fi-rr-angle-small-right"></i>
									</p>
								</div>
							</a>
						</li>
					<?php } ?>
				<?php } ?>
			</ul>
		</div>
	<?php } ?>
	<?php if(engine_in_array('mainMenu',$this->options)) { ?>
		<div class="pulse_mobile_menu_profile_section  mt-3">
			<div class="_head"><?php echo $this->translate("APPS")?></div>
			<ul>
				<?php $index = 0; ?>
				<?php foreach( $this->navigation as $link ): ?>
					<?php 
						$explodedString = explode(' ', $link->class);
						$menuName = end($explodedString); 
						$moduleName = str_replace('core_main_', '', $menuName);
						if(strpos($moduleName, 'custom_') !== 0){
							$moduleName = $moduleName.'_main';
						}
						if($menuName == 'core_main_home') continue;
					?>
					<li class="pulse_mobile_menu_profile_link_item pulse_mobile_menu_item <?php echo $link->get('active') ? 'active' : '' ?>  <?php echo ($index >= 5) ? 'd-none' : ''; ?>">
						<a href='<?php echo $link->getHref() ?>' class="pulse_mobile_menu_profile_link_item_inner <?php echo $link->getClass() ? ' ' . $link->getClass() : ''  ?>" <?php if( $link->get('target') ): ?> target='<?php echo $link->get('target') ?>' <?php endif; ?> >
							<div class="_icon">
								<?php if (isset($link->file_id) && !empty($link->file_id)): ?>
									<?php $photo = Engine_Api::_()->storage()->get($link->file_id, '');
									if ($photo) {
										$photo = $photo->map(); ?>		
										<img src="<?php echo $photo; ?>" alt="<?php echo $this->translate($link->getlabel()) ?>" height="30" width="30" />
									<?php } else { ?>
										<i class="<?php echo $link->get('icon') ? $link->get('icon') : 'fa fa-star' ?>"></i>
									<?php } ?>
								<?php else: ?>
									<i class="<?php echo $link->get('icon') ? $link->get('icon') : 'fa fa-star' ?>"></i>
								<?php endif; ?>
							</div>
							<div class="_info">
								<p class="_title m-0 font_bold"><?php echo $this->translate($link->getlabel()) ?></p>
							</div>
						</a>
					</li>
					<?php $index++; ?>
				<?php endforeach; ?>

				<?php if(count($this->navigation) > 5): ?>
					<li class="pulse_mobile_menu_profile_link_more">
						<button id="pulseLoadMoreBtn" class="btn btn-alt"><span><?php echo $this->translate("Show More"); ?></span><i class="fa-solid fa-angle-down"></i></button>
						<button id="pulseShowLessBtn" class="btn btn-alt" style="display:none;"><span><?php echo $this->translate("Show Less"); ?></span><i class="fa-solid fa-angle-up"></i></button>
					</li>
				<?php endif; ?>
			</ul>
		</div>
	<?php } ?>

	<div class="pulse_mobile_menu_profile_section mt-3">
		<div class="_head"><?php echo $this->translate("HELP & MORE")?></div>
		<ul>
			<?php foreach( $this->helpsupportMobile as $item ): ?>
				<?php $attribs = array_diff_key(array_filter($item->toArray()), array_flip(array('reset_params', 'route', 'module', 'controller', 'action', 'type','visible', 'label', 'href'))); ?>
				<li class="pulse_mobile_menu_profile_link_item">
					<a href="<?php echo $item->getHref() ?>" class="pulse_mobile_menu_profile_link_item_inner">
						<div class="_icon">
							<?php if (isset($item->file_id) && !empty($item->file_id)): ?>
								<?php $photo = Engine_Api::_()->storage()->get($item->file_id, '');
								if ($photo) {
									$photo = $photo->map(); ?>		
									<img src="<?php echo $photo; ?>" alt="<?php echo $this->translate($item->getlabel()) ?>" height="30" width="30" />
								<?php } else { ?>
									<i class="<?php echo $item->get('icon') ? $item->get('icon') : 'fa fa-star' ?>"></i>
								<?php } ?>
							<?php else: ?>
								<i class="<?php echo $item->get('icon') ? $item->get('icon') : 'fa fa-star' ?>"></i>
							<?php endif; ?>
						</div>
						<div class="_info">
							<p class="_title m-0 font_bold"><?php echo $this->translate($item->getLabel()); ?></p>
						</div>
						<div class="_right">
							<p class="m-0 d-flex gap-2">
								<i class="_arrow fi fi-rr-angle-small-right"></i>
							</p>
						</div>
					</a>
				</li>
			<?php endforeach; ?>
			
			<?php if(engine_in_array('miniMenu',$this->options) && !empty($this->accessibility)){ ?>
				<li id="thememodetoggle" class="pulse_mobile_menu_profile_link_item">
					<label class="pulse_mobile_menu_profile_link_item_inner" data-class="notifications_donotclose" for="theme_mode_toggle">
						<div class="_icon">
							<img src="application/modules/Pulse/externals/images/menu-icons/mode.png" alt="<?php echo $this->translate("Mode"); ?>" alt="" height="30" width="30" />
						</div>
						<div class="_info">
							<p class="_title m-0 font_bold"><?php echo $this->translate("Mode"); ?></p>
						</div>
						<div class="_right">
							<?php if($this->contrast_mode == 'dark_mode'){ ?>
								<input type="checkbox" <?php if(isset($_SESSION['mode_theme']) && $_SESSION['mode_theme'] == 'dark_mode'){ ?> checked="checked" <?php } ?> id="theme_mode_toggle" data-class="notifications_donotclose" />
								<i class="contrastmode_toggle _light"><i class="fas fa-sun"></i><i class="fas fa-moon"></i></i>
							<?php } else{ ?>
								<input type="checkbox" <?php if(isset($_SESSION['mode_theme']) && $_SESSION['mode_theme'] == 'light_mode'){ ?> checked="checked" <?php } ?> id="theme_mode_toggle" data-class="notifications_donotclose" />
								<i class="contrastmode_toggle _dark"><i class="fas fa-moon"></i><i class="fas fa-sun"></i></i>
							<?php } ?>
						</div>
					</label>
				</li>
				<li id="themefontmode" class="pulse_mobile_menu_profile_link_item">
					<div class="pulse_mobile_menu_profile_link_item_inner">
						<div class="_icon">
							<img src="application/modules/Pulse/externals/images/menu-icons/text-size.png" alt="<?php echo $this->translate("Font Size"); ?>" alt="" height="30" width="30" />
						</div>
						<div class="_info">
							<p class="_title m-0 font_bold"><?php echo $this->translate("Font Size"); ?></p>
						</div>
						<div class="_right">
							<ul class="resizer"> 
								<li class="<?php echo !empty($_SESSION['font_theme']) && $_SESSION['font_theme'] == '0.9rem' ? 'active' : '' ; ?>"><a href="javascript:void(0)" title="<?php echo $this->translate('Small Font') ?>" onclick="smallfont(this)"><?php echo $this->translate("A"); ?> <sup>-</sup></a></li>
								<li class="<?php echo empty($_SESSION['font_theme']) || !$_SESSION['font_theme'] ? 'active' : '' ; ?>"><a href="javascript:void(0)" title="<?php echo $this->translate('Default Font') ?>" onclick="defaultfont(this)"><?php echo $this->translate("A"); ?></a></li>
								<li class="<?php echo !empty($_SESSION['font_theme']) && $_SESSION['font_theme'] == '1.1rem' ? 'active' : '' ; ?>"><a href="javascript:void(0)" title="<?php echo $this->translate('Large Font') ?>" onclick="largefont(this)"><?php echo $this->translate("A"); ?> <sup>+</sup></a></li>
							</ul>
						</div>
					</div>
				</li>
			<?php } ?>
		</ul>
	</div>

	<?php if(!empty($viewer_id)) { ?>
		<ul class="mt-3 pulse_mobile_menu_profile_section_footer">
			<?php if(Engine_Api::_()->user()->getViewer()->isAllowed('admin')) { ?>
				<li class="mb-3">
					<a target="_blank" class="btn btn-alt" href="<?php echo $this->url(array(), 'admin_default', true); ?>">
						<i class="menuicon fi fi-rr-tools"></i>
						<span><?php echo $this->translate("Admin Panel");?></span>
					</a>
				</li>
			<?php } ?>	
			<li>
				<a class="ajaxPrevent btn btn-alt" href="<?php echo $this->url(array(), 'user_logout', true); ?>">
					<i class="menuicon fi fi-rr-exit"></i>
					<span><?php echo $this->translate("Sign Out");?></span>
				</a>
			</li>
		</ul>
	<?php } ?>

</div>

<script>
en4.core.runonce.add(function () {
	var items = document.querySelectorAll('.pulse_mobile_menu_item');
	var pulseLoadMoreBtn = document.getElementById('pulseLoadMoreBtn');
	var pulseShowLessBtn = document.getElementById('pulseShowLessBtn');

	if (items.length <= 5) {
		pulseLoadMoreBtn.style.display = 'none';
		pulseShowLessBtn.style.display = 'none';
	} else {
		pulseLoadMoreBtn.style.display = 'flex';
		pulseShowLessBtn.style.display = 'none';
	}
	pulseLoadMoreBtn.addEventListener('click', function () {
		for (let i = 5; i < items.length; i++) {
			items[i].classList.remove('d-none');
		}
		pulseLoadMoreBtn.style.display = 'none';
		pulseShowLessBtn.style.display = 'flex';
	});
	pulseShowLessBtn.addEventListener('click', function () {
		for (let i = 5; i < items.length; i++) {
			items[i].classList.add('d-none');
		}
		pulseLoadMoreBtn.style.display = 'flex';
		pulseShowLessBtn.style.display = 'none';
	});
});
</script>