Advertisement
Guest User

Untitled

a guest
Mar 26th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.61 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. import { AppRegistry, StyleSheet, TextInput, Image, SafeAreaView, BackHandler, TouchableOpacity, TouchableHighlight, ActivityIndicator, Platform, RefreshControl, Modal } from 'react-native';
  4. import DatePicker from 'react-native-datepicker'
  5. import BarcodeScanner, { TorchMode, CameraFillMode, FocusMode, FlashMode, BarcodeType } from 'react-native-barcode-scanner-google';
  6. import { Text, View, Item, Input, Icon, Button, Left, Right } from 'native-base';
  7. import { ListItem, SearchBar } from 'react-native-elements';
  8. import { RNCamera } from 'react-native-camera';
  9. import BarcodeMask from 'react-native-barcode-mask';
  10. import { ScrollView } from 'react-native-gesture-handler';
  11.  
  12.  
  13.  
  14. export default class StockCheck extends Component {
  15.  
  16. static navigationOptions = {
  17. title: 'Stock Check',
  18. tabBarOptions: {
  19. labelStyle: {
  20. fontSize: 16,
  21. color: '#52c5d8',
  22. },
  23. style: {
  24. backgroundColor: '#fff',
  25. borderRadius: 15,
  26. },
  27. },
  28. };
  29.  
  30. constructor(props) {
  31.  
  32. super(props);
  33.  
  34. this.state = {
  35. isLoading: false,
  36. search: '',
  37. modenya: '',
  38. barcode: '',
  39. nama: '',
  40. qty_onHeand: '',
  41. qty_commited: '',
  42. on_order: '',
  43. available: '',
  44. connection_Status: ""
  45. }
  46. this.arrayholder = [];
  47. }
  48. BacktoHome = () => {
  49. this.props.navigation.navigate('Home')
  50. };
  51. componentDidMount() {
  52.  
  53. BackHandler.addEventListener("hardwareBackPress", this.BacktoHome);
  54.  
  55. }
  56.  
  57.  
  58. onRefresh() {
  59. //Clear old data of the list
  60. this.setState({ dataSource: [] });
  61. //Call the Service to get the latest data
  62. this.GetData();
  63. }
  64.  
  65. refreshpage = () => {
  66. const { navigation } = this.props;
  67. this.props.navigation.navigate('HomeBoards', {
  68.  
  69.  
  70. emailnya: navigation.getParam('emailnya', 'NO-emailnya'),
  71. passwordnya: navigation.getParam('passwordnya', 'NO-IdDatabase'),
  72. idDbase: navigation.getParam('idDbase', 'NO-IdDatabase'),
  73. Dbname: navigation.getParam('Dbname', 'NO-Dbname')
  74.  
  75. })
  76.  
  77. };
  78.  
  79.  
  80. FlatListItemSeparator = () => {
  81. return (
  82. <View
  83. style={{
  84. height: 1,
  85. width: "100%",
  86. backgroundColor: "#607D8B",
  87. }}
  88. />
  89. );
  90. }
  91.  
  92. renderSeparator = () => {
  93. return (
  94. <View
  95. style={{
  96. height: 1,
  97. width: '86%',
  98. backgroundColor: '#CED0CE',
  99. marginLeft: '14%',
  100. }}
  101. />
  102. );
  103. };
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112. handleChange = () => {
  113. this.setState({ barcode: barcode });// handle user input
  114. }
  115.  
  116. GetData = ({ data, type }) => {
  117.  
  118.  
  119.  
  120. const { navigation } = this.props;
  121. const idDbase = navigation.getParam('idDbase', 'NO-User');
  122. const ItmsGrpCod = navigation.getParam('ItmsGrpCod', 'NO-Pass');
  123.  
  124.  
  125. this.setState({ barcodenya: data })
  126.  
  127.  
  128. fetch('https://www.taysbakers.com/apiims/inv_searcbarcodesap.php', {
  129. method: 'POST',
  130. headers: {
  131. 'Accept': 'application/json',
  132. 'Content-Type': 'application/json',
  133. },
  134. body: JSON.stringify({
  135. // ItmsGrpCod: navigation.getParam('ItmsGrpCod', 'NO-ItmsGrpCod'),
  136. mode: idDbase,
  137. ItemCode: data,
  138.  
  139. })
  140. })
  141. .then((response) => response.json())
  142. .then((responseJson) => {
  143. if ((responseJson != [])) {
  144. this.setState({
  145. ItemCode: data,
  146. ItemName: responseJson[0].ItemName,
  147. OnHand: responseJson[0].OnHand,
  148. IsCommited: responseJson[0].IsCommited,
  149. OnOrder: responseJson[0].OnOrder,
  150. Availablenya: responseJson[0].Avalaible,
  151.  
  152. })
  153. }
  154. else {
  155. alert("Code Barcode yang anda cari tidak ada di database ini");
  156. }
  157. })
  158. .catch((error) => {
  159. console.error(error);
  160. });
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. }
  168.  
  169. Savestockchecking = () => {
  170.  
  171.  
  172. if (this.state.ItemCode == null || this.state.ItemCode == "") {
  173. alert('Empety Itemcode')
  174. } else if (this.state.ItemName == null || this.state.ItemName == "") {
  175. alert('Empety Itemname')
  176. } else if (this.state.OnHand == null || this.state.OnHand == "") {
  177. alert('Empety Onhand')
  178. } else if (this.state.IsCommited == null || this.state.IsCommited == "") {
  179. alert('Empety Iscomminted')
  180. } else if (this.state.OnOrder == null || this.state.OnOrder == "") {
  181. alert('Empety OnOrder')
  182. } else if (this.state.Availablenya == null || this.state.Availablenya == "") {
  183. alert('Empety Available')
  184. }
  185. else {
  186. const { navigation } = this.props;
  187. //https://tracessystem.com/apiims/input_stockcheck.php
  188. fetch('https://tracessystem.com/apiims/input_stockcheck.php', {
  189. method: 'POST',
  190. headers: {
  191. 'Accept': 'application/json',
  192. 'Content-Type': 'application/json',
  193. },
  194. body: JSON.stringify({
  195. // ItmsGrpCod: navigation.getParam('ItmsGrpCod', 'NO-ItmsGrpCod'),
  196. itemcodenya: this.state.ItemCode,
  197. namecodenya: this.state.ItemName,
  198. onhannya: this.state.OnHand,
  199. iscommitednya: this.state.IsCommited,
  200. onordernya:this.state.OnOrder,
  201. availablenya: this.state.Availablenya,
  202. nodoxnya: navigation.getParam('RandomId', 'NO-IdDatabase'),
  203. pemeriksanya: navigation.getParam('pemeriksa', 'NO-IdDatabase'),
  204. lokasinya: navigation.getParam('nameWh', 'NO-IdDatabase'),
  205. Dbasenya:navigation.getParam('idDbase', 'NO-IdDatabase'),
  206. checkernya: navigation.getParam('emailnya', 'NO-User')
  207. })
  208. })
  209. .then((response) => response.json())
  210. .then((responseJson) => {
  211. this.setState({
  212. barcodenya:'',
  213. ItemCode: '',
  214. ItemName: '',
  215. OnHand: '',
  216. IsCommited: '',
  217. OnOrder: '',
  218. Availablenya: '',
  219. })
  220. })
  221. .catch((error) => {
  222. console.error(error);
  223. });
  224.  
  225. }
  226.  
  227.  
  228. }
  229.  
  230. handleClear = () => {
  231. this.setState({
  232. ItemCode: '',
  233. ItemName: '',
  234. OnHand: '',
  235. IsCommited: '',
  236. OnOrder: '',
  237. Availablenya: '',
  238. })
  239. }
  240.  
  241.  
  242. render() {
  243.  
  244. if (this.state.isLoading) {
  245. return (
  246. <View style={{ flex: 1, paddingTop: 20 }}>
  247. <ActivityIndicator />
  248. </View>
  249. );
  250. }
  251. // const { navigation } = this.props;
  252. // const id_sales1 = navigation.getParam('idSales', 'NO-Pass');
  253. items = this.state.serverData
  254. const { navigation } = this.props;
  255. const RandomId = navigation.getParam('RandomId', 'Kode Barcode');
  256. const pemeriksa = navigation.getParam('pemeriksa', 'NO-User');
  257. const nameWh = navigation.getParam('nameWh', 'NO-User');
  258. const idDbase = navigation.getParam('idDbase', 'NO-IdDatabase');
  259. const usernya=navigation.getParam('emailnya', 'NO-User');
  260.  
  261. return (
  262. <View style={styles.container}>
  263. <ScrollView>
  264. {/* <View style={{paddingVertical: 60}} /> */}
  265. <BarcodeScanner
  266. style={{height: 290,}}
  267. cameraType='back'
  268. focusMode={FocusMode.TAP /* could also be TAP or FIXED */}
  269. onBarcodeRead={({ data, type }) => {
  270. this.GetData({ data, type });
  271. }}
  272. cameraFillMode={CameraFillMode.FIT /* could also be FIT */}
  273. FlashMode={FlashMode.OFF /* 0 is OFF or 1 is TORCH */}
  274. />
  275.  
  276. <View style={styles.lowerSection}>
  277. <Item>
  278. <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
  279. <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/scanner.png')} /></View>
  280. <View>
  281. <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Item Code</Text>
  282. <Text style={{ fontSize: 14 }}>{this.state.ItemCode}</Text>
  283. </View>
  284. </View>
  285. </Item>
  286. <Item>
  287. <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
  288. <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/item_name.png')} /></View>
  289. <View>
  290. <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Item Name</Text>
  291. <Text style={{ fontSize: 14 }}>{this.state.ItemName}</Text>
  292. </View>
  293. </View>
  294. </Item>
  295.  
  296.  
  297. <Item>
  298. <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
  299. <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/quality_onhand.png')} /></View>
  300. <View>
  301. <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Quantity OnHand</Text>
  302. <Text style={{ fontSize: 14 }}>{this.state.OnHand}</Text>
  303. </View>
  304. </View>
  305. </Item>
  306. <Item>
  307. <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
  308. <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/quality_is_commited.png')} /></View>
  309. <View>
  310. <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Quantity IsCommited</Text>
  311. <Text style={{ fontSize: 14 }}>{this.state.IsCommited}</Text>
  312. </View>
  313. </View>
  314. </Item>
  315. <Item>
  316. <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
  317. <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/NAME.png')} /></View>
  318. <View>
  319. <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Quantity OnOrder</Text>
  320. <Text style={{ fontSize: 14 }}>{this.state.OnOrder}</Text>
  321. </View>
  322. </View>
  323.  
  324. </Item>
  325. <Item>
  326. <View style={{ width: '100%', flexDirection: 'row', alignItems: 'center' }}>
  327. <View style={{ padding: 10 }}><Image style={{ width: 35, height: 35 }} source={require('../assets/quality_available.png')} /></View>
  328. <View>
  329. <Text style={{ fontSize: 12, fontWeight: 'bold', fontWeight: 'bold' }}>Quantity Available</Text>
  330. <Text style={{ fontSize: 14 }}>{this.state.Availablenya}</Text>
  331. </View>
  332. </View>
  333. </Item>
  334. <View style={{ paddingTop: 20 }}>
  335. <SafeAreaView style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
  336. <View style={{ flexDirection: 'row' }}>
  337. <Left>
  338. <View style={{ marginHorizontal: 17, paddingTop: 15 }}>
  339. <Button small rounded warning onPress={this.Savestockchecking} >
  340. <Text style={{ color: '#fff' }}> Save </Text>
  341. </Button>
  342. </View>
  343. </Left>
  344. <Right>
  345. <View style={{ marginHorizontal: 17, paddingTop: 15 }}>
  346. <Button small rounded danger onPress={this.handleClear}>
  347. <Text style={{ color: '#fff' }}> Cancel </Text>
  348. </Button>
  349. </View>
  350. </Right>
  351. </View>
  352. </SafeAreaView>
  353. </View>
  354. </View>
  355. </ScrollView>
  356. </View>
  357.  
  358. );
  359. }
  360.  
  361. }
  362.  
  363.  
  364. const styles = StyleSheet.create({
  365.  
  366. container: {
  367.  
  368. backgroundColor: 'black',
  369. // paddingTop: 50,
  370. alignItems: 'center',
  371. justifyContent: 'center'
  372.  
  373. },
  374. lowerSection: {
  375. paddingBottom: 30,
  376. paddingHorizontal: 20,
  377. backgroundColor: 'white',
  378. },
  379. preview: {
  380. flex: 1,
  381. justifyContent: 'flex-end',
  382. alignItems: 'center',
  383. },
  384. capture: {
  385. flex: 0,
  386. backgroundColor: '#fff',
  387. borderRadius: 5,
  388. padding: 15,
  389. paddingHorizontal: 20,
  390. alignSelf: 'center',
  391. margin: 20,
  392. },
  393. txt: {
  394. color: 'gray',
  395. fontSize: 14,
  396. textAlign: 'left'
  397. }
  398. // modalViewContainer: {
  399. // height: '100%',
  400. // width: '100%',
  401. // backgroundColor: 'white',
  402. // borderRadius: 3
  403. // }
  404. });
  405.  
  406. AppRegistry.registerComponent('StockCheck', () => StockCheck);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement