| 2 |
lars |
1 |
<?php
|
|
|
2 |
|
| 395 |
lars |
3 |
namespace App\Http\Controllers;
|
| 2 |
lars |
4 |
|
| 395 |
lars |
5 |
use App\Models\SalesPortal;
|
|
|
6 |
use App\Models\SalesPortalItem;
|
|
|
7 |
use Illuminate\Contracts\Foundation\Application;
|
|
|
8 |
use Illuminate\Contracts\View\Factory;
|
|
|
9 |
use Illuminate\Contracts\View\View;
|
| 2 |
lars |
10 |
|
| 395 |
lars |
11 |
class SalesPortalItemController extends Controller
|
| 390 |
lars |
12 |
{
|
| 418 |
lars |
13 |
|
|
|
14 |
public function __construct()
|
|
|
15 |
{
|
|
|
16 |
$statusSelect = array(
|
|
|
17 |
-1 => "- alle -",
|
|
|
18 |
|
|
|
19 |
1 => "Artikel wurde an Verkaufsportal exportiert",
|
|
|
20 |
2 => "Artikel wurde noch nicht an Verkaufsportal übermittelt (z. B. nach einer Änderung)",
|
|
|
21 |
9 => "Artikel wird im Verkaufsportal gesperrt",
|
|
|
22 |
);
|
|
|
23 |
$allowed_exts = array(
|
|
|
24 |
"jpg",
|
|
|
25 |
"png",
|
|
|
26 |
"gif",
|
|
|
27 |
);
|
|
|
28 |
\View::share( "statusSelect", $statusSelect );
|
|
|
29 |
\View::share( "allowed_exts", $allowed_exts );
|
|
|
30 |
}
|
| 395 |
lars |
31 |
//
|
|
|
32 |
//
|
|
|
33 |
/**
|
|
|
34 |
* @return Application|Factory|View
|
|
|
35 |
*/
|
|
|
36 |
public function index(): View|Factory|Application
|
|
|
37 |
{
|
|
|
38 |
$salesPortals = SalesPortal::all();
|
| 399 |
lars |
39 |
$vPortale = array( "" => "Bitte wählen" );
|
| 398 |
lars |
40 |
foreach ( $salesPortals as $vPortal )
|
|
|
41 |
{
|
|
|
42 |
$vPortale[$vPortal->id] = $vPortal->name;
|
|
|
43 |
}
|
|
|
44 |
return view( 'salesPortal/itemPortalSelect', [ "vportale" => $vPortale, ] );
|
| 395 |
lars |
45 |
}
|
| 390 |
lars |
46 |
|
| 417 |
lars |
47 |
public function show( SalesPortal $salesPortal ): Factory|View|Application
|
| 395 |
lars |
48 |
{
|
| 408 |
lars |
49 |
\view::share( "salesPortal", $salesPortal );
|
| 402 |
lars |
50 |
return view( "salesPortal/itemList" );
|
| 395 |
lars |
51 |
}
|
| 390 |
lars |
52 |
|
| 395 |
lars |
53 |
/**
|
|
|
54 |
* @return Application|Factory|View
|
|
|
55 |
*/
|
|
|
56 |
public function create(): View|Factory|Application
|
|
|
57 |
{
|
|
|
58 |
return view( "salesPortal/edit" );
|
|
|
59 |
}
|
| 390 |
lars |
60 |
|
| 395 |
lars |
61 |
/**
|
|
|
62 |
* @param SalesPortal $salesPortal
|
|
|
63 |
* @return Application|Factory|View
|
|
|
64 |
*/
|
|
|
65 |
public function edit( SalesPortal $salesPortal ): View|Factory|Application
|
|
|
66 |
{
|
|
|
67 |
return view( "salesPortal/edit", [ "vportal" => $salesPortal ] );
|
|
|
68 |
}
|
| 390 |
lars |
69 |
|
| 395 |
lars |
70 |
public function store()
|
|
|
71 |
{
|
| 390 |
lars |
72 |
|
| 395 |
lars |
73 |
}
|
| 390 |
lars |
74 |
|
| 395 |
lars |
75 |
public function update()
|
|
|
76 |
{
|
| 390 |
lars |
77 |
|
| 395 |
lars |
78 |
}
|
| 390 |
lars |
79 |
|
| 395 |
lars |
80 |
public function destroy()
|
|
|
81 |
{
|
|
|
82 |
|
|
|
83 |
}
|
|
|
84 |
|
| 417 |
lars |
85 |
public function getArtikel(): bool|string
|
| 404 |
lars |
86 |
{
|
| 418 |
lars |
87 |
$statusInfo = array(
|
|
|
88 |
|
|
|
89 |
1 => "Artikel wurde an Verkaufsportal exportiert",
|
|
|
90 |
2 => "Artikel wurde noch nicht an Verkaufsportal übermittelt (z. B. nach einer Änderung)",
|
|
|
91 |
9 => "Artikel wird im Verkaufsportal gesperrt",
|
|
|
92 |
);
|
| 414 |
lars |
93 |
$items = SalesPortalItem::where( "sales_portal_id", $_GET["vp_id"] )->get();
|
| 417 |
lars |
94 |
foreach ( $items as $id => $item )
|
|
|
95 |
{
|
|
|
96 |
$items[$id]->aktionen = "";
|
|
|
97 |
if ( $items[$id]->artikel_id != 1000 )
|
|
|
98 |
{
|
|
|
99 |
$items[$id]->aktionen .= '<button class="edit" id="edit_' . $items[$id]->id . '"> ändern </button>';
|
|
|
100 |
$items[$id]->aktionen .= '<button class="del" id="del_' . $items[$id]->id . '_' . $items[$id]->name . '"> Löschen </button>';
|
|
|
101 |
if ( $items[$id]->status != 9 )
|
|
|
102 |
{
|
|
|
103 |
$items[$id]->aktionen .= '<button class="lock" id="lock_' . $items[$id]->id . '_' . $items[$id]->name . '"> Sperren </button>';
|
|
|
104 |
}
|
|
|
105 |
/*if ( $bestandsUpdate )
|
|
|
106 |
{
|
|
|
107 |
$items[$id]->aktionen .= '<button class="bestandsUpdate" id="bestandsUpdate_' . $items[$id]->foreign_item_id . '_' . $vp_id . '"> Bestandsupdate </button>';
|
|
|
108 |
}*/
|
|
|
109 |
|
|
|
110 |
if ( $items[$id]->artikel_id == null && $items[$id]["artstamm_id"] == null )
|
|
|
111 |
{
|
|
|
112 |
$items[$id]->aktionen .= '<button class="assign" id="assign_' . $items[$id]->foreign_item_id . '"> Shopartikel zuweisen </button>';
|
|
|
113 |
$items[$id]->aktionen .= '<button class="del" id="del_' . $items[$id]->id . '_' . $items[$id]->name . '"> Löschen </button>';
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
}
|
|
|
117 |
else
|
|
|
118 |
{
|
|
|
119 |
$items[$id]->aktionen .= '<button class="assign" id="assign_' . $items[$id]->foreign_item_id . '"> Shopartikel zuweisen </button>';
|
|
|
120 |
$items[$id]->aktionen .= '<button class="del" id="del_' . $items[$id]->id . '_' . $items[$id]->name . '"> Löschen </button>';
|
|
|
121 |
}
|
| 419 |
lars |
122 |
$items[$id]->last_feedback = str_replace( array(
|
| 418 |
lars |
123 |
" <",
|
|
|
124 |
"> ",
|
| 419 |
lars |
125 |
), " ", $items[$id]->last_feedback );
|
| 420 |
lars |
126 |
$items[$id]->last_feedback = array(
|
| 421 |
lars |
127 |
"status" => "<span style='float:left;'>" . $items[$id]->last_feedback . "</span><span style='float:left' class='ui-icon ui-icon-help' title='" . $statusInfo[$items[$id]->status] . "'/>",
|
| 420 |
lars |
128 |
"feedback" => smarty_modifier_escape( $items[$id]->last_feedback, "html" ),
|
| 418 |
lars |
129 |
);
|
| 417 |
lars |
130 |
}
|
|
|
131 |
$ret = array(
|
|
|
132 |
"data" => $items,
|
|
|
133 |
"recordsTotal" => count( $items ),
|
|
|
134 |
"recordsFiltered" => count( $items ),
|
| 414 |
lars |
135 |
);
|
|
|
136 |
return json_encode( $ret );
|
| 404 |
lars |
137 |
}
|
|
|
138 |
|
| 390 |
lars |
139 |
}
|