Add ShiftSchedule entity and routes. #534

This commit is contained in:
Korina Cordero 2021-01-27 09:36:29 +00:00
parent 5a69899c28
commit 1125020d6f
5 changed files with 179 additions and 0 deletions

View file

@ -430,6 +430,14 @@ access_keys:
label: Menu
- id: analytics.forecast
label: Forecasting
- id: shift_schedule.list
label: List
- id: shift_schedule.add
label: Add
- id: shift_schedule.update
label: Update
- id: shift_schedule.delete
label: Delete
- id: sap_battery
label: SAP Battery Access

View file

@ -216,3 +216,7 @@ main_menu:
acl: analytics.forecast
label: Forecasting
parent: analytics
- id: shift_schedule_list
acl: shift_schedule.list
label: Shift Schedule
parent: analytics

View file

@ -0,0 +1,33 @@
shift_schedule_list:
path: /shift_schedules
controller: App\Controller\ShiftScheduleController::index
shift_schedule_rows:
path: /shift_schedules/rows
controller: App\Controller\ShiftScheduleController::rows
methods: [POST]
shift_schedule_create:
path: /shift_schedules/create
controller: App\Controller\ShiftScheduleController::addForm
methods: [GET]
shift_schedule_create_submit:
path: /shift_schedules/create
controller: App\Controller\ShiftScheduleController::addSubmit
methods: [POST]
shift_schedule_update:
path: /shift_schedules/{id}
controller: App\Controller\ShiftScheduleController::updateForm
methods: [GET]
shift_schedule_update_submit:
path: /shift_schedules/{id}
controller: App\Controller\ShiftScheduleController::updateSubmit
methods: [POST]
shift_schedule_delete:
path: /shift_schedules/{id}
controller: App\Controller\ShiftScheduleController::destroy
methods: [DELETE]

View file

@ -0,0 +1,5 @@
<?php
namespace App\Controller;

View file

@ -0,0 +1,129 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="shift_schedule")
*/
class ShiftSchedule
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// shift name
/**
* @ORM\Column(type="string", length=50, nullable=true)
* @Assert\NotBlank()
*/
protected $name;
// start time
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank()
*/
protected $start_time;
// end time
/**
* @ORM\(Column(type="string", nullable=true)
* @Assert\NotBlank()
*/
protected $end_time;
// number of hours in a shift
/**
* @ORM\(Column(type="integer")
* @Assert\NotBlank()
*/
protected $number_of_hours;
// hours
/**
* @ORM\Column(type="json")
*/
protected $hour_shifts;
public function __construct()
{
$this->hour_shifts = [];
}
public function getID()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getStartTime()
{
return $this->start_time;
}
public function setStartTime($start_time)
{
$this->start_time = $start_time;
return $this;
}
public function getEndTime()
{
return $this->end_time;
}
public function setEndTime($end_time)
{
$this->end_time = $end_time;
return $this;
}
public function getNumberOfHours()
{
return $this->number_of_hours;
}
public function setNumberOfHours($number_of_hours)
{
$this->number_of_hours = $number_of_hours;
return $this;
}
public function addHourShift($id, $value)
{
$this->hour_shifts[$id] = $value;
return $this;
}
public function getHourShiftsiById($id)
{
// return null if we don't have it
if (!isset($this->hour_shifts[$id]))
return null;
return $this->hour_shifts[$id];
}
public function getHourShifts()
{
return $this->hour_shifts;
}
}