Plugin Directory

Changeset 2178321


Ignore:
Timestamp:
10/23/2019 09:55:27 AM (6 years ago)
Author:
hitcode
Message:

4.5.1

Location:
shiftcontroller/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • shiftcontroller/trunk/readme.txt

    r2171048 r2178321  
    6060
    6161== Changelog ==
     62
     63= 4.5.1 =
     64* Group multiple open shifts for the same time in the schedule view.
     65* New setting if employees are allowed to create shifts for themselves with conflicts (overlapping existing shifts).
     66* BUG: compatibility issue - the date picker might have failed to work with some front end themes.
    6267
    6368= 4.5.0 =
  • shiftcontroller/trunk/sh4/calendars/permissions.php

    r1909721 r2178321  
    6262            '__Create Own Draft Shifts__',
    6363            array( 'employee_create_own_draft', 0 ),
     64            NULL
     65            );
     66
     67        $return[] = array(
     68            '__Create Own Shifts With Conflicts__',
     69            array( 'employee_create_own_conflicts', 0 ),
    6470            NULL
    6571            );
  • shiftcontroller/trunk/sh4/new/acl.php

    r1913567 r2178321  
    116116                $return = TRUE;
    117117            }
     118        }
     119
     120        if( $return ){
     121            // check if can create shifts with conflicts
     122            // if( ! $this->calendarsPermissions->get($thisCalendar, 'employee_create_own_conflicts') ){
     123                // $return = FALSE;
     124            // }
    118125        }
    119126
  • shiftcontroller/trunk/sh4/new/view/confirm.php

    r2149207 r2178321  
    55        HC3_Hooks $hooks,
    66
     7        HC3_Auth $auth,
     8        HC3_IPermission $permission,
     9        SH4_Shifts_Conflicts $conflicts,
     10
    711        HC3_Request $request,
    812        HC3_Ui $ui,
     
    1216        SH4_New_View_Common $common,
    1317
    14         SH4_Shifts_Conflicts $conflicts,
    1518        SH4_Shifts_Availability $availability,
    1619
     
    2225        SH4_Calendars_Presenter $calendarsPresenter,
    2326        SH4_ShiftTypes_Presenter $shiftTypesPresenter,
     27
     28        SH4_Calendars_Permissions $calendarsPermissions,
    2429
    2530        SH4_App_Query $appQuery,
     
    3136        $this->self = $hooks->wrap( $this );
    3237
     38        $this->auth = $hooks->wrap( $auth );
     39        $this->permission = $hooks->wrap( $permission );
    3340        $this->request = $request;
    3441        $this->ui = $ui;
     
    3643        $this->common = $hooks->wrap($common);
    3744
     45        $this->calendarsPermissions = $hooks->wrap( $calendarsPermissions );
    3846        $this->t = $t;
    3947
     
    347355        $out = array( $out );
    348356
    349         $btn = $this->self->buttons( $calendarId, $shiftTypeId, $dateString, $employeeString );
    350         $btn = $this->ui->makeListInline( $btn );
     357// employee_create_own_conflicts
     358        $showButtons = TRUE;
     359
     360        if( $withConflicts ){
     361            $isManager = FALSE;
     362
     363            $currentUser = $this->auth->getCurrentUser();
     364            if( $currentUser ){
     365                if( $this->permission->isAdmin($currentUser) ){
     366                    $isManager = TRUE;
     367                }
     368                else {
     369                    $calendarsAsManager = $this->appQuery->findCalendarsManagedByUser( $currentUser );
     370                    if( isset($calendarsAsManager[$calendarId]) ){
     371                        $isManager = TRUE;
     372                    }
     373                }
     374            }
     375
     376            if( ! $isManager ){
     377                if( ! $this->calendarsPermissions->get($calendar, 'employee_create_own_conflicts') ){
     378                    $showButtons = FALSE;
     379                }
     380            }
     381        }
     382
     383        if( $showButtons ){
     384            $btn = $this->self->buttons( $calendarId, $shiftTypeId, $dateString, $employeeString );
     385            $btn = $this->ui->makeListInline( $btn );
     386        }
     387        else {
     388            $btn = '__You cannot create new shifts with conflicts.__';
     389        }
    351390
    352391    // open shift
  • shiftcontroller/trunk/sh4/schedule/html/view/day.php

    r2149207 r2178321  
    570570        $grid->setRange( $dayStart, $dayEnd );
    571571
     572    // groups?
     573        $groups = array();
     574        $groupedShifts = array();
     575        reset( $shifts );
    572576        foreach( $shifts as $shift ){
    573             $thisView = $this->widget->render( $shift, $iknow, $hori, $noZoom );
     577            if( ! $shift->isOpen() ){
     578                continue;
     579            }
     580
     581            $groupId = array();
     582            $groupId[] = $shift->getStart();
     583            $groupId[] = $shift->getEnd();
     584            $groupId[] = $shift->isPublished() ? 1 : 0;
     585
     586            $groupId = join( '-', $groupId );
     587            if( ! isset($groups[$groupId]) ){
     588                $groups[ $groupId ] = $shift->getId();
     589                $groupedShifts[ $shift->getId() ] = array( $shift->getId() );
     590            }
     591            else {
     592                $mainShiftId = $groups[ $groupId ];
     593                $groupedShifts[ $mainShiftId ][] = $shift->getId();
     594                $groupedShifts[ $shift->getId() ] = 0;
     595            }
     596        }
     597
     598        reset( $shifts );
     599        foreach( $shifts as $shift ){
     600            $id = $shift->getId();
     601            if( isset($groupedShifts[$id]) && (! $groupedShifts[$id]) ){
     602                continue;
     603            }
     604
     605            $groupedQty = NULL;
     606            if( isset($groupedShifts[$id]) && (count($groupedShifts[$id]) > 1) ){
     607                $groupedQty = count($groupedShifts[$id]);
     608            }
     609
     610            $thisView = $this->widget->render( $shift, $iknow, $hori, $noZoom, $groupedQty );
    574611            $shiftId = $shift->getId();
    575612
  • shiftcontroller/trunk/sh4/schedule/html/view/month.php

    r2170467 r2178321  
    698698        }
    699699
     700    // groups?
     701        $groups = array();
     702        $groupedShifts = array();
     703        reset( $shifts );
     704        foreach( $shifts as $shift ){
     705            if( ! $shift->isOpen() ){
     706                continue;
     707            }
     708
     709            $groupId = array();
     710            $groupId[] = $shift->getStart();
     711            $groupId[] = $shift->getEnd();
     712            $groupId[] = $shift->isPublished() ? 1 : 0;
     713
     714            $groupId = join( '-', $groupId );
     715            if( ! isset($groups[$groupId]) ){
     716                $groups[ $groupId ] = $shift->getId();
     717                $groupedShifts[ $shift->getId() ] = array( $shift->getId() );
     718            }
     719            else {
     720                $mainShiftId = $groups[ $groupId ];
     721                $groupedShifts[ $mainShiftId ][] = $shift->getId();
     722                $groupedShifts[ $shift->getId() ] = 0;
     723            }
     724        }
     725
    700726        $return = array();
     727        reset( $shifts );
    701728        foreach( $shifts as $shift ){
    702729            $id = $shift->getId();
    703             $thisView = $this->widget->renderCompact( $shift, $iknow );
     730
     731            if( isset($groupedShifts[$id]) && (! $groupedShifts[$id]) ){
     732                continue;
     733            }
     734
     735            $groupedQty = NULL;
     736            if( isset($groupedShifts[$id]) && (count($groupedShifts[$id]) > 1) ){
     737                $groupedQty = count($groupedShifts[$id]);
     738            }
     739
     740            $thisView = $this->widget->renderCompact( $shift, $iknow, $groupedQty );
    704741
    705742            if( ! $noZoom ){
  • shiftcontroller/trunk/sh4/schedule/html/view/week.php

    r2149207 r2178321  
    746746        }
    747747
     748    // groups?
     749        $groups = array();
     750        $groupedShifts = array();
     751        reset( $shifts );
     752        foreach( $shifts as $shift ){
     753            if( ! $shift->isOpen() ){
     754                continue;
     755            }
     756
     757            $groupId = array();
     758            $groupId[] = $shift->getStart();
     759            $groupId[] = $shift->getEnd();
     760            $groupId[] = $shift->isPublished() ? 1 : 0;
     761
     762            $groupId = join( '-', $groupId );
     763            if( ! isset($groups[$groupId]) ){
     764                $groups[ $groupId ] = $shift->getId();
     765                $groupedShifts[ $shift->getId() ] = array( $shift->getId() );
     766            }
     767            else {
     768                $mainShiftId = $groups[ $groupId ];
     769                $groupedShifts[ $mainShiftId ][] = $shift->getId();
     770                $groupedShifts[ $shift->getId() ] = 0;
     771            }
     772        }
     773
    748774        $hori = FALSE;
    749775        $return = array();
     776        reset( $shifts );
    750777        foreach( $shifts as $shift ){
    751778            $id = $shift->getId();
    752             $thisView = $this->widget->render( $shift, $iknow, $hori, $noZoom );
     779
     780            if( isset($groupedShifts[$id]) && (! $groupedShifts[$id]) ){
     781                continue;
     782            }
     783
     784            $groupedQty = NULL;
     785            if( isset($groupedShifts[$id]) && (count($groupedShifts[$id]) > 1) ){
     786                $groupedQty = count($groupedShifts[$id]);
     787            }
     788
     789            $thisView = $this->widget->render( $shift, $iknow, $hori, $noZoom, $groupedQty );
    753790
    754791            $menu = array();
  • shiftcontroller/trunk/sh4/shifts/controller/time.php

    r1854904 r2178321  
    77        HC3_Session $session,
    88        HC3_Time $t,
     9
     10        SH4_Shifts_Conflicts $conflicts,
     11        HC3_Auth $auth,
     12        HC3_IPermission $permission,
     13        SH4_App_Query $appQuery,
     14        SH4_Calendars_Permissions $calendarsPermissions,
    915
    1016        SH4_Shifts_Query $query,
     
    2026        $this->command = $hooks->wrap($command);
    2127        $this->employees = $hooks->wrap($employees);
     28
     29        $this->auth = $hooks->wrap( $auth );
     30        $this->permission = $hooks->wrap( $permission );
     31        $this->conflicts = $hooks->wrap($conflicts);
     32        $this->appQuery = $hooks->wrap( $appQuery );
     33        $this->calendarsPermissions = $hooks->wrap( $calendarsPermissions );
    2234    }
    2335
     
    6072        }
    6173
    62         $this->command->reschedule( $shift, $start, $end, $startBreak, $endBreak );
     74// check if it creates a conflict
     75        $calendar = $shift->getCalendar();
     76        $calendarId = $calendar->getId();
    6377
    64         $msg = '__Shift Rescheduled__';
     78        $testModel = new SH4_Shifts_Model( NULL, $calendar, $start, $end, $shift->getEmployee(), $startBreak, $endBreak );
     79        $conflicts = $this->conflicts->get( $testModel );
     80
     81        $allowed = TRUE;
     82        if( $conflicts ){
     83            $isManager = FALSE;
     84
     85            $currentUser = $this->auth->getCurrentUser();
     86            if( $currentUser ){
     87                if( $this->permission->isAdmin($currentUser) ){
     88                    $isManager = TRUE;
     89                }
     90                else {
     91                    $calendarsAsManager = $this->appQuery->findCalendarsManagedByUser( $currentUser );
     92                    if( isset($calendarsAsManager[$calendarId]) ){
     93                        $isManager = TRUE;
     94                    }
     95                }
     96            }
     97
     98            if( ! $isManager ){
     99                if( ! $this->calendarsPermissions->get($calendar, 'employee_create_own_conflicts') ){
     100                    $allowed = FALSE;
     101                }
     102            }
     103        }
    65104
    66105        $to = 'schedule';
    67106
    68         $return = array( $to, $msg );
     107        if( $allowed ){
     108            $this->command->reschedule( $shift, $start, $end, $startBreak, $endBreak );
     109            $msg = '__Shift Rescheduled__';
     110            $return = array( $to, $msg );
     111        }
     112        else {
     113            $msg = '__You cannot create new shifts with conflicts.__';
     114            $return = array( $to, $msg, TRUE );
     115        }
     116
    69117        return $return;
    70118    }
  • shiftcontroller/trunk/sh4/shifts/view/widget.php

    r2171048 r2178321  
    157157    }
    158158
    159     public function render( SH4_Shifts_Model $model, $iknow = array(), $hori = FALSE, $noLink = FALSE )
     159    public function render( SH4_Shifts_Model $model, $iknow = array(), $hori = FALSE, $noLink = FALSE, $groupedQty = NULL )
    160160    {
    161161        $out = $this->self->prepare( $model, $iknow );
    162         $return = $this->self->renderPrepared( $model, $out, $iknow, $hori, $noLink );
     162        $return = $this->self->renderPrepared( $model, $out, $iknow, $hori, $noLink, $groupedQty );
    163163        return $return;
    164164    }
    165165
    166     public function renderCompact( SH4_Shifts_Model $model, $iknow = array() )
     166    public function renderCompact( SH4_Shifts_Model $model, $iknow = array(), $groupedQty = NULL )
    167167    {
    168168        $id = $model->getId();
     
    205205        }
    206206
     207        if( NULL !== $groupedQty ){
     208            $label = $groupedQty . 'x';
     209        }
     210
    207211        $out = $this->ui->makeBlock( $label )
    208212            ->padding(1)
     
    280284    }
    281285
    282     public function renderPrepared( SH4_Shifts_Model $model, $out, $iknow = array(), $hori = FALSE, $noLink = FALSE )
     286    public function renderPrepared( SH4_Shifts_Model $model, $out, $iknow = array(), $hori = FALSE, $noLink = FALSE, $groupedQty = NULL )
    283287    {
    284288        $id = $model->getId();
     
    330334        $keys = array_keys($out);
    331335        $firstKey = array_shift($keys);
     336
     337        if( NULL !== $groupedQty ){
     338            $out[$firstKey] = $groupedQty . ' x ' . $out[$firstKey];
     339        }
    332340
    333341    // LINK
  • shiftcontroller/trunk/shiftcontroller4.php

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