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

(-)a/C4/Acquisition.pm (-30 / +38 lines)
Lines 42-48 BEGIN { Link Here
42
    @ISA    = qw(Exporter);
42
    @ISA    = qw(Exporter);
43
    @EXPORT = qw(
43
    @EXPORT = qw(
44
        &GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket
44
        &GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket
45
	&GetBasketAsCSV
45
        &GetBasketAsCSV
46
        &GetBasketsByBookseller &GetBasketsByBasketgroup
46
        &GetBasketsByBookseller &GetBasketsByBasketgroup
47
47
48
        &ModBasketHeader
48
        &ModBasketHeader
Lines 181-187 The other parameters are optional, see ModBasketHeader for more info on them. Link Here
181
# FIXME : this function seems to be unused.
181
# FIXME : this function seems to be unused.
182
182
183
sub NewBasket {
183
sub NewBasket {
184
    my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber ) = @_;
184
    my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace ) = @_;
185
    my $dbh = C4::Context->dbh;
185
    my $dbh = C4::Context->dbh;
186
    my $query = "
186
    my $query = "
187
        INSERT INTO aqbasket
187
        INSERT INTO aqbasket
Lines 192-198 sub NewBasket { Link Here
192
    $dbh->do($query);
192
    $dbh->do($query);
193
#find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-(
193
#find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-(
194
    my $basket = $dbh->{'mysql_insertid'};
194
    my $basket = $dbh->{'mysql_insertid'};
195
    ModBasketHeader($basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef);
195
    ModBasketHeader( $basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef, $deliveryplace || undef, $billingplace || undef );
196
    return $basket;
196
    return $basket;
197
}
197
}
198
198
Lines 239-276 sub GetBasketAsCSV { Link Here
239
    # TODO: Translate headers
239
    # TODO: Translate headers
240
    my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp);
240
    my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp);
241
241
242
    $csv->combine(@headers);                                                                                                        
242
    $csv->combine(@headers);
243
    $output = $csv->string() . "\n";	
243
    $output = $csv->string() . "\n";
244
244
245
    my @rows;
245
    my @rows;
246
    foreach my $order (@orders) {
246
    foreach my $order (@orders) {
247
	my @cols;
247
    my @cols;
248
	# newlines are not valid characters for Text::CSV combine()
248
    # newlines are not valid characters for Text::CSV combine()
249
        $order->{'notes'} =~ s/[\r\n]+//g;
249
        $order->{'notes'} =~ s/[\r\n]+//g;
250
	push(@cols,
250
        push(@cols,
251
		$contract->{'contractname'},
251
            $contract->{'contractname'},
252
		$order->{'ordernumber'},
252
            $order->{'ordernumber'},
253
		$order->{'entrydate'}, 
253
            $order->{'entrydate'}, 
254
		$order->{'isbn'},
254
            $order->{'isbn'},
255
		$order->{'author'},
255
            $order->{'author'},
256
		$order->{'title'},
256
            $order->{'title'},
257
		$order->{'publishercode'},
257
            $order->{'publishercode'},
258
		$order->{'collectiontitle'},
258
            $order->{'collectiontitle'},
259
		$order->{'notes'},
259
            $order->{'notes'},
260
		$order->{'quantity'},
260
            $order->{'quantity'},
261
		$order->{'rrp'},
261
            $order->{'rrp'},
262
	    );
262
            $basket->{'deliveryplace'},
263
	push (@rows, \@cols);
263
            $basket->{'billingplace'},
264
        );
265
        push (@rows, \@cols);
264
    }
266
    }
265
267
266
    foreach my $row (@rows) {
268
    foreach my $row (@rows) {
267
	$csv->combine(@$row);                                                                                                                    
269
        $csv->combine(@$row);
268
	$output .= $csv->string() . "\n";    
270
        $output .= $csv->string() . "\n";
269
270
    }
271
    }
271
                                                                                                                                                      
272
    return $output;             
273
272
273
    return $output;
274
}
274
}
275
275
276
276
Lines 384-390 sub ModBasket { Link Here
384
384
385
=head3 ModBasketHeader
385
=head3 ModBasketHeader
386
386
387
  &ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber);
387
  &ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber, $deliveryplace, $billingplace);
