IO-3262 Tech Console Job Clock Out
Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -16,7 +16,7 @@ const mapDispatchToProps = () => ({
|
|||||||
export function TechHeader({ technician }) {
|
export function TechHeader({ technician }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<Header style={{ textAlign: "center" }}>
|
<Header style={{ textAlign: "center", height: "auto", overflow: "visible" }}>
|
||||||
<Typography.Title style={{ color: "#fff" }}>
|
<Typography.Title style={{ color: "#fff" }}>
|
||||||
{technician
|
{technician
|
||||||
? t("tech.labels.loggedin", {
|
? t("tech.labels.loggedin", {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useMutation, useQuery } from "@apollo/client";
|
import { useMutation, useQuery } from "@apollo/client";
|
||||||
import { Button, Card, Col, Form, InputNumber, Popover, Row, Select } from "antd";
|
import { Button, Card, Form, InputNumber, Popover, Select, Space } from "antd";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -124,103 +124,12 @@ export function TechClockOffButton({
|
|||||||
cost_center: isShiftTicket ? "timetickets.labels.shift" : technician ? technician.cost_center : null
|
cost_center: isShiftTicket ? "timetickets.labels.shift" : technician ? technician.cost_center : null
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Row gutter={[16, 16]}>
|
<Space direction="vertical">
|
||||||
<Col span={!isShiftTicket ? 8 : 24}>
|
{!isShiftTicket ? (
|
||||||
{!isShiftTicket ? (
|
<div>
|
||||||
<div>
|
|
||||||
<Form.Item
|
|
||||||
label={t("timetickets.fields.actualhrs")}
|
|
||||||
name="actualhrs"
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber min={0} precision={1} />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("timetickets.fields.productivehrs")}
|
|
||||||
name="productivehrs"
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
},
|
|
||||||
({ getFieldValue }) => ({
|
|
||||||
validator(rule, value) {
|
|
||||||
if (!bodyshop.tt_enforce_hours_for_tech_console) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
if (!value || getFieldValue("cost_center") === null || !lineTicketData)
|
|
||||||
return Promise.resolve();
|
|
||||||
|
|
||||||
//Check the cost center,
|
|
||||||
const totals = CalculateAllocationsTotals(
|
|
||||||
bodyshop,
|
|
||||||
lineTicketData.joblines,
|
|
||||||
lineTicketData.timetickets,
|
|
||||||
lineTicketData.jobs_by_pk.lbr_adjustments
|
|
||||||
);
|
|
||||||
|
|
||||||
const fieldTypeToCheck =
|
|
||||||
bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber ? "mod_lbr_ty" : "cost_center";
|
|
||||||
|
|
||||||
const costCenterDiff =
|
|
||||||
Math.round(
|
|
||||||
totals.find((total) => total[fieldTypeToCheck] === getFieldValue("cost_center"))
|
|
||||||
?.difference * 10
|
|
||||||
) / 10;
|
|
||||||
|
|
||||||
if (value > costCenterDiff)
|
|
||||||
return Promise.reject(t("timetickets.validation.hoursenteredmorethanavailable"));
|
|
||||||
else {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber min={0} precision={1} />
|
|
||||||
</Form.Item>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
<Form.Item
|
|
||||||
name="cost_center"
|
|
||||||
label={t("timetickets.fields.cost_center")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Select disabled={isShiftTicket}>
|
|
||||||
{isShiftTicket ? (
|
|
||||||
<Select.Option value="timetickets.labels.shift">{t("timetickets.labels.shift")}</Select.Option>
|
|
||||||
) : (
|
|
||||||
emps &&
|
|
||||||
emps.rates.map((item) => (
|
|
||||||
<Select.Option key={item.cost_center}>
|
|
||||||
{item.cost_center === "timetickets.labels.shift"
|
|
||||||
? t(item.cost_center)
|
|
||||||
: bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
|
|
||||||
? t(`joblines.fields.lbr_types.${item.cost_center.toUpperCase()}`)
|
|
||||||
: item.cost_center}
|
|
||||||
</Select.Option>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
{isShiftTicket ? (
|
|
||||||
<div></div>
|
|
||||||
) : (
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="status"
|
label={t("timetickets.fields.actualhrs")}
|
||||||
label={t("jobs.fields.status")}
|
name="actualhrs"
|
||||||
initialValue={lineTicketData && lineTicketData.jobs_by_pk.status}
|
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true
|
required: true
|
||||||
@@ -228,35 +137,117 @@ export function TechClockOffButton({
|
|||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select>
|
<InputNumber min={0} precision={1} />
|
||||||
{bodyshop.md_ro_statuses.production_statuses.map((item) => (
|
|
||||||
<Select.Option key={item}></Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
<Form.Item
|
||||||
<Button type="primary" htmlType="submit" loading={loading}>
|
label={t("timetickets.fields.productivehrs")}
|
||||||
{t("general.actions.save")}
|
name="productivehrs"
|
||||||
</Button>
|
rules={[
|
||||||
<TechJobClockoutDelete completedCallback={completedCallback} timeTicketId={timeTicketId} />
|
{
|
||||||
</Col>
|
required: true
|
||||||
{!isShiftTicket && (
|
//message: t("general.validation.required"),
|
||||||
<Col span={16}>
|
},
|
||||||
<LaborAllocationContainer
|
({ getFieldValue }) => ({
|
||||||
jobid={jobId || null}
|
validator(rule, value) {
|
||||||
loading={queryLoading}
|
if (!bodyshop.tt_enforce_hours_for_tech_console) {
|
||||||
lineTicketData={lineTicketData}
|
return Promise.resolve();
|
||||||
/>
|
}
|
||||||
</Col>
|
if (!value || getFieldValue("cost_center") === null || !lineTicketData)
|
||||||
|
return Promise.resolve();
|
||||||
|
//Check the cost center,
|
||||||
|
const totals = CalculateAllocationsTotals(
|
||||||
|
bodyshop,
|
||||||
|
lineTicketData.joblines,
|
||||||
|
lineTicketData.timetickets,
|
||||||
|
lineTicketData.jobs_by_pk.lbr_adjustments
|
||||||
|
);
|
||||||
|
const fieldTypeToCheck =
|
||||||
|
bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber ? "mod_lbr_ty" : "cost_center";
|
||||||
|
const costCenterDiff =
|
||||||
|
Math.round(
|
||||||
|
totals.find((total) => total[fieldTypeToCheck] === getFieldValue("cost_center"))
|
||||||
|
?.difference * 10
|
||||||
|
) / 10;
|
||||||
|
if (value > costCenterDiff)
|
||||||
|
return Promise.reject(t("timetickets.validation.hoursenteredmorethanavailable"));
|
||||||
|
else {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber min={0} precision={1} />
|
||||||
|
</Form.Item>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<Form.Item
|
||||||
|
name="cost_center"
|
||||||
|
label={t("timetickets.fields.cost_center")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select disabled={isShiftTicket}>
|
||||||
|
{isShiftTicket ? (
|
||||||
|
<Select.Option value="timetickets.labels.shift">{t("timetickets.labels.shift")}</Select.Option>
|
||||||
|
) : (
|
||||||
|
emps &&
|
||||||
|
emps.rates.map((item) => (
|
||||||
|
<Select.Option key={item.cost_center}>
|
||||||
|
{item.cost_center === "timetickets.labels.shift"
|
||||||
|
? t(item.cost_center)
|
||||||
|
: bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
|
||||||
|
? t(`joblines.fields.lbr_types.${item.cost_center.toUpperCase()}`)
|
||||||
|
: item.cost_center}
|
||||||
|
</Select.Option>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
{isShiftTicket ? (
|
||||||
|
<div></div>
|
||||||
|
) : (
|
||||||
|
<Form.Item
|
||||||
|
name="status"
|
||||||
|
label={t("jobs.fields.status")}
|
||||||
|
initialValue={lineTicketData && lineTicketData.jobs_by_pk.status}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select>
|
||||||
|
{bodyshop.md_ro_statuses.production_statuses.map((item) => (
|
||||||
|
<Select.Option key={item}></Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
</Row>
|
<Button type="primary" htmlType="submit" loading={loading}>
|
||||||
|
{t("general.actions.save")}
|
||||||
|
</Button>
|
||||||
|
<TechJobClockoutDelete completedCallback={completedCallback} timeTicketId={timeTicketId} />
|
||||||
|
{!isShiftTicket && (
|
||||||
|
<LaborAllocationContainer jobid={jobId || null} loading={queryLoading} lineTicketData={lineTicketData} />
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover content={overlay} trigger="click">
|
<Popover
|
||||||
|
content={<div style={{ maxHeight: "75vh", overflowY: "auto" }}>{overlay}</div>}
|
||||||
|
trigger="click"
|
||||||
|
getPopupContainer={() => document.querySelector('#time-ticket-modal')}
|
||||||
|
>
|
||||||
<Button loading={loading} {...otherBtnProps}>
|
<Button loading={loading} {...otherBtnProps}>
|
||||||
{t("timetickets.actions.clockout")}
|
{t("timetickets.actions.clockout")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user