#===================================================================== # LedgerSMB # Small Medium Business Accounting software # http://www.ledgersmb.org/ # # # See COPYRIGHT file for copyright information #====================================================================== # # This file has NOT undergone whitespace cleanup. # #====================================================================== # # project/job administration # partsgroup administration # translation maintainance # #====================================================================== use LedgerSMB::PE; use LedgerSMB::AA; use LedgerSMB::OE; 1; # end of main sub add { # construct callback $form->{callback} = "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; &{"prepare_$form->{type}"}; $form->{orphaned} = 1; &display_form; } sub edit { &{"prepare_$form->{type}"}; &display_form; } sub prepare_partsgroup { PE->get_partsgroup( \%myconfig, \%$form ) if $form->{id}; } sub prepare_pricegroup { PE->get_pricegroup( \%myconfig, \%$form ) if $form->{id}; } sub prepare_job { # $locale->text('Add Job') # $locale->text('Edit Job') $form->{vc} = 'customer'; PE->get_job( \%myconfig, \%$form ); $form->{taxaccounts} = ""; for ( keys %{ $form->{IC_links} } ) { $form->{"select$_"} = ""; foreach $ref ( @{ $form->{IC_links}{$_} } ) { if (/IC_tax/) { if (/taxpart/) { $form->{taxaccounts} .= "$ref->{accno} "; $form->{"IC_tax_$ref->{accno}_description"} = "$ref->{accno}--$ref->{description}"; if ( $form->{id} ) { if ( $form->{amount}{ $ref->{accno} } ) { $form->{"IC_tax_$ref->{accno}"} = "checked"; } } else { $form->{"IC_tax_$ref->{accno}"} = "checked"; } } } else { $form->{"select$_"} .= "$ref->{accno}--$ref->{description}\n"; } } } chop $form->{taxaccounts}; $form->{selectIC_income} = $form->{selectIC_sale}; $form->{IC_income} = $form->{IC_sale}; $form->{IC_income} = qq|$form->{income_accno}--$form->{income_description}|; delete $form->{IC_links}; $form->{"old$form->{vc}"} = qq|$form->{"$form->{vc}"}--$form->{"$form->{vc}_id"}|; if ( @{ $form->{"all_$form->{vc}"} } ) { $form->{"$form->{vc}"} = qq|$form->{"$form->{vc}"}--$form->{"$form->{vc}_id"}|; $form->{"select$form->{vc}"} = qq|\n|; for ( @{ $form->{"all_$form->{vc}"} } ) { $form->{"select$form->{vc}"} .= qq|$_->{name}\n|; } } $form->get_partsgroup( \%myconfig, { all => 1 } ); $form->{partsgroup} = $form->quote( $form->{partsgroup} ) . "--$form->{partsgroup_id}"; if ( @{ $form->{all_partsgroup} } ) { $form->{selectpartsgroup} = qq|\n|; for ( @{ $form->{all_partsgroup} } ) { $form->{selectpartsgroup} .= qq|$_->{partsgroup}\n|; } } $form->{locked} = ( $form->{revtrans} ) ? '1' : ( $form->datetonum( \%myconfig, $form->{transdate} ) <= $form->datetonum( \%myconfig, $form->{closedto} ) ); $form->{readonly} = 1 if $myconfig{acs} =~ /Job Costing--Add Job/; } sub job_header { for (qw(partnumber partdescription description notes unit)) { $form->{$_} = $form->quote( $form->{$_} ); } for (qw(production weight)) { $form->{$_} = $form->format_amount( \%myconfig, $form->{$_} ); } for (qw(listprice sellprice)) { $form->{$_} = $form->format_amount( \%myconfig, $form->{$_}, 2 ); } if ( ( $rows = $form->numtextrows( $form->{partdescription}, 60 ) ) > 1 ) { $partdescription = qq|$form->{partdescription}|; } else { $partdescription = qq||; } if ( ( $rows = $form->numtextrows( $form->{description}, 60 ) ) > 1 ) { $description = qq|$form->{description}|; } else { $description = qq||; } if ( ( $rows = $form->numtextrows( $form->{notes}, 40 ) ) < 2 ) { $rows = 2; } $notes = qq|$form->{notes}|; $form->{selectIC_income} = $form->unescape( $form->{selectIC_income} ); $form->{"select$form->{vc}"} = $form->unescape( $form->{"select$form->{vc}"} ); $form->{"select$form->{vc}"} =~ s/ selected//; $form->{"select$form->{vc}"} =~ s/({vc}"}\E")/$1 selected/; $label = ucfirst $form->{vc}; if ( $form->{"select$form->{vc}"} ) { $name = qq| | . $locale->text($label) . qq| $form->{"select$form->{vc}"} {vc}"}, 1 ) . qq|"> |; } else { $name = qq| | . $locale->text($label) . qq| {vc}"}" size=35> {vc}"}, 1 ) . qq|"> |; } if ( $form->{orphaned} ) { for (qw(income)) { $form->{"selectIC_$_"} =~ s/ selected//; $form->{"selectIC_$_"} =~ s/option>\Q$form->{"IC_$_"}\E/option selected>$form->{"IC_$_"}/; } $production = qq| | . $locale->text('Production') . qq| | . $locale->text('Completed') . qq| $form->{completed} |; } else { $form->{selectIC_income} = qq|$form->{IC_income}|; $production = qq| | . $locale->text('Production') . qq| $form->{production} | . $locale->text('Completed') . qq| $form->{completed} |; } for ( split / /, $form->{taxaccounts} ) { $form->{"IC_tax_$_"} = ( $form->{"IC_tax_$_"} ) ? "checked" : ""; } if ( $form->{selectpartsgroup} ) { $form->{selectpartsgroup} = $form->unescape( $form->{selectpartsgroup} ); $partsgroup = qq||; $form->{partsgroup} = $form->quote( $form->{partsgroup} ); $form->{selectpartsgroup} =~ s/($form->{selectpartsgroup}|; $group = $locale->text('Group'); } $linkaccounts = qq| | . $locale->text('Income') . qq| $form->{selectIC_income} |; for ( split / /, $form->{taxaccounts} ) { $tax .= qq| {"IC_tax_$_"}> $form->{"IC_tax_${_}_description"} |; } if ($tax) { $linkaccounts .= qq| | . $locale->text('Tax') . qq| $tax |; } $partnumber = qq| | . $locale->text('Number') . qq| | . $locale->text('Description') . qq| $group $partdescription $partsgroup |; $form->{title} = ( $form->{id} ) ? $locale->text('Edit Job') : $locale->text('Add Job'); $form->header; print qq| {script}> |; for (qw(partnumber startdate enddate)) { $form->{"old$_"} = $form->{$_} } print qq|\n|; $form->hide_form( "id", "type", "old$form->{vc}", "$form->{vc}_id", "orphaned", "taxaccounts", "vc", "project" ); print qq| $form->{title} | . $locale->text('Number') . qq| | . $locale->text('Description') . qq| $description $name | . $locale->text('Startdate') . qq| | . $locale->text('Enddate') . qq| $production | . $locale->text('Assembly') . qq| $partnumber | . $locale->text('Link Accounts') . qq| $linkaccounts | . $locale->text('Notes') . qq| $notes | . $locale->text('Updated') . qq| | . $locale->text('List Price') . qq| | . $locale->text('Sell Price') . qq| | . $locale->text('Weight') . qq| $form->{weightunit} | . $locale->text('Bin') . qq| | . $locale->text('Unit') . qq| |; } sub job_footer { $form->hide_form(qw(callback path login sessionid)); # type=submit $locale->text('Update') # type=submit $locale->text('Save') # type=submit $locale->text('Delete') %button = ( 'update' => { ndx => 1, key => 'U', value => $locale->text('Update') }, ); if ( $myconfig{acs} !~ /Job Costing--Add Job/ ) { $button{'save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; if ( $form->{id} && $form->{orphaned} ) { $button{'delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') }; } } for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) { $form->print_button( \%button, $_ ); } if ( $form->{lynx} ) { require "bin/menu.pl"; &menubar; } print qq|