Problems, need help? Have a tip or advice? Post it here.
13 posts Page 1 of 2
Hello KK Sir and all couchies,

I want to create a bill.

I have a products page (clonable) that has product details like: Product Name, Product Description, Warranty (in Years).

I want to be able to add multiple products in a table manner and then generate a bill. The bill is also a clonable template. There is no need of cost. The products do not have costs. hence, I am not using CouchCart.

The bill are to be generate only for warranty validity check purposes.

How do i generate the same?
Please help. A reference will also be helpful.

This is my final design design:
bill.png
bill.png (16.58 KiB) Viewed 1502 times


Regards,
GenXCoders (Priya)
Image
where innovation meets technology
Any help Please!
Image
where innovation meets technology
genxcoders wrote: ..I want to be able to add multiple products in a table manner
..
Any help Please!


Have you established a relation from 'bills' clonable template to 'products' clonable template?
Do you want to create a bill (cloned page) in backend and add products to it via relationship selection popup? Is the posted screenshot coming from custom admin form-view in backend?

I think no one commented yet because the description is not simple enough, but a complicated vague job description. Perhaps no one wanted that job.. Perhaps, answers to the questions above might help?
@trendoman
Have you established a relation from 'bills' clonable template to 'products' clonable template?

No i haven't created a relation.

Do you want to create a bill (cloned page) in backend and add products to it via relationship selection popup?

Yes I want to create a bill in the backend but all transactions of S-CRUD will be from the front-end. Products will be added in the bills on-by-one. As in a PoS. With PoS in mind, I suppose in place of a relationship selection popup a dropdown on every row will suffice the use case (as shown in the attached image, using the Select Product dropdown).

Is the posted screenshot coming from custom admin form-view in backend?

Nope. The posted screenshot is the front-end design, i.e. a data bound form.

The basic intention is to be able to add one product at a time. Then click on the add + Add Product button to add a new row, consisting a Sr. No., Product Name Dropdown, and a Warranty Validity (which will be product dependent and be displayed after the product has been selected) and so on.

Thanks for the heads-up @trendoman. I shall try to be more specific with the problem definition in the future. Also, if any further clarification is required, i shall be here to post the same.

Thanks and Regards,
GenXCoders (Priya)
Image
where innovation meets technology
Then click on the add + Add Product button to add a new row,


What happens when you click 'Add product'? Can you post a screenshot? I suspect you want to have a modal window there with a list of all products?
@trendoman
What happens when you click 'Add product'? Can you post a screenshot? I suspect you want to have a modal window there with a list of all products?


billing.jpg
billing.jpg (264.74 KiB) Viewed 1480 times


In the attached image:
Step #1: Shows how the form appears when the page loads.
a. The table format for entering a product is visible.
b. Since the products are pre-defined, a dropdown to list the product is displayed. (Only 15 to 20 products at maximum)

Step #2: Shows how the form will appear after the products are entered one after the other.
a. Once a product is selected, its "Warranty Validity" Column will reflect its warranty date.
b. Also a cross mark (to delete the product, if it is not required) will appear at the end of the single product line.
c. When the "+ Add Product" button is clicked, a new product line will appear below the previously entered product, so on and so forth.

No modal window will be required.

Regards,
GenXCoders (Priya)
Image
where innovation meets technology
I have created a demo which can be successfully used to craft a data-bound form. But what about warranty? Does each product have a warranty saved somewhere?

Once a product is selected, its "Warranty Validity" Column will reflect its warranty date.
@trendoman

Yes each product has this field filled in as mentioned in my very first post:
I have a products page (clonable) that has product details like: Product Name, Product Description, Warranty (in Years).


Some JS and date operations will set the Warranty in place. As the same needs to be saved in the backend so that while claiming the warranty the current and warranty validity dates can be compared and decision be made.

Regards,
GenXCoders (Priya)
Image
where innovation meets technology
Ok, let me give you some answers (finally). The solution will depend on your JS skills - upon clicking on 'Add product' you'll need to add a new row and clone the dropdown with javascript. CouchCMS will take care of the rest if you do the steps below -

(a) I suggest to make your 'bill' form as a whole - a databound form, bound to 'bills.php' template with mode='create'. So upon a successful submission the form will create a new cloned page in backend with relation of a bill to the products as one-to-many (you have to have that relation established).

(b) Initially place one pre-filled dropdown in the form as a regular input (use cms:pages to create the list of options), mind the name must have [] brackets and final look could be like this with value having the id of the page:
Code: Select all
<select name="my_products[]">
  <option disabled selected value> -- select a product -- </option>
  <option value="11">Volvo</option>
  <option value="12">Saab</option>
  <option value="13">Fiat</option>
  <option value="14">Audi</option>
</select>

That dropdown is your first visible dropdown. I hope you can use JS to clone that dropdown and place it in a new row if user wishes to add a new product below.

At the end, user will submit the form and Couch must catch all those submitted dropdowns. We will use the comma-separated list of values, which are product ids, and place it into cms:db_persist_form tag to populate the editable of relation - remember that saving relation editables via cms:db_persist take comma-separated string of ids. CouchCMS can catch regular inputs into a dummy cms:input of type 'checkbox' and generate such comma-separated string for us - this is exactly why names of 'select' must have brackets and names must be identical ('my_product' in the sample).

(c) Using checkbox in hide to catch those -
Code: Select all
    <cms:hide>
        <cms:input type='checkbox' name='my_products' />
    </cms:hide>


Final sample of a simple non-databound form below -
Code: Select all
<cms:form method="post" anchor='0'>

    <cms:if k_success>
        <cms:if frm_my_products>
            <h2>Selected product id(s) are: <cms:show frm_my_products /></h2>
        <cms:else />
            <h2>Nothing selected!</h2>
        </cms:if>
    </cms:if>

    <cms:hide>
        <cms:input type='checkbox' name='my_products' />
    </cms:hide>

    <select name="my_products[]">
      <option disabled selected value> -- select a product -- </option>
      <option value="11">Volvo</option>
      <option value="12">Saab</option>
      <option value="13">Fiat</option>
      <option value="14">Audi</option>
    </select>

    <select name="my_products[]">
      <option disabled selected value> -- select a product -- </option>
      <option value="11">Volvo</option>
      <option value="12">Saab</option>
      <option value="13">Fiat</option>
      <option value="14">Audi</option>
    </select>

    <cms:input type='submit' name='submit' value='Submit'/>

</cms:form>


You'll need to take this sample, run it and understand how things work. Then adapt it to the databound form and add warranty js.
Thanks for the start. I will get on with it and get back!
Image
where innovation meets technology
13 posts Page 1 of 2