fbb756070b7702f5faf780d58ea73f55a8bf1ce0
[fa-stable.git] / inventory / manage / items.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_ITEM';
13 $path_to_root = "../..";
14 include($path_to_root . "/includes/session.inc");
15
16 $js = "";
17 if ($SysPrefs->use_popup_windows)
18         $js .= get_js_open_window(900, 500);
19 if (user_use_date_picker())
20         $js .= get_js_date_picker();
21
22 if (isset($_GET['FixedAsset'])) {
23   $page_security = 'SA_ASSET';
24   $_SESSION['page_title'] = _($help_context = "FA Items");
25   $_POST['mb_flag'] = 'F';
26   $_POST['fixed_asset']  = 1;
27 }
28 else {
29   $_SESSION['page_title'] = _($help_context = "Items");
30         if (!get_post('fixed_asset'))
31                 $_POST['fixed_asset']  = 0;
32 }
33
34
35 page($_SESSION['page_title'], false, false, "", $js);
36
37 include_once($path_to_root . "/includes/date_functions.inc");
38 include_once($path_to_root . "/includes/ui.inc");
39 include_once($path_to_root . "/includes/data_checks.inc");
40
41 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
42 include_once($path_to_root . "/fixed_assets/includes/fixed_assets_db.inc");
43
44 $user_comp = user_company();
45 $new_item = get_post('stock_id')=='' || get_post('cancel') || get_post('clone'); 
46 //------------------------------------------------------------------------------------
47
48 if (isset($_GET['stock_id']))
49 {
50         $_POST['stock_id'] = $_GET['stock_id'];
51 }
52 $stock_id = get_post('stock_id');
53 if (list_updated('stock_id')) {
54         $_POST['NewStockID'] = $stock_id = get_post('stock_id');
55     clear_data();
56         $Ajax->activate('details');
57         $Ajax->activate('controls');
58 }
59
60 if (get_post('cancel')) {
61         $_POST['NewStockID'] = $stock_id = $_POST['stock_id'] = '';
62     clear_data();
63         set_focus('stock_id');
64         $Ajax->activate('_page_body');
65 }
66 if (list_updated('category_id') || list_updated('mb_flag') || list_updated('fa_class_id') || list_updated('depreciation_method')) {
67         $Ajax->activate('details');
68 }
69 $upload_file = "";
70 if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '') 
71 {
72         $stock_id = $_POST['NewStockID'];
73         $result = $_FILES['pic']['error'];
74         $upload_file = 'Yes'; //Assume all is well to start off with
75         $filename = company_path().'/images';
76         if (!file_exists($filename))
77         {
78                 mkdir($filename);
79         }       
80         $filename .= "/".item_img_name($stock_id).".jpg";
81
82   if ($_FILES['pic']['error'] == UPLOAD_ERR_INI_SIZE) {
83     display_error(_('The file size is over the maximum allowed.'));
84                 $upload_file ='No';
85   }
86   elseif ($_FILES['pic']['error'] > 0) {
87                 display_error(_('Error uploading file.'));
88                 $upload_file ='No';
89   }
90         
91         //But check for the worst 
92         if ((list($width, $height, $type, $attr) = getimagesize($_FILES['pic']['tmp_name'])) !== false)
93                 $imagetype = $type;
94         else
95                 $imagetype = false;
96
97         if ($imagetype != IMAGETYPE_GIF && $imagetype != IMAGETYPE_JPEG && $imagetype != IMAGETYPE_PNG)
98         {       //File type Check
99                 display_warning( _('Only graphics files can be uploaded'));
100                 $upload_file ='No';
101         }
102         elseif (!in_array(strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)), array('JPG','PNG','GIF')))
103         {
104                 display_warning(_('Only graphics files are supported - a file extension of .jpg, .png or .gif is expected'));
105                 $upload_file ='No';
106         } 
107         elseif ( $_FILES['pic']['size'] > ($SysPrefs->max_image_size * 1024)) 
108         { //File Size Check
109                 display_warning(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $SysPrefs->max_image_size);
110                 $upload_file ='No';
111         } 
112         elseif ( $_FILES['pic']['type'] == "text/plain" ) 
113         {  //File type Check
114                 display_warning( _('Only graphics files can be uploaded'));
115         $upload_file ='No';
116         } 
117         elseif (file_exists($filename))
118         {
119                 $result = unlink($filename);
120                 if (!$result) 
121                 {
122                         display_error(_('The existing image could not be removed'));
123                         $upload_file ='No';
124                 }
125         }
126         
127         if ($upload_file == 'Yes')
128         {
129                 $result  =  move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
130         }
131         $Ajax->activate('details');
132  /* EOF Add Image upload for New Item  - by Ori */
133 }
134
135 if (get_post('fixed_asset')) {
136         check_db_has_fixed_asset_categories(_("There are no fixed asset categories defined in the system. At least one fixed asset category is required to add a fixed asset."));
137         check_db_has_fixed_asset_classes(_("There are no fixed asset classes defined in the system. At least one fixed asset class is required to add a fixed asset."));
138 } else
139         check_db_has_stock_categories(_("There are no item categories defined in the system. At least one item category is required to add a item."));
140
141 check_db_has_item_tax_types(_("There are no item tax types defined in the system. At least one item tax type is required to add a item."));
142
143 function clear_data()
144 {
145         unset($_POST['long_description']);
146         unset($_POST['description']);
147         unset($_POST['category_id']);
148         unset($_POST['tax_type_id']);
149         unset($_POST['units']);
150         unset($_POST['mb_flag']);
151         unset($_POST['NewStockID']);
152         unset($_POST['dimension_id']);
153         unset($_POST['dimension2_id']);
154         unset($_POST['no_sale']);
155         unset($_POST['no_purchase']);
156         unset($_POST['depreciation_method']);
157         unset($_POST['depreciation_rate']);
158         unset($_POST['depreciation_start']);
159 }
160
161 //------------------------------------------------------------------------------------
162
163 if (isset($_POST['addupdate'])) 
164 {
165
166         $input_error = 0;
167         if ($upload_file == 'No')
168                 $input_error = 1;
169         if (strlen($_POST['description']) == 0) 
170         {
171                 $input_error = 1;
172                 display_error( _('The item name must be entered.'));
173                 set_focus('description');
174         } 
175         elseif (strlen($_POST['NewStockID']) == 0) 
176         {
177                 $input_error = 1;
178                 display_error( _('The item code cannot be empty'));
179                 set_focus('NewStockID');
180         }
181         elseif (strstr($_POST['NewStockID'], " ") || strstr($_POST['NewStockID'],"'") || 
182                 strstr($_POST['NewStockID'], "+") || strstr($_POST['NewStockID'], "\"") || 
183                 strstr($_POST['NewStockID'], "&") || strstr($_POST['NewStockID'], "\t")) 
184         {
185                 $input_error = 1;
186                 display_error( _('The item code cannot contain any of the following characters -  & + OR a space OR quotes'));
187                 set_focus('NewStockID');
188
189         }
190         elseif ($new_item && db_num_rows(get_item_kit($_POST['NewStockID'])))
191         {
192                         $input_error = 1;
193                 display_error( _("This item code is already assigned to stock item or sale kit."));
194                         set_focus('NewStockID');
195         }
196         
197   if (get_post('fixed_asset')) {
198     if ($_POST['depreciation_rate'] > 100) {
199       $_POST['depreciation_rate'] = 100;
200     }
201     elseif ($_POST['depreciation_rate'] < 0) {
202       $_POST['depreciation_rate'] = 0;
203     }
204     $move_row = get_fixed_asset_move($_POST['NewStockID'], ST_SUPPRECEIVE);
205     if (isset($_POST['depreciation_start']) && strtotime($_POST['depreciation_start']) < strtotime($move_row['tran_date'])) {
206       display_warning(_('The depracation cannot start before the fixed asset purchase date'));
207     }
208   }
209         
210         if ($input_error != 1)
211         {
212                 if (check_value('del_image'))
213                 {
214                         $filename = company_path().'/images/'.item_img_name($_POST['NewStockID']).".jpg";
215                         if (file_exists($filename))
216                                 unlink($filename);
217                 }
218                 
219                 if (!$new_item) 
220                 { /*so its an existing one */
221                         update_item($_POST['NewStockID'], $_POST['description'],
222                                 $_POST['long_description'], $_POST['category_id'], 
223                                 $_POST['tax_type_id'], get_post('units'),
224                                 get_post('fixed_asset') ? 'F' : get_post('mb_flag'), $_POST['sales_account'],
225                                 $_POST['inventory_account'], $_POST['cogs_account'],
226                                 $_POST['adjustment_account'], $_POST['assembly_account'], 
227                                 $_POST['dimension_id'], $_POST['dimension2_id'],
228                                 check_value('no_sale'), check_value('editable'), check_value('no_purchase'),
229                                 get_post('depreciation_method'), get_post('depreciation_rate'), get_post('depreciation_start'),
230                                 get_post('fa_class_id'));
231
232                         update_record_status($_POST['NewStockID'], $_POST['inactive'],
233                                 'stock_master', 'stock_id');
234                         update_record_status($_POST['NewStockID'], $_POST['inactive'],
235                                 'item_codes', 'item_code');
236                         set_focus('stock_id');
237                         $Ajax->activate('stock_id'); // in case of status change
238                         display_notification(_("Item has been updated."));
239                 } 
240                 else 
241                 { //it is a NEW part
242
243                         add_item($_POST['NewStockID'], $_POST['description'],
244                                 $_POST['long_description'], $_POST['category_id'], $_POST['tax_type_id'],
245                                 $_POST['units'], get_post('fixed_asset') ? 'F' : get_post('mb_flag'), $_POST['sales_account'],
246                                 $_POST['inventory_account'], $_POST['cogs_account'],
247                                 $_POST['adjustment_account'], $_POST['assembly_account'], 
248                                 $_POST['dimension_id'], $_POST['dimension2_id'],
249                                 check_value('no_sale'), check_value('editable'), check_value('no_purchase'),
250                                 get_post('depreciation_method'), get_post('depreciation_rate'), get_post('depreciation_start'),
251                                 get_post('fa_class_id'));
252
253                         display_notification(_("A new item has been added."));
254                         $_POST['stock_id'] = $_POST['NewStockID'] = 
255                         $_POST['description'] = $_POST['long_description'] = '';
256                         $_POST['no_sale'] = $_POST['editable'] = $_POST['no_purchase'] =0;
257                         set_focus('NewStockID');
258                 }
259                 $Ajax->activate('_page_body');
260         }
261 }
262
263 if (get_post('clone')) {
264         unset($_POST['stock_id']);
265         $stock_id = '';
266         unset($_POST['inactive']);
267         set_focus('NewStockID');
268         $Ajax->activate('_page_body');
269 }
270
271 //------------------------------------------------------------------------------------
272
273 function check_usage($stock_id, $dispmsg=true)
274 {
275         $msg = item_in_foreign_codes($stock_id);
276
277         if ($msg != '') {
278                 if($dispmsg) display_error($msg);
279                 return false;
280         }
281         return true;
282 }
283
284 //------------------------------------------------------------------------------------
285
286 if (isset($_POST['delete']) && strlen($_POST['delete']) > 1) 
287 {
288
289         if (check_usage($_POST['NewStockID'])) {
290
291                 $stock_id = $_POST['NewStockID'];
292                 delete_item($stock_id);
293                 $filename = company_path().'/images/'.item_img_name($stock_id).".jpg";
294                 if (file_exists($filename))
295                         unlink($filename);
296                 display_notification(_("Selected item has been deleted."));
297                 $_POST['stock_id'] = '';
298                 clear_data();
299                 set_focus('stock_id');
300                 $new_item = true;
301                 $Ajax->activate('_page_body');
302         }
303 }
304
305 function item_settings(&$stock_id, $new_item) 
306 {
307         global $SysPrefs, $path_to_root, $page_nested, $depreciation_methods;
308
309         start_outer_table(TABLESTYLE2);
310
311         table_section(1);
312
313         table_section_title(_("General Settings"));
314
315         //------------------------------------------------------------------------------------
316         if ($new_item) 
317         {
318                 text_row(_("Item Code:"), 'NewStockID', null, 21, 20);
319
320                 $_POST['inactive'] = 0;
321         } 
322         else 
323         { // Must be modifying an existing item
324                 if (get_post('NewStockID') != get_post('stock_id') || get_post('addupdate')) { // first item display
325
326                         $_POST['NewStockID'] = $_POST['stock_id'];
327
328                         $myrow = get_item($_POST['NewStockID']);
329
330                         $_POST['long_description'] = $myrow["long_description"];
331                         $_POST['description'] = $myrow["description"];
332                         $_POST['category_id']  = $myrow["category_id"];
333                         $_POST['tax_type_id']  = $myrow["tax_type_id"];
334                         $_POST['units']  = $myrow["units"];
335                         $_POST['mb_flag']  = $myrow["mb_flag"];
336
337                         $_POST['depreciation_method'] = $myrow['depreciation_method'];
338                         $_POST['depreciation_rate'] = $myrow['depreciation_rate'];
339                         $_POST['depreciation_start'] = sql2date($myrow['depreciation_start']);
340                         $_POST['depreciation_date'] = sql2date($myrow['depreciation_date']);
341                         $_POST['fa_class_id'] = $myrow['fa_class_id'];
342                         $_POST['material_cost'] = $myrow['material_cost'];
343
344                         $_POST['sales_account'] =  $myrow['sales_account'];
345                         $_POST['inventory_account'] = $myrow['inventory_account'];
346                         $_POST['cogs_account'] = $myrow['cogs_account'];
347                         $_POST['adjustment_account']    = $myrow['adjustment_account'];
348                         $_POST['assembly_account']      = $myrow['assembly_account'];
349                         $_POST['dimension_id']  = $myrow['dimension_id'];
350                         $_POST['dimension2_id'] = $myrow['dimension2_id'];
351                         $_POST['no_sale']       = $myrow['no_sale'];
352                         $_POST['no_purchase']   = $myrow['no_purchase'];
353                         $_POST['del_image'] = 0;
354                         $_POST['inactive'] = $myrow["inactive"];
355                         $_POST['editable'] = $myrow["editable"];
356                 }
357                 label_row(_("Item Code:"),$_POST['NewStockID']);
358                 hidden('NewStockID', $_POST['NewStockID']);
359                 set_focus('description');
360         }
361         $fixed_asset = get_post('fixed_asset');
362
363         text_row(_("Name:"), 'description', null, 52, 200);
364
365         textarea_row(_('Description:'), 'long_description', null, 42, 3);
366
367         stock_categories_list_row(_("Category:"), 'category_id', null, false, $new_item, $fixed_asset);
368
369         if ($new_item && (list_updated('category_id') || !isset($_POST['units']))) {
370
371                 $category_record = get_item_category($_POST['category_id']);
372
373                 $_POST['tax_type_id'] = $category_record["dflt_tax_type"];
374                 $_POST['units'] = $category_record["dflt_units"];
375                 $_POST['mb_flag'] = $category_record["dflt_mb_flag"];
376                 $_POST['inventory_account'] = $category_record["dflt_inventory_act"];
377                 $_POST['cogs_account'] = $category_record["dflt_cogs_act"];
378                 $_POST['sales_account'] = $category_record["dflt_sales_act"];
379                 $_POST['adjustment_account'] = $category_record["dflt_adjustment_act"];
380                 $_POST['assembly_account'] = $category_record["dflt_assembly_act"];
381                 $_POST['dimension_id'] = $category_record["dflt_dim1"];
382                 $_POST['dimension2_id'] = $category_record["dflt_dim2"];
383                 $_POST['no_sale'] = $category_record["dflt_no_sale"];
384                 $_POST['no_purchase'] = $category_record["dflt_no_purchase"];
385                 $_POST['editable'] = 0;
386
387         }
388         $fresh_item = !isset($_POST['NewStockID']) || $new_item 
389                 || check_usage($_POST['stock_id'],false);
390
391         item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null);
392
393         if (!get_post('fixed_asset'))
394                 stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item);
395
396         stock_units_list_row(_('Units of Measure:'), 'units', null, $fresh_item);
397
398         check_row(_("Editable description:"), 'editable');
399
400         if (get_post('fixed_asset'))
401                 hidden('no_sale', 0);
402         else
403                 check_row(_("Exclude from sales:"), 'no_sale');
404
405         check_row(_("Exclude from purchases:"), 'no_purchase');
406
407         if (get_post('fixed_asset')) {
408                 table_section_title(_("Depreciation"));
409
410                 fixed_asset_classes_list_row(_("Fixed Asset Class").':', 'fa_class_id', null, false, true);
411
412                 array_selector_row(_("Depreciation Method").":", "depreciation_method", null, $depreciation_methods, array('select_submit'=> true));
413
414                 if (!isset($_POST['depreciation_rate']) || (list_updated('fa_class_id') || list_updated('depreciation_method'))) {
415                         $class_row = get_fixed_asset_class($_POST['fa_class_id']);
416
417                         if ($_POST['depreciation_method'] == 'S')
418                                 $_POST['depreciation_rate'] = $class_row['depreciation_period'];
419                         else
420                                 $_POST['depreciation_rate'] = $class_row['depreciation_rate'];
421                         }
422
423                         switch ($_POST['depreciation_method']) {
424                                 case 'D':
425                                         small_amount_row(_("Depreciation Rate").':', 'depreciation_rate', null, null, '%', user_percent_dec());
426                                         break;
427                                 case 'S':
428                                         text_row_ex(_("Depreciation Period").':', 'depreciation_rate', 3, 3, '', null, null, _("years"));
429                                         break;
430                                 case 'O':
431                                         hidden('depreciation_rate', 100);
432                                         label_row(_("Depreciation Rate").':', "100 %");
433                                         break;
434                         }
435
436                         // do not allow to change the depreciation start after this item has been depreciated
437                         if ($new_item || $_POST['depreciation_start'] == $_POST['depreciation_date'])
438                                 date_row(_("Depreciation Start").':', 'depreciation_start', null, null, 1 - date('j'));
439                         else {
440                                 hidden('depreciation_start');
441                                 label_row(_("Depreciation Start").':', $_POST['depreciation_start']);
442                                 label_row(_("Last Depreciation").':', $_POST['depreciation_date']);
443                         }
444                         hidden('depreciation_date');
445
446                         if (!$new_item) {
447                                 hidden('material_cost');
448                                 label_row(_("Current Value").':', price_format($_POST['material_cost']));
449                         }
450         }
451         table_section(2);
452
453         $dim = get_company_pref('use_dimension');
454         if ($dim >= 1)
455         {
456                 table_section_title(_("Dimensions"));
457
458                 dimensions_list_row(_("Dimension")." 1", 'dimension_id', null, true, " ", false, 1);
459                 if ($dim > 1)
460                         dimensions_list_row(_("Dimension")." 2", 'dimension2_id', null, true, " ", false, 2);
461         }
462         if ($dim < 1)
463                 hidden('dimension_id', 0);
464         if ($dim < 2)
465                 hidden('dimension2_id', 0);
466
467         table_section_title(_("GL Accounts"));
468
469         gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']);
470
471         if (get_post('fixed_asset')) {
472                 gl_all_accounts_list_row(_("Asset account:"), 'inventory_account', $_POST['inventory_account']);
473                 gl_all_accounts_list_row(_("Depreciation cost account:"), 'cogs_account', $_POST['cogs_account']);
474                 gl_all_accounts_list_row(_("Depreciation/Disposal account:"), 'adjustment_account', $_POST['adjustment_account']);
475         }
476         elseif (!is_service($_POST['mb_flag'])) 
477         {
478                 gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
479                 gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
480                 gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']);
481         }
482         else 
483         {
484                 gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
485                 hidden('inventory_account', $_POST['inventory_account']);
486                 hidden('adjustment_account', $_POST['adjustment_account']);
487         }
488
489
490         if (is_manufactured($_POST['mb_flag']))
491                 gl_all_accounts_list_row(_("Item Assembly Costs Account:"), 'assembly_account', $_POST['assembly_account']);
492         else
493                 hidden('assembly_account', $_POST['assembly_account']);
494
495         table_section_title(_("Other"));
496
497         // Add image upload for New Item  - by Joe
498         file_row(_("Image File (.jpg)") . ":", 'pic', 'pic');
499         // Add Image upload for New Item  - by Joe
500         $stock_img_link = "";
501         $check_remove_image = false;
502         if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/'
503                 .item_img_name($_POST['NewStockID']).".jpg")) 
504         {
505          // 31/08/08 - rand() call is necessary here to avoid caching problems.
506                 $stock_img_link .= "<img id='item_img' alt = '[".$_POST['NewStockID'].".jpg".
507                         "]' src='".company_path().'/images/'.item_img_name($_POST['NewStockID']).
508                         ".jpg?nocache=".rand()."'"." height='".$SysPrefs->pic_height."' border='0'>";
509                 $check_remove_image = true;
510         } 
511         else 
512         {
513                 $stock_img_link .= _("No image");
514         }
515
516         label_row("&nbsp;", $stock_img_link);
517         if ($check_remove_image)
518                 check_row(_("Delete Image:"), 'del_image');
519
520         record_status_list_row(_("Item status:"), 'inactive');
521         end_outer_table(1);
522
523         div_start('controls');
524         if (!isset($_POST['NewStockID']) || $new_item) 
525         {
526                 submit_center('addupdate', _("Insert New Item"), true, '', 'default');
527         } 
528         else 
529         {
530                 submit_center_first('addupdate', _("Update Item"), '', 
531                         $page_nested ? true : 'default');
532                 submit_return('select', get_post('stock_id'), 
533                         _("Select this items and return to document entry."), 'default');
534                 submit('clone', _("Clone This Item"), true, '', true);
535                 submit('delete', _("Delete This Item"), true, '', true);
536                 submit_center_last('cancel', _("Cancel"), _("Cancel Edition"), 'cancel');
537         }
538
539         div_end();
540 }
541
542 //-------------------------------------------------------------------------------------------- 
543
544 start_form(true);
545
546 if (db_has_stock_items()) 
547 {
548         start_table(TABLESTYLE_NOBORDER);
549         start_row();
550     stock_items_list_cells(_("Select an item:"), 'stock_id', null,
551           _('New item'), true, check_value('show_inactive'), false, array('fixed_asset' => get_post('fixed_asset')));
552         $new_item = get_post('stock_id')=='';
553         check_cells(_("Show inactive:"), 'show_inactive', null, true);
554         end_row();
555         end_table();
556
557         if (get_post('_show_inactive_update')) {
558                 $Ajax->activate('stock_id');
559                 set_focus('stock_id');
560         }
561 }
562 else
563 {
564         hidden('stock_id', get_post('stock_id'));
565 }
566
567 div_start('details');
568
569 $stock_id = get_post('stock_id');
570 if (!$stock_id)
571         unset($_POST['_tabs_sel']); // force settings tab for new customer
572
573 $tabs = (get_post('fixed_asset'))
574         ? array(
575                 'settings' => array(_('&General settings'), $stock_id),
576                 'movement' => array(_('&Transactions'), $stock_id) )
577         : array(
578                 'settings' => array(_('&General settings'), $stock_id),
579                 'sales_pricing' => array(_('S&ales Pricing'), $stock_id),
580                 'purchase_pricing' => array(_('&Purchasing Pricing'), $stock_id),
581                 'standard_cost' => array(_('Standard &Costs'), $stock_id),
582                 'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) ? $stock_id : null)),
583                 'movement' => array(_('&Transactions'), $stock_id),
584                 'status' => array(_('&Status'), (is_inventory_item($stock_id) ? $stock_id : null)),
585         );
586
587 tabbed_content_start('tabs', $tabs);
588
589         switch (get_post('_tabs_sel')) {
590                 default:
591                 case 'settings':
592                         item_settings($stock_id, $new_item); 
593                         break;
594                 case 'sales_pricing':
595                         $_GET['stock_id'] = $stock_id;
596                         $_GET['page_level'] = 1;
597                         include_once($path_to_root."/inventory/prices.php");
598                         break;
599                 case 'purchase_pricing':
600                         $_GET['stock_id'] = $stock_id;
601                         $_GET['page_level'] = 1;
602                         include_once($path_to_root."/inventory/purchasing_data.php");
603                         break;
604                 case 'standard_cost':
605                         $_GET['stock_id'] = $stock_id;
606                         $_GET['page_level'] = 1;
607                         include_once($path_to_root."/inventory/cost_update.php");
608                         break;
609                 case 'reorder_level':
610                         if (!is_inventory_item($stock_id))
611                         {
612                                 break;
613                         }       
614                         $_GET['page_level'] = 1;
615                         $_GET['stock_id'] = $stock_id;
616                         include_once($path_to_root."/inventory/reorder_level.php");
617                         break;
618                 case 'movement':
619                         $_GET['stock_id'] = $stock_id;
620                         include_once($path_to_root."/inventory/inquiry/stock_movements.php");
621                         break;
622                 case 'status':
623                         $_GET['stock_id'] = $stock_id;
624                         include_once($path_to_root."/inventory/inquiry/stock_status.php");
625                         break;
626         };
627
628 br();
629 tabbed_content_end();
630
631 div_end();
632
633 hidden('fixed_asset', get_post('fixed_asset'));
634
635 if (get_post('fixed_asset'))
636         hidden('mb_flag', 'F');
637
638 end_form();
639
640 //------------------------------------------------------------------------------------
641
642 end_page();