#===================================================================== # LedgerSMB # Small Medium Business Accounting software # # See COPYRIGHT file for copyright information #====================================================================== # # This file has NOT undergone whitespace cleanup. # #====================================================================== # # Job Costing module # #====================================================================== use LedgerSMB::JC; 1; # end of main sub add { if ($form->{type} eq 'timecard') { $form->{title} = $locale->text('Add Time Card'); } if ($form->{type} eq 'storescard') { $form->{title} = $locale->text('Add Stores Card'); } $form->{callback} = "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&path=$form->{path}&sessionid=$form->{sessionid}&project=$form->{project}" unless $form->{callback}; &{ "prepare_$form->{type}" }; $form->{orphaned} = 1; &display_form; } sub edit { if ($form->{type} eq 'timecard') { $form->{title} = $locale->text('Edit Time Card'); } if ($form->{type} eq 'storescard') { $form->{title} = $locale->text('Add Stores Card'); } &{ "prepare_$form->{type}" }; &display_form; } sub jcitems_links { if (@{ $form->{all_project} }) { $form->{selectprojectnumber} = "\n"; foreach $ref (@{ $form->{all_project} }) { $form->{selectprojectnumber} .= qq|$ref->{projectnumber}\n|; if ($form->{projectnumber} eq "$ref->{projectnumber}--$ref->{id}") { $form->{projectdescription} = $ref->{description}; } } } else { if ($form->{project} eq 'job') { $form->error($locale->text('No open Jobs!')); } else { $form->error($locale->text('No open Projects!')); } } if (@{ $form->{all_parts} }) { $form->{selectpartnumber} = "\n"; foreach $ref (@{ $form->{all_parts} }) { $form->{selectpartnumber} .= qq|$ref->{partnumber}\n|; if ($form->{partnumber} eq "$ref->{partnumber}--$ref->{id}") { if ($form->{partnumber} ne $form->{oldpartnumber}) { for (qw(description unit sellprice pricematrix)) { $form->{$_} = $ref->{$_} } } } } } else { if ($form->{type} eq 'timecard') { if ($form->{project} eq 'job') { $form->error($locale->text('No Labor codes on file!')); } else { $form->error($locale->text('No Services on file!')); } } else { $form->error($locale->text('No Parts on file!')); } } # employees if (@{ $form->{all_employee} }) { $form->{selectemployee} = "\n"; for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|$_->{name}\n| } } else { $form->error($locale->text('No Employees on file!')); } } sub search { # accounting years $form->all_years(\%myconfig); if (@{ $form->{all_years} }) { $form->{selectaccountingyear} = "\n"; for (@{ $form->{all_years} }) { $form->{selectaccountingyear} .= qq|$_\n| } $form->{selectaccountingmonth} = "\n"; for (sort keys %{ $form->{all_month} }) { $form->{selectaccountingmonth} .= qq||.$locale->text($form->{all_month}{$_}).qq|\n| } $selectfrom = qq| |.$locale->text('Period').qq| $form->{selectaccountingmonth} $form->{selectaccountingyear} |.$locale->text('Current').qq| |.$locale->text('Month').qq| |.$locale->text('Quarter').qq| |.$locale->text('Year').qq| |; } $fromto = qq| |.$locale->text('Startdate').qq| |.$locale->text('From').qq| |.$locale->text('To').qq| $selectfrom |; if ($form->{type} eq 'timecard') { $form->{title} = $locale->text('Time Cards'); JC->jcitems_links(\%myconfig, \%$form); } if ($form->{type} eq 'storescard') { $form->{title} = $locale->text('Stores Cards'); JC->jcitems_links(\%myconfig, \%$form); } if (@{ $form->{all_project} }) { $form->{selectprojectnumber} = "\n"; for (@{ $form->{all_project} }) { $form->{selectprojectnumber} .= qq|$_->{projectnumber}\n| } } if (@{ $form->{all_parts} }) { $form->{selectpartnumber} = "\n"; foreach $ref (@{ $form->{all_parts} }) { $form->{selectpartnumber} .= qq|$ref->{partnumber}\n|; } } if ($form->{project} eq 'job') { $joblabel = $locale->text('Job Number'); $laborlabel = $locale->text('Labor Code'); } elsif ($form->{project} eq 'project') { $joblabel = $locale->text('Project Number'); $laborlabel = $locale->text('Service Code'); } else { $joblabel = $locale->text('Project/Job Number'); $laborlabel = $locale->text('Service/Labor Code'); } if ($form->{selectprojectnumber}) { $jobnumber = qq| $joblabel $form->{selectprojectnumber} |; } if ($form->{type} eq 'timecard') { # employees if (@{ $form->{all_employee} }) { $form->{selectemployee} = "\n"; for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|$_->{name}\n| } } else { $form->error($locale->text('No Employees on file!')); } if ($form->{selectpartnumber}) { $partnumber = qq| $laborlabel $form->{selectpartnumber} |; } $employee = qq| |.$locale->text('Employee').qq| $form->{selectemployee} |; $l_time = qq| |.$locale->text('Time').qq||; } $form->header; print qq| {script}> $form->{title} $jobnumber $partnumber $employee $fromto |.$locale->text('Include in Report').qq| |.$locale->text('Open').qq| |.$locale->text('Closed').qq| $l_time |.$locale->text('Allocated').qq| |.$locale->text('Subtotal').qq| |; $form->hide_form(qw(db path login sessionid project type)); print qq| |; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|