<!DOCTYPE html> <html lang="{{ app()->getLocale() }}" dir="{{ app()->getLocale() == 'ar'…
- Usercode
- Assistant
<div class="content_page">
<div class="header">
<div class="left">
<div class="icon_menu">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"
/>
</svg>
</div>
<div class="logo_header">
<img src="images/logo.png" alt="logo" loading="lazy" />
</div>
<div class="input_search">
<input type="text" placeholder="{{ __('search_placeholder') }}" />
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
/>
</svg>
</div>
</div>
<div class="right">
@include('include.translation')
<div class="notfication">
<div class="head">
<div class="icon">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0M3.124 7.5A8.969 8.969 0 015.292 3m13.416 0a8.969 8.969 0 012.168 4.5"
/>
</svg>
</div>
</div>
</div>
<div class="nav_item">
<div class="head">
<img
class="img_profile"
src="images/user-1.jpg"
alt="user-1"
loading="lazy"
/>
</div>
@include('include.profile')
</div>
</div>
</div>
<div class="main_content_tables">
<div class="conetnt_table">
<div class="path">
<span>{{ __('home') }}</span> /
<span>{{ __('groups') }}</span>
</div>
<div class="head_table">
<div class="info">
<p class="text_details">
<i class="fa-solid fa-people-group"></i>
{{ __('Group List | Found :count Entries', ['count' => count($allData)]) }}
</p>
</div>
<div class="input_search">
<input type="text" placeholder="{{ __('search_placeholder') }}" />
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
></path>
</svg>
</div>
<div class="utils">
<div class="actions_box">
<button class="btn_actions">
<i class="fa-solid fa-wrench"></i>
{{ __('operations') }}
</button>
<div class="box box_utils">
<a href={{ route('addmgrp') }} class="item">
<i class="fa-solid fa-plus"></i>
<span>{{ __('add') }}</span>
</a>
<a id='aview' href={{ route('prfgrp') }} class="item">
<i class="fa-solid fa-eye"></i>
<span>{{ __('view') }}</span>
</a>
<a href={{ route('addgrop') }} class="item">
<i class="fa-solid fa-envelope"></i>
<span>{{ __('send_message') }}</span>
</a>
<div class="item btn_open_model" data-model="1">
<i class="fa-solid fa-right-left"></i>
<span> {{ __('move_clients') }}</span>
</div>
<div class="item">
<i class="fa-solid fa-users-slash"></i>
<span>{{ __('delete_clients') }}</span>
</div>
<div class="item">
<i class="fa-solid fa-trash"></i>
<button id="deletebtn">
<span> {{ __('delete') }}</span>
</button>
</div>
</div>
</div>
<div class="reload">
<button class="btn_utils">
<i class="fa-solid fa-repeat"></i>
</button>
</div>
<div class="filter">
<button class="btn_utils">
<i class="fa-solid fa-filter"></i>
</button>
</div>
</div>
</div>
<div class="container_table">
<table id="table" class="display" style="width: 100%">
<thead>
<tr>
<th>
<input type="checkbox" id="selectAll"/>
</th>
<th>{{ __('name') }}</th>
<th>{{ __('clients') }}</th>
<th>{{ __('notes') }}</th>
<th>{{ __('creation_date') }}</th>
</tr>
</thead>
<tbody>
@if($allData)
@foreach($allData as $data)
<tr>
<td>
<input type="checkbox" />
</td>
<td>
<a href="profile-group.html">{{ $data->name }}</a>
</td>
<td>{{ __('all_clients') }}</td>
<td>{{ $data->comment }}</td>
<td>2023-05-04 13:09:32</td>
</tr>
@endforeach
@endif
<tr>
<td>
<input type="checkbox" />
</td>
<td>
<a href={{ route('addmgrp') }}>{{ __('all_clients') }}</a>
</td>
<td>136</td>
<td></td>
<td>2023-05-04 13:09:32</td>
</tr>
<tr>
<td>
<input type="checkbox" />
</td>
<td>
<a href="profile-group.html">{{ __('all_clients') }}</a>
</td>
<td>136</td>
<td></td>
<td>2023-05-04 13:09:32</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<!-- start model add group -->
<div class="overflow"></div>
<div class="model_poup" data-model="1">
<div class="content">
<div class="head">
<h5 class="title_model">{{ __('groups') }}</h5>
<div class="close_model">
<i class="fa-solid fa-xmark"></i>
</div>
</div>
<form action="">
<div class="input_item">
<label for="">{{ __('select_group') }}</label>
<select name="" id="">
<option value=""></option>
<option value="">{{ __('all_clients') }}</option>
</select>
</div>
<button class="btn_submit">{{ __('confirm') }}</button>
</form>
</div>
</div>
<!-- end model add group -->
<script src="js/model.js"></script>
<script src="js/tableUtils.js"></script>
<script src="js/boxs-header.js"></script>
<script src="js/sidebar.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
<script>
pdata={};
const selectedPhones = new Set();
function checkSessionStatus() { const checkboxes = document.querySelectorAll('tbody input[type="checkbox"]'); const deleteBtn = document.getElementById('deletebtn'); const selectAllCheckbox = document.getElementById('selectAll');
selectAllCheckbox.addEventListener('change', function() {
checkboxes.forEach(checkbox => {
checkbox.checked = true;
const phone = checkbox.closest('tr').cells[1].textContent.trim();
selectedPhones.add(phone);
});
setTimeout(() => {
this.checked = false;
}, 0);
});
checkboxes.forEach((checkbox) => {
checkbox.addEventListener('change', function() {
const row = this.closest('tr');
const phone = row.cells[1].textContent.trim();
if (this.checked) {
selectedPhones.add(phone);
const accountName = row.cells[1].textContent.trim();
const customertype = row.cells[2].textContent.trim();
const created_at = row.cells[4].textContent.trim();
const data = {
name: accountName,
customertype: customertype,
created_at: created_at
};
fetch('api/data/profile-client-groups', {
method: 'post',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify(data)
})
console.log('Added:', phone, data);
} else {
selectedPhones.delete(phone);
console.log('Removed:', phone);
}
});
});
deleteBtn.addEventListener('click', function() {
if (selectedPhones.size > 0) {
deleteSelectedRows();
}
});
}
function deleteSelectedRows() { console.log('Phones to delete:', Array.from(selectedPhones)); // Debug log fetch('/delete-rows-groups', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content') }, body: JSON.stringify({phones: Array.from(selectedPhones)}) }) .then(response => response.json()) .then(data => { if (data.success) { selectedPhones.forEach(phone => { const rows = document.querySelectorAll('tbody tr'); for (let row of rows) { if (row.cells[1] && row.cells[1].textContent.trim() === phone) { row.remove(); break; } } }); selectedPhones.clear(); alert('{{ __("selected_rows_deleted_successfully") }}'); } else { alert('{{ __("error_deleting_rows") }} ' + data.message); } }) .catch(error => { console.error('Error:', error); alert('{{ __("an_error_occurred_while_deleting_rows") }}'); }); } console.log(pdata);
function sendreqprofile(){ fetch('/handleprofilegroupdata', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content') }, body: JSON.stringify(pdata) }) .then(response => response.json()) .then(data => { console.log('{{ __("profile_data_sent_successfully") }}', data); }) .catch(error => { console.error('{{ __("error_sending_profile_data") }}', error); }); }
const viewIdBtn = document.getElementById('aview'); console.log('viewIdBtn:', viewIdBtn); if (viewIdBtn) { viewIdBtn.addEventListener('click', function() { console.log('Button clicked!'); console.log(pdata); sendreqprofile(); }); } else { console.error('{{ __("button_aview_not_found") }}'); }
checkSessionStatus(); (document).ready(function () { ("#table").DataTable({ pagingType: "full_numbers", scrollX: true, }); });
Certainly! To make your webpage change text direction when switching between Arabic and English, you need to ensure that the dir (direction) attribute of your HTML elements updates according to the selected language. This can be achieved by setting the dir attribute based on the application's locale and ensuring that it's updated whenever the language changes.
Here's how you can implement this:
dir Attribute Based on LocaleIn your HTML template, you're already setting the dir attribute in the <html> tag based on the application's locale:
<html lang="{{ app()->getLocale() }}" dir="{{ app()->getLocale() == 'ar' ? 'rtl' : 'ltr' }}">
This ensures that when the page loads, the text direction is set to right-to-left (rtl) if the locale is Arabic ('ar'), and left-to-right (ltr) for other languages.
To allow users to switch between Arabic and English, you need to implement a language switcher. This typically involves:
Here's how you can do it:
In your header or another appropriate place in your template, add links or buttons that allow users to select their preferred language:
<!-- Language Switcher -->
<div class="language-switcher">
<a href="{{ route('changeLang', ['lang' => 'en']) }}">English</a>
<a href="{{ route('changeLang', ['lang' => 'ar']) }}">العربية</a>
</div>
In your web.php routes file, define a route that updates the session's locale value when a language is selected:
// web.php
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Redirect;
Route::get('change-lang/{lang}', function ($lang) {
if (in_array($lang, ['en', 'ar'])) {
session()->put('locale', $lang);
}
return redirect()->back();
})->name('changeLang');
Create a middleware that sets the application's locale based on the session value:
// app/Http/Middleware/LocaleMiddleware.php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
class LocaleMiddleware
{
public function handle($request, Closure $next)
{
if (Session::has('locale')) {
App::setLocale(Session::get('locale'));
}
return $next($request);
}
}
In your app/Http/Kernel.php, register the middleware:
// app/Http/Kernel.php
protected $middlewareGroups = [
'web' => [
// ...
\App\Http\Middleware\LocaleMiddleware::class,
],
// ...
];
With the above setup, when a user selects a language:
changeLang updates the locale value in the session.LocaleMiddleware sets the application's locale based on the session value.<html> tag's dir attribute updates because it uses app()->getLocale() to determine the direction.To ensure that your layout and styles adjust correctly when switching to RTL, you need to:
If you're using Bootstrap, include the RTL version of the stylesheet for Arabic:
<!-- For LTR (English) -->
<link rel="stylesheet" href="css/bootstrap.css" />
<!-- For RTL (Arabic) -->
<link rel="stylesheet" href="css/bootstrap-rtl.css" />
You can conditionally include the correct stylesheet based on the locale:
@if (app()->getLocale() == 'ar')
<link rel="stylesheet" href="css/bootstrap-rtl.css" />
@else
<link rel="stylesheet" href="css/bootstrap.css" />
@endif
Make sure your custom CSS also supports RTL. You might need to:
margin-inline-start and margin-inline-end instead of margin-left and margin-right.dir attribute is rtl.If you have JavaScript code that manipulates layout or styles, ensure it accounts for the text direction.
For example, if you're setting styles via JavaScript:
const direction = document.documentElement.dir;
if (direction === 'rtl') {
// Apply RTL-specific JavaScript adjustments
} else {
// Apply LTR-specific JavaScript adjustments
}
Below is your adjusted template with the necessary changes:
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}" dir="{{ app()->getLocale() == 'ar' ? 'rtl' : 'ltr' }}">
<head>
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ __('sas_radius_pro_dashboard') }}</title>
<!-- Conditional Bootstrap Stylesheet -->
@if (app()->getLocale() == 'ar')
<!-- Bootstrap RTL -->
<link rel="stylesheet" href="css/bootstrap-rtl.css" />
@else
<!-- Bootstrap LTR -->
<link rel="stylesheet" href="css/bootstrap.css" />
@endif
<!-- Custom Styles -->
<link rel="stylesheet" href="css/style.css" />
<!-- Font Awesome and other dependencies -->
<!-- ... -->
<!-- Scripts -->
<script src="js/bootstrap.js"></script>
<!-- ... -->
</head>
<body>
<main>
<!-- Sidebar, Content, etc. -->
<!-- Language Switcher -->
<div class="language-switcher">
<a href="{{ route('changeLang', ['lang' => 'en']) }}">English</a>
<a href="{{ route('changeLang', ['lang' => 'ar']) }}">العربية</a>
</div>
<!-- Rest of your content -->
</main>
<!-- Scripts -->
<!-- ... -->
</body>
</html>
Language Switching Links/Buttons: The links provided allow the user to switch between English and Arabic. When clicked, they trigger a route that changes the application's locale.
Middleware LocaleMiddleware: This ensures that every request checks the session for a locale value and sets the application's locale accordingly.
dir Attribute in <html> Tag: The direction attribute is set based on the current locale. If the locale is Arabic ('ar'), dir is set to rtl; otherwise, it's ltr.
Conditional Stylesheets: The CSS for Bootstrap is conditionally loaded based on the locale to ensure that RTL styles are applied when needed.
Page Reload: Clicking the language switcher reloads the page with the new locale settings, updating text directions, styles, and content as necessary.
Translating Content: Ensure that your content is properly translated by using Laravel's localization features (__('message.key')).
Asset Management: Consider organizing your assets (stylesheets, scripts) to handle both LTR and RTL styles effectively.
Testing: Test the interface thoroughly in both languages to ensure that the layout, alignment, and functionality work as expected.
If you prefer to switch languages without reloading the page (e.g., using AJAX or JavaScript), you'll need to:
Update the dir attribute dynamically using JavaScript:
function changeLanguage(lang) {
document.documentElement.lang = lang;
document.documentElement.dir = (lang === 'ar') ? 'rtl' : 'ltr';
// Load translations and update content dynamically
// This requires a JavaScript-based localization strategy
}
Handle translations on the client side, possibly using a JavaScript localization library.
Note: Implementing dynamic language switching without a page reload is more complex and requires additional setup to handle translations and content updates on the client side.
By following the steps above, you ensure that when a user switches between Arabic and English:
dir attribute) changes accordingly.This approach provides a seamless experience for users and ensures that your application supports both LTR and RTL languages effectively.
Let me know if you have any questions or need further assistance!
Not yet included in a published release.