Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import { AppRegistry, StyleSheet, TextInput, Image, SafeAreaView, BackHandler, TouchableOpacity, TouchableHighlight, ActivityIndicator, Platform, RefreshControl, Modal } from 'react-native';
- import DatePicker from 'react-native-datepicker'
- import BarcodeScanner, { TorchMode, CameraFillMode, FocusMode, FlashMode, BarcodeType } from 'react-native-barcode-scanner-google';
- import { Text, View, Item, Input, Icon, Button, Left, Right } from 'native-base';
- import { ListItem, SearchBar } from 'react-native-elements';
- import { RNCamera } from 'react-native-camera';
- import BarcodeMask from 'react-native-barcode-mask';
- import { ScrollView } from 'react-native-gesture-handler';
- export default class StockCheck extends Component {
- static navigationOptions = {
- title: 'Stock Check',
- tabBarOptions: {
- labelStyle: {
- fontSize: 16,
- color: '#52c5d8',
- },
- style: {
- backgroundColor: '#fff',
- borderRadius: 15,
- },
- },
- };
- constructor(props) {
- super(props);
- this.state = {
- isLoading: false,
- search: '',
- modenya: '',
- barcode: '',
- nama: '',
- qty_onHeand: '',
- qty_commited: '',
- on_order: '',
- available: '',
- connection_Status: ""
- }
- this.arrayholder = [];
- }
- BacktoHome = () => {
- this.props.navigation.navigate('Home')
- };
- componentDidMount() {
- BackHandler.addEventListener("hardwareBackPress", this.BacktoHome);
- }
- onRefresh() {
- //Clear old data of the list
- this.setState({ dataSource: [] });
- //Call the Service to get the latest data
- this.GetData();
- }
- refreshpage = () => {
- const { navigation } = this.props;
- this.props.navigation.navigate('HomeBoards', {
- emailnya: navigation.getParam('emailnya', 'NO-emailnya'),
- passwordnya: navigation.getParam('passwordnya', 'NO-IdDatabase'),
- idDbase: navigation.getParam('idDbase', 'NO-IdDatabase'),
- Dbname: navigation.getParam('Dbname', 'NO-Dbname')
- })
- };
- FlatListItemSeparator = () => {
- return (
- <View
- style={{
- height: 1,
- width: "100%",
- backgroundColor: "#607D8B",
- }}
- />
- );
- }
- renderSeparator = () => {
- return (
- <View
- style={{
- height: 1,
- width: '86%',
- backgroundColor: '#CED0CE',
- marginLeft: '14%',
- }}
- />
- );
- };
- handleChange = () => {
- this.setState({ barcode: barcode });// handle user input
- }
- GetData = ({ data, type }) => {
- const { navigation } = this.props;
- const idDbase = navigation.getParam('idDbase', 'NO-User');
- const ItmsGrpCod = navigation.getParam('ItmsGrpCod', 'NO-Pass');
- this.setState({ barcodenya: data })
- fetch('https://www.taysbakers.com/apiims/inv_searcbarcodesap.php', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- // ItmsGrpCod: navigation.getParam('ItmsGrpCod', 'NO-ItmsGrpCod'),
- mode: idDbase,
- ItemCode: data,
- })
- })
- .then((response) => response.json())
- .then((responseJson) => {
- if ((responseJson != [])) {
- this.setState({
- ItemCode: data,
- ItemName: responseJson[0].ItemName,
- OnHand: responseJson[0].OnHand,
- IsCommited: responseJson[0].IsCommited,
- OnOrder: responseJson[0].OnOrder,
- Availablenya: responseJson[0].Avalaible,
- })
- }
- else {
- alert("Code Barcode yang anda cari tidak ada di database ini");
- }
- })
- .catch((error) => {
- console.error(error);
- });
- }
- Savestockchecking = () => {
- if (this.state.ItemCode == null || this.state.ItemCode == "") {
- alert('Empety Itemcode')
- } else if (this.state.ItemName == null || this.state.ItemName == "") {
- alert('Empety Itemname')
- } else if (this.state.OnHand == null || this.state.OnHand == "") {
- alert('Empety Onhand')
- } else if (this.state.IsCommited == null || this.state.IsCommited == "") {
- alert('Empety Iscomminted')
- } else if (this.state.OnOrder == null || this.state.OnOrder == "") {
- alert('Empety OnOrder')
- } else if (this.state.Availablenya == null || this.state.Availablenya == "") {
- alert('Empety Available')
- }
- else {
- const { navigation } = this.props;
- //https://tracessystem.com/apiims/input_stockcheck.php
- fetch('https://tracessystem.com/apiims/input_stockcheck.php', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- // ItmsGrpCod: navigation.getParam('ItmsGrpCod', 'NO-ItmsGrpCod'),
- itemcodenya: this.state.ItemCode,
- namecodenya: this.state.ItemName,
- onhannya: this.state.OnHand,
- iscommitednya: this.state.IsCommited,
- onordernya:this.state.OnOrder,
- availablenya: this.state.Availablenya,
- nodoxnya: navigation.getParam('RandomId', 'NO-IdDatabase'),
- pemeriksanya: navigation.getParam('pemeriksa', 'NO-IdDatabase'),
- lokasinya: navigation.getParam('nameWh', 'NO-IdDatabase'),
- Dbasenya:navigation.getParam('idDbase', 'NO-IdDatabase'),
- checkernya: navigation.getParam('emailnya', 'NO-User')
- })
- })
- .then((response) => response.json())
- .then((responseJson) => {
- this.setState({
- barcodenya:'',
- ItemCode: '',
- ItemName: '',
- OnHand: '',
- IsCommited: '',
- OnOrder: '',
- Availablenya: '',
- })
- })
- .catch((error) => {
- console.error(error);
- });
- }
- }
- handleClear = () => {
- this.setState({
- ItemCode: '',
- ItemName: '',
- OnHand: '',
- IsCommited: '',
- OnOrder: '',
- Availablenya: '',
- })
- }
- render() {
- if (this.state.isLoading) {
- return (
- <View style={{ flex: 1, paddingTop: 20 }}>
- <ActivityIndicator />
- </View>
- );
- }
- // const { navigation } = this.props;
- // const id_sales1 = navigation.getParam('idSales', 'NO-Pass');
- items = this.state.serverData
- const { navigation } = this.props;
- const RandomId = navigation.getParam('RandomId', 'Kode Barcode');
- const pemeriksa = navigation.getParam('pemeriksa', 'NO-User');
- const nameWh = navigation.getParam('nameWh', 'NO-User');
- const idDbase = navigation.getParam('idDbase', 'NO-IdDatabase');
- const usernya=navigation.getParam('emailnya', 'NO-User');
- return (
- <View style={styles.container}>
- <ScrollView>
- {/* <View style={{paddingVertical: 60}} /> */}
- <BarcodeScanner
- style={{height: 290,}}
- cameraType='back'
- focusMode={FocusMode.TAP /* could also be TAP or FIXED */}
- onBarcodeRead={({ data, type }) => {
- this.GetData({ data, type });
- }}
- cameraFillMode={CameraFillMode.FIT /* could also be FIT */}
- FlashMode={FlashMode.OFF /* 0 is OFF or 1 is TORCH */}
- />
- <View style={styles.lowerSection}>
- <Item>
- <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
- <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/scanner.png')} /></View>
- <View>
- <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Item Code</Text>
- <Text style={{ fontSize: 14 }}>{this.state.ItemCode}</Text>
- </View>
- </View>
- </Item>
- <Item>
- <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
- <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/item_name.png')} /></View>
- <View>
- <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Item Name</Text>
- <Text style={{ fontSize: 14 }}>{this.state.ItemName}</Text>
- </View>
- </View>
- </Item>
- <Item>
- <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
- <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/quality_onhand.png')} /></View>
- <View>
- <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Quantity OnHand</Text>
- <Text style={{ fontSize: 14 }}>{this.state.OnHand}</Text>
- </View>
- </View>
- </Item>
- <Item>
- <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
- <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/quality_is_commited.png')} /></View>
- <View>
- <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Quantity IsCommited</Text>
- <Text style={{ fontSize: 14 }}>{this.state.IsCommited}</Text>
- </View>
- </View>
- </Item>
- <Item>
- <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
- <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/NAME.png')} /></View>
- <View>
- <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Quantity OnOrder</Text>
- <Text style={{ fontSize: 14 }}>{this.state.OnOrder}</Text>
- </View>
- </View>
- </Item>
- <Item>
- <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
- <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/quality_available.png')} /></View>
- <View>
- <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Quantity Available</Text>
- <Text style={{ fontSize: 14 }}>{this.state.Availablenya}</Text>
- </View>
- </View>
- </Item>
- <View style={{ paddingTop: 20 }}>
- <SafeAreaView style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
- <View style={{ flexDirection: 'row' }}>
- <Left>
- <View style={{ marginHorizontal: 17, paddingTop: 15 }}>
- <Button small rounded warning onPress={this.Savestockchecking} >
- <Text style={{ color: '#fff' }}> Save </Text>
- </Button>
- </View>
- </Left>
- <Right>
- <View style={{ marginHorizontal: 17, paddingTop: 15 }}>
- <Button small rounded danger onPress={this.handleClear}>
- <Text style={{ color: '#fff' }}> Cancel </Text>
- </Button>
- </View>
- </Right>
- </View>
- </SafeAreaView>
- </View>
- </View>
- </ScrollView>
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- backgroundColor: 'black',
- // paddingTop: 50,
- alignItems: 'center',
- justifyContent: 'center'
- },
- lowerSection: {
- paddingBottom: 30,
- paddingHorizontal: 20,
- backgroundColor: 'white',
- },
- preview: {
- flex: 1,
- justifyContent: 'flex-end',
- alignItems: 'center',
- },
- capture: {
- flex: 0,
- backgroundColor: '#fff',
- borderRadius: 5,
- padding: 15,
- paddingHorizontal: 20,
- alignSelf: 'center',
- margin: 20,
- },
- txt: {
- color: 'gray',
- fontSize: 14,
- textAlign: 'left'
- }
- // modalViewContainer: {
- // height: '100%',
- // width: '100%',
- // backgroundColor: 'white',
- // borderRadius: 3
- // }
- });
- AppRegistry.registerComponent('StockCheck', () => StockCheck);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement