Updates to 03-2025
This commit is contained in:
parent
6167273a48
commit
9b54eb0512
348 changed files with 34535 additions and 5774 deletions
|
|
@ -1,36 +1,40 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Attribute;
|
||||
use App\Models\Category;
|
||||
use App\Models\Country;
|
||||
use App\Models\Ingredient;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserLevel;
|
||||
use App\User;
|
||||
use App\Models\Country;
|
||||
use App\Models\Product;
|
||||
use App\Models\Category;
|
||||
use App\Models\LeadType;
|
||||
use App\Models\Attribute;
|
||||
use App\Models\UserLevel;
|
||||
use App\Models\Ingredient;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\AttributeType;
|
||||
use App\Models\ShippingCountry;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class HTMLHelper
|
||||
{
|
||||
|
||||
|
||||
private static $months = [
|
||||
1 => 'Januar',
|
||||
2 => 'Februar',
|
||||
3 => 'März',
|
||||
4 => 'April',
|
||||
5 => 'Mai',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Dezember',
|
||||
public static $months = [
|
||||
1 => 'January',
|
||||
2 => 'February',
|
||||
3 => 'March',
|
||||
4 => 'April',
|
||||
5 => 'May',
|
||||
6 => 'June',
|
||||
7 => 'July',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'October',
|
||||
11 => 'November',
|
||||
12 => 'December'
|
||||
];
|
||||
|
||||
|
||||
|
||||
private static $roles = [
|
||||
0 => 'Kunde',
|
||||
1 => 'Redakteur',
|
||||
|
|
@ -45,6 +49,23 @@ class HTMLHelper
|
|||
return self::$months[intval($i)];
|
||||
}
|
||||
|
||||
public static function getTransMonths($full = false){
|
||||
$ret = [];
|
||||
foreach(self::$months as $key=>$val){
|
||||
$ret[$key] = trans('cal.months.'.$val);
|
||||
}
|
||||
if($full){ //ganzes Jahr
|
||||
$ret[13] = trans('cal.months.full_year');
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getYearRange($start = 2021)
|
||||
{
|
||||
$end = date("Y");
|
||||
return array_reverse(range($start, $end));
|
||||
}
|
||||
|
||||
public static function getRoleLabel($role_id = 0){
|
||||
return '<span class="badge badge-pill '.self::getLabel($role_id).'">'.self::$roles[$role_id].'</span>';
|
||||
}
|
||||
|
|
@ -150,22 +171,68 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAttributesWithoutParents($id = false, $sameId = false, $all = true){
|
||||
$values = Attribute::where('parent_id', null)->get();
|
||||
|
||||
public static function getAttributeTypes($id = false){
|
||||
$values = AttributeType::where('parent_id', null)->where('active', 1)->orderBy('pos', 'asc')->get();
|
||||
$ret = "";
|
||||
if($id === false){
|
||||
$val = $values->first();
|
||||
$id = $val->id;
|
||||
}
|
||||
foreach ($values as $value){
|
||||
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getProductsWhiteLabelOptions($ids = [], $unsets = [], $type_id = false){
|
||||
$values = Product::where('whitelabel', 1)->where('active', 1)->get();
|
||||
$ret = "";
|
||||
foreach ($values as $value){
|
||||
if(is_array($unsets) && in_array($value->id, $unsets)){
|
||||
continue;
|
||||
}
|
||||
$attr = (is_array($ids) && in_array($value->id, $ids)) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getAttributesOptions($ids = array(), $all = true, $type_id = false){
|
||||
if($type_id){
|
||||
$values = Attribute::where('active', 1)->where('attribute_type_id', $type_id)->get();
|
||||
}else{
|
||||
$values = Attribute::where('active', 1)->get();
|
||||
}
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if($sameId == $value->id){
|
||||
continue;
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getProductAttributesOptions($product_attributes, $ids = [], $all = true, $type_id = false){
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($product_attributes as $product_attribute){
|
||||
if($product_attribute->attribute){
|
||||
$attr = (is_array($ids) && in_array($product_attribute->attribute_id, $ids)) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$product_attribute->attribute_id.'" '.$attr.'>'.$product_attribute->attribute->name.'</option>\n';
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCategoriesWithoutParents($id = false, $sameId = false, $all = true){
|
||||
$values = Category::where('parent_id', null)->get();
|
||||
$ret = "";
|
||||
|
|
@ -211,6 +278,14 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCategoriesByShowOn($show_on = []){
|
||||
$values = Category::where('active', true)->whereJsonContains('show_on', $show_on)->orderBy('pos', 'ASC')->get();
|
||||
$ret = [];
|
||||
foreach ($values as $value){
|
||||
$ret[$value->id] = ['name' => $value->name, 'count' => $value->getProductsCountOn($show_on)];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
public static function getCategoriesOptionsByShowOn($ids = array(), $all = false, $show_on = []){
|
||||
$values = Category::where('active', true)->whereJsonContains('show_on', $show_on)->orderBy('pos', 'ASC')->get();
|
||||
$ret = "";
|
||||
|
|
@ -219,7 +294,8 @@ class HTMLHelper
|
|||
}
|
||||
foreach ($values as $value){
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
$count = $value->getProductsCountOn($show_on);
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.' ('.$count.')</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
|
@ -236,14 +312,14 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAttributesOptions($ids = array(), $all = true){
|
||||
$values = Attribute::where('active', 1)->get();
|
||||
public static function getLeadTypeOptions($id = false, $all = true){
|
||||
$values = LeadType::where('active', 1)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue