<?php if ( ! defined( 'ABSPATH' ) ) {
exit;} ?>
	  


		<!-- ======================main content============ -->
		<div class="elex-multi-vendor-for-woocommerce-main ps-2 flex-1">
		<div class="toast p-2 position-fixed top-0 start-50 mt-2 translate-middle-x bg-white" id="wsdesk_update_toast" style="z-index:9999999">
				<div class="toast-header border-0 ">
					<strong class="me-auto d-flex gap-2">
						<div class="wsdesk_update_toast_svg " >
						<svg xmlns="http://www.w3.org/2000/svg" width="22.415" height="22.026"
							viewBox="0 0 22.415 22.026" class="me-2">
							<g id="Icon_feather-check-circle" data-name="Icon feather-check-circle"
								transform="translate(-1.998 -1.979)">
								<path id="Path_646" data-name="Path 646" d="M23,12.076V13a10,10,0,1,1-5.93-9.139"
									fill="none" stroke="#28a745" stroke-linecap="round" stroke-linejoin="round"
									stroke-width="2" />
								<path id="Path_647" data-name="Path 647" d="M26.5,6l-10,10.009-3-3"
									transform="translate(-3.5 -1.003)" fill="none" stroke="#28a745"
									stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
							</g>
						</svg>
						</div>
					
						<span class="toast_message_mv">Credentials Updated Successfully</span>
						</strong>
					<button type="button" class="btn-close" data-bs-dismiss="toast"></button>
				</div>

		</div>
			<!-- ===========side panel open button========= -->
			<div class="d-flex mb-3 gap-4 align-items-center elex-multi-vendor-for-woocommerce-side-panel-open-div  d-md-none">
				<!-- side panel open button -->
				<button class=" btn p-1 shadow-none fs-5   bg-white text-primary position-relative " id="elex-multi-vendor-for-woocommerce-side-panel-open-btn"><svg height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"/></svg></button>
				<div class="fs-5 fw-semi-bold mb-0 ">Shipping</div>
			</div>
			<div class=" h-100 elex-shipping-contents-main-class position-relative" >
				<!-- <div class="bg-info bg-opacity-10 mb-3">
					<ul class="elex-multi-vendor-for-woocommerce-shipping-link d-flex gap-3 nav px-3">
						<li class="nav-item">
							<a href="your-accounts.html" class="nav-link">Your Account(s)</a>
						</li>
						<li class="nav-item">
							<a href="#" class="nav-link active">Admin's Account(s)</a>
						</li>
					</ul>
				</div> -->

				<div class="fs-4 fw-semi-bold my-3">Available Shipping Methods</div>

				<!-- <div class="row  h-100 align-items-center justify-content-center">
					<div class="col-md-4  text-center">
						<img src="../../images/illustration-3-your-a-c.png" alt="" class="w-100 mb-5">

						<button class="btn btn-primary"><i class="fa-solid fa-plus me-2"></i>Add To Your Account</button>
					</div>
				</div> -->
				
				<?php 
			

				if ( empty( $shipping_values_from_dhl ) && empty( $woocommerce_shipping_methods ) ) {
					?>
						<div class="d-flex align-items-center w-100 flex-column position-absolute pt-5" >
							<div class="fs-6 mb-1">You currently don't have access to configure Shipping Methods as it's restricted by the administrator. </div>
							<img style="max-width: 600px" class="w-100" src="<?php echo esc_html( ELEX_MULTI_VENDOR_MAIN_URL_PATH . 'images/illustration-3-your-a-c.png' ); ?>" alt="">
						</div>
					
						
						<?php
				}
				?>
				<!-- list if added account -->
				<div class="me-4 shipping-methods-card">


				<?php

				$shipping_avail = 0;

					$allowed_shipping_array = array( 'free_shipping', 'flat_rate', 'local_pickup' );


				foreach ( $woocommerce_shipping_methods as $shipping_value => $shipping_method ) : 
					
					$settings = $shipping_method->instance_settings;

					

					$setting_option = get_option( 'woocommerce_' . $shipping_method->id . '_' . $shipping_method->instance_id . '_settings', true );
						
					
					$storex_id = isset( $settings['elex_extra_field_assigned_vendor'] ) ? $settings['elex_extra_field_assigned_vendor'] : array() ;
							
					if ( in_array( $store->get_id() , $storex_id ) && in_array( $shipping_method->id, $allowed_shipping_array ) && 'yes' === $shipping_method->enabled ) {
							
						$shipping_avail = 1;

						?>
						<div class="me-4">
							<div class="border border-2 rounded elex-multi-vendor-for-woocommerce-shippping-add-ac mb-3">
								<div class="p-2 mb-3">
									<div class="d-flex justify-content-between align-items-center flex-wrap mb-3">
										<div class="mb-2">
											<h6 class="mb-0">Shipping Method: <span><?php echo esc_html( $shipping_method->title ); ?></span></h6>
										</div>
										<div class="" style="width:200px;">
											<div class="text-end d-flex align-items-center justify-content-end gap-2">
												<span>Status:</span>
												<label class="elex-enable-disable-switch">
											<input type="checkbox" 
											<?php 
											 
											$shipping_method_enabled = get_post_meta( $store->get_id(), $shipping_method->id . $shipping_method->instance_id, true );
											if ( $shipping_method_enabled ) {
												echo esc_attr( 'checked' );
											}

											?>
											class="enable_woocommerce_shipping_method_for_vendor" data-store-id="<?php echo esc_html( $store->get_id() ); ?>" data-shipping-method="<?php echo esc_html( sanitize_text_field( $shipping_method->id ) ); ?>" data-shipping-method-id="<?php echo esc_html( sanitize_text_field( $shipping_method->instance_id ) ); ?>" >
											<div class="switch round"></div>
										</label>
										</div>
										</div>
									</div>

									<?php 
									if ( isset( $settings['cost'] ) ) {
										?>
													
												<small>Cost: <?php echo esc_html( sanitize_text_field( wc_price( $settings['cost'] ) ) ); ?> </small></br>

									<?php } ?>

									<div class="elex_show_shipping_container w-100">
									<div class="bg-light px-2 pt-1 d-flex justify-content-end w-100 elex-shipping-detail-open">
									<button class="btn elex-shipping-detail-open-btn "> Show Details <i class="fa-solid fa-chevron-down"></i></button>
									</div>
									<div class="bg-light px-2 pt-1 d-flex justify-content-end w-100 elex-shipping-detail-close d-none">
										<button class="btn elex-shipping-detail-close-btn"> Hide Details<i class="fa-solid fa-chevron-up"></i></button>
									</div>	
									<div class="elex_show_shipping_details d-none">
										<hr>
										<?php
										if ( isset( $shipping_method->tax_status ) ) {
											?>
														
											<small>Tax Status: <?php echo esc_html( sanitize_text_field( ucfirst( $shipping_method->tax_status ) ) ); ?> </small></br>
										<?php } ?>
										<?php
										if ( ! empty( $settings['zone_name'] ) ) {
											?>
												
											<small>Zone Name: <?php echo esc_html( sanitize_text_field( $settings['zone_name'] ) ); ?> </small></br>
										<?php } ?>
										<?php
										if ( ! empty( $settings['zone_region'] ) ) {
											?>
													
											<small>Regions: <?php echo esc_html( sanitize_text_field( $settings['zone_region'] ) ); ?> </small></br>
										<?php } ?>
									</div>	

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

						<?php 
					}
						endforeach ;  
			
		

				if ( empty( $shipping_values_from_dhl ) && 0 === $shipping_avail ) {
					?>
						<div class="d-flex align-items-center w-100 flex-column position-absolute pt-5" >
							<div class="fs-6 mb-1">You currently don't have access to configure Shipping Methods as it's restricted by the administrator. </div>
							<img style="max-width: 600px" class="w-100" src="<?php echo esc_html( ELEX_MULTI_VENDOR_MAIN_URL_PATH . 'images/illustration-3-your-a-c.png' ); ?>" alt="">
						</div>
					
						
						<?php
				}
			
				foreach ( $shipping_values_from_dhl as $shipping_value => $shipping_data ) :  
					?>

					<div class="border border-2 rounded elex-multi-vendor-for-woocommerce-shippping-add-ac mb-3">
						<div class="p-2 mb-3">
							<div class="d-flex justify-content-between align-items-center flex-wrap">
								<div class="mb-2">
									<div class="fs-6 fw-semi-bold mb-0">Shipping Method: <span><?php echo esc_html( $shipping_data['name'] ); ?></span></div>
								</div>

								<div class="d-flex elex-multi-vendor-for-woocommerce-shipping-brand gap-2 mb-2">
								<?php

							

								if ( isset( $vendor_all_permissions['vendor_to_override_creds'] ) && $vendor_all_permissions['vendor_to_override_creds'] ) :
									?>
									<button
										class="btn btn-sm text-primary d-flex align-items-center gap-1 override-credentials-btn" data-shipping-method="<?php echo esc_html( $shipping_data['slug'] ); ?>">
										<div class="override-credendtial-indicator 
										<?php 
										

										if ( isset( $shipping_data['slug'] ) && isset( $override_credentials_for_shipping_method[ $shipping_data['slug'] ] ) && 'true' === $override_credentials_for_shipping_method[ $shipping_data['slug'] ] ) {
												echo esc_attr( 'active' );
										}
										?>
										" ></div>
										Override Credentials
									</button>

										<?php 
										endif;

								if ( isset( $vendor_all_permissions['vendor_to_allow_vendor_shipping'] ) && $vendor_all_permissions['vendor_to_allow_vendor_shipping'] ) :

									if ( 1 < count( $shipping_data['carriers'] ) ) {
										?>
											<button class="btn btn-sm text-primary d-flex align-items-center gap-1 elex_ac_carrier_setting_btn">
											<svg id="Icon_feather-settings" data-name="Icon feather-settings"
												xmlns="http://www.w3.org/2000/svg" width="16.5" height="16.5"
												viewBox="0 0 31.874 30.765">
												<path id="Path_17" data-name="Path 17"
													d="M21.375,17.286A3.94,3.94,0,1,1,17.437,13.5,3.864,3.864,0,0,1,21.375,17.286Z"
													transform="translate(-1.5 -1.904)" fill="none" stroke="#3F5980"
													stroke-linecap="round" stroke-linejoin="round" stroke-width="1" />
												<path id="Path_18" data-name="Path 18"
													d="M25.649,19.169a2.023,2.023,0,0,0,.433,2.3l.079.076a2.456,2.456,0,0,1,0,3.572,2.7,2.7,0,0,1-3.714,0l-.079-.076a2.23,2.23,0,0,0-2.389-.416,2.082,2.082,0,0,0-1.312,1.906v.215a2.627,2.627,0,0,1-5.25,0v-.114A2.09,2.09,0,0,0,12,24.721a2.23,2.23,0,0,0-2.389.416l-.079.076a2.7,2.7,0,0,1-3.714,0,2.456,2.456,0,0,1,0-3.572l.079-.076a2.023,2.023,0,0,0,.433-2.3,2.169,2.169,0,0,0-1.982-1.262H4.125a2.526,2.526,0,1,1,0-5.048h.118A2.161,2.161,0,0,0,6.225,11.6a2.023,2.023,0,0,0-.433-2.3l-.079-.076a2.456,2.456,0,0,1,0-3.572,2.7,2.7,0,0,1,3.714,0l.079.076a2.23,2.23,0,0,0,2.389.416H12a2.082,2.082,0,0,0,1.312-1.906V4.024a2.627,2.627,0,0,1,5.25,0v.114a2.082,2.082,0,0,0,1.312,1.906,2.23,2.23,0,0,0,2.389-.416l.079-.076a2.7,2.7,0,0,1,3.714,0,2.456,2.456,0,0,1,0,3.572l-.079.076a2.023,2.023,0,0,0-.433,2.3v.1a2.169,2.169,0,0,0,1.982,1.262h.223a2.526,2.526,0,1,1,0,5.048h-.118a2.169,2.169,0,0,0-1.982,1.262Z"
													transform="translate(0)" fill="none" stroke="#3F5980"
													stroke-linecap="round" stroke-linejoin="round" stroke-width="3" />
											</svg>
	
											Carrier Settings
										</button>

									<?php
									} 
									endif;
								?>
							 

								   
								</div>
							<?php include ELEX_MULTI_VENDOR_PLUGIN_PATH . 'templates/shipping/carrier-list.php'; ?>

							</div>

							<div class="row align-items-center">
								<div class="col-md-3">
									<small><?php echo esc_html( $shipping_data['description'] ); ?></small>
								</div>
								<div class="col-md-6 text-center">
									<div class="d-flex justify-content-center align-items-center">
										Carriers:
										<ul class="nav elex-multi-vendor-for-woocommerce-shipping-brand gap-2">
									<?php 
									foreach ( $shipping_data['carriers'] as $carrier ) {
										?>
											<li class="nav-item"><a class="nav-link"><?php echo esc_html( $carrier['name'] ); ?></a></li>
											<?php
									}
									?>
										  
										</ul>
									</div>
								</div>
								<div class="col-md-3">
									<div class="text-end d-flex align-items-center justify-content-end gap-2">
										<span>Status:</span>
										<label class="elex-enable-disable-switch">
											<input type="checkbox" 
									<?php 
											 
									if ( isset( $carriers_enable_list[ $shipping_data['slug'] ] ) && 'true' === $carriers_enable_list[ $shipping_data['slug'] ] ) {
										echo esc_attr( 'checked' );
									}

									?>
											class="enable_shipping_method_for_vendor"  data-carrier-slug ="<?php echo esc_html( $shipping_data['slug'] ); ?>" data-store-id = "<?php echo esc_html( $store->get_id() ); ?>" >
											<div class="switch round"></div>
										</label>
									</div>
								</div>
							</div>


						</div>
						<div class=" bg-light  px-2">
							<div class="d-flex justify-content-end elex-multi-vendor-for-woocommerce-ship-show-service">
								<button class="btn elex-shipping-table-open-btn">Show Services <i
										class="fa-solid fa-chevron-down"></i></button>
							</div>
							<div
								class="d-flex  flex-wrap justify-content-between align-items-center d-none elex-shipping-table-close-sec">
								<div>
									<ul class="nav elex-multi-vendor-for-woocommerce-shipping-brand gap-2">
										<?php foreach ( $shipping_data['carriers'] as  $service_key => $services_value ) : ?>
										<li class="li-for-active-carrier-<?php echo esc_html( $services_value['name'] ); ?>  nav-item"><a class="nav-link services_show_in_table_button"  ><?php echo esc_html( $services_value['name'] ); ?></a></li>
									<?php endforeach; ?>

									</ul>
								</div>

								<div class="elex-multi-vendor-for-woocommerce-ship-hide-service">
									<!-- <button class="btn btn-sm btn-outline-primary elex-easypost-flat-rate-open-btn">Show
										Flat Rate Services</button> -->
									<button class="btn elex-shipping-table-close-btn">Hide Services(s) <i
											class="fa-solid fa-chevron-up"></i></button>
								</div>
							</div>
						</div>

						<div class="table-responsive d-none elex-shipping-table">

							<?php 
							foreach ( $shipping_data['carriers'] as $services_value ) : 
								?>

							<table class="table table-borderless  elex-multi-vendor-for-woocommerce-service-dhl-table align-middle" id="service-table-values-<?php echo esc_html( $services_value['name'] ); ?>" data-carrier-name="<?php echo esc_html( $services_value['name'] ); ?>" >
								<thead class="bg-light">
									<tr>
										<th scope="col" style="width: 300px;max-width: 300px;">
											<input type="checkbox" class="form-check-input me-2">Service(s)
										</th>
										<th scope="col" style="width: 500px;max-width: 500px;">Service Name</th>
										<th scope="col" style="width: 200px;max-width: 200px;">Price Adjustments($ | %)</th>
									</tr>
								</thead>
								<tbody>
								<?php 
								$enable_choose_ship_service = '';
								if ( ! isset( $vendor_all_permissions['vendor_to_choose_ship_services'] ) || ! $vendor_all_permissions['vendor_to_choose_ship_services'] ) {
									$enable_choose_ship_service = 'disabled';
								} else {
									$enable_choose_ship_service = '';

								}
						
								foreach ( $services_value['services'] as $service_key => $service_value ) : 
									?>
									<tr class="elex_row_shipment_services" data-carrier-name="<?php echo esc_html( $services_value['name'] ); ?>" data-carrier-enabled="
																										<?php 
									$enable_service = isset( $services_value['enabled'] ) ? $services_value['enabled'] : ''  ;
											echo esc_html( $enable_service ); 
																										?>
									" >
										<td><input type="checkbox" name="enabled" class="form-check-input me-2 elex_service_enabled"
										<?php 
										if ( isset( $service_value['enabled'] ) && ( 'true' === $service_value['enabled'] || 1 === $service_value['enabled'] ) ) {
											echo esc_html( 'checked  ' ); } 
											echo esc_html( $enable_choose_ship_service );
										?>
											> <?php echo isset( $service_value['name'] ) ? esc_html( $service_value['name'] ) : '' ; ?></td>
										<td>
											<input type="text" name="service_name" class="form-control w-75 elex_service_name" placeholder="service name" value="<?php echo isset( $service_value['name'] ) ? esc_html( $service_value['name'] ) : '' ; ?>" <?php echo esc_html( $enable_choose_ship_service ); ?>>
											<input type="hidden" type="text" name="service_id" class="form-control w-75 elex_service_id"  value="<?php echo isset( $service_value['id'] ) ? esc_html( $service_value['id'] ) : '' ; ?>">

										</td>
										<td>
											<div class="border input-group w-75">
												<input type="text" class="form-control elex_service_value border-0" name="value" placeholder="N.A." value="<?php echo isset( $service_value['price_adjustment']['value'] ) ? esc_html( $service_value['price_adjustment']['value'] ) : ''; ?>" <?php echo esc_html( $enable_choose_ship_service ); ?>>
												<select name="type" class="input-group-text bg-primary bg-opacity-10 px-3 elex_service_type border-0" value="<?php echo isset( $service_value['price_adjustment']['type'] ) ? esc_html( $service_value['price_adjustment']['type'] ) : ''; ?>" <?php echo esc_html( $enable_choose_ship_service ); ?>>
													<option value='percent' <?php echo esc_attr( isset( $service_value['price_adjustment']['type'] ) && 'percent' === $service_value['price_adjustment']['type'] ? 'selected' : '' ); ?> >%</option>
													<option value='flat' <?php echo esc_attr( isset( $service_value['price_adjustment']['type'] ) && 'flat' === $service_value['price_adjustment']['type'] ? 'selected' : '' ); ?> >$</option>
												</select>
											</div>
										</td>
									</tr>
								<?php endforeach; ?>
								</tbody>

							</table>

							<?php endforeach; ?>
							<button class="btn btn-primary save-changes-related-to-service" data-method-slug="<?php echo esc_html( $shipping_data['slug'] ); ?>" data-store-id = "<?php echo esc_html( $store->get_id() ); ?>" >Save Services</button>

						</div>
							<?php include ELEX_MULTI_VENDOR_PLUGIN_PATH . 'templates/shipping/override-credentials.php'; ?>


					</div>
				

				


						<?php endforeach; ?>


				</div>


			</div>



		   


		   

			<!-- carrier settings popup -->
		




			



		</div>
		<!-- ===================end of main content============ -->









