9cb8e22ed0c068605ba2f436b18c6e02f8e5e18c
[fa-stable.git] / manufacturing / work_order_release.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 = 10;
13 $path_to_root="..";
14 include_once($path_to_root . "/includes/session.inc");
15
16 include_once($path_to_root . "/includes/date_functions.inc");
17 include_once($path_to_root . "/includes/manufacturing.inc");
18
19 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
20 include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
21
22 $js = "";
23 if ($use_date_picker)
24         $js .= get_js_date_picker();
25 page(_("Work Order Release to Manufacturing"), false, false, "", $js);
26
27 if (isset($_GET["trans_no"]))
28 {
29         $selected_id = $_GET["trans_no"];
30 }
31 elseif (isset($_POST["selected_id"]))
32 {
33         $selected_id = $_POST["selected_id"];
34 }
35 else
36 {
37         display_note("This page must be called with a work order reference");
38         exit;
39 }
40
41 //------------------------------------------------------------------------------------
42
43 function can_process($myrow)
44 {
45         if ($myrow['released'])
46         {
47                 display_error(_("This work order has already been released."));
48                 set_focus('released');
49                 return false;
50         }
51
52         // make sure item has components
53         if (!has_bom($myrow['stock_id']))
54         {
55                 display_error(_("This Work Order cannot be released. The selected item to manufacture does not have a bom."));
56                 set_focus('stock_id');
57                 return false;
58         }
59
60         return true;
61 }
62
63 //------------------------------------------------------------------------------------
64 if (isset($_POST['release']))
65 {
66         release_work_order($selected_id, $_POST['released_date'], $_POST['memo_']);
67
68         display_note(_("The work order has been released to manufacturing."));
69
70         hyperlink_no_params("search_work_orders.php", _("Select another &work order"));
71
72         $Ajax->activate('_page_body');
73         end_page();
74         exit;
75 }
76
77 //------------------------------------------------------------------------------------
78
79 start_form();
80
81 $myrow = get_work_order($selected_id);
82
83 $_POST['released'] = $myrow["released"];
84 $_POST['memo_'] = "";
85
86 if (can_process($myrow))
87 {
88         start_table($table_style2);
89
90     label_row(_("Work Order #:"), $selected_id);
91     label_row(_("Work Order Reference:"), $myrow["wo_ref"]);
92
93     date_row(_("Released Date") . ":", 'released_date');
94
95     textarea_row(_("Memo:"), 'memo_', $_POST['memo_'], 40, 5);
96
97     end_table(1);
98
99     submit_center('release', _("Release Work Order"), true, '', true);
100
101     hidden('selected_id', $selected_id);
102     hidden('stock_id', $myrow['stock_id']);
103
104 }
105
106 end_form();
107
108 end_page();
109
110 ?>