/doc/ikiwiki/formatting/

title='Atom feed' href='https://source.jones.dk/ledger-smb/atom/bin/pe.pl?h=master' type='application/atom+xml'/>
summaryrefslogtreecommitdiff
path: root/bin/pe.pl
blob: f1c11d35291a238302a19bc136cf92ec51136dce (plain)
  1. #=====================================================================
  2. # LedgerSMB
  3. # Small Medium Business Accounting software
  4. # http://www.ledgersmb.org/
  5. #
  6. #
  7. # See COPYRIGHT file for copyright information
  8. #======================================================================
  9. #
  10. # This file has NOT undergone whitespace cleanup.
  11. #
  12. #======================================================================
  13. #
  14. # project/job administration
  15. # partsgroup administration
  16. # translation maintainance
  17. #
  18. #======================================================================
  19. use LedgerSMB::PE;
  20. use LedgerSMB::AA;
  21. use LedgerSMB::OE;
  22. 1;
  23. # end of main
  24. sub add {
  25. # construct callback
  26. $form->{callback} =
  27. "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
  28. unless $form->{callback};
  29. &{"prepare_$form->{type}"};
  30. $form->{orphaned} = 1;
  31. &display_form;
  32. }
  33. sub edit {
  34. &{"prepare_$form->{type}"};
  35. &display_form;
  36. }
  37. sub prepare_partsgroup {
  38. PE->get_partsgroup( \%myconfig, \%$form )
  39. if $form->{id};
  40. }
  41. sub prepare_pricegroup {
  42. PE->get_pricegroup( \%myconfig, \%$form )
  43. if $form->{id};
  44. }
  45. sub prepare_job {
  46. # $locale->text('Add Job')
  47. # $locale->text('Edit Job')
  48. $form->{vc} = 'customer';
  49. PE->get_job( \%myconfig, \%$form );
  50. $form->{taxaccounts} = "";
  51. for ( keys %{ $form->{IC_links} } ) {
  52. $form->{"select$_"} = "";
  53. foreach $ref ( @{ $form->{IC_links}{$_} } ) {
  54. if (/IC_tax/) {
  55. if (/taxpart/) {
  56. $form->{taxaccounts} .= "$ref->{accno} ";
  57. $form->{"IC_tax_$ref->{accno}_description"} =
  58. "$ref->{accno}--$ref->{description}";
  59. if ( $form->{id} ) {
  60. if ( $form->{amount}{ $ref->{accno} } ) {
  61. $form->{"IC_tax_$ref->{accno}"} = "checked";
  62. }
  63. }
  64. else {
  65. $form->{"IC_tax_$ref->{accno}"} = "checked";
  66. }
  67. }
  68. }
  69. else {
  70. $form->{"select$_"} .=
  71. "<option>$ref->{accno}--$ref->{description}\n";
  72. }
  73. }
  74. }
  75. chop $form->{taxaccounts};
  76. $form->{selectIC_income} = $form->{selectIC_sale};
  77. $form->{IC_income} = $form->{IC_sale};
  78. $form->{IC_income} = qq|$form->{income_accno}--$form->{income_description}|;
  79. delete $form->{IC_links};
  80. $form->{"old$form->{vc}"} =
  81. qq|$form->{"$form->{vc}"}--$form->{"$form->{vc}_id"}|;
  82. if ( @{ $form->{"all_$form->{vc}"} } ) {
  83. $form->{"$form->{vc}"} =
  84. qq|$form->{"$form->{vc}"}--$form->{"$form->{vc}_id"}|;
  85. $form->{"select$form->{vc}"} = qq|<option>\n|;
  86. for ( @{ $form->{"all_$form->{vc}"} } ) {
  87. $form->{"select$form->{vc}"} .=
  88. qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
  89. }
  90. }
  91. $form->get_partsgroup( \%myconfig, { all => 1 } );
  92. $form->{partsgroup} =
  93. $form->quote( $form->{partsgroup} ) . "--$form->{partsgroup_id}";
  94. if ( @{ $form->{all_partsgroup} } ) {
  95. $form->{selectpartsgroup} = qq|<option>\n|;
  96. for ( @{ $form->{all_partsgroup} } ) {
  97. $form->{selectpartsgroup} .=
  98. qq|<option value="|
  99. . $form->quote( $_->{partsgroup} )
  100. . qq|--$_->{id}">$_->{partsgroup}\n|;
  101. }
  102. }
  103. $form->{locked} =
  104. ( $form->{revtrans} )
  105. ? '1'
  106. : ( $form->datetonum( \%myconfig, $form->{transdate} ) <=
  107. $form->datetonum( \%myconfig, $form->{closedto} ) );
  108. $form->{readonly} = 1 if $myconfig{acs} =~ /Job Costing--Add Job/;
  109. }
  110. sub job_header {
  111. for (qw(partnumber partdescription description notes unit)) {
  112. $form->{$_} = $form->quote( $form->{$_} );
  113. }
  114. for (qw(production weight)) {
  115. $form->{$_} = $form->format_amount( \%myconfig, $form->{$_} );
  116. }
  117. for (qw(listprice sellprice)) {
  118. $form->{$_} = $form->format_amount( \%myconfig, $form->{$_}, 2 );
  119. }
  120. if ( ( $rows = $form->numtextrows( $form->{partdescription}, 60 ) ) > 1 ) {
  121. $partdescription =
  122. qq|<textarea name="partdescription" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{partdescription}</textarea>|;
  123. }
  124. else {
  125. $partdescription =
  126. qq|<input name=partdescription size=60 value="$form->{partdescription}">|;
  127. }
  128. if ( ( $rows = $form->numtextrows( $form->{description}, 60 ) ) > 1 ) {
  129. $description =
  130. qq|<textarea name="description" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{description}</textarea>|;
  131. }
  132. else {
  133. $description =
  134. qq|<input name=description size=60 value="$form->{description}">|;
  135. }
  136. if ( ( $rows = $form->numtextrows( $form->{notes}, 40 ) ) < 2 ) {
  137. $rows = 2;
  138. }
  139. $notes =
  140. qq|<textarea name=notes rows=$rows cols=40 wrap=soft>$form->{notes}</textarea>|;
  141. $form->{selectIC_income} = $form->unescape( $form->{selectIC_income} );
  142. $form->{"select$form->{vc}"} =
  143. $form->unescape( $form->{"select$form->{vc}"} );
  144. $form->{"select$form->{vc}"} =~ s/ selected//;
  145. $form->{"select$form->{vc}"} =~
  146. s/(<option value="\Q$form->{"$form->{vc}"}\E")/$1 selected/;
  147. $label = ucfirst $form->{vc};
  148. if ( $form->{"select$form->{vc}"} ) {
  149. $name = qq|
  150. <tr>
  151. <th align=right nowrap>| . $locale->text($label) . qq|</th>
  152. <td colspan=3><select name="$form->{vc}">$form->{"select$form->{vc}"}</select></td>
  153. <input type=hidden name="select$form->{vc}" value="|
  154. . $form->escape( $form->{"select$form->{vc}"}, 1 ) . qq|">
  155. </tr>
  156. |;
  157. }
  158. else {
  159. $name = qq|
  160. <tr>
  161. <th align=right nowrap>| . $locale->text($label) . qq|</th>
  162. <td colspan=3><input name="$form->{vc}" value="$form->{"$form->{vc}"}" size=35></td>
  163. <input type=hidden name="select$form->{vc}" value="|
  164. . $form->escape( $form->{"select$form->{vc}"}, 1 ) . qq|">
  165. </tr>
  166. |;
  167. }
  168. if ( $form->{orphaned} ) {
  169. for (qw(income)) {
  170. $form->{"selectIC_$_"} =~ s/ selected//;
  171. $form->{"selectIC_$_"} =~
  172. s/option>\Q$form->{"IC_$_"}\E/option selected>$form->{"IC_$_"}/;
  173. }
  174. $production = qq|
  175. <tr>
  176. <th align=right nowrap>| . $locale->text('Production') . qq|</th>
  177. <td><input name=production size=10 value="$form->{production}"></td>
  178. <th align=right nowrap>| . $locale->text('Completed') . qq|</th>
  179. <td>$form->{completed}</td>
  180. </tr>
  181. |;
  182. }
  183. else {
  184. $form->{selectIC_income} = qq|<option selected>$form->{IC_income}|;
  185. $production = qq|
  186. <tr>
  187. <th align=right nowrap>| . $locale->text('Production') . qq|</th>
  188. <td><input type=hidden name=production value="$form->{production}">$form->{production}</td>
  189. <th align=right nowrap>| . $locale->text('Completed') . qq|</th>
  190. <td>$form->{completed}</td>
  191. </tr>
  192. |;
  193. }
  194. for ( split / /, $form->{taxaccounts} ) {
  195. $form->{"IC_tax_$_"} = ( $form->{"IC_tax_$_"} ) ? "checked" : "";
  196. }
  197. if ( $form->{selectpartsgroup} ) {
  198. $form->{selectpartsgroup} =
  199. $form->unescape( $form->{selectpartsgroup} );
  200. $partsgroup =
  201. qq|<input type=hidden name=selectpartsgroup value="|
  202. . $form->escape( $form->{selectpartsgroup}, 1 ) . qq|">|;
  203. $form->{partsgroup} = $form->quote( $form->{partsgroup} );
  204. $form->{selectpartsgroup} =~
  205. s/(<option value="\Q$form->{partsgroup}\E")/$1 selected/;
  206. $partsgroup .=
  207. qq|\n<select name=partsgroup>$form->{selectpartsgroup}</select>|;
  208. $group = $locale->text('Group');
  209. }
  210. $linkaccounts = qq|
  211. <tr>
  212. <th align=right nowrap>| . $locale->text('Income') . qq|</th>
  213. <td><select name=IC_income>$form->{selectIC_income}</select></td>
  214. </tr>
  215. |;
  216. for ( split / /, $form->{taxaccounts} ) {
  217. $tax .= qq|
  218. <input class=checkbox type=checkbox name="IC_tax_$_" value=1 $form->{"IC_tax_$_"}>&nbsp;<b>$form->{"IC_tax_${_}_description"}</b>
  219. <br><input type=hidden name=IC_tax_${_}_description value="$form->{"IC_tax_${_}_description"}">
  220. |;
  221. }
  222. if ($tax) {
  223. $linkaccounts .= qq|
  224. <tr>
  225. <th align=right>| . $locale->text('Tax') . qq|</th>
  226. <td>$tax</td>
  227. </tr>
  228. |;
  229. }
  230. $partnumber = qq|
  231. <tr>
  232. <td>
  233. <table>
  234. <tr valign=top>
  235. <th align=left>| . $locale->text('Number') . qq|</th>
  236. <th align=left>| . $locale->text('Description') . qq|</th>
  237. <th align=left>$group</th>
  238. </tr>
  239. <tr valign=top>
  240. <td><input name=partnumber value="$form->{partnumber}" size=20></td>
  241. <td>$partdescription</td>
  242. <td>$partsgroup</td>
  243. </tr>
  244. </table>
  245. </td>
  246. </tr>
  247. |;
  248. $form->{title} =
  249. ( $form->{id} ) ? $locale->text('Edit Job') : $locale->text('Add Job');
  250. $form->header;
  251. print qq|
  252. <body>
  253. <form method=post action=$form->{script}>
  254. |;
  255. for (qw(partnumber startdate enddate)) { $form->{"old$_"} = $form->{$_} }
  256. print qq|<input type=hidden name="selectIC_income" value="|
  257. . $form->escape( $form->{"selectIC_income"}, 1 )
  258. . qq|">\n|;
  259. $form->hide_form(
  260. "id", "type",
  261. "old$form->{vc}", "$form->{vc}_id",
  262. "orphaned", "taxaccounts",
  263. "vc", "project"
  264. );
  265. print qq|
  266. <table width=100%>
  267. <tr>
  268. <th class=listtop>$form->{title}</th>
  269. </tr>
  270. <tr height="5"></tr>
  271. <tr>
  272. <td>
  273. <table>
  274. <tr>
  275. <th align=right>| . $locale->text('Number') . qq|</th>
  276. <td><input name=projectnumber size=20 value="$form->{projectnumber}"></td>
  277. <th align=right>| . $locale->text('Description') . qq|</th>
  278. <td>$description</td>
  279. </tr>
  280. $name
  281. <tr>
  282. <th align=right>| . $locale->text('Startdate') . qq|</th>
  283. <td><input class="date" name=startdate size=11 title="($myconfig{dateformat})" value=$form->{startdate}></td>
  284. <th align=right>| . $locale->text('Enddate') . qq|</th>
  285. <td><input class="date" name=enddate size=11 title="($myconfig{dateformat})" value=$form->{enddate}></td>
  286. </tr>
  287. $production
  288. </table>
  289. </td>
  290. </tr>
  291. <tr class="listheading">
  292. <th class="listheading" align="center">|
  293. . $locale->text('Assembly')
  294. . qq|</th>
  295. </tr>
  296. <tr>
  297. <td>
  298. <table width=100%>
  299. $partnumber
  300. <tr>
  301. <td colspan=3>
  302. <table width=100%>
  303. <tr>
  304. <td width=70%>
  305. <table width=100%>
  306. <tr class="listheading">
  307. <th class="listheading" align="center" colspan=2>|
  308. . $locale->text('Link Accounts')
  309. . qq|</th>
  310. </tr>
  311. $linkaccounts
  312. <tr>
  313. <th align="left">| . $locale->text('Notes') . qq|</th>
  314. </tr>
  315. <tr>
  316. <td colspan=2>
  317. $notes
  318. </td>
  319. </tr>
  320. </table>
  321. </td>
  322. <td align=right>
  323. <table>
  324. <tr>
  325. <th align="right" nowrap="true">| . $locale->text('Updated') . qq|</th>
  326. <td><input name=priceupdate size=11 title="$myconfig{dateformat}" value=$form->{priceupdate}></td>
  327. </tr>
  328. <tr>
  329. <th align="right" nowrap="true">|
  330. . $locale->text('List Price')
  331. . qq|</th>
  332. <td><input name=listprice size=11 value=$form->{listprice}></td>
  333. </tr>
  334. <tr>
  335. <th align="right" nowrap="true">|
  336. . $locale->text('Sell Price')
  337. . qq|</th>
  338. <td><input name=sellprice size=11 value=$form->{sellprice}></td>
  339. </tr>
  340. <tr>
  341. <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
  342. <td>
  343. <table>
  344. <tr>
  345. <td>
  346. <input name=weight size=10 value=$form->{weight}>
  347. </td>
  348. <th>
  349. &nbsp;
  350. $form->{weightunit}
  351. <input type=hidden name=weightunit value=$form->{weightunit}>
  352. </th>
  353. </tr>
  354. </table>
  355. </td>
  356. <tr>
  357. <th align="right" nowrap="true">| . $locale->text('Bin') . qq|</th>
  358. <td><input name=bin size=10 value="$form->{bin}"></td>
  359. </tr>
  360. <tr>
  361. <th align="right" nowrap="true">| . $locale->text('Unit') . qq|</th>
  362. <td><input name=unit size=5 value="$form->{unit}"></td>
  363. </tr>
  364. </table>
  365. </td>
  366. </tr>
  367. </table>
  368. </td>
  369. </tr>
  370. </table>
  371. </td>
  372. </tr>
  373. <tr>
  374. <td><hr size=3 noshade></td>
  375. </tr>
  376. </table>
  377. |;
  378. }
  379. sub job_footer {
  380. $form->hide_form(qw(callback path login sessionid));
  381. # type=submit $locale->text('Update')
  382. # type=submit $locale->text('Save')
  383. # type=submit $locale->text('Delete')
  384. %button =
  385. ( 'update' => { ndx => 1, key => 'U', value => $locale->text('Update') },
  386. );
  387. if ( $myconfig{acs} !~ /Job Costing--Add Job/ ) {
  388. $button{'save'} =
  389. { ndx => 3, key => 'S', value => $locale->text('Save') };
  390. if ( $form->{id} && $form->{orphaned} ) {
  391. $button{'delete'} =
  392. { ndx => 16, key => 'D', value => $locale->text('Delete') };
  393. }
  394. }
  395. for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) {
  396. $form->print_button( \%button, $_ );
  397. }
  398. if ( $form->{lynx} ) {
  399. require "bin/menu.pl";
  400. &menubar;
  401. }
  402. print qq|
  403. </form>
  404. </body>
  405. </html>
  406. |;
  407. }
  408. sub list_stock {
  409. PE->list_stock( \%myconfig, \%$form );
  410. $form->{title} = $locale->text('Stock Finished Goods');
  411. $form->{action} = "list_stock";
  412. $href = "$form->{script}?";
  413. for (qw(action direction oldsort type path login sessionid status)) {
  414. $href .= "$_=$form->{$_}&";
  415. }
  416. $form->sort_order();
  417. $callback = "$form->{script}?";
  418. for (qw(action direction oldsort type path login sessionid status)) {
  419. $callback .= "$_=$form->{$_}&";
  420. }
  421. @column_index =
  422. $form->sort_columns(
  423. qw(projectnumber description startdate partnumber production completed stock)
  424. );
  425. if ( $form->{projectnumber} ) {
  426. $href .= "&projectnumber=" . $form->escape( $form->{projectnumber} );
  427. $callback .= "&projectnumber=$form->{projectnumber}";
  428. ($var) = split /--/, $form->{projectnumber};
  429. $option .= "\n<br>" . $locale->text('Job Number') . " : $var";
  430. }
  431. if ( $form->{stockingdate} ) {
  432. $href .= "&stockingdate=$form->{stockingdate}";
  433. $option .= "\n<br>"
  434. . $locale->text('As of') . " : "
  435. . $locale->date( \%myconfig, $form->{stockingdate}, 1 );
  436. }
  437. $column_header{projectnumber} =
  438. qq|<th width=30%><a class=listheading href=$href&sort=projectnumber>|
  439. . $locale->text('Number')
  440. . qq|</a></th>|;
  441. $column_header{description} =
  442. qq|<th width=50%><a class=listheading href=$href&sort=description>|
  443. . $locale->text('Description')
  444. . qq|</a></th>|;
  445. $column_header{startdate} =
  446. qq|<th width=10%><a class=listheading href=$href&sort=startdate>|
  447. . $locale->text('Startdate')
  448. . qq|</a></th>|;
  449. $column_header{partnumber} =
  450. "<th><a class=listheading href=$href&sort=partnumber>"
  451. . $locale->text('Assembly')
  452. . "</a></th>";
  453. $column_header{production} =
  454. "<th class=listheading>" . $locale->text('Production') . "</a></th>";
  455. $column_header{completed} =
  456. "<th class=listheading>" . $locale->text('Completed') . "</a></th>";
  457. $column_header{stock} =
  458. "<th class=listheading>" . $locale->text('Add') . "</a></th>";
  459. $form->header;
  460. if ( @{ $form->{all_project} } ) {
  461. $sameitem = $form->{all_project}->[0]->{ $form->{sort} };
  462. }
  463. print qq|
  464. <body>
  465. <form method=post action=$form->{script}>
  466. <table width=100%>
  467. <tr>
  468. <th class=listtop>$form->{title}</th>
  469. </tr>
  470. <tr height="5"></tr>
  471. <tr>
  472. <td>$option</td>
  473. </tr>
  474. <tr>
  475. <td>
  476. <table width=100%>
  477. <tr class=listheading>
  478. |;
  479. for (@column_index) { print "$column_header{$_}\n" }
  480. print qq|
  481. </tr>
  482. |;
  483. # escape callback
  484. $form->{callback} = $callback .= "&sort=$form->{sort}";
  485. # escape callback for href
  486. $callback = $form->escape($callback);
  487. # flip direction
  488. $direction = ( $form->{direction} eq 'ASC' ) ? "ASC" : "DESC";
  489. $href =~ s/&direction=(\w+)&/&direction=$direction&/;
  490. $i = 0;
  491. foreach $ref ( @{ $form->{all_project} } ) {
  492. $i++;
  493. for (qw(projectnumber description startdate enddate partnumber)) {
  494. $column_data{$_} = qq|<td>$ref->{$_}&nbsp;</td>|;
  495. }
  496. for (qw(production completed)) {
  497. $column_data{$_} =
  498. qq|<td align=right>|
  499. . $form->format_amount( \%myconfig, $ref->{$_} )
  500. . qq|</td>|;
  501. }
  502. $column_data{stock} = qq|<td><input name="stock_$i" size=6></td>|;
  503. $j++;
  504. $j %= 2;
  505. print qq|
  506. <tr valign=top class=listrow$j>
  507. <input type=hidden name="id_$i" value=$ref->{id}>
  508. |;
  509. for (@column_index) { print "$column_data{$_}\n" }
  510. print "
  511. </tr>
  512. ";
  513. }
  514. print qq|
  515. </table>
  516. </td>
  517. </tr>
  518. <tr>
  519. <td><hr size=3 noshade></td>
  520. </tr>
  521. </table>
  522. |;
  523. $form->hide_form(qw(callback type path login sessionid status));
  524. print qq|
  525. <input type="hidden" name="nextsub" value="stock">
  526. <br>
  527. <button type="submit" class="submit" name="action" value="continue">|
  528. . $locale->text('Continue')
  529. . qq|</button>
  530. </form>
  531. </body>
  532. </html>
  533. |;
  534. }
  535. sub stock {
  536. if ( PE->stock_assembly( \%myconfig, \%$form ) ) {
  537. $form->redirect( $locale->text('Assembly stocked!') );
  538. }
  539. else {
  540. $form->error( $locale->text('Cannot stock Assembly!') );
  541. }
  542. }
  543. sub prepare_project {
  544. $form->{vc} = 'customer';
  545. PE->get_project( \%myconfig, \%$form );
  546. $form->{title} =
  547. ( $form->{id} )
  548. ? $locale->text('Edit Project')
  549. : $locale->text('Add Project');
  550. $form->{"old$form->{vc}"} =
  551. qq|$form->{"$form->{vc}"}--$form->{"$form->{vc}_id"}|;
  552. if ( @{ $form->{"all_$form->{vc}"} } ) {
  553. $form->{"$form->{vc}"} =
  554. qq|$form->{"$form->{vc}"}--$form->{"$form->{vc}_id"}|;
  555. $form->{"select$form->{vc}"} = qq|<option>\n|;
  556. for ( @{ $form->{"all_$form->{vc}"} } ) {
  557. $form->{"select$form->{vc}"} .=
  558. qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
  559. }
  560. }
  561. }
  562. sub search {
  563. # accounting years
  564. $form->all_years( \%myconfig );
  565. if ( @{ $form->{all_years} } ) {
  566. $form->{selectaccountingyear} = "<option>\n";
  567. for ( @{ $form->{all_years} } ) {
  568. $form->{selectaccountingyear} .= qq|<option>$_\n|;
  569. }
  570. $form->{selectaccountingmonth} = "<option>\n";
  571. for ( sort keys %{ $form->{all_month} } ) {
  572. $form->{selectaccountingmonth} .=
  573. qq|<option value=$_>|
  574. . $locale->text( $form->{all_month}{$_} ) . qq|\n|;
  575. }
  576. $fromto = qq|
  577. <tr>
  578. <th align=right>| . $locale->text('Startdate') . qq|</th>
  579. <td>|
  580. . $locale->text('From')
  581. . qq| <input class="date" name=startdatefrom size=11 title="($myconfig{'dateformat'})">|
  582. . $locale->text('To') . qq|
  583. <input class="date" name=startdateto size=11 title="($myconfig{'dateformat'})"></td>
  584. </tr>
  585. |;
  586. $selectperiod = qq|
  587. <tr>
  588. <th align=right>| . $locale->text('Period') . qq|</th>
  589. <td colspan=3>
  590. <select name=month>$form->{selectaccountingmonth}</select>
  591. <select name=year>$form->{selectaccountingyear}</select>
  592. <input name=interval class=radio type=radio value=0 checked>&nbsp;|
  593. . $locale->text('Current') . qq|
  594. <input name=interval class=radio type=radio value=1>&nbsp;|
  595. . $locale->text('Month') . qq|
  596. <input name=interval class=radio type=radio value=3>&nbsp;|
  597. . $locale->text('Quarter') . qq|
  598. <input name=interval class=radio type=radio value=12>&nbsp;|
  599. . $locale->text('Year') . qq|
  600. </td>
  601. </tr>
  602. |;
  603. }
  604. $orphaned = qq|
  605. <input name=status class=radio type=radio value=orphaned>&nbsp;|
  606. . $locale->text('Orphaned');
  607. if ( $form->{type} eq 'project' ) {
  608. $report = "project_report";
  609. $sort = "projectnumber";
  610. $form->{title} = $locale->text('Projects');
  611. $number = qq|
  612. <tr>
  613. <th align=right width=1%>| . $locale->text('Number') . qq|</th>
  614. <td><input name=projectnumber size=20></td>
  615. </tr>
  616. <tr>
  617. <th align=right>| . $locale->text('Description') . qq|</th>
  618. <td><input name=description size=60></td>
  619. </tr>
  620. |;
  621. }
  622. if ( $form->{type} eq 'stock' ) {
  623. $report = "list_stock";
  624. $form->{title} = $locale->text('Stock Finished Goods');
  625. PE->list_stock( \%myconfig, \%$form );
  626. $selectperiod = "";
  627. $orphaned = "";
  628. $fromto = qq|
  629. <tr>
  630. <th align=right nowrap>| . $locale->text('As of') . qq|</th>
  631. <td><input class="date" name=stockingdate size=11 title="$myconfig{dateformat}"></td>
  632. </tr>
  633. |;
  634. $number = qq|
  635. <tr>
  636. <th align=right width=1%>| . $locale->text('Job Number') . qq|</th>
  637. <td><input name=projectnumber size=20></td>
  638. </tr>
  639. <tr>
  640. <th align=right>| . $locale->text('Description') . qq|</th>
  641. <td><input name=description size=60></td>
  642. </tr>
  643. |;
  644. }
  645. if ( $form->{type} eq 'job' ) {
  646. $report = "job_report";
  647. $sort = "projectnumber";
  648. $form->{title} = $locale->text('Jobs');
  649. $number = qq|
  650. <tr>
  651. <th align=right width=1%>| . $locale->text('Number') . qq|</th>
  652. <td><input name=projectnumber size=20></td>
  653. </tr>
  654. <tr>
  655. <th align=right>| . $locale->text('Description') . qq|</th>
  656. <td><input name=description size=60></td>
  657. </tr>
  658. |;
  659. }
  660. if ( $form->{type} eq 'partsgroup' ) {
  661. $report = "partsgroup_report";
  662. $sort = 'partsgroup';
  663. $form->{title} = $locale->text('Groups');
  664. $fromto = "";
  665. $selectperiod = "";
  666. $number = qq|
  667. <tr>
  668. <th align=right width=1%>| . $locale->text('Group') . qq|</th>
  669. <td><input name=partsgroup size=20></td>
  670. </tr>
  671. |;
  672. }
  673. if ( $form->{type} eq 'pricegroup' ) {
  674. $report = "pricegroup_report";
  675. $sort = 'pricegroup';
  676. $form->{title} = $locale->text('Pricegroups');
  677. $fromto = "";
  678. $selectperiod = "";
  679. $number = qq|
  680. <tr>
  681. <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
  682. <td><input name=pricegroup size=20></td>
  683. </tr>
  684. |;
  685. }
  686. $form->header;
  687. print qq|
  688. <body>
  689. <form method=post action=$form->{script}>
  690. <input type=hidden name=sort value=$sort>
  691. <input type=hidden name=type value=$form->{type}>
  692. <table width=100%>
  693. <tr>
  694. <th class=listtop>$form->{title}</th>
  695. </tr>
  696. <tr height="5"></tr>
  697. <tr>
  698. <td>
  699. <table width=100%>
  700. $number
  701. $fromto
  702. $selectperiod
  703. <tr>
  704. <td></td>
  705. <td><input name=status class=radio type=radio value=all checked>&nbsp;|
  706. . $locale->text('All') . qq|
  707. <input name=status class=radio type=radio value=active>&nbsp;|
  708. . $locale->text('Active') . qq|
  709. <input name=status class=radio type=radio value=inactive>&nbsp;|
  710. . $locale->text('Inactive') . qq|
  711. $orphaned</td>
  712. </tr>
  713. </table>
  714. </td>
  715. </tr>
  716. <tr>
  717. <td><hr size=3 noshade></td>
  718. </tr>
  719. </table>
  720. <input type=hidden name=nextsub value=$report>
  721. |;
  722. $form->hide_form(qw(path login sessionid title));
  723. print qq|
  724. <button class="submit" type="submit" name="action" value="continue">|
  725. . $locale->text('Continue')
  726. . qq|</button>
  727. </form>
  728. |;
  729. if ( $form->{lynx} ) {
  730. require "bin/menu.pl";
  731. &menubar;
  732. }
  733. print qq|
  734. </body>
  735. </html>
  736. |;
  737. }
  738. sub job_report {
  739. for (qw(projectnumber description)) {
  740. $form->{$_} = $form->unescape( $form->{$_} );
  741. }
  742. PE->jobs( \%myconfig, \%$form );
  743. $form->{action} = "job_report";
  744. &list_projects;
  745. }
  746. sub project_report {
  747. for (qw(projectnumber description)) {
  748. $form->{$_} = $form->unescape( $form->{$_} );
  749. }
  750. PE->projects( \%myconfig, \%$form );
  751. $form->{action} = "project_report";
  752. &list_projects;
  753. }
  754. sub list_projects {
  755. $href = "$form->{script}?";
  756. for (
  757. qw(action direction oldsort type path login sessionid status startdatefrom startdateto)
  758. )
  759. {
  760. $href .= "$_=$form->{$_}&";
  761. }
  762. $form->sort_order();
  763. $callback = "$form->{script}?";
  764. for (
  765. qw(action direction oldsort type path login sessionid status startdatefrom startdateto)
  766. )
  767. {
  768. $callback .= "$_=$form->{$_}&";
  769. }
  770. @column_index =
  771. $form->sort_columns(qw(projectnumber description name startdate enddate));
  772. if ( $form->{status} eq 'all' ) {
  773. $option = $locale->text('All');
  774. }
  775. if ( $form->{status} eq 'orphaned' ) {
  776. $option .= $locale->text('Orphaned');
  777. }
  778. if ( $form->{status} eq 'active' ) {
  779. $option = $locale->text('Active');
  780. @column_index =
  781. $form->sort_columns(qw(projectnumber description name startdate));
  782. }
  783. if ( $form->{status} eq 'inactive' ) {
  784. $option = $locale->text('Inactive');
  785. }
  786. if ( $form->{type} eq 'project' ) {
  787. $label = $locale->text('Project');
  788. $form->{title} = $locale->text('Projects');
  789. }
  790. else {
  791. $label = $locale->text('Job');
  792. push @column_index, qw(partnumber production completed);
  793. $form->{title} = $locale->text('Jobs');
  794. }
  795. if ( $form->{projectnumber} ) {
  796. $href .= "&projectnumber=" . $form->escape( $form->{projectnumber} );
  797. $callback .= "&projectnumber=$form->{projectnumber}";
  798. $option .= "\n<br>$label : $form->{projectnumber}";
  799. }
  800. if ( $form->{description} ) {
  801. $href .= "&description=" . $form->escape( $form->{description} );
  802. $callback .= "&description=$form->{description}";
  803. $option .=
  804. "\n<br>" . $locale->text('Description') . " : $form->{description}";
  805. }
  806. if ( $form->{startdatefrom} ) {
  807. $href .= "&startdatefrom=$form->{startdatefrom}";
  808. $option .= "\n<br>"
  809. . $locale->text('From')
  810. . "&nbsp;"
  811. . $locale->date( \%myconfig, $form->{startdatefrom}, 1 );
  812. }
  813. if ( $form->{startdateto} ) {
  814. $href .= "&startdateto=$form->{startdateto}";
  815. if ( $form->{startdatefrom} ) {
  816. $option .= " ";
  817. }
  818. else {
  819. $option .= "\n<br>" if ($option);
  820. }
  821. $option .=
  822. $locale->text('To') . "&nbsp;"
  823. . $locale->date( \%myconfig, $form->{startdateto}, 1 );
  824. }
  825. $column_header{projectnumber} =
  826. qq|<th><a class=listheading href=$href&sort=projectnumber>|
  827. . $locale->text('Number')
  828. . qq|</a></th>|;
  829. $column_header{description} =
  830. qq|<th><a class=listheading href=$href&sort=description>|
  831. . $locale->text('Description')
  832. . qq|</a></th>|;
  833. $column_header{startdate} =
  834. qq|<th width=10><a class=listheading href=$href&sort=startdate>|
  835. . $locale->text('Startdate')
  836. . qq|</a></th>|;
  837. $column_header{enddate} =
  838. qq|<th width=10><a class=listheading href=$href&sort=enddate>|
  839. . $locale->text('Enddate')
  840. . qq|</a></th>|;
  841. $column_header{partnumber} =
  842. "<th><a class=listheading href=$href&sort=partnumber>"
  843. . $locale->text('Assembly')
  844. . "</a></th>";
  845. $column_header{production} =
  846. "<th width=10 class=listheading>" . $locale->text('Production') . "</th>";
  847. $column_header{completed} =
  848. "<th width=10 class=listheading>" . $locale->text('Completed') . "</th>";
  849. $column_header{name} =
  850. "<th class=listheading>" . $locale->text('Customer') . "</th>";
  851. $form->header;
  852. if ( @{ $form->{all_project} } ) {
  853. $sameitem = $form->{all_project}->[0]->{ $form->{sort} };
  854. }
  855. print qq|
  856. <body>
  857. <table width=100%>
  858. <tr>
  859. <th class=listtop>$form->{title}</th>
  860. </tr>
  861. <tr height="5"></tr>
  862. <tr>
  863. <td>$option</td>
  864. </tr>
  865. <tr>
  866. <td>
  867. <table width=100%>
  868. <tr class=listheading>
  869. |;
  870. for (@column_index) { print "$column_header{$_}\n" }
  871. print qq|
  872. </tr>
  873. |;
  874. # escape callback
  875. $form->{callback} = $callback .= "&sort=$form->{sort}";
  876. # escape callback for href
  877. $callback = $form->escape($callback);
  878. # flip direction
  879. $direction = ( $form->{direction} eq 'ASC' ) ? "ASC" : "DESC";
  880. $href =~ s/&direction=(\w+)&/&direction=$direction&/;
  881. foreach $ref ( @{ $form->{all_project} } ) {
  882. for (qw(description startdate enddate name)) {
  883. $column_data{$_} = qq|<td>$ref->{$_}&nbsp;</td>|;
  884. }
  885. for (qw(production completed)) {
  886. $column_data{$_} =
  887. qq|<td align=right>|
  888. . $form->format_amount( \%myconfig, $ref->{$_} );
  889. }
  890. $column_data{projectnumber} =
  891. qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&project=$form->{project}&callback=$callback>$ref->{projectnumber}</td>|;
  892. $column_data{partnumber} =
  893. qq|<td><a href=ic.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{partnumber}</td>|;
  894. $j++;