DHL Modul v0.5 Shipping Label ok
This commit is contained in:
parent
480fdc65ed
commit
8fdaa0ba1d
122 changed files with 17938 additions and 2239 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Country;
|
||||
|
|
@ -13,7 +14,7 @@ class Util
|
|||
{
|
||||
|
||||
private static $postRoute = 'base.';
|
||||
|
||||
|
||||
public static function getToken()
|
||||
{
|
||||
return hash_hmac('sha256', Str::random(40), config('app.key'));
|
||||
|
|
@ -23,87 +24,95 @@ class Util
|
|||
{
|
||||
$uuid = (string) Str::uuid();
|
||||
$e_uuid = explode("-", $uuid);
|
||||
if(isset($e_uuid[0]) && $e_uuid[1]){
|
||||
return $e_uuid[0]."-".$e_uuid[1];
|
||||
|
||||
if (isset($e_uuid[0]) && $e_uuid[1]) {
|
||||
return $e_uuid[0] . "-" . $e_uuid[1];
|
||||
}
|
||||
return $uuid;
|
||||
}
|
||||
|
||||
public static function formatDate(){
|
||||
if(\App::getLocale() === "en"){
|
||||
public static function formatDate()
|
||||
{
|
||||
if (\App::getLocale() === "en") {
|
||||
return 'yyyy-mm-dd';
|
||||
}
|
||||
return 'dd.mm.yyyy';
|
||||
|
||||
}
|
||||
|
||||
public static function formatDateDB(){
|
||||
if(\App::getLocale() === "en"){
|
||||
public static function formatDateDB()
|
||||
{
|
||||
if (\App::getLocale() === "en") {
|
||||
return 'Y-m-d';
|
||||
}
|
||||
return 'd.m.Y';
|
||||
}
|
||||
|
||||
public static function formatDateTimeDB(){
|
||||
if(\App::getLocale() === "en"){
|
||||
public static function formatDateTimeDB()
|
||||
{
|
||||
if (\App::getLocale() === "en") {
|
||||
return 'Y-m-d - H:i';
|
||||
}
|
||||
return 'd.m.Y - H:i';
|
||||
}
|
||||
|
||||
public static function _format_number($value){
|
||||
public static function _format_number($value)
|
||||
{
|
||||
return preg_replace("/[^0-9,-]/", "", $value);
|
||||
|
||||
}
|
||||
|
||||
public static function _thousands_separator(){
|
||||
return \App::getLocale() === "en" ? ',' : '.';
|
||||
public static function _thousands_separator()
|
||||
{
|
||||
return \App::getLocale() === "en" ? ',' : '.';
|
||||
}
|
||||
|
||||
public static function _decimal_separator(){
|
||||
return \App::getLocale() === "en" ? '.' : ',';
|
||||
public static function _decimal_separator()
|
||||
{
|
||||
return \App::getLocale() === "en" ? '.' : ',';
|
||||
}
|
||||
|
||||
|
||||
public static function maxStrLength($str, $length = 40){
|
||||
public static function maxStrLength($str, $length = 40)
|
||||
{
|
||||
|
||||
if(strlen($str) > $length){
|
||||
if (strlen($str) > $length) {
|
||||
$str = substr($str, 0, $length);
|
||||
//$str = substr($str, 0, strrpos($str, " "));
|
||||
$str = $str." ...";
|
||||
$str = $str . " ...";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
public static function reFormatNumber($value){
|
||||
|
||||
public static function reFormatNumber($value)
|
||||
{
|
||||
return (float) str_replace(',', '.', self::_format_number($value));
|
||||
}
|
||||
|
||||
public static function formatNumber($value, $dec=2){
|
||||
public static function formatNumber($value, $dec = 2)
|
||||
{
|
||||
$value = floatval(str_replace(',', '', $value));
|
||||
return number_format($value, $dec, self::_decimal_separator(), self::_thousands_separator());
|
||||
|
||||
}
|
||||
public static function cleanIntegerFromString($value) {
|
||||
public static function cleanIntegerFromString($value)
|
||||
{
|
||||
// Entferne alle nicht-numerischen Zeichen außer Minus
|
||||
$cleanStr = preg_replace("/[^0-9-]/", "", $value);
|
||||
|
||||
|
||||
// Konvertiere zu Integer und entferne führende Nullen
|
||||
$number = (int)$cleanStr;
|
||||
|
||||
|
||||
return $number;
|
||||
}
|
||||
public static function cleanNumberFormat($num = 0, $dec = 2, $fullzero = false){
|
||||
|
||||
if($fullzero && $num == 0){
|
||||
public static function cleanNumberFormat($num = 0, $dec = 2, $fullzero = false)
|
||||
{
|
||||
|
||||
if ($fullzero && $num == 0) {
|
||||
return number_format($num, $dec, self::_decimal_separator(), self::_thousands_separator());
|
||||
}
|
||||
return rtrim(rtrim(number_format($num, $dec, self::_decimal_separator(), self::_thousands_separator()),'0'), self::_decimal_separator());
|
||||
return rtrim(rtrim(number_format($num, $dec, self::_decimal_separator(), self::_thousands_separator()), '0'), self::_decimal_separator());
|
||||
}
|
||||
|
||||
public static function utf8ize( $mixed ) {
|
||||
public static function utf8ize($mixed)
|
||||
{
|
||||
if (is_array($mixed)) {
|
||||
foreach ($mixed as $key => $value) {
|
||||
$mixed[$key] = self::utf8ize($value);
|
||||
|
|
@ -115,14 +124,17 @@ class Util
|
|||
}
|
||||
|
||||
|
||||
public static function getPostRoute(){
|
||||
public static function getPostRoute()
|
||||
{
|
||||
return self::$postRoute;
|
||||
}
|
||||
public static function setPostRoute($postRoute){
|
||||
public static function setPostRoute($postRoute)
|
||||
{
|
||||
self::$postRoute = $postRoute;
|
||||
}
|
||||
|
||||
public static function getUserShop(){
|
||||
public static function getUserShop()
|
||||
{
|
||||
$shop = session('user_shop');
|
||||
if (empty($shop) || !is_object($shop)) {
|
||||
return null;
|
||||
|
|
@ -130,17 +142,19 @@ class Util
|
|||
return $shop;
|
||||
}
|
||||
|
||||
public static function getDefaultUserShop(){
|
||||
public static function getDefaultUserShop()
|
||||
{
|
||||
$user = \App\User::find(6);
|
||||
if($user && $user->shop){
|
||||
if ($user && $user->shop) {
|
||||
return $user->shop;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getAuthUser(){
|
||||
if(\Session::has('auth_user')){
|
||||
if($auth_user = \Session::get('auth_user')){
|
||||
public static function getAuthUser()
|
||||
{
|
||||
if (\Session::has('auth_user')) {
|
||||
if ($auth_user = \Session::get('auth_user')) {
|
||||
return $auth_user;
|
||||
}
|
||||
}
|
||||
|
|
@ -148,91 +162,102 @@ class Util
|
|||
}
|
||||
|
||||
|
||||
public static function getUserShopIdentifier(){
|
||||
if(\Session::has('user_shop_identifier')){
|
||||
if($user_shop_identifier = \Session::get('user_shop_identifier')){
|
||||
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 getInstanceStatus(){
|
||||
public static function getInstanceStatus()
|
||||
{
|
||||
$identifier = self::getUserShopIdentifier();
|
||||
if($identifier && \Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6){
|
||||
if ($identifier && \Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6) {
|
||||
return OrderPaymentService::getInstanceStatus($identifier);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setInstanceStatus($status, $lower = true){
|
||||
public static function setInstanceStatus($status, $lower = true)
|
||||
{
|
||||
$identifier = self::getUserShopIdentifier();
|
||||
if($identifier && \Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6){
|
||||
if ($identifier && \Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6) {
|
||||
OrderPaymentService::updateInstanceStatus($identifier, $status, $lower);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setInstanceStatusByPayment($shopping_payment, $status, $lower = true){
|
||||
if($shopping_payment->identifier){
|
||||
public static function setInstanceStatusByPayment($shopping_payment, $status, $lower = true)
|
||||
{
|
||||
if ($shopping_payment->identifier) {
|
||||
OrderPaymentService::updateInstanceStatus($shopping_payment->identifier, $status, $lower);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getShoppingInstance(){
|
||||
if(\Session::has('shopping_instance')){
|
||||
public static function getShoppingInstance()
|
||||
{
|
||||
if (\Session::has('shopping_instance')) {
|
||||
return \Session::get('shopping_instance');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getUserHistory(){
|
||||
public static function getUserHistory()
|
||||
{
|
||||
$auth_user = self::getAuthUser();
|
||||
$user_shop_identifier = self::getUserShopIdentifier();
|
||||
if($user_shop_identifier && $auth_user){
|
||||
if ($user_shop_identifier && $auth_user) {
|
||||
return UserHistory::whereUserId($auth_user->id)->whereIdentifier($user_shop_identifier)->get()->last();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setUserHistoryValue($values = []){
|
||||
if($user_history = self::getUserHistory()){
|
||||
foreach ($values as $key=>$val){
|
||||
public static function setUserHistoryValue($values = [])
|
||||
{
|
||||
if ($user_history = self::getUserHistory()) {
|
||||
foreach ($values as $key => $val) {
|
||||
$user_history->{$key} = $val;
|
||||
}
|
||||
$user_history->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getUserHistoryValue($key){
|
||||
if($user_history = self::getUserHistory()) {
|
||||
public static function getUserHistoryValue($key)
|
||||
{
|
||||
if ($user_history = self::getUserHistory()) {
|
||||
return $user_history->{$key};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getUserShoppingMode(){
|
||||
if($auth_user = self::getAuthUser()){
|
||||
if($auth_user->isTestMode()){
|
||||
public static function getUserShoppingMode()
|
||||
{
|
||||
if ($auth_user = self::getAuthUser()) {
|
||||
if ($auth_user->isTestMode()) {
|
||||
return 'test';
|
||||
}
|
||||
}
|
||||
return config('app.mode');
|
||||
}
|
||||
public static function addRoute($p = []){
|
||||
public static function addRoute($p = [])
|
||||
{
|
||||
$b = [];
|
||||
if(\Session::has('user_shop')){
|
||||
if($user_shop = \Session::get('user_shop')){
|
||||
if (\Session::has('user_shop')) {
|
||||
if ($user_shop = \Session::get('user_shop')) {
|
||||
$b = ['subdomain' => $user_shop->slug];
|
||||
}
|
||||
}
|
||||
return array_merge($p, $b);
|
||||
}
|
||||
|
||||
public static function checkUserLandIsNot($user){
|
||||
public static function checkUserLandIsNot($user)
|
||||
{
|
||||
|
||||
if(isset($user->account->country_id)){
|
||||
if (isset($user->account->country_id)) {
|
||||
//ch schweiz is out
|
||||
if($user->account->country_id === 6){
|
||||
if ($user->account->country_id === 6) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -241,9 +266,10 @@ class Util
|
|||
}
|
||||
|
||||
|
||||
public static function getMyMivitaShopUrl($add_url = ""){
|
||||
if(\Session::has('user_shop_domain')){
|
||||
$url = \Session::get('user_shop_domain').$add_url;
|
||||
public static function getMyMivitaShopUrl($add_url = "")
|
||||
{
|
||||
if (\Session::has('user_shop_domain')) {
|
||||
$url = \Session::get('user_shop_domain') . $add_url;
|
||||
if (!str_starts_with($url, 'http')) {
|
||||
$url = 'https://' . ltrim($url, '/');
|
||||
}
|
||||
|
|
@ -251,83 +277,90 @@ class Util
|
|||
}
|
||||
//alois sein shop
|
||||
$user = \App\User::find(6);
|
||||
if($user && $user->shop){
|
||||
return config('app.protocol').$user->shop->slug.".".config('app.domain').config('app.tld_care').$add_url;
|
||||
if ($user && $user->shop) {
|
||||
return config('app.protocol') . $user->shop->slug . "." . config('app.domain') . config('app.tld_care') . $add_url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getMyMivitaPortalUrl($protocol = true){
|
||||
public static function getMyMivitaPortalUrl($protocol = true)
|
||||
{
|
||||
$pro = $protocol ? config('app.protocol') : "";
|
||||
return $pro.config('app.pre_url_portal').config('app.domain').config('app.tld_care');
|
||||
return $pro . config('app.pre_url_portal') . config('app.domain') . config('app.tld_care');
|
||||
}
|
||||
public static function getMyMivitaUrl($protocol = true){
|
||||
public static function getMyMivitaUrl($protocol = true)
|
||||
{
|
||||
$pro = $protocol ? config('app.protocol') : "";
|
||||
return $pro.config('app.pre_url_crm').config('app.domain').config('app.tld_care');
|
||||
return $pro . config('app.pre_url_crm') . config('app.domain') . config('app.tld_care');
|
||||
}
|
||||
|
||||
public static function getUserPaymentFor($instance = 'shopping'){
|
||||
if(Yard::instance($instance)->getYardExtra('user_shop_payment')){
|
||||
public static function getUserPaymentFor($instance = 'shopping')
|
||||
{
|
||||
if (Yard::instance($instance)->getYardExtra('user_shop_payment')) {
|
||||
return Yard::instance($instance)->getYardExtra('user_shop_payment');
|
||||
}
|
||||
if(\Session::has('user_shop_payment')){
|
||||
if (\Session::has('user_shop_payment')) {
|
||||
return \Session::get('user_shop_payment');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getUserShopBackUrl($reference = ""){
|
||||
public static function getUserShopBackUrl($reference = "")
|
||||
{
|
||||
|
||||
if(\Session::has('user_shop')){
|
||||
if(\Session::has('user_shop_domain')){
|
||||
if (\Session::has('user_shop')) {
|
||||
if (\Session::has('user_shop_domain')) {
|
||||
return \Session::get('user_shop_domain');
|
||||
}
|
||||
if($user_shop = \Session::get('user_shop')){
|
||||
return config('app.protocol').$user_shop->slug.".".config('app.domain').config('app.tld_care')."/back/to/shop/".$reference;
|
||||
if ($user_shop = \Session::get('user_shop')) {
|
||||
return config('app.protocol') . $user_shop->slug . "." . config('app.domain') . config('app.tld_care') . "/back/to/shop/" . $reference;
|
||||
}
|
||||
}
|
||||
return config('app.protocol').config('app.domain').config('app.tld_care');
|
||||
return config('app.protocol') . config('app.domain') . config('app.tld_care');
|
||||
}
|
||||
|
||||
public static function getUserCardBackUrl($uri, $instance = 'shopping'){
|
||||
public static function getUserCardBackUrl($uri, $instance = 'shopping')
|
||||
{
|
||||
|
||||
if(\Session::has('user_shop')){
|
||||
if(\Session::has('user_shop_domain')){
|
||||
if(\Session::has('back_link')){
|
||||
if (\Session::has('user_shop')) {
|
||||
if (\Session::has('user_shop_domain')) {
|
||||
if (\Session::has('back_link')) {
|
||||
return \Session::get('back_link');
|
||||
}
|
||||
if(self::getUserPaymentFor($instance) === 3){
|
||||
return \Session::get('user_shop_domain')."/user/membership";
|
||||
if (self::getUserPaymentFor($instance) === 3) {
|
||||
return \Session::get('user_shop_domain') . "/user/membership";
|
||||
}
|
||||
if(self::getUserPaymentFor($instance) === 2){
|
||||
return \Session::get('user_shop_domain')."/user/orders";
|
||||
if (self::getUserPaymentFor($instance) === 2) {
|
||||
return \Session::get('user_shop_domain') . "/user/orders";
|
||||
}
|
||||
return \Session::get('user_shop_domain');
|
||||
}
|
||||
if($user_shop = \Session::get('user_shop')){
|
||||
return config('app.protocol').$user_shop->slug.".".config('app.domain').config('app.tld_care').$uri;
|
||||
if ($user_shop = \Session::get('user_shop')) {
|
||||
return config('app.protocol') . $user_shop->slug . "." . config('app.domain') . config('app.tld_care') . $uri;
|
||||
}
|
||||
}
|
||||
return config('app.protocol').config('app.domain').config('app.tld_care');
|
||||
return config('app.protocol') . config('app.domain') . config('app.tld_care');
|
||||
}
|
||||
|
||||
public static function isMivitaShop(){
|
||||
if(Request::getHost() === 'checkout.'.config('app.domain').config('app.tld_care')){
|
||||
if($user_shop = \Session::get('user_shop')){
|
||||
if($user_shop->slug === 'aloevera' || $user_shop->slug === 'naturcosmetic'){
|
||||
public static function isMivitaShop()
|
||||
{
|
||||
if (Request::getHost() === 'checkout.' . config('app.domain') . config('app.tld_care')) {
|
||||
if ($user_shop = \Session::get('user_shop')) {
|
||||
if ($user_shop->slug === 'aloevera' || $user_shop->slug === 'naturcosmetic') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Request::getHost() === 'naturcosmetic.'.config('app.domain').config('app.tld_care')){
|
||||
if (Request::getHost() === 'naturcosmetic.' . config('app.domain') . config('app.tld_care')) {
|
||||
return true;
|
||||
}
|
||||
return \Config::get('app.url') === config('app.domain').config('app.tld_shop');
|
||||
}
|
||||
return \Config::get('app.url') === config('app.domain') . config('app.tld_shop');
|
||||
}
|
||||
|
||||
public static function isTestSystem($dev = false){
|
||||
if(\Config::get('app.tld_care') === '.test' || \Config::get('app.tld_shop') === '.lshop'){
|
||||
if($dev && config('app.debug') !== true){
|
||||
public static function isTestSystem($dev = false)
|
||||
{
|
||||
if (\Config::get('app.tld_care') === '.test' || \Config::get('app.tld_shop') === '.lshop') {
|
||||
if ($dev && config('app.debug') !== true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -347,25 +380,61 @@ class Util
|
|||
return $size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function sanitize($string, $force_lowercase = true, $anal = false, $substr = false)
|
||||
{
|
||||
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
|
||||
"}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—",
|
||||
"—", "–", ",", "<", ".", ">", "/", "?");
|
||||
$strip = array(
|
||||
"~",
|
||||
"`",
|
||||
"!",
|
||||
"@",
|
||||
"#",
|
||||
"$",
|
||||
"%",
|
||||
"^",
|
||||
"&",
|
||||
"*",
|
||||
"(",
|
||||
")",
|
||||
"_",
|
||||
"=",
|
||||
"+",
|
||||
"[",
|
||||
"{",
|
||||
"]",
|
||||
"}",
|
||||
"\\",
|
||||
"|",
|
||||
";",
|
||||
":",
|
||||
"\"",
|
||||
"'",
|
||||
"‘",
|
||||
"’",
|
||||
"“",
|
||||
"”",
|
||||
"–",
|
||||
"—",
|
||||
"—",
|
||||
"–",
|
||||
",",
|
||||
"<",
|
||||
".",
|
||||
">",
|
||||
"/",
|
||||
"?"
|
||||
);
|
||||
$clean = trim(str_replace($strip, "", strip_tags($string)));
|
||||
$clean = preg_replace('/\s+/', "_", $clean);
|
||||
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
|
||||
|
||||
if($substr){
|
||||
$clean = (strlen($clean) > 20) ? substr($clean,-20) : $clean;
|
||||
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean;
|
||||
|
||||
if ($substr) {
|
||||
$clean = (strlen($clean) > 20) ? substr($clean, -20) : $clean;
|
||||
}
|
||||
return ($force_lowercase) ?
|
||||
(function_exists('mb_strtolower')) ?
|
||||
mb_strtolower($clean, 'UTF-8') :
|
||||
strtolower($clean) :
|
||||
mb_strtolower($clean, 'UTF-8') :
|
||||
strtolower($clean) :
|
||||
$clean;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue