diff --git a/app/Console/Commands/RoadObservationProblems.php b/app/Console/Commands/RoadObservationProblems.php index 3c2b3201..d56da6bb 100755 --- a/app/Console/Commands/RoadObservationProblems.php +++ b/app/Console/Commands/RoadObservationProblems.php @@ -2,6 +2,11 @@ namespace App\Console\Commands; +use App\Enums\NikarayanComplaints; +use App\Services\NikarayanService; +use App\Services\NominatimService; +use Exception; +use Illuminate\Support\Facades\Log; use SoapFault; use SoapClient; use Illuminate\Console\Command; @@ -38,15 +43,14 @@ class RoadObservationProblems extends Command parent::__construct(); } - /** - * Execute the console command. - * - * @return mixed - */ - public function handle() + /** + * Execute the console command. + * + * @return int|string + * @throws Exception + */ + public function handle(NikarayanService $nikarayanService, NominatimService $nominatimService) { - ////// TODO bayad ba date ham az 1 bahman ye darkhast bedim data koli biad - $url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl"; // try { // $soap_client = new SoapClient($url); // $result = $soap_client->Get_RoadObservedProblems_Current(array('strUserName' => 'vaytelrop', 'strPassword' => 'VaYtelROP*2024')); @@ -58,37 +62,10 @@ class RoadObservationProblems extends Command // // self::sms_sender('09367487107', $msg); // return 0; // } - // echo $v->year = 1395; - // echo "hi\n"; - $v = verta(); // 1396-03-14 14:18:23 - $month = $v->month; - $day = $v->day; - if ($v->month < 10) - $month = '0' . $v->month; - if ($v->day < 10) - $day = '0' . $v->day; - $date = $v->year . $month . $day; - // dd($date); - try { - $soap_client = new SoapClient($url); - $result = $soap_client->Get_RoadObservedProblems_ByDate(array( - 'strUserName' => 'vaytelrop', - 'strPassword' => 'VaYtelROP*2024', - 'strStartDate' => $date, - 'strEndDate' => $date - )); - } catch (SoapFault $e) { - echo $e->getMessage(); - $msg = 'rms: error in get road observation webservice babe!!!!' . "\n"; - $msg .= $e->getMessage(); - // self::sms_sender('09398586633', $msg); - // self::sms_sender('09367487107', $msg); - return 0; - } + $result = $nikarayanService->getRoadObservedProblemsByDate(); + $result = serialize($result); - // return $result; - // dd($result); $x = strpos($result, ' 1, - "57" => 2, - "91" => 3, - "21" => 4, - "18" => 5, - //"83" => 6, - "83" => 7, - "95" => 8, - "11" => 9, - "77" => 10, - "33" => 11, - "31" => 12, - "32" => 13, - "36" => 14, - "67" => 15, - //"26" => 16, - "87" => 17, - "61" => 18, - "41" => 19, - "15" => 20, - "14" => 21, - "73" => 22, - "45" => 23, - //"26" => 24, - "71" => 25, - "85" => 26, - "97" => 27, - "54" => 28, - //"26" => 29, - "81" => 30, - "16" => 31, - "51" => 32, - "64" => 33, - "75" => 34, - "93" => 35, - ]; - - $rmsCityId = [ - 1 => [ - "OnvarID" => 1, - "CityName" => "گمیشان", - "ProvinceID" => "97", - "InvarID" => 353 - ], - 2 => [ - "OnvarID" => 2, - "CityName" => "آق قلا", - "ProvinceID" => "97", - "InvarID" => 13 - ], - 3 => [ - "OnvarID" => 3, - "CityName" => "رامیان", - "ProvinceID" => "97", - "InvarID" => 194 - ], - 4 => [ - "OnvarID" => 4, - "CityName" => "آزادشهر", - "ProvinceID" => "97", - "InvarID" => 8 - ], - 5 => [ - "OnvarID" => 5, - "CityName" => "مینو دشت", - "ProvinceID" => "97", - "InvarID" => 401 - ], - 6 => [ - "OnvarID" => 6, - "CityName" => "گالیكش", - "ProvinceID" => "97", - "InvarID" => 343 - ], - 7 => [ - "OnvarID" => 7, - "CityName" => "علی آباد", - "ProvinceID" => "97", - "InvarID" => 282 - ], - 8 => [ - "OnvarID" => 8, - "CityName" => "گرگان", - "ProvinceID" => "97", - "InvarID" => 347 - ], - 9 => [ - "OnvarID" => 9, - "CityName" => "كردكوی", - "ProvinceID" => "97", - "InvarID" => 324 - ], - 10 => [ - "OnvarID" => 10, - "CityName" => "بندرگز", - "ProvinceID" => "97", - "InvarID" => 80 - ], - 11 => [ - "OnvarID" => 11, - "CityName" => "تركمن", - "ProvinceID" => "97", - "InvarID" => 112 - ], - 12 => [ - "OnvarID" => 12, - "CityName" => "گنبدكاووس", - "ProvinceID" => "97", - "InvarID" => 356 - ], - 13 => [ - "OnvarID" => 13, - "CityName" => "كلاله", - "ProvinceID" => "97", - "InvarID" => 329 - ], - 14 => [ - "OnvarID" => 14, - "CityName" => "مراوه تپه", - "ProvinceID" => "97", - "InvarID" => 374 - ], - 15 => [ - "OnvarID" => 15, - "CityName" => "آستارا", - "ProvinceID" => "54", - "InvarID" => 9 - ], - 16 => [ - "OnvarID" => 16, - "CityName" => "طوالش", - "ProvinceID" => "54", - "InvarID" => 278 - ], - 17 => [ - "OnvarID" => 17, - "CityName" => "رضوانشهر", - "ProvinceID" => "54", - "InvarID" => 201 - ], - 18 => [ - "OnvarID" => 18, - "CityName" => "ماسال", - "ProvinceID" => "54", - "InvarID" => 366 - ], - 19 => [ - "OnvarID" => 19, - "CityName" => "بندر انزلی", - "ProvinceID" => "54", - "InvarID" => 76 - ], - 20 => [ - "OnvarID" => 20, - "CityName" => "صومعه سرا", - "ProvinceID" => "54", - "InvarID" => 274 - ], - 21 => [ - "OnvarID" => 21, - "CityName" => "فومن", - "ProvinceID" => "54", - "InvarID" => 300 - ], - 22 => [ - "OnvarID" => 22, - "CityName" => "شفت", - "ProvinceID" => "54", - "InvarID" => 260 - ], - 23 => [ - "OnvarID" => 23, - "CityName" => "املش", - "ProvinceID" => "54", - "InvarID" => 40 - ], - 24 => [ - "OnvarID" => 24, - "CityName" => "رودسر", - "ProvinceID" => "54", - "InvarID" => 207 - ], - 25 => [ - "OnvarID" => 25, - "CityName" => "آستانه اشرفیه", - "ProvinceID" => "54", - "InvarID" => 10 - ], - 26 => [ - "OnvarID" => 26, - "CityName" => "لاهیجان", - "ProvinceID" => "54", - "InvarID" => 361 - ], - 27 => [ - "OnvarID" => 27, - "CityName" => "رشت", - "ProvinceID" => "54", - "InvarID" => 199 - ], - 28 => [ - "OnvarID" => 28, - "CityName" => "سیاهكل", - "ProvinceID" => "54", - "InvarID" => 248 - ], - 29 => [ - "OnvarID" => 29, - "CityName" => "لنگرود", - "ProvinceID" => "54", - "InvarID" => 365 - ], - 30 => [ - "OnvarID" => 30, - "CityName" => "رودبار", - "ProvinceID" => "54", - "InvarID" => 205 - ], - 31 => [ - "OnvarID" => 31, - "CityName" => "آباده", - "ProvinceID" => "41", - "InvarID" => 2 - ], - 32 => [ - "OnvarID" => 32, - "CityName" => "ممسنی", - "ProvinceID" => "41", - "InvarID" => 385 - ], - 33 => [ - "OnvarID" => 33, - "CityName" => "سپیدان", - "ProvinceID" => "41", - "InvarID" => 225 - ], - 34 => [ - "OnvarID" => 34, - "CityName" => "رستم", - "ProvinceID" => "41", - "InvarID" => 198 - ], - 35 => [ - "OnvarID" => 35, - "CityName" => "پاسارگاد", - "ProvinceID" => "41", - "InvarID" => 99 - ], - 36 => [ - "OnvarID" => 36, - "CityName" => "بوانات", - "ProvinceID" => "41", - "InvarID" => 89 - ], - 37 => [ - "OnvarID" => 37, - "CityName" => "خرم بید", - "ProvinceID" => "41", - "InvarID" => 149 - ], - 38 => [ - "OnvarID" => 38, - "CityName" => "اقلید", - "ProvinceID" => "41", - "InvarID" => 37 - ], - 39 => [ - "OnvarID" => 39, - "CityName" => "كازرون", - "ProvinceID" => "41", - "InvarID" => 318 - ], - 40 => [ - "OnvarID" => 40, - "CityName" => "سروستان", - "ProvinceID" => "41", - "InvarID" => 237 - ], - 41 => [ - "OnvarID" => 41, - "CityName" => "كوار", - "ProvinceID" => "41", - "InvarID" => 337 - ], - 42 => [ - "OnvarID" => 42, - "CityName" => "خرامه", - "ProvinceID" => "41", - "InvarID" => 147 - ], - 43 => [ - "OnvarID" => 43, - "CityName" => "شیراز", - "ProvinceID" => "41", - "InvarID" => 270 - ], - 44 => [ - "OnvarID" => 44, - "CityName" => "مرودشت", - "ProvinceID" => "41", - "InvarID" => 376 - ], - 45 => [ - "OnvarID" => 45, - "CityName" => "ارسنجان", - "ProvinceID" => "41", - "InvarID" => 25 - ], - 46 => [ - "OnvarID" => 46, - "CityName" => "نی ریز", - "ProvinceID" => "41", - "InvarID" => 414 - ], - 47 => [ - "OnvarID" => 47, - "CityName" => "فراشبند", - "ProvinceID" => "41", - "InvarID" => 288 - ], - 48 => [ - "OnvarID" => 48, - "CityName" => "جهرم", - "ProvinceID" => "41", - "InvarID" => 127 - ], - 49 => [ - "OnvarID" => 49, - "CityName" => "قیر و كارزین", - "ProvinceID" => "41", - "InvarID" => 316 - ], - 50 => [ - "OnvarID" => 50, - "CityName" => "فیروز آباد", - "ProvinceID" => "41", - "InvarID" => 301 - ], - 51 => [ - "OnvarID" => 51, - "CityName" => "داراب", - "ProvinceID" => "41", - "InvarID" => 165 - ], - 52 => [ - "OnvarID" => 52, - "CityName" => "زرین دشت", - "ProvinceID" => "41", - "InvarID" => 216 - ], - 53 => [ - "OnvarID" => 53, - "CityName" => "مهر", - "ProvinceID" => "41", - "InvarID" => 3 - ], - 54 => [ - "OnvarID" => 54, - "CityName" => "خنج", - "ProvinceID" => "41", - "InvarID" => 390 - ], - 55 => [ - "OnvarID" => 55, - "CityName" => "لامرد", - "ProvinceID" => "41", - "InvarID" => 360 - ], - 56 => [ - "OnvarID" => 56, - "CityName" => "گراش", - "ProvinceID" => "41", - "InvarID" => 346 - ], - 57 => [ - "OnvarID" => 57, - "CityName" => "لارستان", - "ProvinceID" => "41", - "InvarID" => 358 - ], - 58 => [ - "OnvarID" => 58, - "CityName" => "فسا", - "ProvinceID" => "41", - "InvarID" => 296 - ], - 59 => [ - "OnvarID" => 59, - "CityName" => "استهبان", - "ProvinceID" => "41", - "InvarID" => 28 - ], - 60 => [ - "OnvarID" => 60, - "CityName" => "آران و بیدگل", - "ProvinceID" => "21", - "InvarID" => 7 - ], - 61 => [ - "OnvarID" => 61, - "CityName" => "بوئین و میان دشت", - "ProvinceID" => "21", - "InvarID" => 88 - ], - 62 => [ - "OnvarID" => 62, - "CityName" => "خوانسار", - "ProvinceID" => "21", - "InvarID" => 160 - ], - 63 => [ - "OnvarID" => 63, - "CityName" => "گلپایگان", - "ProvinceID" => "21", - "InvarID" => 351 - ], - 64 => [ - "OnvarID" => 64, - "CityName" => "اردستان", - "ProvinceID" => "21", - "InvarID" => 21 - ], - 65 => [ - "OnvarID" => 65, - "CityName" => "كاشان", - "ProvinceID" => "21", - "InvarID" => 319 - ], - 66 => [ - "OnvarID" => 66, - "CityName" => "خور و بیابانك", - "ProvinceID" => "21", - "InvarID" => 161 - ], - 67 => [ - "OnvarID" => 67, - "CityName" => "چادگان", - "ProvinceID" => "21", - "InvarID" => 133 - ], - 68 => [ - "OnvarID" => 68, - "CityName" => "فریدن", - "ProvinceID" => "21", - "InvarID" => 292 - ], - 69 => [ - "OnvarID" => 69, - "CityName" => "فریدون شهر", - "ProvinceID" => "21", - "InvarID" => 293 - ], - 70 => [ - "OnvarID" => 70, - "CityName" => "شهرضا", - "ProvinceID" => "21", - "InvarID" => 263 - ], - 71 => [ - "OnvarID" => 71, - "CityName" => "مباركه", - "ProvinceID" => "21", - "InvarID" => 370 - ], - 72 => [ - "OnvarID" => 72, - "CityName" => "لنجان", - "ProvinceID" => "21", - "InvarID" => 363 - ], - 73 => [ - "OnvarID" => 73, - "CityName" => "اصفهان", - "ProvinceID" => "21", - "InvarID" => 36 - ], - 74 => [ - "OnvarID" => 74, - "CityName" => "فلاورجان", - "ProvinceID" => "21", - "InvarID" => 297 - ], - 75 => [ - "OnvarID" => 75, - "CityName" => "نجف آباد", - "ProvinceID" => "21", - "InvarID" => 403 - ], - 76 => [ - "OnvarID" => 76, - "CityName" => "خمینی شهر", - "ProvinceID" => "21", - "InvarID" => 156 - ], - 77 => [ - "OnvarID" => 77, - "CityName" => "تیران و كرون", - "ProvinceID" => "21", - "InvarID" => 120 - ], - 78 => [ - "OnvarID" => 78, - "CityName" => "برخوار", - "ProvinceID" => "21", - "InvarID" => 64 - ], - 79 => [ - "OnvarID" => 79, - "CityName" => "نائین", - "ProvinceID" => "21", - "InvarID" => 402 - ], - 80 => [ - "OnvarID" => 80, - "CityName" => "سمیرم", - "ProvinceID" => "21", - "InvarID" => 243 - ], - 81 => [ - "OnvarID" => 81, - "CityName" => "دهاقان", - "ProvinceID" => "21", - "InvarID" => 181 - ], - 82 => [ - "OnvarID" => 82, - "CityName" => "نطنز", - "ProvinceID" => "21", - "InvarID" => 405 - ], - 83 => [ - "OnvarID" => 83, - "CityName" => "شاهین شهر و میمه", - "ProvinceID" => "21", - "InvarID" => 258 - ], - 84 => [ - "OnvarID" => 84, - "CityName" => "مراغه", - "ProvinceID" => "26", - "InvarID" => 373 - ], - 85 => [ - "OnvarID" => 85, - "CityName" => "خدا آفرین", - "ProvinceID" => "26", - "InvarID" => 145 - ], - 86 => [ - "OnvarID" => 86, - "CityName" => "جلفا", - "ProvinceID" => "26", - "InvarID" => 125 - ], - 87 => [ - "OnvarID" => 87, - "CityName" => "شبستر", - "ProvinceID" => "26", - "InvarID" => 259 - ], - 88 => [ - "OnvarID" => 88, - "CityName" => "مرند", - "ProvinceID" => "26", - "InvarID" => 375 - ], - 89 => [ - "OnvarID" => 89, - "CityName" => "تبریز", - "ProvinceID" => "26", - "InvarID" => 109 - ], - 90 => [ - "OnvarID" => 90, - "CityName" => "ورزقان", - "ProvinceID" => "26", - "InvarID" => 429 - ], - 91 => [ - "OnvarID" => 91, - "CityName" => "اهر", - "ProvinceID" => "26", - "InvarID" => 45 - ], - 92 => [ - "OnvarID" => 92, - "CityName" => "كلیبر", - "ProvinceID" => "26", - "InvarID" => 330 - ], - 93 => [ - "OnvarID" => 93, - "CityName" => "اسكو", - "ProvinceID" => "26", - "InvarID" => 31 - ], - 94 => [ - "OnvarID" => 94, - "CityName" => "آذرشهر", - "ProvinceID" => "26", - "InvarID" => 5 - ], - 95 => [ - "OnvarID" => 95, - "CityName" => "عجب شیر", - "ProvinceID" => "26", - "InvarID" => 280 - ], - 96 => [ - "OnvarID" => 96, - "CityName" => "بناب", - "ProvinceID" => "26", - "InvarID" => 75 - ], - 97 => [ - "OnvarID" => 97, - "CityName" => "ملكان", - "ProvinceID" => "26", - "InvarID" => 383 - ], - 98 => [ - "OnvarID" => 98, - "CityName" => "بستان آباد", - "ProvinceID" => "26", - "InvarID" => 69 - ], - 99 => [ - "OnvarID" => 99, - "CityName" => "سراب", - "ProvinceID" => "26", - "InvarID" => 226 - ], - 100 => [ - "OnvarID" => 100, - "CityName" => "هشترود", - "ProvinceID" => "26", - "InvarID" => 422 - ], - 101 => [ - "OnvarID" => 101, - "CityName" => "میانه", - "ProvinceID" => "26", - "InvarID" => 397 - ], - 102 => [ - "OnvarID" => 102, - "CityName" => "چاراویماق", - "ProvinceID" => "26", - "InvarID" => 134 - ], - 103 => [ - "OnvarID" => 103, - "CityName" => "هریس", - "ProvinceID" => "26", - "InvarID" => 421 - ], - 104 => [ - "OnvarID" => 104, - "CityName" => "هوراند", - "ProvinceID" => "26", - "InvarID" => 109 - ], - 105 => [ - "OnvarID" => 105, - "CityName" => "كیار", - "ProvinceID" => "77", - "InvarID" => 342 - ], - 106 => [ - "OnvarID" => 106, - "CityName" => "فارسان", - "ProvinceID" => "77", - "InvarID" => 284 - ], - 107 => [ - "OnvarID" => 107, - "CityName" => "كوهرنگ", - "ProvinceID" => "77", - "InvarID" => 341 - ], - 108 => [ - "OnvarID" => 108, - "CityName" => "لردگان", - "ProvinceID" => "77", - "InvarID" => 362 - ], - 109 => [ - "OnvarID" => 109, - "CityName" => "اردل", - "ProvinceID" => "77", - "InvarID" => 23 - ], - 110 => [ - "OnvarID" => 110, - "CityName" => "بروجن", - "ProvinceID" => "77", - "InvarID" => 68 - ], - 111 => [ - "OnvarID" => 111, - "CityName" => "سامان", - "ProvinceID" => "77", - "InvarID" => 221 - ], - 112 => [ - "OnvarID" => 112, - "CityName" => "بن", - "ProvinceID" => "77", - "InvarID" => 74 - ], - 113 => [ - "OnvarID" => 113, - "CityName" => "شهركرد", - "ProvinceID" => "77", - "InvarID" => 264 - ], - 114 => [ - "OnvarID" => 114, - "CityName" => "دیلم", - "ProvinceID" => "95", - "InvarID" => 187 - ], - 115 => [ - "OnvarID" => 115, - "CityName" => "گناوه", - "ProvinceID" => "95", - "InvarID" => 395 - ], - 116 => [ - "OnvarID" => 116, - "CityName" => "دشتستان", - "ProvinceID" => "95", - "InvarID" => 174 - ], - 117 => [ - "OnvarID" => 117, - "CityName" => "دشتی", - "ProvinceID" => "95", - "InvarID" => 175 - ], - 118 => [ - "OnvarID" => 118, - "CityName" => "بوشهر", - "ProvinceID" => "95", - "InvarID" => 90 - ], - 119 => [ - "OnvarID" => 119, - "CityName" => "تنگستان", - "ProvinceID" => "95", - "InvarID" => 117 - ], - 120 => [ - "OnvarID" => 120, - "CityName" => "دیر", - "ProvinceID" => "95", - "InvarID" => 186 - ], - 121 => [ - "OnvarID" => 121, - "CityName" => "جم", - "ProvinceID" => "95", - "InvarID" => 126 - ], - 122 => [ - "OnvarID" => 122, - "CityName" => "كنگان", - "ProvinceID" => "95", - "InvarID" => 333 - ], - 123 => [ - "OnvarID" => 123, - "CityName" => "عسلویه", - "ProvinceID" => "95", - "InvarID" => 281 - ], - 124 => [ - "OnvarID" => 124, - "CityName" => "مهران", - "ProvinceID" => "83", - "InvarID" => 391 - ], - 125 => [ - "OnvarID" => 125, - "CityName" => "ایلام", - "ProvinceID" => "83", - "InvarID" => 50 - ], - 126 => [ - "OnvarID" => 126, - "CityName" => "ایوان", - "ProvinceID" => "83", - "InvarID" => 51 - ], - 127 => [ - "OnvarID" => 127, - "CityName" => "دره شهر", - "ProvinceID" => "83", - "InvarID" => 171 - ], - 128 => [ - "OnvarID" => 128, - "CityName" => "ملكشاهی", - "ProvinceID" => "83", - "InvarID" => 384 - ], - 129 => [ - "OnvarID" => 129, - "CityName" => "سیروان", - "ProvinceID" => "83", - "InvarID" => 251 - ], - 130 => [ - "OnvarID" => 130, - "CityName" => "بدره", - "ProvinceID" => "83", - "InvarID" => 63 - ], - 131 => [ - "OnvarID" => 131, - "CityName" => "چرداول", - "ProvinceID" => "71", - "InvarID" => 139 - ], - 132 => [ - "OnvarID" => 132, - "CityName" => "دهلران", - "ProvinceID" => "83", - "InvarID" => 183 - ], - 133 => [ - "OnvarID" => 133, - "CityName" => "آبدانان", - "ProvinceID" => "83", - "InvarID" => 3 - ], - 134 => [ - "OnvarID" => 134, - "CityName" => "راور", - "ProvinceID" => "45", - "InvarID" => 195 - ], - 135 => [ - "OnvarID" => 135, - "CityName" => "كوهبنان", - "ProvinceID" => "45", - "InvarID" => 339 - ], - 136 => [ - "OnvarID" => 136, - "CityName" => "شهر بابك", - "ProvinceID" => "45", - "InvarID" => 262 - ], - 137 => [ - "OnvarID" => 137, - "CityName" => "انار", - "ProvinceID" => "45", - "InvarID" => 42 - ], - 138 => [ - "OnvarID" => 138, - "CityName" => "رفسنجان", - "ProvinceID" => "45", - "InvarID" => 202 - ], - 139 => [ - "OnvarID" => 139, - "CityName" => "زرند", - "ProvinceID" => "45", - "InvarID" => 214 - ], - 140 => [ - "OnvarID" => 140, - "CityName" => "كرمان", - "ProvinceID" => "45", - "InvarID" => 325 - ], - 141 => [ - "OnvarID" => 141, - "CityName" => "رابر", - "ProvinceID" => "45", - "InvarID" => 189 - ], - 142 => [ - "OnvarID" => 142, - "CityName" => "بافت", - "ProvinceID" => "45", - "InvarID" => 57 - ], - 143 => [ - "OnvarID" => 143, - "CityName" => "سیرجان", - "ProvinceID" => "45", - "InvarID" => 250 - ], - 144 => [ - "OnvarID" => 144, - "CityName" => "بردسیر", - "ProvinceID" => "45", - "InvarID" => 66 - ], - 145 => [ - "OnvarID" => 145, - "CityName" => "ارزوئیه", - "ProvinceID" => "45", - "InvarID" => 24 - ], - 146 => [ - "OnvarID" => 146, - "CityName" => "ریگان", - "ProvinceID" => "45", - "InvarID" => 210 - ], - 147 => [ - "OnvarID" => 147, - "CityName" => "فهرج", - "ProvinceID" => "45", - "InvarID" => 299 - ], - 148 => [ - "OnvarID" => 148, - "CityName" => "نرماشیر", - "ProvinceID" => "45", - "InvarID" => 404 - ], - 149 => [ - "OnvarID" => 149, - "CityName" => "منوجان", - "ProvinceID" => "45", - "InvarID" => 386 - ], - 150 => [ - "OnvarID" => 150, - "CityName" => "قلعه گنج", - "ProvinceID" => "45", - "InvarID" => 313 - ], - 151 => [ - "OnvarID" => 151, - "CityName" => "كهنوج", - "ProvinceID" => "45", - "InvarID" => 336 - ], - 152 => [ - "OnvarID" => 152, - "CityName" => "فاریاب", - "ProvinceID" => "45", - "InvarID" => 286 - ], - 153 => [ - "OnvarID" => 153, - "CityName" => "رودبار جنوب", - "ProvinceID" => "45", - "InvarID" => 205 - ], - 154 => [ - "OnvarID" => 154, - "CityName" => "عنبرآباد", - "ProvinceID" => "45", - "InvarID" => 283 - ], - 155 => [ - "OnvarID" => 155, - "CityName" => "جیرفت", - "ProvinceID" => "45", - "InvarID" => 131 - ], - 156 => [ - "OnvarID" => 156, - "CityName" => "بم", - "ProvinceID" => "45", - "InvarID" => 73 - ], - 157 => [ - "OnvarID" => 157, - "CityName" => "گیلانغرب", - "ProvinceID" => "71", - "InvarID" => 357 - ], - 158 => [ - "OnvarID" => 158, - "CityName" => "دالاهو", - "ProvinceID" => "71", - "InvarID" => 166 - ], - 159 => [ - "OnvarID" => 159, - "CityName" => "قصر شیرین", - "ProvinceID" => "71", - "InvarID" => 311 - ], - 160 => [ - "OnvarID" => 160, - "CityName" => "سر پل ذهاب", - "ProvinceID" => "71", - "InvarID" => 231 - ], - 161 => [ - "OnvarID" => 161, - "CityName" => "ثلاث باباجانی", - "ProvinceID" => "71", - "InvarID" => 121 - ], - 162 => [ - "OnvarID" => 162, - "CityName" => "جوانرود", - "ProvinceID" => "71", - "InvarID" => 128 - ], - 163 => [ - "OnvarID" => 163, - "CityName" => "اسلام آباد غرب", - "ProvinceID" => "71", - "InvarID" => 32 - ], - 164 => [ - "OnvarID" => 164, - "CityName" => "هرسین", - "ProvinceID" => "71", - "InvarID" => 420 - ], - 165 => [ - "OnvarID" => 165, - "CityName" => "كنگاور", - "ProvinceID" => "71", - "InvarID" => 334 - ], - 166 => [ - "OnvarID" => 166, - "CityName" => "روانسر", - "ProvinceID" => "71", - "InvarID" => 203 - ], - 167 => [ - "OnvarID" => 167, - "CityName" => "سنقر", - "ProvinceID" => "71", - "InvarID" => 244 - ], - 168 => [ - "OnvarID" => 168, - "CityName" => "صحنه", - "ProvinceID" => "71", - "InvarID" => 272 - ], - 169 => [ - "OnvarID" => 169, - "CityName" => "پاوه", - "ProvinceID" => "71", - "InvarID" => 101 - ], - 170 => [ - "OnvarID" => 170, - "CityName" => "كرمانشاه", - "ProvinceID" => "71", - "InvarID" => 326 - ], - 171 => [ - "OnvarID" => 171, - "CityName" => "قوچان", - "ProvinceID" => "31", - "InvarID" => 315 - ], - 172 => [ - "OnvarID" => 172, - "CityName" => "درگز", - "ProvinceID" => "31", - "InvarID" => 169 - ], - 173 => [ - "OnvarID" => 173, - "CityName" => "داورزن", - "ProvinceID" => "31", - "InvarID" => 168 - ], - 174 => [ - "OnvarID" => 174, - "CityName" => "سبزوار", - "ProvinceID" => "31", - "InvarID" => 224 - ], - 175 => [ - "OnvarID" => 175, - "CityName" => "خوشاب", - "ProvinceID" => "31", - "InvarID" => 163 - ], - 176 => [ - "OnvarID" => 176, - "CityName" => "جغتای", - "ProvinceID" => "31", - "InvarID" => 124 - ], - 177 => [ - "OnvarID" => 177, - "CityName" => "جوین", - "ProvinceID" => "31", - "InvarID" => 130 - ], - 178 => [ - "OnvarID" => 178, - "CityName" => "مشهد", - "ProvinceID" => "31", - "InvarID" => 380 - ], - 179 => [ - "OnvarID" => 179, - "CityName" => "بینالود", - "ProvinceID" => "31", - "InvarID" => 96 - ], - 180 => [ - "OnvarID" => 180, - "CityName" => "نیشابور", - "ProvinceID" => "31", - "InvarID" => 416 - ], - 181 => [ - "OnvarID" => 181, - "CityName" => "فیروزه", - "ProvinceID" => "31", - "InvarID" => 303 - ], - 182 => [ - "OnvarID" => 182, - "CityName" => "چناران", - "ProvinceID" => "31", - "InvarID" => 140 - ], - 183 => [ - "OnvarID" => 183, - "CityName" => "كلات", - "ProvinceID" => "31", - "InvarID" => 327 - ], - 184 => [ - "OnvarID" => 184, - "CityName" => "سرخس", - "ProvinceID" => "31", - "InvarID" => 232 - ], - 185 => [ - "OnvarID" => 185, - "CityName" => "كاشمر", - "ProvinceID" => "31", - "InvarID" => 320 - ], - 186 => [ - "OnvarID" => 186, - "CityName" => "خلیل آباد", - "ProvinceID" => "31", - "InvarID" => 153 - ], - 187 => [ - "OnvarID" => 187, - "CityName" => "مه ولایت", - "ProvinceID" => "31", - "InvarID" => 387 - ], - 188 => [ - "OnvarID" => 188, - "CityName" => "تربت حیدریه", - "ProvinceID" => "31", - "InvarID" => 111 - ], - 189 => [ - "OnvarID" => 189, - "CityName" => "زاوه", - "ProvinceID" => "31", - "InvarID" => 213 - ], - 190 => [ - "OnvarID" => 190, - "CityName" => "فریمان", - "ProvinceID" => "31", - "InvarID" => 295 - ], - 191 => [ - "OnvarID" => 191, - "CityName" => "تربت جام", - "ProvinceID" => "31", - "InvarID" => 110 - ], - 192 => [ - "OnvarID" => 192, - "CityName" => "بردسكن", - "ProvinceID" => "31", - "InvarID" => 65 - ], - 193 => [ - "OnvarID" => 193, - "CityName" => "بجستان", - "ProvinceID" => "31", - "InvarID" => 61 - ], - 194 => [ - "OnvarID" => 194, - "CityName" => "گناباد", - "ProvinceID" => "31", - "InvarID" => 354 - ], - 195 => [ - "OnvarID" => 195, - "CityName" => "رشتخوار", - "ProvinceID" => "31", - "InvarID" => 200 - ], - 196 => [ - "OnvarID" => 196, - "CityName" => "خواف", - "ProvinceID" => "31", - "InvarID" => 159 - ], - 197 => [ - "OnvarID" => 197, - "CityName" => "تایباد", - "ProvinceID" => "31", - "InvarID" => 108 - ], - 198 => [ - "OnvarID" => 198, - "CityName" => "باخرز", - "ProvinceID" => "31", - "InvarID" => 54 - ], - 199 => [ - "OnvarID" => 199, - "CityName" => "فردوس", - "ProvinceID" => "33", - "InvarID" => 290 - ], - 200 => [ - "OnvarID" => 200, - "CityName" => "طبس", - "ProvinceID" => "33", - "InvarID" => 277 - ], - 201 => [ - "OnvarID" => 201, - "CityName" => "بشرویه", - "ProvinceID" => "33", - "InvarID" => 72 - ], - 202 => [ - "OnvarID" => 202, - "CityName" => "سرایان", - "ProvinceID" => "33", - "InvarID" => 228 - ], - 203 => [ - "OnvarID" => 203, - "CityName" => "قائنات", - "ProvinceID" => "33", - "InvarID" => 305 - ], - 204 => [ - "OnvarID" => 204, - "CityName" => "زیركوه", - "ProvinceID" => "33", - "InvarID" => 219 - ], - 205 => [ - "OnvarID" => 205, - "CityName" => "سربیشه", - "ProvinceID" => "33", - "InvarID" => 230 - ], - 206 => [ - "OnvarID" => 206, - "CityName" => "خوسف", - "ProvinceID" => "33", - "InvarID" => 162 - ], - 207 => [ - "OnvarID" => 207, - "CityName" => "بیرجند", - "ProvinceID" => "33", - "InvarID" => 94 - ], - 208 => [ - "OnvarID" => 208, - "CityName" => "درمیان", - "ProvinceID" => "33", - "InvarID" => 170 - ], - 209 => [ - "OnvarID" => 209, - "CityName" => "نهبندان", - "ProvinceID" => "33", - "InvarID" => 411 - ], - 210 => [ - "OnvarID" => 210, - "CityName" => "شوشتر", - "ProvinceID" => "36", - "InvarID" => 268 - ], - 211 => [ - "OnvarID" => 211, - "CityName" => "اندیكا", - "ProvinceID" => "36", - "InvarID" => 43 - ], - 212 => [ - "OnvarID" => 212, - "CityName" => "لالی", - "ProvinceID" => "36", - "InvarID" => 359 - ], - 213 => [ - "OnvarID" => 213, - "CityName" => "گتوند", - "ProvinceID" => "36", - "InvarID" => 344 - ], - 214 => [ - "OnvarID" => 214, - "CityName" => "شوش", - "ProvinceID" => "36", - "InvarID" => 267 - ], - 215 => [ - "OnvarID" => 215, - "CityName" => "اندیمشك", - "ProvinceID" => "36", - "InvarID" => 44 - ], - 216 => [ - "OnvarID" => 216, - "CityName" => "دزفول", - "ProvinceID" => "36", - "InvarID" => 172 - ], - 217 => [ - "OnvarID" => 217, - "CityName" => "كارون", - "ProvinceID" => "36", - "InvarID" => 317 - ], - 218 => [ - "OnvarID" => 218, - "CityName" => "هویزه", - "ProvinceID" => "36", - "InvarID" => 426 - ], - 219 => [ - "OnvarID" => 219, - "CityName" => "حمیدیه", - "ProvinceID" => "36", - "InvarID" => 142 - ], - 220 => [ - "OnvarID" => 220, - "CityName" => "باوی", - "ProvinceID" => "36", - "InvarID" => 60 - ], - 221 => [ - "OnvarID" => 221, - "CityName" => "دشت آزادگان", - "ProvinceID" => "36", - "InvarID" => 173 - ], - 222 => [ - "OnvarID" => 222, - "CityName" => "مسجد سلیمان", - "ProvinceID" => "36", - "InvarID" => 378 - ], - 223 => [ - "OnvarID" => 223, - "CityName" => "هفتگل", - "ProvinceID" => "36", - "InvarID" => 423 - ], - 224 => [ - "OnvarID" => 224, - "CityName" => "رامهرمز", - "ProvinceID" => "36", - "InvarID" => 193 - ], - 225 => [ - "OnvarID" => 225, - "CityName" => "باغ ملك", - "ProvinceID" => "36", - "InvarID" => 56 - ], - 226 => [ - "OnvarID" => 226, - "CityName" => "ایذه", - "ProvinceID" => "36", - "InvarID" => 48 - ], - 227 => [ - "OnvarID" => 227, - "CityName" => "شادگان", - "ProvinceID" => "36", - "InvarID" => 254 - ], - 228 => [ - "OnvarID" => 228, - "CityName" => "رامشیر", - "ProvinceID" => "36", - "InvarID" => 192 - ], - 229 => [ - "OnvarID" => 229, - "CityName" => "هندیجان", - "ProvinceID" => "36", - "InvarID" => 425 - ], - 230 => [ - "OnvarID" => 230, - "CityName" => "بهبهان", - "ProvinceID" => "36", - "InvarID" => 84 - ], - 231 => [ - "OnvarID" => 231, - "CityName" => "آغاجاری", - "ProvinceID" => "36", - "InvarID" => 12 - ], - 232 => [ - "OnvarID" => 232, - "CityName" => "امیدیه", - "ProvinceID" => "36", - "InvarID" => 41 - ], - 233 => [ - "OnvarID" => 233, - "CityName" => "آبادان", - "ProvinceID" => "36", - "InvarID" => 1 - ], - 234 => [ - "OnvarID" => 234, - "CityName" => "خرمشهر", - "ProvinceID" => "36", - "InvarID" => 151 - ], - 235 => [ - "OnvarID" => 235, - "CityName" => "اهواز", - "ProvinceID" => "36", - "InvarID" => 46 - ], - 236 => [ - "OnvarID" => 236, - "CityName" => "بندر ماهشهر", - "ProvinceID" => "36", - "InvarID" => 78 - ], - 237 => [ - "OnvarID" => 237, - "CityName" => "گچساران", - "ProvinceID" => "85", - "InvarID" => 345 - ], - 238 => [ - "OnvarID" => 238, - "CityName" => "بهمئی", - "ProvinceID" => "85", - "InvarID" => 86 - ], - 239 => [ - "OnvarID" => 239, - "CityName" => "كهگیلویه", - "ProvinceID" => "85", - "InvarID" => 335 - ], - 240 => [ - "OnvarID" => 240, - "CityName" => "چرام", - "ProvinceID" => "85", - "InvarID" => 138 - ], - 241 => [ - "OnvarID" => 241, - "CityName" => "لنده", - "ProvinceID" => "85", - "InvarID" => 364 - ], - 242 => [ - "OnvarID" => 242, - "CityName" => "باشت", - "ProvinceID" => "85", - "InvarID" => 55 - ], - 243 => [ - "OnvarID" => 243, - "CityName" => "بویراحمد", - "ProvinceID" => "85", - "InvarID" => 92 - ], - 244 => [ - "OnvarID" => 244, - "CityName" => "دنا", - "ProvinceID" => "85", - "InvarID" => 180 - ], - 245 => [ - "OnvarID" => 245, - "CityName" => "پارس آباد", - "ProvinceID" => "91", - "InvarID" => 97 - ], - 246 => [ - "OnvarID" => 246, - "CityName" => "گرمی", - "ProvinceID" => "91", - "InvarID" => 350 - ], - 247 => [ - "OnvarID" => 247, - "CityName" => "بیله سوار", - "ProvinceID" => "91", - "InvarID" => 95 - ], - 248 => [ - "OnvarID" => 248, - "CityName" => "مشگین شهر", - "ProvinceID" => "91", - "InvarID" => 379 - ], - 249 => [ - "OnvarID" => 249, - "CityName" => "نیر", - "ProvinceID" => "91", - "InvarID" => 415 - ], - 250 => [ - "OnvarID" => 250, - "CityName" => "نمین", - "ProvinceID" => "91", - "InvarID" => 409 - ], - 251 => [ - "OnvarID" => 251, - "CityName" => "اردبیل", - "ProvinceID" => "91", - "InvarID" => 20 - ], - 252 => [ - "OnvarID" => 252, - "CityName" => "سرعین", - "ProvinceID" => "91", - "InvarID" => 235 - ], - 253 => [ - "OnvarID" => 253, - "CityName" => "كوثر", - "ProvinceID" => "91", - "InvarID" => 338 - ], - 254 => [ - "OnvarID" => 254, - "CityName" => "خلخال", - "ProvinceID" => "91", - "InvarID" => 152 - ], - 255 => [ - "OnvarID" => 255, - "CityName" => "حاجی آباد", - "ProvinceID" => "64", - "InvarID" => 141 - ], - 256 => [ - "OnvarID" => 256, - "CityName" => "پارسیان", - "ProvinceID" => "64", - "InvarID" => 98 - ], - 257 => [ - "OnvarID" => 257, - "CityName" => "بستك", - "ProvinceID" => "64", - "InvarID" => 70 - ], - 258 => [ - "OnvarID" => 258, - "CityName" => "بندر عباس", - "ProvinceID" => "64", - "InvarID" => 79 - ], - 259 => [ - "OnvarID" => 259, - "CityName" => "میناب", - "ProvinceID" => "64", - "InvarID" => 400 - ], - 260 => [ - "OnvarID" => 260, - "CityName" => "رودان", - "ProvinceID" => "64", - "InvarID" => 204 - ], - 261 => [ - "OnvarID" => 261, - "CityName" => "بندر لنگه", - "ProvinceID" => "64", - "InvarID" => 77 - ], - 262 => [ - "OnvarID" => 262, - "CityName" => "خمیر", - "ProvinceID" => "64", - "InvarID" => 154 - ], - 263 => [ - "OnvarID" => 263, - "CityName" => "بشاگرد", - "ProvinceID" => "64", - "InvarID" => 71 - ], - 264 => [ - "OnvarID" => 264, - "CityName" => "سیریك", - "ProvinceID" => "64", - "InvarID" => 252 - ], - 265 => [ - "OnvarID" => 265, - "CityName" => "جاسك", - "ProvinceID" => "64", - "InvarID" => 123 - ], - 266 => [ - "OnvarID" => 266, - "CityName" => "ابوموسی", - "ProvinceID" => "NULL", - "InvarID" => 18 - ], - 267 => [ - "OnvarID" => 267, - "CityName" => "قشم", - "ProvinceID" => "64", - "InvarID" => 310 - ], - 268 => [ - "OnvarID" => 268, - "CityName" => "طالقان", - "ProvinceID" => "18", - "InvarID" => 276 - ], - 269 => [ - "OnvarID" => 269, - "CityName" => "اشتهارد", - "ProvinceID" => "18", - "InvarID" => 34 - ], - 270 => [ - "OnvarID" => 270, - "CityName" => "كرج", - "ProvinceID" => "18", - "InvarID" => 323 - ], - 271 => [ - "OnvarID" => 271, - "CityName" => "فردیس", - "ProvinceID" => "18", - "InvarID" => 291 - ], - 272 => [ - "OnvarID" => 272, - "CityName" => "ساوجبلاغ", - "ProvinceID" => "18", - "InvarID" => 222 - ], - 273 => [ - "OnvarID" => 273, - "CityName" => "نظر آباد", - "ProvinceID" => "18", - "InvarID" => 406 - ], - 274 => [ - "OnvarID" => 274, - "CityName" => "فامنین", - "ProvinceID" => "75", - "InvarID" => 287 - ], - 275 => [ - "OnvarID" => 275, - "CityName" => "كبودرآهنگ", - "ProvinceID" => "75", - "InvarID" => 322 - ], - 276 => [ - "OnvarID" => 276, - "CityName" => "رزن", - "ProvinceID" => "75", - "InvarID" => 197 - ], - 277 => [ - "OnvarID" => 277, - "CityName" => "ملایر", - "ProvinceID" => "75", - "InvarID" => 382 - ], - 278 => [ - "OnvarID" => 278, - "CityName" => "نهاوند", - "ProvinceID" => "75", - "InvarID" => 410 - ], - 279 => [ - "OnvarID" => 279, - "CityName" => "تویسركان", - "ProvinceID" => "75", - "InvarID" => 119 - ], - 280 => [ - "OnvarID" => 280, - "CityName" => "اسد آباد", - "ProvinceID" => "75", - "InvarID" => 29 - ], - 281 => [ - "OnvarID" => 281, - "CityName" => "همدان", - "ProvinceID" => "75", - "InvarID" => 424 - ], - 282 => [ - "OnvarID" => 282, - "CityName" => "بهار", - "ProvinceID" => "75", - "InvarID" => 82 - ], - 283 => [ - "OnvarID" => 283, - "CityName" => "سقز", - "ProvinceID" => "73", - "InvarID" => 238 - ], - 284 => [ - "OnvarID" => 284, - "CityName" => "سرو آباد", - "ProvinceID" => "73", - "InvarID" => 236 - ], - 285 => [ - "OnvarID" => 285, - "CityName" => "مریوان", - "ProvinceID" => "73", - "InvarID" => 377 - ], - 286 => [ - "OnvarID" => 286, - "CityName" => "بانه", - "ProvinceID" => "73", - "InvarID" => 59 - ], - 287 => [ - "OnvarID" => 287, - "CityName" => "قروه", - "ProvinceID" => "73", - "InvarID" => 308 - ], - 288 => [ - "OnvarID" => 288, - "CityName" => "دهگلان", - "ProvinceID" => "73", - "InvarID" => 182 - ], - 289 => [ - "OnvarID" => 289, - "CityName" => "سنندج", - "ProvinceID" => "73", - "InvarID" => 245 - ], - 290 => [ - "OnvarID" => 290, - "CityName" => "بیجار", - "ProvinceID" => "73", - "InvarID" => 93 - ], - 291 => [ - "OnvarID" => 291, - "CityName" => "دیواندره", - "ProvinceID" => "73", - "InvarID" => 188 - ], - 292 => [ - "OnvarID" => 292, - "CityName" => "كامیاران", - "ProvinceID" => "73", - "InvarID" => 321 - ], - 293 => [ - "OnvarID" => 293, - "CityName" => "دلفان", - "ProvinceID" => "81", - "InvarID" => 176 - ], - 294 => [ - "OnvarID" => 294, - "CityName" => "پل دختر", - "ProvinceID" => "81", - "InvarID" => 103 - ], - 295 => [ - "OnvarID" => 295, - "CityName" => "رومشكان", - "ProvinceID" => "81", - "InvarID" => 208 - ], - 296 => [ - "OnvarID" => 296, - "CityName" => "كوه دشت", - "ProvinceID" => "81", - "InvarID" => 340 - ], - 297 => [ - "OnvarID" => 297, - "CityName" => "دوره", - "ProvinceID" => "81", - "InvarID" => 184 - ], - 298 => [ - "OnvarID" => 298, - "CityName" => "خرم آباد", - "ProvinceID" => "81", - "InvarID" => 148 - ], - 299 => [ - "OnvarID" => 299, - "CityName" => "دورود", - "ProvinceID" => "81", - "InvarID" => 185 - ], - 300 => [ - "OnvarID" => 300, - "CityName" => "ازنا", - "ProvinceID" => "81", - "InvarID" => 27 - ], - 301 => [ - "OnvarID" => 301, - "CityName" => "سلسله", - "ProvinceID" => "81", - "InvarID" => 239 - ], - 302 => [ - "OnvarID" => 302, - "CityName" => "بروجرد", - "ProvinceID" => "81", - "InvarID" => 67 - ], - 303 => [ - "OnvarID" => 303, - "CityName" => "الیگودرز", - "ProvinceID" => "81", - "InvarID" => 39 - ], - 304 => [ - "OnvarID" => 304, - "CityName" => "ساوه", - "ProvinceID" => "51", - "InvarID" => 223 - ], - 305 => [ - "OnvarID" => 305, - "CityName" => "زرندیه", - "ProvinceID" => "51", - "InvarID" => 215 - ], - 306 => [ - "OnvarID" => 306, - "CityName" => "خنداب", - "ProvinceID" => "51", - "InvarID" => 158 - ], - 307 => [ - "OnvarID" => 307, - "CityName" => "كمیجان", - "ProvinceID" => "51", - "InvarID" => 331 - ], - 308 => [ - "OnvarID" => 308, - "CityName" => "اراك", - "ProvinceID" => "51", - "InvarID" => 19 - ], - 309 => [ - "OnvarID" => 309, - "CityName" => "فراهان", - "ProvinceID" => "51", - "InvarID" => 289 - ], - 310 => [ - "OnvarID" => 310, - "CityName" => "آشتیان", - "ProvinceID" => "51", - "InvarID" => 11 - ], - 311 => [ - "OnvarID" => 311, - "CityName" => "تفرش", - "ProvinceID" => "51", - "InvarID" => 114 - ], - 312 => [ - "OnvarID" => 312, - "CityName" => "شازند", - "ProvinceID" => "51", - "InvarID" => 255 - ], - 313 => [ - "OnvarID" => 313, - "CityName" => "خمین", - "ProvinceID" => "51", - "InvarID" => 155 - ], - 314 => [ - "OnvarID" => 314, - "CityName" => "دلیجان", - "ProvinceID" => "51", - "InvarID" => 178 - ], - 315 => [ - "OnvarID" => 315, - "CityName" => "محلات", - "ProvinceID" => "51", - "InvarID" => 371 - ], - 316 => [ - "OnvarID" => 316, - "CityName" => "چالوس", - "ProvinceID" => "16", - "InvarID" => 136 - ], - 317 => [ - "OnvarID" => 317, - "CityName" => "عباس آباد", - "ProvinceID" => "16", - "InvarID" => 279 - ], - 318 => [ - "OnvarID" => 318, - "CityName" => "كلاردشت", - "ProvinceID" => "16", - "InvarID" => 328 - ], - 319 => [ - "OnvarID" => 319, - "CityName" => "تنكابن", - "ProvinceID" => "16", - "InvarID" => 116 - ], - 320 => [ - "OnvarID" => 320, - "CityName" => "رامسر", - "ProvinceID" => "16", - "InvarID" => 191 - ], - 321 => [ - "OnvarID" => 321, - "CityName" => "آمل", - "ProvinceID" => "16", - "InvarID" => 14 - ], - 322 => [ - "OnvarID" => 322, - "CityName" => "نور", - "ProvinceID" => "16", - "InvarID" => 412 - ], - 323 => [ - "OnvarID" => 323, - "CityName" => "نوشهر", - "ProvinceID" => "16", - "InvarID" => 413 - ], - 324 => [ - "OnvarID" => 324, - "CityName" => "محمودآباد", - "ProvinceID" => "16", - "InvarID" => 372 - ], - 325 => [ - "OnvarID" => 325, - "CityName" => "فریدونكنار", - "ProvinceID" => "16", - "InvarID" => 294 - ], - 326 => [ - "OnvarID" => 326, - "CityName" => "سوادكوه", - "ProvinceID" => "16", - "InvarID" => 246 - ], - 327 => [ - "OnvarID" => 327, - "CityName" => "سوادكوه شمالی", - "ProvinceID" => "16", - "InvarID" => 247 - ], - 328 => [ - "OnvarID" => 328, - "CityName" => "قائمشهر", - "ProvinceID" => "16", - "InvarID" => 304 - ], - 329 => [ - "OnvarID" => 329, - "CityName" => "میاندورود", - "ProvinceID" => "16", - "InvarID" => 395 - ], - 330 => [ - "OnvarID" => 330, - "CityName" => "ساری", - "ProvinceID" => "16", - "InvarID" => 220 - ], - 331 => [ - "OnvarID" => 331, - "CityName" => "بابل", - "ProvinceID" => "16", - "InvarID" => 52 - ], - 332 => [ - "OnvarID" => 332, - "CityName" => "سیمرغ", - "ProvinceID" => "16", - "InvarID" => 253 - ], - 333 => [ - "OnvarID" => 333, - "CityName" => "جویبار", - "ProvinceID" => "16", - "InvarID" => 129 - ], - 334 => [ - "OnvarID" => 334, - "CityName" => "نكا", - "ProvinceID" => "16", - "InvarID" => 408 - ], - 335 => [ - "OnvarID" => 335, - "CityName" => "گلوگاه", - "ProvinceID" => "16", - "InvarID" => 352 - ], - 336 => [ - "OnvarID" => 336, - "CityName" => "بهشهر", - "ProvinceID" => "16", - "InvarID" => 85 - ], - 337 => [ - "OnvarID" => 337, - "CityName" => "بابلسر", - "ProvinceID" => "16", - "InvarID" => 53 - ], - 338 => [ - "OnvarID" => 338, - "CityName" => "تاكستان", - "ProvinceID" => "15", - "InvarID" => 107 - ], - 339 => [ - "OnvarID" => 339, - "CityName" => "آبیك", - "ProvinceID" => "15", - "InvarID" => 4 - ], - 340 => [ - "OnvarID" => 340, - "CityName" => "البرز", - "ProvinceID" => "15", - "InvarID" => 38 - ], - 341 => [ - "OnvarID" => 341, - "CityName" => "قزوین", - "ProvinceID" => "15", - "InvarID" => 309 - ], - 342 => [ - "OnvarID" => 342, - "CityName" => "آوج", - "ProvinceID" => "15", - "InvarID" => 15 - ], - 343 => [ - "OnvarID" => 343, - "CityName" => "بوئین زهرا", - "ProvinceID" => "15", - "InvarID" => 87 - ], - 344 => [ - "OnvarID" => 344, - "CityName" => "قم", - "ProvinceID" => "14", - "InvarID" => 314 - ], - 345 => [ - "OnvarID" => 345, - "CityName" => "دامغان", - "ProvinceID" => "87", - "InvarID" => 167 - ], - 346 => [ - "OnvarID" => 346, - "CityName" => "شاهرود", - "ProvinceID" => "87", - "InvarID" => 256 - ], - 347 => [ - "OnvarID" => 347, - "CityName" => "میامی", - "ProvinceID" => "87", - "InvarID" => 394 - ], - 348 => [ - "OnvarID" => 348, - "CityName" => "سرخه", - "ProvinceID" => "87", - "InvarID" => 233 - ], - 349 => [ - "OnvarID" => 349, - "CityName" => "سمنان", - "ProvinceID" => "87", - "InvarID" => 242 - ], - 350 => [ - "OnvarID" => 350, - "CityName" => "مهدیشهر", - "ProvinceID" => "87", - "InvarID" => 389 - ], - 351 => [ - "OnvarID" => 351, - "CityName" => "آرادان", - "ProvinceID" => "87", - "InvarID" => 6 - ], - 352 => [ - "OnvarID" => 352, - "CityName" => "گرمسار", - "ProvinceID" => "87", - "InvarID" => 348 - ], - 353 => [ - "OnvarID" => 353, - "CityName" => "ممانه و سملقان", - "ProvinceID" => "32", - "InvarID" => 368 - ], - 354 => [ - "OnvarID" => 354, - "CityName" => "راز و جرگلان", - "ProvinceID" => "32", - "InvarID" => 190 - ], - 355 => [ - "OnvarID" => 355, - "CityName" => "اسفراین", - "ProvinceID" => "32", - "InvarID" => 30 - ], - 356 => [ - "OnvarID" => 356, - "CityName" => "فاروج", - "ProvinceID" => "32", - "InvarID" => 285 - ], - 357 => [ - "OnvarID" => 357, - "CityName" => "شیروان", - "ProvinceID" => "32", - "InvarID" => 271 - ], - 358 => [ - "OnvarID" => 358, - "CityName" => "بجنورد", - "ProvinceID" => "32", - "InvarID" => 62 - ], - 359 => [ - "OnvarID" => 359, - "CityName" => "جاجرم", - "ProvinceID" => "32", - "InvarID" => 122 - ], - 360 => [ - "OnvarID" => 360, - "CityName" => "گرمه", - "ProvinceID" => "32", - "InvarID" => 349 - ], - 361 => [ - "OnvarID" => 361, - "CityName" => "نیمروز", - "ProvinceID" => "61", - "InvarID" => 418 - ], - 362 => [ - "OnvarID" => 362, - "CityName" => "هیرمند", - "ProvinceID" => "61", - "InvarID" => 427 - ], - 363 => [ - "OnvarID" => 363, - "CityName" => "هامون", - "ProvinceID" => "61", - "InvarID" => 419 - ], - 364 => [ - "OnvarID" => 364, - "CityName" => "زابل", - "ProvinceID" => "61", - "InvarID" => 211 - ], - 365 => [ - "OnvarID" => 365, - "CityName" => "زهك", - "ProvinceID" => "61", - "InvarID" => 218 - ], - 366 => [ - "OnvarID" => 366, - "CityName" => "میرجاوه", - "ProvinceID" => "61", - "InvarID" => 399 - ], - 367 => [ - "OnvarID" => 367, - "CityName" => "زاهدان", - "ProvinceID" => "61", - "InvarID" => 212 - ], - 368 => [ - "OnvarID" => 368, - "CityName" => "خاش", - "ProvinceID" => "61", - "InvarID" => 144 - ], - 369 => [ - "OnvarID" => 369, - "CityName" => "دلگان", - "ProvinceID" => "61", - "InvarID" => 177 - ], - 370 => [ - "OnvarID" => 370, - "CityName" => "ایرانشهر", - "ProvinceID" => "61", - "InvarID" => 49 - ], - 371 => [ - "OnvarID" => 371, - "CityName" => "مهرستان", - "ProvinceID" => "61", - "InvarID" => 392 - ], - 372 => [ - "OnvarID" => 372, - "CityName" => "سیب و سواران", - "ProvinceID" => "61", - "InvarID" => 249 - ], - 373 => [ - "OnvarID" => 373, - "CityName" => "سراوان", - "ProvinceID" => "61", - "InvarID" => 227 - ], - 374 => [ - "OnvarID" => 374, - "CityName" => "فنوج", - "ProvinceID" => "61", - "InvarID" => 298 - ], - 375 => [ - "OnvarID" => 375, - "CityName" => "سرباز", - "ProvinceID" => "61", - "InvarID" => 229 - ], - 376 => [ - "OnvarID" => 376, - "CityName" => "قصر قند", - "ProvinceID" => "61", - "InvarID" => 312 - ], - 377 => [ - "OnvarID" => 377, - "CityName" => "نیك شهر", - "ProvinceID" => "61", - "InvarID" => 417 - ], - 378 => [ - "OnvarID" => 378, - "CityName" => "چاه بهار", - "ProvinceID" => "61", - "InvarID" => 132 - ], - 379 => [ - "OnvarID" => 379, - "CityName" => "كنارك", - "ProvinceID" => "61", - "InvarID" => 332 - ], - 380 => [ - "OnvarID" => 380, - "CityName" => "فیروزكوه", - "ProvinceID" => "11", - "InvarID" => 302 - ], - 381 => [ - "OnvarID" => 381, - "CityName" => "ملارد", - "ProvinceID" => "11", - "InvarID" => 381 - ], - 382 => [ - "OnvarID" => 382, - "CityName" => "پیشوا", - "ProvinceID" => "11", - "InvarID" => 106 - ], - 383 => [ - "OnvarID" => 383, - "CityName" => "قرچك", - "ProvinceID" => "11", - "InvarID" => 307 - ], - 384 => [ - "OnvarID" => 384, - "CityName" => "پاكدشت", - "ProvinceID" => "11", - "InvarID" => 100 - ], - 385 => [ - "OnvarID" => 385, - "CityName" => "پردیس", - "ProvinceID" => "11", - "InvarID" => 102 - ], - 386 => [ - "OnvarID" => 386, - "CityName" => "دماوند", - "ProvinceID" => "11", - "InvarID" => 179 - ], - 387 => [ - "OnvarID" => 387, - "CityName" => "ری", - "ProvinceID" => "11", - "InvarID" => 209 - ], - 388 => [ - "OnvarID" => 388, - "CityName" => "اسلامشهر", - "ProvinceID" => "11", - "InvarID" => 33 - ], - 389 => [ - "OnvarID" => 389, - "CityName" => "قدس", - "ProvinceID" => "11", - "InvarID" => 306 - ], - 390 => [ - "OnvarID" => 390, - "CityName" => "شهریار", - "ProvinceID" => "11", - "InvarID" => 265 - ], - 391 => [ - "OnvarID" => 391, - "CityName" => "ورامین", - "ProvinceID" => "11", - "InvarID" => 428 - ], - 392 => [ - "OnvarID" => 392, - "CityName" => "تهران", - "ProvinceID" => "11", - "InvarID" => 118 - ], - 393 => [ - "OnvarID" => 393, - "CityName" => "شمیرانات", - "ProvinceID" => "11", - "InvarID" => 261 - ], - 394 => [ - "OnvarID" => 394, - "CityName" => "رباط كریم", - "ProvinceID" => "11", - "InvarID" => 196 - ], - 395 => [ - "OnvarID" => 395, - "CityName" => "بهارستان", - "ProvinceID" => "11", - "InvarID" => 83 - ], - 396 => [ - "OnvarID" => 396, - "CityName" => "چالدران", - "ProvinceID" => "57", - "InvarID" => 135 - ], - 397 => [ - "OnvarID" => 397, - "CityName" => "شوط", - "ProvinceID" => "57", - "InvarID" => 269 - ], - 398 => [ - "OnvarID" => 398, - "CityName" => "ماكو", - "ProvinceID" => "57", - "InvarID" => 367 - ], - 399 => [ - "OnvarID" => 399, - "CityName" => "خوی", - "ProvinceID" => "57", - "InvarID" => 164 - ], - 400 => [ - "OnvarID" => 400, - "CityName" => "سلماس", - "ProvinceID" => "57", - "InvarID" => 241 - ], - 401 => [ - "OnvarID" => 401, - "CityName" => "پلدشت", - "ProvinceID" => "57", - "InvarID" => 104 - ], - 402 => [ - "OnvarID" => 402, - "CityName" => "جایپاره", - "ProvinceID" => "57", - "InvarID" => 137 - ], - 403 => [ - "OnvarID" => 403, - "CityName" => "ارومیه", - "ProvinceID" => "57", - "InvarID" => 26 - ], - 404 => [ - "OnvarID" => 404, - "CityName" => "اشنویه", - "ProvinceID" => "57", - "InvarID" => 35 - ], - 405 => [ - "OnvarID" => 405, - "CityName" => "سردشت", - "ProvinceID" => "57", - "InvarID" => 234 - ], - 406 => [ - "OnvarID" => 406, - "CityName" => "بوكان", - "ProvinceID" => "57", - "InvarID" => 91 - ], - 407 => [ - "OnvarID" => 407, - "CityName" => "مهاباد", - "ProvinceID" => "57", - "InvarID" => 388 - ], - 408 => [ - "OnvarID" => 408, - "CityName" => "پیرانشهر", - "ProvinceID" => "57", - "InvarID" => 105 - ], - 409 => [ - "OnvarID" => 409, - "CityName" => "میاندوآب", - "ProvinceID" => "26", - "InvarID" => 396 - ], - 410 => [ - "OnvarID" => 410, - "CityName" => "نقده", - "ProvinceID" => "57", - "InvarID" => 407 - ], - 411 => [ - "OnvarID" => 411, - "CityName" => "تكاب", - "ProvinceID" => "57", - "InvarID" => 115 - ], - 412 => [ - "OnvarID" => 412, - "CityName" => "شاهین دژ", - "ProvinceID" => "57", - "InvarID" => 257 - ], - 413 => [ - "OnvarID" => 413, - "CityName" => "اشكذر", - "ProvinceID" => "93", - "InvarID" => 430 - ], - 414 => [ - "OnvarID" => 414, - "CityName" => "میبد", - "ProvinceID" => "93", - "InvarID" => 398 - ], - 415 => [ - "OnvarID" => 415, - "CityName" => "اردكان", - "ProvinceID" => "93", - "InvarID" => 22 - ], - 416 => [ - "OnvarID" => 416, - "CityName" => "ابركوه", - "ProvinceID" => "93", - "InvarID" => 16 - ], - 417 => [ - "OnvarID" => 417, - "CityName" => "بافق", - "ProvinceID" => "93", - "InvarID" => 58 - ], - 418 => [ - "OnvarID" => 418, - "CityName" => "مهریز", - "ProvinceID" => "93", - "InvarID" => 393 - ], - 419 => [ - "OnvarID" => 419, - "CityName" => "تفت", - "ProvinceID" => "93", - "InvarID" => 113 - ], - 420 => [ - "OnvarID" => 420, - "CityName" => "یزد", - "ProvinceID" => "93", - "InvarID" => 430 - ], - 421 => [ - "OnvarID" => 421, - "CityName" => "بهاباد", - "ProvinceID" => "93", - "InvarID" => 81 - ], - 422 => [ - "OnvarID" => 422, - "CityName" => "خاتم", - "ProvinceID" => "93", - "InvarID" => 143 - ], - 423 => [ - "OnvarID" => 423, - "CityName" => "ماهنشان", - "ProvinceID" => "67", - "InvarID" => 369 - ], - 424 => [ - "OnvarID" => 424, - "CityName" => "خدابنده", - "ProvinceID" => "67", - "InvarID" => 146 - ], - 425 => [ - "OnvarID" => 425, - "CityName" => "ابهر", - "ProvinceID" => "67", - "InvarID" => 17 - ], - 426 => [ - "OnvarID" => 426, - "CityName" => "ابهر", - "ProvinceID" => "67", - "InvarID" => 17 - ], - 427 => [ - "OnvarID" => 427, - "CityName" => "سلطانیه", - "ProvinceID" => "67", - "InvarID" => 240 - ], - 428 => [ - "OnvarID" => 428, - "CityName" => "ایجرود", - "ProvinceID" => "67", - "InvarID" => 47 - ], - 429 => [ - "OnvarID" => 429, - "CityName" => "زنجان", - "ProvinceID" => "67", - "InvarID" => 217 - ], - 430 => [ - "OnvarID" => 430, - "CityName" => "طارم", - "ProvinceID" => "67", - "InvarID" => 275 - ], - 431 => [ - "OnvarID" => 431, - "CityName" => "خرمدره", - "ProvinceID" => "67", - "InvarID" => 150 - ] - ]; - + $affectedRows = 0; $cities = []; foreach ($xml as $value) { // if ($value->fk_FeatureType >= 1 && $value->fk_FeatureType <= 6) { //// code ghabli @@ -2739,7 +90,7 @@ class RoadObservationProblems extends Command $city = findCityFromGeoJson($value->YGeo, $value->XGeo); $cityModel = $city ? City::find($city['city_id']) : null; - $rop = RoadObserved::updateOrCreate( + $rop = RoadObserved::query()->updateOrCreate( ['fk_RegisteredEventMessage' => $value->fk_RegisteredEventMessage], [ 'fk_RegisteredEventMessage' => $value->fk_RegisteredEventMessage ?? null, @@ -2769,9 +120,12 @@ class RoadObservationProblems extends Command 'fk_FeatureType' => $value->fk_FeatureType ?? null, 'Description' => (strlen($value->Description) > 5) ? $value->Description : null, 'MobileForSendEventSms' => $mobile, - 'rms_province_id' => $rmsProvinceId[(int) $value->fk_Province] ?? null, - 'rms_city_id' => $rmsCityId[(int) $value->fk_Town]["InvarID"] ?? null, - 'observed_way_id' => self::get_way_id_from_nominatim($value->XGeo, $value->YGeo) ?? null, +// 'rms_province_id' => $rmsProvinceId[(int) $value->fk_Province] ?? null, +// 'rms_city_id' => $rmsCityId[(int) $value->fk_Town]["InvarID"] ?? null, +// 'observed_way_id' => self::get_way_id_from_nominatim($value->XGeo, $value->YGeo) ?? null, + 'rms_province_id' => NikarayanComplaints::mapProvinces((int) $value->fk_Province) ?? null, + 'rms_city_id' => NikarayanComplaints::mapCities((int) $value->fk_Town) ?? null, + 'observed_way_id' => $nominatimService->get_way_id_from_nominatim($value->XGeo, $value->YGeo) ?? null, 'province_id' => $city ? $city['province_id'] : null, 'city_id' => $city ? $city['city_id'] : null, @@ -2781,56 +135,17 @@ class RoadObservationProblems extends Command 'city_fa' => $cityModel ? $cityModel->name_fa : null, ] ); + $affectedRows += 1; } } - } else { - /////log for error add all of things like successfull operation - $msg = 'rms: error in get data roadobserved babe!!!!' . "\n"; - // self::sms_sender('09398586633', $msg); - // self::sms_sender('09367487107', $msg); - return $result; + } + else { + $this->info('the received body is empty'); + Log::channel('nikarayan')->error("the received body is empty" . date('Y-m-d H:i:s')); + return $result; } echo 'done at: ' . date("Y-m-d H:i:s") . "\n"; + $this->info("{$affectedRows} row's affected"); return 0; } - public function sms_sender($mobile, $msg) - { - $client = new SoapClient("http://sms1000.ir/webservice/smspro.asmx?WSDL"); - $result = $client->doSendSMS( - array( - 'uUsername' => 'rmto', - 'uPassword' => 'Rahdari89', - 'uNumber' => '1000141', - 'uCellphones' => $mobile, - 'uMessage' => $msg, - 'uFarsi' => true, - 'uTopic' => false, - 'uFlash' => false - ) - ); - //print_r($result); - $x = $result->doSendSMSResult; - return $x; - } - - - public function get_way_id_from_nominatim($lat, $lng) - { - $url = "https://testmap.141.ir/nominatim/reverse?format=jsonv2&lat=" . $lat . "&lon=" . $lng . "&zoom=16&addressdetails=16"; - $arrContextOptions = array( - "ssl" => array( - "verify_peer" => false, - "verify_peer_name" => false, - ) - ); - - $result = file_get_contents($url, false, stream_context_create($arrContextOptions)); - $result = json_decode($result); - if (isset($result->osm_type)) { - if ($result->osm_type == 'way') { - return $result->osm_id; - } - } - return 0; - } -} \ No newline at end of file +} diff --git a/app/Console/Commands/SendRoadObservationToNikarayanCommand.php b/app/Console/Commands/SendRoadObservationToNikarayanCommand.php index 224c0acd..e04568bd 100644 --- a/app/Console/Commands/SendRoadObservationToNikarayanCommand.php +++ b/app/Console/Commands/SendRoadObservationToNikarayanCommand.php @@ -32,15 +32,14 @@ class SendRoadObservationToNikarayanCommand extends Command $count = 0; $this->info("Dispatching jobs with a delay between each..."); - DB::transaction(function () use ($count) { + DB::transaction(function () use (&$count) { $delay = 0; RoadObserved::query() ->whereBetween('StartTime_DateTime_fa', ['1403-01-01 00:00:00', '1403-07-13 23:59:59']) - ->where('rms_status', '=', 0) - ->chunkById(50, function ($roads) use ($delay, $count) { + ->chunkById(50, function ($roads) use (&$delay, &$count) { foreach ($roads as $road) { - $road->update(['rms_status' => 1]); - SendRoadObservationToNikarayan::dispatch($road)->delay(now()->addMinutes(10)->addSeconds($delay)); + $road->update(['status' => 1]); + SendRoadObservationToNikarayan::dispatch($road)->delay(now()->addSeconds($delay)); Log::channel('road_observation_problem')->info("Job for Road Observed ID {$road->id} scheduled with a {$delay} seconds delay."); $this->info("Scheduled job for Road ID: {$road->id} {$delay}s"); $delay += 3; diff --git a/app/Enums/AccidentStates.php b/app/Enums/AccidentStates.php new file mode 100644 index 00000000..b6494271 --- /dev/null +++ b/app/Enums/AccidentStates.php @@ -0,0 +1,28 @@ + "بدون اقدام", + 1 => "صدور نامه بیمه و کارشناسی داغی", + 2 => "فیش ها ثبت شده است.", + 3 => "فاکتور صادر شده است.", + 4 => "فاکتور پرداخت شده است", + 5 => "نامه پلیس راه صادر شده است (اتمام فرایند)", + ]; + + return $mapArray[$state]; + } +} \ No newline at end of file diff --git a/app/Enums/AxisTypes.php b/app/Enums/AxisTypes.php new file mode 100644 index 00000000..ae9ac691 --- /dev/null +++ b/app/Enums/AxisTypes.php @@ -0,0 +1,26 @@ + 'آزادراه', + 2 => 'بزرگراه', + 3 => 'اصلی', + 4 => 'فرعی', + 5 => 'روستایی', + ]; + + return $mapArray[$state]; + } +} \ No newline at end of file diff --git a/app/Enums/NikarayanComplaints.php b/app/Enums/NikarayanComplaints.php new file mode 100644 index 00000000..9d2d5feb --- /dev/null +++ b/app/Enums/NikarayanComplaints.php @@ -0,0 +1,2643 @@ + 1, + "57" => 2, + "91" => 3, + "21" => 4, + "18" => 5, + //"83" => 6, + "83" => 7, + "95" => 8, + "11" => 9, + "77" => 10, + "33" => 11, + "31" => 12, + "32" => 13, + "36" => 14, + "67" => 15, + //"26" => 16, + "87" => 17, + "61" => 18, + "41" => 19, + "15" => 20, + "14" => 21, + "73" => 22, + "45" => 23, + //"26" => 24, + "71" => 25, + "85" => 26, + "97" => 27, + "54" => 28, + //"26" => 29, + "81" => 30, + "16" => 31, + "51" => 32, + "64" => 33, + "75" => 34, + "93" => 35, + ]; + + return $nikarayanToRmsProvinceId[$province_id]; + } + + public static function mapCities(int $city_id): int + { + $nikarayanToRmsCityId = [ + 1 => [ + "OnvarID" => 1, + "CityName" => "گمیشان", + "ProvinceID" => "97", + "InvarID" => 353 + ], + 2 => [ + "OnvarID" => 2, + "CityName" => "آق قلا", + "ProvinceID" => "97", + "InvarID" => 13 + ], + 3 => [ + "OnvarID" => 3, + "CityName" => "رامیان", + "ProvinceID" => "97", + "InvarID" => 194 + ], + 4 => [ + "OnvarID" => 4, + "CityName" => "آزادشهر", + "ProvinceID" => "97", + "InvarID" => 8 + ], + 5 => [ + "OnvarID" => 5, + "CityName" => "مینو دشت", + "ProvinceID" => "97", + "InvarID" => 401 + ], + 6 => [ + "OnvarID" => 6, + "CityName" => "گالیكش", + "ProvinceID" => "97", + "InvarID" => 343 + ], + 7 => [ + "OnvarID" => 7, + "CityName" => "علی آباد", + "ProvinceID" => "97", + "InvarID" => 282 + ], + 8 => [ + "OnvarID" => 8, + "CityName" => "گرگان", + "ProvinceID" => "97", + "InvarID" => 347 + ], + 9 => [ + "OnvarID" => 9, + "CityName" => "كردكوی", + "ProvinceID" => "97", + "InvarID" => 324 + ], + 10 => [ + "OnvarID" => 10, + "CityName" => "بندرگز", + "ProvinceID" => "97", + "InvarID" => 80 + ], + 11 => [ + "OnvarID" => 11, + "CityName" => "تركمن", + "ProvinceID" => "97", + "InvarID" => 112 + ], + 12 => [ + "OnvarID" => 12, + "CityName" => "گنبدكاووس", + "ProvinceID" => "97", + "InvarID" => 356 + ], + 13 => [ + "OnvarID" => 13, + "CityName" => "كلاله", + "ProvinceID" => "97", + "InvarID" => 329 + ], + 14 => [ + "OnvarID" => 14, + "CityName" => "مراوه تپه", + "ProvinceID" => "97", + "InvarID" => 374 + ], + 15 => [ + "OnvarID" => 15, + "CityName" => "آستارا", + "ProvinceID" => "54", + "InvarID" => 9 + ], + 16 => [ + "OnvarID" => 16, + "CityName" => "طوالش", + "ProvinceID" => "54", + "InvarID" => 278 + ], + 17 => [ + "OnvarID" => 17, + "CityName" => "رضوانشهر", + "ProvinceID" => "54", + "InvarID" => 201 + ], + 18 => [ + "OnvarID" => 18, + "CityName" => "ماسال", + "ProvinceID" => "54", + "InvarID" => 366 + ], + 19 => [ + "OnvarID" => 19, + "CityName" => "بندر انزلی", + "ProvinceID" => "54", + "InvarID" => 76 + ], + 20 => [ + "OnvarID" => 20, + "CityName" => "صومعه سرا", + "ProvinceID" => "54", + "InvarID" => 274 + ], + 21 => [ + "OnvarID" => 21, + "CityName" => "فومن", + "ProvinceID" => "54", + "InvarID" => 300 + ], + 22 => [ + "OnvarID" => 22, + "CityName" => "شفت", + "ProvinceID" => "54", + "InvarID" => 260 + ], + 23 => [ + "OnvarID" => 23, + "CityName" => "املش", + "ProvinceID" => "54", + "InvarID" => 40 + ], + 24 => [ + "OnvarID" => 24, + "CityName" => "رودسر", + "ProvinceID" => "54", + "InvarID" => 207 + ], + 25 => [ + "OnvarID" => 25, + "CityName" => "آستانه اشرفیه", + "ProvinceID" => "54", + "InvarID" => 10 + ], + 26 => [ + "OnvarID" => 26, + "CityName" => "لاهیجان", + "ProvinceID" => "54", + "InvarID" => 361 + ], + 27 => [ + "OnvarID" => 27, + "CityName" => "رشت", + "ProvinceID" => "54", + "InvarID" => 199 + ], + 28 => [ + "OnvarID" => 28, + "CityName" => "سیاهكل", + "ProvinceID" => "54", + "InvarID" => 248 + ], + 29 => [ + "OnvarID" => 29, + "CityName" => "لنگرود", + "ProvinceID" => "54", + "InvarID" => 365 + ], + 30 => [ + "OnvarID" => 30, + "CityName" => "رودبار", + "ProvinceID" => "54", + "InvarID" => 205 + ], + 31 => [ + "OnvarID" => 31, + "CityName" => "آباده", + "ProvinceID" => "41", + "InvarID" => 2 + ], + 32 => [ + "OnvarID" => 32, + "CityName" => "ممسنی", + "ProvinceID" => "41", + "InvarID" => 385 + ], + 33 => [ + "OnvarID" => 33, + "CityName" => "سپیدان", + "ProvinceID" => "41", + "InvarID" => 225 + ], + 34 => [ + "OnvarID" => 34, + "CityName" => "رستم", + "ProvinceID" => "41", + "InvarID" => 198 + ], + 35 => [ + "OnvarID" => 35, + "CityName" => "پاسارگاد", + "ProvinceID" => "41", + "InvarID" => 99 + ], + 36 => [ + "OnvarID" => 36, + "CityName" => "بوانات", + "ProvinceID" => "41", + "InvarID" => 89 + ], + 37 => [ + "OnvarID" => 37, + "CityName" => "خرم بید", + "ProvinceID" => "41", + "InvarID" => 149 + ], + 38 => [ + "OnvarID" => 38, + "CityName" => "اقلید", + "ProvinceID" => "41", + "InvarID" => 37 + ], + 39 => [ + "OnvarID" => 39, + "CityName" => "كازرون", + "ProvinceID" => "41", + "InvarID" => 318 + ], + 40 => [ + "OnvarID" => 40, + "CityName" => "سروستان", + "ProvinceID" => "41", + "InvarID" => 237 + ], + 41 => [ + "OnvarID" => 41, + "CityName" => "كوار", + "ProvinceID" => "41", + "InvarID" => 337 + ], + 42 => [ + "OnvarID" => 42, + "CityName" => "خرامه", + "ProvinceID" => "41", + "InvarID" => 147 + ], + 43 => [ + "OnvarID" => 43, + "CityName" => "شیراز", + "ProvinceID" => "41", + "InvarID" => 270 + ], + 44 => [ + "OnvarID" => 44, + "CityName" => "مرودشت", + "ProvinceID" => "41", + "InvarID" => 376 + ], + 45 => [ + "OnvarID" => 45, + "CityName" => "ارسنجان", + "ProvinceID" => "41", + "InvarID" => 25 + ], + 46 => [ + "OnvarID" => 46, + "CityName" => "نی ریز", + "ProvinceID" => "41", + "InvarID" => 414 + ], + 47 => [ + "OnvarID" => 47, + "CityName" => "فراشبند", + "ProvinceID" => "41", + "InvarID" => 288 + ], + 48 => [ + "OnvarID" => 48, + "CityName" => "جهرم", + "ProvinceID" => "41", + "InvarID" => 127 + ], + 49 => [ + "OnvarID" => 49, + "CityName" => "قیر و كارزین", + "ProvinceID" => "41", + "InvarID" => 316 + ], + 50 => [ + "OnvarID" => 50, + "CityName" => "فیروز آباد", + "ProvinceID" => "41", + "InvarID" => 301 + ], + 51 => [ + "OnvarID" => 51, + "CityName" => "داراب", + "ProvinceID" => "41", + "InvarID" => 165 + ], + 52 => [ + "OnvarID" => 52, + "CityName" => "زرین دشت", + "ProvinceID" => "41", + "InvarID" => 216 + ], + 53 => [ + "OnvarID" => 53, + "CityName" => "مهر", + "ProvinceID" => "41", + "InvarID" => 3 + ], + 54 => [ + "OnvarID" => 54, + "CityName" => "خنج", + "ProvinceID" => "41", + "InvarID" => 390 + ], + 55 => [ + "OnvarID" => 55, + "CityName" => "لامرد", + "ProvinceID" => "41", + "InvarID" => 360 + ], + 56 => [ + "OnvarID" => 56, + "CityName" => "گراش", + "ProvinceID" => "41", + "InvarID" => 346 + ], + 57 => [ + "OnvarID" => 57, + "CityName" => "لارستان", + "ProvinceID" => "41", + "InvarID" => 358 + ], + 58 => [ + "OnvarID" => 58, + "CityName" => "فسا", + "ProvinceID" => "41", + "InvarID" => 296 + ], + 59 => [ + "OnvarID" => 59, + "CityName" => "استهبان", + "ProvinceID" => "41", + "InvarID" => 28 + ], + 60 => [ + "OnvarID" => 60, + "CityName" => "آران و بیدگل", + "ProvinceID" => "21", + "InvarID" => 7 + ], + 61 => [ + "OnvarID" => 61, + "CityName" => "بوئین و میان دشت", + "ProvinceID" => "21", + "InvarID" => 88 + ], + 62 => [ + "OnvarID" => 62, + "CityName" => "خوانسار", + "ProvinceID" => "21", + "InvarID" => 160 + ], + 63 => [ + "OnvarID" => 63, + "CityName" => "گلپایگان", + "ProvinceID" => "21", + "InvarID" => 351 + ], + 64 => [ + "OnvarID" => 64, + "CityName" => "اردستان", + "ProvinceID" => "21", + "InvarID" => 21 + ], + 65 => [ + "OnvarID" => 65, + "CityName" => "كاشان", + "ProvinceID" => "21", + "InvarID" => 319 + ], + 66 => [ + "OnvarID" => 66, + "CityName" => "خور و بیابانك", + "ProvinceID" => "21", + "InvarID" => 161 + ], + 67 => [ + "OnvarID" => 67, + "CityName" => "چادگان", + "ProvinceID" => "21", + "InvarID" => 133 + ], + 68 => [ + "OnvarID" => 68, + "CityName" => "فریدن", + "ProvinceID" => "21", + "InvarID" => 292 + ], + 69 => [ + "OnvarID" => 69, + "CityName" => "فریدون شهر", + "ProvinceID" => "21", + "InvarID" => 293 + ], + 70 => [ + "OnvarID" => 70, + "CityName" => "شهرضا", + "ProvinceID" => "21", + "InvarID" => 263 + ], + 71 => [ + "OnvarID" => 71, + "CityName" => "مباركه", + "ProvinceID" => "21", + "InvarID" => 370 + ], + 72 => [ + "OnvarID" => 72, + "CityName" => "لنجان", + "ProvinceID" => "21", + "InvarID" => 363 + ], + 73 => [ + "OnvarID" => 73, + "CityName" => "اصفهان", + "ProvinceID" => "21", + "InvarID" => 36 + ], + 74 => [ + "OnvarID" => 74, + "CityName" => "فلاورجان", + "ProvinceID" => "21", + "InvarID" => 297 + ], + 75 => [ + "OnvarID" => 75, + "CityName" => "نجف آباد", + "ProvinceID" => "21", + "InvarID" => 403 + ], + 76 => [ + "OnvarID" => 76, + "CityName" => "خمینی شهر", + "ProvinceID" => "21", + "InvarID" => 156 + ], + 77 => [ + "OnvarID" => 77, + "CityName" => "تیران و كرون", + "ProvinceID" => "21", + "InvarID" => 120 + ], + 78 => [ + "OnvarID" => 78, + "CityName" => "برخوار", + "ProvinceID" => "21", + "InvarID" => 64 + ], + 79 => [ + "OnvarID" => 79, + "CityName" => "نائین", + "ProvinceID" => "21", + "InvarID" => 402 + ], + 80 => [ + "OnvarID" => 80, + "CityName" => "سمیرم", + "ProvinceID" => "21", + "InvarID" => 243 + ], + 81 => [ + "OnvarID" => 81, + "CityName" => "دهاقان", + "ProvinceID" => "21", + "InvarID" => 181 + ], + 82 => [ + "OnvarID" => 82, + "CityName" => "نطنز", + "ProvinceID" => "21", + "InvarID" => 405 + ], + 83 => [ + "OnvarID" => 83, + "CityName" => "شاهین شهر و میمه", + "ProvinceID" => "21", + "InvarID" => 258 + ], + 84 => [ + "OnvarID" => 84, + "CityName" => "مراغه", + "ProvinceID" => "26", + "InvarID" => 373 + ], + 85 => [ + "OnvarID" => 85, + "CityName" => "خدا آفرین", + "ProvinceID" => "26", + "InvarID" => 145 + ], + 86 => [ + "OnvarID" => 86, + "CityName" => "جلفا", + "ProvinceID" => "26", + "InvarID" => 125 + ], + 87 => [ + "OnvarID" => 87, + "CityName" => "شبستر", + "ProvinceID" => "26", + "InvarID" => 259 + ], + 88 => [ + "OnvarID" => 88, + "CityName" => "مرند", + "ProvinceID" => "26", + "InvarID" => 375 + ], + 89 => [ + "OnvarID" => 89, + "CityName" => "تبریز", + "ProvinceID" => "26", + "InvarID" => 109 + ], + 90 => [ + "OnvarID" => 90, + "CityName" => "ورزقان", + "ProvinceID" => "26", + "InvarID" => 429 + ], + 91 => [ + "OnvarID" => 91, + "CityName" => "اهر", + "ProvinceID" => "26", + "InvarID" => 45 + ], + 92 => [ + "OnvarID" => 92, + "CityName" => "كلیبر", + "ProvinceID" => "26", + "InvarID" => 330 + ], + 93 => [ + "OnvarID" => 93, + "CityName" => "اسكو", + "ProvinceID" => "26", + "InvarID" => 31 + ], + 94 => [ + "OnvarID" => 94, + "CityName" => "آذرشهر", + "ProvinceID" => "26", + "InvarID" => 5 + ], + 95 => [ + "OnvarID" => 95, + "CityName" => "عجب شیر", + "ProvinceID" => "26", + "InvarID" => 280 + ], + 96 => [ + "OnvarID" => 96, + "CityName" => "بناب", + "ProvinceID" => "26", + "InvarID" => 75 + ], + 97 => [ + "OnvarID" => 97, + "CityName" => "ملكان", + "ProvinceID" => "26", + "InvarID" => 383 + ], + 98 => [ + "OnvarID" => 98, + "CityName" => "بستان آباد", + "ProvinceID" => "26", + "InvarID" => 69 + ], + 99 => [ + "OnvarID" => 99, + "CityName" => "سراب", + "ProvinceID" => "26", + "InvarID" => 226 + ], + 100 => [ + "OnvarID" => 100, + "CityName" => "هشترود", + "ProvinceID" => "26", + "InvarID" => 422 + ], + 101 => [ + "OnvarID" => 101, + "CityName" => "میانه", + "ProvinceID" => "26", + "InvarID" => 397 + ], + 102 => [ + "OnvarID" => 102, + "CityName" => "چاراویماق", + "ProvinceID" => "26", + "InvarID" => 134 + ], + 103 => [ + "OnvarID" => 103, + "CityName" => "هریس", + "ProvinceID" => "26", + "InvarID" => 421 + ], + 104 => [ + "OnvarID" => 104, + "CityName" => "هوراند", + "ProvinceID" => "26", + "InvarID" => 109 + ], + 105 => [ + "OnvarID" => 105, + "CityName" => "كیار", + "ProvinceID" => "77", + "InvarID" => 342 + ], + 106 => [ + "OnvarID" => 106, + "CityName" => "فارسان", + "ProvinceID" => "77", + "InvarID" => 284 + ], + 107 => [ + "OnvarID" => 107, + "CityName" => "كوهرنگ", + "ProvinceID" => "77", + "InvarID" => 341 + ], + 108 => [ + "OnvarID" => 108, + "CityName" => "لردگان", + "ProvinceID" => "77", + "InvarID" => 362 + ], + 109 => [ + "OnvarID" => 109, + "CityName" => "اردل", + "ProvinceID" => "77", + "InvarID" => 23 + ], + 110 => [ + "OnvarID" => 110, + "CityName" => "بروجن", + "ProvinceID" => "77", + "InvarID" => 68 + ], + 111 => [ + "OnvarID" => 111, + "CityName" => "سامان", + "ProvinceID" => "77", + "InvarID" => 221 + ], + 112 => [ + "OnvarID" => 112, + "CityName" => "بن", + "ProvinceID" => "77", + "InvarID" => 74 + ], + 113 => [ + "OnvarID" => 113, + "CityName" => "شهركرد", + "ProvinceID" => "77", + "InvarID" => 264 + ], + 114 => [ + "OnvarID" => 114, + "CityName" => "دیلم", + "ProvinceID" => "95", + "InvarID" => 187 + ], + 115 => [ + "OnvarID" => 115, + "CityName" => "گناوه", + "ProvinceID" => "95", + "InvarID" => 395 + ], + 116 => [ + "OnvarID" => 116, + "CityName" => "دشتستان", + "ProvinceID" => "95", + "InvarID" => 174 + ], + 117 => [ + "OnvarID" => 117, + "CityName" => "دشتی", + "ProvinceID" => "95", + "InvarID" => 175 + ], + 118 => [ + "OnvarID" => 118, + "CityName" => "بوشهر", + "ProvinceID" => "95", + "InvarID" => 90 + ], + 119 => [ + "OnvarID" => 119, + "CityName" => "تنگستان", + "ProvinceID" => "95", + "InvarID" => 117 + ], + 120 => [ + "OnvarID" => 120, + "CityName" => "دیر", + "ProvinceID" => "95", + "InvarID" => 186 + ], + 121 => [ + "OnvarID" => 121, + "CityName" => "جم", + "ProvinceID" => "95", + "InvarID" => 126 + ], + 122 => [ + "OnvarID" => 122, + "CityName" => "كنگان", + "ProvinceID" => "95", + "InvarID" => 333 + ], + 123 => [ + "OnvarID" => 123, + "CityName" => "عسلویه", + "ProvinceID" => "95", + "InvarID" => 281 + ], + 124 => [ + "OnvarID" => 124, + "CityName" => "مهران", + "ProvinceID" => "83", + "InvarID" => 391 + ], + 125 => [ + "OnvarID" => 125, + "CityName" => "ایلام", + "ProvinceID" => "83", + "InvarID" => 50 + ], + 126 => [ + "OnvarID" => 126, + "CityName" => "ایوان", + "ProvinceID" => "83", + "InvarID" => 51 + ], + 127 => [ + "OnvarID" => 127, + "CityName" => "دره شهر", + "ProvinceID" => "83", + "InvarID" => 171 + ], + 128 => [ + "OnvarID" => 128, + "CityName" => "ملكشاهی", + "ProvinceID" => "83", + "InvarID" => 384 + ], + 129 => [ + "OnvarID" => 129, + "CityName" => "سیروان", + "ProvinceID" => "83", + "InvarID" => 251 + ], + 130 => [ + "OnvarID" => 130, + "CityName" => "بدره", + "ProvinceID" => "83", + "InvarID" => 63 + ], + 131 => [ + "OnvarID" => 131, + "CityName" => "چرداول", + "ProvinceID" => "71", + "InvarID" => 139 + ], + 132 => [ + "OnvarID" => 132, + "CityName" => "دهلران", + "ProvinceID" => "83", + "InvarID" => 183 + ], + 133 => [ + "OnvarID" => 133, + "CityName" => "آبدانان", + "ProvinceID" => "83", + "InvarID" => 3 + ], + 134 => [ + "OnvarID" => 134, + "CityName" => "راور", + "ProvinceID" => "45", + "InvarID" => 195 + ], + 135 => [ + "OnvarID" => 135, + "CityName" => "كوهبنان", + "ProvinceID" => "45", + "InvarID" => 339 + ], + 136 => [ + "OnvarID" => 136, + "CityName" => "شهر بابك", + "ProvinceID" => "45", + "InvarID" => 262 + ], + 137 => [ + "OnvarID" => 137, + "CityName" => "انار", + "ProvinceID" => "45", + "InvarID" => 42 + ], + 138 => [ + "OnvarID" => 138, + "CityName" => "رفسنجان", + "ProvinceID" => "45", + "InvarID" => 202 + ], + 139 => [ + "OnvarID" => 139, + "CityName" => "زرند", + "ProvinceID" => "45", + "InvarID" => 214 + ], + 140 => [ + "OnvarID" => 140, + "CityName" => "كرمان", + "ProvinceID" => "45", + "InvarID" => 325 + ], + 141 => [ + "OnvarID" => 141, + "CityName" => "رابر", + "ProvinceID" => "45", + "InvarID" => 189 + ], + 142 => [ + "OnvarID" => 142, + "CityName" => "بافت", + "ProvinceID" => "45", + "InvarID" => 57 + ], + 143 => [ + "OnvarID" => 143, + "CityName" => "سیرجان", + "ProvinceID" => "45", + "InvarID" => 250 + ], + 144 => [ + "OnvarID" => 144, + "CityName" => "بردسیر", + "ProvinceID" => "45", + "InvarID" => 66 + ], + 145 => [ + "OnvarID" => 145, + "CityName" => "ارزوئیه", + "ProvinceID" => "45", + "InvarID" => 24 + ], + 146 => [ + "OnvarID" => 146, + "CityName" => "ریگان", + "ProvinceID" => "45", + "InvarID" => 210 + ], + 147 => [ + "OnvarID" => 147, + "CityName" => "فهرج", + "ProvinceID" => "45", + "InvarID" => 299 + ], + 148 => [ + "OnvarID" => 148, + "CityName" => "نرماشیر", + "ProvinceID" => "45", + "InvarID" => 404 + ], + 149 => [ + "OnvarID" => 149, + "CityName" => "منوجان", + "ProvinceID" => "45", + "InvarID" => 386 + ], + 150 => [ + "OnvarID" => 150, + "CityName" => "قلعه گنج", + "ProvinceID" => "45", + "InvarID" => 313 + ], + 151 => [ + "OnvarID" => 151, + "CityName" => "كهنوج", + "ProvinceID" => "45", + "InvarID" => 336 + ], + 152 => [ + "OnvarID" => 152, + "CityName" => "فاریاب", + "ProvinceID" => "45", + "InvarID" => 286 + ], + 153 => [ + "OnvarID" => 153, + "CityName" => "رودبار جنوب", + "ProvinceID" => "45", + "InvarID" => 205 + ], + 154 => [ + "OnvarID" => 154, + "CityName" => "عنبرآباد", + "ProvinceID" => "45", + "InvarID" => 283 + ], + 155 => [ + "OnvarID" => 155, + "CityName" => "جیرفت", + "ProvinceID" => "45", + "InvarID" => 131 + ], + 156 => [ + "OnvarID" => 156, + "CityName" => "بم", + "ProvinceID" => "45", + "InvarID" => 73 + ], + 157 => [ + "OnvarID" => 157, + "CityName" => "گیلانغرب", + "ProvinceID" => "71", + "InvarID" => 357 + ], + 158 => [ + "OnvarID" => 158, + "CityName" => "دالاهو", + "ProvinceID" => "71", + "InvarID" => 166 + ], + 159 => [ + "OnvarID" => 159, + "CityName" => "قصر شیرین", + "ProvinceID" => "71", + "InvarID" => 311 + ], + 160 => [ + "OnvarID" => 160, + "CityName" => "سر پل ذهاب", + "ProvinceID" => "71", + "InvarID" => 231 + ], + 161 => [ + "OnvarID" => 161, + "CityName" => "ثلاث باباجانی", + "ProvinceID" => "71", + "InvarID" => 121 + ], + 162 => [ + "OnvarID" => 162, + "CityName" => "جوانرود", + "ProvinceID" => "71", + "InvarID" => 128 + ], + 163 => [ + "OnvarID" => 163, + "CityName" => "اسلام آباد غرب", + "ProvinceID" => "71", + "InvarID" => 32 + ], + 164 => [ + "OnvarID" => 164, + "CityName" => "هرسین", + "ProvinceID" => "71", + "InvarID" => 420 + ], + 165 => [ + "OnvarID" => 165, + "CityName" => "كنگاور", + "ProvinceID" => "71", + "InvarID" => 334 + ], + 166 => [ + "OnvarID" => 166, + "CityName" => "روانسر", + "ProvinceID" => "71", + "InvarID" => 203 + ], + 167 => [ + "OnvarID" => 167, + "CityName" => "سنقر", + "ProvinceID" => "71", + "InvarID" => 244 + ], + 168 => [ + "OnvarID" => 168, + "CityName" => "صحنه", + "ProvinceID" => "71", + "InvarID" => 272 + ], + 169 => [ + "OnvarID" => 169, + "CityName" => "پاوه", + "ProvinceID" => "71", + "InvarID" => 101 + ], + 170 => [ + "OnvarID" => 170, + "CityName" => "كرمانشاه", + "ProvinceID" => "71", + "InvarID" => 326 + ], + 171 => [ + "OnvarID" => 171, + "CityName" => "قوچان", + "ProvinceID" => "31", + "InvarID" => 315 + ], + 172 => [ + "OnvarID" => 172, + "CityName" => "درگز", + "ProvinceID" => "31", + "InvarID" => 169 + ], + 173 => [ + "OnvarID" => 173, + "CityName" => "داورزن", + "ProvinceID" => "31", + "InvarID" => 168 + ], + 174 => [ + "OnvarID" => 174, + "CityName" => "سبزوار", + "ProvinceID" => "31", + "InvarID" => 224 + ], + 175 => [ + "OnvarID" => 175, + "CityName" => "خوشاب", + "ProvinceID" => "31", + "InvarID" => 163 + ], + 176 => [ + "OnvarID" => 176, + "CityName" => "جغتای", + "ProvinceID" => "31", + "InvarID" => 124 + ], + 177 => [ + "OnvarID" => 177, + "CityName" => "جوین", + "ProvinceID" => "31", + "InvarID" => 130 + ], + 178 => [ + "OnvarID" => 178, + "CityName" => "مشهد", + "ProvinceID" => "31", + "InvarID" => 380 + ], + 179 => [ + "OnvarID" => 179, + "CityName" => "بینالود", + "ProvinceID" => "31", + "InvarID" => 96 + ], + 180 => [ + "OnvarID" => 180, + "CityName" => "نیشابور", + "ProvinceID" => "31", + "InvarID" => 416 + ], + 181 => [ + "OnvarID" => 181, + "CityName" => "فیروزه", + "ProvinceID" => "31", + "InvarID" => 303 + ], + 182 => [ + "OnvarID" => 182, + "CityName" => "چناران", + "ProvinceID" => "31", + "InvarID" => 140 + ], + 183 => [ + "OnvarID" => 183, + "CityName" => "كلات", + "ProvinceID" => "31", + "InvarID" => 327 + ], + 184 => [ + "OnvarID" => 184, + "CityName" => "سرخس", + "ProvinceID" => "31", + "InvarID" => 232 + ], + 185 => [ + "OnvarID" => 185, + "CityName" => "كاشمر", + "ProvinceID" => "31", + "InvarID" => 320 + ], + 186 => [ + "OnvarID" => 186, + "CityName" => "خلیل آباد", + "ProvinceID" => "31", + "InvarID" => 153 + ], + 187 => [ + "OnvarID" => 187, + "CityName" => "مه ولایت", + "ProvinceID" => "31", + "InvarID" => 387 + ], + 188 => [ + "OnvarID" => 188, + "CityName" => "تربت حیدریه", + "ProvinceID" => "31", + "InvarID" => 111 + ], + 189 => [ + "OnvarID" => 189, + "CityName" => "زاوه", + "ProvinceID" => "31", + "InvarID" => 213 + ], + 190 => [ + "OnvarID" => 190, + "CityName" => "فریمان", + "ProvinceID" => "31", + "InvarID" => 295 + ], + 191 => [ + "OnvarID" => 191, + "CityName" => "تربت جام", + "ProvinceID" => "31", + "InvarID" => 110 + ], + 192 => [ + "OnvarID" => 192, + "CityName" => "بردسكن", + "ProvinceID" => "31", + "InvarID" => 65 + ], + 193 => [ + "OnvarID" => 193, + "CityName" => "بجستان", + "ProvinceID" => "31", + "InvarID" => 61 + ], + 194 => [ + "OnvarID" => 194, + "CityName" => "گناباد", + "ProvinceID" => "31", + "InvarID" => 354 + ], + 195 => [ + "OnvarID" => 195, + "CityName" => "رشتخوار", + "ProvinceID" => "31", + "InvarID" => 200 + ], + 196 => [ + "OnvarID" => 196, + "CityName" => "خواف", + "ProvinceID" => "31", + "InvarID" => 159 + ], + 197 => [ + "OnvarID" => 197, + "CityName" => "تایباد", + "ProvinceID" => "31", + "InvarID" => 108 + ], + 198 => [ + "OnvarID" => 198, + "CityName" => "باخرز", + "ProvinceID" => "31", + "InvarID" => 54 + ], + 199 => [ + "OnvarID" => 199, + "CityName" => "فردوس", + "ProvinceID" => "33", + "InvarID" => 290 + ], + 200 => [ + "OnvarID" => 200, + "CityName" => "طبس", + "ProvinceID" => "33", + "InvarID" => 277 + ], + 201 => [ + "OnvarID" => 201, + "CityName" => "بشرویه", + "ProvinceID" => "33", + "InvarID" => 72 + ], + 202 => [ + "OnvarID" => 202, + "CityName" => "سرایان", + "ProvinceID" => "33", + "InvarID" => 228 + ], + 203 => [ + "OnvarID" => 203, + "CityName" => "قائنات", + "ProvinceID" => "33", + "InvarID" => 305 + ], + 204 => [ + "OnvarID" => 204, + "CityName" => "زیركوه", + "ProvinceID" => "33", + "InvarID" => 219 + ], + 205 => [ + "OnvarID" => 205, + "CityName" => "سربیشه", + "ProvinceID" => "33", + "InvarID" => 230 + ], + 206 => [ + "OnvarID" => 206, + "CityName" => "خوسف", + "ProvinceID" => "33", + "InvarID" => 162 + ], + 207 => [ + "OnvarID" => 207, + "CityName" => "بیرجند", + "ProvinceID" => "33", + "InvarID" => 94 + ], + 208 => [ + "OnvarID" => 208, + "CityName" => "درمیان", + "ProvinceID" => "33", + "InvarID" => 170 + ], + 209 => [ + "OnvarID" => 209, + "CityName" => "نهبندان", + "ProvinceID" => "33", + "InvarID" => 411 + ], + 210 => [ + "OnvarID" => 210, + "CityName" => "شوشتر", + "ProvinceID" => "36", + "InvarID" => 268 + ], + 211 => [ + "OnvarID" => 211, + "CityName" => "اندیكا", + "ProvinceID" => "36", + "InvarID" => 43 + ], + 212 => [ + "OnvarID" => 212, + "CityName" => "لالی", + "ProvinceID" => "36", + "InvarID" => 359 + ], + 213 => [ + "OnvarID" => 213, + "CityName" => "گتوند", + "ProvinceID" => "36", + "InvarID" => 344 + ], + 214 => [ + "OnvarID" => 214, + "CityName" => "شوش", + "ProvinceID" => "36", + "InvarID" => 267 + ], + 215 => [ + "OnvarID" => 215, + "CityName" => "اندیمشك", + "ProvinceID" => "36", + "InvarID" => 44 + ], + 216 => [ + "OnvarID" => 216, + "CityName" => "دزفول", + "ProvinceID" => "36", + "InvarID" => 172 + ], + 217 => [ + "OnvarID" => 217, + "CityName" => "كارون", + "ProvinceID" => "36", + "InvarID" => 317 + ], + 218 => [ + "OnvarID" => 218, + "CityName" => "هویزه", + "ProvinceID" => "36", + "InvarID" => 426 + ], + 219 => [ + "OnvarID" => 219, + "CityName" => "حمیدیه", + "ProvinceID" => "36", + "InvarID" => 142 + ], + 220 => [ + "OnvarID" => 220, + "CityName" => "باوی", + "ProvinceID" => "36", + "InvarID" => 60 + ], + 221 => [ + "OnvarID" => 221, + "CityName" => "دشت آزادگان", + "ProvinceID" => "36", + "InvarID" => 173 + ], + 222 => [ + "OnvarID" => 222, + "CityName" => "مسجد سلیمان", + "ProvinceID" => "36", + "InvarID" => 378 + ], + 223 => [ + "OnvarID" => 223, + "CityName" => "هفتگل", + "ProvinceID" => "36", + "InvarID" => 423 + ], + 224 => [ + "OnvarID" => 224, + "CityName" => "رامهرمز", + "ProvinceID" => "36", + "InvarID" => 193 + ], + 225 => [ + "OnvarID" => 225, + "CityName" => "باغ ملك", + "ProvinceID" => "36", + "InvarID" => 56 + ], + 226 => [ + "OnvarID" => 226, + "CityName" => "ایذه", + "ProvinceID" => "36", + "InvarID" => 48 + ], + 227 => [ + "OnvarID" => 227, + "CityName" => "شادگان", + "ProvinceID" => "36", + "InvarID" => 254 + ], + 228 => [ + "OnvarID" => 228, + "CityName" => "رامشیر", + "ProvinceID" => "36", + "InvarID" => 192 + ], + 229 => [ + "OnvarID" => 229, + "CityName" => "هندیجان", + "ProvinceID" => "36", + "InvarID" => 425 + ], + 230 => [ + "OnvarID" => 230, + "CityName" => "بهبهان", + "ProvinceID" => "36", + "InvarID" => 84 + ], + 231 => [ + "OnvarID" => 231, + "CityName" => "آغاجاری", + "ProvinceID" => "36", + "InvarID" => 12 + ], + 232 => [ + "OnvarID" => 232, + "CityName" => "امیدیه", + "ProvinceID" => "36", + "InvarID" => 41 + ], + 233 => [ + "OnvarID" => 233, + "CityName" => "آبادان", + "ProvinceID" => "36", + "InvarID" => 1 + ], + 234 => [ + "OnvarID" => 234, + "CityName" => "خرمشهر", + "ProvinceID" => "36", + "InvarID" => 151 + ], + 235 => [ + "OnvarID" => 235, + "CityName" => "اهواز", + "ProvinceID" => "36", + "InvarID" => 46 + ], + 236 => [ + "OnvarID" => 236, + "CityName" => "بندر ماهشهر", + "ProvinceID" => "36", + "InvarID" => 78 + ], + 237 => [ + "OnvarID" => 237, + "CityName" => "گچساران", + "ProvinceID" => "85", + "InvarID" => 345 + ], + 238 => [ + "OnvarID" => 238, + "CityName" => "بهمئی", + "ProvinceID" => "85", + "InvarID" => 86 + ], + 239 => [ + "OnvarID" => 239, + "CityName" => "كهگیلویه", + "ProvinceID" => "85", + "InvarID" => 335 + ], + 240 => [ + "OnvarID" => 240, + "CityName" => "چرام", + "ProvinceID" => "85", + "InvarID" => 138 + ], + 241 => [ + "OnvarID" => 241, + "CityName" => "لنده", + "ProvinceID" => "85", + "InvarID" => 364 + ], + 242 => [ + "OnvarID" => 242, + "CityName" => "باشت", + "ProvinceID" => "85", + "InvarID" => 55 + ], + 243 => [ + "OnvarID" => 243, + "CityName" => "بویراحمد", + "ProvinceID" => "85", + "InvarID" => 92 + ], + 244 => [ + "OnvarID" => 244, + "CityName" => "دنا", + "ProvinceID" => "85", + "InvarID" => 180 + ], + 245 => [ + "OnvarID" => 245, + "CityName" => "پارس آباد", + "ProvinceID" => "91", + "InvarID" => 97 + ], + 246 => [ + "OnvarID" => 246, + "CityName" => "گرمی", + "ProvinceID" => "91", + "InvarID" => 350 + ], + 247 => [ + "OnvarID" => 247, + "CityName" => "بیله سوار", + "ProvinceID" => "91", + "InvarID" => 95 + ], + 248 => [ + "OnvarID" => 248, + "CityName" => "مشگین شهر", + "ProvinceID" => "91", + "InvarID" => 379 + ], + 249 => [ + "OnvarID" => 249, + "CityName" => "نیر", + "ProvinceID" => "91", + "InvarID" => 415 + ], + 250 => [ + "OnvarID" => 250, + "CityName" => "نمین", + "ProvinceID" => "91", + "InvarID" => 409 + ], + 251 => [ + "OnvarID" => 251, + "CityName" => "اردبیل", + "ProvinceID" => "91", + "InvarID" => 20 + ], + 252 => [ + "OnvarID" => 252, + "CityName" => "سرعین", + "ProvinceID" => "91", + "InvarID" => 235 + ], + 253 => [ + "OnvarID" => 253, + "CityName" => "كوثر", + "ProvinceID" => "91", + "InvarID" => 338 + ], + 254 => [ + "OnvarID" => 254, + "CityName" => "خلخال", + "ProvinceID" => "91", + "InvarID" => 152 + ], + 255 => [ + "OnvarID" => 255, + "CityName" => "حاجی آباد", + "ProvinceID" => "64", + "InvarID" => 141 + ], + 256 => [ + "OnvarID" => 256, + "CityName" => "پارسیان", + "ProvinceID" => "64", + "InvarID" => 98 + ], + 257 => [ + "OnvarID" => 257, + "CityName" => "بستك", + "ProvinceID" => "64", + "InvarID" => 70 + ], + 258 => [ + "OnvarID" => 258, + "CityName" => "بندر عباس", + "ProvinceID" => "64", + "InvarID" => 79 + ], + 259 => [ + "OnvarID" => 259, + "CityName" => "میناب", + "ProvinceID" => "64", + "InvarID" => 400 + ], + 260 => [ + "OnvarID" => 260, + "CityName" => "رودان", + "ProvinceID" => "64", + "InvarID" => 204 + ], + 261 => [ + "OnvarID" => 261, + "CityName" => "بندر لنگه", + "ProvinceID" => "64", + "InvarID" => 77 + ], + 262 => [ + "OnvarID" => 262, + "CityName" => "خمیر", + "ProvinceID" => "64", + "InvarID" => 154 + ], + 263 => [ + "OnvarID" => 263, + "CityName" => "بشاگرد", + "ProvinceID" => "64", + "InvarID" => 71 + ], + 264 => [ + "OnvarID" => 264, + "CityName" => "سیریك", + "ProvinceID" => "64", + "InvarID" => 252 + ], + 265 => [ + "OnvarID" => 265, + "CityName" => "جاسك", + "ProvinceID" => "64", + "InvarID" => 123 + ], + 266 => [ + "OnvarID" => 266, + "CityName" => "ابوموسی", + "ProvinceID" => "NULL", + "InvarID" => 18 + ], + 267 => [ + "OnvarID" => 267, + "CityName" => "قشم", + "ProvinceID" => "64", + "InvarID" => 310 + ], + 268 => [ + "OnvarID" => 268, + "CityName" => "طالقان", + "ProvinceID" => "18", + "InvarID" => 276 + ], + 269 => [ + "OnvarID" => 269, + "CityName" => "اشتهارد", + "ProvinceID" => "18", + "InvarID" => 34 + ], + 270 => [ + "OnvarID" => 270, + "CityName" => "كرج", + "ProvinceID" => "18", + "InvarID" => 323 + ], + 271 => [ + "OnvarID" => 271, + "CityName" => "فردیس", + "ProvinceID" => "18", + "InvarID" => 291 + ], + 272 => [ + "OnvarID" => 272, + "CityName" => "ساوجبلاغ", + "ProvinceID" => "18", + "InvarID" => 222 + ], + 273 => [ + "OnvarID" => 273, + "CityName" => "نظر آباد", + "ProvinceID" => "18", + "InvarID" => 406 + ], + 274 => [ + "OnvarID" => 274, + "CityName" => "فامنین", + "ProvinceID" => "75", + "InvarID" => 287 + ], + 275 => [ + "OnvarID" => 275, + "CityName" => "كبودرآهنگ", + "ProvinceID" => "75", + "InvarID" => 322 + ], + 276 => [ + "OnvarID" => 276, + "CityName" => "رزن", + "ProvinceID" => "75", + "InvarID" => 197 + ], + 277 => [ + "OnvarID" => 277, + "CityName" => "ملایر", + "ProvinceID" => "75", + "InvarID" => 382 + ], + 278 => [ + "OnvarID" => 278, + "CityName" => "نهاوند", + "ProvinceID" => "75", + "InvarID" => 410 + ], + 279 => [ + "OnvarID" => 279, + "CityName" => "تویسركان", + "ProvinceID" => "75", + "InvarID" => 119 + ], + 280 => [ + "OnvarID" => 280, + "CityName" => "اسد آباد", + "ProvinceID" => "75", + "InvarID" => 29 + ], + 281 => [ + "OnvarID" => 281, + "CityName" => "همدان", + "ProvinceID" => "75", + "InvarID" => 424 + ], + 282 => [ + "OnvarID" => 282, + "CityName" => "بهار", + "ProvinceID" => "75", + "InvarID" => 82 + ], + 283 => [ + "OnvarID" => 283, + "CityName" => "سقز", + "ProvinceID" => "73", + "InvarID" => 238 + ], + 284 => [ + "OnvarID" => 284, + "CityName" => "سرو آباد", + "ProvinceID" => "73", + "InvarID" => 236 + ], + 285 => [ + "OnvarID" => 285, + "CityName" => "مریوان", + "ProvinceID" => "73", + "InvarID" => 377 + ], + 286 => [ + "OnvarID" => 286, + "CityName" => "بانه", + "ProvinceID" => "73", + "InvarID" => 59 + ], + 287 => [ + "OnvarID" => 287, + "CityName" => "قروه", + "ProvinceID" => "73", + "InvarID" => 308 + ], + 288 => [ + "OnvarID" => 288, + "CityName" => "دهگلان", + "ProvinceID" => "73", + "InvarID" => 182 + ], + 289 => [ + "OnvarID" => 289, + "CityName" => "سنندج", + "ProvinceID" => "73", + "InvarID" => 245 + ], + 290 => [ + "OnvarID" => 290, + "CityName" => "بیجار", + "ProvinceID" => "73", + "InvarID" => 93 + ], + 291 => [ + "OnvarID" => 291, + "CityName" => "دیواندره", + "ProvinceID" => "73", + "InvarID" => 188 + ], + 292 => [ + "OnvarID" => 292, + "CityName" => "كامیاران", + "ProvinceID" => "73", + "InvarID" => 321 + ], + 293 => [ + "OnvarID" => 293, + "CityName" => "دلفان", + "ProvinceID" => "81", + "InvarID" => 176 + ], + 294 => [ + "OnvarID" => 294, + "CityName" => "پل دختر", + "ProvinceID" => "81", + "InvarID" => 103 + ], + 295 => [ + "OnvarID" => 295, + "CityName" => "رومشكان", + "ProvinceID" => "81", + "InvarID" => 208 + ], + 296 => [ + "OnvarID" => 296, + "CityName" => "كوه دشت", + "ProvinceID" => "81", + "InvarID" => 340 + ], + 297 => [ + "OnvarID" => 297, + "CityName" => "دوره", + "ProvinceID" => "81", + "InvarID" => 184 + ], + 298 => [ + "OnvarID" => 298, + "CityName" => "خرم آباد", + "ProvinceID" => "81", + "InvarID" => 148 + ], + 299 => [ + "OnvarID" => 299, + "CityName" => "دورود", + "ProvinceID" => "81", + "InvarID" => 185 + ], + 300 => [ + "OnvarID" => 300, + "CityName" => "ازنا", + "ProvinceID" => "81", + "InvarID" => 27 + ], + 301 => [ + "OnvarID" => 301, + "CityName" => "سلسله", + "ProvinceID" => "81", + "InvarID" => 239 + ], + 302 => [ + "OnvarID" => 302, + "CityName" => "بروجرد", + "ProvinceID" => "81", + "InvarID" => 67 + ], + 303 => [ + "OnvarID" => 303, + "CityName" => "الیگودرز", + "ProvinceID" => "81", + "InvarID" => 39 + ], + 304 => [ + "OnvarID" => 304, + "CityName" => "ساوه", + "ProvinceID" => "51", + "InvarID" => 223 + ], + 305 => [ + "OnvarID" => 305, + "CityName" => "زرندیه", + "ProvinceID" => "51", + "InvarID" => 215 + ], + 306 => [ + "OnvarID" => 306, + "CityName" => "خنداب", + "ProvinceID" => "51", + "InvarID" => 158 + ], + 307 => [ + "OnvarID" => 307, + "CityName" => "كمیجان", + "ProvinceID" => "51", + "InvarID" => 331 + ], + 308 => [ + "OnvarID" => 308, + "CityName" => "اراك", + "ProvinceID" => "51", + "InvarID" => 19 + ], + 309 => [ + "OnvarID" => 309, + "CityName" => "فراهان", + "ProvinceID" => "51", + "InvarID" => 289 + ], + 310 => [ + "OnvarID" => 310, + "CityName" => "آشتیان", + "ProvinceID" => "51", + "InvarID" => 11 + ], + 311 => [ + "OnvarID" => 311, + "CityName" => "تفرش", + "ProvinceID" => "51", + "InvarID" => 114 + ], + 312 => [ + "OnvarID" => 312, + "CityName" => "شازند", + "ProvinceID" => "51", + "InvarID" => 255 + ], + 313 => [ + "OnvarID" => 313, + "CityName" => "خمین", + "ProvinceID" => "51", + "InvarID" => 155 + ], + 314 => [ + "OnvarID" => 314, + "CityName" => "دلیجان", + "ProvinceID" => "51", + "InvarID" => 178 + ], + 315 => [ + "OnvarID" => 315, + "CityName" => "محلات", + "ProvinceID" => "51", + "InvarID" => 371 + ], + 316 => [ + "OnvarID" => 316, + "CityName" => "چالوس", + "ProvinceID" => "16", + "InvarID" => 136 + ], + 317 => [ + "OnvarID" => 317, + "CityName" => "عباس آباد", + "ProvinceID" => "16", + "InvarID" => 279 + ], + 318 => [ + "OnvarID" => 318, + "CityName" => "كلاردشت", + "ProvinceID" => "16", + "InvarID" => 328 + ], + 319 => [ + "OnvarID" => 319, + "CityName" => "تنكابن", + "ProvinceID" => "16", + "InvarID" => 116 + ], + 320 => [ + "OnvarID" => 320, + "CityName" => "رامسر", + "ProvinceID" => "16", + "InvarID" => 191 + ], + 321 => [ + "OnvarID" => 321, + "CityName" => "آمل", + "ProvinceID" => "16", + "InvarID" => 14 + ], + 322 => [ + "OnvarID" => 322, + "CityName" => "نور", + "ProvinceID" => "16", + "InvarID" => 412 + ], + 323 => [ + "OnvarID" => 323, + "CityName" => "نوشهر", + "ProvinceID" => "16", + "InvarID" => 413 + ], + 324 => [ + "OnvarID" => 324, + "CityName" => "محمودآباد", + "ProvinceID" => "16", + "InvarID" => 372 + ], + 325 => [ + "OnvarID" => 325, + "CityName" => "فریدونكنار", + "ProvinceID" => "16", + "InvarID" => 294 + ], + 326 => [ + "OnvarID" => 326, + "CityName" => "سوادكوه", + "ProvinceID" => "16", + "InvarID" => 246 + ], + 327 => [ + "OnvarID" => 327, + "CityName" => "سوادكوه شمالی", + "ProvinceID" => "16", + "InvarID" => 247 + ], + 328 => [ + "OnvarID" => 328, + "CityName" => "قائمشهر", + "ProvinceID" => "16", + "InvarID" => 304 + ], + 329 => [ + "OnvarID" => 329, + "CityName" => "میاندورود", + "ProvinceID" => "16", + "InvarID" => 395 + ], + 330 => [ + "OnvarID" => 330, + "CityName" => "ساری", + "ProvinceID" => "16", + "InvarID" => 220 + ], + 331 => [ + "OnvarID" => 331, + "CityName" => "بابل", + "ProvinceID" => "16", + "InvarID" => 52 + ], + 332 => [ + "OnvarID" => 332, + "CityName" => "سیمرغ", + "ProvinceID" => "16", + "InvarID" => 253 + ], + 333 => [ + "OnvarID" => 333, + "CityName" => "جویبار", + "ProvinceID" => "16", + "InvarID" => 129 + ], + 334 => [ + "OnvarID" => 334, + "CityName" => "نكا", + "ProvinceID" => "16", + "InvarID" => 408 + ], + 335 => [ + "OnvarID" => 335, + "CityName" => "گلوگاه", + "ProvinceID" => "16", + "InvarID" => 352 + ], + 336 => [ + "OnvarID" => 336, + "CityName" => "بهشهر", + "ProvinceID" => "16", + "InvarID" => 85 + ], + 337 => [ + "OnvarID" => 337, + "CityName" => "بابلسر", + "ProvinceID" => "16", + "InvarID" => 53 + ], + 338 => [ + "OnvarID" => 338, + "CityName" => "تاكستان", + "ProvinceID" => "15", + "InvarID" => 107 + ], + 339 => [ + "OnvarID" => 339, + "CityName" => "آبیك", + "ProvinceID" => "15", + "InvarID" => 4 + ], + 340 => [ + "OnvarID" => 340, + "CityName" => "البرز", + "ProvinceID" => "15", + "InvarID" => 38 + ], + 341 => [ + "OnvarID" => 341, + "CityName" => "قزوین", + "ProvinceID" => "15", + "InvarID" => 309 + ], + 342 => [ + "OnvarID" => 342, + "CityName" => "آوج", + "ProvinceID" => "15", + "InvarID" => 15 + ], + 343 => [ + "OnvarID" => 343, + "CityName" => "بوئین زهرا", + "ProvinceID" => "15", + "InvarID" => 87 + ], + 344 => [ + "OnvarID" => 344, + "CityName" => "قم", + "ProvinceID" => "14", + "InvarID" => 314 + ], + 345 => [ + "OnvarID" => 345, + "CityName" => "دامغان", + "ProvinceID" => "87", + "InvarID" => 167 + ], + 346 => [ + "OnvarID" => 346, + "CityName" => "شاهرود", + "ProvinceID" => "87", + "InvarID" => 256 + ], + 347 => [ + "OnvarID" => 347, + "CityName" => "میامی", + "ProvinceID" => "87", + "InvarID" => 394 + ], + 348 => [ + "OnvarID" => 348, + "CityName" => "سرخه", + "ProvinceID" => "87", + "InvarID" => 233 + ], + 349 => [ + "OnvarID" => 349, + "CityName" => "سمنان", + "ProvinceID" => "87", + "InvarID" => 242 + ], + 350 => [ + "OnvarID" => 350, + "CityName" => "مهدیشهر", + "ProvinceID" => "87", + "InvarID" => 389 + ], + 351 => [ + "OnvarID" => 351, + "CityName" => "آرادان", + "ProvinceID" => "87", + "InvarID" => 6 + ], + 352 => [ + "OnvarID" => 352, + "CityName" => "گرمسار", + "ProvinceID" => "87", + "InvarID" => 348 + ], + 353 => [ + "OnvarID" => 353, + "CityName" => "ممانه و سملقان", + "ProvinceID" => "32", + "InvarID" => 368 + ], + 354 => [ + "OnvarID" => 354, + "CityName" => "راز و جرگلان", + "ProvinceID" => "32", + "InvarID" => 190 + ], + 355 => [ + "OnvarID" => 355, + "CityName" => "اسفراین", + "ProvinceID" => "32", + "InvarID" => 30 + ], + 356 => [ + "OnvarID" => 356, + "CityName" => "فاروج", + "ProvinceID" => "32", + "InvarID" => 285 + ], + 357 => [ + "OnvarID" => 357, + "CityName" => "شیروان", + "ProvinceID" => "32", + "InvarID" => 271 + ], + 358 => [ + "OnvarID" => 358, + "CityName" => "بجنورد", + "ProvinceID" => "32", + "InvarID" => 62 + ], + 359 => [ + "OnvarID" => 359, + "CityName" => "جاجرم", + "ProvinceID" => "32", + "InvarID" => 122 + ], + 360 => [ + "OnvarID" => 360, + "CityName" => "گرمه", + "ProvinceID" => "32", + "InvarID" => 349 + ], + 361 => [ + "OnvarID" => 361, + "CityName" => "نیمروز", + "ProvinceID" => "61", + "InvarID" => 418 + ], + 362 => [ + "OnvarID" => 362, + "CityName" => "هیرمند", + "ProvinceID" => "61", + "InvarID" => 427 + ], + 363 => [ + "OnvarID" => 363, + "CityName" => "هامون", + "ProvinceID" => "61", + "InvarID" => 419 + ], + 364 => [ + "OnvarID" => 364, + "CityName" => "زابل", + "ProvinceID" => "61", + "InvarID" => 211 + ], + 365 => [ + "OnvarID" => 365, + "CityName" => "زهك", + "ProvinceID" => "61", + "InvarID" => 218 + ], + 366 => [ + "OnvarID" => 366, + "CityName" => "میرجاوه", + "ProvinceID" => "61", + "InvarID" => 399 + ], + 367 => [ + "OnvarID" => 367, + "CityName" => "زاهدان", + "ProvinceID" => "61", + "InvarID" => 212 + ], + 368 => [ + "OnvarID" => 368, + "CityName" => "خاش", + "ProvinceID" => "61", + "InvarID" => 144 + ], + 369 => [ + "OnvarID" => 369, + "CityName" => "دلگان", + "ProvinceID" => "61", + "InvarID" => 177 + ], + 370 => [ + "OnvarID" => 370, + "CityName" => "ایرانشهر", + "ProvinceID" => "61", + "InvarID" => 49 + ], + 371 => [ + "OnvarID" => 371, + "CityName" => "مهرستان", + "ProvinceID" => "61", + "InvarID" => 392 + ], + 372 => [ + "OnvarID" => 372, + "CityName" => "سیب و سواران", + "ProvinceID" => "61", + "InvarID" => 249 + ], + 373 => [ + "OnvarID" => 373, + "CityName" => "سراوان", + "ProvinceID" => "61", + "InvarID" => 227 + ], + 374 => [ + "OnvarID" => 374, + "CityName" => "فنوج", + "ProvinceID" => "61", + "InvarID" => 298 + ], + 375 => [ + "OnvarID" => 375, + "CityName" => "سرباز", + "ProvinceID" => "61", + "InvarID" => 229 + ], + 376 => [ + "OnvarID" => 376, + "CityName" => "قصر قند", + "ProvinceID" => "61", + "InvarID" => 312 + ], + 377 => [ + "OnvarID" => 377, + "CityName" => "نیك شهر", + "ProvinceID" => "61", + "InvarID" => 417 + ], + 378 => [ + "OnvarID" => 378, + "CityName" => "چاه بهار", + "ProvinceID" => "61", + "InvarID" => 132 + ], + 379 => [ + "OnvarID" => 379, + "CityName" => "كنارك", + "ProvinceID" => "61", + "InvarID" => 332 + ], + 380 => [ + "OnvarID" => 380, + "CityName" => "فیروزكوه", + "ProvinceID" => "11", + "InvarID" => 302 + ], + 381 => [ + "OnvarID" => 381, + "CityName" => "ملارد", + "ProvinceID" => "11", + "InvarID" => 381 + ], + 382 => [ + "OnvarID" => 382, + "CityName" => "پیشوا", + "ProvinceID" => "11", + "InvarID" => 106 + ], + 383 => [ + "OnvarID" => 383, + "CityName" => "قرچك", + "ProvinceID" => "11", + "InvarID" => 307 + ], + 384 => [ + "OnvarID" => 384, + "CityName" => "پاكدشت", + "ProvinceID" => "11", + "InvarID" => 100 + ], + 385 => [ + "OnvarID" => 385, + "CityName" => "پردیس", + "ProvinceID" => "11", + "InvarID" => 102 + ], + 386 => [ + "OnvarID" => 386, + "CityName" => "دماوند", + "ProvinceID" => "11", + "InvarID" => 179 + ], + 387 => [ + "OnvarID" => 387, + "CityName" => "ری", + "ProvinceID" => "11", + "InvarID" => 209 + ], + 388 => [ + "OnvarID" => 388, + "CityName" => "اسلامشهر", + "ProvinceID" => "11", + "InvarID" => 33 + ], + 389 => [ + "OnvarID" => 389, + "CityName" => "قدس", + "ProvinceID" => "11", + "InvarID" => 306 + ], + 390 => [ + "OnvarID" => 390, + "CityName" => "شهریار", + "ProvinceID" => "11", + "InvarID" => 265 + ], + 391 => [ + "OnvarID" => 391, + "CityName" => "ورامین", + "ProvinceID" => "11", + "InvarID" => 428 + ], + 392 => [ + "OnvarID" => 392, + "CityName" => "تهران", + "ProvinceID" => "11", + "InvarID" => 118 + ], + 393 => [ + "OnvarID" => 393, + "CityName" => "شمیرانات", + "ProvinceID" => "11", + "InvarID" => 261 + ], + 394 => [ + "OnvarID" => 394, + "CityName" => "رباط كریم", + "ProvinceID" => "11", + "InvarID" => 196 + ], + 395 => [ + "OnvarID" => 395, + "CityName" => "بهارستان", + "ProvinceID" => "11", + "InvarID" => 83 + ], + 396 => [ + "OnvarID" => 396, + "CityName" => "چالدران", + "ProvinceID" => "57", + "InvarID" => 135 + ], + 397 => [ + "OnvarID" => 397, + "CityName" => "شوط", + "ProvinceID" => "57", + "InvarID" => 269 + ], + 398 => [ + "OnvarID" => 398, + "CityName" => "ماكو", + "ProvinceID" => "57", + "InvarID" => 367 + ], + 399 => [ + "OnvarID" => 399, + "CityName" => "خوی", + "ProvinceID" => "57", + "InvarID" => 164 + ], + 400 => [ + "OnvarID" => 400, + "CityName" => "سلماس", + "ProvinceID" => "57", + "InvarID" => 241 + ], + 401 => [ + "OnvarID" => 401, + "CityName" => "پلدشت", + "ProvinceID" => "57", + "InvarID" => 104 + ], + 402 => [ + "OnvarID" => 402, + "CityName" => "جایپاره", + "ProvinceID" => "57", + "InvarID" => 137 + ], + 403 => [ + "OnvarID" => 403, + "CityName" => "ارومیه", + "ProvinceID" => "57", + "InvarID" => 26 + ], + 404 => [ + "OnvarID" => 404, + "CityName" => "اشنویه", + "ProvinceID" => "57", + "InvarID" => 35 + ], + 405 => [ + "OnvarID" => 405, + "CityName" => "سردشت", + "ProvinceID" => "57", + "InvarID" => 234 + ], + 406 => [ + "OnvarID" => 406, + "CityName" => "بوكان", + "ProvinceID" => "57", + "InvarID" => 91 + ], + 407 => [ + "OnvarID" => 407, + "CityName" => "مهاباد", + "ProvinceID" => "57", + "InvarID" => 388 + ], + 408 => [ + "OnvarID" => 408, + "CityName" => "پیرانشهر", + "ProvinceID" => "57", + "InvarID" => 105 + ], + 409 => [ + "OnvarID" => 409, + "CityName" => "میاندوآب", + "ProvinceID" => "26", + "InvarID" => 396 + ], + 410 => [ + "OnvarID" => 410, + "CityName" => "نقده", + "ProvinceID" => "57", + "InvarID" => 407 + ], + 411 => [ + "OnvarID" => 411, + "CityName" => "تكاب", + "ProvinceID" => "57", + "InvarID" => 115 + ], + 412 => [ + "OnvarID" => 412, + "CityName" => "شاهین دژ", + "ProvinceID" => "57", + "InvarID" => 257 + ], + 413 => [ + "OnvarID" => 413, + "CityName" => "اشكذر", + "ProvinceID" => "93", + "InvarID" => 430 + ], + 414 => [ + "OnvarID" => 414, + "CityName" => "میبد", + "ProvinceID" => "93", + "InvarID" => 398 + ], + 415 => [ + "OnvarID" => 415, + "CityName" => "اردكان", + "ProvinceID" => "93", + "InvarID" => 22 + ], + 416 => [ + "OnvarID" => 416, + "CityName" => "ابركوه", + "ProvinceID" => "93", + "InvarID" => 16 + ], + 417 => [ + "OnvarID" => 417, + "CityName" => "بافق", + "ProvinceID" => "93", + "InvarID" => 58 + ], + 418 => [ + "OnvarID" => 418, + "CityName" => "مهریز", + "ProvinceID" => "93", + "InvarID" => 393 + ], + 419 => [ + "OnvarID" => 419, + "CityName" => "تفت", + "ProvinceID" => "93", + "InvarID" => 113 + ], + 420 => [ + "OnvarID" => 420, + "CityName" => "یزد", + "ProvinceID" => "93", + "InvarID" => 430 + ], + 421 => [ + "OnvarID" => 421, + "CityName" => "بهاباد", + "ProvinceID" => "93", + "InvarID" => 81 + ], + 422 => [ + "OnvarID" => 422, + "CityName" => "خاتم", + "ProvinceID" => "93", + "InvarID" => 143 + ], + 423 => [ + "OnvarID" => 423, + "CityName" => "ماهنشان", + "ProvinceID" => "67", + "InvarID" => 369 + ], + 424 => [ + "OnvarID" => 424, + "CityName" => "خدابنده", + "ProvinceID" => "67", + "InvarID" => 146 + ], + 425 => [ + "OnvarID" => 425, + "CityName" => "ابهر", + "ProvinceID" => "67", + "InvarID" => 17 + ], + 426 => [ + "OnvarID" => 426, + "CityName" => "ابهر", + "ProvinceID" => "67", + "InvarID" => 17 + ], + 427 => [ + "OnvarID" => 427, + "CityName" => "سلطانیه", + "ProvinceID" => "67", + "InvarID" => 240 + ], + 428 => [ + "OnvarID" => 428, + "CityName" => "ایجرود", + "ProvinceID" => "67", + "InvarID" => 47 + ], + 429 => [ + "OnvarID" => 429, + "CityName" => "زنجان", + "ProvinceID" => "67", + "InvarID" => 217 + ], + 430 => [ + "OnvarID" => 430, + "CityName" => "طارم", + "ProvinceID" => "67", + "InvarID" => 275 + ], + 431 => [ + "OnvarID" => 431, + "CityName" => "خرمدره", + "ProvinceID" => "67", + "InvarID" => 150 + ] + ]; + return $nikarayanToRmsCityId[$city_id]["InvarID"]; + } +} \ No newline at end of file diff --git a/app/Exceptions/ProhibitedAction.php b/app/Exceptions/ProhibitedAction.php new file mode 100644 index 00000000..1117f997 --- /dev/null +++ b/app/Exceptions/ProhibitedAction.php @@ -0,0 +1,26 @@ +errorResponse($this->message); + } +} diff --git a/app/Exports/V3/AccidentReceipt/CountryReport.php b/app/Exports/V3/AccidentReceipt/CountryReport.php new file mode 100644 index 00000000..e05bdb64 --- /dev/null +++ b/app/Exports/V3/AccidentReceipt/CountryReport.php @@ -0,0 +1,125 @@ +data; + + $country = array_search(-1, array_column($data['data'], 'province_id')); + + $activities[] = [ + 'name' => 'کل کشور', + 'tedade' => $data['data'][$country]->tedade, + 'police_rah' => $data['data'][$country]->police_rah, + 'gozaresh_gasht' => $data['data'][$country]->gozaresh_gasht, + 'kol_sabt_shode' => $data['data'][$country]->kol_sabt_shode, + 'vasel_shode' => $data['data'][$country]->vasel_shode ?? 0, + 'vasel_shode_bimeh' => $data['data'][$country]->vasel_shode_bimeh ?? 0, + 'vasel_shode_daghi' => $data['data'][$country]->vasel_shode_daghi ?? 0, + 'vasel_shode_final' => $data['data'][$country]->vasel_shode_final ?? 0, + ]; + + foreach (Province::all() as $province) { + + $existingProvince = array_search($province->id, array_column($data['data'], 'province_id')); + + if ($existingProvince) { + $activities[] = [ + 'name' => $province->name_fa, + 'tedade' => $data['data'][$existingProvince]->tedade, + 'police_rah' => $data['data'][$existingProvince]->police_rah, + 'gozaresh_gasht' => $data['data'][$existingProvince]->gozaresh_gasht, + 'kol_sabt_shode' => $data['data'][$existingProvince]->kol_sabt_shode, + 'vasel_shode' => $data['data'][$existingProvince]->vasel_shode ?? 0, + 'vasel_shode_bimeh' => $data['data'][$existingProvince]->vasel_shode_bimeh ?? 0, + 'vasel_shode_daghi' => $data['data'][$existingProvince]->vasel_shode_daghi ?? 0, + 'vasel_shode_final' => $data['data'][$existingProvince]->vasel_shode_final ?? 0, + ]; + } else { + $activities[] = [ + 'name' => $province->name_fa, + 'tedade' => "", + 'police_rah' => "", + 'gozaresh_gasht' => "", + 'kol_sabt_shode' => "", + 'vasel_shode' => "", + 'vasel_shode_bimeh' => "", + 'vasel_shode_daghi' => "", + 'vasel_shode_final' => "", + ]; + } + } + + return view('v3.Reports.AccidentReceipt.CountryReport', [ + 'data' => $activities, + 'fromDate' => $data['fromDate'], + 'toDate' => $data['toDate'], + ]); + } + + /** + * @return array + */ + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + }, + ]; + } + + public function drawings(): array + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('B1'); + return [$drawing, $drawing2]; + } + + public function styles(Worksheet $sheet): array + { + return [ + // Style the first row as bold text. + 'A:BA' => [ + 'font' => [ + 'name' => 'B Nazanin' + ] + ], + ]; + } +} diff --git a/app/Exports/V3/AccidentReceipt/DataTableReport.php b/app/Exports/V3/AccidentReceipt/DataTableReport.php new file mode 100644 index 00000000..4d6a0a5f --- /dev/null +++ b/app/Exports/V3/AccidentReceipt/DataTableReport.php @@ -0,0 +1,75 @@ + $this->data, + ]); + } + + /** + * @return array + */ + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + }, + ]; + } + + public function drawings() + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('B1'); + return [$drawing, $drawing2]; + } + + public function styles(Worksheet $sheet) + { + return [ + // Style the first row as bold text. + 'A:BA' => [ + 'font' => [ + 'name' => 'B Nazanin' + ] + ], + ]; + } +} diff --git a/app/Exports/V3/AccidentReceipt/ProvinceReport.php b/app/Exports/V3/AccidentReceipt/ProvinceReport.php new file mode 100644 index 00000000..ab63e7f6 --- /dev/null +++ b/app/Exports/V3/AccidentReceipt/ProvinceReport.php @@ -0,0 +1,125 @@ +data; + $reportData =$inputData['report']; + + $province = array_search(-1, array_column($reportData, 'province_id')); + + $activities[] = [ + 'name' => 'کل استان', + 'tedade' => $reportData['data'][$province]->tedade, + 'police_rah' => $reportData['data'][$province]->police_rah, + 'gozaresh_gasht' => $reportData['data'][$province]->gozaresh_gasht, + 'kol_sabt_shode' => $reportData['data'][$province]->kol_sabt_shode, + 'vasel_shode' => $reportData['data'][$province]->vasel_shode ?? 0, + 'vasel_shode_bimeh' => $reportData['data'][$province]->vasel_shode_bimeh ?? 0, + 'vasel_shode_daghi' => $reportData['data'][$province]->vasel_shode_daghi ?? 0, + 'vasel_shode_final' => $reportData['data'][$province]->vasel_shode_final ?? 0, + ]; + + foreach ($inputData['cities'] as $city) { + + $existingCity = array_search($city->id, array_column($reportData['data'], 'city_id')); + + if ($existingCity) { + $activities[] = [ + 'name' => $city->name_fa, + 'tedade' => $reportData['data'][$existingCity]->tedade, + 'police_rah' => $reportData['data'][$existingCity]->police_rah, + 'gozaresh_gasht' => $reportData['data'][$existingCity]->gozaresh_gasht, + 'kol_sabt_shode' => $reportData['data'][$existingCity]->kol_sabt_shode, + 'vasel_shode' => $reportData['data'][$existingCity]->vasel_shode ?? 0, + 'vasel_shode_bimeh' => $reportData['data'][$existingCity]->vasel_shode_bimeh ?? 0, + 'vasel_shode_daghi' => $reportData['data'][$existingCity]->vasel_shode_daghi ?? 0, + 'vasel_shode_final' => $reportData['data'][$existingCity]->vasel_shode_final ?? 0, + ]; + } else { + $activities[] = [ + 'name' => $city->name_fa, + 'tedade' => "", + 'police_rah' => "", + 'gozaresh_gasht' => "", + 'kol_sabt_shode' => "", + 'vasel_shode' => "", + 'vasel_shode_bimeh' => "", + 'vasel_shode_daghi' => "", + 'vasel_shode_final' => "", + ]; + } + } + + return view('v3.Reports.AccidentReceipt.ProvinceReport', [ + 'data' => $activities, + 'fromDate' => $reportData['fromDate'], + 'toDate' => $reportData['toDate'], + ]); + } + + /** + * @return array + */ + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + }, + ]; + } + + public function drawings() + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('B1'); + return [$drawing, $drawing2]; + } + + public function styles(Worksheet $sheet) + { + return [ + // Style the first row as bold text. + 'A:BA' => [ + 'font' => [ + 'name' => 'B Nazanin' + ] + ], + ]; + } +} diff --git a/app/Exports/V3/RoadObservation/ComplaintsReport.php b/app/Exports/V3/RoadObservation/ComplaintsReport.php new file mode 100644 index 00000000..e8012634 --- /dev/null +++ b/app/Exports/V3/RoadObservation/ComplaintsReport.php @@ -0,0 +1,67 @@ + $this->data, + ]); + } + + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + $event->sheet->getDelegate()->getStyle('A:U')->getFont()->setName('Arial'); + $event->sheet->getDelegate()->getStyle('A:U') + ->getAlignment() + ->setHorizontal(Alignment::HORIZONTAL_CENTER); + + $event->sheet->getDelegate()->getStyle('A:U') + ->getAlignment() + ->setVertical(Alignment::VERTICAL_CENTER); + } + ]; + } + + public function drawings(): array + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('q1'); + return [$drawing, $drawing2]; + } +} diff --git a/app/Exports/V3/RoadObservation/OperatorCartableReport.php b/app/Exports/V3/RoadObservation/OperatorCartableReport.php new file mode 100644 index 00000000..6285c700 --- /dev/null +++ b/app/Exports/V3/RoadObservation/OperatorCartableReport.php @@ -0,0 +1,70 @@ + $this->data, + ]); + } + + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + $event->sheet->getDelegate()->getStyle('A:U')->getFont()->setName('Arial'); + $event->sheet->getDelegate()->getStyle('A:U') + ->getAlignment() + ->setHorizontal(Alignment::HORIZONTAL_CENTER); + + $event->sheet->getDelegate()->getStyle('A:U') + ->getAlignment() + ->setVertical(Alignment::VERTICAL_CENTER); + } + ]; + } + + public function drawings(): array + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('K1'); + return [$drawing, $drawing2]; + } + +} diff --git a/app/Exports/V3/RoadObservation/SupervisorCartableReport.php b/app/Exports/V3/RoadObservation/SupervisorCartableReport.php new file mode 100644 index 00000000..4aa2b072 --- /dev/null +++ b/app/Exports/V3/RoadObservation/SupervisorCartableReport.php @@ -0,0 +1,69 @@ +data; + + return view('v3.Reports.RoadObservation.SupervisorCartableReport', [ + 'data' => $this->data, + ]); + } + + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + $event->sheet->getDelegate()->getStyle('A:U')->getFont()->setName('Arial'); + $event->sheet->getDelegate()->getStyle('A:U') + ->getAlignment() + ->setHorizontal(Alignment::HORIZONTAL_CENTER); + + $event->sheet->getDelegate()->getStyle('A:U') + ->getAlignment() + ->setVertical(Alignment::VERTICAL_CENTER); + } + ]; + } + + public function drawings(): array + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('K1'); + return [$drawing, $drawing2]; + } +} diff --git a/app/Exports/V3/SafetyAndPrivacy/CartableReport.php b/app/Exports/V3/SafetyAndPrivacy/CartableReport.php new file mode 100644 index 00000000..6c066aa1 --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/CartableReport.php @@ -0,0 +1,69 @@ + $this->data, + ]); + } + + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + }, + ]; + } + + public function drawings(): array + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('B1'); + return [$drawing, $drawing2]; + } + + public function styles(Worksheet $sheet): array + { + return [ + 'A:BA' => [ + 'font' => [ + 'name' => 'B Nazanin' + ] + ], + ]; + } +} \ No newline at end of file diff --git a/app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php b/app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php new file mode 100644 index 00000000..b6e6ccb2 --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php @@ -0,0 +1,78 @@ +data; + $existedProvinces = array_keys($data['activities']); + + foreach (\App\Models\Province::all() as $value) { + $provinceId = $value->id; + + if (!array_key_exists($provinceId, $existedProvinces)) { + $data['activities'][] = (object) [ + 'province_id' => $provinceId, + 'name_fa' => $value->name_fa, + 'sum' => 0, + '89' => ['1' => 0, '2' => 0, '3' => 0], + '90' => ['1' => 0, '2' => 0, '3' => 0], + '91' => ['1' => 0, '2' => 0, '3' => 0], + ]; + } + } + + return view('v3.Reports.SafetyAndPrivacy.CountryActivityReport', [ + 'data' => $data['activities'], + 'fromDate' => $data['fromDate'], + 'toDate' => $data['toDate'], + ]); + } + + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + }, + ]; + } + + public function drawings(): array + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('K1'); + return [$drawing, $drawing2]; + } +} \ No newline at end of file diff --git a/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php b/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php new file mode 100644 index 00000000..399b5bca --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php @@ -0,0 +1,81 @@ +data; + $existedCities = array_keys($data['activities']); + $edarat = EdarateShahri::query()->where('province_id', '=', $this->request->province_id)->get(['id', 'name_fa']); + + foreach ($edarat as $value) { + $edareId = $value->id; + + if (!array_key_exists($edareId, $existedCities)) { + $data['activities'][] = (object) [ + 'edare_shahri_id' => $edareId, + 'name_fa' => $value->name_fa, + 'sum' => 0, + '89' => ['1' => 0, '2' => 0, '3' => 0], + '90' => ['1' => 0, '2' => 0, '3' => 0], + '91' => ['1' => 0, '2' => 0, '3' => 0], + ]; + } + } + + return view('v3.Reports.SafetyAndPrivacy.ProvinceActivityReport', [ + 'data' => $data['activities'], + 'fromDate' => $data['fromDate'], + 'toDate' => $data['toDate'], + ]); + } + + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $event->sheet->getDelegate()->setRightToLeft(true); + }, + ]; + } + + public function drawings(): array + { + $drawing = new Drawing(); + $drawing->setName('Logo'); + $drawing->setDescription('This is my logo'); + $drawing->setPath(public_path('/dist/logo.png')); + $drawing->setWidth(50); + $drawing->setHeight(50); + $drawing->setOffsetX(5); + $drawing->setOffsetY(5); + $drawing->setCoordinates('A1'); + + $drawing2 = new Drawing(); + $drawing2->setName('Logo'); + $drawing2->setDescription('This is my logo'); + $drawing2->setPath(public_path('/dist/141icon.png')); + $drawing2->setWidth(50); + $drawing2->setHeight(50); + $drawing2->setOffsetX(5); + $drawing2->setOffsetY(5); + $drawing2->setCoordinates('K1'); + return [$drawing, $drawing2]; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/V3/DamageManagementController.php b/app/Http/Controllers/V3/DamageManagementController.php new file mode 100644 index 00000000..27da5b63 --- /dev/null +++ b/app/Http/Controllers/V3/DamageManagementController.php @@ -0,0 +1,93 @@ +json($data); + } + + public function list(): JsonResponse + { + $damages = Damage::query()->where('status', '=', 1)->get(); + return $this->successResponse($damages); + } + + + /** + * Store a newly created resource in storage. + */ + public function store(StoreRequest $request): JsonResponse + { + Damage::query()->create([ + 'title' => $request->title, + 'unit' => $request->unit, + 'base_price' => $request->base_price, + 'status' => 1, + ]); + + return $this->successResponse(); + } + + /** + * Display the specified resource. + */ + public function show(Damage $damage): JsonResponse + + { + return $this->successResponse($damage); + } + + /** + * Show the form for editing the specified resource. + */ + + public function update(UpdateRequest $request, Damage $damage): JsonResponse + + { + $damage->update([ + 'title' => $request->title, + 'unit' => $request->unit, + 'base_price' => $request->base_price, + ]); + + return $this->successResponse(); + } + + /** + * Remove the specified resource from storage. + */ + public function activate(Damage $damage): JsonResponse + { + $damage->status == 1 ? $damage->update(['status' => 0]) : $damage->update(['status' => 1]); + + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php b/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php new file mode 100644 index 00000000..5368e931 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php @@ -0,0 +1,342 @@ +dataTable($request); + + auth()->user()->addActivityComplete(1122); + + return response()->json($data); + } + + public function excelReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): BinaryFileResponse + { + auth()->user()->addActivityComplete(1126); + $name = 'گزارش از خسارات وارده به ابنیه فنی و تاسیسات راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + $data = $accidentReceiptTableService->dataTable($request, true); + return Excel::download(new DataTableReport($data['data']), $name); + } + + public function accidentDamage(Accident $accident): JsonResponse + { + return $this->successResponse($accident->damages()->get(['unit', 'amount', 'value'])); + } + + public function store(StoreRequest $request, NominatimService $nominatimService): JsonResponse + { + DB::transaction(function () use ($request, $nominatimService) { + + $province = Province::query()->where('id', '=', $request->province_id)->first(); + $city = City::query()->where('id', '=', $request->city_id)->first(); + + $accidentData = [ + 'province_id' => $province->id, + 'province_fa' => $province->name_fa, + 'city_id' => $city->id, + 'city_fa' => $city->name_fa, + 'axis_name' => $request->axis_name, + 'driver_name' => $request->driver_name, + 'plaque' => $request->plaque, + 'driver_national_code' => $request->driver_national_code, + 'driver_phone_number' => $request->driver_phone_number, + 'user_id' => auth()->user()->id, + 'lat' => $request->lat, + 'lng' => $request->lng, + 'accident_type' => $request->accident_type, + 'accident_date' => $request->accident_date, + 'accident_time' => $request->accident_time, + 'accident_type_fa' => DailyAccidentSettings::query()->where('type', 'accident_type')->where('name', $request->accident_type)->first()->value, + 'way_id' => $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng), + 'report_base' => $request->report_base, + 'police_file' => $request->report_base ? null : FileFacade::save($request->file('police_file'), 'receipts_files/'), + 'police_serial' => $request->police_serial ?? null, + 'police_file_date' => $request->police_file_date ?? null, + 'damage_picture1' => FileFacade::save($request->file('damage_picture1'), 'receipts_files/'), + 'damage_picture2' => FileFacade::save($request->file('damage_picture2'), 'receipts_files/'), + 'status' => AccidentStates::BEDON_EGHDAM->value, + 'status_fa' => AccidentStates::name(AccidentStates::BEDON_EGHDAM->value), + ]; + + $sum = 0; + $damageData = []; + + foreach ($request->damage_items as $key => $item) { + $damage = Damage::query()->find($item['id']); + $damageData[$item['id']] = [ + 'value' => $item['value'], + 'unit' => $damage->unit, + 'amount' => $item['amount'], + ]; + $sum += $item['amount']; + } + + $ojrate_nasb = $sum/100*20; + $sum += $ojrate_nasb; + + $accidentData['ojrate_nasb'] = $ojrate_nasb; + $accidentData['sum'] = $sum; + + $accident = Accident::query()->create($accidentData); + + $accident->damages()->attach($damageData); + + auth()->user()->addActivityComplete(1123); + }); + + return $this->successResponse(); + } + + public function show(Accident $accident): JsonResponse + { + return $this->successResponse($accident->load('damages')); + } + + public function update(Accident $accident, UpdateRequest $request, NominatimService $nominatimService): JsonResponse + { + DB::transaction(function () use ($request, $accident, $nominatimService) { + + $province = Province::query()->where('id', '=', $request->province_id)->first(); + $city = City::query()->where('id', '=', $request->city_id)->first(); + + $accidentData = [ + 'province_id' => $province->id, + 'province_fa' => $province->name_fa, + 'city_id' => $city->id, + 'city_fa' => $city->name_fa, + 'axis_name' => $request->axis_name, + 'driver_name' => $request->driver_name, + 'plaque' => $request->plaque, + 'driver_national_code' => $request->driver_national_code, + 'driver_phone_number' => $request->driver_phone_number, + 'user_id' => auth()->user()->id, + 'lat' => $request->lat, + 'lng' => $request->lng, + 'accident_type' => $request->accident_type, + 'accident_date' => $request->accident_date, + 'accident_time' => $request->accident_time, + 'accident_type_fa' => DailyAccidentSettings::query()->where('type', 'accident_type')->where('name', $request->accident_type)->first()->value, + 'way_id' => $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng), + 'report_base' => $request->report_base, + 'police_serial' => $request->police_serial ?? null, + 'police_file_date' => $request->police_file_date ?? null, + ]; + + if ($request->report_base && $accident->police_file) { + FileFacade::delete($accident->police_file, true); + } + + if (!$request->report_base && $request->has('police_file')) { + FileFacade::delete($accident->police_file, true); + $accidentData['police_file'] = FileFacade::save($request->file('police_file'), "receipts_files/{$accident->id}/"); + } + + if ($request->has('damage_picture1')) { + FileFacade::delete($accident->damage_picture1, true); + $accidentData['damage_picture1'] = FileFacade::save($request->file('damage_picture1'), "receipts_files/{$accident->id}/"); + } + + if ($request->has('damage_picture2')) { + FileFacade::delete($accident->damage_picture2, true); + $accidentData['damage_picture2'] = FileFacade::save($request->file('damage_picture2'), "receipts_files/{$accident->id}/"); + } + + $sum = 0; + $damageData = []; + + foreach ($request->damage_items as $key => $item) { + $damage = Damage::query()->find($item['id']); + $damageData[$item['id']] = [ + 'value' => $item['value'], + 'unit' => $damage->unit, + 'amount' => $item['amount'], + ]; + $sum += $item['amount']; + } + + $ojrate_nasb = $sum/100*20; + $sum += $ojrate_nasb; + + $accidentData['ojrate_nasb'] = $ojrate_nasb; + $accidentData['sum'] = $sum; + + $accident->update($accidentData); + + $accident->damages()->sync($damageData); + + auth()->user()->addActivityComplete(1124); + }); + + return $this->successResponse(); + } + + public function destroy(Accident $accident): JsonResponse + { + FileFacade::delete('storage/receipts_files/'.$accident->id); + + DB::transaction(function () use ($accident) { + + $accident->damages()->detach(); + + $accident->delete(); + + auth()->user()->addActivityComplete(1125); + }); + + return $this->successResponse(); + } + + public function generateInsuranceLetter(Accident $accident): JsonResponse + { + DB::transaction(function () use ($accident) { + $accident->update([ + 'status' => AccidentStates::SODOR_NAME_BIME_VA_DAGHI->value, + 'status_fa' => AccidentStates::name(AccidentStates::SODOR_NAME_BIME_VA_DAGHI->value), + ]); + + auth()->user()->addActivityComplete(1126); + }); + + $account_data = Province::query()->where('id', $accident->province_id)->first(); + + return $this->successResponse([ + $account_data, + $accident->load('damages') + ]); + } + + public function confirmPaymentInfo(ConfirmPaymentInfoRequest $request, Accident $accident): JsonResponse + { + DB::transaction(function () use ($request, $accident) { + + $accident->update([ + 'deposit_insurance_image' => $request->deposit_insurance_image != null ? FileFacade::save($request->deposit_insurance_image, "receipts_files/{$accident->id}/deposit_insurance/") : null, + 'deposit_insurance_amount' => $request->deposit_insurance_amount ?? 0, + 'deposit_daghi_image' => $request->deposit_insurance_image != null ? FileFacade::save($request->deposit_daghi_image, "receipts_files/{$accident->id}/deposit_daghi/") : null, + 'deposit_daghi_amount' => $request->deposit_daghi_amount ?? 0, + 'status' => AccidentStates::SABT_FISH->value, + 'status_fa' => AccidentStates::name(AccidentStates::SABT_FISH->value), + ]); + + auth()->user()->addActivityComplete(1132); + }); + + return $this->successResponse(); + } + + public function submitInvoice(Accident $accident, PaymentService $paymentService): JsonResponse + { + $final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount); + + if ($final_amount < 0) { + return $this->errorResponse('error'); + } + + $bill_code = $paymentService->invoiceBillApi($accident->driver_national_code, $final_amount); + + DB::transaction(function () use ($bill_code, $final_amount, $accident) { + + $accident->update([ + 'final_amount' => $final_amount, + 'bill_code' => $bill_code, + 'status' => AccidentStates::SODOR_FACTOR->value, + 'status_fa' => AccidentStates::name(AccidentStates::SODOR_FACTOR->value), + ]); + + auth()->user()->addActivityComplete(1129); + }); + + $msg = "فاکتور با شناسه پرداخت \n" . explode("/", $accident->bill_code)[0]. "\n در سامانه سازمان راهداری ثبت شد. برای پرداخت از لینک زیر اقدام نمایید.\n\n".env("PAYMENT_LINK")."/#/pay/".explode("/", $accident->bill_code)[0]."/$final_amount"; + + Sms::sendSms($accident->driver_phone_number, $msg); + + return $this->successResponse(); + } + + public function checkPaymentStatus(Accident $accident, PaymentService $paymentService): JsonResponse + { + DB::transaction(function () use ($accident, $paymentService) { + if ($accident->final_amount > 0) { + + $response = json_decode($paymentService->callPaymentStatusBillApi(explode("/", $accident->bill_code)[0])); + + if ($response->isPayed) { + $accident->update([ + 'status' => AccidentStates::PARDAKHT_FACTOR->value, + 'status_fa' => AccidentStates::name(AccidentStates::PARDAKHT_FACTOR->value), + ]); + } + } + else + { + $accident->update([ + 'status' => AccidentStates::PARDAKHT_FACTOR->value, + 'status_fa' => AccidentStates::name(AccidentStates::PARDAKHT_FACTOR->value), + ]); + } + + auth()->user()->addActivityComplete(1130); + }); + + return $this->successResponse($accident); + } + + public function generatePoliceDocument(Request $request, Accident $accident): JsonResponse + { + DB::transaction(function () use ($request, $accident) { + + $accident->update([ + 'status' => AccidentStates::SODOR_NAME_POLICE_RAH->value, + 'status_fa' => AccidentStates::name(AccidentStates::SODOR_NAME_POLICE_RAH->value), + ]); + + auth()->user()->addActivityComplete(1131); + }); + + return $this->successResponse($accident); + } + + public function sendSmsAgain(Accident $accident): JsonResponse + { + $msg = "فاکتور با شناسه پرداخت \n" . explode("/", $accident->bill_code)[0]. "\n در سامانه سازمان راهداری ثبت شد. برای پرداخت از لینک زیر اقدام نمایید.\n\n".env("PAYMENT_LINK")."/#/pay/".explode("/", $accident->bill_code)[0]."/$accident->final_amount"; + + Sms::sendSms($accident->driver_phone_number, $msg); + + return $this->successResponse(); + } + + public function accidentTypes(): JsonResponse + { + return $this->successResponse(DailyAccidentSettings::query()->where('type', 'accident_type')->get()); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/ItemsManagementController.php b/app/Http/Controllers/V3/Dashboard/ItemsManagementController.php new file mode 100644 index 00000000..dcdf0094 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/ItemsManagementController.php @@ -0,0 +1,34 @@ +successResponse( + InfoItem::query() + ->select('item as id', 'item_str as name', 'icon') + ->where('type', '=', 'item') + ->groupby('item') + ->get() + ); + } + + public function getSubItems($item): JsonResponse + { + return $this->successResponse( + InfoItem::query() + ->where('item', '=', $item) + ->select('id', 'item', 'item_str', 'sub_item_str as name', 'sub_item_unit as unit', 'needs_image', 'needs_end_point', 'sub_item') + ->get() + ); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/OtpManagementController.php b/app/Http/Controllers/V3/Dashboard/OtpManagementController.php new file mode 100644 index 00000000..307dc05d --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/OtpManagementController.php @@ -0,0 +1,22 @@ +ip(), $request->phone_number, "کد تایید تلفن همراه سامانه جامع راهداری (RMS) : \n"); + + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/ReceiptController.php b/app/Http/Controllers/V3/Dashboard/ReceiptController.php deleted file mode 100644 index 0e9ad4dd..00000000 --- a/app/Http/Controllers/V3/Dashboard/ReceiptController.php +++ /dev/null @@ -1,131 +0,0 @@ -user(); - $query = null; - - if ($user->hasPermissionTo('show-receipt')) { - $query = Accident::with('damages'); - } else { - if (is_null($user->province_id)) { - return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); - } - - $query = Accident::with('damages')->where('province_id', '=', $user->province_id); - } - - $data = DataTableFacade::run( - $query, - $request, - allowedFilters: $allowedFilters, - allowedSortings: $allowedSortings - ); - - - $user->addActivityComplete(1122); - - return $this->successResponse($data); - } - - public function store(Request $request, NominatimService $nominatimService) - { - DB::transaction(function () use ($request, $nominatimService) { - - $province = Province::query()->where('id', '=', $request->province_id)->first(); - $city = City::query()->where('id', '=', $request->city_id)->first(); - - $accident = [ - 'province_id' => $province->id, - 'province_fa' => $province->name_fa, - 'city_id' => $city->id, - 'city_fa' => $city->name_fa, - 'axis_name' => $request->axis_name, - 'driver_name' => $request->driver_name, - 'plaque' => $request->plaque, - 'driver_national_code' => $request->driver_national_code, - 'driver_phone_number' => $request->driver_phone_number, - 'user_id' => auth()->user()->id, - 'lat' => $request->lat, - 'lng' => $request->lng, - 'accident_type' => $request->accident_type, - 'accident_date' => $request->accident_date, - 'accident_time' => $request->accident_time, - 'accident_type_fa' => DailyAccidentSettings::where('type', 'accident_type')->where('name', $request->accident_type)->first()->value, - 'way_id' => $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng), - ]; - - if ($request->report_base) { - $accident['report_base'] = 1; - } else { - $accident['police_file'] = $request->file('police_file')->storeAs('receipts_files/'.$accident->id, 'police_file_'.$accident->id.'_'.time().'.'.$request->file('police_file')->extension(), 'public'); - $accident['police_serial'] = $request->police_serial; - $accident['police_file_date'] = $request->police_file_date; - $accident['report_base'] = 0; - } - - if ($request->has('damage_picture1')) { - $new_accident->damage_picture1 = $request->file('damage_picture1')->storeAs('receipts_files/'.$new_accident->id, 'damage_picture1_'.$new_accident->id.'_'.time().'.'.$request->file('damage_picture1')->extension(), 'public'); - } - - if ($request->has('damage_picture2')) { - $new_accident->damage_picture2 = $request->file('damage_picture2')->storeAs('receipts_files/'.$new_accident->id, 'damage_picture2_'.$new_accident->id.'_'.time().'.'.$request->file('damage_picture2')->extension(), 'public'); - } - - $new_accident->save(); - $sum = 0; - foreach (json_decode($request->items_damge) as $key => $item) { - $damage = Damage::find($item->id); - $new_accident->damages()->attach($item->id, [ - 'value' => $item->value, - 'unit' => $damage->unit, - 'amount' => $item->amount, - ]); - $sum += $item->amount; - } - - $ojrate_nasb = $sum/100*20; - $new_accident->ojrate_nasb = $ojrate_nasb; - - $sum += $ojrate_nasb; - $new_accident->sum = $sum; - $new_accident->withoutAction(); - $new_accident->save(); - $msg = "درخواست شما بابت پرداخت خسارت وارده به ابنیه فنی و تاسیسات راه با کد یکتا ".$new_accident->id." ثبت شد.\n".verta()->now()->format('Y/m/d H:i') ; - Sms::sendSms($request->phone_number, $msg); - auth()->user()->addActivityComplete(1123); - }); - } -} diff --git a/app/Http/Controllers/V3/Dashboard/Reports/AccidentReceiptReportController.php b/app/Http/Controllers/V3/Dashboard/Reports/AccidentReceiptReportController.php new file mode 100644 index 00000000..e9a29694 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/Reports/AccidentReceiptReportController.php @@ -0,0 +1,59 @@ +countryReport($request); + return $this->successResponse([ + 'activities' => $data['data'], + 'provinces' => Province::all(['id', 'name_fa']), + ]); + } + + public function provinceReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): JsonResponse + { + $data = $accidentReceiptTableService->provinceReport($request); + return $this->successResponse([ + 'activities' => $data['data'], + 'cities' => City::query()->where('province_id', '=', $request->province_id) + ->where('type_id', '=', 1) + ->get(['id', 'name_fa']), + ]); + } + + public function countryExcelReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): BinaryFileResponse + { + $data = $accidentReceiptTableService->countryReport($request); + $name = 'گزارش از خسارات وارده به ابنیه فنی و تاسیسات راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + return Excel::download(new CountryReport($data), $name); + } + + public function provinceExcelReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): BinaryFileResponse + { + $data = $accidentReceiptTableService->provinceReport($request); + $name = 'گزارش از خسارات وارده به ابنیه فنی و تاسیسات راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + return Excel::download(new ProvinceReport([ + 'report' => $data, + 'cities' => City::query()->where('province_id', '=', $request->province_id) + ->where('type_id', '=', 1) + ->get(['id', 'name_fa']), + ]), $name); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Reports/RoadItemsReportController.php b/app/Http/Controllers/V3/Dashboard/Reports/RoadItemsReportController.php index 70d15be0..46b47699 100644 --- a/app/Http/Controllers/V3/Dashboard/Reports/RoadItemsReportController.php +++ b/app/Http/Controllers/V3/Dashboard/Reports/RoadItemsReportController.php @@ -12,7 +12,7 @@ use App\Models\EdarateShahri; use App\Models\InfoItem; use App\Models\Province; use App\Models\RoadItemsProject; -use App\Services\Reports\RoadItemReportService; +use App\Services\Cartables\RoadItemTableService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Maatwebsite\Excel\Facades\Excel; @@ -32,9 +32,9 @@ class RoadItemsReportController extends Controller ]); } - public function countryActivityPerSubItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse + public function countryActivityPerSubItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse { - $activities = $roadItemReportService->countryActivityPerSubItem($request); + $activities = $roadItemTableService->countryActivityPerSubItem($request); $provinces = Province::all(['id', 'name_fa']); $subItems = InfoItem::query() ->where('item', $request->item) @@ -47,9 +47,9 @@ class RoadItemsReportController extends Controller ]); } - public function provinceActivityPerSubItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse + public function provinceActivityPerSubItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse { - $activities = $roadItemReportService->provinceActivityPerSubItem($request); + $activities = $roadItemTableService->provinceActivityPerSubItem($request); $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); @@ -64,13 +64,13 @@ class RoadItemsReportController extends Controller ]); } - public function countryActivityPerItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse + public function countryActivityPerItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse { if (auth()->check()) { auth()->user()->addActivityComplete(1033); } - $activities = $roadItemReportService->countryActivityPerItem($request); + $activities = $roadItemTableService->countryActivityPerItem($request); $provinces = Province::all(['id', 'name_fa']); return $this->successResponse([ @@ -79,9 +79,9 @@ class RoadItemsReportController extends Controller ]); } - public function provinceActivityPerItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse + public function provinceActivityPerItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse { - $activities = $roadItemReportService->provinceActivityPerItem($request); + $activities = $roadItemTableService->provinceActivityPerItem($request); $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); return $this->successResponse([ @@ -90,11 +90,11 @@ class RoadItemsReportController extends Controller ]); } - public function countryActivityExcelPerItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse + public function countryActivityExcelPerItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse { auth()->user()->addActivityComplete(1034); $name = 'گزارش کشوری از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; - $activities = $roadItemReportService->countryActivityPerItem($request); + $activities = $roadItemTableService->countryActivityPerItem($request); return Excel::download(new CountryActivityPerItemReport([ 'activities' => $activities, 'provinces' => Province::all(['id', 'name_fa']), @@ -102,11 +102,11 @@ class RoadItemsReportController extends Controller ]), $name); } - public function provinceActivityExcelPerItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse + public function provinceActivityExcelPerItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse { auth()->user()->addActivityComplete(1034); $name = 'گزارش استانی از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; - $activities = $roadItemReportService->provinceActivityPerItem($request); + $activities = $roadItemTableService->provinceActivityPerItem($request); return Excel::download(new ProvinceActivityPerItemReport([ 'activities' => $activities, 'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']), @@ -114,11 +114,11 @@ class RoadItemsReportController extends Controller ]), $name); } - public function countryActivityExcelPerSubItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse + public function countryActivityExcelPerSubItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse { auth()->user()->addActivityComplete(1034); $name = "گزارش کشوری از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx'; - $activities = $roadItemReportService->countryActivityPerSubItem($request); + $activities = $roadItemTableService->countryActivityPerSubItem($request); $subItems = InfoItem::query() ->where('item', $request->item) ->get(['id', 'item', 'item_str', 'sub_item_str', 'sub_item_unit', 'sub_item']); @@ -130,10 +130,10 @@ class RoadItemsReportController extends Controller ]), $name); } - public function provinceActivityExcelPerSubItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse + public function provinceActivityExcelPerSubItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse { auth()->user()->addActivityComplete(1034); - $activities = $roadItemReportService->provinceActivityPerSubItem($request); + $activities = $roadItemTableService->provinceActivityPerSubItem($request); $name = "گزارش استانی از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx'; $subItems = InfoItem::query() ->where('item', $request->item) diff --git a/app/Http/Controllers/V3/Dashboard/Reports/RoadObservationReportController.php b/app/Http/Controllers/V3/Dashboard/Reports/RoadObservationReportController.php new file mode 100644 index 00000000..eb20abf8 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/Reports/RoadObservationReportController.php @@ -0,0 +1,28 @@ +reportIndex($request); + return response()->json($data['data']); + } + + public function excelReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse + { + $name = 'گزارش رسیدگی به شکایات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; + $data = $roadObservationTableService->reportIndex($request); + return Excel::download(new ReportComplaintsExport($data), $name); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Reports/RoadPatrolReportController.php b/app/Http/Controllers/V3/Dashboard/Reports/RoadPatrolReportController.php index 9f485e05..d4382427 100644 --- a/app/Http/Controllers/V3/Dashboard/Reports/RoadPatrolReportController.php +++ b/app/Http/Controllers/V3/Dashboard/Reports/RoadPatrolReportController.php @@ -10,7 +10,7 @@ use App\Models\EdarateShahri; use App\Models\Province; use App\Models\RoadObserved; use App\Models\RoadPatrol; -use App\Services\Reports\RoadPatrolReportService; +use App\Services\Cartables\RoadPatrolTableService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Maatwebsite\Excel\Facades\Excel; @@ -19,9 +19,9 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse; class RoadPatrolReportController extends Controller { use ApiResponse; - public function countryPatrolActivity(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse + public function countryPatrolActivity(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse { - $activities = $roadPatrolReportService->countryActivity($request); + $activities = $roadPatrolTableService->countryActivity($request); $provinces = Province::all(['id', 'name_fa']); @@ -31,11 +31,11 @@ class RoadPatrolReportController extends Controller ]); } - public function provincePatrolActivity(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse + public function provincePatrolActivity(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse { $request->validate(["province_id" => "required",]); - $activities = $roadPatrolReportService->provinceActivity($request); + $activities = $roadPatrolTableService->provinceActivity($request); $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); @@ -45,9 +45,9 @@ class RoadPatrolReportController extends Controller ]); } - public function countryActivityExcel(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse + public function countryActivityExcel(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse { - $activities = $roadPatrolReportService->countryActivity($request); + $activities = $roadPatrolTableService->countryActivity($request); $provinces = Province::all(['id', 'name_fa']); $name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; @@ -58,9 +58,9 @@ class RoadPatrolReportController extends Controller ]), $name); } - public function provinceActivityExcel(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse + public function provinceActivityExcel(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse { - $activities = $roadPatrolReportService->provinceActivity($request); + $activities = $roadPatrolTableService->provinceActivity($request); $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); $name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; diff --git a/app/Http/Controllers/V3/Dashboard/Reports/SafetyAndPrivacyReportController.php b/app/Http/Controllers/V3/Dashboard/Reports/SafetyAndPrivacyReportController.php new file mode 100644 index 00000000..cc3d5673 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/Reports/SafetyAndPrivacyReportController.php @@ -0,0 +1,52 @@ +countryActivity($request); + return $this->successResponse([ + 'activities' => $data['activities'], + 'provinces' => Province::all(['id', 'name_fa']) + ]); + } + + public function provinceActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse + { + $data = $safetyAndPrivacyTableService->provinceActivity($request); + return $this->successResponse([ + 'activities' => $data['activities'], + 'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']), + ]); + } + + public function countryExcelActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse + { + $data = $safetyAndPrivacyTableService->countryActivity($request); + $name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + return Excel::download(new CountryActivityReport($data), $name); + } + + public function provinceExcelActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse + { + $data = $safetyAndPrivacyTableService->provinceActivity($request); + $name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + return Excel::download(new ProvinceActivityReport($data, $request), $name); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/RoadItemsProjectController.php b/app/Http/Controllers/V3/Dashboard/RoadItemsProjectController.php index 00295fb7..bcb9e6fb 100644 --- a/app/Http/Controllers/V3/Dashboard/RoadItemsProjectController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadItemsProjectController.php @@ -13,7 +13,7 @@ use App\Models\EdarateShahri; use App\Models\InfoItem; use App\Models\RoadItemsProject; use App\Services\NominatimService; -use App\Services\Reports\RoadItemReportService; +use App\Services\Cartables\RoadItemTableService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; @@ -28,9 +28,9 @@ class RoadItemsProjectController extends Controller /** * Display a listing of the resource. */ - public function supervisorIndex(Request $request, RoadItemReportService $roadItemReportService): JsonResponse + public function supervisorIndex(Request $request, RoadItemTableService $roadItemTableService): JsonResponse { - $data = $roadItemReportService->supervisorCartableReport($request); + $data = $roadItemTableService->supervisorCartableReport($request); foreach ($data['data'] as $road_item) { if (Gate::allows('gate-supervise-road-item', $road_item)) { @@ -96,16 +96,16 @@ class RoadItemsProjectController extends Controller } - public function supervisorCartableReport(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse + public function supervisorCartableReport(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse { $name = 'گزارش از کارتابل ارزیابی فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; - $data = $roadItemReportService->supervisorCartableReport($request); + $data = $roadItemTableService->supervisorCartableReport($request, true); return Excel::download(new SupervisorCartableReport($data['data']), $name); } - public function operatorIndex(Request $request, RoadItemReportService $roadItemReportService): JsonResponse + public function operatorIndex(Request $request, RoadItemTableService $roadItemTableService): JsonResponse { - $data = $roadItemReportService->operatorCartableReport($request); + $data = $roadItemTableService->operatorCartableReport($request); return response()->json($data); } @@ -264,10 +264,25 @@ class RoadItemsProjectController extends Controller return $this->successResponse(); } - public function operatorCartableReport(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse + public function operatorCartableReport(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse { $name = 'گزارش از کارتابل عملیات فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; - $data = $roadItemReportService->operatorCartableReport($request); + $data = $roadItemTableService->operatorCartableReport($request, true); return Excel::download(new OperatorCartableReport($data['data']), $name); } + + public function roadItemMachine(RoadItemsProject $roadItemsProject): JsonResponse + { + return $this->successResponse($roadItemsProject->cmmsMachines()->get(['cmms_machines.id', 'cmms_machines.machine_code', 'cmms_machines.car_name', 'cmms_machines.plak_number'])); + } + + public function roadItemRahdar(RoadItemsProject $roadItemsProject): JsonResponse + { + return $this->successResponse($roadItemsProject->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code'])); + } + + public function roadItemFile(RoadItemsProject $roadItemsProject): JsonResponse + { + return $this->successResponse($roadItemsProject->files()->get(['path'])); + } } diff --git a/app/Http/Controllers/V3/Dashboard/RoadObservationController.php b/app/Http/Controllers/V3/Dashboard/RoadObservationController.php new file mode 100644 index 00000000..a3b97c4c --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/RoadObservationController.php @@ -0,0 +1,308 @@ +json($roadObservationTableService->supervisorCartableIndex($request)); + } + + public function verifyBySupervisor(VerifyBySupervisorRequest $request, RoadObserved $roadObserved): JsonResponse + { + $statusFa = $request->verify == 1 ? 'تایید شده' : 'عدم تایید'; + + $roadObserved->update([ + 'status' => $request->verify, + 'status_fa' => $statusFa, + 'supervisor_id' => auth()->user()->id, + 'supervisor_name' => auth()->user()->name, + 'supervisor_description' => $request->description, + 'supervising_time' => now(), + ]); + + auth()->user()->addActivityComplete(1138); + + return $this->successResponse(); + } + + public function supervisorCartableReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse + { + $name = 'گزارش از کارتابل ارزیابی واکنش سریع '. verta()->now()->format('Y-m-d H:i') . '.xlsx'; + $data = $roadObservationTableService->supervisorCartableIndex($request); + + return Excel::download(new SupervisorCartableReport($data['data']), $name); + } + + public function operatorIndex(Request $request, RoadObservationTableService $roadObservationTableService): JsonResponse + { + return response()->json($roadObservationTableService->operatorCartableIndex($request)); + } + + public function operatorCartableReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse + { + $name = 'گزارش از کارتابل عملیات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; + $data = $roadObservationTableService->operatorCartableIndex($request); + return Excel::download(new OperatorCartableReport($data['data']), $name); + } + + public function complaintsIndex(Request $request, RoadObservationTableService $roadObservationTableService): JsonResponse + { + return response()->json($roadObservationTableService->complaintsIndex($request)); + } + + public function complaintsReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse + { + $name = 'گزارش از رسیدگی به شکایات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; + $data = $roadObservationTableService->complaintsIndex($request); + return Excel::download(new ComplaintsReport($data['data']), $name); + } + + public function show(RoadObserved $roadObserved): JsonResponse + { + return $this->successResponse($roadObserved->only(['rms_status', 'rms_description', 'image_before', 'image_after', 'rms_start_latlng'])); + } + + public function register(RegisterRequest $request, RoadObserved $roadObserved, NikarayanService $nikarayanService): JsonResponse + { + $roadObservedData = [ + 'status' => 0, + 'status_fa' => 'در حال بررسی', + 'rms_status' => $request->rms_status ?? $roadObserved->rms_status, + 'rms_description' => $request->rms_description ?? $roadObserved->rms_description, + ]; + + $roadObservedHistoryData = [ + 'user_id' => auth()->user()->id, + 'previous_rms_status' => $roadObserved->rms_status, + 'previous_rms_start_latlng' => $roadObserved->rms_start_latlng, + 'previous_rms_end_latlng' => $roadObserved->rms_end_latlng, + 'previous_rms_description' => $roadObserved->rms_description, + 'new_files' => json_encode([]) + ]; + + if ($request->rms_status == 1) { + + $files_path = []; + + $roadObserved->files()->where('path', 'like', '%_image_before%')->delete(); + $roadObserved->files()->where('path', 'like', '%_image_after%')->delete(); + + $image_before = FileFacade::save($request->image_before, "road_observeds/{$roadObserved->id}/"); + $image_after = FileFacade::save($request->image_after, "road_observeds/{$roadObserved->id}/"); + + $files_path[0]['path'] = $image_before; + $files_path[1]['path'] = $image_after; + + $files = json_encode($files_path); + $now_date_time = Carbon::now(); + + $roadObservedData['image_after'] = $image_after; + $roadObservedData['image_before'] = $image_before; + $roadObservedData['rms_start_latlng'] = explode(',', $request->start_point); + $roadObservedData['updated_at_fa'] = Verta::instance($now_date_time); + $roadObservedData['rms_last_activity_fa'] = Verta::instance($now_date_time); + $roadObservedData['rms_last_activity'] = $now_date_time; + $roadObservedHistoryData['new_files'] = $files; + } + + $roadObserved->problemHistories()->create($roadObservedHistoryData); + $roadObserved->update($roadObservedData); + + auth()->user()->addActivityComplete(1142); + + try { + $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, json_encode($roadObservedHistoryData['new_files'])); + } + catch (SoapFault $e) { + + $msg = "error in send to nikarayan at" . date("Y-m-d H:i:s") . "\n"; + $msg .= $e->getMessage(); + Sms::sendSms(env('RMS_CTO_PHONE_NUMBER'), $msg); + } + + return $this->successResponse(); + } + + public function modifyRegistration(ModifyRegisterationRequest $request, RoadObserved $roadObserved, NikarayanService $nikarayanService): JsonResponse + { + $roadObservedData = [ + 'status' => 0, + 'status_fa' => 'در حال بررسی', + 'rms_status' => $request->rms_status ?? $roadObserved->rms_status, + 'rms_description' => $request->rms_description ?? $roadObserved->rms_description, + ]; + + $roadObservedHistoryData = [ + 'user_id' => auth()->user()->id, + 'previous_rms_status' => $roadObserved->rms_status, + 'previous_rms_start_latlng' => $roadObserved->rms_start_latlng, + 'previous_rms_end_latlng' => $roadObserved->rms_end_latlng, + 'previous_rms_description' => $roadObserved->rms_description, + 'new_files' => json_encode([]) + ]; + + if ($request->rms_status == 1) { + + $files_path = []; + + $roadObserved->files()->where('path', 'like', '%_image_before%')->delete(); + $roadObserved->files()->where('path', 'like', '%_image_after%')->delete(); + + if ($request->has('image_before')) { + if ($roadObserved->image_before) { + FileFacade::delete($roadObserved->image_before, true); + } + $image_before = FileFacade::save($request->image_before, "road_observeds/{$roadObserved->id}/"); + $roadObservedData['image_before'] = $image_before; + $files_path[0]['path'] = $image_before; + } + + if ($request->has('image_after')) { + if ($roadObserved->image_after) { + FileFacade::delete($roadObserved->image_after, true); + } + $image_after = FileFacade::save($request->image_after, "road_observeds/{$roadObserved->id}/"); + $roadObservedData['image_after'] = $image_after; + $files_path[1]['path'] = $image_after; + } + + $files = json_encode($files_path); + $now_date_time = Carbon::now(); + + $roadObservedData['rms_start_latlng'] = explode(',', $request->start_point); + $roadObservedData['updated_at_fa'] = Verta::instance($now_date_time); + $roadObservedData['rms_last_activity_fa'] = Verta::instance($now_date_time); + $roadObservedData['rms_last_activity'] = $now_date_time; + $roadObservedHistoryData['new_files'] = $files; + } + + $roadObserved->problemHistories()->create($roadObservedHistoryData); + $roadObserved->update($roadObservedData); + + auth()->user()->addActivityComplete(1142); + + try { + $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, json_encode($roadObservedHistoryData['new_files'])); + } + catch (SoapFault $e) { + + $msg = "error in send to nikarayan at" . date("Y-m-d H:i:s") . "\n"; + $msg .= $e->getMessage(); + Sms::sendSms(env('RMS_CTO_PHONE_NUMBER'), $msg); + } + + return $this->successResponse(); + } + + public function refer(ReferRequest $request, RoadObserved $roadObserved): JsonResponse + { + $province = Province::query()->find($request->province_id); + + RoadObservationHistory::query()->create([ + 'id' => $roadObserved->id, + 'user_id' => auth()->user()->id, + 'action' => 'refer', + 'description' => $request->refer_description, + 'from_edareh' => $roadObserved->edarate_shahri_id, + 'to_edareh' => $request->edarate_shahri_id, + 'from_province' => $roadObserved->province_id, + 'to_province' => $province->id + ]); + + $roadObserved->update([ + 'edarate_shahri_id' => $request->edarate_shahri_id, + 'province_id' => $province->id, + 'province_fa' => $province->name_fa, + ]); + + auth()->user()->addActivityComplete(1037); + + return $this->successResponse(); + } + + public function referList(RoadObserved $roadObserved): JsonResponse + { + $data = RoadObservationHistory::query() + ->where('id', '=', $roadObserved->id) + ->where('action', '=', 'refer') + ->orderBy('created_at', 'desc') + ->get([ + 'created_at', 'description', 'from_edareh', 'to_edareh', + 'from_province', 'to_province', 'user_id' + ]); + + foreach ($data as $key => $value) { + $data[$key]->from_edareh = EdarateShahri::query()->find($value->from_edareh)->name_fa ?? null; + $data[$key]->to_edareh = EdarateShahri::query()->find($value->to_edareh)->name_fa ?? null; + $data[$key]->from_province = Province::query()->find($value->from_province)->name_fa ?? null; + $data[$key]->to_province = Province::query()->find($value->to_province)->name_fa ?? null; + $user = User::query()->find($value->user_id); + $data[$key]->user = $user->first_name . ' ' . $user->last_name; + } + return $this->successResponse($data); + } + + public function restore(RestoreRequest $request, RoadObserved $roadObserved): JsonResponse + { + if ($roadObserved->image_before) { + FileFacade::delete($roadObserved->image_before); + } + + if ($roadObserved->image_after) { + FileFacade::delete($roadObserved->image_after); + } + + $roadObserved->update([ + 'image_before' => null, + 'image_after' => null, + 'rms_last_activity' => null, + 'rms_last_activity_fa' => null, + 'updated_at_fa' => null, + 'updated_at' => null, + 'rms_status' => 0, + 'status' => null, + 'status_fa' => null, + ]); + + RoadObservationHistory::query()->create([ + 'id' => $roadObserved->id, + 'user_id' => auth()->user()->id, + 'action' => 'restore', + 'description' => $request->restore_description, + ]); + + auth()->user()->addActivityComplete(1141); + + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/RoadPatrolProjectController.php b/app/Http/Controllers/V3/Dashboard/RoadPatrolProjectController.php index 6056a563..98550c02 100644 --- a/app/Http/Controllers/V3/Dashboard/RoadPatrolProjectController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadPatrolProjectController.php @@ -15,7 +15,7 @@ use App\Models\RoadItemsProject; use App\Models\RoadObserved; use App\Models\RoadPatrol; use App\Services\NominatimService; -use App\Services\Reports\RoadPatrolReportService; +use App\Services\Cartables\RoadPatrolTableService; use Carbon\Carbon; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -30,9 +30,9 @@ class RoadPatrolProjectController extends Controller { use ApiResponse; - public function supervisorIndex(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse + public function supervisorIndex(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse { - $data = $roadPatrolReportService->supervisorCartableReport($request); + $data = $roadPatrolTableService->supervisorCartableReport($request); foreach ($data['data'] as $road_patrol) { if (Gate::allows('gate-supervise-road-item', $road_patrol)) { @@ -80,16 +80,16 @@ class RoadPatrolProjectController extends Controller return $this->successResponse(); } - public function supervisorCartableReport(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse + public function supervisorCartableReport(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse { $name = 'گزارش از کارتابل ارزیابی گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; - $data = $roadPatrolReportService->supervisorCartableReport($request); + $data = $roadPatrolTableService->supervisorCartableReport($request, true); return Excel::download(new SupervisorCartableReport($data['data']), $name); } - public function operatorIndex(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse + public function operatorIndex(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse { - $data = $roadPatrolReportService->operatorCartableReport($request); + $data = $roadPatrolTableService->operatorCartableReport($request); return response()->json($data); } @@ -322,10 +322,20 @@ class RoadPatrolProjectController extends Controller return $this->successResponse($roadPatrol); } - public function operatorCartableReport(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse + public function operatorCartableReport(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse { $name = 'گزارش از کارتابل عملیات گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; - $data = $roadPatrolReportService->operatorCartableReport($request); + $data = $roadPatrolTableService->operatorCartableReport($request, true); return Excel::download(new OperatorCartableReport($data['data']), $name); } + + public function roadPatrolMachine(RoadPatrol $roadPatrol): JsonResponse + { + return $this->successResponse($roadPatrol->cmmsMachines()->get(['cmms_machines.id', 'cmms_machines.machine_code', 'cmms_machines.car_name', 'cmms_machines.plak_number'])); + } + + public function roadPatrolRahdar(RoadPatrol $roadPatrol): JsonResponse + { + return $this->successResponse($roadPatrol->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code'])); + } } diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php new file mode 100644 index 00000000..a36842d3 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php @@ -0,0 +1,189 @@ +json($safetyAndPrivacyTableService->datatable($request)); + } + + public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse + { + $name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + $data = $safetyAndPrivacyTableService->datatable($request); + return Excel::download(new CartableReport($data['data']), $name); + } + + public function firstStepStore(FirstStepStoreRequest $request, NominatimService $nominatimService): JsonResponse + { + $user = auth()->user(); + + if ($user->edarate_ostani_id || is_null($user->city_id)) { + return $this->errorResponse('امکان ثبت این مورد برای ادارات استانی و ستادی وجود ندارد!'); + } + + if (is_null($user->edarate_shahri_id)) { + return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!'); + } + + $coordinates = explode(',', $request->point); + $item = InfoItem::query() + ->where('id', $request->info_id) + ->where('item', 17) + ->firstOrFail(); + + DB::transaction(function () use ($request, $coordinates, $item, $nominatimService, $user) + { + $safety_and_privacy = SafetyAndPrivacy::query()->create([ + 'lat' => $coordinates[0], + 'lon' => $coordinates[1], + 'operator_id' => $user->id, + 'operator_name' => $user->name, + 'province_id' => $user->province_id, + 'province_fa' => $user->province_fa, + 'info_id' => $item->id, + 'info_fa' => $item->sub_item_str, + 'city_id' => $user->city_id, + 'city_fa' => $user->city_fa, + 'activity_date_time' => $request->activity_date." ".$request->activity_time, + 'edare_shahri_id' => $user->edarate_shahri_id, + 'edare_shahri_name' => $user->edarate_shahri_name, + 'way_id' => $nominatimService->get_way_id_from_nominatim($coordinates[0], $coordinates[1]), + 'axis_type_id' => $request->axis_type_id, + 'axis_type_name' => AxisTypes::name($request->axis_type_id), + 'step' => 1, + 'step_fa' => 'گام اول (شناسایی)' + ]); + + $safety_and_privacy->recognize_picture = $request->has('recognize_picture') ? + FileFacade::save($request->recognize_picture, "safety_and_privacy/{$safety_and_privacy->id}") : + null; + $safety_and_privacy->save(); + + $user->addActivityComplete(1134); + }); + + return $this->successResponse(); + } + + public function secondStepStore(SafetyAndPrivacy $safetyAndPrivacy, SecondStepStoreRequest $request): JsonResponse + { + $user = auth()->user(); + + if ($user->edarate_ostani_id || is_null($user->city_id)) { + return $this->errorResponse('امکان ثبت این مورد برای ادارات استانی و ستادی وجود ندارد!'); + } + + if (is_null($user->edarate_shahri_id)) { + return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!'); + } + + DB::transaction(function () use ($request, $safetyAndPrivacy, $user) + { + $judiciary_document = []; + foreach ($request->judiciary_document as $index => $file) { + $judiciary_document[] = FileFacade::save($file, "safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document"); + } + $safetyAndPrivacy->update([ + 'judiciary_document' => serialize($judiciary_document), + 'judiciary_document_upload_date' => now(), + 'step' => 2, + 'step_fa' => 'گام دوم (مستندات قضایی)' + ]); + + $user->addActivityComplete(1135); + }); + + return $this->successResponse(); + } + + public function thirdStepStore(SafetyAndPrivacy $safetyAndPrivacy, ThirdStepStoreRequest $request): JsonResponse + { + $user = auth()->user(); + + if ($user->edarate_ostani_id || is_null($user->city_id)) { + return $this->errorResponse('امکان ثبت این مورد برای ادارات استانی و ستادی وجود ندارد!'); + } + + if (is_null($user->edarate_shahri_id)) { + return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!'); + } + + DB::transaction(function () use ($request, $safetyAndPrivacy, $user) { + $safetyAndPrivacy->update([ + 'step' => 3, + 'step_fa' => 'گام سوم (برخورد)', + 'action_picture' => FileFacade::save($request->action_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/action_picture"), + 'action_picture_document_upload_date' => now(), + ]); + + $user->addActivityComplete(1136); + }); + + return $this->successResponse(); + } + + public function show(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse + { + return $this->successResponse($safetyAndPrivacy); + } + + public function destroy(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse + { + Storage::deleteDirectory("public/safety_and_privacy/{$safetyAndPrivacy->id}"); + + DB::transaction(function () use ($safetyAndPrivacy) + { + auth()->user()->addActivityComplete(1155); + $safetyAndPrivacy->delete(); + }); + + return $this->successResponse(); + } + + public function deserialize(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse + { + $judiciaries = $safetyAndPrivacy->judiciary_document ? unserialize($safetyAndPrivacy->judiciary_document) : []; + + $result = []; + + foreach ($judiciaries as $judiciary) { + $result[] = Storage::disk('public')->url($judiciary); + } + + return $this->successResponse($result); + } + + public function subItems(): JsonResponse + { + return $this->successResponse(InfoItem::query() + ->where('item', '=', 17) + ->select('id', 'item', 'item_str', 'sub_item_str as name', 'sub_item_unit as unit', 'needs_image', 'needs_end_point', 'sub_item') + ->get()); + } +} diff --git a/app/Http/Controllers/V3/LogListManagementController.php b/app/Http/Controllers/V3/LogListManagementController.php new file mode 100644 index 00000000..c351fca6 --- /dev/null +++ b/app/Http/Controllers/V3/LogListManagementController.php @@ -0,0 +1,63 @@ +json(DataTableFacade::run( + LogList::query(), + $request, + allowedFilters: ['*'], + allowedSortings: ['*'])); + } + + public function list(): JsonResponse + { + return $this->successResponse(LogList::all('description', 'log_unique_code')); + } + + public function store(StoreRequest $request): JsonResponse + { + LogList::query()->create([ + 'description' => $request->description, + 'log_unique_code' => $request->log_unique_code, + 'action_type' => $request->action_type, + ]); + + return $this->successResponse(); + } + + public function show(LogList $logList): JsonResponse + { + return $this->successResponse($logList); + } + + public function update(UpdateRequest $request, LogList $logList): JsonResponse + { + $logList->update([ + 'description' => $request->description, + 'log_unique_code' => $request->log_unique_code, + 'action_type' => $request->action_type, + ]); + return $this->successResponse(); + } + + public function destroy(LogList $logList): JsonResponse + { + $logList->delete(); + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/V3/NotificationController.php b/app/Http/Controllers/V3/NotificationController.php new file mode 100644 index 00000000..d322a95a --- /dev/null +++ b/app/Http/Controllers/V3/NotificationController.php @@ -0,0 +1,197 @@ +successResponse([ + 'roadItem' => $this->roadItemNotifications(), + 'safetyAndPrivacy' => $this->safetyAndPrivacyNotifications(), + 'roadObserved' => $this->roadObservedNotifications(), + ]); + } + + /** + * @throws Throwable + */ + private function roadItemNotifications(): JsonResponse|array + { + $user = auth()->user(); + $road_items = [ + 'total' => 0 + ]; + + if ($user->hasPermissionTo('create-road-item')) { + $road_items['operation_cnt'] = RoadItemsProject::query() + ->where('is_new', '=', 1) + ->where('user_id', '=', $user->id) + ->where('status', '=', 2) + ->count(); + + $road_items['total'] += $road_items['operation_cnt']; + } + if ($user->hasPermissionTo('supervise-road-item')) { + $road_items['supervise_cnt'] = RoadItemsProject::query() + ->where('is_new', '=', 1) + ->where('status', '=', 0) + ->count(); + + $road_items['total'] += $road_items['supervise_cnt']; + } + elseif ($user->hasPermissionTo('supervise-road-item-province')) { + throw_if(is_null($user->province_id) || !$user->province_id, new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); + + $road_items['supervise_cnt'] = RoadItemsProject::query() + ->where('is_new', '=', 1) + ->where('province_id', '=', $user->province_id) + ->where('status', '=', 0) + ->count(); + + $road_items['total'] += $road_items['supervise_cnt']; + } + elseif ($user->hasPermissionTo('supervise-road-item-by-edareostani')) { + throw_if(is_null($user->edarate_ostani_id) || !$user->edarate_ostani_id, new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!')); + + $confirmableItems = EdarateOstani::query()->where('id', '=', $user->edarate_ostani_id)->value('items_for_confirm'); + $road_items['supervise_cnt'] = RoadItemsProject::query() + ->where('is_new', '=', 1) + ->where('province_id', '=', $user->province_id) + ->whereIn('item', explode(",", $confirmableItems)) + ->where('status', '=', 0) + ->count(); + + $road_items['total'] += $road_items['supervise_cnt']; + } + return $road_items; + } + + /** + * @throws Throwable + */ + private function safetyAndPrivacyNotifications(): JsonResponse|array + { + $user = auth()->user(); + $safety_and_privacy = array(); + if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) { + $activity = SafetyAndPrivacy::query() + ->selectRaw('count(*) as cnt, step') + ->groupby('step') + ->orderBy('step') + ->get(); + + } + elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) { + throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); + + $activity = SafetyAndPrivacy::query() + ->where('province_id', '=', $user->province_id) + ->selectRaw('count(*) as cnt, step') + ->groupby('step') + ->orderBy('step') + ->get(); + + } + elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) { + throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!')); + + $activity = SafetyAndPrivacy::query() + ->where('edare_shahri_id', '=', $user->edarate_shahri_id) + ->selectRaw('count(*) as cnt, step') + ->groupby('step') + ->orderBy('step') + ->get(); + } + + $safety_and_privacy['step_one'] = isset($activity[0]) ? $activity[0]->cnt : 0; + $safety_and_privacy['step_two'] = isset($activity[1]) ? $activity[1]->cnt : 0; + + return $safety_and_privacy; + } + + /** + * @throws Throwable + */ + private function roadObservedNotifications(): JsonResponse|array + { + $user = auth()->user(); + $road_observations = [ + 'total' => 0, + 'operation_cnt' => 0, + 'complaint_cnt' => 0, + 'supervise_cnt' => 0 + ]; + + $conditions = []; + $complaintConditions = [ + ['rms_status', '=', 0], + ['edarate_shahri_id', '!=', null] + ]; + + if ($user->hasPermissionTo('show-fast-react')) { + $conditions[] = ['status', '=', 2]; + } + elseif ($user->hasPermissionTo('show-fast-react-province')) { + throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); + $conditions = [ + ['status', '=', 2], + ['rms_province_id', '=', $user->province_id] + ]; + $complaintConditions[] = ['province_id', '=', $user->province_id]; + } + elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) { + throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!')); + $conditions = [ + ['status', '=', 2], + ['edarate_shahri_id', '=', $user->edarate_shahri_id] + ]; + $complaintConditions[] = ['edarate_shahri_id', '=', $user->edarate_shahri_id]; + } + + if (!empty($conditions)) { + $road_observations['operation_cnt'] = RoadObserved::query()->where($conditions)->count(); + $road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count(); + $road_observations['total'] += $road_observations['operation_cnt'] + $road_observations['complaint_cnt']; + } + + $superviseConditions = [ + ['status', '=', 0] + ]; + + if ($user->hasPermissionTo('supervise-fast-react')) { + $road_observations['supervise_cnt'] = RoadObserved::query()->where($superviseConditions)->count(); + $road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count(); + $road_observations['total'] += $road_observations['supervise_cnt'] + $road_observations['complaint_cnt']; + } + elseif ($user->hasPermissionTo('supervise-fast-react-province')) { + throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); + $superviseConditions[] = ['province_id', '=', $user->province_id]; + $complaintConditions[] = ['province_id', '=', $user->province_id]; + + $road_observations['supervise_cnt'] = RoadObserved::query()->where($superviseConditions)->count(); + $road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count(); + $road_observations['total'] += $road_observations['supervise_cnt'] + $road_observations['complaint_cnt']; + } + + return $road_observations; + } +} diff --git a/app/Http/Controllers/V3/PermissionManagementController.php b/app/Http/Controllers/V3/PermissionManagementController.php new file mode 100644 index 00000000..8ac3eec6 --- /dev/null +++ b/app/Http/Controllers/V3/PermissionManagementController.php @@ -0,0 +1,83 @@ +json(DataTableFacade::run( + Permission::query(), + $request, + allowedFilters: ['*'], + allowedSortings: ['*']) + ); + } + + /** + * Store a newly created resource in storage. + */ + public function store(StoreRequest $request): JsonResponse + { + Permission::create([ + 'name' => $request->name, + 'guard_name' => 'web', + 'name_fa' => $request->name_fa, + 'description' => $request->description, + 'type' => $request->type, + 'type_fa' => $request->type_fa, + 'need_province' => $request->need_province, + 'need_edare_shahri' => $request->need_edare_shahri, + ]); + + return $this->successResponse(); + } + + /** + * Display the specified resource. + */ + public function show(Permission $permission): JsonResponse + { + return $this->successResponse($permission); + } + + /** + * Update the specified resource in storage. + */ + public function update(UpdateRequest $request, Permission $permission): JsonResponse + { + $permission->update([ + 'name' => $request->name, + 'name_fa' => $request->name_fa, + 'description' => $request->description, + 'type' => $request->type, + 'type_fa' => $request->type_fa, + 'need_province' => $request->need_province, + 'need_edare_shahri' => $request->need_edare_shahri, + ]); + + return $this->successResponse(); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Permission $permission): JsonResponse + { + $permission->delete(); + return $this->successResponse(); + } +} diff --git a/app/Http/Requests/V3/AccidentReceipt/ConfirmPaymentInfoRequest.php b/app/Http/Requests/V3/AccidentReceipt/ConfirmPaymentInfoRequest.php new file mode 100644 index 00000000..3b079953 --- /dev/null +++ b/app/Http/Requests/V3/AccidentReceipt/ConfirmPaymentInfoRequest.php @@ -0,0 +1,31 @@ +|string> + */ + public function rules(): array + { + return [ + 'deposit_insurance_image' => 'file', + 'deposit_insurance_amount' => 'required_with:deposit_insurance_image', + 'deposit_daghi_image' => 'file', + 'deposit_daghi_amount' => 'required_with:deposit_daghi_image', + ]; + } +} diff --git a/app/Http/Requests/V3/AccidentReceipt/StoreRequest.php b/app/Http/Requests/V3/AccidentReceipt/StoreRequest.php new file mode 100644 index 00000000..5b7f34bf --- /dev/null +++ b/app/Http/Requests/V3/AccidentReceipt/StoreRequest.php @@ -0,0 +1,50 @@ +|string> + */ + public function rules(): array + { + return [ + 'province_id' => 'required|integer|exists:provinces,id', + 'city_id' => 'required|integer|exists:cities,id', + 'axis_name' => 'required|string', + 'driver_name' => 'required|string', + 'plaque' => 'required|string', + 'driver_national_code' => 'required|string', + 'driver_phone_number' => 'required|string', + 'lat' => 'required|numeric', + 'lng' => 'required|numeric', + 'accident_type' => 'required|integer', + 'accident_date' => 'required|date', + 'accident_time' => 'required|string', + 'report_base' => 'required|in:0,1', + 'police_file' => 'required_if:report_base,0|file|mimes:pdf,jpg,jpeg,png', + 'police_serial' => 'required_if:report_base,0|string', + 'police_file_date' => 'required_if:report_base,0|date', + 'damage_picture1' => 'required|file|mimes:pdf,jpg,jpeg,png', + 'damage_picture2' => 'required|file|mimes:pdf,jpg,jpeg,png', + 'damage_items' => 'required|array', + 'damage_items.*.value' => 'required', + 'damage_items.*.amount' => 'required', + ]; + } +} diff --git a/app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php b/app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php new file mode 100644 index 00000000..3160896d --- /dev/null +++ b/app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php @@ -0,0 +1,48 @@ +|string> + */ + public function rules(): array + { + return [ + 'province_id' => 'required|integer|exists:provinces,id', + 'city_id' => 'required|integer|exists:cities,id', + 'axis_name' => 'required|string', + 'driver_name' => 'required|string', + 'plaque' => 'required|string', + 'driver_national_code' => 'required|string', + 'driver_phone_number' => 'required|string', + 'lat' => 'required|numeric', + 'lng' => 'required|numeric', + 'accident_type' => 'required|integer', + 'accident_date' => 'required|date', + 'accident_time' => 'required|string', + 'report_base' => 'required|in:0,1', + 'police_file' => 'file|mimes:pdf,jpg,jpeg,png', + 'police_serial' => 'required_if:report_base,0|string', + 'police_file_date' => 'required_if:report_base,0|date', + 'damage_picture1' => 'file|mimes:pdf,jpg,jpeg,png', + 'damage_picture2' => 'file|mimes:pdf,jpg,jpeg,png', + 'damage_items' => 'required|array', + 'damage_items.*.value' => 'required', + 'damage_items.*.amount' => 'required', + ]; + } +} diff --git a/app/Http/Requests/V3/Damage/StoreRequest.php b/app/Http/Requests/V3/Damage/StoreRequest.php new file mode 100644 index 00000000..6d8647b0 --- /dev/null +++ b/app/Http/Requests/V3/Damage/StoreRequest.php @@ -0,0 +1,30 @@ +|string> + */ + public function rules(): array + { + return [ + 'title' =>'required|string|max:255|unique:damages,title', + 'unit' =>'required|string|max:255', + 'base_price' =>'required|integer', + ]; + } +} diff --git a/app/Http/Requests/V3/Damage/UpdateRequest.php b/app/Http/Requests/V3/Damage/UpdateRequest.php new file mode 100644 index 00000000..8021f716 --- /dev/null +++ b/app/Http/Requests/V3/Damage/UpdateRequest.php @@ -0,0 +1,31 @@ +|string> + */ + public function rules(): array + { + return [ + 'title' =>['required', 'string', 'max:255',Rule::unique('damages','title')->ignore($this->damage->id)], + 'unit' =>'required|string', + 'base_price' =>'required|integer', + ]; + } +} diff --git a/app/Http/Requests/V3/LogList/StoreRequest.php b/app/Http/Requests/V3/LogList/StoreRequest.php new file mode 100644 index 00000000..65d1da73 --- /dev/null +++ b/app/Http/Requests/V3/LogList/StoreRequest.php @@ -0,0 +1,30 @@ +|string> + */ + public function rules(): array + { + return [ + 'description' =>'required|string', + 'log_unique_code' =>'required|numeric|unique:log_lists,log_unique_code', + 'action_type' =>'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/LogList/UpdateRequest.php b/app/Http/Requests/V3/LogList/UpdateRequest.php new file mode 100644 index 00000000..feee0d27 --- /dev/null +++ b/app/Http/Requests/V3/LogList/UpdateRequest.php @@ -0,0 +1,31 @@ +|string> + */ + public function rules(): array + { + return [ + 'description' => 'required|string', + 'log_unique_code' => ['required', 'numeric', Rule::unique('log_lists', 'log_unique_code')->ignore($this->logList->id)], + 'action_type' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Otp/GetOtpTokenRequest.php b/app/Http/Requests/V3/Otp/GetOtpTokenRequest.php new file mode 100644 index 00000000..9dae8269 --- /dev/null +++ b/app/Http/Requests/V3/Otp/GetOtpTokenRequest.php @@ -0,0 +1,35 @@ +|string> + */ + public function rules(): array + { + return [ + 'phone_number' => 'required|digits:11|starts_with:09', + ]; + } + + public function messages(): array + { + return [ + 'starts_with' => ':attribute باید با :values شروع شود.' + ]; + } +} diff --git a/app/Http/Requests/V3/Permission/StoreRequest.php b/app/Http/Requests/V3/Permission/StoreRequest.php new file mode 100644 index 00000000..9a09ab36 --- /dev/null +++ b/app/Http/Requests/V3/Permission/StoreRequest.php @@ -0,0 +1,34 @@ +|string> + */ + public function rules(): array + { + return [ + 'name' => 'required|string|unique:permissions,name', + 'name_fa' => 'required|string', + 'description' => 'string', + 'type' => 'required|string', + 'type_fa' => 'required|string', + 'need_province' => 'required|in:0,1', + 'need_edare_shahri' => 'required|in:0,1', + ]; + } +} diff --git a/app/Http/Requests/V3/Permission/UpdateRequest.php b/app/Http/Requests/V3/Permission/UpdateRequest.php new file mode 100644 index 00000000..e5213c11 --- /dev/null +++ b/app/Http/Requests/V3/Permission/UpdateRequest.php @@ -0,0 +1,34 @@ +|string> + */ + public function rules(): array + { + return [ + 'name' => "required|string|unique:permissions,name,{$this->permission->id}", + 'name_fa' => 'required|string', + 'description' => 'string', + 'type' => 'required|string', + 'type_fa' => 'required|string', + 'need_province' => 'required|in:0,1', + 'need_edare_shahri' => 'required|in:0,1', + ]; + } +} diff --git a/app/Http/Requests/V3/RoadObservation/ModifyRegisterationRequest.php b/app/Http/Requests/V3/RoadObservation/ModifyRegisterationRequest.php new file mode 100644 index 00000000..288ea697 --- /dev/null +++ b/app/Http/Requests/V3/RoadObservation/ModifyRegisterationRequest.php @@ -0,0 +1,32 @@ +|string> + */ + public function rules(): array + { + return [ + 'rms_status' => 'required|in:1,2', + 'rms_description' => 'required_if:rms_status,1|string', + 'image_before' => 'file|mimes:jpg,jpeg,png', + 'image_after' => 'file|mimes:jpg,jpeg,png', + 'start_point' => 'string', + ]; + } +} diff --git a/app/Http/Requests/V3/RoadObservation/ReferRequest.php b/app/Http/Requests/V3/RoadObservation/ReferRequest.php new file mode 100644 index 00000000..33e2bc83 --- /dev/null +++ b/app/Http/Requests/V3/RoadObservation/ReferRequest.php @@ -0,0 +1,30 @@ +roadObserved->rms_status == 0; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'edarate_shahri_id' => 'required|exists:edarate_shahri,id', + 'province_id' => 'required|exists:provinces,id', + 'refer_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/RoadObservation/RegisterRequest.php b/app/Http/Requests/V3/RoadObservation/RegisterRequest.php new file mode 100644 index 00000000..c3f59834 --- /dev/null +++ b/app/Http/Requests/V3/RoadObservation/RegisterRequest.php @@ -0,0 +1,32 @@ +|string> + */ + public function rules(): array + { + return [ + 'rms_status' => 'required|in:1,2', + 'rms_description' => 'required_if:rms_status,1|string', + 'image_before' => 'required_if:rms_status,1|file|mimes:jpg,jpeg,png', + 'image_after' => 'required_if:rms_status,1|file|mimes:jpg,jpeg,png', + 'start_point' => 'string', + ]; + } +} diff --git a/app/Http/Requests/V3/RoadObservation/RestoreRequest.php b/app/Http/Requests/V3/RoadObservation/RestoreRequest.php new file mode 100644 index 00000000..1c02a650 --- /dev/null +++ b/app/Http/Requests/V3/RoadObservation/RestoreRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + 'restore_description' => 'string', + ]; + } +} diff --git a/app/Http/Requests/V3/RoadObservation/VerifyBySupervisorRequest.php b/app/Http/Requests/V3/RoadObservation/VerifyBySupervisorRequest.php new file mode 100644 index 00000000..db1450cd --- /dev/null +++ b/app/Http/Requests/V3/RoadObservation/VerifyBySupervisorRequest.php @@ -0,0 +1,30 @@ +roadObserved); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + {return [ + 'verify' => ['required', 'in:1,2'], + 'description' => ['string'], + ]; + } +} diff --git a/app/Http/Requests/V3/SafetyAndPrivacy/FirstStepStoreRequest.php b/app/Http/Requests/V3/SafetyAndPrivacy/FirstStepStoreRequest.php new file mode 100644 index 00000000..b7b7cf82 --- /dev/null +++ b/app/Http/Requests/V3/SafetyAndPrivacy/FirstStepStoreRequest.php @@ -0,0 +1,41 @@ +|string> + */ + public function rules(): array + { + return [ + 'point' => 'required', + 'info_id' => 'required', + 'activity_date' => 'required|date_format:Y-m-d', + 'activity_time' => 'required|date_format:H:i', + 'recognize_picture' => 'required|image', + 'axis_type_id' => 'required|integer|exists:axis_types,id', + ]; + } + + public function attributes(): array + { + return [ + 'activity_date' => 'تاریخ فعالیت', + 'activity_time' => 'ساعت فعالیت', + ]; + } +} diff --git a/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php b/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php new file mode 100644 index 00000000..5d130d51 --- /dev/null +++ b/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php @@ -0,0 +1,29 @@ +|string> + */ + public function rules(): array + { + return [ + 'judiciary_document' => 'required|array', + 'judiciary_document.*' => 'file', + ]; + } +} diff --git a/app/Http/Requests/V3/SafetyAndPrivacy/ThirdStepStoreRequest.php b/app/Http/Requests/V3/SafetyAndPrivacy/ThirdStepStoreRequest.php new file mode 100644 index 00000000..652ea3a4 --- /dev/null +++ b/app/Http/Requests/V3/SafetyAndPrivacy/ThirdStepStoreRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + 'action_picture' => 'required|image', + ]; + } +} diff --git a/app/Jobs/SendRoadObservationToNikarayan.php b/app/Jobs/SendRoadObservationToNikarayan.php index ffb21eab..87cdeb0c 100644 --- a/app/Jobs/SendRoadObservationToNikarayan.php +++ b/app/Jobs/SendRoadObservationToNikarayan.php @@ -15,6 +15,13 @@ class SendRoadObservationToNikarayan implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + /** + * The number of times the job may be attempted. + * + * @var int + */ + public int $tries = 2; + /** * Create a new job instance. */ diff --git a/app/Models/Accident.php b/app/Models/Accident.php index 8221365b..f1495dce 100644 --- a/app/Models/Accident.php +++ b/app/Models/Accident.php @@ -2,13 +2,19 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use App\Traits\ReceiptReportAble; +use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Support\Facades\Storage; class Accident extends Model { use ReceiptReportAble, HasFactory; + + protected $guarded = []; + public static function boot() { parent::boot(); @@ -87,4 +93,29 @@ class Accident extends Model } } + public function files(): MorphMany + { + return $this->morphMany(File::class, 'fileable'); + } + + protected function damagePicture1(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + ); + } + + protected function damagePicture2(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + ); + } + + protected function policeFile(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + ); + } } diff --git a/app/Models/AxisType.php b/app/Models/AxisType.php new file mode 100644 index 00000000..59fbeec1 --- /dev/null +++ b/app/Models/AxisType.php @@ -0,0 +1,13 @@ +belongsToMany('App\Accident'); } diff --git a/app/Models/File.php b/app/Models/File.php new file mode 100644 index 00000000..cfafa7e9 --- /dev/null +++ b/app/Models/File.php @@ -0,0 +1,19 @@ +morphTo(); + } +} diff --git a/app/Models/LogList.php b/app/Models/LogList.php index c7831a54..bc07f4f0 100644 --- a/app/Models/LogList.php +++ b/app/Models/LogList.php @@ -10,4 +10,6 @@ class LogList extends Model use HasFactory; public $timestamps = false; + + protected $guarded = []; } \ No newline at end of file diff --git a/app/Models/RoadObserved.php b/app/Models/RoadObserved.php index 54fd8c29..18c4c9af 100644 --- a/app/Models/RoadObserved.php +++ b/app/Models/RoadObserved.php @@ -2,8 +2,10 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Storage; class RoadObserved extends Model { @@ -60,6 +62,9 @@ class RoadObserved extends Model 'supervisor_description', 'supervising_time', 'supervisor_name', + 'rms_start_latlng', + 'rms_end_latlng', + 'rms_description', ]; /** @@ -99,4 +104,18 @@ class RoadObserved extends Model { return $this->belongsTo('App\Models\EdarateShahri', 'edarate_shahri_id'); } + + protected function imageAfter(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + ); + } + + protected function imageBefore(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + ); + } } diff --git a/app/Models/SafetyAndPrivacy.php b/app/Models/SafetyAndPrivacy.php index 7df8202d..8cb61c14 100644 --- a/app/Models/SafetyAndPrivacy.php +++ b/app/Models/SafetyAndPrivacy.php @@ -2,9 +2,11 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use App\Traits\SafetyAndPrivacyReportAble; +use Illuminate\Support\Facades\Storage; class SafetyAndPrivacy extends Model { @@ -26,7 +28,14 @@ class SafetyAndPrivacy extends Model 'edare_shahri_name', 'way_id', 'activity_date_time', - + 'step', + 'step_fa', + 'judiciary_document', + 'judiciary_document_upload_date', + 'action_picture', + 'action_picture_document_upload_date', + 'axis_type_id', + 'axis_type_name', ]; public $table = "safety_and_privacy"; @@ -60,4 +69,23 @@ class SafetyAndPrivacy extends Model } } + protected function recognizePicture(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : + (filter_var($value, FILTER_VALIDATE_URL) + ? $value + : Storage::disk('public')->url($value)) + ); + } + + protected function actionPicture(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : + (filter_var($value, FILTER_VALIDATE_URL) + ? $value + : Storage::disk('public')->url($value)) + ); + } } diff --git a/app/Services/Cartables/AccidentReceiptTableService.php b/app/Services/Cartables/AccidentReceiptTableService.php new file mode 100644 index 00000000..4f251709 --- /dev/null +++ b/app/Services/Cartables/AccidentReceiptTableService.php @@ -0,0 +1,123 @@ +user(); + $query = null; + + if ($user->hasPermissionTo('show-receipt')) { + $query = Accident::query() + ->when($loadRelations, fn ($query) => $query->with('damages')); + } + else { + if (is_null($user->province_id)) { + return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); + } + + $query = Accident::query() + ->where('province_id', '=', $user->province_id) + ->when($loadRelations, fn ($query) => $query->with('damages')); + } + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'] + ); + } + + public function countryReport(Request $request): array + { + $data = DB::select( + 'SELECT + "کشوری" as province_fa, + -1 as province_id, + COUNT(id) AS tedade, + COUNT(CASE WHEN report_base = 0 THEN 1 END) AS police_rah, + COUNT(CASE WHEN report_base = 1 THEN 1 END) AS gozaresh_gasht, + SUM(`sum`) AS kol_sabt_shode, + SUM(CASE WHEN STATUS > 3 THEN `sum` END) AS vasel_shode, + SUM(CASE WHEN STATUS > 3 THEN `deposit_insurance_amount` END) AS vasel_shode_bimeh, + SUM(CASE WHEN STATUS > 3 THEN `deposit_daghi_amount` END) AS vasel_shode_daghi, + SUM(CASE WHEN STATUS > 3 THEN `final_amount` END) AS vasel_shode_final + FROM `accidents` + where created_at BETWEEN "'.$request->from_date.'" AND "'.$request->date_to.'" + union + SELECT + province_fa, + province_id, + COUNT(id) AS tedade, + COUNT(CASE WHEN report_base = 0 THEN 1 END) AS police_rah, + COUNT(CASE WHEN report_base = 1 THEN 1 END) AS gozaresh_gasht, + SUM(`sum`) AS kol_sabt_shode, + SUM(CASE WHEN STATUS > 3 THEN `sum` END) AS vasel_shode, + SUM(CASE WHEN STATUS > 3 THEN `deposit_insurance_amount` END) AS vasel_shode_bimeh, + SUM(CASE WHEN STATUS > 3 THEN `deposit_daghi_amount` END) AS vasel_shode_daghi, + SUM(CASE WHEN STATUS > 3 THEN `final_amount` END) AS vasel_shode_final + FROM `accidents` + where created_at BETWEEN "'.$request->from_date.'" AND "'.$request->date_to.'" + GROUP BY province_id + ' + ); + + return [ + 'data' => $data, + 'fromDate' => $request->from_date, + 'toDate' => $request->date_to, + ]; + } + + public function provinceReport(Request $request): array + { + $data = DB::select( + 'SELECT + "استانی" as city_fa, + -1 as city_id, + COUNT(id) AS tedade, + COUNT(CASE WHEN report_base = 0 THEN 1 END) AS police_rah, + COUNT(CASE WHEN report_base = 1 THEN 1 END) AS gozaresh_gasht, + SUM(`sum`) AS kol_sabt_shode, + SUM(CASE WHEN STATUS > 3 THEN `sum` END) AS vasel_shode, + SUM(CASE WHEN STATUS > 3 THEN `deposit_insurance_amount` END) AS vasel_shode_bimeh, + SUM(CASE WHEN STATUS > 3 THEN `deposit_daghi_amount` END) AS vasel_shode_daghi, + SUM(CASE WHEN STATUS > 3 THEN `final_amount` END) AS vasel_shode_final + FROM `accidents` + where created_at BETWEEN "'.$request->from_date.'" AND "'.$request->date_to.'" AND province_id ='.$request->province_id.' + union + SELECT + city_fa, + city_id, + COUNT(id) AS tedade, + COUNT(CASE WHEN report_base = 0 THEN 1 END) AS police_rah, + COUNT(CASE WHEN report_base = 1 THEN 1 END) AS gozaresh_gasht, + SUM(`sum`) AS kol_sabt_shode, + SUM(CASE WHEN STATUS > 3 THEN `sum` END) AS vasel_shode, + SUM(CASE WHEN STATUS > 3 THEN `deposit_insurance_amount` END) AS vasel_shode_bimeh, + SUM(CASE WHEN STATUS > 3 THEN `deposit_daghi_amount` END) AS vasel_shode_daghi, + SUM(CASE WHEN STATUS > 3 THEN `final_amount` END) AS vasel_shode_final + FROM `accidents` + where created_at BETWEEN "'.$request->from_date.'" AND "'.$request->date_to.'" AND province_id ='.$request->province_id.' + GROUP BY city_id + ' + ); + + return [ + 'data' => $data, + 'fromDate' => $request->from_date, + 'toDate' => $request->date_to, + ]; + } +} diff --git a/app/Services/Reports/RoadItemReportService.php b/app/Services/Cartables/RoadItemTableService.php similarity index 79% rename from app/Services/Reports/RoadItemReportService.php rename to app/Services/Cartables/RoadItemTableService.php index 4751cda3..0b64e741 100644 --- a/app/Services/Reports/RoadItemReportService.php +++ b/app/Services/Cartables/RoadItemTableService.php @@ -1,6 +1,6 @@ user(); $query = null; if ($user->hasPermissionTo('show-road-item-supervise-cartable')) { - $query = RoadItemsProject::query()->where('is_new', 1)->with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']); + $query = RoadItemsProject::query() + ->select(['id', 'province_fa', 'edarat_name', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', + 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status']) + ->where('is_new', 1) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); } elseif ($user->hasPermissionTo('show-road-item-supervise-cartable-province')) { if (is_null($user->province_id)) { return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); } - $query = RoadItemsProject::query()->where('is_new', 1) - ->with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])->where('province_id', auth()->user()->province_id); + $query = RoadItemsProject::query() + ->select(['id', 'province_fa', 'edarat_name', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', + 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status']) + ->where('is_new', 1) + ->where('province_id', auth()->user()->province_id) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); } $data = DataTableFacade::run( @@ -47,22 +47,17 @@ class RoadItemReportService return $data; } - public function operatorCartableReport(Request $request) + public function operatorCartableReport(Request $request, $loadRelations = false) { - $columns = array( - 'id', 'user_id', 'start_lat', 'start_lng', 'end_lat', - 'end_lng', 'project_distance', 'item', 'item_fa', 'sub_item_fa', 'sub_item', - 'sub_item_data', 'created_at', 'updated_at', 'province_id', 'province_fa', - 'unit_fa', 'status', 'status_fa', 'supervisor_description', 'supervising_time', - 'supervisor_name', 'edarat_id', 'edarat_name', 'activity_date_time', 'cmmsMachines.machine_code', 'rahdaran.code', - ); + $allowedFilters = ['*']; + $allowedSortings = ['*']; - $allowedFilters = $columns; - $allowedSortings = $columns; - - $query = RoadItemsProject::with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']) + $query = RoadItemsProject::query() + ->select(['id', 'supervisor_description', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', + 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status']) ->where('is_new', 1) - ->where('user_id', auth()->user()->id); + ->where('user_id', auth()->user()->id) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));; $data = DataTableFacade::run( $query, diff --git a/app/Services/Cartables/RoadObservationTableService.php b/app/Services/Cartables/RoadObservationTableService.php new file mode 100644 index 00000000..810d4b88 --- /dev/null +++ b/app/Services/Cartables/RoadObservationTableService.php @@ -0,0 +1,169 @@ +user(); + + $fields = [ + 'fk_RegisteredEventMessage', 'road_observeds.id', 'Title', 'road_observeds.created_at', 'StartTime_DateTime', + 'lat', 'lng', 'FeatureTypeTitle', 'Description', 'MobileForSendEventSms', 'rms_start_latlng', + 'rms_description', 'rms_status', 'rms_last_activity_fa', 'rms_last_activity', 'edarate_shahri_id', + 'road_observeds.province_id', 'province_fa', 'city_id', 'city_fa', 'edarate_shahri.name_fa', + 'status', 'status_fa', 'supervisor_description', 'supervising_time', 'image_after', 'image_before' + ]; + + if ($user->hasPermissionTo('show-fast-react')) { + $query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id') + ->whereNotNull('road_observeds.status') + ->select($fields); + } + elseif ($user->hasPermissionTo('show-fast-react-province')) + { + if (is_null($user->province_id)) + { + return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); + } + + $query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id') + ->where('road_observeds.province_id', $user->province_id) + ->whereNotNull('road_observeds.status') + ->select($fields); + } + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*']); + } + + public function operatorCartableIndex(Request $request) + { + $user = auth()->user(); + + $fields = [ + 'fk_RegisteredEventMessage', 'road_observeds.id', 'Title', 'road_observeds.created_at', 'StartTime_DateTime', + 'lat', 'lng', 'FeatureTypeTitle', 'Description', 'MobileForSendEventSms', 'edarate_shahri_id', + 'rms_description', 'rms_status', 'rms_start_latlng', 'rms_last_activity_fa', 'image_after', 'image_before', + 'rms_last_activity', 'road_observeds.province_id', 'province_fa', 'city_id', 'city_fa', + 'edarate_shahri.name_fa', 'status', 'status_fa', 'supervisor_description', 'supervising_time' + ]; + + $query = RoadObserved::query() + ->where('rms_status', '!=', 0) + ->whereNotNull('road_observeds.province_id') + ->whereNotNull('status') + ->leftJoin('edarate_shahri', 'road_observeds.edarate_shahri_id', '=', 'edarate_shahri.id') + ->where('edarate_shahri_id', $user->edarate_shahri_id) + ->select($fields); + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*']); + } + + public function complaintsIndex(Request $request) + { + $user = auth()->user(); + + $fields = 'fk_RegisteredEventMessage, road_observeds.id, Title, FeatureTypeTitle, MobileForSendEventSms, StartTime_DateTime, + road_observeds.created_at, rms_last_activity, rms_last_activity_fa, status, edarate_shahri_id, + status_fa, supervisor_description, rms_description, province_fa, city_id, city_fa, Description, edarate_shahri.name_fa as edarate_shahri_name_fa, lat, lng'; + + if ($user->hasPermissionTo('show-fast-react')) { + $query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id') + ->where('rms_status', '=', 0) + ->whereNotNull('edarate_shahri_id') + ->selectRaw($fields); + } + elseif ($user->hasPermissionTo('show-fast-react-province')) { + + if (is_null($user->province_id)) { + return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); + } + + $query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id') + ->where('rms_status', '=', 0) + ->whereNotNull('road_observeds.province_id') + ->where('road_observeds.province_id', '=', $user->province_id) + ->selectRaw($fields); + + } + elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) { + + if (is_null($user->edarate_shahri_id)) { + return $this->errorResponse('اداره ای برای شما در سامانه ثبت نشده است!'); + } + + $query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id') + ->where('rms_status', '=', 0) + ->whereNotNull('edarate_shahri_id') + ->where('edarate_shahri_id', '=', $user->edarate_shahri_id) + ->selectRaw($fields); + + } + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'] + ); + } + + public function reportIndex(Request $request) + { + $fromDate = $request->from_date . ' 00:00:00'; + $toDate = $request->date_to . ' 23:59:59'; + + $fields = [ + 'fk_RegisteredEventMessage', + 'road_observeds.id', + 'Title', + 'road_observeds.created_at', + 'lat', + 'lng', + 'FeatureTypeTitle', + 'Description', + 'MobileForSendEventSms', + 'road_observeds.province_id', + 'province_fa', + 'city_fa', + 'edarate_shahri.name_fa', + 'rms_last_activity_fa', + 'rms_description' + ]; + + $query = RoadObserved::leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id') + ->where('rms_status', "<>", 0) + ->whereNotNull('edarate_shahri_id') + ->whereBetween('road_observeds.created_at', [$fromDate, $toDate]) + ->select($fields); + + $data = DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'] + ); + + return [ + 'data' => $data, + 'fromDate' => $fromDate, + 'toDate' => $toDate, + ]; + } +} \ No newline at end of file diff --git a/app/Services/Reports/RoadPatrolReportService.php b/app/Services/Cartables/RoadPatrolTableService.php similarity index 83% rename from app/Services/Reports/RoadPatrolReportService.php rename to app/Services/Cartables/RoadPatrolTableService.php index 38559505..d43a45d7 100644 --- a/app/Services/Reports/RoadPatrolReportService.php +++ b/app/Services/Cartables/RoadPatrolTableService.php @@ -1,41 +1,41 @@ user(); $query = null; if ($user->hasPermissionTo('show-road-patrol-supervise-cartable')) { $query = RoadPatrol::query() - ->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']); + ->select([ + 'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description', + 'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points' + ]) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); } elseif ($user->hasPermissionTo('show-road-patrol-supervise-cartable-province')) { if (is_null($user->province_id)) { return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); } $query = RoadPatrol::query() - ->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']) - ->where('province_id', '=', $user->province_id); + ->select([ + 'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description', + 'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points' + ]) + ->where('province_id', '=', $user->province_id) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); } $data = DataTableFacade::run( @@ -47,20 +47,18 @@ class RoadPatrolReportService return $data; } - public function operatorCartableReport(Request $request) + public function operatorCartableReport(Request $request, $loadRelations = false) { - $columns = array( - 'id', 'start_lat', 'start_lon', 'end_lat', 'end_lon', 'officer_plaque', 'created_at', - 'officer_phone_number', 'officer_name', 'supervisor_description', 'supervising_time', - 'supervisor_name', 'status', 'status_fa', 'distance', 'start_time', 'end_time', 'cmmsMachines.machine_code', 'rahdaran.code', - ); - - $allowedFilters = $columns; - $allowedSortings = $columns; + $allowedFilters = ['*']; + $allowedSortings = ['*']; $query = RoadPatrol::query() - ->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']) - ->where('operator_id', '=', auth()->user()->id); + ->select([ + 'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description', + 'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points' + ]) + ->where('operator_id', '=', auth()->user()->id) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); $data = DataTableFacade::run( $query, diff --git a/app/Services/Cartables/SafetyAndPrivacyTableService.php b/app/Services/Cartables/SafetyAndPrivacyTableService.php new file mode 100644 index 00000000..e7c9a85d --- /dev/null +++ b/app/Services/Cartables/SafetyAndPrivacyTableService.php @@ -0,0 +1,240 @@ +user(); + + $fields = ['id','lat','lon','province_id','province_fa','city_id','city_fa','edare_shahri_id','edare_shahri_name', + 'recognize_picture','action_picture','operator_id','operator_name','way_id','created_at','updated_at','step', + 'info_id','info_fa','activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', + 'step_fa', 'axis_type_id', 'axis_type_name' + ]; + + if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) { + $query = SafetyAndPrivacy::query()->select($fields); + } + elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) { + if (is_null($user->province_id)) { + return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); + } + + $query = SafetyAndPrivacy::query()->where('province_id', '=', $user->province_id)->select($fields); + } + elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) { + if (is_null($user->edarate_shahri_id)) { + return $this->errorResponse('اداره ای برای شما در سامانه ثبت نشده است!'); + } + + $query = SafetyAndPrivacy::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id); + } + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'] + ); + } + + public function countryActivity(Request $request): array + { + $fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString(); + $toDate = $request->date_to ? $request->date_to . ' 23:59:59' : now()->endOfDay()->toDateTimeString(); + $axisTypeId = $request->axis_type_id; + + $activities = []; + + $country = SafetyAndPrivacy::query() + ->selectRaw('COUNT(*) as qty,info_id, step') + ->whereBetween('created_at', [$fromDate, $toDate]) + ->when($axisTypeId, function ($query) use ($axisTypeId) { + $query->where('axis_type_id', '=', $axisTypeId); + }) + ->groupBy('info_id', 'step') + ->get(); + +// $country = DB::select( +// "SELECT COUNT(*) as qty,info_id, step +// FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."' +// GROUP BY info_id,step" +// ); + + $countryTotalSum = 0; + $countryData = [ + 'name_fa' => 'کشوری', + 'province_id' => -1, + 'sum' => 0, + '89' => [ + '1' => 0, + '2' => 0, + '3' => 0, + ], + '90' => [ + '1' => 0, + '2' => 0, + '3' => 0, + ], + '91' => [ + '1' => 0, + '2' => 0, + '3' => 0, + ], + ]; + foreach ($country as $key => $value) { + $countryTotalSum += $value->qty; + $countryData[$value->info_id][$value->step] = $value->qty; + $countryData["sum"] = $countryTotalSum; + } + $activities[] = (object) $countryData; + + $provinces = SafetyAndPrivacy::query() + ->selectRaw('province_id, province_fa, COUNT(*) as qty,info_id, step') + ->whereBetween('created_at', [$fromDate, $toDate]) + ->when($axisTypeId, function ($query) use ($axisTypeId) { + $query->where('axis_type_id', '=', $axisTypeId); + }) + ->groupBy('info_id', 'step', 'province_id', 'province_fa') + ->get(); + +// $provinces = DB::select( +// "SELECT province_id, province_fa, COUNT(*) as qty,info_id, step +// FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."' +// GROUP BY info_id,step,province_id,province_fa" +// ); + + foreach ($provinces as $value) { + $provinceId = $value->province_id; + + // Check if the province already exists in the activities array + if (!isset($activities[$provinceId])) { + $activities[$provinceId] = (object) [ + 'province_id' => $provinceId, + 'name_fa' => $value->province_fa, + 'sum' => 0, + '89' => ['1' => 0, '2' => 0, '3' => 0], + '90' => ['1' => 0, '2' => 0, '3' => 0], + '91' => ['1' => 0, '2' => 0, '3' => 0], + ]; + } + + $activities[$provinceId]->{$value->info_id}[$value->step] = $value->qty; + $activities[$provinceId]->sum += $value->qty; + } + + $activities = array_values($activities); + + return [ + 'activities' => $activities, + 'fromDate' => $fromDate, + 'toDate' => $toDate, + ]; + } + + public function provinceActivity(Request $request): array + { + $fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString(); + $toDate = $request->date_to ? $request->date_to . ' 23:59:59' : now()->endOfDay()->toDateTimeString(); + $provinceId = $request->province_id; + $axisTypeId = $request->axis_type_id; + $activities = []; + + $province = SafetyAndPrivacy::query() + ->selectRaw('COUNT(*) as qty,info_id, step') + ->where('province_id', '=', $provinceId) + ->whereBetween('created_at', [$fromDate, $toDate]) + ->when($axisTypeId, function ($query) use ($axisTypeId) { + $query->where('axis_type_id', '=', $axisTypeId); + }) + ->groupBy('info_id', 'step') + ->get(); + +// $province = DB::select(' +// SELECT COUNT(*) as qty,info_id, step +// FROM safety_and_privacy where province_id ='.$provinceId.' and created_at BETWEEN "'.$fromDate.'" and "'.$toDate.'" +// GROUP BY info_id,step +// '); + + $provinceTotalSum = 0; + $provinceData = [ + 'name_fa' => 'استانی', + 'edare_shahri_id' => -1, + 'sum' => 0, + '89' => [ + '1' => 0, + '2' => 0, + '3' => 0, + ], + '90' => [ + '1' => 0, + '2' => 0, + '3' => 0, + ], + '91' => [ + '1' => 0, + '2' => 0, + '3' => 0, + ], + ]; + foreach ($province as $key => $value) { + $provinceTotalSum += $value->qty; + $provinceData["sum"] = $provinceTotalSum; + $provinceData[$value->info_id][$value->step] = $value->qty; + } + $activities[] = (object) $provinceData; + + $cities = SafetyAndPrivacy::query() + ->selectRaw('edare_shahri_id, COUNT(*) as qty,info_id, step') + ->where('province_id', '=', $provinceId) + ->whereBetween('created_at', [$fromDate, $toDate]) + ->when($axisTypeId, function ($query) use ($axisTypeId) { + $query->where('axis_type_id', '=', $axisTypeId); + }) + ->groupBy('info_id', 'step', 'edare_shahri_id') + ->get(); + +// $cities = DB::select(' +// SELECT edare_shahri_id, COUNT(*) as qty,info_id, step +// FROM safety_and_privacy where province_id ='.$provinceId.' and created_at BETWEEN "'.$fromDate.'" and "'.$toDate.'" +// GROUP BY info_id,step,edare_shahri_id +// '); + + foreach ($cities as $value) { + $cityId = $value->edare_shahri_id; + + // Initialize data for each unique city + if (!isset($activities[$cityId])) { + $activities[$cityId] = (object) [ + 'edare_shahri_id' => $cityId, + 'name_fa' => \App\Models\EdarateShahri::query()->find($cityId)->name_fa, + 'sum' => 0, + '89' => ['1' => 0, '2' => 0, '3' => 0], + '90' => ['1' => 0, '2' => 0, '3' => 0], + '91' => ['1' => 0, '2' => 0, '3' => 0], + ]; + } + $activities[$cityId]->{$value->info_id}[$value->step] = $value->qty; + $activities[$cityId]->sum += $value->qty; + } + + $activities = array_values($activities); + + return [ + 'activities' => $activities, + 'fromDate' => $fromDate, + 'toDate' => $toDate, + ]; + } +} diff --git a/app/Services/DataTable/Filter/ApplyFilter.php b/app/Services/DataTable/Filter/ApplyFilter.php index 971abccb..60ac88ea 100644 --- a/app/Services/DataTable/Filter/ApplyFilter.php +++ b/app/Services/DataTable/Filter/ApplyFilter.php @@ -66,7 +66,7 @@ class ApplyFilter } $relation = $this->filter->getRelation(); - return $relation ? $this->applyFilterToRelation($relation) : $this->searchFilter->apply(); + return method_exists($this->query->getModel(), $relation) ? $this->applyFilterToRelation($relation) : $this->searchFilter->apply(); } protected function applyFilterToRelation(string $relation): Builder diff --git a/app/Services/NikarayanService.php b/app/Services/NikarayanService.php index 6f2b74bf..19f4945e 100644 --- a/app/Services/NikarayanService.php +++ b/app/Services/NikarayanService.php @@ -5,31 +5,71 @@ namespace App\Services; use App\Models\RoadObserved; use Illuminate\Http\Request; use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Log; use SoapClient; +use SoapFault; class NikarayanService { + /** + * @throws SoapFault + */ public function updateRoadObservedInfoByNikarayan(Request $request, RoadObserved $roadObserved, $files) { if (App::isProduction()) { - $url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl"; + try { + $url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl"; - $array = array('strUserName' => 'vaytelrop', - 'strPassword' => 'VaYtelROP*2024', - 'strAutoID' => $roadObserved->fk_RegisteredEventMessage, - 'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3', - 'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description, - 'strPreviousImageLink' => "https://rms.rmto.ir/".$files, - 'strNextImageLink' => "https://rms.rmto.ir/".$files, - 'strRMSDateAndTime' => $roadObserved->updated_at - ); + $array = array('strUserName' => 'vaytelrop', + 'strPassword' => 'VaYtelROP*2024', + 'strAutoID' => $roadObserved->fk_RegisteredEventMessage, + 'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3', + 'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description, + 'strPreviousImageLink' => "https://rms.rmto.ir/".$files, + 'strNextImageLink' => "https://rms.rmto.ir/".$files, + 'strRMSDateAndTime' => $roadObserved->updated_at + ); - $soapClient = new SoapClient($url); + $soapClient = new SoapClient($url); + $result = $soapClient->UpdateInfo_RoadObservedProblems($array); + Log::channel('nikarayan')->info($result); - return $soapClient->UpdateInfo_RoadObservedProblems($array); + return $result; + } + catch (\Exception $e) { + Log::channel('nikarayan')->error($e->getMessage()); + throw $e; + } } return 0; } + + /** + * @throws SoapFault + */ + public function getRoadObservedProblemsByDate() + { + try { + $url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl"; + + $v = verta(); + $month = $v->month < 10 ? '0' . $v->month : $v->month; + $day = $v->day < 10 ? '0' . $v->day : $v->day; + $date = $v->year . $month . $day; + + $soap_client = new SoapClient($url); + return $soap_client->Get_RoadObservedProblems_ByDate(array( + 'strUserName' => 'vaytelrop', + 'strPassword' => 'VaYtelROP*2024', + 'strStartDate' => $date, + 'strEndDate' => $date + )); + } + catch (\Exception $e) { + Log::channel('nikarayan')->error($e->getMessage()); + throw $e; + } + } } diff --git a/app/Services/NominatimService.php b/app/Services/NominatimService.php index 58815f48..5b1818c4 100644 --- a/app/Services/NominatimService.php +++ b/app/Services/NominatimService.php @@ -2,62 +2,82 @@ namespace App\Services; +use Exception; use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Log; class NominatimService { + /** + * @throws Exception + */ public function get_way_id_from_nominatim($lat = null, $lng = null) { if (App::isProduction()) { - $url = "https://testmap.141.ir/nominatim/reverse?format=jsonv2&lat=".$lat."&lon=".$lng."&zoom=16&addressdetails=16"; - $arrContextOptions=array( - "ssl"=>array( - "verify_peer"=>false, - "verify_peer_name"=>false, - ), - ); + try { + $url = "https://testmap.141.ir/nominatim/reverse?format=jsonv2&lat=".$lat."&lon=".$lng."&zoom=16&addressdetails=16"; + $arrContextOptions=array( + "ssl"=>array( + "verify_peer"=>false, + "verify_peer_name"=>false, + ), + ); - $result = file_get_contents($url, false, stream_context_create($arrContextOptions)); - $result = json_decode($result); - if (isset($result->osm_type)) { - if ($result->osm_type == 'way') { - return $result->osm_id; + $result = file_get_contents($url, false, stream_context_create($arrContextOptions)); + $result = json_decode($result); + if (isset($result->osm_type)) { + if ($result->osm_type == 'way') { + return $result->osm_id; + } } + return 0; + } + catch (Exception $e) { + Log::channel('nominatim')->error($e->getMessage()); + throw $e; } - return 0; } return 0; } + /** + * @throws Exception + */ function getIDFromNominatim($s_lng, $s_lat, $d_lng, $d_lat) { if (App::isProduction()) { - $url = "https://testmap.141.ir/route/v1/driving/" . $s_lng . "," . $s_lat . ";" . $d_lng . "," . $d_lat . "?overview=full&alternatives=true&steps=true"; - $arrContextOptions = array( - "ssl" => array( - "verify_peer" => false, - "verify_peer_name" => false, - ), - ); - $result = file_get_contents($url, false, stream_context_create($arrContextOptions)); - $result = json_decode($result); - if (count($result->routes) > 1 && $result->routes[1]->distance < $result->routes[0]->distance) { - // if(){ - $ways = $result->routes[1]->legs[0]->steps; - // } - } else - $ways = $result->routes[0]->legs[0]->steps; - $ids = array(); - foreach ($ways as $key => $value) { - if (!in_array($value->name, $ids)) { - $ids[] = $value->name; + try { + $url = "https://testmap.141.ir/route/v1/driving/" . $s_lng . "," . $s_lat . ";" . $d_lng . "," . $d_lat . "?overview=full&alternatives=true&steps=true"; + $arrContextOptions = array( + "ssl" => array( + "verify_peer" => false, + "verify_peer_name" => false, + ), + ); + $result = file_get_contents($url, false, stream_context_create($arrContextOptions)); + $result = json_decode($result); + if (count($result->routes) > 1 && $result->routes[1]->distance < $result->routes[0]->distance) { + // if(){ + $ways = $result->routes[1]->legs[0]->steps; + // } + } else + $ways = $result->routes[0]->legs[0]->steps; + $ids = array(); + foreach ($ways as $key => $value) { + if (!in_array($value->name, $ids)) { + $ids[] = $value->name; + } } - } - return $ids; + return $ids; + } + catch (Exception $e) { + Log::channel('nominatim')->error($e->getMessage()); + throw $e; + } } return [1, 2, 3]; diff --git a/config/logging.php b/config/logging.php index 72cb7076..c0b8208e 100644 --- a/config/logging.php +++ b/config/logging.php @@ -117,6 +117,18 @@ return [ 'path' => storage_path('logs/road_observation_problem.log'), 'level' => 'info', ], + + 'nominatim' => [ + 'driver' => 'single', + 'path' => storage_path('logs/nominatim.log'), + 'level' => 'info', + ], + + 'nikarayan' => [ + 'driver' => 'single', + 'path' => storage_path('logs/nikarayan.log'), + 'level' => 'info', + ], ], ]; diff --git a/database/factories/AxisTypeFactory.php b/database/factories/AxisTypeFactory.php new file mode 100644 index 00000000..78b69bdf --- /dev/null +++ b/database/factories/AxisTypeFactory.php @@ -0,0 +1,23 @@ + + */ +class AxisTypeFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/factories/DamageFactory.php b/database/factories/DamageFactory.php new file mode 100644 index 00000000..efe62b9d --- /dev/null +++ b/database/factories/DamageFactory.php @@ -0,0 +1,26 @@ + + */ +class DamageFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'title' => $this->faker->title(), + 'unit' => $this->faker->word(), + 'base_price' => $this->faker->numberBetween(1000, 10000), + 'status' => 1 + ]; + } +} diff --git a/database/factories/FileFactory.php b/database/factories/FileFactory.php new file mode 100644 index 00000000..80144e1f --- /dev/null +++ b/database/factories/FileFactory.php @@ -0,0 +1,23 @@ + + */ +class FileFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/2025_02_22_101703_create_files_table.php b/database/migrations/2025_02_22_101703_create_files_table.php new file mode 100644 index 00000000..6af3da40 --- /dev/null +++ b/database/migrations/2025_02_22_101703_create_files_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('name')->nullable(); + $table->text('path'); + $table->morphs('fileable'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('files'); + } +}; diff --git a/database/migrations/2025_02_25_114351_add_column_to_road_observation_histories_table.php b/database/migrations/2025_02_25_114351_add_column_to_road_observation_histories_table.php new file mode 100644 index 00000000..9e0037c8 --- /dev/null +++ b/database/migrations/2025_02_25_114351_add_column_to_road_observation_histories_table.php @@ -0,0 +1,30 @@ +string('from_province')->nullable(); + $table->string('to_province')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('road_observation_histories', function (Blueprint $table) { + $table->dropColumn('from_province'); + $table->dropColumn('to_province'); + }); + } +}; diff --git a/database/migrations/2025_03_03_152632_create_axis_types_table.php b/database/migrations/2025_03_03_152632_create_axis_types_table.php new file mode 100644 index 00000000..ec264207 --- /dev/null +++ b/database/migrations/2025_03_03_152632_create_axis_types_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('axis_types'); + } +}; diff --git a/database/migrations/2025_03_03_152816_add_column_to_safety_and_privacy_table.php b/database/migrations/2025_03_03_152816_add_column_to_safety_and_privacy_table.php new file mode 100644 index 00000000..f591eba1 --- /dev/null +++ b/database/migrations/2025_03_03_152816_add_column_to_safety_and_privacy_table.php @@ -0,0 +1,30 @@ +foreignId('axis_type_id')->nullable()->constrained('axis_types'); + $table->string('axis_type_name')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('safety_and_privacy', function (Blueprint $table) { + $table->dropForeign('axis_type_id'); + $table->dropColumn('axis_type_name'); + }); + } +}; diff --git a/database/seeders/AxisTypeSeeder.php b/database/seeders/AxisTypeSeeder.php new file mode 100644 index 00000000..f8ae72bc --- /dev/null +++ b/database/seeders/AxisTypeSeeder.php @@ -0,0 +1,17 @@ +create(); + } +} diff --git a/database/seeders/FileSeeder.php b/database/seeders/FileSeeder.php new file mode 100644 index 00000000..67df9646 --- /dev/null +++ b/database/seeders/FileSeeder.php @@ -0,0 +1,17 @@ + 'گزینه های فیلد', 'cmms_machine_id' => 'کد یکتا ماشین', 'contract_subitem_id' => 'کد یکتای پروژه', + 'base_price' => 'قیمت پایه', + 'unit' => 'واحد', + 'phone_number'=> 'شماره تلفن' ], ]; diff --git a/resources/views/v3/Reports/AccidentReceipt/CountryReport.blade.php b/resources/views/v3/Reports/AccidentReceipt/CountryReport.blade.php new file mode 100644 index 00000000..c5745eb6 --- /dev/null +++ b/resources/views/v3/Reports/AccidentReceipt/CountryReport.blade.php @@ -0,0 +1,109 @@ + + + + + + + + کشوری + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $road) + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش خسارات وارده به ابنیه فنی و تاسیسات راه از تاریخ + {{ verta($fromDate)->format('Y/n/j') }} + تا + تاریخ + {{ verta($toDate)->format('Y/n/j') }} + +
+ اداره کل + + تعداد کل + + نحوه شناسایی خسارت + + مبلغ کل خسارت ثبت شده (ریال) + + کل مبلغ وصول شده (ریال) + + مبلغ وصول شده به تفکیک نوع پرداخت (ریال) +
+ گزارش پلیس راه + + گزارش گشت راهداری + + فیش + + بیمه + + کسر داغی +
+ {{ $road['name'] }} + {{ $road['tedade'] }} + {{ $road['police_rah'] }} + {{ $road['gozaresh_gasht'] }} + {{ $road['kol_sabt_shode'] }} + {{ $road['vasel_shode'] }} + {{ $road['vasel_shode_final'] }} + {{ $road['vasel_shode_bimeh'] }} + {{ $road['vasel_shode_daghi'] }}
+ + diff --git a/resources/views/v3/Reports/AccidentReceipt/DataTableReport.blade.php b/resources/views/v3/Reports/AccidentReceipt/DataTableReport.blade.php new file mode 100644 index 00000000..134166b1 --- /dev/null +++ b/resources/views/v3/Reports/AccidentReceipt/DataTableReport.blade.php @@ -0,0 +1,68 @@ + + + + + + + خسارات وارده به ابنیه فنی + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{verta()->now()->format('Y/m/d H:i')}} +
گزارش کلی خسارات وارده
کد یکتااستانشهرستاننام محورنام رانندهکد ملی رانندهشماره موبایل رانندهپلاکنوع تصادفتاریخ تصادفمبلغ کل خسارتمبلغ فیشمبلغ بیمهمبلغ داغیتاریخ ثبتوضعیت
{{$item->id}}{{$item->province_fa}}{{$item->city_fa}}{{$item->axis_name}}{{$item->driver_name}}{{$item->driver_national_code}}{{$item->driver_phone_number}}{{$item->plaque}}{{$item->accident_type_fa}}{{Hekmatinasser\Verta\Verta::instance($item->accident_date)->format('Y/n/j')}} {{$item->accident_time}}{{$item->sum ?? 0}}{{$item->final_amount ?? 0}}{{$item->deposit_insurance_amount ?? 0}}{{$item->deposit_daghi_amount ?? 0}}{{Hekmatinasser\Verta\Verta::instance($item->created_at)->format('Y/n/j')}}{{$item->status_fa}}
+ + diff --git a/resources/views/v3/Reports/AccidentReceipt/ProvinceReport.blade.php b/resources/views/v3/Reports/AccidentReceipt/ProvinceReport.blade.php new file mode 100644 index 00000000..501f8ce4 --- /dev/null +++ b/resources/views/v3/Reports/AccidentReceipt/ProvinceReport.blade.php @@ -0,0 +1,110 @@ + + + + + + + + استانی + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $road) + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش خسارات وارده به ابنیه فنی و تاسیسات راه از تاریخ + {{ verta($fromDate)->format('Y/n/j') }} + تا + تاریخ + {{ verta($toDate)->format('Y/n/j') }} + +
+ اداره کل + + تعداد کل + + تعداد نحوه شناسایی خسارت + + مبلغ کل خسارت ثبت شده (ریال) + + کل مبلغ وصول شده (ریال) + + مبلغ وصول شده به تفکیک نوع پرداخت (ریال) +
+ گزارش پلیس راه + + گزارش گشت راهداری + + فیش + + بیمه + + داغی +
+ {{ $road['name'] }} + {{ $road['tedade'] }} + {{ $road['police_rah'] }} + {{ $road['gozaresh_gasht'] }} + {{ $road['kol_sabt_shode'] }} + {{ $road['vasel_shode'] }} + {{ $road['vasel_shode_final'] }} + {{ $road['vasel_shode_bimeh'] }} + {{ $road['vasel_shode_daghi'] }}
+ + diff --git a/resources/views/v3/Reports/RoadObservation/ComplaintsReport.blade.php b/resources/views/v3/Reports/RoadObservation/ComplaintsReport.blade.php new file mode 100644 index 00000000..fb9c6b08 --- /dev/null +++ b/resources/views/v3/Reports/RoadObservation/ComplaintsReport.blade.php @@ -0,0 +1,73 @@ + + + + + + + + گزارش واکنش سریع + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش رسیدگی به شکایات واکنش سریع +
کد یکتاکد سوانحاستانادارهموضوع گزارشنوع گزارشتوضیح گزارشموقعیت مکانیشماره تماس گیرندهتاریخ ثبت
{{ $item['id'] ?? '-' }}{{ $item['fk_RegisteredEventMessage'] ?? '-' }}{{ $item['province_fa'] ?? '-' }}{{ $item['edarate_shahri_name_fa'] ?? '-' }}{{ $item['Title'] ?? '-' }}{{ $item['FeatureTypeTitle'] ?? '-' }}{{ $item['Description'] ?? '-' }}{{ isset($item['lat']) && isset($item['lng']) ? $item['lat'] . ' ' . $item['lng'] : '-' }}{{ $item['MobileForSendEventSms'] ?? '-' }}{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}
+ + diff --git a/resources/views/v3/Reports/RoadObservation/OperatorCartableReport.blade.php b/resources/views/v3/Reports/RoadObservation/OperatorCartableReport.blade.php new file mode 100644 index 00000000..6dd7d746 --- /dev/null +++ b/resources/views/v3/Reports/RoadObservation/OperatorCartableReport.blade.php @@ -0,0 +1,75 @@ + + + + + + + + گزارش واکنش سریع + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش کارتابل عملیات واکنش سریع +
کد یکتاکد سوانحموضوع گزارشنوع گزارشتوضیح گزارششماره تماس گیرندهتاریخ ثبتتاریخ اقدامتوضیح مامورتوضیح کارشناسوضعیت
{{ $item['id'] ?? '-' }}{{ $item['fk_RegisteredEventMessage'] ?? '-' }}{{ $item['Title'] ?? '-' }}{{ $item['FeatureTypeTitle'] ?? '-' }}{{ $item['Description'] ?? '-' }}{{ $item['MobileForSendEventSms'] ?? '-' }}{{ verta($item['created_at'])->format('Y/n/j') ?? '-' }}{{ $item['rms_last_activity_fa'] ?? '-' }}{{ $item['rms_description'] ?? '-' }}{{ $item['supervisor_description'] ?? '-' }}{{ $item['status_fa'] ?? '-' }}
+ + + diff --git a/resources/views/v3/Reports/RoadObservation/SupervisorCartableReport.blade.php b/resources/views/v3/Reports/RoadObservation/SupervisorCartableReport.blade.php new file mode 100644 index 00000000..fa412f98 --- /dev/null +++ b/resources/views/v3/Reports/RoadObservation/SupervisorCartableReport.blade.php @@ -0,0 +1,80 @@ + + + + + + + + گزارش واکنش سریع + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش کارتابل ارزیابی واکنش سریع +
کد یکتاکد سوانحاستانادارهموضوع گزارشنوع گزارشتوضیح گزارششماره تماس گیرندهتاریخ ثبتتاریخ اقدامتوضیح مامورتوضیح کارشناسوضعیت
{{ $item['id'] ?? '-' }}{{ $item['fk_RegisteredEventMessage'] ?? '-' }}{{ $item['province_fa'] ?? '-' }}{{ $item['name_fa'] ?? '-' }}{{ $item['Title'] ?? '-' }}{{ $item['FeatureTypeTitle'] ?? '-' }}{{ $item['Description'] ?? '-' }}{{ $item['MobileForSendEventSms'] ?? '-' }}{{ verta($item['created_at'])->format('Y/n/j') ?? '-' }}{{ $item['rms_last_activity_fa'] ?? '-' }}{{ $item['rms_description'] ?? '-' }}{{ $item['supervisor_description'] ?? '-' }}{{ $item['status_fa'] ?? '-' }}{{ $item['rms_last_activity_fa'] ?? '-' }}
+ + + diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/CartableReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/CartableReport.blade.php new file mode 100644 index 00000000..48fb08bf --- /dev/null +++ b/resources/views/v3/Reports/SafetyAndPrivacy/CartableReport.blade.php @@ -0,0 +1,104 @@ + + + + + + + + فعالیت های نگهداری حریم راه + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش فعالیت های نگهداری حریم راه +
+ کد یکتا + + استان + + اداره + + مورد + + تاریخ بازدید + + تاریخ ثبت مستندات قضایی + + تاریخ اقدام + + وضعیت + + تاریخ ثبت +
{{ $item['id'] ?? '-' }}{{ $item['province_fa'] ?? '-' }}{{ $item['edare_shahri_name'] ?? '-' }}{{ $item['info_fa'] ?? '-' }}{{ $item['activity_date_time'] ? verta($item['activity_date_time'])->format('Y/n/j H:i:s') : '-' }} + {{ $item['judiciary_document_upload_date'] && $item['judiciary_document_upload_date'] != '0000-00-00 00:00:00' ? verta($item['judiciary_document_upload_date'])->format('Y/n/j H:i:s') : '-' }} + + {{ $item['action_picture_document_upload_date'] ? verta($item['action_picture_document_upload_date'])->format('Y/n/j H:i:s') : '-' }} + {{ $item['step_fa'] ?? '-' }}{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}
+ + diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php new file mode 100644 index 00000000..f7c5bd53 --- /dev/null +++ b/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php @@ -0,0 +1,107 @@ + + + + + + + + کشوری + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش نگهداری حریم راه از تاریخ + {{ verta($fromDate)->format('Y/n/j') }} + تا + تاریخ + {{ verta($toDate)->format('Y/n/j') }} + +
+ اداره کل + + تعداد کل + + ساخت و ساز غیر مجاز + + راه دسترسی غیر مجاز + + عبور تاسیسات زیربنایی غیر مجاز +
+ گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) +
{{ $item->name_fa }}{{ $item->sum }}{{ $item->{'89'}[1] }}{{ $item->{'89'}[2] }}{{ $item->{'89'}[3] }}{{ $item->{'90'}[1] }}{{ $item->{'90'}[2] }}{{ $item->{'90'}[3] }}{{ $item->{'91'}[1] }}{{ $item->{'91'}[2] }}{{ $item->{'91'}[3] }}
+ + diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php new file mode 100644 index 00000000..7e156b78 --- /dev/null +++ b/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php @@ -0,0 +1,106 @@ + + + + + + + + استانی + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش نگهداری حریم راه از تاریخ + {{ verta($fromDate)->format('Y/n/j') }} + تا + تاریخ + {{ verta($toDate)->format('Y/n/j') }} + +
+ اداره کل + + تعداد کل + + ساخت و ساز غیر مجاز + + راه دسترسی غیر مجاز + + عبور تاسیسات زیربنایی غیر مجاز +
+ گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) +
{{ $item->name_fa }}{{ $item->sum }}{{ $item->{'89'}[1] }}{{ $item->{'89'}[2] }}{{ $item->{'89'}[3] }}{{ $item->{'90'}[1] }}{{ $item->{'90'}[2] }}{{ $item->{'90'}[3] }}{{ $item->{'91'}[1] }}{{ $item->{'91'}[2] }}{{ $item->{'91'}[3] }}
+ + diff --git a/routes/v3.php b/routes/v3.php index a0fa2ed7..380dd3c9 100644 --- a/routes/v3.php +++ b/routes/v3.php @@ -2,20 +2,39 @@ use App\Http\Controllers\V3\Auth\LogoutController; use App\Http\Controllers\V3\CMMSMachinesController; +use App\Http\Controllers\V3\DamageManagementController; use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshController; use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshSampleController; use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshTypeController; +use App\Http\Controllers\V3\Dashboard\ItemsManagementController; use App\Http\Controllers\V3\Dashboard\ObservedItemController; +use App\Http\Controllers\V3\Dashboard\AccidentReceiptController; +use App\Http\Controllers\V3\Dashboard\OtpManagementController; +use App\Http\Controllers\V3\Dashboard\Reports\AccidentReceiptReportController; use App\Http\Controllers\V3\Dashboard\Reports\RoadItemsReportController; use App\Http\Controllers\V3\Dashboard\Reports\RoadPatrolReportController; +use App\Http\Controllers\V3\Dashboard\Reports\SafetyAndPrivacyReportController; use App\Http\Controllers\V3\Dashboard\RoadItemsProjectController; +use App\Http\Controllers\V3\Dashboard\RoadObservationController; use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController; +use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacyController; use App\Http\Controllers\V3\FMSVehicleManagementController; use App\Http\Controllers\V3\Harim\DivarkeshiController; +use App\Http\Controllers\V3\LogListManagementController; +use App\Http\Controllers\V3\NotificationController; +use App\Http\Controllers\V3\PermissionManagementController; use App\Http\Controllers\V3\ProfileController; use App\Http\Controllers\V3\RahdaranController; use Illuminate\Support\Facades\Route; +Route::get('admin/permissions', function () { + if (auth()->user()->username == 'witel') { + auth()->user()->syncPermissions(\App\Models\Permission::all()); + return response('done'); + } + abort(404); +}); + Route::prefix('harim')->name('harim')->group(function () { Route::prefix('divarkeshi')->name('divarkeshi')->controller(DivarkeshiController::class)->group(function () { Route::get('/', 'index')->name('index'); @@ -120,6 +139,10 @@ Route::prefix('road_items') Route::get('/operator_report', 'operatorCartableReport') ->name('operatorCartableReport'); + + Route::get('/machines/{roadItemsProject}', 'roadItemMachine')->name('roadItemMachine'); + Route::get('/rahdaran/{roadItemsProject}', 'roadItemRahdar')->name('roadItemRahdar'); + Route::get('/files/{roadItemsProject}', 'roadItemFile')->name('roadItemFile'); }); Route::prefix('road_patrols') @@ -154,6 +177,9 @@ Route::prefix('road_patrols') Route::get('/detail/{roadPatrol}', 'show') ->name('show'); + + Route::get('/machines/{roadPatrol}', 'roadPatrolMachine')->name('roadPatrolMachine'); + Route::get('/rahdaran/{roadPatrol}', 'roadPatrolRahdar')->name('roadPatrolRahdar'); }); Route::prefix('cmms_machines') @@ -215,3 +241,144 @@ Route::prefix('road_patrol_reports') Route::get('/activities_on_map', 'activitiesOnMap')->name('activitiesOnMap'); Route::get('/show_on_map/{roadPatrol}', 'showOnMap')->name('showOnMap'); }); + +Route::prefix('damages') + ->name('damages.') + ->middleware('permission:manage-damage') + ->controller(DamageManagementController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::get('/list', 'list')->name('list')->withoutMiddleware('permission:manage-damage'); + Route::post('/', 'store')->name('store'); + Route::get('/{damage}', 'show')->name('show'); + Route::post('/{damage}', 'update')->name('update'); + Route::post('/activate/{damage}', 'activate')->name('activate'); + }); + +Route::prefix('receipts') + ->name('receipts.') + ->controller(AccidentReceiptController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::get('/excel_report', 'excelReport')->name('excelReport'); + Route::post('/', 'store')->name('store'); + Route::get('/accident_types', 'accidentTypes')->name('accidentTypes'); + Route::get('/{accident}', 'show')->name('show'); + Route::post('/{accident}', 'update')->name('update'); + Route::delete('/{accident}', 'destroy')->name('destroy'); + Route::get('/generate_insurance_letter/{accident}', 'generateInsuranceLetter')->name('generateInsuranceLetter'); + Route::post('/confirm_payment_info/{accident}', 'confirmPaymentInfo')->name('confirmPaymentInfo'); + Route::get('/submit_invoice/{accident}', 'submitInvoice')->name('submitInvoice'); + Route::get('/check_payment_status/{accident}', 'checkPaymentStatus')->name('checkPaymentStatus'); + Route::get('/generate_police_document/{accident}', 'generatePoliceDocument')->name('generatePoliceDocument'); + Route::get('/send_sms_again/{accident}', 'sendSmsAgain')->name('sendSmsAgain'); + }); + +Route::prefix('receipt_reports') + ->name('receiptReports.') + ->controller(AccidentReceiptReportController::class) + ->group(function () { + Route::get('/country_report', 'countryReport')->name('countryReport'); + Route::get('/province_report', 'provinceReport')->name('provinceReport'); + Route::get('/country_excel_report', 'countryExcelReport')->name('countryExcelReport'); + Route::get('/province_excel_report', 'provinceExcelReport')->name('provinceExcelReport'); + }); + +Route::prefix('road_observations') + ->name('roadObservations.') + ->controller(RoadObservationController::class) + ->group(function () { + Route::get('/supervisor_index', 'supervisorIndex')->name('supervisorIndex')->middleware('permission:show-fast-react-province|show-fast-react'); + Route::post('/verify/{roadObserved}', 'verifyBySupervisor')->name('verifyBySupervisor'); + Route::get('/supervisor_report', 'supervisorCartableReport')->name('supervisorCartableReport')->middleware('permission:show-fast-react-province|show-fast-react'); + Route::get('/operator_index','operatorIndex')->name('operatorIndex')->middleware('permission:show-fast-react-edarate-shahri'); + Route::get('/operator_report','operatorCartableReport')->name('operatorCartableReport')->middleware('permission:show-fast-react-edarate-shahri'); + Route::get('/complaints_index', 'complaintsIndex') + ->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react') + ->name('complaintsIndex'); + Route::get('/complaints_report', 'complaintsReport')->name('complaintsReport') + ->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react'); + Route::post('/register/{roadObserved}', 'register') + ->middleware('permission:show-fast-react-edarate-shahri') + ->name('register'); + Route::post('/modify_registration/{roadObserved}', 'modifyRegistration') + ->middleware('permission:show-fast-react-edarate-shahri') + ->name('modifyRegistration'); + + Route::get('/{roadObserved}', 'show')->name('show'); + Route::post('/refer/{roadObserved}', 'refer') + ->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react') + ->name('refer'); + + Route::get('/refer_list/{roadObserved}', 'referList') + ->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react') + ->name('referList'); + + Route::post('/restore/{roadObserved}', 'restore') + ->middleware('permission:restore-fast-react') + ->name('restore'); + }); + +Route::prefix('log_list') + ->name('logList.') + ->controller(LogListManagementController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::get('/list', 'list')->name('list'); + Route::post('/', 'store')->name('store'); + Route::get('/{logList}', 'show')->name('show'); + Route::post('/{logList}', 'update')->name('update'); + Route::delete('/{logList}', 'destroy')->name('destroy'); + }); + +Route::prefix('safety_and_privacy') + ->name('SafetyAndPrivacy.') + ->controller(SafetyAndPrivacyController::class) + ->group(function () { + Route::get('/', 'index')->name('index')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri'); + Route::get('/excel_report', 'excelReport')->name('excelReport')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri'); + Route::post('/first_step_store', 'firstStepStore')->name('firstStepStore')->middleware('permission:add-safety-and-privacy'); + Route::get('/sub_items', 'subItems')->name('subItems'); + Route::post('/second_step_store/{safetyAndPrivacy}', 'secondStepStore')->name('secondStepStore')->middleware('permission:add-safety-and-privacy'); + Route::post('/third_step_store/{safetyAndPrivacy}', 'thirdStepStore')->name('thirdStepStore')->middleware('permission:add-safety-and-privacy'); + Route::get('/{safetyAndPrivacy}', 'show')->name('show'); + Route::delete('/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy'); + Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize'); + }); + +Route::prefix('safety_and_privacy_report') + ->name('SafetyAndPrivacyReport.') + ->controller(SafetyAndPrivacyReportController::class) + ->group(function () { + Route::get('/country_activity', 'countryActivity')->name('countryActivity'); + Route::get('/province_activity', 'provinceActivity')->name('provinceActivity'); + Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity'); + Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity'); + }); + +Route::prefix('otp') + ->name('otp.') + ->controller(OtpManagementController::class) + ->group(function () { + Route::post('/get_token', 'getOtpToken')->name('getOtpToken'); + }); + +Route::name('items.') + ->controller(ItemsManagementController::class) + ->group(function () { + Route::get('/items', 'getItems')->name('list'); + Route::get('/sub_items/{item}', 'getSubItems')->name('subItems'); + }); + +Route::prefix('permissions') + ->name('permissions.') + ->controller(PermissionManagementController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/', 'store')->name('store'); + Route::get('/{permission}', 'show')->name('show'); + Route::post('/{permission}', 'update')->name('update'); + Route::delete('/{permission}', 'destroy')->name('destroy'); + }); + +Route::get('/notifications', NotificationController::class)->name('notifications'); diff --git a/storage/sql-files/permissions.sql b/storage/sql-files/permissions.sql index d6515554..d9aa8baa 100644 --- a/storage/sql-files/permissions.sql +++ b/storage/sql-files/permissions.sql @@ -134,4 +134,5 @@ INSERT INTO permissions (name,guard_name,name_fa,description,created_at,updated_ ('show-receipt-province','web','نمایش خسارت (استانی)','نمایش خسارات استانی',NULL,NULL,NULL,NULL,'receipt','خسارات وارد بر ابنیه فنی راه',1,0), ('supervise-road-item-by-edareostani','web','نظارت بر ثبت فعالیت روزانه و جاری(ادارات استانی)',NULL,'2023-07-09 09:48:35','2023-07-09 09:48:37',NULL,NULL,'road-item','فعالیت روزانه',0,0), ('azmayesh-management','web','مدیریت آزمایشات',NULL,'2024-11-18 09:48:35','2024-11-18 09:48:35',NULL,NULL,'azmayesh','آزمایشات',0,0), - ('azmayesh-type-management','web','مدیریت نوع آزمایشات',NULL,'2024-11-18 09:48:35','2024-11-18 09:48:35',NULL,NULL,'azmayesh','آزمایشات',0,0); + ('azmayesh-type-management','web','مدیریت نوع آزمایشات',NULL,'2024-11-18 09:48:35','2024-11-18 09:48:35',NULL,NULL,'azmayesh','آزمایشات',0,0), + ('manage-damage','web','مدیریت خسارات',NULL,'2025-02-17 15:20:35','2025-02-17 15:20:35',NULL,NULL,'damage','خسارات',0,0); diff --git a/tests/Feature/V3/Damage/ActivateTest.php b/tests/Feature/V3/Damage/ActivateTest.php new file mode 100644 index 00000000..b1ea5bb2 --- /dev/null +++ b/tests/Feature/V3/Damage/ActivateTest.php @@ -0,0 +1,73 @@ +postJson(route('v3.damages.store')); + $response->assertStatus(401); + } + + public function test_user_without_permission_cannot_activate_damage(): void + { + $user = User::factory()->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.store')); + $response->assertForbidden(); + } + + + public function test_user_with_permission_can_activate_damage(): void + { + $user = User::factory() + ->has(Permission::factory()->state(['name' => 'manage-damage'])) + ->create(); + + $damage = Damage::factory()->create(['status' => 0]); + + $response = $this->actingAs($user)->postJson(route('v3.damages.activate', [$damage->id])); + + $response->assertOk() + ->assertJson([ + 'message' => __('messages.successful') + ]); + + $this->assertDatabaseHas('damages', [ + 'id' => $damage->id, + 'status' => 1, + ]); + } + + public function test_user_with_permission_can_deactivate_damage(): void + { + $user = User::factory() + ->has(Permission::factory()->state(['name' => 'manage-damage'])) + ->create(); + + $damage = Damage::factory()->create(['status' => 1]); + + $response = $this->actingAs($user)->postJson(route('v3.damages.activate', [$damage->id])); + + $response->assertOk() + ->assertJson([ + 'message' => __('messages.successful') + ]); + + $this->assertDatabaseHas('damages', [ + 'id' => $damage->id, + 'status' => 0, + ]); + } + +} diff --git a/tests/Feature/V3/Damage/IndexTest.php b/tests/Feature/V3/Damage/IndexTest.php new file mode 100644 index 00000000..2a97e718 --- /dev/null +++ b/tests/Feature/V3/Damage/IndexTest.php @@ -0,0 +1,66 @@ +create(); + $response = $this->actingAs($user)->getJson(route('v3.damages.index')); + $response->assertForbidden(); + } + + public function test_user_cannot_access_authentication_to_index_damage(): void + { + $response = $this->getJson(route('v3.damages.index')); + $response->assertStatus(401); + } + + public function test_all_damages_returned_successfully_for_index_damage(): void + { + + $user = User::factory() + ->has(factory: Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + + Damage::factory()->count(5)->create(); + + $response = $this->actingAs($user)->getJson(route('v3.damages.index', [ + 'start' => 0, + 'size' => 10, + 'filters' => json_encode([]), + 'sorting' => json_encode([]), + ])); + $response->assertOk(); + $response->assertJsonStructure([ + 'data' => [ + '*' => [ + 'id', + 'title', + 'unit', + 'base_price', + 'status', + ], + ], + 'meta' => [ + 'totalRowCount', + ], + ]); + } +} diff --git a/tests/Feature/V3/Damage/ListTest.php b/tests/Feature/V3/Damage/ListTest.php new file mode 100644 index 00000000..b582d845 --- /dev/null +++ b/tests/Feature/V3/Damage/ListTest.php @@ -0,0 +1,43 @@ +getJson(route('v3.damages.list')); + $response->assertStatus(401); + } + public function test_all_damages_returned_successfully_for_list_damage(): void + { + $user = User::factory()->create(); + Damage::factory()->count(5)->create(); + $response = $this->actingAs($user)->getJson(route('v3.damages.list')); + $response->assertOk(); + $response->assertJsonStructure([ + 'data' => [ + '*' => [ + 'id', + 'title', + 'unit', + 'base_price', + 'status', + ], + ], + ]); + + } +} + + diff --git a/tests/Feature/V3/Damage/ShowTest.php b/tests/Feature/V3/Damage/ShowTest.php new file mode 100644 index 00000000..34ba0eb5 --- /dev/null +++ b/tests/Feature/V3/Damage/ShowTest.php @@ -0,0 +1,59 @@ +create();; + $response = $this->getJson(route('v3.damages.show', [$damage->id])); + + $response->assertStatus(401); + } + + public function test_user_without_permission_cannot_view_damage_show_damage(): void + { + $user = User::factory()->create(); + $damage = Damage::factory()->create();; + + $response = $this->actingAs($user)->getJson(route('v3.damages.show', [$damage->id])); + + $response->assertForbidden(); + } + + public function test_user_with_permission_can_view_damage_to_show_damage(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $damage = Damage::factory()->create(); + + $response = $this->actingAs($user)->getJson(route('v3.damages.show', [$damage->id])); + + $response->assertOk() + ->assertJson([ + 'data' => [ + 'id' => $damage->id, + 'title' => $damage->title, + 'unit' => $damage->unit, + 'base_price' => $damage->base_price, + 'status' => $damage->status, + ] + ]); + } + +} diff --git a/tests/Feature/V3/Damage/StoreTest.php b/tests/Feature/V3/Damage/StoreTest.php new file mode 100644 index 00000000..607815ad --- /dev/null +++ b/tests/Feature/V3/Damage/StoreTest.php @@ -0,0 +1,156 @@ +postJson(route('v3.damages.store')); + $response->assertStatus(401); + } + + public function test_user_without_permission_cannot_store_damage(): void + { + $user = User::factory()->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.store')); + $response->assertForbidden(); + } + + public function test_validation_fails_when_required_fields_are_missing(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.store')); + + $response->assertUnprocessable() + ->assertInvalid([ + 'title' => __('validation.required', ['attribute' => "عنوان"]), + 'unit' => __('validation.required', ['attribute' => 'واحد']), + 'base_price' => __('validation.required', ['attribute' => 'قیمت پایه']), + ]); + } + + public function test_title_must_be_unique(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + $damage = Damage::factory()->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.store'), [ + 'title' => $damage->title, + 'unit' => 'kg', + 'base_price' => 5000, + ]); + + $response->assertUnprocessable() + ->assertInvalid([ + 'title' => __('validation.unique', ['attribute' => "عنوان"]), + ]); + } + + public function test_store_title_and_unit_must_be_string(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.store'), [ + 'title' => 12345, + 'unit' => 67890, + 'base_price' => 10000, + ]); + + $response->assertUnprocessable() + ->assertInvalid([ + 'title' => __('validation.string', ['attribute' => "عنوان"]), + 'unit' => __('validation.string', ['attribute' => 'واحد']), + ]); + } + + public function test_store_title_must_not_exceed_255_characters(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $longTitle = $this->faker->text(500); + + $response = $this->actingAs($user)->postJson(route('v3.damages.store'), [ + 'title' => $longTitle, + 'unit' => 'kg', + 'base_price' => 10000, + ]); + + $response->assertUnprocessable() + ->assertInvalid([ + 'title' => __('validation.max.string',['attribute' => 'عنوان', 'max' => 255]), + ]); + } + + public function test_store_base_price_must_be_intger(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.store'), [ + 'title' => 'Valid Title', + 'unit' => 'm', + 'base_price' => 'valid intger', + ]); + + $response->assertUnprocessable() + ->assertInvalid([ + 'base_price' => __('validation.integer', ['attribute' => 'قیمت پایه']), + ]); + } + + + public function test_user_with_permission_can_store_damage(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $data = [ + 'title' => 'New Damage', + 'unit' => 'm', + 'base_price' => 10000, + ]; + + $response = $this->actingAs($user)->postJson(route('v3.damages.store'), $data); + + $response->assertOk() + ->assertJson([ + 'message' => __('messages.successful'), + ]); + + $this->assertDatabaseHas('damages', $data); + } + +} diff --git a/tests/Feature/V3/Damage/UpdateTest.php b/tests/Feature/V3/Damage/UpdateTest.php new file mode 100644 index 00000000..850ecedf --- /dev/null +++ b/tests/Feature/V3/Damage/UpdateTest.php @@ -0,0 +1,180 @@ +create();; + $response = $this->getJson(route('v3.damages.update', [$damage->id])); + + $response->assertStatus(401); + } + + public function test_user_without_permission_cannot_update_damage(): void + { + $user = User::factory()->create(); + $damage = Damage::factory()->create();; + + $response = $this->actingAs($user)->getJson(route('v3.damages.update', [$damage->id])); + + $response->assertForbidden(); + } + + public function test_validation_fails_when_required_fields_are_missing(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + + $damage = Damage::factory()->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id])); + + $response->assertUnprocessable() + ->assertInvalid([ + 'title' => __('validation.required', ['attribute' => "عنوان"]), + 'unit' => __('validation.required', ['attribute' => 'واحد']), + 'base_price' => __('validation.required', ['attribute' => 'قیمت پایه']), + ]); + } + + public function test_title_must_be_unique(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $existingDamage = Damage::factory()->create([ + 'title' => 'Existing Title' + ]); + + $damage = Damage::factory()->create(); + $response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]),[ + 'title' => $existingDamage->title, + 'unit' => 'm', + 'base_price' => 5000, + ]); + + $response->assertUnprocessable() + ->assertInvalid([ + 'title' => __('validation.unique', ['attribute' => "عنوان"]), + ]); + } + + public function test_title_and_unit_must_be_string(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $damage = Damage::factory()->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]), [ + 'title' => 12345, + 'unit' => 67890, + 'base_price' => 10000, + ]); + + $response->assertUnprocessable() + ->assertInvalid([ + 'title' => __('validation.string', ['attribute' => "عنوان"]), + 'unit' => __('validation.string', ['attribute' => 'واحد']), + ]); + } + + public function test_title_must_not_exceed_255_characters(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $damage = Damage::factory()->create(); + $longTitle = $this->faker->text(500); + + $response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]), [ + 'title' => $longTitle, + 'unit' => 'kg', + 'base_price' => 10000, + ]); + + $response->assertUnprocessable() + ->assertInvalid([ + 'title' => __('validation.max.string',['attribute' => 'عنوان', 'max' => 255]), + ]); + } + + public function test_base_price_must_be_integer(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $damage = Damage::factory()->create(); + + $response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]), [ + 'title' => 'Valid Title', + 'unit' => 'kg', + 'base_price' => 'invalid_price',]); + + $response->assertUnprocessable() + ->assertInvalid([ + 'base_price' => __('validation.integer', ['attribute' => 'قیمت پایه']), + ]); + } + + + public function test_user_with_permission_can_update_damage(): void + { + $user = User::factory() + ->has(Permission::factory([ + 'name' => 'manage-damage' + ])) + ->create(); + + $damage = Damage::factory()->create(); + + $updateData = [ + 'title' => 'Updated Damage', + 'unit' => 'litre', + 'base_price' => 20000, + ]; + + $response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]), $updateData); + + $response->assertStatus(200) + ->assertJson([ + 'message' => __('messages.successful'), + ]); + + $this->assertDatabaseHas('damages', [ + 'id' => $damage->id, + 'title' => $updateData['title'], + 'unit' => $updateData['unit'], + 'base_price' => $updateData['base_price'], + ]); + } + + +}