388
388
389
Modifies a basket's header.
389
Modifies a basket's header.
390
390
Lines 400-415 Modifies a basket's header. Link Here
400
400
401
=item C<$contractnumber> is the "contractnumber" (foreign) key in the "aqbasket" table.
401
=item C<$contractnumber> is the "contractnumber" (foreign) key in the "aqbasket" table.
402
402
403
=item C<$deliveryplace> is the "deliveryplace" field in the aqbasket table.
404
405
=item C<$billingplace> is the "billingplace" field in the aqbasket table.
406
403
=back
407
=back
404
408
405
=cut
409
=cut
406
410
407
sub ModBasketHeader {
411
sub ModBasketHeader {
408
    my ($basketno, $basketname, $note, $booksellernote, $contractnumber) = @_;
412
    my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $deliveryplace, $billingplace) = @_;
409
    my $query = "UPDATE aqbasket SET basketname=?, note=?, booksellernote=? WHERE basketno=?";
413
    my $query = qq{
414
        UPDATE aqbasket
415
        SET basketname=?, note=?, booksellernote=?, deliveryplace=?, billingplace=?
416
        WHERE basketno=?
417
    };
410
    my $dbh = C4::Context->dbh;
418
    my $dbh = C4::Context->dbh;
411
    my $sth = $dbh->prepare($query);
419
    my $sth = $dbh->prepare($query);
412
    $sth->execute($basketname,$note,$booksellernote,$basketno);
420
    $sth->execute($basketname, $note, $booksellernote, $deliveryplace, $billingplace, $basketno);
413
    if ( $contractnumber ) {
421
    if ( $contractnumber ) {
414
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
422
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
415
        my $sth2 = $dbh->prepare($query2);
423
        my $sth2 = $dbh->prepare($query2);
(-)a/acqui/basket.pl (-1 / +11 lines)
Lines 129-134 if ( $op eq 'delete_confirm' ) { Link Here
129
        creationdate         => format_date( $basket->{creationdate} ),
129
        creationdate         => format_date( $basket->{creationdate} ),
130
        authorisedby         => $basket->{authorisedby},
130
        authorisedby         => $basket->{authorisedby},
131
        authorisedbyname     => $basket->{authorisedbyname},
131
        authorisedbyname     => $basket->{authorisedbyname},
132
        deliveryplace        => $basket->{deliveryplace} || $basket->{freedeliveryplace},
133
        billingplace         => $basket->{billingplace},
132
        closedate            => format_date( $basket->{closedate} ),
134
        closedate            => format_date( $basket->{closedate} ),
133
        active               => $bookseller->{'active'},
135
        active               => $bookseller->{'active'},
134
        booksellerid         => $bookseller->{'id'},
136
        booksellerid         => $bookseller->{'id'},
Lines 340-346 my $total_est_gste; Link Here
340
342
341
    my $contract = &GetContract($basket->{contractnumber});
343
    my $contract = &GetContract($basket->{contractnumber});
342
    my @orders = GetOrders($basketno);
344
    my @orders = GetOrders($basketno);
343
345
    if ($basket->{basketgroupid}){
346
        my $basketgroup = GetBasketgroup($basket->{basketgroupid});
347
        for my $key (keys %$basketgroup ){
348
            $basketgroup->{"basketgroup$key"} = delete $basketgroup->{$key};
349
        }
350
        $template->param(%$basketgroup);
351
    }
344
    my $borrower= GetMember('borrowernumber' => $loggedinuser);
352
    my $borrower= GetMember('borrowernumber' => $loggedinuser);
345
    my $budgets = GetBudgetHierarchy(q{},$borrower->{branchcode},$borrower->{borrowernumber});
353
    my $budgets = GetBudgetHierarchy(q{},$borrower->{branchcode},$borrower->{borrowernumber});
346
    my $has_budgets = 0;
354
    my $has_budgets = 0;
Lines 367-372 my $total_est_gste; Link Here
367
        creationdate         => C4::Dates->new($basket->{creationdate},'iso')->output,
375
        creationdate         => C4::Dates->new($basket->{creationdate},'iso')->output,
368
        authorisedby         => $basket->{authorisedby},
376
        authorisedby         => $basket->{authorisedby},
369
        authorisedbyname     => $basket->{authorisedbyname},
377
        authorisedbyname     => $basket->{authorisedbyname},
378
        deliveryplace        => $basket->{deliveryplace} || $basket->{freedeliveryplace},
379
        billingplace         => $basket->{billingplace},
370
        closedate            => C4::Dates->new($basket->{closedate},'iso')->output,
380
        closedate            => C4::Dates->new($basket->{closedate},'iso')->output,
371
        active               => $bookseller->{'active'},
381
        active               => $bookseller->{'active'},
372
        booksellerid         => $bookseller->{'id'},
382
        booksellerid         => $bookseller->{'id'},
(-)a/acqui/basketheader.pl (-8 / +78 lines)
Lines 50-55 use warnings; Link Here
50
use CGI;
50
use CGI;
51
use C4::Context;
51
use C4::Context;
52
use C4::Auth;
52
use C4::Auth;
53
use C4::Branch;
53
use C4::Output;
54
use C4::Output;
54
use C4::Acquisition qw/GetBasket NewBasket GetContracts ModBasketHeader/;
55
use C4::Acquisition qw/GetBasket NewBasket GetContracts ModBasketHeader/;
55
use C4::Bookseller qw/GetBookSellerFromId/;
56
use C4::Bookseller qw/GetBookSellerFromId/;
Lines 68-76 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
68
);
69
);
69
70
70
#parameters:
71
#parameters:
71
my $booksellerid;
72
my $booksellerid = $input->param('booksellerid');
72
$booksellerid = $input->param('booksellerid');
73
my $basketno = $input->param('basketno');
73
my $basketno = $input->param('basketno');
74
my $branches = GetBranches;
74
my $basket;
75
my $basket;
75
my $op = $input ->param('op');
76
my $op = $input ->param('op');
76
my $is_an_edit= $input ->param('is_an_edit');
77
my $is_an_edit= $input ->param('is_an_edit');
Lines 107-123 if ( $op eq 'add_form' ) { Link Here
107
                    basketbooksellernote => $basket->{'booksellernote'},
108
                    basketbooksellernote => $basket->{'booksellernote'},
108
                    booksellername => $bookseller->{'name'},
109
                    booksellername => $bookseller->{'name'},
109
                    booksellerid => $booksellerid,
110
                    booksellerid => $booksellerid,
110
                    basketno => $basketno
111
                    basketno => $basketno,
111
    	);
112
                    deliveryplace => $basket->{deliveryplace},
113
                    billingplace => $basket->{billingplace},
114
    );
115
116
    my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"};
117
    my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"};
118
119
    # Build the combobox to select the billing place
120
    my @billingplaceloop;
121
122
    # In case there's no branch selected
123
    if ($billingplace eq "NO_LIBRARY_SET") {
124
        my %row = (
125
          value => "",
126
          selected => 1,
127
          branchname => "--",
128
        );
129
        push @billingplaceloop, \%row;
130
    }
131
132
    for ( sort keys %$branches ) {
133
        my $selected = 1 if $_ eq $billingplace;
134
        my %row = (
135
            value      => $_,
136
            selected   => $selected,
137
            branchname => $branches->{$_}->{branchname},
138
        );
139
        push @billingplaceloop, \%row;
140
    }
141
    $template->param( billingplaceloop => \@billingplaceloop );
142
143
    # Build the combobox to select the delivery place
144
    my @deliveryplaceloop;
145
146
    # In case there's no branch selected
147
    if ($deliveryplace eq "NO_LIBRARY_SET") {
148
        my %row = (
149
          value => "",
150
          selected => 1,
151
          branchname => "--",
152
        );
153
        push @deliveryplaceloop, \%row;
154
    }
155
156
    for ( sort keys %$branches ) {
157
        my $selected = 1 if $_ eq $deliveryplace;
158
        my %row = (
159
            value      => $_,
160
            selected   => $selected,
161
            branchname => $branches->{$_}->{branchname},
162
        );
163
        push @deliveryplaceloop, \%row;
164
    }
165
    $template->param( deliveryplaceloop => \@deliveryplaceloop );
166
112
#End Edit
167
#End Edit
113
} elsif ( $op eq 'add_validate' ) {
168
} elsif ( $op eq 'add_validate' ) {
114
#we are confirming the changes, save the basket
169
#we are confirming the changes, save the basket
115
    my $basketno;
116
    if ( $is_an_edit ) {
170
    if ( $is_an_edit ) {
117
        $basketno = $input->param('basketno');
171
        ModBasketHeader(
118
        ModBasketHeader($input->param('basketno'),$input->param('basketname'),$input->param('basketnote'),$input->param('basketbooksellernote'),$input->param('basketcontractnumber'));
172
            $basketno,
173
            $input->param('basketname'),
174
            $input->param('basketnote'),
175
            $input->param('basketbooksellernote'),
176
            $input->param('basketcontractnumber'),
177
            $input->param('deliveryplace'),
178
            $input->param('billingplace'),
179
        );
119
    } else { #New basket
180
    } else { #New basket
120
        $basketno = NewBasket($booksellerid, $loggedinuser, $input->param('basketname'), $input->param('basketnote'), $input->param('basketbooksellernote'), $input->param('basketcontractnumber'));
181
        $basketno = NewBasket(
182
            $booksellerid,
183
            $loggedinuser,
184
            $input->param('basketname'),
185
            $input->param('basketnote'),
186
            $input->param('basketbooksellernote'),
187
            $input->param('basketcontractnumber'),
188
            $input->param('deliveryplace'),
189
            $input->param('billingplace'),
190
        );
121
    }
191
    }
122
    print $input->redirect('basket.pl?basketno='.$basketno);
192
    print $input->redirect('basket.pl?basketno='.$basketno);
123
    exit 0;
193
    exit 0;
(-)a/installer/data/mysql/kohastructure.sql (+3 lines)
Lines 2525-2530 CREATE TABLE `aqbasket` ( Link Here
2525
  `authorisedby` varchar(10) default NULL,
2525
  `authorisedby` varchar(10) default NULL,
2526
  `booksellerinvoicenumber` mediumtext,
2526
  `booksellerinvoicenumber` mediumtext,
2527
  `basketgroupid` int(11),
2527
  `basketgroupid` int(11),
2528
  deliveryplace varchar(10) default NULL,
2529
  billingplace varchar(10) default NULL,
2530
  freedeliveryplace VARCHAR(10) default NULL,
2528
  PRIMARY KEY  (`basketno`),
2531
  PRIMARY KEY  (`basketno`),
2529
  KEY `booksellerid` (`booksellerid`),
2532
  KEY `booksellerid` (`booksellerid`),
2530
  KEY `basketgroupid` (`basketgroupid`),
2533
  KEY `basketgroupid` (`basketgroupid`),
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 4960-4965 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4960
    SetVersion($DBversion);
4960
    SetVersion($DBversion);
4961
}
4961
}
4962
4962
4963
4964
$DBversion = "3.07.00.XXX";
4965
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4966
    $dbh->do("ALTER TABLE aqbasket ADD deliveryplace VARCHAR(10) default NULL;");
