Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 69ad8bec

Von Thomas Kasulke vor fast 18 Jahren hinzugefügt

  • ID 69ad8bec12ae8351fad7712b329e41081ce3689f
  • Vorgänger 13438aa4
  • Nachfolger 0d225f52

Historie eingefügt

Unterschiede anzeigen:

bin/mozilla/io.pl
1359 1359
    $attachment_filename =~ s/ /_/g;
1360 1360
    my %umlaute =
1361 1361
      (
1362
       "
1362
       "?" => "ae", "?" => "oe", "?" => "ue",
1363
       "?" => "Ae", "?" => "Oe", "?" => "Ue",
1364
       "?" => "ss"
1365
      );
1366
    map({ $attachment_filename =~ s/$_/$umlaute{$_}/g; } keys(%umlaute));
1367
  } else {
1368
    $attachment_filename = "";
1369
  }
1370

  
1371
  if ($form->{"email"}) {
1372
    $form->{"fokus"} = "Form.subject";
1373
  } else {
1374
    $form->{"fokus"} = "Form.email";
1375
  }
1376
  $form->header;
1377

  
1378
  print qq|
1379
<body onload="fokus()">
1380

  
1381
<form name="Form" method="post" action="$form->{script}">
1382

  
1383
<table width="100%">
1384
  <tr class="listtop">
1385
    <th class="listtop">$title</th>
1386
  </tr>
1387
  <tr height="5"></tr>
1388
  <tr>
1389
    <td>
1390
      <table>
1391
        <tr>
1392
          <th align="right" nowrap>| . $locale->text('To') . qq|</th>
1393
          <td><input name="email" size="30" value="| .
1394
          Q($form->{"email"}) . qq|"></td>
1395
        </tr>
1396
        <tr>
1397
          <th align="right" nowrap>| . $locale->text('Cc') . qq|</th>
1398
          <td><input name="cc" size="30" value="| .
1399
          Q($form->{"cc"}) . qq|"></td>
1400
        </tr>
1401
        $bcc
1402
        <tr>
1403
          <th align="right" nowrap>| . $locale->text('Subject') . qq|</th>
1404
          <td><input name="subject" size="30" value="| .
1405
          Q($form->{"subject"}) . qq|"></td>
1406
        </tr>
1407
        <tr>
1408
          <th align="right" nowrap>| . $locale->text('Attachment name') .
1409
          qq|</th>
1410
          <td><input name="attachment_filename" size="30" value="| .
1411
          Q($attachment_filename) . qq|"></td>
1412
      </table>
1413
    </td>
1414
  </tr>
1415
  <tr>
1416
    <td>
1417
      <table>
1418
        <tr>
1419
          <th align="left" nowrap>| . $locale->text('Message') . qq|</th>
1420
        </tr>
1421
        <tr>
1422
          <td><textarea name="message" rows="15" cols="60" wrap="soft">| .
1423
          H($form->{"message"}) . qq|</textarea></td>
1424
        </tr>
1425
      </table>
1426
    </td>
1427
  </tr>
1428
  <tr>
1429
    <td>
1430
|;
1431

  
1432
  &print_options;
1433

  
1434
  map { delete $form->{$_} }
1435
    qw(action email cc bcc subject message formname sendmode format header override);
1436

  
1437
  # save all other variables
1438
  foreach $key (keys %$form) {
1439
    $form->{$key} =~ s/\"/&quot;/g;
1440
    print qq|<input type="hidden" name="$key" value="| . Q($form->{$key}) . qq|">\n|;
1441
  }
1442

  
1443
  print qq|
1444
    </td>
1445
  </tr>
1446
  <tr>
1447
    <td><hr size="3" noshade></td>
1448
  </tr>
1449
</table>
1450

  
1451
<input type="hidden" name="nextsub" value="send_email">
1452

  
1453
<br>
1454
<input name="action" class="submit" type="submit" value="|
1455
    . $locale->text('Continue') . qq|">
1456
</form>
1457

  
1458
</body>
1459
</html>
1460
|;
1461

  
1462
  $lxdebug->leave_sub();
