pizzas: fix 2, wtf
This commit is contained in:
parent
c4c52809d2
commit
9cc85a2525
@ -2,7 +2,6 @@
|
||||
import "$lib/global.css";
|
||||
import { path } from "@tauri-apps/api";
|
||||
import Database from "@tauri-apps/plugin-sql";
|
||||
// import { writeTextFile, BaseDirectory } from "@tauri-apps/plugin-fs";
|
||||
|
||||
import ScreenWrap from "$lib/components/ui/ScreenWrap.svelte";
|
||||
import Dialog from "$lib/components/ui/Dialog.svelte";
|
||||
@ -12,7 +11,6 @@
|
||||
import NumberInput from "$lib/components/form/NumberInput.svelte";
|
||||
import ItemList from "$lib/components/form/ItemList.svelte";
|
||||
import DateInput from "$lib/components/form/DateInput.svelte";
|
||||
// import PhoneInput from "$lib/components/form/PhoneInput.svelte";
|
||||
import Select from "$lib/components/form/Select.svelte";
|
||||
|
||||
import Table from "$lib/components/table/Table.svelte";
|
||||
@ -23,7 +21,6 @@
|
||||
import TableCudButtons from "$lib/components/shorts/TableCUDButtons.svelte";
|
||||
import TableButtonsWrap from "$lib/components/shorts/TableButtonsWrap.svelte";
|
||||
import ViewTable from "$lib/components/shorts/ViewTable.svelte";
|
||||
// import TableListShort from "$lib/components/shorts/TableListShort.svelte";
|
||||
|
||||
/** @type {Database} */
|
||||
let db;
|
||||
@ -84,11 +81,12 @@ GROUP BY Ingredients.id;
|
||||
|
||||
DROP VIEW IF EXISTS SalesIngredientsCount;
|
||||
CREATE VIEW IF NOT EXISTS SalesIngredientsCount (id, name, count) AS
|
||||
SELECT Ingredients.id AS id, Ingredients.name AS name, -sum(Ingredients.weight) as count
|
||||
SELECT Ingredients.id AS id, Ingredients.name AS name, sum(Ingredients.weight) as count
|
||||
FROM Sales
|
||||
JOIN Pizzas on Pizzas.id = Sales.pizza_id
|
||||
JOIN PizzasIngredientsJoin on PizzasIngredientsJoin.pizza_id = Sales.pizza_id
|
||||
JOIN Ingredients on Ingredients.id = PizzasIngredientsJoin.ingredient_id;
|
||||
JOIN Ingredients on Ingredients.id = PizzasIngredientsJoin.ingredient_id
|
||||
GROUP BY Ingredients.id;
|
||||
|
||||
|
||||
DROP VIEW IF EXISTS IngredientsLeft;
|
||||
@ -267,6 +265,9 @@ join IdBuffer on IdBuffer.id = Ingredients.id
|
||||
<Field name={"цена"}>
|
||||
<NumberInput bind:value={current_item.price}></NumberInput>
|
||||
</Field>
|
||||
<Field name={"разрешено"}>
|
||||
<Boolean bind:value={current_item.is_allowed}></Boolean>
|
||||
</Field>
|
||||
|
||||
<TableCudButtons
|
||||
{form}
|
||||
@ -280,9 +281,6 @@ join IdBuffer on IdBuffer.id = Ingredients.id
|
||||
console.log(las_id.lastInsertId);
|
||||
|
||||
const query = `insert into PizzasIngredientsJoin (pizza_id, ingredient_id) values
|
||||
<Field name={"разрешено"}>
|
||||
<Boolean bind:value={current_item.is_allowed}></Boolean>
|
||||
</Field>
|
||||
${current_item.ingredients_ids.map((el) => "(" + las_id.lastInsertId + "," + el + ")").join(",")}
|
||||
`;
|
||||
console.log(query);
|
||||
@ -340,76 +338,6 @@ ${current_item.ingredients_ids.map((el) => "(" + current_item.id + "," + el + ")
|
||||
</Tr>
|
||||
</Table>
|
||||
</TableButtonsWrap>
|
||||
<!-- {:else if current_table === "PizzasIngredientsJoin"} -->
|
||||
<!-- {@const cur_cols = ["pizza_id", "ingredient_id"]} -->
|
||||
<!-- <Dialog -->
|
||||
<!-- bind:is_open={is_item_dialog_open} -->
|
||||
<!-- name={cur_dialog_name} -->
|
||||
<!-- let:form -->
|
||||
<!-- > -->
|
||||
<!-- {#if !is_dialog_item_add} -->
|
||||
<!-- <h1>id {current_item.id}</h1> -->
|
||||
<!-- {/if} -->
|
||||
<!-- <Field name={"питса"}> -->
|
||||
<!-- <Select -->
|
||||
<!-- bind:value={current_item.pizza_id} -->
|
||||
<!-- query={db.select("select id, name from Pizzas")} -->
|
||||
<!-- let:vtype -->
|
||||
<!-- > -->
|
||||
<!-- {vtype.name} -->
|
||||
<!-- {vtype.id} -->
|
||||
<!-- </Select> -->
|
||||
<!-- </Field> -->
|
||||
<!-- <Field name={"ингридиент"}> -->
|
||||
<!-- <Select -->
|
||||
<!-- bind:value={current_item.ingredient_id} -->
|
||||
<!-- query={db.select("select id, name from Ingredients")} -->
|
||||
<!-- let:vtype -->
|
||||
<!-- > -->
|
||||
<!-- {vtype.name} -->
|
||||
<!-- {vtype.id} -->
|
||||
<!-- </Select> -->
|
||||
<!-- </Field> -->
|
||||
<!-- <TableCudButtons -->
|
||||
<!-- {form} -->
|
||||
<!-- bind:is_dialog_item_add -->
|
||||
<!-- on_add={async () => { -->
|
||||
<!-- await sql_insert_short(current_table, cur_cols); -->
|
||||
<!-- }} -->
|
||||
<!-- on_save={async () => { -->
|
||||
<!-- await sql_update_short(current_table, cur_cols); -->
|
||||
<!-- }} -->
|
||||
<!-- on_delete={sql_delete_short} -->
|
||||
<!-- ></TableCudButtons> -->
|
||||
<!-- </Dialog> -->
|
||||
<!-- <TableButtonsWrap -->
|
||||
<!-- {current_table} -->
|
||||
<!-- {current_item} -->
|
||||
<!-- {toggle_add_dialog} -->
|
||||
<!-- on_add_click={() => { -->
|
||||
<!-- current_item = { -->
|
||||
<!-- id: 0, -->
|
||||
<!-- pizza_id: null, -->
|
||||
<!-- ingredient_id: null, -->
|
||||
<!-- }; -->
|
||||
<!-- }} -->
|
||||
<!-- columns={cur_cols} -->
|
||||
<!-- let:is_searching -->
|
||||
<!-- let:search_query_result -->
|
||||
<!-- > -->
|
||||
<!-- <Table -->
|
||||
<!-- {is_searching} -->
|
||||
<!-- search_query={db.select(search_query_result)} -->
|
||||
<!-- columns={["id", "питса", "ингридиент"]} -->
|
||||
<!-- query={db.select(`select * from ${current_table}`)} -->
|
||||
<!-- let:item -->
|
||||
<!-- let:index -->
|
||||
<!-- > -->
|
||||
<!-- <Tr {index} on_click={() => open_item_edit(item)}> -->
|
||||
<!-- <Atd {item} names={["id", ...cur_cols]}></Atd> -->
|
||||
<!-- </Tr> -->
|
||||
<!-- </Table> -->
|
||||
<!-- </TableButtonsWrap> -->
|
||||
{:else if current_table === "Ingredients"}
|
||||
{@const cur_cols = ["name", "price", "is_allowed", "weight"]}
|
||||
<Dialog
|
||||
@ -428,6 +356,9 @@ ${current_item.ingredients_ids.map((el) => "(" + current_item.id + "," + el + ")
|
||||
<Field name={"цена"}>
|
||||
<NumberInput bind:value={current_item.price}></NumberInput>
|
||||
</Field>
|
||||
<Field name={"разрешено"}>
|
||||
<Boolean bind:value={current_item.is_allowed}></Boolean>
|
||||
</Field>
|
||||
|
||||
<Field name={"Вес"}>
|
||||
<NumberInput is_float={true} bind:value={current_item.weight}
|
||||
@ -637,9 +568,4 @@ ${current_item.ingredients_ids.map((el) => "(" + current_item.id + "," + el + ")
|
||||
></ViewTable>
|
||||
{/if}
|
||||
{/if}
|
||||
is_allowed: true,
|
||||
<Field name={"разрешено"}>
|
||||
<Boolean bind:value={current_item.is_allowed}></Boolean>
|
||||
</Field>
|
||||
is_allowed: true,
|
||||
</ScreenWrap>
|
||||
|
Loading…
x
Reference in New Issue
Block a user