4967
    $dbh->do("ALTER TABLE aqbasket ADD billingplace VARCHAR(10) default NULL;");
4968
    $dbh->do("ALTER TABLE aqbasket ADD freedeliveryplace VARCHAR(10) default NULL;");
4969
    print "Upgrade to $DBversion done (Added billingplace and deliveryplace to aqbasket)\n";
4970
    SetVersion($DBversion);
4971
}
4972
4963
=head1 FUNCTIONS
4973
=head1 FUNCTIONS
4964
4974
4965
=head2 DropAllForeignKeys($table)
4975
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-1 / +7 lines)
Lines 134-144 Link Here
134
                        // YUI Toolbar Functions
134
                        // YUI Toolbar Functions
135
                        function yuiToolbar() {
135
                        function yuiToolbar() {
136
                            new YAHOO.widget.Button("reopenbutton");
136
                            new YAHOO.widget.Button("reopenbutton");
137
                            new YAHOO.widget.Button("exportbutton");
137
                        }
138
                        }
138
                        //]]>
139
                        //]]>
139
                    </script>
140
                    </script>
140
                        <ul id="toolbar-list" class="toolbar">
141
                        <ul id="toolbar-list" class="toolbar">
141
                            <li><a href="javascript:confirm_reopen([% skip_confirm_reopen %]);" class="button" id="reopenbutton">Reopen this basket</a></li>