1463
}
1464

  
1465
sub send_email {
1466
  $lxdebug->enter_sub();
1467

  
1468
  $old_form = new Form;
1469

  
1470
  map { $old_form->{$_} = $form->{$_} } keys %$form;
1471
  $old_form->{media} = $form->{oldmedia};
1472

  
1473
  &print_form($old_form);
1474

  
1475
  $lxdebug->leave_sub();
1476
}
1477

  
1478
sub print_options {
1479
  $lxdebug->enter_sub();
1480
  $form->{sendmode} = "attachment";
1481

  
1482
  $form->{"format"} =
1483
    $form->{"format"} ? $form->{"format"} :
1484
    $myconfig{"template_format"} ? $myconfig{"template_format"} :
1485
    "pdf";
1486

  
1487
  $form->{"copies"} =
1488
    $form->{"copies"} ? $form->{"copies"} :
1489
    $myconfig{"copies"} ? $myconfig{"copies"} :
1490
    3;
1491

  
1492
  $form->{"media"} =
1493
    $form->{"media"} ? $form->{"media"} :
1494
    $myconfig{"default_media"} ? $myconfig{"default_media"} :
1495
    "screen";
1496

  
1497
  $form->{"printer_id"} =
1498
    defined($form->{"printer_id"}) ? $form->{"printer_id"} :
1499
    $myconfig{"default_printer_id"} ? $myconfig{"default_printer_id"} :
1500
    "";
1501

  
1502
  $form->{PD}{ $form->{formname} } = "selected";
1503
  $form->{DF}{ $form->{format} }   = "selected";
1504
  $form->{OP}{ $form->{media} }    = "selected";
1505
  $form->{SM}{ $form->{sendmode} } = "selected";
1506

  
1507
  if ($form->{type} eq 'purchase_order') {
1508
    $type = qq|<select name=formname>
1509
	    <option value=purchase_order $form->{PD}{purchase_order}>|
1510
      . $locale->text('Purchase Order') . qq|
1511
	    <option value=bin_list $form->{PD}{bin_list}>|
1512
      . $locale->text('Bin List');
1513
  }
1514

  
1515
  if ($form->{type} eq 'credit_note') {
1516
    $type = qq|<select name=formname>
1517
	    <option value=credit_note $form->{PD}{credit_note}>|
1518
      . $locale->text('Credit Note');
1519
  }
1520

  
1521
  if ($form->{type} eq 'sales_order') {
1522
    $type = qq|<select name=formname>
1523
	    <option value=sales_order $form->{PD}{sales_order}>|
1524
      . $locale->text('Confirmation') . qq|
1525
      <option value=proforma $form->{PD}{proforma}>|
1526
      . $locale->text('Proforma Invoice') . qq|
1527
	    <option value=pick_list $form->{PD}{pick_list}>|
1528
      . $locale->text('Pick List') . qq|
1529
	    <option value=packing_list $form->{PD}{packing_list}>|
1530
      . $locale->text('Packing List');
1531
  }
1532

  
1533
  if ($form->{type} =~ /_quotation$/) {
1534
    $type = qq|<select name=formname>
1535
	    <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1536
      . $locale->text('Quotation');
1537
  }
1538

  
1539
  if ($form->{type} eq 'invoice') {
1540
    $type = qq|<select name=formname>
1541
	    <option value=invoice $form->{PD}{invoice}>|
1542
      . $locale->text('Invoice') . qq|
1543
      <option value=proforma $form->{PD}{proforma}>|
1544
      . $locale->text('Proforma Invoice') . qq|
1545
      <option value=packing_list $form->{PD}{packing_list}>|
1546
      . $locale->text('Packing List');
1547
  }
1548

  
1549
  if ($form->{type} eq 'invoice' && $form->{storno}) {
1550
    $type = qq|<select name=formname>
1551
	    <option value=storno_invoice $form->{PD}{storno_invoice}>|
1552
      . $locale->text('Storno Invoice') . qq|
1553
      <option value=storno_packing_list $form->{PD}{storno_packing_list}>|
1554
      . $locale->text('Storno Packing List');
1555
  }
1556

  
1557
  if ($form->{type} eq 'credit_note') {
1558
    $type = qq|<select name=formname>
1559
	    <option value=credit_note $form->{PD}{credit_note}>|
1560
      . $locale->text('Credit Note');
1561
  }
1562

  
1563
  if ($form->{media} eq 'email') {
1564
    $media = qq|<select name=sendmode>
1565
	    <option value=attachment $form->{SM}{attachment}>|
1566
      . $locale->text('Attachment') . qq|
1567
	    <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1568
  } else {
1569
    $media = qq|<select name=media>
1570
	    <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1571
    if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates) {
1572
      $media .= qq|
1573
            <option value=printer $form->{OP}{printer}>|
1574
        . $locale->text('Printer');
1575
    }
1576
    if ($latex_templates) {
1577
      $media .= qq|
1578
            <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1579
    }
1580
  }
1581

  
1582
  $format = qq|<select name=format>|;
1583
  if ($opendocument_templates && $openofficeorg_writer_bin &&
1584
      $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
1585
    $format .= qq|<option value=opendocument_pdf | .
1586
      $form->{DF}{"opendocument_pdf"} . qq|>| .
1587
      $locale->text("PDF (OpenDocument/OASIS)") . qq|</option>|;
1588
  }
1589

  
1590
  if ($latex_templates) {
1591
    $format .= qq|<option value=pdf $form->{DF}{pdf}>| .
1592
      $locale->text('PDF') . qq|</option>|;
1593
  }
