Server : Apache System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64 User : tradze ( 1001) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/tradze/www/dev/storage/framework/views/ |
<?php $__env->startSection('title'); ?>
<?php echo $page_title; ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('css_page'); ?>
<link href="<?php echo e(asset('/themes/admin/assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.css')); ?>" rel="stylesheet">
<link href="<?php echo e(asset('/themes/admin/assets/global/plugins/bootstrap-timepicker/css/bootstrap-timepicker.min.css')); ?>" rel="stylesheet">
<?php $__env->stopSection(); ?>
<style>
.input-group.bootstrap-timepicker .form-control.time-error {
border-color: #e74c3c !important;
background-color: #fdecea !important;
color: #e74c3c !important;
}
</style>
<?php $__env->startSection('content'); ?>
<?php
use Carbon\Carbon;
function formatTo12Hour($time24) {
if (!$time24) return '';
$format = strlen($time24) === 5 ? 'H:i' : 'H:i:s';
try {
return Carbon::createFromFormat($format, $time24)->format('h:i A');
} catch (\Exception $e) {
return '';
}
}
?>
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<i class="fa fa-home"></i>
<a href="#">Home</a>
<i class="fa fa-angle-right"></i>
</li>
<li><a href="#">Dynamic Pricing</a></li>
</ul>
</div>
<?php echo $__env->make('flash::message', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<div class="row">
<div class="col-md-12">
<div class="portlet">
<div class="portlet-title">
<div class="caption">
<i class="icon-calendar"></i> Working Days Pricing
</div>
</div>
<div class="portlet-body">
<form method="POST" action="<?php echo e(route('admin.schedules.dynamic.pricing.update')); ?>">
<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th width="12%">Day</th>
<th width="18%">From</th>
<th width="18%">Until</th>
<th width="12%">Price</th>
<th width="10%">%</th>
<th width="15%">Tradze Commission</th>
<th width="15%">Provider Commission</th>
<th width="10%">Action</th>
</tr>
</thead>
<tbody>
<?php /* DEFAULT ROW */ ?>
<?php if(isset($prices['Default'])): ?>
<?php foreach($prices['Default'] as $slot): ?>
<tr class="default-row bg-info">
<td><strong>Default</strong></td>
<td colspan="2" class="text-center">
<em>Used when no slot matches</em>
</td>
<td>
<input type="number" step="0.01"
name="default[price]"
class="form-control default-price"
value="<?php echo e($slot->price); ?>">
</td>
<?php /* FIXED */ ?>
<td>
<input type="number" step="0.01" min="0" max="100"
name="default[percentage]"
class="form-control default-percentage"
value="<?php echo e($slot->percentage ?? ''); ?>">
</td>
<td>
<input type="number" step="0.01"
name="default[tradze_commission]"
class="form-control default-tradze"
value="<?php echo e($slot->tradze_co ?? ''); ?>"
readonly>
</td>
<td>
<input type="number" step="0.01"
name="default[provider_commission]"
class="form-control default-provider"
value="<?php echo e($slot->provider_co ?? ''); ?>"
readonly>
</td>
<td class="text-center">
<span class="label label-info">Fixed</span>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php /* WEEK DAYS */ ?>
<?php foreach($prices as $day => $slots): ?>
<?php if($day != "Default"): ?>
<?php /* DAY HEADER ALWAYS VISIBLE */ ?>
<tr class="day-header bg-light" data-day="<?php echo e($day); ?>">
<td><strong><?php echo e($day); ?></strong></td>
<td colspan="6" class="text-center">
<em class="text-muted">Slots for <?php echo e($day); ?></em>
</td>
<td class="text-center">
<button type="button" class="btn btn-success add-slot">
<i class="fa fa-plus"></i>
</button>
</td>
</tr>
<?php /* SLOT ROWS */ ?>
<?php foreach($slots as $index => $slot): ?>
<tr class="pricing-row" data-day="<?php echo e($day); ?>">
<td></td>
<?php /* FROM */ ?>
<td>
<div class="input-group bootstrap-timepicker">
<input type="text"
name="pricing[<?php echo e($day); ?>][<?php echo e($index); ?>][from]"
class="form-control timepicker from-time"
value="<?php echo e(formatTo12Hour($slot->time_start)); ?>"
readonly>
<span class="input-group-addon">
<i class="fa fa-clock-o"></i>
</span>
</div>
</td>
<?php /* UNTIL */ ?>
<td>
<div class="input-group bootstrap-timepicker">
<input type="text"
name="pricing[<?php echo e($day); ?>][<?php echo e($index); ?>][to]"
class="form-control timepicker to-time"
value="<?php echo e(formatTo12Hour($slot->time_end)); ?>"
readonly>
<span class="input-group-addon">
<i class="fa fa-clock-o"></i>
</span>
</div>
</td>
<?php /* PRICE */ ?>
<td>
<input type="number" step="0.01"
name="pricing[<?php echo e($day); ?>][<?php echo e($index); ?>][price]"
class="form-control price-input"
value="<?php echo e($slot->price); ?>">
</td>
<?php /* FIXED PERCENTAGE */ ?>
<td>
<input type="number" step="0.01"
name="pricing[<?php echo e($day); ?>][<?php echo e($index); ?>][percentage]"
class="form-control percentage-input"
value="<?php echo e($slot->percentage ?? ''); ?>">
</td>
<?php /* COMMISSIONS */ ?>
<td>
<input type="number"
class="form-control tradze-commission"
value="<?php echo e($slot->tradze_co ?? ''); ?>"
readonly>
</td>
<td>
<input type="number"
class="form-control provider-commission"
value="<?php echo e($slot->provider_co ?? ''); ?>"
readonly>
</td>
<?php /* REMOVE SLOT */ ?>
<td class="text-center">
<button type="button" class="btn btn-danger remove-slot">
<i class="fa fa-times"></i>
</button>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
<button type="submit" class="btn btn-primary">
Save Pricing
</button>
</form>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts_page_plugins'); ?>
<script src="<?php echo e(asset('/themes/admin/assets/global/plugins/bootstrap-timepicker/js/bootstrap-timepicker.min.js')); ?>"></script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts_custom2'); ?>
<script>
function initTimepicker(context = document) {
$(context).find('.timepicker').timepicker({
autoclose: true,
minuteStep: 5,
showSeconds: false,
defaultTime: false
});
}
function timeToMinutes(time) {
let [t, modifier] = time.split(" ");
let [h, m] = t.split(":").map(Number);
if (modifier === "PM" && h < 12) h += 12;
if (modifier === "AM" && h === 12) h = 0;
return h * 60 + m;
}
function minutesToTime(minutes) {
let h = Math.floor(minutes / 60);
let m = minutes % 60;
let ampm = h >= 12 ? "PM" : "AM";
h = h % 12 || 12;
return `${String(h).padStart(2,"0")}:${String(m).padStart(2,"0")} ${ampm}`;
}
$(document).ready(function() {
initTimepicker();
// ADD SLOT ALWAYS WORKS
$(document).on("click", ".add-slot", function() {
let day = $(this).closest("tr").data("day");
let rows = $('tr.pricing-row[data-day="' + day + '"]');
let index = rows.length;
let startMin = 540;
let endMin = 600;
if (rows.length > 0) {
let lastTo = rows.last().find(".to-time").val();
startMin = timeToMinutes(lastTo);
endMin = startMin + 60;
}
let newRow = `
<tr class="pricing-row" data-day="${day}">
<td></td>
<td>
<div class="input-group bootstrap-timepicker">
<input type="text"
name="pricing[${day}][${index}][from]"
class="form-control timepicker from-time"
value="${minutesToTime(startMin)}"
readonly>
<span class="input-group-addon">
<i class="fa fa-clock-o"></i>
</span>
</div>
</td>
<td>
<div class="input-group bootstrap-timepicker">
<input type="text"
name="pricing[${day}][${index}][to]"
class="form-control timepicker to-time"
value="${minutesToTime(endMin)}"
readonly>
<span class="input-group-addon">
<i class="fa fa-clock-o"></i>
</span>
</div>
</td>
<td>
<input type="number" step="0.01"
name="pricing[${day}][${index}][price]"
class="form-control price-input">
</td>
<td>
<input type="number" step="0.01"
name="pricing[${day}][${index}][percentage]"
class="form-control percentage-input">
</td>
<td>
<input type="number"
class="form-control tradze-commission"
readonly>
</td>
<td>
<input type="number"
class="form-control provider-commission"
readonly>
</td>
<td class="text-center">
<button type="button" class="btn btn-danger remove-slot">
<i class="fa fa-times"></i>
</button>
</td>
</tr>
`;
if (rows.length > 0) {
rows.last().after(newRow);
} else {
$('tr.day-header[data-day="' + day + '"]').after(newRow);
}
initTimepicker();
});
// REMOVE SLOT EVEN LAST SLOT
$(document).on("click", ".remove-slot", function() {
$(this).closest("tr").remove();
});
// CALCULATE COMMISSION PER SLOT
function calculateSlotCommission(row) {
let price = parseFloat(row.find(".price-input").val()) || 0;
let percentage = parseFloat(row.find(".percentage-input").val()) || 0;
let tradze = (price * percentage) / 100;
let provider = price - tradze;
row.find(".tradze-commission").val(tradze.toFixed(2));
row.find(".provider-commission").val(provider.toFixed(2));
}
// LIVE CALCULATION WHEN USER TYPES
$(document).on("input", ".price-input, .percentage-input", function() {
let row = $(this).closest("tr");
calculateSlotCommission(row);
});
// CALCULATE DEFAULT ROW ALSO
function calculateDefaultCommission() {
let price = parseFloat($(".default-price").val()) || 0;
let percentage = parseFloat($(".default-percentage").val()) || 0;
let tradze = (price * percentage) / 100;
let provider = price - tradze;
$(".default-tradze").val(tradze.toFixed(2));
$(".default-provider").val(provider.toFixed(2));
}
// LIVE DEFAULT CALCULATION
$(document).on("input", ".default-price, .default-percentage", function() {
calculateDefaultCommission();
});
// AUTO-CALCULATE EXISTING ROWS ON PAGE LOAD
$(".pricing-row").each(function() {
calculateSlotCommission($(this));
});
calculateDefaultCommission();
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>