def NA_Goods_Disposal_Search(request):
	try:
		IcolumnName = request.GET.get('columnName');
		IvalueKey =  request.GET.get('valueKey')
		IdataType =  request.GET.get('dataType')
		Icriteria =  request.GET.get('criteria')
		Ilimit = request.GET.get('rows', '')
		Isidx = request.GET.get('sidx', '')
		Isord = request.GET.get('sord', '')
		criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
		dataType = ResolveCriteria.getDataType(str(IdataType))
		if(Isord is not None and str(Isord) != '') or(Isidx is not None and str(Isidx) != ''):
			NAData = NADisposal.objects.PopulateQuery(str(Isidx),Isord,Ilimit, request.GET.get('page', '1'),request.user.username if (request.user.username is not None and request.user.username != '') else 'Admin',IcolumnName,IvalueKey,criteria,dataType)#return tuples
		else:
			NAData = NADisposal.objects.PopulateQuery('','DESC',Ilimit, request.GET.get('page', '1'),request.user.username if (request.user.username is not None and request.user.username != '') else 'Admin',IcolumnName,IvalueKey,criteria,dataType)#return tuples
		totalRecord = NAData[1]
		dataRows = NAData[0]
		rows = []
		#column idapp,goods,type,serialnumber,bookvalue,datedisposal,afterrepair,lastrepairfrom,issold,sellingprice,soldto,proposedby,acknowledgeby,approvedby,descriptions,createdby,createddate	
		i = 0;
		for row in dataRows:
			i = i+1
			datarow = {"id" :row['idapp'], 'cell' :[row['idapp'],i,row['goods'],row['goodstype'],row['serialnumber'],row['bookvalue'],row['datedisposal'],row['afterrepair'],row['lastrepairfrom'],row['islost'],
						row['refgoodsfrom'],row['issold'],row['sellingprice'],row['soldto'],row['proposedby'],row['acknowledgeby'],
				row['approvedby'],row['descriptions'],row['createddate'],row['createdby']]}
			rows.append(datarow)
		TotalPage = 1 if totalRecord < int(Ilimit) else (math.ceil(float(totalRecord/int(Ilimit)))) # round up to next number
		results = {"page": int(request.GET.get('page', '1')),"total": TotalPage ,"records": totalRecord,"rows": rows }
		return HttpResponse(json.dumps(results, indent=4,cls=DjangoJSONEncoder),content_type='application/json')
	except Exception as e :
		result = repr(e)
		return HttpResponse(json.dumps({'message':result}),status = 500, content_type='application/json')
def NA_MaintenanceGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey =  request.GET.get('valueKey')
    IdataType =  request.GET.get('dataType')
    Icriteria =  request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    Ipage = request.GET.get('page')
    criteria = ResolveCriteria.getCriteriaSearch(Icriteria)
    dataType = ResolveCriteria.getDataType(IdataType)
    getColumn = commonFunct.retriveColumn(table=[NAMaintenance,goods],resolve=IcolumnName,initial_name=['m','g'])
    maintenanceData = NAMaintenance.objects.PopulateQuery(getColumn,IvalueKey,criteria,dataType)
    totalRecords = len(maintenanceData)
    paginator = Paginator(maintenanceData,Ilimit)
    try:
        dataRows = paginator.page(Ipage)
    except EmptyPage:
        dataRows = paginator.page(paginator.num_pages)
    rows = []
    i = 0
    for row in dataRows.object_list:
        i+=1
        datarow = {"id" :row['idapp'], "cell" :[row['idapp'],i,row['goods'],row['itemcode'],row['serialnumber'],row['requestdate'],\
            row['startdate'],row['isstillguarantee'],row['expense'],row['maintenanceby'],row['personalname'],row['enddate'],row['issucced'],\
            row['descriptions'],row['createddate'],row['createdby']]}
        rows.append(datarow)
    results = {"page": Ipage,"total": paginator.num_pages ,"records": totalRecords,"rows": rows }
    return HttpResponse(json.dumps(results,cls=DjangoJSONEncoder),content_type='application/json')
