PHP Classes

PHP Work from Home Schedule: Propose a schedule to work from home or the office

Recommend this page to a friend!

  Author Author  
Picture of Chun-Sheng, Li
Name: Chun-Sheng, Li <contact>
Classes: 16 packages by
Country: Taiwan Taiwan
Innovation award
Innovation award
Nominee: 8x

Winner: 1x


  Detailed description   Download Download .zip .tar.gz  
This package can propose a schedule to work from home or the office.

It considers two teams that can work from home or the office on alternate days.

The package can generate work schedules for both teams and output the schedules as files in CSV format.

Details

Working Home Schedule

CI Coverage Status StyleCI

Installation

  • Download `composer` firstly:
curl -sS https://getcomposer.org/installer | php

  • Install `lee/work-home-schedule` secondly:
php composer.phar require lee/work-home-schedule:^1

Introduction

This is about working home schedule to estimate current working status on specific date.

It's based on following scenario for A/B team work:

  • A team work from office today, and B team will work from home today.
  • A team work from home tomorrow, and B team will work from office tomorrow.
  • And so on.

This situation will skip on country holiday and weekend.

Usage

This class depends on Carbon::mixin method.

The code snippets are as follows:

  • Set `startDateStatus` about working from home or office.
  • Set `csvPath` about specific CSV file path.
  • Set `csvHead` about whether CSV file path has head.
  • Loading calendar data, the calendar CSV format is available here.

We assume that the 2020-04-06 is start date and working statuses are as follows:

  • The start date status is `office`.

Get next working date about code snippets are as follows:

require __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$nextWorkingDate = $currentDate->nextWorkingDate();

$carbonDate = $nextWorkingDate['date']; // Carbon::class instance
$carbonDateString = (string)$nextWorkingDate['date']; // 2020-04-07 00:00:00
$workingStatus = $nextWorkingDate['status']; // home

Get previous working date about code snippets are as follows:

require __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$previousWorkingDate = $currentDate->previousWorkingDate();

$carbonDate = $previousWorkingDate['date']; // Carbon::class instance
$carbonDateString = (string)$previousWorkingDate['date']; // 2020-04-01 00:00:00
$workingStatus = $previousWorkingDate['status']; // home

Get next working dates with specific date ranges about code snippets are as follows:

require __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true
$workingHomeSchedule->workingDays = 2; // The default value is 1

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$nextWorkingDates = $currentDate->nextWorkingDates(); // The array length is 2

$nextWorkingDates[0]['date'] // Carbon::class instance
(string)$nextWorkingDates[0]['date'] // 2020-04-07 00:00:00
$nextWorkingDates[0]['status'] // home

$nextWorkingDates[1]['date'] // Carbon::class instance
(string)$nextWorkingDates[1]['date'] // 2020-04-08 00:00:00
$nextWorkingDates[1]['status'] // office

Get previous working dates with date ranges about code snippets are as follows:

require __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true
$workingHomeSchedule->workingDays = 2; // The default value is 1

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$previousWorkingDates = $currentDate->previousWorkingDates(); // array length is 2

$previousWorkingDates[0]['date'] // Carbon::class instance
(string)$previousWorkingDates[0]['date'] // 2020-04-01 00:00:00
$previousWorkingDates[0]['status'] // home

$previousWorkingDates[1]['date'] // Carbon::class instance
(string)$previousWorkingDates[1]['date'] // 2020-03-31 00:00:00
$previousWorkingDates[1]['status'] // office

  Classes of Chun-Sheng, Li  >  PHP Work from Home Schedule  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog (1)  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Work from Home Schedule
Base name: work-home-schedule
Description: Propose a schedule to work from home or the office
Version: -
PHP version: 5
License: MIT/X Consortium License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Time and Date Time and date values, formats and conversion View top rated classes
Group folder image Project Management Tools to assist project management View top rated classes


  Innovation Award  
PHP Programming Innovation award nominee
March 2023
Nominee
Vote
Many developers have worked from home for years because they feel it is a more comfortable workplace.

Still, many companies prefer that employees work from their offices.

Since the pandemic, this preference has changed because many people have realized it is safer and faster to work from home, and employees can work more productively.

This package provides a solution to suggest a schedule to define how two teams will alternate the work location between home and office space.

Manuel Lemos

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (4 files)
Files folder imagetests (1 file, 1 directory)
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file ci.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file CannotFindDateOnCalendarException.php Class Class source
  Plain text file InvalidCsvRecordException.php Class Class source
  Plain text file InvalidStartDateStatusException.php Class Class source
  Plain text file WorkHomeSchedule.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imagefixtures (4 files)
  Plain text file WorkHomeScheduleTest.php Class Class source

  Files folder image Files  /  tests  /  fixtures  
File Role Description
  Accessible without login Plain text file 2020_calendar.csv Data Auxiliary data
  Accessible without login Plain text file invalid_calendar.csv Data Auxiliary data
  Accessible without login Plain text file invalid_holiday_calendar.csv Data Auxiliary data
  Accessible without login Plain text file not_enough_calendar.csv Data Auxiliary data

Download Download all files: work-home-schedule.tar.gz work-home-schedule.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (4 files)
Files folder imagetests (1 file, 1 directory)
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file ci.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file CannotFindDateOnCalendarException.php Class Class source
  Plain text file InvalidCsvRecordException.php Class Class source
  Plain text file InvalidStartDateStatusException.php Class Class source
  Plain text file WorkHomeSchedule.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imagefixtures (4 files)
  Plain text file WorkHomeScheduleTest.php Class Class source

  Files folder image Files  /  tests  /  fixtures  
File Role Description
  Accessible without login Plain text file 2020_calendar.csv Data Auxiliary data
  Accessible without login Plain text file invalid_calendar.csv Data Auxiliary data
  Accessible without login Plain text file invalid_holiday_calendar.csv Data Auxiliary data
  Accessible without login Plain text file not_enough_calendar.csv Data Auxiliary data

Download Download all files: work-home-schedule.tar.gz work-home-schedule.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.