Hello Everything is right? My problem is the following:
我有3个表格:
create table products (
id int not null auto_increment primary key,
name varchar(80) not null,
mold varchar(80),
amount int,
value decimal(10,2),
real_value decimal(10,2),
created datetime,
modified datetime,
active boolean default 1
);
create table sales (
id int not null auto_increment primary key,
customer_id int not null,
method_payment_id int not null,
portions smallint(4),
entry decimal(10,2),
subtotal decimal(10,2),
total decimal(10,2),
debtor decimal(10,2),
expiration_date datetime,
created datetime,
modified datetime,
active boolean default 1
);
create table products_sales (
product_id int not null,
sale_id int not null,
amount smallint(4),
value decimal(10,2)
);
在products_sales(HABTM)中,我不得不增加两个额外领域(amount和 数值),因为产品的价值不稳定,而另一个是客户购买的数量。
When I put in add() page:
echo $this->form->input( Product );
CakePHP renders a , until then I understand.
But my need is: the customer must choose the product and the amount of it, or even if it is, the product value is also sent, not only the id (anything, I create a page just to report the amount, after confirmation the sale ).
Then:
1 - How do I save the ID and value of the product at the same time?
2 - I am using the tables / relationships the right way?
3 - what better way to do this?
Sorry for my English. I hope you understand.