1594

  
1595
  $format .= qq|<option value=html $form->{DF}{html}>HTML</option>|;
1596

  
1597
  if ($latex_templates) {
1598
    $format .= qq|<option value=postscript $form->{DF}{postscript}>| .
1599
      $locale->text('Postscript') . qq|</option>|;
1600
  }
1601

  
1602
  if ($opendocument_templates) {
1603
    $format .= qq|<option value=opendocument $form->{DF}{opendocument}>| .
1604
      $locale->text("OpenDocument/OASIS") . qq|</option>|;
1605
  }
1606
  $format .= qq|</select>|;
1607

  
1608
  if (scalar(keys (%{ $form->{languages} })) !=0) {
1609
    $language_select = qq|<select name=language_id>
1610
		<option value=""></option>}|;
1611
    foreach $item (@{ $form->{languages} }) {
1612
      if ($form->{language_id} eq $item->{id}) {
1613
        $language_select .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
1614
      } else {
1615
        $language_select .= qq|<option value="$item->{id}">$item->{description}</option>|;
1616
      }
1617
    }
1618
  }
1619

  
1620
  if (scalar(keys (%{ $form->{printers} })) !=0) {
1621
    my $selected = !$form->{"printer_id"} ? "selected" : "";
1622
    $printer_select = qq|<select name=printer_id $selected>
1623
                  <option value=""></option>|;
1624
    foreach $item (@{ $form->{printers} }) {
1625
      $selected = $item->{"id"} == $form->{"printer_id"} ? "selected" : "";
1626
      $printer_select .= qq|<option value="$item->{id}" $selected>$item->{printer_description}</option>|;
1627
    }
1628
  }
1629

  
1630

  
1631

  
1632
  print qq|
1633
<table width=100% cellspacing=0 cellpadding=0>
1634
  <tr>
1635
    <td>
1636
      <table>
1637
	<tr>
1638
	  <td>$type</select></td>|;
1639
  if (scalar(keys (%{ $form->{languages} })) !=0) {
1640
  print qq|
1641
          <td>${language_select}</select></td>|;
1642
  }
1643
  print qq|
1644
	  <td>$format</select></td>
1645
	  <td>$media</select></td>|;
1646
  if (scalar(keys (%{ $form->{printers} })) !=0) {
1647
  print qq|
1648
	  <td>$printer_select</select></td>
1649
|;
1650
  }
1651

  
1652
  if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates && $form->{media} ne 'email') {
1653
    print qq|
1654
	  <td>| . $locale->text('Copies') . qq|
1655
	  <input name=copies size=2 value=$form->{copies}></td>
1656
|;
1657
  }
1658

  
1659
  $form->{groupitems} = "checked" if $form->{groupitems};
1660

  
1661
  print qq|
1662
          <td>| . $locale->text('Group Items') . qq|</td>
1663
          <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
1664
        </tr>
1665
      </table>
1666
    </td>
1667
    <td align=right>
1668
      <table>
1669
        <tr>
1670
|;
1671

  
1672
  if ($form->{printed} =~ /$form->{formname}/) {
1673
    print qq|
1674
	  <th>\|| . $locale->text('Printed') . qq|\|</th>
1675
|;
1676
  }
1677

  
1678
  if ($form->{emailed} =~ /$form->{formname}/) {
1679
    print qq|
1680
	  <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1681
|;
1682
  }
1683

  
1684
  if ($form->{queued} =~ /$form->{formname}/) {
1685
    print qq|
1686
	  <th>\|| . $locale->text('Queued') . qq|\|</th>
1687
|;
1688
  }
1689

  
1690
  print qq|
1691
        </tr>
1692
      </table>
1693
    </td>
1694
  </tr>
1695
</table>
1696
|;
1697

  
1698
  $lxdebug->leave_sub();
1699
}
1700

  
1701
sub print {
1702
  $lxdebug->enter_sub();
1703

  
1704
  # if this goes to the printer pass through
1705
  if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1706
    $form->error($locale->text('Select postscript or PDF!'))
1707
      if ($form->{format} !~ /(postscript|pdf)/);
1708

  
1709
    $old_form = new Form;
1710
    map { $old_form->{$_} = $form->{$_} } keys %$form;
1711
  }
1712

  
1713
  if (!$form->{id} || (($form->{formname} eq "proforma") && !$form->{proforma} && (($form->{type} =~ /_order$/) || ($form->{type} =~ /_quotation$/)))) {
1714
    if ($form->{formname} eq "proforma") {
1715
      $form->{proforma} = 1;
1716
    }
1717
    $form->{print_and_save} = 1;
1718
    my $formname = $form->{formname};
1719
    &save();
1720
    $form->{formname} = $formname;
1721
    &edit();
1722
    exit;
1723
  }