Exemplo n.º 3
0
def NA_Goods_Lending_Search(request):
	try:
		IcolumnName = request.GET.get('columnName')
		IvalueKey = request.GET.get('valueKey')
		IdataType = request.GET.get('dataType')
		Icriteria = request.GET.get('criteria')
		Ilimit = request.GET.get('rows', '')
		Isidx = request.GET.get('sidx', '')
		Isord = request.GET.get('sord', '')
		criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
		dataType = ResolveCriteria.getDataType(str(IdataType))
		if(Isord is not None and str(Isord) != '') or(Isidx is not None and str(Isidx) != ''):
			NAData = NAGoodsLending.objects.PopulateQuery(str(Isidx),Isord,Ilimit, request.GET.get('page', '1'),request.user.username if (request.user.username is not None and request.user.username != '') else 'Admin',IcolumnName,IvalueKey,criteria,dataType)#return tuples
		else:
			NAData = NAGoodsLending.objects.PopulateQuery('','DESC',Ilimit, request.GET.get('page', '1'),request.user.username if (request.user.username is not None and request.user.username != '') else 'Admin',IcolumnName,IvalueKey,criteria,dataType)#return tuples
		totalRecord = NAData[1]
		dataRows = NAData[0]
		rows = []
		#column idapp,goods,goodstype,serialnumber,lentby,sentby,lentdate,interests,responsibleby,refgoodsfrom,isnew,status,descriptions,createdby,createddate
		i = 0
		for row in dataRows:
			i = i+1
			datarow = {"id" :row['idapp'], "cell" :[row['idapp'],i,row['territory'],row['goods'],row['goodstype'],row['serialnumber'],row['lentby'],row['sentby'],row['lentdate'],row['datereturn'],row['interests'], \
				row['responsibleby'],row['refgoodsfrom'],row['isnew'],row['status'],row['descriptions'],datetime.date(row['createddate']),row['createdby']]}
			#datarow = {"id" :row.idapp, "cell" :[row.idapp,row.itemcode,row.goodsname,row.brandname,row.unit,row.priceperunit, \
			#	row.placement,row.depreciationmethod,row.economiclife,row.createddate,row.createdby]}
			rows.append(datarow)
		TotalPage = 1 if totalRecord < int(Ilimit) else (math.ceil(float(totalRecord/int(Ilimit)))) # round up to next number
		results = {"page": int(request.GET.get('page', '1')),"total": TotalPage ,"records": totalRecord,"rows": rows }
		return HttpResponse(json.dumps(results, indent=4,cls=DjangoJSONEncoder),content_type='application/json')
	except Exception as e:
		result = repr(e)
		return HttpResponse(json.dumps({'message':result}),status = 500, content_type='application/json')
Exemplo n.º 4
0
def export_to_excels(request,Options):
	response = HttpResponse
	NAData = []
	colNames = []
    # tentukan column
	try:
		IcolumnName = request.GET.get('columnName')
		IvalueKey =  request.GET.get('valueKey')
		IdataType =  request.GET.get('dataType')
		Icriteria =  request.GET.get('criteria')
		Ilimit = request.GET.get('rows', '')
		Isidx = request.GET.get('sidx', '')
		Isord = request.GET.get('sord', '')
		criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
		dataType = ResolveCriteria.getDataType(str(IdataType))
		if(Isord is not None and str(Isord) != '') or(Isidx is not None and str(Isidx) != ''):
			if(Isord is not None and str(Isord) != '') or(Isidx is not None and str(Isidx) != ''):
				NAData = NAGoodsReceive.objects.PopulateQuery(str(Isidx),Isord,Ilimit, request.GET.get('page', '1'),IcolumnName,IvalueKey,criteria,dataType,Options == "headeronly")#return tuples
			else:
				NAData = NAGoodsReceive.objects.PopulateQuery('','DESC',Ilimit, request.GET.get('page', '1'),IcolumnName,IvalueKey,criteria,dataType,Options == "headeronly")#return tuples
			dataRows = NAData[0]
			rows = []
		if Options == "headeronly":
			colNames = ['IDApp','NO','Reference No','Goods Name','Date Received','Suplier Name','FK_ReceivedBy',
				'Received By','FK_P_R_By','Purchase Request By','Total Purchase','Total Received','descriptions','Created Date','Created By']
			#columns in data
			#IDApp,NO,refno,goods,datereceived,supliername,FK_ReceivedBy,receivedby,FK_P_R_By,
			#pr_by,totalpurchase,totalreceived,descriptions,CreatedDate,CreatedBy
			i = 0
			for row in dataRows:
				i = i + 1
				datarow = tuple([row['idapp'], i, row['refno'], row['goods'], datetime.strftime(row['datereceived'], "%m/%d/%Y"), row['supliername'],
				row['FK_ReceivedBy'], row['receivedby'], row['FK_P_R_By'], row['pr_by'], row['totalpurchase'], row['totalreceived'], row['descriptions'],
				row['CreatedDate'], row['CreatedBy']])
				rows.append(datarow)
			dataRows = list(dict(zip(colNames, row)) for row in rows)
			column_hidden = ['IDApp','FK_ReceivedBy','FK_P_R_By','descriptions']
			response = commonFunct.create_excel(
				colNames, column_hidden, dataRows, 'Goods_Receive_Header_' + datetime.strftime(datetime.now(),"%Y_%m_%d"),'Goods Receive Header Only')
		elif Options == "All":
			#columns in data
			#NO,refno,goods,datereceived,supliername,receivedby,pr_by,BrandName,TypeApp,Warranty,EndOfWarranty,SerialNumber
			colNames = ['NO','Reference No','Goods Name','Date Received','Suplier Name',
				'Received By','Purchase Request By','Brand Name','Goods Type','Warranty','EndOfWarranty','Serial Number','Created Date','Created By']
			i = 0
			for row in dataRows:
				i = i + 1
				datarow = tuple([i, row['refno'], row['goods'], datetime.strftime(row['datereceived'], "%m/%d/%Y"), row['supliername'],
				row['receivedby'],row['pr_by'], row['BrandName'], row['TypeApp'], row['Warranty'],
				row['EndOfWarranty'],row['SerialNumber'],datetime.strftime(row['CreatedDate'], "%m/%d/%Y"), row['CreatedBy']])
				rows.append(datarow)
			dataRows = list(dict(zip(colNames, row)) for row in rows)
			column_hidden = []
			response = commonFunct.create_excel(
				colNames, column_hidden, dataRows, 'Goods_Receive_With_Detail_' + datetime.strftime(datetime.now(),"%Y_%m_%d"),'Goods Receive With Detail')
	except Exception as e:
		result = repr(e)
		return HttpResponse(json.dumps({'message':result}),status = 500, content_type='application/json')
	return response
