1#===================================================================== 2# SQL-Ledger 3# Copyright (c) DWS Systems Inc. 4# 5# Author: DWS Systems Inc. 6# Web: http://www.sql-ledger.com 7# 8#====================================================================== 9# 10# customer/vendor module 11# 12#====================================================================== 13 14use SL::CT; 15 16require "$form->{path}/cm.pl"; 17require "$form->{path}/js.pl"; 18 191; 20# end of main 21 22 23 24sub add { 25 26 $form->{title} = "Add"; 27 28 $form->{callback} = "$form->{script}?action=add&db=$form->{db}&typeofcontact=$form->{typeofcontact}&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 29 30 $form->helpref("$form->{db}", $myconfig{countrycode}); 31 &create_links; 32 33 &display_form; 34 35} 36 37 38sub edit { 39 40 $form->{title} = "Edit"; 41 42 $form->helpref("$form->{db}", $myconfig{countrycode}); 43 &create_links; 44 45 &display_form; 46 47} 48 49 50sub create_links { 51 52 if ($form->{db} eq 'customer') { 53 $form->{ARAP} = 'AR'; 54 } else { 55 $form->{ARAP} = 'AP'; 56 } 57 58 CT->create_links(\%myconfig, \%$form); 59 60 for (keys %$form) { $form->{$_} = $form->quote($form->{$_}) } 61 62 for (qw(discount cashdiscount)) { $form->{$_} *= 100 } 63 64 $form->{contactid} = $form->{all_contact}->[0]->{id}; 65 if ($form->{all_contact}->[0]->{typeofcontact}) { 66 $form->{typeofcontact} = $form->{all_contact}->[0]->{typeofcontact}; 67 } 68 $form->{typeofcontact} ||= "company"; 69 for (qw(email phone fax mobile salutation firstname lastname gender contacttitle occupation)) { $form->{$_} = $form->{all_contact}->[0]->{$_} } 70 $form->{gender} ||= 'M'; 71 72 if ($form->{currencies}) { 73 # currencies 74 for (split /:/, $form->{currencies}) { $form->{selectcurrency} .= "$_\n" } 75 } 76 77 # accounts 78 foreach $item (qw(arap discount payment)) { 79 if (@ { $form->{"${item}_accounts"} }) { 80 $form->{"select$item"} = "\n"; 81 for (@{ $form->{"${item}_accounts"} }) { $form->{"select$item"} .= qq|$_->{accno}--$_->{description}\n| } 82 83 $form->{"select$item"} = $form->escape($form->{"select$item"},1); 84 } 85 } 86 87 if (@{ $form->{all_business} }) { 88 $form->{selectbusiness} = qq|\n|; 89 for (@{ $form->{all_business} }) { $form->{selectbusiness} .= qq|$_->{description}--$_->{id}\n| } 90 $form->{selectbusiness} = $form->escape($form->{selectbusiness},1); 91 } 92 93 if (@{ $form->{all_paymentmethod} }) { 94 $form->{selectpaymentmethod} = qq|\n|; 95 for (@{ $form->{all_paymentmethod} }) { $form->{selectpaymentmethod} .= qq|$_->{description}--$_->{id}\n| } 96 $form->{selectpaymentmethod} = $form->escape($form->{selectpaymentmethod},1); 97 } 98 99 if (@{ $form->{all_pricegroup} } && $form->{db} eq 'customer') { 100 $form->{selectpricegroup} = qq|\n|; 101 for (@{ $form->{all_pricegroup} }) { $form->{selectpricegroup} .= qq|$_->{pricegroup}--$_->{id}\n| } 102 $form->{selectpricegroup} = $form->escape($form->{selectpricegroup},1); 103 } 104 105 if (@{ $form->{all_language} }) { 106 $form->{selectlanguage} = qq|\n|; 107 for (@{ $form->{all_language} }) { $form->{selectlanguage} .= qq|$_->{code}--$_->{description}\n| } 108 $form->{selectlanguage} = $form->escape($form->{selectlanguage},1); 109 } 110 111 if (@{ $form->{all_employee} }) { 112 $form->{selectemployee} = qq|\n|; 113 for (@{ $form->{all_employee} }) { 114 $form->{selectemployee} .= qq|$_->{name}--$_->{id}\n|; 115 } 116 $form->{selectemployee} = $form->escape($form->{selectemployee},1); 117 } 118 119 &all_references; 120 121} 122 123 124sub history { 125 126# $locale->text('Customer History') 127# $locale->text('Vendor History') 128 129 $history = 1; 130 $label = ucfirst $form->{db}; 131 $label .= " History"; 132 133 if ($form->{db} eq 'customer') { 134 $form->helpref("customer_history", $myconfig{countrycode}); 135 136 $invlabel = $locale->text('Sales Invoices'); 137 $ordlabel = $locale->text('Sales Orders'); 138 $quolabel = $locale->text('Quotations'); 139 } else { 140 $form->helpref("vendor_history", $myconfig{countrycode}); 141 142 $invlabel = $locale->text('Vendor Invoices'); 143 $ordlabel = $locale->text('Purchase Orders'); 144 $quolabel = $locale->text('Request for Quotations'); 145 } 146 147 $form->all_years(\%myconfig); 148 149 if (@{ $form->{all_years} }) { 150 # accounting years 151 $selectaccountingyear = "\n"; 152 for (@{ $form->{all_years} }) { $selectaccountingyear .= qq|$_\n| } 153 $selectaccountingmonth = "\n"; 154 for (sort keys %{ $form->{all_month} }) { $selectaccountingmonth .= qq|$_--|.$locale->text($form->{all_month}{$_}).qq|\n| } 155 156 $selectfrom = qq| 157 <tr> 158 <th align=right>|.$locale->text('Period').qq|</th> 159 <td> 160 <select name=month>|.$form->select_option($selectaccountingmonth, undef, 1, 1).qq|</select> 161 <select name=year>|.$form->select_option($selectaccountingyear, undef, 1).qq|</select> 162 <input name=interval class=radio type=radio value=0 checked> |.$locale->text('Current').qq| 163 <input name=interval class=radio type=radio value=1> |.$locale->text('Month').qq| 164 <input name=interval class=radio type=radio value=3> |.$locale->text('Quarter').qq| 165 <input name=interval class=radio type=radio value=12> |.$locale->text('Year').qq| 166 </td> 167 </tr> 168|; 169 } 170 171 172 $form->{title} = $locale->text($label); 173 174 $form->{nextsub} = "list_history"; 175 176 $transactions = qq| 177 <tr> 178 <td></td> 179 <td> 180 <table> 181 <tr> 182 <td> 183 <table> 184 <tr> 185 <td><input name=type type=radio class=radio value=invoice checked> $invlabel</td> 186 </tr> 187 <tr> 188 <td><input name=type type=radio class=radio value=order> $ordlabel</td> 189 </tr> 190 <tr> 191 <td><input name="type" type=radio class=radio value=quotation> $quolabel</td> 192 </tr> 193 </table> 194 </td> 195 <td> 196 <table> 197 <tr> 198 <th>|.$locale->text('From').qq|</th> 199 <td><input name=transdatefrom size=11 class=date title="$myconfig{dateformat}"> <b>|.&js_calendar("main", "transdatefrom").$locale->text('To').qq|</b> <input name=transdateto size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "transdateto").qq|</td> 200 </tr> 201 $selectfrom 202 <tr> 203 <td></td> 204 <td colspan=3> 205 <input name="open" type=checkbox class=checkbox value=Y checked> |.$locale->text('Open').qq| 206 <input name="closed" type=checkbox class=checkbox value=Y checked> |.$locale->text('Closed').qq| 207 </td> 208 </tr> 209 </table> 210 </td> 211 </tr> 212 </table> 213 </td> 214 </tr> 215|; 216 217 $include = qq| 218 <tr> 219 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th> 220 <td> 221 <table> 222 <tr> 223 <td><input name=history type=radio class=radio value=summary checked> |.$locale->text('Summary').qq|</td> 224 <td><input name=history type=radio class=radio value=detail> |.$locale->text('Detail').qq| 225 </td> 226 </tr> 227 <tr> 228 <td> 229 <input name="l_partnumber" type=checkbox class=checkbox value=Y checked> |.$locale->text('Part Number').qq| 230 </td> 231 <td> 232 <input name="l_description" type=checkbox class=checkbox value=Y checked> |.$locale->text('Description').qq| 233 </td> 234 <td> 235 <input name="l_sellprice" type=checkbox class=checkbox value=Y checked> |.$locale->text('Sell Price').qq| 236 </td> 237 <td> 238 <input name="l_curr" type=checkbox class=checkbox value=Y> |.$locale->text('Currency').qq| 239 </td> 240 </tr> 241 <tr> 242 <td> 243 <input name="l_qty" type=checkbox class=checkbox value=Y checked> |.$locale->text('Qty').qq| 244 </td> 245 <td> 246 <input name="l_unit" type=checkbox class=checkbox value=Y> |.$locale->text('Unit').qq| 247 </td> 248 <td> 249 <input name="l_discount" type=checkbox class=checkbox value=Y> |.$locale->text('Discount').qq| 250 </td> 251 <tr> 252 </tr> 253 <td> 254 <input name="l_deliverydate" type=checkbox class=checkbox value=Y> |.$locale->text('Delivery Date').qq| 255 </td> 256 <td> 257 <input name="l_projectnumber" type=checkbox class=checkbox value=Y> |.$locale->text('Project Number').qq| 258 </td> 259 <td> 260 <input name="l_serialnumber" type=checkbox class=checkbox value=Y> |.$locale->text('Serial Number').qq| 261 </td> 262 </tr> 263 </table> 264 </td> 265 </tr> 266|; 267 268 &search_name; 269 270 %button = ('Continue' => { ndx => 1, key => 'C', value => $locale->text('Continue') } 271 ); 272 273 $form->print_button(\%button); 274 275 $form->hide_form(qw(ARAP db nextsub path login)); 276 277 if ($form->{menubar}) { 278 require "$form->{path}/menu.pl"; 279 &menubar; 280 } 281 282 print qq| 283</form> 284 285</body> 286</html> 287|; 288 289} 290 291 292sub transactions { 293 294 if ($form->{db} eq 'customer') { 295 $translabel = $locale->text('AR Transactions'); 296 $invlabel = $locale->text('Sales Invoices'); 297 $ordlabel = $locale->text('Sales Orders'); 298 $quolabel = $locale->text('Quotations'); 299 } else { 300 $translabel = $locale->text('AP Transactions'); 301 $invlabel = $locale->text('Vendor Invoices'); 302 $ordlabel = $locale->text('Purchase Orders'); 303 $quolabel = $locale->text('Request for Quotations'); 304 } 305 306 $form->all_years(\%myconfig); 307 308 if (@{ $form->{all_years} }) { 309 # accounting years 310 $selectaccountingyear = "\n"; 311 for (@{ $form->{all_years} }) { $selectaccountingyear .= qq|$_\n| } 312 $selectaccountingmonth = "\n"; 313 for (sort keys %{ $form->{all_month} }) { $selectaccountingmonth .= qq|$_--|.$locale->text($form->{all_month}{$_}).qq|\n| } 314 315 $selectfrom = qq| 316 <tr> 317 <th align=right>|.$locale->text('Period').qq|</th> 318 <td> 319 <select name=month>|.$form->select_option($selectaccountingmonth, undef, 1, 1).qq|</select> 320 <select name=year>|.$form->select_option($selectaccountingyear, undef, 1).qq|</select> 321 <input name=interval class=radio type=radio value=0 checked> |.$locale->text('Current').qq| 322 <input name=interval class=radio type=radio value=1> |.$locale->text('Month').qq| 323 <input name=interval class=radio type=radio value=3> |.$locale->text('Quarter').qq| 324 <input name=interval class=radio type=radio value=12> |.$locale->text('Year').qq| 325 </td> 326 </tr> 327|; 328 } 329 330 $transactions = qq| 331 <tr> 332 <td></td> 333 <td> 334 <table> 335 <tr> 336 <td> 337 <table> 338 <tr> 339 <td><input name="l_transnumber" type=checkbox class=checkbox value=Y> $translabel</td> 340 </tr> 341 <tr> 342 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> $invlabel</td> 343 </tr> 344 <tr> 345 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> $ordlabel</td> 346 </tr> 347 <tr> 348 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> $quolabel</td> 349 </tr> 350 </table> 351 </td> 352 <td> 353 <table> 354 <tr> 355 <th>|.$locale->text('From').qq|</th> 356 <td nowrap><input name=transdatefrom size=11 class=date title="$myconfig{dateformat}"> <b>|.&js_calendar("main", "transdatefrom").$locale->text('To').qq|</b> <input name=transdateto size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "transdateto").qq|</td> 357 </tr> 358 $selectfrom 359 <tr> 360 <td></td> 361 <td colspan=3> 362 <input name="open" type=checkbox class=checkbox value=Y checked> |.$locale->text('Open').qq| 363 <input name="closed" type=checkbox class=checkbox value=Y checked> |.$locale->text('Closed').qq| 364 </td> 365 </tr> 366 <tr> 367 <td></td> 368 <td colspan=3> 369 <input name="l_amount" type=checkbox class=checkbox value=Y checked> |.$locale->text('Amount').qq| 370 <input name="l_tax" type=checkbox class=checkbox value=Y checked> |.$locale->text('Tax').qq| 371 <input name="l_total" type=checkbox class=checkbox value=Y checked> |.$locale->text('Total').qq| 372 <input name="l_subtotal" type=checkbox class=checkbox value=Y> |.$locale->text('Subtotal').qq| 373 </td> 374 </tr> 375 </table> 376 </td> 377 </tr> 378 </table> 379 </td> 380 </tr> 381|; 382 383} 384 385 386sub include_in_report { 387 388 if ($form->{db} eq 'customer') { 389 $vcname = $locale->text('Customer'); 390 $vcnumber = $locale->text('Customer Number'); 391 } else { 392 $vcname = $locale->text('Vendor'); 393 $vcnumber = $locale->text('Vendor Number'); 394 } 395 396 @f = (); 397 398 push @f, qq|<input name="l_ndx" type=checkbox class=checkbox value=Y> |.$locale->text('No.'); 399 push @f, qq|<input name="l_id" type=checkbox class=checkbox value=Y> |.$locale->text('ID'); 400 push @f, qq|<input name="l_typeofcontact" type=checkbox class=checkbox value=Y> |.$locale->text('Type'); 401 push @f, qq|<input name="l_name" type=checkbox class=checkbox value=Y $form->{l_name}> $vcname|; 402 push @f, qq|<input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> $vcnumber|; 403 push @f, qq|<input name="l_address" type=checkbox class=checkbox value=Y> |.$locale->text('Address'); 404 push @f, qq|<input name="l_salutation" type=checkbox class=checkbox value=Y $form->{l_salutation}> |.$locale->text('Salutation'); 405 push @f, qq|<input name="l_contact" type=checkbox class=checkbox value=Y $form->{l_contact}> |.$locale->text('Contact'); 406 push @f, qq|<input name="l_contacttitle" type=checkbox class=checkbox value=Y $form->{l_contacttitle}> |.$locale->text('Title'); 407 push @f, qq|<input name="l_gender" type=checkbox class=checkbox value=Y $form->{l_gender}> |.$locale->text('Gender'); 408 push @f, qq|<input name="l_occupation" type=checkbox class=checkbox value=Y $form->{l_occupation}> |.$locale->text('Occupation'); 409 push @f, qq|<input name="l_email" type=checkbox class=checkbox value=Y $form->{l_email}> |.$locale->text('E-mail'); 410 push @f, qq|<input name="l_cc" type=checkbox class=checkbox value=Y> |.$locale->text('Cc'); 411 push @f, qq|<input name="l_bcc" type=checkbox class=checkbox value=Y> |.$locale->text('Bcc'); 412 push @f, qq|<input name="l_city" type=checkbox class=checkbox value=Y> |.$locale->text('City'); 413 push @f, qq|<input name="l_state" type=checkbox class=checkbox value=Y> |.$locale->text('State/Province'); 414 push @f, qq|<input name="l_zipcode" type=checkbox class=checkbox value=Y> |.$locale->text('Zip/Postal Code'); 415 push @f, qq|<input name="l_country" type=checkbox class=checkbox value=Y> |.$locale->text('Country'); 416 push @f, qq|<input name="l_phone" type=checkbox class=checkbox value=Y $form->{l_phone}> |.$locale->text('Phone'); 417 push @f, qq|<input name="l_fax" type=checkbox class=checkbox value=Y> |.$locale->text('Fax'); 418 push @f, qq|<input name="l_notes" type=checkbox class=checkbox value=Y> |.$locale->text('Notes'); 419 push @f, qq|<input name="l_discount" type=checkbox class=checkbox value=Y> |.$locale->text('Discount'); 420 push @f, qq|<input name="l_threshold" type=checkbox class=checkbox value=Y> |.$locale->text('Threshold'); 421 push @f, qq|<input name="l_accounts" type=checkbox class=checkbox value=Y> |.$locale->text('Accounts'); 422 push @f, qq|<input name="l_paymentmethod" type=checkbox class=checkbox value=Y> |.$locale->text('Payment Method'); 423 push @f, qq|<input name="l_taxnumber" type=checkbox class=checkbox value=Y> |.$locale->text('Tax Number'); 424 425 if ($form->{db} eq 'customer') { 426 push @f, qq|<input name="l_employee" type=checkbox class=checkbox value=Y> |.$locale->text('Salesperson'); 427 push @f, qq|<input name="l_pricegroup" type=checkbox class=checkbox value=Y> |.$locale->text('Pricegroup'); 428 429 } else { 430 push @f, qq|<input name="l_employee" type=checkbox class=checkbox value=Y> |.$locale->text('Employee'); 431 push @f, qq|<input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |.$locale->text('GIFI'); 432 433 } 434 435 push @f, qq|<input name="l_sic_code" type=checkbox class=checkbox value=Y> |.$locale->text('SIC'); 436 push @f, qq|<input name="l_bankname" type=checkbox class=checkbox value=Y> |.$locale->text('Bank'); 437 push @f, qq|<input name="l_bankaddress" type=checkbox class=checkbox value=Y> |.$locale->text('Address'); 438 push @f, qq|<input name="l_bankcity" type=checkbox class=checkbox value=Y> |.$locale->text('City'); 439 push @f, qq|<input name="l_bankstate" type=checkbox class=checkbox value=Y> |.$locale->text('State/Province'); 440 push @f, qq|<input name="l_bankzipcode" type=checkbox class=checkbox value=Y> |.$locale->text('Zip/Postal Code'); 441 push @f, qq|<input name="l_bankcountry" type=checkbox class=checkbox value=Y> |.$locale->text('Country'); 442 443 push @f, qq|<input name="l_iban" type=checkbox class=checkbox value=Y> |.$locale->text('IBAN'); 444 push @f, qq|<input name="l_bic" type=checkbox class=checkbox value=Y> |.$locale->text('BIC'); 445 push @f, qq|<input name="l_membernumber" type=checkbox class=checkbox value=Y> |.$locale->text('Member Number'); 446 push @f, qq|<input name="l_clearingnumber" type=checkbox class=checkbox value=Y> |.$locale->text('BC Number'); 447 push @f, qq|<input name="l_business" type=checkbox class=checkbox value=Y> |.$locale->text('Type of Business'); 448 push @f, qq|<input name="l_creditlimit" type=checkbox class=checkbox value=Y> |.$locale->text('Credit Limit'); 449 push @f, qq|<input name="l_outstanding" type=checkbox class=checkbox value=Y> |.$locale->text('Outstanding'); 450 push @f, qq|<input name="l_availablecredit" type=checkbox class=checkbox value=Y> |.$locale->text('Available Credit'); 451 push @f, qq|<input name="l_terms" type=checkbox class=checkbox value=Y> |.$locale->text('Terms'); 452 push @f, qq|<input name="l_language" type=checkbox class=checkbox value=Y> |.$locale->text('Language'); 453 push @f, qq|<input name="l_remittancevoucher" type=checkbox class=checkbox value=Y> |.$locale->text('Remittance Voucher'); 454 push @f, qq|<input name="l_startdate" type=checkbox class=checkbox value=Y> |.$locale->text('Startdate'); 455 push @f, qq|<input name="l_enddate" type=checkbox class=checkbox value=Y> |.$locale->text('Enddate'); 456 457 458 $include = qq| 459 <tr> 460 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th> 461 <td> 462 <table> 463|; 464 465 while (@f) { 466 $include .= qq|<tr>\n|; 467 for (1 .. 5) { 468 $include .= qq|<td nowrap>|. shift @f; 469 $include .= qq|</td>\n|; 470 } 471 $include .= qq|</tr>\n|; 472 } 473 474 $include .= qq| 475 </table> 476 </td> 477 </tr> 478|; 479 480} 481 482 483sub search { 484 485# $locale->text('Customers') 486# $locale->text('Vendors') 487 488 489 $form->{title} = $locale->text('Search') unless $form->{title}; 490 491 for (qw(name contact phone email)) { $form->{"l_$_"} = 'checked' } 492 493 $form->{nextsub} = "list_names"; 494 495 %checked = ( all => 'checked' ); 496 497 $orphan = qq| 498 <tr> 499 <td></td> 500 <td><input name=status class=radio type=radio value=all $checked{all}> |.$locale->text('All').qq| 501 <input name=status class=radio type=radio value=active $checked{active}> |.$locale->text('Active').qq| 502 <input name=status class=radio type=radio value=inactive $checked{inactive}> |.$locale->text('Inactive').qq| 503 <input name=status class=radio type=radio value=orphaned $checked{orphaned}> |.$locale->text('Orphaned').qq|</td> 504 </tr> 505|; 506 507 508 &transactions; 509 &include_in_report; 510 &search_name; 511 512 %button = ('Continue' => { ndx => 1, key => 'C', value => $locale->text('Continue') } 513 ); 514 515 $form->print_button(\%button); 516 517 $form->hide_form(qw(ARAP db nextsub path login)); 518 519 if ($form->{menubar}) { 520 require "$form->{path}/menu.pl"; 521 &menubar; 522 } 523 524 print qq| 525</form> 526 527</body> 528</html> 529|; 530 531} 532 533 534sub search_name { 535 536 $form->all_employees(\%myconfig, undef, undef, 1); 537 538 if (@{ $form->{all_employee} }) { 539 $form->{selectemployee} = "\n"; 540 for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|$_->{name}--$_->{id}\n| } 541 } 542 543 if ($form->{db} eq 'customer') { 544 $vcname = $locale->text('Customer'); 545 $vcnumber = $locale->text('Customer Number'); 546 $label = $locale->text('Salesperson'); 547 548 $form->{ARAP} = "AR"; 549 550 } 551 if ($form->{db} eq 'vendor') { 552 $vcname = $locale->text('Vendor'); 553 $vcnumber = $locale->text('Vendor Number'); 554 $label = $locale->text('Employee'); 555 556 $form->{ARAP} = "AP"; 557 } 558 559 if ($form->{selectemployee}) { 560 $employee = qq| 561 <tr> 562 <th align=right nowrap>$label</th> 563 <td><select name=employee>| 564 .$form->select_option($form->{selectemployee}, undef, 1) 565 .qq| 566 </select> 567 </td> 568 </tr> 569|; 570 } 571 572 $form->all_business(\%myconfig); 573 574 if (@{ $form->{all_business} }) { 575 $form->{selectbusiness} = "\n"; 576 for (@{ $form->{all_business} }) { $form->{selectbusiness} .= qq|$_->{description}--$_->{id}\n| } 577 578 $typeofbusiness = qq| 579 <tr> 580 <th align=right nowrap>|.$locale->text('Type of Business').qq|</th> 581 <td><select name=business>| 582 .$form->select_option($form->{selectbusiness}, undef, 1) 583 .qq| 584 </select> 585 </td> 586 </tr> 587|; 588 } 589 590 $form->all_countries(\%myconfig, $form->{db}); 591 592 if ($form->{all_countries}) { 593 $form->{selectcountry} = "\n"; 594 for (@{ $form->{all_countries} }) { $form->{selectcountry} .= qq|$_->{country}\n| } 595 596 $selectcountry = qq| 597 <tr> 598 <th align=right nowrap>|.$locale->text('Country').qq|</th> 599 <td><select name=country>| 600 .$form->select_option($form->{selectcountry}) 601 .qq|</select></td> 602 </tr> 603|; 604 } 605 606 if (! $form->{helpref}) { 607 $form->helpref("search_$form->{db}", $myconfig{countrycode}); 608 } 609 610 $focus = "name"; 611 612 $form->header; 613 614 &calendar; 615 616 print qq| 617<body onLoad="main.${focus}.focus()" /> 618 619<form method="post" name="main" action=$form->{script}> 620 621<table width=100%> 622 <tr> 623 <th class=listtop>$form->{helpref}$form->{title}</a></th> 624 </tr> 625 <tr height="5"></tr> 626 <tr valign=top> 627 <td> 628 <table> 629 <tr valign=top> 630 <td> 631 <table> 632 <tr> 633 <th align=right nowrap>$vcname</th> 634 <td><input name=name size=32></td> 635 </tr> 636 <tr> 637 <th align=right nowrap>|.$locale->text('Contact').qq|</th> 638 <td><input name=contact size=32></td> 639 </tr> 640 <tr> 641 <th align=right nowrap>|.$locale->text('E-mail').qq|</th> 642 <td><input name=email size=32></td> 643 </tr> 644 <tr> 645 <th align=right nowrap>|.$locale->text('Phone').qq|</th> 646 <td><input name=phone size=20></td> 647 </tr> 648 <tr> 649 </tr> 650 <tr> 651 <th align=right nowrap>|.$locale->text('Notes').qq|</th> 652 <td colspan=3><textarea name=notes rows=3 cols=32></textarea></td> 653 </tr> 654 $employee 655 $typeofbusiness 656 </table> 657 </td> 658 659 <td> 660 <table> 661 <tr> 662 <th align=right nowrap>$vcnumber</th> 663 <td><input name=$form->{db}number size=32></td> 664 </tr> 665 <tr> 666 <th align=right nowrap>|.$locale->text('Address').qq|</th> 667 <td><input name=address size=32></td> 668 </tr> 669 <tr> 670 <th align=right nowrap>|.$locale->text('City').qq|</th> 671 <td><input name=city size=32></td> 672 </tr> 673 <tr> 674 <th align=right nowrap>|.$locale->text('State/Province').qq|</th> 675 <td><input name=state size=32></td> 676 </tr> 677 <tr> 678 <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th> 679 <td><input name=zipcode size=10></td> 680 </tr> 681 $selectcountry 682 <tr> 683 <th align=right nowrap>|.$locale->text('Startdate').qq|</th> 684 <td nowrap>|.$locale->text('From').qq| <input name=startdatefrom size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "startdatefrom").$locale->text('To').qq| <input name=startdateto size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "startdateto").qq|</td> 685 </tr> 686 </table> 687 </td> 688 </tr> 689 </table> 690 </td> 691 </tr> 692 693 <tr> 694 <td> 695 <table> 696 697 $orphan 698 $transactions 699 $include 700 701 </table> 702 </td> 703 </tr> 704 705 <tr> 706 <td><hr size=3 noshade></td> 707 </tr> 708</table> 709 710<br> 711|; 712 713} 714 715 716sub list_names { 717 718 CT->search(\%myconfig, \%$form); 719 720 $href = "$form->{script}?action=list_names"; 721 for (qw(direction oldsort db ARAP path login status l_subtotal)) { $href .= "&$_=$form->{$_}" } 722 723 $form->sort_order(); 724 725 $callback = "$form->{script}?action=list_names"; 726 for (qw(direction oldsort db ARAP path login status l_subtotal)) { $callback .= "&$_=$form->{$_}" } 727 728 if ($form->{db} eq 'customer') { 729 $vcname = $locale->text('Customer'); 730 $vcnumber = $locale->text('Customer Number'); 731 } else { 732 $vcname = $locale->text('Vendor'); 733 $vcnumber = $locale->text('Vendor Number'); 734 } 735 736 @columns = (id, name, typeofcontact, "$form->{db}number"); 737 738 if ($form->{l_address}) { 739 for (address1, address2) { 740 $form->{"l_$_"} = "Y"; 741 push @columns, $_; 742 } 743 $callback .= "&l_address=Y"; 744 $href .= "&l_address=Y"; 745 } 746 747 push @columns, (city, state, zipcode, country, salutation); 748 749 if ($form->{l_contact}) { 750 for (firstname, lastname) { 751 $form->{"l_$_"} = "Y"; 752 push @columns, $_; 753 } 754 $callback .= "&l_contact=Y"; 755 $href .= "&l_contact=Y"; 756 } 757 758 push@ columns, (contacttitle, gender, occupation, 759 phone, fax, email, cc, bcc, employee, 760 notes, discount, terms, creditlimit, outstanding, availablecredit); 761 762 if ($form->{l_accounts}) { 763 for (arap_accno, payment_accno, discount_accno, taxaccounts) { 764 $form->{"l_$_"} = "Y"; 765 push @columns, $_; 766 } 767 $callback .= "&l_accounts=Y"; 768 $href .= "&l_accounts=Y"; 769 } 770 771 push @columns, (paymentmethod, threshold, taxnumber, gifi_accno, sic_code, 772 business, pricegroup, language, bankname); 773 774 if ($form->{l_bankaddress}) { 775 for (bankaddress1, bankaddress2) { 776 $form->{"l_$_"} = "Y"; 777 push @columns, $_; 778 } 779 $callback .= "&l_bankaddress=Y"; 780 $href .= "&l_bankaddress=Y"; 781 } 782 783 push @columns, qw(bankcity bankstate bankzipcode bankcountry iban bic remittancevoucher membernumber clearingnumber startdate enddate invnumber invamount invtax invtotal ordnumber ordamount ordtax ordtotal quonumber quoamount quotax quototal); 784 @columns = $form->sort_columns(@columns); 785 786 if ($form->{sort} eq 'contact') { 787 grep { s/^(firstname|lastname|contact)$// } @columns; 788 unshift @columns, (firstname, lastname); 789 } 790 unshift @columns, "ndx"; 791 792 $form->{l_invnumber} = "Y" if $form->{l_transnumber}; 793 foreach $item (qw(inv ord quo)) { 794 if ($form->{"l_${item}number"}) { 795 for (qw(amount tax total)) { $form->{"l_$item$_"} = $form->{"l_$_"} } 796 $removeemployee = 1; 797 $openclosed = 1; 798 } 799 } 800 $form->{open} = $form->{closed} = "" if !$openclosed; 801 802 803 for (@columns) { 804 if ($form->{"l_$_"} eq "Y") { 805 push @column_index, $_; 806 # add column to href and callback 807 $callback .= "&l_$_=Y"; 808 $href .= "&l_$_=Y"; 809 } 810 } 811 812 for (qw(amount tax total transnumber)) { 813 if ($form->{"l_$_"} eq "Y") { 814 $callback .= "&l_$_=Y"; 815 $href .= "&l_$_=Y"; 816 } 817 } 818 819 820 if ($form->{status} eq 'all') { 821 $option = $locale->text('All'); 822 } 823 if ($form->{status} eq 'orphaned') { 824 $option = $locale->text('Orphaned'); 825 unshift @column_index, "delete"; 826 } 827 if ($form->{status} eq 'active') { 828 $option = $locale->text('Active'); 829 } 830 if ($form->{status} eq 'inactive') { 831 $option = $locale->text('Inactive'); 832 } 833 834 if ($form->{name}) { 835 $callback .= "&name=".$form->escape($form->{name},1); 836 $href .= "&name=".$form->escape($form->{name}); 837 $option .= "\n<br>$vcname : $form->{name}"; 838 } 839 if ($form->{address}) { 840 $callback .= "&address=".$form->escape($form->{address},1); 841 $href .= "&address=".$form->escape($form->{address}); 842 $option .= "\n<br>".$locale->text('Address')." : $form->{address}"; 843 } 844 if ($form->{city}) { 845 $callback .= "&city=".$form->escape($form->{city},1); 846 $href .= "&city=".$form->escape($form->{city}); 847 $option .= "\n<br>".$locale->text('City')." : $form->{city}"; 848 } 849 if ($form->{state}) { 850 $callback .= "&state=".$form->escape($form->{state},1); 851 $href .= "&state=".$form->escape($form->{state}); 852 $option .= "\n<br>".$locale->text('State')." : $form->{state}"; 853 } 854 if ($form->{zipcode}) { 855 $callback .= "&zipcode=".$form->escape($form->{zipcode},1); 856 $href .= "&zipcode=".$form->escape($form->{zipcode}); 857 $option .= "\n<br>".$locale->text('Zip/Postal Code')." : $form->{zipcode}"; 858 } 859 if ($form->{country}) { 860 $callback .= "&country=".$form->escape($form->{country},1); 861 $href .= "&country=".$form->escape($form->{country}); 862 $option .= "\n<br>".$locale->text('Country')." : $form->{country}"; 863 } 864 if ($form->{contact}) { 865 $callback .= "&contact=".$form->escape($form->{contact},1); 866 $href .= "&contact=".$form->escape($form->{contact}); 867 $option .= "\n<br>".$locale->text('Contact')." : $form->{contact}"; 868 } 869 if ($form->{employee}) { 870 $callback .= "&employee=".$form->escape($form->{employee},1); 871 $href .= "&employee=".$form->escape($form->{employee}); 872 $option .= "\n<br>"; 873 if ($form->{db} eq 'customer') { 874 $option .= $locale->text('Salesperson'); 875 } 876 if ($form->{db} eq 'vendor') { 877 $option .= $locale->text('Employee'); 878 } 879 $var = $form->{employee}; 880 $var =~ s/--.*//; 881 $option .= " : $var"; 882 } 883 if ($form->{business}) { 884 $callback .= "&business=".$form->escape($form->{business},1); 885 $href .= "&business=".$form->escape($form->{business}); 886 $var = $form->{business}; 887 $var =~ s/--.*//; 888 $option .= "\n<br>".$locale->text('Type of Business')." : $var"; 889 } 890 891 $fromdate = ""; 892 $todate = ""; 893 if ($form->{startdatefrom}) { 894 $callback .= "&startdatefrom=$form->{startdatefrom}"; 895 $href .= "&startdatefrom=$form->{startdatefrom}"; 896 $fromdate = $locale->date(\%myconfig, $form->{startdatefrom}, 1); 897 } 898 if ($form->{startdateto}) { 899 $callback .= "&startdateto=$form->{startdateto}"; 900 $href .= "&startdateto=$form->{startdateto}"; 901 $todate = $locale->date(\%myconfig, $form->{startdateto}, 1); 902 } 903 if ($fromdate || $todate) { 904 $option .= "\n<br>".$locale->text('Startdate')." $fromdate - $todate"; 905 } 906 907 if ($form->{notes}) { 908 $callback .= "¬es=".$form->escape($form->{notes},1); 909 $href .= "¬es=".$form->escape($form->{notes}); 910 $option .= "\n<br>".$locale->text('Notes')." : $form->{notes}"; 911 } 912 if ($form->{"$form->{db}number"}) { 913 $callback .= qq|&$form->{db}number=|.$form->escape($form->{"$form->{db}number"},1); 914 $href .= "&$form->{db}number=".$form->escape($form->{"$form->{db}number"}); 915 $option .= qq|\n<br>$vcnumber : $form->{"$form->{db}number"}|; 916 } 917 if ($form->{phone}) { 918 $callback .= "&phone=".$form->escape($form->{phone},1); 919 $href .= "&phone=".$form->escape($form->{phone}); 920 $option .= "\n<br>".$locale->text('Phone')." : $form->{phone}"; 921 } 922 if ($form->{email}) { 923 $callback .= "&email=".$form->escape($form->{email},1); 924 $href .= "&email=".$form->escape($form->{email}); 925 $option .= "\n<br>".$locale->text('E-mail')." : $form->{email}"; 926 } 927 if ($form->{transdatefrom}) { 928 $callback .= "&transdatefrom=$form->{transdatefrom}"; 929 $href .= "&transdatefrom=$form->{transdatefrom}"; 930 $option .= "\n<br>" if ($option); 931 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1); 932 } 933 if ($form->{transdateto}) { 934 $callback .= "&transdateto=$form->{transdateto}"; 935 $href .= "&transdateto=$form->{transdateto}"; 936 if ($form->{transdatefrom}) { 937 $option .= " "; 938 } else { 939 $option .= "\n<br>" if ($option); 940 } 941 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1); 942 } 943 if ($form->{open}) { 944 $callback .= "&open=$form->{open}"; 945 $href .= "&open=$form->{open}"; 946 $option .= "\n<br>" if ($option); 947 $option .= $locale->text('Open'); 948 } 949 if ($form->{closed}) { 950 $callback .= "&closed=$form->{closed}"; 951 $href .= "&closed=$form->{closed}"; 952 $option .= "\n<br>" if ($option); 953 $option .= $locale->text('Closed'); 954 } 955 956 $form->helpref("list_$form->{db}", $myconfig{countrycode}); 957 958 $form->{callback} = "$callback&sort=$form->{sort}"; 959 $callback = $form->escape($form->{callback}); 960 961 $column_header{delete} = qq|<th class=listheading width=1%><input name="allbox_delete" type=checkbox class=checkbox value="1" onChange="CheckAll();"></th>|; 962 $column_header{ndx} = qq|<th class=listheading width=1%> </th>|; 963 $column_header{id} = qq|<th class=listheading>|.$locale->text('ID').qq|</th>|; 964 $column_header{typeofcontact} = qq|<th class=listheading>|.$locale->text('Type').qq|</th>|; 965 $column_header{"$form->{db}number"} = qq|<th><a class=listheading href=$href&sort=$form->{db}number>$vcnumber</a></th>|; 966 $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>$vcname</a></th>|; 967 $column_header{address1} = qq|<th class=listheading>|.$locale->text('Address').qq|</th>|; 968 $column_header{address2} = qq|<th class=listheading> </th>|; 969 $column_header{city} = qq|<th><a class=listheading href=$href&sort=city>|.$locale->text('City').qq|</a></th>|; 970 $column_header{state} = qq|<th><a class=listheading href=$href&sort=state>|.$locale->text('State/Province').qq|</a></th>|; 971 $column_header{zipcode} = qq|<th><a class=listheading href=$href&sort=zipcode>|.$locale->text('Zip/Postal Code').qq|</a></th>|; 972 $column_header{country} = qq|<th><a class=listheading href=$href&sort=country>|.$locale->text('Country').qq|</a></th>|; 973 $column_header{salutation} = qq|<th>|.$locale->text('Salutation').qq|</th>|; 974 $column_header{firstname} = qq|<th><a class=listheading href=$href&sort=contact>|.$locale->text('Contact').qq|</a></th>|; 975 $column_header{lastname} = qq|<th> </th>|; 976 $column_header{contacttitle} = qq|<th>|.$locale->text('Title').qq|</th>|; 977 $column_header{gender} = qq|<th>|.$locale->text('G').qq|</th>|; 978 $column_header{occupation} = qq|<th><a class=listheading href=$href&sort=occupation>|.$locale->text('Occupation').qq|</a></th>|; 979 $column_header{phone} = qq|<th><a class=listheading href=$href&sort=phone>|.$locale->text('Phone').qq|</a></th>|; 980 $column_header{fax} = qq|<th><a class=listheading href=$href&sort=fax>|.$locale->text('Fax').qq|</a></th>|; 981 $column_header{email} = qq|<th><a class=listheading href=$href&sort=email>|.$locale->text('E-mail').qq|</a></th>|; 982 $column_header{cc} = qq|<th><a class=listheading href=$href&sort=cc>|.$locale->text('Cc').qq|</a></th>|; 983 $column_header{bcc} = qq|<th><a class=listheading href=$href&sort=bcc>|.$locale->text('Bcc').qq|</a></th>|; 984 $column_header{notes} = qq|<th><a class=listheading href=$href&sort=notes>|.$locale->text('Notes').qq|</a></th>|; 985 $column_header{discount} = qq|<th class=listheading>%</th>|; 986 $column_header{terms} = qq|<th class=listheading>|.$locale->text('Terms').qq|</th>|; 987 $column_header{threshold} = qq|<th class=listheading>|.$locale->text('Threshold').qq|</th>|; 988 $column_header{paymentmethod} = qq|<th><a class=listheading href=$href&sort=paymentmethod>|.$locale->text('Payment Method').qq|</a></th>|; 989 $column_header{creditlimit} = qq|<th class=listheading>|.$locale->text('Credit Limit').qq|</th>|; 990 $column_header{outstanding} = qq|<th class=listheading>|.$locale->text('Outstanding').qq|</th>|; 991 $column_header{availablecredit} = qq|<th class=listheading>|.$locale->text('Available Credit').qq|</th>|; 992 993# $locale->text('AR') 994# $locale->text('AP') 995 996 $column_header{arap_accno} = qq|<th class=listheading>|.$locale->text($form->{ARAP}).qq|</th>|; 997 $column_header{payment_accno} = qq|<th class=listheading>|.$locale->text('Payment').qq|</th>|; 998 $column_header{discount_accno} = qq|<th class=listheading>|.$locale->text('Cash Discount').qq|</th>|; 999 $column_header{taxaccounts} = qq|<th class=listheading>|.$locale->text('Tax').qq|</th>|; 1000 1001 $column_header{taxnumber} = qq|<th><a class=listheading href=$href&sort=taxnumber>|.$locale->text('Tax Number').qq|</a></th>|; 1002 $column_header{gifi_accno} = qq|<th><a class=listheading href=$href&sort=gifi_accno>|.$locale->text('GIFI').qq|</a></th>|; 1003 $column_header{sic_code} = qq|<th><a class=listheading href=$href&sort=sic_code>|.$locale->text('SIC').qq|</a></th>|; 1004 $column_header{business} = qq|<th><a class=listheading href=$href&sort=business>|.$locale->text('Type of Business').qq|</a></th>|; 1005 1006 $column_header{bankname} = qq|<th class=listheading>|.$locale->text('Bank').qq|</th>|; 1007 $column_header{bankaddress1} = qq|<th class=listheading>|.$locale->text('Address').qq|</th>|; 1008 $column_header{bankaddress2} = qq|<th class=listheading> </th>|; 1009 $column_header{bankcity} = qq|<th class=listheading>|.$locale->text('City').qq|</th>|; 1010 $column_header{bankstate} = qq|<th class=listheading>|.$locale->text('State/Province').qq|</th>|; 1011 $column_header{bankzipcode} = qq|<th class=listheading>|.$locale->text('Zip/Postal Code').qq|</th>|; 1012 $column_header{bankcountry} = qq|<th class=listheading>|.$locale->text('Country').qq|</th>|; 1013 $column_header{iban} = qq|<th class=listheading>|.$locale->text('IBAN').qq|</th>|; 1014 $column_header{bic} = qq|<th class=listheading>|.$locale->text('BIC').qq|</th>|; 1015 $column_header{membernumber} = qq|<th class=listheading>|.$locale->text('Member Number').qq|</th>|; 1016 $column_header{clearingnumber} = qq|<th class=listheading>|.$locale->text('BC Number').qq|</th>|; 1017 $column_header{remittancevoucher} = qq|<th class=listheading>|.$locale->text('RV').qq|</th>|; 1018 $column_header{startdate} = qq|<th><a class=listheading href=$href&sort=startdate>|.$locale->text('Startdate').qq|</a></th>|; 1019 $column_header{enddate} = qq|<th><a class=listheading href=$href&sort=enddate>|.$locale->text('Enddate').qq|</a></th>|; 1020 1021 $column_header{invnumber} = qq|<th><a class=listheading href=$href&sort=invnumber>|.$locale->text('Invoice').qq|</a></th>|; 1022 $column_header{ordnumber} = qq|<th><a class=listheading href=$href&sort=ordnumber>|.$locale->text('Order').qq|</a></th>|; 1023 $column_header{quonumber} = qq|<th><a class=listheading href=$href&sort=quonumber>|.$locale->text('Quotation').qq|</a></th>|; 1024 1025 if ($form->{db} eq 'customer') { 1026 $column_header{employee} = qq|<th><a class=listheading href=$href&sort=employee>|.$locale->text('Salesperson').qq|</a></th>|; 1027 } else { 1028 $column_header{employee} = qq|<th><a class=listheading href=$href&sort=employee>|.$locale->text('Employee').qq|</a></th>|; 1029 } 1030 1031 $column_header{pricegroup} = qq|<th><a class=listheading href=$href&sort=pricegroup>|.$locale->text('Pricegroup').qq|</a></th>|; 1032 $column_header{language} = qq|<th><a class=listheading href=$href&sort=language>|.$locale->text('Language').qq|</a></th>|; 1033 1034 1035 $amount = $locale->text('Amount'); 1036 $tax = $locale->text('Tax'); 1037 $total = $locale->text('Total'); 1038 1039 $column_header{invamount} = qq|<th class=listheading>$amount</th>|; 1040 $column_header{ordamount} = qq|<th class=listheading>$amount</th>|; 1041 $column_header{quoamount} = qq|<th class=listheading>$amount</th>|; 1042 1043 $column_header{invtax} = qq|<th class=listheading>$tax</th>|; 1044 $column_header{ordtax} = qq|<th class=listheading>$tax</th>|; 1045 $column_header{quotax} = qq|<th class=listheading>$tax</th>|; 1046 1047 $column_header{invtotal} = qq|<th class=listheading>$total</th>|; 1048 $column_header{ordtotal} = qq|<th class=listheading>$total</th>|; 1049 $column_header{quototal} = qq|<th class=listheading>$total</th>|; 1050 1051 1052 if ($form->{status}) { 1053 $form->{title} = ($form->{db} eq 'customer') ? $locale->text('Customers') : $locale->text('Vendors'); 1054 } else { 1055 $label = $vcname; 1056 $form->{title} = ($form->{db} eq 'customer') ? $locale->text('Customer Transactions') : $locale->text('Vendor Transactions'); 1057 } 1058 1059 $form->{title} .= " / $form->{company}"; 1060 1061 $form->header; 1062 1063 &check_all(qw(allbox_delete id_)); 1064 1065 print qq| 1066<body> 1067 1068<form method=post name="main" action="$form->{script}"> 1069 1070<table width=100%> 1071 <tr> 1072 <th class=listtop>$form->{helpref}$form->{title}</a></th> 1073 </tr> 1074 <tr height="5"></tr> 1075 <tr> 1076 <td>$option</td> 1077 </tr> 1078 <tr> 1079 <td> 1080 <table width=100%> 1081 <tr class=listheading> 1082|; 1083 1084 for (@column_index) { print "$column_header{$_}\n" } 1085 1086 print qq| 1087 </tr> 1088|; 1089 1090 $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order'; 1091 $quotationtype = ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation'; 1092 $subtotal = 0; 1093 1094 $i = 0; 1095 foreach $ref (@{ $form->{CT} }) { 1096 1097 if ($ref->{$form->{sort}} ne $sameitem && $form->{l_subtotal}) { 1098 # print subtotal 1099 if ($subtotal) { 1100 for (@column_index) { $column_data{$_} = "<td> </td>" } 1101 &list_subtotal; 1102 } 1103 } 1104 1105 if ($ref->{id} eq $sameid) { 1106 for (@column_index) { $column_data{$_} = "<td> </td>" } 1107 } else { 1108 1109 $i++; 1110 1111 $ref->{notes} =~ s/\r?\n/<br>/g; 1112 for (@column_index) { $column_data{$_} = "<td>$ref->{$_} </td>" } 1113 1114 $column_data{ndx} = "<td align=right>$i</td>"; 1115 $column_data{delete} = qq|<td><input name="id_$i" class=checkbox type=checkbox value=$ref->{id}></td>|; 1116 1117 if ($ref->{$form->{sort}} eq $sameitem) { 1118 $column_data{$form->{sort}} = "<td> </td>"; 1119 } 1120 1121 $column_data{name} = "<td><a href=$form->{script}?action=edit&id=$ref->{id}&db=$form->{db}&path=$form->{path}&login=$form->{login}&status=$form->{status}&callback=$callback>$ref->{name} </td>"; 1122 1123 $email = ""; 1124 if ($form->{sort} =~ /(email|cc)/) { 1125 if ($ref->{$form->{sort}} ne $sameitem) { 1126 $email = 1; 1127 } 1128 } else { 1129 $email = 1; 1130 } 1131 1132 if ($email) { 1133 foreach $item (qw(email cc bcc)) { 1134 if ($ref->{$item}) { 1135 $email = $ref->{$item}; 1136 $email =~ s/</\</; 1137 $email =~ s/>/\>/; 1138 1139 $column_data{$item} = qq|<td><a href="mailto:$ref->{$item}">$email</a></td>|; 1140 } 1141 } 1142 } 1143 } 1144 1145 if ($ref->{formtype} eq 'invoice') { 1146 $column_data{invnumber} = "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{invnumber} </td>"; 1147 1148 $column_data{invamount} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{netamount}, $form->{precision}, " ")."</td>"; 1149 $column_data{invtax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, $form->{precision}, " ")."</td>"; 1150 $column_data{invtotal} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, $form->{precision}, " ")."</td>"; 1151 1152 $column_data{employee} = "<td>$ref->{employee} </td>" if $ref->{employee} ne $sameemployee; 1153 1154 $invamountsubtotal += $ref->{netamount}; 1155 $invtaxsubtotal += ($ref->{amount} - $ref->{netamount}); 1156 $invtotalsubtotal += $ref->{amount}; 1157 $subtotal = 1; 1158 } 1159 1160 if ($ref->{formtype} eq 'order') { 1161 $column_data{ordnumber} = "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{ordnumber} </td>"; 1162 1163 $column_data{ordamount} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{netamount}, $form->{precision}, " ")."</td>"; 1164 $column_data{ordtax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, $form->{precision}, " ")."</td>"; 1165 $column_data{ordtotal} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, $form->{precision}, " ")."</td>"; 1166 1167 $column_data{employee} = "<td>$ref->{employee} </td>" if $ref->{employee} ne $sameemployee; 1168 1169 $ordamountsubtotal += $ref->{netamount}; 1170 $ordtaxsubtotal += ($ref->{amount} - $ref->{netamount}); 1171 $ordtotalsubtotal += $ref->{amount}; 1172 $subtotal = 1; 1173 } 1174 1175 if ($ref->{formtype} eq 'quotation') { 1176 $column_data{quonumber} = "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{quonumber} </td>"; 1177 1178 $column_data{quoamount} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{netamount}, $form->{precision}, " ")."</td>"; 1179 $column_data{quotax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, $form->{precision}, " ")."</td>"; 1180 $column_data{quototal} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, $form->{precision}, " ")."</td>"; 1181 1182 $column_data{employee} = "<td>$ref->{employee} </td>" if $ref->{employee} ne $sameemployee; 1183 1184 $quoamountsubtotal += $ref->{netamount}; 1185 $quotaxsubtotal += ($ref->{amount} - $ref->{netamount}); 1186 $quototalsubtotal += $ref->{amount}; 1187 $subtotal = 1; 1188 } 1189 1190 if ($sameid ne "$ref->{id}") { 1191 if ($form->{l_discount}) { 1192 $column_data{discount} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{discount} * 100, undef, " ")."</td>"; 1193 } 1194 if ($form->{l_terms}) { 1195 @f = (); 1196 push @f, $form->format_amount(\%myconfig, $ref->{cashdiscount} * 100, undef) if $ref->{cashdiscount}; 1197 push @f, $ref->{discountterms} if $ref->{discountterms}; 1198 push @f, $ref->{terms} if $ref->{terms}; 1199 1200 $x = join '/', @f; 1201 $column_data{terms} = "<td> $x</td>"; 1202 } 1203 if ($form->{l_threshold}) { 1204 $column_data{threshold} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{threshold}, 0, " ")."</td>"; 1205 } 1206 if ($form->{l_creditlimit}) { 1207 $column_data{creditlimit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{creditlimit}, $form->{precision}, " ")."</td>"; 1208 } 1209 if ($form->{l_outstanding}) { 1210 $column_data{outstanding} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{outstanding}, $form->{precision}, " ")."</td>"; 1211 } 1212 if ($form->{l_availablecredit}) { 1213 $column_data{availablecredit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{creditlimit} - $ref->{outstanding}, $form->{precision}, " ")."</td>"; 1214 } 1215 if ($form->{l_remittancevoucher}) { 1216 $column_data{remittancevoucher} = "<td align=center>". (($ref->{remittancevoucher}) ? "*" : " ") . "</td>"; 1217 } 1218 } 1219 1220 $j++; $j %= 2; 1221 print " 1222 <tr class=listrow$j> 1223"; 1224 1225 for (@column_index) { print "$column_data{$_}\n" } 1226 1227 print qq| 1228 </tr> 1229|; 1230 1231 $sameitem = "$ref->{$form->{sort}}"; 1232 $sameid = $ref->{id}; 1233 $sameemployee = $ref->{employee}; 1234 1235 } 1236 1237 if ($form->{l_subtotal} && $subtotal) { 1238 for (@column_index) { $column_data{$_} = "<td> </td>" } 1239 &list_subtotal; 1240 } 1241 1242 $form->{rowcount} = $i; 1243 1244 $i = 1; 1245 if ($myconfig{acs} !~ /AR--AR/) { 1246 if ($form->{db} eq 'customer') { 1247 $button{'Customers--Add Customer'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Customer').qq|"> |; 1248 $button{'Customers--Add Customer'}{order} = $i++; 1249 } 1250 } 1251 if ($myconfig{acs} !~ /AP--AP/) { 1252 if ($form->{db} eq 'vendor') { 1253 $button{'Vendors--Add Vendor'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Vendor').qq|"> |; 1254 $button{'Vendors--Add Vendor'}{order} = $i++; 1255 } 1256 } 1257 1258 if ($form->{status} eq 'orphaned') { 1259 if ($form->{db} eq 'customer') { 1260 $button{'Customer--Delete'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Delete Customers').qq|"> |; 1261 $button{'Customer--Delete'}{order} = $i++; 1262 } else { 1263 $button{'Vendor--Delete'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Delete Vendors').qq|"> |; 1264 $button{'Vendor--Delete'}{order} = $i++; 1265 } 1266 } 1267 1268 foreach $item (split /;/, $myconfig{acs}) { 1269 delete $button{$item}; 1270 } 1271 1272 print qq| 1273 </table> 1274 </td> 1275 </tr> 1276 <tr> 1277 <td><hr size=3 noshade></td> 1278 </tr> 1279</table> 1280 1281<br> 1282|; 1283 1284 $form->hide_form(qw(rowcount callback db path login)); 1285 1286 if ($form->{status}) { 1287 foreach $item (sort { $a->{order} <=> $b->{order} } %button) { 1288 print $item->{code}; 1289 } 1290 } 1291 1292 if ($form->{menubar}) { 1293 require "$form->{path}/menu.pl"; 1294 &menubar; 1295 } 1296 1297 print qq| 1298 </form> 1299 1300</body> 1301</html> 1302|; 1303 1304} 1305 1306 1307sub list_subtotal { 1308 1309 $column_data{invamount} = "<td align=right>".$form->format_amount(\%myconfig, $invamountsubtotal, $form->{precision}, " ")."</td>"; 1310 $column_data{invtax} = "<td align=right>".$form->format_amount(\%myconfig, $invtaxsubtotal, $form->{precision}, " ")."</td>"; 1311 $column_data{invtotal} = "<td align=right>".$form->format_amount(\%myconfig, $invtotalsubtotal, $form->{precision}, " ")."</td>"; 1312 1313 $invamountsubtotal = 0; 1314 $invtaxsubtotal = 0; 1315 $invtotalsubtotal = 0; 1316 1317 $column_data{ordamount} = "<td align=right>".$form->format_amount(\%myconfig, $ordamountsubtotal, $form->{precision}, " ")."</td>"; 1318 $column_data{ordtax} = "<td align=right>".$form->format_amount(\%myconfig, $ordtaxsubtotal, $form->{precision}, " ")."</td>"; 1319 $column_data{ordtotal} = "<td align=right>".$form->format_amount(\%myconfig, $ordtotalsubtotal, $form->{precision}, " ")."</td>"; 1320 1321 $ordamountsubtotal = 0; 1322 $ordtaxsubtotal = 0; 1323 $ordtotalsubtotal = 0; 1324 1325 $column_data{quoamount} = "<td align=right>".$form->format_amount(\%myconfig, $quoamountsubtotal, $form->{precision}, " ")."</td>"; 1326 $column_data{quotax} = "<td align=right>".$form->format_amount(\%myconfig, $quotaxsubtotal, $form->{precision}, " ")."</td>"; 1327 $column_data{quototal} = "<td align=right>".$form->format_amount(\%myconfig, $quototalsubtotal, $form->{precision}, " ")."</td>"; 1328 1329 $quoamountsubtotal = 0; 1330 $quotaxsubtotal = 0; 1331 $quototalsubtotal = 0; 1332 1333 print " 1334 <tr class=listsubtotal> 1335"; 1336 for (@column_index) { print "$column_data{$_}\n" } 1337 1338 print qq| 1339 </tr> 1340|; 1341 1342 1343} 1344 1345 1346sub list_history { 1347 1348 CT->get_history(\%myconfig, \%$form); 1349 1350 $href = "$form->{script}?action=list_history"; 1351 for (qw(oldsort db path login type transdatefrom transdateto history)) { $href .= "&$_=$form->{$_}" } 1352 1353 $callback = $href; 1354 $href .= "&direction=$form->{direction}"; 1355 1356 $form->sort_order(); 1357 1358 $callback .= "&direction=$form->{direction}"; 1359 1360 $form->{l_fxsellprice} = $form->{l_curr}; 1361 @columns = $form->sort_columns(qw(partnumber description qty unit sellprice fxsellprice total curr discount deliverydate projectnumber serialnumber)); 1362 1363 if ($form->{db} eq 'customer') { 1364 $vcname = $locale->text('Customer'); 1365 $vcnumber = $locale->text('Customer Number'); 1366 } else { 1367 $vcname = $locale->text('Vendor'); 1368 $vcnumber = $locale->text('Vendor Number'); 1369 } 1370 1371 if ($form->{history} eq 'summary') { 1372 @columns = $form->sort_columns(qw(partnumber description qty unit sellprice total discount)); 1373 } 1374 $form->{l_total} = "Y" if $form->{l_sellprice}; 1375 1376 foreach $item (@columns) { 1377 if ($form->{"l_$item"} eq "Y") { 1378 push @column_index, $item; 1379 1380 # add column to href and callback 1381 $callback .= "&l_$item=Y"; 1382 $href .= "&l_$item=Y"; 1383 } 1384 } 1385 1386 if ($form->{history} eq 'detail') { 1387 $option = $locale->text('Detail'); 1388 } 1389 if ($form->{history} eq 'summary') { 1390 $option .= $locale->text('Summary'); 1391 } 1392 if ($form->{name}) { 1393 $callback .= "&name=".$form->escape($form->{name},1); 1394 $href .= "&name=".$form->escape($form->{name}); 1395 $option .= "\n<br>$vcname : $form->{name}"; 1396 } 1397 if ($form->{contact}) { 1398 $callback .= "&contact=".$form->escape($form->{contact},1); 1399 $href .= "&contact=".$form->escape($form->{contact}); 1400 $option .= "\n<br>".$locale->text('Contact')." : $form->{contact}"; 1401 } 1402 if ($form->{"$form->{db}number"}) { 1403 $callback .= qq|&$form->{db}number=|.$form->escape($form->{"$form->{db}number"},1); 1404 $href .= "&$form->{db}number=".$form->escape($form->{"$form->{db}number"}); 1405 $option .= qq|\n<br>$vcnumber : $form->{"$form->{db}number"}|; 1406 } 1407 if ($form->{email}) { 1408 $callback .= "&email=".$form->escape($form->{email},1); 1409 $href .= "&email=".$form->escape($form->{email}); 1410 $option .= "\n<br>".$locale->text('E-mail')." : $form->{email}"; 1411 } 1412 if ($form->{employee}) { 1413 $callback .= "&employee=".$form->escape($form->{employee},1); 1414 $href .= "&employee=".$form->escape($form->{employee}); 1415 $option .= "\n<br>"; 1416 if ($form->{db} eq 'customer') { 1417 $option .= $locale->text('Salesperson'); 1418 } 1419 if ($form->{db} eq 'vendor') { 1420 $option .= $locale->text('Employee'); 1421 } 1422 $var = $form->{employee}; 1423 $var =~ s/--.*//; 1424 $option .= " : $var"; 1425 } 1426 if ($form->{business}) { 1427 $callback .= "&business=".$form->escape($form->{business},1); 1428 $href .= "&business=".$form->escape($form->{business}); 1429 $var = $form->{business}; 1430 $var =~ s/--.*//; 1431 $option .= "\n<br>".$locale->text('Type of Business')." : $var"; 1432 } 1433 if ($form->{transdatefrom}) { 1434 $callback .= "&transdatefrom=$form->{transdatefrom}"; 1435 $href .= "&transdatefrom=$form->{transdatefrom}"; 1436 $option .= "\n<br>" if ($option); 1437 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1); 1438 } 1439 if ($form->{transdateto}) { 1440 $callback .= "&transdateto=$form->{transdateto}"; 1441 $href .= "&transdateto=$form->{transdateto}"; 1442 if ($form->{transdatefrom}) { 1443 $option .= " "; 1444 } else { 1445 $option .= "\n<br>" if ($option); 1446 } 1447 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1); 1448 } 1449 if ($form->{open}) { 1450 $callback .= "&open=$form->{open}"; 1451 $href .= "&open=$form->{open}"; 1452 $option .= "\n<br>" if ($option); 1453 $option .= $locale->text('Open'); 1454 } 1455 if ($form->{closed}) { 1456 $callback .= "&closed=$form->{closed}"; 1457 $href .= "&closed=$form->{closed}"; 1458 $option .= "\n<br>" if ($option); 1459 $option .= $locale->text('Closed'); 1460 } 1461 1462 1463 $form->{callback} = "$callback&sort=$form->{sort}"; 1464 $callback = $form->escape($form->{callback}); 1465 1466 $column_header{partnumber} = qq|<th><a class=listheading href=$href&sort=partnumber>|.$locale->text('Part Number').qq|</a></th>|; 1467 $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|; 1468 1469 $column_header{total} = qq|<th class=listheading>|.$locale->text('Total').qq|</th>|; 1470 $column_header{sellprice} = qq|<th class=listheading>|.$locale->text('Sell Price').qq|</th>|; 1471 $column_header{fxsellprice} = qq|<th> </th>|; 1472 1473 $column_header{curr} = qq|<th class=listheading>|.$locale->text('Curr').qq|</th>|; 1474 $column_header{discount} = qq|<th class=listheading>|.$locale->text('Disc').qq|</th>|; 1475 $column_header{qty} = qq|<th class=listheading>|.$locale->text('Qty').qq|</th>|; 1476 $column_header{unit} = qq|<th class=listheading>|.$locale->text('Unit').qq|</th>|; 1477 $column_header{deliverydate} = qq|<th><a class=listheading href=$href&sort=deliverydate>|.$locale->text('Delivery Date').qq|</a></th>|; 1478 $column_header{projectnumber} = qq|<th><a class=listheading href=$href&sort=projectnumber>|.$locale->text('Project Number').qq|</a></th>|; 1479 $column_header{serialnumber} = qq|<th><a class=listheading href=$href&sort=serialnumber>|.$locale->text('Serial Number').qq|</a></th>|; 1480 1481 1482# $locale->text('Customer History') 1483# $locale->text('Vendor History') 1484 1485 $label = ucfirst $form->{db}; 1486 $form->{title} = $locale->text($label." History") . " / $form->{company}"; 1487 1488 $colspan = $#column_index + 1; 1489 1490 $form->helpref("list_$form->{db}_history", $myconfig{countrycode}); 1491 1492 $form->header; 1493 1494 print qq| 1495<body> 1496 1497<table width=100%> 1498 <tr> 1499 <th class=listtop>$form->{helpref}$form->{title}</a></th> 1500 </tr> 1501 <tr height="5"></tr> 1502 <tr> 1503 <td>$option</td> 1504 </tr> 1505 <tr> 1506 <td> 1507 <table width=100%> 1508 <tr class=listheading> 1509|; 1510 1511 for (@column_index) { print "$column_header{$_}\n" } 1512 1513 print qq| 1514 </tr> 1515|; 1516 1517 1518 $module = 'oe'; 1519 if ($form->{db} eq 'customer') { 1520 $invlabel = $locale->text('Sales Invoice'); 1521 $ordlabel = $locale->text('Sales Order'); 1522 $quolabel = $locale->text('Quotation'); 1523 1524 $ordertype = 'sales_order'; 1525 $quotationtype = 'sales_quotation'; 1526 if ($form->{type} eq 'invoice') { 1527 $module = 'is'; 1528 } 1529 } else { 1530 $invlabel = $locale->text('Vendor Invoice'); 1531 $ordlabel = $locale->text('Purchase Order'); 1532 $quolabel = $locale->text('RFQ'); 1533 1534 $ordertype = 'purchase_order'; 1535 $quotationtype = 'request_quotation'; 1536 if ($form->{type} eq 'invoice') { 1537 $module = 'ir'; 1538 } 1539 } 1540 1541 $ml = ($form->{db} eq 'vendor') ? -1 : 1; 1542 $lastndx = $#{$form->{CT}}; 1543 $j = 0; 1544 $sellprice = 0; 1545 $discount = 0; 1546 $qty = 0; 1547 1548 foreach $ref (@{ $form->{CT} }) { 1549 1550 if ($ref->{id} ne $sameid) { 1551 # print the header 1552 print qq| 1553 <tr class=listheading> 1554 <th colspan=$colspan><a class=listheading href=$form->{script}?action=edit&id=$ref->{ctid}&db=$form->{db}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{name} $ref->{address}</a></th> 1555 </tr> 1556|; 1557 } 1558 1559 $ref->{sellprice} = $ref->{sellprice} * (1 - $ref->{discount}); 1560 $ref->{fxsellprice} = $ref->{sellprice}; 1561 if ($form->{type} ne 'invoice') { 1562 $ref->{fxsellprice} = $ref->{sellprice}; 1563 } 1564 $ref->{sellprice} *= $ref->{exchangerate}; 1565 1566 if ($form->{history} eq 'summary') { 1567 1568 $sellprice += $ref->{sellprice} * $ref->{qty}; 1569 $discount += $ref->{discount} * $ref->{qty}; 1570 $qty += $ref->{qty}; 1571 1572 # check next item 1573 if ($j < $lastndx) { 1574 if ($ref->{id} eq $form->{CT}[$j+1]->{id}) { 1575 if ($ref->{$form->{sort}} eq $form->{CT}[$j+1]->{$form->{sort}}) { 1576 $sameid = $ref->{id}; 1577 $j++; 1578 next; 1579 } 1580 } 1581 } 1582 1583 if ($qty) { 1584 $ref->{sellprice} = $form->round_amount($sellprice/$qty, $form->{precision}); 1585 $ref->{discount} = $discount/$qty; 1586 $ref->{qty} = $qty; 1587 } 1588 1589 $sellprice = 0; 1590 $discount = 0; 1591 $qty = 0; 1592 } 1593 1594 if ($form->{history} eq 'detail' and $ref->{invid} ne $sameinvid) { 1595 # print inv, ord, quo number 1596 $i++; $i %= 2; 1597 1598 print qq| 1599 <tr class=listrow$i> 1600|; 1601 1602 if ($form->{type} eq 'invoice') { 1603 print qq|<th align=left colspan=$colspan><a href=${module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&callback=$callback>$invlabel $ref->{invnumber} / $ref->{employee}</a></th>|; 1604 } 1605 1606 if ($form->{type} eq 'order') { 1607 print qq|<th align=left colspan=$colspan><a href=${module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&callback=$callback>$ordlabel $ref->{ordnumber} / $ref->{employee}</a></th>|; 1608 } 1609 1610 if ($form->{type} eq 'quotation') { 1611 print qq|<th align=left colspan=$colspan><a href=${module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&callback=$callback>$quolabel $ref->{quonumber} / $ref->{employee}</a></th>|; 1612 } 1613 1614 print qq| 1615 </tr> 1616|; 1617 } 1618 1619 for (@column_index) { $column_data{$_} = "<td>$ref->{$_} </td>" } 1620 1621 if ($form->{l_curr}) { 1622 $column_data{fxsellprice} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{sellprice} / $ref->{exchangerate}, $form->{precision})."</td>"; 1623 } 1624 $column_data{sellprice} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{sellprice}, $form->{precision})."</td>"; 1625 $column_data{total} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{sellprice} * $ref->{qty}, $form->{precision})."</td>"; 1626 1627 $column_data{qty} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{qty} * $ml)."</td>"; 1628 $column_data{discount} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{discount} * 100, 1, " ")."</td>"; 1629 $column_data{partnumber} = qq|<td><a href=ic.pl?action=edit&id=$ref->{pid}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{partnumber}</td>|; 1630 1631 1632 $i++; $i %= 2; 1633 print qq| 1634 <tr class=listrow$i> 1635|; 1636 1637 for (@column_index) { print "$column_data{$_}\n" } 1638 1639 print qq| 1640 </tr> 1641|; 1642 1643 $total += $ref->{sellprice} * $ref->{qty} * $ml; 1644 1645 # check next item for subtotal 1646 if ($j < $lastndx) { 1647 if ($ref->{id} ne $form->{CT}[$j+1]->{id}) { 1648 # print subtotal 1649 print qq| 1650 <tr class=listtotal> 1651|; 1652 for (@column_index) { $column_data{$_} = "<td> </td>" } 1653 $column_data{total} = qq|<th align=right>|.$form->format_amount(\%myconfig, $total, $form->{precision})."</th>"; 1654 for (@column_index) { print "\n$column_data{$_}" } 1655 $total = 0; 1656 } 1657 } else { 1658 # print subtotal 1659 print qq| 1660 <tr class=listtotal> 1661|; 1662 for (@column_index) { $column_data{$_} = "<td> </td>" } 1663 $column_data{total} = qq|<th align=right>|.$form->format_amount(\%myconfig, $total, $form->{precision})."</th>"; 1664 for (@column_index) { print "\n$column_data{$_}" } 1665 } 1666 1667 $sameid = $ref->{id}; 1668 $sameinvid = $ref->{invid}; 1669 1670 $j++; 1671 1672 } 1673 1674 print qq| 1675 </table> 1676 </td> 1677 </tr> 1678 <tr> 1679 <td><hr size=3 noshade></td> 1680 </tr> 1681</table> 1682 1683|; 1684 1685 if ($form->{menubar}) { 1686 require "$form->{path}/menu.pl"; 1687 &menubar; 1688 } 1689 1690 print qq| 1691 </form> 1692 1693</body> 1694</html> 1695|; 1696 1697} 1698 1699 1700 1701sub form_header { 1702 1703 for (qw(creditlimit threshold)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, $form->{precision}) } 1704 for (qw(discount cashdiscount)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}) } 1705 1706 for (qw(terms discountterms)) { $form->{$_} = "" if ! $form->{$_} } 1707 1708 if ($form->{selectcurrency}) { 1709 $currency = qq| 1710 <th align=right>|.$locale->text('Currency').qq|</th> 1711 <td><select name=curr>| 1712 .$form->select_option($form->{selectcurrency}, $form->{curr}) 1713 .qq|</select></td> 1714|; 1715 } 1716 1717 $taxable = ""; 1718 for (split / /, $form->{taxaccounts}) { 1719 $form->{"tax_${_}_description"} =~ s/ / /g; 1720 if ($form->{"tax_$_"}) { 1721 $taxable .= qq| <input name="tax_$_" value=1 class=checkbox type=checkbox checked> <b>$form->{"tax_${_}_description"}</b>|; 1722 } else { 1723 $taxable .= qq| <input name="tax_$_" value=1 class=checkbox type=checkbox> <b>$form->{"tax_${_}_description"}</b>|; 1724 } 1725 } 1726 1727 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; 1728 1729 if ($taxable) { 1730 $tax = qq| 1731 <tr> 1732 <td> 1733 <table> 1734 <tr> 1735 <td>$taxable</td> 1736 <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|.$locale->text('Tax Included').qq|</b></td> 1737 </tr> 1738 </table> 1739 </td> 1740 </tr> 1741|; 1742 } 1743 1744 1745 # accounts 1746 if ($form->{selectarap}) { 1747 1748 $arapaccount = qq| 1749 <tr> 1750 <th align=right>|.$locale->text($form->{ARAP}).qq|</th> 1751 <td><select name="arap_accno">| 1752 .$form->select_option($form->{selectarap}, $form->{arap_accno}) 1753 .qq|</select> 1754 </td> 1755 <th align=right>|.$locale->text('Credit Limit').qq|</th> 1756 <td><input name=creditlimit class="inputright" size=11 value="$form->{creditlimit}"> 1757 1758 <b>|.$locale->text('Pre-Payment').qq|</b> 1759 <select name="prepayment_accno">| 1760 .$form->select_option($form->{selectarap}, $form->{prepayment_accno}) 1761 .qq|</select> 1762 </td> 1763 </tr> 1764|; 1765 1766 } 1767 1768 $discountaccount = qq| 1769 <tr> 1770 <th align=right>|.$locale->text('Terms').qq|</th> 1771 <td><b>|.$locale->text('Net').qq|</b> <input name=terms class="inputright" size=3 value="$form->{terms}"> <b>|.$locale->text('days').qq|</b></td> 1772 </tr> 1773|.$form->hide_form(qw(discount_accno cashdiscount discountterms)); 1774 1775 if ($form->{selectdiscount}) { 1776 1777 $discountaccount = qq| 1778 <tr> 1779 <th align=right>|.$locale->text('Cash Discount').qq|</th> 1780 <td><select name="discount_accno">| 1781 .$form->select_option($form->{selectdiscount}, $form->{discount_accno}) 1782 .qq|</select> 1783 </td> 1784 <th align=right>|.$locale->text('Terms').qq|</th> 1785 <td><input name=cashdiscount class="inputright" size=3 value=$form->{cashdiscount}>% / <input name=discountterms class="inputright" size=3 value=$form->{discountterms}> <b>|.$locale->text('Net').qq|</b> <input name=terms class="inputright" size=3 value="$form->{terms}"> <b>|.$locale->text('days').qq|</b></td> 1786 </tr> 1787|; 1788 } 1789 1790 if ($form->{selectpaymentmethod}) { 1791 1792 $paymentmethod = qq| 1793 <b>|.$locale->text('Method').qq|</b> 1794 <select name=paymentmethod>| 1795 .$form->select_option($form->{selectpaymentmethod}, $form->{paymentmethod}, 1) 1796 .qq|</select> 1797|; 1798 1799 } 1800 1801 if ($form->{selectpayment}) { 1802 1803 $paymentaccount = qq| 1804 <tr> 1805 <th align=right>|.$locale->text('Payment').qq|</th> 1806 <td><select name="payment_accno">| 1807 .$form->select_option($form->{selectpayment}, $form->{payment_accno}) 1808 .qq|</select> 1809 </td> 1810 <th align=right>|.$locale->text('Threshold').qq|</th> 1811 <td><input name=threshold class="inputright" size=11 value="$form->{threshold}"> 1812 $paymentmethod 1813 </td> 1814 </tr> 1815|; 1816 } 1817 1818 1819 $typeofbusiness = qq| 1820 <th></th> 1821 <td></td> 1822|; 1823 1824 if ($form->{selectbusiness}) { 1825 1826 $typeofbusiness = qq| 1827 <th align=right>|.$locale->text('Type of Business').qq|</th> 1828 <td><select name=business>| 1829 .$form->select_option($form->{selectbusiness}, $form->{business}, 1) 1830 .qq|</select> 1831 </td> 1832|; 1833 1834 } 1835 1836 $pricegroup = qq|<th></th><td></td>|; 1837 1838 if ($form->{selectpricegroup} && $form->{db} eq 'customer') { 1839 1840 $pricegroup = qq| 1841 <th align=right>|.$locale->text('Pricegroup').qq|</th> 1842 <td><select name=pricegroup>| 1843 .$form->select_option($form->{selectpricegroup}, $form->{pricegroup}, 1) 1844 .qq|</select> 1845 </td> 1846|; 1847 } 1848 1849 $lang = qq| 1850 <th></th> 1851 <td></td> 1852|; 1853 1854 if ($form->{selectlanguage}) { 1855 1856 $lang = qq| 1857 <th align=right>|.$locale->text('Language').qq|</th> 1858 <td><select name=language_code>|.$form->select_option($form->{selectlanguage}, $form->{language_code}, undef, 1).qq|</select></td> 1859|; 1860 } 1861 1862 $employeelabel = $locale->text('Salesperson'); 1863 1864 if ($form->{db} eq 'vendor') { 1865 $gifi = qq| 1866 <th align=right>|.$locale->text('Sub-contract GIFI').qq|</th> 1867 <td><input name=gifi_accno size=9 value="|.$form->quote($form->{gifi_accno}).qq|"></td> 1868|; 1869 $employeelabel = $locale->text('Employee'); 1870 } 1871 1872 1873 if ($form->{selectemployee}) { 1874 $employee = qq| 1875 <th align=right>$employeelabel</th> 1876 <td><select name=employee>| 1877 .$form->select_option($form->{selectemployee}, $form->{employee}, 1) 1878 .qq|</select> 1879 </td> 1880|; 1881 } 1882 1883 1884# $locale->text('Add Customer') 1885# $locale->text('Add Vendor') 1886# $locale->text('Edit Customer') 1887# $locale->text('Edit Vendor') 1888 1889 if ($form->{db} eq 'customer') { 1890 $vcname = $locale->text('Customer'); 1891 $vcnumber = $locale->text('Customer Number'); 1892 $form->{title} = $locale->text("$form->{title} Customer"); 1893 } else { 1894 $vcname = $locale->text('Vendor'); 1895 $vcnumber = $locale->text('Vendor Number'); 1896 $form->{title} = $locale->text("$form->{title} Vendor"); 1897 } 1898 1899 $typeofcontact{company} = "checked" if $form->{typeofcontact} eq 'company'; 1900 $typeofcontact{person} = "checked" if $form->{typeofcontact} eq 'person'; 1901 1902 $typeofcontact = qq| 1903 <input type=hidden name=action value="update"> 1904 <tr> 1905 <td align=center><b>|.$locale->text('Type').qq|</b> 1906 <input name=typeofcontact type=radio value="company" $typeofcontact{company} onClick="javascript:main.submit()">|.$locale->text('Company').qq| 1907 <input name=typeofcontact type=radio value="person" $typeofcontact{person} onClick="javascript:main.submit()">|.$locale->text('Person').qq| 1908 </td> 1909 </tr> 1910|; 1911 1912 1913 for (qw(M F)) { $gender{$_} = "checked" if $form->{gender} eq $_ } 1914 1915 if ($form->{typeofcontact} eq 'person') { 1916 1917 $name = qq| 1918 <tr> 1919 <th align=right nowrap>|.$locale->text('Salutation').qq|</th> 1920 <td><input name=salutation size=32 maxlength=32 value="|.$form->quote($form->{salutation}).qq|"></td> 1921 </tr> 1922 <tr> 1923 <th align=right nowrap>|.$locale->text('First Name').qq|</th> 1924 <td><input name=firstname size=32 maxlength=31 value="|.$form->quote($form->{firstname}).qq|"></td> 1925 </tr> 1926 <tr> 1927 <th align=right nowrap>|.$locale->text('Last Name').qq|</th> 1928 <td><input name=lastname size=32 maxlength=32 value="|.$form->quote($form->{lastname}).qq|"></td> 1929 </tr> 1930 <tr> 1931 <th align=right nowrap>|.$locale->text('Title').qq|</th> 1932 <td><input name=contacttitle size=32 maxlength=32 value="|.$form->quote($form->{contacttitle}).qq|"></td> 1933 </tr> 1934 <tr> 1935 <th align=right nowrap>|.$locale->text('Occupation').qq|</th> 1936 <td><input name=occupation size=32 maxlength=32 value="|.$form->quote($form->{occupation}).qq|"></td> 1937 </tr> 1938 <tr> 1939 <th align=right></th> 1940 <td><input name=gender type=radio value="M" $gender{M}>|.$locale->text('Male').qq| 1941 <input name=gender type=radio value="F" $gender{F}>|.$locale->text('Female').qq| 1942 </td> 1943 </tr> 1944|; 1945 1946 } else { 1947 1948 $name = qq| 1949 <tr> 1950 <th align=right nowrap>$vcname <font color=red>*</font></th> 1951 <td><input name=name size=32 maxlength=64 value="|.$form->quote($form->{name}).qq|"></td> 1952 </tr> 1953|; 1954 $contact = qq| 1955 <tr> 1956 <th align=right nowrap>|.$locale->text('Salutation').qq|</th> 1957 <td><input name=salutation size=32 maxlength=32 value="|.$form->quote($form->{salutation}).qq|"></td> 1958 </tr> 1959 <tr> 1960 <th align=right nowrap>|.$locale->text('First Name').qq|</th> 1961 <td><input name=firstname size=32 maxlength=31 value="|.$form->quote($form->{firstname}).qq|"></td> 1962 </tr> 1963 <tr> 1964 <th align=right nowrap>|.$locale->text('Last Name').qq|</th> 1965 <td><input name=lastname size=32 maxlength=32 value="|.$form->quote($form->{lastname}).qq|"></td> 1966 </tr> 1967 <tr> 1968 <th align=right nowrap>|.$locale->text('Title').qq|</th> 1969 <td><input name=contacttitle size=32 maxlength=32 value="|.$form->quote($form->{contacttitle}).qq|"></td> 1970 </tr> 1971 <tr> 1972 <th align=right nowrap>|.$locale->text('Occupation').qq|</th> 1973 <td><input name=occupation size=32 maxlength=32 value="|.$form->quote($form->{occupation}).qq|"></td> 1974 </tr> 1975 <tr> 1976 <th align=right></th> 1977 <td><input name=gender type=radio value="M" $gender{M}>|.$locale->text('Male').qq| 1978 <input name=gender type=radio value="F" $gender{F}>|.$locale->text('Female').qq| 1979 </td> 1980 </tr> 1981|; 1982 1983 } 1984 1985 if ($form->{id} && $form->{"lock_$form->{db}number"}) { 1986 $number = qq| 1987 <tr> 1988 <th align=right nowrap>$vcnumber</th> 1989 <td>|.$form->quote($form->{"$form->{db}number"}).qq|</td> 1990 </tr>|.$form->hide_form("lock_$form->{db}number") 1991 .$form->hide_form("$form->{db}number"); 1992 } else { 1993 $number = qq| 1994 <tr> 1995 <th align=right nowrap>$vcnumber</th> 1996 <td><input name="$form->{db}number" size=32 maxlength=32 value="|.$form->quote($form->{"$form->{db}number"}).qq|"></td> 1997 </tr>|; 1998 } 1999 2000 $form->{remittancevoucher} = ($form->{remittancevoucher}) ? "checked" : ""; 2001 2002 $reference_documents = &references; 2003 2004 $form->{title} .= " / $form->{company}"; 2005 2006 $form->header; 2007 2008 &calendar; 2009 2010 print qq| 2011 2012<form method="post" name="main" action="$form->{script}"> 2013 2014<table width=100%> 2015 <tr> 2016 <th class=listtop>$form->{helpref}$form->{title}</a></th> 2017 </tr> 2018 <tr> 2019 <td> 2020 <table width=100%> 2021 <tr class=listheading> 2022 <th class=listheading colspan=2>|.$locale->text('Billing Address').qq|</th> 2023 </tr> 2024 $typeofcontact 2025 <tr valign=top> 2026 <td width=50%> 2027 <table> 2028 2029 $number 2030 2031 2032 $name 2033 2034 <tr> 2035 <th align=right nowrap>|.$locale->text('Address').qq|</th> 2036 <td><input name=address1 size=32 maxlength=32 value="|.$form->quote($form->{address1}).qq|"></td> 2037 </tr> 2038 <tr> 2039 <th></th> 2040 <td><input name=address2 size=32 maxlength=32 value="|.$form->quote($form->{address2}).qq|"></td> 2041 </tr> 2042 <tr> 2043 <th align=right nowrap>|.$locale->text('City').qq|</th> 2044 <td><input name=city size=32 maxlength=32 value="|.$form->quote($form->{city}).qq|"></td> 2045 </tr> 2046 <tr> 2047 <th align=right nowrap>|.$locale->text('State/Province').qq|</th> 2048 <td><input name=state size=32 maxlength=32 value="|.$form->quote($form->{state}).qq|"></td> 2049 </tr> 2050 <tr> 2051 <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th> 2052 <td><input name=zipcode size=11 maxlength=10 value="|.$form->quote($form->{zipcode}).qq|"></td> 2053 </tr> 2054 <tr> 2055 <th align=right nowrap>|.$locale->text('Country').qq|</th> 2056 <td><input name=country size=32 maxlength=32 value="|.$form->quote($form->{country}).qq|"></td> 2057 </tr> 2058 </table> 2059 </td> 2060 2061 <td width=50%> 2062 <table> 2063 $contact 2064 <tr> 2065 <th align=right nowrap>|.$locale->text('Phone').qq|</th> 2066 <td><input name=phone size=22 maxlength=20 value="$form->{phone}"></td> 2067 </tr> 2068 <tr> 2069 <th align=right nowrap>|.$locale->text('Fax').qq|</th> 2070 <td><input name=fax size=22 maxlength=20 value="$form->{fax}"></td> 2071 </tr> 2072 <tr> 2073 <th align=right nowrap>|.$locale->text('Mobile').qq|</th> 2074 <td><input name=mobile size=22 maxlength=20 value="$form->{mobile}"></td> 2075 </tr> 2076 <tr> 2077 <th align=right nowrap>|.$locale->text('E-mail').qq|</th> 2078 <td><input name=email size=32 value="$form->{email}"></td> 2079 </tr> 2080 <tr> 2081 <th align=right nowrap>|.$locale->text('Cc').qq|</th> 2082 <td><input name=cc size=32 value="$form->{cc}"></td> 2083 </tr> 2084 <tr> 2085 <th align=right nowrap>|.$locale->text('Bcc').qq|</th> 2086 <td><input name=bcc size=35 value="$form->{bcc}"></td> 2087 </tr> 2088 </table> 2089 </td> 2090 </tr> 2091 </table> 2092 </td> 2093 </tr> 2094 $tax 2095 <tr> 2096 <td> 2097 <table> 2098 <tr valign=top> 2099 <td> 2100 <table> 2101 $arapaccount 2102 $paymentaccount 2103 $discountaccount 2104 </table> 2105 </td> 2106 </tr> 2107 </table> 2108 </td> 2109 </tr> 2110 2111 <tr> 2112 <td> 2113 <table> 2114 <tr> 2115 $currency 2116 <th align=right>|.$locale->text('Startdate').qq|</th> 2117 <td nowrap><input name=startdate size=11 class=date title="$myconfig{dateformat}" value=$form->{startdate}>|.&js_calendar("main", "startdate").qq|</td> 2118 </tr> 2119 <tr> 2120 $pricegroup 2121 <th align=right>|.$locale->text('Enddate').qq|</th> 2122 <td nowrap><input name=enddate size=11 class=date title="$myconfig{dateformat}" value=$form->{enddate}>|.&js_calendar("main", "enddate").qq|</td> 2123 </tr> 2124 <tr> 2125 <th align=right>|.$locale->text('Discount').qq|</th> 2126 <td><input name=discount class="inputright" size=4 value="$form->{discount}"> 2127 <b>%</b></td> 2128 2129 $lang 2130 </tr> 2131 <tr> 2132 $typeofbusiness 2133 $gifi 2134 </tr> 2135 <tr> 2136 <th align=right>|.$locale->text('Tax Number / SSN').qq|</th> 2137 <td><input name=taxnumber size=20 value="|.$form->quote($form->{taxnumber}).qq|"></td> 2138 <th align=right>|.$locale->text('SIC').qq|</th> 2139 <td><input name=sic_code size=6 maxlength=6 value="|.$form->quote($form->{sic_code}).qq|"></td> 2140 </tr> 2141 <tr valign=top> 2142 $employee 2143 <td colspan=4> 2144 <table width=100%> 2145 <tr valign=top> 2146 <th width=1% align=left nowrap>|.$locale->text('Notes').qq|</th> 2147 <td><textarea name=notes rows=3 cols=40 wrap=soft>$form->{notes}</textarea></td> 2148 </tr> 2149 </table> 2150 </td> 2151 </tr> 2152 <tr valign=top> 2153 <td colspan=2> 2154 <table> 2155 <tr> 2156 <th align=right nowrap>|.$locale->text('Bank').qq|</th> 2157 <td><input name=bankname size=32 maxlength=64 value="|.$form->quote($form->{bankname}).qq|"></td> 2158 </tr> 2159 <tr> 2160 <th align=right nowrap>|.$locale->text('Address').qq|</th> 2161 <td><input name=bankaddress1 size=32 maxlength=32 value="|.$form->quote($form->{bankaddress1}).qq|"></td> 2162 </tr> 2163 <tr> 2164 <th></th> 2165 <td><input name=bankaddress2 size=32 maxlength=32 value="|.$form->quote($form->{bankaddress2}).qq|"></td> 2166 </tr> 2167 <tr> 2168 <th align=right nowrap>|.$locale->text('City').qq|</th> 2169 <td><input name=bankcity size=32 maxlength=32 value="|.$form->quote($form->{bankcity}).qq|"></td> 2170 </tr> 2171 <tr> 2172 <th align=right nowrap>|.$locale->text('State/Province').qq|</th> 2173 <td><input name=bankstate size=32 maxlength=32 value="|.$form->quote($form->{bankstate}).qq|"></td> 2174 </tr> 2175 <tr> 2176 <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th> 2177 <td><input name=bankzipcode size=11 maxlength=10 value="|.$form->quote($form->{bankzipcode}).qq|"></td> 2178 </tr> 2179 <tr> 2180 <th align=right nowrap>|.$locale->text('Country').qq|</th> 2181 <td><input name=bankcountry size=32 maxlength=32 value="|.$form->quote($form->{bankcountry}).qq|"></td> 2182 </tr> 2183 </table> 2184 </td> 2185 <td colspan=4> 2186 <table> 2187 <tr> 2188 <th align=right>|.$locale->text('IBAN').qq|</th> 2189 <td><input name=iban size=34 maxlength=34 value="$form->{iban}"></td> 2190 </tr> 2191 <tr> 2192 <th align=right>|.$locale->text('BIC').qq|</th> 2193 <td><input name=bic size=11 maxlength=11 value="$form->{bic}"></td> 2194 </tr> 2195 <tr> 2196 <th align=right nowrap>|.$locale->text('Member Number').qq|</th> 2197 <td><input name=membernumber size=20 value="$form->{membernumber}"></td> 2198 </tr> 2199 <tr> 2200 <th align=right nowrap>|.$locale->text('BC Number').qq|</th> 2201 <td><input name=clearingnumber size=20 value="$form->{clearingnumber}"></td> 2202 </tr> 2203 <tr> 2204 <td align=right><input name=remittancevoucher class=checkbox type=checkbox value=1 $form->{remittancevoucher}></td> 2205 <th align=left>|.$locale->text('Remittance Voucher').qq|</th> 2206 </tr> 2207 </table> 2208 </td> 2209 </tr> 2210 <tr> 2211 <td colspan=4> 2212 $reference_documents 2213 </td> 2214 </tr> 2215 </table> 2216 </td> 2217 </tr> 2218 <tr> 2219 <td><hr size=3 noshade></td> 2220 </tr> 2221</table> 2222|; 2223 2224 2225 $form->hide_form(map { "tax_${_}_description" } (split / /, $form->{taxaccounts})) if $form->{taxaccounts}; 2226 $form->hide_form(map { "select$_" } qw(currency arap discount payment business pricegroup language employee paymentmethod)); 2227 $form->hide_form(map { "shipto$_" } qw(name address1 address2 city state zipcode country contact phone fax email)); 2228 2229} 2230 2231 2232 2233sub form_footer { 2234 2235 %button = ('Update' => { ndx => 1, key => 'U', value => $locale->text('Update') }, 2236 'Save' => { ndx => 2, key => 'S', value => $locale->text('Save') }, 2237 'Shipping Address' => { ndx => 3, key => 'H', value => $locale->text('Shipping Address') }, 2238 'Save as new' => { ndx => 4, key => 'N', value => $locale->text('Save as new') }, 2239 'AR Transaction' => { ndx => 7, key => 'A', value => $locale->text('AR Transaction') }, 2240 'Credit Note' => { ndx => 8, key => 'E', value => $locale->text('Credit Note') }, 2241 'AP Transaction' => { ndx => 9, key => 'A', value => $locale->text('AP Transaction') }, 2242 'Debit Note' => { ndx => 10, key => 'E', value => $locale->text('Debit Note') }, 2243 'Sales Invoice' => { ndx => 11, key => 'I', value => $locale->text('Sales Invoice') }, 2244 'Credit Invoice' => { ndx => 12, key => 'R', value => $locale->text('Credit Invoice') }, 2245 'POS' => { ndx => 13, key => 'C', value => $locale->text('POS') }, 2246 'Sales Order' => { ndx => 14, key => 'O', value => $locale->text('Sales Order') }, 2247 'Quotation' => { ndx => 15, key => 'Q', value => $locale->text('Quotation') }, 2248 'Vendor Invoice' => { ndx => 16, key => 'I', value => $locale->text('Vendor Invoice') }, 2249 'Debit Invoice' => { ndx => 17, key => 'R', value => $locale->text('Debit Invoice') }, 2250 'Purchase Order' => { ndx => 18, key => 'O', value => $locale->text('Purchase Order') }, 2251 'RFQ' => { ndx => 19, key => 'Q', value => $locale->text('RFQ') }, 2252 'Pricelist' => { ndx => 20, key => 'P', value => $locale->text('Pricelist') }, 2253 'New Number' => { ndx => 21, key => 'M', value => $locale->text('New Number') }, 2254 'Delete' => { ndx => 22, key => 'D', value => $locale->text('Delete') }, 2255 ); 2256 2257 2258 %f = (); 2259 2260 if ($form->{db} eq 'customer') { 2261 if ($myconfig{acs} !~ /Customers--Add Customer/) { 2262 $f{'Save'} = 1; 2263 $f{'New Number'} = 1; 2264 $f{'Shipping Address'} = 1; 2265 $f{'Update'} = 1; 2266 2267 if ($form->{id}) { 2268 $f{'Save as new'} = 1; 2269 if ($form->{status} eq 'orphaned') { 2270 $f{'Delete'} = 1; 2271 } 2272 } 2273 } 2274 2275 if ($myconfig{acs} !~ /AR--AR/) { 2276 if ($myconfig{acs} !~ /AR--Add Transaction/) { 2277 $f{'AR Transaction'} = 1; 2278 } 2279 if ($myconfig{acs} !~ /AR--Credit Note/) { 2280 $f{'Credit Note'} = 1; 2281 } 2282 if ($myconfig{acs} !~ /AR--Sales Invoice/) { 2283 $f{'Sales Invoice'} = 1; 2284 } 2285 if ($myconfig{acs} !~ /AR--Credit Invoice/) { 2286 $f{'Credit Invoice'} = 1; 2287 } 2288 } 2289 if ($myconfig{acs} !~ /POS--POS/) { 2290 if ($myconfig{acs} !~ /POS--Sale/) { 2291 $f{'POS'} = 1; 2292 } 2293 } 2294 if ($myconfig{acs} !~ /Order Entry--Order Entry/) { 2295 if ($myconfig{acs} !~ /Order Entry--Sales Order/) { 2296 $f{'Sales Order'} = 1; 2297 } 2298 } 2299 if ($myconfig{acs} !~ /Quotations--Quotations/) { 2300 if ($myconfig{acs} !~ /Quotations--Quotation/) { 2301 $f{'Quotation'} = 1; 2302 } 2303 } 2304 } 2305 2306 if ($form->{db} eq 'vendor') { 2307 if ($myconfig{acs} !~ /Vendors--Add Vendor/) { 2308 $f{'Save'} = 1; 2309 $f{'New Number'} = 1; 2310 $f{'Shipping Address'} = 1; 2311 $f{'Update'} = 1; 2312 2313 if ($form->{id}) { 2314 $f{'Save as new'} = 1; 2315 if ($form->{status} eq 'orphaned') { 2316 $f{'Delete'} = 1; 2317 } 2318 } 2319 } 2320 2321 if ($myconfig{acs} !~ /AP--AP/) { 2322 if ($myconfig{acs} !~ /AP--Add Transaction/) { 2323 $f{'AP Transaction'} = 1; 2324 } 2325 if ($myconfig{acs} !~ /AP--Debit Note/) { 2326 $f{'Debit Note'} = 1; 2327 } 2328 if ($myconfig{acs} !~ /AP--Vendor Invoice/) { 2329 $f{'Vendor Invoice'} = 1; 2330 } 2331 if ($myconfig{acs} !~ /AP--Debit Invoice/) { 2332 $f{'Debit Invoice'} = 1; 2333 } 2334 } 2335 if ($myconfig{acs} !~ /Order Entry--Order Entry/) { 2336 if ($myconfig{acs} !~ /Order Entry--Purchase Order/) { 2337 $f{'Purchase Order'} = 1; 2338 } 2339 } 2340 if ($myconfig{acs} !~ /Quotations--Quotations/) { 2341 if ($myconfig{acs} !~ /Quotations--RFQ/) { 2342 $f{'RFQ'} = 1; 2343 } 2344 } 2345 } 2346 2347 if ($myconfig{acs} !~ /Goods & Services--Goods & Services/) { 2348 $myconfig{acs} =~ s/(Goods & Services--)Add (Service|Assembly).*;/$1--Add Part/g; 2349 if ($myconfig{acs} !~ /Goods & Services--Add Part/) { 2350 $f{'Pricelist'} = 1; 2351 } 2352 } 2353 2354 $form->{update_contact} = 1; 2355 $form->hide_form(qw(id ARAP update_contact addressid contactid taxaccounts path login callback db status reference_rows referenceurl precision company)); 2356 2357 for (keys %button) { delete $button{$_} if ! $f{$_} } 2358 2359 $form->print_button(\%button); 2360 2361 if ($form->{menubar}) { 2362 require "$form->{path}/menu.pl"; 2363 &menubar; 2364 } 2365 2366 print qq| 2367 2368 </form> 2369 2370</body> 2371</html> 2372|; 2373 2374} 2375 2376 2377sub shipping_address { 2378 2379 $form->{title} = $locale->text('Shipping Address'); 2380 $form->helpref("$form->{db}_shipping_address", $myconfig{countrycode}); 2381 2382 $form->{name} ||= "$form->{firstname} $form->{lastname}"; 2383 2384 CT->ship_to(\%myconfig, \%$form); 2385 2386 %shipto = ( 2387 address1 => { i => 2, label => $locale->text('Address') }, 2388 address2 => { i => 3, label => '' }, 2389 city => { i => 4, label => $locale->text('City') }, 2390 state => { i => 5, label => $locale->text('State/Province') }, 2391 zipcode => { i => 6, label => $locale->text('Zip/Postal Code') }, 2392 country => { i => 7, label => $locale->text('Country') }, 2393 contact => { i => 8, label => $locale->text('Contact') }, 2394 phone => { i => 9, label => $locale->text('Phone') }, 2395 fax => { i => 10, label => $locale->text('Fax') }, 2396 email => { i => 11, label => $locale->text('E-mail') } ); 2397 2398 $form->header; 2399 2400 $vcname = $locale->text('Name'); 2401 2402 print qq| 2403<body> 2404 2405<form method=post action=$form->{script}> 2406 2407<table width=100%> 2408 <tr> 2409 <th class=listtop>$form->{helpref}$form->{title}</a></th> 2410 </tr> 2411 <tr height="5"></tr> 2412 <tr> 2413 <td> 2414 <table width=100%> 2415 <tr> 2416 <th class=listheading colspan=3>$form->{name}</th> 2417 </tr> 2418 <tr> 2419 <td></td> 2420 <th align=right nowrap>$vcname</th> 2421 <td><input name=shiptoname size=32 maxlength=64 value="|.$form->quote($form->{shiptoname}).qq|"></td> 2422 </tr> 2423 <tr> 2424 <td></td> 2425 <th align=right nowrap>$shipto{address1}{label}</th> 2426 <td><input name=shiptoaddress1 size=32 maxlength=32 value="|.$form->quote($form->{shiptoaddress1}).qq|"></td> 2427 </tr> 2428 <tr> 2429 <td></td> 2430 <td></td> 2431 <td><input name=shiptoaddress2 size=32 maxlength=32 value="|.$form->quote($form->{shiptoaddress2}).qq|"></td> 2432 </tr> 2433 <tr> 2434 <td></td> 2435 <th align=right nowrap>$shipto{city}{label}</th> 2436 <td><input name=shiptocity size=32 maxlength=32 value="|.$form->quote($form->{shiptocity}).qq|"></td> 2437 </tr> 2438 <tr> 2439 <td></td> 2440 <th align=right nowrap>$shipto{state}{label}</th> 2441 <td><input name=shiptostate size=32 maxlength=32 value="|.$form->quote($form->{shiptostate}).qq|"></td> 2442 </tr> 2443 <tr> 2444 <td></td> 2445 <th align=right nowrap>$shipto{zipcode}{label}</th> 2446 <td><input name=shiptozipcode size=11 maxlength=10 value="|.$form->quote($form->{shiptozipcode}).qq|"></td> 2447 </tr> 2448 <tr> 2449 <td></td> 2450 <th align=right nowrap>$shipto{country}{label}</th> 2451 <td><input name=shiptocountry size=32 maxlength=32 value="|.$form->quote($form->{shiptocountry}).qq|"></td> 2452 </tr> 2453 <tr> 2454 <td></td> 2455 <th align=right nowrap>$shipto{contact}{label}</th> 2456 <td><input name=shiptocontact size=35 maxlength=64 value="|.$form->quote($form->{shiptocontact}).qq|"></td> 2457 </tr> 2458 <tr> 2459 <td></td> 2460 <th align=right nowrap>$shipto{phone}{label}</th> 2461 <td><input name=shiptophone size=22 maxlength=20 value="$form->{shiptophone}"></td> 2462 </tr> 2463 <tr> 2464 <td></td> 2465 <th align=right nowrap>$shipto{fax}{label}</th> 2466 <td><input name=shiptofax size=22 maxlength=20 value="$form->{shiptofax}"></td> 2467 </tr> 2468 <tr> 2469 <td></td> 2470 <th align=right nowrap>$shipto{email}{label}</th> 2471 <td><input name=shiptoemail size=32 value="$form->{shiptoemail}"></td> 2472 </tr> 2473|; 2474 2475 $select = $locale->text('Default'); 2476 2477 $i = 1; 2478 for $ref (@{ $form->{all_shipto} }) { 2479 2480 print qq| 2481 <tr> 2482 <td>$select</td> 2483 <td><hr noshade></td> 2484 <td><hr noshade></td> 2485 </tr> 2486 2487 <tr> 2488 <td><input name="ndx_$i" type=checkbox class=checkbox> 2489 <th align=right nowrap>$vcname</th> 2490 <td>$ref->{shiptoname}</td> 2491 </tr> 2492|; 2493 2494 for (sort { $shipto{$a}{i} <=> $shipto{$b}{i} } keys %shipto) { 2495 print qq| 2496 <tr> 2497 <td></td> 2498 <th align=right nowrap>$shipto{$_}{label}</th> 2499 <td>$ref->{"shipto$_"}</td> 2500 </tr> 2501|; 2502 } 2503 2504 for (keys %$ref) { $form->{"${_}_$i"} = $ref->{$_} } 2505 $form->hide_form(map { "${_}_$i" } keys %$ref); 2506 2507 $i++; 2508 } 2509 $form->{shipto_rows} = $i - 1; 2510 2511 print qq| 2512 </table> 2513 </td> 2514 </tr> 2515</table> 2516|; 2517 2518 for (qw(name address1 address2 city state zipcode country contact phone fax email)) { 2519 delete $form->{"shipto$_"}; 2520 $form->{flds} .= "$_ "; 2521 } 2522 chop $form->{flds}; 2523 2524 $form->{nextsub} = "shipto_selected"; 2525 $form->{action} = $form->{nextsub}; 2526 2527 $form->hide_form; 2528 2529 print qq| 2530<hr size=3 noshade> 2531 2532<br> 2533<input type=submit class=submit name=action value="|.$locale->text('Continue').qq|"> 2534</form> 2535 2536</body> 2537</html> 2538|; 2539 2540} 2541 2542 2543sub shipto_selected { 2544 2545 for $i (1 .. $form->{shipto_rows}) { 2546 if ($form->{"ndx_$i"}) { 2547 for (split / /, $form->{flds}) { $form->{"shipto$_"} = $form->{"shipto${_}_$i"} } 2548 last; 2549 } 2550 } 2551 2552 &update; 2553 2554} 2555 2556 2557sub pricelist { 2558 2559 if ("$form->{name}$form->{lastname}$form->{firstname}" eq "") { 2560 $form->error($locale->text('Name missing!')); 2561 } 2562 2563 delete $form->{update_contact}; 2564 $form->{display_form} ||= "display_pricelist"; 2565 2566 CT->pricelist(\%myconfig, \%$form); 2567 2568 $i = 0; 2569 foreach $ref (@{ $form->{"all_partspricelist"} }) { 2570 $i++; 2571 for (keys %$ref) { $form->{"${_}_$i"} = $ref->{$_} } 2572 } 2573 $form->{rowcount} = $i; 2574 2575 # currencies 2576 $form->{selectcurrency} = ""; 2577 for (split /:/, $form->{currencies}) { $form->{selectcurrency} .= "$_\n" } 2578 $form->{selectcurrency} = $form->escape($form->{selectcurrency},1); 2579 2580 if (@ { $form->{all_partsgroup} }) { 2581 $form->{selectpartsgroup} = "\n"; 2582 foreach $ref (@ { $form->{all_partsgroup} }) { 2583 $form->{selectpartsgroup} .= qq|$ref->{partsgroup}--$ref->{id}\n|; 2584 } 2585 $form->{selectpartsgroup} = $form->escape($form->{selectpartsgroup},1); 2586 } 2587 2588 for (qw(currencies all_partsgroup all_partspricelist)) { delete $form->{$_} } 2589 2590 foreach $i (1 .. $form->{rowcount}) { 2591 2592 if ($form->{db} eq 'customer') { 2593 2594 $form->{"pricebreak_$i"} = $form->format_amount(\%myconfig, $form->{"pricebreak_$i"}); 2595 2596 $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}); 2597 2598 } 2599 2600 if ($form->{db} eq 'vendor') { 2601 2602 $form->{"leadtime_$i"} = $form->format_amount(\%myconfig, $form->{"leadtime_$i"}); 2603 2604 $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}); 2605 2606 } 2607 } 2608 2609 $form->{rowcount}++; 2610 &{ "$form->{db}_pricelist" }; 2611 2612} 2613 2614 2615sub customer_pricelist { 2616 2617 @flds = qw(runningnumber id partnumber description sellprice unit partsgroup pricebreak curr validfrom validto); 2618 2619 $form->{rowcount}--; 2620 2621 # remove empty rows 2622 if ($form->{rowcount}) { 2623 2624 foreach $i (1 .. $form->{rowcount}) { 2625 2626 for (qw(pricebreak sellprice)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } 2627 2628 ($x, $y) = split /\./, $form->{"pricebreak_$i"}; 2629 $x = length $x; 2630 $y = length $y; 2631 $whole = ($whole > $x) ? $whole : $x; 2632 $dec = ($dec > $y) ? $dec : $y; 2633 } 2634 $pad1 = '0' x $whole; 2635 $pad2 = '0' x $dec; 2636 2637 foreach $i (1 .. $form->{rowcount}) { 2638 ($x, $y) = split /\./, $form->{"pricebreak_$i"}; 2639 2640 $x = substr("$pad1$x", -$whole); 2641 $y = substr("$y$pad2", 0, $dec); 2642 $ndx{qq|$form->{"partnumber_$i"}_$form->{"id_$i"}_$x$y|} = $i; 2643 } 2644 2645 $i = 1; 2646 for (sort keys %ndx) { $form->{"runningnumber_$ndx{$_}"} = $i++ } 2647 2648 foreach $i (1 .. $form->{rowcount}) { 2649 if ($form->{"partnumber_$i"} && $form->{"sellprice_$i"}) { 2650 if ($form->{"id_$i"} eq $sameid) { 2651 $j = $i + 1; 2652 next if ($form->{"id_$j"} eq $sameid && !$form->{"pricebreak_$i"}); 2653 } 2654 2655 push @f, {}; 2656 $j = $#f; 2657 2658 for (@flds) { $f[$j]->{$_} = $form->{"${_}_$i"} } 2659 $count++; 2660 } 2661 $sameid = $form->{"id_$i"}; 2662 } 2663 2664 $form->redo_rows(\@flds, \@f, $count, $form->{rowcount}); 2665 $form->{rowcount} = $count; 2666 2667 } 2668 2669 $form->{rowcount}++; 2670 2671 if ($form->{display_form}) { 2672 &{ "$form->{display_form}" }; 2673 } 2674 2675} 2676 2677 2678sub vendor_pricelist { 2679 2680 @flds = qw(runningnumber id sku partnumber description lastcost unit partsgroup curr leadtime); 2681 2682 $form->{rowcount}--; 2683 2684 # remove empty rows 2685 if ($form->{rowcount}) { 2686 2687 foreach $i (1 .. $form->{rowcount}) { 2688 2689 for (qw(leadtime lastcost)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } 2690 $var = ($form->{"partnumber_$i"}) ? $form->{"sku_$i"} : qq|_$form->{"sku_$i"}|; 2691 $ndx{$var} = $i; 2692 2693 } 2694 2695 $i = 1; 2696 for (sort keys %ndx) { $form->{"runningnumber_$ndx{$_}"} = $i++ } 2697 2698 foreach $i (1 .. $form->{rowcount}) { 2699 if ($form->{"sku_$i"}) { 2700 push @f, {}; 2701 $j = $#f; 2702 2703 for (@flds) { $f[$j]->{$_} = $form->{"${_}_$i"} } 2704 $count++; 2705 } 2706 } 2707 2708 $form->redo_rows(\@flds, \@f, $count, $form->{rowcount}); 2709 $form->{rowcount} = $count; 2710 2711 } 2712 2713 $form->{rowcount}++; 2714 2715 if ($form->{display_form}) { 2716 &{ "$form->{display_form}" }; 2717 } 2718 2719} 2720 2721 2722sub display_pricelist { 2723 2724 &pricelist_header; 2725 delete $form->{action}; 2726 $form->hide_form; 2727 &pricelist_footer; 2728 2729} 2730 2731 2732sub pricelist_header { 2733 2734 $form->{title} = ($form->{typeofcontact} ne 'company') ? "$form->{firstname} $form->{lastname}" : $form->{name}; 2735 2736 $form->helpref("pricelist", $myconfig{countrycode}); 2737 2738 $form->header; 2739 2740 print qq| 2741<body> 2742 2743<form method=post action="$form->{script}"> 2744 2745<table width=100%> 2746 <tr> 2747 <th class=listtop>$form->{helpref}$form->{title}</a></th> 2748 </tr> 2749 <tr height="5"></tr> 2750|; 2751 2752 if ($form->{db} eq 'customer') { 2753 @column_index = qw(partnumber description); 2754 push @column_index, "partsgroup" if $form->{selectpartsgroup}; 2755 push @column_index, qw(pricebreak sellprice curr validfrom validto); 2756 2757 $column_header{pricebreak} = qq|<th class=listheading nowrap>|.$locale->text('Break').qq|</th>|; 2758 $column_header{sellprice} = qq|<th class=listheading nowrap>|.$locale->text('Sell Price').qq|</th>|; 2759 $column_header{validfrom} = qq|<th class=listheading nowrap>|.$locale->text('From').qq|</th>|; 2760 $column_header{validto} = qq|<th class=listheading nowrap>|.$locale->text('To').qq|</th>|; 2761 } 2762 2763 if ($form->{db} eq 'vendor') { 2764 @column_index = qw(sku partnumber description); 2765 push @column_index, "partsgroup" if $form->{selectpartsgroup}; 2766 push @column_index, qw(lastcost curr leadtime); 2767 2768 2769 $column_header{sku} = qq|<th class=listheading nowrap>|.$locale->text('SKU').qq|</th>|; 2770 $column_header{leadtime} = qq|<th class=listheading nowrap>|.$locale->text('Leadtime').qq|</th>|; 2771 $column_header{lastcost} = qq|<th class=listheading nowrap>|.$locale->text('Cost').qq|</th>|; 2772 } 2773 2774 $column_header{partnumber} = qq|<th class=listheading nowrap>|.$locale->text('Number').qq|</th>|; 2775 $column_header{description} = qq|<th class=listheading nowrap width=80%>|.$locale->text('Description').qq|</th>|; 2776 $column_header{partsgroup} = qq|<th class=listheading nowrap>|.$locale->text('Group').qq|</th>|; 2777 $column_header{curr} = qq|<th class=listheading nowrap>|.$locale->text('Curr').qq|</th>|; 2778 2779 print qq| 2780 <tr> 2781 <td> 2782 <table width=100%> 2783 <tr class=listheading> 2784|; 2785 2786 for (@column_index) { print "\n$column_header{$_}" } 2787 2788 print qq| 2789 </tr> 2790|; 2791 2792 $sameid = ""; 2793 foreach $i (1 .. $form->{rowcount}) { 2794 2795 if ($i < $form->{rowcount}) { 2796 $column_data{partsgroup} = qq|<td>$form->{"partsgroup_$i"}</td>| if $form->{selectpartsgroup}; 2797 2798 if ($form->{"id_$i"} eq $sameid) { 2799 for (qw(partnumber description partsgroup)) { $column_data{$_} = qq|<td> </td>| } 2800 $form->hide_form(map { "${_}_$i" } qw(id partnumber description partsgroup partsgroup_id)); 2801 2802 } else { 2803 2804 $column_data{sku} = qq|<td><input name="sku_$i" value="|.$form->quote($form->{"sku_$i"}).qq|"></td>|; 2805 $column_data{partnumber} = qq|<td><input name="partnumber_$i" value="|.$form->quote($form->{"partnumber_$i"}).qq|"></td>|; 2806 2807 $column_data{description} = qq|<td>$form->{"description_$i"} </td>|; 2808 $form->hide_form(map { "${_}_$i" } qw(id description partsgroup partsgroup_id)); 2809 } 2810 2811 } else { 2812 2813 if ($form->{db} eq 'customer') { 2814 $column_data{partnumber} = qq|<td><input name="partnumber_$i"></td>|; 2815 } else { 2816 $column_data{partnumber} = qq|<td> </td>|; 2817 } 2818 2819 $column_data{sku} = qq|<td><input name="sku_$i"></td>|; 2820 $column_data{description} = qq|<td><input name="description_$i"></td>|; 2821 2822 if ($form->{selectpartsgroup}) { 2823 $column_data{partsgroup} = qq|<td><select name="partsgroup_$i">| 2824 .$form->select_option($form->{selectpartsgroup}, undef, 1) 2825 .qq|</select> 2826 </td> 2827|; 2828 } 2829 } 2830 2831 2832 if ($form->{db} eq 'customer') { 2833 2834 $column_data{pricebreak} = qq|<td><input name="pricebreak_$i" class="inputright" size=5 value=|.$form->format_amount(\%myconfig, $form->{"pricebreak_$i"}).qq|></td>|; 2835 $column_data{sellprice} = qq|<td><input name="sellprice_$i" class="inputright" size=11 value=|.$form->format_amount(\%myconfig, $form->{"sellprice_$i"}).qq|></td>|; 2836 2837 $column_data{validfrom} = qq|<td nowrap><input name="validfrom_$i" size=11 value=$form->{"validfrom_$i"}></td>|; 2838 $column_data{validto} = qq|<td nowrap><input name="validto_$i" size=11 value=$form->{"validto_$i"}></td>|; 2839 } 2840 2841 if ($form->{db} eq 'vendor') { 2842 $column_data{leadtime} = qq|<td><input name="leadtime_$i" class="inputright" size=5 value=|.$form->format_amount(\%myconfig, $form->{"leadtime_$i"}).qq|></td>|; 2843 $column_data{lastcost} = qq|<td><input name="lastcost_$i" class="inputright" size=11 value=|.$form->format_amount(\%myconfig, $form->{"lastcost_$i"}).qq|></td>|; 2844 } 2845 2846 2847 $column_data{curr} = qq|<td><select name="curr_$i">|.$form->select_option($form->{selectcurrency}, $form->{"curr_$i"}).qq|</select></td>|; 2848 2849 2850 print qq|<tr valign=top>|; 2851 2852 for (@column_index) { print "\n$column_data{$_}" } 2853 2854 print qq|</tr>|; 2855 2856 $sameid = $form->{"id_$i"}; 2857 2858 } 2859 2860 print qq| 2861 </table> 2862 </td> 2863 </tr> 2864 <tr> 2865 <td><hr size=3 noshade></td> 2866 </tr> 2867</table> 2868|; 2869 2870 # delete variables 2871 foreach $i (1 .. $form->{rowcount}) { 2872 for (@column_index, "id", "partsgroup_id") { delete $form->{"${_}_$i"} } 2873 } 2874 for (qw(title script none)) { delete $form->{$_} } 2875 2876} 2877 2878 2879sub pricelist_footer { 2880 2881 %button = ('Update' => { ndx => 1, key => 'U', value => $locale->text('Update') }, 2882 'Save Pricelist' => { ndx => 3, key => 'S', value => $locale->text('Save Pricelist') }, 2883 ); 2884 2885 $form->print_button(\%button); 2886 2887 print qq| 2888</form> 2889 2890</body> 2891</html> 2892|; 2893 2894} 2895 2896 2897sub update { 2898 2899 for (qw(creditlimit threshold discount cashdiscount)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } 2900 2901 if ($form->{update_contact}) { 2902 2903 $form->{title} = ($form->{id}) ? 'Edit' : 'Add'; 2904 2905 &display_form; 2906 2907 return; 2908 2909 } 2910 2911 2912 $i = $form->{rowcount}; 2913 $additem = 0; 2914 2915 if ($form->{db} eq 'customer') { 2916 $additem = 1 if ! (($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") && ($form->{"partsgroup_$i"} eq "")); 2917 } 2918 if ($form->{db} eq 'vendor') { 2919 if (! (($form->{"sku_$i"} eq "") && ($form->{"description_$i"} eq "") && ($form->{"partsgroup_$i"} eq ""))) { 2920 $additem = 1; 2921 $form->{"partnumber_$i"} = $form->{"sku_$i"}; 2922 } 2923 } 2924 2925 if ($additem) { 2926 2927 CT->retrieve_item(\%myconfig, \%$form); 2928 2929 $rows = scalar @{ $form->{item_list} }; 2930 2931 if ($rows > 0) { 2932 2933 if ($rows > 1) { 2934 2935 &select_item; 2936 exit; 2937 2938 } else { 2939 2940 $sellprice = $form->{"sellprice_$i"}; 2941 $pricebreak = $form->{"pricebreak_$i"}; 2942 $lastcost = $form->{"lastcost_$i"}; 2943 2944 for (qw(partnumber description)) { $form->{item_list}[0]{$_} = $form->quote($form->{item_list}[0]{$_}) } 2945 for (keys %{ $form->{item_list}[0] }) { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } 2946 2947 if ($form->{db} eq 'customer') { 2948 2949 if ($sellprice) { 2950 $form->{"sellprice_$i"} = $sellprice; 2951 } 2952 2953 $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}); 2954 2955 $form->{"pricebreak_$i"} = $pricebreak; 2956 2957 } else { 2958 2959 foreach $j (1 .. $form->{rowcount} - 1) { 2960 if ($form->{"sku_$j"} eq $form->{"partnumber_$i"}) { 2961 $form->error($locale->text('Item already on pricelist!')); 2962 } 2963 } 2964 2965 $form->{"lastcost_$i"} ||= $lastcost; 2966 $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}); 2967 2968 $form->{"sku_$i"} = $form->{"partnumber_$i"}; 2969 2970 } 2971 2972 $form->{rowcount}++; 2973 2974 } 2975 2976 } else { 2977 2978 $form->error($locale->text('Item not on file!')); 2979 2980 } 2981 } 2982 2983 &{ "$form->{db}_pricelist" }; 2984 2985} 2986 2987 2988 2989sub select_item { 2990 2991 @column_index = qw(ndx partnumber description partsgroup unit sellprice lastcost); 2992 2993 $column_data{ndx} = qq|<th class=listheading width=1%> </th>|; 2994 $column_data{partnumber} = qq|<th class=listheading>|.$locale->text('Number').qq|</th>|; 2995 $column_data{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</th>|; 2996 $column_data{partsgroup} = qq|<th class=listheading>|.$locale->text('Group').qq|</th>|; 2997 $column_data{unit} = qq|<th class=listheading>|.$locale->text('Unit').qq|</th>|; 2998 $column_data{sellprice} = qq|<th class=listheading>|.$locale->text('Sell Price').qq|</th>|; 2999 $column_data{lastcost} = qq|<th class=listheading>|.$locale->text('Cost').qq|</th>|; 3000 3001 $helpref = $form->{helpref}; 3002 $form->helpref("select_item", $myconfig{countrycode}); 3003 3004 $form->header; 3005 3006 $title = $locale->text('Select items'); 3007 3008 print qq| 3009<body> 3010 3011<form method=post action="$form->{script}"> 3012 3013<table width=100%> 3014 <tr> 3015 <th class=listtop>$form->{helpref}$title</a></th> 3016 </tr> 3017 <tr height="5"></tr> 3018 <tr> 3019 <td>$option</td> 3020 </tr> 3021 <tr> 3022 <td> 3023 <table width=100%> 3024 <tr class=listheading>|; 3025 3026 for (@column_index) { print "\n$column_data{$_}" } 3027 3028 print qq| 3029 </tr> 3030|; 3031 3032 my $i = 0; 3033 foreach $ref (@{ $form->{item_list} }) { 3034 $i++; 3035 3036 for (qw(partnumber description unit)) { $ref->{$_} = $form->quote($ref->{$_}) } 3037 3038 $column_data{ndx} = qq|<td><input name="ndx_$i" class=checkbox type=checkbox value=$i></td>|; 3039 3040 for (qw(partnumber description partsgroup unit)) { $column_data{$_} = qq|<td>$ref->{$_} </td>| } 3041 3042 $column_data{sellprice} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{sellprice}, undef, " ").qq|</td>|; 3043 $column_data{lastcost} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{lastcost}, undef, " ").qq|</td>|; 3044 3045 $j++; $j %= 2; 3046 3047 print qq| 3048 <tr class=listrow$j>|; 3049 3050 for (@column_index) { print "\n$column_data{$_}" } 3051 3052 print qq| 3053 </tr> 3054|; 3055 3056 for (qw(partnumber description partsgroup partsgroup_id sellprice lastcost unit id)) { 3057 print qq|<input type=hidden name="new_${_}_$i" value="|.$form->quote($ref->{$_}).qq|">\n|; 3058 } 3059 } 3060 3061 print qq| 3062 </table> 3063 </td> 3064 </tr> 3065 <tr> 3066 <td><hr size=3 noshade></td> 3067 </tr> 3068</table> 3069 3070<input name=lastndx type=hidden value=$i> 3071 3072|; 3073 3074 # delete action variable 3075 for (qw(nextsub item_list)) { delete $form->{$_} } 3076 3077 $form->{helpref} = $helpref; 3078 $form->{action} = "item_selected"; 3079 3080 $form->hide_form; 3081 3082 print qq| 3083<input type=hidden name=nextsub value=item_selected> 3084 3085<br> 3086<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|"> 3087</form> 3088 3089</body> 3090</html> 3091|; 3092} 3093 3094 3095 3096sub item_selected { 3097 3098 # add rows 3099 $i = $form->{rowcount}; 3100 3101 %id = (); 3102 for $i (1 .. $form->{rowcount} - 1) { 3103 $id{$form->{"id_$i"}} = 1; 3104 } 3105 3106 for $j (1 .. $form->{lastndx}) { 3107 3108 if ($form->{"ndx_$j"}) { 3109 3110 if ($id{$form->{"new_id_$j"}}) { 3111 next if $form->{db} eq 'vendor'; 3112 } 3113 3114 for (qw(id partnumber description unit sellprice lastcost partsgroup partsgroup_id)) { 3115 $form->{"${_}_$i"} = $form->{"new_${_}_$j"}; 3116 } 3117 3118 $form->{"sku_$i"} = $form->{"new_partnumber_$j"}; 3119 3120 $i++; 3121 3122 } 3123 } 3124 3125 $form->{rowcount} = $i; 3126 3127 # delete all the new_ variables 3128 for $i (1 .. $form->{lastndx}) { 3129 for (qw(id partnumber description unit sellprice lastcost partsgroup partsgroup_id)) { delete $form->{"new_${_}_$i"} } 3130 delete $form->{"ndx_$i"}; 3131 } 3132 3133 for (qw(ndx lastndx nextsub)) { delete $form->{$_} } 3134 3135 &{ "$form->{db}_pricelist" }; 3136 3137} 3138 3139 3140 3141 3142sub save_pricelist { 3143 3144 CT->save(\%myconfig, \%$form); 3145 3146 $callback = $form->{callback}; 3147 $form->{callback} = "$form->{script}?action=edit"; 3148 for (qw(db id login path)) { $form->{callback} .= "&$_=$form->{$_}" } 3149 $form->{callback} .= "&callback=".$form->escape($callback,1); 3150 3151 if (CT->save_pricelist(\%myconfig, \%$form)) { 3152 $form->redirect; 3153 } else { 3154 $form->error($locale->text('Could not save pricelist!')); 3155 } 3156 3157} 3158 3159 3160 3161sub add_transaction { 3162 3163 if ("$form->{name}$form->{lastname}$form->{firstname}" eq "") { 3164 $form->error($locale->text("Name missing!")); 3165 } 3166 3167 $form->{enddate} = "" if $form->{enddate}; 3168 3169 CT->save(\%myconfig, \%$form); 3170 3171 $form->{callback} = $form->escape($form->{callback},1); 3172 $name = $form->escape($form->{name},1); 3173 3174 $form->{callback} = "$form->{script}?login=$form->{login}&path=$form->{path}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}"; 3175 3176 $form->redirect; 3177 3178} 3179 3180 3181sub ap_transaction { 3182 3183 $form->{script} = "ap.pl"; 3184 $form->{type} = "transaction"; 3185 $form->{ARAP} = "AP"; 3186 &add_transaction; 3187 3188} 3189 3190 3191sub debit_note { 3192 3193 $form->{script} = "ap.pl"; 3194 $form->{type} = "debit_note"; 3195 $form->{ARAP} = "AP"; 3196 &add_transaction; 3197 3198} 3199 3200 3201sub ar_transaction { 3202 3203 $form->{script} = "ar.pl"; 3204 $form->{type} = "transaction"; 3205 $form->{ARAP} = "AR"; 3206 &add_transaction; 3207 3208} 3209 3210 3211sub credit_note { 3212 3213 $form->{script} = "ar.pl"; 3214 $form->{type} = "credit_note"; 3215 $form->{ARAP} = "AR"; 3216 &add_transaction; 3217 3218} 3219 3220 3221sub sales_invoice { 3222 3223 $form->{script} = "is.pl"; 3224 $form->{type} = "invoice"; 3225 &add_transaction; 3226 3227} 3228 3229 3230sub credit_invoice { 3231 3232 $form->{script} = "is.pl"; 3233 $form->{type} = "credit_invoice"; 3234 &add_transaction; 3235 3236} 3237 3238 3239sub pos { 3240 3241 $form->{script} = "ps.pl"; 3242 $form->{type} = "pos_invoice"; 3243 &add_transaction; 3244 3245} 3246 3247 3248sub vendor_invoice { 3249 3250 $form->{script} = "ir.pl"; 3251 $form->{type} = "invoice"; 3252 &add_transaction; 3253 3254} 3255 3256 3257sub debit_invoice { 3258 3259 $form->{script} = "ir.pl"; 3260 $form->{type} = "debit_invoice"; 3261 &add_transaction; 3262 3263} 3264 3265 3266sub rfq { 3267 3268 $form->{script} = "oe.pl"; 3269 $form->{type} = "request_quotation"; 3270 &add_transaction; 3271 3272} 3273 3274 3275sub quotation { 3276 3277 $form->{script} = "oe.pl"; 3278 $form->{type} = "sales_quotation"; 3279 &add_transaction; 3280 3281} 3282 3283 3284sub sales_order { 3285 3286 $form->{script} = "oe.pl"; 3287 $form->{type} = "sales_order"; 3288 &add_transaction; 3289 3290} 3291 3292 3293sub purchase_order { 3294 3295 $form->{script} = "oe.pl"; 3296 $form->{type} = "purchase_order"; 3297 &add_transaction; 3298 3299} 3300 3301 3302sub save_as_new { 3303 3304 for (qw(id contactid)) { delete $form->{$_} } 3305 3306 if ($form->{"lock_$form->{db}number"}) { 3307 delete $form->{"$form->{db}number"}; 3308 } 3309 3310 &save; 3311 3312} 3313 3314 3315sub save { 3316 3317# $locale->text('Customer saved!') 3318# $locale->text('Vendor saved!') 3319 3320 $msg = ucfirst $form->{db}; 3321 $msg .= " saved!"; 3322 3323 if ("$form->{name}$form->{lastname}$form->{firstname}" eq "") { 3324 $form->error($locale->text("Name missing!")); 3325 } 3326 3327 &references; 3328 3329 $form->{userspath} = $userspath; 3330 3331 CT->save(\%myconfig, \%$form); 3332 3333 $form->redirect($locale->text($msg)); 3334 3335} 3336 3337 3338sub delete { 3339 3340# $locale->text('Customer deleted!') 3341# $locale->text('Cannot delete customer!') 3342# $locale->text('Vendor deleted!') 3343# $locale->text('Cannot delete vendor!') 3344 3345 CT->delete(\%myconfig, \%$form); 3346 3347 $msg = ucfirst $form->{db}; 3348 $msg .= " deleted!"; 3349 $form->redirect($locale->text($msg)); 3350 3351} 3352 3353 3354sub new_number { 3355 3356 $form->{"$form->{db}number"} = $form->update_defaults(\%myconfig, "$form->{db}number"); 3357 3358 &display_form; 3359 3360} 3361 3362 3363sub display_form { 3364 3365 &form_header; 3366 &form_footer; 3367 3368} 3369 3370 3371sub continue { &{ $form->{nextsub} } }; 3372 3373sub add_customer { &add }; 3374sub add_vendor { &add }; 3375 3376 3377sub lookup_name { 3378 3379 CT->search(\%myconfig, \%$form); 3380 3381 @column_index = qw(name city); 3382 3383 $form->{title} = $locale->text('Vendor'); 3384 3385 if ($form->{db} eq 'customer') { 3386 $form->{title} = $locale->text('Customer'); 3387 } 3388 3389 $form->header; 3390 3391 &resize; 3392 3393 &pickvalue; 3394 3395 print qq| 3396<body> 3397 3398<table width=100%> 3399 <tr> 3400 <th class=listtop>$form->{title}</th> 3401 </tr> 3402 <tr height="5"></tr> 3403 3404 <tr> 3405 <td> 3406 <table width=100%> 3407|; 3408 3409 foreach $ref (@{ $form->{CT} }) { 3410 3411 for (@column_index) { $column_data{$_} = "<td>$ref->{$_} </td>" } 3412 3413 $column_data{name} = qq|<td><a href="#" onClick="pickvalue('$form->{pickvar}','$ref->{name}'); pickvalue('$form->{pickid}','$ref->{id}'); window.close();">$ref->{name}</a></td>|; 3414 3415 $j++; $j %= 2; 3416 print "<tr class=listrow$j>"; 3417 3418 for (@column_index) { print "\n$column_data{$_}" } 3419 3420 print qq| 3421 </tr> 3422|; 3423 3424 } 3425 3426 print qq| 3427 </table> 3428 </td> 3429 </tr> 3430 <tr><td><hr size=3 noshade></td></tr> 3431</table> 3432 3433x <a href="javascript:window.close();">|.$locale->text('Close Window').qq|</a> 3434|; 3435 3436 3437} 3438 3439 3440sub delete_customers { &retrieve_names }; 3441sub delete_vendors { &retrieve_names }; 3442 3443 3444sub retrieve_names { 3445 3446 CT->retrieve_names(\%myconfig, \%$form); 3447 3448 $form->error($locale->text('Nothing selected!')) unless @{$form->{names}}; 3449 3450 $form->header; 3451 3452 print qq| 3453 3454<body> 3455 3456<form method=post action=$form->{script}> 3457|; 3458 3459 $form->hide_form; 3460 3461 print qq| 3462<h2 class=confirm>|.$locale->text('Confirm!').qq|</h2> 3463 3464<h4>|.$locale->text('Are you sure you want to delete').qq|</h4> 3465<p> 3466|; 3467 3468 for (@{$form->{names}}) { 3469 print "$_<br>\n"; 3470 } 3471 3472 print qq| 3473<p> 3474<input name=action class=submit type=submit value="|.$locale->text('Yes, delete').qq|"> 3475</form> 3476 3477</body> 3478</html> 3479|; 3480 3481} 3482 3483sub yes__delete { 3484 3485 CT->batch_delete(\%myconfig, \%$form); 3486 3487 $form->redirect; 3488 3489} 3490 3491 3492