White Label WL-02: verbindliche Tiegelfarbe, Etikettposition und gemeinsamer Resolver
- products.whitelabel_variant_id, product_images.position/size_cm mit Backfill aus Produktnamen - WhiteLabelResolver: Farbe vom Produkt, Kundenlogo je Position, Fehler statt stillem Rückfall; Altlogik für Produkte ohne Variante - Attribute: Variantenwert-Parsing und Farbname ohne Größe - Produkt- und Kundenformular um Variante, Position und Größe ergänzt - Lieferschein noch nicht umgestellt (WL-03, wartet auf K6/K7) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0dc3dea85e
commit
cff749b133
14 changed files with 1159 additions and 280 deletions
|
|
@ -3,22 +3,27 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exports\ExcelExport;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Services\SysLog;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserHistory;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Services\UserService;
|
||||
use App\Mail\MailAccountActive;
|
||||
use App\Mail\MailCustomMessage;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Mail\MailVerifyContact;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\UserWhitelabelProduct;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\ProductImage;
|
||||
use App\Services\SysLog;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\View\View;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
class LeadController extends Controller
|
||||
{
|
||||
|
|
@ -32,7 +37,7 @@ class LeadController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
|
@ -41,26 +46,26 @@ class LeadController extends Controller
|
|||
'values' => User::where('admin', '=', 0)->where('confirmation_code_remider', '!=', 2)->get(),
|
||||
|
||||
];
|
||||
|
||||
return view('admin.lead.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
if($id === "new"){
|
||||
$user = new User();
|
||||
$user->account = new UserAccount();
|
||||
if ($id === 'new') {
|
||||
$user = new User;
|
||||
$user->account = new UserAccount;
|
||||
$user->account->same_as_billing = 1;
|
||||
$user->account->country_id = 1;
|
||||
$user->account->shipping_country_id = 1;
|
||||
$user->id = "new";
|
||||
}else{
|
||||
$user->id = 'new';
|
||||
} else {
|
||||
$user = User::findOrFail($id);
|
||||
if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
if (! $user->account) {
|
||||
$user->account = new UserAccount;
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -70,39 +75,39 @@ class LeadController extends Controller
|
|||
'm_data_load' => false,
|
||||
'm_data_error' => false,
|
||||
];
|
||||
|
||||
return view('admin.lead.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function editPost($id)
|
||||
{
|
||||
$m_data_load = false;
|
||||
$m_data_error = false;
|
||||
$data = Request::all();
|
||||
if(!isset($data['edit_m_data_key']) || $data['edit_m_data_key'] !== config('main.edit_data_pass')){
|
||||
$m_data_error = "Das Passwort ist falsch.";
|
||||
}else{
|
||||
if (! isset($data['edit_m_data_key']) || $data['edit_m_data_key'] !== config('main.edit_data_pass')) {
|
||||
$m_data_error = 'Das Passwort ist falsch.';
|
||||
} else {
|
||||
$m_data_load = true;
|
||||
}
|
||||
|
||||
if($id === "new"){
|
||||
$user = new User();
|
||||
$user->account = new UserAccount();
|
||||
if ($id === 'new') {
|
||||
$user = new User;
|
||||
$user->account = new UserAccount;
|
||||
$user->account->same_as_billing = 1;
|
||||
$user->account->country_id = 1;
|
||||
$user->account->shipping_country_id = 1;
|
||||
$user->id = "new";
|
||||
}else{
|
||||
$user->id = 'new';
|
||||
} else {
|
||||
$user = User::findOrFail($id);
|
||||
if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
if (! $user->account) {
|
||||
$user->account = new UserAccount;
|
||||
}
|
||||
}
|
||||
$next_account_id = UserAccount::withTrashed()->max('m_account') +1;
|
||||
if($user->account->m_account === null){
|
||||
$next_account_id = UserAccount::withTrashed()->max('m_account') + 1;
|
||||
if ($user->account->m_account === null) {
|
||||
$user->account->m_account = $next_account_id;
|
||||
}
|
||||
|
||||
|
|
@ -112,14 +117,14 @@ class LeadController extends Controller
|
|||
'm_data_load' => $m_data_load,
|
||||
'm_data_error' => $m_data_error,
|
||||
'can_change_mail' => true,
|
||||
'next_account_id' => $next_account_id
|
||||
'next_account_id' => $next_account_id,
|
||||
];
|
||||
|
||||
return view('admin.lead.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
|
@ -127,153 +132,157 @@ class LeadController extends Controller
|
|||
$data = Request::all();
|
||||
$show = Request::get('show');
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate" && isset($data['user_id'])){
|
||||
if (isset($data['action']) && $data['action'] == 'reverse_charge_validate' && isset($data['user_id'])) {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
|
||||
return $this->userRepo->reverse_charge_validate($data, $user, route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete" && isset($data['user_id'])){
|
||||
if (isset($data['action']) && $data['action'] == 'reverse_charge_delete' && isset($data['user_id'])) {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
return $this->userRepo->reverse_charge_delete($data, $user, route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$rules = array(
|
||||
return $this->userRepo->reverse_charge_delete($data, $user, route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
if ($data['user_id'] === 'new' || $data['user_id'] == 0) {
|
||||
$rules = [
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'email-confirm' => 'required|same:email',
|
||||
);
|
||||
}else{
|
||||
$rules = array(
|
||||
];
|
||||
} else {
|
||||
$rules = [
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'address'=>'required',
|
||||
'zipcode'=>'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'address' => 'required',
|
||||
'zipcode' => 'required',
|
||||
'city' => 'required',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
);
|
||||
if(!Request::get('same_as_billing')){
|
||||
];
|
||||
if (! Request::get('same_as_billing')) {
|
||||
$rules = array_merge($rules, [
|
||||
'shipping_firstname'=>'required',
|
||||
'shipping_lastname'=>'required',
|
||||
'shipping_address'=>'required',
|
||||
'shipping_zipcode'=>'required',
|
||||
'shipping_firstname' => 'required',
|
||||
'shipping_lastname' => 'required',
|
||||
'shipping_address' => 'required',
|
||||
'shipping_zipcode' => 'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_salutation' => 'required'
|
||||
'shipping_salutation' => 'required',
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['m_account']) && $data['m_account']){
|
||||
if (isset($data['m_account']) && $data['m_account']) {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
$rules['m_account'] = 'unique:user_accounts,m_account,'.$user->account->id.',id';
|
||||
}
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$user_id = "new";
|
||||
}else{
|
||||
if ($data['user_id'] === 'new' || $data['user_id'] == 0) {
|
||||
$user_id = 'new';
|
||||
} else {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
$user_id = $user->id;
|
||||
}
|
||||
return redirect(route('admin_lead_edit', [$user_id])."?show=".$show)->withErrors($validator)->withRequest(Request::all());
|
||||
|
||||
return redirect(route('admin_lead_edit', [$user_id]).'?show='.$show)->withErrors($validator)->withRequest(Request::all());
|
||||
}
|
||||
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$user = new User();
|
||||
$user->id = "new";
|
||||
$user->account = new UserAccount();
|
||||
if ($data['user_id'] === 'new' || $data['user_id'] == 0) {
|
||||
$user = new User;
|
||||
$user->id = 'new';
|
||||
$user->account = new UserAccount;
|
||||
|
||||
}else {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
}
|
||||
} else {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
if (! $user->account) {
|
||||
$user->account = new UserAccount;
|
||||
}
|
||||
}
|
||||
|
||||
$this->userRepo->update($data);
|
||||
$this->userRepo->update($data);
|
||||
|
||||
if(isset($data['m_data_edit']) && $data['m_data_edit'] === "TSOK"){
|
||||
$user = $this->userRepo->getModel();
|
||||
$user->m_level = isset($data['m_level']) ? $data['m_level'] : NULL;
|
||||
$user->lead_type_id = isset($data['lead_type_id']) ? $data['lead_type_id'] : NULL;
|
||||
$user->m_sponsor = isset($data['m_sponsor']) ? $data['m_sponsor'] : NULL;
|
||||
$user->save();
|
||||
}
|
||||
if (isset($data['m_data_edit']) && $data['m_data_edit'] === 'TSOK') {
|
||||
$user = $this->userRepo->getModel();
|
||||
$user->m_level = isset($data['m_level']) ? $data['m_level'] : null;
|
||||
$user->lead_type_id = isset($data['lead_type_id']) ? $data['lead_type_id'] : null;
|
||||
$user->m_sponsor = isset($data['m_sponsor']) ? $data['m_sponsor'] : null;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
if(isset($data['contact_verify'])){
|
||||
if (isset($data['contact_verify'])) {
|
||||
|
||||
$user = $this->userRepo->getModel();
|
||||
$user = $this->userRepo->getModel();
|
||||
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
|
||||
$user->lang = $user->getLandByCountry();
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
//10 == start wizard form create Lead
|
||||
$user->wizard = 10;
|
||||
$user->save();
|
||||
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyContact($confirmation_code, $user));
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_leads'));
|
||||
}
|
||||
$user->lang = $user->getLandByCountry();
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
// 10 == start wizard form create Lead
|
||||
$user->wizard = 10;
|
||||
$user->save();
|
||||
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyContact($confirmation_code, $user));
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_lead_edit', [$user->id])."?show=".$show);
|
||||
|
||||
return redirect(route('admin_leads'));
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
|
||||
return redirect(route('admin_lead_edit', [$user->id]).'?show='.$show);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function update()
|
||||
{
|
||||
$data = Request::all();
|
||||
$show = Request::get('show');
|
||||
if(!isset($data['user_id']) || $data['user_id'] === "new" || $data['user_id'] == 0){
|
||||
if (! isset($data['user_id']) || $data['user_id'] === 'new' || $data['user_id'] == 0) {
|
||||
abort(404, 'User not found');
|
||||
}
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
|
||||
if(isset($data['action'])){
|
||||
if (isset($data['action'])) {
|
||||
|
||||
//add whitelabel products
|
||||
if($data['action'] === 'add_whitelabel_products'){
|
||||
if(isset($data['whitelabel_products']) && is_array($data['whitelabel_products'])){
|
||||
foreach ($data['whitelabel_products'] as $product_id){
|
||||
// add whitelabel products
|
||||
if ($data['action'] === 'add_whitelabel_products') {
|
||||
if (isset($data['whitelabel_products']) && is_array($data['whitelabel_products'])) {
|
||||
foreach ($data['whitelabel_products'] as $product_id) {
|
||||
$user->whitelabel_products()->create(['product_id' => $product_id]);
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-save', true);
|
||||
}
|
||||
//remove whitelabel products
|
||||
if($data['action'] === 'remove_whitelabel_products'){
|
||||
if(isset($data['whitelabel_products']) && is_array($data['whitelabel_products'])){
|
||||
// remove whitelabel products
|
||||
if ($data['action'] === 'remove_whitelabel_products') {
|
||||
if (isset($data['whitelabel_products']) && is_array($data['whitelabel_products'])) {
|
||||
$user->whitelabel_products()->whereIn('product_id', $data['whitelabel_products'])->delete();
|
||||
}
|
||||
\Session()->flash('alert-success', "Produkt gelöscht");
|
||||
\Session()->flash('alert-success', 'Produkt gelöscht');
|
||||
}
|
||||
if($data['action'] === 'upload_white_label_image'){
|
||||
//id == user_whitelabel_product_id
|
||||
$whitelabel_product = UserWhitelabelProduct::findOrFail($data['id']);
|
||||
if($whitelabel_product && $user->id == $whitelabel_product->user_id){
|
||||
return \App\Services\ProductImage::imageUpload('user_wl_product', $whitelabel_product, Request::get('upload_type'));
|
||||
}
|
||||
if ($data['action'] === 'upload_white_label_image') {
|
||||
// id == user_whitelabel_product_id
|
||||
$whitelabel_product = UserWhitelabelProduct::findOrFail($data['id']);
|
||||
if ($whitelabel_product && $user->id == $whitelabel_product->user_id) {
|
||||
return ProductImage::imageUpload('user_wl_product', $whitelabel_product, Request::get('upload_type'));
|
||||
}
|
||||
}
|
||||
//update whitelabel products
|
||||
if($data['action'] === 'update_whitelabel_products'){
|
||||
if(isset($data['image_wl_attributes']) && is_array($data['image_wl_attributes'])){
|
||||
foreach ( $user->whitelabel_products as $wl_product){
|
||||
// update whitelabel products
|
||||
if ($data['action'] === 'update_whitelabel_products') {
|
||||
$positions = isset($data['image_wl_position']) && is_array($data['image_wl_position']) ? $data['image_wl_position'] : [];
|
||||
if (isset($data['image_wl_attributes']) && is_array($data['image_wl_attributes'])) {
|
||||
foreach ($user->whitelabel_products as $wl_product) {
|
||||
foreach ($wl_product->whitelabel_images as $wl_image) {
|
||||
$position = $positions[$wl_image->id] ?? null;
|
||||
$wl_image->update([
|
||||
'attributes' => isset($data['image_wl_attributes'][$wl_image->id]) ? $data['image_wl_attributes'][$wl_image->id] : NULL,
|
||||
'attributes' => isset($data['image_wl_attributes'][$wl_image->id]) ? $data['image_wl_attributes'][$wl_image->id] : null,
|
||||
'position' => array_key_exists($position, \App\Models\ProductImage::POSITIONS) ? $position : ($wl_image->position ?: 'deckel'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -281,86 +290,95 @@ class LeadController extends Controller
|
|||
\Session()->flash('alert-save', true);
|
||||
}
|
||||
}
|
||||
return redirect(route('admin_lead_edit', [$user->id])."?show=".$show);
|
||||
|
||||
return redirect(route('admin_lead_edit', [$user->id]).'?show='.$show);
|
||||
}
|
||||
|
||||
public function remove($action, $user_id, $id, $mid=null){
|
||||
public function remove($action, $user_id, $id, $mid = null)
|
||||
{
|
||||
$show = Request::get('show');
|
||||
$user = User::findOrFail($user_id);
|
||||
|
||||
if($action === 'remove_whitelabel_label'){
|
||||
if ($action === 'remove_whitelabel_label') {
|
||||
$model = $user->whitelabel_products()->where('id', $id)->first();
|
||||
return \App\Services\ProductImage::imageDelete('user_wl_image', $model, $mid);
|
||||
|
||||
return ProductImage::imageDelete('user_wl_image', $model, $mid);
|
||||
}
|
||||
|
||||
if($action === 'remove_whitelabel_product'){
|
||||
if ($action === 'remove_whitelabel_product') {
|
||||
|
||||
$model = $user->whitelabel_products()->where('id', $id)->first();
|
||||
//remove images
|
||||
foreach ($model->whitelabel_images as $image){
|
||||
\App\Services\ProductImage::imageDelete('user_wl_image', $model, $image->id);
|
||||
// remove images
|
||||
foreach ($model->whitelabel_images as $image) {
|
||||
ProductImage::imageDelete('user_wl_image', $model, $image->id);
|
||||
|
||||
}
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', "White Label Produkt entfernt");
|
||||
\Session()->flash('alert-success', 'White Label Produkt entfernt');
|
||||
|
||||
return redirect(route('admin_lead_edit', [$user->id])."?show=$show");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function download(){
|
||||
|
||||
if(Request::get('action') === "export"){
|
||||
}
|
||||
|
||||
public function download()
|
||||
{
|
||||
|
||||
if (Request::get('action') === 'export') {
|
||||
$query = $this->initSearch();
|
||||
$columns = [];
|
||||
$filename = "GS-VP-export-".date("d-m-Y");
|
||||
$headers = array(
|
||||
'ID',
|
||||
'Email',
|
||||
'Firma',
|
||||
'Anrede',
|
||||
'Vorname',
|
||||
'Nachname',
|
||||
'Mitglied',
|
||||
$filename = 'GS-VP-export-'.date('d-m-Y');
|
||||
$headers = [
|
||||
'ID',
|
||||
'Email',
|
||||
'Firma',
|
||||
'Anrede',
|
||||
'Vorname',
|
||||
'Nachname',
|
||||
'Mitglied',
|
||||
'Bis',
|
||||
'Art',
|
||||
|
||||
);
|
||||
|
||||
];
|
||||
$objects = $query->get();
|
||||
if($objects){
|
||||
foreach ($objects as $obj){
|
||||
$columns[] = array(
|
||||
'ID' => $obj->id,
|
||||
'Email' => $obj->email,
|
||||
'Firma' => $obj->account ? $obj->account->company : '',
|
||||
'Anrede' => $obj->account ? ($obj->account->salutation == 'mr' ? 'Herr' : 'Frau') : '-',
|
||||
'Vorname' => $obj->account ? $obj->account->first_name : '',
|
||||
'Nachname' => $obj->account ? $obj->account->last_name : '',
|
||||
'Mitglied' => $obj->payment_account ? ($obj->isActiveAccount() ? 'JA' : 'Abgelaufen') : "Nein",
|
||||
'Bis' => $obj->payment_account ? $obj->getPaymentAccountDateFormat(false) : '-',
|
||||
'Art' => $obj->lead_type ? $obj->lead_type->name : '-',
|
||||
);
|
||||
if ($objects) {
|
||||
foreach ($objects as $obj) {
|
||||
$columns[] = [
|
||||
'ID' => $obj->id,
|
||||
'Email' => $obj->email,
|
||||
'Firma' => $obj->account ? $obj->account->company : '',
|
||||
'Anrede' => $obj->account ? ($obj->account->salutation == 'mr' ? 'Herr' : 'Frau') : '-',
|
||||
'Vorname' => $obj->account ? $obj->account->first_name : '',
|
||||
'Nachname' => $obj->account ? $obj->account->last_name : '',
|
||||
'Mitglied' => $obj->payment_account ? ($obj->isActiveAccount() ? 'JA' : 'Abgelaufen') : 'Nein',
|
||||
'Bis' => $obj->payment_account ? $obj->getPaymentAccountDateFormat(false) : '-',
|
||||
'Art' => $obj->lead_type ? $obj->lead_type->name : '-',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return Excel::download(new ExcelExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
if(!session('filter_lead_type_id')){
|
||||
private function setFilterVars()
|
||||
{
|
||||
if (! session('filter_lead_type_id')) {
|
||||
session(['filter_lead_type_id' => 'all']);
|
||||
}
|
||||
if(Request::get('filter_lead_type_id')){
|
||||
if (Request::get('filter_lead_type_id')) {
|
||||
session(['filter_lead_type_id' => Request::get('filter_lead_type_id')]);
|
||||
}
|
||||
}
|
||||
|
||||
private function initSearch(){
|
||||
private function initSearch()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', "<", 4);
|
||||
if(session('filter_lead_type_id') && session('filter_lead_type_id') !== null && session('filter_lead_type_id') !== "all"){
|
||||
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', '<', 4);
|
||||
if (session('filter_lead_type_id') && session('filter_lead_type_id') !== null && session('filter_lead_type_id') !== 'all') {
|
||||
$query->where('lead_type_id', session('filter_lead_type_id'));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
|
@ -385,7 +403,7 @@ class LeadController extends Controller
|
|||
return $user->lead_type ? $user->lead_type->name : '';
|
||||
})
|
||||
->addColumn('id', function (User $user) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
return '<a href="'.route('admin_lead_edit', [$user->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
|
|
@ -400,7 +418,7 @@ class LeadController extends Controller
|
|||
return $user->payment_account ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('payment_account_date', function (User $user) {
|
||||
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
|
||||
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : '-';
|
||||
})
|
||||
/*->addColumn('payment_shop', function (User $user) {
|
||||
return $user->payment_shop ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
|
|
@ -409,10 +427,10 @@ class LeadController extends Controller
|
|||
return $user->payment_shop ? $user->getPaymentShopDateFormat(false) : "-";
|
||||
})*/
|
||||
->addColumn('turnover', function (User $user) {
|
||||
return "-";
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_total', function (User $user) {
|
||||
return "-";
|
||||
return '-';
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
|
|
@ -421,16 +439,17 @@ class LeadController extends Controller
|
|||
->orderColumn('lead_type', 'lead_type_id $1')
|
||||
->orderColumn('agreement', 'agreement $1')
|
||||
->orderColumn('payment_account', 'payment_account $1')
|
||||
//->orderColumn('payment_shop', 'payment_shop $1')
|
||||
// ->orderColumn('payment_shop', 'payment_shop $1')
|
||||
->rawColumns(['id', 'confirmed', 'active', 'agreement', 'payment_account'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
private function activeAccountPayment($user){
|
||||
private function activeAccountPayment($user)
|
||||
{
|
||||
|
||||
if($user->user_level){
|
||||
if($user->user_level->payment_year){
|
||||
//if true = payments
|
||||
if ($user->user_level) {
|
||||
if ($user->user_level->payment_year) {
|
||||
// if true = payments
|
||||
$user->wizard = 20;
|
||||
$user->active = 1;
|
||||
$user->active_date = now();
|
||||
|
|
@ -438,8 +457,8 @@ class LeadController extends Controller
|
|||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
}else{
|
||||
//if false = no payments for 1 year
|
||||
} else {
|
||||
// if false = no payments for 1 year
|
||||
$user->wizard = 100;
|
||||
$user->payment_account = \Carbon::now()->modify('1 year');
|
||||
$user->active = 1;
|
||||
|
|
@ -449,37 +468,38 @@ class LeadController extends Controller
|
|||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//user released when register is complete
|
||||
public function released($action, $id){
|
||||
// user released when register is complete
|
||||
public function released($action, $id)
|
||||
{
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
if($action === 'completed'){
|
||||
if ($action === 'completed') {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
/*if(!$user->m_sponsor){
|
||||
$validator->errors()->add('m_sponsor', __('Vertriebspartner hat keinen Sponsor.'));
|
||||
}*/
|
||||
if(!$user->account->m_first_name){
|
||||
if (! $user->account->m_first_name) {
|
||||
$validator->errors()->add('m_first_name', __('Vertriebspartner hat keinen Vornamen.'));
|
||||
}
|
||||
if(!$user->account->m_last_name){
|
||||
if (! $user->account->m_last_name) {
|
||||
$validator->errors()->add('m_last_name', __('Vertriebspartner hat keinen Nachnamen.'));
|
||||
}
|
||||
if(!$user->m_level){
|
||||
if (! $user->m_level) {
|
||||
$validator->errors()->add('m_level', __('Vertriebspartner hat keine Rolle'));
|
||||
}
|
||||
if ($validator->errors()->count()) {
|
||||
return back()->withErrors($validator)->withRequest(Request::all());
|
||||
}
|
||||
|
||||
if(!$user->account->m_account){
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') +1;
|
||||
if (! $user->account->m_account) {
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') + 1;
|
||||
$user->account->save();
|
||||
}
|
||||
|
||||
//create PDF
|
||||
// create PDF
|
||||
$pdf = new ContractPDFRepository($user);
|
||||
$pdf->_set('disk', 'user');
|
||||
$pdf->_set('dir', '/'.$user->id.'/documents/');
|
||||
|
|
@ -487,14 +507,13 @@ class LeadController extends Controller
|
|||
$pdf->_set('identifier', 'contract');
|
||||
$pdf->createContractPDF();
|
||||
|
||||
//set wizard to payments / activate
|
||||
$this->activeAccountPayment($user);
|
||||
// set wizard to payments / activate
|
||||
$this->activeAccountPayment($user);
|
||||
|
||||
//mail with code to user?
|
||||
// mail with code to user?
|
||||
try {
|
||||
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailAccountActive($user));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
SysLog::action('released', 'admin_lead', 5)
|
||||
->setUserId($user->id)
|
||||
->setModel($user->id, User::class)
|
||||
|
|
@ -502,12 +521,12 @@ class LeadController extends Controller
|
|||
->save();
|
||||
}
|
||||
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'released_completed', 'status'=>0]);
|
||||
\Session()->flash('alert-success', "Vertriebspartner freigeschaltet!");
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'released_completed', 'status' => 0]);
|
||||
\Session()->flash('alert-success', 'Vertriebspartner freigeschaltet!');
|
||||
}
|
||||
|
||||
if($action === 'incomplete'){
|
||||
//reset release
|
||||
if ($action === 'incomplete') {
|
||||
// reset release
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
|
||||
|
|
@ -524,55 +543,53 @@ class LeadController extends Controller
|
|||
];
|
||||
try {
|
||||
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailCustomMessage($user, $data, \Auth::user(), true));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
SysLog::action('released_incomplete', 'admin_lead', 5)
|
||||
->setUserId($user->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Error send released_incomplete E-Mail: '.$e->getMessage())
|
||||
->save();
|
||||
}
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'released_incomplete', 'status'=>0]);
|
||||
\Session()->flash('alert-success', "E-Mail an Vertriebspartner gesendet.");
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'released_incomplete', 'status' => 0]);
|
||||
\Session()->flash('alert-success', 'E-Mail an Vertriebspartner gesendet.');
|
||||
}
|
||||
if($action === 'reset_switch'){
|
||||
if ($action === 'reset_switch') {
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'reset_switch', 'status'=>0]);
|
||||
\Session()->flash('alert-success', "Vertriebspartner zurückgesetzt!");
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'reset_switch', 'status' => 0]);
|
||||
\Session()->flash('alert-success', 'Vertriebspartner zurückgesetzt!');
|
||||
}
|
||||
if($action === 'unlock'){
|
||||
if ($action === 'unlock') {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
/*if(!$user->m_sponsor){
|
||||
$validator->errors()->add('m_sponsor', __('Vertriebspartner hat keinen Sponsor.'));
|
||||
}*/
|
||||
if(!$user->account->m_first_name){
|
||||
if (! $user->account->m_first_name) {
|
||||
$validator->errors()->add('m_first_name', __('Vertriebspartner hat keinen Vornamen.'));
|
||||
}
|
||||
if(!$user->account->m_last_name){
|
||||
if (! $user->account->m_last_name) {
|
||||
$validator->errors()->add('m_last_name', __('Vertriebspartner hat keinen Nachnamen.'));
|
||||
}
|
||||
if(!$user->m_level){
|
||||
if (! $user->m_level) {
|
||||
$validator->errors()->add('m_level', __('Vertriebspartner hat keine Rolle'));
|
||||
}
|
||||
|
||||
|
||||
if ($validator->errors()->count()) {
|
||||
return back()->withErrors($validator)->withRequest(Request::all());
|
||||
}
|
||||
|
||||
if(!$user->account->m_account){
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') +1;
|
||||
if (! $user->account->m_account) {
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') + 1;
|
||||
$user->account->save();
|
||||
}
|
||||
|
||||
//set wizard to payments / activate
|
||||
// set wizard to payments / activate
|
||||
$this->activeAccountPayment($user);
|
||||
|
||||
//mail with code to user?
|
||||
|
||||
// mail with code to user?
|
||||
try {
|
||||
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailAccountActive($user));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
SysLog::action('unlock', 'admin_lead', 5)
|
||||
->setUserId($user->id)
|
||||
->setModel($user->id, User::class)
|
||||
|
|
@ -580,55 +597,56 @@ class LeadController extends Controller
|
|||
->save();
|
||||
}
|
||||
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'unlock_completed', 'status'=>0]);
|
||||
\Session()->flash('alert-success', "Vertriebspartner erneut freigeschaltet!");
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'unlock_completed', 'status' => 0]);
|
||||
\Session()->flash('alert-success', 'Vertriebspartner erneut freigeschaltet!');
|
||||
}
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
|
||||
}
|
||||
|
||||
// send new verfified mail to user
|
||||
/* public function newMailVerified($id){
|
||||
|
||||
//send new verfified mail to user
|
||||
/* public function newMailVerified($id){
|
||||
User Register sind in der DB UserRegister, erst bei bestätigung wird es in die User DB übertragen
|
||||
|
||||
User Register sind in der DB UserRegister, erst bei bestätigung wird es in die User DB übertragen
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
try {
|
||||
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyAccount($confirmation_code, $user));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
SysLog::action('new_mail_verified', 'admin_lead', 5)
|
||||
->setUserId($user->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Error send new_mail_verified E-Mail: '.$e->getMessage())
|
||||
->save();
|
||||
}
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'new_mail_verified', 'status'=>0]);
|
||||
|
||||
try {
|
||||
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyAccount($confirmation_code, $user));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
SysLog::action('new_mail_verified', 'admin_lead', 5)
|
||||
->setUserId($user->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Error send new_mail_verified E-Mail: '.$e->getMessage())
|
||||
->save();
|
||||
}
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'new_mail_verified', 'status'=>0]);
|
||||
\Session()->flash('alert-success', "E-Mail erneut gesendet");
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
|
||||
\Session()->flash('alert-success', "E-Mail erneut gesendet");
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
}*/
|
||||
|
||||
}*/
|
||||
public function deleteFile($user_id, $file_id, $relation)
|
||||
{
|
||||
|
||||
public function deleteFile($user_id, $file_id, $relation){
|
||||
|
||||
if($relation === 'upload'){
|
||||
if ($relation === 'upload') {
|
||||
$user = User::findOrFail($user_id);
|
||||
$file = $user->files()->findOrFail($file_id);
|
||||
//remove file
|
||||
// remove file
|
||||
\Storage::disk('user')->delete($file->dir.$file->filename);
|
||||
$file->delete();
|
||||
\Session()->flash('alert-success', "Datei gelöscht");
|
||||
\Session()->flash('alert-success', 'Datei gelöscht');
|
||||
}
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue