# need the current dbh to get the not yet committed mtime
$form->new_lastmtime('ar', $provided_dbh);
- $form->{name} = $form->{customer};
- $form->{name} =~ s/--\Q$form->{customer_id}\E//;
-
# add shipto
if (!$form->{shipto_id}) {
$form->add_shipto($dbh, $form->{id}, "AR");
use SL::IR;
use SL::IS;
use SL::DB::Default;
+use SL::DB::Department;
use SL::DB::PurchaseInvoice;
use List::Util qw(max sum);
use List::UtilsBy qw(sort_by);
$form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
}
- # departments
- if ($form->{all_departments}) {
- $form->{selectdepartment} = "<option>\n";
- $form->{department} = "$form->{department}--$form->{department_id}";
-
- map {
- $form->{selectdepartment} .=
- "<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} || [] });
- }
-
# forex
$form->{forex} = $form->{exchangerate};
my $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
my @old_project_ids = ($form->{"globalproject_id"});
map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
- $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
- "all" => 0,
- "old_id" => \@old_project_ids },
- "taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
+ $form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
"currencies" => "ALL_CURRENCIES",
"vendors" => "ALL_VENDORS",
- "departments" => "all_departments",
"price_factors" => "ALL_PRICE_FACTORS");
+ $TMPL_VAR{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
$TMPL_VAR{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{employee_id}, deleted => 0 ] ]);
$TMPL_VAR{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(query => [
or => [
]
]
]);
- $TMPL_VAR{department_labels} = sub { "$_[0]->{description}--$_[0]->{id}" };
# customer
$TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
$TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice();
$form->{duedate} = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{due_due})->to_kivitendo if $TMPL_VAR{payment_terms_obj};
- $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js));
+ $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part autocomplete_project client_js));
$form->header();
[%- USE T8 %]
[%- USE HTML %]
[%- USE LxERP %]
-[%- USE L %]
+[%- USE L %][%- USE P -%]
<h1>[% title %]</h1>
[%- SET follow_up_trans_info = invnumber _ ' (' _ vendor_name _ ')' %]
<input type='hidden' name='taxzone_id' value='[% taxzone_id %]'>
[%- END %]
</tr>
-[%- IF all_departments %]
+[%- IF ALL_DEPARTMENTS.as_list.size %]
<tr>
<th align="right" nowrap>[% 'Department' | $T8 %]</th>
- <td colspan="3">
- [%- INCLUDE 'generic/multibox.html'
- name = 'department_id',
- style = 'width: 250px',
- DATA = all_departments,
- id_key = 'id',
- label_sub = 'department_labels',
- show_empty = 1 -%]
- </td>
+ <td colspan="3">[% P.select_tag("department_id", ALL_DEPARTMENTS, with_empty=1, default=department_id, title_key="description", style="width: 250px") %]</td>
</tr>
[%- END %]
[%- IF currencies %]
</tr>
<tr>
<th align="right" nowrap>[% 'Project Number' | $T8 %]</th>
- <td>
- [%- INCLUDE 'generic/multibox.html'
- name = 'globalproject_id',
- DATA = ALL_PROJECTS,
- id_key = 'id',
- label_key = 'projectnumber',
- show_empty = 1,
- onChange = "document.getElementById('update_button').click();" -%]
- </td>
+ <td>[% P.project_picker('globalproject_id', globalproject_id) %]</td>
</tr>
</table>
</td>