summaryrefslogtreecommitdiff
path: root/t/syntax.t
blob: 7e0cfbd2d68e03efbd063db0987cd181c9786292 (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More;
  5. my @progs="ikiwiki.in";
  6. my @libs="IkiWiki.pm";
  7. # monotone and external skipped since they need a perl modules
  8. push @libs, map { chomp; $_ } `find IkiWiki -type f -name \\*.pm | grep -v IkiWiki/Rcs/monotone.pm | grep -v IkiWiki/Plugin/external.pm`;
  9. plan(tests => (@progs + @libs));
  10. foreach my $file (@progs) {
  11. ok(system("perl -T -c $file >/dev/null 2>&1") eq 0, $file);
  12. }
  13. foreach my $file (@libs) {
  14. ok(system("perl -c $file >/dev/null 2>&1") eq 0, $file);
  15. }
an>
  • #======================================================================
  • 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$_"} .= "<option>$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|<option>\n|;
  • for (@{ $form->{"all_$form->{vc}"} }) { $form->{"select$form->{vc}"} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  • }
  • $form->get_partsgroup(\%myconfig, {all => 1});
  • $form->{partsgroup} = $form->quote($form->{partsgroup})."--$form->{partsgroup_id}";
  • if (@{ $form->{all_partsgroup} }) {
  • $form->{selectpartsgroup} = qq|<option>\n|;
  • for (@{ $form->{all_partsgroup} }) { $form->{selectpartsgroup} .= qq|<option value="|.$form->quote($_->{partsgroup}).qq|--$_->{id}">$_->{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|<textarea name="partdescription" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{partdescription}</textarea>|;
  • } else {
  • $partdescription = qq|<input name=partdescription size=60 value="$form->{partdescription}">|;
  • }
  • if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
  • $description = qq|<textarea name="description" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{description}</textarea>|;
  • } else {
  • $description = qq|<input name=description size=60 value="$form->{description}">|;
  • }
  • if (($rows = $form->numtextrows($form->{notes}, 40)) < 2) {
  • $rows = 2;
  • }
  • $notes = qq|<textarea name=notes rows=$rows cols=40 wrap=soft>$form->{notes}</textarea>|;
  • $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/(<option value="\Q$form->{"$form->{vc}"}\E")/$1 selected/;
  • $label = ucfirst $form->{vc};
  • if ($form->{"select$form->{vc}"}) {
  • $name = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text($label).qq|</th>
  • <td colspan=3><select name="$form->{vc}">$form->{"select$form->{vc}"}</select></td>
  • <input type=hidden name="select$form->{vc}" value="|.
  • $form->escape($form->{"select$form->{vc}"},1).qq|">
  • </tr>
  • |;
  • } else {
  • $name = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text($label).qq|</th>
  • <td colspan=3><input name="$form->{vc}" value="$form->{"$form->{vc}"}" size=35></td>
  • <input type=hidden name="select$form->{vc}" value="|.
  • $form->escape($form->{"select$form->{vc}"},1).qq|">
  • </tr>
  • |;
  • }
  • if ($form->{orphaned}) {
  • for (qw(income)) {
  • $form->{"selectIC_$_"} =~ s/ selected//;
  • $form->{"selectIC_$_"} =~ s/option>\Q$form->{"IC_$_"}\E/option selected>$form->{"IC_$_"}/;
  • }
  • $production = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Production').qq|</th>
  • <td><input name=production size=10 value="$form->{production}"></td>
  • <th align=right nowrap>|.$locale->text('Completed').qq|</th>
  • <td>$form->{completed}</td>
  • </tr>
  • |;
  • } else {
  • $form->{selectIC_income} = qq|<option selected>$form->{IC_income}|;
  • $production = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Production').qq|</th>
  • <td><input type=hidden name=production value="$form->{production}">$form->{production}</td>
  • <th align=right nowrap>|.$locale->text('Completed').qq|</th>
  • <td>$form->{completed}</td>
  • </tr>
  • |;
  • }
  • for (split / /, $form->{taxaccounts}) { $form->{"IC_tax_$_"} = ($form->{"IC_tax_$_"}) ? "checked" : "" }
  • if ($form->{selectpartsgroup}) {
  • $form->{selectpartsgroup} = $form->unescape($form->{selectpartsgroup});
  • $partsgroup = qq|<input type=hidden name=selectpartsgroup value="|.$form->escape($form->{selectpartsgroup},1).qq|">|;
  • $form->{partsgroup} = $form->quote($form->{partsgroup});
  • $form->{selectpartsgroup} =~ s/(<option value="\Q$form->{partsgroup}\E")/$1 selected/;
  • $partsgroup .= qq|\n<select name=partsgroup>$form->{selectpartsgroup}</select>|;
  • $group = $locale->text('Group');
  • }
  • $linkaccounts = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Income').qq|</th>
  • <td><select name=IC_income>$form->{selectIC_income}</select></td>
  • </tr>
  • |;
  • for (split / /, $form->{taxaccounts}) {
  • $tax .= qq|
  • <input class=checkbox type=checkbox name="IC_tax_$_" value=1 $form->{"IC_tax_$_"}>&nbsp;<b>$form->{"IC_tax_${_}_description"}</b>
  • <br><input type=hidden name=IC_tax_${_}_description value="$form->{"IC_tax_${_}_description"}">
  • |;
  • }
  • if ($tax) {
  • $linkaccounts .= qq|
  • <tr>
  • <th align=right>|.$locale->text('Tax').qq|</th>
  • <td>$tax</td>
  • </tr>
  • |;
  • }
  • $partnumber = qq|
  • <tr>
  • <td>
  • <table>
  • <tr valign=top>
  • <th align=left>|.$locale->text('Number').qq|</th>
  • <th align=left>|.$locale->text('Description').qq|</th>
  • <th align=left>$group</th>
  • </tr>
  • <tr valign=top>
  • <td><input name=partnumber value="$form->{partnumber}" size=20></td>
  • <td>$partdescription</td>
  • <td>$partsgroup</td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • |;
  • $form->{title} = ($form->{id}) ? $locale->text('Edit Job') : $locale->text('Add Job');
  • $form->header;
  • print qq|
  • <body>
  • <form method=post action=$form->{script}>
  • |;
  • for (qw(partnumber startdate enddate)) { $form->{"old$_"} = $form->{$_} }
  • print qq|<input type=hidden name="selectIC_income" value="|.$form->escape($form->{"selectIC_income"},1).qq|">\n|;
  • $form->hide_form("id", "type", "old$form->{vc}", "$form->{vc}_id", "orphaned", "taxaccounts", "vc", "project");
  • print qq|
  • <table width=100%>
  • <tr>
  • <th class=listtop>$form->{title}</th>
  • </tr>
  • <tr height="5"></tr>
  • <tr>
  • <td>
  • <table>
  • <tr>
  • <th align=right>|.$locale->text('Number').qq|</th>
  • <td><input name=projectnumber size=20 value="$form->{projectnumber}"></td>
  • <th align=right>|.$locale->text('Description').qq|</th>
  • <td>$description</td>
  • </tr>
  • $name
  • <tr>
  • <th align=right>|.$locale->text('Startdate').qq|</th>
  • <td><input name=startdate size=11 title="($myconfig{dateformat})" value=$form->{startdate}></td>
  • <th align=right>|.$locale->text('Enddate').qq|</th>
  • <td><input name=enddate size=11 title="($myconfig{dateformat})" value=$form->{enddate}></td>
  • </tr>
  • $production
  • </table>
  • </td>
  • </tr>
  • <tr class="listheading">
  • <th class="listheading" align="center">|.$locale->text('Assembly').qq|</th>
  • </tr>
  • <tr>
  • <td>
  • <table width=100%>
  • $partnumber
  • <tr>
  • <td colspan=3>
  • <table width=100%>
  • <tr>
  • <td width=70%>
  • <table width=100%>
  • <tr class="listheading">
  • <th class="listheading" align="center" colspan=2>|.$locale->text('Link Accounts').qq|</th>
  • </tr>
  • $linkaccounts
  • <tr>
  • <th align="left">|.$locale->text('Notes').qq|</th>
  • </tr>
  • <tr>
  • <td colspan=2>
  • $notes
  • </td>
  • </tr>
  • </table>
  • </td>
  • <td align=right>
  • <table>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Updated').qq|</th>
  • <td><input name=priceupdate size=11 title="$myconfig{dateformat}" value=$form->{priceupdate}></td>
  • </tr>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('List Price').qq|</th>
  • <td><input name=listprice size=11 value=$form->{listprice}></td>
  • </tr>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Sell Price').qq|</th>
  • <td><input name=sellprice size=11 value=$form->{sellprice}></td>
  • </tr>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Weight').qq|</th>
  • <td>
  • <table>
  • <tr>
  • <td>
  • <input name=weight size=10 value=$form->{weight}>
  • </td>
  • <th>
  • &nbsp;
  • $form->{weightunit}
  • <input type=hidden name=weightunit value=$form->{weightunit}>
  • </th>
  • </tr>
  • </table>
  • </td>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Bin').qq|</th>
  • <td><input name=bin size=10 value="$form->{bin}"></td>
  • </tr>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Unit').qq|</th>
  • <td><input name=unit size=5 value="$form->{unit}"></td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • <tr>
  • <td><hr size=3 noshade></td>
  • </tr>
  • </table>
  • |;
  • }
  • 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|
  • </form>
  • </body>
  • </html>
  • |;
  • }
  • sub list_stock {
  • PE->list_stock(\%myconfig, \%$form);
  • $form->{title} = $locale->text('Stock Finished Goods');
  • $form->{action} = "list_stock";
  • $href = "$form->{script}?";
  • for (qw(action direction oldsort type path login sessionid status)) { $href .= "$_=$form->{$_}&" }
  • $form->sort_order();
  • $callback = "$form->{script}?";
  • for (qw(action direction oldsort type path login sessionid status)) { $callback .= "$_=$form->{$_}&" }
  • @column_index = $form->sort_columns(qw(projectnumber description startdate partnumber production completed stock));
  • if ($form->{projectnumber}) {
  • $href .= "&projectnumber=".$form->escape($form->{projectnumber});
  • $callback .= "&projectnumber=$form->{projectnumber}";
  • ($var) = split /--/, $form->{projectnumber};
  • $option .= "\n<br>".$locale->text('Job Number')." : $var";
  • }
  • if ($form->{stockingdate}) {
  • $href .= "&stockingdate=$form->{stockingdate}";
  • $option .= "\n<br>".$locale->text('As of')." : ".$locale->date(\%myconfig, $form->{stockingdate}, 1);
  • }
  • $column_header{projectnumber} = qq|<th width=30%><a class=listheading href=$href&sort=projectnumber>|.$locale->text('Number').qq|</a></th>|;
  • $column_header{description} = qq|<th width=50%><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
  • $column_header{startdate} = qq|<th width=10%><a class=listheading href=$href&sort=startdate>|.$locale->text('Startdate').qq|</a></th>|;
  • $column_header{partnumber} = "<th><a class=listheading href=$href&sort=partnumber>" . $locale->text('Assembly') . "</a></th>";
  • $column_header{production} = "<th class=listheading>" . $locale->text('Production') . "</a></th>";
  • $column_header{completed} = "<th class=listheading>" . $locale->text('Completed') . "</a></th>";
  • $column_header{stock} = "<th class=listheading>" . $locale->text('Add') . "</a></th>";
  • $form->header;
  • if (@{ $form->{all_project} }) {
  • $sameitem = $form->{all_project}->[0]->{$form->{sort}};
  • }
  • print qq|
  • <body>
  • <form method=post action=$form->{script}>
  • <table width=100%>
  • <tr>
  • <th class=listtop>$form->{title}</th>
  • </tr>
  • <tr height="5"></tr>
  • <tr>
  • <td>$option</td>
  • </tr>
  • <tr>
  • <td>
  • <table width=100%>
  • <tr class=listheading>
  • |;
  • for (@column_index) { print "$column_header{$_}\n" }
  • print qq|
  • </tr>
  • |;
  • # escape callback
  • $form->{callback} = $callback .= "&sort=$form->{sort}";
  • # escape callback for href
  • $callback = $form->escape($callback);
  • # flip direction
  • $direction = ($form->{direction} eq 'ASC') ? "ASC" : "DESC";
  • $href =~ s/&direction=(\w+)&/&direction=$direction&/;
  • $i = 0;
  • foreach $ref (@{ $form->{all_project} }) {
  • $i++;
  • for (qw(projectnumber description startdate enddate partnumber)) { $column_data{$_} = qq|<td>$ref->{$_}&nbsp;</td>| }
  • for (qw(production completed)) { $column_data{$_} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{$_}).qq|</td>| }
  • $column_data{stock} = qq|<td><input name="stock_$i" size=6></td>|;
  • $j++; $j %= 2;
  • print qq|
  • <tr valign=top class=listrow$j>
  • <input type=hidden name="id_$i" value=$ref->{id}>
  • |;
  • for (@column_index) { print "$column_data{$_}\n" }
  • print "
  • </tr>
  • ";
  • }
  • print qq|
  • </table>
  • </td>
  • </tr>
  • <tr>
  • <td><hr size=3 noshade></td>
  • </tr>
  • </table>
  • |;
  • $form->hide_form(qw(callback type path login sessionid status));
  • print qq|
  • <input type="hidden" name="nextsub" value="stock">
  • <br>
  • <button type="submit" class="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>
  • </form>
  • </body>
  • </html>
  • |;
  • }
  • sub stock {
  • if (PE->stock_assembly(\%myconfig, \%$form)) {
  • $form->redirect($locale->text('Assembly stocked!'));
  • } else {
  • $form->error($locale->text('Cannot stock Assembly!'));
  • }
  • }
  • sub prepare_project {
  • $form->{vc} = 'customer';
  • PE->get_project(\%myconfig, \%$form);
  • $form->{title} = ($form->{id}) ? $locale->text('Edit Project') : $locale->text('Add Project');