Exemplo n.º 5
0
def NA_Goods_Receive_GAGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    Ipage = request.GET.get('page')
    criteria = ResolveCriteria.getCriteriaSearch(Icriteria)
    dataType = ResolveCriteria.getDataType(IdataType)

    gaData = NAGaReceive.objects.PopulateQuery(
        IcolumnName,
        IvalueKey,
        criteria,
        dataType
    )
    totalRecords = len(gaData)
    paginator = Paginator(gaData, Ilimit)
    try:
        dataRows = paginator.page(Ipage)
    except EmptyPage:
        dataRows = paginator.page(paginator.num_pages)
    rows = []
    i = 0
    for row in dataRows.object_list:
        i += 1
        datarow = {
            "id": row['idapp'], "cell": [
                row['idapp'],
                i,
                row['goodsname'],
                row['brand'],
                row['typeapp'],
                row['received_by'],
                row['pr_by'],
                row['datereceived'],
                row['price'],
                row['supliername'],
                row['invoice_no'],
                row['machine_no'],
                row['chassis_no'],
                row['year_made'],
                row['colour'],
                row['model'],
                row['kind'],
                row['cylinder'],
                row['fuel'],
                row['descriptions'],
                row['createddate'],
                row['createdby']
            ]
        }
        rows.append(datarow)
    results = {"page": Ipage, "total": paginator.num_pages,
               "records": totalRecords, "rows": rows}
    return HttpResponse(json.dumps(results, cls=DjangoJSONEncoder), content_type='application/json')