142
                            <li><a href="javascript:confirm_reopen([% skip_confirm_reopen %]);" class="button" id="reopenbutton">Reopen this basket</a></li>
143
                            <li><a href="[% script_name %]?op=export&amp;basketno=[% basketno %]&amp;booksellerid=[% booksellerid %]" class="button" id="exportbutton">Export this basket as CSV</a></li>
144
142
                        </ul>
145
                        </ul>
143
                </div>
146
                </div>
144
                [% END %]
147
                [% END %]
Lines 177-182 Link Here
177
                [% IF ( basketcontractno ) %]
180
                [% IF ( basketcontractno ) %]
178
                    <li><span class="label">Contract name:</span> <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno %]&amp;booksellerid=[% booksellerid %]">[% basketcontractname %]</a></li>
181
                    <li><span class="label">Contract name:</span> <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno %]&amp;booksellerid=[% booksellerid %]">[% basketcontractname %]</a></li>
179
                [% END %]
182
                [% END %]
183
                [% IF ( deliveryplace ) %]<li><span class="label">Delivery place:</span> [% deliveryplace %]</li>[% END %]
184
                [% IF ( billingplace ) %]<li><span class="label">Billing place:</span> [% billingplace %]</li>[% END %]
180
                [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span>  [% authorisedbyname %]</li>[% END %]
185
                [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span>  [% authorisedbyname %]</li>[% END %]
181
                [% IF ( creationdate ) %]<li><span class="label">Opened on:</span>  [% creationdate %]</li>[% END %]
186
                [% IF ( creationdate ) %]<li><span class="label">Opened on:</span>  [% creationdate %]</li>[% END %]
182
                [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate %]</li>[% END %]
187
                [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate %]</li>[% END %]
Lines 203-210 Link Here
203
                        <input type="hidden" value="mod_basket" name="op" />
208
                        <input type="hidden" value="mod_basket" name="op" />
204
                        <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
209
                        <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
205
                        <input type="submit" value="Change basket group" /></p>
210
                        <input type="submit" value="Change basket group" /></p>
206
207
                    </form>
211
                    </form>
212
                    [% IF ( basketgroupdeliveryplace ) %]<p>Basketgroup Delivery place: [% basketgroupdeliveryplace %]</p>[% END %]
213
                    [% IF ( basketgroupbillingplace ) %]<p>Basketgroup Billing place: [% basketgroupbillingplace %]</p>[% END %]
208
                </div>
214
                </div>
209
                [% END %]
215
                [% END %]
210
            </div>
216
            </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt (+1 lines)
Lines 189-194 function yuiToolbar() { Link Here
189
							<input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" /></li>
189
							<input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" /></li>
190
						<li><label for="billingplace">Billing Place:</label>
190
						<li><label for="billingplace">Billing Place:</label>
191
							<select name="billingplace" id="billingplace" style="width:13em;">
191
							<select name="billingplace" id="billingplace" style="width:13em;">
192
                                <option value="">--</option>
192
								[% FOREACH billingplaceloo IN billingplaceloop %]
193
								[% FOREACH billingplaceloo IN billingplaceloop %]
193
	                                [% IF ( billingplaceloo.selected ) %]<option value="[% billingplaceloo.value %]" selected="selected">[% billingplaceloo.branchname %]</option>
194
	                                [% IF ( billingplaceloo.selected ) %]<option value="[% billingplaceloo.value %]" selected="selected">[% billingplaceloo.branchname %]</option>
194
	                                [% ELSE %]<option value="[% billingplaceloo.value %]">[% billingplaceloo.branchname %]</option>[% END%]
195
	                                [% ELSE %]<option value="[% billingplaceloo.value %]">[% billingplaceloo.branchname %]</option>[% END%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt (-1 / +22 lines)
Lines 125-130 li.list2 { Link Here
125
                    <label for="basketname" class="required">Basket name</label> &nbsp;
125
                    <label for="basketname" class="required">Basket name</label> &nbsp;
126
                        <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname %]" />
126
                        <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname %]" />
127
                </li>
127
                </li>
128
                 <li>
129
                    <label for="billingplace">Billing Place:</label>
130
                    <select name="billingplace" id="billingplace">
131
                        <option value="">--</option>
132
                        [% FOREACH billingplace IN billingplaceloop %]
133
                            <option value="[% billingplace.value %]"[% IF ( billingplace.selected ) %] selected="selected"[% END %]>
134
                                [% billingplace.branchname %]
135
                            </option>
136
                        [% END %]
137
                    </select>
138
                </li>
139
                <li>
140
                    <label for="deliveryplace">Delivery  Place:</label>
141
                    <select name="deliveryplace" id="deliveryplace">
142
                        <option value="">--</option>
143
                        [% FOREACH deliveryplace IN deliveryplaceloop %]
144
                            <option value="[% deliveryplace.value %]"[% IF ( deliveryplace.selected ) %] selected="selected"[% END %]>
145
                                [% deliveryplace.branchname %]
146
                            </option>
147
                        [% END %]
148
                    </select>
149
                </li>
128
                <li>
150
                <li>
129
                    <label for="basketnote">Internal note</label> &nbsp;
151
                    <label for="basketnote">Internal note</label> &nbsp;
130
                    <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basketnote %]</textarea>
152
                    <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basketnote %]</textarea>
131
- 

Return to bug 5356