Revision 7a7f33b5
Von Moritz Bunkus vor fast 17 Jahren hinzugefügt
SL/CT.pm | ||
---|---|---|
39 | 39 |
|
40 | 40 |
use Data::Dumper; |
41 | 41 |
|
42 |
use SL::Common; |
|
42 | 43 |
use SL::CVar; |
43 | 44 |
use SL::DBUtils; |
45 |
use SL::FU; |
|
46 |
use SL::Notes; |
|
44 | 47 |
|
45 | 48 |
sub get_tuple { |
46 | 49 |
$main::lxdebug->enter_sub(); |
... | ... | |
73 | 76 |
selectrow_query($form, $dbh, $query, $form->{salesman_id}); |
74 | 77 |
} |
75 | 78 |
|
79 |
my ($employee_id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $form->{login}); |
|
80 |
$query = |
|
81 |
qq|SELECT n.*, n.itime::DATE AS created_on, |
|
82 |
e.name AS created_by_name, e.login AS created_by_login |
|
83 |
FROM notes n |
|
84 |
LEFT JOIN employee e ON (n.created_by = e.id) |
|
85 |
WHERE (n.trans_id = ?) AND (n.trans_module = 'ct')|; |
|
86 |
$form->{NOTES} = selectall_hashref_query($form, $dbh, $query, conv_i($form->{id})); |
|
87 |
|
|
88 |
$query = |
|
89 |
qq|SELECT fu.follow_up_date, fu.done AS follow_up_done, e.name AS created_for_name, e.name AS created_for_login |
|
90 |
FROM follow_ups fu |
|
91 |
LEFT JOIN employee e ON (fu.created_for_user = e.id) |
|
92 |
WHERE (fu.note_id = ?) |
|
93 |
AND NOT COALESCE(fu.done, FALSE) |
|
94 |
AND ( (fu.created_by = ?) |
|
95 |
OR (fu.created_by IN (SELECT DISTINCT what FROM follow_up_access WHERE who = ?)))|; |
|
96 |
$sth = prepare_query($form, $dbh, $query); |
|
97 |
|
|
98 |
foreach my $note (@{ $form->{NOTES} }) { |
|
99 |
do_statement($form, $sth, $query, conv_i($note->{id}), conv_i($note->{created_by}), conv_i($employee_id)); |
|
100 |
$ref = $sth->fetchrow_hashref(); |
|
101 |
|
|
102 |
map { $note->{$_} = $ref->{$_} } keys %{ $ref } if ($ref); |
|
103 |
} |
|
104 |
|
|
105 |
$sth->finish(); |
|
106 |
|
|
107 |
if ($form->{edit_note_id}) { |
|
108 |
$query = |
|
109 |
qq|SELECT n.id AS NOTE_id, n.subject AS NOTE_subject, n.body AS NOTE_body, |
|
110 |
fu.id AS FU_id, fu.follow_up_date AS FU_date, fu.done AS FU_done, fu.created_for_user AS FU_created_for_user |
|
111 |
FROM notes n |
|
112 |
LEFT JOIN follow_ups fu ON ((n.id = fu.note_id) AND NOT COALESCE(fu.done, FALSE)) |
|
113 |
WHERE n.id = ?|; |
|
114 |
$ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{edit_note_id})); |
|
115 |
|
|
116 |
if ($ref) { |
|
117 |
foreach my $key (keys %{ $ref }) { |
|
118 |
my $new_key = $key; |
|
119 |
$new_key =~ s/^([^_]+)/\U\1\E/; |
|
120 |
$form->{$new_key} = $ref->{$key}; |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
76 | 125 |
# check if it is orphaned |
77 | 126 |
my $arap = ( $form->{db} eq 'customer' ) ? "ar" : "ap"; |
78 | 127 |
$query = |
... | ... | |
384 | 433 |
# add shipto |
385 | 434 |
$form->add_shipto( $dbh, $form->{id}, "CT" ); |
386 | 435 |
|
436 |
$self->_save_note('dbh' => $dbh); |
|
437 |
$self->_delete_selected_notes('dbh' => $dbh); |
|
438 |
|
|
387 | 439 |
CVar->save_custom_variables('dbh' => $dbh, |
388 | 440 |
'module' => 'CT', |
389 | 441 |
'trans_id' => $form->{id}, |
... | ... | |
586 | 638 |
# add shipto |
587 | 639 |
$form->add_shipto( $dbh, $form->{id}, "CT" ); |
588 | 640 |
|
641 |
$self->_save_note('dbh' => $dbh); |
|
642 |
$self->_delete_selected_notes('dbh' => $dbh); |
|
643 |
|
|
589 | 644 |
CVar->save_custom_variables('dbh' => $dbh, |
590 | 645 |
'module' => 'CT', |
591 | 646 |
'trans_id' => $form->{id}, |
... | ... | |
845 | 900 |
$main::lxdebug->leave_sub(); |
846 | 901 |
} |
847 | 902 |
|
903 |
sub _save_note { |
|
904 |
$main::lxdebug->enter_sub(); |
|
905 |
|
|
906 |
my $self = shift; |
|
907 |
my %params = @_; |
|
908 |
|
|
909 |
my $form = $main::form; |
|
910 |
|
|
911 |
Common::check_params(\%params, 'dbh'); |
|
912 |
|
|
913 |
if (!$form->{NOTE_subject}) { |
|
914 |
$main::lxdebug->leave_sub(); |
|
915 |
return; |
|
916 |
} |
|
917 |
|
|
918 |
my $dbh = $params{dbh}; |
|
919 |
|
|
920 |
my %follow_up; |
|
921 |
my %note = ( |
|
922 |
'id' => $form->{NOTE_id}, |
|
923 |
'subject' => $form->{NOTE_subject}, |
|
924 |
'body' => $form->{NOTE_body}, |
|
925 |
'trans_id' => $form->{id}, |
|
926 |
'trans_module' => 'ct', |
|
927 |
); |
|
928 |
|
|
929 |
$note{id} = Notes->save(%note); |
|
930 |
|
|
931 |
if ($form->{FU_date}) { |
|
932 |
%follow_up = ( |
|
933 |
'id' => $form->{FU_id}, |
|
934 |
'note_id' => $note{id}, |
|
935 |
'follow_up_date' => $form->{FU_date}, |
|
936 |
'created_for_user' => $form->{FU_created_for_user}, |
|
937 |
'done' => $form->{FU_done} ? 1 : 0, |
|
938 |
'subject' => $form->{NOTE_subject}, |
|
939 |
'body' => $form->{NOTE_body}, |
|
940 |
'LINKS' => [ |
|
941 |
{ |
|
942 |
'trans_id' => $form->{id}, |
|
943 |
'trans_type' => $form->{db} eq 'customer' ? 'customer' : 'vendor', |
|
944 |
'trans_info' => $form->{name}, |
|
945 |
}, |
|
946 |
], |
|
947 |
); |
|
948 |
|
|
949 |
$follow_up{id} = FU->save(%follow_up); |
|
950 |
|
|
951 |
} elsif ($form->{FU_id}) { |
|
952 |
do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id = ?|, conv_i($form->{FU_id})); |
|
953 |
do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE id = ?|, conv_i($form->{FU_id})); |
|
954 |
} |
|
955 |
|
|
956 |
delete @{$form}{grep { /^NOTE_|^FU_/ } keys %{ $form }}; |
|
957 |
|
|
958 |
$main::lxdebug->leave_sub(); |
|
959 |
} |
|
960 |
|
|
961 |
sub _delete_selected_notes { |
|
962 |
$main::lxdebug->enter_sub(); |
|
963 |
|
|
964 |
my $self = shift; |
|
965 |
my %params = @_; |
|
966 |
|
|
967 |
Common::check_params(\%params, 'dbh'); |
|
968 |
|
|
969 |
my $form = $main::form; |
|
970 |
my $dbh = $params{dbh}; |
|
971 |
|
|
972 |
foreach my $i (1 .. $form->{NOTES_rowcount}) { |
|
973 |
next unless ($form->{"NOTE_delete_$i"} && $form->{"NOTE_id_$i"}); |
|
974 |
|
|
975 |
Notes->delete('dbh' => $params{dbh}, |
|
976 |
'id' => $form->{"NOTE_id_$i"}); |
|
977 |
} |
|
978 |
|
|
979 |
$main::lxdebug->leave_sub(); |
|
980 |
} |
|
981 |
|
|
848 | 982 |
1; |
SL/FU.pm | ||
---|---|---|
1 |
# Follow-Ups |
|
2 |
|
|
3 |
package FU; |
|
4 |
|
|
5 |
use List::Util qw(first); |
|
6 |
|
|
7 |
use SL::Common; |
|
8 |
use SL::DBUtils; |
|
9 |
use SL::Notes; |
|
10 |
|
|
11 |
sub save { |
|
12 |
$main::lxdebug->enter_sub(); |
|
13 |
|
|
14 |
my $self = shift; |
|
15 |
my %params = @_; |
|
16 |
|
|
17 |
my $myconfig = \%main::myconfig; |
|
18 |
my $form = $main::form; |
|
19 |
|
|
20 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
21 |
my ($query, @values); |
|
22 |
|
|
23 |
if (!$params{id}) { |
|
24 |
($params{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('follow_up_id')|); |
|
25 |
|
|
26 |
$query = qq|INSERT INTO follow_ups (created_by, done, note_id, follow_up_date, created_for_user, id) |
|
27 |
VALUES ((SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|; |
|
28 |
|
|
29 |
push @values, $form->{login}; |
|
30 |
|
|
31 |
} else { |
|
32 |
$query = qq|UPDATE follow_ups SET done = ?, note_id = ?, follow_up_date = ?, created_for_user = ? WHERE id = ?|; |
|
33 |
} |
|
34 |
|
|
35 |
$params{note_id} = Notes->save('id' => $params{note_id}, |
|
36 |
'trans_id' => $params{id}, |
|
37 |
'trans_module' => 'fu', |
|
38 |
'subject' => $params{subject}, |
|
39 |
'body' => $params{body}); |
|
40 |
|
|
41 |
$params{done} = 1 if (!defined $params{done}); |
|
42 |
|
|
43 |
do_query($form, $dbh, $query, @values, $params{done} ? 't' : 'f', conv_i($params{note_id}), $params{follow_up_date}, conv_i($params{created_for_user}), conv_i($params{id})); |
|
44 |
|
|
45 |
do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id = ?|, conv_i($params{id})); |
|
46 |
|
|
47 |
my $query = qq|INSERT INTO follow_up_links (follow_up_id, trans_id, trans_type, trans_info) VALUES (?, ?, ?, ?)|; |
|
48 |
my $sth = prepare_query($form, $dbh, $query); |
|
49 |
|
|
50 |
foreach my $link (@{ $params{LINKS} }) { |
|
51 |
do_statement($form, $sth, $query, conv_i($params{id}), conv_i($link->{trans_id}), $link->{trans_type}, $link->{trans_info}); |
|
52 |
} |
|
53 |
|
|
54 |
$sth->finish(); |
|
55 |
|
|
56 |
$dbh->commit() unless ($params{dbh}); |
|
57 |
|
|
58 |
$main::lxdebug->leave_sub(); |
|
59 |
} |
|
60 |
|
|
61 |
sub finish { |
|
62 |
$main::lxdebug->enter_sub(); |
|
63 |
|
|
64 |
my $self = shift; |
|
65 |
my %params = @_; |
|
66 |
|
|
67 |
Common::check_params(\%params, 'id'); |
|
68 |
|
|
69 |
my $myconfig = \%main::myconfig; |
|
70 |
my $form = $main::form; |
|
71 |
|
|
72 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
73 |
|
|
74 |
do_query($form, $dbh, qq|UPDATE follow_ups SET done = TRUE WHERE id = ?|, conv_i($params{id})); |
|
75 |
|
|
76 |
$dbh->commit(); |
|
77 |
|
|
78 |
$main::lxdebug->leave_sub(); |
|
79 |
} |
|
80 |
|
|
81 |
sub delete { |
|
82 |
$main::lxdebug->enter_sub(); |
|
83 |
|
|
84 |
my $self = shift; |
|
85 |
my %params = @_; |
|
86 |
|
|
87 |
Common::check_params(\%params, 'id'); |
|
88 |
|
|
89 |
my $myconfig = \%main::myconfig; |
|
90 |
my $form = $main::form; |
|
91 |
|
|
92 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
93 |
|
|
94 |
my $id = conv_i($params{id}); |
|
95 |
|
|
96 |
do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id = ?|, $id); |
|
97 |
do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE id = ?|, $id); |
|
98 |
do_query($form, $dbh, qq|DELETE FROM notes WHERE (trans_id = ?) AND (trans_module = 'fu')|, $id); |
|
99 |
|
|
100 |
$dbh->commit(); |
|
101 |
|
|
102 |
$main::lxdebug->leave_sub(); |
|
103 |
} |
|
104 |
|
|
105 |
sub retrieve { |
|
106 |
$main::lxdebug->enter_sub(); |
|
107 |
|
|
108 |
my $self = shift; |
|
109 |
my %params = @_; |
|
110 |
|
|
111 |
Common::check_params(\%params, 'id'); |
|
112 |
|
|
113 |
my $myconfig = \%main::myconfig; |
|
114 |
my $form = $main::form; |
|
115 |
|
|
116 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
117 |
my ($query, @values); |
|
118 |
|
|
119 |
my ($employee_id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $form->{login}); |
|
120 |
$query = qq|SELECT fu.*, n.subject, n.body, n.created_by |
|
121 |
FROM follow_ups fu |
|
122 |
LEFT JOIN notes n ON (fu.note_id = n.id) |
|
123 |
WHERE (fu.id = ?) |
|
124 |
AND ( (fu.created_by = ?) OR (fu.created_for_user = ?) |
|
125 |
OR (fu.created_by IN (SELECT DISTINCT what FROM follow_up_access WHERE who = ?)))|; |
|
126 |
my $ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($params{id}), $employee_id, $employee_id, $employee_id); |
|
127 |
|
|
128 |
if (!$ref) { |
|
129 |
$main::lxdebug->leave_sub(); |
|
130 |
return undef; |
|
131 |
} |
|
132 |
|
|
133 |
$ref->{LINKS} = $self->retrieve_links(%{ $ref }); |
|
134 |
|
|
135 |
$main::lxdebug->leave_sub(); |
|
136 |
|
|
137 |
return $ref; |
|
138 |
} |
|
139 |
|
|
140 |
sub retrieve_links { |
|
141 |
$main::lxdebug->enter_sub(); |
|
142 |
|
|
143 |
my $self = shift; |
|
144 |
my %params = @_; |
|
145 |
|
|
146 |
Common::check_params(\%params, qw(id)); |
|
147 |
|
|
148 |
my $myconfig = \%main::myconfig; |
|
149 |
my $form = $main::form; |
|
150 |
|
|
151 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
152 |
|
|
153 |
my $query = qq|SELECT ful.trans_id, ful.trans_type, ful.trans_info, fu.note_id |
|
154 |
FROM follow_up_links ful |
|
155 |
LEFT JOIN follow_ups fu ON (ful.follow_up_id = fu.id) |
|
156 |
WHERE ful.follow_up_id = ? |
|
157 |
ORDER BY ful.itime|; |
|
158 |
|
|
159 |
my $links = selectall_hashref_query($form, $dbh, $query, conv_i($params{id})); |
|
160 |
|
|
161 |
foreach my $link_ref (@{ $links }) { |
|
162 |
my $link_details = FU->link_details(%{ $link_ref }); |
|
163 |
map { $link_ref->{$_} = $link_details->{$_} } keys %{ $link_details} if ($link_details); |
|
164 |
} |
|
165 |
|
|
166 |
$main::lxdebug->leave_sub(); |
|
167 |
|
|
168 |
return $links; |
|
169 |
} |
|
170 |
|
|
171 |
sub follow_ups { |
|
172 |
$main::lxdebug->enter_sub(); |
|
173 |
|
|
174 |
my $self = shift; |
|
175 |
my %params = @_; |
|
176 |
|
|
177 |
my $myconfig = \%main::myconfig; |
|
178 |
my $form = $main::form; |
|
179 |
|
|
180 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
181 |
my ($query, $where, $where_user); |
|
182 |
|
|
183 |
my ($employee_id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $form->{login}); |
|
184 |
my @values = ($employee_id, $employee_id); |
|
185 |
|
|
186 |
if ($params{trans_id}) { |
|
187 |
$where .= qq| AND EXISTS (SELECT * FROM follow_up_links ful |
|
188 |
WHERE (ful.follow_up_id = fu.id) AND (ful.trans_id = ?))|; |
|
189 |
push @values, conv_i($params{trans_id}); |
|
190 |
} |
|
191 |
|
|
192 |
if ($params{due_only}) { |
|
193 |
$where .= qq| AND (fu.follow_up_date <= current_date)|; |
|
194 |
} |
|
195 |
|
|
196 |
if ($params{done} ne $params{not_done}) { |
|
197 |
my $not = $params{not_done} ? 'NOT' : ''; |
|
198 |
$where .= qq| AND $not COALESCE(fu.done, FALSE)|; |
|
199 |
} |
|
200 |
|
|
201 |
if ($params{not_id}) { |
|
202 |
$where .= qq| AND (fu.id <> ?)|; |
|
203 |
push @values, conv_i($params{not_id}); |
|
204 |
} |
|
205 |
|
|
206 |
foreach my $item (qw(subject body)) { |
|
207 |
next unless ($params{$item}); |
|
208 |
$where .= qq| AND (n.${item} ILIKE ?)|; |
|
209 |
push @values, '%' . $params{$item} . '%'; |
|
210 |
} |
|
211 |
|
|
212 |
if ($params{reference}) { |
|
213 |
$where .= qq| AND EXISTS (SELECT ful.follow_up_id |
|
214 |
FROM follow_up_links ful |
|
215 |
WHERE (ful.follow_up_id = fu.id) |
|
216 |
AND (ful.trans_info ILIKE ?) |
|
217 |
LIMIT 1)|; |
|
218 |
push @values, '%' . $params{reference} . '%'; |
|
219 |
} |
|
220 |
|
|
221 |
if ($params{follow_up_date_from}) { |
|
222 |
$where .= qq| AND (fu.follow_up_date >= ?)|; |
|
223 |
push @values, conv_date($params{follow_up_date_from}); |
|
224 |
} |
|
225 |
if ($params{follow_up_date_to}) { |
|
226 |
$where .= qq| AND (fu.follow_up_date <= ?)|; |
|
227 |
push @values, conv_date($params{follow_up_date_to}); |
|
228 |
} |
|
229 |
|
|
230 |
if ($params{itime_from}) { |
|
231 |
$where .= qq| AND (date_trunc('DAY', fu.itime) >= ?)|; |
|
232 |
push @values, conv_date($params{itime_from}); |
|
233 |
} |
|
234 |
if ($params{itime_to}) { |
|
235 |
$where .= qq| AND (date_trunc('DAY', fu.itime) <= ?)|; |
|
236 |
push @values, conv_date($params{itime_to}); |
|
237 |
} |
|
238 |
|
|
239 |
if ($params{all_users}) { |
|
240 |
$where_user = qq|OR (fu.created_by IN (SELECT DISTINCT what FROM follow_up_access WHERE who = ?))|; |
|
241 |
push @values, $employee_id; |
|
242 |
} |
|
243 |
|
|
244 |
$query = qq|SELECT fu.*, n.subject, n.body, n.created_by, |
|
245 |
fu.follow_up_date <= current_date AS due, |
|
246 |
fu.itime::DATE AS created_on, |
|
247 |
COALESCE(eby.name, eby.login) AS created_by_name, |
|
248 |
COALESCE(efor.name, efor.login) AS created_for_user_name |
|
249 |
FROM follow_ups fu |
|
250 |
LEFT JOIN notes n ON (fu.note_id = n.id) |
|
251 |
LEFT JOIN employee eby ON (n.created_by = eby.id) |
|
252 |
LEFT JOIN employee efor ON (fu.created_for_user = efor.id) |
|
253 |
WHERE ((fu.created_by = ?) OR (fu.created_for_user = ?) |
|
254 |
$where_user) |
|
255 |
$where |
|
256 |
ORDER BY fu.follow_up_date DESC, fu.id ASC|; |
|
257 |
|
|
258 |
my $follow_ups = selectall_hashref_query($form, $dbh, $query, @values); |
|
259 |
|
|
260 |
if (!scalar @{ $follow_ups }) { |
|
261 |
$main::lxdebug->leave_sub(); |
|
262 |
return $follow_ups; |
|
263 |
} |
|
264 |
|
|
265 |
foreach my $fu (@{ $follow_ups }) { |
|
266 |
$fu->{LINKS} = $self->retrieve_links(%{ $fu }); |
|
267 |
} |
|
268 |
|
|
269 |
$main::lxdebug->leave_sub(); |
|
270 |
|
|
271 |
return $follow_ups; |
|
272 |
} |
|
273 |
|
|
274 |
sub link_details { |
|
275 |
$main::lxdebug->enter_sub(); |
|
276 |
|
|
277 |
my $self = shift; |
|
278 |
my %params = @_; |
|
279 |
|
|
280 |
Common::check_params(\%params, qw(trans_id trans_type)); |
|
281 |
|
|
282 |
my $myconfig = \%main::myconfig; |
|
283 |
my $form = $main::form; |
|
284 |
my $locale = $main::locale; |
|
285 |
|
|
286 |
my $q_id = $form->quote($params{trans_id}); |
|
287 |
my $link; |
|
288 |
|
|
289 |
if ($params{trans_type} eq 'customer') { |
|
290 |
$link = { |
|
291 |
'url' => 'ct.pl?action=edit&db=customer&id=' . $form->quote($params{trans_id}) . '&edit_note_id=' . $form->quote($params{note_id}), |
|
292 |
'title' => $locale->text('Customer') . " '$params{trans_info}'", |
|
293 |
}; |
|
294 |
|
|
295 |
} elsif ($params{trans_type} eq 'vendor') { |
|
296 |
$link = { |
|
297 |
'url' => 'ct.pl?action=edit&type=sales_quotation&id=' . $params{trans_id} . '&edit_note_id=' . $form->quote($params{note_id}), |
|
298 |
'title' => $locale->text('Vendor') . " '$params{trans_info}'", |
|
299 |
}; |
|
300 |
|
|
301 |
} elsif ($params{trans_type} eq 'sales_quotation') { |
|
302 |
$link = { |
|
303 |
'url' => 'oe.pl?action=edit&type=sales_quotation&id=' . $params{trans_id}, |
|
304 |
'title' => $locale->text('Sales quotation') . " $params{trans_info}", |
|
305 |
}; |
|
306 |
|
|
307 |
} elsif ($params{trans_type} eq 'sales_order') { |
|
308 |
$link = { |
|
309 |
'url' => 'oe.pl?action=edit&type=sales_order&id=' . $params{trans_id}, |
|
310 |
'title' => $locale->text('Sales Order') . " $params{trans_info}", |
|
311 |
}; |
|
312 |
|
|
313 |
} elsif ($params{trans_type} eq 'sales_invoice') { |
|
314 |
$link = { |
|
315 |
'url' => 'is.pl?action=edit&type=invoice&id=' . $params{trans_id}, |
|
316 |
'title' => $locale->text('Sales Invoice') . " $params{trans_info}", |
|
317 |
}; |
|
318 |
|
|
319 |
} elsif ($params{trans_type} eq 'credit_note') { |
|
320 |
$link = { |
|
321 |
'url' => 'is.pl?action=edit&type=credit_note&id=' . $params{trans_id}, |
|
322 |
'title' => $locale->text('Credit Note') . " $params{trans_info}", |
|
323 |
}; |
|
324 |
|
|
325 |
} elsif ($params{trans_type} eq 'dunning') { |
|
326 |
$link = { |
|
327 |
'url' => 'dn.pl?action=print_dunning&format=pdf&media=screen&dunning_id=' . $params{trans_id}, |
|
328 |
'title' => $locale->text('Dunning') . " $params{trans_info}", |
|
329 |
}; |
|
330 |
|
|
331 |
} elsif ($params{trans_type} eq 'request_quotation') { |
|
332 |
$link = { |
|
333 |
'url' => 'oe.pl?action=edit&type=request_quotation&id=' . $params{trans_id}, |
|
334 |
'title' => $locale->text('Request quotation') . " $params{trans_info}", |
|
335 |
}; |
|
336 |
|
|
337 |
} elsif ($params{trans_type} eq 'purchase_order') { |
|
338 |
$link = { |
|
339 |
'url' => 'oe.pl?action=edit&type=purchase_order&id=' . $params{trans_id}, |
|
340 |
'title' => $locale->text('Purchase Order') . " $params{trans_info}", |
|
341 |
}; |
|
342 |
|
|
343 |
} elsif ($params{trans_type} eq 'vendor_invoice') { |
|
344 |
$link = { |
|
345 |
'url' => 'ir.pl?action=edit&type=invoice&id=' . $params{trans_id}, |
|
346 |
'title' => $locale->text('Vendor Invoice') . " $params{trans_info}", |
|
347 |
}; |
|
348 |
|
|
349 |
} elsif ($params{trans_type} eq 'ar_transaction') { |
|
350 |
$link = { |
|
351 |
'url' => 'ar.pl?action=editid=' . $params{trans_id}, |
|
352 |
'title' => $locale->text('AR Transaction') . " $params{trans_info}", |
|
353 |
}; |
|
354 |
|
|
355 |
} elsif ($params{trans_type} eq 'ap_transaction') { |
|
356 |
$link = { |
|
357 |
'url' => 'ap.pl?action=editid=' . $params{trans_id}, |
|
358 |
'title' => $locale->text('AP Transaction') . " $params{trans_info}", |
|
359 |
}; |
|
360 |
|
|
361 |
} elsif ($params{trans_type} eq 'gl_transaction') { |
|
362 |
$link = { |
|
363 |
'url' => 'gl.pl?action=edit&id=' . $params{trans_id}, |
|
364 |
'title' => $locale->text('GL Transaction') . " $params{trans_info}", |
|
365 |
}; |
|
366 |
|
|
367 |
} |
|
368 |
|
|
369 |
$main::lxdebug->leave_sub(); |
|
370 |
|
|
371 |
return $link || { }; |
|
372 |
} |
|
373 |
|
|
374 |
sub save_access_rights { |
|
375 |
$main::lxdebug->enter_sub(); |
|
376 |
|
|
377 |
my $self = shift; |
|
378 |
my %params = @_; |
|
379 |
|
|
380 |
Common::check_params(\%params, 'access'); |
|
381 |
|
|
382 |
my $myconfig = \%main::myconfig; |
|
383 |
my $form = $main::form; |
|
384 |
|
|
385 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
386 |
|
|
387 |
my ($id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $form->{login}); |
|
388 |
|
|
389 |
my $query = qq|INSERT INTO follow_up_access (who, what) VALUES (?, ?)|; |
|
390 |
my $sth = prepare_query($form, $dbh, $query); |
|
391 |
|
|
392 |
do_query($form, $dbh, qq|DELETE FROM follow_up_access WHERE what = ?|, $id); |
|
393 |
|
|
394 |
while (my ($who, $access_allowed) = each %{ $params{access} }) { |
|
395 |
next unless ($access_allowed); |
|
396 |
|
|
397 |
do_statement($form, $sth, $query, conv_i($who), $id); |
|
398 |
} |
|
399 |
|
|
400 |
$sth->finish(); |
|
401 |
|
|
402 |
$dbh->commit(); |
|
403 |
|
|
404 |
$main::lxdebug->leave_sub(); |
|
405 |
} |
|
406 |
|
|
407 |
sub retrieve_access_rights { |
|
408 |
$main::lxdebug->enter_sub(); |
|
409 |
|
|
410 |
my $self = shift; |
|
411 |
my %params = @_; |
|
412 |
|
|
413 |
my $myconfig = \%main::myconfig; |
|
414 |
my $form = $main::form; |
|
415 |
|
|
416 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
417 |
|
|
418 |
my $sth = prepare_execute_query($form, $dbh, qq|SELECT who FROM follow_up_access WHERE what = (SELECT id FROM employee WHERE login = ?)|, $form->{login}); |
|
419 |
my $access = {}; |
|
420 |
|
|
421 |
while (my $ref = $sth->fetchrow_hashref()) { |
|
422 |
$access->{$ref->{who}} = 1; |
|
423 |
} |
|
424 |
|
|
425 |
$sth->finish(); |
|
426 |
|
|
427 |
$main::lxdebug->leave_sub(); |
|
428 |
|
|
429 |
return $access; |
|
430 |
} |
|
431 |
|
|
432 |
1; |
SL/Form.pm | ||
---|---|---|
2213 | 2213 |
$main::lxdebug->leave_sub(); |
2214 | 2214 |
} |
2215 | 2215 |
|
2216 |
sub _get_groups { |
|
2217 |
$main::lxdebug->enter_sub(); |
|
2218 |
|
|
2219 |
my ($self, $dbh, $key) = @_; |
|
2220 |
|
|
2221 |
$key ||= "all_groups"; |
|
2222 |
|
|
2223 |
my $groups = $main::auth->read_groups(); |
|
2224 |
|
|
2225 |
$self->{$key} = selectall_hashref_query($self, $dbh, $query); |
|
2226 |
|
|
2227 |
$main::lxdebug->leave_sub(); |
|
2228 |
} |
|
2229 |
|
|
2216 | 2230 |
sub get_lists { |
2217 | 2231 |
$main::lxdebug->enter_sub(); |
2218 | 2232 |
|
... | ... | |
2311 | 2325 |
$self->_get_warehouses($dbh, $params{warehouses}); |
2312 | 2326 |
} |
2313 | 2327 |
|
2328 |
if ($params{groups}) { |
|
2329 |
$self->_get_groups($dbh, $params{groups}); |
|
2330 |
} |
|
2331 |
|
|
2314 | 2332 |
$main::lxdebug->leave_sub(); |
2315 | 2333 |
} |
2316 | 2334 |
|
SL/Notes.pm | ||
---|---|---|
1 |
# Notes |
|
2 |
|
|
3 |
package Notes; |
|
4 |
|
|
5 |
use SL::Common; |
|
6 |
use SL::DBUtils; |
|
7 |
|
|
8 |
sub save { |
|
9 |
$main::lxdebug->enter_sub(); |
|
10 |
|
|
11 |
my $self = shift; |
|
12 |
my %params = @_; |
|
13 |
|
|
14 |
my $myconfig = \%main::myconfig; |
|
15 |
my $form = $main::form; |
|
16 |
|
|
17 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
18 |
my ($query, @values); |
|
19 |
|
|
20 |
if (!$params{id}) { |
|
21 |
($params{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('note_id')|); |
|
22 |
$query = qq|INSERT INTO notes (created_by, trans_id, trans_module, subject, body, id) |
|
23 |
VALUES ((SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|; |
|
24 |
push @values, $form->{login}, conv_i($params{trans_id}), $params{trans_module}; |
|
25 |
|
|
26 |
} else { |
|
27 |
$query = qq|UPDATE notes SET subject = ?, body = ? WHERE id = ?|; |
|
28 |
} |
|
29 |
|
|
30 |
push @values, $params{subject}, $params{body}, conv_i($params{id}); |
|
31 |
|
|
32 |
do_query($form, $dbh, $query, @values); |
|
33 |
|
|
34 |
$dbh->commit() unless ($params{dbh}); |
|
35 |
|
|
36 |
$main::lxdebug->leave_sub(); |
|
37 |
|
|
38 |
return $params{id}; |
|
39 |
} |
|
40 |
|
|
41 |
sub retrieve { |
|
42 |
$main::lxdebug->enter_sub(); |
|
43 |
|
|
44 |
my $self = shift; |
|
45 |
my %params = @_; |
|
46 |
|
|
47 |
Common::check_params(\%params, qw(id)); |
|
48 |
|
|
49 |
my $myconfig = \%main::myconfig; |
|
50 |
my $form = $main::form; |
|
51 |
|
|
52 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
53 |
|
|
54 |
my $ref = selectfirst_hashref_query($form, $dbh, qq|SELECT * FROM notes WHERE id = ?|, conv_i($param{id})); |
|
55 |
|
|
56 |
$main::lxdebug->leave_sub(); |
|
57 |
|
|
58 |
return $ref; |
|
59 |
} |
|
60 |
|
|
61 |
sub delete { |
|
62 |
$main::lxdebug->enter_sub(); |
|
63 |
|
|
64 |
my $self = shift; |
|
65 |
my %params = @_; |
|
66 |
|
|
67 |
Common::check_params(\%params, qw(id)); |
|
68 |
|
|
69 |
my $myconfig = \%main::myconfig; |
|
70 |
my $form = $main::form; |
|
71 |
|
|
72 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
73 |
my $id = conv_i($params{id}); |
|
74 |
|
|
75 |
do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id IN (SELECT DISTINCT id FROM follow_ups WHERE note_id = ?)|, $id); |
|
76 |
do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE note_id = ?|, $id); |
|
77 |
do_query($form, $dbh, qq|DELETE FROM notes WHERE id = ?|, $id); |
|
78 |
|
|
79 |
$dbh->commit() unless ($params{dbh}); |
|
80 |
|
|
81 |
$main::lxdebug->leave_sub(); |
|
82 |
|
|
83 |
return $ref; |
|
84 |
} |
|
85 |
|
|
86 |
1; |
SL/OE.pm | ||
---|---|---|
184 | 184 |
$main::lxdebug->leave_sub(); |
185 | 185 |
} |
186 | 186 |
|
187 |
sub transactions_for_todo_list { |
|
188 |
$main::lxdebug->enter_sub(); |
|
189 |
|
|
190 |
my $self = shift; |
|
191 |
my %params = @_; |
|
192 |
|
|
193 |
my $myconfig = \%main::myconfig; |
|
194 |
my $form = $main::form; |
|
195 |
|
|
196 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
197 |
|
|
198 |
my $query = qq|SELECT id FROM employee WHERE login = ?|; |
|
199 |
my ($e_id) = selectrow_query($form, $dbh, $query, $form->{login}); |
|
200 |
|
|
201 |
$query = |
|
202 |
qq|SELECT oe.id, oe.transdate, oe.reqdate, oe.quonumber, oe.transaction_description, oe.amount, |
|
203 |
c.name AS customer, |
|
204 |
e.name AS employee |
|
205 |
FROM oe |
|
206 |
LEFT JOIN customer c ON (oe.customer_id = c.id) |
|
207 |
LEFT JOIN employee e ON (oe.employee_id = e.id) |
|
208 |
WHERE (COALESCE(quotation, FALSE) = TRUE) |
|
209 |
AND (COALESCE(closed, FALSE) = FALSE) |
|
210 |
AND ((oe.employee_id = ?) OR (oe.salesman_id = ?)) |
|
211 |
AND NOT (oe.reqdate ISNULL) |
|
212 |
AND (oe.reqdate < current_date) |
|
213 |
ORDER BY transdate|; |
|
214 |
|
|
215 |
my $quotations = selectall_hashref_query($form, $dbh, $query, $e_id, $e_id); |
|
216 |
|
|
217 |
$main::lxdebug->leave_sub(); |
|
218 |
|
|
219 |
return $quotations; |
|
220 |
} |
|
221 |
|
|
187 | 222 |
sub save { |
188 | 223 |
$main::lxdebug->enter_sub(); |
189 | 224 |
|
bin/mozilla/ap.pl | ||
---|---|---|
32 | 32 |
#====================================================================== |
33 | 33 |
|
34 | 34 |
use POSIX qw(strftime); |
35 |
use List::Util qw(sum); |
|
35 | 36 |
|
36 | 37 |
use SL::AP; |
38 |
use SL::FU; |
|
37 | 39 |
use SL::IR; |
38 | 40 |
use SL::IS; |
39 | 41 |
use SL::PE; |
... | ... | |
387 | 389 |
$button2 = |
388 | 390 |
qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>|; |
389 | 391 |
} |
392 |
|
|
393 |
my $follow_up_vc = $form->{vendor}; |
|
394 |
$follow_up_vc =~ s/--.*?//; |
|
395 |
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; |
|
396 |
|
|
390 | 397 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|; |
391 | 398 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|; |
399 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/follow_up.js"></script>|; |
|
392 | 400 |
|
393 | 401 |
$form->header; |
394 | 402 |
$onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; |
... | ... | |
404 | 412 |
<input type=hidden name=locked value=$form->{locked}> |
405 | 413 |
<input type=hidden name=title value="$title"> |
406 | 414 |
|
415 |
<input type="hidden" name="follow_up_trans_id_1" value="| . H($form->{id}) . qq|"> |
|
416 |
<input type="hidden" name="follow_up_trans_type_1" value="ap_transaction"> |
|
417 |
<input type="hidden" name="follow_up_trans_info_1" value="| . H($follow_up_trans_info) . qq|"> |
|
418 |
<input type="hidden" name="follow_up_rowcount" value="1"> |
|
419 |
|
|
407 | 420 |
| . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq| |
408 | 421 |
|
409 | 422 |
<table width=100%> |
... | ... | |
753 | 766 |
|
754 | 767 |
$auth->assert('general_ledger'); |
755 | 768 |
|
769 |
my $follow_ups_block; |
|
770 |
if ($form->{id}) { |
|
771 |
my $follow_ups = FU->follow_ups('trans_id' => $form->{id}); |
|
772 |
|
|
773 |
if (@{ $follow_ups} ) { |
|
774 |
my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups }; |
|
775 |
$follow_ups_block = qq|<p>| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</p>|; |
|
776 |
} |
|
777 |
} |
|
778 |
|
|
756 | 779 |
print qq| |
757 | 780 |
|
781 |
$follow_ups_block |
|
782 |
|
|
758 | 783 |
<input name=callback type=hidden value="$form->{callback}"> |
759 | 784 |
<input name="gldate" type="hidden" value="| . Q($form->{gldate}) . qq|"> |
760 | 785 |
| |
... | ... | |
792 | 817 |
|
793 | 818 |
print qq| <input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|"> |
794 | 819 |
<input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|"> |
820 |
<input type="button" class="submit" onclick="follow_up_window()" value="| . $locale->text('Follow-Up') . qq|"> |
|
795 | 821 |
|; |
796 | 822 |
} elsif (($transdate > $closedto) && !$form->{id}) { |
797 | 823 |
print qq| |
bin/mozilla/ar.pl | ||
---|---|---|
32 | 32 |
#====================================================================== |
33 | 33 |
|
34 | 34 |
use POSIX qw(strftime); |
35 |
use List::Util qw(sum); |
|
35 | 36 |
|
36 | 37 |
use SL::AR; |
38 |
use SL::FU; |
|
37 | 39 |
use SL::IS; |
38 | 40 |
use SL::PE; |
39 | 41 |
use SL::ReportGenerator; |
... | ... | |
431 | 433 |
qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"></td>|; |
432 | 434 |
} |
433 | 435 |
|
436 |
my $follow_up_vc = $form->{customer}; |
|
437 |
$follow_up_vc =~ s/--.*?//; |
|
438 |
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; |
|
439 |
|
|
434 | 440 |
$form->{javascript} .= |
435 | 441 |
qq|<script type="text/javascript" src="js/common.js"></script>| . |
436 |
qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|; |
|
442 |
qq|<script type="text/javascript" src="js/show_vc_details.js"></script>| . |
|
443 |
qq|<script type="text/javascript" src="js/follow_up.js"></script>|; |
|
437 | 444 |
|
438 | 445 |
$form->header; |
439 | 446 |
$onload = qq|focus()|; |
... | ... | |
449 | 456 |
<input type=hidden name=closedto value=$form->{closedto}> |
450 | 457 |
<input type=hidden name=locked value=$form->{locked}> |
451 | 458 |
<input type=hidden name=title value="$title"> |
459 |
<input type="hidden" name="follow_up_trans_id_1" value="| . H($form->{id}) . qq|"> |
|
460 |
<input type="hidden" name="follow_up_trans_type_1" value="ar_transaction"> |
|
461 |
<input type="hidden" name="follow_up_trans_info_1" value="| . H($follow_up_trans_info) . qq|"> |
|
462 |
<input type="hidden" name="follow_up_rowcount" value="1"> |
|
452 | 463 |
|
453 | 464 |
| . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq| |
454 | 465 |
|
... | ... | |
800 | 811 |
|
801 | 812 |
my ($transdate, $closedto); |
802 | 813 |
|
814 |
my $follow_ups_block; |
|
815 |
if ($form->{id}) { |
|
816 |
my $follow_ups = FU->follow_ups('trans_id' => $form->{id}); |
|
817 |
|
|
818 |
if (@{ $follow_ups} ) { |
|
819 |
my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups }; |
|
820 |
$follow_ups_block = qq|<p>| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</p>|; |
|
821 |
} |
|
822 |
} |
|
823 |
|
|
803 | 824 |
print qq| |
804 | 825 |
|
826 |
$follow_ups_block |
|
827 |
|
|
805 | 828 |
<input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|"> |
806 | 829 |
|
807 | 830 |
<input name=callback type=hidden value="$form->{callback}"> |
... | ... | |
842 | 865 |
<input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|"> |; |
843 | 866 |
} |
844 | 867 |
print qq| |
845 |
<input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|"> |; |
|
868 |
<input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|"> |
|
869 |
<input type="button" class="submit" onclick="follow_up_window()" value="| |
|
870 |
. $locale->text('Follow-Up') |
|
871 |
. qq|"> |; |
|
846 | 872 |
|
847 | 873 |
} else { |
848 | 874 |
if ($transdate > $closedto) { |
bin/mozilla/ct.pl | ||
---|---|---|
267 | 267 |
|
268 | 268 |
$auth->assert('customer_vendor_edit'); |
269 | 269 |
|
270 |
$form->get_lists("employees" => "ALL_SALESMEN",
|
|
270 |
$form->get_lists("employees" => "ALL_EMPLOYEES",
|
|
271 | 271 |
"taxzones" => "ALL_TAXZONES"); |
272 | 272 |
$form->get_pricegroup(\%myconfig, { all => 1 }); |
273 | 273 |
|
274 |
$form->{ALL_SALESMEN} = $form->{ALL_EMPLOYEES}; |
|
274 | 275 |
$form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; |
275 | 276 |
$form->{is_admin} = $myconfig{role} eq 'admin'; |
276 | 277 |
$form->{is_customer} = $form->{db} eq 'customer'; |
... | ... | |
295 | 296 |
map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT); |
296 | 297 |
## /LINET |
297 | 298 |
|
299 |
$form->{NOTES} ||= [ ]; |
|
300 |
|
|
298 | 301 |
$form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'CT', 'trans_id' => $form->{id}); |
299 | 302 |
|
300 | 303 |
CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}) if (scalar @{ $form->{CUSTOM_VARIABLES} }); |
301 | 304 |
|
302 |
$main::lxdebug->dump(0, "cvar", $form->{CUSTOM_VARIABLES}); |
|
303 |
|
|
304 | 305 |
$form->header; |
305 | 306 |
print $form->parse_html_template('ct/form_header'); |
306 | 307 |
|
bin/mozilla/fu.pl | ||
---|---|---|
1 |
use POSIX qw(strftime); |
|
2 |
|
|
3 |
use SL::FU; |
|
4 |
use SL::ReportGenerator; |
|
5 |
|
|
6 |
require "bin/mozilla/reportgenerator.pl"; |
|
7 |
|
|
8 |
sub _collect_links { |
|
9 |
$lxdebug->enter_sub(); |
|
10 |
|
|
11 |
my $dest = shift; |
|
12 |
|
|
13 |
$dest->{LINKS} = []; |
|
14 |
|
|
15 |
foreach my $i (1 .. $form->{trans_rowcount}) { |
|
16 |
next if (!$form->{"trans_id_$i"} || !$form->{"trans_type_$i"}); |
|
17 |
|
|
18 |
push @{ $dest->{LINKS} }, { map { +"trans_$_" => $form->{"trans_${_}_$i"} } qw(id type info) }; |
|
19 |
} |
|
20 |
|
|
21 |
$lxdebug->leave_sub(); |
|
22 |
} |
|
23 |
|
|
24 |
sub add { |
|
25 |
$lxdebug->enter_sub(); |
|
26 |
|
|
27 |
_collect_links($form); |
|
28 |
|
|
29 |
$form->get_employee($form->get_standard_dbh(\%myconfig)); |
|
30 |
$form->{created_for_user} = $form->{employee_id}; |
|
31 |
|
|
32 |
my $link_details; |
|
33 |
|
|
34 |
if (0 < scalar @{ $form->{LINKS} }) { |
|
35 |
$link_details = FU->link_details(%{ $form->{LINKS}->[0] }); |
|
36 |
} |
|
37 |
|
|
38 |
if ($link_details && $link_details->{title}) { |
|
39 |
$form->{title} = $locale->text('Add Follow-Up for #1', $link_details->{title}); |
|
40 |
} else { |
|
41 |
$form->{title} = $locale->text('Add Follow-Up'); |
|
42 |
} |
|
43 |
|
|
44 |
display_form(); |
|
45 |
|
|
46 |
$lxdebug->leave_sub(); |
|
47 |
} |
|
48 |
|
|
49 |
sub edit { |
|
50 |
$lxdebug->enter_sub(); |
|
51 |
|
|
52 |
my $ref = FU->retrieve('id' => $form->{id}); |
|
53 |
|
|
54 |
if (!$ref) { |
|
55 |
$form->error($locale->text("Invalid follow-up ID.")); |
|
56 |
} |
|
57 |
|
|
58 |
map { $form->{$_} = $ref->{$_} } keys %{ $ref }; |
|
59 |
|
|
60 |
if (@{ $form->{LINKS} } && $form->{LINKS}->[0]->{title}) { |
|
61 |
$form->{title} = $locale->text('Edit Follow-Up for #1', $form->{LINKS}->[0]->{title}); |
|
62 |
} else { |
|
63 |
$form->{title} = $locale->text('Edit Follow-Up'); |
|
64 |
} |
|
65 |
|
|
66 |
display_form(); |
|
67 |
|
|
68 |
$lxdebug->leave_sub(); |
|
69 |
} |
|
70 |
|
|
71 |
sub display_form { |
|
72 |
$lxdebug->enter_sub(); |
|
73 |
|
|
74 |
$form->get_lists("employees" => "EMPLOYEES"); |
|
75 |
|
|
76 |
my %params; |
|
77 |
$params{not_id} = $form->{id} if ($form->{id}); |
|
78 |
$params{trans_id} = $form->{LINKS}->[0]->{trans_id} if (@{ $form->{LINKS} }); |
|
79 |
$form->{FOLLOW_UPS} = FU->follow_ups(%params); |
|
80 |
|
|
81 |
$form->{jsscript} = 1; |
|
82 |
|
|
83 |
$form->header(); |
|
84 |
print $form->parse_html_template('fu/add_edit'); |
|
85 |
|
|
86 |
$lxdebug->leave_sub(); |
|
87 |
} |
|
88 |
|
|
89 |
sub save_follow_up { |
|
90 |
$lxdebug->enter_sub(); |
|
91 |
|
|
92 |
$form->isblank('created_for_user', $locale->text('You must chose a user.')); |
|
93 |
$form->isblank('follow_up_date', $locale->text('The follow-up date is missing.')); |
|
94 |
$form->isblank('subject', $locale->text('The subject is missing.')); |
|
95 |
|
|
96 |
my %params = (map({ $_ => $form->{$_} } qw(id subject body created_for_user follow_up_date)), 'done' => 0); |
|
97 |
|
|
98 |
_collect_links(\%params); |
|
99 |
|
|
100 |
FU->save(%params); |
|
101 |
|
|
102 |
if ($form->{POPUP_MODE}) { |
|
103 |
$form->header(); |
|
104 |
print $form->parse_html_template('fu/close_window'); |
|
105 |
exit 0; |
|
106 |
} |
|
107 |
|
|
108 |
$form->{SAVED_MESSAGE} = $locale->text('Follow-Up saved.'); |
|
109 |
|
|
110 |
if ($form->{callback}) { |
|
111 |
$form->redirect(); |
|
112 |
} |
|
113 |
|
|
114 |
delete @{$form}{qw(id subject body created_for_user follow_up_date)}; |
|
115 |
|
|
116 |
map { $form->{$_} = 1 } qw(due_only all_users not_done); |
|
117 |
|
|
118 |
report(); |
|
119 |
|
|
120 |
$lxdebug->leave_sub(); |
|
121 |
} |
|
122 |
|
|
123 |
sub finish { |
|
124 |
$lxdebug->enter_sub(); |
|
125 |
|
|
126 |
if ($form->{id}) { |
|
127 |
my $ref = FU->retrieve('id' => $form->{id}); |
|
128 |
|
|
129 |
if (!$ref) { |
|
130 |
$form->error($locale->text("Invalid follow-up ID.")); |
|
131 |
} |
|
132 |
|
|
133 |
FU->finish('id' => $form->{id}); |
|
134 |
|
|
135 |
} else { |
|
136 |
foreach my $i (1..$form->{rowcount}) { |
|
137 |
next unless ($form->{"selected_$i"} && $form->{"follow_up_id_$i"}); |
|
138 |
|
|
139 |
FU->finish('id' => $form->{"follow_up_id_$i"}); |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
if ($form->{POPUP_MODE}) { |
|
144 |
$form->header(); |
|
145 |
print $form->parse_html_template('fu/close_window'); |
|
146 |
exit 0; |
|
147 |
} |
|
148 |
|
|
149 |
$form->redirect() if ($form->{callback}); |
|
150 |
|
|
151 |
report(); |
|
152 |
|
|
153 |
$lxdebug->leave_sub(); |
|
154 |
} |
|
155 |
|
|
156 |
sub delete { |
|
157 |
$lxdebug->enter_sub(); |
|
158 |
|
|
159 |
if ($form->{id}) { |
|
160 |
my $ref = FU->retrieve('id' => $form->{id}); |
|
161 |
|
|
162 |
if (!$ref) { |
|
163 |
$form->error($locale->text("Invalid follow-up ID.")); |
|
164 |
} |
|
165 |
|
|
166 |
FU->delete('id' => $form->{id}); |
|
167 |
|
|
168 |
} else { |
|
169 |
foreach my $i (1..$form->{rowcount}) { |
|
170 |
next unless ($form->{"selected_$i"} && $form->{"follow_up_id_$i"}); |
|
171 |
|
|
172 |
FU->delete('id' => $form->{"follow_up_id_$i"}); |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
if ($form->{POPUP_MODE}) { |
|
177 |
$form->header(); |
|
178 |
print $form->parse_html_template('fu/close_window'); |
|
179 |
exit 0; |
|
180 |
} |
|
181 |
|
|
182 |
$form->redirect() if ($form->{callback}); |
|
183 |
|
|
184 |
report(); |
|
185 |
|
|
186 |
$lxdebug->leave_sub(); |
|
187 |
} |
|
188 |
|
|
189 |
sub search { |
|
190 |
$lxdebug->enter_sub(); |
|
191 |
|
|
192 |
$form->get_lists("employees" => "EMPLOYEES"); |
|
193 |
|
|
194 |
$form->{jsscript} = 1; |
|
195 |
$form->{title} = $locale->text('Follow-Ups'); |
|
196 |
|
|
197 |
$form->header(); |
|
198 |
print $form->parse_html_template('fu/search'); |
|
199 |
|
|
200 |
$lxdebug->leave_sub(); |
|
201 |
} |
|
202 |
|
|
203 |
sub report { |
|
204 |
$lxdebug->enter_sub(); |
|
205 |
|
|
206 |
my @report_params = qw(created_for subject body reference follow_up_date_from follow_up_date_to itime_from itime_to due_only all_users done not_done); |
|
207 |
|
|
208 |
my $follow_ups = FU->follow_ups(map { $_ => $form->{$_} } @report_params); |
|
209 |
$form->{rowcount} = scalar @{ $follow_ups }; |
|
210 |
|
|
211 |
$form->{title} = $locale->text('Follow-Ups'); |
|
212 |
|
|
213 |
my %column_defs = ( |
|
214 |
'selected' => { 'text' => '', }, |
|
215 |
'follow_up_date' => { 'text' => $locale->text('Follow-Up Date'), }, |
|
216 |
'created_on' => { 'text' => $locale->text('Created on'), }, |
|
217 |
'title' => { 'text' => $locale->text('Reference'), }, |
|
218 |
'subject' => { 'text' => $locale->text('Subject'), }, |
|
219 |
'created_by_name' => { 'text' => $locale->text('Created by'), }, |
|
220 |
'created_for_user_name' => { 'text' => $locale->text('Follow-up for'), }, |
|
221 |
'done' => { 'text' => $locale->text('Done'), 'visible' => $form->{done} && $form->{not_done} ? 1 : 0 }, |
|
222 |
); |
|
223 |
|
|
224 |
my @columns = qw(selected follow_up_date created_on subject title created_by_name created_for_user_name done); |
|
225 |
|
|
226 |
my @options; |
|
227 |
|
|
228 |
if ($form->{created_for}) { |
|
229 |
$form->get_lists("employees" => "EMPLOYEES"); |
|
230 |
|
|
231 |
foreach my $employee (@{ $form->{EMPLOYEES} }) { |
|
232 |
if ($employee->{id} == $form->{created_for}) { |
|
233 |
push @options, $locale->text('Created for') . " : " . ($employee->{name} ? "$employee->{name} ($employee->{login})" : $employee->{login}); |
|
234 |
last; |
|
235 |
} |
|
236 |
} |
|
237 |
} |
|
238 |
|
|
239 |
push @options, $locale->text('Subject') . " : $form->{subject}" if ($form->{subject}); |
|
240 |
push @options, $locale->text('Body') . " : $form->{body}" if ($form->{body}); |
|
241 |
push @options, $locale->text('Reference') . " : $form->{reference}" if ($form->{reference}); |
|
242 |
push @options, $locale->text('Done') if ($form->{done}); |
|
243 |
push @options, $locale->text('Not done yet') if ($form->{not_done}); |
|
244 |
push @options, $locale->text('Only due follow-ups') if ($form->{due_only}); |
|
245 |
push @options, $locale->text("Other users' follow-ups") if ($form->{all_users}); |
|
246 |
|
|
247 |
my @hidden_report_params = map { +{ 'key' => $_, 'value' => $form->{$_} } } @report_params; |
|
248 |
|
|
249 |
my $report = SL::ReportGenerator->new(\%myconfig, $form, 'std_column_visibility' => 1); |
|
250 |
|
|
251 |
$report->set_columns(%column_defs); |
|
252 |
$report->set_column_order(@columns); |
|
253 |
|
|
254 |
$report->set_export_options('report', @report_params); |
|
255 |
|
|
256 |
$report->set_sort_indicator('follow_up_date', 1); |
|
257 |
|
|
258 |
$report->set_options('raw_top_info_text' => $form->parse_html_template('fu/report_top', { 'OPTIONS' => \@options }), |
|
259 |
'raw_bottom_info_text' => $form->parse_html_template('fu/report_bottom', { 'HIDDEN' => \@hidden_report_params }), |
|
260 |
'output_format' => 'HTML', |
|
261 |
'title' => $form->{title}, |
|
262 |
'attachment_basename' => $locale->text('follow_up_list') . strftime('_%Y%m%d', localtime time), |
|
263 |
); |
|
264 |
$report->set_options_from_form(); |
|
265 |
|
|
266 |
my $idx = 0; |
|
267 |
my $callback = build_std_url('action=report', grep { $form->{$_} } @report_params); |
|
268 |
my $edit_url = build_std_url('action=edit', 'callback=' . E($callback)); |
|
269 |
|
|
270 |
foreach my $fu (@{ $follow_ups }) { |
|
271 |
$idx++; |
|
272 |
|
|
273 |
$fu->{done} = $fu->{done} ? $locale->text('Yes') : $locale->text('No'); |
|
274 |
|
|
275 |
my $row = { map { $_ => { 'data' => $fu->{$_} } } keys %{ $fu } }; |
|
276 |
|
|
277 |
$row->{selected} = { |
|
278 |
'raw_data' => $cgi->hidden('-name' => "follow_up_id_${idx}", '-value' => $fu->{id}) |
|
279 |
. $cgi->checkbox('-name' => "selected_${idx}", '-value' => 1, '-label' => ''), |
|
280 |
'valign' => 'center', |
|
281 |
'align' => 'center', |
|
282 |
}; |
|
283 |
|
|
284 |
if (@{ $fu->{LINKS} }) { |
|
285 |
my $link = $fu->{LINKS}->[0]; |
|
286 |
|
|
287 |
$row->{title}->{data} = $link->{title}; |
|
288 |
$row->{title}->{link} = $link->{url}; |
|
289 |
} |
|
290 |
|
|
291 |
$row->{subject}->{link} = $edit_url . '&id=' . Q($fu->{id}); |
|
292 |
|
|
293 |
$report->add_data($row); |
|
294 |
} |
|
295 |
|
|
296 |
$report->generate_with_headers(); |
|
297 |
|
|
298 |
$lxdebug->leave_sub(); |
|
299 |
} |
|
300 |
|
|
301 |
sub report_for_todo_list { |
|
302 |
$lxdebug->enter_sub(); |
|
303 |
|
|
304 |
my @report_params = qw(created_for subject body reference follow_up_date_from follow_up_date_to itime_from itime_to due_only all_users done not_done); |
|
305 |
|
|
306 |
my %params = ( |
|
307 |
'due_only' => 1, |
|
308 |
'not_done' => 1, |
|
309 |
'created_for_login' => $form->{login}, |
|
310 |
); |
|
311 |
|
|
312 |
my $follow_ups = FU->follow_ups(%params); |
|
313 |
my $content; |
|
314 |
|
|
315 |
if (@{ $follow_ups }) { |
|
316 |
my $callback = build_std_url('action'); |
|
317 |
my $edit_url = build_std_url('script=fu.pl', 'action=edit', 'callback=' . E($callback)) . '&id='; |
|
318 |
|
|
319 |
foreach my $fu (@{ $follow_ups }) { |
|
320 |
if (@{ $fu->{LINKS} }) { |
|
321 |
my $link = $fu->{LINKS}->[0]; |
|
322 |
|
|
323 |
$fu->{reference} = $link->{title}; |
|
324 |
$fu->{reference_link} = $link->{url}; |
|
325 |
} |
|
326 |
} |
|
327 |
|
|
328 |
$content = $form->parse_html_template('fu/report_for_todo_list', { 'FOLLOW_UPS' => $follow_ups, |
|
329 |
'callback' => $callback, |
|
330 |
'edit_url' => $edit_url, }); |
|
331 |
} |
|
332 |
|
|
333 |
$lxdebug->leave_sub(); |
|
334 |
|
|
335 |
return $content; |
|
336 |
} |
|
337 |
|
|
338 |
sub edit_access_rights { |
|
339 |
$lxdebug->enter_sub(); |
|
340 |
|
|
341 |
my $access = FU->retrieve_access_rights(); |
|
342 |
|
|
343 |
$form->get_lists("employees" => "EMPLOYEES"); |
|
344 |
|
|
345 |
map { $_->{access} = $access->{$_->{id}} } @{ $form->{EMPLOYEES} }; |
|
346 |
|
|
347 |
$form->{title} = $locale->text('Edit Access Rights for Follow-Ups'); |
|
348 |
|
|
349 |
$form->header(); |
|
350 |
print $form->parse_html_template('fu/edit_access_rights'); |
|
351 |
|
|
352 |
$lxdebug->leave_sub(); |
|
353 |
} |
|
354 |
|
|
355 |
sub save_access_rights { |
|
356 |
$lxdebug->enter_sub(); |
|
357 |
|
|
358 |
my %access; |
|
359 |
|
|
360 |
foreach my $i (1 .. $form->{rowcount}) { |
|
361 |
my $id = $form->{"employee_id_$i"}; |
|
362 |
|
|
363 |
$access{$id} = 1 if ($id && $form->{"access_$id"}); |
|
364 |
} |
|
365 |
|
|
366 |
FU->save_access_rights('access' => \%access); |
|
367 |
|
|
368 |
$form->{SAVED_MESSAGE} = $locale->text('The access rights have been saved.'); |
|
369 |
edit_access_rights(); |
|
370 |
|
|
371 |
$lxdebug->leave_sub(); |
|
372 |
} |
|
373 |
|
|
374 |
sub update { |
|
375 |
call_sub($form->{nextsub}); |
|
376 |
} |
|
377 |
|
|
378 |
sub continue { |
|
379 |
call_sub($form->{nextsub}); |
|
380 |
} |
|
381 |
|
|
382 |
sub save { |
|
383 |
if ($form->{save_nextsub}) { |
|
384 |
call_sub($form->{save_nextsub}); |
|
385 |
} else { |
|
386 |
save_follow_up(); |
|
387 |
} |
|
388 |
} |
|
389 |
|
|
390 |
sub dispatcher { |
|
391 |
foreach my $action (qw(finish save delete)) { |
|
392 |
if ($form->{"action_${action}"}) { |
|
393 |
call_sub($action); |
|
394 |
return; |
|
395 |
} |
|
396 |
} |
|
397 |
|
|
398 |
call_sub($form->{default_action}) if ($form->{default_action}); |
|
399 |
|
|
400 |
$form->error($locale->text('No action defined.')); |
|
401 |
} |
|
402 |
|
|
403 |
1; |
bin/mozilla/gl.pl | ||
---|---|---|
32 | 32 |
#====================================================================== |
33 | 33 |
|
34 | 34 |
use POSIX qw(strftime); |
35 |
use List::Util qw(sum); |
|
35 | 36 |
|
37 |
use SL::FU; |
|
36 | 38 |
use SL::GL; |
37 | 39 |
use SL::IS; |
38 | 40 |
use SL::PE; |
... | ... | |
1068 | 1070 |
print qq| |
1069 | 1071 |
<body onLoad="fokus()"> |
1070 | 1072 |
|
1073 |
<script type="text/javascript" src="js/common.js"></script> |
|
1074 |
<script type="text/javascript" src="js/follow_up.js"></script> |
|
1075 |
|
|
1071 | 1076 |
<form method=post name="gl" action=gl.pl> |
1072 | 1077 |
|; |
1073 | 1078 |
|
... | ... | |
1076 | 1081 |
print qq| |
1077 | 1082 |
<input type=hidden name=title value="$title"> |
1078 | 1083 |
|
1084 |
<input type="hidden" name="follow_up_trans_id_1" value="| . H($form->{id}) . qq|"> |
|
1085 |
<input type="hidden" name="follow_up_trans_type_1" value="gl_transaction"> |
|
1086 |
<input type="hidden" name="follow_up_trans_info_1" value="| . H($form->{id}) . qq|"> |
|
1087 |
<input type="hidden" name="follow_up_rowcount" value="1"> |
|
1079 | 1088 |
|
1080 | 1089 |
<table width=100%> |
1081 | 1090 |
<tr> |
... | ... | |
1205 | 1214 |
|
1206 | 1215 |
$auth->assert('general_ledger'); |
1207 | 1216 |
|
1217 |
my $follow_ups_block; |
|
1218 |
if ($form->{id}) { |
|
1219 |
my $follow_ups = FU->follow_ups('trans_id' => $form->{id}); |
|
1220 |
|
|
1221 |
if (@{ $follow_ups} ) { |
|
1222 |
my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups }; |
|
1223 |
$follow_ups_block = qq|<p>| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</p>|; |
|
1224 |
} |
|
1225 |
} |
|
1226 |
|
|
1208 | 1227 |
($dec) = ($form->{totaldebit} =~ /\.(\d+)/); |
1209 | 1228 |
$dec = length $dec; |
1210 | 1229 |
$decimalplaces = ($dec > 2) ? $dec : 2; |
... | ... | |
1228 | 1247 |
|
1229 | 1248 |
<input name=callback type=hidden value="$form->{callback}"> |
1230 | 1249 |
|
1250 |
$follow_ups_block |
|
1251 |
|
|
1231 | 1252 |
<br> |
1232 | 1253 |
|; |
1233 | 1254 |
|
... | ... | |
1247 | 1268 |
<input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">|; |
1248 | 1269 |
} |
1249 | 1270 |
|
1271 |
print qq| |
|
1272 |
<input type="button" class="submit" onclick="follow_up_window()" value="| |
|
1273 |
. $locale->text('Follow-Up') |
|
1274 |
. qq|"> |; |
|
1275 |
|
|
1250 | 1276 |
} else { |
1251 | 1277 |
if ($transdate > $closedto) { |
1252 | 1278 |
print qq| |
bin/mozilla/ir.pl | ||
---|---|---|
31 | 31 |
# |
32 | 32 |
#====================================================================== |
33 | 33 |
|
34 |
use SL::FU; |
|
34 | 35 |
use SL::IR; |
35 | 36 |
use SL::IS; |
36 | 37 |
use SL::PE; |
37 |
use List::Util qw(max); |
|
38 |
use List::Util qw(max sum);
|
|
38 | 39 |
|
39 | 40 |
require "bin/mozilla/io.pl"; |
40 | 41 |
require "bin/mozilla/invoice_io.pl"; |
... | ... | |
400 | 401 |
"invdate", "BL", "trigger1", |
401 | 402 |
"duedate", "BL", "trigger2"); |
402 | 403 |
|
404 |
my $follow_up_vc = $form->{vendor}; |
|
405 |
$follow_up_vc =~ s/--.*?//; |
|
406 |
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; |
|
407 |
|
|
403 | 408 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|; |
404 | 409 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|; |
405 | 410 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|; |
411 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/follow_up.js"></script>|; |
|
406 | 412 |
|
407 | 413 |
$jsscript .= $form->write_trigger(\%myconfig, 2, "orddate", "BL", "trigger_orddate", "quodate", "BL", "trigger_quodate"); |
408 | 414 |
|
... | ... | |
608 | 614 |
$form->{invtotal} = |
609 | 615 |
$form->format_amount(\%myconfig, $form->{invtotal}, 2, 0); |
610 | 616 |
|
617 |
my $follow_ups_block; |
|
618 |
if ($form->{id}) { |
|
619 |
my $follow_ups = FU->follow_ups('trans_id' => $form->{id}); |
|
620 |
|
|
621 |
if (@{ $follow_ups} ) { |
|
622 |
my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups }; |
|
623 |
$follow_ups_block = qq| |
|
624 |
<tr> |
|
625 |
<td colspan="2">| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</td> |
|
626 |
</tr> |
|
627 |
|; |
|
628 |
} |
Auch abrufbar als: Unified diff
Zwei neue Features:
1. Beliebige Notizen für Kunden und Lieferanten können angelegt werden. Solche Notizen können auf Wiedervorlage gelegt werden, was durch 2. implementiert ist.
2. Einkaufs- und Verkaufsbelege können auf Wiedervorlage gelegt werden. Wiedervorlagen können für beliebige Nutzer erstellt werden (Aufgabe an andere Nutzer deligieren). Anstehende Wiedervorlagen und abgelaufene Angebote werden auf der Startseite in einer Aufgabenliste angezeigt.