1724

  
1725
  &print_form($old_form);
1726

  
1727
  $lxdebug->leave_sub();
1728
}
1729

  
1730
sub print_form {
1731
  $lxdebug->enter_sub();
1732
  my ($old_form) = @_;
1733

  
1734
  $inv       = "inv";
1735
  $due       = "due";
1736
  $numberfld = "invnumber";
1737

  
1738
  $display_form =
1739
    ($form->{display_form}) ? $form->{display_form} : "display_form";
1740

  
1741
  # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1742
  $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1743

  
1744
  if ($form->{formname} eq "invoice") {
1745
    $form->{label} = $locale->text('Invoice');
1746
  }
1747
  if ($form->{formname} eq "packing_list") {
1748

  
1749
    # this is from an invoice
1750
    $form->{label} = $locale->text('Packing List');
1751
  }
1752
  if ($form->{formname} eq 'sales_order') {
1753
    $inv                  = "ord";
1754
    $due                  = "req";
1755
    $form->{"${inv}date"} = $form->{transdate};
1756
    $form->{label}        = $locale->text('Sales Order');
1757
    $numberfld            = "sonumber";
1758
    $order                = 1;
1759
  }
1760

  
1761
  if (($form->{type} eq 'invoice') && ($form->{formname} eq 'proforma') ) {
1762
    $inv                  = "inv";
1763
    $due                  = "due";
1764
    $form->{"${inv}date"} = $form->{invdate};
1765
    $form->{label}        = $locale->text('Proforma Invoice');
1766
    $numberfld            = "sonumber";
1767
    $order                = 0;
1768
  }
1769

  
1770
  if (($form->{type} eq 'sales_order') && ($form->{formname} eq 'proforma') ) {
1771
    $inv                  = "inv";
1772
    $due                  = "due";
1773
    $form->{"${inv}date"} = $form->{transdate};
1774
    $form->{"invdate"}    = $form->{transdate};
1775
    $form->{invnumber}    = $form->{ordnumber};
1776
    $form->{label}        = $locale->text('Proforma Invoice');
1777
    $numberfld            = "sonumber";
1778
    $order                = 1;
1779
  }
1780

  
1781
  if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1782

  
1783
    # we use the same packing list as from an invoice
1784
    $inv = "ord";
1785
    $due = "req";
1786
    $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1787
    $form->{label} = $locale->text('Packing List');
1788
    $order = 1;
1789
    # set invnumber for template packing_list 
1790
    $form->{invnumber}   = $form->{ordnumber};
1791
  }
1792
  if ($form->{formname} eq 'pick_list') {
1793
    $inv                  = "ord";
1794
    $due                  = "req";
1795
    $form->{"${inv}date"} =
1796
      ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1797
    $form->{label} = $locale->text('Pick List');
1798
    $order = 1 unless $form->{type} eq 'invoice';
1799
  }
1800
  if ($form->{formname} eq 'purchase_order') {
1801
    $inv                  = "ord";
1802
    $due                  = "req";
1803
    $form->{"${inv}date"} = $form->{transdate};
1804
    $form->{label}        = $locale->text('Purchase Order');
1805
    $numberfld            = "ponumber";
1806
    $order                = 1;
1807
  }
1808
  if ($form->{formname} eq 'bin_list') {
1809
    $inv                  = "ord";
1810
    $due                  = "req";
1811
    $form->{"${inv}date"} = $form->{transdate};
1812
    $form->{label}        = $locale->text('Bin List');
1813
    $order                = 1;
1814
  }
1815
  if ($form->{formname} eq 'sales_quotation') {
1816
    $inv                  = "quo";
1817
    $due                  = "req";
1818
    $form->{"${inv}date"} = $form->{transdate};
1819
    $form->{label}        = $locale->text('Quotation');
1820
    $numberfld            = "sqnumber";
1821
    $order                = 1;
1822
  }
1823

  
1824
  if (($form->{type} eq 'sales_quotation') && ($form->{formname} eq 'proforma') ) {
1825
    $inv                  = "quo";
1826
    $due                  = "req";
1827
    $form->{"${inv}date"} = $form->{transdate};
1828
    $form->{"invdate"}    = $form->{transdate};
1829
    $form->{label}        = $locale->text('Proforma Invoice');
1830
    $numberfld            = "sqnumber";
1831
    $order                = 1;
1832
  }
1833

  
1834
  if ($form->{formname} eq 'request_quotation') {
1835
    $inv                  = "quo";
1836
    $due                  = "req";
1837
    $form->{"${inv}date"} = $form->{transdate};
1838
    $form->{label}        = $locale->text('Quotation');
1839
    $numberfld            = "rfqnumber";
1840
    $order                = 1;
1841
  }
