/doc/users/TaylorKillian/

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