View | Details | Raw Unified | Return to bug 21173
Collapse All | Expand All

(-)a/C4/Items.pm (-3 / +7 lines)
Lines 289-295 sub AddItem { Link Here
289
        $itype_sth->execute( $item->{'biblionumber'} );
289
        $itype_sth->execute( $item->{'biblionumber'} );
290
        ( $item->{'itype'} ) = $itype_sth->fetchrow_array;
290
        ( $item->{'itype'} ) = $itype_sth->fetchrow_array;
291
    }
291
    }
292
293
    my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} );
292
    my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} );
294
    return if $error;
293
    return if $error;
295
294
Lines 1630-1636 C<items.withdrawn> Link Here
1630
1629
1631
sub _set_defaults_for_add {
1630
sub _set_defaults_for_add {
1632
    my $item = shift;
1631
    my $item = shift;
1633
    $item->{dateaccessioned} ||= output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
1632
    $item->{dateaccessioned} ||= DateTime->now( time_zone => C4::Context->tz() );
1634
    $item->{$_} ||= 0 for (qw( notforloan damaged itemlost withdrawn));
1633
    $item->{$_} ||= 0 for (qw( notforloan damaged itemlost withdrawn));
1635
}
1634
}
1636
1635
Lines 1936-1946 sub _mod_item_dates { # date formatting for date fields in item hash Link Here
1936
    my @keys = grep
1935
    my @keys = grep
1937
        { $_ =~ /^onloan$|^date|date$|datetime$/ }
1936
        { $_ =~ /^onloan$|^date|date$|datetime$/ }
1938
        keys %$item;
1937
        keys %$item;
1939
    # Incl. dateaccessioned,replacementpricedate,datelastborrowed,datelastseen
1938
    # Incl. replacementpricedate,datelastborrowed,datelastseen
1940
    # NOTE: We do not (yet) have items fields ending with datetime
1939
    # NOTE: We do not (yet) have items fields ending with datetime
1941
    # Fields with _on$ have been handled already
1940
    # Fields with _on$ have been handled already
1942
1941
1943
    foreach my $key ( @keys ) {
1942
    foreach my $key ( @keys ) {
1943
        # If the key is 'dateaccessioned' then escape out of this loop
1944
        # We want to store the date and time for the dateaccessioned field
1945
        if ($key eq "dateaccessioned") {
1946
            last;
1947
        }
1944
        next if !defined $item->{$key}; # skip undefs
1948
        next if !defined $item->{$key}; # skip undefs
1945
        my $dt = eval { dt_from_string( $item->{$key} ) };
1949
        my $dt = eval { dt_from_string( $item->{$key} ) };
1946
            # eval: dt_from_string will die on us if we pass illegal dates
1950
            # eval: dt_from_string will die on us if we pass illegal dates
(-)a/installer/data/mysql/atomicupdate/bug_21173-alter_item_table_change_dateaccessioned_to_datetime_datatype.sql (+1 lines)
Line 0 Link Here
1
ALTER TABLE items MODIFY COLUMN dateaccessioned datetime;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt (-9 / +9 lines)
Lines 72-83 Link Here
72
                    <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled -->
72
                    <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled -->
73
                    <div class="age">
73
                    <div class="age">
74
                      <h5>Age</h5>
74
                      <h5>Age</h5>
75
                      <input class="age" type="number" value="[% rule.age %]" name="age_[% id %]" />
75
                      <input class="age" type="number" value="[% rule.age | html %]" name="age_[% id | html %]" />
76
                    </div>
76
                    </div>
77
                    <div>
77
                    <div>
78
                      <h5>Unit</h5>
78
                      <h5>Unit</h5>
79
                      <p>Note: If the unit of 'Hours' is set then you cannot choose an age starting point, the item age starting point will default to the last item alteration event. The Age starting point selection will be hidden if you have set the unit to 'Hours'.</p>
79
                      <p>Note: If the unit of 'Hours' is set then you cannot choose an age starting point, the item age starting point will default to the last item alteration event. The Age starting point selection will be hidden if you have set the unit to 'Hours'.</p>
80
                      <select id="existing_rule_unit" name="unit_[% id %]" id="unit">
80
                      <select id="existing_rule_unit" name="unit_[% id | html %]" id="unit">
81
                       <option value="">Choose a unit</option>
81
                       <option value="">Choose a unit</option>
82
                       [% IF rule.unit == "hours" %]
82
                       [% IF rule.unit == "hours" %]
83
                          <option value="hours" selected="selected">Hours</option>
83
                          <option value="hours" selected="selected">Hours</option>
Lines 91-97 Link Here
91
                    [% IF rule.unit == "days" %]
91
                    [% IF rule.unit == "days" %]
92
                       <div id="age_starting_point_div">
92
                       <div id="age_starting_point_div">
93
                          <h5>Age starting point (starting point from which the item age is calculated)</h5>
93
                          <h5>Age starting point (starting point from which the item age is calculated)</h5>
94
                          <select name="age_starting_point_[% id %]" id="age_starting_point">
94
                          <select name="age_starting_point_[% id | html %]" id="age_starting_point">
95
                            <option value="">Choose age starting point</option>
95
                            <option value="">Choose age starting point</option>
96
                            [% IF rule.age_starting_point == "itemcreation" %]
96
                            [% IF rule.age_starting_point == "itemcreation" %]
97
                               <option value="itemcreation" selected="selected">Created</option>
97
                               <option value="itemcreation" selected="selected">Created</option>
Lines 117-123 Link Here
117
                              [% END %]
117
                              [% END %]
118
                            [% END %]
118
                            [% END %]
119
                          </select>
119
                          </select>
120
                          <input type="text" value="[% condition.value %]" name="condition_value_[% id%]" />
120
                          <input type="text" value="[% condition.value | html %]" name="condition_value_[% id | html %]" />
121
                          <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a>
121
                          <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a>
122
                          <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a>
122
                          <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a>
123
                        </div>
123
                        </div>
Lines 137-143 Link Here
137
                              [% END %]
137
                              [% END %]
138
                            [% END %]
138
                            [% END %]
139
                          </select>
139
                          </select>
140
                          <input type="text" value="[% substitution.value %]" name="substitution_value_[% id %]" />
140
                          <input type="text" value="[% substitution.value | html %]" name="substitution_value_[% id | html %]" />
141
                          <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a>
141
                          <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a>
142
                          <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a>
142
                          <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a>
143
                          <span class="required">A field name is required</span>
143
                          <span class="required">A field name is required</span>
Lines 228-239 Link Here
228
                                        [% IF rule.age.defined and rule.unit.defined and rule.age.length > 0 %]
228
                                        [% IF rule.age.defined and rule.unit.defined and rule.age.length > 0 %]
229
                                            [% IF rule.age == 1 %]
229
                                            [% IF rule.age == 1 %]
230
                                                [% IF rule.unit == "days" %]
230
                                                [% IF rule.unit == "days" %]
231
                                                   [% rule.age %] day
231
                                                   [% rule.age | html %] day
232
                                                [% ELSE %]
232
                                                [% ELSE %]
233
                                                   [% rule.age %] hour
233
                                                   [% rule.age | html %] hour
234
                                                [% END %]
234
                                                [% END %]
235
                                            [% ELSE %]
235
                                            [% ELSE %]
236
                                                [% rule.age %] [% rule.unit %]
236
                                                [% rule.age | html %] [% rule.unit | html %]
237
                                            [% END %]
237
                                            [% END %]
238
                                        [% ELSE %]
238
                                        [% ELSE %]
239
                                            There is no age for this rule.
239
                                            There is no age for this rule.
Lines 241-247 Link Here
241
                                    </td>
241
                                    </td>
242
                                    <td>
242
                                    <td>
243
                                        [% IF rule.age_starting_point.defined %]
243
                                        [% IF rule.age_starting_point.defined %]
244
                                            [% rule.age_starting_point %]
244
                                            [% rule.age_starting_point | html %]
245
                                        [% ELSE %]
245
                                        [% ELSE %]
246
                                            There is no age starting point for this rule.
246
                                            There is no age starting point for this rule.
247
                                        [% END %]
247
                                        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js (-12 lines)
Lines 52-58 function update_rule_count(){ Link Here
52
$(document).ready(function() {
52
$(document).ready(function() {
53
    $("#new_rule .remove_rule").hide();
53
    $("#new_rule .remove_rule").hide();
54
    $("#new_rule a.remove_block").hide();
54
    $("#new_rule a.remove_block").hide();
55
    $("#new_rule_age_starting_point_div").hide();
56
55
57
    $("#rules a.remove_block").click(function(e){
56
    $("#rules a.remove_block").click(function(e){
58
        e.preventDefault();
57
        e.preventDefault();
Lines 63-78 $(document).ready(function() { Link Here
63
        remove_rule_action($(this));
62
        remove_rule_action($(this));
64
    });
63
    });
65
64
66
    $("#new_rule_unit").change(function(){
67
        var unitselected = $(this).find("option:selected").attr("id");
68
        var newruleagestart = document.getElementById("new_rule_age_starting_point_div");
69
        if (unitselected == "days") {
70
            newruleagestart.style.display = "block"
71
        } else {
72
            newruleagestart.style.display = "none";
73
        }
74
    });
75
76
    var unique_id = $(".rule").length + 1;
65
    var unique_id = $(".rule").length + 1;
77
    $(".add_rule").click(function(e){
66
    $(".add_rule").click(function(e){
78
        e.preventDefault();
67
        e.preventDefault();
79
- 

Return to bug 21173