You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2011-01-31 17:28:03

Zipp
Member
Registered: 2011-01-31
Posts: 9

[Working on it] Clone or Add Multiple Items

Our use of GLPI consists of adding items then going back through and adding financial information. This takes quite a bit of time when large orders come in that need to be inventoried as we have to add all our items then go back through and find the newly created items in order to add the financial information.

I've been looking through the source and hacked together some of the parts of the feature but realized it would probably be better done by you guys. Basically:

./ajax/dropdownMassiveAction.php

Modified to add a "clone" option to the dropdown after searching for an item.

./inc/dropdown.function.php

Modified to allow the user to enter the number of copies of the item they'd wish to create from the item they've selected.

./front/massiveaction.php

Case "clone" added that outputs 'n' form(s) filled with the previously selected item's information. The problem here is that the views are all very linear. Solution to this problem was to redo all the views with redundant code that sends data for each form as a 2d array to PHP using a 4th argument specify which iteration needed to be specified.

e.g.

for ($i = 0; $i < $_POST["quantity"]; $i++)
$peripheral->showForm($_SERVER["PHP_SELF"], $ci->id_device, 1337, $i);

1337 tells the function to ignore GLPIs normal form output and use the form outputs I've written. $i is my quantity iterator which is used in creating the forms.

Last edited by Zipp (2011-02-01 19:03:03)

Offline

#2 2011-01-31 22:47:56

Zipp
Member
Registered: 2011-01-31
Posts: 9

Re: [Working on it] Clone or Add Multiple Items

Meh, no responses. I'm just going to output the queries, see what a normal one looks like, rewrite the other forms to have 2d array-like post data, and just pass a formatted array to the add function tongue

Offline

#3 2011-02-01 18:41:31

Zipp
Member
Registered: 2011-01-31
Posts: 9

Re: [Working on it] Clone or Add Multiple Items

Coming along alright so far, but I really feel as though this is a "hack and slash" effort -- GLPI seems to be fighting me every step of the way in terms of working out similar solutions for computers, networks, software, etc.

bCE8J.png

oIBgx.png

Edit: Currently working out how to slipstream adding financial information to my forms. I believe it's a separate query, but I'll get to that as soon as I reverse the page that contains it tongue

The forms create $_POST["postData"][$iterator]["ELEMENT"] - I just have to pass the post data to the add method and BOOM

for ($i = 0; $i < $_POST["quantity"]; $i++) {
   // Sanity checking code goes HERE (makes sure all the elements needed by the add method are in the array being passed)
   $whatever->add($_POST["postData"][$i]);
}

Last edited by Zipp (2011-02-01 18:55:44)

Offline

#4 2011-02-01 23:43:48

Zipp
Member
Registered: 2011-01-31
Posts: 9

Re: [Working on it] Clone or Add Multiple Items

Status: Complete. Sort of. I can now clone items completely and add their financial information all on the same page, which is kinda cool and saves me time. The problem now? Because everything is split up, it's only been done for peripherals -- I need to figure out a more.. uhh.. pragmatic way to add this feature to every inventory type.

If anyone is paying attention to this thread, how does one go about contributing code to the project? Mailing list? The 'contribute' page is vague.

Offline

#5 2011-02-02 01:25:42

JMD
GLPI - Lead
Registered: 2004-09-13
Posts: 9,180
Website

Re: [Working on it] Clone or Add Multiple Items

Hi,

Thank you for your interest in glpi-project.

You could send your patch to the dev mailing list.


JMD / Jean-Mathieu Doléans - Glpi-project.org - Association Indepnet
Apportez votre pierre au  projet GLPI   : Soutenir

Offline

#6 2011-02-02 20:54:42

Zipp
Member
Registered: 2011-01-31
Posts: 9

Re: [Working on it] Clone or Add Multiple Items

Wicked. Once I get the feature working for any inventory type I'll submit it to you guys smile

Offline

#7 2011-02-03 21:28:44

Zipp
Member
Registered: 2011-01-31
Posts: 9

Re: [Working on it] Clone or Add Multiple Items

Update for the fans I don't have:

Got the forms showing up for every standard object type (computer, peripheral, software, etc) but there's no way my code knows if someone's trying to clone a custom type (added via the generic object plugin or something) .. in order for this to be better done, I'm probably going to need to rewrite part of the add() methods to accept single or multi-dimensional arrays.. this would mean I wouldn't need two sets of forms. Then again, having two sets of forms means I can tweak things specifically for my needs, albeit I don't really need it -- I feel as though a templating engine could work wonders in a situation like this (instead of having html and php mixed, it would keep things more separate.. I guess more MVC-like. But that's not really within the scope of the GLPI project.)

Anyway, status is that I believe all I've left to do on the clone feature is rewrite the showForm() method for the standard object types to output forms that act as 2d arrays when 1337 is specified as the third argument and $iterator for the fourth.

Edit: turns out showForm() doesn't have a set argument list.. looks like I'll need a switch statement to call specific showForm functions based on their types >.> Kind of a pain, imo

Last edited by Zipp (2011-02-07 15:50:44)

Offline

#8 2012-08-08 13:49:44

Henry78
Member
Registered: 2009-07-07
Posts: 37

Re: [Working on it] Clone or Add Multiple Items

Fan here...

I miss such a feature, as we do some things very special and that means a lot of manual work. Could you post your latest patchset or host it somewhere, so I might test it?

Offline

#9 2012-08-31 16:00:11

bazzer
Member
Registered: 2010-10-25
Posts: 3

Re: [Working on it] Clone or Add Multiple Items

I'm a fan too - please continue and share!

Offline

#10 2013-01-24 20:01:08

yves.holenstein
Member
Registered: 2012-09-17
Posts: 7

Re: [Working on it] Clone or Add Multiple Items

Big fan of a "Clone" feature, too. Currently, we're re-entering all tickets which affect multiple computers so that we have a relationship to all computers. Ideally, I'd love both features
a) cloning tickets
and
b) linking multiple assets to a ticket

Offline

#11 2013-01-24 20:20:12

eppepp
Member
Registered: 2013-01-24
Posts: 1

Re: [Working on it] Clone or Add Multiple Items

Greetings, When I'm on the display followed and I will add a new track the date and time are wrong, write me a day later and time is not just another system and I have not let me modificarla.Que misconfigured.
I use GLPI GLPI 0.83.7.
Thank you.

Emilio Perera.

Offline

Board footer

Powered by FluxBB