Projekt

Allgemein

Profil

Fehler #180 » testcmd1.pl

erster perlscript - Martin Helmling, 22.06.2016 08:19

 
1
#!/usr/bin/perl
2

    
3
use warnings;
4
use strict;
5
use 5.008;
6

    
7
warn "MH start\n";
8
use SL::Dispatcher;
9
use Data::Dumper;
10
use Devel::REPL 1.002001;
11
use File::Slurp;
12
use Getopt::Long;
13
use Pod::Usage;
14
use CGI qw( -no_xhtml);
15
use DateTime;
16
use SL::Auth;
17
use SL::Form;
18
use SL::Helper::DateTime;
19
use SL::InstanceConfiguration;
20
use SL::Locale;
21
use SL::LXDebug;
22
use Data::Dumper;
23
use List::Util qw(max);
24
use Time::HiRes;
25

    
26
warn "MH lx conf\n";
27
use SL::LxOfficeConf;
28
warn "MH read config\n";
29
SL::LxOfficeConf->read;
30

    
31

    
32
# FILL IN!
33
my $client = '1';
34
my $login  = 'odadmin';
35

    
36
$::lxdebug = LXDebug->new();
37
$::locale  = Locale->new($::lx_office_conf{system}->{language});
38
$::form    = Form->new;
39
$::auth    = SL::Auth->new;
40
die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client);
41

    
42
warn "MH instance config\n";
43
$::instance_conf = SL::InstanceConfiguration->new;
44
$::request       = SL::Request->new(
45
  cgi    => CGI->new({}),
46
  layout => SL::Layout::None->new,
47
);
48

    
49
die 'cannot reach auth db'               unless $::auth->session_tables_present;
50

    
51
$::auth->restore_session;
52

    
53
require "bin/mozilla/common.pl";
54

    
55
die "cannot find user $login"            unless %::myconfig = $::auth->read_user(login => $login);
56

    
57
die "cannot find locale for user $login" unless $::locale   = Locale->new($::myconfig{countrycode});
58

    
59
warn "MH instance config init\n";
60
$main::lxdebug->message(LXDebug->DEBUG2(),"MH instance config init\n");
61
$::instance_conf->init;
62

    
63

    
64

    
65
# ACTUAL REQUEST GOES HERE
66
# example:
67

    
68
my $formvars = <<EOF;
69
   id = 
70
   type = purchase_order
71
   vc = vendor
72
   proforma = 
73
   queued = 
74
   printed = 
75
   emailed = 
76
   ui_tab = 
77
   title = Lieferantenauftrag erfassen
78
   creditlimit = 0.00000
79
   creditremaining = -31558.0668
80
   tradediscount = 
81
   business = 
82
   max_dunning_level = 
83
   dunning_amount = 
84
   shiptoname = 
85
   shiptostreet = 
86
   shiptozipcode = 
87
   credit_note_amount = 
88
   openinvoicesum = -3239.61
89
   openordersum = -17980.07
90
   CFDD_shipto = 
91
   CFDD_shipto_id = 
92
   shiptocity = 
93
   shiptocountry = 
94
   shiptogln = 
95
   shiptocontact = 
96
   shiptophone = 
97
   shiptofax = 
98
   shiptodepartment_1 = 
99
   shiptodepartment_2 = 
100
   shiptoemail = 
101
   shiptocp_gender = 
102
   taxpart = 
103
   taxservice = 
104
   taxaccounts = 1406 
105
   cursor_fokus = partnumber_3
106
   addnumber = 7
107
   show_details = 0
108
   useasnew = 
109
   oldvendor = xxxxx--28553
110
   selectvendor = 
111
   old_currency = EUR
112
   forex = 0
113
   1406_rate = 0.19000
114
   1406_description = Vorsteuer
115
   1406_taxnumber = 1406
116
   convert_from_oe_ids = 
117
   convert_from_ar_ids = 
118
   convert_from_do_id = 
119
   follow_up_trans_id_1 = 
120
   follow_up_trans_type_1 = purchase_order
121
   follow_up_trans_info_1 =  (xxxx)
122
   follow_up_rowcount = 1
123
   lastmtime = 
124
   vendor_id = 28553
125
   vendor = xxxxx
126
   has_customer_vendor_picker = 1
127
   cp_id = 
128
   taxzone_id = 4
129
   department_id = 
130
   currency = EUR
131
   shippingpoint = 
132
   shipvia = 
133
   transaction_description = 
134
   employee_id = 12284
135
   ordnumber = 
136
   quonumber = 
137
   cusordnumber = 
138
   rfqdate = 
139
   transdate = 14.06.2016
140
   reqdate = 15.06.2016
141
   globalproject_id = 
142
   partupd1 = 0
143
   currentrow = 1
144
   runningnumber_1 = 1
145
   partnumber_1 = 355776
146
   description_1 = yyyy 1695071171002
147
   ship_1 = 0,00
148
   qty_1 = 50,00
149
   price_factor_id_1 = 942
150
   unit_1 = Stck
151
   sellprice_1 = 169,46
152
   discount_1 = 0
153
   unit_old_1 = Stck
154
   price_new_1 = 0
155
   orderitems_id_1 = 
156
   bo_1 = 
157
   pricegroup_old_1 = 
158
   price_old_1 = 0
159
   id_1 = 14373
160
   inventory_accno_1 = 1140
161
   bin_1 = 
162
   partsgroup_1 = 
163
   partnotes_1 = 
164
   active_price_source_1 = 
165
   active_discount_source_1 = 
166
   customer_exclusive_1 = 
167
   vendor_exclusive_1 = 
168
   std_warehouse_1 = Elektromateriallager
169
   std_bin_1 = 1
