mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:57:33 -05:00 
			
		
		
		
	Merge pull request #950 from codedge/#868-Configurable-start-of-week
Adding configuration for first day of the week
This commit is contained in:
		
						commit
						fd2155d10a
					
				@ -471,6 +471,7 @@ class AccountController extends BaseController
 | 
			
		||||
            'datetimeFormats' => Cache::get('datetimeFormats'),
 | 
			
		||||
            'currencies' => Cache::get('currencies'),
 | 
			
		||||
            'title' => trans('texts.localization'),
 | 
			
		||||
            'weekdays' => Utils::getTranslatedWeekdayNames(),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        return View::make('accounts.localization', $data);
 | 
			
		||||
@ -1270,6 +1271,7 @@ class AccountController extends BaseController
 | 
			
		||||
        $account->language_id = Input::get('language_id') ? Input::get('language_id') : 1; // English
 | 
			
		||||
        $account->military_time = Input::get('military_time') ? true : false;
 | 
			
		||||
        $account->show_currency_code = Input::get('show_currency_code') ? true : false;
 | 
			
		||||
        $account->start_of_week = Input::get('start_of_week') ? Input::get('start_of_week') : 0;
 | 
			
		||||
        $account->save();
 | 
			
		||||
 | 
			
		||||
        event(new UserSettingsChanged());
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,11 @@ use WePay;
 | 
			
		||||
 | 
			
		||||