1842

  
1843
  $form->isblank("email", $locale->text('E-mail address missing!'))
1844
    if ($form->{media} eq 'email');
1845
  $form->isblank("${inv}date",
1846
           $locale->text($form->{label}) 
1847
           . ": "
1848
           . $locale->text(' Date missing!'));
1849

  
1850
  # $locale->text('Invoice Number missing!')
1851
  # $locale->text('Invoice Date missing!')
1852
  # $locale->text('Packing List Number missing!')
1853
  # $locale->text('Packing List Date missing!')
1854
  # $locale->text('Order Number missing!')
1855
  # $locale->text('Order Date missing!')
1856
  # $locale->text('Quotation Number missing!')
1857
  # $locale->text('Quotation Date missing!')
1858

  
1859
  # assign number
1860
  $form->{what_done} = $form->{formname};
1861
  if (!$form->{"${inv}number"} && !$form->{preview}) {
1862
    $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1863
    if ($form->{media} ne 'email') {
1864

  
1865
      # get pricegroups for parts
1866
      IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1867

  
1868
      # build up html code for prices_$i
1869
      set_pricegroup($form->{rowcount});
1870

  
1871
      $form->{rowcount}--;
1872

  
1873
      &{"$display_form"};
1874
      # saving the history
1875
  	  if(!exists $form->{addition}) {
1876
  	    $form->{addition} = "PRINTED";
1877
  	    $form->save_history($form->dbconnect(\%myconfig));
1878
      }
1879
      # /saving the history
1880
      exit;
1881
    }
1882
  }
1883

  
1884
  &validate_items;
1885

  
1886
  # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1887
  my ($saved_email, $saved_cc, $saved_bcc) =
1888
    ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1889

  
1890
  $language_saved = $form->{language_id};
1891
  $payment_id_saved = $form->{payment_id};
1892

  
1893
  &{"$form->{vc}_details"}();
1894

  
1895
  $form->{language_id} = $language_saved;
1896
  $form->{payment_id} = $payment_id_saved;
1897

  
1898
  $form->{"email"} = $saved_email if ($saved_email);
1899
  $form->{"cc"}    = $saved_cc    if ($saved_cc);
1900
  $form->{"bcc"}   = $saved_bcc   if ($saved_bcc);
1901

  
1902
  my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates);
1903
  if ($form->{"language_id"}) {
1904
    ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) =
1905
      AM->get_language_details(\%myconfig, $form, $form->{language_id});
1906
  } else {
1907
    $output_dateformat = $myconfig{"dateformat"};
1908
    $output_numberformat = $myconfig{"numberformat"};
1909
    $output_longdates = 1;
1910
  }
1911

  
1912
  ($form->{employee}) = split /--/, $form->{employee};
1913

  
1914
  # create the form variables
1915
  if ($order) {
1916
    OE->order_details(\%myconfig, \%$form);
1917
  } else {
1918
    IS->invoice_details(\%myconfig, \%$form, $locale);
1919
  }
1920

  
1921
  if ($form->{shipto_id}) {
1922
    $form->get_shipto(\%myconfig);
1923
  }
1924

  
1925
  @a = qw(name street zipcode city country);
1926

  
1927
  $shipto = 1;
1928

  
1929
  # if there is no shipto fill it in from billto
1930
  foreach $item (@a) {
1931
    if ($form->{"shipto$item"}) {
1932
      $shipto = 0;
1933
      last;
1934
    }
1935
  }
1936

  
1937
  if ($shipto) {
1938
    if (   $form->{formname} eq 'purchase_order'
1939
        || $form->{formname} eq 'request_quotation') {
1940
      $form->{shiptoname}   = $myconfig{company};
1941
      $form->{shiptostreet} = $myconfig{address};
1942
    } else {
1943
      map { $form->{"shipto$_"} = $form->{$_} } @a;
1944
    }
1945
  }
1946

  
1947
  $form->{notes} =~ s/^\s+//g;
1948

  
1949
  $form->{templates} = "$myconfig{templates}";
1950

  
1951
  $form->{language} = $form->get_template_language(\%myconfig);
1952
  $form->{printer_code} = $form->get_printer_code(\%myconfig);
1953

  
1954
  if ($form->{language} ne "") {
1955
    map({ $form->{"unit"}->[$_] =
1956
            AM->translate_units($form, $form->{"language"},
1957
                                $form->{"unit"}->[$_], $form->{"qty"}->[$_]); }
1958
        (0..scalar(@{$form->{"unit"}}) - 1));
1959
    $form->{language} = "_" . $form->{language};
1960
  }
1961

  
1962
  # Format dates.
