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
        &GetBasketsInfosByBookseller
47
        &GetBasketsInfosByBookseller
48
48
Lines 182-188 The other parameters are optional, see ModBasketHeader for more info on them. Link Here
182
# FIXME : this function seems to be unused.
182
# FIXME : this function seems to be unused.
183
183
184
sub NewBasket {
184
sub NewBasket {
185
    my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber ) = @_;
185
    my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace ) = @_;
186
    my $dbh = C4::Context->dbh;
186
    my $dbh = C4::Context->dbh;
187
    my $query = "
187
    my $query = "
188
        INSERT INTO aqbasket
188
        INSERT INTO aqbasket
Lines 193-199 sub NewBasket { Link Here
193
    $dbh->do($query);
193
    $dbh->do($query);
194
#find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-(
194
#find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-(
195
    my $basket = $dbh->{'mysql_insertid'};
195
    my $basket = $dbh->{'mysql_insertid'};
196
    ModBasketHeader($basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef);
196
    ModBasketHeader( $basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef, $deliveryplace || undef, $billingplace || undef );
197
    return $basket;
197
    return $basket;
198
}
198
}
199
199
Lines 240-277 sub GetBasketAsCSV { Link Here
240
    # TODO: Translate headers
240
    # TODO: Translate headers
241
    my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp);
241
    my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp);
242
242
243
    $csv->combine(@headers);                                                                                                        
243
    $csv->combine(@headers);
244
    $output = $csv->string() . "\n";	
244
    $output = $csv->string() . "\n";
245
245
246
    my @rows;
246
    my @rows;
247
    foreach my $order (@orders) {
247
    foreach my $order (@orders) {
248
	my @cols;
248
    my @cols;
249
	# newlines are not valid characters for Text::CSV combine()
249
    # newlines are not valid characters for Text::CSV combine()
250
        $order->{'notes'} =~ s/[\r\n]+//g;
250
        $order->{'notes'} =~ s/[\r\n]+//g;
251
	push(@cols,
251
        push(@cols,
252
		$contract->{'contractname'},
252
            $contract->{'contractname'},
253
		$order->{'ordernumber'},
253
            $order->{'ordernumber'},
254
		$order->{'entrydate'}, 
254
            $order->{'entrydate'}, 
255
		$order->{'isbn'},
255
            $order->{'isbn'},
256
		$order->{'author'},
256
            $order->{'author'},
257
		$order->{'title'},
257
            $order->{'title'},
258
		$order->{'publishercode'},
258
            $order->{'publishercode'},
259
		$order->{'collectiontitle'},
259
            $order->{'collectiontitle'},
260
		$order->{'notes'},
260
            $order->{'notes'},
261
		$order->{'quantity'},
261
            $order->{'quantity'},
262
		$order->{'rrp'},
262
            $order->{'rrp'},
263
	    );
263
            $basket->{'deliveryplace'},
264
	push (@rows, \@cols);
264
            $basket->{'billingplace'},
265
        );
266
        push (@rows, \@cols);
265
    }
267
    }
266
268
267
    foreach my $row (@rows) {
269
    foreach my $row (@rows) {
268
	$csv->combine(@$row);                                                                                                                    
270
        $csv->combine(@$row);
269
	$output .= $csv->string() . "\n";    
271
        $output .= $csv->string() . "\n";
270
271
    }
272
    }
272
                                                                                                                                                      
273
    return $output;             
274
273
274
    return $output;
275
}
275
}
276
276
277
277
Lines 385-391 sub ModBasket { Link Here
385
385
386
=head3 ModBasketHeader
386
=head3 ModBasketHeader
387
387
388
  &ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber);
388
  &ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber, $deliveryplace, $billingplace);
