// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.28.0
// source: trackhygiene.sql

package db

import (
	"context"
	"database/sql"
	"time"
)

const checkInspectionReportByConsignment = `-- name: CheckInspectionReportByConsignment :one
 SELECT EXISTS(
      SELECT 1 FROM inspectionreportrecommendation
      WHERE consignment_no = $1
 )
`

func (q *Queries) CheckInspectionReportByConsignment(ctx context.Context, consignmentNo string) (bool, error) {
	row := q.db.QueryRowContext(ctx, checkInspectionReportByConsignment, consignmentNo)
	var exists bool
	err := row.Scan(&exists)
	return exists, err
}

const createInspectionRecommendation = `-- name: CreateInspectionRecommendation :one
INSERT INTO inspectionreportrecommendation (
    consignment_no,
    consignment_status,
    comment,
    user_id,
    exportcompany_id
 ) VALUES (
    $1, 
    $2, 
    $3, 
    $4, 
    $5
 ) RETURNING id, consignment_no, consignment_status, comment, phytocertificate, user_id, exportcompany_id, created_at
`

type CreateInspectionRecommendationParams struct {
	ConsignmentNo     string         `json:"consignment_no"`
	ConsignmentStatus string         `json:"consignment_status"`
	Comment           sql.NullString `json:"comment"`
	UserID            int32          `json:"user_id"`
	ExportcompanyID   int32          `json:"exportcompany_id"`
}