1963
  format_dates($output_dateformat, $output_longdates,
1964
               qw(invdate orddate quodate pldate duedate reqdate transdate
1965
                  shippingdate deliverydate validitydate paymentdate
1966
                  datepaid transdate_oe deliverydate_oe
1967
                  employee_startdate employee_enddate
1968
                  ),
1969
               grep({ /^datepaid_\d+$/ ||
1970
                        /^transdate_oe_\d+$/ ||
1971
                        /^deliverydate_oe_\d+$/ ||
1972
                        /^reqdate_\d+$/ ||
1973
                        /^deliverydate_\d+$/ ||
1974
                        /^transdate_\d+$/
1975
                    } keys(%{$form})));
1976

  
1977
  reformat_numbers($output_numberformat, 2,
1978
                   qw(invtotal ordtotal quototal subtotal linetotal
1979
                      listprice sellprice netprice discount
1980
                      tax taxbase),
1981
                   grep({ /^linetotal_\d+$/ ||
1982
                            /^listprice_\d+$/ ||
1983
                            /^sellprice_\d+$/ ||
1984
                            /^netprice_\d+$/ ||
1985
                            /^taxbase_\d+$/ ||
1986
                            /^discount_\d+$/ ||
1987
                            /^tax_\d+$/
1988
                        } keys(%{$form})));
1989

  
1990
  reformat_numbers($output_numberformat, undef,
1991
                   qw(qty),
1992
                   grep({ /^qty_\d+$/
1993
                        } keys(%{$form})));
1994

  
1995
  if ($form->{printer_code} ne "") {
1996
    $form->{printer_code} = "_" . $form->{printer_code};
1997
  }
1998

  
1999
  $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
2000
  if ($form->{format} eq 'postscript') {
2001
    $form->{postscript} = 1;
2002
    $form->{IN} =~ s/html$/tex/;
2003
  } elsif ($form->{"format"} =~ /pdf/) {
2004
    $form->{pdf} = 1;
2005
    if ($form->{"format"} =~ /opendocument/) {
2006
      $form->{IN} =~ s/html$/odt/;
2007
    } else {
2008
      $form->{IN} =~ s/html$/tex/;
2009
    }
2010
  } elsif ($form->{"format"} =~ /opendocument/) {
2011
    $form->{"opendocument"} = 1;
2012
    $form->{"IN"} =~ s/html$/odt/;
2013
  }
2014

  
2015
  if ($form->{media} eq 'printer') {
2016
    $form->{OUT} = "| $form->{printer_command} &>/dev/null";
2017
    $form->{printed} .= " $form->{formname}";
2018
    $form->{printed} =~ s/^ //;
2019
  }
2020
  $printed = $form->{printed};
2021

  
2022
  if ($form->{media} eq 'email') {
2023
    $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
2024
      unless $form->{subject};
2025

  
2026
    $form->{OUT} = "$sendmail";
2027

  
2028
    $form->{emailed} .= " $form->{formname}";
2029
    $form->{emailed} =~ s/^ //;
2030
  }
2031
  $emailed = $form->{emailed};
2032

  
2033
  if ($form->{media} eq 'queue') {
2034
    %queued = split / /, $form->{queued};
2035

  
2036
    if ($filename = $queued{ $form->{formname} }) {
2037
      $form->{queued} =~ s/$form->{formname} $filename//;
2038
      unlink "$spool/$filename";
2039
      $filename =~ s/\..*$//g;
2040
    } else {
2041
      $filename = time;
2042
      $filename .= $$;
2043
    }
2044

  
2045
    $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
2046
    $form->{OUT} = ">$spool/$filename";
2047

  
2048
    # add type
2049
    $form->{queued} .= " $form->{formname} $filename";
2050

  
2051
    $form->{queued} =~ s/^ //;
2052
  }
2053
  $queued = $form->{queued};
2054

  
2055
# saving the history
2056
  if(!exists $form->{addition}) {
2057
    if($form->{media} =~ /printer/) {
2058
    	$form->{addition} = "PRINTED";
2059
    }
2060
    elsif($form->{media} =~ /email/) {
2061
    	$form->{addition} = "MAILED";
2062
    }
2063
    elsif($form->{media} =~ /queue/) {
2064
    	$form->{addition} = "QUEUED";
2065
    }
2066
    elsif($form->{media} =~ /screen/) {
2067
    	$form->{addition} = "SCREENED";
2068
    }
2069
    $form->save_history($form->dbconnect(\%myconfig));
2070
  }
2071
  # /saving the history
2072

  
2073
  $form->parse_template(\%myconfig, $userspath);
2074

  
2075
  $form->{callback} = "";
2076

  
2077
  if ($form->{media} eq 'email') {
2078
    $form->{message} = $locale->text('sent') unless $form->{message};
2079
  }
2080
  $message = $form->{message};
2081

  
2082
  # if we got back here restore the previous form