389
389
390
Modifies a basket's header.
390
Modifies a basket's header.
391
391
Lines 401-416 Modifies a basket's header. Link Here
401
401
402
=item C<$contractnumber> is the "contractnumber" (foreign) key in the "aqbasket" table.
402
=item C<$contractnumber> is the "contractnumber" (foreign) key in the "aqbasket" table.
403
403
404
=item C<$deliveryplace> is the "deliveryplace" field in the aqbasket table.
405
406
=item C<$billingplace> is the "billingplace" field in the aqbasket table.
407
404
=back
408
=back
405
409
406
=cut
410
=cut
407
411
408
sub ModBasketHeader {
412
sub ModBasketHeader {
409
    my ($basketno, $basketname, $note, $booksellernote, $contractnumber) = @_;
413
    my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $deliveryplace, $billingplace) = @_;
410
    my $query = "UPDATE aqbasket SET basketname=?, note=?, booksellernote=? WHERE basketno=?";
414
    my $query = qq{
415
        UPDATE aqbasket
416
        SET basketname=?, note=?, booksellernote=?, deliveryplace=?, billingplace=?
417
        WHERE basketno=?
418
    };
411
    my $dbh = C4::Context->dbh;
419
    my $dbh = C4::Context->dbh;
412
    my $sth = $dbh->prepare($query);
420
    my $sth = $dbh->prepare($query);
413
    $sth->execute($basketname,$note,$booksellernote,$basketno);
421
    $sth->execute($basketname, $note, $booksellernote, $deliveryplace, $billingplace, $basketno);
414
    if ( $contractnumber ) {
422
    if ( $contractnumber ) {
415
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
423
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
416
        my $sth2 = $dbh->prepare($query2);
424
        my $sth2 = $dbh->prepare($query2);
(-)a/acqui/basket.pl (-1 / +11 lines)
Lines 130-135 if ( $op eq 'delete_confirm' ) { Link Here
130
        authorisedby         => $basket->{authorisedby},
130
        authorisedby         => $basket->{authorisedby},
131
        authorisedbyname     => $basket->{authorisedbyname},
131
        authorisedbyname     => $basket->{authorisedbyname},
132
        closedate            => $basket->{closedate},
132
        closedate            => $basket->{closedate},
133
        deliveryplace        => $basket->{deliveryplace} || $basket->{freedeliveryplace},
134
        billingplace         => $basket->{billingplace},
133
        active               => $bookseller->{'active'},
135
        active               => $bookseller->{'active'},
134
        booksellerid         => $bookseller->{'id'},
136
        booksellerid         => $bookseller->{'id'},
135
        name                 => $bookseller->{'name'},
137
        name                 => $bookseller->{'name'},
Lines 349-355 my $total_est_gste; Link Here
349
351
350
    my $contract = &GetContract($basket->{contractnumber});
352
    my $contract = &GetContract($basket->{contractnumber});
351
    my @orders = GetOrders($basketno);
353
    my @orders = GetOrders($basketno);
352
354
    if ($basket->{basketgroupid}){
355
        my $basketgroup = GetBasketgroup($basket->{basketgroupid});
356
        for my $key (keys %$basketgroup ){
357
            $basketgroup->{"basketgroup$key"} = delete $basketgroup->{$key};
358
        }
359
        $template->param(%$basketgroup);
360
    }
353
    my $borrower= GetMember('borrowernumber' => $loggedinuser);
361
    my $borrower= GetMember('borrowernumber' => $loggedinuser);
354
    my $budgets = GetBudgetHierarchy(q{},$borrower->{branchcode},$borrower->{borrowernumber});
362
    my $budgets = GetBudgetHierarchy(q{},$borrower->{branchcode},$borrower->{borrowernumber});
355
    my $has_budgets = 0;
363
    my $has_budgets = 0;
Lines 378-383 my $total_est_gste; Link Here
378
        authorisedbyname     => $basket->{authorisedbyname},
386
        authorisedbyname     => $basket->{authorisedbyname},
379
        closedate            => $basket->{closedate},
387
        closedate            => $basket->{closedate},
380
        estimateddeliverydate=> $estimateddeliverydate,
388
        estimateddeliverydate=> $estimateddeliverydate,
389
        deliveryplace        => $basket->{deliveryplace} || $basket->{freedeliveryplace},
390
        billingplace         => $basket->{billingplace},
381
        active               => $bookseller->{'active'},
391
        active               => $bookseller->{'active'},
382
        booksellerid         => $bookseller->{'id'},
392
        booksellerid         => $bookseller->{'id'},
383
        name                 => $bookseller->{'name'},
393
        name                 => $bookseller->{'name'},
(-)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 2555-2560 CREATE TABLE `aqbasket` ( Link Here
2555
  `authorisedby` varchar(10) default NULL,
2555
  `authorisedby` varchar(10) default NULL,
2556
  `booksellerinvoicenumber` mediumtext,
2556
  `booksellerinvoicenumber` mediumtext,
2557
  `basketgroupid` int(11),
2557
  `basketgroupid` int(11),
2558
  deliveryplace varchar(10) default NULL,
2559
  billingplace varchar(10) default NULL,
2560
  freedeliveryplace VARCHAR(10) default NULL,
2558
  PRIMARY KEY  (`basketno`),
2561
  PRIMARY KEY  (`basketno`),
2559
  KEY `booksellerid` (`booksellerid`),
2562
  KEY `booksellerid` (`booksellerid`),
2560
  KEY `basketgroupid` (`basketgroupid`),
2563
  KEY `basketgroupid` (`basketgroupid`),
(-)a/installer/data/mysql/updatedatabase.pl (+12 lines)
Lines 5146-5151 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5146
    SetVersion($DBversion);
5146
    SetVersion($DBversion);
5147
}
5147
}
5148
5148
5149
5150
5151
5152
$DBversion = "3.07.00.XXX";
5153
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5154
    $dbh->do("ALTER TABLE aqbasket ADD deliveryplace VARCHAR(10) default NULL;");
5155
    $dbh->do("ALTER TABLE aqbasket ADD billingplace VARCHAR(10) default NULL;");
5156
    $dbh->do("ALTER TABLE aqbasket ADD freedeliveryplace VARCHAR(10) default NULL;");
5157
    print "Upgrade to $DBversion done (Added billingplace and deliveryplace to aqbasket)\n";
5158
    SetVersion($DBversion);
5159
}
5160
5149
=head1 FUNCTIONS
5161
=head1 FUNCTIONS
5150
5162
5151
=head2 DropAllForeignKeys($table)
5163
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-1 / +7 lines)
Lines 135-145 Link Here
135
                        // YUI Toolbar Functions
135
                        // YUI Toolbar Functions
136
                        function yuiToolbar() {
136
                        function yuiToolbar() {
137
                            new YAHOO.widget.Button("reopenbutton");
137
                            new YAHOO.widget.Button("reopenbutton");
138
                            new YAHOO.widget.Button("exportbutton");
138
                        }
139
                        }
139
                        //]]>
140
                        //]]>
140
                    </script>
141
                    </script>
141
                        <ul id="toolbar-list" class="toolbar">
142
                        <ul id="toolbar-list" class="toolbar">
142
                            <li><a href="javascript:confirm_reopen([% skip_confirm_reopen %]);" class="button" id="reopenbutton">Reopen this basket</a></li>
143
                            <li><a href="javascript:confirm_reopen([% skip_confirm_reopen %]);" class="button" id="reopenbutton">Reopen this basket</a></li>
144
                            <li><a href="[% script_name %]?op=export&amp;basketno=[% basketno %]&amp;booksellerid=[% booksellerid %]" class="button" id="exportbutton">Export this basket as CSV</a></li>
145
143
                        </ul>
146
                        </ul>
144
                </div>
147
                </div>
145
                [% END %]
148
                [% END %]
Lines 178-183 Link Here
178
                [% IF ( basketcontractno ) %]
181
                [% IF ( basketcontractno ) %]
179
                    <li><span class="label">Contract name:</span> <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno %]&amp;booksellerid=[% booksellerid %]">[% basketcontractname %]</a></li>
