add shipping rules

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 14:45:42 +02:00
parent 297dcc62d2
commit 39c80ce6d1
459 changed files with 6219 additions and 5416 deletions

View File

@@ -7,6 +7,7 @@ use Carbon\Carbon;
class Stat
{
public static $is_debug = false;
public static $force_output = true;
public static function getNewByPeriod($model, $start, $end)
@@ -45,6 +46,7 @@ class Stat
$var_option = $var;
}
$options = self::getOption($var_option);
return self::getStatsbyMultiOptions($var, $options);
}
@@ -53,6 +55,7 @@ class Stat
$count = self::getModel()
->whereBetween($var, $begin, $end)
->count();
return $count;
}
@@ -64,10 +67,9 @@ class Stat
->groupBy($var)
->get();
// var_Debug::message($data);
return ($data);
return $data;
}
public static function getStatsbyOptions($var, $var_option = '')
{
if (empty($var_option)) {
@@ -81,7 +83,7 @@ class Stat
$data[] = ['y' => $y, 'name' => $value];
}
// var_Debug::message($data);
return ($data);
return $data;
}
public static function getCountbyOption($var)
@@ -98,7 +100,8 @@ class Stat
$data[$key] = (int) $data[$key]->nb;
}
}
return ($data);
return $data;
}
public static function getStatsbyMultiOptions($var, $options)
@@ -107,7 +110,8 @@ class Stat
$nb = self::getCountbyBin($var, $key);
$data[] = ['y' => $nb, 'name' => $value];
}
return ($data);
return $data;
}
public static function getCountbyBin($var, $value)
@@ -116,27 +120,28 @@ class Stat
$count = self::getModel()
->where($var, '&', $bit)
->count();
return $count;
}
public static function getStatsbyPeriod($begin = '', $end = '', $period = 'days')
{
$end = Carbon::now();
$begin = Carbon::now()->subMonth(1);
switch ($period) {
case 'days':
$periods = DateRange::getPeriodsbyDay($begin, $end);
break;
case 'months':
$periods = DateRange::getPeriodsbyMonth($begin, $end);
break;
case 'weeks':
$periods = DateRange::getPeriodsbyWeek($begin, $end);
break;
default:
case 'days':
$periods = DateRange::getPeriodsbyDay($begin, $end);
break;
case 'months':
$periods = DateRange::getPeriodsbyMonth($begin, $end);
break;
case 'weeks':
$periods = DateRange::getPeriodsbyWeek($begin, $end);
break;
default:
}
return ($periods);
return $periods;
}
public static function serializeValues($tab)
@@ -154,7 +159,7 @@ class Stat
$tab = $collection->pluck($var)->toArray();
}
return implode(",", $tab);
return implode(',', $tab);
}
public static function avgByVar($tab, $var)