fatturati

This commit is contained in:
paoloar77
2024-12-18 08:56:53 +01:00
parent ceacf59278
commit c74580af4b

View File

@@ -1,5 +1,6 @@
<?php
use App\ArticoliFatturati;
use Carbon\Carbon;
use Codexshaper\WooCommerce\Facades\Product;
use Illuminate\Console\Command;
@@ -36,12 +37,14 @@ setlocale(LC_TIME, 'it_IT.UTF-8');
function showarray($array)
{
echo '<pre>' . json_encode($array, JSON_PRETTY_PRINT) . '</pre>';
};
}
;
function getarraystr($array)
{
return '<pre>' . json_encode($array, JSON_PRETTY_PRINT) . '</pre>';
};
}
;
function isKeyPresent($array, $key)
{
@@ -638,9 +641,9 @@ function showOrdiniWeb()
} else {
$mylink = "";
$finelink = "";
}
}
if ($product && isset($product['name']))
$titolo = $mylink . "<span style='font-weigth: bold;'>" . $product['name'] . "</span>" . $finelink;
else
@@ -690,20 +693,26 @@ function showArticoliFatturatiWeb()
// Show the fields of the orders
foreach ($orders as $order) {
$product = Product::where('sku', $order->CodArticolo)->first();
$usaprod = true;
if (isset($product['permalink'])) {
$mylink = "<a href='" . $product['permalink'] . "' target='_blank'>";
$finelink = "</a>";
if ($usaprod) {
$product = Product::where('sku', $order->CodArticolo)->first();
if (isset($product['permalink'])) {
$mylink = "<a href='" . $product['permalink'] . "' target='_blank'>";
$finelink = "</a>";
} else {
$mylink = "";
$finelink = "";
}
if ($product && isset($product['name']))
$titolo = $mylink . "<span style='font-weigth: bold;'>" . $product['name'] . "</span>" . $finelink;
else
$titolo = "";
} else {
$mylink = "";
$finelink = "";
}
if ($product && isset($product['name']))
$titolo = $mylink . "<span style='font-weigth: bold;'>" . $product['name'] . "</span>" . $finelink;
else
$titolo = "";
}
$str .= getvalstr("", $order->Codice) . " ";
$str .= getvalstr("", $order->AnnoDoc) . " ";
@@ -714,7 +723,7 @@ function showArticoliFatturatiWeb()
$str .= getvalstr("", $order->DataOra);
$str .= getvalstr("", $order->Stato);
$str .= getvalstr("", $order->Note);
$str .= getvalstr("", $titolo);
//$str .= getvalstr("", $titolo);
$str .= getvalstr("Ordine", $order->IdInternet, true) . " ";
if ($order->PercSconto)
$str .= getvalstr("Sconto", $order->PercSconto);
@@ -793,7 +802,7 @@ function setOrdine($idinternet, $mode)
{
try {
$str = "setOrdine: mode =" . $mode . ' idinternet=' . $idinternet;
$str = "setOrdine: mode =" . $mode . ' idinternet=' . $idinternet;
// $str .= getAllTablesStr();
@@ -1152,7 +1161,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
if (array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options)) {
$id = $prodotto->id;
$variations = Variation::all($prodotto->id);
foreach ($variations as $variation) {
foreach ($variations as $variation) {
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
if ($variation->attributes[$found_key_version]->option == 'Nuovo') {
$id = 0;
@@ -1214,15 +1223,15 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
] : [],
$article->Ristampa ? [
'key' => 'ristampa',
'value' => $article->Ristampa
'value' => $article->Ristampa
] : [],
$datepubbl_ts ? [
'key' => 'DataPubblicazione',
'value' => $datepubbl_ts
'value' => $datepubbl_ts
] : [],
$datepubblstr ? [
'key' => 'DataPubbStr',
'value' => $datepubblstr
'value' => $datepubblstr
] : [],
]
@@ -1240,7 +1249,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
'name' => $article->Titolo,
'type' => 'variable',
'short_description' => $article->Sottotitolo,
'short_description' => $article->Sottotitolo,
'categories' => [
['id' => $categoriaid]
@@ -1280,7 +1289,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
'visible' => true,
'options' =>
$article->authors
$article->authors
],
@@ -1346,7 +1355,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
}
}
$attributes[] = [
$attributes[] = [
//'id' => 1,
'id' => 6,
'position' => 0,
@@ -1421,7 +1430,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
if (array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options)) {
$id = $prodotto->id;
$variations = Variation::all($prodotto->id);
foreach ($variations as $variation) {
foreach ($variations as $variation) {
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
if ($variation->attributes[$found_key_version]->option == $formato) {
$id = 0;
@@ -1488,7 +1497,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
'name' => $titolo,
'type' => 'variable',
'short_description' => $article->Sottotitolo,
'short_description' => $article->Sottotitolo,
'categories' => [
['id' => $categoriaid]
@@ -1521,7 +1530,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
'visible' => true,
'options' =>
$article->authors
$article->authors
],
@@ -1583,7 +1592,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
}
}
$attributes[] = [
$attributes[] = [
//'id' => 1,
'id' => 6,
'position' => 0,
@@ -1636,7 +1645,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
if (array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options)) {
$id = $prodotto->id;
$variations = Variation::all($prodotto->id);
foreach ($variations as $variation) {
foreach ($variations as $variation) {
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
if ($variation->attributes[$found_key_version]->option == 'DVD') {
$id = 0;
@@ -1701,7 +1710,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
'name' => $article->Titolo,
'type' => 'variable',
'short_description' => $article->Sottotitolo,
'short_description' => $article->Sottotitolo,
'categories' => [
['id' => $categoriaid]
@@ -1739,7 +1748,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
'visible' => true,
'options' =>
$article->authors
$article->authors
],
@@ -1801,7 +1810,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
}
}
$attributes[] = [
$attributes[] = [
//'id' => 1,
'id' => 6,
'position' => 0,
@@ -1876,7 +1885,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
if (array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options)) {
$id = $prodotto->id;
$variations = Variation::all($prodotto->id);
foreach ($variations as $variation) {
foreach ($variations as $variation) {
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
if ($variation->attributes[$found_key_version]->option == $formato) {
$id = 0;
@@ -1942,7 +1951,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
'name' => $titolo,
'type' => 'variable',
'short_description' => $article->Sottotitolo,
'short_description' => $article->Sottotitolo,
'categories' => [
['id' => $categoriaid]
@@ -1975,7 +1984,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
'visible' => true,
'options' =>
$article->authors
$article->authors
],
@@ -2037,7 +2046,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
}
}
$attributes[] = [
$attributes[] = [
//'id' => 1,
'id' => 6,
'position' => 0,
@@ -2071,7 +2080,7 @@ function setProductFromGM($article, $initlog, ProductLogger &$passproductLogger)
}
} else {
// ESISTE GIA' IL LIBRO
$data1 = [
'regular_price' => $article->PrezzoIvato,