170
   not_discountable_1 = 0
171
   income_accno_1 = 4400
172
   expense_accno_1 = 5400
173
   listprice_1 = 3.50000
174
   assembly_1 = 0
175
   taxaccounts_1 = 1406
176
   ordnumber_1 = 
177
   donumber_1 = 
178
   transdate_1 = 
179
   cusordnumber_1 = 
180
   longdescription_1 = 
181
   basefactor_1 = 
182
   marge_absolut_1 = 84,73
183
   marge_percent_1 = 100,00
184
   marge_price_factor_1 = 100.00000
185
   weight_1 = 0
186
   orderitems_id_1 = 
187
   converted_from_orderitems_id_1 = 
188
   converted_from_invoice_id_1 = 
189
   serialnumber_1 = 
190
   project_id_1 = 
191
   reqdate_1 = 
192
   currentrow = 2
193
   runningnumber_2 = 2
194
   partnumber_2 = 355780
195
   description_2 = zzzzz
196
   ship_2 = 0,00
197
   qty_2 = 500
198
   price_factor_id_2 = 942
199
   unit_2 = Stck
200
   sellprice_2 = 45,26
201
   discount_2 = 0
202
   unit_old_2 = Stck
203
   price_new_2 = 0
204
   orderitems_id_2 = 
205
   bo_2 = 
206
   pricegroup_old_2 = 
207
   price_old_2 = 0
208
   id_2 = 14297
209
   inventory_accno_2 = 1140
210
   bin_2 = 
211
   partsgroup_2 = 
212
   partnotes_2 = 
213
   active_price_source_2 =
214
   active_discount_source_2 = 
215
   customer_exclusive_2 = 
216
   vendor_exclusive_2 = 
217
   std_warehouse_2 = Elektromateriallager
218
   std_bin_2 = 1
219
   not_discountable_2 = 0
220
   income_accno_2 = 4400
221
   expense_accno_2 = 5400
222
   listprice_2 = 0.00000
223
   assembly_2 = 0
224
   taxaccounts_2 = 1406
225
   ordnumber_2 = 
226
   donumber_2 = 
227
   transdate_2 = 
228
   cusordnumber_2 = 
229
   longdescription_2 = 
230
   basefactor_2 = 
231
   marge_absolut_2 = 0,00
232
   marge_percent_2 = 0,00
233
   marge_price_factor_2 = 100.00000
234
   weight_2 = 0
235
   orderitems_id_2 = 
236
   converted_from_orderitems_id_2 = 
237
   converted_from_invoice_id_2 = 
238
   serialnumber_2 = 
239
   project_id_2 = 
240
   reqdate_2 = 
241
   currentrow = 3
242
   runningnumber_3 = 3
243
   partnumber_3 = 
244
   description_3 = 
245
   qty_3 = 0,00
246
   price_factor_id_3 = 
247
   unit_3 = Stck
248
   sellprice_3 = 0,00
249
   discount_3 = 0
250
   unit_old_3 = 
251
   price_new_3 = 0
252
   orderitems_id_3 = 
253
   bo_3 = 
254
   pricegroup_old_3 = 
255
   price_old_3 = 0
256
   id_3 = 
257
   inventory_accno_3 = 
258
   bin_3 = 
259
   partsgroup_3 = 
260
   partnotes_3 = 
261
   active_price_source_3 = 
262
   active_discount_source_3 = 
263
   customer_exclusive_3 = 
264
   vendor_exclusive_3 = 
265
   std_warehouse_3 = 
266
   std_bin_3 = 
267
   not_discountable_3 = 
268
   income_accno_3 = 
269
   expense_accno_3 = 
270
   listprice_3 = 
271
   assembly_3 = 
272
   taxaccounts_3 = 
273
   ordnumber_3 = 
274
   donumber_3 = 
275
   transdate_3 = 
276
   cusordnumber_3 = 
277
   longdescription_3 = 
278
   basefactor_3 = 
279
   marge_absolut_3 = 0,00
280
   marge_percent_3 = 0,00
281
   marge_price_factor_3 = 
282
   weight_3 = 0
283
   orderitems_id_3 = 
284
   converted_from_orderitems_id_3 = 
285
   converted_from_invoice_id_3 = 
286
   serialnumber_3 = 
287
   project_id_3 = 
288
   reqdate_3 = 
289
   notes = 
290
   intnotes = 
291
   payment_id = 43427
292
   delivery_term_id = 
293
   taxincluded_changed_by_user = 0
294
   oldinvtotal = 101.36
295
   oldtotalpaid = 
296
   formname = purchase_order
297
   language_id = 
298
   format = pdf
299
   media = screen
300
   action_update = Erneuern
301
   action = dispatcher
302
   saved_xyznumber = 
303
   rowcount = 3
304
   callback = oe.pl?action=add&type=purchase_order&vc=vendor
305
   vendor_discount = 0
306
EOF
307

    
308

    
309
my @lines = split("\n",$formvars);
310
foreach my $line ( @lines ) {
311
  my ( $name,$value ) = split("=",$line,2);
312
  $name =~ s/^\s+|\s+$//g;
313
  $value =~ s/^\s+|\s+$//g;
314
  $::form->{"$name"} = $value;
315
}
316

    
317
warn "MH now start\n";
318
$main::lxdebug->message(LXDebug->DEBUG2(),"MH now start\n");
319
#my $dbh = SL::DB::Object->new->db->dbh;
320
#warn "MH dbh=".$dbh."\n";
321
#$::form->set_standard_dbh($dbh);
322
#$main::lxdebug->message(LXDebug->DEBUG2(),"MH newdbh=".$dbh);
323
require "bin/mozilla/oe.pl";
324
update();
325

    
(2-2/5)