https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21173
--- Comment #8 from Alex Buckley <alexbuck...@catalyst.net.nz> --- Created attachment 77605 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=77605&action=edit Bug 21173 - Customize age unit and starting point for automatic item modification by age tool and cronjob. This allows librarians to define either the item creation date or items last altered timestamp as the starting point for the age of the item so the autmatic_item_modification_by_age.pl can alter item fields for example for items which have been in the catalogue for a while. A use case for this functionality is: * When an items shelving location changes from 'In processing' to 'Shelving trolley' after 1 hour the status 'Shelving trolley' is removed for the item. The unit 'Hours' can now be set (extending the functionality of this cronjob from just calculating item age in days) and the age starting point of 'Last altered' can be defined so existing items in the catalogue like this example item will be altered by the cronjob. Test plan: 1. Go to Tools->Automatic item modifications by age and create a new rule by selecting the 'Edit rules' button 2. Notice you can only set the age in the unit of days not hours. Also alsthough not visible in the interface the rule will calculate the age of the item based on when it was created (i.e. added to Koha). 3. Apply patch and run ./updatedatabase.pl in the koha-shell 4. Now revisit Tools->Automatic item modifications by age. Notice the table of existing rules now contains a new column 'Age starting point' this is the date from which the item age is calculated. This enhancement offers you two options as the age starting point: Created (displayed in this table as 'itemcreated') or Last altered (displayed in this table as 'itemaltered'). 5. Click 'Edit rules' to create a new rule. Notice in the form for creating the new rule you can set the unit to either 'Hours' or 'Days'. When you select 'Days' then the Age starting point selection will appear where you can specify if you want the rule to work on the number of days since the item was last altered or number of days since the item was created. NOTE: If you select 'Hours' as the unit type when creating a new rule then the Age starting point selection area is hidden. This is because the item creation value is saved in the database as a date not a datetime. Therefore we cannot calculate the number of hours since the item was created in the Koha catalog. Therefore if the unit is set to 'Hours' then by default the item will use the item last altered value (stored as a date time) as the age starting point. For existing rules if they have the unit set to 'Hours' then the Age starting point area is hidden by default when the page loads. 6. In the new rule set the following values: Age: 1, Unit: Hours, condition items.location = 'CART', items.location = '' 7. Now save the rule and confirm the correct values are dispayed in the rules table which is loaded 8. Click 'Edit rules' button again. 9. Modify the rule you just created changing Age to 2 and create another new rule with the following values: Age='1', Unit='Days', 'Age starting point'='Created', Condition 'items.homebranch'='<a branchcode of a branch in your Koha instance>', substituions 'items.homebranch'='<another branchcode in your Koha instance>' 10. Now click 'Save' and confirm the data displayed for both rules is correct. 11. In the database manually set the location field of two items to 'CART' and set their timestamp value to 2 hours before the current time 12. Exit out of the database terminal and manually run the automatic_item_modification_by_age.pl cronjob from the koha-shell with this command: ./automatic_item_modification_by_age.pl --confirm 13. Now return to the database and notice the two items you set have a location of 'CART' now have a blank location field because the manually run cronjob altered them as they meet the conditions of the rule. 14. Repeat step 11 and enter this text into your /etc/cron.d/koha-common file: */2 * * * * root koha-foreach --enabled /usr/share/koha/bin/cronjobs/automatic_item_modification_by_age.pl --confirm This will make the cronjob run every 2 minutes. 15. Now restart koha-common with this command: sudo /etc/init.d/koha-common restart 16. Now wait for more than 2 minutes and check the database again and notice that the two items have blank location fields as the automatically running cronjob altered the items. Sponsored-By: Toi Ohomai Institute of Technology, New Zealand -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug. _______________________________________________ Koha-bugs mailing list Koha-bugs@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/