Changeset 2178321
- Timestamp:
- 10/23/2019 09:55:27 AM (6 years ago)
- Location:
- shiftcontroller/trunk
- Files:
-
- 10 edited
-
readme.txt (modified) (1 diff)
-
sh4/calendars/permissions.php (modified) (1 diff)
-
sh4/new/acl.php (modified) (1 diff)
-
sh4/new/view/confirm.php (modified) (6 diffs)
-
sh4/schedule/html/view/day.php (modified) (1 diff)
-
sh4/schedule/html/view/month.php (modified) (1 diff)
-
sh4/schedule/html/view/week.php (modified) (1 diff)
-
sh4/shifts/controller/time.php (modified) (3 diffs)
-
sh4/shifts/view/widget.php (modified) (4 diffs)
-
shiftcontroller4.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shiftcontroller/trunk/readme.txt
r2171048 r2178321 60 60 61 61 == 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. 62 67 63 68 = 4.5.0 = -
shiftcontroller/trunk/sh4/calendars/permissions.php
r1909721 r2178321 62 62 '__Create Own Draft Shifts__', 63 63 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 ), 64 70 NULL 65 71 ); -
shiftcontroller/trunk/sh4/new/acl.php
r1913567 r2178321 116 116 $return = TRUE; 117 117 } 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 // } 118 125 } 119 126 -
shiftcontroller/trunk/sh4/new/view/confirm.php
r2149207 r2178321 5 5 HC3_Hooks $hooks, 6 6 7 HC3_Auth $auth, 8 HC3_IPermission $permission, 9 SH4_Shifts_Conflicts $conflicts, 10 7 11 HC3_Request $request, 8 12 HC3_Ui $ui, … … 12 16 SH4_New_View_Common $common, 13 17 14 SH4_Shifts_Conflicts $conflicts,15 18 SH4_Shifts_Availability $availability, 16 19 … … 22 25 SH4_Calendars_Presenter $calendarsPresenter, 23 26 SH4_ShiftTypes_Presenter $shiftTypesPresenter, 27 28 SH4_Calendars_Permissions $calendarsPermissions, 24 29 25 30 SH4_App_Query $appQuery, … … 31 36 $this->self = $hooks->wrap( $this ); 32 37 38 $this->auth = $hooks->wrap( $auth ); 39 $this->permission = $hooks->wrap( $permission ); 33 40 $this->request = $request; 34 41 $this->ui = $ui; … … 36 43 $this->common = $hooks->wrap($common); 37 44 45 $this->calendarsPermissions = $hooks->wrap( $calendarsPermissions ); 38 46 $this->t = $t; 39 47 … … 347 355 $out = array( $out ); 348 356 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 } 351 390 352 391 // open shift -
shiftcontroller/trunk/sh4/schedule/html/view/day.php
r2149207 r2178321 570 570 $grid->setRange( $dayStart, $dayEnd ); 571 571 572 // groups? 573 $groups = array(); 574 $groupedShifts = array(); 575 reset( $shifts ); 572 576 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 ); 574 611 $shiftId = $shift->getId(); 575 612 -
shiftcontroller/trunk/sh4/schedule/html/view/month.php
r2170467 r2178321 698 698 } 699 699 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 700 726 $return = array(); 727 reset( $shifts ); 701 728 foreach( $shifts as $shift ){ 702 729 $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 ); 704 741 705 742 if( ! $noZoom ){ -
shiftcontroller/trunk/sh4/schedule/html/view/week.php
r2149207 r2178321 746 746 } 747 747 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 748 774 $hori = FALSE; 749 775 $return = array(); 776 reset( $shifts ); 750 777 foreach( $shifts as $shift ){ 751 778 $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 ); 753 790 754 791 $menu = array(); -
shiftcontroller/trunk/sh4/shifts/controller/time.php
r1854904 r2178321 7 7 HC3_Session $session, 8 8 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, 9 15 10 16 SH4_Shifts_Query $query, … … 20 26 $this->command = $hooks->wrap($command); 21 27 $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 ); 22 34 } 23 35 … … 60 72 } 61 73 62 $this->command->reschedule( $shift, $start, $end, $startBreak, $endBreak ); 74 // check if it creates a conflict 75 $calendar = $shift->getCalendar(); 76 $calendarId = $calendar->getId(); 63 77 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 } 65 104 66 105 $to = 'schedule'; 67 106 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 69 117 return $return; 70 118 } -
shiftcontroller/trunk/sh4/shifts/view/widget.php
r2171048 r2178321 157 157 } 158 158 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 ) 160 160 { 161 161 $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 ); 163 163 return $return; 164 164 } 165 165 166 public function renderCompact( SH4_Shifts_Model $model, $iknow = array() )166 public function renderCompact( SH4_Shifts_Model $model, $iknow = array(), $groupedQty = NULL ) 167 167 { 168 168 $id = $model->getId(); … … 205 205 } 206 206 207 if( NULL !== $groupedQty ){ 208 $label = $groupedQty . 'x'; 209 } 210 207 211 $out = $this->ui->makeBlock( $label ) 208 212 ->padding(1) … … 280 284 } 281 285 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 ) 283 287 { 284 288 $id = $model->getId(); … … 330 334 $keys = array_keys($out); 331 335 $firstKey = array_shift($keys); 336 337 if( NULL !== $groupedQty ){ 338 $out[$firstKey] = $groupedQty . ' x ' . $out[$firstKey]; 339 } 332 340 333 341 // LINK -
shiftcontroller/trunk/shiftcontroller4.php
r2171048 r2178321 4 4 * Plugin URI: http://www.shiftcontroller.com/ 5 5 * Description: Staff scheduling plugin 6 * Version: 4.5. 06 * Version: 4.5.1 7 7 * Author: hitcode.com 8 8 * Author URI: http://www.shiftcontroller.com/ … … 11 11 */ 12 12 13 define( 'SH4_VERSION', 45 0);13 define( 'SH4_VERSION', 451 ); 14 14 15 15 if (! defined('ABSPATH')) exit; // Exit if accessed directly
Note: See TracChangeset
for help on using the changeset viewer.