func (q *Queries) CreateInspectionRecommendation(ctx context.Context, arg CreateInspectionRecommendationParams) (Inspectionreportrecommendation, error) {
	row := q.db.QueryRowContext(ctx, createInspectionRecommendation,
		arg.ConsignmentNo,
		arg.ConsignmentStatus,
		arg.Comment,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Inspectionreportrecommendation
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.ConsignmentStatus,
		&i.Comment,
		&i.Phytocertificate,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createInspectionReportRecommendation = `-- name: CreateInspectionReportRecommendation :one
INSERT INTO inspectionreportrecommendation (
    consignment_no,
    consignment_status,
    comment,
    phytocertificate,
    user_id,
    exportcompany_id
 ) VALUES (
    $1, 
    $2, 
    $3, 
    $4, 
    $5,
    $6
 ) RETURNING id, consignment_no, consignment_status, comment, phytocertificate, user_id, exportcompany_id, created_at
`

type CreateInspectionReportRecommendationParams struct {
	ConsignmentNo     string         `json:"consignment_no"`
	ConsignmentStatus string         `json:"consignment_status"`
	Comment           sql.NullString `json:"comment"`
	Phytocertificate  sql.NullString `json:"phytocertificate"`
	UserID            int32          `json:"user_id"`
	ExportcompanyID   int32          `json:"exportcompany_id"`
}

func (q *Queries) CreateInspectionReportRecommendation(ctx context.Context, arg CreateInspectionReportRecommendationParams) (Inspectionreportrecommendation, error) {
	row := q.db.QueryRowContext(ctx, createInspectionReportRecommendation,
		arg.ConsignmentNo,
		arg.ConsignmentStatus,
		arg.Comment,
		arg.Phytocertificate,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Inspectionreportrecommendation
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.ConsignmentStatus,
		&i.Comment,
		&i.Phytocertificate,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createInspectionReports = `-- name: CreateInspectionReports :one
INSERT INTO inspectionreport (
    consignment_no,
    notes,
    instruction,
    user_id,
    exportcompany_id
 ) VALUES (
    $1, 
    $2, 
    $3, 
    $4, 
    $5
 ) RETURNING id, consignment_no, notes, instruction, user_id, exportcompany_id, created_at
`

type CreateInspectionReportsParams struct {
	ConsignmentNo   string `json:"consignment_no"`
	Notes           string `json:"notes"`
	Instruction     string `json:"instruction"`
	UserID          int32  `json:"user_id"`
	ExportcompanyID int32  `json:"exportcompany_id"`
}

func (q *Queries) CreateInspectionReports(ctx context.Context, arg CreateInspectionReportsParams) (Inspectionreport, error) {
	row := q.db.QueryRowContext(ctx, createInspectionReports,
		arg.ConsignmentNo,
		arg.Notes,
		arg.Instruction,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Inspectionreport
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.Notes,
		&i.Instruction,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createTrackHygiene = `-- name: CreateTrackHygiene :one
INSERT INTO trackhygiene (
    type,
    requirement
 ) VALUES (
    $1, $2
 ) RETURNING id, type, requirement, created_at
`

type CreateTrackHygieneParams struct {
	Type        string `json:"type"`
	Requirement string `json:"requirement"`
}

func (q *Queries) CreateTrackHygiene(ctx context.Context, arg CreateTrackHygieneParams) (Trackhygiene, error) {
	row := q.db.QueryRowContext(ctx, createTrackHygiene, arg.Type, arg.Requirement)
	var i Trackhygiene
	err := row.Scan(
		&i.ID,
		&i.Type,
		&i.Requirement,
		&i.CreatedAt,
	)
	return i, err
}

const createTrackHygienesCheckList = `-- name: CreateTrackHygienesCheckList :one
INSERT INTO trackhygienereport_checklist (
    trackhygienereport_id,
    trackhygiene_id
 ) VALUES (
    $1,
    $2
 ) RETURNING id, trackhygienereport_id, trackhygiene_id, created_at
`

type CreateTrackHygienesCheckListParams struct {
	TrackhygienereportID int32 `json:"trackhygienereport_id"`
	TrackhygieneID       int32 `json:"trackhygiene_id"`
}

func (q *Queries) CreateTrackHygienesCheckList(ctx context.Context, arg CreateTrackHygienesCheckListParams) (TrackhygienereportChecklist, error) {
	row := q.db.QueryRowContext(ctx, createTrackHygienesCheckList, arg.TrackhygienereportID, arg.TrackhygieneID)
	var i TrackhygienereportChecklist
	err := row.Scan(
		&i.ID,
		&i.TrackhygienereportID,
		&i.TrackhygieneID,
		&i.CreatedAt,
	)
	return i, err
}

const createTrackHygienesReport = `-- name: CreateTrackHygienesReport :one
INSERT INTO trackhygienereport (
    truckimage,
    consignment_no,
    vehicleregno
 ) VALUES (
    $1,
    $2,
    $3
 ) RETURNING id, truckimage, consignment_no, vehicleregno, date, detergent, refrigerationstatus, created_at, report_status, checklist_status
`

type CreateTrackHygienesReportParams struct {
	Truckimage    sql.NullString `json:"truckimage"`
	ConsignmentNo sql.NullString `json:"consignment_no"`
	Vehicleregno  sql.NullString `json:"vehicleregno"`
}

func (q *Queries) CreateTrackHygienesReport(ctx context.Context, arg CreateTrackHygienesReportParams) (Trackhygienereport, error) {
	row := q.db.QueryRowContext(ctx, createTrackHygienesReport, arg.Truckimage, arg.ConsignmentNo, arg.Vehicleregno)
	var i Trackhygienereport
	err := row.Scan(
		&i.ID,
		&i.Truckimage,
		&i.ConsignmentNo,
		&i.Vehicleregno,
		&i.Date,
		&i.Detergent,
		&i.Refrigerationstatus,
		&i.CreatedAt,
		&i.ReportStatus,
		&i.ChecklistStatus,
	)
	return i, err
}

const deleteTruckHygieneChecklist = `-- name: DeleteTruckHygieneChecklist :exec
DELETE FROM trackhygienereport_checklist WHERE trackhygienereport_id= $1
`

func (q *Queries) DeleteTruckHygieneChecklist(ctx context.Context, trackhygienereportID int32) error {
	_, err := q.db.ExecContext(ctx, deleteTruckHygieneChecklist, trackhygienereportID)
	return err
}

const deleteTruckHygieneReport = `-- name: DeleteTruckHygieneReport :exec
DELETE FROM trackhygienereport 
WHERE id= $1
`

func (q *Queries) DeleteTruckHygieneReport(ctx context.Context, id int64) error {
	_, err := q.db.ExecContext(ctx, deleteTruckHygieneReport, id)
	return err
}

const getInspectionRecommendationByConsignment = `-- name: GetInspectionRecommendationByConsignment :one
SELECT id, consignment_no, consignment_status, comment, phytocertificate, user_id, exportcompany_id, created_at FROM inspectionreportrecommendation
WHERE consignment_no = $1 LIMIT 1
`

func (q *Queries) GetInspectionRecommendationByConsignment(ctx context.Context, consignmentNo string) (Inspectionreportrecommendation, error) {
	row := q.db.QueryRowContext(ctx, getInspectionRecommendationByConsignment, consignmentNo)
	var i Inspectionreportrecommendation
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.ConsignmentStatus,
		&i.Comment,
		&i.Phytocertificate,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const getInspectionReportByConsignment = `-- name: GetInspectionReportByConsignment :one
SELECT inspectionreport.consignment_no,inspectionreport.notes,
inspectionreport.instruction,inspectionreportrecommendation.consignment_status,inspectionreport.id,
inspectionreportrecommendation.comment,inspectionreportrecommendation.phytocertificate,inspectionreport.created_at,
users.fullname,users.signature,exportcompanies.expname,exportcompanies.logo,exportcompanies.id as exporter_id FROM inspectionreport
LEFT JOIN inspectionreportrecommendation on inspectionreportrecommendation.consignment_no = inspectionreport.consignment_no
JOIN  exportcompanies on exportcompanies.id = inspectionreport.exportcompany_id
JOIN  users           on users.id           = inspectionreport.user_id
WHERE inspectionreport.consignment_no = $1 
LIMIT 1
`

type GetInspectionReportByConsignmentRow struct {
	ConsignmentNo     string         `json:"consignment_no"`
	Notes             string         `json:"notes"`
	Instruction       string         `json:"instruction"`
	ConsignmentStatus sql.NullString `json:"consignment_status"`
	ID                int64          `json:"id"`
	Comment           sql.NullString `json:"comment"`
	Phytocertificate  sql.NullString `json:"phytocertificate"`
	CreatedAt         time.Time      `json:"created_at"`
	Fullname          string         `json:"fullname"`
	Signature         sql.NullString `json:"signature"`
	Expname           string         `json:"expname"`
	Logo              sql.NullString `json:"logo"`
	ExporterID        int64          `json:"exporter_id"`
}

func (q *Queries) GetInspectionReportByConsignment(ctx context.Context, consignmentNo string) (GetInspectionReportByConsignmentRow, error) {
	row := q.db.QueryRowContext(ctx, getInspectionReportByConsignment, consignmentNo)
	var i GetInspectionReportByConsignmentRow
	err := row.Scan(
		&i.ConsignmentNo,
		&i.Notes,
		&i.Instruction,
		&i.ConsignmentStatus,
		&i.ID,
		&i.Comment,
		&i.Phytocertificate,
		&i.CreatedAt,
		&i.Fullname,
		&i.Signature,
		&i.Expname,
		&i.Logo,
		&i.ExporterID,
	)
	return i, err
}

const getInspectionReportDetailsByConsignment = `-- name: GetInspectionReportDetailsByConsignment :one
SELECT EXISTS (
    SELECT 1 FROM inspectionreport
    WHERE consignment_no = $1
)
`

func (q *Queries) GetInspectionReportDetailsByConsignment(ctx context.Context, consignmentNo string) (bool, error) {
	row := q.db.QueryRowContext(ctx, getInspectionReportDetailsByConsignment, consignmentNo)
	var exists bool
	err := row.Scan(&exists)
	return exists, err
}

const getTrackHygiene = `-- name: GetTrackHygiene :one
SELECT id, type, requirement, created_at FROM trackhygiene
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetTrackHygiene(ctx context.Context, id int64) (Trackhygiene, error) {
	row := q.db.QueryRowContext(ctx, getTrackHygiene, id)
	var i Trackhygiene
	err := row.Scan(
		&i.ID,
		&i.Type,
		&i.Requirement,
		&i.CreatedAt,
	)
	return i, err
}

const getTrackHygienesCheckList = `-- name: GetTrackHygienesCheckList :many
SELECT trackhygienereport_id,trackhygiene.requirement,trackhygiene.type,trackhygiene_id from trackhygienereport_checklist
JOIN   trackhygiene on trackhygiene.id = trackhygienereport_checklist.trackhygiene_id
WHERE  trackhygienereport_id = $1
`

type GetTrackHygienesCheckListRow struct {
	TrackhygienereportID int32  `json:"trackhygienereport_id"`
	Requirement          string `json:"requirement"`
	Type                 string `json:"type"`
	TrackhygieneID       int32  `json:"trackhygiene_id"`
}

func (q *Queries) GetTrackHygienesCheckList(ctx context.Context, trackhygienereportID int32) ([]GetTrackHygienesCheckListRow, error) {
	rows, err := q.db.QueryContext(ctx, getTrackHygienesCheckList, trackhygienereportID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GetTrackHygienesCheckListRow{}
	for rows.Next() {
		var i GetTrackHygienesCheckListRow
		if err := rows.Scan(
			&i.TrackhygienereportID,
			&i.Requirement,
			&i.Type,
			&i.TrackhygieneID,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const getTruckHygieneByConsignment = `-- name: GetTruckHygieneByConsignment :one
SELECT EXISTS (
    SELECT 1 FROM trackhygienereport
    WHERE consignment_no = $1
)
`

func (q *Queries) GetTruckHygieneByConsignment(ctx context.Context, consignmentNo sql.NullString) (bool, error) {
	row := q.db.QueryRowContext(ctx, getTruckHygieneByConsignment, consignmentNo)
	var exists bool
	err := row.Scan(&exists)
	return exists, err
}

const getTruckHygieneDetailsByConsignment = `-- name: GetTruckHygieneDetailsByConsignment :one
SELECT trackhygienereport.truckimage,trackhygienereport.vehicleregno,
trackhygienereport.date,trackhygienereport.detergent,trackhygienereport.id as report_id,
trackhygienereport.refrigerationstatus,exportcompanies.expname,
exportcompanies.expregno,packhouses.phname,trackhygienereport.created_at as report_created_at,
users.signature,plannedconsignments.id as consignment__no,
exportcompanies.id as exporter_id FROM trackhygienereport
JOIN  plannedconsignments on plannedconsignments.id = trackhygienereport.consignment_no
JOIN  exportcompanies    on exportcompanies.id = plannedconsignments.exportcompany_id
JOIN  packhouse_exporter on packhouse_exporter.exportcompany_id = exportcompanies.id
JOIN  packhouses         on packhouses.id    = packhouse_exporter.packhouse_id
JOIN  users              on users.id         = plannedconsignments.user_id
WHERE trackhygienereport.consignment_no      = $1 LIMIT 1
`

type GetTruckHygieneDetailsByConsignmentRow struct {
	Truckimage          sql.NullString `json:"truckimage"`
	Vehicleregno        sql.NullString `json:"vehicleregno"`
	Date                sql.NullTime   `json:"date"`
	Detergent           sql.NullString `json:"detergent"`
	ReportID            int64          `json:"report_id"`
	Refrigerationstatus sql.NullString `json:"refrigerationstatus"`
	Expname             string         `json:"expname"`
	Expregno            string         `json:"expregno"`
	Phname              string         `json:"phname"`
	ReportCreatedAt     time.Time      `json:"report_created_at"`
	Signature           sql.NullString `json:"signature"`
	ConsignmentNo       string         `json:"consignment__no"`
	ExporterID          int64          `json:"exporter_id"`
}

func (q *Queries) GetTruckHygieneDetailsByConsignment(ctx context.Context, consignmentNo sql.NullString) (GetTruckHygieneDetailsByConsignmentRow, error) {
	row := q.db.QueryRowContext(ctx, getTruckHygieneDetailsByConsignment, consignmentNo)
	var i GetTruckHygieneDetailsByConsignmentRow
	err := row.Scan(
		&i.Truckimage,
		&i.Vehicleregno,
		&i.Date,
		&i.Detergent,
		&i.ReportID,
		&i.Refrigerationstatus,
		&i.Expname,
		&i.Expregno,
		&i.Phname,
		&i.ReportCreatedAt,
		&i.Signature,
		&i.ConsignmentNo,
		&i.ExporterID,
	)
	return i, err
}

const getTruckHygieneReportBased = `-- name: GetTruckHygieneReportBased :one
SELECT id, truckimage, consignment_no, vehicleregno, date, detergent, refrigerationstatus, created_at, report_status, checklist_status FROM trackhygienereport
WHERE vehicleregno= $1 AND 
consignment_no = $2 LIMIT 1
`

type GetTruckHygieneReportBasedParams struct {
	Vehicleregno  sql.NullString `json:"vehicleregno"`
	ConsignmentNo sql.NullString `json:"consignment_no"`
}

func (q *Queries) GetTruckHygieneReportBased(ctx context.Context, arg GetTruckHygieneReportBasedParams) (Trackhygienereport, error) {
	row := q.db.QueryRowContext(ctx, getTruckHygieneReportBased, arg.Vehicleregno, arg.ConsignmentNo)
	var i Trackhygienereport
	err := row.Scan(
		&i.ID,
		&i.Truckimage,
		&i.ConsignmentNo,
		&i.Vehicleregno,
		&i.Date,
		&i.Detergent,
		&i.Refrigerationstatus,
		&i.CreatedAt,
		&i.ReportStatus,
		&i.ChecklistStatus,
	)
	return i, err
}

const inspectionReportDetails = `-- name: InspectionReportDetails :one
SELECT inspectionreport.consignment_no,inspectionreport.notes,
inspectionreport.instruction,inspectionreport.user_id,
inspectionreport.exportcompany_id,users.fullname,users.signature FROM inspectionreport
JOIN users on users.id = inspectionreport.user_id
WHERE consignment_no = $1
`

type InspectionReportDetailsRow struct {
	ConsignmentNo   string         `json:"consignment_no"`
	Notes           string         `json:"notes"`
	Instruction     string         `json:"instruction"`
	UserID          int32          `json:"user_id"`
	ExportcompanyID int32          `json:"exportcompany_id"`
	Fullname        string         `json:"fullname"`
	Signature       sql.NullString `json:"signature"`
}

func (q *Queries) InspectionReportDetails(ctx context.Context, consignmentNo string) (InspectionReportDetailsRow, error) {
	row := q.db.QueryRowContext(ctx, inspectionReportDetails, consignmentNo)
	var i InspectionReportDetailsRow
	err := row.Scan(
		&i.ConsignmentNo,
		&i.Notes,
		&i.Instruction,
		&i.UserID,
		&i.ExportcompanyID,
		&i.Fullname,
		&i.Signature,
	)
	return i, err
}

const listTrackHygieneTrucks = `-- name: ListTrackHygieneTrucks :many
SELECT trackhygienereport.consignment_no,trackhygienereport.truckimage,trackhygienereport.id,
trackhygienereport.vehicleregno,plannedconsignments.user_id,trackhygienereport.created_at,
trackhygienereport.date,trackhygienereport.detergent,exportcompanies.id as exportcompany_id,
trackhygienereport.refrigerationstatus
from   trackhygienereport
JOIN   plannedconsignments on plannedconsignments.id = trackhygienereport.consignment_no
JOIN   exportcompanies     on exportcompanies.id = plannedconsignments.exportcompany_id
WHERE  plannedconsignments.id= $1
`

type ListTrackHygieneTrucksRow struct {
	ConsignmentNo       sql.NullString `json:"consignment_no"`
	Truckimage          sql.NullString `json:"truckimage"`
	ID                  int64          `json:"id"`
	Vehicleregno        sql.NullString `json:"vehicleregno"`
	UserID              int32          `json:"user_id"`
	CreatedAt           time.Time      `json:"created_at"`
	Date                sql.NullTime   `json:"date"`
	Detergent           sql.NullString `json:"detergent"`
	ExportcompanyID     int64          `json:"exportcompany_id"`
	Refrigerationstatus sql.NullString `json:"refrigerationstatus"`
}

func (q *Queries) ListTrackHygieneTrucks(ctx context.Context, id string) ([]ListTrackHygieneTrucksRow, error) {
	rows, err := q.db.QueryContext(ctx, listTrackHygieneTrucks, id)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListTrackHygieneTrucksRow{}
	for rows.Next() {
		var i ListTrackHygieneTrucksRow
		if err := rows.Scan(
			&i.ConsignmentNo,
			&i.Truckimage,
			&i.ID,
			&i.Vehicleregno,
			&i.UserID,
			&i.CreatedAt,
			&i.Date,
			&i.Detergent,
			&i.ExportcompanyID,
			&i.Refrigerationstatus,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listTrackHygienes = `-- name: ListTrackHygienes :many
SELECT id, type, requirement, created_at FROM trackhygiene
`

func (q *Queries) ListTrackHygienes(ctx context.Context) ([]Trackhygiene, error) {
	rows, err := q.db.QueryContext(ctx, listTrackHygienes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Trackhygiene{}
	for rows.Next() {
		var i Trackhygiene
		if err := rows.Scan(
			&i.ID,
			&i.Type,
			&i.Requirement,
			&i.CreatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listTruckHygienesReport = `-- name: ListTruckHygienesReport :many
SELECT trackhygiene.type as type_track, trackhygiene.id as trackhygiene_id  from trackhygienereport_checklist
JOIN  trackhygiene on trackhygiene.id = trackhygienereport_checklist.trackhygiene_id
WHERE trackhygienereport_id = $1
`

type ListTruckHygienesReportRow struct {
	TypeTrack      string `json:"type_track"`
	TrackhygieneID int64  `json:"trackhygiene_id"`
}

func (q *Queries) ListTruckHygienesReport(ctx context.Context, trackhygienereportID int32) ([]ListTruckHygienesReportRow, error) {
	rows, err := q.db.QueryContext(ctx, listTruckHygienesReport, trackhygienereportID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListTruckHygienesReportRow{}
	for rows.Next() {
		var i ListTruckHygienesReportRow
		if err := rows.Scan(&i.TypeTrack, &i.TrackhygieneID); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const trackHygienes = `-- name: TrackHygienes :many
SELECT id, type, requirement, created_at FROM trackhygiene
LIMIT  $1 OFFSET $2
`

type TrackHygienesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

func (q *Queries) TrackHygienes(ctx context.Context, arg TrackHygienesParams) ([]Trackhygiene, error) {
	rows, err := q.db.QueryContext(ctx, trackHygienes, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Trackhygiene{}
	for rows.Next() {
		var i Trackhygiene
		if err := rows.Scan(
			&i.ID,
			&i.Type,
			&i.Requirement,
			&i.CreatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const updateCheckListStatus = `-- name: UpdateCheckListStatus :one
UPDATE trackhygienereport
   set
    checklist_status = $2
   WHERE id = $1
 RETURNING id, truckimage, consignment_no, vehicleregno, date, detergent, refrigerationstatus, created_at, report_status, checklist_status
`

type UpdateCheckListStatusParams struct {
	ID              int64          `json:"id"`
	ChecklistStatus sql.NullString `json:"checklist_status"`
}

func (q *Queries) UpdateCheckListStatus(ctx context.Context, arg UpdateCheckListStatusParams) (Trackhygienereport, error) {
	row := q.db.QueryRowContext(ctx, updateCheckListStatus, arg.ID, arg.ChecklistStatus)
	var i Trackhygienereport
	err := row.Scan(
		&i.ID,
		&i.Truckimage,
		&i.ConsignmentNo,
		&i.Vehicleregno,
		&i.Date,
		&i.Detergent,
		&i.Refrigerationstatus,
		&i.CreatedAt,
		&i.ReportStatus,
		&i.ChecklistStatus,
	)
	return i, err
}

const updateInspectionReport = `-- name: UpdateInspectionReport :one
 UPDATE inspectionreport
   set
    notes = $2,
    instruction = $3
   WHERE id = $1
 RETURNING id, consignment_no, notes, instruction, user_id, exportcompany_id, created_at
`

type UpdateInspectionReportParams struct {
	ID          int64  `json:"id"`
	Notes       string `json:"notes"`
	Instruction string `json:"instruction"`
}

func (q *Queries) UpdateInspectionReport(ctx context.Context, arg UpdateInspectionReportParams) (Inspectionreport, error) {
	row := q.db.QueryRowContext(ctx, updateInspectionReport, arg.ID, arg.Notes, arg.Instruction)
	var i Inspectionreport
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.Notes,
		&i.Instruction,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const updateInspectionReportRecommendation = `-- name: UpdateInspectionReportRecommendation :one
UPDATE inspectionreportrecommendation
  SET
    consignment_status = $4,
    comment = $3,
    phytocertificate = $2
  WHERE consignment_no = $1
  RETURNING id, consignment_no, consignment_status, comment, phytocertificate, user_id, exportcompany_id, created_at
`

type UpdateInspectionReportRecommendationParams struct {
	ConsignmentNo     string         `json:"consignment_no"`
	Phytocertificate  sql.NullString `json:"phytocertificate"`
	Comment           sql.NullString `json:"comment"`
	ConsignmentStatus string         `json:"consignment_status"`
}

func (q *Queries) UpdateInspectionReportRecommendation(ctx context.Context, arg UpdateInspectionReportRecommendationParams) (Inspectionreportrecommendation, error) {
	row := q.db.QueryRowContext(ctx, updateInspectionReportRecommendation,
		arg.ConsignmentNo,
		arg.Phytocertificate,
		arg.Comment,
		arg.ConsignmentStatus,
	)
	var i Inspectionreportrecommendation
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.ConsignmentStatus,
		&i.Comment,
		&i.Phytocertificate,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const updateInspectionReportWithoutFileRecommendation = `-- name: UpdateInspectionReportWithoutFileRecommendation :one
UPDATE inspectionreportrecommendation
  SET
    consignment_status = $3,
    comment = $2
  WHERE consignment_no = $1

  RETURNING id, consignment_no, consignment_status, comment, phytocertificate, user_id, exportcompany_id, created_at
`

type UpdateInspectionReportWithoutFileRecommendationParams struct {
	ConsignmentNo     string         `json:"consignment_no"`
	Comment           sql.NullString `json:"comment"`
	ConsignmentStatus string         `json:"consignment_status"`
}

func (q *Queries) UpdateInspectionReportWithoutFileRecommendation(ctx context.Context, arg UpdateInspectionReportWithoutFileRecommendationParams) (Inspectionreportrecommendation, error) {
	row := q.db.QueryRowContext(ctx, updateInspectionReportWithoutFileRecommendation, arg.ConsignmentNo, arg.Comment, arg.ConsignmentStatus)
	var i Inspectionreportrecommendation
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.ConsignmentStatus,
		&i.Comment,
		&i.Phytocertificate,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const updateTrackHygienesCheckList = `-- name: UpdateTrackHygienesCheckList :one
 UPDATE trackhygienereport_checklist
   set
    trackhygiene_id = $2
   WHERE trackhygienereport_id = $1
 RETURNING id, trackhygienereport_id, trackhygiene_id, created_at
`

type UpdateTrackHygienesCheckListParams struct {
	TrackhygienereportID int32 `json:"trackhygienereport_id"`
	TrackhygieneID       int32 `json:"trackhygiene_id"`
}

func (q *Queries) UpdateTrackHygienesCheckList(ctx context.Context, arg UpdateTrackHygienesCheckListParams) (TrackhygienereportChecklist, error) {
	row := q.db.QueryRowContext(ctx, updateTrackHygienesCheckList, arg.TrackhygienereportID, arg.TrackhygieneID)
	var i TrackhygienereportChecklist
	err := row.Scan(
		&i.ID,
		&i.TrackhygienereportID,
		&i.TrackhygieneID,
		&i.CreatedAt,
	)
	return i, err
}

const updateTruckHygiene = `-- name: UpdateTruckHygiene :one
UPDATE trackhygienereport
  set 
  truckimage   = $2,
  vehicleregno = $3
WHERE consignment_no = $1
RETURNING id, truckimage, consignment_no, vehicleregno, date, detergent, refrigerationstatus, created_at, report_status, checklist_status
`

type UpdateTruckHygieneParams struct {
	ConsignmentNo sql.NullString `json:"consignment_no"`
	Truckimage    sql.NullString `json:"truckimage"`
	Vehicleregno  sql.NullString `json:"vehicleregno"`
}

func (q *Queries) UpdateTruckHygiene(ctx context.Context, arg UpdateTruckHygieneParams) (Trackhygienereport, error) {
	row := q.db.QueryRowContext(ctx, updateTruckHygiene, arg.ConsignmentNo, arg.Truckimage, arg.Vehicleregno)
	var i Trackhygienereport
	err := row.Scan(
		&i.ID,
		&i.Truckimage,
		&i.ConsignmentNo,
		&i.Vehicleregno,
		&i.Date,
		&i.Detergent,
		&i.Refrigerationstatus,
		&i.CreatedAt,
		&i.ReportStatus,
		&i.ChecklistStatus,
	)
	return i, err
}

const updateTruckHygienesReport = `-- name: UpdateTruckHygienesReport :one
UPDATE trackhygienereport
  set 
    consignment_no = $2,
    date = $3,
    detergent = $4,
    refrigerationstatus = $5
WHERE id = $1
RETURNING id, truckimage, consignment_no, vehicleregno, date, detergent, refrigerationstatus, created_at, report_status, checklist_status
`

type UpdateTruckHygienesReportParams struct {
	ID                  int64          `json:"id"`
	ConsignmentNo       sql.NullString `json:"consignment_no"`
	Date                sql.NullTime   `json:"date"`
	Detergent           sql.NullString `json:"detergent"`
	Refrigerationstatus sql.NullString `json:"refrigerationstatus"`
}

func (q *Queries) UpdateTruckHygienesReport(ctx context.Context, arg UpdateTruckHygienesReportParams) (Trackhygienereport, error) {
	row := q.db.QueryRowContext(ctx, updateTruckHygienesReport,
		arg.ID,
		arg.ConsignmentNo,
		arg.Date,
		arg.Detergent,
		arg.Refrigerationstatus,
	)
	var i Trackhygienereport
	err := row.Scan(
		&i.ID,
		&i.Truckimage,
		&i.ConsignmentNo,
		&i.Vehicleregno,
		&i.Date,
		&i.Detergent,
		&i.Refrigerationstatus,
		&i.CreatedAt,
		&i.ReportStatus,
		&i.ChecklistStatus,
	)
	return i, err
}

const updateTruckHygienesReportByID = `-- name: UpdateTruckHygienesReportByID :one
UPDATE trackhygienereport
  set 
    consignment_no = $2,
    date = $3,
    detergent = $4,
    refrigerationstatus = $5
WHERE id = $1
RETURNING id, truckimage, consignment_no, vehicleregno, date, detergent, refrigerationstatus, created_at, report_status, checklist_status
`

type UpdateTruckHygienesReportByIDParams struct {
	ID                  int64          `json:"id"`
	ConsignmentNo       sql.NullString `json:"consignment_no"`
	Date                sql.NullTime   `json:"date"`
	Detergent           sql.NullString `json:"detergent"`
	Refrigerationstatus sql.NullString `json:"refrigerationstatus"`
}

func (q *Queries) UpdateTruckHygienesReportByID(ctx context.Context, arg UpdateTruckHygienesReportByIDParams) (Trackhygienereport, error) {
	row := q.db.QueryRowContext(ctx, updateTruckHygienesReportByID,
		arg.ID,
		arg.ConsignmentNo,
		arg.Date,
		arg.Detergent,
		arg.Refrigerationstatus,
	)
	var i Trackhygienereport
	err := row.Scan(
		&i.ID,
		&i.Truckimage,
		&i.ConsignmentNo,
		&i.Vehicleregno,
		&i.Date,
		&i.Detergent,
		&i.Refrigerationstatus,
		&i.CreatedAt,
		&i.ReportStatus,
		&i.ChecklistStatus,
	)
	return i, err
}