2083
  if ($form->{media} =~ /(printer|email|queue)/) {
2084

  
2085
    $form->update_status(\%myconfig)
2086
      if ($form->{media} eq 'queue' && $form->{id});
2087

  
2088
    if ($old_form) {
2089

  
2090
      $old_form->{"${inv}number"} = $form->{"${inv}number"};
2091

  
2092
      # restore and display form
2093
      map { $form->{$_} = $old_form->{$_} } keys %$old_form;
2094

  
2095
      $form->{queued}  = $queued;
2096
      $form->{printed} = $printed;
2097
      $form->{emailed} = $emailed;
2098
      $form->{message} = $message;
2099

  
2100
      $form->{rowcount}--;
2101
      map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2102
        qw(exchangerate creditlimit creditremaining);
2103

  
2104
      for $i (1 .. $form->{paidaccounts}) {
2105
        map {
2106
          $form->{"${_}_$i"} =
2107
            $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2108
        } qw(paid exchangerate);
2109
      }
2110

  
2111
      &{"$display_form"};
2112
      exit;
2113
    }
2114

  
2115
    $msg =
2116
      ($form->{media} eq 'printer')
2117
      ? $locale->text('sent to printer')
2118
      : $locale->text('emailed to') . " $form->{email}";
2119
    $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
2120
  }
2121
  if ($form->{printing}) {
2122
   &{"$display_form"};
2123
   exit; 
2124
  }
2125

  
2126
  $lxdebug->leave_sub();
2127
}
2128

  
2129
sub customer_details {
2130
  $lxdebug->enter_sub();
2131
  IS->customer_details(\%myconfig, \%$form, @_);
2132
  $lxdebug->leave_sub();
2133
}
2134

  
2135
sub vendor_details {
2136
  $lxdebug->enter_sub();
2137

  
2138
  IR->vendor_details(\%myconfig, \%$form, @_);
2139

  
2140
  $lxdebug->leave_sub();
2141
}
2142

  
2143
sub post_as_new {
2144
  $lxdebug->enter_sub();
2145

  
2146
  $form->{postasnew} = 1;
2147
  map { delete $form->{$_} } qw(printed emailed queued);
2148

  
2149
  &post;
2150

  
2151
  $lxdebug->leave_sub();
2152
}
2153

  
2154
sub ship_to {
2155
  $lxdebug->enter_sub();
2156
  if ($form->{second_run}) {
2157
    $form->{print_and_post} = 0;
2158
  }
2159

  
2160
  $title = $form->{title};
2161
  $form->{title} = $locale->text('Ship to');
2162

  
2163
  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2164
    qw(exchangerate creditlimit creditremaining);
2165

  
2166
  my @shipto_vars =
2167
    qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry
2168
       shiptocontact shiptophone shiptofax shiptoemail
2169
       shiptodepartment_1 shiptodepartment_2);
2170

  
2171
  my @addr_vars =
2172
    (qw(name department_1 department_2 street zipcode city country
2173
        contact email phone fax));
2174

  
2175
  # get details for name
2176
  &{"$form->{vc}_details"}(@addr_vars);
2177

  
2178
  $number =
2179
    ($form->{vc} eq 'customer')
2180
    ? $locale->text('Customer Number')
2181
    : $locale->text('Vendor Number');
2182

  
2183
  # get pricegroups for parts
2184
  IS->get_pricegroups_for_parts(\%myconfig, \%$form);
2185

  
2186
  # build up html code for prices_$i
2187
  set_pricegroup($form->{rowcount});
2188

  
2189
  $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
2190

  
2191
  $form->{rowcount}--;
2192

  
2193
  $form->header;
2194

  
2195
  print qq|
2196
<body>
2197

  
2198
<form method=post action=$form->{script}>
2199

  
2200
<table width=100%>
2201
  <tr>
2202
    <td>
2203
      <table>
2204
	<tr class=listheading>
2205
	  <th class=listheading colspan=2 width=50%>|
2206
    . $locale->text('Billing Address') . qq|</th>
2207
	  <th class=listheading width=50%>|
2208
    . $locale->text('Shipping Address') . qq|</th>
2209
	</tr>
2210
	<tr height="5"></tr>
2211
	<tr>
2212
	  <th align=right nowrap>$number</th>
2213
	  <td>$form->{"$form->{vc}number"}</td>
2214
	</tr>
2215
	<tr>
2216
	  <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
2217
	  <td>$form->{name}</td>
2218
	  <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
2219
	</tr>
2220
	<tr>
2221
	  <th align=right nowrap>| . $locale->text('Department') . qq|</th>
2222
	  <td>$form->{department_1}</td>
2223
	  <td><input name=shiptodepartment_1 size=35 value="$form->{shiptodepartment_1}"></td>
2224
	</tr>
2225
	<tr>
2226
	  <th align=right nowrap>&nbsp;</th>
2227
	  <td>$form->{department_2}</td>
