X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fmanage%2Fitems.php;h=d3af29ea44dda68bdbe0c6f613085e781a245ff5;hb=bdeb340a0330f79b276d47252ea09ce7d9afad3c;hp=07cfcfcd0faa45060b198d451b99f071b309aee8;hpb=dfb5670c0eb599ea0df7a9148a2864feec324e74;p=fa-stable.git diff --git a/inventory/manage/items.php b/inventory/manage/items.php index 07cfcfcd..d3af29ea 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -316,8 +316,18 @@ function item_settings(&$stock_id, $new_item) //------------------------------------------------------------------------------------ if ($new_item) { - text_row(_("Item Code:"), 'NewStockID', null, 21, 20); - + $tmpCodeID=null; + $post_label = null; + if (!empty($SysPrefs->prefs['barcodes_on_stock'])) + { + $post_label = ''; + if (isset($_POST['generateBarcode'])) + { + $tmpCodeID=generateBarcode(); + $_POST['NewStockID'] = $tmpCodeID; + } + } + text_row(_("Item Code:"), 'NewStockID', $tmpCodeID, 21, 20, null, "", $post_label); $_POST['inactive'] = 0; } else @@ -391,7 +401,8 @@ function item_settings(&$stock_id, $new_item) $fresh_item = !isset($_POST['NewStockID']) || $new_item || check_usage($_POST['stock_id'],false); - item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null); + // show inactive item tax type in selector only if already set. + item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null, !$new_item && item_type_inactive(get_post('tax_type_id'))); if (!get_post('fixed_asset')) stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item); @@ -530,6 +541,7 @@ function item_settings(&$stock_id, $new_item) end_outer_table(1); div_start('controls'); + if (@$_REQUEST['popup']) hidden('popup', 1); if (!isset($_POST['NewStockID']) || $new_item) { submit_center('addupdate', _("Insert New Item"), true, '', 'default'); @@ -539,7 +551,7 @@ function item_settings(&$stock_id, $new_item) submit_center_first('addupdate', _("Update Item"), '', $page_nested ? true : 'default'); submit_return('select', get_post('stock_id'), - _("Select this items and return to document entry."), 'default'); + _("Select this items and return to document entry.")); submit('clone', _("Clone This Item"), true, '', true); submit('delete', _("Delete This Item"), true, '', true); submit_center_last('cancel', _("Cancel"), _("Cancel Edition"), 'cancel'); @@ -585,12 +597,14 @@ $tabs = (get_post('fixed_asset')) 'movement' => array(_('&Transactions'), $stock_id) ) : array( 'settings' => array(_('&General settings'), $stock_id), - 'sales_pricing' => array(_('S&ales Pricing'), $stock_id), - 'purchase_pricing' => array(_('&Purchasing Pricing'), $stock_id), - 'standard_cost' => array(_('Standard &Costs'), $stock_id), - 'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) ? $stock_id : null)), - 'movement' => array(_('&Transactions'), $stock_id), - 'status' => array(_('&Status'), (is_inventory_item($stock_id) ? $stock_id : null)), + 'sales_pricing' => array(_('S&ales Pricing'), (user_check_access('SA_SALESPRICE') ? $stock_id : null)), + 'purchase_pricing' => array(_('&Purchasing Pricing'), (user_check_access('SA_PURCHASEPRICING') ? $stock_id : null)), + 'standard_cost' => array(_('Standard &Costs'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)), + 'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) && + user_check_access('SA_REORDER') ? $stock_id : null)), + 'movement' => array(_('&Transactions'), (user_check_access('SA_ITEMSTRANSVIEW') && is_inventory_item($stock_id) ? + $stock_id : null)), + 'status' => array(_('&Status'), (user_check_access('SA_ITEMSSTATVIEW') ? $stock_id : null)), ); tabbed_content_start('tabs', $tabs); @@ -617,14 +631,14 @@ tabbed_content_start('tabs', $tabs); break; case 'reorder_level': if (!is_inventory_item($stock_id)) - { break; - } $_GET['page_level'] = 1; $_GET['stock_id'] = $stock_id; include_once($path_to_root."/inventory/reorder_level.php"); break; case 'movement': + if (!is_inventory_item($stock_id)) + break; $_GET['stock_id'] = $stock_id; include_once($path_to_root."/inventory/inquiry/stock_movements.php"); break; @@ -649,3 +663,41 @@ end_form(); //------------------------------------------------------------------------------------ end_page(); + +function generateBarcode() { + $tmpBarcodeID = ""; + $tmpCountTrys = 0; + while ($tmpBarcodeID == "") { + srand ((double) microtime( )*1000000); + $random_1 = rand(1,9); + $random_2 = rand(0,9); + $random_3 = rand(0,9); + $random_4 = rand(0,9); + $random_5 = rand(0,9); + $random_6 = rand(0,9); + $random_7 = rand(0,9); + //$random_8 = rand(0,9); + + // http://stackoverflow.com/questions/1136642/ean-8-how-to-calculate-checksum-digit + $sum1 = $random_2 + $random_4 + $random_6; + $sum2 = 3 * ($random_1 + $random_3 + $random_5 + $random_7 ); + $checksum_value = $sum1 + $sum2; + + $checksum_digit = 10 - ($checksum_value % 10); + if ($checksum_digit == 10) + $checksum_digit = 0; + + $random_8 = $checksum_digit; + + $tmpBarcodeID = $random_1 . $random_2 . $random_3 . $random_4 . $random_5 . $random_6 . $random_7 . $random_8; + + // LETS CHECK TO SEE IF THIS NUMBER HAS EVER BEEN USED + $query = "SELECT stock_id FROM ".TB_PREF."stock_master WHERE stock_id='" . $tmpBarcodeID . "'"; + $arr_stock = db_fetch(db_query($query)); + + if ( !$arr_stock['stock_id'] ) { + return $tmpBarcodeID; + } + $tmpBarcodeID = ""; + } +}