class Utils
 | 
			
		||||
{
 | 
			
		||||
    private static $weekdayNames = [
 | 
			
		||||
        "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static function isRegistered()
 | 
			
		||||
    {
 | 
			
		||||
        return Auth::check() && Auth::user()->registered;
 | 
			
		||||
@ -1020,4 +1025,28 @@ class Utils
 | 
			
		||||
            return new WePay(null);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets an array of weekday names (in English)
 | 
			
		||||
     *
 | 
			
		||||
     * @see getTranslatedWeekdayNames()
 | 
			
		||||
     *
 | 
			
		||||
     * @return \Illuminate\Support\Collection
 | 
			
		||||
     */
 | 
			
		||||
    public static function getWeekdayNames()
 | 
			
		||||
    {
 | 
			
		||||
        return collect(static::$weekdayNames);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets an array of translated weekday names
 | 
			
		||||
     *
 | 
			
		||||
     * @return \Illuminate\Support\Collection
 | 
			
		||||
     */
 | 
			
		||||
    public static function getTranslatedWeekdayNames()
 | 
			
		||||
    {
 | 
			
		||||
        return collect(static::$weekdayNames)->transform(function ($day) {
 | 
			
		||||
             return trans('texts.'.strtolower($day));
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -79,6 +79,7 @@ class Account extends Eloquent
 | 
			
		||||
        'show_item_taxes',
 | 
			
		||||
        'default_tax_rate_id',
 | 
			
		||||
        'enable_second_tax_rate',
 | 
			
		||||
        'start_of_week',
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -1063,6 +1064,8 @@ class Account extends Eloquent
 | 
			
		||||
            $format = str_replace('g:i a', 'H:i', $format);
 | 
			
		||||
        }
 | 
			
		||||
        Session::put(SESSION_DATETIME_FORMAT, $format);
 | 
			
		||||
 | 
			
		||||
        Session::put('start_of_week', $this->start_of_week);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,34 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
use Illuminate\Database\Schema\Blueprint;
 | 
			
		||||
use Illuminate\Database\Migrations\Migration;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class AddStartOfWeekToAccountsTable
 | 
			
		||||
 */
 | 
			
		||||
class AddStartOfWeekToAccountsTable extends Migration
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Run the migrations.
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function up()
 | 
			
		||||
    {
 | 
			
		||||
        Schema::table('accounts', function (Blueprint $table) {
 | 
			
		||||
            $table->integer('start_of_week');
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Reverse the migrations.
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function down()
 | 
			
		||||
    {
 | 
			
		||||
        Schema::table('accounts', function (Blueprint $table) {
 | 
			
		||||
            $table->dropColumn('start_of_week');
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -1362,6 +1362,7 @@ $LANG = array(
 | 
			
		||||
    'failed_remove_payment_method' => 'Failed to remove the payment method',
 | 
			
		||||
    'gateway_exists' => 'This gateway already exists',
 | 
			
		||||
    'manual_entry' => 'Manual entry',
 | 
			
		||||
    'start_of_week' => 'Erster Tag der Woche',
 | 
			
		||||
 | 
			
		||||
    // Frequencies
 | 
			
		||||
    'freq_weekly' => 'wöchentlich',
 | 
			
		||||
 | 
			
		||||
@ -1362,6 +1362,7 @@ $LANG = array(
 | 
			
		||||
    'failed_remove_payment_method' => 'Failed to remove the payment method',
 | 
			
		||||
    'gateway_exists' => 'This gateway already exists',
 | 
			
		||||
    'manual_entry' => 'Manual entry',
 | 
			
		||||
    'start_of_week' => 'First day of the week',
 | 
			
		||||
 | 
			
		||||
    // Frequencies
 | 
			
		||||
    'freq_weekly' => 'Weekly',
 | 
			
		||||
 | 
			
		||||
@ -30,6 +30,8 @@
 | 
			
		||||
                    ->fromQuery($dateFormats) !!}
 | 
			
		||||
                {!! Former::select('datetime_format_id')->addOption('','')
 | 
			
		||||
                    ->fromQuery($datetimeFormats) !!}
 | 
			
		||||
                {!! Former::select('start_of_week')->addOption('','')
 | 
			
		||||
                    ->fromQuery($weekdays) !!}
 | 
			
		||||
                {!! Former::checkbox('military_time')->text(trans('texts.enable')) !!}
 | 
			
		||||
                {{-- Former::checkbox('show_currency_code')->text(trans('texts.enable')) --}}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -66,7 +66,8 @@
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                trackEvent('/error', errorMsg);
 | 
			
		||||
            } catch(err) {}
 | 
			
		||||
            } catch (err) {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
@ -92,19 +93,34 @@
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        /* Set the defaults for Bootstrap datepicker */
 | 
			
		||||
        $.extend(true, $.fn.datepicker.defaults, {
 | 
			
		||||
            weekStart: {{ Session::get('start_of_week') }}
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        /* This causes problems with some languages. ie, fr_CA
 | 
			
		||||
         var appLocale = '{{App::getLocale()}}';
 | 
			
		||||
        $.extend( true, $.fn.datepicker.defaults, {
 | 
			
		||||
			language: appLocale.replace("_", "-")
 | 
			
		||||
        });
 | 
			
		||||
         */
 | 
			
		||||
 | 
			
		||||
        @if (env('FACEBOOK_PIXEL'))
 | 
			
		||||
        <!-- Facebook Pixel Code -->
 | 
			
		||||
            !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
 | 
			
		||||
            n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
 | 
			
		||||
            n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
 | 
			
		||||
            t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
 | 
			
		||||
        !function (f, b, e, v, n, t, s) {
 | 
			
		||||
            if (f.fbq)return;
 | 
			
		||||
            n = f.fbq = function () {
 | 
			
		||||
                n.callMethod ?
 | 
			
		||||
                        n.callMethod.apply(n, arguments) : n.queue.push(arguments)
 | 
			
		||||
            };
 | 
			
		||||
            if (!f._fbq)f._fbq = n;
 | 
			
		||||
            n.push = n;
 | 
			
		||||
            n.loaded = !0;
 | 
			
		||||
            n.version = '2.0';
 | 
			
		||||
            n.queue = [];
 | 
			
		||||
            t = b.createElement(e);
 | 
			
		||||
            t.async = !0;
 | 
			
		||||
            t.src = v;
 | 
			
		||||
            s = b.getElementsByTagName(e)[0];
 | 
			
		||||
            s.parentNode.insertBefore(t, s)
 | 
			
		||||
        }(window,
 | 
			
		||||
                document, 'script', '//connect.facebook.net/en_US/fbevents.js');
 | 
			
		||||
 | 
			
		||||
        fbq('init', '{{ env('FACEBOOK_PIXEL') }}');
 | 
			
		||||
@ -125,7 +141,8 @@
 | 
			
		||||
        @else
 | 
			
		||||
        function fbq() {
 | 
			
		||||
            // do nothing
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
        ;
 | 
			
		||||
        @endif
 | 
			
		||||
 | 
			
		||||
                window._fbq = window._fbq || [];
 | 
			
		||||
@ -147,23 +164,40 @@
 | 
			
		||||
 | 
			
		||||
@if (isset($_ENV['TAG_MANAGER_KEY']) && $_ENV['TAG_MANAGER_KEY'])
 | 
			
		||||
    <!-- Google Tag Manager -->
 | 
			
		||||
    <noscript><iframe src="//www.googletagmanager.com/ns.html?id={{ $_ENV['TAG_MANAGER_KEY'] }}"
 | 
			
		||||
        height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
 | 
			
		||||
        <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
 | 
			
		||||
            new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
 | 
			
		||||
        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
 | 
			
		||||
        '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
 | 
			
		||||
    <noscript>
 | 
			
		||||
        <iframe src="//www.googletagmanager.com/ns.html?id={{ $_ENV['TAG_MANAGER_KEY'] }}"
 | 
			
		||||
                height="0" width="0" style="display:none;visibility:hidden"></iframe>
 | 
			
		||||
    </noscript>
 | 
			
		||||
    <script>(function (w, d, s, l, i) {
 | 
			
		||||
            w[l] = w[l] || [];
 | 
			
		||||
            w[l].push({
 | 
			
		||||
                'gtm.start': new Date().getTime(), event: 'gtm.js'
 | 
			
		||||
            });
 | 
			
		||||
            var f = d.getElementsByTagName(s)[0],
 | 
			
		||||
                    j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
 | 
			
		||||
            j.async = true;
 | 
			
		||||
            j.src =
 | 
			
		||||
                    '//www.googletagmanager.com/gtm.js?id=' + i + dl;
 | 
			
		||||
            f.parentNode.insertBefore(j, f);
 | 
			
		||||
        })(window, document, 'script', 'dataLayer', '{{ $_ENV['TAG_MANAGER_KEY'] }}');</script>
 | 
			
		||||
    <!-- End Google Tag Manager -->
 | 
			
		||||
 | 
			
		||||
    <script>
 | 
			
		||||
        function trackEvent(category, action) {}
 | 
			
		||||
        function trackEvent(category, action) {
 | 
			
		||||
        }
 | 
			
		||||
    </script>
 | 
			
		||||
@elseif (isset($_ENV['ANALYTICS_KEY']) && $_ENV['ANALYTICS_KEY'])
 | 
			
		||||
    <script>
 | 
			
		||||
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
 | 
			
		||||
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
 | 
			
		||||
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 | 
			
		||||
        (function (i, s, o, g, r, a, m) {
 | 
			
		||||
            i['GoogleAnalyticsObject'] = r;
 | 
			
		||||
            i[r] = i[r] || function () {
 | 
			
		||||
                        (i[r].q = i[r].q || []).push(arguments)
 | 
			
		||||
                    }, i[r].l = 1 * new Date();
 | 
			
		||||
            a = s.createElement(o),
 | 
			
		||||
                    m = s.getElementsByTagName(o)[0];
 | 
			
		||||
            a.async = 1;
 | 
			
		||||
            a.src = g;
 | 
			
		||||
            m.parentNode.insertBefore(a, m)
 | 
			
		||||
        })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
 | 
			
		||||
 | 
			
		||||
        ga('create', '{{ $_ENV['ANALYTICS_KEY'] }}', 'auto');
 | 
			
		||||
@ -175,7 +209,8 @@
 | 
			
		||||
    </script>
 | 
			
		||||
@else
 | 
			
		||||
    <script>
 | 
			
		||||
        function trackEvent(category, action) {}
 | 
			
		||||
        function trackEvent(category, action) {
 | 
			
		||||
        }
 | 
			
		||||
    </script>
 | 
			
		||||
@endif
 | 
			
		||||
 | 
			
		||||
@ -191,7 +226,10 @@
 | 
			
		||||
 | 
			
		||||
        @if (Session::has('trackEventCategory') && Session::has('trackEventAction'))
 | 
			
		||||
            @if (Session::get('trackEventAction') === '/buy_pro_plan')
 | 
			
		||||
                window._fbq.push(['track', '{{ env('FACEBOOK_PIXEL_BUY_PRO') }}', {'value':'{{ session('trackEventAmount') }}','currency':'USD'}]);
 | 
			
		||||
                window._fbq.push(['track', '{{ env('FACEBOOK_PIXEL_BUY_PRO') }}', {
 | 
			
		||||
            'value': '{{ session('trackEventAmount') }}',
 | 
			
		||||
            'currency': 'USD'
 | 
			
		||||
        }]);
 | 
			
		||||
        @endif
 | 
			
		||||
        @endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -178,7 +178,8 @@
 | 
			
		||||
                $(element).datetimepicker({
 | 
			
		||||
                    value: current_time
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            },
 | 
			
		||||
            dayOfWeekStart: {{ Session::get('start_of_week') }}
 | 
			
		||||
         });
 | 
			
		||||
 | 
			
		||||
         $(element).change(function() {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user