summaryrefslogtreecommitdiff
path: root/scripts/vendor.pl
blob: c8c21503a1c84f6ae72c9cdf63659a654ac800ad (plain)
  1. =pod
  2. =head1 NAME
  3. LedgerSMB::Scripts::Vendor - LedgerSMB class defining the Controller
  4. functions, template instantiation and rendering for Vendor editing and display.
  5. =head1 SYOPSIS
  6. This module is the UI controller for the Vendor DB access; it provides the
  7. View interface, as well as defines the Save Vendor.
  8. Save vendor will update or create as needed.
  9. =head1 METHODS
  10. =cut
  11. package LedgerSMB::Scripts::Vendor;
  12. use LedgerSMB::Template;
  13. use LedgerSMB::DBObject::Vendor;
  14. =pod
  15. =over
  16. =item get($self, $request, $user)
  17. Requires form var: id
  18. Extracts a single Vendor from the database, using its company ID as the primary
  19. point of uniqueness. Shows (appropriate to user privileges) and allows editing
  20. of the vendor informations.
  21. =back
  22. =cut
  23. sub get {
  24. my ($class, $request) = @_;
  25. my $vendor = LedgerSMB::DBObject::Vendor->new(base => $request, copy => 'all');
  26. my $result = $vendor->get($vendor->{id});
  27. my $template = LedgerSMB::Template->new( user => $user,
  28. template => 'vendor.html', language => $user->{language},
  29. format => 'html');
  30. $template->render($results);
  31. }
  32. =pod
  33. =over
  34. =item search($self, $request, $user)
  35. Requires form var: search_pattern
  36. Directly calls the database function search, and returns a set of all vendors
  37. found that match the search parameters. Search parameters search over address
  38. as well as Vendor/Company name.
  39. =back
  40. =cut
  41. sub search {
  42. my ($class, $request) = @_;
  43. my $vendor = LedgerSMB::DBObject::Vendor->new(base => $request, copy => 'all');
  44. my $results = $vendor->search($vendor->{search_pattern});
  45. my $template = LedgerSMB::Template->new( user => $user,
  46. template => 'vendor_search.html', language => $user->{language},
  47. format => 'html');
  48. $template->render($results);
  49. }
  50. =pod
  51. =over
  52. =item save($self, $request, $user)
  53. Saves a Vendor to the database. The function will update or insert a new
  54. vendor as needed, and will generate a new Company ID for the vendor if needed.
  55. =back
  56. =cut
  57. sub save {
  58. my ($class, $request) = @_;
  59. my $vendor = LedgerSMB::DBObject::Vendor->new(base => $request, copy => 'all');
  60. my $result = $vendor->save_to_db();
  61. my $template = LedgerSMB::Template->new( user => $user,
  62. template => 'vendor.html', language => $user->{language},
  63. format => 'html');
  64. $template->render($result);
  65. }
  66. =pod
  67. =over
  68. =item vendor_invoice($self, $request, $user)
  69. Added based on existing New Vendor screen.
  70. =back
  71. =cut
  72. sub vendor_invoice {
  73. }
  74. =pod
  75. =over
  76. =item purchase_order($self, $request, $user)
  77. Added based on existing New Vendor screen.
  78. =back
  79. =cut
  80. sub purchase_order {
  81. }
  82. =pod
  83. =over
  84. =item rfq($self, $request, $user)
  85. Added based on existing New Vendor screen.
  86. =back
  87. =cut
  88. sub rfq {
  89. $self->save(@_);
  90. my ($class, $request) = @_;
  91. # saves a new vendor, then generates something.
  92. }
  93. =pod
  94. =over
  95. =item pricelist($self, $request, $user)
  96. Added based on existing New Vendor screen.
  97. =back
  98. =cut
  99. sub pricelist {
  100. }
  101. 1;