This commit is contained in:
Dobromir Popov
2024-03-26 01:08:57 +02:00
parent 3fcdfc1347
commit acd776e988
37 changed files with 143 additions and 107 deletions

View File

@ -40,7 +40,7 @@ class ExampleForm extends React.Component {
} }
const [item, set] = useState({ const [item, set] = useState({
isactive: true, isActive: true,
}); });
const router = useRouter(); const router = useRouter();
@ -63,7 +63,7 @@ class ExampleForm extends React.Component {
handleChange = ({ target }) => { handleChange = ({ target }) => {
if (target.name === "isactive") { if (target.name === "isActive") {
set({ ...item, [target.name]: target.checked }); set({ ...item, [target.name]: target.checked });
} else if (target.name === "age") { } else if (target.name === "age") {
set({ ...item, [target.name]: parseInt(target.value) }); set({ ...item, [target.name]: parseInt(target.value) });
@ -100,8 +100,8 @@ class ExampleForm extends React.Component {
<h3>{router.query?.id ? "Редактирай" : "Създай"} Item </h3> <h3>{router.query?.id ? "Редактирай" : "Създай"} Item </h3>
<div className="mb-4"> <div className="mb-4">
<div className="form-check"> <div className="form-check">
<input className="checkbox" type="checkbox" id="isactive" name="isactive" onChange={handleChange} checked={item.isactive} autoComplete="off" /> <input className="checkbox" type="checkbox" id="isActive" name="isActive" onChange={handleChange} checked={item.isActive} autoComplete="off" />
<label className="label" htmlFor="isactive"> <label className="label" htmlFor="isActive">
Is Active</label> Is Active</label>
</div> </div>
</div> </div>

View File

@ -39,7 +39,7 @@ export default function AvailabilityForm({ publisherId, existingItems, inline, o
dayOfMonth: null, dayOfMonth: null,
// startTime: "08:00", // startTime: "08:00",
// endTime: "20:00", // endTime: "20:00",
isactive: true, isActive: true,
repeatWeekly: false, repeatWeekly: false,
endDate: null, endDate: null,
isFirst: false, isFirst: false,

View File

@ -36,7 +36,7 @@ model Availability {
weekOfMonth Int? weekOfMonth Int?
startTime DateTime startTime DateTime
endTime DateTime endTime DateTime
isactive Boolean @default(true) isActive Boolean @default(true)
type AvailabilityType @default(Weekly) type AvailabilityType @default(Weekly)
isWithTransport Boolean @default(false) isWithTransport Boolean @default(false)
isFromPreviousAssignment Boolean @default(false) isFromPreviousAssignment Boolean @default(false)
@ -69,7 +69,7 @@ export default function AvailabilityForm({ publisherId, existingItem, inline, on
dayOfMonth: null, dayOfMonth: null,
startTime: "08:00", startTime: "08:00",
endTime: "20:00", endTime: "20:00",
isactive: true, isActive: true,
repeatWeekly: false, repeatWeekly: false,
endDate: null, endDate: null,
}); });
@ -554,11 +554,11 @@ export default function AvailabilityForm({ publisherId, existingItem, inline, on
<div className="mb-2 hidden"> <div className="mb-2 hidden">
<div className="form-check"> <div className="form-check">
<input className="checkbox form-input" type="checkbox" id="isactive" name="isactive" onChange={handleChange} checked={availability.isactive} autoComplete="off" /> <input className="checkbox form-input" type="checkbox" id="isActive" name="isActive" onChange={handleChange} checked={availability.isActive} autoComplete="off" />
<label className="label" htmlFor="isactive">активно</label> <label className="label" htmlFor="isActive">активно</label>
</div> </div>
</div> </div>
{/* <input type="hidden" name="isactive" value={availability.isactive} /> */} {/* <input type="hidden" name="isActive" value={availability.isActive} /> */}
<div className="panel-actions"> <div className="panel-actions">
<button className="action-button" onClick={() => handleCompletion()}> Отмени </button> <button className="action-button" onClick={() => handleCompletion()}> Отмени </button>

View File

@ -56,7 +56,7 @@ export default function AvailabilityList({ publisher, showNew }) {
</thead> </thead>
<tbody> <tbody>
{items?.sort((a, b) => new Date(a.startTime) - new Date(b.startTime)).map(item => ( {items?.sort((a, b) => new Date(a.startTime) - new Date(b.startTime)).map(item => (
<tr key={item.id} availability={item} disabled={!item.isactive} className={`${item.isFromPreviousMonth ? 'bg-yellow-200' : ''} ${!item.isactive ? 'opacity-50' : ''}`}> <tr key={item.id} availability={item} disabled={!item.isActive} className={`${item.isFromPreviousMonth ? 'bg-yellow-200' : ''} ${!item.isActive ? 'opacity-50' : ''}`}>
<td className="px-6 py-4 whitespace-nowrap"> <td className="px-6 py-4 whitespace-nowrap">
{item.dayOfMonth ? `${common.getDateFormated(new Date(item.startTime))}` : `Всеки(Всяка) ${common.getDayOfWeekName(new Date(item.startTime))}`} {item.dayOfMonth ? `${common.getDateFormated(new Date(item.startTime))}` : `Всеки(Всяка) ${common.getDayOfWeekName(new Date(item.startTime))}`}
{/* {common.getDateFormated(new Date(item.startTime))} */} {/* {common.getDateFormated(new Date(item.startTime))} */}

View File

@ -70,7 +70,7 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a
const newAssignment = { const newAssignment = {
publisher: { connect: { id: publisher.id } }, publisher: { connect: { id: publisher.id } },
shift: { connect: { id: shiftId } }, shift: { connect: { id: shiftId } },
//isactive: true, //isActive: true,
isConfirmed: true, isConfirmed: true,
}; };
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment); const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);

View File

@ -206,7 +206,7 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
// startTime: start, // startTime: start,
// endTime: end, // endTime: end,
// dayOfMonth: start.getDate(), // dayOfMonth: start.getDate(),
// isactive: true, // isActive: true,
// publisherId: publisherId, // publisherId: publisherId,
// // Add any other initial values needed // // Add any other initial values needed
// //set dayOfMonth to null, so that we repeat the availability every week // //set dayOfMonth to null, so that we repeat the availability every week
@ -273,9 +273,9 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
//if event.type is availability show in blue. if it is schedule - green if confirmed, yellow if not confirmed //if event.type is availability show in blue. if it is schedule - green if confirmed, yellow if not confirmed
//if event is not active - show in gray //if event is not active - show in gray
let bgColorClass = 'bg-gray-500'; // Default color for inactive events let bgColorClass = 'bg-gray-500'; // Default color for inactive events
var bgColor = event.isactive ? "" : "bg-gray-500"; var bgColor = event.isActive ? "" : "bg-gray-500";
if (event.type === "assignment") { if (event.type === "assignment") {
bgColor = event.isTentative ? "bg-red-500" : (event.isConfirmed ? "bg-green-500" : "bg-yellow-500"); bgColor = event.isBySystem ? "bg-red-500" : (event.isConfirmed ? "bg-green-500" : "bg-yellow-500");
//event.title = event.publisher.name; //ToDo: add other publishers names //event.title = event.publisher.name; //ToDo: add other publishers names
//event.title = common.getTimeFomatted(event.startTime) + " - " + common.getTimeFomatted(event.endTime); //event.title = common.getTimeFomatted(event.startTime) + " - " + common.getTimeFomatted(event.endTime);
@ -319,7 +319,7 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
toast.info("Потвърдено!", { autoClose: 2000 }); toast.info("Потвърдено!", { autoClose: 2000 });
// Update the event data // Update the event data
event.isConfirmed = true; event.isConfirmed = true;
event.isTentative = false; event.isBySystem = false;
// Update the events array by first removing the old event and then adding the updated one // Update the events array by first removing the old event and then adding the updated one
setEvents(currentEvents => { setEvents(currentEvents => {
const filteredEvents = currentEvents.filter(e => e.id !== event.id); const filteredEvents = currentEvents.filter(e => e.id !== event.id);
@ -328,7 +328,7 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
//store the updated event in the database //store the updated event in the database
var assignment = { var assignment = {
isConfirmed: true, isConfirmed: true,
isTentative: false isBySystem: false
}; };
axiosInstance.put('/api/data/assignments/' + event.id, assignment) axiosInstance.put('/api/data/assignments/' + event.id, assignment)
.then((response) => { .then((response) => {
@ -388,7 +388,7 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
// orange-500 from Tailwind CSS // orange-500 from Tailwind CSS
backgroundColor = '#f56565'; backgroundColor = '#f56565';
} }
if (event.isactive) { if (event.isActive) {
switch (event.type) { switch (event.type) {
case 'assignment': case 'assignment':
backgroundColor = event.isConfirmed ? '#48bb78' : '#f6e05e'; // green-500 and yellow-300 from Tailwind CSS backgroundColor = event.isConfirmed ? '#48bb78' : '#f6e05e'; // green-500 and yellow-300 from Tailwind CSS

View File

@ -15,7 +15,7 @@ model CartEvent {
shiftDuration Int shiftDuration Int
shifts Shift[] shifts Shift[]
dayofweek DayOfWeek dayofweek DayOfWeek
isactive Boolean @default(true) isActive Boolean @default(true)
}*/ }*/
interface Location { interface Location {
id: number; id: number;
@ -174,8 +174,8 @@ export default function CartEventForm(props: IProps) {
<div className="mb-4"> <div className="mb-4">
<div className="form-check"> <div className="form-check">
<input className="checkbox" type="checkbox" name="isactive" id="isactive" checked={evt.isactive} onChange={handleChange} /> <input className="checkbox" type="checkbox" name="isActive" id="isActive" checked={evt.isActive} onChange={handleChange} />
<label className='label align-text-bottom' htmlFor="isactive">Active</label> <label className='label align-text-bottom' htmlFor="isActive">Active</label>
</div> </div>
</div> </div>
<div className="panel-actions"> <div className="panel-actions">

View File

@ -28,11 +28,11 @@ export default function LocationCard({ location }) {
<> <>
<div <div
id={`location-card-${location.id}`} id={`location-card-${location.id}`}
className={`relative block p-6 max-w-sm rounded-lg border border-gray-200 shadow-md hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700 mb-3 cursor-pointer ${location.isactive ? 'text-gray-900 dark:text-white font-bold' : 'text-gray-400 dark:text-gray-600'}`} className={`relative block p-6 max-w-sm rounded-lg border border-gray-200 shadow-md hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700 mb-3 cursor-pointer ${location.isActive ? 'text-gray-900 dark:text-white font-bold' : 'text-gray-400 dark:text-gray-600'}`}
onClick={() => router.push(`/cart/locations/edit/${location.id}`)} onClick={() => router.push(`/cart/locations/edit/${location.id}`)}
> >
<h5 className={`mb-2 text-2xl tracking-tight`}> <h5 className={`mb-2 text-2xl tracking-tight`}>
{location.name} ({location.isactive ? "active" : "inactive"}) {location.name} ({location.isActive ? "active" : "inactive"})
</h5> </h5>
<p className="font-normal text-gray-700 dark:text-gray-200"> <p className="font-normal text-gray-700 dark:text-gray-200">
{location.address} {location.address}

View File

@ -19,7 +19,7 @@ const common = require('src/helpers/common');
// id Int @id @default(autoincrement()) // id Int @id @default(autoincrement())
// name String // name String
// address String // address String
// isactive Boolean @default(true) // isActive Boolean @default(true)
// content String? @db.Text // content String? @db.Text
// cartEvents CartEvent[] // cartEvents CartEvent[]
// reports Report[] // reports Report[]
@ -65,7 +65,7 @@ export default function LocationForm() {
const [location, set] = useState({ const [location, set] = useState({
name: "", name: "",
address: "", address: "",
isactive: true, isActive: true,
}); });
// const [isEdit, setIsEdit] = useState(false); // const [isEdit, setIsEdit] = useState(false);
@ -171,11 +171,11 @@ export default function LocationForm() {
<input className="textbox" <input className="textbox"
placeholder="address" id="address" name="address" onChange={handleChange} value={location.address} autoComplete="off" /> placeholder="address" id="address" name="address" onChange={handleChange} value={location.address} autoComplete="off" />
</div> </div>
{/* UI for Location.isactive */} {/* UI for Location.isActive */}
<div className="mb-4"> <div className="mb-4">
<div className="form-check"> <div className="form-check">
<input className="checkbox form-input" type="checkbox" id="isactive" name="isactive" onChange={handleChange} checked={location.isactive} autoComplete="off" /> <input className="checkbox form-input" type="checkbox" id="isActive" name="isActive" onChange={handleChange} checked={location.isActive} autoComplete="off" />
<label className="label" htmlFor="isactive">Активна</label> <label className="label" htmlFor="isActive">Активна</label>
</div> </div>
</div> </div>
{/* backupLocation */} {/* backupLocation */}

View File

@ -57,7 +57,7 @@ export default function PublisherCard({ publisher }) {
return isCardVisible ? ( return isCardVisible ? (
// className="block p-6 max-w-sm bg-white rounded-lg border border-gray-200 shadow-md hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700 mb-3" // className="block p-6 max-w-sm bg-white rounded-lg border border-gray-200 shadow-md hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700 mb-3"
<div id={`publisher-card-${publisher.id}`} className={`relative block p-6 max-w-sm rounded-lg border border-gray-200 shadow-md hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700 mb-3 <div id={`publisher-card-${publisher.id}`} className={`relative block p-6 max-w-sm rounded-lg border border-gray-200 shadow-md hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700 mb-3
${!publisher.isactive ? "opacity-50 bg-gray-200 border-gray-300 text-gray-400" : (publisher.isImported ? "bg-orange-50" : (publisher.isTrained ? "bg-white" : "bg-red-50"))}`} ${!publisher.isActive ? "opacity-50 bg-gray-200 border-gray-300 text-gray-400" : (publisher.isImported ? "bg-orange-50" : (publisher.isTrained ? "bg-white" : "bg-red-50"))}`}
> >
<a <a
href={`/cart/publishers/edit/${publisher.id}`} href={`/cart/publishers/edit/${publisher.id}`}
@ -66,7 +66,7 @@ export default function PublisherCard({ publisher }) {
> >
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white"> <h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
{publisher.firstName} {publisher.lastName} ({publisher.isactive ? "active" : "inactive"}) {publisher.firstName} {publisher.lastName} ({publisher.isActive ? "active" : "inactive"})
</h5> </h5>
<div className="font-normal text-gray-700 dark:text-gray-200"> <div className="font-normal text-gray-700 dark:text-gray-200">
<p> {publisher.assignments.length} смени общо</p> <p> {publisher.assignments.length} смени общо</p>

View File

@ -23,7 +23,7 @@ import { UserRole } from "@prisma/client";
// lastName String // lastName String
// email String @unique // email String @unique
// phone String? // phone String?
// isactive Boolean @default(true) // isActive Boolean @default(true)
// isImported Boolean @default(false) // isImported Boolean @default(false)
// age Int? // age Int?
// availabilities Availability[] // availabilities Availability[]
@ -75,7 +75,7 @@ export default function PublisherForm({ item, me }) {
}, []); }, []);
const [publisher, set] = useState(item || { const [publisher, set] = useState(item || {
isactive: true, isActive: true,
}); });
const handleChange = ({ target }) => { const handleChange = ({ target }) => {
@ -259,8 +259,8 @@ export default function PublisherForm({ item, me }) {
</div> </div>
<div className="mb-4"> <div className="mb-4">
<div className="form-check"> <div className="form-check">
<input className="checkbox" type="checkbox" id="isactive" name="isactive" onChange={handleChange} checked={publisher.isactive} autoComplete="off" /> <input className="checkbox" type="checkbox" id="isActive" name="isActive" onChange={handleChange} checked={publisher.isActive} autoComplete="off" />
<label className="label" htmlFor="isactive">Активен</label> <label className="label" htmlFor="isActive">Активен</label>
<input className="checkbox" type="checkbox" id="isTrained" name="isTrained" onChange={handleChange} checked={publisher.isTrained} autoComplete="off" /> <input className="checkbox" type="checkbox" id="isTrained" name="isTrained" onChange={handleChange} checked={publisher.isTrained} autoComplete="off" />
<label className="label" htmlFor="isTrained">Получил обучение</label> <label className="label" htmlFor="isTrained">Получил обучение</label>
<input className="checkbox disabled" type="checkbox" id="isImported" name="isImported" onChange={handleChange} checked={publisher.isImported} autoComplete="off" /> <input className="checkbox disabled" type="checkbox" id="isImported" name="isImported" onChange={handleChange} checked={publisher.isImported} autoComplete="off" />

View File

@ -18,7 +18,7 @@ function PublisherSearchBox({ selectedId, onChange, isFocused, filterDate, showS
const fetchPublishers = async () => { const fetchPublishers = async () => {
console.log("fetchPublishers called"); console.log("fetchPublishers called");
try { try {
let url = `/api/?action=filterPublishers&select=id,firstName,lastName,email,isactive&searchText=${searchText}&availabilities=false`; let url = `/api/?action=filterPublishers&select=id,firstName,lastName,email,isActive&searchText=${searchText}&availabilities=false`;
if (filterDate) { if (filterDate) {
url += `&filterDate=${common.getISODateOnly(filterDate)}`; url += `&filterDate=${common.getISODateOnly(filterDate)}`;
@ -29,7 +29,7 @@ function PublisherSearchBox({ selectedId, onChange, isFocused, filterDate, showS
const { data: publishersData } = await axiosInstance.get(url); const { data: publishersData } = await axiosInstance.get(url);
//setPublishers(publishersData); //setPublishers(publishersData);
const activePublishers = publishersData.filter(publisher => publisher.isactive === true); const activePublishers = publishersData.filter(publisher => publisher.isActive === true);
setPublishers(activePublishers); setPublishers(activePublishers);
} catch (error) { } catch (error) {

View File

@ -35,7 +35,7 @@ const ShiftsList = ({ assignments, selectedtab }: ShiftsListProps) => {
try { try {
var assignment = (await axiosInstance.get("/api/data/assignments/" + id)).data; var assignment = (await axiosInstance.get("/api/data/assignments/" + id)).data;
assignment.isConfirmed = false; assignment.isConfirmed = false;
assignment.isTentative = true; // ! assignment.isTentative = true;
// assignment.isDeleted = true; // assignment.isDeleted = true;
await axiosInstance.put("/api/data/assignments/" + id, assignment); await axiosInstance.put("/api/data/assignments/" + id, assignment);
toast.success("Shift Tentative", { toast.success("Shift Tentative", {

View File

@ -99,7 +99,7 @@ export default function Sidebar({ isSidebarOpen, toggleSidebar }) {
try { try {
const response = await axiosInstance.get('/api/data/locations'); // Adjust the API endpoint as needed const response = await axiosInstance.get('/api/data/locations'); // Adjust the API endpoint as needed
const locationsData = response.data const locationsData = response.data
.filter(location => location.isactive === true) .filter(location => location.isActive === true)
.map(location => ({ .map(location => ({
text: location.name, text: location.name,
url: `/cart/locations/${location.id}`, url: `/cart/locations/${location.id}`,

View File

@ -143,7 +143,7 @@ export default async function handler(req, res) {
case "getUnassignedPublishers": case "getUnassignedPublishers":
//let monthInfo = common.getMonthDatesInfo(date); //let monthInfo = common.getMonthDatesInfo(date);
let allPubs = await filterPublishers("id,firstName,lastName,email,isactive".split(","), "", date, true, true, false); let allPubs = await filterPublishers("id,firstName,lastName,email,isActive".split(","), "", date, true, true, false);
let unassignedPubs = allPubs.filter(pub => pub.currentMonthAssignments == 0 && pub.availabilities.length > 0); let unassignedPubs = allPubs.filter(pub => pub.currentMonthAssignments == 0 && pub.availabilities.length > 0);
res.status(200).json(unassignedPubs); res.status(200).json(unassignedPubs);
break; break;
@ -690,7 +690,7 @@ async function replaceInAssignment(oldPublisherId, newPublisherId, shiftId) {
data: { data: {
publisherId: newPublisherId, publisherId: newPublisherId,
isConfirmed: false, isConfirmed: false,
isTentative: true, isBySystem: true,
isMailSent: false isMailSent: false
} }
}); });

View File

@ -89,7 +89,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const shifts = await prisma.shift.findMany({ const shifts = await prisma.shift.findMany({
where: { where: {
isactive: true, isActive: true,
startTime: { startTime: {
gte: fromDate, gte: fromDate,
lt: toDate, lt: toDate,

View File

@ -68,7 +68,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
case "test": case "test":
var data = prisma.shift.findMany({ var data = prisma.shift.findMany({
where: { where: {
isactive: true isActive: true
} }
}); });
@ -110,7 +110,7 @@ async function GenerateSchedule(axios: Axios, date: string, copyFromPreviousMont
} }
console.log("finding shifts for previous 3 months for statistics (between " + new Date(monthInfo.date.getFullYear(), monthInfo.date.getMonth() - 3, 1).toISOString() + " and " + monthInfo.firstDay.toISOString() + ")"); console.log("finding shifts for previous 3 months for statistics (between " + new Date(monthInfo.date.getFullYear(), monthInfo.date.getMonth() - 3, 1).toISOString() + " and " + monthInfo.firstDay.toISOString() + ")");
const { data: events } = await axios.get(`/api/data/cartevents?where={"isactive":{"$eq":true}}`); const { data: events } = await axios.get(`/api/data/cartevents?where={"isActive":{"$eq":true}}`);
//// let [shiftsLastMonth, publishers] = await getShiftsAndPublishersForPreviousMonths(lastMonthInfo); //// let [shiftsLastMonth, publishers] = await getShiftsAndPublishersForPreviousMonths(lastMonthInfo);
//use filterPublishers from /pages/api/data/index.ts to get publishers with stats //use filterPublishers from /pages/api/data/index.ts to get publishers with stats
@ -308,7 +308,7 @@ async function GenerateSchedule(axios: Axios, date: string, copyFromPreviousMont
assignments: 'true', assignments: 'true',
availabilities: 'true', availabilities: 'true',
date: common.getISODateOnly(shiftStart), date: common.getISODateOnly(shiftStart),
select: 'id,firstName,lastName,isactive,desiredShiftsPerMonth' select: 'id,firstName,lastName,isActive,desiredShiftsPerMonth'
}); });
let allAvailablePublishers = (await axios.get(`/api/?${queryParams.toString()}`)).data; let allAvailablePublishers = (await axios.get(`/api/?${queryParams.toString()}`)).data;
let availablePublishers = allAvailablePublishers; let availablePublishers = allAvailablePublishers;
@ -616,12 +616,12 @@ async function ImportShiftsFromDocx(axios: Axios) {
// prisma.publisher.findMany({ // prisma.publisher.findMany({
// where: { // where: {
// isactive: true, // isActive: true,
// }, // },
// include: { // include: {
// availabilities: { // availabilities: {
// where: { // where: {
// isactive: true, // isActive: true,
// }, // },
// }, // },
// assignments: { // assignments: {

View File

@ -30,7 +30,7 @@ export default function AvPage({ initialItems, id }: IProps) {
date: new Date(item.startTime), date: new Date(item.startTime),
start: new Date(item.startTime), start: new Date(item.startTime),
end: new Date(item.endTime), end: new Date(item.endTime),
isactive: item.isactive, isActive: item.isActive,
publisherId: item.publisher.id, publisherId: item.publisher.id,
dayOfMonth: item.dayOfMonth, dayOfMonth: item.dayOfMonth,
dayOfWeek: item.dayOfWeek, dayOfWeek: item.dayOfWeek,
@ -66,9 +66,9 @@ export default function AvPage({ initialItems, id }: IProps) {
</thead> </thead>
<tbody> <tbody>
{initialItems?.map((item: Availability) => ( {initialItems?.map((item: Availability) => (
<tr key={item.id} className={item.isactive ? "" : "text-gray-300"}> <tr key={item.id} className={item.isActive ? "" : "text-gray-300"}>
<td className="px-6 py-4 whitespace-nowrap "> <td className="px-6 py-4 whitespace-nowrap ">
{item.id} {item.isactive} {item.id} {item.isActive}
</td> </td>
<td className="px-6 py-4 whitespace-nowrap"> <td className="px-6 py-4 whitespace-nowrap">
{item.publisher.lastName}, {item.publisher.firstName} {item.publisher.lastName}, {item.publisher.firstName}
@ -133,14 +133,14 @@ export const getServerSideProps = async (context) => {
const role = session?.user.role; const role = session?.user.role;
console.log("server role: " + role); console.log("server role: " + role);
var queryUrl = process.env.NEXTAUTH_URL + "/api/data/availabilities?select=id,name,isactive,dayofweek,dayOfMonth,startTime,endTime,publisher.firstName,publisher.lastName,publisher.id"; var queryUrl = process.env.NEXTAUTH_URL + "/api/data/availabilities?select=id,name,isActive,dayofweek,dayOfMonth,startTime,endTime,publisher.firstName,publisher.lastName,publisher.id";
if (role === UserRole.USER || context.query.my) { if (role === UserRole.USER || context.query.my) {
queryUrl += `&where={"publisherId":"${session?.user.id}"}`; queryUrl += `&where={"publisherId":"${session?.user.id}"}`;
} else if (role == UserRole.ADMIN) { } else if (role == UserRole.ADMIN) {
if (context.query.id) { if (context.query.id) {
queryUrl += `&where={"publisherId":"${context.query.id}"}`; queryUrl += `&where={"publisherId":"${context.query.id}"}`;
} else { } else {
queryUrl += `&where={"isactive":true}`; queryUrl += `&where={"isActive":true}`;
} }
} }
var resp = await axios.get( var resp = await axios.get(

View File

@ -100,7 +100,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
console.log("Setting date to '" + date.toLocaleDateString() + "' from '" + selectedDate.toLocaleDateString() + "'. ISO: " + date.toISOString(), "locale ISO:", common.getISODateOnly(date)); console.log("Setting date to '" + date.toLocaleDateString() + "' from '" + selectedDate.toLocaleDateString() + "'. ISO: " + date.toISOString(), "locale ISO:", common.getISODateOnly(date));
if (isCheckboxChecked) { if (isCheckboxChecked) {
console.log(`getting unassigned publishers for ${common.getMonthName(date.getMonth())} ${date.getFullYear()}`); console.log(`getting unassigned publishers for ${common.getMonthName(date.getMonth())} ${date.getFullYear()}`);
const { data: availablePubsForDate } = await axiosInstance.get(`/api/?action=getUnassignedPublishers&date=${dateStr}&select=id,firstName,lastName,isactive,desiredShiftsPerMonth`); const { data: availablePubsForDate } = await axiosInstance.get(`/api/?action=getUnassignedPublishers&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
setAvailablePubs(availablePubsForDate); setAvailablePubs(availablePubsForDate);
} }
else { else {
@ -108,7 +108,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
try { try {
const { data: shiftsForDate } = await axiosInstance.get(`/api/?action=getShiftsForDay&date=${dateStr}`); const { data: shiftsForDate } = await axiosInstance.get(`/api/?action=getShiftsForDay&date=${dateStr}`);
setShifts(shiftsForDate); setShifts(shiftsForDate);
let { data: availablePubsForDate } = await axiosInstance.get(`/api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isactive,desiredShiftsPerMonth`); let { data: availablePubsForDate } = await axiosInstance.get(`/api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
availablePubsForDate.forEach(pub => { availablePubsForDate.forEach(pub => {
pub.canTransport = pub.availabilities.some(av => pub.canTransport = pub.availabilities.some(av =>
@ -172,8 +172,8 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
// currentMonthAssignments and previousMonthAssignments properties // currentMonthAssignments and previousMonthAssignments properties
// Sort publishers based on availability and then by assignment counts. // Sort publishers based on availability and then by assignment counts.
const sortedPubs = updatedPubs.sort((a, b) => { const sortedPubs = updatedPubs.sort((a, b) => {
if (a.isactive !== b.isactive) { if (a.isActive !== b.isActive) {
return a.isactive ? -1 : 1; return a.isActive ? -1 : 1;
} }
// First, sort by isselected. // First, sort by isselected.
if (a.isSelected !== b.isSelected) { if (a.isSelected !== b.isSelected) {
@ -355,7 +355,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
const newAssignment = { const newAssignment = {
publisher: { connect: { id: publisher.id } }, publisher: { connect: { id: publisher.id } },
shift: { connect: { id: shiftId } }, shift: { connect: { id: shiftId } },
isactive: true, isActive: true,
isConfirmed: true isConfirmed: true
}; };
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment); const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
@ -669,7 +669,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
// Determine border class if selected // Determine border class if selected
const selectedBorderClass = pub.isSelected ? 'border-blue-400 border-b-4' : ''; const selectedBorderClass = pub.isSelected ? 'border-blue-400 border-b-4' : '';
// Determine opacity class // Determine opacity class
const activeOpacityClass = pub.isactive ? '' : 'opacity-25'; const activeOpacityClass = pub.isActive ? '' : 'opacity-25';
return ( return (
@ -878,20 +878,20 @@ export const getServerSideProps = async (context) => {
const url = `/api/data/shifts?where={"startTime":{"$and":[{"$gte":"${common.getISODateOnly(firstDayOfMonth)}","$lt":"${common.getISODateOnly(lastDayOfMonth)}"}]}}`; const url = `/api/data/shifts?where={"startTime":{"$and":[{"$gte":"${common.getISODateOnly(firstDayOfMonth)}","$lt":"${common.getISODateOnly(lastDayOfMonth)}"}]}}`;
const prismaClient = common.getPrismaClient(); const prismaClient = common.getPrismaClient();
// let events = await prismaClient.cartEvent.findMany({ where: { isactive: true } }); // let events = await prismaClient.cartEvent.findMany({ where: { isActive: true } });
// events = events.map(event => ({ // events = events.map(event => ({
// ...event, // ...event,
// // Convert Date objects to ISO strings // // Convert Date objects to ISO strings
// startTime: event.startTime.toISOString(), // startTime: event.startTime.toISOString(),
// endTime: event.endTime.toISOString(), // endTime: event.endTime.toISOString(),
// })); // }));
const { data: events } = await axios.get(`/api/data/cartevents?where={"isactive":true}`); const { data: events } = await axios.get(`/api/data/cartevents?where={"isActive":true}`);
//const { data: shifts } = await axios.get(url); //const { data: shifts } = await axios.get(url);
// get all shifts for the month, including assigments // get all shifts for the month, including assigments
let shifts = await prismaClient.shift.findMany({ let shifts = await prismaClient.shift.findMany({
where: { where: {
isactive: true, isActive: true,
startTime: { startTime: {
gte: firstDayOfMonth, gte: firstDayOfMonth,
//lt: lastDayOfMonth //lt: lastDayOfMonth

View File

@ -69,7 +69,7 @@ export default function CartEventPage({ items, locations }: ICartEventPageProps)
{item.shiftDuration} {item.shiftDuration}
</td> </td>
<td className="px-6 py-4 whitespace-nowrap"> <td className="px-6 py-4 whitespace-nowrap">
{item.isactive ? "Yes" : "No"} {item.isActive ? "Yes" : "No"}
</td> </td>
<td> <td>
<button className="button bg-blue-500 hover:bg-blue-700" <button className="button bg-blue-500 hover:bg-blue-700"

View File

@ -194,7 +194,7 @@ export default function ImportPage() {
let personNames = names.join(' '); let personNames = names.join(' ');
try { try {
try { try {
const select = "&select=id,firstName,lastName,phone,isTrained,desiredShiftsPerMonth,isactive,type,availabilities"; const select = "&select=id,firstName,lastName,phone,isTrained,desiredShiftsPerMonth,isActive,type,availabilities";
const responseByName = await axiosInstance.get(`/api/?action=findPublisher&filter=${names.join(' ')}${select}`); const responseByName = await axiosInstance.get(`/api/?action=findPublisher&filter=${names.join(' ')}${select}`);
let existingPublisher = responseByName.data[0]; let existingPublisher = responseByName.data[0];
if (!existingPublisher) { if (!existingPublisher) {
@ -248,7 +248,7 @@ export default function ImportPage() {
{ key: 'phone', value: phone }, { key: 'phone', value: phone },
{ key: 'desiredShiftsPerMonth', value: desiredShiftsPerMonth, parse: parseInt }, { key: 'desiredShiftsPerMonth', value: desiredShiftsPerMonth, parse: parseInt },
{ key: 'isTrained', value: isTrained }, { key: 'isTrained', value: isTrained },
{ key: 'isactive', value: isActive }, { key: 'isActive', value: isActive },
{ key: 'type', value: publisherType, parse: common.getPubTypeEnum } { key: 'type', value: publisherType, parse: common.getPubTypeEnum }
]; ];
@ -286,7 +286,7 @@ export default function ImportPage() {
phone, phone,
firstName: names[0], firstName: names[0],
lastName: names[1], lastName: names[1],
isactive: isActive, isActive: isActive,
isTrained, isTrained,
desiredShiftsPerMonth, desiredShiftsPerMonth,
}); });
@ -301,7 +301,7 @@ export default function ImportPage() {
phone, phone,
firstName: firstname, firstName: firstname,
lastName: names[names.length - 1], lastName: names[names.length - 1],
isactive: isActive, isActive: isActive,
isTrained, isTrained,
desiredShiftsPerMonth desiredShiftsPerMonth
}); });
@ -530,7 +530,7 @@ export default function ImportPage() {
weekOfMonth: weekNr, // Add the missing 'weekOfMonth' weekOfMonth: weekNr, // Add the missing 'weekOfMonth'
startTime, startTime,
endTime, endTime,
isactive: true, isActive: true,
type: AvailabilityType.OneTime, type: AvailabilityType.OneTime,
isWithTransportIn: false, // Add the missing 'isWithTransport' property isWithTransportIn: false, // Add the missing 'isWithTransport' property
isWithTransportOut: false, // Add the missing 'isWithTransport' property isWithTransportOut: false, // Add the missing 'isWithTransport' property

View File

@ -225,7 +225,7 @@ export default PublishersPage;
export const getServerSideProps = async (context) => { export const getServerSideProps = async (context) => {
const axios = await axiosServer(context); const axios = await axiosServer(context);
//ToDo: refactor all axios calls to use axiosInstance and this URL //ToDo: refactor all axios calls to use axiosInstance and this URL
const { data: publishers } = await axios.get('/api/data/publishers?select=id,firstName,lastName,email,isactive,isTrained,isImported,assignments.shift.startTime,availabilities.startTime&dev=fromuseefect'); const { data: publishers } = await axios.get('/api/data/publishers?select=id,firstName,lastName,email,isActive,isTrained,isImported,assignments.shift.startTime,availabilities.startTime&dev=fromuseefect');
return { return {
props: { props: {

View File

@ -74,12 +74,12 @@ export default ContactsPage;
export const getServerSideProps = async (context) => { export const getServerSideProps = async (context) => {
const dateStr = new Date().toISOString().split('T')[0]; const dateStr = new Date().toISOString().split('T')[0];
let publishers = await filterPublishers('id,firstName,lastName,email,isactive,desiredShiftsPerMonth', "", new Date(), true, true, false); let publishers = await filterPublishers('id,firstName,lastName,email,isActive,desiredShiftsPerMonth', "", new Date(), true, true, false);
// const axios = await axiosServer(context); // const axios = await axiosServer(context);
// const { data: publishers } = await axios.get(`api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isactive,desiredShiftsPerMonth`); // const { data: publishers } = await axios.get(`api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
// api/index?action=filterPublishers&assignments=true&availabilities=true&date=2024-03-14&select=id%2CfirstName%2ClastName%2Cisactive%2CdesiredShiftsPerMonth // api/index?action=filterPublishers&assignments=true&availabilities=true&date=2024-03-14&select=id%2CfirstName%2ClastName%2CisActive%2CdesiredShiftsPerMonth
publishers.forEach(publisher => { publishers.forEach(publisher => {
publisher.desiredShiftsPerMonth = publisher.desiredShiftsPerMonth || 0; publisher.desiredShiftsPerMonth = publisher.desiredShiftsPerMonth || 0;
publisher.assignments = publisher.assignments || []; publisher.assignments = publisher.assignments || [];

View File

@ -74,6 +74,18 @@ export default function Reports() {
Добави нов отчет Добави нов отчет
</button> </button>
</Link> </Link>
<label className="mr-4">
<input type="radio" name="reportType" value="ServiceReport" defaultChecked />
Отчети
</label>
<label className="mr-4">
<input type="radio" name="reportType" value="Experience" />
Случка
</label>
<label className="mr-4">
<input type="radio" name="reportType" value="Feedback" />
Отзиви
</label>
<div className="mt-4 w-full overflow-x-auto"> <div className="mt-4 w-full overflow-x-auto">
<table className="w-full table-auto"> <table className="w-full table-auto">
<thead> <thead>

View File

@ -86,7 +86,7 @@ async function getAvailabilities(userId) {
select: { select: {
id: true, id: true,
name: true, name: true,
isactive: true, isActive: true,
isFromPreviousAssignment: true, isFromPreviousAssignment: true,
dayofweek: true, dayofweek: true,
dayOfMonth: true, dayOfMonth: true,
@ -121,7 +121,7 @@ async function getAvailabilities(userId) {
shiftId Int shiftId Int
publisher Publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade) publisher Publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade)
publisherId String publisherId String
isactive Boolean @default(true) isActive Boolean @default(true)
isConfirmed Boolean @default(false) isConfirmed Boolean @default(false)
isWithTransport Boolean @default(false) isWithTransport Boolean @default(false)
Report Report[] Report Report[]
@ -133,7 +133,7 @@ async function getAvailabilities(userId) {
}, },
select: { select: {
id: true, id: true,
isTentative: true, isBySystem: true,
isConfirmed: true, isConfirmed: true,
isWithTransport: true, isWithTransport: true,
shift: { shift: {

View File

@ -13,7 +13,7 @@ export const publisherSelectWithAvCount = {
select: { select: {
availability: { availability: {
where: { where: {
isactive: true isActive: true
} }
} }
@ -40,7 +40,7 @@ export const publisherSelect = {
// endTime: true, // endTime: true,
// dayOfMonth: true, // dayOfMonth: true,
// dayofweek: true, // dayofweek: true,
// isactive: true, // isActive: true,
// count: 'Availability_count' // count: 'Availability_count'
// } // }
// } // }

View File

@ -5,7 +5,7 @@ CREATE TABLE `Publisher` (
`lastName` VARCHAR(191) NOT NULL, `lastName` VARCHAR(191) NOT NULL,
`email` VARCHAR(191) NOT NULL, `email` VARCHAR(191) NOT NULL,
`phone` VARCHAR(191) NULL, `phone` VARCHAR(191) NULL,
`isactive` BOOLEAN NOT NULL DEFAULT true, `isActive` BOOLEAN NOT NULL DEFAULT true,
`age` INTEGER NULL, `age` INTEGER NULL,
UNIQUE INDEX `Publisher_email_key`(`email`), UNIQUE INDEX `Publisher_email_key`(`email`),
@ -41,7 +41,7 @@ CREATE TABLE `Shift` (
`name` VARCHAR(191) NOT NULL, `name` VARCHAR(191) NOT NULL,
`startTime` DATETIME(3) NOT NULL, `startTime` DATETIME(3) NOT NULL,
`endTime` DATETIME(3) NOT NULL, `endTime` DATETIME(3) NOT NULL,
`isactive` BOOLEAN NOT NULL DEFAULT true, `isActive` BOOLEAN NOT NULL DEFAULT true,
`requiresTransport` BOOLEAN NOT NULL DEFAULT false, `requiresTransport` BOOLEAN NOT NULL DEFAULT false,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@ -52,7 +52,7 @@ CREATE TABLE `Location` (
`id` INTEGER NOT NULL AUTO_INCREMENT, `id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL, `name` VARCHAR(191) NOT NULL,
`address` VARCHAR(191) NOT NULL, `address` VARCHAR(191) NOT NULL,
`isactive` BOOLEAN NOT NULL DEFAULT true, `isActive` BOOLEAN NOT NULL DEFAULT true,
`dayofweek` ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') NOT NULL, `dayofweek` ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)

View File

@ -6,10 +6,10 @@
*/ */
-- AlterTable -- AlterTable
ALTER TABLE `Availability` ADD COLUMN `isactive` BOOLEAN NOT NULL DEFAULT true; ALTER TABLE `Availability` ADD COLUMN `isActive` BOOLEAN NOT NULL DEFAULT true;
-- AlterTable -- AlterTable
ALTER TABLE `CartEvent` ADD COLUMN `isactive` BOOLEAN NOT NULL DEFAULT true, ALTER TABLE `CartEvent` ADD COLUMN `isActive` BOOLEAN NOT NULL DEFAULT true,
ADD COLUMN `locationId` INTEGER NOT NULL, ADD COLUMN `locationId` INTEGER NOT NULL,
ADD COLUMN `shiftDuration` INTEGER NOT NULL; ADD COLUMN `shiftDuration` INTEGER NOT NULL;

View File

@ -18,7 +18,7 @@ CREATE TABLE `Assignment` (
`id` INTEGER NOT NULL AUTO_INCREMENT, `id` INTEGER NOT NULL AUTO_INCREMENT,
`shiftId` INTEGER NOT NULL, `shiftId` INTEGER NOT NULL,
`publisherId` INTEGER NOT NULL, `publisherId` INTEGER NOT NULL,
`isactive` BOOLEAN NOT NULL DEFAULT true, `isActive` BOOLEAN NOT NULL DEFAULT true,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

View File

@ -1,11 +1,11 @@
/* /*
Warnings: Warnings:
- You are about to drop the column `isactive` on the `assignment` table. All the data in the column will be lost. - You are about to drop the column `isActive` on the `assignment` table. All the data in the column will be lost.
*/ */
-- AlterTable -- AlterTable
ALTER TABLE `Assignment` DROP COLUMN `isactive`, ALTER TABLE `Assignment` DROP COLUMN `isActive`,
ADD COLUMN `isTentative` BOOLEAN NOT NULL DEFAULT false; ADD COLUMN `isTentative` BOOLEAN NOT NULL DEFAULT false;
-- AlterTable -- AlterTable

View File

@ -0,0 +1,15 @@
/*
Warnings:
- You are about to drop the column `isTentative` on the `Assignment` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE `Assignment`
ADD COLUMN `isBySystem` BOOLEAN NOT NULL DEFAULT false;
UPDATE `Assignment` SET `isBySystem` = isTentative;
ALTER TABLE `Assignment` DROP COLUMN `isTentative`,
-- AlterTable
ALTER TABLE `Report` ADD COLUMN `type` ENUM('ServiceReport', 'Experience', 'Feedback_Problem', 'Feedback_Suggestion', 'Feedback') NOT NULL DEFAULT 'ServiceReport';

View File

@ -81,13 +81,21 @@ enum PublisherType {
SpecialPioneer_Missionary SpecialPioneer_Missionary
} }
enum ReportType {
ServiceReport
Experience
Feedback_Problem
Feedback_Suggestion
Feedback
}
model Publisher { model Publisher {
id String @id @default(cuid()) id String @id @default(cuid())
firstName String firstName String
lastName String lastName String
email String @unique email String @unique
phone String? phone String?
isactive Boolean @default(true) isActive Boolean @default(true)
isImported Boolean @default(false) isImported Boolean @default(false)
isTrained Boolean @default(false) isTrained Boolean @default(false)
age Int? age Int?
@ -124,7 +132,7 @@ model Availability {
weekOfMonth Int? weekOfMonth Int?
startTime DateTime startTime DateTime
endTime DateTime endTime DateTime
isactive Boolean @default(true) isActive Boolean @default(true)
type AvailabilityType @default(Weekly) type AvailabilityType @default(Weekly)
isWithTransportIn Boolean @default(false) isWithTransportIn Boolean @default(false)
isWithTransportOut Boolean @default(false) isWithTransportOut Boolean @default(false)
@ -143,7 +151,7 @@ model CartEvent {
shiftDuration Int shiftDuration Int
shifts Shift[] shifts Shift[]
dayofweek DayOfWeek dayofweek DayOfWeek
isactive Boolean @default(true) isActive Boolean @default(true)
location Location @relation(fields: [locationId], references: [id]) location Location @relation(fields: [locationId], references: [id])
locationId Int locationId Int
eventType EventType @default(PW_Cart) eventType EventType @default(PW_Cart)
@ -160,7 +168,7 @@ model Shift {
name String name String
startTime DateTime startTime DateTime
endTime DateTime endTime DateTime
isactive Boolean @default(true) isActive Boolean @default(true)
requiresTransport Boolean @default(false) requiresTransport Boolean @default(false)
notes String? notes String?
//date DateTime //date DateTime
@ -177,7 +185,7 @@ model Assignment {
shiftId Int shiftId Int
publisher Publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade) publisher Publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade)
publisherId String publisherId String
isTentative Boolean @default(false) // if no availability for it, when importing previous schedules isBySystem Boolean @default(false) // if no availability for it, when importing previous schedules
isConfirmed Boolean @default(false) isConfirmed Boolean @default(false)
isWithTransport Boolean @default(false) isWithTransport Boolean @default(false)
isMailSent Boolean @default(false) isMailSent Boolean @default(false)
@ -190,7 +198,7 @@ model Location {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
name String name String
address String address String
isactive Boolean @default(true) isActive Boolean @default(true)
content String? @db.LongText content String? @db.LongText
cartEvents CartEvent[] cartEvents CartEvent[]
reports Report[] reports Report[]
@ -220,6 +228,7 @@ model Report {
conversationCount Int? conversationCount Int?
experienceInfo String? @db.LongText experienceInfo String? @db.LongText
type ReportType @default(ServiceReport)
@@map("Report") @@map("Report")
} }

View File

@ -30,7 +30,7 @@ INSERT INTO
`id`, `id`,
`name`, `name`,
`address`, `address`,
`isactive` `isActive`
) )
VALUES ( VALUES (
1, 1,
@ -57,7 +57,7 @@ INSERT INTO
`startTime`, `startTime`,
`endTime`, `endTime`,
`dayofweek`, `dayofweek`,
`isactive`, `isActive`,
`locationId`, `locationId`,
`shiftDuration`, `shiftDuration`,
`eventType`, `eventType`,
@ -147,7 +147,7 @@ VALUES (
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */ /*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */
; ;
-- INSERT INTO `cartevent` (`id`, `startTime`, `endTime`, `dayofweek`, `isactive`, `locationId`, `shiftDuration`, `eventType`, `numberOfPublishers`) -- INSERT INTO `cartevent` (`id`, `startTime`, `endTime`, `dayofweek`, `isActive`, `locationId`, `shiftDuration`, `eventType`, `numberOfPublishers`)
-- VALUES -- VALUES
-- (2, '2023-12-27 07:00:33.174', '2023-12-27 16:00:33.174', 'Tuesday', 1, 2, 90, 'PW_Cart', 4), -- (2, '2023-12-27 07:00:33.174', '2023-12-27 16:00:33.174', 'Tuesday', 1, 2, 90, 'PW_Cart', 4),
-- (3, '2023-12-28 07:00:33.174', '2023-12-28 16:00:33.174', 'Wednesday', 1, 3, 90, 'PW_Cart', 4), -- (3, '2023-12-28 07:00:33.174', '2023-12-28 16:00:33.174', 'Wednesday', 1, 3, 90, 'PW_Cart', 4),

View File

@ -259,7 +259,7 @@ nextApp
var shifts = await prisma.shift.findMany({ var shifts = await prisma.shift.findMany({
where: { where: {
isactive: true, isActive: true,
startTime: { startTime: {
gte: fromDate, gte: fromDate,
lt: toDate, lt: toDate,
@ -410,7 +410,7 @@ nextApp
var publishers = await prisma.publisher.findMany({ var publishers = await prisma.publisher.findMany({
where: { where: {
isactive: true, isActive: true,
email: { email: {
not: "", not: "",
}, },

View File

@ -147,7 +147,7 @@ async function getAvailabilities(userId) {
select: { select: {
id: true, id: true,
name: true, name: true,
isactive: true, isActive: true,
isFromPreviousAssignment: true, isFromPreviousAssignment: true,
dayofweek: true, dayofweek: true,
dayOfMonth: true, dayOfMonth: true,
@ -182,7 +182,7 @@ async function getAvailabilities(userId) {
shiftId Int shiftId Int
publisher Publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade) publisher Publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade)
publisherId String publisherId String
isactive Boolean @default(true) isActive Boolean @default(true)
isConfirmed Boolean @default(false) isConfirmed Boolean @default(false)
isWithTransport Boolean @default(false) isWithTransport Boolean @default(false)
Report Report[] Report Report[]
@ -194,7 +194,7 @@ async function getAvailabilities(userId) {
}, },
select: { select: {
id: true, id: true,
isTentative: true, isBySystem: true,
isConfirmed: true, isConfirmed: true,
isWithTransport: true, isWithTransport: true,
shift: { shift: {

View File

@ -323,21 +323,21 @@ exports.processEvents = async function (events, year, monthNumber, progressCallb
} }
var shifts = await prisma.shift.findMany({ var shifts = await prisma.shift.findMany({
where: { where: {
isactive: true, isActive: true,
startTime: { startTime: {
gte: monthDatesInfo.firstMonday, gte: monthDatesInfo.firstMonday,
lt: monthDatesInfo.lastSunday, lt: monthDatesInfo.lastSunday,
}, },
} }
}); });
var locations = await prisma.location.findMany({ where: { isactive: true, } }); var locations = await prisma.location.findMany({ where: { isActive: true, } });
var cartEvents = await prisma.cartEvent.findMany({ where: { isactive: true, } }); var cartEvents = await prisma.cartEvent.findMany({ where: { isActive: true, } });
var publishers = await prisma.publisher.findMany({ var publishers = await prisma.publisher.findMany({
where: { isactive: true, }, where: { isActive: true, },
include: { include: {
availabilities: { where: { isactive: true, }, }, availabilities: { where: { isActive: true, }, },
assignments: { include: { shift: true, }, }, assignments: { include: { shift: true, }, },
}, },
}); });
@ -472,7 +472,7 @@ exports.processEvents = async function (events, year, monthNumber, progressCallb
email: name.toLowerCase().replace(/ /g, "."), // + "@gmail.com" email: name.toLowerCase().replace(/ /g, "."), // + "@gmail.com"
firstName: firstname, firstName: firstname,
lastName: lastname, lastName: lastname,
isactive: true, isActive: true,
isImported: true, isImported: true,
// role: "EXTERNAL", // role: "EXTERNAL",
}; };
@ -492,7 +492,7 @@ exports.processEvents = async function (events, year, monthNumber, progressCallb
// endTime: endTime, // endTime: endTime,
// name: `от предишен график, ${publisher.firstName} ${publisher.lastName}`, // name: `от предишен график, ${publisher.firstName} ${publisher.lastName}`,
// isFromPreviousAssignment: true, // isFromPreviousAssignment: true,
// isactive: true, // isActive: true,
// }, // },
// }); // });
// console.log(`Created WEEKLY availability with ID ${availability.id} for date '${date.toDateString()}' and publisher '${publisher.firstName} ${publisher.lastName}'`); // console.log(`Created WEEKLY availability with ID ${availability.id} for date '${date.toDateString()}' and publisher '${publisher.firstName} ${publisher.lastName}'`);

View File

@ -11,7 +11,7 @@ SELECT DISTINCT Publisher.*
FROM Publisher FROM Publisher
INNER JOIN Availability ON Availability.publisherId = Publisher.id INNER JOIN Availability ON Availability.publisherId = Publisher.id
WHERE WHERE
Availability.isactive = true Availability.isActive = true
AND ( ( AND ( (
Availability.dayOfMonth IS NOT NULL Availability.dayOfMonth IS NOT NULL
AND Availability.startTime <= '2023-03-30 13:00:00' AND Availability.startTime <= '2023-03-30 13:00:00'
@ -30,7 +30,7 @@ SELECT DISTINCT Publisher.*
FROM Publisher FROM Publisher
INNER JOIN Availability ON Availability.publisherId = Publisher.id INNER JOIN Availability ON Availability.publisherId = Publisher.id
WHERE WHERE
Availability.isactive = true Availability.isActive = true
AND (Availability.dayOfMonth = 5) clfuyo33e005aknvchf1wm3bu All publishers: 121; AND (Availability.dayOfMonth = 5) clfuyo33e005aknvchf1wm3bu All publishers: 121;
(118) unique, (118) unique,