web.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <?php
  2. use App\Http\Livewire\Report;
  3. use Illuminate\Support\Facades\Route;
  4. /*
  5. |--------------------------------------------------------------------------
  6. | Web Routes
  7. |--------------------------------------------------------------------------
  8. |
  9. | Here is where you can register web routes for your application. These
  10. | routes are loaded by the RouteServiceProvider and all of them will
  11. | be assigned to the "web" middleware group. Make something great!
  12. |
  13. */
  14. Route::get('/', function () {
  15. return view('login');
  16. })->name('login');
  17. Route::get('/logout', function () {
  18. Auth::logout();
  19. return redirect()->to('/');
  20. });
  21. Route::post('/login', function (Request $requests)
  22. {
  23. $email = $_POST["email"];
  24. $password = $_POST["password"];
  25. if ($user = Auth::attempt(['email' => $_POST["email"], 'password' => $_POST["password"]]))
  26. {
  27. return redirect()->to('/reports');
  28. }
  29. else
  30. {
  31. // if (Auth::attempt(['email' => $email, 'password' => $password]) == false) {
  32. return back()->withErrors([
  33. 'message' => 'Dati di accesso errati'
  34. ]);
  35. }
  36. });
  37. Route::group(['middleware' => 'auth'],function(){
  38. Route::get('/dashboard', \App\Http\Livewire\Dashboard::class);
  39. Route::get('/accertatore-grado', \App\Http\Livewire\AccertatoreGrado::class);
  40. Route::get('/ausilio-altri-enti', \App\Http\Livewire\AusilioAltriEnti::class);
  41. Route::get('/compagnie', \App\Http\Livewire\Compagnia::class);
  42. Route::get('/condizioni-strada', \App\Http\Livewire\CondizioneStrada::class);
  43. Route::get('/condizioni-atmosferiche', \App\Http\Livewire\CondizioniAtmosferiche::class);
  44. Route::get('/condizioni-luce', \App\Http\Livewire\CondizioniLuce::class);
  45. Route::get('/fondo-stradale', \App\Http\Livewire\FondoStradale::class);
  46. Route::get('/marche', \App\Http\Livewire\MarcaVeicolo::class);
  47. Route::get('/modelli', \App\Http\Livewire\ModelloVeicolo::class);
  48. Route::get('/materiale-recuperato', \App\Http\Livewire\MaterialeRecuperato::class);
  49. Route::get('/nomenclatura-strada', \App\Http\Livewire\NomenclaturaStrada::class);
  50. Route::get('/particolarita-strada', \App\Http\Livewire\ParticolaritaStrada::class);
  51. Route::get('/pavimentazione-strada', \App\Http\Livewire\PavimentazioneStrada::class);
  52. Route::get('/rilievi', \App\Http\Livewire\Rilievi::class);
  53. Route::get('/segnalazione-pervenuta-da', \App\Http\Livewire\SegnalazionePervenutaDa::class);
  54. Route::get('/segnalazione-verticale', \App\Http\Livewire\SegnalazioneVerticale::class);
  55. Route::get('/segnalazione-orizzontale', \App\Http\Livewire\SegnalazioneOrizzontale::class);
  56. Route::get('/stradario', \App\Http\Livewire\Stradario::class);
  57. Route::get('/tipo-segnalazione', \App\Http\Livewire\TipoSegnalazione::class);
  58. Route::get('/tipo-strada', \App\Http\Livewire\TipoStrada::class);
  59. Route::get('/entita-danno', \App\Http\Livewire\EntitaDanno::class);
  60. Route::get('/effetto-danno', \App\Http\Livewire\EffettoDanno::class);
  61. Route::get('/tipo-danno', \App\Http\Livewire\TipoDanno::class);
  62. Route::get('/tipo-urto', \App\Http\Livewire\TipoUrto::class);
  63. Route::get('/parte-macchina', \App\Http\Livewire\ParteMacchina::class);
  64. Route::get('/tipo-veicolo', \App\Http\Livewire\TipoVeicolo::class);
  65. Route::get('/users', \App\Http\Livewire\User::class);
  66. Route::get('/reports', \App\Http\Livewire\Report::class);
  67. Route::get('/istat', \App\Http\Livewire\Istat::class);
  68. Route::get('/print', Report::class);
  69. Route::get('/stradario_api', function(){
  70. if (isset($_GET["q"]))
  71. $stradario = \App\Models\Stradario::where('descrizione', 'like', '%' . $_GET["q"] . '%')->orderBy('descrizione')->get();
  72. else
  73. $stradario = \App\Models\Stradario::orderBy('descrizione')->get();
  74. $data = array();
  75. foreach($stradario as $s)
  76. {
  77. $data[] = array("id" => $s->id, "text" => $s->TOPONIMO . " " . $s->DESCRIZIONE);
  78. }
  79. return array("results" => $data);
  80. });
  81. Route::get('/anagrafica', function() {
  82. if (isset($_GET["q"])) {
  83. $anagrafica = \App\Models\Anagrafica::where('lastname', 'like', '%' . $_GET["q"] . '%')
  84. ->orWhere('firstname', 'like', '%' . $_GET["q"] . '%')
  85. ->orWhere('rag_soc', 'like', '%' . $_GET["q"] . '%')
  86. ->orderBy('lastname')
  87. ->orderBy('firstname')
  88. ->get();
  89. } else {
  90. $anagrafica = \App\Models\Anagrafica::orderBy('lastname')
  91. ->orderBy('firstname')
  92. ->get();
  93. }
  94. $data = [];
  95. foreach ($anagrafica as $a) {
  96. $text = (empty($a->lastname) && empty($a->firstname))
  97. ? $a->rag_soc // Use company name if names are empty
  98. : trim($a->lastname . ' ' . $a->firstname);
  99. $data[] = ["id" => $a->id, "text" => $text];
  100. }
  101. return ["results" => $data];
  102. });
  103. Route::get('/localita', function(){
  104. if (isset($_GET["q"]))
  105. $localita = \App\Models\LocationTown::where('title', 'like', '%' . $_GET["q"] . '%')->orderBy('title')->get();
  106. else
  107. $localita = \App\Models\LocationTown::orderBy('title')->get();
  108. $data = array();
  109. foreach($localita as $l)
  110. {
  111. $data[] = array("id" => $l->id, "text" => $l->title);
  112. }
  113. return array("results" => $data);
  114. });
  115. Route::get('/veicoli', function(){
  116. if (isset($_GET["q"]))
  117. {
  118. $value = $_GET["q"];
  119. $veicoli = \App\Models\Vehicle::with('marca')->with('modello')->whereHas('marca', function ($q) use ($value) {
  120. $q->where('name', "LIKE", '%' . $value . '%');
  121. })->orWhereHas('modello', function ($q) use ($value) {
  122. $q->where('name', "LIKE", '%' . $value . '%');
  123. })->get()->sortBy('marca.name',SORT_REGULAR,false);
  124. }
  125. else
  126. $veicoli = \App\Models\Vehicle::with('marca')->with('modello')->get()->sortBy('marca.name',SORT_REGULAR,false);
  127. $data = array();
  128. foreach($veicoli as $v)
  129. {
  130. $data[] = array("id" => $v->id, "text" => ($v->marca ? $v->marca->name : '') . " " . ($v->modello ? $v->modello->name : '') . " " . $v->targa);
  131. }
  132. return array("results" => $data);
  133. });
  134. Route::get('/accertatori', function(){
  135. if (isset($_GET["q"]))
  136. {
  137. $value = $_GET["q"];
  138. $accertatori = DB::table('fcf_users')
  139. ->leftjoin('fcf_user_user_groups','fcf_user_user_groups.user_id','=','fcf_users.id')
  140. ->selectRaw('fcf_users.*')
  141. ->where('fcf_user_user_groups.group_id', 2)
  142. ->where(function ($query) {
  143. $query->where('fcf_users.lastname', 'like', '%' . $_GET["q"] . '%')
  144. ->orWhere('fcf_users.firstname', 'like', '%' . $_GET["q"] . '%');
  145. })
  146. ->orderBy('fcf_users.lastname')
  147. ->get();
  148. }
  149. else
  150. $accertatori = DB::table('fcf_users')
  151. ->leftjoin('fcf_user_user_groups','fcf_user_user_groups.user_id','=','fcf_users.id')
  152. ->selectRaw('fcf_users.*')
  153. ->where('fcf_user_user_groups.group_id', 2)
  154. ->orderBy('fcf_users.lastname')
  155. ->get();
  156. $data = array();
  157. foreach($accertatori as $a)
  158. {
  159. $data[] = array("id" => $a->id, "text" => $a->lastname . " " . $a->firstname);
  160. }
  161. return array("results" => $data);
  162. });
  163. Route::get('/polizze', function(){
  164. if (isset($_GET["q"]))
  165. {
  166. $value = $_GET["q"];
  167. $polizze = \App\Models\Polizza::with('compagnia')->with('anagrafica')->where('agenzia', 'LIKE', '%' . $_GET["q"] . '%')
  168. ->orWhereHas('compagnia', function ($q) use ($value) {
  169. $q->where('name', "LIKE", '%' . $value . '%');
  170. })->orWhereHas('anagrafica', function ($q) use ($value) {
  171. $q->where('lastname', "LIKE", '%' . $value . '%')->orWhere('firstname', "LIKE", '%' . $value . '%');
  172. })->get()->sortBy('marca.name',SORT_REGULAR,false);
  173. }
  174. else
  175. $polizze = \App\Models\Polizza::with('compagnia')->with('anagrafica')->get()->sortBy('agenzia',SORT_REGULAR,false);
  176. $data = array();
  177. foreach($polizze as $p)
  178. {
  179. $data[] = array("id" => $p->id, "text" => $p->agenzia . " " . ($p->compagnia ? $p->compagnia->name : '') . " " . ($p->anagrafica ? ($p->anagrafica->lastname . " " . $p->anagrafica->firstname) : ''));
  180. }
  181. return array("results" => $data);
  182. });
  183. });
  184. Route::get('/test_targa/{targa}', function ($targa) {
  185. try
  186. {
  187. $wd = "dettaglioAutoveicoloBase";
  188. $wd = "datiCartaCircolazioneAutoveicoloProprietario";
  189. $url = 'https://www.ilportaledellautomobilista.it/Info-ws/services';
  190. $client = new \SoapClient($url . '/' . $wd . '/' . $wd . '.wsdl', array(
  191. 'stream_context' => stream_context_create(array(
  192. 'ssl' => array(
  193. 'verify_peer' => false,
  194. 'verify_peer_name' => false,
  195. 'allow_self_signed' => true
  196. )
  197. )),
  198. 'trace'=>1
  199. ));
  200. $utente = 'CMRM001301';
  201. $password = '2PMPM*86';
  202. $xml = '<wsse:Security
  203. xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
  204. SOAP-ENV:mustUnderstand="1">
  205. <wsse:UsernameToken
  206. xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
  207. wsu:Id="XWSSGID-1253605895203984534550">
  208. <wsse:Username>' . $utente . '</wsse:Username>
  209. <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $password . '</wsse:Password>
  210. </wsse:UsernameToken>
  211. </wsse:Security>';
  212. $header = new \SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd',
  213. 'Security',
  214. new \SoapVar($xml, XSD_ANYXML),
  215. true
  216. );
  217. $client->__setSoapHeaders($header);
  218. $classe = "dettaglioAutoveicoloBase";
  219. $classe = "dettaglioCartaCircolazioneProprietarioAutoveicolo";
  220. try
  221. {
  222. // Run the function
  223. $obj = $client->__soapCall($classe, array(
  224. $classe . "Request" => array(
  225. "login" => array(
  226. ),
  227. //"dettaglioAutoveicoloBaseInput" => array(
  228. "targa" => array("numeroTarga" => $targa),
  229. //),
  230. "pdf" => false
  231. )
  232. ));
  233. print "<pre>";
  234. print_r($obj);
  235. print "</pre>";
  236. }
  237. catch(\SoapFault $fault)
  238. {
  239. print $fault;
  240. // <xmp> tag displays xml output in html
  241. //echo 'Request : <br/><xmp>',
  242. //$client->__getLastRequest(),
  243. //'</xmp><br/><br/> Error Message : <br/>',
  244. //$fault->getMessage();
  245. }
  246. }
  247. catch(Exception $ex)
  248. {
  249. print "QUA5";
  250. print $ex;
  251. }
  252. });
  253. Route::get('/print-pdf/{id}', [Report::class, 'print'])->name('print.pdf');
  254. Route::get('/countries', function() {
  255. $search = request()->get('search');
  256. $query = \App\Models\LocationCountry::query();
  257. if($search) {
  258. $query->where('name', 'like', "%{$search}%");
  259. }
  260. $countries = $query->get()->map(function($country) {
  261. return [
  262. 'id' => $country->id,
  263. 'text' => $country->name
  264. ];
  265. });
  266. return response()->json([
  267. 'results' => $countries
  268. ]);
  269. });