} elseif ($ean['serial'] && $ean['serial'] != $default_number) { $res = cw_serials_add($user_account['warehouse_customer_id'], $product_id, $ean['serial']); $result['numbers'] = $ean['serial']; if (!$res) { $result['error'] = 2; } } } if (!$result['error']) { $current_avail = cw_warehouse_get_warehouse_avail($user_account['warehouse_customer_id'], $product_info['product_id'], null, $product_info['variant_id']); $insert = array(); $insert['avail'] = intval($current_avail) + 1; $insert['warehouse_customer_id'] = $user_account['warehouse_customer_id']; $insert['variant_id'] = $product_info['variant_id']; $insert['product_id'] = $product_info['product_id']; cw_warehouse_insert_avail($insert, true); } } else { $result['error'] = 1; } $ean_products[] = $result; } if (count($ean_products)) { $mode = 'result'; } else { cw_header_location('index.php?target=ean_serials'); } } if ($mode == 'result' && is_array($ean_products)) { $errors_arr = array('1' => cw_get_langvar_by_name('lbl_not_found'), '2' => cw_get_langvar_by_name('lbl_err_serial_already_exists')); foreach ($ean_products as $k => $v) {
$product_ids = array_keys($product_ids); $ge_id = cw_group_edit_add($product_ids); $product_id = $product_ids[0]; cw_header_location('index.php?target=products&mode=details&product_id=' . $product_id . '&ge_id=' . $ge_id); } } if ($action == 'update' && is_array($posted_data)) { cw_load('product'); foreach ($posted_data as $k => $v) { if (isset($v['orderby']) && is_numeric($v['orderby'])) { $cat = intval($cat); db_query("update {$tables['products_categories']} set orderby='" . $v['orderby'] . "' where product_id='{$k}' and category_id='{$cat}'"); } if (AREA_TYPE == 'P') { $wu = array('avail' => $v['avail'], 'product_id' => $k, 'warehouse_customer_id' => $customer_id, 'variant_id' => 0); cw_warehouse_insert_avail($wu, true); } elseif (!$addons['warehouse']) { cw_array2update('products', array('avail' => $v['avail']), "product_id='{$k}'"); } else { cw_array2update('products_warehouses_amount', array('avail' => $v['avail']), "product_id='{$k}'"); } // TODO, TOFIX: Does it set avail for all warehouses? Maybe use warehouses=0 as condition? if (AREA_TYPE == 'A') { # kornev, variant product is possible here. # cw_price_lists_replace_price($k, $v['price'], 0, false, $v['is_manual_price']); cw_call('cw_product_update_status', array($k, $v['status'])); } } $top_message = array('content' => cw_get_langvar_by_name('msg_adm_products_upd'), 'type' => 'I'); if ($cat) { cw_header_location('index.php?target=categories&mode=products&cat=' . $cat);