| Current Path : /var/www/html/crm/views/rider/ |
| Current File : /var/www/html/crm/views/rider/index2.php |
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use app\models\Menu;
use app\models\ParamList;
use app\models\StockDelivery;
use app\models\DeliveryOrder;
use yii\widgets\ActiveForm;
$Menu = new Menu();
$this->title = 'Manage Rider Wages : ' . $modelRider->name;
$this->registerCss('.table-custom tbody td{vertical-align:top !important;}');
?>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
<div class="kt-subheader kt-grid__item" id="kt_subheader">
<div class="kt-container kt-container--fluid ">
<div class="kt-subheader__main">
<h3 class="kt-subheader__title"><?= $this->title ?></h3>
<div class="kt-subheader__breadcrumbs">
<?= $Menu->getbreadcrumbs($menu_id, ''); ?>
<span class="kt-subheader__breadcrumbs-separator"></span><span class="kt-subheader__breadcrumbs-link"><?= $this->title ?></span>
</div>
</div>
</div>
</div>
<div class="kt-container kt-grid__item kt-grid__item--fluid">
<p></p>
<div class="kt-portlet kt-portlet--mobile">
<div class="kt-portlet__head">
<div class="mt-4" style="width:100%;">
<?php $form = ActiveForm::begin(['action' => ['index2', 'year' => $year, 'type' => Yii::$app->getRequest()->getQueryParam('type'), 'rider_id' => Yii::$app->getRequest()->getQueryParam('rider_id')], 'method' => 'get', 'options' => ['class' => 'kt-form kt-form--label-right']]); ?>
<div class="row">
<div class="col-sm-4"><?php echo $form->field($searchModel, 'receiver_search')->textInput(['class' => 'form-control', 'placeholder' => 'Receiver details (eg: company, name, address)'])->label(false); ?></div>
<div class="col-sm-4"><?php echo $form->field($searchModel, 'do_search')->textInput(['class' => 'form-control', 'placeholder' => 'DO Number'])->label(false); ?></div>
<div class="col-sm-4">
<?= Html::submitButton('Search', ['class' => 'btn btn-brand']) ?>
<?= Html::a('Reset', ['index2', 'year' => $year, 'type' => Yii::$app->getRequest()->getQueryParam('type'), 'rider_id' => Yii::$app->getRequest()->getQueryParam('rider_id')], ['class' => 'btn btn-outline-brand']) ?>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalWages">
Add Wages
</button>
<?= Html::a('Back to rider list', ['index'], ['class' => 'btn btn-warning']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
<div class="kt-portlet__body p-0" style="position:relative;">
<div class="pl-4 pt-4"><i class="fas fa-info-circle"></i> Data will update automatically when you change the value for Wages Amount(RM) or Wages Status</div>
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'tableOptions' => ['class' => 'table table-bordered mb-0 table-striped table-hover table-custom'],
'pager' => [
'firstPageLabel' => '<i class="fa fa-angle-double-left kt-font-brand"></i>',
'lastPageLabel' => '<i class="fa fa-angle-double-right kt-font-brand"></i>',
'prevPageLabel' => '<i class="fa fa-angle-left kt-font-brand"></i>',
'nextPageLabel' => '<i class="fa fa-angle-right kt-font-brand"></i>',
'maxButtonCount' => 3,
'options' => ['tag' => 'ul', 'class' => 'kt-pagination--brand kt-pagination__links p-3',],
'activePageCssClass' => 'kt-pagination__link--active',
'prevPageCssClass' => 'kt-pagination__link--prev',
'nextPageCssClass' => 'kt-pagination__link--next',
'firstPageCssClass' => 'kt-pagination__link--first',
'lastPageCssClass' => 'kt-pagination__link--last',
],
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
'headerOptions' => ['class' => 'text-center', 'width' => '1%'],
'contentOptions' => ['class' => 'text-center'],
],
[
'headerOptions' => ['width' => '30%'],
'header' => 'Receiver Details',
'format' => 'raw',
'value' => function ($model) {
$ParamList = new ParamList();
$output = '<div class="row">';
$output .= '<div class="col-1 text-center"><i class="fas fa-building"></i></div><div class="col-11">' . $model->company_name . '</div>';
$output .= '<div class="col-1 text-center"><i class="fas fa-info-circle"></i></div><div class="col-11">' . $model->industry . '</div>';
$output .= '<div class="col-1 text-center"><i class="fas fa-user"></i></div><div class="col-11">' . $model->customer_name . '</div>';
$output .= '<div class="col-1 text-center"><i class="fas fa-phone"></i></div><div class="col-11">' . $model->customer_phone . '</div>';
$output .= '<div class="col-1 text-center"><i class="fas fa-map-marker-alt"></i></div><div class="col-11">' . $model->customer_address1 . ' ' .
$model->customer_address2 . ' ' .
$model->customer_address3 . ' ' .
$model->customer_postcode . ' ' .
$model->customer_city . ' ' . $ParamList->getlabel(3, $model->customer_state) . '</div>';
$output .= '</div>';
return $output;
}
],
[
'header' => 'Delivery Details',
'format' => 'raw',
'value' => function ($model) {
$ParamList = new ParamList();
$output = '';
if (($modelDO = DeliveryOrder::findOne($model->do_id)) !== null) {
$output .= Html::a($modelDO->doc_no, Url::to(['deliveryorder/downloadfromdelivery', 'uuid' => $modelDO->uuid]), ['target' => '_blank',]);
}
if (!empty($model->delivery_date))
$output .= '<div class="row"><div class="col-sm-1 text-center"><i class="fas fa-calendar"></i></div><div class="col-sm-10">' . date("d M Y", strtotime($model->delivery_date)) . '</div></div>';
if (!empty($model->tracking_no))
$output .= '<div class="row"><div class="col-sm-1 text-center"><i class="fas fa-file"></i></div><div class="col-sm-10">' . $model->tracking_no . ' ' . Html::a('<i class="fas fa-info-circle"></i>', ['stockdelivery/view', 'uuid' => $model->uuid]) . '</div></div>';
return $output;
}
],
[
'header' => 'Delivery Status',
'format' => 'raw',
'value' => function ($model) {
$ParamList = new ParamList();
return $ParamList->getlabel(46, $model->delivery_status) . ' ' . Html::a('<i class="fas fa-edit"></i>', ['stockdelivery/update', 'uuid' => $model->uuid]);
}
],
[
'headerOptions' => ['width' => '15%'],
'header' => 'Wages Amount(RM)',
'format' => 'raw',
'value' => function ($model) {
return Html::dropDownList('rider_wages_status_' . $model->id, $model->rider_wages_status,
['pending' => 'Pending', 'paid' => 'Paid'],
['class' => 'form-control', 'onchange' => "updatedata(" . $model->id . ",'rider_wages_status',this.value)"]);
}
],
[
'headerOptions' => ['width' => '15%'],
'header' => 'Wages Status',
'format' => 'raw',
'value' => function ($model) {
return Html::textInput('rider_wages_amount_' . $model->id, $model->rider_wages_amount,
['class' => 'form-control', 'onchange' => "updatedata(" . $model->id . ",'rider_wages_amount',this.value)"]);
}
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Action',
'headerOptions' => ['class' => 'text-center'],
'contentOptions' => ['class' => 'text-center text-nowrap'],
'template' => '{delete}',
'buttons' => [
'delete' => function ($url, $model) {
return '<span title="Delete" class="btn btn-danger btn-sm" style="cursor:pointer;" onclick="deletedata(' . $model->id . ')"><i class="far fa-trash-alt pr-0"></i>';
},
],
],
],
]);
?>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="modalWages" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Wages</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Please insert the DO Number to add the job to this rider wages
<input type="text" class="form-control" id="do_number" placeholder="Example : BLU/DO/22/00754">
<input type="hidden" class="form-control" id="rider_id" value="<?= $_GET['rider_id'] ?>">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="addwages()">Add Wages</button>
</div>
</div>
</div>
</div>
<?php $this->registerJs(""); ?>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<script>
function addwages() {
var do_number = $('#do_number').val();
var rider_id = $('#rider_id').val();
if (do_number === '') {
alert('Please insert the DO Number to continue');
} else {
$.ajax({
url: "index.php?r=stockdelivery/addwages",
method: "POST",
data: {"do_number": do_number, "rider_id": rider_id},
success: function (response) {
//alert(response);
if (response === 'success') {
swal.fire({
position: 'center-center',
type: 'success',
title: 'Your data has been added',
showConfirmButton: false,
timer: 1500, }).then(function (result) {
location.reload();
});
} else {
swal.fire({
position: 'center-center',
type: 'error',
title: 'Delivery Order not found. Please try again',
showConfirmButton: false,
timer: 1500, }).then(function (result) {
location.reload();
});
}
},
});
}
}
function deletedata(id) {
Swal.fire({
title: 'Are you sure to delete this data?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.value) {
$.ajax({
url: "index.php?r=stockdelivery/deletewages",
method: "POST",
data: {"id": id},
success: function (response) {
if (response === 'success') {
swal.fire({
position: 'center-center',
type: 'success',
title: 'Your data has been deleted',
showConfirmButton: false,
timer: 1500, }).then(function (result) {
location.reload();
});
}
},
});
}
}
)
}
function updatedata(delivery_id, type, val) {
$.ajax({
url: "index.php?r=stockdelivery/updateforrider",
method: "GET",
data: {"delivery_id": delivery_id, "type": type, "val": val},
success: function (response) {
if (response === 'success') {
Toastify({
text: "Data has been updated",
duration: 3000,
style: {background: "#18a899", },
offset: {
x: 20,
y: 30
},
}).showToast();
} else {
Toastify({
text: "Data failed to update",
duration: 3000,
style: {background: "#fd1361", },
offset: {
x: 20,
y: 30
},
}).showToast();
}
},
});
}
</script>