23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Attribute;
|
||||
|
|
@ -13,24 +14,21 @@ use App\User;
|
|||
|
||||
class HTMLHelper
|
||||
{
|
||||
|
||||
|
||||
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'
|
||||
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 => 'Berater',
|
||||
1 => 'VIP',
|
||||
|
|
@ -39,30 +37,35 @@ class HTMLHelper
|
|||
4 => 'SySAdmin',
|
||||
];
|
||||
|
||||
|
||||
public static function getMonth($i){
|
||||
public static function getMonth($i)
|
||||
{
|
||||
return trans('cal.months.'.self::$months[intval($i)]);
|
||||
}
|
||||
|
||||
public static function getTransMonths(){
|
||||
public static function getTransMonths()
|
||||
{
|
||||
$ret = [];
|
||||
foreach(self::$months as $key=>$val){
|
||||
$ret[$key] = trans('cal.months.'.$val);
|
||||
}
|
||||
return $ret;
|
||||
foreach (self::$months as $key => $val) {
|
||||
$ret[$key] = trans('cal.months.'.$val);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getYearRange($start = 2021)
|
||||
{
|
||||
$end = date("Y");
|
||||
$end = date('Y');
|
||||
|
||||
return array_reverse(range($start, $end));
|
||||
}
|
||||
|
||||
public static function getRoleLabel($role_id = 0){
|
||||
|
||||
public static function getRoleLabel($role_id = 0)
|
||||
{
|
||||
return '<span class="badge badge-pill '.self::getLabel($role_id).'">'.self::$roles[$role_id].'</span>';
|
||||
}
|
||||
|
||||
public static function getLabel($id){
|
||||
public static function getLabel($id)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
return 'badge-default';
|
||||
|
|
@ -80,308 +83,375 @@ class HTMLHelper
|
|||
return 'badge-primary';
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function getRolesOptions(){
|
||||
$ret = "";
|
||||
foreach (self::$roles as $role_id => $value){
|
||||
public static function getRolesOptions()
|
||||
{
|
||||
$ret = '';
|
||||
foreach (self::$roles as $role_id => $value) {
|
||||
$ret .= '<option value="'.$role_id.'">'.$value.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getYearSelectOptions(){
|
||||
$start = date("Y", strtotime("-5 years", time()));
|
||||
$end = date("Y", strtotime("+1 years", time()));
|
||||
public static function getYearSelectOptions()
|
||||
{
|
||||
$start = date('Y', strtotime('-5 years', time()));
|
||||
$end = date('Y', strtotime('+1 years', time()));
|
||||
$values = range($start, $end);
|
||||
$now = date("Y", time());
|
||||
$ret = "";
|
||||
foreach ($values as $value){
|
||||
$now = date('Y', time());
|
||||
$ret = '';
|
||||
foreach ($values as $value) {
|
||||
$attr = ($value == $now) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAboDeliveryOptions($default = 5){
|
||||
$values = \App\Models\UserAbo::$aboDeliveryDays;
|
||||
$ret = "";
|
||||
foreach ($values as $value){
|
||||
public static function getAboDeliveryOptions($default = 5)
|
||||
{
|
||||
$values = \App\Models\UserAbo::$aboDeliveryDays;
|
||||
$ret = '';
|
||||
foreach ($values as $value) {
|
||||
$attr = ($value == $default) ? 'selected="selected"' : '';
|
||||
$str = self::getAboStrLang($value);
|
||||
$ret .= '<option value="'.$value.'" '.$attr.'>'.$str.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAboStrLang($num){
|
||||
public static function getAboStrLang($num)
|
||||
{
|
||||
return $num.'. '.__('abo.of_month');
|
||||
}
|
||||
|
||||
public static function getAboFirstExecutionDate($date, $interval)
|
||||
{
|
||||
return AboHelper::getFirstAboDate($date, $interval)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public static function getAttributesWithoutParents($id = false, $sameId = false, $all = true){
|
||||
public static function getAttributesWithoutParents($id = false, $sameId = false, $all = true)
|
||||
{
|
||||
$values = Attribute::where('parent_id', null)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('none').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if($sameId == $value->id){
|
||||
foreach ($values as $value) {
|
||||
if ($sameId == $value->id) {
|
||||
continue;
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCategoriesWithoutParents($id = false, $sameId = false, $all = true){
|
||||
public static function getCategoriesWithoutParents($id = false, $sameId = false, $all = true)
|
||||
{
|
||||
$values = Category::where('parent_id', null)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('none').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if($sameId == $value->id){
|
||||
foreach ($values as $value) {
|
||||
if ($sameId == $value->id) {
|
||||
continue;
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getProductsOptions($ids = array(), $all = true){
|
||||
if($ids == null){
|
||||
$ids = array();
|
||||
public static function getProductsOptions($ids = [], $all = true)
|
||||
{
|
||||
if ($ids == null) {
|
||||
$ids = [];
|
||||
}
|
||||
$values = Product::all();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('none').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
foreach ($values as $value) {
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.' ('.($value->active ? 'on' : 'off').')</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCategoriesOptions($ids = array(), $all = true){
|
||||
public static function getCategoriesOptions($ids = [], $all = true)
|
||||
{
|
||||
$values = Category::where('active', 1)->orderBy('pos', 'DESC')->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('none').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
foreach ($values as $value) {
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getProductIngredientsOptions($has_ids = array(), $all = true){
|
||||
public static function getProductIngredientsOptions($has_ids = [], $all = true)
|
||||
{
|
||||
$values = Ingredient::where('active', 1)->get();
|
||||
$ret = "";
|
||||
$attr = "";
|
||||
foreach ($values as $value){
|
||||
if(!in_array($value->id, $has_ids)){
|
||||
$ret = '';
|
||||
$attr = '';
|
||||
foreach ($values as $value) {
|
||||
if (! in_array($value->id, $has_ids)) {
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAttributesOptions($ids = array(), $all = true){
|
||||
/**
|
||||
* Erzeugt Options für Bundle-Produkt-Auswahl
|
||||
* Filtert bereits enthaltene Produkte und das aktuelle Produkt selbst aus
|
||||
*
|
||||
* @param array $has_ids IDs der bereits enthaltenen Produkte
|
||||
* @param int|null $exclude_product_id ID des aktuellen Produkts (um Selbst-Referenz zu vermeiden)
|
||||
* @return string HTML Options
|
||||
*/
|
||||
public static function getProductBundleOptions($has_ids = [], $exclude_product_id = null)
|
||||
{
|
||||
$values = Product::where('active', 1)->orderBy('name')->get();
|
||||
$ret = '';
|
||||
foreach ($values as $value) {
|
||||
// Überspringe bereits enthaltene Produkte und das Produkt selbst
|
||||
if (! in_array($value->id, $has_ids) && $value->id != $exclude_product_id) {
|
||||
$label = $value->name;
|
||||
if ($value->number) {
|
||||
$label = $value->number.' - '.$value->name;
|
||||
}
|
||||
$ret .= '<option value="'.$value->id.'">'.htmlspecialchars($label).'</option>\n';
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAttributesOptions($ids = [], $all = true)
|
||||
{
|
||||
$values = Attribute::where('active', 1)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('none').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
foreach ($values as $value) {
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getUserLevelOptions($id = false, $all = true){
|
||||
public static function getUserLevelOptions($id = false, $all = true)
|
||||
{
|
||||
$values = UserLevel::where('active', 1)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('none').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
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 getCompanyOptions($company){
|
||||
$options = array(1 => __('business'), 0 => __('private'), );
|
||||
$ret = "";
|
||||
foreach ($options as $id => $value){
|
||||
public static function getCompanyOptions($company)
|
||||
{
|
||||
$options = [1 => __('business'), 0 => __('private')];
|
||||
$ret = '';
|
||||
foreach ($options as $id => $value) {
|
||||
$attr = ($id == $company) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$id.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getContriesWithMore($id, $all=true){#
|
||||
public static function getContriesWithMore($id, $all = true)
|
||||
{ //
|
||||
$values = Country::all();
|
||||
$counter = 1;
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if( $counter == 7){
|
||||
foreach ($values as $value) {
|
||||
if ($counter == 7) {
|
||||
$ret .= '<optgroup label="'.__('further countrie').'">';
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->getLocated().'</option>\n';
|
||||
|
||||
$counter ++;
|
||||
$counter++;
|
||||
}
|
||||
$ret .= '</optgroup>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getContriesCodes($id, $all=true){#
|
||||
public static function getContriesCodes($id, $all = true)
|
||||
{ //
|
||||
$values = Country::all();
|
||||
$counter = 1;
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
|
||||
}
|
||||
foreach ($values as $value){
|
||||
foreach ($values as $value) {
|
||||
|
||||
if(!$value->phone) continue;
|
||||
if( $counter == 7){
|
||||
if (! $value->phone) {
|
||||
continue;
|
||||
}
|
||||
if ($counter == 7) {
|
||||
$ret .= '<optgroup label="'.__('further countrie').'">';
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->phone.'('.$value->getLocated().')</option>\n';
|
||||
|
||||
$counter ++;
|
||||
$counter++;
|
||||
}
|
||||
$ret .= '</optgroup>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCountriesWithoutUsedShippings($all=true){#
|
||||
public static function getCountriesWithoutUsedShippings($all = true)
|
||||
{ //
|
||||
$values = Country::all();
|
||||
$country_ids = ShippingCountry::all()->pluck('country_id')->toArray();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if(!in_array($value->id, $country_ids)){
|
||||
foreach ($values as $value) {
|
||||
if (! in_array($value->id, $country_ids)) {
|
||||
$ret .= '<option value="'.$value->id.'">'.$value->getLocated().'</option>\n';
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCountryNameFormShipping($id){
|
||||
public static function getCountryNameFormShipping($id)
|
||||
{
|
||||
$value = ShippingCountry::find($id);
|
||||
if($value){
|
||||
if ($value) {
|
||||
return $value->country->getLocated();
|
||||
}
|
||||
return "not defined";
|
||||
|
||||
return 'not defined';
|
||||
}
|
||||
|
||||
public static function getCountriesForShipping($id, $all=false){#
|
||||
public static function getCountriesForShipping($id, $all = false)
|
||||
{ //
|
||||
$values = ShippingCountry::all();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
foreach ($values as $value) {
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->country->getLocated().'</option>\n';
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getSalutation($id){
|
||||
$values = array('mr' => __('MR'), 'ms' => __('MS'), 'di' => __('DIV'));
|
||||
$ret = "";
|
||||
public static function getSalutation($id)
|
||||
{
|
||||
$values = ['mr' => __('MR'), 'ms' => __('MS'), 'di' => __('DIV')];
|
||||
$ret = '';
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
foreach ($values as $key => $value){
|
||||
foreach ($values as $key => $value) {
|
||||
$attr = ($key == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getSalutationLang($id){
|
||||
$values = array('mr' => __('MR'), 'ms' => __('MS'), 'di' => __('DIV'));
|
||||
return (!empty($values[$id]) ? $values[$id] : '');
|
||||
public static function getSalutationLang($id)
|
||||
{
|
||||
$values = ['mr' => __('MR'), 'ms' => __('MS'), 'di' => __('DIV')];
|
||||
|
||||
return ! empty($values[$id]) ? $values[$id] : '';
|
||||
}
|
||||
|
||||
public static function getTaxSaleOptions($id){
|
||||
$values = array('1' => __('account.taxable_sales_1'), '2' => __('account.taxable_sales_2'));
|
||||
$ret = "";
|
||||
public static function getTaxSaleOptions($id)
|
||||
{
|
||||
$values = ['1' => __('account.taxable_sales_1'), '2' => __('account.taxable_sales_2')];
|
||||
$ret = '';
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
foreach ($values as $key => $value){
|
||||
foreach ($values as $key => $value) {
|
||||
$attr = ($key == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getMembersOptions($id, $all=false){
|
||||
public static function getMembersOptions($id, $all = false)
|
||||
{
|
||||
$values = User::where('active', '=', true)->where('blocked', '=', false)->where('payment_account', '>=', now())->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
foreach ($values as $value) {
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$to="";
|
||||
if($value->account){
|
||||
$to = $value->account->first_name." ".$value->account->last_name." | ";
|
||||
$to = '';
|
||||
if ($value->account) {
|
||||
$to = $value->account->first_name.' '.$value->account->last_name.' | ';
|
||||
}
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$to.$value->email.' #'.$value->account->m_account.'</option>\n';
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getUserCustomerOptions($id, $all=false){
|
||||
public static function getUserCustomerOptions($id, $all = false)
|
||||
{
|
||||
$values = ShoppingUser::select(['id', 'billing_firstname', 'billing_lastname', 'billing_email', 'number'])
|
||||
->where('shopping_users.member_id', '=', \Auth::user()->id)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret = '';
|
||||
if ($all) {
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
foreach ($values as $value) {
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$to = $value->billing_firstname." ".$value->billing_lastname." | ".$value->billing_email;
|
||||
$to = $value->billing_firstname.' '.$value->billing_lastname.' | '.$value->billing_email;
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$to.' #'.$value->number.'</option>\n';
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getOptionRange($select, $from=1, $to=50){
|
||||
public static function getOptionRange($select, $from = 1, $to = 50)
|
||||
{
|
||||
$values = range($from, $to);
|
||||
$ret = "";
|
||||
foreach ($values as $value){
|
||||
$ret = '';
|
||||
foreach ($values as $value) {
|
||||
$attr = ($value == $select) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue