<?php
namespace Elementor;

class mobilebar extends Widget_Base {
	
	public function get_name() {
		return 'mobilebar';
	}
	
	public function get_title() {
		return 'المان منو موبایل';
	}
	
	    public function get_icon() {
		return 'eicon eicon-header';
    }
    
    public function get_categories() {
        return [ 'farnam' ];
    }
	
protected function _register_controls() {

		$this->start_controls_section(
			'section_title',
			[
				'label' => __( 'Content', 'elementor' ),
			]
		);
		
		$this->add_control(
			'posts_per_page',
			[
				'label' => __( 'عنوان', 'elementor' ),
				'label_block' => true,
				'type' => Controls_Manager::TEXT,
				'placeholder' => __( 'یک عنوان وارد کنید', 'elementor' ),
			]
		);
       		$this->end_controls_section();


 

		
	}
	
		protected function render() {
		$settings = $this->get_settings_for_display();
		

		?>
		
			
		<div id="myshopmodalq" class="modal-iran-hazf">

  <!-- modalq content -->
  <div class="modaldakhel">
  
    <span class="closeq closeiran-s">&times; خروج از این پنجره</span></div>

<div class="sepid-mini-cart-header saasdadsasd23">
<div class="sabad-mobile-test mini-cart-3">
<div class="widget_shopping_cart_content"><?php woocommerce_mini_cart(); ?></div> 
</div>
</div>
</div>




		
		<div id="searchmodal" class="modal-iran-hazf">

  <!-- modalq content -->
  <div class="modalqdakhel">
  
    <span class="closew1 closeiran-s">&times; خروج از این پنجره</span></div>
<div class="modal-etel111">
	 
	 
	 <div class="etela-bazsho-1">
	<?php	include es_TPL_PATH . 'header-mobile.php'; ?>

</div>

</div></div>
</div>




	<div id="etelmodal" class="modal-iran-hazf">

  <!-- modalq content -->
  <div class="modaldakhel">
  
    <span class="closee closeiran-s">&times; خروج از این پنجره</span></div>
<div class="modal-etel111">
<div class="sepid-head-bazsho">
<div class="sepid-head-bazsho-1">
   <div class="user-avatar">
		<div class="in1"><?php

// Get current user id
$user_id = get_current_user_id();

// Get attachment id
$attachment_id = get_user_meta( $user_id, 'avatar', true );

// Get default avatar URL
$default_avatar = wp_get_attachment_image_src(get_option('avatar_default'), '100');

// True
if ( $attachment_id ) {

  // Get image url
  $image_url = wp_get_attachment_url( $attachment_id );

  // Display image
  if ( $image_url ) {
    echo wp_get_attachment_image( $attachment_id, '100' );
  } else {
    // Display default avatar
    echo '<img src="' . esc_url($default_avatar[0]) . '" alt="اواتار" width="100" height="100">';
  }
} else {

  // Display default avatar
  echo '<img src="' . get_template_directory_uri() . '/img/user.jpg' . '" alt="اواتار پیشفرض" width="100" height="100">';
}
?></div>
       <div class="in2">
	   <span>
	   سلام
	   <?php global $current_user;
      get_currentuserinfo();
      echo '' . $current_user->user_firstname . "\n";
?>
</span>
<a class="khorooj-sistem" href="<?php echo home_url() ?>/my-account/customer-logout/">خروج از سایت</a>

</div>
        
    
    </div>
	
	<div class="sepid-head-bazsho-2">
<div class="user-meta">
<a href="<?php echo home_url() ?>/my-account/"><i class="fi fi-rr-user"></i> پنل کاربری </a>
<a href="<?php echo home_url() ?>/my-account/edit-account/"><i class="fi fi-rr-edit"></i> ویرایش حساب کاربری </a>
<a href="<?php echo home_url() ?>/my-account/orders/"><i class="fi fi-rr-shopping-cart"></i> سفارش های شما </a>
<a href="<?php echo home_url() ?>/my-account/mywishlist/"><i class="fi fi-rr-heart"></i> علاقه مندی های شما </a>

</div>
</div>

</div>

</div>
</div>
</div>

</div>
		<div class="navar-paiin-site">
		<div class="min-icon-footer" id="shopbot">
		<div class="sabad-foot-433">
		<i class="fi fi-rr-shopping-bag"></i>
				 <span class="sabadnumbercolor"><div class="header-cart-count"><?php echo WC()->cart->get_cart_contents_count(); ?></div></span>
</div>
				<span class="text-alaghe">سبد خرید</span>


		</div>
		<script>
		// Get the modalq
var modalq = document.getElementById("myshopmodalq");

// Get the button that opens the modalq
var btn = document.getElementById("shopbot");

// Get the <span> element that closes the modalq
var span = document.getElementsByClassName("closeq")[0];

// When the user clicks on the button, open the modalq
btn.onclick = function() {
  modalq.style.display = "block";
}

// When the user clicks on <span> (x), close the modalq
span.onclick = function() {
  modalq.style.display = "none";
}

// When the user clicks anywhere outside of the modalq, close it
window.onclick = function(event) {
  if (event.target == modalq) {
    modalq.style.display = "none";
  }
}


 </script>
		<div class="min-icon-footer" id="searchbot">
		<i class="fi fi-rr-bell-ring"></i>
				<span class="text-alaghe">اطلاعیه ها</span>

		</div>
		
		<script>
		// Get the modalq
var modalq1 = document.getElementById("searchmodal");

// Get the button that opens the modalq
var btn = document.getElementById("searchbot");

// Get the <span> element that closes the modalq
var span = document.getElementsByClassName("closew1")[0];

// When the user clicks on the button, open the modalq
btn.onclick = function() {
  modalq1.style.display = "block";
}

// When the user clicks on <span> (x), close the modalq
span.onclick = function() {
  modalq1.style.display = "none";
}

// When the user clicks anywhere outside of the modalq, close it
window.onclick = function(event) {
  if (event.target == modalq1) {
    modalq1.style.display = "none";
  }
}

</script>

		<a class="min-icon-footer" href="<?php echo get_home_url(); ?>">
		
		<i class="fi fi-rr-home"></i>
		</a>
		
		<a class="min-icon-footer" href="<?php echo home_url() ?>/wishlist/">
		<i class="fi fi-rr-heart"></i>
		<span class="text-alaghe">علاقه مندی</span>
		</a>
				<?php if ( is_user_logged_in() ) { ?>

		<div class="min-icon-footer" id="etelbot">
		<i class="fi fi-rr-user"></i>
				<span class="text-alaghe">منو کاربر</span>

		</div>
		
					<script>
		// Get the modalq
var modalq2 = document.getElementById("etelmodal");

// Get the button that opens the modalq
var btn = document.getElementById("etelbot");

// Get the <span> element that closes the modalq
var span = document.getElementsByClassName("closee")[0];

// When the user clicks on the button, open the modalq
btn.onclick = function() {
  modalq2.style.display = "block";
}

// When the user clicks on <span> (x), close the modalq
span.onclick = function() {
  modalq2.style.display = "none";
}

// When the user clicks anywhere outside of the modalq, close it
window.onclick = function(event) {
  if (event.target == modalq2) {
    modalq2.style.display = "none";
  }
}

</script>
		<?php } 
 else { ?>
 
 <a class="min-icon-footer" href="<?php echo home_url() ?>/my-account/">
		<i class="fi fi-rr-user"></i>
				<span class="text-alaghe">ورود</span>

		</a>
  <?php } ?>
 

		</div>
		<?php
	}
	
	
	protected function _content_template() {

    }
	
	
}