Feature 5388: Print Invoices (documents) list gets too long. Fixed by default 180...
[fa-stable.git] / manufacturing / view / wo_costs_view.php
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 'SA_MANUFTRANSVIEW';
13 $path_to_root = "../..";
14
15 include_once($path_to_root . "/includes/session.inc");
16
17 $js = "";
18 if ($SysPrefs->use_popup_windows)
19         $js .= get_js_open_window(900, 500);
20 page(_($help_context = "View Work Order Costs"), true, false, "", $js);
21
22 include_once($path_to_root . "/includes/date_functions.inc");
23 include_once($path_to_root . "/includes/data_checks.inc");
24
25 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
26 include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
27
28 //-------------------------------------------------------------------------------------------------
29
30 if ($_GET['trans_no'] != "")
31 {
32         $wo_id = $_GET['trans_no'];
33 }
34
35 //-------------------------------------------------------------------------------------------------
36 function print_gl_rows($result, $title)
37 {
38         global $systypes_array;
39
40     if (db_num_rows($result))
41     {
42                 table_section_title($title, 7);
43                 while($myrow = db_fetch($result)) {
44                         start_row();
45                         label_cell(sql2date($myrow["tran_date"]));
46                         label_cell(get_trans_view_str($myrow['type'],$myrow["type_no"], $systypes_array[$myrow['type']]. ' '.$myrow['type_no']));
47                     label_cell($myrow['account']);
48                         label_cell($myrow['account_name']);
49                         display_debit_or_credit_cells($myrow['amount']);
50                         label_cell($myrow['memo_']);
51                         end_row();
52                 }
53         }
54 }
55 function display_wo_costs($prod_id)
56 {
57         br(1);
58     start_table(TABLESTYLE);
59
60         $th = array(_("Date"), _("Transaction"), _("Account Code"), _("Account Name"),
61                 _("Debit"), _("Credit"), _("Memo"));
62
63         table_header($th);
64
65         $productions = get_gl_wo_productions($prod_id, true);
66         print_gl_rows($productions, _("Finished Product Requirements"));
67
68         $issues = get_gl_wo_issue_trans($prod_id, -1, true);
69         print_gl_rows($issues, _("Additional Material Issues"));
70
71     $costs = get_gl_wo_cost_trans($prod_id, -1, true);
72         print_gl_rows($costs, _("Additional Costs"));
73
74         $wo = get_gl_trans(ST_WORKORDER, $prod_id);
75         print_gl_rows($wo, _("Finished Product Receival"));
76         end_table(1);
77 }
78
79 //-------------------------------------------------------------------------------------------------
80 display_heading(sprintf(_("Production Costs for Work Order # %d"), $wo_id));
81
82 display_wo_details($wo_id, true);
83
84 display_wo_costs($wo_id);
85
86 //-------------------------------------------------------------------------------------------------
87
88 br(2);
89
90 end_page(true, false, false, ST_WORKORDER, $wo_id);
91