Exemplo n.º 6
0
def NA_Goods_Search(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    if (',' in Isidx):
        Isidx = Isidx.split(',')

    criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
    dataType = ResolveCriteria.getDataType(str(IdataType))
    if (Isord is not None and str(Isord) != ''):
        NAData = goods.objects.PopulateQuery(IcolumnName, IvalueKey, criteria,
                                             dataType).order_by('-' +
                                                                str(Isidx))
    else:
        NAData = goods.objects.PopulateQuery(IcolumnName, IvalueKey, criteria,
                                             dataType)


#		from django.db.models import F
#cityList = City.objects.using(settings.DATABASE_CONF).filter(status=1).values(
#    'city_name_en', 'city_id')
## use F expression to annotate with an alias
#cityList = cityList.annotate(cityname=F('city_name_en'))

    totalRecord = NAData.count()
    paginator = Paginator(NAData, int(Ilimit))
    try:
        page = request.GET.get('page', '1')
    except ValueError:
        page = 1
    try:
        dataRows = paginator.page(page)
    except (EmptyPage, InvalidPage):
        dataRows = paginator.page(paginator.num_pages)

    rows = []
    i = 0 if page == '1' else int(Ilimit)
    #idapp,itemcode,goods
    for row in dataRows.object_list:
        i += 1
        datarow = {"id" :row['idapp'], "cell" :[row['idapp'],i,row['itemcode'],row['goodsname'],row['unit'],row['typeapp'],row['priceperunit'], \
         row['placement'],row['typeofdepreciation'],row['economiclife'],row['inactive'],datetime.date(row['createddate']),row['createdby']]}
        #datarow = {"id" :row.idapp, "cell" :[row.idapp,row.itemcode,row.goodsname,row.brandname,row.unit,row.priceperunit, \
        #	row.placement,row.depreciationmethod,row.economiclife,row.createddate,row.createdby]}
        rows.append(datarow)
    results = {
        "page": page,
        "total": paginator.num_pages,
        "records": totalRecord,
        "rows": rows
    }
    return HttpResponse(json.dumps(results, indent=4, cls=DjangoJSONEncoder),
                        content_type='application/json')
def NA_EmployeeGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    if (',' in Isidx):
        Isidx = Isidx.split(',')

    criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
    dataType = ResolveCriteria.getDataType(str(IdataType))
    if (Isord is not None and str(Isord) != ''):
        emplData = Employee.objects.PopulateQuery(
            IcolumnName, IvalueKey, criteria,
            dataType).order_by('-' + str(Isidx))
    else:
        emplData = Employee.objects.PopulateQuery(IcolumnName, IvalueKey,
                                                  criteria, dataType)

    totalRecord = emplData.count()
    paginator = Paginator(emplData, int(Ilimit))
    try:
        page = request.GET.get('page', '1')
    except ValueError:
        page = 1
    try:
        data = paginator.page(page)
    except (EmptyPage, InvalidPage):
        data = paginator.page(paginator.num_pages)

    rows = []
    i = 0
    for row in data.object_list:
        i += 1
        datarow = {
            "id":
            row['idapp'],
            "cell": [
                row['idapp'], i, row['nik'], row['employee_name'],
                row['typeapp'], row['jobtype'], row['gender'], row['status'],
                row['telphp'], row['territory'], row['descriptions'],
                row['inactive'], row['createddate'], row['createdby']
            ]
        }
        rows.append(datarow)
    results = {
        "page": data.number,
        "total": paginator.num_pages,
        "records": totalRecord,
        "rows": rows
    }
    return HttpResponse(json.dumps(results, indent=4, cls=DjangoJSONEncoder),
                        content_type='application/json')
Exemplo n.º 8
0
def NA_Goods_Outwards_GAGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    Ipage = request.GET.get('page')
    criteria = ResolveCriteria.getCriteriaSearch(Icriteria)
    dataType = ResolveCriteria.getDataType(IdataType)

    column = commonFunct.retriveColumn(
        table=[goods, NAGaReceive, NAGaVnHistory, NAGaOutwards],
        custom_fields=[['employee'], ['used_employee'], ['resp_employee'],
                       ['sender']],
        resolve=IcolumnName,
        initial_name=[
            'g', 'ngr', 'ngh', 'ngo', 'emp1', 'emp2', 'emp3', 'emp4'
        ],
        exclude=['g.typeapp'])

    gaData = NAGaOutwards.objects.populate_query(column, IvalueKey, criteria,
                                                 dataType)
    totalRecords = len(gaData)
    paginator = Paginator(gaData, Ilimit)
    try:
        dataRows = paginator.page(Ipage)
    except EmptyPage:
        dataRows = paginator.page(paginator.num_pages)
    rows = []
    i = 0
    for row in dataRows.object_list:
        i += 1
        datarow = {
            "id":
            row['idapp'],
            "cell": [
                row['idapp'], i, row['goodsname'], row['brand'],
                row['typeapp'], row['invoice_no'], row['reg_no'], row['isnew'],
                row['daterequest'], row['datereleased'], row['employee_name'],
                row['sender'], row['resp_employee'], row['equipment'],
                row['add_equipment'], row['descriptions'], row['createddate'],
                row['createdby']
            ]
        }
        rows.append(datarow)
    results = {
        "page": Ipage,
        "total": paginator.num_pages,
        "records": totalRecords,
        "rows": rows
    }
    return HttpResponse(json.dumps(results, cls=DjangoJSONEncoder),
                        content_type='application/json')
Exemplo n.º 9
0
def NA_Goods_Receive_otherGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    Ipage = request.GET.get('page')
    criteria = ResolveCriteria.getCriteriaSearch(Icriteria)
    dataType = ResolveCriteria.getDataType(IdataType)
    getColumn = commonFunct.retriveColumn(
        table=[NAGoodsReceive_other, goods],
        resolve=IcolumnName,
        initial_name=['ngr', 'g', 'emp1', 'emp2', 'sp'],
        custom_fields=[['receivedby'], ['pr_by'], ['supliername']])
    maintenanceData = NAGoodsReceive_other.objects.PopulateQuery(
        getColumn, IvalueKey, criteria, dataType)
    totalRecords = len(maintenanceData)
    paginator = Paginator(maintenanceData, Ilimit)
    try:
        dataRows = paginator.page(Ipage)
    except EmptyPage:
        dataRows = paginator.page(paginator.num_pages)
    rows = []
    i = 0
    for row in dataRows.object_list:
        i += 1
        datarow = {
            "id":
            row['IDApp'],
            "cell": [
                row['IDApp'], i, row['refno'], row['goods'],
                row['datereceived'], row['supliername'], row['receivedby'],
                row['pr_by'], row['totalpurchase'], row['totalreceived'],
                row['descriptions'],
                datetime.date(row['CreatedDate']), row['CreatedBy']
            ]
        }
        rows.append(datarow)
    results = {
        "page": Ipage,
        "total": paginator.num_pages,
        "records": totalRecords,
        "rows": rows
    }
    return HttpResponse(json.dumps(results, cls=DjangoJSONEncoder),
                        content_type='application/json')
def NA_PriviledgeGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
   
    if(',' in Isidx):
        Isidx = Isidx.split(',')

    criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
    dataType = ResolveCriteria.getDataType(str(IdataType))
    if(Isord is not None and str(Isord) != ''):
        priviledgeData = NAPriviledge.objects.PopulateQuery(
            IcolumnName, IvalueKey, criteria, dataType).order_by('-' + str(Isidx))
    else:
        priviledgeData = NAPriviledge.objects.PopulateQuery(
            IcolumnName, IvalueKey, criteria, dataType)

    totalRecord = priviledgeData.count()
    paginator = Paginator(priviledgeData, int(Ilimit))
    try:
        page = request.GET.get('page', '1')
    except ValueError:
        page = 1
    try:
        dataRows = paginator.page(page)
    except (EmptyPage, InvalidPage):
        dataRows = paginator.page(paginator.num_pages)

    rows = []
    i = 0
    for row in dataRows.object_list:
        i += 1
        datarow = {
            "id": row['idapp'], "cell": [
                i, row['idapp'], row['first_name'], row['last_name'], row['username'],
                row['email'], row['divisi'], row['role'], row['password'], row['last_login'], row['last_form'],
                row['is_active'], row['date_joined'], row['createdby']
            ]
        }
        rows.append(datarow)
    results = {"page": page, "total": paginator.num_pages,
               "records": totalRecord, "rows": rows}
    return HttpResponse(json.dumps(results, indent=4, cls=DjangoJSONEncoder), content_type='application/json')
Exemplo n.º 11
0
def NA_Goods_ReturnGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    Ipage = request.GET.get('page')
    criteria = ResolveCriteria.getCriteriaSearch(Icriteria)
    dataType = ResolveCriteria.getDataType(IdataType)
    getColumn = commonFunct.retriveColumn(
        table=[NAGoodsReturn, goods],
        resolve=IcolumnName,
        initial_name=['ngr', 'g', 'emp1', 'emp2'],
        custom_fields=[['fromemployee'], ['usedemployee']])
    returnData = NAGoodsReturn.objects.PopulateQuery(getColumn, IvalueKey,
                                                     criteria, dataType)
    totalRecords = len(returnData)
    paginator = Paginator(returnData, Ilimit)
    try:
        dataRows = paginator.page(Ipage)
    except EmptyPage:
        dataRows = paginator.page(paginator.num_pages)
    rows = []
    i = 0
    for row in dataRows.object_list:
        i += 1
        datarow = {
            "id":
            row['idapp'],
            "cell": [
                row['idapp'], i, row['goods'], row['serialnumber'],
                row['fromemployee'], row['usedemployee'], row['datereturn'],
                row['conditions'], row['minusDesc'], row['iscompleted'],
                row['descriptions'], row['createddate'], row['createdby']
            ]
        }
        rows.append(datarow)
    results = {
        "page": Ipage,
        "total": paginator.num_pages,
        "records": totalRecords,
        "rows": rows
    }
    return HttpResponse(json.dumps(results, cls=DjangoJSONEncoder),
                        content_type='application/json')
Exemplo n.º 12
0
def NA_GoodsLost_GetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
#    getColumn = commonFunct.retriveColumn(
#		table=[NAGoodsLost,goods],resolve=IcolumnName,
#		initial_name=['gls','g','empl1','empl2','empl3'],
#		custom_fields=[['used_by'], ['lost_by'], ['resp_person']]
#    )
    criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
    dataType = ResolveCriteria.getDataType(str(IdataType))
    NAData = []
    if(Isord is not None and str(Isord) != '') or (Isidx is not None and str(Isidx) != ''):
    	NAData = NAGoodsLost.objects.PopulateQuery(str(Isidx),Isord,Ilimit, request.GET.get('page', '1'),request.user.username,IcolumnName,IvalueKey,criteria,dataType)#return tuples
    else:
    	NAData = NAGoodsLost.objects.PopulateQuery('','DESC',Ilimit, request.GET.get('page', '1'),request.user.username,IcolumnName,IvalueKey,criteria,dataType)#return tuples
    totalRecord = NAData[1]
    dataRows = NAData[0]
    # paginator = Paginator(accData,Ilimit)
    # try:
    #     dataRows = paginator.page(Ipage)
    # except EmptyPage:
    #     dataRows = paginator.page(paginator.num_pages)
    # totalRecord = len(accData)
    if NAData == []:
        results = {"page": "1", "total": 0, "records": 0, "rows": []}
    else:
        totalRecord = NAData[1]
        dataRows = NAData[0]
    rows = []
    i = 0
    for row in dataRows:
        i +=1
        datarow = {"id" :row['idapp'], "cell" :[row['idapp'],i,row['goods'],row['itemcode'],row['serialnumber'],row['fromgoods'],row['used_by'],\
            row['lost_by'],row['resp_person'],row['reason'],row['descriptions'],row['createddate'],row['createdby']]}
        rows.append(datarow)
    # results = {"page": Iparequest.GET.get('page', '1'),"total": paginator.num_pages ,"records": totalRecord,"rows": rows }
    TotalPage = 1 if totalRecord < int(Ilimit) else (math.ceil(float(totalRecord/int(Ilimit)))) # round up to next number
    results = {"page": int(request.GET.get('page', '1')),"total": TotalPage ,"records": totalRecord,"rows": rows}
    return HttpResponse(json.dumps(results, indent=4,cls=DjangoJSONEncoder),content_type='application/json')
Exemplo n.º 13
0
def export_to_excels(request):
	#get qryset
	NAData = []
	#tentukan column
	colNames= ['idapp', 'NO','Territory', 'Goods Name', 'Type', 'Serial Number', 'Date Request', 'Date Released', 'Is New', 'fk_employee', 'For Employee','mobile',
		'fk_usedemployee', 'Eks Employee', 'fk_responsibleperson', 'Responsible By', 'fk_sender', 'Employee Sender', 'fk_stock', 'Ref Goods From', 'Equipment', 'Descriptions', 'Created Date', 'Created By']
	try:
		IcolumnName = request.GET.get('columnName')
		IvalueKey = request.GET.get('valueKey')
		IdataType = request.GET.get('dataType')
		Icriteria = request.GET.get('criteria')
		Ilimit = request.GET.get('rows', '')
		Isidx = request.GET.get('sidx', '')
		Isord = request.GET.get('sord', '')
		criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
		dataType = ResolveCriteria.getDataType(str(IdataType))
		if(Isord is not None and str(Isord) != '') or(Isidx is not None and str(Isidx) != ''):
			NAData = NAGoodsOutwards.objects.PopulateQuery(str(Isidx),Isord,Ilimit, request.GET.get('page', '1'),request.user.username if (request.user.username is not None and request.user.username != '') else 'Admin',IcolumnName,IvalueKey,criteria,dataType)#return tuples
		else:
			NAData = NAGoodsOutwards.objects.PopulateQuery('','DESC',Ilimit, request.GET.get('page', '1'),request.user.username if (request.user.username is not None and request.user.username != '') else 'Admin',IcolumnName,IvalueKey,criteria,dataType)#return tuples
		#totalRecord = NAData[1]
		dataRows = NAData[0]
		rows = []
		#column IDapp 	goods 	datereceived suppliername FK_ReceivedBy 	receivedby FK_P_R_By pr_by totalpurchase totalreceived,CreatedDate, CreatedBy
		i = 0
		for row in dataRows:
			i = i + 1
			datarow = tuple([row['idapp'], i,row['territory'], row['goods'], row['goodstype'], row['serialnumber'], datetime.strftime(row['daterequest'], "%m/%d/%Y"), datetime.strftime(row['datereleased'], "%m/%d/%Y"),
						row['isnew'],row['fk_employee'],row['for_employee'],row['mobile'],row['fk_usedemployee'],row['eks_employee'],row['fk_responsibleperson'],
				row['responsible_by'], row['fk_sender'], row['senderby'], row['fk_stock'], row['refgoodsfrom'], row['equipment_desc'], row['descriptions'], datetime.strftime(row['createddate'],"%m/%d/%Y"), row['createdby']])
			#datarow = {"id" :row.idapp, "cell" :[row.idapp,row.itemcode,row.goodsname,row.brandname,row.unit,row.priceperunit, \
			#	row.placement,row.depreciationmethod,row.economiclife,row.createddate,row.createdby]}
			rows.append(datarow)
		dataRows = list(dict(zip(colNames, row)) for row in rows)
		column_hidden = ['idapp', 'fk_employee', 'fk_usedemployee','fk_responsibleperson', 'fk_sender', 'fk_stock']
		response = commonFunct.create_excel(
			colNames, column_hidden, dataRows, 'Goods_Outwards_' + datetime.strftime(datetime.now(),"%Y_%m_%d"),'Goods_Outwards')
		return response
	except Exception as e:
		result = repr(e)
		return HttpResponse(json.dumps({'message':result}),status = 500, content_type='application/json')
Exemplo n.º 14
0
def NA_Goods_Receive_Search(request):
	try:
		IcolumnName = request.GET.get('columnName')
		IvalueKey =  request.GET.get('valueKey')
		IdataType =  request.GET.get('dataType')
		Icriteria =  request.GET.get('criteria')
		Ilimit = request.GET.get('rows', '')
		Isidx = request.GET.get('sidx', '')
		Isord = request.GET.get('sord', '')
		#if 'supplier' in Isidx:#ganti supplier key column jadi suppliername
		#	#IndexS = Isidx.index['supplier']
		#	#del(Isidx[IndexS])
		#	#Isindx.insert(IndexS,'suppliername')
		#	str(Isidx).replace('supplier','suppliername')
		NAData = []
		criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
		dataType = ResolveCriteria.getDataType(str(IdataType))
		if(Isord is not None and str(Isord) != '') or(Isidx is not None and str(Isidx) != ''):
			NAData = NAGoodsReceive.objects.PopulateQuery(str(Isidx),Isord,Ilimit, request.GET.get('page', '1'),IcolumnName,IvalueKey,criteria,dataType)#return tuples
		else:
			NAData = NAGoodsReceive.objects.PopulateQuery('','DESC',Ilimit, request.GET.get('page', '1'),IcolumnName,IvalueKey,criteria,dataType)#return tuples
		totalRecord = NAData[1]
		dataRows = NAData[0]

		rows = []
		#column IDapp 	goods 	datereceived suppliername FK_ReceivedBy 	receivedby FK_P_R_By pr_by totalpurchase totalreceived,CreatedDate, CreatedBy
		i = 0
		for row in dataRows:
			i = i+1
			datarow = {"id" :row['IDApp'], "cell" :[row['IDApp'],i,row['refno'],row['goods'],row['datereceived'],row['suppliername'],row['FK_ReceivedBy'],row['receivedby'],row['FK_P_R_By'], \
				row['pr_by'],row['totalpurchase'],row['totalreceived'],row['descriptions'],datetime.date(row['CreatedDate']),row['CreatedBy']]}
			#datarow = {"id" :row.idapp, "cell" :[row.idapp,row.itemcode,row.goodsname,row.brandname,row.unit,row.priceperunit, \
			#	row.placement,row.depreciationmethod,row.economiclife,row.createddate,row.createdby]}
			rows.append(datarow)
		TotalPage = 1 if totalRecord < int(Ilimit) else (math.ceil(float(totalRecord/int(Ilimit)))) # round up to next number
		results = {"page": int(request.GET.get('page', '1')),"total": TotalPage ,"records": totalRecord,"rows": rows }
		return HttpResponse(json.dumps(results, indent=4,cls=DjangoJSONEncoder),content_type='application/json')
	except Exception as e:
		result = repr(e)
		return HttpResponse(json.dumps({'message':result}),status = 500, content_type='application/json')
Exemplo n.º 15
0
def NA_GoodsLost_GetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    Ipage = request.GET.get('page')
    getColumn = commonFunct.retriveColumn(
        table=[NAGoodsLost, goods],
        resolve=IcolumnName,
        initial_name=['gls', 'g', 'empl1', 'empl2', 'empl3'],
        custom_fields=[['used_by'], ['lost_by'], ['resp_person']])
    criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
    dataType = ResolveCriteria.getDataType(str(IdataType))
    accData = NAGoodsLost.objects.PopulateQuery(IcolumnName, IvalueKey,
                                                criteria, dataType, Isidx,
                                                Isord)
    paginator = Paginator(accData, Ilimit)
    try:
        dataRows = paginator.page(Ipage)
    except EmptyPage:
        dataRows = paginator.page(paginator.num_pages)
    totalRecord = len(accData)
    rows = []
    i = 0
    for row in dataRows.object_list:
        i += 1
        datarow = {"id" :row['idapp'], "cell" :[row['idapp'],i,row['goods'],row['itemcode'],row['serialnumber'],row['fromgoods'],row['used_by'],\
            row['lost_by'],row['resp_person'],row['descriptions'],row['createddate'],row['createdby']]}
        rows.append(datarow)
    results = {
        "page": Ipage,
        "total": paginator.num_pages,
        "records": totalRecord,
        "rows": rows
    }
    return HttpResponse(json.dumps(results, indent=4, cls=DjangoJSONEncoder),
                        content_type='application/json')
Exemplo n.º 16
0
def export_to_excels(request):
	try:
		NAData = []
		IcolumnName = request.GET.get('columnName')
		IvalueKey = request.GET.get('valueKey')
		IdataType = request.GET.get('dataType')
		Icriteria = request.GET.get('criteria')
		Ilimit = request.GET.get('rows', '')
		Isidx = request.GET.get('sidx', '')
		Isord = request.GET.get('sord', '')
		criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
		dataType = ResolveCriteria.getDataType(str(IdataType))
		if(Isord is not None and str(Isord) != '') or(Isidx is not None and str(Isidx) != ''):
			NAData = NAGoodsLending.objects.PopulateQuery(str(Isidx),Isord,Ilimit, request.GET.get('page', '1'),request.user.username if (request.user.username is not None and request.user.username != '') else 'Admin',IcolumnName,IvalueKey,criteria,dataType)#return tuples
		else:
			NAData = NAGoodsLending.objects.PopulateQuery('','DESC',Ilimit, request.GET.get('page', '1'),request.user.username if (request.user.username is not None and request.user.username != '') else 'Admin',IcolumnName,IvalueKey,criteria,dataType)#return tuples
		dataRows = NAData[0]
		rows = []
		#column idapp,goods,goodstype,serialnumber,lentby,sentby,lentdate,interests,responsibleby,refgoodsfrom,isnew,status,descriptions,createdby,createddate
		colNames= ['idapp', 'NO','Territory', 'Goods Name', 'Type', 'Serial Number','Lent By', 'Lent Date', 'Return Date','Interest',
					'Responsible By', 'Ref Goods From', 'Isnew','Status Lent','Descriptions', 'Created Date', 'Created By']
		i = 0
		print(dataRows)
		for row in dataRows:
			i = i + 1
			datarow = tuple([row['idapp'],i,row['territory'],row['goods'],row['goodstype'],row['serialnumber'],row['lentby'],datetime.strftime(row['lentdate'], "%m/%d/%Y"),(datetime.strftime(row['datereturn'], "%m/%d/%Y")) if row['datereturn'] is not None else '',row['interests'],
						row['responsibleby'],row['refgoodsfrom'],row['isnew'],row['status'],row['descriptions'],datetime.strftime(row['createddate'],"%m/%d/%Y"),row['createdby']])
			#	row.placement,row.depreciationmethod,row.economiclife,row.createddate,row.createdby]}
			rows.append(datarow)
		dataRows = list(dict(zip(colNames, row)) for row in rows)
		column_hidden = ['idapp',]
		response = commonFunct.create_excel(
			colNames, column_hidden, dataRows, 'Goods_Lending_' + datetime.strftime(datetime.now(),"%Y_%m_%d"),'Goods_Lending')
		return response
	except Exception as e:
		result = repr(e)
		return HttpResponse(json.dumps({'message':result}),status = 500, content_type='application/json')
Exemplo n.º 17
0
def NA_MaintenanceGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    Ipage = request.GET.get('page')
    criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
    dataType = ResolveCriteria.getDataType(str(IdataType))
    NAData = []
    if (Isord is not None and str(Isord) != '') or (Isidx is not None
                                                    and str(Isidx) != ''):
        NAData = NAMaintenance.objects.PopulateQuery(
            str(Isidx), Isord, Ilimit, request.GET.get('page', '1'),
            request.user.username, IcolumnName, IvalueKey, criteria,
            dataType)  # return tuples
    else:
        NAData = NAMaintenance.objects.PopulateQuery(
            '', 'DESC', Ilimit, request.GET.get('page',
                                                '1'), request.user.username,
            IcolumnName, IvalueKey, criteria, dataType)  # return tuples
    totalRecord = NAData[1]
    dataRows = NAData[0]

    # totalRecords = len(maintenanceData)
    # paginator = Paginator(maintenanceData,Ilimit)
    # try:
    #     dataRows = paginator.page(Ipage)
    # except EmptyPage:
    #     dataRows = paginator.page(paginator.num_pages)
    # rows = []
    # i = 0
    if NAData == []:
        results = {"page": "1", "total": 0, "records": 0, "rows": []}
    else:
        totalRecord = NAData[1]
        dataRows = NAData[0]
    rows = []
    i = 0
    for row in dataRows:
        i += 1
        datarow = {
            "id":
            row['idapp'],
            "cell": [
                row['idapp'], i, row['goods'], row['itemcode'],
                row['serialnumber'], row['requestdate'], row['startdate'],
                row['isstillguarantee'], row['expense'], row['maintenanceby'],
                row['personalname'], row['enddate'], row['isfinished'],
                row['issucced'], row['descriptions'], row['createddate'],
                row['createdby']
            ]
        }
        rows.append(datarow)
    TotalPage = 1 if totalRecord < int(Ilimit) else (math.ceil(
        float(totalRecord / int(Ilimit))))  # round up to next number
    results = {
        "page": int(request.GET.get('page', '1')),
        "total": TotalPage,
        "records": totalRecord,
        "rows": rows
    }
    return HttpResponse(json.dumps(results, indent=4, cls=DjangoJSONEncoder),
                        content_type='application/json')
Exemplo n.º 18
0
def NA_AccGetData(request):
    IcolumnName = request.GET.get('columnName')
    IvalueKey = request.GET.get('valueKey')
    IdataType = request.GET.get('dataType')
    Icriteria = request.GET.get('criteria')
    Ilimit = request.GET.get('rows', '')
    Isidx = request.GET.get('sidx', '')
    Isord = request.GET.get('sord', '')
    Ipage = request.GET.get('page')
    getColumn = commonFunct.retriveColumn(
        table=[NAAccFa, goods], resolve=IcolumnName, initial_name=['ac', 'g'])
    criteria = ResolveCriteria.getCriteriaSearch(str(Icriteria))
    dataType = ResolveCriteria.getDataType(str(IdataType))
    is_parent = request.GET.get('is_parent')
    serial_number = request.GET.get('serialnumber')
    accData = NAAccFa.objects.PopulateQuery(
        columnKey=getColumn,
        is_parent=int(is_parent),
        serialnumber=serial_number,
        ValueKey=IvalueKey,
        criteria=criteria,
        typeofData=dataType,
        sidx=Isidx,
        sord=Isord
    )
    paginator = Paginator(accData, Ilimit)
    try:
        dataRows = paginator.page(Ipage)
    except EmptyPage:
        dataRows = paginator.page(paginator.num_pages)
    totalRecord = len(accData)
    rows = []
    i = 0
    if commonFunct.str2bool(is_parent):
        for row in dataRows.object_list:
            i += 1
            datarow = {
                "id": row['idapp'],
                "cell": [
                    row['idapp'], i, row['itemcode'], row['goods'], row['typeapp'], row['serialnumber'],
                    row['startdate'], row['year'], row['createddate'], row['createdby']
                ]
            }
            rows.append(datarow)
    else:
        for row in dataRows.object_list:
            i += 1
            datarow = {
                "id": row['idapp'],
                "cell": [
                    row['idapp'], i, row['itemcode'], row['goods'], row['typeapp'],
                    row['serialnumber'],
                    row['startdate'], row['datedepreciation'],
                    row['depreciationmethod'], row['depr_expense'],
                    row['depr_accumulation'], row['bookvalue'], row['createddate'],
                    row['createdby']
                ]
            }
            rows.append(datarow)
    results = {"page": dataRows.number, "total": paginator.num_pages,
               "records": totalRecord, "rows": rows}
    return HttpResponse(
        json.dumps(results, indent=4, cls=DjangoJSONEncoder),
        content_type='application/json'
    )