Plugin Directory

Changeset 2258787


Ignore:
Timestamp:
03/11/2020 08:10:33 AM (6 years ago)
Author:
hitcode
Message:

4.5.9

Location:
shiftcontroller/trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • shiftcontroller/trunk/hc3/_wordpress/abstract/plugin.php

    r2241596 r2258787  
    7171        $lang = $settings->get('lang');
    7272
     73    // Polylang plugin
    7374        if( function_exists('pll_current_language') ){
    7475            $lang = pll_current_language( 'locale' );
  • shiftcontroller/trunk/hc3/_wordpress/ui/element/input/richtextarea.php

    r2182610 r2258787  
    5757
    5858        $out = ob_get_clean();
     59
     60        if( strlen($this->label) ){
     61            $out = $this->htmlFactory->makeLabelled( $this->label, $out, $this->htmlId() );
     62        }
     63
    5964        return $out;
    6065    }
  • shiftcontroller/trunk/hc3/assets/js/hc2.js

    r2212879 r2258787  
    131131        // parse default value
    132132        var this_value = $hidden.val();
    133 
     133        self.default_duration = 5 * 60;
    134134        self.input_value = [];
    135135
     
    138138            for( var jj = 0; jj < this_times.length; jj++ ){
    139139                self.input_value.push( parseInt(this_times[jj]) );
     140            }
     141
     142            if( 2 == this_times.length ){
     143                self.default_duration = parseInt(this_times[1]) - parseInt(this_times[0]);
    140144            }
    141145        }
     
    207211
    208212            var current_end = self.input_value[1] ? self.input_value[1] : $input_end.val();
     213            current_end = start + self.default_duration;
    209214            current_end = parseInt( current_end );
    210215
  • shiftcontroller/trunk/readme.txt

    r2241596 r2258787  
    55Stable tag: trunk
    66Requires at least: 4.1
    7 Tested up to: 5.3
     7Tested up to: 5.4
    88Requires PHP: 5.3
    99
     
    6060
    6161== Changelog ==
     62
     63= 4.5.9 =
     64* Added label for textarea custom field in the admin area.
     65* When creating a shift or assigning new or another employee, unavailable employees are displayed below available ones.
     66* Added a setting for default shift duration.
     67* In the admin calendars list view we added the quantity of notifications and permission options enabled for each calendar.
     68* The schedule view remembers last filtered calendars and employees.
    6269
    6370= 4.5.8 =
  • shiftcontroller/trunk/sh4/app/boot.php

    r2221157 r2258787  
    2828            ->init( 'datetime_max_time', 24*60*60 )
    2929            ->init( 'datetime_step', 5*60 )
    30 
    31             ->init( 'shifttypes_nobreak', FALSE )
    3230
    3331            ->init( 'datetime_hide_schedule_reports', 0 )
  • shiftcontroller/trunk/sh4/calendars/boot.php

    r2107416 r2258787  
    4646            ->register( 'post:admin/calendars/{id}/shifttypes', array('SH4_Calendars_Html_Admin_Controller_ShiftTypes', 'execute') )
    4747
     48            ->register( 'get:admin/calendars/{id}/shifttypes/{new}', array('SH4_Calendars_Html_Admin_View_ShiftTypes', 'render') )
     49            ->register( 'post:admin/calendars/{id}/shifttypes/{new}', array('SH4_Calendars_Html_Admin_Controller_ShiftTypes', 'execute') )
     50
    4851            ->register( 'get:admin/calendars/{id}/prm', array('SH4_Calendars_Html_Admin_View_Permissions', 'render') )
    4952            ->register( 'post:admin/calendars/{id}/prm', array('SH4_Calendars_Html_Admin_Controller_Permissions', 'execute') )
  • shiftcontroller/trunk/sh4/calendars/html/admin/controller/new.php

    r1909721 r2258787  
    2222        $newId = $this->command->create( $title, $color, $description, $type );
    2323
    24         $to = 'admin/calendars/' . $newId . '/shifttypes';
     24        $to = 'admin/calendars/' . $newId . '/shifttypes/new';
    2525        $return = array( $to, array('__New Calendar Added__') );
    2626        return $return;
  • shiftcontroller/trunk/sh4/calendars/html/admin/controller/shifttypes.php

    r1851180 r2258787  
    2222    }
    2323
    24     public function execute( $calendarId )
     24    public function execute( $calendarId, $new = FALSE )
    2525    {
    2626        $calendar = $this->calendarsQuery->findById( $calendarId );
     
    5151        }
    5252
    53         $return = array( 'admin/calendars', '__Calendar Updated__' );
     53        if( $new ){
     54            $to = 'admin/calendars/' . $calendarId . '/prm';
     55        }
     56        else {
     57            $to = 'admin/calendars';
     58        }
     59
     60        $return = array( $to, array('__Calendar Updated__') );
     61
    5462        return $return;
    5563    }
  • shiftcontroller/trunk/sh4/calendars/html/admin/view/index.php

    r2107416 r2258787  
    1414        SH4_Calendars_Query $calendarsQuery,
    1515        SH4_Calendars_Presenter $calendarsPresenter,
     16        SH4_Calendars_Permissions $calendarsPermissions,
     17
     18        SH4_Notifications_Service $notificationsService,
    1619
    1720        SH4_Employees_Query $employees
     
    2831        $this->calendarsQuery = $hooks->wrap( $calendarsQuery );
    2932        $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
     33        $this->calendarsPermissions = $hooks->wrap( $calendarsPermissions );
    3034
    3135        $this->employees = $hooks->wrap($employees);
     36        $this->notificationsService = $hooks->wrap( $notificationsService );
    3237
    3338        $this->self = $hooks->wrap($this);
     
    238243            );
    239244
    240         $return['notifications'] = array( 'admin/notifications/' . $id, '__Notifications__');
    241         $return['permissions'] = array( 'admin/calendars/' . $id . '/prm', '__Permissions__');
     245        $allNotifications = $this->notificationsService->findAll();
     246        $allNotifications = array_keys( $allNotifications );
     247        $notificationsCount = 0;
     248        foreach( $allNotifications as $notificationId ){
     249            if( $this->notificationsService->isOn($model, $notificationId) ){
     250                $notificationsCount++;
     251            }
     252        }
     253        $label = '__Notifications__' . ' [' . $notificationsCount . ']';
     254
     255        $return['notifications'] = array( 'admin/notifications/' . $id, $label );
     256
     257        $allPermissionsOptions = $this->calendarsPermissions->categorizedOptions();
     258        $thisPermissionsOptions = $this->calendarsPermissions->getAll( $model );
     259
     260        $permissionCounts = array();
     261        foreach( $allPermissionsOptions as $group => $perms ){
     262            // $permissionCounts[ $group ] = array( 0, count($perms) );
     263            $permissionCounts[ $group ] = 0;
     264        }
     265
     266        foreach( $thisPermissionsOptions as $k => $v ){
     267            if( ! $v ){
     268                continue;
     269            }
     270
     271            $ka = explode( '_', $k );
     272            $group = $ka[0];
     273
     274            if( ! isset($allPermissionsOptions[$group]) ){
     275                continue;
     276            }
     277
     278            if( ! in_array($k, $allPermissionsOptions[$group]) ){
     279                continue;
     280            }
     281
     282            $permissionCounts[ $group ]++;
     283        }
     284        $permissionCountsView = join( '/', $permissionCounts );
     285
     286        $label = '__Permissions__' . ' [' . $permissionCountsView . ']';
     287        $return['permissions'] = array( 'admin/calendars/' . $id . '/prm', $label);
    242288
    243289        if( $model->isArchived() ){
  • shiftcontroller/trunk/sh4/calendars/html/admin/view/shifttypes.php

    r1854904 r2258787  
    2929    }
    3030
    31     public function render( $id )
     31    public function render( $id, $new = FALSE )
    3232    {
    3333        $model = $this->calendarsQuery->findById($id);
     
    7474        $out = $this->ui->makeList( array($out, $buttons) );
    7575
    76         $out = $this->ui->makeForm(
    77             'admin/calendars/' . $id . '/shifttypes',
    78             $out
    79             );
     76        $to = $new ? 'admin/calendars/' . $id . '/shifttypes/new' : 'admin/calendars/' . $id . '/shifttypes';
     77        $out = $this->ui->makeForm( $to, $out );
    8078
    8179        $this->layout
  • shiftcontroller/trunk/sh4/calendars/permissions.php

    r2217010 r2258787  
    55    public function get( SH4_Calendars_Model $calendar, $permissionId );
    66    public function getAll( SH4_Calendars_Model $calendar );
     7    public function options();
     8    public function categorizedOptions();
    79}
    810
     
    3537            }
    3638        }
     39    }
     40
     41    public function categorizedOptions()
     42    {
     43        $ret = array( 'employee' => array(), 'employee2' => array(), 'visitor' => array() );
     44
     45        $options = $this->self->options();
     46        foreach( $options as $o ){
     47            $label = array_shift( $o );
     48            $employeeOption = array_shift( $o );
     49            $visitorOption = array_shift( $o );
     50            $employee2Option = array_shift( $o );
     51            // list( $label, $employeeOption, $visitorOption ) = $o;
     52
     53            if( $employeeOption ){
     54                $ret['employee'][] = $employeeOption[0];
     55            }
     56            if( $visitorOption ){
     57                $ret['visitor'][] = $visitorOption[0];
     58            }
     59            if( $employee2Option ){
     60                $ret['employee2'][] = $employee2Option[0];
     61            }
     62        }
     63
     64        return $ret;
    3765    }
    3866
  • shiftcontroller/trunk/sh4/new/view/calendar.php

    r2149207 r2258787  
    1818        HC3_Hooks $hooks,
    1919
     20        HC3_Settings $settings,
    2021        HC3_Request $request,
    2122        HC3_Ui $ui,
     
    3637        $this->layout = $layout;
    3738        $this->common = $hooks->wrap($common);
     39        $this->settings = $hooks->wrap($settings);
    3840
    3941        $this->appQuery = $hooks->wrap( $appQuery );
     
    274276            $to = 'new/customtime/' . $calendarId;
    275277            $to = array( $to, $params );
    276             $thisForm = $this->ui->makeForm(
    277                 $to,
    278                 $this->ui->makeList()
    279                     // ->add( $this->ui->makeInputTimeRange( 'time', '__Time__' ) )
    280                     ->add( $this->ui->makeInputTimeRange( 'time', NULL ) )
    281                     ->add(
    282                         $this->ui->makeCollapseCheckbox(
    283                             'break_on',
    284                             '__Lunch Break__' . '?',
    285                             $this->ui->makeInputTimeRange( 'break', NULL)
    286                             )
    287                         )
    288                     ->add( $this->ui->makeInputSubmit( '__Continue__')->tag('secondary') )
    289                 );
     278
     279            $thisFormInputs = array();
     280
     281            $value = array();
     282            $minTime = $this->settings->get('datetime_min_time');
     283            $defaultDuration = $this->settings->get('shifttypes_default_duration');
     284            if( (NULL !== $minTime) && (NULL !== $defaultDuration) ){
     285                $value = array( $minTime, $minTime + $defaultDuration );
     286            }
     287            $thisFormInputs[] = $this->ui->makeInputTimeRange( 'time', NULL, $value );
     288
     289            $noBreak = $this->settings->get( 'shifttypes_nobreak' );
     290            if( ! $noBreak ){
     291                $thisFormInputs[] = $this->ui->makeCollapseCheckbox(
     292                    'break_on',
     293                    '__Lunch Break__' . '?',
     294                    $this->ui->makeInputTimeRange( 'break', NULL)
     295                    );
     296            }
     297
     298            $thisFormInputs[] = $this->ui->makeInputSubmit( '__Continue__')->tag('secondary');
     299
     300            $thisFormInputs = $this->ui->makeList( $thisFormInputs );
     301
     302            $thisForm = $this->ui->makeForm( $to, $thisFormInputs );
    290303
    291304            $thisForm = $this->ui->makeBlock( $thisForm )
  • shiftcontroller/trunk/sh4/new/view/employee.php

    r2107416 r2258787  
    128128
    129129        $employeesView = array();
     130        $employeesWithConflictsView = array();
    130131
    131132        foreach( $employees as $employee ){
     
    287288            }
    288289
    289             $employeesView[] = $thisView;
     290            if( $withConflicts ){
     291                $employeesWithConflictsView[] = $thisView;
     292            }
     293            else {
     294                $employeesView[] = $thisView;
     295            }
    290296        }
    291297
     
    298304
    299305        $employeesView = $this->ui->makeList( array($toggleAll, $employeesView) );
    300 
    301         $out = array( $employeesView );
    302 
    303         $btn = $this->self->buttons( $calendarId, $shiftTypeId );
    304         $btn = $this->ui->makeListInline( $btn );
    305 
    306     // open shift
    307         // $inputs = $this->common->inputs( $calendarId, $shiftTypeId, $employeeId );
    308         // $out = array_merge( $out, $inputs );
    309 
    310         $out[] = $btn;
    311 
    312         $out = $this->ui->makeList( $out )->gutter(3);
    313306
    314307        $js = <<<EOT
     
    331324EOT;
    332325
    333         $out = $this->ui->makeCollection( array($js, $out) );
    334         $out = $this->ui->makeBlock( $out )
     326        $employeesView = $this->ui->makeCollection( array($js, $employeesView) );
     327        $employeesView = $this->ui->makeBlock( $employeesView )
    335328            ->addAttr( 'class', 'sh4-new-employee-container' )
    336329            ;
     330
     331        $out = array();
     332        $out[] = $employeesView;
     333
     334        if( $employeesWithConflictsView ){
     335            $employeesWithConflictsView = $this->ui->makeGrid( $employeesWithConflictsView, 4 );
     336            $employeesWithConflictsView = $this->ui->makeCollapse( '__Unavailable Employees__', $employeesWithConflictsView );
     337            $out[] = $employeesWithConflictsView;
     338        }
     339
     340        $btn = $this->self->buttons( $calendarId, $shiftTypeId );
     341        $btn = $this->ui->makeListInline( $btn );
     342
     343    // open shift
     344        // $inputs = $this->common->inputs( $calendarId, $shiftTypeId, $employeeId );
     345        // $out = array_merge( $out, $inputs );
     346
     347        $out[] = $btn;
     348
     349        $out = $this->ui->makeList( $out )->gutter(3);
     350
     351
    337352
    338353        $to = 'new/employee';
  • shiftcontroller/trunk/sh4/schedule/html/view/index.php

    r2241596 r2258787  
    104104
    105105        $employee = array( $meEmployeeId );
    106         $calendar = array();
     106
     107        $calendar = $this->session->getUserdata('scheduleViewCalendar');
     108        if( ! $calendar ){
     109            $calendar = array();
     110        }
     111
    107112        $hideui = array(
    108113            'filter-employee',
     
    153158            ->setUserdata( 'scheduleViewType', $params['type'] )
    154159            ->setUserdata( 'scheduleViewGroupby', $params['groupby'] )
     160            // ->setUserdata( 'scheduleViewEmployee', $params['employee'] )
     161            ->setUserdata( 'scheduleViewCalendar', $params['calendar'] )
    155162            ;
    156163
     
    427434        }
    428435
    429         $employee = array();
    430         $calendar = array();
     436        $employee = $this->session->getUserdata('scheduleViewEmployee');
     437        if( ! $employee ){
     438            $employee = array();
     439        }
     440
     441        $calendar = $this->session->getUserdata('scheduleViewCalendar');
     442        if( ! $calendar ){
     443            $calendar = array();
     444        }
     445
    431446        $hideui = array();
    432447
     
    442457
    443458        $params = $this->request->getParams();
    444 
    445459        $params = array_merge( $defaultParams, $params );
    446460
     
    462476            ->setUserdata( 'scheduleViewType', $params['type'] )
    463477            ->setUserdata( 'scheduleViewGroupby', $params['groupby'] )
     478            ->setUserdata( 'scheduleViewEmployee', $params['employee'] )
     479            ->setUserdata( 'scheduleViewCalendar', $params['calendar'] )
    464480            ;
    465481
  • shiftcontroller/trunk/sh4/shifts/view/employee.php

    r1912260 r2258787  
    8787
    8888        $employeesView = array();
     89        $employeesWithConflictsView = array();
    8990
    9091        foreach( $employees as $employee ){
     
    223224            }
    224225
    225             $employeesView[] = $thisView;
    226         }
    227 
    228         if( $employeesView ){
     226            if( $withConflicts ){
     227                $employeesWithConflictsView[] = $thisView;
     228            }
     229            else {
     230                $employeesView[] = $thisView;
     231            }
     232        }
     233
     234        if( $employeesView OR $employeesWithConflictsView ){
     235
    229236            $out = $this->ui->makeGrid();
    230237            foreach( $employeesView as $ev ){
    231238                $out->add( $ev, 3, 12 );
     239            }
     240
     241            if( $employeesWithConflictsView ){
     242                $out = array( $out );
     243
     244                $employeesWithConflictsView = $this->ui->makeGrid( $employeesWithConflictsView, 4 );
     245                $employeesWithConflictsView = $this->ui->makeCollapse( '__Unavailable Employees__', $employeesWithConflictsView );
     246                $out[] = $employeesWithConflictsView;
     247
     248                $out = $this->ui->makeList( $out )->gutter(2);
    232249            }
    233250        }
  • shiftcontroller/trunk/sh4/shifttypes/boot.php

    r1857967 r2258787  
    1313        $settings
    1414            ->init( 'shifttypes_show_title', 1 )
     15            ->init( 'shifttypes_default_duration', 4*60*60 )
     16            ->init( 'shifttypes_nobreak', FALSE )
    1517            ;
    1618
  • shiftcontroller/trunk/sh4/shifttypes/html/admin/controller/settings.php

    r2212879 r2258787  
    1414    public function execute()
    1515    {
    16         $take = array( 'shifttypes_show_title', 'shifttypes_nobreak' );
     16        $take = array( 'shifttypes_show_title', 'shifttypes_nobreak', 'shifttypes_default_duration' );
    1717
    1818        foreach( $take as $k ){
  • shiftcontroller/trunk/sh4/shifttypes/html/admin/view/new.php

    r2212879 r2258787  
    4646        $inputs = array();
    4747        $inputs[] = $this->ui->makeInputText( 'title', '__Title__' )->bold();
    48         $inputs[] = $this->ui->makeInputTimeRange( 'time', '__Time__' );
     48
     49        $value = array();
     50        $minTime = $this->settings->get('datetime_min_time');
     51        $defaultDuration = $this->settings->get('shifttypes_default_duration');
     52        if( (NULL !== $minTime) && (NULL !== $defaultDuration) ){
     53            $value = array( $minTime, $minTime + $defaultDuration );
     54        }
     55        $inputs[] = $this->ui->makeInputTimeRange( 'time', '__Time__', $value );
    4956
    5057        $noBreak = $this->settings->get( 'shifttypes_nobreak' );
  • shiftcontroller/trunk/sh4/shifttypes/html/admin/view/settings.php

    r2212879 r2258787  
    2323    public function render()
    2424    {
    25         $pnames = array( 'shifttypes_show_title', 'shifttypes_nobreak' );
     25        $pnames = array( 'shifttypes_show_title', 'shifttypes_nobreak', 'shifttypes_default_duration' );
    2626        foreach( $pnames as $pname ){
    2727            $values[$pname] = $this->settings->get($pname);
     
    4141            1,
    4242            $values['shifttypes_nobreak']
     43            );
     44
     45        $options = range( 1, 24, 1 );
     46        $defaultDurationOptions = array();
     47        foreach( $options as $e ){
     48            $defaultDurationOptions[ $e*60*60 ] = $e;
     49        }
     50        $inputs[] = $this->ui->makeInputSelect(
     51            'shifttypes_default_duration',
     52            '__Default Shift Duration__' . ' (' . '__Hours__' . ')',
     53            $defaultDurationOptions,
     54            $values['shifttypes_default_duration']
    4355            );
    4456
  • shiftcontroller/trunk/shiftcontroller4.php

    r2241596 r2258787  
    44 * Plugin URI: http://www.shiftcontroller.com/
    55 * Description: Staff scheduling plugin
    6  * Version: 4.5.8
     6 * Version: 4.5.9
    77 * Author: hitcode.com
    88 * Author URI: http://www.shiftcontroller.com/
     
    1111*/
    1212
    13 define( 'SH4_VERSION', 458 );
     13define( 'SH4_VERSION', 459 );
    1414
    1515if (! defined('ABSPATH')) exit; // Exit if accessed directly
Note: See TracChangeset for help on using the changeset viewer.