From 2c3800184338ce6d4e519808ed6b7401bbfeb095 Mon Sep 17 00:00:00 2001 From: paoloar77 Date: Mon, 12 Aug 2024 10:44:54 +0200 Subject: [PATCH] =?UTF-8?q?se=20gi=C3=A0=20esiste=20l'ordine,=20non=20crea?= =?UTF-8?q?rne=20uno=20nuovo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/CustomFuncPao.php | 19 +++++++++++++++---- composer.json | 1 - routes/web.php | 8 +++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php index 6346faaa..304e780e 100644 --- a/app/CustomFuncPao.php +++ b/app/CustomFuncPao.php @@ -514,8 +514,8 @@ function showOrdini() if ($order->Descrizione) $str .= getvalstr("Descr", $order->Descrizione); - $str .= ' IMPOSTA IDSITO FDV' . $sep; - $str .= ' ELIMINA!' . $sep; + $str .= ' [IMPOSTA IDSITO FDV] ' . $sep; + $str .= ' ELIMINA! ' . $sep; // $str .= getarraystr($product) . "
"; // $str .= $product; @@ -682,7 +682,7 @@ function setOrdine($idinternet, $mode) ->update([ 'IdSito' => "7" ]); - + $str .= "
record Aggiornati: " . $updatedCount . ""; } } @@ -775,7 +775,6 @@ function showDettSingleOrdineWeb($idordine) $orders = AppOrderWeb::where('IdInternet', $idordine)->get(); $str .= showRecordOrder($orders); - } catch (\Exception $e) { return "Errore showDettOrdini: " . $e->getMessage(); } @@ -1995,6 +1994,18 @@ function getClienteByIdCodClienteInternet($codClienteInternet) return $clienteinGM; } +function getOrderByIdInternet($idInternet) +{ + + try { + $ordergm = AppOrder::where('IdInternet', $idInternet)->first(); + + return $ordergm; + } catch (\Exception $e) { + return null; + } +} + function getClienti() { try { diff --git a/composer.json b/composer.json index 2c2889a4..e7537bcb 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,6 @@ "php": "^7.2.5|^8.0", "codexshaper/laravel-woocommerce": "^3.0", "fideloper/proxy": "^4.4", - "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^6.3.1|^7.0.1", "laravel/framework": "^7.29", "laravel/tinker": "^2.5", diff --git a/routes/web.php b/routes/web.php index 889e804a..f735298a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2183,7 +2183,6 @@ Route::get('/testcli', function () { } catch (\Throwable $th) { dd($th); } - }); Route::post('/updatecreate', function (Request $request) { @@ -2208,6 +2207,13 @@ Route::post('/updatecreate', function (Request $request) { $myidInternet = (int) $request->id; $CodClienteInternet = (int) $request->customer_id; + $myexistorder = getOrderByIdInternet($myidInternet); + if ($myexistorder) { + // Se questo ordine è stato già creato, allora ESCO. + $productLogger->addLog('', 'ORDINE GIA ESISTENTE ! ' . $myidInternet); + return true; + } + $clienteinGM = null; $codClienteGM = '';