-->
Welcome, Guest
Username: Password: Remember me

TOPIC: Add columns to lines of proposals, customer orders

Add columns to lines of proposals, customer orders 2 weeks 1 day ago #37469

  • prueba2306
  • prueba2306's Avatar
  • OFFLINE
  • Newcomer
  • Posts: 3
  • Thank you received: 2
  • Karma: 0
Hello:

Is there a way to add columns to the lines of proposals, customer orders and invoices? (for developers)

I need to add 2 extra columns (width, height) in the lines of those elements so I can use it for extra information and to calculate the price. Right now I only have the quantity column, but is not enough (sometimes I need 2 products of the same measure) Is there a developer tutorial or something on where and how to add the code?

To give you and idea I add an screenshot.

Any page or idea of how to code that will be appreciated.

example.png
Last Edit: 2 weeks 1 day ago by prueba2306. Reason: The screenhost does not appear
The administrator has disabled public write access.

Add columns to lines of proposals, customer orders 2 weeks 23 hours ago #37473

  • ksar
  • ksar's Avatar
  • OFFLINE
  • Moderator
  • Posts: 267
  • Thank you received: 71
  • Karma: 11
Hello,

Yes it is of course possible to do that, I have done it for my own use.
You need to create an aditional module. You can see guide lines there : wiki.dolibarr.org/index.php/Module_development

With two parts :
1- A trigger to update the price according to the extrafields. You can have a look on my Volume module that does it with 4 extrafields github.com/ksar-ksar/Dolibarr_Volume
2- A hook that recreate the HTML code to put the imput fileds on the same row.

Good luck !
The administrator has disabled public write access.
The following user(s) said Thank You: ariffidaali, prueba2306

Add columns to lines of proposals, customer orders 1 week 4 days ago #37504

  • prueba2306
  • prueba2306's Avatar
  • OFFLINE
  • Newcomer
  • Posts: 3
  • Thank you received: 2
  • Karma: 0
Thanks to @ksar for the help and for the module that provided, it was very useful.

I had to do many things to be able to do what I wanted (Dolibarr version 9.0.3), here are the steps:

1) Created 3 not visible extrafields in the lines of proposals, customer orders and invoices: length, width and quantity. The reason that I add my own quantity column is because the "qty" property of each object works to calculate the total price but I need the information separated. Example: 2 (my quantity) sheets of paper of 3(length)x1.5(width) mts will give me 9 "qty" in reality.

Screenshot_2019-06-14ConfiguracindelmduloPresupuestos.png


2) Created my own module using Module Builder (I really encourage to use it) and change the code that I can overwrite templates (tpl = 1), the hooks are used in the context 'propalcard' and 'globalcard' and removed the menu code (so it does not appear at the top)

Screenshot_2019-06-14MduloBuilder.png


3) Created the trigger (based in the module that @ksar provided with some extra lines like set $object->special_code = 0 because I don't use directly the "qty" property of the object, I use my own, and that cause problems displaying values later.

Screenshot_2019-06-14MduloBuilder1.png


4) Created a hook for "printObjectLineTitle" because I put the extrafields inside the row of each line (not at the bottom) so I needed to add the columns for my extrafields. I copied the original code, made some changes to add the columns and done with that.

Screenshot_2019-06-14MduloBuilder2.png


5) Inside \core\tpl folder of my module I copied 3 files "objectline_create.tpl.php" "objectline_edit.tpl" "objectline_view.tpl.php" that I got from \htdocs\core\tpl folder of Dolibarr. I changed the code so it displays my extrafields (the "qty" field is hidden and given the value="1" by default to avoid errors in the edit template, the code of the trigger makes the correct calculation later)
<td class="nobottom linecolqty" align="right">
	    <input type="hidden" name="qty" id="qty" value="1" />
	    <input type="text" size="2" name="options_cantidad" id="options_cantidad" class="flat right" value="<?php echo (isset($_POST["options_cantidad"])?GETPOST("options_cantidad",'alpha',2):1); ?>">
	</td>
	<td class="nobottom" align="right"><input type="text" size="2" name="options_largo" id="options_largo" class="flat right" value="<?php echo (isset($_POST["options_largo"])?GETPOST("options_largo",'alpha',2):1); ?>"></td>
	<td class="nobottom" align="right"><input type="text" size="2" name="options_ancho" id="options_ancho" class="flat right" value="<?php echo (isset($_POST["options_ancho"])?GETPOST("options_ancho",'alpha',2):1); ?>"></td>

These are the results (I keep the qty values between () for clarification:

Screenshot_2019-06-14Presupuesto.png


Screenshot_2019-06-14Presupuesto1.png


Finding the exact contexts, functions, templates and the conditions in the templates that does this was a pain in the *** but it worked.
Last Edit: 1 week 4 days ago by prueba2306. Reason: typo and clarifications
The administrator has disabled public write access.
The following user(s) said Thank You: ariffidaali, ksar

Add columns to lines of proposals, customer orders 1 week 3 days ago #37505

  • ksar
  • ksar's Avatar
  • OFFLINE
  • Moderator
  • Posts: 267
  • Thank you received: 71
  • Karma: 11
Perfect you did it !
The administrator has disabled public write access.
Time to create page: 0.113 seconds