2228
	  <td><input name=shiptodepartment_2 size=35 value="$form->{shiptodepartment_2}"></td>
2229
	</tr>
2230
	<tr>
2231
	  <th align=right nowrap>| . $locale->text('Street') . qq|</th>
2232
	  <td>$form->{street}</td>
2233
	  <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
2234
	</tr>
2235
	<tr>
2236
	  <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
2237
	  <td>$form->{zipcode}</td>
2238
	  <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
2239
	</tr>
2240
	<tr>
2241
	  <th align=right nowrap>| . $locale->text('City') . qq|</th>
2242
	  <td>$form->{city}</td>
2243
	  <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
2244
	</tr>
2245
	<tr>
2246
	  <th align=right nowrap>| . $locale->text('Country') . qq|</th>
2247
	  <td>$form->{country}</td>
2248
	  <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
2249
	</tr>
2250
	<tr>
2251
	  <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2252
	  <td>$form->{contact}</td>
2253
	  <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
2254
	</tr>
2255
	<tr>
2256
	  <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
2257
	  <td>$form->{phone}</td>
2258
	  <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
2259
	</tr>
2260
	<tr>
2261
	  <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
2262
	  <td>$form->{fax}</td>
2263
	  <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
2264
	</tr>
2265
	<tr>
2266
	  <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
2267
	  <td>$form->{email}</td>
2268
	  <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
2269
	</tr>
2270
      </table>
2271
    </td>
2272
  </tr>
2273
</table>
2274

  
2275
<input type=hidden name=nextsub value=$nextsub>
2276
|;
2277

  
2278
  # delete shipto
2279
  map({ delete $form->{$_} } (@shipto_vars, qw(header)));
2280
  $form->{title} = $title;
2281

  
2282
  foreach $key (keys %$form) {
2283
    $form->{$key} =~ s/\"/&quot;/g;
2284
    print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2285
  }
2286

  
2287
  print qq|
2288

  
2289
<hr size=3 noshade>
2290

  
2291
<br>
2292
<input class=submit type=submit name=action value="|
2293
    . $locale->text('Continue') . qq|">
2294
</form>
2295

  
2296
</body>
2297
</html>
2298
|;
2299

  
2300
  $lxdebug->leave_sub();
2301
}
2302

  
2303
sub new_license {
2304
  $lxdebug->enter_sub();
2305

  
2306
  my $row = shift;
2307

  
2308
  # change callback
2309
  $form->{old_callback} = $form->escape($form->{callback}, 1);
2310
  $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
2311
  $form->{old_callback} = $form->escape($form->{old_callback}, 1);
2312

  
2313
  # delete action
2314
  delete $form->{action};
2315
  $customer = $form->{customer};
2316
  map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
2317

  
2318
  # save all other form variables in a previousform variable
2319
  $form->{row} = $row;
2320
  foreach $key (keys %$form) {
2321

  
2322
    # escape ampersands
2323
    $form->{$key} =~ s/&/%26/g;
2324
    $previousform .= qq|$key=$form->{$key}&|;
2325
  }
2326
  chop $previousform;
2327
  $previousform = $form->escape($previousform, 1);
2328

  
2329
  $form->{script} = "licenses.pl";
2330

  
2331
  map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
2332
  map { $form->{$_} = $form->escape($form->{$_}, 1) }
2333
    qw(partnumber description);
2334
  $form->{callback} =
2335
    qq|$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&customer=$customer&partnumber=$form->{partnumber}&description=$form->{description}&previousform="$previousform"&initial=1|;
2336
  $form->redirect;
2337

  
2338
  $lxdebug->leave_sub();
2339
}
2340

  
2341
sub relink_accounts {
2342
  $lxdebug->enter_sub();
2343

  
2344
  $form->{"taxaccounts"} =~ s/\s*$//;
2345
  $form->{"taxaccounts"} =~ s/^\s*//;
2346
  foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
2347
    map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber));
2348
  }
2349
  $form->{"taxaccounts"} = "";
2350

  
2351
  for (my $i = 1; $i <= $form->{"rowcount"}; $i++) {
2352
    if ($form->{"id_$i"}) {
2353
      IC->retrieve_accounts(\%myconfig, $form, $form->{"id_$i"}, $i, 1);
2354
    }
2355
  }
2356

  
2357
  $lxdebug->leave_sub();
2358
}
2359

  
2360
sub set_duedate {
2361
  $lxdebug->enter_sub();
2362

  
2363
  $form->get_duedate(\%myconfig);
2364

  
2365
  my $q = new CGI;
2366
  $result = "$form->{duedate}";
2367
  print $q->header();
2368
  print $result;
2369
  $lxdebug->leave_sub();
2370

  
2371
}
2372

  

Auch abrufbar als: Unified diff