Files
Global-Jain/app/Traits/ActionButtons.php
2025-11-05 10:37:10 +05:30

163 lines
5.5 KiB
PHP

<?php
namespace App\Traits;
use Carbon\Carbon;
/**
* Trait ActionButtons
* @package App\Traits
*/
trait ActionButtons
{
/**
* @param int $status
* @return string
*/
protected function statusLabel(int $status): string
{
if ($status === 0) {
return '<span class="label label-lg label-light-danger label-inline">' . __('label.inactive') . '</span>';
} else {
return '<span class="label label-lg label-light-success label-inline">' . __('label.active') . '</span>';
}
}
/**
* @param int $status
* @return string
*/
protected function dropdownAction(): string
{
return view('backend.tender.partials._table_action');
}
/**
* @param string $route
* @param string $title
* @return string
*/
protected function editButton(string $route, string $title): string
{
return '<a href="' . $route . '" class="btn btn-icon btn-light btn-hover-primary btn-sm btn-clean mr-3" title="' . $title . '"><i class="fa fa-pencil-alt icon-md"></i></a>';
}
/**
* @param int $id
* @param string $title
* @return string
*/
protected function deleteButton(int $id, string $title): string
{
return '<a href="javascript:void(0);" data-id="' . $id . '" class="btn btn-icon btn-light btn-hover-primary btn-sm delete-confirmation mr-3" title="' . $title . '"><i class="fa fa-trash icon-md"></i></a>';
}
/**
* @param string $route
* @param string $title
* @return string
*/
protected function chaturmasListButton(string $route, string $title): string
{
return '<a href="' . $route . '" class="btn btn-icon btn-light btn-hover-primary btn-sm btn-clean mr-3" title="' . $title . '"><i class="fa fa-praying-hands icon-md"></i></a>';
}
/**
* @param string $route
* @param string $title
* @return string
*/
protected function chaturmasPendingListButton(string $route, string $title): string
{
return '<a href="' . $route . '" class="notification-dot btn btn-icon btn-light btn-hover-primary btn-sm btn-clean mr-3" title="' . $title . '"><i class="fa fa-praying-hands icon-md"></i></a>';
}
/**
* @param int $status
* @return string
*/
protected function publishLabel(int $status): string
{
if ($status === 0) {
return '<span class="label label-lg label-light-danger label-inline">' . __('label.no') . '</span>';
} else {
return '<span class="label label-lg label-light-success label-inline">' . __('label.yes') . '</span>';
}
}
/**
* @param string $text
* @param string $title
* @return string
*/
protected function readMessageInPopup(string $text, string $title): string
{
return '<a href="javascript:void(0);" data-text="' . htmlentities($text) . '" class="btn btn-icon btn-light btn-hover-primary btn-sm btn-clean mr-3 read-description" title="' . $title . '"><i class="fa fa-eye"></i></a>';
}
/**
* @param object $record
* @return string
*/
protected function checkboxAction(object $record): string
{
return '<span style="width: 20px;">
<label class="checkbox checkbox-single">
<input type="checkbox" name="checkbox_action[]" value="' . $record->id . '" class="check-record" id="record-' . $record->id . '">&nbsp;<span></span>
</label>
</span>';
}
/**
* @param object $record
* @return string
*/
protected function santCheckboxAction(object $record): string
{
return '<span style="width: 20px;">
<label class="checkbox checkbox-single">
<input type="checkbox" name="checkbox_action[]" value="' . $record->sant_id . '" class="check-record" id="record-' . $record->sant_id . '">&nbsp;<span></span>
</label>
</span>';
}
/**
* @param int $status
* @return string
*/
protected function highlightsDateLabel(string $date): string
{
$currentDate = date('Y-m-d', strtotime(Carbon::now()));
$columnDate = date('Y-m-d', strtotime($date));
if ($columnDate == $currentDate) {
return '<span style="color:red">' . defaultDateTimeFormat($date) . '</span>';
} elseif ($columnDate >= $currentDate) {
return '<span style="color:green">' . defaultDateTimeFormat($date) . '</span>';
} elseif ($columnDate <= $currentDate) {
return '<span style="color:gray">' . defaultDateTimeFormat($date) . '</span>';
}
}
/**
* @param string $route
* @param string $title
* @return string
*/
protected function viewButton(string $route, string $title): string
{
return '<a href="' . $route . '" class="btn btn-icon btn-light btn-hover-primary btn-sm btn-clean mr-3" title="' . $title . '"><i class="fa fa-eye fa-md"></i></a>';
}
protected function requestStatusLabel(int $status): string
{
if ($status === 0) {
return '<span class="label label-lg label-light-warning label-inline">' . __('label.in_review') . '</span>';
} elseif ($status === 1) {
return '<span class="label label-lg label-light-success label-inline">' . __('label.approved') . '</span>';
} else {
return '<span class="label label-lg label-light-danger label-inline">' . __('label.rejected') . '</span>';
}
}
}