Esempio n. 1
0
def show_main_page(request):
    employeeDAO = EmployeeDAO()
    customerDAO = CustomerDAO()
    supplierDAO = SupplierDAO()
    saleDAO = SaleDAO()

    employeeList = employeeDAO.get_all()
    customerList = customerDAO.get_all()
    supplierList = supplierDAO.get_all()
    saleList = saleDAO.get_all()

    now = datetime.datetime.now()
    delta = datetime.timedelta(weeks=-4)
    last_month = now + delta
    last_month = last_month.strftime("%Y-%m-%d")
    today = now.strftime("%Y-%m-%d")

    return render_to_response(
        "main.html",
        {
            "employeeList": employeeList,
            "customerList": customerList,
            "supplierList": supplierList,
            "saleList": saleList,
            "last_month": last_month,
            "today": today,
        },
        RequestContext(request),
    )
Esempio n. 2
0
	def __init__(self, *args, **kwargs):
		super(SaleForm, self).__init__(*args,**kwargs)
		self.fields['id'] = forms.CharField(initial=uuid.uuid4(), widget=forms.HiddenInput())
		employeeDAO = EmployeeDAO()
		employees = employeeDAO.get_all()
		employee_list = []
		for employee in employees:
			tmp = []
			tmp.append(employee.name)
			tmp.append(employee.name)
			employee_list.append(tmp)
		self.fields['employee'] = forms.ChoiceField(choices=employee_list)
		self.fields['employee'].label = _("sale.employee") 


		supplierDAO = SupplierDAO()
		suppliers = supplierDAO.get_all()
		supplier_list = []
		for supplier in suppliers:
			tmp = []
			tmp.append(supplier.name)
			tmp.append(supplier.name)
			supplier_list.append(tmp)

		self.fields['supplier'] = forms.ChoiceField(choices=supplier_list)
		self.fields['supplier'].label = _("sale.supplier") 

		customerDAO = CustomerDAO()
		customers = customerDAO.get_all()
		customer_list = []
		for customer in customers:
			tmp = []
			tmp.append(customer.name)
			tmp.append(customer.name)
			customer_list.append(tmp)

		self.fields['customer'] = forms.ChoiceField(choices=supplier_list)
		self.fields['customer'].label = _("sale.customer") 

		not_settled = _('sale.status.not_settled')
		settled = _('sale.status.settled')
		status_list = [['0',not_settled],['1',settled]]
		self.fields['status'] = forms.ChoiceField(choices=status_list)
		self.fields['status'].label = _("sale.status")