Created
December 14, 2020 07:12
-
-
Save shamim2883/e7299561159c8363136047e7299ceebc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import BellowList from './Components/BellowList'; | |
import { | |
List, | |
Show, | |
Create, | |
Edit, | |
Datagrid, | |
SimpleForm, | |
SimpleFormIterator, | |
SimpleShowLayout, | |
TextField, | |
NumberField, | |
TextInput, | |
NumberInput, | |
SelectInput, | |
ReferenceInput, | |
ArrayInput, | |
AutocompleteInput, | |
Filter, | |
required, | |
Pagination, | |
} from 'react-admin'; | |
const PurchasesFilter = (props) => ( | |
<Filter {...props}> | |
<TextInput label="Search" source="_search" alwaysOn /> | |
<SelectInput source="_category" label="Category" choices={[ | |
{ id: 'allopathic', name: 'allopathic' }, | |
{ id: 'healthcare', name: 'Healthcare' }, | |
]} /> | |
<ReferenceInput source="_c_id" label="Company" reference="v1/companies" filterToQuery={searchText => ({ _search: searchText })} sort={{ field: 'c_name', order: 'ASC' }}> | |
<AutocompleteInput optionValue="c_id" optionText="c_name" /> | |
</ReferenceInput> | |
<ReferenceInput source="_ph_id" label="Pharmacy" reference="v1/users" filter={{ _role: 'pharmacy' }} filterToQuery={searchText => ({ _search: searchText })}> | |
<AutocompleteInput optionValue="u_id" optionText="u_name" /> | |
</ReferenceInput> | |
<SelectInput source="_status" choices={[ | |
{ id: 'pending', name: 'Pending' }, | |
{ id: 'sync', name: 'Sync' }, | |
]} /> | |
</Filter> | |
); | |
const PurchasesPagination = props => (<div><Pagination {...props} /><BellowList context="Purchases" {...props} /></div>); | |
export const PurchasesList = (props) => ( | |
<List {...props} pagination={<PurchasesPagination />} title="Purchases" filters={<PurchasesFilter />} perPage={25} sort={{ field: 'pu_id', order: 'DESC' }} > | |
<Datagrid rowClick="edit"> | |
<TextField source="pu_inv_id" label="Invoice id" /> | |
<TextField source="ph_name" label="Pharmacy" sortable={false} /> | |
<TextField source="m_name" label="Name" /> | |
<TextField source="m_form" label="Form" /> | |
<TextField source="m_strength" label="Strength" /> | |
<TextField source="m_unit" label="Unit" /> | |
<NumberField source="pu_qty" label="Quantity" /> | |
<NumberField source="pu_price" label="TP Price" /> | |
<NumberField source="m_d_price" label="Sell Price" /> | |
<NumberField source="m_price" label="MRP" /> | |
<NumberField source="pu_price_total" label="Total" /> | |
<NumberField source="discount_percent" label="MRP Percent" /> | |
<NumberField source="profit_percent" label="Profit Percent" /> | |
<TextField source="pu_status" label="Status" /> | |
</Datagrid> | |
</List> | |
); | |
export const PurchasesCreate = (props) => ( | |
<Create {...props}> | |
<SimpleForm redirect="list"> | |
<ReferenceInput source="pu_ph_id" label="Pharmacy" reference="v1/users" filter={{ _role: 'pharmacy' }} filterToQuery={searchText => ({ _search: searchText })}> | |
<AutocompleteInput optionValue="u_id" optionText="u_name" /> | |
</ReferenceInput> | |
<NumberInput source="pu_inv_id" label="Invoice id" /> | |
<NumberInput source="d_percent" label="Additional Discount Percent" /> | |
{/* | |
<FileInput source="csvFile" label="Upload file (.csv)" accept="text/csv" > | |
<FileField source="src" title="title" /> | |
</FileInput> | |
*/} | |
<ArrayInput source="items" label="Medicines with Quantity" validate={[required()]}> | |
<SimpleFormIterator> | |
<ReferenceInput helperText={false} fullWidth label="Medicine" source="pu_m_id" reference="v1/medicines" filterToQuery={searchText => ({ _search: searchText })} filter={{ _status: 'active', _available: 1 }} sort={{ field: 'm_name', order: 'ASC' }}> | |
<AutocompleteInput optionValue="m_id" optionText={(choice) => !!choice && `${choice.m_name} (${choice.m_form}) (${choice.m_strength}) (${choice.m_price}Tk) (${choice.m_d_price}Tk/${choice.m_unit}) (${choice.m_company})`} shouldRenderSuggestions={(val) => { return !!val && val.trim().length > 0 }} /> | |
</ReferenceInput> | |
<NumberInput source="pu_qty" label="Quantity" helperText={false} /> | |
<NumberInput source="pu_price" label="Price" helperText={false} /> | |
</SimpleFormIterator> | |
</ArrayInput> | |
</SimpleForm> | |
</Create> | |
); | |
export const PurchasesEdit = (props) => ( | |
<Edit {...props}> | |
<SimpleForm> | |
<TextInput disabled source="pu_inv_id" label="Invoice id" /> | |
<TextInput disabled source="pu_ph_id" label="Pharmacy id" /> | |
<TextInput disabled source="m_name" label="Name" /> | |
<TextInput disabled source="m_form" label="Form" /> | |
<TextInput disabled source="m_strength" label="Strength" /> | |
<TextInput disabled source="m_unit" label="Unit" /> | |
<NumberInput source="pu_qty" label="Quantity" /> | |
<NumberInput source="pu_price" label="Price" /> | |
</SimpleForm> | |
</Edit> | |
); | |
export const PurchasesShow = (props) => ( | |
<Show {...props}> | |
<SimpleShowLayout> | |
<TextField source="pu_inv_id" label="Invoice id" /> | |
<TextField source="pu_ph_id" label="Pharmacy id" /> | |
<TextField source="m_name" label="Name" /> | |
<TextField source="m_form" label="Form" /> | |
<TextField source="m_strength" label="Strength" /> | |
<TextField source="m_unit" label="Unit" /> | |
<NumberField source="pu_qty" label="Quantity" /> | |
<NumberField source="pu_price" label="Price" /> | |
</SimpleShowLayout> | |
</Show> | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Medicines:
{"total":14,"status":"success","data":[{"m_id":21159,"m_name":"Napa","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"120mg\/5ml","m_unit":"60ml bot","m_price":"20.70","m_d_price":"20.70","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Syrup","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":21159},{"m_id":12464,"m_name":"Napa","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"80mg\/ml","m_unit":"15ml bot","m_price":"15.00","m_d_price":"15.00","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Paediatric Drops","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12464},{"m_id":12465,"m_name":"Napa","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"125mg","m_unit":"Suppository","m_price":"4.00","m_d_price":"4.00","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Suppository","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12465},{"m_id":12466,"m_name":"Napa","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"250mg","m_unit":"Suppository","m_price":"5.00","m_d_price":"5.00","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Suppository","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12466},{"m_id":12467,"m_name":"Napa","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"500mg","m_unit":"Suppository","m_price":"8.00","m_d_price":"8.00","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Suppository","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12467},{"m_id":12468,"m_name":"Napa","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"60mg","m_unit":"Suppository","m_price":"3.50","m_d_price":"3.50","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Suppository","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12468},{"m_id":21181,"m_name":"Napa","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"120mg\/5ml","m_unit":"100ml bot","m_price":"31.87","m_d_price":"31.87","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Syrup","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":21181},{"m_id":25051,"m_name":"Napa","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"120mg\/5ml","m_unit":"50ml bot","m_price":"18.29","m_d_price":"18.29","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Suspension","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":25051},{"m_id":12475,"m_name":"Napa DT","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"500mg","m_unit":"10 Tablets","m_price":"12.80","m_d_price":"12.80","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Tablet","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12475},{"m_id":25272,"m_name":"Napa EXTRA","m_g_id":247,"m_generic":"Paracetamol + Caffeine","m_strength":"65mg+500mg","m_unit":"10 Tablets","m_price":"25.00","m_d_price":"25.00","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Tablet","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":25272},{"m_id":12478,"m_name":"Napa IV","m_g_id":1126,"m_generic":"Paracetamol IV","m_strength":"10mg\/ml","m_unit":"100ml bot","m_price":"149.93","m_d_price":"139.43","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Infusion","m_rob":true,"m_rx_req":true,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12478},{"m_id":12479,"m_name":"Napa IV","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"1000mg","m_unit":"100ml bot","m_price":"150.00","m_d_price":"150.00","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"IV Infusion","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12479},{"m_id":12480,"m_name":"Napa Rapid","m_g_id":1124,"m_generic":"Paracetamol","m_strength":"500mg","m_unit":"10 Rapid Tablets","m_price":"8.00","m_d_price":"8.00","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Rapid Tablet","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":12480},{"m_id":25311,"m_name":"Napadol","m_g_id":1125,"m_generic":"Paracetamol + Tramadol Hydrochloride","m_strength":"325mg+37.5mg","m_unit":"Tablet","m_price":"8.00","m_d_price":"7.44","m_c_id":37,"m_company":"Beximco Pharmaceuticals Ltd.","m_form":"Tablet","m_rob":true,"m_rx_req":false,"m_status":"active","m_category":"allopathic","m_comment":"","m_i_comment":"","m_u_id":0,"id":25311}]}
Pharmacies:
{"total":9,"status":"success","data":[{"u_id":79,"u_name":"Amzad Pharmacy","u_mobile":"+8801683579998","u_email":null,"u_token":"ce03739cd2cb","fcm_token":"eT1V0GxC6H4:APA91bFoudU7xeK94gMQdAw4kq1WeIenzXMpWrALbMuUNQEaWfZT3QuT3ESEdWRsnQtPOpLw1XD3YZP2rixgkTC9ke5FD1_CwvUpycYRT93FMI5yDyYaC9C3aH2-R2sIUv0d2o0LnN2I","u_lat":"0.000000","u_long":"0.000000","u_created":"2020-03-09 12:14:59","u_updated":"2020-11-28 10:18:01","u_role":"pharmacy","u_status":"active","u_cash":5465.65,"u_p_cash":-1,"u_otp":0,"u_otp_time":"2020-03-20 21:26:48","u_referrer":"EFH2ENYMP5","u_r_uid":0,"id":79},{"u_id":1549,"u_name":"Mokka Pharma","u_mobile":"+8801777761564","u_email":null,"u_token":"8247c85efd97","fcm_token":"eunHHEc_gI4:APA91bGhAuxxaa2U2aMiWNxSNKb_PjAkCTuKCiXWkbvslo0qaXEpwgFApcSSekhwgNxIZiaHHa_bPIf4uc4EGGAxdoimFg5FxoqO_xdZ77gmXEtdXKIFARr2Rfk3Mu-e29xO9X8Fd7Zi","u_lat":"22.821357","u_long":"88.579690","u_created":"2020-04-04 20:10:11","u_updated":"2020-04-19 11:29:37","u_role":"pharmacy","u_status":"active","u_cash":0,"u_p_cash":0,"u_otp":0,"u_otp_time":"2020-04-19 11:29:19","u_referrer":"CZ7J6EX925","u_r_uid":0,"id":1549},{"u_id":2073,"u_name":"tpharma","u_mobile":"+8801450658585","u_email":null,"u_token":"55bd6eaf073f","fcm_token":"eqRL8EguMQA:APA91bEJ4dCMUodSQM8Vfxm0ZaN09gNQOXm2YDNIYUn8FKeIeF9qHQXyN32oAqeiwcB9WzrpKTe8RbB-zevfpSix4_Qn5WrDyquOtuk508pcB0amWBCK1nE2DGVo66rl_wUZeiTYlDnD","u_lat":"0.000000","u_long":"0.000000","u_created":"2020-04-11 10:46:33","u_updated":"2020-05-18 08:42:02","u_role":"pharmacy","u_status":"inactive","u_cash":0,"u_p_cash":-511,"u_otp":0,"u_otp_time":"2020-04-19 11:30:20","u_referrer":"ZZKRW3STSN","u_r_uid":0,"id":2073},{"u_id":2079,"u_name":"Old Prime","u_mobile":"+8801911460880","u_email":null,"u_token":"a9d5a42950b0","fcm_token":"cKpzkXP3sAk:APA91bHRxn5QxA1aBISF-QQbaRNBAKZkuie-mn60EORahc9m3beIyAF9X6etLnJPF6a5DXGWxXQ5xCsU47XjdUznATtt032tFenjuqz13Ut7019UK4XdGsyuCTG4wN5VwQHMvuIdqhrw","u_lat":"0.000000","u_long":"0.000000","u_created":"2020-04-12 20:04:31","u_updated":"2020-04-29 15:51:03","u_role":"pharmacy","u_status":"active","u_cash":0,"u_p_cash":0,"u_otp":0,"u_otp_time":"2020-04-29 15:50:45","u_referrer":"2TASX7KWLA","u_r_uid":0,"id":2079},{"u_id":2097,"u_name":"Prime","u_mobile":"+8801814907592","u_email":null,"u_token":"1ac73ec13f6e","fcm_token":"fAYSDVhCjkOhnEzKFjr-LN:APA91bHnXFxXhbTHg0isrPWKoloFnF0brcN1rAbqayF-sweN70SmyvupbMXy1bmfMhpFsZQHXZplsktee67iT31iQLGAYhFtzUDPdT0KWB-ZBg-pb3mbzghSG1NGU5d4BXatvmMOnAF7","u_lat":"0.000000","u_long":"0.000000","u_created":"2020-04-14 18:51:53","u_updated":"2020-04-27 21:09:46","u_role":"pharmacy","u_status":"active","u_cash":0,"u_p_cash":0,"u_otp":0,"u_otp_time":"2020-04-27 21:09:33","u_referrer":"EVWN29T6RL","u_r_uid":0,"id":2097},{"u_id":2264,"u_name":"Shakil","u_mobile":"+8801859350880","u_email":null,"u_token":"5343eca70b0c","fcm_token":"feLB0D8bEbg:APA91bGhuVDPZGH9C0Jgmwv0lMWu7oDIiiZrBGmbnW1fEy3pudKKkMuGcBma5hnQtEf6gPN506ytGsc07zbgyL0jj9nQOBQj8fMnVWfFt3ppjmmJeE82o38vMecAuPl0I9SQJJEFqXL-","u_lat":"0.000000","u_long":"0.000000","u_created":"2020-04-24 12:06:38","u_updated":"2020-05-14 19:37:43","u_role":"pharmacy","u_status":"active","u_cash":0,"u_p_cash":0,"u_otp":0,"u_otp_time":"2020-05-12 13:03:40","u_referrer":"VYECMPN3ZH","u_r_uid":0,"id":2264},{"u_id":2989,"u_name":"Arogga Pharmacy ","u_mobile":"+8801819514436","u_email":null,"u_token":"4612d7972f7e","fcm_token":"f2q1HWOND2k:APA91bGTKnJYNCUL6izOLZM11qdjOYSeFPDPfGlzWhRw51rGUDvnbAn3YWrPOXAgJUnh1-VsJ6Xb_wFRp1DbkRNbmIZ9kM-CvN4dIbTzdUBbKsGgc0gpIGgATZRAaROvAL6UAl0NzKCO","u_lat":"0.000000","u_long":"0.000000","u_created":"2020-05-14 19:34:26","u_updated":"2020-05-22 16:46:40","u_role":"pharmacy","u_status":"active","u_cash":0,"u_p_cash":0,"u_otp":0,"u_otp_time":"2020-05-18 00:15:28","u_referrer":"W5M6YSDSLJ","u_r_uid":0,"id":2989},{"u_id":3121,"u_name":"Arogga Ctg","u_mobile":"+8801763728510","u_email":null,"u_token":"7a7d0410c6f6","fcm_token":"ff7Q5f8EBhY:APA91bFTZZfX4I5ErqYylObHn2ewmAkf9coo-iI8eVvAhtrlQskp2KJjXI-_ZuqaQwobESK6JN3rLcmLI9BAM1k2jutJe_Dpy-QqQPypMdjFKKTk4-PS2wIUY9E1UdI6L2eA8QRzkAzy","u_lat":"22.366215","u_long":"91.846793","u_created":"2020-05-18 00:37:39","u_updated":"2020-07-15 20:41:32","u_role":"pharmacy","u_status":"active","u_cash":9863,"u_p_cash":2352,"u_otp":0,"u_otp_time":"2020-07-08 01:03:45","u_referrer":"EJTZCKPRVJ","u_r_uid":0,"id":3121},{"u_id":6139,"u_name":"Arogga Pharma DHK","u_mobile":"+8801703090562","u_email":null,"u_token":"0866e92d6241","fcm_token":"","u_lat":"23.828836","u_long":"90.416750","u_created":"2020-11-29 19:55:35","u_updated":"2020-12-13 10:25:15","u_role":"pharmacy","u_status":"active","u_cash":-45041,"u_p_cash":0,"u_otp":0,"u_otp_time":"2020-11-29 21:00:05","u_referrer":"WD4TN92J76","u_r_uid":0,"id":6139}]}
Companies:
{"total":160,"status":"success","data":[{"c_id":2,"c_name":"ACI Limited","id":2},{"c_id":830,"c_name":"Active Fine Chemicals Ltd.","id":830},{"c_id":5,"c_name":"Ad-din Pharmaceuticals Ltd.","id":5},{"c_id":10,"c_name":"Al-Madina Pharmaceuticals Ltd.","id":10},{"c_id":12,"c_name":"Albion Laboratories Ltd.","id":12},{"c_id":13,"c_name":"Alco Pharma Limited","id":13},{"c_id":817,"c_name":"Allied Pharmaceuticals Ltd.","id":817},{"c_id":16,"c_name":"Ambee Pharmaceuticals Ltd.","id":16},{"c_id":17,"c_name":"Amico Laboratories Ltd.","id":17},{"c_id":18,"c_name":"Amulet Pharmaceuticals Ltd.","id":18},{"c_id":19,"c_name":"APC Pharma Limited","id":19},{"c_id":20,"c_name":"Apex Pharma Ltd.","id":20},{"c_id":21,"c_name":"Apollo Pharmaceutical Laboratories Ltd.","id":21},{"c_id":22,"c_name":"Aristopharma Limited","id":22},{"c_id":23,"c_name":"Asiatic Laboratories Ltd.","id":23},{"c_id":24,"c_name":"Astra Biopharmaceuticals Ltd.","id":24},{"c_id":26,"c_name":"Aztec Pharmaceuticals Ltd.","id":26},{"c_id":31,"c_name":"Beacon Pharmaceuticals Ltd.","id":31},{"c_id":33,"c_name":"Belsen Pharmaceuticals Ltd.","id":33},{"c_id":34,"c_name":"Bengal Drugs & Chemical Works Pharm. Ltd.","id":34},{"c_id":36,"c_name":"Benham Pharmaceuticals Ltd.","id":36},{"c_id":37,"c_name":"Beximco Pharmaceuticals Ltd.","id":37},{"c_id":40,"c_name":"Biopharma Ltd.","id":40},{"c_id":41,"c_name":"Bios Pharmaceuticals Ltd.","id":41},{"c_id":46,"c_name":"Bridge Pharmaceuticals Ltd.","id":46}]}