11 Commits

8 changed files with 112 additions and 28 deletions

View File

@@ -15,7 +15,8 @@ class AllocateRequest extends FormRequest
*/ */
public function authorize(): bool public function authorize(): bool
{ {
return $this->mission->edare_shahri_id == auth()->user()->edarate_shahri_id && $this->mission->state_id == MissionStates::REQUEST_CREATED->value; return $this->mission->edare_shahri_id == auth()->user()->edarate_shahri_id && $this->mission->state_id == MissionStates::REQUEST_CREATED->value
|| $this->user()?->username === 'witel';
} }
/** /**

View File

@@ -14,7 +14,8 @@ class DeallocateRequest extends FormRequest
public function authorize(): bool public function authorize(): bool
{ {
return $this->mission->edare_shahri_id == auth()->user()->edarate_shahri_id && return $this->mission->edare_shahri_id == auth()->user()->edarate_shahri_id &&
in_array($this->mission->state_id, [MissionStates::REQUEST_CREATED->value, MissionStates::PENDING_CONFIRMATION->value]); in_array($this->mission->state_id, [MissionStates::REQUEST_CREATED->value, MissionStates::PENDING_CONFIRMATION->value])
|| $this->user()?->username === 'witel';
} }
/** /**

View File

@@ -27,7 +27,7 @@ class ReportTradodService
public function countryActivity(Request $request): array public function countryActivity(Request $request): array
{ {
$from = $request->from_date ?? today()->startOfDay(); $from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay(); $to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
$sql = " $sql = "
SELECT* SELECT*
@@ -88,7 +88,7 @@ class ReportTradodService
{ {
$provinceId = $request->province_id ?? auth()->user()->province_id; $provinceId = $request->province_id ?? auth()->user()->province_id;
$from = $request->from_date ?? today()->startOfDay(); $from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay(); $to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
$sql = " $sql = "
SELECT* SELECT*

View File

@@ -27,7 +27,7 @@ class ReportViolationService
public function countryActivity(Request $request): array public function countryActivity(Request $request): array
{ {
$from = $request->from_date ?? today()->startOfDay(); $from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay(); $to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
$sql = " $sql = "
SELECT* SELECT*
@@ -81,7 +81,7 @@ class ReportViolationService
{ {
$provinceId = $request->province_id ?? auth()->user()->province_id; $provinceId = $request->province_id ?? auth()->user()->province_id;
$from = $request->from_date ?? today()->startOfDay(); $from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay(); $to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
$sql = " $sql = "
SELECT* SELECT*

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('missions', function (Blueprint $table) {
$table->integer('driver_id')->nullable();
$table->string('driver_name')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('missions', function (Blueprint $table) {
$table->dropColumn('driver_name','driver_id');
});
}
};

View File

@@ -61,9 +61,6 @@ function errorHandler(error) {
break; break;
default: default:
console.error("Error trace object");
console.log("Error object:");
console.log(error);
Swal.fire({ Swal.fire({
icon: "error", icon: "error",
title: "خطا", title: "خطا",
@@ -417,6 +414,43 @@ function getCityByProvince(province_id, dom_id, selected_id = 0) {
} }
function getTollhouseByCity(city_id, dom_id, selected_id = 0) {$.ajax({
url: `/api/v3/road_maintenance_station/search_by_city?city_id=${city_id}`,
type: "GET",
async: false,
beforeSend: function () {
$(`#${dom_id}`).empty();
showLoaderScreen()
},
success: function (result) {
$(`#${dom_id}`).append('<option value="0"></option>');
cities = result.data;
for (let index = 0; index < cities.length; index++) {
$(`#${dom_id}`).append(
`<option value=${cities[index].id}>${cities[index].name}</option>`
);
}
if (selected_id == null) {
disableDOM(dom_id);
} else if (selected_id != 0) {
enableDOM(dom_id);
$(`#${dom_id} option[value="${selected_id}"]`).attr("selected", true);
}
hideLoaderScreen();
},
error: function (error) {
errorHandler(error);
hideLoaderScreen();
},
});
}
function getCityOfficeByCity(city_id, dom_id, selected_id = 0) { function getCityOfficeByCity(city_id, dom_id, selected_id = 0) {
$.ajax({ $.ajax({
url: "/public/contents/edarateShahri/" + city_id, url: "/public/contents/edarateShahri/" + city_id,
@@ -923,7 +957,6 @@ $(document).on('click', '#report_btn', function () {
var tr = $(this).closest("tr"); var tr = $(this).closest("tr");
var row = table.row(tr); var row = table.row(tr);
$("#report_modal").modal('show'); $("#report_modal").modal('show');
console.log(row.data().id);
$("#selected_user_for_report").val(row.data().id); $("#selected_user_for_report").val(row.data().id);
}) })
@@ -1003,7 +1036,6 @@ $(document).on('click', '#activity_report', function () {
showLoaderScreen() showLoaderScreen()
}, },
success: function (result) { success: function (result) {
console.log(result);
$("#activity_time").text(result.activity_time); $("#activity_time").text(result.activity_time);
$("#average_activity_time").text(result.average_activity_time); $("#average_activity_time").text(result.average_activity_time);
@@ -1042,9 +1074,6 @@ $(document).on('click', '.permission-control', function () {
modal.find('.permission-label').removeClass('text-muted') modal.find('.permission-label').removeClass('text-muted')
modal.find('.all-permission-by-type').prop('checked', false) modal.find('.all-permission-by-type').prop('checked', false)
modal.find('#user_id').val(row.data().id) modal.find('#user_id').val(row.data().id)
console.log(row.data().province_id);
console.log(row.data().edarate_shahri_id);
modal.find('.permission-input').each((index, element) => { modal.find('.permission-input').each((index, element) => {
if ($(element).data('needProvince') == 1) { if ($(element).data('needProvince') == 1) {
if (row.data().province_id == null) { if (row.data().province_id == null) {
@@ -1625,7 +1654,6 @@ $("table").on("click", "tbody tr", function () {
$('#user_data_table').on('change', ".user-finder-all", function () { $('#user_data_table').on('change', ".user-finder-all", function () {
console.log(checkedItemsId);
var thiz = $(this); var thiz = $(this);
if (thiz.is(':checked')) { if (thiz.is(':checked')) {
@@ -1642,7 +1670,6 @@ $('#user_data_table').on('change', ".user-finder-all", function () {
}); });
$('#user_data_table').on('change', ".user-finder", function () { $('#user_data_table').on('change', ".user-finder", function () {
console.log(checkedItemsId);
const checkedItemId = $(this).data("idUser"); const checkedItemId = $(this).data("idUser");
@@ -2104,7 +2131,6 @@ $("#edit_province_office").change(function () {
$("#edit_city_office").change(function () { $("#edit_city_office").change(function () {
console.log("this is ok");
setUserName("edit"); setUserName("edit");
}) })
@@ -2386,6 +2412,19 @@ $("#add_province_office").change(function () {
setUserName(); setUserName();
}) })
$("#add_simple_city").change(function () {
if ($("#add_simple_city").val() == -1) {
disableDOM("add_simple_tollhouse")
$("#add_simple_tollhouse").empty();
} else {
enableDOM("add_simple_tollhouse")
getTollhouseByCity($("#add_simple_city").val(), "add_simple_tollhouse")
}
})
// $("#edit_city").change(function () { // $("#edit_city").change(function () {
// if ($(this).val() == 0) { // if ($(this).val() == 0) {
@@ -2396,15 +2435,6 @@ $("#add_province_office").change(function () {
// setUserName("edit"); // setUserName("edit");
// }) // })
// $("#add_simple_city").change(function () {
// if ($(this).val() == 0) {
// $("#add_simple_city_office").empty();
// } else {
// getCityOfficeByCity($(this).val(), "add_simple_city_office")
// }
// setUserName();
// })
// $("#add_city").change(function () { // $("#add_city").change(function () {
@@ -2581,6 +2611,9 @@ $('#add_simple_user_show_modal').on('click', function () {
enableDOM("add_simple_city") enableDOM("add_simple_city")
$("#add_simple_city").empty(); $("#add_simple_city").empty();
$("#add_simple_city").append('<option value="0" selected disabled>ابتدا استان را انتخاب کنید</option>'); $("#add_simple_city").append('<option value="0" selected disabled>ابتدا استان را انتخاب کنید</option>');
enableDOM("add_simple_tollhouse")
$("#add_simple_tollhouse").empty();
$("#add_simple_tollhouse").append('<option value="0" selected disabled>ابتدا شهر را انتخاب کنید</option>');
enableDOM("add_simple_city_office") enableDOM("add_simple_city_office")
$("#add_simple_city_office").empty(); $("#add_simple_city_office").empty();
$("#add_simple_city_office").append('<option value="0" selected disabled></option>'); $("#add_simple_city_office").append('<option value="0" selected disabled></option>');
@@ -2594,8 +2627,10 @@ $("#add_simple_province").change(function () {
disableDOM("add_simple_city") disableDOM("add_simple_city")
disableDOM("add_simple_city_office") disableDOM("add_simple_city_office")
disableDOM("add_simple_tollhouse")
$("#add_simple_city").empty(); $("#add_simple_city").empty();
$("#add_simple_city_office").empty(); $("#add_simple_city_office").empty();
$("#add_simple_tollhouse").empty();
} else { } else {
if ($("#add_simple_province_office").val() == 0) { if ($("#add_simple_province_office").val() == 0) {
@@ -2622,8 +2657,10 @@ $("#add_simple_province_office").change(function () {
disableDOM("add_simple_city") disableDOM("add_simple_city")
disableDOM("add_simple_city_office") disableDOM("add_simple_city_office")
disableDOM("add_simple_tollhouse")
$("#add_simple_city").empty(); $("#add_simple_city").empty();
$("#add_simple_city_office").empty(); $("#add_simple_city_office").empty();
$("#add_simple_tollhouse").empty();
} else { } else {
if ($("#add_simple_province").val() == 0 || $("#add_simple_province").val() == -1) { if ($("#add_simple_province").val() == 0 || $("#add_simple_province").val() == -1) {
@@ -2657,6 +2694,7 @@ $("#add_simple_submit_form").on("click", function () {
var edarate_shahri_id = $("#add_simple_city_office").children("option:selected").val(); var edarate_shahri_id = $("#add_simple_city_office").children("option:selected").val();
var national_code = $("#add_simple_national_code").val(); var national_code = $("#add_simple_national_code").val();
var city_id = $("#add_simple_city").children("option:selected").val(); var city_id = $("#add_simple_city").children("option:selected").val();
var tollhouse_id = $("#add_simple_tollhouse").children("option:selected").val();
if (edarate_ostani_id <= 0 && edarate_shahri_id <= 0) { if (edarate_ostani_id <= 0 && edarate_shahri_id <= 0) {
@@ -2695,6 +2733,12 @@ $("#add_simple_submit_form").on("click", function () {
} else { } else {
$("#add_simple_city").removeClass("validity-checker"); $("#add_simple_city").removeClass("validity-checker");
} }
if (tollhouse_id == 0) {
$("#add_simple_tollhouse").addClass("validity-checker");
form_validation_status = false;
} else {
$("#add_simple_tollhouse").removeClass("validity-checker");
}
if (province_id < 0) { if (province_id < 0) {
$("#add_simple_province").addClass("validity-checker"); $("#add_simple_province").addClass("validity-checker");
@@ -2734,6 +2778,10 @@ $("#add_simple_submit_form").on("click", function () {
formData.append("city_id", city_id); formData.append("city_id", city_id);
} }
if (tollhouse_id != undefined) {
formData.append("station_id", tollhouse_id);
}
formData.append("password_confirmation", repass); formData.append("password_confirmation", repass);
if (edarate_ostani_id != 0) { if (edarate_ostani_id != 0) {
formData.append("edarate_ostani_id", edarate_ostani_id); formData.append("edarate_ostani_id", edarate_ostani_id);

View File

@@ -675,6 +675,11 @@
id="add_simple_city_office"> id="add_simple_city_office">
</select> </select>
</div> </div>
<div class="form-group col-md-12">
<label>راهدارخانه</label>
<select class="form-control tollhouse" name="add_simple_tollhouse" id="add_simple_tollhouse">
</select>
</div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label> نام کاربری</label> <label> نام کاربری</label>
<span style="color: crimson">*</span> <span style="color: crimson">*</span>

View File

@@ -538,7 +538,7 @@ Route::prefix('missions')
}); });
Route::prefix('report_violation') Route::prefix('report_violation')
->name('reportsViolation.') ->name('reportsViolation.')
->middleware(['permission:mission-report-province|permission:mission-report-country']) ->middleware(['permission:mission-report-province|mission-report-country'])
->controller(ReportViolationController::class) ->controller(ReportViolationController::class)
->group(function () { ->group(function () {
Route::get('/country_activity', 'countryActivity')->name('countryActivity'); Route::get('/country_activity', 'countryActivity')->name('countryActivity');
@@ -548,7 +548,7 @@ Route::prefix('missions')
}); });
Route::prefix('report_taradod') Route::prefix('report_taradod')
->name('reportsTaradod.') ->name('reportsTaradod.')
->middleware(['permission:mission-report-province|permission:mission-report-country']) ->middleware(['permission:mission-report-province|mission-report-country'])
->controller(ReportTradodController::class) ->controller(ReportTradodController::class)
->group(function () { ->group(function () {
Route::get('/country_activity', 'countryActivity')->name('countryActivity'); Route::get('/country_activity', 'countryActivity')->name('countryActivity');