182
                    <li><span class="label">Contract name:</span> <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno %]&amp;booksellerid=[% booksellerid %]">[% basketcontractname %]</a></li>
180
                [% END %]
183
                [% END %]
184
                [% IF ( deliveryplace ) %]<li><span class="label">Delivery place:</span> [% deliveryplace %]</li>[% END %]
185
                [% IF ( billingplace ) %]<li><span class="label">Billing place:</span> [% billingplace %]</li>[% END %]
181
                [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span>  [% authorisedbyname %]</li>[% END %]
186
                [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span>  [% authorisedbyname %]</li>[% END %]
182
                [% IF ( creationdate ) %]<li><span class="label">Opened on:</span>  [% creationdate | $KohaDates %]</li>[% END %]
187
                [% IF ( creationdate ) %]<li><span class="label">Opened on:</span>  [% creationdate | $KohaDates %]</li>[% END %]
183
                [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>[% END %]
188
                [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>[% END %]
Lines 205-212 Link Here
205
                        <input type="hidden" value="mod_basket" name="op" />
210
                        <input type="hidden" value="mod_basket" name="op" />
206
                        <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
211
                        <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
207
                        <input type="submit" value="Change basket group" /></p>
212
                        <input type="submit" value="Change basket group" /></p>
208
209
                    </form>
213
                    </form>
214
                    [% IF ( basketgroupdeliveryplace ) %]<p>Basketgroup Delivery place: [% basketgroupdeliveryplace %]</p>[% END %]
215
                    [% IF ( basketgroupbillingplace ) %]<p>Basketgroup Billing place: [% basketgroupbillingplace %]</p>[% END %]
210
                </div>
216
                </div>
211
                [% END %]
217
                [% END %]
212
            </div>
218
            </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