1

I have three tables :

orders :

id_order PK int
id_client
.
.
.
etc ...

Products :

id_product PK int
product_name  varchar(255)
.
.
.
etc ...

orders_products

id  PK int
id_order  FK int
id_product   FK int
quantity    int
discount    float

and Im using Xcrud as a crud framework based.

this is my code :

    $xcrud = Xcrud::get_instance();
    $xcrud->table('orders');
    $xcrud->fk_relation('Products','id_order','orders_products','id_order','id_product','products', 'id_product','product_name');
  • So each order has multi products
  • And each product has a quantity

When I go to add an order it only shows me a multiselect field of products and it's inserting products find in the orders_products table.

but I want to add for each product a quantity.

How can I do that using xcrud ?

Florian Lemaitre
  • 5,905
  • 2
  • 21
  • 44
ADiL
  • 367
  • 4
  • 17
  • 1
    xcrud is awesome. I wish most of the PHP developers here used it :p – Drew Jun 09 '16 at 02:59
  • @Drew yeah it is awesome ... but I think no one uses it here ? no one answered this question and I searched for similar questions here I found nothing :/ – ADiL Jun 09 '16 at 11:04
  • You might consider making an `xcrud` tag and populate it with dev questions. Whether or not it is commercial is irrelevant (I'd say 5 percent of tags are commerical related). Plus it only costs like 10 buck or something. I could have a lot of fun with it with PHP questions from newbies if you know what I mean.... "Hey Joe, this dev thing seems too complicated for you at the moment. Have you ever heard about xcrud ! " – Drew Jun 09 '16 at 11:41
  • yeah I'd like make it in xcrud tag but it requires at least 1500 reputation in stack overflow :/ – ADiL Jun 09 '16 at 11:49
  • Ok stop on by [Campaigns](http://chat.stackoverflow.com/rooms/95290) and we can discuss it. Link reference for everyone is [here](http://codecanyon.net/item/xcrud-data-management-system-php-crud/3215400) for xcrud on codecanyon – Drew Jun 09 '16 at 11:52

2 Answers2

1

It seems that a nested table should do what you want, although it would be a two step process: 1) Add a new order, 2) populate the order with each product/quantity entry.

$some_name = $xcrud->nested_table('some_name','id_order','orders_products','id');
Adash
  • 11
  • 2
  • I did it wiht fk_relation and its showing multi select for products ... but I need with each product to be a quantity. – ADiL Jun 11 '16 at 14:00
1

Solved it by using NESTED TABLE and NESTED TABS to make products TABS alongside with the add order process.

ADiL
  • 367
  • 4
  • 17