# Declaration section
from .models import  tags, country_state, disease
#from accountsapp.models import CoA_models
import os, openpyxl, json
from pathlib import Path

# Global Variables
BASE_DIR = Path(__file__).parent.parent 
str_fileloc = os.path.join(BASE_DIR, 'ayushtn','documents' , 'data_initial.xlsx')
#print(str_fileloc)
wb_input = openpyxl.load_workbook(str_fileloc)

def update_inital_data_tags():
    ws_data = wb_input['tags']  
    for rownum in range(2,ws_data.max_row + 1):
        tags.objects.create(tag_name =ws_data.cell(row=rownum, column=1).value, 
                            tag_description =ws_data.cell(row=rownum, column=2).value, 
                            tag_color =ws_data.cell(row=rownum, column=3).value, )
def update_inital_data_country_state():
    ws_data = wb_input['country_state']  
    for rownum in range(2,ws_data.max_row + 1):
        #print(ws_data.cell(row=rownum, column=3).value)#state_code	state	countrycode	country_name
        country_state.objects.create(state_code =ws_data.cell(row=rownum, column=1).value, 
                            state_name =ws_data.cell(row=rownum, column=2).value, 
                            countrycode =ws_data.cell(row=rownum, column=3).value, 
                            country_name =ws_data.cell(row=rownum, column=4).value, )
            
def update_initial_disease():
    ws_data = wb_input['Disease']  
    for rownum in range(2,ws_data.max_row + 1):
        #print(ws_data.cell(row=rownum, column=3).value)#state_code	state	countrycode	country_name
        disease.objects.create(disease_name =ws_data.cell(row=rownum, column=1).value, 
                            disease_name_tamil =ws_data.cell(row=rownum, column=2).value, )
def delete_all_static_files_from_a_folder(str_folder):
    # delete any files from the given folder
    pass

def delete_all_static_files():
    # loop all folder in static and delete if there is any files
    pass
