main system

This commit is contained in:
Kevin Adametz 2021-01-15 18:16:31 +01:00
parent 0baac018a2
commit a96d7d5c77
115 changed files with 4589 additions and 557 deletions

View file

@ -90,7 +90,7 @@ class CronController extends Controller
== 7 abo_booking_days + sepa + cron = 37 reminder_collect_sepa
*/
//max Date for reminder
$renewalDate = Carbon::now()->modify('+'.(config('mivita.remind_first_days')+1).' days');
$renewalDate = Carbon::now()->modify('+'.(config('main.remind_first_days')+1).' days');
//dump($renewalDate);
$users = User::where('payment_account', '!=', NULL)
->where('active', '=', 1)
@ -134,13 +134,13 @@ class CronController extends Controller
}
//34 reminder_last
if($user->daysActiveAccount() <= config('mivita.remind_last_days')){
if($user->daysActiveAccount() <= config('main.remind_last_days')){
$isSend = $this->checkIsReminderSend($user, 34);
return $isSend;
}
//33 reminder_sec
if($user->daysActiveAccount() <= config('mivita.remind_sec_days')){
if($user->daysActiveAccount() <= config('main.remind_sec_days')){
if(!$user->isAboOption()){
$isSend = $this->checkIsReminderSend($user, 33);
return $isSend;
@ -148,7 +148,7 @@ class CronController extends Controller
}
//31 reminder_first, 32 reminder_first_sepa
if($user->daysActiveAccount() > config('mivita.remind_sec_days')){
if($user->daysActiveAccount() > config('main.remind_sec_days')){
if($user->isAboOption()){
$isSend = $this->checkIsReminderSend($user, 32);
return $isSend;
@ -186,7 +186,7 @@ class CronController extends Controller
//dump($days);
//dump($status);
$pay_date = Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y');
$pay_date = Carbon::parse($user->payment_account)->modify('- '.config('main.abo_booking_days').' days')->format('d.m.Y');
$datetime = $user->getPaymentAccountDateFormat();
$price = "";
if($user->payment_order_id && isset($user->payment_order_product->price)){

View file

@ -19,7 +19,7 @@ class HomeController extends Controller
*/
public function __construct()
{
$this->middleware('guest');
// $this->middleware('guest');
}
/**
@ -46,7 +46,7 @@ class HomeController extends Controller
'user' => Auth::user(),
'now' => Carbon::now(),
];
return view('home', $data);
return view('dashboard', $data);
}
public function loadingModal(){

View file

@ -7,7 +7,7 @@ use App\Models\Ingredient;
use App\Models\IqImage;
use App\Models\ProductCategory;
use App\Models\ProductIngredient;
use\Request;
use Request;
class IngredientController extends Controller

View file

@ -10,6 +10,7 @@ use App\Models\UserAccount;
use App\Models\UserHistory;
use App\Repositories\ContractPDFRepository;
use App\Repositories\UserRepository;
use App\Services\SysLog;
use App\Services\UserService;
use App\User;
use Illuminate\Support\Facades\Mail;
@ -258,7 +259,17 @@ class LeadController extends Controller
$user->save();
//mail with code to user?
Mail::to($user->email)->send(new MailAccountActive($user));
try {
Mail::to($user->email)->send(new MailAccountActive($user));
}
catch(\Exception $e){
SysLog::action('released', 'admin_lead', 5)
->setUserId($user->id)
->setModel($user->id, User::class)
->setMessage('Error send released E-Mail: '.$e->getMessage())
->save();
}
UserHistory::create(['user_id' => $user->id, 'action'=>'released_completed', 'status'=>0]);
\Session()->flash('alert-success', "Berater freigeschaltet!");
}
@ -285,8 +296,11 @@ class LeadController extends Controller
Mail::to($user->email)->send(new MailCustomMessage($user, $data, \Auth::user(), true));
}
catch(\Exception $e){
dump($e->getMessage());
dd("error");
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 Berater gesendet.");
@ -311,8 +325,11 @@ class LeadController extends Controller
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
}
catch(\Exception $e){
dump($e->getMessage());
dd("error");
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]);
@ -321,7 +338,6 @@ class LeadController extends Controller
}
public function deleteFile($user_id, $file_id, $relation){
if($relation === 'upload'){
@ -369,12 +385,12 @@ class LeadController extends Controller
->addColumn('payment_account_date', function (User $user) {
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
})
->addColumn('payment_shop', function (User $user) {
/*->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>';
})
->addColumn('payment_shop_date', function (User $user) {
return $user->payment_shop ? $user->getPaymentShopDateFormat(false) : "-";
})
})*/
->addColumn('turnover', function (User $user) {
return "-";
})
@ -389,8 +405,8 @@ class LeadController extends Controller
->orderColumn('active', 'active $1')
->orderColumn('agreement', 'agreement $1')
->orderColumn('payment_account', 'payment_account $1')
->orderColumn('payment_shop', 'payment_shop $1')
->rawColumns(['id', 'confirmed', 'active', 'agreement', 'payment_account', 'payment_shop'])
//->orderColumn('payment_shop', 'payment_shop $1')
->rawColumns(['id', 'confirmed', 'active', 'agreement', 'payment_account'])
->make(true);
}
}

View file

@ -6,6 +6,7 @@ use App\Mail\MailInfo;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Models\UserHistory;
use App\Models\UserLevel;
use App\User;
use Auth;
use Carbon;
@ -43,7 +44,6 @@ class MembershipController extends Controller
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
$data = [
'user' => $user,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
@ -52,19 +52,22 @@ class MembershipController extends Controller
'userHistoryPaymentOrder' => $userHistoryPaymentOrder,
'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder,
'userHistoryDeleteMembership' => $userHistoryDeleteMembership,
'user_levels' => UserLevel::where('active', true)->get(),
];
return view('user.membership.index', $data);
}
public function storePayment($action){
$data = Request::all();
//#### remove_abo
if($action === "remove_abo"){
/*if($action === "remove_abo"){
if(Request::get('abo_options_remove')){
$user = User::find(Auth::user()->id);
$user->abo_options = false;
@ -77,10 +80,10 @@ class MembershipController extends Controller
}
\Session()->flash('alert-error', "Fehler, Checkbox nicht bestätigt.");
return back();
}
}*/
//#### payment order
//#### shop upgrade
if($action === "upgrade_order" || $action === "payment_order"){
/*if($action === "upgrade_order" || $action === "payment_order"){
if(Request::get('switchers-package-wizard')){
$user = User::find(Auth::user()->id);
Yard::instance('shopping')->destroy();
@ -126,8 +129,9 @@ class MembershipController extends Controller
return redirect()->secure($path);
}
}
}
}*/
/*
if($action === "change_order"){
if(Request::get('switchers-package-wizard')){
$user = User::find(Auth::user()->id);
@ -146,8 +150,22 @@ class MembershipController extends Controller
}
}
}
*/
if($action === "change_level"){
if(Request::get('switchers-package-level')){
$user = User::find(Auth::user()->id);
$user->next_m_level = Request::get('switchers-package-level');
$user->save();
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>10, 'referenz'=>Request::get('switchers-package-level')]);
\Session()->flash('alert-success', "Änderung gespeichert");
return back();
}
}
if($action === "delete_membership"){
if(Request::get('delete_membership_mivita')){
if(Request::get('delete_membership')){
//TODO
$user = User::find(Auth::user()->id);
if($user->isTestMode()){

View file

@ -129,7 +129,7 @@ class PayController extends Controller
}
//Rechnungskauf
if($payment_method[0] === 'fnc'){
if($payment_method === 'fnc'){
$this->method = [
"clearingtype" => "fnc",
"wallettype" => "",
@ -157,7 +157,7 @@ class PayController extends Controller
]);
Util::setUserHistoryValue(['status'=>5]);
Util::setUserHistoryValue(['status'=>5], $identifier);
return redirect(route('user_checkout_final', [$payt->id, $this->reference, $identifier]));
}

View file

@ -271,12 +271,12 @@ class SalesController extends Controller
$shopping_order = ShoppingOrder::findOrFail($data['id']);
$shopping_payment = ShoppingPayment::findOrFail($data['payment_id']);
PaymentTransaction::create([
$payt = PaymentTransaction::create([
'shopping_payment_id' => $shopping_payment->id,
'request' => 'transaction',
'txid' => 0,
'userid' => 0,
'status' => 'FNCMIV',
'status' => $shopping_payment->clearingtype,
'transmitted_data' => NULL,
'txaction' => $data['txaction'],
'mode' => $shopping_payment->mode,
@ -288,14 +288,24 @@ class SalesController extends Controller
$shopping_payment->txaction = $data['txaction'];
$shopping_payment->save();
if($payt->status === 'vor' && $payt->txaction === 'paid'){
$send_link = Payment::paymentStatusPaidAction($shopping_order, false);
}
$edata = [
'mode' => $payt->mode,
'txaction' => $payt->txaction,
'send_link' => false,
];
//TODO can send MAIL
//Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $edata);
}
}
if(isset($data['back'])){
return redirect($data['back']);
}
return back();
}
}

View file

@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\Ingredient;
use App\Models\IqImage;
use App\Models\ProductCategory;
use App\Models\ProductIngredient;
use App\Models\Setting;
use Request;
class SettingController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index()
{
$data = [
'values' => Ingredient::all(),
];
return view('admin.settings.index', $data);
}
public function store()
{
$data = Request::all();
if(isset($data['action'])){
if(isset($data['settings'])){
foreach ($data['settings'] as $key=>$value){
Setting::setContentBySlug($key, $value['val'], $value['type']);
}
}
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_settings'));
}
}

View file

@ -76,16 +76,16 @@ class CheckoutController extends Controller
Yard::instance('shopping')->setShippingCountryWithPrice($shopping_instance->country_id, $is_for);
*/
if($this->getPayments('identifier') !== $identifier){
$this->destroy();
$this->putPayments('identifier', $identifier);
}
$shopping_data = Yard::instance('shopping')->getYardExtra('shopping_data');
$is_from = isset($shopping_data['is_from']) ? $shopping_data['is_from'] : 'shopping';
$is_for = isset($shopping_data['is_for']) ? $shopping_data['is_for'] : false;
$shopping_user = null;
if(\Session::has('new_session')){
$this->destroy();
\Session::forget('new_session');
}
if(!$this->getPayments('shopping_user_id')){
if($shopping_data && $is_from !== 'shopping'){
@ -98,7 +98,6 @@ class CheckoutController extends Controller
$shopping_user = new ShoppingUser();
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
$shopping_user->homeparty_id = $homeparty_id;
$shopping_user->mode = 'prev';
}
}else{
@ -278,7 +277,7 @@ class CheckoutController extends Controller
if($shopping_user->is_from === 'shopping'){
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
}
Util::setUserHistoryValue(['status'=>2, 'shopping_order_id'=>$shopping_order->id]);
Util::setUserHistoryValue(['status'=>2, 'shopping_order_id'=>$shopping_order->id], $identifier);
//check credit Card
if(Request::get('payment_method')){
@ -302,48 +301,7 @@ class CheckoutController extends Controller
}
public function transactionStatus($status, $reference){
$shopping_order_id = $this->getPayments('shopping_order_id');
$ShoppingPayment = ShoppingPayment::where('shopping_order_id', $shopping_order_id)->where('reference', $reference)->first();
if(!$ShoppingPayment){
//TODO log this
Util::setUserHistoryValue(['status'=>21]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang konnte nicht abgeschlossen werden, die Zahlung wurde nicht gefunden: '.$reference);
return redirect(route('checkout.checkout_card'));
}
$ShoppingPayment->status = $status;
$ShoppingPayment->save();
if($status === "success"){
Yard::instance('shopping')->destroy();
$this->destroy();
$payt = $ShoppingPayment->payment_transactions->last();
$data = [
'user_shop' => Util::getUserShop(),
'order_reference' => $reference,
'pay_trans' => $payt,
];
return view('web.templates.checkout-final', $data);
}
if($status === "cancel"){
Util::setUserHistoryValue(['status'=>22]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
return redirect(route('checkout.checkout_card'));
}
if($status === "error"){
Util::setUserHistoryValue(['status'=>23]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
return redirect(route('checkout.checkout_card'));
}
}
public function final($transactionId, $reference, $identifier) {
@ -355,7 +313,7 @@ class CheckoutController extends Controller
$this->destroy();
if($payt->status === 'fnc' || $payt->status === 'vor'){
$this->directPaymentStatus($payt);
$this->directPaymentStatus($payt, $identifier);
}
$data = [
@ -376,6 +334,48 @@ class CheckoutController extends Controller
}
}
}*/
public function transactionStatus($status, $reference){
die("not defined");
$shopping_order_id = $this->getPayments('shopping_order_id');
$ShoppingPayment = ShoppingPayment::where('shopping_order_id', $shopping_order_id)->where('reference', $reference)->first();
if(!$ShoppingPayment){
//TODO log this
Util::setUserHistoryValue(['status'=>21]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang konnte nicht abgeschlossen werden, die Zahlung wurde nicht gefunden: '.$reference);
return redirect(route('checkout.checkout_card'));
}
$ShoppingPayment->status = $status;
$ShoppingPayment->save();
if($status === "success"){
Yard::instance('shopping')->destroy();
$this->destroy();
$payt = $ShoppingPayment->payment_transactions->last();
$data = [
'user_shop' => Util::getUserShop(),
'order_reference' => $reference,
'pay_trans' => $payt,
];
return view('web.templates.checkout-final', $data);
}
if($status === "cancel"){
Util::setUserHistoryValue(['status'=>22]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
return redirect(route('checkout.checkout_card'));
}
if($status === "error"){
Util::setUserHistoryValue(['status'=>23]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
return redirect(route('checkout.checkout_card'));
}
}
private function makeShoppingUser($data){
@ -403,7 +403,6 @@ class CheckoutController extends Controller
$user_shop = Util::getUserShop();
$data = [
'shopping_user_id' => $shopping_user->id,
'auth_user_id' => $shopping_user->auth_user_id,
@ -506,18 +505,32 @@ class CheckoutController extends Controller
$this->session->remove($this->instance);
}
private function directPaymentStatus(PaymentTransaction $payt){
private function directPaymentStatus(PaymentTransaction $payt, $identifier){
if(isset($payt->transmitted_data['param'])){
$shopping_order = ShoppingOrder::find($payt->transmitted_data['param']);
$shopping_payment = ShoppingPayment::where('reference', $payt->transmitted_data['reference'])->first();
$shopping_order->txaction = 'open';
$shopping_order->save();
$shopping_payment = ShoppingPayment::where('reference', $payt->transmitted_data['reference'])->first();
if($shopping_payment){
$shopping_payment->txaction = 'open';
if($payt->status === 'vor'){
$shopping_payment->txaction = 'open';
$shopping_order->txaction = 'open';
}
if($payt->status === 'fnc'){
$send_link = Payment::paymentStatusPaidAction($shopping_order, false);
$shopping_payment->txaction = 'open';
$shopping_order->txaction = 'open';
}
$shopping_payment->save();
}
//$send_link = Payment::paymentStatusPaidAction($shopping_order, false);
//$payt->request = "approved";
//$payt->save();
$data = [

View file

@ -91,7 +91,7 @@ class CustomerController extends Controller
$step = 1;
$shopping_user->same_as_billing = true;
$shopping_user->faker_mail = true;
$billing_email = time()."-faker@mivita.care";
$billing_email = time()."-faker@gruene-seele.bio";
}
}
$data = [

View file

@ -24,8 +24,6 @@ class OrderController extends Controller
public function __construct()
{
$this->middleware('superadmin');
$this->middleware('active.account');
}
@ -159,14 +157,13 @@ class OrderController extends Controller
'isView' => 'customer',
'for' => $for,
'delivery_id' => $delivery_id,
'comp_products' => $this->getCompProducts($for),
//'comp_products' => $this->getCompProducts($for),
];
return view('user.order.list', $data);
}
public function payment($for, $id=null){
$data = Request::all();
$user = User::find(Auth::user()->id);
$rules = array(
'shipping_salutation' => 'required',
@ -180,10 +177,11 @@ class OrderController extends Controller
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
dd($validator);
return back()->withErrors($validator)->withInput(Request::all());
}
if(Yard::instance('shopping')->getNumComp() > 0){
/* if(Yard::instance('shopping')->getNumComp() > 0){
if(!isset($data['switchers-comp-product'])){
$validator->errors()->add('switchers-comp-product', __('Bitte wähle ein Kompensationsprodukt aus'));
}else{
@ -199,16 +197,20 @@ class OrderController extends Controller
return back()->withErrors($validator)->withInput(Request::all());
}
}
do {
*/
/*do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
} while( ShoppingInstance::where('identifier', $identifier)->count() );*/
$identifier = Util::getToken();
$data['is_from'] = 'user_order';
$data['is_for'] = $for;
$data['shopping_user_id'] = $id;
unset($data['quantity']);
unset($data['_token']);
ShoppingInstance::create([
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
/*ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop for buy intern
'auth_user_id' => Auth::user()->id,
@ -220,14 +222,13 @@ class OrderController extends Controller
]);
Yard::instance('shopping')->store($identifier);
*/
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier, 'abo_options'=>0]);
//$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier]);
//$path = str_replace('http', 'https', $path);
return redirect()->secure($path);
//return redirect()->secure($path);
return redirect(route('user_checkout', [$identifier]));
}
private function checkShoppingCountry($for, $id=null){
@ -384,14 +385,13 @@ class OrderController extends Controller
->make(true);
}
public function performRequest(){
if(Request::ajax()) {
$data = Request::all();
$data = Request::all();
$is_for = isset($data['shipping_is_for']) ? $data['shipping_is_for'] : 'ot';
$data['comp_products'] = $this->getCompProducts($is_for);
// $data['comp_products'] = $this->getCompProducts($is_for);
if($data['action'] === 'updateCart' && isset($data['product_id'])){
if($product = Product::find($data['product_id'])){
@ -401,7 +401,7 @@ class OrderController extends Controller
}
//get the card item
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true), $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
Yard::setTax($cartItem->rowId, $product->tax);
if(isset($data['qty']) && $data['qty'] > 0){
@ -411,34 +411,31 @@ class OrderController extends Controller
Yard::instance('shopping')->remove($cartItem->rowId);
}
//
Yard::instance('shopping')->reCalculateShippingPrice();
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
//$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
//$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>'']);
}
}
if($data['action'] === 'clearCart') {
Yard::instance('shopping')->destroy();
return response()->json(['response' => true, 'data'=>Yard::instance('shopping')->count(), 'html_card'=>'', 'html_comp'=>'']);
}
if($data['action'] === 'updateShippingCountry') {
if(isset($data['shipping_country_id'])){
if($shipping_country = ShippingCountry::find($data['shipping_country_id'])){
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country->id, $is_for);
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
//$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
}
}
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
//$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>'']);
}
if($data['action'] === 'updateCompProduct'){
/* if($data['action'] === 'updateCompProduct'){
// $data['comp_product_id']
// $data['comp_num']
//count_comp_products
@ -450,11 +447,12 @@ class OrderController extends Controller
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
}
*/
return response()->json(['response' => false, 'data'=>$data]);
}
}
private function checkCompProduct($count_comp_products){
/* private function checkCompProduct($count_comp_products){
foreach (Yard::instance('shopping')->content() as $row) {
//wenn gleich löschen, da neue Versandkosten
if($row->options->comp > $count_comp_products) {
@ -491,5 +489,5 @@ class OrderController extends Controller
return Product::whereActive(true)->where('show_at', '=', 1)->where('shipping_addon', true)->orderBy('pos', 'DESC')->get();
}
return null;
}
}*/
}

View file

@ -17,14 +17,11 @@ class TeamController extends Controller
public function members()
{
$user = User::find(\Auth::user()->id);
if($user->isActiveShop() && $user->shop){
$shop_register_link = $user->shop->getSubdomain(false)."/reg";
}else{
$member_id = 'm'.($user->id + config('mivita.add_number_id'));
$shop_register_link = config('app.protocol').config('app.domain').config('app.tld_care').'/reg/'.$member_id;
}
$member_id = 'gs'.($user->id + config('main.add_number_id'));
$register_link = route('register_user_member', [$member_id]);
$data = [
'shop_register_link' => $shop_register_link
'register_link' => $register_link
];
return view('user.team.members', $data);
}

View file

@ -20,9 +20,7 @@ class UserDataController extends Controller
$this->userRepo = $userRepo;
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function userEdit(){
$user = Auth::user();
@ -35,16 +33,13 @@ class UserDataController extends Controller
return view('user.edit', $data);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function userEditStore(){
$user = Auth::user();
/*if(!$user->account){
$user->account = new UserAccount();
}*/
$rules = array(
'salutation' => 'required',
'first_name'=>'required',
@ -82,8 +77,10 @@ class UserDataController extends Controller
}
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function userDataStore(){

View file

@ -6,7 +6,9 @@ namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Mail\MailContact;
use App\Mail\MailVerifyAccount;
use App\Models\UserHistory;
use App\Repositories\UserRepository;
use App\Services\SysLog;
use App\Services\UserService;
use App\User;
use GuzzleHttp\Client;
@ -32,23 +34,21 @@ class RegisterController extends Controller
$this->userRepo = $userRepo;
}
/* public function member($member_id = false)
public function member($member_id = false)
{
if(!$member_id){
return redirect('/registrierung');
}
$user_id = (int) str_replace('m', '', $member_id) - config('mivita.add_number_id');
$user_id = (int) str_replace('gs', '', $member_id) - config('main.add_number_id');
$user = User::find($user_id);
if(!$user || !$user->isActive() || !$user->isActiveAccount()){
return redirect('/registrierung');
}
$data = [
'GOOGLE_ReCAPTCHA_KEY' => $this->GOOGLE_ReCAPTCHA_KEY,
'user_shop' => Util::getUserShop(),
'from_member_id' => $member_id
];
return view('web.templates.registrierung', $data);
}*/
return view('auth.register', $data);
}
public function register(){
@ -78,13 +78,23 @@ class RegisterController extends Controller
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
$user->confirmation_code_remider = 0;
if(isset($data['from_member_id'])){
$user->m_sponsor = (int) str_replace('m', '', $data['from_member_id']) - config('main.add_number_id');
$user->m_sponsor = (int) str_replace('gs', '', $data['from_member_id']) - config('main.add_number_id');
}
$user->save();
$user = User::find($user->id);
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
try {
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
}
catch(\Exception $e){
SysLog::action('register-user', 'auth_register', 5)
->setUserId($user->id)
->setModel($user->id, User::class)
->setMessage('Error send register E-Mail: '.$e->getMessage())
->save();
}
UserHistory::create(['user_id' => $user->id, 'action'=>'register', 'status'=>0]);
return redirect('/user_register/finish');
}

View file

@ -451,7 +451,7 @@ class WizardController extends Controller
if($product->images->count()){
$image = $product->images->first()->slug;
}
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
//set onboarding products
if(Request::get('products_on_board')){
@ -461,7 +461,7 @@ class WizardController extends Controller
if($product_on_board->images->count()){
$image = $product_on_board->images->first()->slug;
}
Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->price, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->price, $product->tax, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
}
}
@ -488,7 +488,7 @@ class WizardController extends Controller
]);*/
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
Yard::instance('shopping')->store($identifier);
//Yard::instance('shopping')->store($identifier);
//add to DB
//$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>'wizard_payment', 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier]);

View file

@ -13,7 +13,7 @@ class ContractPDF extends Fpdi
public function Header()
{
if (null === $this->_tplIdx) {
$this->setSourceFile('./pdf/mivita_template_contract_de.pdf');
$this->setSourceFile('./pdf/template_contract_de.pdf');
}
$this->_tplIdx = $this->importPage($this->_site++);
$this->useTemplate($this->_tplIdx);

View file

@ -20,11 +20,8 @@ class MailContact extends Mailable
public function __construct($data)
{
$this->data = $data;
$this->user_shop = Util::getUserShop();
$this->subject = __('email.your_request_from').' mivita.care';
if($this->user_shop){
$this->subject = __('email.your_request_from')." ".$this->user_shop->slug.'.mivita.care';
}
$this->subject = __('email.your_request_from').' gruene-seele.bio';
}
public function build()
@ -42,10 +39,8 @@ class MailContact extends Mailable
$this->data['salutation'] = 'Frau';
}
}
$copy1line = __('email.your_request_from')." mivita.care";
if($this->user_shop){
$copy1line = __('email.your_request_from')." ".$this->user_shop->slug.'.mivita.care';
}
$copy1line = __('email.your_request_from')." gruene-seele.bio";
return $this->view('emails.contact')->with([
'salutation' => $salutation,

View file

@ -22,7 +22,7 @@ class MailSyS extends Mailable
$this->action = $action;
if($this->action === "log"){
$this->subject = 'mivita Logger';
$this->subject = 'gruene-seele Logger';
}
}

View file

@ -176,7 +176,7 @@ class Product extends Model
'show_order' => 'Wird immer als Option angezeigt',
'upgrade' => 'Produktupgrade zur Produkt ID',
'upgrade_member' => 'Beraterupgrade zur Karriere ID',
'proportional_voucher' => 'Anteiliger Gutschein Berater',
//'proportional_voucher' => 'Anteiliger Gutschein Berater',
];
@ -189,22 +189,22 @@ class Product extends Model
];
public $showATs = [
0 => 'Nur Kunden Shop',
1 => 'Kunden + Berater Shop',
2 => 'Nur Berater Shop',
0 => 'Nur Kunden Bestellungen',
1 => 'Kunden + Berater Bestellungen',
2 => 'Nur Berater Bestellungen',
3 => 'Registrierung / Mitgliedschaft Berater',
4 => 'Nur Mitgliedschaft Berater',
5 => 'Onboarding Berater',
6 => 'Onboarding Berater + Berater Shop',
//5 => 'Onboarding Berater',
//6 => 'Onboarding Berater + Berater Shop',
7 => 'zur internen Berechnung',
];
public $actions = [
0 => 'payment_for_account',
1 => 'payment_for_shop',
2 => 'payment_for_shop_upgrade',
4 => 'payment_for_lead_upgrade',
// 1 => 'payment_for_shop',
// 2 => 'payment_for_shop_upgrade',
// 4 => 'payment_for_lead_upgrade',
];

111
app/Models/Setting.php Normal file
View file

@ -0,0 +1,111 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
* Class Setting
*
* @property int $id
* @property string|null $identifier
* @property string $slug
* @property int $referenz
* @property string|null $action
* @property string|null $object
* @property string|null $content
* @property int $status
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @package App\Models
*/
class Setting extends Model
{
use Sluggable;
protected $table = 'settings';
protected $casts = [
'referenz' => 'int',
'status' => 'int',
'object' => 'array'
];
protected $fillable = [
'identifier',
'slug',
'referenz',
'action',
'object',
'full_text',
'text',
'status',
'type'
];
protected static $types = [
'object' => 'Object',
'full_text' => 'Full Text',
'text' => 'Text',
];
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public static function getContentBySlug($slug){
$content = self::whereSlug(trim($slug))->first();
if($content){
switch ($content->type){
case 'object':
return $content->object;
break;
case 'full_text':
return $content->full_text;
break;
case 'text':
return $content->text;
break;
}
}
return false;
}
public static function setContentBySlug($slug, $value, $type = "full_text"){
$content = self::whereSlug(trim($slug))->first();
if(!$content) {
$content = self::create([
'slug' => $slug,
'type' => $type,
]);
}
$content->type = $type;
switch ($content->type){
case 'object':
$content->object = $value;
break;
case 'full_text':
$content->full_text = $value;
break;
case 'text':
$content->text = $value;
break;
}
$content->save();
return $content;
}
}

View file

@ -71,7 +71,7 @@ class ShippingPrice extends Model
$this->attributes['factor'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTaxAttribute($value)
public function setTaxRateAttribute($value)
{
$this->attributes['tax_rate'] = $value ? Util::reFormatNumber($value) : null;
}

View file

@ -185,6 +185,10 @@ class ShoppingOrder extends Model
return $this->hasMany('App\Models\ShoppingPayment', 'shopping_order_id');
}
public function shopping_payment_last(){
return $this->hasOne('App\Models\ShoppingPayment', 'shopping_order_id')->latest();
}
public function setUserHistoryValue($values = []){
if($user_history = $this->user_history){
foreach ($values as $key=>$val){

View file

@ -104,10 +104,10 @@ class ContractPDFRepository extends BaseRepository {
$pdf->SetXY($x1, $y);
$pdf->Write(0, $this->convert($this->model->user_sponsor->account->m_first_name)." ".$this->convert($this->model->user_sponsor->account->m_last_name));
$website = $this->model->user_sponsor->shop()->count() ? $this->model->user_sponsor->shop->getSubdomain(false) : "www.mivita.care";
$website = "www.gruene-seele.bio";
}else{
$website = "www.mivita.care";
$website = "www.gruene-seele.bio";
}
$pdf->AddPage('P', array(210, 297));
@ -128,7 +128,7 @@ class ContractPDFRepository extends BaseRepository {
if(!Storage::disk($this->disk)->exists( $this->dir )){
Storage::disk($this->disk)->makeDirectory($this->dir); //creates directory
}
$filename = "MIVITA_Beratervertrag.pdf";
$filename = "Beratervertrag.pdf";
Storage::disk($this->disk)->put($this->dir.$filename, $pdf->Output('S'));
$size = Storage::disk($this->disk)->size($this->dir.$filename);
$mine = Storage::disk($this->disk)->getMimeType($this->dir.$filename);

View file

@ -16,26 +16,41 @@ class Payment
'appointed' => "offen",
'failed' => "abbruch",
'extern' => "extern",
'open' => "offen",
'invoice_open' => "Re. offen",
'invoice_paid' => "Re. bezahlt",
'invoice_non' => "keine Zahlung",
'invoice_non' => "Re. keine Zahlung",
'non' => "keine Zahlung",
'NULL' => 'keine Zahlung',
];
public static $txaction_invoice = [
'invoice_open' => "Re. offen",
'invoice_paid' => "Re. bezahlt",
'invoice_non' => 'keine Zahlung',
'open' => "offen",
'paid' => "bezahlt",
'non' => "keine Zahlung",
/*'open_vor' => "Vorkasse offen",
'paid_vor' => "Vorkasse bezahlt",
'non_vor' => "Vorkasse keine Zahlung",
'invoice_open' => "Rechung offen",
'invoice_paid' => "Rechung bezahlt",
'invoice_non' => 'Rechung keine Zahlung',*/
];
public static $txaction_color = [
'paid' => "success",
'appointed' => "warning",
'failed' => "danger",
'extern' => "success",
'open' => "warning",
'paid' => "success",
'non' => "danger",
'open_vor' => "warning",
'paid_vor' => "success",
'non_vor' => "danger",
'invoice_open' => "warning",
'invoice_paid' => "success",
'invoice_non' => "failed",
'invoice_non' => "danger",
];
@ -71,8 +86,9 @@ class Payment
}
/* public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
$send_link = false;
$shopping_order->setUserHistoryValue(['status' => 8]);
Shop::userOrders();
$shopping_order->paid = $paid;
@ -83,6 +99,7 @@ class Payment
foreach($shopping_order->shopping_order_items as $shopping_order_item){
if($shopping_order_item->product){
if($shopping_order_item->product->action){
$user = User::findOrFail($shopping_order->auth_user_id);
$user->save();
$send_link = true;
@ -93,12 +110,13 @@ class Payment
}
foreach ($shopping_order_item->product->action as $do){
if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){
$user->payment_order_id = $shopping_order_item->product->id; //34
// $user->payment_order_id = $shopping_order_item->product->id; //34
$user->payment_account = $date;
$user->wizard = 100;
$user->payment_credit = $shopping_order_item->product->price;
$shopping_order->setUserHistoryValue(['status' => 9]);
}
if($shopping_order_item->product->getActionName($do) === 'payment_for_shop'){
/*if($shopping_order_item->product->getActionName($do) === 'payment_for_shop'){
$user->payment_order_id = $shopping_order_item->product->id; //35
$user->payment_shop = $date;
$user->wizard = 100;
@ -115,7 +133,7 @@ class Payment
if($shopping_order_item->product->upgrade_to_id){
$user->m_level = $shopping_order_item->product->upgrade_to_id;
}
}
}*/
$user->save();
}
}
@ -125,7 +143,7 @@ class Payment
}
return $send_link;
}*/
}
public static function paymentStatusSendMail(ShoppingOrder $shopping_order, $shopping_payment, $data){
$bcc = [];

View file

@ -107,25 +107,25 @@ class Util
}
public static function getUserShopIdentifier(){
/*public static function getUserShopIdentifier(){
if(\Session::has('user_shop_identifier')){
if($user_shop_identifier = \Session::get('user_shop_identifier')){
return $user_shop_identifier;
}
}
return false;
}
public static function getUserHistory(){
}*/
public static function getUserHistory($identifier){
$auth_user = self::getAuthUser();
$user_shop_identifier = self::getUserShopIdentifier();
if($user_shop_identifier && $auth_user){
return UserHistory::whereUserId($auth_user->id)->whereIdentifier($user_shop_identifier)->get()->last();
if($auth_user){
return UserHistory::whereUserId($auth_user->id)->whereIdentifier($identifier)->get()->last();
}
return false;
}
public static function setUserHistoryValue($values = []){
if($user_history = self::getUserHistory()){
public static function setUserHistoryValue($values = [], $identifier){
if($user_history = self::getUserHistory($identifier)){
foreach ($values as $key=>$val){
$user_history->{$key} = $val;
}
@ -133,8 +133,8 @@ class Util
}
}
public static function getUserHistoryValue($key){
if($user_history = self::getUserHistory()) {
public static function getUserHistoryValue($key, $identifier){
if($user_history = self::getUserHistory($identifier)) {
return $user_history->{$key};
}
return null;

View file

@ -19,7 +19,7 @@ class Yard extends Cart
private $shipping_tax = 0;
private $shipping_country_id = 0; //default de
private $shipping_is_for;
private $num_comp;
//private $num_comp;
private $ysession;
private $yinstance;
private $shopping_data = [];
@ -52,9 +52,9 @@ class Yard extends Cart
$this->shipping_is_for = $this->getYardExtra('shipping_is_for');
}
if($this->getYardExtra('num_comp')){
/*if($this->getYardExtra('num_comp')){
$this->num_comp = $this->getYardExtra('num_comp');
}
}*/
parent::__construct($session, $events);
@ -146,12 +146,13 @@ class Yard extends Cart
return;
}
$shipping = $shippingCountry->shipping;
if($this->weight() == 0){
$shipping_price = $shipping->shipping_prices->first();
$shipping_price->price = 0;
$shipping_price->price_comp = 0;
}else{
//first by price
$shipping_price = $this->shippingPriceByTotal($shipping->shipping_prices, $this->total(2, '.', ''));
//sec by weight
@ -160,23 +161,24 @@ class Yard extends Cart
}
//default
if(!$shipping_price){
$shipping_price = $shipping->shipping_prices->first();
}
}
if($shipping_price){
$price = $shipping_price->price;
$this->num_comp = 0;
/*$this->num_comp = 0;
if($this->shipping_is_for === 'me'){
$price = $shipping_price->price_comp;
$this->num_comp = $shipping_price->num_comp;
}
}*/
$this->shipping_price = $price;
$this->shipping_tax_rate = $shipping_price->tax_rate;
$this->shipping_price_net = round($price / ((100+$shipping_price->tax_rate) / 100), 2);
$this->shipping_tax = round($price / (100+$shipping_price->tax_rate) * 100, 2);
$this->putYardExtra('num_comp', $this->num_comp);
//$this->putYardExtra('num_comp', $this->num_comp);
$this->putYardExtra('shipping_price', $this->shipping_price);
$this->putYardExtra('shipping_tax_rate', $this->shipping_tax_rate);
$this->putYardExtra('shipping_tax', $this->shipping_tax);
@ -419,7 +421,7 @@ class Yard extends Cart
}
public function getNumComp(){
return $this->num_comp;
return 0; //$this->num_comp;
}
public function getCompProductBy($comp, $product_id=false){

View file

@ -9,6 +9,7 @@ use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Support\Facades\Mail;
use Util;
/**
* App\User
@ -251,13 +252,13 @@ class User extends Authenticatable
public function isRenewalAccount(){
if ($this->payment_account) {
return Carbon::parse($this->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days')->lt(Carbon::now());
return Carbon::parse($this->payment_account)->modify('-'.(config('main.renewal_days')+1).' days')->lt(Carbon::now());
}
return false;
}
public function nextRenewalAccount(){
return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-'.config('mivita.renewal_days').' days')->format(\Util::formatDateTimeDB()) : false ;
return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-'.config('main.renewal_days').' days')->format(\Util::formatDateTimeDB()) : false ;
}
public function daysActiveAccount(){
@ -332,6 +333,10 @@ class User extends Authenticatable
return Carbon::parse($this->attributes['release_account'])->format(\Util::formatDateTimeDB());
}
public function getFormattedPaymentCredit()
{
return isset($this->attributes['payment_credit']) ? Util::formatNumber($this->attributes['payment_credit']) : "0";
}
public function setSetting(array $revisions, bool $save = true){
if(!$this->settings){